@interncom/diplomatic 0.17.0 → 0.18.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.
@@ -62,13 +62,18 @@ export type Identity = {
62
62
  declare const SEAL_BIND_DOMAIN: Uint8Array<ArrayBufferLike>;
63
63
  declare const SEAL_KEY_LEN = 32;
64
64
  declare const SEAL_PRF_MIN_LEN = 16;
65
+ /** Minimum musec length (Mandatory User-Space Entropy Contribution). */
66
+ declare const MUSEC_MIN_LEN = 32;
65
67
  /** Brand `bytes` as {@link MasterSeed} only if length is {@link MASTER_SEED_LEN}. */
66
68
  export declare function asMasterSeed(bytes: Uint8Array): ValStat<MasterSeed>;
67
69
  export declare class Enclave {
68
70
  #private;
69
71
  private constructor();
70
- /** New enclave with a fresh 32-byte master seed. */
71
- static fromRandom(): Promise<Enclave>;
72
+ /**
73
+ * New enclave: blake3(OS CSPRNG ‖ musec). musec is required (MUSEC_MIN_LEN).
74
+ * Mix stays in this method; musec is wiped before return.
75
+ */
76
+ static fromRandom(musec: Uint8Array): Promise<ValStat<Enclave>>;
72
77
  /**
73
78
  * Construct from raw master seed bytes (import / bootstrap only).
74
79
  * Copies the seed so callers may zero their buffer after success.
@@ -99,6 +104,16 @@ export declare class Enclave {
99
104
  enclave: Enclave;
100
105
  credId: Uint8Array;
101
106
  }>>;
107
+ /**
108
+ * AEAD-seal master under caller-supplied PRF IKM (CLI hmac-secret).
109
+ * Wipes `ikm` before return. Ciphertext only — never the seed.
110
+ */
111
+ sealWithIkm(ikm: Uint8Array): Promise<ValStat<SealedMasterKey>>;
112
+ /**
113
+ * Unseal a PRF binding given IKM (CLI hmac-secret eval). Returns Enclave.
114
+ * Wipes `ikm` before return.
115
+ */
116
+ static unsealWithIkm(sealed: SealedMasterKey, ikm: Uint8Array): Promise<ValStat<Enclave>>;
102
117
  /**
103
118
  * UV + write IdentityBundle (seed + hosts) to largeBlob.
104
119
  * Encode and WebAuthn write complete inside this method; nothing seed-bearing
@@ -163,4 +178,4 @@ export declare class Enclave {
163
178
  }
164
179
  /** Derive seal key from PRF output (domain-separated). Used by enclave seal/unseal. */
165
180
  export declare function sealKeyFromPrf(crypto: ICrypto, prf: Uint8Array, domain?: Uint8Array): Promise<ValStat<Uint8Array>>;
166
- export { MASTER_SEED_LEN, SEAL_BIND_DOMAIN, SEAL_KEY_LEN, SEAL_PRF_MIN_LEN };
181
+ export { MASTER_SEED_LEN, MUSEC_MIN_LEN, SEAL_BIND_DOMAIN, SEAL_KEY_LEN, SEAL_PRF_MIN_LEN, };
@@ -1,12 +1,21 @@
1
1
  import { Enclave } from "./crypto/enclave.ts";
2
2
  import { ICrypto, IMessageHead } from "./types.ts";
3
3
  import { ValStat } from "./valstat.ts";
4
- export declare const defaultFileExtension = "dpl";
5
- export declare function encodeFile(keyLbl: string, keyIdx: number, msgs: Iterable<{
6
- head: IMessageHead;
7
- body?: Uint8Array;
8
- }>, crypto: ICrypto, enclave: Enclave): Promise<ValStat<Uint8Array>>;
9
- export declare function decodeFile(file: Uint8Array, crypto: ICrypto, enclave: Enclave): Promise<ValStat<{
10
- head: IMessageHead;
11
- body?: Uint8Array;
12
- }[]>>;
4
+ export declare namespace Exim {
5
+ const defaultFileExtension = "dpl";
6
+ function encodeFile(keyLbl: string, keyIdx: number, msgs: Iterable<{
7
+ head: IMessageHead;
8
+ body?: Uint8Array;
9
+ }>, crypto: ICrypto, enclave: Enclave): Promise<ValStat<Uint8Array>>;
10
+ function decodeFile(file: Uint8Array, crypto: ICrypto, enclave: Enclave): Promise<ValStat<{
11
+ head: IMessageHead;
12
+ body?: Uint8Array;
13
+ }[]>>;
14
+ function migrateFile(file: Uint8Array, crypto: ICrypto, enclaveIn: Enclave, enclaveOut: Enclave, transform: (msgs: Iterable<{
15
+ head: IMessageHead;
16
+ body?: Uint8Array;
17
+ }>) => Iterable<{
18
+ head: IMessageHead;
19
+ body?: Uint8Array;
20
+ }>): Promise<ValStat<Uint8Array>>;
21
+ }
@@ -1,8 +1,9 @@
1
1
  import { type AuthenticatorAttachmentName, type WebAuthnRp } from "./common.ts";
2
- export type PrfRp = WebAuthnRp;
3
- export type PrfCreateOpts = PrfRp & {
4
- /** WebAuthn user.name — stable account id. */
2
+ export type PrfRp = WebAuthnRp & {
3
+ /** WebAuthn user.name — stable account id shown on the binding key. */
5
4
  userName?: string;
5
+ };
6
+ export type PrfCreateOpts = PrfRp & {
6
7
  /** WebAuthn user.displayName — human nick. */
7
8
  displayName?: string;
8
9
  /** Omit so the UA can offer roaming keys (YubiKey) and third-party providers. */
@@ -14,7 +15,7 @@ export type PrfCreateOpts = PrfRp & {
14
15
  };
15
16
  /** Default salt for DIPLOMATIC PRF eval (UTF-8). */
16
17
  export declare const DEFAULT_PRF_SALT: Uint8Array<ArrayBufferLike>;
17
- /** Default WebAuthn user.name / displayName when none is supplied. */
18
+ /** Last-resort WebAuthn user.name when the app omits userName, rpId, and rpName. */
18
19
  export declare const DEFAULT_PRF_USER_NAME = "diplomatic-prf";
19
20
  /** Public ceremony facts (no PRF bytes). */
20
21
  export type PrfCeremony = {