@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.
- package/README.md +69 -42
- package/dist/cli/bin/host.js +6 -0
- package/dist/cli/bun/src/codec.d.ts +3 -0
- package/dist/cli/bun/src/crypto.d.ts +3 -0
- package/dist/cli/bun/src/host.d.ts +1 -0
- package/dist/cli/bun/src/storage/sqlite.d.ts +3 -0
- package/dist/cli/index.js +6020 -0
- package/dist/cli/index.mjs +6020 -0
- package/dist/{shared/crypto/libsodium.d.ts → cli/shared/crypto/noble.d.ts} +1 -6
- package/dist/{shared → cli/shared}/types.d.ts +1 -2
- package/dist/cli/src/index.d.ts +44 -0
- package/dist/{client.d.ts → web/client.d.ts} +1 -1
- package/dist/web/crypto.d.ts +3 -0
- package/dist/{index.d.ts → web/index.d.ts} +2 -2
- package/dist/web/index.js +6800 -0
- package/dist/web/index.mjs +7645 -0
- package/dist/web/shared/api/peek.d.ts +3 -0
- package/dist/web/shared/api/pull.d.ts +3 -0
- package/dist/web/shared/api/push.d.ts +4 -0
- package/dist/web/shared/api/user.d.ts +2 -0
- package/dist/web/shared/auth.d.ts +8 -0
- package/dist/web/shared/bag.d.ts +15 -0
- package/dist/web/shared/binary.d.ts +8 -0
- package/dist/web/shared/client.d.ts +22 -0
- package/dist/web/shared/clock.d.ts +13 -0
- package/dist/web/shared/codec.d.ts +43 -0
- package/dist/web/shared/codecs/authTimestamp.d.ts +8 -0
- package/dist/web/shared/codecs/bag.d.ts +3 -0
- package/dist/web/shared/codecs/eid.d.ts +10 -0
- package/dist/web/shared/codecs/messageHead.d.ts +16 -0
- package/dist/web/shared/codecs/notifItem.d.ts +7 -0
- package/dist/web/shared/codecs/peekItem.d.ts +6 -0
- package/dist/web/shared/codecs/peekItemHead.d.ts +7 -0
- package/dist/web/shared/codecs/pullItem.d.ts +6 -0
- package/dist/web/shared/codecs/pushItem.d.ts +11 -0
- package/dist/web/shared/codecs/respHead.d.ts +10 -0
- package/dist/web/shared/codecs/usageQuota.d.ts +6 -0
- package/dist/web/shared/consts.d.ts +50 -0
- package/dist/web/shared/crypto/noble.d.ts +11 -0
- package/dist/web/shared/enclave.d.ts +8 -0
- package/dist/web/shared/endpoint.d.ts +23 -0
- package/dist/web/shared/events.d.ts +8 -0
- package/dist/web/shared/http/listener.d.ts +11 -0
- package/dist/web/shared/http/server.d.ts +14 -0
- package/dist/web/shared/http.d.ts +82 -0
- package/dist/web/shared/message.d.ts +22 -0
- package/dist/web/shared/singleton.d.ts +15 -0
- package/dist/web/shared/sync.d.ts +9 -0
- package/dist/web/shared/types.d.ts +163 -0
- package/dist/web/shared/valstat.d.ts +6 -0
- package/package.json +27 -11
- package/dist/crypto.d.ts +0 -3
- package/dist/exim.d.ts +0 -0
- package/dist/index.mjs +0 -11295
- package/dist/lib.d.ts +0 -2
- /package/dist/{shared → cli/shared}/api/peek.d.ts +0 -0
- /package/dist/{shared → cli/shared}/api/pull.d.ts +0 -0
- /package/dist/{shared → cli/shared}/api/push.d.ts +0 -0
- /package/dist/{shared → cli/shared}/api/user.d.ts +0 -0
- /package/dist/{shared → cli/shared}/auth.d.ts +0 -0
- /package/dist/{shared → cli/shared}/bag.d.ts +0 -0
- /package/dist/{shared → cli/shared}/binary.d.ts +0 -0
- /package/dist/{shared → cli/shared}/client.d.ts +0 -0
- /package/dist/{shared → cli/shared}/clock.d.ts +0 -0
- /package/dist/{shared → cli/shared}/codec.d.ts +0 -0
- /package/dist/{shared → cli/shared}/codecs/authTimestamp.d.ts +0 -0
- /package/dist/{shared → cli/shared}/codecs/bag.d.ts +0 -0
- /package/dist/{shared → cli/shared}/codecs/eid.d.ts +0 -0
- /package/dist/{shared → cli/shared}/codecs/messageHead.d.ts +0 -0
- /package/dist/{shared → cli/shared}/codecs/notifItem.d.ts +0 -0
- /package/dist/{shared → cli/shared}/codecs/peekItem.d.ts +0 -0
- /package/dist/{shared → cli/shared}/codecs/peekItemHead.d.ts +0 -0
- /package/dist/{shared → cli/shared}/codecs/pullItem.d.ts +0 -0
- /package/dist/{shared → cli/shared}/codecs/pushItem.d.ts +0 -0
- /package/dist/{shared → cli/shared}/codecs/respHead.d.ts +0 -0
- /package/dist/{shared → cli/shared}/codecs/usageQuota.d.ts +0 -0
- /package/dist/{shared → cli/shared}/consts.d.ts +0 -0
- /package/dist/{shared → cli/shared}/enclave.d.ts +0 -0
- /package/dist/{shared → cli/shared}/endpoint.d.ts +0 -0
- /package/dist/{shared → cli/shared}/events.d.ts +0 -0
- /package/dist/{shared → cli/shared}/http/listener.d.ts +0 -0
- /package/dist/{shared → cli/shared}/http/server.d.ts +0 -0
- /package/dist/{shared → cli/shared}/http.d.ts +0 -0
- /package/dist/{shared → cli/shared}/message.d.ts +0 -0
- /package/dist/{shared → cli/shared}/singleton.d.ts +0 -0
- /package/dist/{shared → cli/shared}/sync.d.ts +0 -0
- /package/dist/{shared → cli/shared}/valstat.d.ts +0 -0
- /package/dist/{entdb → web/entdb}/entdb.d.ts +0 -0
- /package/dist/{entdb → web/entdb}/idb.d.ts +0 -0
- /package/dist/{entdb → web/entdb}/memory.d.ts +0 -0
- /package/dist/{events.d.ts → web/events.d.ts} +0 -0
- /package/dist/{react → web/react}/useClient.d.ts +0 -0
- /package/dist/{react → web/react}/useEntities.d.ts +0 -0
- /package/dist/{react → web/react}/useStateWatcher.d.ts +0 -0
- /package/dist/{shared → web/shared}/codecs/file.d.ts +0 -0
- /package/dist/{shared → web/shared}/codecs/fileHead.d.ts +0 -0
- /package/dist/{shared → web/shared}/codecs/fileIndexItem.d.ts +0 -0
- /package/dist/{shared → web/shared}/exim.d.ts +0 -0
- /package/dist/{shared → web/shared}/lpc/listener.d.ts +0 -0
- /package/dist/{shared → web/shared}/lpc/pusher.d.ts +0 -0
- /package/dist/{shared → web/shared}/lpc/server.d.ts +0 -0
- /package/dist/{shared → web/shared}/storage/memory.d.ts +0 -0
- /package/dist/{state.d.ts → web/state.d.ts} +0 -0
- /package/dist/{stores → web/stores}/idb/dnlds.d.ts +0 -0
- /package/dist/{stores → web/stores}/idb/hosts.d.ts +0 -0
- /package/dist/{stores → web/stores}/idb/msgs.d.ts +0 -0
- /package/dist/{stores → web/stores}/idb/seed.d.ts +0 -0
- /package/dist/{stores → web/stores}/idb/store.d.ts +0 -0
- /package/dist/{stores → web/stores}/idb/uplds.d.ts +0 -0
- /package/dist/{stores → web/stores}/memory/dnlds.d.ts +0 -0
- /package/dist/{stores → web/stores}/memory/hosts.d.ts +0 -0
- /package/dist/{stores → web/stores}/memory/msgs.d.ts +0 -0
- /package/dist/{stores → web/stores}/memory/seed.d.ts +0 -0
- /package/dist/{stores → web/stores}/memory/store.d.ts +0 -0
- /package/dist/{stores → web/stores}/memory/uplds.d.ts +0 -0
- /package/dist/{sync.d.ts → web/sync.d.ts} +0 -0
- /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
|
-
|
|
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: "
|
|
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
|
|
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>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SyncClient } from "./client";
|
|
2
|
-
import
|
|
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,
|
|
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, };
|