@interncom/diplomatic 0.20.0 → 0.21.1

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.
@@ -6,6 +6,11 @@ type OpenDiplomaticClientBase = {
6
6
  clock?: IClock;
7
7
  /** Max wait for setSeed → Enclave.spawnSyncWorker handshake (default 15s). */
8
8
  readyTimeoutMs?: number;
9
+ /**
10
+ * Timed `[dip]` traces for local writes, EntDB, and watchers (default false).
11
+ * Process-wide; same flag as {@link openEntDB}.
12
+ */
13
+ verbose?: boolean;
9
14
  /**
10
15
  * Debounce local write → worker sync (default `defaultSyncDebounceMs`).
11
16
  * Use `0` in tests for an immediate upload-queue handoff.
@@ -17,6 +17,11 @@ type UseClientBase = {
17
17
  * Set false to notify only after durable commit.
18
18
  */
19
19
  optimistic?: boolean;
20
+ /**
21
+ * Timed `[dip]` traces (default false). See {@link openEntDB} /
22
+ * {@link openDiplomaticClient}.
23
+ */
24
+ verbose?: boolean;
20
25
  };
21
26
  /**
22
27
  * Worker path: IndexedDB on main; sync Worker appears on setSeed via Enclave.
@@ -60,6 +60,7 @@ export type Identity = {
60
60
  kdmFor: (msgHeadEnc: Uint8Array) => Promise<Uint8Array>;
61
61
  };
62
62
  declare const SEAL_BIND_DOMAIN: Uint8Array<ArrayBufferLike>;
63
+ declare const FP_MODE: Uint8Array<ArrayBufferLike>;
63
64
  declare const SEAL_KEY_LEN = 32;
64
65
  declare const SEAL_PRF_MIN_LEN = 16;
65
66
  /** Minimum musec length (Mandatory User-Space Entropy Contribution). */
@@ -142,6 +143,12 @@ export declare class Enclave {
142
143
  }>>;
143
144
  /** UV + overwrite largeBlob with zeros (destroys stored seed material). */
144
145
  static clearLargeBlob(credId: Uint8Array, opts?: LargeBlobRp): Promise<Status>;
146
+ /**
147
+ * Write numbered `n] xxxx xxxx` hex lines plus a # check to /dev/tty.
148
+ * Paced mode erases the previous line before the next (Enter between).
149
+ * Web bundles set DIP_CLI_DUMP=false; the write is compiled out.
150
+ */
151
+ dumpToTty(): Promise<Status>;
145
152
  /**
146
153
  * Absorb seed‖hosts plaintext (pair AEAD inner).
147
154
  * Encoder/Decoder never see the seed.
@@ -178,4 +185,4 @@ export declare class Enclave {
178
185
  }
179
186
  /** Derive seal key from PRF output (domain-separated). Used by enclave seal/unseal. */
180
187
  export declare function sealKeyFromPrf(crypto: ICrypto, prf: Uint8Array, domain?: Uint8Array): Promise<ValStat<Uint8Array>>;
181
- export { MASTER_SEED_LEN, MUSEC_MIN_LEN, SEAL_BIND_DOMAIN, SEAL_KEY_LEN, SEAL_PRF_MIN_LEN, };
188
+ export { FP_MODE, MASTER_SEED_LEN, MUSEC_MIN_LEN, SEAL_BIND_DOMAIN, SEAL_KEY_LEN, SEAL_PRF_MIN_LEN, };
@@ -1,5 +1,5 @@
1
1
  import { type X25519Sk } from "./x25519.ts";
2
- import type { DerivationSeed, Hash, ICrypto, KeyPair } from "../types.ts";
2
+ import type { Blake3Opts, DerivationSeed, Hash, ICrypto, KeyPair } from "../types.ts";
3
3
  /**
4
4
  * ICrypto: noble for XSalsa20 + blake3; WebCrypto Ed25519 + X25519
5
5
  * (our scalar; RFC 7748 check before trusting pub/DH).
@@ -15,7 +15,7 @@ export declare class NobleCrypto implements ICrypto {
15
15
  private importVerifyKey;
16
16
  signEd25519(message: Uint8Array | string, secKey: Uint8Array): Promise<Uint8Array>;
17
17
  checkSigEd25519(sig: Uint8Array, message: Uint8Array | string, pubKey: Uint8Array): Promise<boolean>;
18
- blake3(data: Uint8Array): Promise<Hash>;
18
+ blake3(data: Uint8Array, opts?: Blake3Opts): Promise<Hash>;
19
19
  genX25519(): Promise<{
20
20
  priv: X25519Sk;
21
21
  pub: Uint8Array;
@@ -125,6 +125,13 @@ export type Hash = Uint8Array & {
125
125
  export interface IHostCrypto {
126
126
  checkSigEd25519: (sig: Uint8Array, message: Uint8Array | string, pubKey: PublicKey) => Promise<boolean>;
127
127
  }
128
+ /** BLAKE3 hash / MAC / KDF (noble: `key` XOR `context`, not both). */
129
+ export type Blake3Opts = {
130
+ /** 32-byte MAC key. */
131
+ key?: Uint8Array;
132
+ /** KDF context (hardcoded, app-specific). */
133
+ context?: Uint8Array | string;
134
+ };
128
135
  export interface ICrypto extends IHostCrypto {
129
136
  genRandomBytes: (bytes: number) => Promise<Uint8Array>;
130
137
  gen256BitSecureRandomSeed: () => Promise<Uint8Array>;
@@ -132,7 +139,7 @@ export interface ICrypto extends IHostCrypto {
132
139
  decryptXSalsa20Poly1305Combined: (headerAndCipher: Uint8Array, key: Uint8Array) => Promise<Uint8Array>;
133
140
  deriveEd25519KeyPair: (derivationSeed: DerivationSeed) => Promise<KeyPair>;
134
141
  signEd25519: (message: Uint8Array | string, secKey: PrivateKey) => Promise<Uint8Array>;
135
- blake3: (data: Uint8Array) => Promise<Hash>;
142
+ blake3: (data: Uint8Array, opts?: Blake3Opts) => Promise<Hash>;
136
143
  }
137
144
  export interface IMsgpackCodec {
138
145
  encode: (source: unknown) => Uint8Array;
@@ -295,7 +295,7 @@ export interface IStateEmitter<T> {
295
295
  export interface IClient<Handle extends HostHandle> {
296
296
  /** Install session enclave (master seed stays inside enclave). */
297
297
  setSeed(enclave: Enclave, opts?: SetSeedOpts): Promise<void>;
298
- link(host: IHostConnectionInfo<Handle>): Promise<void>;
298
+ link(host: IHostConnectionInfo<Handle>, connect?: boolean): Promise<void>;
299
299
  unlink(label: string): Promise<void>;
300
300
  /** Linked hosts from the protocol store (handle, label, lastSeq, …). */
301
301
  hosts(): Promise<IHostRow<Handle>[]>;
@@ -0,0 +1,4 @@
1
+ /** Turn `[dip]` timings on or off. */
2
+ export declare function setVerbose(v: boolean): void;
3
+ /** Timed `[dip]` line when verbose. */
4
+ export declare function dipLog(msg: string, extra?: object): void;