@interncom/diplomatic 0.12.2 → 0.12.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,6 +29,11 @@ export declare class Encoder {
29
29
  writeVarInt(n: number): Status;
30
30
  writeVarString(s: string): Status;
31
31
  prependBytes(bytes: Uint8Array): void;
32
+ /**
33
+ * Append a copy of `bytes`. Parts must not alias caller buffers — callers
34
+ * often zero sensitive material after encode (seed, PRF, etc.); holding a
35
+ * live reference would corrupt the eventual {@link result}.
36
+ */
32
37
  writeBytes(bytes: Uint8Array): void;
33
38
  writeVarBytes(bytes: Uint8Array): Status;
34
39
  writeStruct<T>(codec: ICodecStruct<T>, str: T): Status;
@@ -24,8 +24,15 @@ export type WebAuthnRp = {
24
24
  * Normalizes case and trailing dots. Empty → `"localhost"`.
25
25
  */
26
26
  export declare function defaultWebAuthnRpId(hostname: string): string;
27
- /** Copy into a fresh ArrayBuffer-backed view (DOM BufferSource typing). */
28
- export declare function copyToArrayBuffer(src: Uint8Array): Uint8Array;
27
+ /**
28
+ * Fresh standalone {@link ArrayBuffer} copy of `src`.
29
+ * Safari (and some Chromium paths) are picky about BufferSource for
30
+ * largeBlob write / allowCredentials id — pass a real ArrayBuffer, not a
31
+ * view into a larger pooled buffer.
32
+ */
33
+ export declare function copyToArrayBuffer(src: Uint8Array): ArrayBuffer;
34
+ /** Copy WebAuthn blob / BufferSource into an owned Uint8Array. */
35
+ export declare function bufferSourceToUint8(src: BufferSource): Uint8Array;
29
36
  /** Resolve RP id from opts or `location.hostname`. */
30
37
  export declare function resolveWebAuthnRpId(opts?: WebAuthnRp): ValStat<string>;
31
38
  /** Success if WebAuthn credentials API is available in this environment. */
@@ -10,6 +10,8 @@ export declare class IDBSeedStore implements ISeedStore {
10
10
  /**
11
11
  * Hold enclave in memory only. Durable identity is sealed meta
12
12
  * ({@link openPrfStore} / {@link persistPrfMeta}), never plain seed.
13
+ * Pins identity (nonce+hash) on first save; later saves must match
14
+ * (largeBlob / hex / PRF unlock cannot switch masters under this DB).
13
15
  * `opts.persist` is ignored (kept for API compatibility).
14
16
  *
15
17
  * TODO(passphrase): when PRF is missing, `persist: true` (or a dedicated
@@ -20,7 +22,7 @@ export declare class IDBSeedStore implements ISeedStore {
20
22
  load(): Promise<Enclave | undefined>;
21
23
  /**
22
24
  * Drop in-memory enclave and any leftover legacy hex. Keeps {@link K_PRF_META}
23
- * so daily unlock via PRF still works after a soft lock.
25
+ * and {@link K_ID_PIN} so unlock / largeBlob restore still match this device.
24
26
  */
25
27
  clearSession(): Promise<void>;
26
28
  wipe(): Promise<void>;
@@ -0,0 +1,19 @@
1
+ import type { Enclave } from "../shared/crypto/enclave";
2
+ import type { ICrypto } from "../shared/types";
3
+ /**
4
+ * Prefix so pin paths never collide with user host labels ("host", …).
5
+ * Full path: `diplomatic.pin/<hex(nonce)>`.
6
+ */
7
+ export declare const ID_PIN_PATH_PREFIX = "diplomatic.pin/";
8
+ /** Durable pin row: path-nonce + digest of path-scoped public key. */
9
+ export type IdPin = {
10
+ n: Uint8Array;
11
+ h: Uint8Array;
12
+ };
13
+ /** keyPath for deriveIdentity from the stored nonce. */
14
+ export declare function idPinPath(nonce: Uint8Array): string;
15
+ export declare function idPinDigest(crypto: ICrypto, enclave: Enclave, nonce: Uint8Array): Promise<Uint8Array>;
16
+ export declare function makeIdPin(crypto: ICrypto, enclave: Enclave): Promise<IdPin>;
17
+ export declare function idPinMatches(crypto: ICrypto, enclave: Enclave, pin: IdPin): Promise<boolean>;
18
+ export declare function decodeIdPin(raw: unknown): IdPin | undefined;
19
+ export declare function cloneIdPin(pin: IdPin): IdPin;
@@ -1,8 +1,14 @@
1
1
  import type { Enclave } from "../../shared/crypto/enclave";
2
+ import type { ICrypto } from "../../shared/types";
2
3
  import type { ISeedStore, SetSeedOpts } from "../../types";
4
+ import { type IdPin } from "../identityPin";
3
5
  export declare class MemorySeedStore implements ISeedStore {
6
+ #private;
4
7
  enclave?: Enclave;
8
+ constructor(crypto: ICrypto);
5
9
  save(enclave: Enclave, _opts?: SetSeedOpts): Promise<Enclave>;
6
10
  load(): Promise<Enclave | undefined>;
7
11
  wipe(): Promise<void>;
12
+ /** Test helper: snapshot of durable pin (nonce+hash only). */
13
+ peekPin(): IdPin | undefined;
8
14
  }