@ghostlytools/sdk 0.0.0-stage → 1.2.3
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 +13 -2
- package/dist/app.js +67 -0
- package/dist/app.js.map +1 -0
- package/dist/core.js +207 -0
- package/dist/core.js.map +1 -0
- package/dist/fakes-CBIuqo5e.js +536 -0
- package/dist/fakes-CBIuqo5e.js.map +1 -0
- package/dist/fakes.js +2 -0
- package/dist/index.js +179 -0
- package/dist/index.js.map +1 -0
- package/dist/keet-identity-key-BylxCPl4.js +76483 -0
- package/dist/keet-identity-key-BylxCPl4.js.map +1 -0
- package/dist/src-DCeLPsi-.js +31056 -0
- package/dist/src-DCeLPsi-.js.map +1 -0
- package/dist/testing.js +330 -0
- package/dist/testing.js.map +1 -0
- package/dist/types/browser/src/engine/paymentAdapters/providers/contractSuite.d.ts +41 -0
- package/dist/types/browser/src/engine/paymentAdapters/providers/lightning.d.ts +103 -0
- package/dist/types/browser/src/engine/paymentAdapters/providers/onchain.d.ts +88 -0
- package/dist/types/browser/src/engine/paymentAdapters/providers/testing.d.ts +89 -0
- package/dist/types/browser/src/engine/paymentAdapters/providers/types.d.ts +151 -0
- package/dist/types/browser/src/plugins/bundled.d.ts +8 -0
- package/dist/types/browser/src/plugins/registry.d.ts +57 -0
- package/dist/types/browser/src/proofs/contract.d.ts +262 -0
- package/dist/types/browser/src/proofs/contractSuite.d.ts +27 -0
- package/dist/types/browser/src/proofs/testing.d.ts +36 -0
- package/dist/types/browser/src/proofs/verify.d.ts +23 -0
- package/dist/types/browser/src/shared/mints.d.ts +50 -0
- package/dist/types/core/src/appBundle.d.ts +173 -0
- package/dist/types/core/src/appStatements.d.ts +142 -0
- package/dist/types/core/src/appStore.d.ts +133 -0
- package/dist/types/core/src/appUpdates.d.ts +88 -0
- package/dist/types/core/src/atprotoIdentity.d.ts +49 -0
- package/dist/types/core/src/atprotoRepo.d.ts +101 -0
- package/dist/types/core/src/avatar.d.ts +19 -0
- package/dist/types/core/src/bip322.d.ts +57 -0
- package/dist/types/core/src/bitcoinAddress.d.ts +5 -0
- package/dist/types/core/src/bitcoinMessage.d.ts +15 -0
- package/dist/types/core/src/bitcoinScript.d.ts +69 -0
- package/dist/types/core/src/bolt11.d.ts +30 -0
- package/dist/types/core/src/bytes.d.ts +11 -0
- package/dist/types/core/src/callSignal.d.ts +232 -0
- package/dist/types/core/src/canonicalJson.d.ts +22 -0
- package/dist/types/core/src/capsRecord.d.ts +234 -0
- package/dist/types/core/src/catchUp.d.ts +45 -0
- package/dist/types/core/src/chatFiles.d.ts +271 -0
- package/dist/types/core/src/clockWatch.d.ts +72 -0
- package/dist/types/core/src/communityRendezvous.d.ts +113 -0
- package/dist/types/core/src/crypto.d.ts +10 -0
- package/dist/types/core/src/datalink.d.ts +187 -0
- package/dist/types/core/src/deviceInvite.d.ts +51 -0
- package/dist/types/core/src/deviceLink.d.ts +70 -0
- package/dist/types/core/src/dhtDelivery.d.ts +403 -0
- package/dist/types/core/src/dhtFiles.d.ts +46 -0
- package/dist/types/core/src/did.d.ts +134 -0
- package/dist/types/core/src/didDht.d.ts +155 -0
- package/dist/types/core/src/directPath.d.ts +63 -0
- package/dist/types/core/src/dns.d.ts +41 -0
- package/dist/types/core/src/domainProofs.d.ts +88 -0
- package/dist/types/core/src/engineErrors.d.ts +90 -0
- package/dist/types/core/src/enroll.d.ts +98 -0
- package/dist/types/core/src/files.d.ts +73 -0
- package/dist/types/core/src/forwards.d.ts +12 -0
- package/dist/types/core/src/frames.d.ts +211 -0
- package/dist/types/core/src/ghostlink.d.ts +1510 -0
- package/dist/types/core/src/groupCommits.d.ts +103 -0
- package/dist/types/core/src/groupCommunity.d.ts +714 -0
- package/dist/types/core/src/groupCrypto.d.ts +60 -0
- package/dist/types/core/src/groupEdits.d.ts +67 -0
- package/dist/types/core/src/groupEntry.d.ts +61 -0
- package/dist/types/core/src/groupFiles.d.ts +106 -0
- package/dist/types/core/src/groupHubs.d.ts +61 -0
- package/dist/types/core/src/groupMentions.d.ts +27 -0
- package/dist/types/core/src/groupMeta.d.ts +162 -0
- package/dist/types/core/src/groupSession.d.ts +710 -0
- package/dist/types/core/src/groupSignals.d.ts +167 -0
- package/dist/types/core/src/groupTyping.d.ts +56 -0
- package/dist/types/core/src/groupWake.d.ts +68 -0
- package/dist/types/core/src/handoff.d.ts +255 -0
- package/dist/types/core/src/http.d.ts +125 -0
- package/dist/types/core/src/identity.d.ts +17 -0
- package/dist/types/core/src/identityProofs.d.ts +243 -0
- package/dist/types/core/src/identityTimeline.d.ts +72 -0
- package/dist/types/core/src/image.d.ts +33 -0
- package/dist/types/core/src/index.d.ts +100 -0
- package/dist/types/core/src/invite.d.ts +128 -0
- package/dist/types/core/src/link.d.ts +353 -0
- package/dist/types/core/src/linkPreview.d.ts +60 -0
- package/dist/types/core/src/linkTrace.d.ts +12 -0
- package/dist/types/core/src/lnurl.d.ts +99 -0
- package/dist/types/core/src/messageTime.d.ts +28 -0
- package/dist/types/core/src/miniApp.d.ts +141 -0
- package/dist/types/core/src/pairedApps.d.ts +151 -0
- package/dist/types/core/src/pairedCalls.d.ts +59 -0
- package/dist/types/core/src/pairedCapabilities.d.ts +101 -0
- package/dist/types/core/src/pairedEdits.d.ts +83 -0
- package/dist/types/core/src/pairedFiles.d.ts +30 -0
- package/dist/types/core/src/pairedHttp.d.ts +15 -0
- package/dist/types/core/src/pairedSession.d.ts +163 -0
- package/dist/types/core/src/pairedSignal.d.ts +17 -0
- package/dist/types/core/src/pairedTransports.d.ts +76 -0
- package/dist/types/core/src/pairedTyping.d.ts +130 -0
- package/dist/types/core/src/pairedWake.d.ts +109 -0
- package/dist/types/core/src/pairingProgress.d.ts +107 -0
- package/dist/types/core/src/paymentIntent.d.ts +111 -0
- package/dist/types/core/src/paymentUri.d.ts +34 -0
- package/dist/types/core/src/payments.d.ts +97 -0
- package/dist/types/core/src/peerProofs.d.ts +98 -0
- package/dist/types/core/src/pins.d.ts +73 -0
- package/dist/types/core/src/pkarr.d.ts +48 -0
- package/dist/types/core/src/pkdns.d.ts +35 -0
- package/dist/types/core/src/pubkyProofs.d.ts +25 -0
- package/dist/types/core/src/pubkyRing.d.ts +21 -0
- package/dist/types/core/src/reactions.d.ts +108 -0
- package/dist/types/core/src/records.d.ts +89 -0
- package/dist/types/core/src/relay.d.ts +437 -0
- package/dist/types/core/src/relayBreaker.d.ts +99 -0
- package/dist/types/core/src/replies.d.ts +41 -0
- package/dist/types/core/src/services.d.ts +35 -0
- package/dist/types/core/src/setUpdate.d.ts +53 -0
- package/dist/types/core/src/signal.d.ts +53 -0
- package/dist/types/core/src/signer.d.ts +13 -0
- package/dist/types/core/src/sparkAddress.d.ts +37 -0
- package/dist/types/core/src/sshsig.d.ts +74 -0
- package/dist/types/core/src/statusCards.d.ts +253 -0
- package/dist/types/core/src/storeForward.d.ts +144 -0
- package/dist/types/core/src/text.d.ts +20 -0
- package/dist/types/core/src/transport.d.ts +151 -0
- package/dist/types/core/src/transportSwitch.d.ts +160 -0
- package/dist/types/core/src/turnRead.d.ts +145 -0
- package/dist/types/core/src/turnRecord.d.ts +165 -0
- package/dist/types/core/src/version.d.ts +9 -0
- package/dist/types/core/src/video.d.ts +44 -0
- package/dist/types/core/src/voice.d.ts +88 -0
- package/dist/types/core/src/webPush.d.ts +58 -0
- package/dist/types/sdk/src/app.d.ts +23 -0
- package/dist/types/sdk/src/core.d.ts +7 -0
- package/dist/types/sdk/src/fakes.d.ts +6 -0
- package/dist/types/sdk/src/index.d.ts +26 -0
- package/dist/types/sdk/src/testing.d.ts +7 -0
- package/dist/types-DvtCy3WB.js +99 -0
- package/dist/types-DvtCy3WB.js.map +1 -0
- package/dist/verify-DBGw6wYt.js +106 -0
- package/dist/verify-DBGw6wYt.js.map +1 -0
- package/package.json +70 -4
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import type { Identity } from "./identity.js";
|
|
2
|
+
import { type GhostRecord, type SignedPacket } from "./pkarr.js";
|
|
3
|
+
import { type PkarrRequestOptions, type PkarrTransport } from "./transport.js";
|
|
4
|
+
/**
|
|
5
|
+
* Edge signaling through members (WISP 902 · Group Mesh § Signaling through members). An edge of a private group is a
|
|
6
|
+
* paired link, and its presence, offer and answer are Pkarr packets: each costs relay requests, of which an app allows
|
|
7
|
+
* itself 30 a minute per relay, and each is seen at the other end's next poll. A member that joins a group of eight
|
|
8
|
+
* opens seven edges at once, and the admin reads the link's knocks meanwhile: the minute was spent before the edges
|
|
9
|
+
* were up, and what was left waited for it to free (40 to 75 s for a fifth member on two relays, 2026-10-01).
|
|
10
|
+
*
|
|
11
|
+
* Two members about to open an edge usually both have an open link to a third: the admin that just admitted one of
|
|
12
|
+
* them, any member both already reach. That member **carries** the packet: the very bytes a relay would store, signed
|
|
13
|
+
* by the edge's key, which only the two ends can derive. The carrier can neither read nor forge it (to it, as to a
|
|
14
|
+
* relay, it is an opaque signed blob), and the receiver takes it exactly as it takes a relay's answer. The relays still
|
|
15
|
+
* get the packet, a moment later and only the newest one, so an edge that opens through members costs one publish
|
|
16
|
+
* where it cost three and several reads.
|
|
17
|
+
*/
|
|
18
|
+
/** The `paired-groups` version an app announces when it carries and takes edge signaling through members. */
|
|
19
|
+
export declare const GROUP_VERSION_SIGNALS = 5;
|
|
20
|
+
export declare const GROUP_SIGNAL_FRAME: "group-signal";
|
|
21
|
+
/**
|
|
22
|
+
* How long a packet handed to carriers waits before it goes to the relays too. An edge that opens meanwhile publishes
|
|
23
|
+
* its settled packet instead, and this one never goes; with nothing heard from the other end by then (its app is older,
|
|
24
|
+
* or no member reaches both), the relays get it and the edge goes on as before, this much later, once.
|
|
25
|
+
*/
|
|
26
|
+
export declare const CARRIED_DEFER_MS = 1500;
|
|
27
|
+
/** Carriers a packet is handed to at most: two members down at once is rare, and every copy costs the receiver a frame. */
|
|
28
|
+
export declare const SIGNAL_CARRIERS = 2;
|
|
29
|
+
/** Frames of one member a carrier passes on per minute: a member joining a group of 32 sends about a hundred. */
|
|
30
|
+
export declare const SIGNALS_PER_MINUTE = 240;
|
|
31
|
+
/**
|
|
32
|
+
* How long after a carried packet came from the other end the way through members counts as known to work: its own
|
|
33
|
+
* packets then wait before going to the relays (`CARRIED_DEFER_MS`).
|
|
34
|
+
*/
|
|
35
|
+
export declare const SIGNAL_PROVEN_MS = 10000;
|
|
36
|
+
/**
|
|
37
|
+
* How long a member keeps a frame it cannot pass on yet: the edge to whom it is for is often a moment from up (the
|
|
38
|
+
* member was just admitted, or its app just came back and its edges open one after the other).
|
|
39
|
+
*/
|
|
40
|
+
export declare const SIGNAL_HOLD_MS = 5000;
|
|
41
|
+
/** After a carried packet came from a member, mine goes back the same way at most this often. */
|
|
42
|
+
export declare const SIGNAL_REPLY_MS = 30000;
|
|
43
|
+
/**
|
|
44
|
+
* How far from this clock a carried packet's time may be. Signaling is live: an offer is answered within seconds or
|
|
45
|
+
* given up. A member that kept another's old offer cannot hand it on later as if it were new; a packet from a clock
|
|
46
|
+
* further off than this is left to the relays, as before.
|
|
47
|
+
*/
|
|
48
|
+
export declare const SIGNAL_FRESH_MS: number;
|
|
49
|
+
/** `p`: the relay payload (signature, timestamp, DNS packet) as a relay would take it. `h`: passed on once already. */
|
|
50
|
+
export interface GroupSignalFrame {
|
|
51
|
+
t: typeof GROUP_SIGNAL_FRAME;
|
|
52
|
+
g: string;
|
|
53
|
+
to: string;
|
|
54
|
+
from: string;
|
|
55
|
+
p: string;
|
|
56
|
+
h?: 1;
|
|
57
|
+
}
|
|
58
|
+
export declare function groupSignalFrame(g: string, from: string, to: string, payload: Uint8Array, hop?: boolean): GroupSignalFrame;
|
|
59
|
+
/** A well-formed `group-signal`, or null. Its packet is checked by whoever it is for (`CarriedTransport.accept`). */
|
|
60
|
+
export declare function readGroupSignal(raw: unknown): {
|
|
61
|
+
g: string;
|
|
62
|
+
to: string;
|
|
63
|
+
from: string;
|
|
64
|
+
payload: Uint8Array;
|
|
65
|
+
hop: boolean;
|
|
66
|
+
} | null;
|
|
67
|
+
export interface CarriedHooks {
|
|
68
|
+
/**
|
|
69
|
+
* Hands my packet for this edge to links that may pass it on. `taken`: how many took it (0: nobody could). `sure`:
|
|
70
|
+
* one of them reaches the other end as far as anyone can tell (a link of the two of us beside the edge, or the
|
|
71
|
+
* admin, which keeps an edge with everyone), so the relays can wait even before anything came back that way.
|
|
72
|
+
*/
|
|
73
|
+
carry(payload: Uint8Array): {
|
|
74
|
+
taken: number;
|
|
75
|
+
sure: boolean;
|
|
76
|
+
};
|
|
77
|
+
/** The edge's own data link is open: it carries everything, and nothing is handed to anyone. */
|
|
78
|
+
open(): boolean;
|
|
79
|
+
/** A carried packet of the member's is here and no read is under way: look now. */
|
|
80
|
+
look(): void;
|
|
81
|
+
/**
|
|
82
|
+
* Hands my packet to the member over this edge's own data link while it is open: false when it could not go (the
|
|
83
|
+
* member's app takes no carried packets, or the link closed).
|
|
84
|
+
*/
|
|
85
|
+
direct?(payload: Uint8Array): boolean;
|
|
86
|
+
/** `CARRIED_DEFER_MS`, for tests. */
|
|
87
|
+
deferMs?: number;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The Pkarr transport of one edge, with members carrying its packets beside the relays. Publishes under the edge's own
|
|
91
|
+
* key and reads of the member's key go through it; anything else goes straight to the transport underneath.
|
|
92
|
+
*/
|
|
93
|
+
export declare class CarriedTransport implements PkarrTransport {
|
|
94
|
+
private readonly inner;
|
|
95
|
+
private readonly myKey;
|
|
96
|
+
private readonly peerKey;
|
|
97
|
+
private readonly hooks;
|
|
98
|
+
/** My last packet while the edge is down: what a member that just became reachable is handed. */
|
|
99
|
+
private mine;
|
|
100
|
+
private lastTimestamp;
|
|
101
|
+
/** My newest packet, wherever it went: what the edge hands the member over itself once it is ready (`linkReady`). */
|
|
102
|
+
private newest;
|
|
103
|
+
/** The newest packet of the member's that came through a carrier, and the timestamp of the one a read last returned. */
|
|
104
|
+
private carried;
|
|
105
|
+
private returned;
|
|
106
|
+
/** The newest packet of the member's any read returned, from the relays or a carrier: nothing older is taken after it. */
|
|
107
|
+
private seen;
|
|
108
|
+
/** A read under way: resolved when a carried packet comes meanwhile. */
|
|
109
|
+
private waiting;
|
|
110
|
+
/** The packet the relays have not got yet. */
|
|
111
|
+
private pending;
|
|
112
|
+
/** How many carried packets of the member's came: a deferral that ends with none more says no member reaches it. */
|
|
113
|
+
private heard;
|
|
114
|
+
/** When the last one came (`SIGNAL_PROVEN_MS`). */
|
|
115
|
+
private heardAt;
|
|
116
|
+
/** No member reached the other end: packets go to the relays at once until one does. */
|
|
117
|
+
private quiet;
|
|
118
|
+
private stopped;
|
|
119
|
+
readonly publishPayload?: PkarrTransport["publishPayload"];
|
|
120
|
+
readonly discovery?: PkarrTransport["discovery"];
|
|
121
|
+
readonly subscribe?: PkarrTransport["subscribe"];
|
|
122
|
+
readonly networkChanged?: PkarrTransport["networkChanged"];
|
|
123
|
+
readonly configure?: PkarrTransport["configure"];
|
|
124
|
+
constructor(inner: PkarrTransport, myKey: string, peerKey: string, hooks: CarriedHooks);
|
|
125
|
+
describe(): {
|
|
126
|
+
protocol: string;
|
|
127
|
+
relays: string[];
|
|
128
|
+
};
|
|
129
|
+
publish(identity: Identity, records: GhostRecord[], options?: PkarrRequestOptions): Promise<void>;
|
|
130
|
+
/** My next packet for this edge, signed and dated: each newer than the last, as the relays' copy keeps them. */
|
|
131
|
+
private stamp;
|
|
132
|
+
/**
|
|
133
|
+
* The relays get the very packet members carried or the edge itself handed over, byte for byte, where the transport
|
|
134
|
+
* can put a payload signed here: a copy dated again by the relays' transport was a packet the member had not seen,
|
|
135
|
+
* and its first read after this app said goodbye took it for a sign that the app was back already. It dialled: two
|
|
136
|
+
* writes and fast looks for an app that was gone, and an offer left on the relays that this app could answer after
|
|
137
|
+
* its restart and then wait 40 s for (7 of 16 goodbyes on the admin in the member-back runs, 1 of 16 on dev, 2026-10-03).
|
|
138
|
+
*/
|
|
139
|
+
private toRelays;
|
|
140
|
+
/**
|
|
141
|
+
* The packet the relays just took, handed to the member over the edge itself while it is up. An edge up reads nothing
|
|
142
|
+
* from the relays until its slow look, so the member's app would otherwise meet that packet first after a goodbye.
|
|
143
|
+
*/
|
|
144
|
+
private handDirect;
|
|
145
|
+
/**
|
|
146
|
+
* The edge is up and the member's app takes carried packets: my newest packet goes over it. The one that went as the
|
|
147
|
+
* edge opened (before its session was ready, so to the relays, or to members) is often one the member never read.
|
|
148
|
+
* A packet it has already is dropped on its side.
|
|
149
|
+
*/
|
|
150
|
+
linkReady(): void;
|
|
151
|
+
/** The deferred packet goes to the relays: the edge did not open meanwhile. Tried again while it is still the newest. */
|
|
152
|
+
private flush;
|
|
153
|
+
private drop;
|
|
154
|
+
resolve(pubKeyZ32: string, options?: PkarrRequestOptions): Promise<SignedPacket | null>;
|
|
155
|
+
private take;
|
|
156
|
+
/**
|
|
157
|
+
* A packet a member carried here. True when it is the member's (its signature holds under the edge's key), of now
|
|
158
|
+
* (`SIGNAL_FRESH_MS`) and newer than any seen before, carried or read: the next read answers with it, at once.
|
|
159
|
+
* `direct`: the member handed it over this edge itself while it was up (`CarriedHooks.direct`), which says nothing
|
|
160
|
+
* about whether other members reach it.
|
|
161
|
+
*/
|
|
162
|
+
accept(payload: Uint8Array, direct?: boolean): boolean;
|
|
163
|
+
/** My newest packet for this edge while it is down, for a member that can pass it on now; null once it is up. */
|
|
164
|
+
latest(): Uint8Array | null;
|
|
165
|
+
/** The edge is going: nothing more is deferred or carried, and a last packet goes straight to the relays. */
|
|
166
|
+
stop(): void;
|
|
167
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type TypingActivity, type TypingFrame } from "./pairedTyping.js";
|
|
2
|
+
/**
|
|
3
|
+
* The typing indicator of a private group (WISP 902 · Group Mesh § Typing): "Ana is typing", said on the group's
|
|
4
|
+
* edges only, the way a 1:1 chat says it on its session (WISP 401 § Typing), with the same kinds, limits and wording.
|
|
5
|
+
*
|
|
6
|
+
* {"t":"group-typing","g":"<group>","e":3,"n":"<nonce>","c":"<sealed>"}
|
|
7
|
+
*
|
|
8
|
+
* `c` is the 1:1 frame's word (`{"s":"start","kind":"recording"}`, `{"s":"stop"}`) sealed under the message key of
|
|
9
|
+
* epoch `e`, bound to the group, the epoch and the sender (the member the edge is pinned to): a frame another member
|
|
10
|
+
* replays on its own edge does not open. It is presence, not a message: no id, no sequence number, never stored,
|
|
11
|
+
* never handed on in a catch-up, never in the chain, never passed on by a hub. Older apps drop the frame.
|
|
12
|
+
*
|
|
13
|
+
* Community groups do not carry it yet: everything a community carries is a stored message that hubs relay and
|
|
14
|
+
* members hand on in catch-ups, and typing is not one.
|
|
15
|
+
*/
|
|
16
|
+
export declare const GROUP_TYPING_FRAME = "group-typing";
|
|
17
|
+
export interface GroupTypingFrame {
|
|
18
|
+
t: typeof GROUP_TYPING_FRAME;
|
|
19
|
+
g: string;
|
|
20
|
+
e: number;
|
|
21
|
+
n: string;
|
|
22
|
+
c: string;
|
|
23
|
+
}
|
|
24
|
+
/** A 1:1 typing frame (from a `TypingSender`, one per group), sealed for the group under the epoch's secret (base64url). */
|
|
25
|
+
export declare function sealGroupTyping(groupId: string, epoch: number, secretB64: string, sender: string, word: TypingFrame): GroupTypingFrame;
|
|
26
|
+
/** The epoch a `group-typing` frame says it is sealed under, or null when it is not one for this group. */
|
|
27
|
+
export declare function groupTypingEpoch(raw: unknown, groupId: string): number | null;
|
|
28
|
+
/**
|
|
29
|
+
* The word inside a `group-typing` frame from `sender`, as a 1:1 typing frame (`TypingReceiver` reads it, kind and
|
|
30
|
+
* status checked there), or null when it does not open under that epoch's secret or is not a word.
|
|
31
|
+
*/
|
|
32
|
+
export declare function openGroupTyping(raw: GroupTypingFrame, secretB64: string, sender: string): TypingFrame | null;
|
|
33
|
+
/** Who is typing in one group: member key → what they are doing, in the order they started. */
|
|
34
|
+
export type GroupTyping = {
|
|
35
|
+
member: string;
|
|
36
|
+
activity: TypingActivity;
|
|
37
|
+
}[];
|
|
38
|
+
/**
|
|
39
|
+
* The members' words in one group: one `TypingReceiver` per member, so each has the 1:1 timeout (6 s without a new
|
|
40
|
+
* `start`) and its own rate limit (a member flooding frames is held where it was, and nobody else is). The caller
|
|
41
|
+
* says who is a member: a frame from anyone else never reaches it. `onChange` hears every change.
|
|
42
|
+
*/
|
|
43
|
+
export declare class GroupTypingBoard {
|
|
44
|
+
private readonly onChange;
|
|
45
|
+
private readonly now;
|
|
46
|
+
private readonly members;
|
|
47
|
+
constructor(onChange: () => void, now?: () => number);
|
|
48
|
+
/** A word from `member`, already opened. False when it was dropped (malformed, or over the member's limit). */
|
|
49
|
+
receive(member: string, word: Record<string, unknown>): boolean;
|
|
50
|
+
/** A message from `member` arrived, or it left the group: it is not typing any more. */
|
|
51
|
+
clear(member: string): void;
|
|
52
|
+
/** Nobody is typing: the group was left, or this app stopped. */
|
|
53
|
+
clearAll(): void;
|
|
54
|
+
/** Who is typing now, among `members` when given (someone the roster took out is not shown). */
|
|
55
|
+
typing(members?: readonly string[]): GroupTyping;
|
|
56
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { type GroupMention } from "./groupMentions.js";
|
|
2
|
+
import { wakeFrame, type WakeTarget } from "./pairedWake.js";
|
|
3
|
+
/**
|
|
4
|
+
* Wake-up push in a private group (WISP 902 · Group Mesh § Wake-up push): a member whose web app is closed is woken
|
|
5
|
+
* when a message names it. `wake/1` as a 1:1 chat has it (WISP 401 § Wake-up push), carried on the group's edges: each
|
|
6
|
+
* member shares its subscription with each other member on their own edge, under a token of that edge alone, and
|
|
7
|
+
* only in a group it has not muted:
|
|
8
|
+
*
|
|
9
|
+
* {"t":"group-wake","g":"<group id>","w":{"e":…,"p":…,"a":…,"vp":…,"vk":…,"k":"<token>"}}
|
|
10
|
+
* {"t":"group-wake","g":"<group id>","w":null} (muted, or stopped: forget it)
|
|
11
|
+
*
|
|
12
|
+
* The author of a message wakes the members it names by key (never `*`, everyone), and only those it cannot reach now.
|
|
13
|
+
* The push is the 1:1 one, `{"wake":1,"k":"<token>"}`: no text, no group, no author. A community has no edge between
|
|
14
|
+
* two members, so it has none of this (§ Wake-up push, not yet).
|
|
15
|
+
*/
|
|
16
|
+
export declare const GROUP_WAKE_FRAME = "group-wake";
|
|
17
|
+
/** At most one wake-up to a member in this long, whatever group names it: a mention storm is one push. */
|
|
18
|
+
export declare const GROUP_WAKE_MEMBER_INTERVAL_MS: number;
|
|
19
|
+
/** At most this many wake-ups from one group in `GROUP_WAKE_GROUP_WINDOW_MS`: a message naming 16 wakes four. */
|
|
20
|
+
export declare const GROUP_WAKE_GROUP_LIMIT = 4;
|
|
21
|
+
export declare const GROUP_WAKE_GROUP_WINDOW_MS = 60000;
|
|
22
|
+
/** Frames a member reads on one edge in a minute: it changes when the other member rotates or mutes. */
|
|
23
|
+
export declare const GROUP_WAKE_RECEIVE_LIMIT = 6;
|
|
24
|
+
export type GroupWakeFrame = {
|
|
25
|
+
t: typeof GROUP_WAKE_FRAME;
|
|
26
|
+
g: string;
|
|
27
|
+
w: ReturnType<typeof wakeFrame>["w"];
|
|
28
|
+
};
|
|
29
|
+
export declare function groupWakeFrame(groupId: string, target: WakeTarget | null): GroupWakeFrame;
|
|
30
|
+
/** What a `group-wake` frame says for this group: a target, null (forget it), or undefined (malformed, or another group's). */
|
|
31
|
+
export declare function parseGroupWakeFrame(frame: Record<string, unknown>, groupId: string): WakeTarget | null | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* The members a message wakes, as its author sends it: those it names by key (the mentions that hold on the trimmed
|
|
34
|
+
* text), each once, in order. Never `*`: everyone is a group's whole roster, and a wake-up is for one person.
|
|
35
|
+
*/
|
|
36
|
+
export declare function mentionedMembers(mentions: readonly GroupMention[] | undefined, text: string): string[];
|
|
37
|
+
/**
|
|
38
|
+
* The limits of group wake-ups on the author's side: one per member per `GROUP_WAKE_MEMBER_INTERVAL_MS` (across
|
|
39
|
+
* groups), and `GROUP_WAKE_GROUP_LIMIT` per group per `GROUP_WAKE_GROUP_WINDOW_MS`. In memory, as the 1:1 limiter.
|
|
40
|
+
*/
|
|
41
|
+
export declare class GroupWakeLimiter {
|
|
42
|
+
private readonly memberInterval;
|
|
43
|
+
private readonly groupLimit;
|
|
44
|
+
private readonly groupWindow;
|
|
45
|
+
private readonly members;
|
|
46
|
+
private readonly groups;
|
|
47
|
+
constructor(memberInterval?: number, groupLimit?: number, groupWindow?: number);
|
|
48
|
+
/** Whether a wake-up to `member` for `group` may go now; if so, it counts against both. */
|
|
49
|
+
take(group: string, member: string, now?: number): boolean;
|
|
50
|
+
/** The member is reachable again: the next time it is away, a mention may wake it at once. */
|
|
51
|
+
reset(member: string): void;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Who the author of a message wakes: the members it names, that shared how, that it cannot reach now, within the
|
|
55
|
+
* limits. `target` answers a member's shared target (its edge's), `reachable` whether it is live (its edge, or a hub).
|
|
56
|
+
*/
|
|
57
|
+
export declare function groupWakes<T>(options: {
|
|
58
|
+
group: string;
|
|
59
|
+
mentions: readonly GroupMention[] | undefined;
|
|
60
|
+
text: string;
|
|
61
|
+
target: (member: string) => T | undefined;
|
|
62
|
+
reachable: (member: string) => boolean;
|
|
63
|
+
limiter: GroupWakeLimiter;
|
|
64
|
+
now?: number;
|
|
65
|
+
}): {
|
|
66
|
+
member: string;
|
|
67
|
+
target: T;
|
|
68
|
+
}[];
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import type { DeviceFrame } from "./deviceLink.js";
|
|
2
|
+
import { type DeviceKind } from "./enroll.js";
|
|
3
|
+
import type { Signer } from "./signer.js";
|
|
4
|
+
export declare const HANDOFF_HELLO = "handoff-hello";
|
|
5
|
+
export declare const HANDOFF_REQUEST = "handoff-request";
|
|
6
|
+
export declare const HANDOFF_OFFER = "handoff-offer";
|
|
7
|
+
export declare const HANDOFF_BUSY = "handoff-busy";
|
|
8
|
+
export declare const HANDOFF_PAKE = "handoff-pake";
|
|
9
|
+
export declare const HANDOFF_HAVE = "handoff-have";
|
|
10
|
+
export declare const HANDOFF_MANIFEST = "handoff-manifest";
|
|
11
|
+
export declare const HANDOFF_DATA = "handoff-data";
|
|
12
|
+
export declare const HANDOFF_ACK = "handoff-ack";
|
|
13
|
+
export declare const HANDOFF_VERIFIED = "handoff-verified";
|
|
14
|
+
export declare const HANDOFF_RELEASE = "handoff-release";
|
|
15
|
+
export declare const HANDOFF_DONE = "handoff-done";
|
|
16
|
+
export declare const HANDOFF_CANCEL = "handoff-cancel";
|
|
17
|
+
export declare const HANDOFF_FILE_REQUEST = "handoff-file-request";
|
|
18
|
+
export declare const HANDOFF_FILE_MISSING = "handoff-file-missing";
|
|
19
|
+
/** The version `handoff-hello` says. */
|
|
20
|
+
export declare const HANDOFF_VERSION = 1;
|
|
21
|
+
/** The WISP's timeouts (§ States and events), in one place. */
|
|
22
|
+
export declare const HANDOFF_TIMINGS: {
|
|
23
|
+
/** The taker: no session with the giver within this long. */
|
|
24
|
+
readonly connectMs: 30000;
|
|
25
|
+
/** The giver: the proof held, and no frame came for this long. Also a frame of the proof that never comes. */
|
|
26
|
+
readonly idleMs: 60000;
|
|
27
|
+
/** Pass 1: no confirmed bytes for this long, or the link dropped: paused. */
|
|
28
|
+
readonly stallMs: 60000;
|
|
29
|
+
/**
|
|
30
|
+
* The copy (pass 1, and pass 2 until its parts are confirmed): nothing from the other device for this long, on either
|
|
31
|
+
* side, whether the link is up or not. The handoff fails on both devices and says so (`stalled`); the device that had
|
|
32
|
+
* the profile keeps it, and the files already copied stay staged for Try again.
|
|
33
|
+
*/
|
|
34
|
+
readonly stuckMs: 120000;
|
|
35
|
+
/** A taker's staged files of a handoff that stopped are used again by a new one within this long. */
|
|
36
|
+
readonly giveUpMs: number;
|
|
37
|
+
/** Quiesce waits this long for a payment that is going through. */
|
|
38
|
+
readonly paymentMs: 30000;
|
|
39
|
+
/** Pass 2: no `handoff-verified` within this long of the last part: the giver is active again. */
|
|
40
|
+
readonly verifiedMs: number;
|
|
41
|
+
/** The taker, verified: no release within this long. It reads the turn and asks again. */
|
|
42
|
+
readonly releaseMs: 60000;
|
|
43
|
+
/** A staging namespace that was not installed is dropped after this long at the latest. */
|
|
44
|
+
readonly stagingMs: number;
|
|
45
|
+
/**
|
|
46
|
+
* The taker, installed: no settled turn (`start`, or a turn above the release) within this long. It stops trying and
|
|
47
|
+
* says it cannot check which device is active, with Try again. It stays `taking`: the release is still its own.
|
|
48
|
+
*/
|
|
49
|
+
readonly settleMs: number;
|
|
50
|
+
};
|
|
51
|
+
/** One piece of a part, before it is sealed. Sealed and in base64url it fits a device frame (60 KiB). */
|
|
52
|
+
export declare const HANDOFF_PIECE_BYTES: number;
|
|
53
|
+
/** Pieces sent and not yet confirmed, at most. */
|
|
54
|
+
export declare const HANDOFF_WINDOW = 16;
|
|
55
|
+
/** "Bring large files later" on mobile data: files over this size stay behind (WISP 06 § User experience). */
|
|
56
|
+
export declare const HANDOFF_LATER_BYTES: number;
|
|
57
|
+
/** Entries per `handoff-manifest` or `handoff-have` frame. */
|
|
58
|
+
export declare const HANDOFF_LIST_PER_FRAME = 300;
|
|
59
|
+
/** Why a giver says it cannot hand over now (`handoff-busy`). */
|
|
60
|
+
export declare const HANDOFF_BUSY_REASONS: readonly ["handoff", "payment", "call", "locked-out", "refused", "wallet", "older", "offline"];
|
|
61
|
+
export type HandoffBusyReason = (typeof HANDOFF_BUSY_REASONS)[number];
|
|
62
|
+
/** Why a side ended a handoff (`handoff-cancel`). */
|
|
63
|
+
export declare const HANDOFF_CANCEL_REASONS: readonly ["cancelled", "damaged", "room", "version", "timeout", "failed", "turn", "password", "stalled"];
|
|
64
|
+
export type HandoffCancelReason = (typeof HANDOFF_CANCEL_REASONS)[number];
|
|
65
|
+
/** One part as a manifest and `H` name it: its name, its size in bytes and its SHA-256 (base64url). */
|
|
66
|
+
export type HandoffPart = [name: string, size: number, sha256: string];
|
|
67
|
+
export declare const isHandoffPartName: (name: unknown) => name is string;
|
|
68
|
+
/** The part a file is: `file/<its SHA-256, base64url>`. */
|
|
69
|
+
export declare const filePartName: (sha256B64: string) => string;
|
|
70
|
+
/** The digest a file part names, or null for any other part. */
|
|
71
|
+
export declare const filePartDigest: (name: string) => string | null;
|
|
72
|
+
/** Parts sorted by name as byte strings, with one entry per name: what `H` and a manifest list. */
|
|
73
|
+
export declare function sortParts(parts: readonly HandoffPart[]): HandoffPart[];
|
|
74
|
+
/**
|
|
75
|
+
* `H`, the digest of the state handed over (WISP 06 § Frames): SHA-256 of the UTF-8 bytes of
|
|
76
|
+
* `JSON.stringify(["ghostly-handoff/1", N + 1, fromKey, toKey, parts])`, where `parts` is every part of both passes
|
|
77
|
+
* and every part the taker already held and keeps, as `[name, size, sha256]` sorted by name. Keys are base64url.
|
|
78
|
+
*/
|
|
79
|
+
export declare function handoffDigest(turn: number, fromKey: Uint8Array, toKey: Uint8Array, parts: readonly HandoffPart[]): Uint8Array;
|
|
80
|
+
/** What `handoff-verified` signs: `["ghostly-handoff-verified", turnAddress, N + 1, H]`, the bytes in base64url. */
|
|
81
|
+
export declare function handoffVerifiedMessage(turnAddress: Uint8Array, turn: number, h: Uint8Array): Uint8Array;
|
|
82
|
+
/**
|
|
83
|
+
* The context the password proof is bound to (WISP 06 § Authorizing a handoff): `"ghostly-handoff/1" || turnAddress ||
|
|
84
|
+
* A's key || B's key || the session's transcript hash` (32 bytes, from its hex).
|
|
85
|
+
*/
|
|
86
|
+
export declare function handoffContext(turnAddress: Uint8Array, giverKey: Uint8Array, takerKey: Uint8Array, transcriptHash: string): Uint8Array;
|
|
87
|
+
/**
|
|
88
|
+
* The proof that the password proof's key was made in this context: HMAC-SHA256 under that key. The OPAQUE library
|
|
89
|
+
* this build uses takes no context of its own (its identifiers go into the envelope at registration, and cannot carry
|
|
90
|
+
* a session), so the taker sends this beside the third message, and the giver checks it.
|
|
91
|
+
*/
|
|
92
|
+
export declare function handoffContextProof(pakeKey: Uint8Array, context: Uint8Array): Uint8Array;
|
|
93
|
+
/** A fresh X25519 key pair for one session of a handoff: the secret stays in memory, the public key goes in `handoff-hello`. */
|
|
94
|
+
export declare function handoffEphemeral(secret?: Uint8Array): {
|
|
95
|
+
secret: Uint8Array;
|
|
96
|
+
publicKey: Uint8Array;
|
|
97
|
+
};
|
|
98
|
+
/** A session's stream key (see the top of this file). `k`: the password proof's key, the handoff's first stream key, or empty. */
|
|
99
|
+
export declare function handoffStreamKey(ownSecret: Uint8Array, peerPublic: Uint8Array, k: Uint8Array, transcriptHash: string): Uint8Array;
|
|
100
|
+
/** What sealing adds to a piece: the nonce, the header and the tag. */
|
|
101
|
+
export declare const HANDOFF_PIECE_OVERHEAD: number;
|
|
102
|
+
/**
|
|
103
|
+
* One piece of part `part` at byte `offset`, sealed with the stream key:
|
|
104
|
+
* `nonce(24) || XSalsa20-Poly1305(key, nonce, header(16) || piece)`, a random nonce each.
|
|
105
|
+
*/
|
|
106
|
+
export declare function sealHandoffPiece(key: Uint8Array, part: string, offset: number, piece: Uint8Array, nonce?: Uint8Array): Uint8Array;
|
|
107
|
+
/** A sealed piece opened, or null when it was not sealed with this key, for this part and offset, or was changed. */
|
|
108
|
+
export declare function openHandoffPiece(key: Uint8Array, part: string, offset: number, sealed: Uint8Array): Uint8Array | null;
|
|
109
|
+
/** What a device says about itself in the first frame (WISP 06 § Versions). */
|
|
110
|
+
export interface HandoffHello {
|
|
111
|
+
v: 1;
|
|
112
|
+
/** This session's X25519 public key, base64url. */
|
|
113
|
+
e: string;
|
|
114
|
+
/** The app's version. */
|
|
115
|
+
app: string;
|
|
116
|
+
/** The peer database's schema version (`DB_VERSION`). */
|
|
117
|
+
db: number;
|
|
118
|
+
/** The pinned version of each wallet SDK, by wallet type. */
|
|
119
|
+
pins: Record<string, string>;
|
|
120
|
+
kind: DeviceKind;
|
|
121
|
+
/** Bytes free for the profile on this device, or -1 when the platform does not say. */
|
|
122
|
+
room: number;
|
|
123
|
+
/** On a connection that costs by the byte (mobile data). */
|
|
124
|
+
metered: boolean;
|
|
125
|
+
/** The taker: files over this many bytes stay behind for later; 0 for none. */
|
|
126
|
+
later?: number;
|
|
127
|
+
/** The handoff this session goes on with. */
|
|
128
|
+
id?: string;
|
|
129
|
+
}
|
|
130
|
+
export declare function handoffHelloFrame(hello: HandoffHello): DeviceFrame;
|
|
131
|
+
export declare function readHandoffHello(frame: DeviceFrame): HandoffHello | null;
|
|
132
|
+
/** A new handoff's id: 16 random bytes, base64url. */
|
|
133
|
+
export declare const newHandoffId: () => string;
|
|
134
|
+
/** `handoff-request` (B): `turn` is the turn B read as the active device's, `id` the handoff's. */
|
|
135
|
+
export declare const handoffRequestFrame: (turn: number, id: string) => DeviceFrame;
|
|
136
|
+
/** `handoff-offer` (A, a push): `bytes` is about how much would move. */
|
|
137
|
+
export declare const handoffOfferFrame: (turn: number, id: string, bytes: number) => DeviceFrame;
|
|
138
|
+
export declare function readHandoffTurnFrame(frame: DeviceFrame): {
|
|
139
|
+
turn: number;
|
|
140
|
+
id: string;
|
|
141
|
+
bytes?: number;
|
|
142
|
+
} | null;
|
|
143
|
+
export declare const handoffBusyFrame: (why: HandoffBusyReason, retry: number) => DeviceFrame;
|
|
144
|
+
export declare function readHandoffBusy(frame: DeviceFrame): {
|
|
145
|
+
why: HandoffBusyReason;
|
|
146
|
+
retry: number;
|
|
147
|
+
} | null;
|
|
148
|
+
export declare const handoffCancelFrame: (why: HandoffCancelReason) => DeviceFrame;
|
|
149
|
+
export declare function readHandoffCancel(frame: DeviceFrame): HandoffCancelReason | null;
|
|
150
|
+
/** `handoff-pake`: one of the three messages of the password proof. */
|
|
151
|
+
export interface HandoffPake {
|
|
152
|
+
n: 1 | 2 | 3;
|
|
153
|
+
m?: string;
|
|
154
|
+
c?: string;
|
|
155
|
+
wrong?: true;
|
|
156
|
+
}
|
|
157
|
+
export declare const handoffPakeFrame: (pake: HandoffPake) => DeviceFrame;
|
|
158
|
+
export declare function readHandoffPake(frame: DeviceFrame): HandoffPake | null;
|
|
159
|
+
/** `handoff-have` (B): digests of the files it holds, and parts it holds in part, in frames of `HANDOFF_LIST_PER_FRAME`. */
|
|
160
|
+
export declare function handoffHaveFrames(digests: readonly string[], partial?: Record<string, number>): DeviceFrame[];
|
|
161
|
+
export declare function readHandoffHave(frame: DeviceFrame): {
|
|
162
|
+
d: string[];
|
|
163
|
+
p: Record<string, number>;
|
|
164
|
+
more: boolean;
|
|
165
|
+
} | null;
|
|
166
|
+
/**
|
|
167
|
+
* A manifest as one side holds it: the parts to send, the files left for later, and which file ids each digest is,
|
|
168
|
+
* for every file the giver holds (sent now, sent before, or already on the taker), so the taker writes each file under
|
|
169
|
+
* the id its records name.
|
|
170
|
+
*/
|
|
171
|
+
export interface HandoffManifest {
|
|
172
|
+
pass: 1 | 2;
|
|
173
|
+
parts: HandoffPart[];
|
|
174
|
+
ids: Record<string, string[]>;
|
|
175
|
+
later: HandoffPart[];
|
|
176
|
+
}
|
|
177
|
+
/** `handoff-manifest` (A), in as many frames as it takes. */
|
|
178
|
+
export declare function handoffManifestFrames(manifest: HandoffManifest): DeviceFrame[];
|
|
179
|
+
export declare function readHandoffManifest(frame: DeviceFrame): (HandoffManifest & {
|
|
180
|
+
more: boolean;
|
|
181
|
+
}) | null;
|
|
182
|
+
/** `handoff-data`: one sealed piece of part `p` at byte `o` of the part. */
|
|
183
|
+
export declare const handoffDataFrame: (part: string, offset: number, sealed: Uint8Array) => DeviceFrame;
|
|
184
|
+
export declare function readHandoffData(frame: DeviceFrame): {
|
|
185
|
+
part: string;
|
|
186
|
+
offset: number;
|
|
187
|
+
sealed: Uint8Array;
|
|
188
|
+
} | null;
|
|
189
|
+
/** `handoff-ack`: the taker holds part `p` up to byte `o`, written. */
|
|
190
|
+
export declare const handoffAckFrame: (part: string, offset: number) => DeviceFrame;
|
|
191
|
+
export declare function readHandoffAck(frame: DeviceFrame): {
|
|
192
|
+
part: string;
|
|
193
|
+
offset: number;
|
|
194
|
+
} | null;
|
|
195
|
+
/** `handoff-verified` (B): `H`, and B's signature over it (`handoffVerifiedMessage`). */
|
|
196
|
+
export declare function handoffVerifiedFrame(turnAddress: Uint8Array, turn: number, h: Uint8Array, signer: Signer): Promise<DeviceFrame>;
|
|
197
|
+
/** `H` of a `handoff-verified` that B's key signed for this turn address and turn, or null. */
|
|
198
|
+
export declare function readHandoffVerified(frame: DeviceFrame, turnAddress: Uint8Array, turn: number, takerKey: Uint8Array): Uint8Array | null;
|
|
199
|
+
/** `handoff-release` (A): the release of the turn record, as A signed it into its own state. */
|
|
200
|
+
export interface HandoffReleaseFrame {
|
|
201
|
+
turn: number;
|
|
202
|
+
to: string;
|
|
203
|
+
h: string;
|
|
204
|
+
s: string;
|
|
205
|
+
}
|
|
206
|
+
export declare const handoffReleaseFrame: (release: HandoffReleaseFrame) => DeviceFrame;
|
|
207
|
+
export declare function readHandoffRelease(frame: DeviceFrame): HandoffReleaseFrame | null;
|
|
208
|
+
export declare const handoffDoneFrame: (sequence: number) => DeviceFrame;
|
|
209
|
+
export declare function readHandoffDone(frame: DeviceFrame): number | null;
|
|
210
|
+
export declare const handoffFileRequestFrame: (sha256B64: string) => DeviceFrame;
|
|
211
|
+
export declare const handoffFileMissingFrame: (sha256B64: string) => DeviceFrame;
|
|
212
|
+
export declare function readHandoffFileFrame(frame: DeviceFrame): {
|
|
213
|
+
missing: boolean;
|
|
214
|
+
sha256: string;
|
|
215
|
+
} | null;
|
|
216
|
+
/**
|
|
217
|
+
* Whether two devices can hand over (WISP 06 § Versions), seen from the taker: a taker whose database is older than
|
|
218
|
+
* the giver's cannot read what it would get (`older`: "Update Ghostly on this device first."). A newer taker migrates
|
|
219
|
+
* on arrival, and the giver, older now, must update before it takes the profile back (`newerTaker`). A wallet whose
|
|
220
|
+
* SDK pin differs stays home (`stayHome`, by wallet type).
|
|
221
|
+
*/
|
|
222
|
+
export declare function handoffVersions(giver: Pick<HandoffHello, "db" | "pins" | "app">, taker: Pick<HandoffHello, "db" | "pins" | "app">): {
|
|
223
|
+
older: boolean;
|
|
224
|
+
newerTaker: boolean;
|
|
225
|
+
stayHome: string[];
|
|
226
|
+
};
|
|
227
|
+
/** The WISP's limits on wrong passwords, per taking device (§ Authorizing a handoff). */
|
|
228
|
+
export declare const HANDOFF_ATTEMPTS: {
|
|
229
|
+
readonly perHour: 5;
|
|
230
|
+
readonly hourMs: number;
|
|
231
|
+
readonly total: 15;
|
|
232
|
+
};
|
|
233
|
+
/** What the giver keeps of one taking device's attempts. */
|
|
234
|
+
export interface HandoffAttempts {
|
|
235
|
+
/** When each failure of the last hour happened (ms). */
|
|
236
|
+
recent: number[];
|
|
237
|
+
/** Failures since the last success. */
|
|
238
|
+
total: number;
|
|
239
|
+
/** Locked out until then (ms). */
|
|
240
|
+
until?: number;
|
|
241
|
+
}
|
|
242
|
+
export declare const NO_ATTEMPTS: HandoffAttempts;
|
|
243
|
+
/** Whether a device may try now: `refused` after 15 failures with no success, until the person lets it try again. */
|
|
244
|
+
export declare function handoffAttemptAllowed(attempts: HandoffAttempts | undefined, now: number): "ok" | "locked-out" | "refused";
|
|
245
|
+
/**
|
|
246
|
+
* One more failure. The giver counts an attempt as failed when it answers the first message, before it learns the
|
|
247
|
+
* outcome, and takes it back on success: a taker that stops after the second message has used a try.
|
|
248
|
+
*/
|
|
249
|
+
export declare function handoffAttemptFailed(attempts: HandoffAttempts | undefined, now: number): HandoffAttempts;
|
|
250
|
+
/** A proof that held: the count starts again. */
|
|
251
|
+
export declare const handoffAttemptSucceeded: () => HandoffAttempts;
|
|
252
|
+
/** Seconds until a locked-out device may try again (for `handoff-busy`). */
|
|
253
|
+
export declare const handoffRetryAfter: (attempts: HandoffAttempts | undefined, now: number) => number;
|
|
254
|
+
/** Two digests compared. */
|
|
255
|
+
export declare const sameDigest: (a: Uint8Array, b: Uint8Array) => boolean;
|