@ghostlytools/sdk 1.7.4 → 1.8.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/core.js +2 -2
- package/dist/{fakes-ClE16ouz.js → fakes-DSeGiDvk.js} +2 -2
- package/dist/fakes-DSeGiDvk.js.map +1 -0
- package/dist/fakes.js +1 -1
- package/dist/index.js +2 -2
- package/dist/{keet-identity-key-BRKv78jp.js → keet-identity-key-Db5KY0V1.js} +2 -2
- package/dist/{keet-identity-key-BRKv78jp.js.map → keet-identity-key-Db5KY0V1.js.map} +1 -1
- package/dist/{src-B5uLojgn.js → src-CfpOdLVf.js} +902 -78
- package/dist/src-CfpOdLVf.js.map +1 -0
- package/dist/testing.js +3 -3
- package/dist/types/browser/src/shared/features.d.ts +5 -0
- package/dist/types/browser/src/shared/mints.d.ts +6 -0
- package/dist/types/core/src/chatFiles.d.ts +6 -0
- package/dist/types/core/src/dhtDelivery.d.ts +51 -0
- package/dist/types/core/src/domainProofs.d.ts +3 -2
- package/dist/types/core/src/engineErrors.d.ts +5 -1
- package/dist/types/core/src/ghostlink.d.ts +8 -0
- package/dist/types/core/src/groupCommunity.d.ts +21 -1
- package/dist/types/core/src/index.d.ts +1 -0
- package/dist/types/core/src/link.d.ts +13 -0
- package/dist/types/core/src/ratchet.d.ts +201 -0
- package/dist/types/core/src/relay.d.ts +15 -0
- package/dist/types/core/src/storeForward.d.ts +32 -11
- package/dist/{verify-yJe2Uqod.js → verify-C-u4HILn.js} +2 -2
- package/dist/{verify-yJe2Uqod.js.map → verify-C-u4HILn.js.map} +1 -1
- package/package.json +1 -1
- package/dist/fakes-ClE16ouz.js.map +0 -1
- package/dist/src-B5uLojgn.js.map +0 -1
package/dist/testing.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Oa as decodeBolt11,
|
|
1
|
+
import { Bu as IDENTITY_MAX_EVIDENCE, Oa as decodeBolt11, QC as createIdentity, Qu as emptyIdentityLedger, Xu as IdentityExchange, id as newIdentityBinding, ra as isBitcoinAddress, td as identityStatement } from "./src-CfpOdLVf.js";
|
|
2
2
|
import { l as providerDescriptorProblems, o as isNothingSpentError } from "./types-DvtCy3WB.js";
|
|
3
|
-
import { i as verifyIdentity, r as descriptorProblems } from "./verify-
|
|
4
|
-
import { _ as fakeAddress, a as fakeAccount, b as fakeOnchain, c as fakeKeySign, d as fakeRecord, f as fakeRecordText, g as TEST_PROVIDERS_FLAG, h as FakeOnchainProvider, i as TEST_IDENTITIES_FLAG, l as fakeKeySubject, m as FakeLightningProvider, n as FAKE_ISSUER, o as fakeAccountToken, p as testIdentitiesEnabled, r as FAKE_RECORD_HOST, s as fakeKey, t as FAKE_IDENTITY_PROVIDERS, u as fakeKeyring, v as fakeInvoice, x as testProvidersEnabled, y as fakeLightning } from "./fakes-
|
|
3
|
+
import { i as verifyIdentity, r as descriptorProblems } from "./verify-C-u4HILn.js";
|
|
4
|
+
import { _ as fakeAddress, a as fakeAccount, b as fakeOnchain, c as fakeKeySign, d as fakeRecord, f as fakeRecordText, g as TEST_PROVIDERS_FLAG, h as FakeOnchainProvider, i as TEST_IDENTITIES_FLAG, l as fakeKeySubject, m as FakeLightningProvider, n as FAKE_ISSUER, o as fakeAccountToken, p as testIdentitiesEnabled, r as FAKE_RECORD_HOST, s as fakeKey, t as FAKE_IDENTITY_PROVIDERS, u as fakeKeyring, v as fakeInvoice, x as testProvidersEnabled, y as fakeLightning } from "./fakes-DSeGiDvk.js";
|
|
5
5
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
6
6
|
//#region ../browser/src/engine/paymentAdapters/providers/contractSuite.ts
|
|
7
7
|
var WAIT = 1e4;
|
|
@@ -13,3 +13,8 @@ export declare const APPS_ENABLED: boolean;
|
|
|
13
13
|
* themselves are still in the bundle (the registries import them); plugins may still pass fakes to the registry.
|
|
14
14
|
*/
|
|
15
15
|
export declare const testBuild: () => boolean;
|
|
16
|
+
/**
|
|
17
|
+
* A suite's switch in the page's storage (`localStorage["ghostly-test-…"]`), read only in a test build (`testBuild`): a
|
|
18
|
+
* release build reads none, so a leftover or pasted key changes nothing there. Null when unset, unreadable or released.
|
|
19
|
+
*/
|
|
20
|
+
export declare const testSwitch: (key: string) => string | null;
|
|
@@ -19,6 +19,12 @@ export declare const TEST_MINT = "https://testnut.cashu.space";
|
|
|
19
19
|
*/
|
|
20
20
|
export declare const TEST_MINTS: readonly string[];
|
|
21
21
|
export declare const isTestMint: (url: string) => boolean;
|
|
22
|
+
/**
|
|
23
|
+
* A mint URL spelled as the wallet stores its mints: lower-case scheme and host, no default port, no trailing slash.
|
|
24
|
+
* Another Cashu wallet's token or request names a mint as its user typed it (`HTTPS://Mint.Example:443/`), which is
|
|
25
|
+
* still one of ours. Not a check: `normalizeMintUrl` is the one that refuses a mint.
|
|
26
|
+
*/
|
|
27
|
+
export declare function mintUrlSpelling(url: string): string;
|
|
22
28
|
/** A mint on this very machine (a local test server): whatever it issues is not money anyone else holds. */
|
|
23
29
|
export declare function isLocalMint(url: string): boolean;
|
|
24
30
|
/**
|
|
@@ -159,6 +159,12 @@ export interface FileTransferRecord {
|
|
|
159
159
|
agreed?: boolean;
|
|
160
160
|
}
|
|
161
161
|
export declare const transferEnded: (record: FileTransferRecord) => boolean;
|
|
162
|
+
/**
|
|
163
|
+
* Whether a file sent from here arrived whole (the receiver confirmed every byte, and may be checking it): too late
|
|
164
|
+
* for its person to cancel. The receiver's check comes before a `pf-abort` behind it, so it would keep the file while
|
|
165
|
+
* the sender said it was cancelled. Not once the receiver asks about it again (`asking`), nor paused here.
|
|
166
|
+
*/
|
|
167
|
+
export declare function sentWhole(record: FileTransferRecord): boolean;
|
|
162
168
|
/**
|
|
163
169
|
* Whether an unfinished transfer is stuck, so its person is offered to push it: "Send again" (sending) or "Ask again"
|
|
164
170
|
* (receiving). `movedAt` is when its bytes last moved, `restored` that it has not moved since the app started. What
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RatchetBox, type RatchetState } from "./ratchet.js";
|
|
1
2
|
import type { LinkParams } from "./invite.js";
|
|
2
3
|
import type { PairingCredentials } from "./pairedSession.js";
|
|
3
4
|
import { type PkarrRequestOptions, type PkarrTransport } from "./transport.js";
|
|
@@ -104,6 +105,11 @@ export interface DhtDeliveryState {
|
|
|
104
105
|
* the chat is read as an invite nobody used (`unusedInviteWait`), counted from the join.
|
|
105
106
|
*/
|
|
106
107
|
unanswered?: number;
|
|
108
|
+
/**
|
|
109
|
+
* A digest of the contact's last ratcheted envelope taken (WISP 4xx § The DHT floor): a reader reads more often than
|
|
110
|
+
* the contact publishes, and a floor key once used is gone, so the same envelope read again is known by this.
|
|
111
|
+
*/
|
|
112
|
+
lastDr?: string;
|
|
107
113
|
}
|
|
108
114
|
export interface DhtDeliveryView {
|
|
109
115
|
mode: DeliveryMode;
|
|
@@ -122,6 +128,12 @@ export interface DhtDeliveryView {
|
|
|
122
128
|
foreignKeySeenAt?: number;
|
|
123
129
|
/** The invite was used by someone else first (`DhtDeliveryState.inviteTaken`): this side's texts reach nobody. */
|
|
124
130
|
inviteTaken?: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Forward secrecy of the floor (WISP 4xx): `on`, the turn passed both ways; `starting`, both apps have it and it is on
|
|
133
|
+
* once both have written; `unsupported`, the contact's app does not have it; `stopped`, it was on and the contact's
|
|
134
|
+
* app no longer says it has it (floor texts wait for the live session). Absent: this app does not run it here.
|
|
135
|
+
*/
|
|
136
|
+
forwardSecrecy?: "on" | "starting" | "unsupported" | "stopped";
|
|
125
137
|
}
|
|
126
138
|
/**
|
|
127
139
|
* What can be said about one DHT envelope without opening it: which text it carried, its sequence and times, the
|
|
@@ -162,6 +174,11 @@ export declare class DhtDelivery {
|
|
|
162
174
|
private live;
|
|
163
175
|
private active;
|
|
164
176
|
private readonly startedAt;
|
|
177
|
+
/**
|
|
178
|
+
* When an envelope of the contact's newer than any before was last read here, in this run. A contact that is there
|
|
179
|
+
* puts a keep-alive every four minutes: none in `PRESENCE_WINDOW`, it is away (`publish`).
|
|
180
|
+
*/
|
|
181
|
+
private peerNewAt;
|
|
165
182
|
/** The next read was asked for (a refresh, a fresh packet of the contact): it is not a background one. */
|
|
166
183
|
private urgent;
|
|
167
184
|
/** Reads left that are signaling: the contact is leaving DHT only, and the live link waits on them (`expect`). */
|
|
@@ -257,8 +274,25 @@ export declare class DhtDelivery {
|
|
|
257
274
|
* uses it, or while its inviter never answered the join (`unanswered`) (`unusedInviteWait`).
|
|
258
275
|
*/
|
|
259
276
|
inviteMadeAt?: number;
|
|
277
|
+
/**
|
|
278
|
+
* The chat's ratchet (WISP 4xx), shared with its held items, and whether the contact's capability record lists
|
|
279
|
+
* `ratchet/1`. Absent: every envelope is sealed as before.
|
|
280
|
+
*/
|
|
281
|
+
ratchet?: {
|
|
282
|
+
box: RatchetBox;
|
|
283
|
+
peerSupports(): boolean;
|
|
284
|
+
};
|
|
260
285
|
});
|
|
261
286
|
get view(): DhtDeliveryView;
|
|
287
|
+
private get forwardSecrecy();
|
|
288
|
+
/**
|
|
289
|
+
* Whether an envelope to `recipient` is sealed with the ratchet: the contact is pinned and its record lists
|
|
290
|
+
* `ratchet/1`, or a ratcheted envelope of its was opened here, after which nothing goes plain (WISP 4xx § Downgrade).
|
|
291
|
+
* And the contact pinned this side too (an envelope of its sealed to this side read, or a live session had): a joiner
|
|
292
|
+
* pins its inviter from the invite, and its first contact sealed with the ratchet would reach an inviter that has no key
|
|
293
|
+
* to open it with, and so never pins it.
|
|
294
|
+
*/
|
|
295
|
+
private ratcheted;
|
|
262
296
|
/**
|
|
263
297
|
* This side joined, and its inviter never answered (`DhtDeliveryState.unanswered`): no envelope of its newer than the
|
|
264
298
|
* one that pinned it, none sealed to this side, no text confirmed, never live (as `sealedToAnother` asks too).
|
|
@@ -276,6 +310,9 @@ export declare class DhtDelivery {
|
|
|
276
310
|
*/
|
|
277
311
|
private pinned;
|
|
278
312
|
private lastPublished?;
|
|
313
|
+
/** The envelope a trace line was last said for, per step: a packet read again says nothing new (a Desktop logs every line). */
|
|
314
|
+
private traced;
|
|
315
|
+
private traceOnce;
|
|
279
316
|
/** The sealed record's nonce is its first 24 bytes: 32 characters of base64. */
|
|
280
317
|
private static facts;
|
|
281
318
|
get comparisonCode(): string | undefined;
|
|
@@ -286,6 +323,16 @@ export declare class DhtDelivery {
|
|
|
286
323
|
private sealedKey;
|
|
287
324
|
private signed;
|
|
288
325
|
private records;
|
|
326
|
+
/**
|
|
327
|
+
* The envelope's records. Ratcheted (`ratcheted`), its `_dr` record is the right length but not sealed yet: `seal`
|
|
328
|
+
* gives its bytes, under the chat's lock, once the publication is sure to go. Measuring a packet takes no key.
|
|
329
|
+
*/
|
|
330
|
+
private envelope;
|
|
331
|
+
/**
|
|
332
|
+
* The records to publish: a ratcheted one sealed now, its state saved first (seal, save, send), from the plaintext
|
|
333
|
+
* the envelope was measured with.
|
|
334
|
+
*/
|
|
335
|
+
private sealed;
|
|
289
336
|
start(): Promise<void>;
|
|
290
337
|
stop(): Promise<void>;
|
|
291
338
|
setMode(mode: DeliveryMode): Promise<void>;
|
|
@@ -389,6 +436,8 @@ export declare class DhtDelivery {
|
|
|
389
436
|
* can write to) or `pinned`. `none`: nothing from the contact in it; `old`: the contact's, already read; `new`: taken.
|
|
390
437
|
*/
|
|
391
438
|
private receive;
|
|
439
|
+
/** `ratchet`: the envelope was ratcheted; its state is saved once what it carried is stored, with its digest. */
|
|
440
|
+
private take;
|
|
392
441
|
/**
|
|
393
442
|
* Reads the contact's mailbox: the pinned one first once the contact said it can use it, the invite's otherwise. The
|
|
394
443
|
* other is read too when the first held nothing from the contact (the contact publishes in the other one still, or a
|
|
@@ -427,6 +476,7 @@ export declare class DhtDelivery {
|
|
|
427
476
|
private schedule;
|
|
428
477
|
}
|
|
429
478
|
export declare const DHT_TEXT_REFUSED = "Your contact's app does not accept text over the DHT. It is sent when you are live.";
|
|
479
|
+
export declare const DHT_RATCHET_STOPPED = "Your contact's app no longer reads protected messages over the DHT. It is sent when you are live.";
|
|
430
480
|
export declare const DHT_FILE_REFUSED = "Your contact's app shows a file only once it comes. It is sent when you are live.";
|
|
431
481
|
export declare const DHT_FILE_TOO_LARGE = "This file's name is too long to say over the DHT. It is sent when you are live.";
|
|
432
482
|
/**
|
|
@@ -439,6 +489,7 @@ export declare function peekDhtMailbox(options: {
|
|
|
439
489
|
state?: DhtDeliveryState;
|
|
440
490
|
transport: PkarrTransport;
|
|
441
491
|
background?: boolean;
|
|
492
|
+
ratchet?: RatchetState;
|
|
442
493
|
}): Promise<{
|
|
443
494
|
reads: number;
|
|
444
495
|
text: string | null;
|
|
@@ -43,11 +43,12 @@ export declare function domainTxtRecord(r: DomainRecord): string;
|
|
|
43
43
|
/** Parses one TXT string. Undefined for anything that is not ours or not exactly
|
|
44
44
|
* well-formed; unknown extra tags are ignored for forward compatibility. */
|
|
45
45
|
export declare function parseDomainTxt(value: string): DomainRecord | undefined;
|
|
46
|
-
/** All records among the TXT strings of `_ghostly.<domain>`; other strings are skipped.
|
|
46
|
+
/** All records among the first 32 TXT strings of `_ghostly.<domain>`; other strings are skipped. A TXT set has
|
|
47
|
+
* no order, so every record is kept: the one a proof needs may come in any position. */
|
|
47
48
|
export declare function recordsFromTxt(values: string[]): DomainRecord[];
|
|
48
49
|
/** The body of `/.well-known/ghostly.json`. */
|
|
49
50
|
export declare function domainWellKnownFile(records: DomainRecord[]): string;
|
|
50
|
-
/** Records from `ghostly.json`. Throws on a malformed file; [] when it names none. */
|
|
51
|
+
/** Records from the first 32 entries of `ghostly.json`. Throws on a malformed file; [] when it names none. */
|
|
51
52
|
export declare function recordsFromWellKnown(text: string): DomainRecord[];
|
|
52
53
|
/** NIP-05: only the root name `_` speaks for the domain itself. Undefined when absent. */
|
|
53
54
|
export declare function nip05RootKey(text: string): string | undefined;
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* none of these (a mint's own words, a provider's) stays as it is.
|
|
7
7
|
*
|
|
8
8
|
* `{name}` in a template is a value: a host or domain (no spaces), a network ("Mainnet" or "Testnet"), a chain's name,
|
|
9
|
-
* an ecash unit ("usd"),
|
|
9
|
+
* an ecash unit ("usd"), an amount (digits, with the separators of whatever locale wrote it), or a server's own `{reason}`
|
|
10
|
+
* (one line, last in its text).
|
|
10
11
|
*/
|
|
11
12
|
export declare const ENGINE_ERRORS: {
|
|
12
13
|
readonly mintUnreachable: "Could not reach {host}. Check the address: it should be a Cashu mint.";
|
|
@@ -23,13 +24,16 @@ export declare const ENGINE_ERRORS: {
|
|
|
23
24
|
readonly mintNotHttps: "Mints must use https";
|
|
24
25
|
readonly notEnoughSats: "Not enough sats in your wallet";
|
|
25
26
|
readonly notEnoughForFee: "Not enough sats in your wallet: {amount} sats leave room for the fee";
|
|
27
|
+
readonly mintsNoAnyAmount: "None of your mints can pay an invoice with no amount";
|
|
26
28
|
readonly noSharedMint: "You share no mint with this contact";
|
|
27
29
|
readonly ecashAlreadySpent: "This ecash was already spent somewhere else";
|
|
28
30
|
readonly ecashBeingReceived: "This ecash is already being received";
|
|
31
|
+
readonly ecashFeeTakesAll: "The mint keeps all {amount} sats of this ecash as its fee to take it in: nothing was redeemed, and its sender can still take it back";
|
|
29
32
|
readonly ecashOtherUnit: "This ecash is in {unit}: only sat ecash can be redeemed here";
|
|
30
33
|
readonly reviewedEcashSpent: "The ecash for this payment was already spent somewhere else. Nothing was sent, and your balance now shows what the mint still holds.";
|
|
31
34
|
readonly reviewedSatsGone: "The sats this payment was reviewed with went to another payment. Nothing was sent: review it again.";
|
|
32
35
|
readonly lightningFeeTooHigh: "The Lightning fee ({fee} sats) is too high";
|
|
36
|
+
readonly lightningRefused: "The mint refused this Lightning payment, and no sats left your wallet: it is safe to try again. The mint said: {reason}";
|
|
33
37
|
readonly invoiceExpired: "That invoice has expired";
|
|
34
38
|
readonly lnurlExactly: "{domain} asks for exactly {amount} sats";
|
|
35
39
|
readonly lnurlRange: "{domain} takes between {min} and {max} sats";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RatchetBox } from "./ratchet.js";
|
|
1
2
|
import { type DeliveryMode, type DhtDeliveryState, type DhtDeliveryView, type DhtPacketFacts } from "./dhtDelivery.js";
|
|
2
3
|
import type { DhtFileAnnouncement, DhtFileOffer } from "./dhtFiles.js";
|
|
3
4
|
import { type ProofAdapter, type ProofScope } from "./peerProofs.js";
|
|
@@ -540,6 +541,11 @@ export interface GhostLinkOptions {
|
|
|
540
541
|
peerAcceptsFile?(): boolean;
|
|
541
542
|
/** This side's reactions the contact has not confirmed, oldest first: they ride on the envelopes. */
|
|
542
543
|
reactions?(): readonly WireReaction[];
|
|
544
|
+
/** The chat's ratchet (WISP 4xx) and whether the contact's record lists `ratchet/1`: the floor is sealed with it. */
|
|
545
|
+
ratchet?: {
|
|
546
|
+
box: RatchetBox;
|
|
547
|
+
peerSupports(): boolean;
|
|
548
|
+
};
|
|
543
549
|
};
|
|
544
550
|
rtcAvailable?: boolean;
|
|
545
551
|
/** `automatic`: the chat follows the app's rule (no transport chosen for it); `preferred` is then the rule's. Absent: automatic unless `preferred` is given. */
|
|
@@ -1272,6 +1278,8 @@ export declare class GhostLink {
|
|
|
1272
1278
|
private attemptEnded;
|
|
1273
1279
|
/** The last attempt to go live that did not (WISP 100, "Why a chat is not live"); none while live. */
|
|
1274
1280
|
get liveAttempt(): LiveAttempt | undefined;
|
|
1281
|
+
/** Automatic dials since the link was last live or its wait started over (`wake`), the one under way included. */
|
|
1282
|
+
get dialAttempts(): number;
|
|
1275
1283
|
/**
|
|
1276
1284
|
* Which side dials this chat to go live: the lower rendezvous key, or the joiner of a first pairing (WISP 100). The
|
|
1277
1285
|
* other side answers, so what it can tell of a failed attempt is only what reached it.
|
|
@@ -547,11 +547,31 @@ export declare class CommunitySession {
|
|
|
547
547
|
get canSend(): boolean;
|
|
548
548
|
/** The entry key of the group's link, or "" when it is off. */
|
|
549
549
|
get entryKey(): string;
|
|
550
|
+
/**
|
|
551
|
+
* The entry key of the link my admission that lost was let in by (the one its branch named), where I ask again: a
|
|
552
|
+
* link replaced since keeps me out as it does anyone. `entryKey` once that admission is no longer held.
|
|
553
|
+
*/
|
|
554
|
+
get lostEntryKey(): string;
|
|
550
555
|
role(key: string): GroupRole | undefined;
|
|
551
556
|
/** The group's picture, if it has one. */
|
|
552
557
|
get picture(): string | undefined;
|
|
553
|
-
/**
|
|
558
|
+
/**
|
|
559
|
+
* Members of any epoch in the window: whom a frame may come from. A side commit's roster counts only while its branch
|
|
560
|
+
* could still win (`mayWin`): one let in only on a branch that lost is not in the roster anyone sees, and the main
|
|
561
|
+
* branch past where they part, a later link among it, is not its business (`lostAt`).
|
|
562
|
+
*/
|
|
554
563
|
isRecentMember(key: string): boolean;
|
|
564
|
+
/**
|
|
565
|
+
* The side commits whose branch could still win: it does not drop an admin change the main branch holds (one that
|
|
566
|
+
* does never wins, see `better`), and it parts within the window. Kept until the tip or the side moves.
|
|
567
|
+
*/
|
|
568
|
+
private mayWin;
|
|
569
|
+
private winning;
|
|
570
|
+
/**
|
|
571
|
+
* For a key that is no recent member, let in on a branch that lost: the main-branch index it parts from, and that of
|
|
572
|
+
* the commit that makes it lose (the latest over its branches). Undefined for anyone else.
|
|
573
|
+
*/
|
|
574
|
+
private lostAt;
|
|
555
575
|
/**
|
|
556
576
|
* Whether `key` could read message `messageId` (`<s>:<e>:<h>:<n>`) and still can: a member of the roster it was sealed
|
|
557
577
|
* for, and of the roster now. A holder serves a group file only to such a member (WISP 503 § Asking).
|
|
@@ -61,6 +61,7 @@ export * from "./capsRecord.js";
|
|
|
61
61
|
export { DhtDelivery, peekDhtMailbox, DHT_TEXT_BYTES, DHT_MESSAGE_TTL, DHT_TEXT_REFUSED, DHT_FILE_REFUSED, DHT_FILE_TOO_LARGE, LIVE_POLL_MS, ACTIVE_DHT_POLL_MS, emptyDhtDeliveryState, type DeliveryMode, type DhtDeliveryState, type DhtDeliveryView, type DhtPacketFacts } from "./dhtDelivery.js";
|
|
62
62
|
export { DHT_FILE_CAPABILITY, dhtFileId, dhtFileElements, readDhtFile, type DhtFileAnnouncement, type DhtFileElement, type DhtFileMeta, type DhtFileOffer } from "./dhtFiles.js";
|
|
63
63
|
export * from "./storeForward.js";
|
|
64
|
+
export * from "./ratchet.js";
|
|
64
65
|
export * from "./paymentIntent.js";
|
|
65
66
|
export * from "./bitcoinAddress.js";
|
|
66
67
|
export * from "./sparkAddress.js";
|
|
@@ -90,6 +90,13 @@ export declare const UNUSED_INVITE_WAIT_MAX_MS: number;
|
|
|
90
90
|
* hunt 1014-0136, 2026-10-14).
|
|
91
91
|
*/
|
|
92
92
|
export declare const UNUSED_INVITE_READS_PER_MINUTE = 10;
|
|
93
|
+
/**
|
|
94
|
+
* An invite this side made that nobody used, once no longer awaited, puts its key and its mailbox out this often, not
|
|
95
|
+
* every `PRESENCE_HEARTBEAT`: 20 of them added about 17 relay writes a minute for as long as the app ran (bug hunt,
|
|
96
|
+
* 2026-10-30). Not longer: a joiner goes live sooner while it finds both still good, the packet within `PRESENCE_WINDOW`
|
|
97
|
+
* and the envelope unexpired. At 30 minutes the slowest of 6 joins took 235 s, against 86 s of 9 at the heartbeat's pace.
|
|
98
|
+
*/
|
|
99
|
+
export declare const UNUSED_INVITE_UPKEEP_MS: number;
|
|
93
100
|
/** Counts `reader` (an invite's key or mailbox) among the unused ones read over `transport` while `unused`, or no longer: how many there are. */
|
|
94
101
|
export declare function countUnusedInvite(transport: PkarrTransport, reader: object, unused: boolean): number;
|
|
95
102
|
/**
|
|
@@ -210,6 +217,8 @@ export interface LinkSessionOptions {
|
|
|
210
217
|
* longer awaited, read less often while nobody is there (`unusedInviteWait`).
|
|
211
218
|
*/
|
|
212
219
|
invite?: () => boolean;
|
|
220
|
+
/** Whether this is an invite this side made that nobody used yet (not one it joined): its upkeep slows too (`UNUSED_INVITE_UPKEEP_MS`). */
|
|
221
|
+
ownInvite?: () => boolean;
|
|
213
222
|
}
|
|
214
223
|
/** With `firstPublish: "after-first-poll"`, the first packet goes out by then whatever happened. */
|
|
215
224
|
export declare const FIRST_PUBLISH_MAX_MS = 2000;
|
|
@@ -258,6 +267,8 @@ export declare class LinkSession {
|
|
|
258
267
|
private readonly awaitingSince;
|
|
259
268
|
/** This side's invite, nobody used yet (`LinkSessionOptions.invite`). */
|
|
260
269
|
private readonly invite;
|
|
270
|
+
/** This side's own invite, nobody used yet (`LinkSessionOptions.ownInvite`). */
|
|
271
|
+
private readonly ownInvite;
|
|
261
272
|
private readonly intervals;
|
|
262
273
|
private fastPollUntil;
|
|
263
274
|
/** An offer to a saved contact is out: from then on its fast window looks less often (`OFFER_FAST_MS`); 0 for none. */
|
|
@@ -404,6 +415,8 @@ export declare class LinkSession {
|
|
|
404
415
|
/** How urgently this link looks right now. */
|
|
405
416
|
private pace;
|
|
406
417
|
private scheduleHeartbeat;
|
|
418
|
+
/** An unused invite of this side's, no longer awaited, whose packet went out less than `UNUSED_INVITE_UPKEEP_MS` ago. */
|
|
419
|
+
private upkeepWaits;
|
|
407
420
|
/**
|
|
408
421
|
* Coalesces publishes: at most one in flight and one queued behind it. `upkeep`: nothing new to say (the heartbeat, a
|
|
409
422
|
* retry of what waits): with nothing else asked for since, the packet goes as upkeep (`publishOnce`).
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ratchet of a 1:1 chat's stored paths (WISP 4xx-ratchet, reserved number 407): what goes on the DHT floor
|
|
3
|
+
* (WISP 403) and what is held (WISP 404) is sealed with a key used once, from a double ratchet in the manner of
|
|
4
|
+
* Signal's (an X25519 step each time the turn passes, a one-way chain per message), so a participation key stolen
|
|
5
|
+
* later opens none of it once the turn has passed. The live session needs none: its transports agree fresh keys on
|
|
6
|
+
* every connection.
|
|
7
|
+
*
|
|
8
|
+
* Pure: every call takes a state and returns the next one. The caller holds one lock per chat from reading the state
|
|
9
|
+
* to saving the next (an open's until what it opened is stored), and saves a seal's state before the sealed bytes
|
|
10
|
+
* leave the device. Nothing here reads a clock or the network but through its options.
|
|
11
|
+
*/
|
|
12
|
+
export declare const RATCHET_CAPABILITY: "ratchet/1";
|
|
13
|
+
export type RatchetLane = "floor" | "hold";
|
|
14
|
+
/** version, lane, session id, the sender's ratchet key, the hold lane's previous chain length, the message number. */
|
|
15
|
+
export declare const RATCHET_HEADER_BYTES: number;
|
|
16
|
+
/** What sealing adds to a plaintext: the header and the 16-byte tag (the nonce is derived, never sent). */
|
|
17
|
+
export declare const RATCHET_OVERHEAD: number;
|
|
18
|
+
/**
|
|
19
|
+
* How far a message may be ahead of the last one opened on its chain. A mailbox shows only its newest envelope, so the
|
|
20
|
+
* floor's between were replaced unread: their keys are stepped over and never kept. A held item's are kept. A sender
|
|
21
|
+
* whose chain reaches the bound without the turn passing starts a new session rather than seal past it.
|
|
22
|
+
*/
|
|
23
|
+
export declare const MAX_SKIP: Record<RatchetLane, number>;
|
|
24
|
+
/** Keys kept for held items not opened yet, at most, oldest dropped first. */
|
|
25
|
+
export declare const MAX_SKIPPED_KEYS = 512;
|
|
26
|
+
/** A kept key, and a session only received on, is dropped this long after it was last of use: a held item lives 7 days. */
|
|
27
|
+
export declare const RATCHET_KEEP_MS: number;
|
|
28
|
+
/**
|
|
29
|
+
* A session that lost (`lost`) becomes current when its floor envelopes keep rising in sequence while the current one
|
|
30
|
+
* has opened no floor envelope for this long: two that started at once settle within one keep-alive (about four
|
|
31
|
+
* minutes), and a contact that lost its state meanwhile seals in its own session from then on.
|
|
32
|
+
*/
|
|
33
|
+
export declare const FOLLOW_MS: number;
|
|
34
|
+
interface Chain {
|
|
35
|
+
k: string;
|
|
36
|
+
n: number;
|
|
37
|
+
}
|
|
38
|
+
interface Lanes {
|
|
39
|
+
floor: Chain;
|
|
40
|
+
hold: Chain;
|
|
41
|
+
}
|
|
42
|
+
export interface RatchetSession {
|
|
43
|
+
/** 8 random bytes, base64url: the session, chosen by the side that started it. */
|
|
44
|
+
sid: string;
|
|
45
|
+
rk: string;
|
|
46
|
+
/** This side's ratchet secret; null while it is still the participation key's (the second side, before its first step). */
|
|
47
|
+
dhs: string | null;
|
|
48
|
+
dhsPub: string;
|
|
49
|
+
/** The contact's ratchet key; null until its first message (the second side). */
|
|
50
|
+
dhr: string | null;
|
|
51
|
+
send: Lanes;
|
|
52
|
+
/** How many held items the previous sending chain used: said in every header. */
|
|
53
|
+
pnHold: number;
|
|
54
|
+
recv: Lanes | null;
|
|
55
|
+
/** A message of the contact's opened under this session. */
|
|
56
|
+
heard: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* The highest floor sequence (WISP 403's, signed by the contact and kept across its restores) of an envelope opened
|
|
59
|
+
* under this session: what orders the contact's sessions, so an envelope from before both settled never wins.
|
|
60
|
+
*/
|
|
61
|
+
floorSeq?: number;
|
|
62
|
+
/** When a floor envelope was last opened under it. */
|
|
63
|
+
floorAt?: number;
|
|
64
|
+
/** A session that lost when both started at once, or came from before both settled: only opened with (but `FOLLOW_MS`). */
|
|
65
|
+
lost?: true;
|
|
66
|
+
/** When this side made or first opened it. */
|
|
67
|
+
made: number;
|
|
68
|
+
/**
|
|
69
|
+
* The turn passed both ways: this side stepped on a key of the contact's with a ratchet secret of its own, so what
|
|
70
|
+
* either side seals from now on needs secrets that are deleted after use, not the participation keys.
|
|
71
|
+
*/
|
|
72
|
+
fs: boolean;
|
|
73
|
+
at: number;
|
|
74
|
+
}
|
|
75
|
+
interface Skipped {
|
|
76
|
+
s: string;
|
|
77
|
+
d: string;
|
|
78
|
+
n: number;
|
|
79
|
+
k: string;
|
|
80
|
+
at: number;
|
|
81
|
+
}
|
|
82
|
+
export interface RatchetState {
|
|
83
|
+
v: 1;
|
|
84
|
+
/** The session this side seals with. */
|
|
85
|
+
current?: RatchetSession;
|
|
86
|
+
/**
|
|
87
|
+
* Sessions this side only opens with, newest last, at most `MAX_OTHERS`: the contact's that lost to this side's, this
|
|
88
|
+
* side's before the contact started anew, or one the contact had left.
|
|
89
|
+
*/
|
|
90
|
+
others: RatchetSession[];
|
|
91
|
+
/** Hold lane only. */
|
|
92
|
+
skipped: Skipped[];
|
|
93
|
+
retired: string[];
|
|
94
|
+
/** A ratcheted item from the contact was opened on this lane: from then on a plain one is refused there. */
|
|
95
|
+
heard: {
|
|
96
|
+
floor?: true;
|
|
97
|
+
hold?: true;
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
export declare const emptyRatchetState: () => RatchetState;
|
|
101
|
+
/** What both sides of one chat derive the ratchet from: never stored in the state. */
|
|
102
|
+
export interface RatchetKeys {
|
|
103
|
+
/** This side's participation seed (Ed25519, 32 bytes). */
|
|
104
|
+
seed: Uint8Array;
|
|
105
|
+
/** Both participation keys, z-base-32. */
|
|
106
|
+
self: string;
|
|
107
|
+
peer: string;
|
|
108
|
+
/** The chat's two rendezvous keys, z-base-32, in either order. */
|
|
109
|
+
rendezvous: [string, string];
|
|
110
|
+
/** The invite's secret (`LinkParams.encKeyB64`). */
|
|
111
|
+
secret: Uint8Array;
|
|
112
|
+
}
|
|
113
|
+
export interface RatchetOptions {
|
|
114
|
+
now?: number;
|
|
115
|
+
/** For test vectors only: where random bytes come from. */
|
|
116
|
+
random?: (bytes: number) => Uint8Array;
|
|
117
|
+
}
|
|
118
|
+
/** The root key a session starts from: the two participation keys' agreement, salted by the invite and the chat, per session id. */
|
|
119
|
+
export declare const ratchetRoot: (keys: RatchetKeys, sid: Uint8Array) => Uint8Array;
|
|
120
|
+
/**
|
|
121
|
+
* Seals one item for the contact on a lane, with the current session (started here when there is none, or when its
|
|
122
|
+
* chain on this lane reached `MAX_SKIP` without the turn passing: past it the contact could not step over to it). The
|
|
123
|
+
* state returned MUST be saved before the sealed bytes leave the device: a key is used once, and a crash between the
|
|
124
|
+
* two that kept the old state would use it again on other bytes.
|
|
125
|
+
*/
|
|
126
|
+
export declare function ratchetSeal(prev: RatchetState, keys: RatchetKeys, lane: RatchetLane, plaintext: Uint8Array, options?: RatchetOptions): {
|
|
127
|
+
state: RatchetState;
|
|
128
|
+
sealed: Uint8Array;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Opens an item the contact sealed. Null: not a ratcheted item of this chat on this lane, or one already opened, or
|
|
132
|
+
* past the bounds. Otherwise the plaintext, and `finish`, which gives the state to save once the item is stored and
|
|
133
|
+
* passed its path's own checks (a newer DHT sequence, a held item not taken before): those, not the ratchet, are what
|
|
134
|
+
* refuse a replay. `order`: a floor envelope's sequence, read from the body once opened. `fresh`: it came under a
|
|
135
|
+
* session this side did not know.
|
|
136
|
+
*/
|
|
137
|
+
export declare function ratchetOpen(prev: RatchetState, keys: RatchetKeys, lane: RatchetLane, sealed: Uint8Array, options?: RatchetOptions): {
|
|
138
|
+
plaintext: Uint8Array;
|
|
139
|
+
fresh: boolean;
|
|
140
|
+
finish(order?: number): RatchetState;
|
|
141
|
+
} | null;
|
|
142
|
+
/** Whether `sealed` is shaped as a ratcheted item of this lane (it may still not open). */
|
|
143
|
+
export declare const isRatcheted: (sealed: Uint8Array, lane: RatchetLane) => boolean;
|
|
144
|
+
/** The session a ratcheted item of this lane names (its `sid`, base64url), as its header says; undefined for anything else. */
|
|
145
|
+
export declare const ratchetSessionOf: (sealed: Uint8Array, lane: RatchetLane) => string | undefined;
|
|
146
|
+
/**
|
|
147
|
+
* Whether `sealed` names a session this side has no state of and did not retire: neither the current one nor one of the
|
|
148
|
+
* others. What the contact sealed in the session it shares with a device this profile was on before (a Move, a restore:
|
|
149
|
+
* WISP 4xx § Several devices) is such an item, once the turn passed there; so is anything under a made-up `sid`. It says
|
|
150
|
+
* nothing of whether the item is genuine: only that this side could not tell, having never had the session.
|
|
151
|
+
*/
|
|
152
|
+
export declare function ratchetUnknownSession(state: RatchetState | undefined, sealed: Uint8Array, lane: RatchetLane): boolean;
|
|
153
|
+
/** Whether forward secrecy is on for this chat: the turn passed both ways in the session this side seals with. */
|
|
154
|
+
export declare const ratchetOn: (state: RatchetState | undefined) => boolean;
|
|
155
|
+
/** Whether a lane refuses plain items from the contact: a ratcheted one opened there (WISP 4xx § Downgrade). */
|
|
156
|
+
export declare const ratchetHeard: (state: RatchetState | undefined, lane: RatchetLane) => boolean;
|
|
157
|
+
/**
|
|
158
|
+
* One chat's ratchet, shared by its two lanes (the DHT floor and held items): the one lock per chat of WISP 4xx §
|
|
159
|
+
* Saving state, and the order of saving. Every change goes through `lock`, so a seal and an open never start from the
|
|
160
|
+
* same state.
|
|
161
|
+
*/
|
|
162
|
+
export declare class RatchetBox {
|
|
163
|
+
private readonly keys;
|
|
164
|
+
private state;
|
|
165
|
+
private readonly save;
|
|
166
|
+
private chain;
|
|
167
|
+
constructor(keys: () => RatchetKeys, state: RatchetState, save: (state: RatchetState) => Promise<void>);
|
|
168
|
+
/** Runs `fn` alone among this chat's ratchet changes; `seal` and `open` are called inside it only. */
|
|
169
|
+
lock<T>(fn: (box: RatchetTransaction) => Promise<T>): Promise<T>;
|
|
170
|
+
private transaction;
|
|
171
|
+
/**
|
|
172
|
+
* Opens without keeping anything, and without the lock: a look from another profile, or the first half of a receive
|
|
173
|
+
* whose content is then stored with no lock held (`commitOpen` keeps it).
|
|
174
|
+
*/
|
|
175
|
+
peek(lane: RatchetLane, sealed: Uint8Array): Uint8Array | null;
|
|
176
|
+
/**
|
|
177
|
+
* The second half of a receive, once what `peek` gave is stored: opened again under the lock on the state as it is now
|
|
178
|
+
* (a seal or another open may have moved it meanwhile), and that state saved. False: it no longer opens (taken by a
|
|
179
|
+
* receive of the same item meanwhile), and nothing moved. So the lock is never held while content is stored, which
|
|
180
|
+
* may call back into the other lane.
|
|
181
|
+
*/
|
|
182
|
+
commitOpen(lane: RatchetLane, sealed: Uint8Array, order?: number): Promise<boolean>;
|
|
183
|
+
heard(lane: RatchetLane): boolean;
|
|
184
|
+
/** A ratcheted item from the contact opened on either lane: this side seals with the ratchet whatever the contact's record says. */
|
|
185
|
+
get heardAny(): boolean;
|
|
186
|
+
get on(): boolean;
|
|
187
|
+
/** The session this side seals with now, if any (its `sid`). */
|
|
188
|
+
get session(): string | undefined;
|
|
189
|
+
/** `ratchetUnknownSession` on the state as it is: an item under a session this side never had. */
|
|
190
|
+
unknownSession(lane: RatchetLane, sealed: Uint8Array): boolean;
|
|
191
|
+
}
|
|
192
|
+
export interface RatchetTransaction {
|
|
193
|
+
seal(lane: RatchetLane, plaintext: Uint8Array): Promise<Uint8Array>;
|
|
194
|
+
/** `commit(order)`: a floor envelope's sequence, as `ratchetOpen`'s `finish`. */
|
|
195
|
+
open(lane: RatchetLane, sealed: Uint8Array): {
|
|
196
|
+
plaintext: Uint8Array;
|
|
197
|
+
fresh: boolean;
|
|
198
|
+
commit(order?: number): Promise<void>;
|
|
199
|
+
} | null;
|
|
200
|
+
}
|
|
201
|
+
export {};
|
|
@@ -31,6 +31,14 @@ export declare const REQUESTS_PER_MINUTE = 30;
|
|
|
31
31
|
* signaling cannot wait, and a burst of signaling does not hold the background ones back afterwards.
|
|
32
32
|
*/
|
|
33
33
|
export declare const BACKGROUND_REQUESTS_PER_MINUTE = 20;
|
|
34
|
+
/**
|
|
35
|
+
* Of the background share, what background writes may spend in a minute on a relay (10 of the 20): the rest is kept
|
|
36
|
+
* for background reads. Those writes are mostly the upkeep of chats whose contacts are away (the link's heartbeat, the
|
|
37
|
+
* DHT floor's keep-alive, the capability record), about one a minute for every two chats. A profile with 200 such chats
|
|
38
|
+
* spent the share on them, and on one relay 147 of its 200 contacts were not read once in 25 minutes: a contact back
|
|
39
|
+
* then went unnoticed (bug hunt, 2026-11-01). Upkeep held back goes when a request of this share frees.
|
|
40
|
+
*/
|
|
41
|
+
export declare const BACKGROUND_WRITES_SHARE: number;
|
|
34
42
|
/**
|
|
35
43
|
* A link's write the budget refused (its presence, its offer, its answer) goes first when the minute
|
|
36
44
|
* frees a request: reads on that relay wait this long after the refusal. A link that polls fast for a
|
|
@@ -236,6 +244,11 @@ export interface RelayTransportOptions {
|
|
|
236
244
|
log?: (line: string) => void;
|
|
237
245
|
}
|
|
238
246
|
export declare function normalizeRelayUrl(input: string): string | null;
|
|
247
|
+
/**
|
|
248
|
+
* Why a line of a Pkarr relay list is not a relay `normalizeRelayUrl` keeps, with the line as typed; null when it is
|
|
249
|
+
* one. A host alone or another scheme (`relay.example.org`, `wss://…`) was meant as an https:// relay.
|
|
250
|
+
*/
|
|
251
|
+
export declare function relayUrlProblem(input: string): string | null;
|
|
239
252
|
/**
|
|
240
253
|
* A read the relays failed (or left alone for failing before), when its caller has another path to ask
|
|
241
254
|
* (`RelayTransport.resolve` with `keptOnFailure` false): `kept` is the newest packet the relays gave for the key before.
|
|
@@ -273,6 +286,8 @@ export declare class RelayTransport implements PkarrTransport {
|
|
|
273
286
|
private readonly lastReadFrom;
|
|
274
287
|
private readonly spent;
|
|
275
288
|
private readonly spentBackground;
|
|
289
|
+
/** Background writes on each relay in the last minute (`BACKGROUND_WRITES_SHARE`). */
|
|
290
|
+
private readonly spentBackgroundWrites;
|
|
276
291
|
/** Groups' urgent reads on each relay in the last `GROUP_BURST_MS`. */
|
|
277
292
|
private readonly spentGroupUrgent;
|
|
278
293
|
/** Watch reads on each relay in the last `GROUP_RATION_WINDOW_MS` (`WATCH_SHARE`). */
|
|
@@ -38,6 +38,15 @@ export declare const HOLD_LIMITS: {
|
|
|
38
38
|
*/
|
|
39
39
|
export declare const HOLD_DATED_BACK_MS: number;
|
|
40
40
|
export type HoldKind = "text" | "file" | "pay-req" | "manifest";
|
|
41
|
+
type HoldItem = {
|
|
42
|
+
mailbox: string;
|
|
43
|
+
seq: number;
|
|
44
|
+
id: string;
|
|
45
|
+
ts: number;
|
|
46
|
+
kind: HoldKind;
|
|
47
|
+
meta?: unknown;
|
|
48
|
+
expires: number;
|
|
49
|
+
};
|
|
41
50
|
export interface HoldFileMeta {
|
|
42
51
|
name: string;
|
|
43
52
|
size: number;
|
|
@@ -80,8 +89,10 @@ export interface HoldPointer {
|
|
|
80
89
|
}
|
|
81
90
|
/** Why a bundle, manifest or pointer was refused. Never a reason to trust it a little. */
|
|
82
91
|
export declare class HoldRefusedError extends Error {
|
|
83
|
-
readonly reason: "size" | "format" | "tampered" | "not-for-me" | "author" | "signature" | "digest" | "limits" | "expired";
|
|
84
|
-
|
|
92
|
+
readonly reason: "size" | "format" | "tampered" | "not-for-me" | "author" | "signature" | "digest" | "limits" | "expired" | "plain";
|
|
93
|
+
/** The bytes the chat's ratchet opened, when it opened them before the item was refused: the caller commits them. */
|
|
94
|
+
ratcheted?: Uint8Array;
|
|
95
|
+
constructor(reason: "size" | "format" | "tampered" | "not-for-me" | "author" | "signature" | "digest" | "limits" | "expired" | "plain", message: string);
|
|
85
96
|
}
|
|
86
97
|
declare const newMailbox: () => string;
|
|
87
98
|
export { newMailbox as newHoldMailbox };
|
|
@@ -102,29 +113,39 @@ export declare class HoldKeys {
|
|
|
102
113
|
private readonly sealKey;
|
|
103
114
|
constructor(params: LinkParams, participationSeedB64: string, peerKey: string);
|
|
104
115
|
/** Seals one item for the contact: signed with my participation key, encrypted to our shared key. */
|
|
105
|
-
seal(item:
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}, body: Uint8Array): Uint8Array;
|
|
116
|
+
seal(item: HoldItem, body: Uint8Array): Uint8Array;
|
|
117
|
+
/**
|
|
118
|
+
* The same item as a version-2 bundle (WISP 4xx § Held items): the same plaintext, sealed by the chat's ratchet
|
|
119
|
+
* (`seal`, which saves the ratchet's state before it returns), so the bundle can be uploaded once this returns.
|
|
120
|
+
*/
|
|
121
|
+
sealRatcheted(item: HoldItem, body: Uint8Array, seal: (plaintext: Uint8Array) => Promise<Uint8Array>): Promise<Uint8Array>;
|
|
122
|
+
/** What a bundle seals: the header's length, the signed header, the body. */
|
|
123
|
+
private inner;
|
|
114
124
|
/**
|
|
115
125
|
* Opens a bundle the contact sealed for me. Everything is checked before anything is returned: the
|
|
116
126
|
* authenticated encryption, the header's shape, that it names this link, this contact and me, the
|
|
117
127
|
* signature, the body digest and the limits of its kind. `loopback`: see `isHoldUrl`.
|
|
118
128
|
*/
|
|
129
|
+
/**
|
|
130
|
+
* `ratchet`: opens a version-2 bundle's sealed bytes (WISP 4xx), without keeping anything; absent, one is from a newer
|
|
131
|
+
* Ghostly. `refusePlain`: a ratcheted item from this contact opened here, so a version-1 item other than the manifest is
|
|
132
|
+
* refused (WISP 4xx § Downgrade). `ratcheted` in the result: the bytes the ratchet opened, for the caller to commit once
|
|
133
|
+
* the item is stored.
|
|
134
|
+
*/
|
|
119
135
|
open(bytes: Uint8Array, expect?: {
|
|
120
136
|
maxBytes?: number;
|
|
121
137
|
mailbox?: string;
|
|
122
138
|
now?: number;
|
|
123
139
|
loopback?: boolean;
|
|
140
|
+
ratchet?: (sealed: Uint8Array) => Uint8Array | null;
|
|
141
|
+
refusePlain?: boolean;
|
|
124
142
|
}): {
|
|
125
143
|
header: HoldHeader;
|
|
126
144
|
body: Uint8Array;
|
|
145
|
+
ratcheted?: Uint8Array;
|
|
127
146
|
};
|
|
147
|
+
/** The checks of `open` once the bundle is decrypted. */
|
|
148
|
+
private read;
|
|
128
149
|
/** My pointer, as records to publish under `identity`. Throws when it cannot fit a packet. */
|
|
129
150
|
pointerRecords(pointer: HoldPointer, now?: number): GhostRecord[];
|
|
130
151
|
/**
|