@interncom/diplomatic 0.3.4 → 0.4.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/dist/web/batch.d.ts +7 -0
- package/dist/web/client.d.ts +14 -20
- package/dist/web/index.mjs +1 -1
- package/dist/web/progress.d.ts +1 -1
- package/dist/web/sync.d.ts +36 -16
- package/dist/web/worker.mjs +1 -1
- package/package.json +1 -1
package/dist/web/progress.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
*
|
|
3
3
|
* Exposed only via `IDiplomaticClientXferState.progress` on `client.xferState`
|
|
4
4
|
* (get + listen / `useClientXferState`). There is no separate progress channel. */
|
|
5
|
-
export type SyncPhase = "peek" | "
|
|
5
|
+
export type SyncPhase = "peek" | "pull" | "open" | "exec" | "push" | "import" | "idle";
|
|
6
6
|
export interface SyncProgressEvent {
|
|
7
7
|
phase: SyncPhase;
|
|
8
8
|
/** Host label when the work is host-scoped. */
|
package/dist/web/sync.d.ts
CHANGED
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
import DiplomaticClientAPI from "./shared/client";
|
|
2
|
-
import { IClock } from "./shared/clock";
|
|
3
2
|
import { Status } from "./shared/consts";
|
|
4
3
|
import { Enclave } from "./shared/enclave";
|
|
5
4
|
import { Hash, HostHandle, IBag, ICrypto } from "./shared/types";
|
|
5
|
+
import { ValStat } from "./shared/valstat";
|
|
6
6
|
import { ProgressFn } from "./progress";
|
|
7
7
|
import { IDownloadMessage, IHostRow, IMsgParts, IStore, type IStoredMessageWrite } from "./types";
|
|
8
8
|
/** Default soft cap for one push/pull request (~1 MiB). Apps with large
|
|
9
9
|
* payloads (e.g. media) should raise maxPushBytes / maxPullBytes. */
|
|
10
10
|
export declare const defaultMaxPushBytes: number;
|
|
11
11
|
export declare const defaultMaxPullBytes: number;
|
|
12
|
+
/** Pull result held in memory until open (not durable). */
|
|
13
|
+
export type IPulled = {
|
|
14
|
+
dl: IDownloadMessage;
|
|
15
|
+
bodyCph?: Uint8Array;
|
|
16
|
+
};
|
|
17
|
+
/** Host connection methods used by sync phases. */
|
|
18
|
+
export type SyncConn<Handle extends HostHandle> = Pick<DiplomaticClientAPI<Handle>, "pull" | "push" | "peek" | "seal" | "keys">;
|
|
12
19
|
export interface ISyncParams<Handle extends HostHandle> {
|
|
13
|
-
conn:
|
|
20
|
+
conn: SyncConn<Handle>;
|
|
14
21
|
store: IStore<Handle>;
|
|
15
22
|
enclave: Enclave;
|
|
16
|
-
clock: IClock;
|
|
17
23
|
host: IHostRow<Handle>;
|
|
18
24
|
crypto: ICrypto;
|
|
19
25
|
/** Soft max sealed-bag bytes per push request. Oversized bags go alone. */
|
|
@@ -27,19 +33,33 @@ export interface ISyncParams<Handle extends HostHandle> {
|
|
|
27
33
|
}
|
|
28
34
|
/** Push one batch of sealed bags; deq successes; advance lastSeq from store. */
|
|
29
35
|
export declare function pushBatch<Handle extends HostHandle>(conn: Pick<DiplomaticClientAPI<Handle>, "push">, store: IStore<Handle>, hostLabel: string, bags: IBag[], hashes: Hash[]): Promise<Status>;
|
|
30
|
-
/**
|
|
31
|
-
export declare function
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
/** pull: network only. Download-queue items → ciphertext (still enqueued). */
|
|
37
|
+
export declare function pullBodies<Handle extends HostHandle>(conn: Pick<DiplomaticClientAPI<Handle>, "pull">, items: IDownloadMessage[]): Promise<ValStat<IPulled[]>>;
|
|
38
|
+
export type IOpened = {
|
|
39
|
+
parts: IMsgParts[];
|
|
40
|
+
hashes: Hash[];
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* open: decrypt pulled bodies → msg archive (apld=false), deq downloads.
|
|
44
|
+
* Bad bags are dequeued and skipped (not retry-able).
|
|
45
|
+
* Does not exec or push.
|
|
46
|
+
*/
|
|
47
|
+
export declare function openPulled<Handle extends HostHandle>(store: IStore<Handle>, enclave: Enclave, crypto: ICrypto, items: IPulled[]): Promise<ValStat<IOpened>>;
|
|
48
|
+
/** Discover unseen bags and enqueue download work; advance host lastSeq. */
|
|
35
49
|
export declare function syncPeek<Handle extends HostHandle>({ conn, store, enclave, host, crypto, onProgress, peekProgressEvery, }: ISyncParams<Handle>): Promise<Status>;
|
|
50
|
+
/** Seal and upload pending msgs; list once so concurrent enqs wait for next sync. */
|
|
36
51
|
export declare function syncPush<Handle extends HostHandle>({ conn, store, host, maxPushBytes, onProgress }: ISyncParams<Handle>): Promise<Status>;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Pull + open for one host, depth-1 pipelined:
|
|
54
|
+
* await pull(i); start pull(i+1); open(i); afterOpen? (exec)
|
|
55
|
+
* Ciphertext only in the in-flight Promise, never IDB.
|
|
56
|
+
*/
|
|
57
|
+
export declare function syncPull<Handle extends HostHandle>({ conn, store, enclave, host, crypto, maxPullBytes, onProgress, }: ISyncParams<Handle>,
|
|
58
|
+
/** After each opened pull batch (e.g. drainApplyQueue / exec). */
|
|
59
|
+
afterOpen?: () => Promise<void>): Promise<Status>;
|
|
41
60
|
export declare function msg2StoredMsgData({ head, body }: IMsgParts): IStoredMessageWrite;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
61
|
+
/**
|
|
62
|
+
* notif → open inline bodies into archive; enq incomplete → scheduleSync.
|
|
63
|
+
* `scheduleSync` runs full peek/push/pull (or worker handoff).
|
|
64
|
+
*/
|
|
65
|
+
export declare function handleNotif<Handle extends HostHandle>(bytes: Uint8Array, { conn, store, enclave, host, crypto, onProgress, }: ISyncParams<Handle>, scheduleSync: () => void): Promise<void>;
|