@interncom/diplomatic 0.0.74 → 0.1.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.
- package/README.md +12 -6
- package/dist/client.d.ts +43 -56
- package/dist/entdb/entdb.d.ts +36 -0
- package/dist/entdb/idb.d.ts +27 -0
- package/dist/entdb/memory.d.ts +30 -0
- package/dist/events.d.ts +18 -0
- package/dist/exim.d.ts +0 -0
- package/dist/index.d.ts +23 -14
- package/dist/index.mjs +6210 -6767
- package/dist/lib.d.ts +2 -0
- package/dist/react/useClient.d.ts +5 -4
- package/dist/react/useEntities.d.ts +0 -0
- package/dist/react/useStateWatcher.d.ts +3 -3
- package/dist/shared/api/peek.d.ts +3 -0
- package/dist/shared/api/pull.d.ts +3 -0
- package/dist/shared/api/push.d.ts +4 -0
- package/dist/shared/api/user.d.ts +2 -0
- package/dist/shared/auth.d.ts +8 -0
- package/dist/shared/bag.d.ts +16 -0
- package/dist/shared/binary.d.ts +8 -0
- package/dist/shared/client.d.ts +20 -9
- package/dist/shared/clock.d.ts +13 -0
- package/dist/shared/codec.d.ts +43 -0
- package/dist/shared/codecs/authTimestamp.d.ts +8 -0
- package/dist/shared/codecs/bag.d.ts +3 -0
- package/dist/shared/codecs/eid.d.ts +10 -0
- package/dist/shared/codecs/file.d.ts +8 -0
- package/dist/shared/codecs/fileHead.d.ts +10 -0
- package/dist/shared/codecs/fileIndexItem.d.ts +8 -0
- package/dist/shared/codecs/messageHead.d.ts +16 -0
- package/dist/shared/codecs/notifItem.d.ts +7 -0
- package/dist/shared/codecs/peekItem.d.ts +6 -0
- package/dist/shared/codecs/peekItemHead.d.ts +7 -0
- package/dist/shared/codecs/pullItem.d.ts +6 -0
- package/dist/shared/codecs/pushItem.d.ts +11 -0
- package/dist/shared/codecs/respHead.d.ts +10 -0
- package/dist/shared/codecs/usageQuota.d.ts +6 -0
- package/dist/shared/consts.d.ts +50 -0
- package/dist/shared/crypto/libsodium.d.ts +5 -5
- package/dist/shared/enclave.d.ts +8 -0
- package/dist/shared/endpoint.d.ts +23 -0
- package/dist/shared/exim.d.ts +12 -0
- package/dist/shared/http/listener.d.ts +11 -0
- package/dist/shared/http/server.d.ts +11 -0
- package/dist/shared/http.d.ts +81 -0
- package/dist/shared/lpc/listener.d.ts +16 -0
- package/dist/shared/lpc/pusher.d.ts +9 -0
- package/dist/shared/lpc/server.d.ts +19 -0
- package/dist/shared/message.d.ts +30 -0
- package/dist/shared/storage/memory.d.ts +10 -0
- package/dist/shared/types.d.ts +127 -49
- package/dist/shared/valstat.d.ts +6 -0
- package/dist/state.d.ts +12 -17
- package/dist/stores/idb/dnlds.d.ts +10 -0
- package/dist/stores/idb/hosts.d.ts +15 -0
- package/dist/stores/idb/msgs.d.ts +19 -0
- package/dist/stores/idb/seed.d.ts +11 -0
- package/dist/stores/idb/store.d.ts +23 -0
- package/dist/stores/idb/uplds.d.ts +11 -0
- package/dist/stores/memory/dnlds.d.ts +9 -0
- package/dist/stores/memory/hosts.d.ts +13 -0
- package/dist/stores/memory/msgs.d.ts +19 -0
- package/dist/stores/memory/seed.d.ts +9 -0
- package/dist/stores/memory/store.d.ts +16 -0
- package/dist/stores/memory/uplds.d.ts +10 -0
- package/dist/sync.d.ts +32 -2
- package/dist/types.d.ts +113 -29
- package/package.json +9 -6
- package/dist/api.d.ts +0 -3
- package/dist/entityDB.d.ts +0 -34
- package/dist/eventEmitter.d.ts +0 -8
- package/dist/idbStore.d.ts +0 -38
- package/dist/localStorageStore.d.ts +0 -36
- package/dist/memoryStore.d.ts +0 -40
- package/dist/queue.d.ts +0 -10
- package/dist/react/initSeedView.d.ts +0 -7
- package/dist/react/statusBar.d.ts +0 -7
- package/dist/shared/lib.d.ts +0 -2
- package/dist/shared/ops.d.ts +0 -4
- package/dist/shared/server.d.ts +0 -12
- package/dist/typedEventEmitter.d.ts +0 -8
- package/dist/useClient.d.ts +0 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@interncom/diplomatic",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Secure sync layer",
|
|
6
6
|
"main": "dist/index.mjs",
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
"scripts": {
|
|
12
12
|
"tsc": "tsc",
|
|
13
13
|
"build": "node esbuild.mjs",
|
|
14
|
-
"test": "vitest"
|
|
14
|
+
"test": "vitest",
|
|
15
|
+
"coverage": "vitest run --coverage",
|
|
16
|
+
"fmt": "deno fmt"
|
|
15
17
|
},
|
|
16
18
|
"author": "The Internet Committee",
|
|
17
19
|
"license": "ISC",
|
|
@@ -22,18 +24,19 @@
|
|
|
22
24
|
"@types/file-saver": "^2.0.7",
|
|
23
25
|
"@types/node": "^20.14.11",
|
|
24
26
|
"@types/react": "^19.1.0",
|
|
27
|
+
"@vitest/coverage-v8": "^4.0.17",
|
|
25
28
|
"esbuild": "0.21.5",
|
|
26
29
|
"react": "^19.1.0",
|
|
27
30
|
"typescript": "^5.8.3",
|
|
28
|
-
"vitest": "^
|
|
31
|
+
"vitest": "^4.0.17"
|
|
29
32
|
},
|
|
30
33
|
"peerDependencies": {
|
|
31
34
|
"react": "^19.0.0"
|
|
32
35
|
},
|
|
33
36
|
"dependencies": {
|
|
34
37
|
"@msgpack/msgpack": "^3.0.0-beta2",
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
+
"@noble/hashes": "1.8.0",
|
|
39
|
+
"file-saver": "2.0.5",
|
|
40
|
+
"libsodium.js": "git+ssh://github.com/interncom/libsodium.js#e4e7647"
|
|
38
41
|
}
|
|
39
42
|
}
|
package/dist/api.d.ts
DELETED
package/dist/entityDB.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { type DBSchema } from "idb";
|
|
2
|
-
import type { Applier } from "./types";
|
|
3
|
-
import { type EntityID, type GroupID } from "./shared/types";
|
|
4
|
-
import { StateManager } from "./state";
|
|
5
|
-
export declare const entityTableName = "entities";
|
|
6
|
-
export declare const typeIndexName = "entity_type_created_at";
|
|
7
|
-
export declare const typeUpdatedAtIndexName = "entity_type_updated_at";
|
|
8
|
-
export declare const typeGroupIndexName = "entity_type_group_id";
|
|
9
|
-
export declare const typeParentIndexName = "entity_type_parent_id";
|
|
10
|
-
export interface IEntity<T> {
|
|
11
|
-
eid: EntityID;
|
|
12
|
-
gid?: GroupID;
|
|
13
|
-
pid?: EntityID;
|
|
14
|
-
type: string;
|
|
15
|
-
updatedAt: Date;
|
|
16
|
-
createdAt: Date;
|
|
17
|
-
body: T;
|
|
18
|
-
}
|
|
19
|
-
interface IEntityDB extends DBSchema {
|
|
20
|
-
entities: {
|
|
21
|
-
key: Uint8Array;
|
|
22
|
-
value: IEntity<unknown>;
|
|
23
|
-
indexes: {
|
|
24
|
-
[typeIndexName]: [string, Date];
|
|
25
|
-
[typeUpdatedAtIndexName]: [string, Date];
|
|
26
|
-
[typeGroupIndexName]: [string, GroupID];
|
|
27
|
-
[typeParentIndexName]: [string, EntityID];
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
export declare const db: import("idb").IDBPDatabase<IEntityDB>;
|
|
32
|
-
export declare const applier: Applier;
|
|
33
|
-
export declare const stateManager: StateManager;
|
|
34
|
-
export {};
|
package/dist/eventEmitter.d.ts
DELETED
package/dist/idbStore.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { IClientStateStore } from "./types";
|
|
2
|
-
declare class IDBStore implements IClientStateStore {
|
|
3
|
-
seed?: Uint8Array;
|
|
4
|
-
hostURL?: string;
|
|
5
|
-
hostID?: string;
|
|
6
|
-
lastFetchedAt?: Date;
|
|
7
|
-
wipe(): Promise<void>;
|
|
8
|
-
getSeed(): Promise<Uint8Array<ArrayBufferLike> | undefined>;
|
|
9
|
-
setSeed(seed: Uint8Array): Promise<void>;
|
|
10
|
-
getHostURL(): Promise<string | undefined>;
|
|
11
|
-
setHostURL(url: string): Promise<void>;
|
|
12
|
-
getHostID(): Promise<string | undefined>;
|
|
13
|
-
setHostID(id: string): Promise<void>;
|
|
14
|
-
getLastFetchedAt(): Promise<Date | undefined>;
|
|
15
|
-
setLastFetchedAt(ts: Date): Promise<void>;
|
|
16
|
-
enqueueUpload: (sha256: Uint8Array, cipherOp: Uint8Array) => Promise<void>;
|
|
17
|
-
dequeueUpload: (sha256: Uint8Array) => Promise<void>;
|
|
18
|
-
peekUpload: (sha256: Uint8Array) => Promise<Uint8Array<ArrayBufferLike> | undefined>;
|
|
19
|
-
listUploads: () => Promise<Uint8Array<ArrayBufferLike>[]>;
|
|
20
|
-
numUploads: () => Promise<number>;
|
|
21
|
-
downloadQueue: Set<string>;
|
|
22
|
-
enqueueDownload: (sha256: Uint8Array, recordedAt: Date) => Promise<void>;
|
|
23
|
-
dequeueDownload: (sha256: Uint8Array) => Promise<void>;
|
|
24
|
-
listDownloads: () => Promise<{
|
|
25
|
-
sha256: Uint8Array<ArrayBufferLike>;
|
|
26
|
-
recordedAt: Date;
|
|
27
|
-
}[]>;
|
|
28
|
-
numDownloads: () => Promise<number>;
|
|
29
|
-
storeOp: (sha256: Uint8Array, cipherOp: Uint8Array) => Promise<void>;
|
|
30
|
-
clearOp: (sha256: Uint8Array) => Promise<void>;
|
|
31
|
-
listOps: () => Promise<{
|
|
32
|
-
sha256: string;
|
|
33
|
-
cipherOp: Uint8Array<ArrayBufferLike>;
|
|
34
|
-
}[]>;
|
|
35
|
-
hasOp: (sha256: Uint8Array) => Promise<boolean>;
|
|
36
|
-
}
|
|
37
|
-
export declare const idbStore: IDBStore;
|
|
38
|
-
export {};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { IClientStateStore } from "./types";
|
|
2
|
-
declare class LocalStorageStore implements IClientStateStore {
|
|
3
|
-
wipe(): Promise<void>;
|
|
4
|
-
getSeed(): Promise<Uint8Array<ArrayBufferLike> | undefined>;
|
|
5
|
-
setSeed(seed: Uint8Array): Promise<void>;
|
|
6
|
-
getHostURL(): Promise<string | undefined>;
|
|
7
|
-
setHostURL(url: string): Promise<void>;
|
|
8
|
-
getHostID(): Promise<string | undefined>;
|
|
9
|
-
setHostID(id: string): Promise<void>;
|
|
10
|
-
getLastFetchedAt(): Promise<Date | undefined>;
|
|
11
|
-
setLastFetchedAt(ts: Date): Promise<void>;
|
|
12
|
-
uploadQueue: Map<string, Uint8Array<ArrayBufferLike>>;
|
|
13
|
-
enqueueUpload: (sha256: Uint8Array, cipherOp: Uint8Array) => Promise<void>;
|
|
14
|
-
dequeueUpload: (sha256: Uint8Array) => Promise<void>;
|
|
15
|
-
peekUpload: (sha256: Uint8Array) => Promise<Uint8Array<ArrayBufferLike> | undefined>;
|
|
16
|
-
listUploads: () => Promise<Uint8Array<ArrayBufferLike>[]>;
|
|
17
|
-
numUploads: () => Promise<number>;
|
|
18
|
-
downloadQueue: Map<string, Date>;
|
|
19
|
-
enqueueDownload: (sha256: Uint8Array, recordedAt: Date) => Promise<void>;
|
|
20
|
-
dequeueDownload: (sha256: Uint8Array) => Promise<void>;
|
|
21
|
-
listDownloads: () => Promise<{
|
|
22
|
-
sha256: Uint8Array<ArrayBufferLike>;
|
|
23
|
-
recordedAt: Date;
|
|
24
|
-
}[]>;
|
|
25
|
-
numDownloads: () => Promise<number>;
|
|
26
|
-
ops: Map<string, Uint8Array<ArrayBufferLike>>;
|
|
27
|
-
storeOp: (sha256: Uint8Array, cipherOp: Uint8Array) => Promise<void>;
|
|
28
|
-
clearOp: (sha256: Uint8Array) => Promise<void>;
|
|
29
|
-
listOps: () => Promise<{
|
|
30
|
-
sha256: string;
|
|
31
|
-
cipherOp: Uint8Array<ArrayBufferLike>;
|
|
32
|
-
}[]>;
|
|
33
|
-
hasOp: (sha256: Uint8Array) => Promise<boolean>;
|
|
34
|
-
}
|
|
35
|
-
export declare const localStorageStore: LocalStorageStore;
|
|
36
|
-
export {};
|
package/dist/memoryStore.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { IClientStateStore } from "./types";
|
|
2
|
-
declare class MemoryStore implements IClientStateStore {
|
|
3
|
-
seed?: Uint8Array;
|
|
4
|
-
hostURL?: string;
|
|
5
|
-
hostID?: string;
|
|
6
|
-
lastFetchedAt?: Date;
|
|
7
|
-
wipe(): Promise<void>;
|
|
8
|
-
getSeed(): Promise<Uint8Array<ArrayBufferLike> | undefined>;
|
|
9
|
-
setSeed(seed: Uint8Array): Promise<void>;
|
|
10
|
-
getHostURL(): Promise<string | undefined>;
|
|
11
|
-
setHostURL(url: string): Promise<void>;
|
|
12
|
-
getHostID(): Promise<string | undefined>;
|
|
13
|
-
setHostID(id: string): Promise<void>;
|
|
14
|
-
getLastFetchedAt(): Promise<Date | undefined>;
|
|
15
|
-
setLastFetchedAt(ts: Date): Promise<void>;
|
|
16
|
-
uploadQueue: Map<string, Uint8Array<ArrayBufferLike>>;
|
|
17
|
-
enqueueUpload: (sha256: Uint8Array, cipherOp: Uint8Array) => Promise<void>;
|
|
18
|
-
dequeueUpload: (sha256: Uint8Array) => Promise<void>;
|
|
19
|
-
peekUpload: (sha256: Uint8Array) => Promise<Uint8Array<ArrayBufferLike> | undefined>;
|
|
20
|
-
listUploads: () => Promise<Uint8Array<ArrayBufferLike>[]>;
|
|
21
|
-
numUploads: () => Promise<number>;
|
|
22
|
-
downloadQueue: Map<string, Date>;
|
|
23
|
-
enqueueDownload: (sha256: Uint8Array, recordedAt: Date) => Promise<void>;
|
|
24
|
-
dequeueDownload: (sha256: Uint8Array) => Promise<void>;
|
|
25
|
-
listDownloads: () => Promise<{
|
|
26
|
-
sha256: Uint8Array<ArrayBufferLike>;
|
|
27
|
-
recordedAt: Date;
|
|
28
|
-
}[]>;
|
|
29
|
-
numDownloads: () => Promise<number>;
|
|
30
|
-
ops: Map<string, Uint8Array<ArrayBufferLike>>;
|
|
31
|
-
storeOp: (sha256: Uint8Array, cipherOp: Uint8Array) => Promise<void>;
|
|
32
|
-
clearOp: (sha256: Uint8Array) => Promise<void>;
|
|
33
|
-
listOps: () => Promise<{
|
|
34
|
-
sha256: string;
|
|
35
|
-
cipherOp: Uint8Array<ArrayBufferLike>;
|
|
36
|
-
}[]>;
|
|
37
|
-
hasOp: (sha256: Uint8Array) => Promise<boolean>;
|
|
38
|
-
}
|
|
39
|
-
export declare const memoryStore: MemoryStore;
|
|
40
|
-
export {};
|
package/dist/queue.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { IQueue } from "./types";
|
|
2
|
-
export declare class Queue<K, V> implements IQueue<K, V> {
|
|
3
|
-
private map;
|
|
4
|
-
constructor();
|
|
5
|
-
enqueue(key: K, value: V): Promise<void>;
|
|
6
|
-
peek(key: K): Promise<V | undefined>;
|
|
7
|
-
entries(): Promise<Array<[K, V]>>;
|
|
8
|
-
dequeue(key: K): Promise<V | undefined>;
|
|
9
|
-
size(): Promise<number>;
|
|
10
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { IDiplomaticClientState, IDiplomaticClientXferState } from "../types";
|
|
2
|
-
interface IProps {
|
|
3
|
-
state: IDiplomaticClientState;
|
|
4
|
-
xferState: IDiplomaticClientXferState;
|
|
5
|
-
}
|
|
6
|
-
export default function ClientStatusBar({ state, xferState }: IProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
export {};
|
package/dist/shared/lib.d.ts
DELETED
package/dist/shared/ops.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { type EntityID, type GroupID, type IDeleteOp, type IOp, type IUpsertOp } from "./types.ts";
|
|
2
|
-
export declare function genUpsertOp<T>(eid: EntityID, type: string, body: T, version?: number, gid?: GroupID, pid?: EntityID): IUpsertOp;
|
|
3
|
-
export declare function genDeleteOp<T>(eid: Uint8Array, type: string, version?: number): IDeleteOp;
|
|
4
|
-
export declare function isOp(op: any): op is IOp;
|
package/dist/shared/server.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { IHostCrypto, IMsgpackCodec, IStorage, IWebsocketNotifier } from "./types.ts";
|
|
2
|
-
export declare class DiplomaticServer {
|
|
3
|
-
hostID: string;
|
|
4
|
-
regToken: string;
|
|
5
|
-
storage: IStorage;
|
|
6
|
-
codec: IMsgpackCodec;
|
|
7
|
-
crypto: IHostCrypto;
|
|
8
|
-
notifier: IWebsocketNotifier;
|
|
9
|
-
constructor(hostID: string, regToken: string, storage: IStorage, codec: IMsgpackCodec, crypto: IHostCrypto, notifier: IWebsocketNotifier);
|
|
10
|
-
corsHandler: (request: Request) => Promise<Response>;
|
|
11
|
-
handler: (request: Request) => Promise<Response>;
|
|
12
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
type Listener<T> = (data: T) => void;
|
|
2
|
-
export default class TypedEventEmitter<T> {
|
|
3
|
-
private listeners;
|
|
4
|
-
addEventListener(eventType: string, listener: Listener<T>): () => void;
|
|
5
|
-
removeEventListener(eventType: string, listener: Listener<T>): void;
|
|
6
|
-
emit(eventType: string, data: T): void;
|
|
7
|
-
}
|
|
8
|
-
export {};
|
package/dist/useClient.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { IDiplomaticClientState } from "./types";
|
|
2
|
-
import type DiplomaticClient from "./client";
|
|
3
|
-
export declare function useClientState(client: DiplomaticClient): IDiplomaticClientState | undefined;
|
|
4
|
-
export declare function useSyncOnResume(client: DiplomaticClient): void;
|