[Fix] Harden MTP codec, transport, and SDK security
This commit is contained in:
parent
188caf56cc
commit
a7e804c603
73 changed files with 11892 additions and 5756 deletions
26
src/sdk/credentials.ts
Normal file
26
src/sdk/credentials.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import type { MTPClientCredentials } from "./index.js";
|
||||
|
||||
export type InternalCredentials = {
|
||||
clientId: bigint | null;
|
||||
keyring: Uint8Array;
|
||||
hostPublicKey?: Uint8Array;
|
||||
};
|
||||
|
||||
export function publicCredentials(
|
||||
credentials: InternalCredentials | null,
|
||||
): MTPClientCredentials | null {
|
||||
if (!credentials) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
clientId: credentials.clientId,
|
||||
keyring: credentials.keyring.slice(),
|
||||
hostPublicKey: credentials.hostPublicKey?.slice(),
|
||||
};
|
||||
}
|
||||
|
||||
export function zeroCredentials(credentials: InternalCredentials | null): void {
|
||||
// The host public key is intentionally not wiped: it is public configuration
|
||||
// and may also be retained by the connection options.
|
||||
credentials?.keyring.fill(0);
|
||||
}
|
||||
Loading…
Reference in a new issue