@interncom/diplomatic 0.21.1 → 0.23.0

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.
Files changed (84) hide show
  1. package/dist/cli/bun/src/crypto.d.ts +2 -3
  2. package/dist/cli/index.mjs +4 -5
  3. package/dist/cli/shared/api/peek.d.ts +9 -1
  4. package/dist/cli/shared/api/pull.d.ts +9 -1
  5. package/dist/cli/shared/api/push.d.ts +3 -1
  6. package/dist/cli/shared/api/user.d.ts +1 -1
  7. package/dist/cli/shared/bag.d.ts +7 -4
  8. package/dist/cli/shared/client.d.ts +10 -4
  9. package/dist/cli/shared/codecs/kdm.d.ts +6 -0
  10. package/dist/cli/shared/codecs/notifItem.d.ts +2 -0
  11. package/dist/cli/shared/crypto/derivation.d.ts +45 -0
  12. package/dist/cli/shared/crypto/enclave.d.ts +40 -61
  13. package/dist/cli/shared/crypto/largeBlob.d.ts +8 -0
  14. package/dist/cli/shared/crypto/noble.d.ts +15 -22
  15. package/dist/cli/shared/crypto/pairing.d.ts +8 -4
  16. package/dist/cli/shared/crypto/prf.d.ts +52 -0
  17. package/dist/cli/shared/crypto/realms.d.ts +7 -0
  18. package/dist/cli/shared/endpoint.d.ts +2 -2
  19. package/dist/cli/shared/http.d.ts +12 -12
  20. package/dist/cli/shared/sync.d.ts +4 -2
  21. package/dist/cli/shared/types.d.ts +24 -11
  22. package/dist/cli/shared/webauthn/prf.d.ts +8 -0
  23. package/dist/cli/src/index.d.ts +5 -4
  24. package/dist/web/client.d.ts +10 -5
  25. package/dist/web/crypto.d.ts +2 -3
  26. package/dist/web/entdb/cached.d.ts +4 -0
  27. package/dist/web/entdb/entdb.d.ts +3 -0
  28. package/dist/web/entdb/idb.d.ts +9 -4
  29. package/dist/web/index.d.ts +11 -5
  30. package/dist/web/index.mjs +1 -1
  31. package/dist/web/passkey/prf-store.d.ts +26 -10
  32. package/dist/web/passkey/seed.d.ts +12 -6
  33. package/dist/web/shared/api/peek.d.ts +9 -1
  34. package/dist/web/shared/api/pull.d.ts +9 -1
  35. package/dist/web/shared/api/push.d.ts +3 -1
  36. package/dist/web/shared/api/user.d.ts +1 -1
  37. package/dist/web/shared/bag.d.ts +7 -4
  38. package/dist/web/shared/client.d.ts +10 -4
  39. package/dist/web/shared/codecs/kdm.d.ts +6 -0
  40. package/dist/web/shared/codecs/notifItem.d.ts +2 -0
  41. package/dist/web/shared/crypto/derivation.d.ts +45 -0
  42. package/dist/web/shared/crypto/enclave.d.ts +40 -61
  43. package/dist/web/shared/crypto/largeBlob.d.ts +8 -0
  44. package/dist/web/shared/crypto/noble.d.ts +15 -22
  45. package/dist/web/shared/crypto/pairing.d.ts +8 -4
  46. package/dist/web/shared/crypto/prf.d.ts +52 -0
  47. package/dist/web/shared/crypto/realms.d.ts +7 -0
  48. package/dist/web/shared/crypto/tty.d.ts +3 -0
  49. package/dist/web/shared/endpoint.d.ts +2 -2
  50. package/dist/web/shared/http.d.ts +12 -12
  51. package/dist/web/shared/storage/memory.d.ts +2 -2
  52. package/dist/web/shared/sync.d.ts +4 -2
  53. package/dist/web/shared/types.d.ts +24 -11
  54. package/dist/web/shared/webauthn/prf.d.ts +8 -0
  55. package/dist/web/stores/cursor.d.ts +30 -0
  56. package/dist/web/stores/idb/account.d.ts +58 -0
  57. package/dist/web/stores/idb/catalog.d.ts +1 -0
  58. package/dist/web/stores/idb/dnlds.d.ts +3 -2
  59. package/dist/web/stores/idb/hosts.d.ts +8 -7
  60. package/dist/web/stores/idb/idbutil.d.ts +2 -0
  61. package/dist/web/stores/idb/migrate.d.ts +2 -0
  62. package/dist/web/stores/idb/msgs.d.ts +1 -1
  63. package/dist/web/stores/idb/names.d.ts +13 -0
  64. package/dist/web/stores/idb/realms.d.ts +11 -0
  65. package/dist/web/stores/idb/store.d.ts +26 -19
  66. package/dist/web/stores/idb/uplds.d.ts +1 -1
  67. package/dist/web/stores/keyTag.d.ts +14 -0
  68. package/dist/web/stores/label.d.ts +3 -0
  69. package/dist/web/stores/memory/account.d.ts +14 -0
  70. package/dist/web/stores/memory/dnlds.d.ts +4 -2
  71. package/dist/web/stores/memory/hosts.d.ts +8 -6
  72. package/dist/web/stores/memory/realms.d.ts +10 -0
  73. package/dist/web/stores/memory/store.d.ts +6 -2
  74. package/dist/web/stores/realm.d.ts +35 -0
  75. package/dist/web/sync.d.ts +14 -11
  76. package/dist/web/types.d.ts +52 -16
  77. package/dist/web/worker/client.d.ts +1 -1
  78. package/dist/web/worker/protocol.d.ts +6 -0
  79. package/dist/web/worker/runtime.d.ts +4 -2
  80. package/dist/web/worker.mjs +1 -1
  81. package/package.json +1 -1
  82. package/dist/web/stores/idb/seed.d.ts +0 -32
  83. package/dist/web/stores/identityPin.d.ts +0 -19
  84. package/dist/web/stores/memory/seed.d.ts +0 -13
@@ -25,6 +25,10 @@ export type OpenEntDBOptions = {
25
25
  * Process-wide; also accepted on openDiplomaticClient / useClient.
26
26
  */
27
27
  verbose?: boolean;
28
+ /** Account whose EntDB to open. Default is the unlabeled account. */
29
+ label?: string;
30
+ /** Database name. The worker passes this and does not open the catalog. */
31
+ name?: string;
28
32
  };
29
33
  export type CachedEntDBOptions = {
30
34
  /** Secondary mem indexes (default true). See {@link OpenEntDBOptions.indexes}. */
@@ -1,3 +1,4 @@
1
+ import type { EntRlm } from "../stores/realm";
1
2
  import { Status } from "../shared/consts";
2
3
  import { ValStat } from "../shared/valstat";
3
4
  import { EntityID, Hash, ICrypto, IEntRev, IMessageHead, IMsgEntBody, IOp } from "../shared/types";
@@ -9,6 +10,8 @@ export interface IEntity<T = unknown> extends Omit<IMsgEntBody<T>, "body"> {
9
10
  createdAt: Date;
10
11
  ctr: number;
11
12
  body: T;
13
+ /** Realm label. Omitted for the default realm. */
14
+ rlm?: EntRlm;
12
15
  }
13
16
  /**
14
17
  * Deleted eid's LWW frontier: eid + updatedAt + ctr only (no type/body/…).
@@ -8,15 +8,20 @@ export declare const typeUpdatedAtIndexName = "entity_type_updated_at";
8
8
  export declare const typeParentIndexName = "entity_type_parent_id";
9
9
  /** multiEntry index on tgs[]; query by tag then filter by type. */
10
10
  export declare const tagsIndexName = "entity_tags";
11
- /** Shared by main thread and sync worker — must stay in lockstep. */
11
+ /** Realm label. Rows in the default realm omit rlm and are not in this index. */
12
+ export declare const realmIndexName = "entity_rlm";
13
+ /** Pre-split EntDB name. New accounts use `ents-<acct>`. */
12
14
  export declare const ENT_IDB_NAME = "db";
13
- /** v14: drop [`typ`,`gid`] index (gid superseded by tags). */
14
- export declare const ENT_IDB_VERSION = 14;
15
+ /** v15: optional rlm (realm label) index. Omitted on the default realm. */
16
+ export declare const ENT_IDB_VERSION = 15;
15
17
  export declare class EntIDB implements IEntDB {
18
+ private name;
16
19
  db: IDBDatabase | undefined;
17
20
  /** In-flight open; coalesces concurrent ensureDb / peer upgrade reopen. */
18
21
  private opening;
22
+ constructor(name: string);
19
23
  init(): Promise<void>;
24
+ close(): void;
20
25
  /**
21
26
  * Open (or reopen) the shared EntDB IDB connection.
22
27
  * Main + worker both hold connections; on versionchange we must close so the
@@ -43,4 +48,4 @@ export declare class EntIDB implements IEntDB {
43
48
  checksum(crypto: ICrypto): Promise<ValStat<Hash>>;
44
49
  }
45
50
  /** Durable IndexedDB EntDB. Internal-only. Apps use {@link openEntDB} instead. */
46
- export declare function openEntIDB(): Promise<EntIDB>;
51
+ export declare function openEntIDB(name: string): Promise<EntIDB>;
@@ -17,12 +17,17 @@ import { TypedEventEmitter } from "./shared/events";
17
17
  import { asSealedMasterKey, MASTER_SEED_LEN, SEALED_MASTER_KEY_LEN, type SealedMasterKey } from "./shared/seed";
18
18
  import { EntityID, HostHandle, ICrypto, IDeleteParams, IEntRev, IHostConnectionInfo, IMessage, IMutateOp, type IOp, IStateManager, ITransport, IUpdateParams } from "./shared/types";
19
19
  import { Enclave } from "./shared/crypto/enclave";
20
+ import type { Identity } from "./shared/crypto/enclave";
21
+ import { asChildKey, asHostRlm, type ChildKey, type HostRlm, nullKDM, Purpose } from "./shared/crypto/derivation";
22
+ import type { PairRequest } from "./shared/crypto/pairing";
23
+ import type { BindPrior, PrfBound } from "./shared/crypto/prf";
20
24
  import { nullStateManager, StateManager } from "./state";
21
- import { IDBSeedStore } from "./stores/idb/seed";
25
+ import type { EntRlm, IRealm } from "./stores/realm";
26
+ import { IDBAccountStore } from "./stores/idb/account";
22
27
  import { IDBStore, openIDBStore } from "./stores/idb/store";
23
28
  import { MemoryStore } from "./stores/memory/store";
24
29
  import { SingletonStateManager } from "./shared/singleton";
25
- import type { ApldState, Applier, HostStatsUpdate, IClient, IDiplomaticClientState, IHostRow, IStore, IStoredMessage, IStoredMessageData, IStoredMessageWrite, ListMsgsOpts, ReconcileOpts, ReconcileReport, SetSeedOpts } from "./types";
30
+ import type { ApldState, Applier, HostSeqsUpdate, IClient, IDiplomaticClientState, IHostRow, IStore, IStoredMessage, IStoredMessageData, IStoredMessageWrite, ListMsgsOpts, OpenAccount, ReconcileOpts, ReconcileReport, SetSeedOpts } from "./types";
26
31
  import { APLD_APPLIED, APLD_ERROR, APLD_PENDING, apldFromStored, isApldState, isPendingApply, isTerminalApplyFailure, setApld } from "./types";
27
32
  import type { SyncProgressEvent } from "./progress";
28
33
  import { defaultPeekProgressEvery, idleProgress, shouldEmitItemProgress } from "./progress";
@@ -33,7 +38,8 @@ import { KEYRING_MAX, keyringCredIds, keyringKind, keyringLabel, PrfSeedStore }
33
38
  import type { Keyring, KeyringEntry, KeyringRow, PersistKeyring, PrfSeedStoreOpts } from "./passkey/prf-store";
34
39
  import type { PasskeySeedStoreOpts } from "./passkey/seed";
35
40
  import { type BundleHost } from "./shared/codecs/bundleHost";
36
- import { asDHKEReq, asDHKEResp, PairRequest } from "./shared/crypto/pairing";
41
+ import { type IKDM } from "./shared/codecs/kdm";
42
+ import { asDHKEReq, asDHKEResp } from "./shared/crypto/pairing";
37
43
  import type { DHKEReq, DHKEResp } from "./shared/crypto/pairing";
38
44
  import { checksumEntRevs, checksumSet, cmpBytes, encodeEntRev } from "./shared/checksum";
39
45
  import { openDiplomaticClient, type OpenDiplomaticClientMainOptions, type OpenDiplomaticClientOptions, type OpenDiplomaticClientWorkerOptions, type OpenedDiplomaticClient } from "./openClient";
@@ -43,5 +49,5 @@ import type { WipeOpts } from "./types";
43
49
  /** Platform advertises largeBlob (not a guarantee the binding key has it). */
44
50
  export { largeBlobCapable } from "./shared/webauthn/largeBlob";
45
51
  export { webAuthnLastError } from "./shared/webauthn/common";
46
- export { APLD_APPLIED, APLD_ERROR, APLD_PENDING, apldFromStored, asDHKEReq, asDHKEResp, asSealedMasterKey, b64tob, b64urltob, btob64, btob64url, btoh, CachedEntDB, checksumEntRevs, checksumSet, Clock, cmpBytes, crypto, Decoder, DEFAULT_PRF_SALT, defaultPeekProgressEvery, defaultWebAuthnRpId, eidCodec, Enclave, encodeEntRev, Encoder, EntDBMemory, EntIDB, EntitiesQuery, EntityID, entStateManager, genSingletonEID, hostHTTPTransport, htob, HTTPTransport, IDBSeedStore, IDBStore, idleProgress, IEntDB, IEntity, isApldState, isLiveEnt, isPendingApply, isTerminalApplyFailure, isTombstone, IStore, KEYRING_MAX, keyringCredIds, keyringKind, keyringLabel, MASTER_SEED_LEN, MemoryStore, normalizeTags, nullEntDB, nullStateManager, openDiplomaticClient, openEntDB, openIDBStore, PairRequest, PasskeySeedStore, prfCapable, PrfSeedStore, revFromEntity, revFromHead, SEALED_MASTER_KEY_LEN, setApld, shouldEmitItemProgress, SingletonStateManager, StateManager, Status, SyncClient, TypedEventEmitter, useClient, useClientState, useClientXferState, useStateWatcher, useStateWatcherSuspense, useSyncOnResume, WorkerClient, };
47
- export type { ApldState, Applier, BundleHost, CachedEntDBOptions, DateSpec, DHKEReq, DHKEResp, EntDBMemoryOptions, HostHandle, HostStatsUpdate, IClient, ICrypto, IDateRange, IDeleteParams, IDiplomaticClientState, IEntRev, IEntRow, IHostConnectionInfo, IHostRow, IMessage, IMutateOp, IOp, IStateManager, IStoredMessage, IStoredMessageData, IStoredMessageWrite, ITagRange, ITombstone, ITransport, IUpdateParams, Keyring, KeyringEntry, KeyringRow, ListMsgsOpts, OpenDiplomaticClientMainOptions, OpenDiplomaticClientOptions, OpenDiplomaticClientWorkerOptions, OpenedDiplomaticClient, OpenEntDBOptions, PasskeySeedStoreOpts, PersistKeyring, PrfRp, PrfSeedStoreOpts, ReconcileOpts, ReconcileReport, SealedMasterKey, SetSeedOpts, SyncProgressEvent, TagSpec, WipeOpts, WorkerClientOptions, };
52
+ export { APLD_APPLIED, APLD_ERROR, APLD_PENDING, apldFromStored, asChildKey, asDHKEReq, asDHKEResp, asHostRlm, asSealedMasterKey, b64tob, b64urltob, btob64, btob64url, btoh, CachedEntDB, checksumEntRevs, checksumSet, Clock, cmpBytes, crypto, Decoder, DEFAULT_PRF_SALT, defaultPeekProgressEvery, defaultWebAuthnRpId, eidCodec, Enclave, encodeEntRev, Encoder, EntDBMemory, EntIDB, EntitiesQuery, EntityID, entStateManager, genSingletonEID, hostHTTPTransport, htob, HTTPTransport, IDBAccountStore, IDBStore, idleProgress, IEntDB, IEntity, isApldState, isLiveEnt, isPendingApply, isTerminalApplyFailure, isTombstone, IStore, KEYRING_MAX, keyringCredIds, keyringKind, keyringLabel, MASTER_SEED_LEN, MemoryStore, normalizeTags, nullEntDB, nullKDM, nullStateManager, openDiplomaticClient, openEntDB, openIDBStore, PasskeySeedStore, prfCapable, PrfSeedStore, Purpose, revFromEntity, revFromHead, SEALED_MASTER_KEY_LEN, setApld, shouldEmitItemProgress, SingletonStateManager, StateManager, Status, SyncClient, TypedEventEmitter, useClient, useClientState, useClientXferState, useStateWatcher, useStateWatcherSuspense, useSyncOnResume, WorkerClient, };
53
+ export type { ApldState, Applier, BindPrior, BundleHost, CachedEntDBOptions, ChildKey, DateSpec, DHKEReq, DHKEResp, EntDBMemoryOptions, EntRlm, HostHandle, HostRlm, HostSeqsUpdate, IClient, ICrypto, IDateRange, IDeleteParams, Identity, IDiplomaticClientState, IEntRev, IEntRow, IHostConnectionInfo, IHostRow, IKDM, IMessage, IMutateOp, IOp, IRealm, IStateManager, IStoredMessage, IStoredMessageData, IStoredMessageWrite, ITagRange, ITombstone, ITransport, IUpdateParams, Keyring, KeyringEntry, KeyringRow, ListMsgsOpts, OpenAccount, OpenDiplomaticClientMainOptions, OpenDiplomaticClientOptions, OpenDiplomaticClientWorkerOptions, OpenedDiplomaticClient, OpenEntDBOptions, PairRequest, PasskeySeedStoreOpts, PersistKeyring, PrfBound, PrfRp, PrfSeedStoreOpts, ReconcileOpts, ReconcileReport, SealedMasterKey, SetSeedOpts, SyncProgressEvent, TagSpec, WipeOpts, WorkerClientOptions, };