@interncom/diplomatic 0.1.3 → 0.2.0-rc2

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 (117) hide show
  1. package/README.md +69 -42
  2. package/dist/cli/bin/host.js +6 -0
  3. package/dist/cli/bun/src/codec.d.ts +3 -0
  4. package/dist/cli/bun/src/crypto.d.ts +3 -0
  5. package/dist/cli/bun/src/host.d.ts +1 -0
  6. package/dist/cli/bun/src/storage/sqlite.d.ts +3 -0
  7. package/dist/cli/index.js +6020 -0
  8. package/dist/cli/index.mjs +6020 -0
  9. package/dist/{shared/crypto/libsodium.d.ts → cli/shared/crypto/noble.d.ts} +1 -6
  10. package/dist/{shared → cli/shared}/types.d.ts +1 -2
  11. package/dist/cli/src/index.d.ts +44 -0
  12. package/dist/{client.d.ts → web/client.d.ts} +1 -1
  13. package/dist/web/crypto.d.ts +3 -0
  14. package/dist/{index.d.ts → web/index.d.ts} +2 -2
  15. package/dist/web/index.js +6800 -0
  16. package/dist/web/index.mjs +7645 -0
  17. package/dist/web/shared/api/peek.d.ts +3 -0
  18. package/dist/web/shared/api/pull.d.ts +3 -0
  19. package/dist/web/shared/api/push.d.ts +4 -0
  20. package/dist/web/shared/api/user.d.ts +2 -0
  21. package/dist/web/shared/auth.d.ts +8 -0
  22. package/dist/web/shared/bag.d.ts +15 -0
  23. package/dist/web/shared/binary.d.ts +8 -0
  24. package/dist/web/shared/client.d.ts +22 -0
  25. package/dist/web/shared/clock.d.ts +13 -0
  26. package/dist/web/shared/codec.d.ts +43 -0
  27. package/dist/web/shared/codecs/authTimestamp.d.ts +8 -0
  28. package/dist/web/shared/codecs/bag.d.ts +3 -0
  29. package/dist/web/shared/codecs/eid.d.ts +10 -0
  30. package/dist/web/shared/codecs/messageHead.d.ts +16 -0
  31. package/dist/web/shared/codecs/notifItem.d.ts +7 -0
  32. package/dist/web/shared/codecs/peekItem.d.ts +6 -0
  33. package/dist/web/shared/codecs/peekItemHead.d.ts +7 -0
  34. package/dist/web/shared/codecs/pullItem.d.ts +6 -0
  35. package/dist/web/shared/codecs/pushItem.d.ts +11 -0
  36. package/dist/web/shared/codecs/respHead.d.ts +10 -0
  37. package/dist/web/shared/codecs/usageQuota.d.ts +6 -0
  38. package/dist/web/shared/consts.d.ts +50 -0
  39. package/dist/web/shared/crypto/noble.d.ts +11 -0
  40. package/dist/web/shared/enclave.d.ts +8 -0
  41. package/dist/web/shared/endpoint.d.ts +23 -0
  42. package/dist/web/shared/events.d.ts +8 -0
  43. package/dist/web/shared/http/listener.d.ts +11 -0
  44. package/dist/web/shared/http/server.d.ts +14 -0
  45. package/dist/web/shared/http.d.ts +82 -0
  46. package/dist/web/shared/message.d.ts +22 -0
  47. package/dist/web/shared/singleton.d.ts +15 -0
  48. package/dist/web/shared/sync.d.ts +9 -0
  49. package/dist/web/shared/types.d.ts +163 -0
  50. package/dist/web/shared/valstat.d.ts +6 -0
  51. package/package.json +27 -11
  52. package/dist/crypto.d.ts +0 -3
  53. package/dist/exim.d.ts +0 -0
  54. package/dist/index.mjs +0 -11295
  55. package/dist/lib.d.ts +0 -2
  56. /package/dist/{shared → cli/shared}/api/peek.d.ts +0 -0
  57. /package/dist/{shared → cli/shared}/api/pull.d.ts +0 -0
  58. /package/dist/{shared → cli/shared}/api/push.d.ts +0 -0
  59. /package/dist/{shared → cli/shared}/api/user.d.ts +0 -0
  60. /package/dist/{shared → cli/shared}/auth.d.ts +0 -0
  61. /package/dist/{shared → cli/shared}/bag.d.ts +0 -0
  62. /package/dist/{shared → cli/shared}/binary.d.ts +0 -0
  63. /package/dist/{shared → cli/shared}/client.d.ts +0 -0
  64. /package/dist/{shared → cli/shared}/clock.d.ts +0 -0
  65. /package/dist/{shared → cli/shared}/codec.d.ts +0 -0
  66. /package/dist/{shared → cli/shared}/codecs/authTimestamp.d.ts +0 -0
  67. /package/dist/{shared → cli/shared}/codecs/bag.d.ts +0 -0
  68. /package/dist/{shared → cli/shared}/codecs/eid.d.ts +0 -0
  69. /package/dist/{shared → cli/shared}/codecs/messageHead.d.ts +0 -0
  70. /package/dist/{shared → cli/shared}/codecs/notifItem.d.ts +0 -0
  71. /package/dist/{shared → cli/shared}/codecs/peekItem.d.ts +0 -0
  72. /package/dist/{shared → cli/shared}/codecs/peekItemHead.d.ts +0 -0
  73. /package/dist/{shared → cli/shared}/codecs/pullItem.d.ts +0 -0
  74. /package/dist/{shared → cli/shared}/codecs/pushItem.d.ts +0 -0
  75. /package/dist/{shared → cli/shared}/codecs/respHead.d.ts +0 -0
  76. /package/dist/{shared → cli/shared}/codecs/usageQuota.d.ts +0 -0
  77. /package/dist/{shared → cli/shared}/consts.d.ts +0 -0
  78. /package/dist/{shared → cli/shared}/enclave.d.ts +0 -0
  79. /package/dist/{shared → cli/shared}/endpoint.d.ts +0 -0
  80. /package/dist/{shared → cli/shared}/events.d.ts +0 -0
  81. /package/dist/{shared → cli/shared}/http/listener.d.ts +0 -0
  82. /package/dist/{shared → cli/shared}/http/server.d.ts +0 -0
  83. /package/dist/{shared → cli/shared}/http.d.ts +0 -0
  84. /package/dist/{shared → cli/shared}/message.d.ts +0 -0
  85. /package/dist/{shared → cli/shared}/singleton.d.ts +0 -0
  86. /package/dist/{shared → cli/shared}/sync.d.ts +0 -0
  87. /package/dist/{shared → cli/shared}/valstat.d.ts +0 -0
  88. /package/dist/{entdb → web/entdb}/entdb.d.ts +0 -0
  89. /package/dist/{entdb → web/entdb}/idb.d.ts +0 -0
  90. /package/dist/{entdb → web/entdb}/memory.d.ts +0 -0
  91. /package/dist/{events.d.ts → web/events.d.ts} +0 -0
  92. /package/dist/{react → web/react}/useClient.d.ts +0 -0
  93. /package/dist/{react → web/react}/useEntities.d.ts +0 -0
  94. /package/dist/{react → web/react}/useStateWatcher.d.ts +0 -0
  95. /package/dist/{shared → web/shared}/codecs/file.d.ts +0 -0
  96. /package/dist/{shared → web/shared}/codecs/fileHead.d.ts +0 -0
  97. /package/dist/{shared → web/shared}/codecs/fileIndexItem.d.ts +0 -0
  98. /package/dist/{shared → web/shared}/exim.d.ts +0 -0
  99. /package/dist/{shared → web/shared}/lpc/listener.d.ts +0 -0
  100. /package/dist/{shared → web/shared}/lpc/pusher.d.ts +0 -0
  101. /package/dist/{shared → web/shared}/lpc/server.d.ts +0 -0
  102. /package/dist/{shared → web/shared}/storage/memory.d.ts +0 -0
  103. /package/dist/{state.d.ts → web/state.d.ts} +0 -0
  104. /package/dist/{stores → web/stores}/idb/dnlds.d.ts +0 -0
  105. /package/dist/{stores → web/stores}/idb/hosts.d.ts +0 -0
  106. /package/dist/{stores → web/stores}/idb/msgs.d.ts +0 -0
  107. /package/dist/{stores → web/stores}/idb/seed.d.ts +0 -0
  108. /package/dist/{stores → web/stores}/idb/store.d.ts +0 -0
  109. /package/dist/{stores → web/stores}/idb/uplds.d.ts +0 -0
  110. /package/dist/{stores → web/stores}/memory/dnlds.d.ts +0 -0
  111. /package/dist/{stores → web/stores}/memory/hosts.d.ts +0 -0
  112. /package/dist/{stores → web/stores}/memory/msgs.d.ts +0 -0
  113. /package/dist/{stores → web/stores}/memory/seed.d.ts +0 -0
  114. /package/dist/{stores → web/stores}/memory/store.d.ts +0 -0
  115. /package/dist/{stores → web/stores}/memory/uplds.d.ts +0 -0
  116. /package/dist/{sync.d.ts → web/sync.d.ts} +0 -0
  117. /package/dist/{types.d.ts → web/types.d.ts} +0 -0
@@ -1,11 +1,7 @@
1
1
  import type { DerivationSeed, Hash, ICrypto, KeyPair } from "../types.ts";
2
- type Libsodium = any;
3
- export declare class LibsodiumCrypto implements ICrypto {
4
- sodium: Libsodium;
5
- constructor(sodium: Libsodium);
2
+ export declare class NobleCrypto implements ICrypto {
6
3
  genRandomBytes(bytes: number): Promise<Uint8Array>;
7
4
  gen256BitSecureRandomSeed(): Promise<Uint8Array>;
8
- deriveXSalsa20Poly1305Key(seed: Uint8Array, derivationIndex?: number): Promise<Uint8Array>;
9
5
  encryptXSalsa20Poly1305Combined(data: Uint8Array, key: Uint8Array): Promise<Uint8Array>;
10
6
  decryptXSalsa20Poly1305Combined(data: Uint8Array, key: Uint8Array): Promise<Uint8Array>;
11
7
  deriveEd25519KeyPair(derivationSeed: DerivationSeed): Promise<KeyPair>;
@@ -13,4 +9,3 @@ export declare class LibsodiumCrypto implements ICrypto {
13
9
  checkSigEd25519(sig: Uint8Array, message: Uint8Array | string, pubKey: Uint8Array): Promise<boolean>;
14
10
  blake3(data: Uint8Array): Promise<Hash>;
15
11
  }
16
- export {};
@@ -53,7 +53,7 @@ export interface IStorage {
53
53
  listHeads: (pubKey: PublicKey, minSeq: number) => Promise<ValStat<IBagPeekItem[]>>;
54
54
  }
55
55
  export interface KeyPair {
56
- keyType: "public" | "private" | "secret";
56
+ keyType: "ed25519";
57
57
  privateKey: PrivateKey;
58
58
  publicKey: PublicKey;
59
59
  }
@@ -87,7 +87,6 @@ export interface IHostCrypto {
87
87
  export interface ICrypto extends IHostCrypto {
88
88
  genRandomBytes: (bytes: number) => Promise<Uint8Array>;
89
89
  gen256BitSecureRandomSeed: () => Promise<Uint8Array>;
90
- deriveXSalsa20Poly1305Key: (seed: Uint8Array, derivationIndex: number) => Promise<Uint8Array>;
91
90
  encryptXSalsa20Poly1305Combined: (plaintext: Uint8Array, key: Uint8Array) => Promise<Uint8Array>;
92
91
  decryptXSalsa20Poly1305Combined: (headerAndCipher: Uint8Array, key: Uint8Array) => Promise<Uint8Array>;
93
92
  deriveEd25519KeyPair: (derivationSeed: DerivationSeed) => Promise<KeyPair>;
@@ -0,0 +1,44 @@
1
+ import { IOpenBag } from "../shared/bag.ts";
2
+ import { IClock } from "../shared/clock.ts";
3
+ import type { IBagPeekItem } from "../shared/codecs/peekItem.ts";
4
+ import { IBagPullItem } from "../shared/codecs/pullItem.ts";
5
+ import { IBagPushItem } from "../shared/codecs/pushItem.ts";
6
+ import { Status } from "../shared/consts.ts";
7
+ import { HostHandle, IHostConnectionInfo, IMessage, ITransport, MasterSeed } from "../shared/types.ts";
8
+ import { ValStat } from "../shared/valstat.ts";
9
+ export declare class CLIClient<Handle extends HostHandle> {
10
+ private enclave;
11
+ private conn?;
12
+ private clock;
13
+ constructor({ seed, clock }: {
14
+ seed: MasterSeed;
15
+ clock?: IClock;
16
+ });
17
+ connect(host: IHostConnectionInfo<Handle>, transport: ITransport): Promise<Status>;
18
+ push(msgs: IMessage[]): Promise<ValStat<IBagPushItem[]>>;
19
+ peek(lastSeq: number): Promise<ValStat<IBagPeekItem[]>>;
20
+ pull(seqs: number[]): Promise<ValStat<IBagPullItem[]>>;
21
+ open(peekItem: IBagPeekItem, pullItem: IBagPullItem): Promise<ValStat<IOpenBag>>;
22
+ upsertSingletonSync(type: string, body: Uint8Array): Promise<Status>;
23
+ listen(onNotification: (bytes: Uint8Array) => Promise<Status>): Promise<Status>;
24
+ }
25
+ export declare function initCLI<Handle extends URL>({ seed, host, transport }: {
26
+ seed: MasterSeed;
27
+ host: IHostConnectionInfo<Handle>;
28
+ transport: ITransport;
29
+ }): Promise<[CLIClient<Handle>, Status]>;
30
+ export declare function initCLIOrPanic<Handle extends URL>({ seed, host, transport }: {
31
+ seed: MasterSeed;
32
+ host: IHostConnectionInfo<Handle>;
33
+ transport?: ITransport;
34
+ }): Promise<CLIClient<Handle>>;
35
+ export declare function loadSeedOrPanic(envVar: string): MasterSeed;
36
+ export declare function loadHostOrPanic(envVar: string): IHostConnectionInfo<URL>;
37
+ export { default as msgpack } from "../bun/src/codec.ts";
38
+ export { Decoder } from "../shared/codec.ts";
39
+ export { notifItemCodec } from "../shared/codecs/notifItem.ts";
40
+ export type { IBagNotifItem } from "../shared/codecs/notifItem.ts";
41
+ export type { IBagPullItem } from "../shared/codecs/pullItem.ts";
42
+ export { Status } from "../shared/consts.ts";
43
+ export { hostHTTPTransport } from "../shared/http.ts";
44
+ export { runBunHost } from "../bun/src/host.ts";
@@ -16,7 +16,7 @@ export declare class SyncClient<Handle extends HostHandle> implements IClient<Ha
16
16
  private currentSync;
17
17
  clientState: IStateEmitter<IDiplomaticClientState>;
18
18
  xferState: IStateEmitter<IDiplomaticClientXferState>;
19
- constructor(clock: IClock, state: IStateManager, store: IStore<Handle>, transport: (host: IHostConnectionInfo<Handle>) => ITransport, crypto?: ICrypto, forceSkewHandlingByDefault?: boolean);
19
+ constructor(clock: IClock, state: IStateManager, store: IStore<Handle>, transport: (host: IHostConnectionInfo<Handle>) => ITransport, crypto: ICrypto, forceSkewHandlingByDefault?: boolean);
20
20
  private readonly SYNC_DEBOUNCE_DELAY_MS;
21
21
  private syncTimeout;
22
22
  setSeed(seed: MasterSeed): Promise<void>;
@@ -0,0 +1,3 @@
1
+ import { NobleCrypto } from "./shared/crypto/noble";
2
+ declare const crypto: NobleCrypto;
3
+ export default crypto;
@@ -1,5 +1,5 @@
1
1
  import { SyncClient } from "./client";
2
- import libsodiumCrypto from "./crypto";
2
+ import crypto from "./crypto";
3
3
  import { EntitiesQuery, entStateManager, IEntDB, IEntity, nullEntDB } from "./entdb/entdb";
4
4
  import { EntIDB, openEntIDB } from "./entdb/idb";
5
5
  import { EntDBMemory } from "./entdb/memory";
@@ -22,5 +22,5 @@ export declare function genWebClient(stateMgr: IStateManager, url: URL): Promise
22
22
  client: SyncClient<URL>;
23
23
  setSeed: (seedHex: string) => Promise<void>;
24
24
  }>;
25
- export { btoh, Clock, Decoder, eidCodec, Encoder, EntDBMemory, EntIDB, EntitiesQuery, EntityID, entStateManager, genSingletonEID, GroupID, htob, HTTPTransport, IDBStore, IEntDB, IEntity, IStore, libsodiumCrypto, MasterSeed, MemoryStore, nullEntDB, nullStateManager, openEntIDB, openIDBStore, SingletonStateManager, StateManager, Status, SyncClient, TypedEventEmitter, useClient, useClientState, useClientXferState, useStateWatcher, useStateWatcherSuspense, useSyncOnResume, };
25
+ export { btoh, Clock, crypto, Decoder, eidCodec, Encoder, EntDBMemory, EntIDB, EntitiesQuery, EntityID, entStateManager, genSingletonEID, GroupID, htob, HTTPTransport, IDBStore, IEntDB, IEntity, IStore, MasterSeed, MemoryStore, nullEntDB, nullStateManager, openEntIDB, openIDBStore, SingletonStateManager, StateManager, Status, SyncClient, TypedEventEmitter, useClient, useClientState, useClientXferState, useStateWatcher, useStateWatcherSuspense, useSyncOnResume, };
26
26
  export type { Applier, IDiplomaticClientState, IMessage, IMutateOp, IOp, IStateManager, IStoredMessage, IStoredMessageData, };