@interncom/diplomatic 0.19.2 → 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.
- package/dist/cli/index.mjs +2 -2
- package/dist/cli/shared/codecs/messageHead.d.ts +2 -8
- package/dist/cli/shared/crypto/enclave.d.ts +8 -1
- package/dist/cli/shared/crypto/noble.d.ts +2 -2
- package/dist/cli/shared/message.d.ts +8 -5
- package/dist/cli/shared/types.d.ts +13 -3
- package/dist/web/client.d.ts +16 -15
- package/dist/web/entdb/cached.d.ts +19 -2
- package/dist/web/entdb/entdb.d.ts +1 -0
- package/dist/web/entdb/manager.d.ts +3 -3
- package/dist/web/index.mjs +1 -1
- package/dist/web/openClient.d.ts +5 -0
- package/dist/web/react/useClient.d.ts +5 -0
- package/dist/web/shared/codecs/messageHead.d.ts +2 -8
- package/dist/web/shared/crypto/enclave.d.ts +8 -1
- package/dist/web/shared/crypto/noble.d.ts +2 -2
- package/dist/web/shared/exim.d.ts +4 -1
- package/dist/web/shared/message.d.ts +8 -5
- package/dist/web/shared/types.d.ts +13 -3
- package/dist/web/types.d.ts +6 -4
- package/dist/web/verbose.d.ts +4 -0
- package/dist/web/worker/client.d.ts +2 -2
- package/dist/web/worker.mjs +1 -1
- package/package.json +2 -1
package/dist/web/openClient.d.ts
CHANGED
|
@@ -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.
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { ICodecStruct } from "../codec.ts";
|
|
2
|
-
import { EntityID } from "../types.ts";
|
|
3
|
-
export
|
|
4
|
-
eid: EntityID;
|
|
5
|
-
off: number;
|
|
6
|
-
ctr: number;
|
|
7
|
-
len: number;
|
|
8
|
-
hsh?: Uint8Array;
|
|
9
|
-
}
|
|
2
|
+
import { EntityID, IMessageHead } from "../types.ts";
|
|
3
|
+
export type { IMessageHead };
|
|
10
4
|
export declare const messageHeadCodec: ICodecStruct<IMessageHead>;
|
|
11
5
|
export interface IMinimalMessageHead {
|
|
12
6
|
eid: EntityID;
|
|
@@ -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;
|
|
@@ -5,18 +5,21 @@ interface IInsertParams {
|
|
|
5
5
|
now: Date;
|
|
6
6
|
bod: SerializedContent;
|
|
7
7
|
crypto: ICrypto;
|
|
8
|
+
typ?: string;
|
|
8
9
|
}
|
|
9
|
-
export declare function genInsertHead({ now, bod, crypto }: IInsertParams): Promise<ValStat<IMessageHead>>;
|
|
10
|
-
interface IUpsertParams extends Omit<IMessage, "off" | "len" | "hsh"> {
|
|
10
|
+
export declare function genInsertHead({ now, bod, crypto, typ }: IInsertParams): Promise<ValStat<IMessageHead>>;
|
|
11
|
+
interface IUpsertParams extends Omit<IMessage, "off" | "len" | "hsh" | "typ"> {
|
|
11
12
|
now: Date;
|
|
12
13
|
crypto: ICrypto;
|
|
14
|
+
typ?: string;
|
|
13
15
|
}
|
|
14
|
-
export declare function genUpsertHead({ now, eid, ctr, bod, crypto }: IUpsertParams): Promise<ValStat<IMessageHead>>;
|
|
15
|
-
interface IDeleteParams extends Omit<IMessage, "off" | "len" | "hsh" | "bod"> {
|
|
16
|
+
export declare function genUpsertHead({ now, eid, ctr, typ, bod, crypto }: IUpsertParams): Promise<ValStat<IMessageHead>>;
|
|
17
|
+
interface IDeleteParams extends Omit<IMessage, "off" | "len" | "hsh" | "bod" | "typ"> {
|
|
16
18
|
now: Date;
|
|
17
19
|
crypto: ICrypto;
|
|
20
|
+
typ?: string;
|
|
18
21
|
}
|
|
19
|
-
export declare function genDeleteHead({ now, eid, ctr, crypto }: IDeleteParams): Promise<ValStat<IMessageHead>>;
|
|
22
|
+
export declare function genDeleteHead({ now, eid, ctr, typ, crypto }: IDeleteParams): Promise<ValStat<IMessageHead>>;
|
|
20
23
|
export declare function genInsert({ now, bod, crypto }: IInsertParams): Promise<ValStat<IUpsertMessage>>;
|
|
21
24
|
export declare function genDelete(params: IDeleteParams): Promise<ValStat<IDeleteMessage>>;
|
|
22
25
|
export {};
|
|
@@ -21,10 +21,10 @@ export interface IMsgEntBody<T = unknown> {
|
|
|
21
21
|
* dropped on apply. Omit or [] means no tags.
|
|
22
22
|
*/
|
|
23
23
|
tags?: string[];
|
|
24
|
-
type: string;
|
|
25
24
|
body?: T;
|
|
26
25
|
}
|
|
27
26
|
export interface IMessageHead {
|
|
27
|
+
typ?: string;
|
|
28
28
|
eid: EntityID;
|
|
29
29
|
off: number;
|
|
30
30
|
ctr: number;
|
|
@@ -37,15 +37,17 @@ export interface IMessage extends IMessageHead {
|
|
|
37
37
|
export interface IMessageWithHash extends IMessage {
|
|
38
38
|
headHash: Hash;
|
|
39
39
|
}
|
|
40
|
-
export interface IDeleteOp extends Omit<IMessageHead, "len" | "hsh" | "bod"> {
|
|
40
|
+
export interface IDeleteOp extends Omit<IMessageHead, "len" | "hsh" | "bod" | "typ"> {
|
|
41
41
|
}
|
|
42
42
|
export interface IMutateOp<T = unknown> extends IDeleteOp, Omit<IMsgEntBody<T>, "body"> {
|
|
43
|
+
type: string;
|
|
43
44
|
body: T;
|
|
44
45
|
}
|
|
45
46
|
export type IOp = IDeleteOp | IMutateOp;
|
|
46
47
|
export declare function isDeleteOp(op: IOp): op is IDeleteOp;
|
|
47
48
|
export declare function isMutateOp(op: IOp): op is IMutateOp;
|
|
48
49
|
export interface IInsertParams<T> extends IMsgEntBody<T> {
|
|
50
|
+
type: string;
|
|
49
51
|
/** Optional 8-byte id material for the new eid; else random. */
|
|
50
52
|
id?: Uint8Array;
|
|
51
53
|
}
|
|
@@ -60,6 +62,7 @@ export interface IEntRev {
|
|
|
60
62
|
updatedAt: Date;
|
|
61
63
|
}
|
|
62
64
|
export interface IUpdateParams<T> extends IMsgEntBody<T> {
|
|
65
|
+
type: string;
|
|
63
66
|
prior: IEntRev;
|
|
64
67
|
/** Clock-skew recovery; default client-wide (usually true). */
|
|
65
68
|
force?: boolean;
|
|
@@ -122,6 +125,13 @@ export type Hash = Uint8Array & {
|
|
|
122
125
|
export interface IHostCrypto {
|
|
123
126
|
checkSigEd25519: (sig: Uint8Array, message: Uint8Array | string, pubKey: PublicKey) => Promise<boolean>;
|
|
124
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
|
+
};
|
|
125
135
|
export interface ICrypto extends IHostCrypto {
|
|
126
136
|
genRandomBytes: (bytes: number) => Promise<Uint8Array>;
|
|
127
137
|
gen256BitSecureRandomSeed: () => Promise<Uint8Array>;
|
|
@@ -129,7 +139,7 @@ export interface ICrypto extends IHostCrypto {
|
|
|
129
139
|
decryptXSalsa20Poly1305Combined: (headerAndCipher: Uint8Array, key: Uint8Array) => Promise<Uint8Array>;
|
|
130
140
|
deriveEd25519KeyPair: (derivationSeed: DerivationSeed) => Promise<KeyPair>;
|
|
131
141
|
signEd25519: (message: Uint8Array | string, secKey: PrivateKey) => Promise<Uint8Array>;
|
|
132
|
-
blake3: (data: Uint8Array) => Promise<Hash>;
|
|
142
|
+
blake3: (data: Uint8Array, opts?: Blake3Opts) => Promise<Hash>;
|
|
133
143
|
}
|
|
134
144
|
export interface IMsgpackCodec {
|
|
135
145
|
encode: (source: unknown) => Uint8Array;
|
package/dist/web/types.d.ts
CHANGED
|
@@ -177,6 +177,8 @@ export interface IStoredMessageFields {
|
|
|
177
177
|
eid: EntityID;
|
|
178
178
|
off?: number;
|
|
179
179
|
ctr?: number;
|
|
180
|
+
/** Msg head typ. Omit when empty (raw). */
|
|
181
|
+
typ?: string;
|
|
180
182
|
body?: EncodedMessage;
|
|
181
183
|
}
|
|
182
184
|
/**
|
|
@@ -192,7 +194,7 @@ export interface IStoredMessageData extends IStoredMessageFields {
|
|
|
192
194
|
/**
|
|
193
195
|
* Required shape for every put into the message archive (app/API layer).
|
|
194
196
|
* `apld` is required and must be one of the three {@link ApldState} values.
|
|
195
|
-
* Omit optional fields (`off`, `ctr`, `body`, `err`) rather than storing empties.
|
|
197
|
+
* Omit optional fields (`off`, `ctr`, `typ`, `body`, `err`) rather than storing empties.
|
|
196
198
|
*/
|
|
197
199
|
export type IStoredMessageWrite = IStoredMessageFields & {
|
|
198
200
|
apld: ApldState;
|
|
@@ -293,14 +295,14 @@ export interface IStateEmitter<T> {
|
|
|
293
295
|
export interface IClient<Handle extends HostHandle> {
|
|
294
296
|
/** Install session enclave (master seed stays inside enclave). */
|
|
295
297
|
setSeed(enclave: Enclave, opts?: SetSeedOpts): Promise<void>;
|
|
296
|
-
link(host: IHostConnectionInfo<Handle
|
|
298
|
+
link(host: IHostConnectionInfo<Handle>, connect?: boolean): Promise<void>;
|
|
297
299
|
unlink(label: string): Promise<void>;
|
|
298
300
|
/** Linked hosts from the protocol store (handle, label, lastSeq, …). */
|
|
299
301
|
hosts(): Promise<IHostRow<Handle>[]>;
|
|
300
302
|
connect(): Promise<void>;
|
|
301
303
|
disconnect(): Promise<void>;
|
|
302
|
-
insertRaw(content: SerializedContent): Promise<ValStat<IMessageHead>>;
|
|
303
|
-
updateRaw(prior: IEntRev, content: SerializedContent | undefined, force?: boolean): Promise<ValStat<IMessageHead>>;
|
|
304
|
+
insertRaw(content: SerializedContent, typ?: string): Promise<ValStat<IMessageHead>>;
|
|
305
|
+
updateRaw(prior: IEntRev, content: SerializedContent | undefined, force?: boolean, typ?: string): Promise<ValStat<IMessageHead>>;
|
|
304
306
|
insert<T = unknown>(op: IInsertParams<T>): Promise<ValStat<IMessageHead>>;
|
|
305
307
|
update<T = unknown>(op: IUpdateParams<T>): Promise<ValStat<IMessageHead>>;
|
|
306
308
|
/**
|
|
@@ -86,8 +86,8 @@ export declare class WorkerClient implements IClient<URL> {
|
|
|
86
86
|
connect(listen?: boolean, sync?: boolean): Promise<void>;
|
|
87
87
|
disconnect(): Promise<void>;
|
|
88
88
|
/** Local UI write on main (cache notifies in apply's sync prefix); sync via worker. */
|
|
89
|
-
insertRaw(content: SerializedContent): Promise<ValStat<IMessageHead>>;
|
|
90
|
-
updateRaw(prior: IEntRev, content: SerializedContent | undefined, force?: boolean): Promise<ValStat<IMessageHead>>;
|
|
89
|
+
insertRaw(content: SerializedContent, typ?: string): Promise<ValStat<IMessageHead>>;
|
|
90
|
+
updateRaw(prior: IEntRev, content: SerializedContent | undefined, force?: boolean, typ?: string): Promise<ValStat<IMessageHead>>;
|
|
91
91
|
insert<T = unknown>(op: IInsertParams<T>): Promise<ValStat<IMessageHead>>;
|
|
92
92
|
update<T = unknown>(op: IUpdateParams<T>): Promise<ValStat<IMessageHead>>;
|
|
93
93
|
delete(op: IDeleteParams): Promise<ValStat<IMessageHead>>;
|