@muhkoo/connect 0.14.0-alpha.9 → 0.15.0-alpha.1
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 +2 -2
- package/dist/browser/index.js +2422 -538
- package/dist/browser/index.js.map +1 -1
- package/dist/connect.d.ts +813 -43
- package/dist/connect.workers.d.ts +38 -1
- package/dist/server/index.js +2422 -538
- package/dist/server/index.js.map +1 -1
- package/dist/workers/index.js +111 -22
- package/dist/workers/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -514,20 +514,51 @@ interface DehydratedKeys {
|
|
|
514
514
|
ecdsaPub: string;
|
|
515
515
|
ecdsaPriv: string;
|
|
516
516
|
}
|
|
517
|
+
/** A member's own ECDH and ECDSA pairs, held outside the store until {@link KeyStore.replaceOwnKeyPair}. */
|
|
518
|
+
interface OwnKeyPair {
|
|
519
|
+
ecdh: KeyPair;
|
|
520
|
+
ecdsa: AuthKeyPair;
|
|
521
|
+
}
|
|
517
522
|
declare class KeyStore {
|
|
518
523
|
private static instance;
|
|
519
524
|
private _keys;
|
|
520
525
|
private _authKeys;
|
|
526
|
+
/** The exact pairs marked vault-backed, so a pair written over them later is never taken for them. */
|
|
527
|
+
private _vaultBacked;
|
|
521
528
|
private constructor();
|
|
522
529
|
static getInstance(): KeyStore;
|
|
523
530
|
get keys(): Map<string, KeyPair>;
|
|
524
531
|
get authKeys(): Map<string, AuthKeyPair>;
|
|
525
532
|
generateOwnKeyPair(id: string): Promise<KeyPair>;
|
|
526
533
|
storeRemotePublicKeys(id: string, ecdhPublicKey: CryptoKey, ecdsaPublicKey: CryptoKey): Promise<void>;
|
|
534
|
+
/** Generate an own pair without touching the store; {@link replaceOwnKeyPair} puts it in place. */
|
|
535
|
+
generateKeyPair(): Promise<OwnKeyPair>;
|
|
527
536
|
hydrateKeyPair(id: string, dehydrated: DehydratedKeys): Promise<void>;
|
|
537
|
+
/** Import a dehydrated pair without touching the store; {@link replaceOwnKeyPair} puts it in place. */
|
|
538
|
+
importKeyPair(dehydrated: DehydratedKeys): Promise<OwnKeyPair>;
|
|
528
539
|
getKeyPair(id: string): KeyPair | null;
|
|
529
540
|
getAuthKeyPair(id: string): AuthKeyPair | null;
|
|
541
|
+
/** Record that the pair `id` holds now came from the seed-wrapped vault (ChatKeyVault). */
|
|
542
|
+
markVaultBacked(id: string): void;
|
|
543
|
+
/**
|
|
544
|
+
* Put `pair` in place as `id`'s own pair and mark it vault-backed, in one
|
|
545
|
+
* synchronous step: whatever `id` held before is dropped, so a pair minted
|
|
546
|
+
* while the vault pair was being fetched or generated is never kept and
|
|
547
|
+
* marked in its place (design §3.3).
|
|
548
|
+
*/
|
|
549
|
+
replaceOwnKeyPair(id: string, pair: OwnKeyPair): void;
|
|
550
|
+
/**
|
|
551
|
+
* Whether `id`'s own pair was loaded from, or persisted to, the vault in this
|
|
552
|
+
* tab, and is still the very pair that was marked. A Space identity must be
|
|
553
|
+
* vault-backed (design §3.3): any other pair, such as one minted by a locked
|
|
554
|
+
* DM subscription, never takes part, even one that lands over the marked pair.
|
|
555
|
+
*/
|
|
556
|
+
isVaultBacked(id: string): boolean;
|
|
557
|
+
/** Drop every key held for `id` (SpecA §6.4 `KeyStore.forget`). */
|
|
558
|
+
forget(id: string): void;
|
|
530
559
|
dehydrateKeyPair(id: string): Promise<DehydratedKeys>;
|
|
560
|
+
/** Dehydrate a pair that is not (yet) in the store, in the same format as {@link dehydrateKeyPair}. */
|
|
561
|
+
exportKeyPair(pair: OwnKeyPair): Promise<DehydratedKeys>;
|
|
531
562
|
getRawEcdsaPublicKey(id: string): Promise<Uint8Array | null>;
|
|
532
563
|
packDehydratedKeys(id: string): Promise<string>;
|
|
533
564
|
hydrateFromPacked(id: string, masterKey: string): Promise<void>;
|
|
@@ -602,7 +633,6 @@ declare class DoubleRatchet {
|
|
|
602
633
|
private sessionType;
|
|
603
634
|
private maxSkip;
|
|
604
635
|
private overlapPeriod;
|
|
605
|
-
private windowSize;
|
|
606
636
|
constructor(senderId: string, recipientId: string, sessionType: 'global' | 'specific', isClient?: boolean);
|
|
607
637
|
private hkdf;
|
|
608
638
|
initializeSession(isClient?: boolean): Promise<void>;
|
|
@@ -965,6 +995,8 @@ interface WSTransportOptions {
|
|
|
965
995
|
* auto-response. Default `"pong"`.
|
|
966
996
|
*/
|
|
967
997
|
pongFrame?: string;
|
|
998
|
+
/** A close with one of these codes is terminal: no reconnect, `DISCONNECTED` carries `{code, reason}`; `resume()` restarts. */
|
|
999
|
+
terminalCloseCodes?: number[];
|
|
968
1000
|
}
|
|
969
1001
|
declare class WSTransport extends EventCore {
|
|
970
1002
|
/**
|
|
@@ -997,11 +1029,14 @@ declare class WSTransport extends EventCore {
|
|
|
997
1029
|
private pongFrame;
|
|
998
1030
|
private heartbeatTimer;
|
|
999
1031
|
private pongTimer;
|
|
1032
|
+
private readonly terminalCloseCodes;
|
|
1000
1033
|
constructor(opts: WSTransportOptions);
|
|
1001
1034
|
/** Open the socket. Resolves when CONNECTED fires. Rejects on first error. */
|
|
1002
1035
|
connect(): Promise<void>;
|
|
1003
1036
|
/** Close the socket and stop reconnecting. */
|
|
1004
1037
|
disconnect(): void;
|
|
1038
|
+
/** Restart reconnecting after a terminal close or `disconnect()`; the next URL comes from `urlProvider`. */
|
|
1039
|
+
resume(): void;
|
|
1005
1040
|
/**
|
|
1006
1041
|
* Send a raw frame. If currently disconnected, the frame is queued and sent
|
|
1007
1042
|
* after the next successful reconnect (up to `maxQueueSize`).
|
|
@@ -1115,6 +1150,8 @@ declare class BroadcastChannel {
|
|
|
1115
1150
|
connect(): Promise<void>;
|
|
1116
1151
|
/** Close the WebSocket and stop reconnecting. */
|
|
1117
1152
|
disconnect(): void;
|
|
1153
|
+
/** Reconnect after a terminal close (see `terminalCloseCodes`) or `disconnect()`, on a fresh `urlProvider` URL. */
|
|
1154
|
+
resume(): void;
|
|
1118
1155
|
/**
|
|
1119
1156
|
* Send our `keyExchange` frame to the room. Idempotent — only sends on the
|
|
1120
1157
|
* first call. Call this once your higher-level handshake (e.g. sending a
|