@interncom/diplomatic 0.2.5 → 0.2.7
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 +3 -3
- package/dist/cli/shared/events.d.ts +2 -0
- package/dist/cli/shared/singleton.d.ts +1 -0
- package/dist/cli/shared/types.d.ts +18 -2
- package/dist/web/client.d.ts +19 -2
- package/dist/web/coalesce.d.ts +24 -0
- package/dist/web/index.mjs +1 -1
- package/dist/web/shared/events.d.ts +2 -0
- package/dist/web/shared/singleton.d.ts +1 -0
- package/dist/web/shared/types.d.ts +18 -2
- package/dist/web/state.d.ts +4 -2
- package/dist/web/sync.d.ts +20 -5
- package/package.json +1 -1
|
@@ -48,8 +48,22 @@ export interface IStorage {
|
|
|
48
48
|
addUser: (pubKey: PublicKey) => Promise<ValStat<void>>;
|
|
49
49
|
hasUser: (pubKey: PublicKey) => Promise<ValStat<boolean>>;
|
|
50
50
|
subMeta: (pubKey: PublicKey) => Promise<ValStat<ISubscriptionMetadata>>;
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Store bags for a user. Returns host seq for each bag in order.
|
|
53
|
+
* Empty list succeeds with []. Implementations must assign contiguous
|
|
54
|
+
* seqs atomically (transaction / single batch) so concurrent writers
|
|
55
|
+
* cannot claim the same seq.
|
|
56
|
+
*/
|
|
57
|
+
setBags: (pubKey: PublicKey, bags: IBag[]) => Promise<ValStat<number[]>>;
|
|
58
|
+
/**
|
|
59
|
+
* Fetch ciphertext bodies for the given host seqs.
|
|
60
|
+
* Returns only seqs that exist (missing seqs are omitted, not an error).
|
|
61
|
+
* Empty `seqs` succeeds with [].
|
|
62
|
+
*/
|
|
63
|
+
getBodies: (pubKey: PublicKey, seqs: number[]) => Promise<ValStat<{
|
|
64
|
+
seq: number;
|
|
65
|
+
bodyCph: Uint8Array;
|
|
66
|
+
}[]>>;
|
|
53
67
|
listHeads: (pubKey: PublicKey, minSeq: number) => Promise<ValStat<IBagPeekItem[]>>;
|
|
54
68
|
}
|
|
55
69
|
export interface KeyPair {
|
|
@@ -151,6 +165,8 @@ export interface ITransport {
|
|
|
151
165
|
}
|
|
152
166
|
export interface IStateManager {
|
|
153
167
|
apply: (msgs: IMessage[]) => Promise<Status[]>;
|
|
168
|
+
/** Drop local application state (e.g. EntDB) and notify subscribers. */
|
|
169
|
+
clear: () => Promise<Status>;
|
|
154
170
|
on: (type: string, listener: () => void) => void;
|
|
155
171
|
off: (type: string, listener: () => void) => void;
|
|
156
172
|
}
|
package/dist/web/state.d.ts
CHANGED
|
@@ -6,10 +6,12 @@ export declare function isMsgEntBody(bodDec: unknown): bodDec is IMsgEntBody;
|
|
|
6
6
|
export declare function msgToOp(msg: IMessage): ValStat<IOp>;
|
|
7
7
|
export declare class StateManager implements IStateManager {
|
|
8
8
|
applier: Applier;
|
|
9
|
-
clear: () => Promise<Status>;
|
|
10
9
|
private emitter;
|
|
11
|
-
|
|
10
|
+
private clearer;
|
|
11
|
+
constructor(applier: Applier, clearer: () => Promise<Status>);
|
|
12
12
|
apply: (msgs: IMessage[]) => Promise<Status[]>;
|
|
13
|
+
/** Clear underlying store (e.g. EntDB) and notify all type subscribers. */
|
|
14
|
+
clear: () => Promise<Status>;
|
|
13
15
|
on: (opType: string, listener: () => void) => void;
|
|
14
16
|
off: (opType: string, listener: () => void) => void;
|
|
15
17
|
}
|
package/dist/web/sync.d.ts
CHANGED
|
@@ -2,8 +2,12 @@ import DiplomaticClientAPI from "./shared/client";
|
|
|
2
2
|
import { IClock } from "./shared/clock";
|
|
3
3
|
import { Status } from "./shared/consts";
|
|
4
4
|
import { Enclave } from "./shared/enclave";
|
|
5
|
-
import { HostHandle, ICrypto } from "./shared/types";
|
|
6
|
-
import { IHostRow, IMsgParts, IStore, IStoredMessageData } from "./types";
|
|
5
|
+
import { Hash, HostHandle, IBag, ICrypto } from "./shared/types";
|
|
6
|
+
import { IDownloadMessage, IHostRow, IMsgParts, IStore, IStoredMessageData } from "./types";
|
|
7
|
+
/** Default soft cap for one push/pull request (~1 MiB). Apps with large
|
|
8
|
+
* payloads (e.g. media) should raise maxPushBytes / maxPullBytes. */
|
|
9
|
+
export declare const defaultMaxPushBytes: number;
|
|
10
|
+
export declare const defaultMaxPullBytes: number;
|
|
7
11
|
export interface ISyncParams<Handle extends HostHandle> {
|
|
8
12
|
conn: DiplomaticClientAPI<Handle>;
|
|
9
13
|
store: IStore<Handle>;
|
|
@@ -11,15 +15,26 @@ export interface ISyncParams<Handle extends HostHandle> {
|
|
|
11
15
|
clock: IClock;
|
|
12
16
|
host: IHostRow<Handle>;
|
|
13
17
|
crypto: ICrypto;
|
|
18
|
+
/** Soft max sealed-bag bytes per push request. Oversized bags go alone. */
|
|
19
|
+
maxPushBytes?: number;
|
|
20
|
+
/** Soft max body bytes (head.len) per pull request. Oversized items go alone. */
|
|
21
|
+
maxPullBytes?: number;
|
|
14
22
|
}
|
|
23
|
+
/** Push one batch of sealed bags; deq successes; advance lastSeq from store. */
|
|
24
|
+
export declare function pushBatch<Handle extends HostHandle>(conn: Pick<DiplomaticClientAPI<Handle>, "push">, store: IStore<Handle>, hostLabel: string, bags: IBag[], hashes: Hash[]): Promise<Status>;
|
|
25
|
+
/** Pull one batch of download-queue items; store, deq, apply. */
|
|
26
|
+
export declare function pullBatch<Handle extends HostHandle>(conn: Pick<DiplomaticClientAPI<Handle>, "pull">, store: IStore<Handle>, enclave: Enclave, hostLabel: string, crypto: ICrypto, items: IDownloadMessage[], apply: (parts: IMsgParts[], options?: {
|
|
27
|
+
enqueueUpload: boolean;
|
|
28
|
+
triggerUpload: boolean;
|
|
29
|
+
}) => Promise<Status[]>): Promise<Status>;
|
|
15
30
|
export declare function syncPeek<Handle extends HostHandle>({ conn, store, enclave, host, crypto }: ISyncParams<Handle>): Promise<Status>;
|
|
16
|
-
export declare function syncPush<Handle extends HostHandle>({ conn, store, host }: ISyncParams<Handle>): Promise<Status>;
|
|
17
|
-
export declare function syncPull<Handle extends HostHandle>({ conn, store, enclave, host, crypto }: ISyncParams<Handle>, apply: (parts: IMsgParts[], options?: {
|
|
31
|
+
export declare function syncPush<Handle extends HostHandle>({ conn, store, host, maxPushBytes }: ISyncParams<Handle>): Promise<Status>;
|
|
32
|
+
export declare function syncPull<Handle extends HostHandle>({ conn, store, enclave, host, crypto, maxPullBytes }: ISyncParams<Handle>, apply: (parts: IMsgParts[], options?: {
|
|
18
33
|
enqueueUpload: boolean;
|
|
19
34
|
triggerUpload: boolean;
|
|
20
35
|
}) => Promise<Status[]>): Promise<Status>;
|
|
21
36
|
export declare function msg2StoredMsgData({ head, body }: IMsgParts): IStoredMessageData;
|
|
22
|
-
export declare function handleNotif<Handle extends HostHandle>(bytes: Uint8Array, { conn, store, enclave, host, crypto, clock }: ISyncParams<Handle>, apply: (parts: IMsgParts[], options?: {
|
|
37
|
+
export declare function handleNotif<Handle extends HostHandle>(bytes: Uint8Array, { conn, store, enclave, host, crypto, clock, maxPullBytes, maxPushBytes, }: ISyncParams<Handle>, apply: (parts: IMsgParts[], options?: {
|
|
23
38
|
enqueueUpload: boolean;
|
|
24
39
|
triggerUpload: boolean;
|
|
25
40
|
}) => Promise<Status[]>, scheduleSync: () => void): Promise<void>;
|