@ghostlytools/sdk 1.13.1 → 1.13.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/dist/{bitcoinAddress-BbPG0DF7.js → bitcoinAddress-DifDz48H.js} +254 -34
- package/dist/bitcoinAddress-DifDz48H.js.map +1 -0
- package/dist/core.js +534 -95
- package/dist/core.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/{pairedTransports-C0I24YFz.js → pairedTransports-D8ZSZJBi.js} +22 -16
- package/dist/pairedTransports-D8ZSZJBi.js.map +1 -0
- package/dist/testing.js +2 -2
- package/dist/types/browser/src/proofs/contract.d.ts +2 -1
- package/dist/types/core/src/appStatements.d.ts +16 -0
- package/dist/types/core/src/canonicalJson.d.ts +9 -0
- package/dist/types/core/src/chatFiles.d.ts +36 -4
- package/dist/types/core/src/deviceInvite.d.ts +16 -2
- package/dist/types/core/src/didDht.d.ts +2 -1
- package/dist/types/core/src/engineErrors.d.ts +6 -0
- package/dist/types/core/src/groupCommunity.d.ts +10 -0
- package/dist/types/core/src/groupSession.d.ts +40 -3
- package/dist/types/core/src/identityProofs.d.ts +44 -2
- package/dist/types/core/src/link.d.ts +1 -1
- package/dist/types/core/src/linkPreview.d.ts +13 -1
- package/dist/types/core/src/linkTrace.d.ts +2 -0
- package/dist/types/core/src/localNames.d.ts +7 -0
- package/dist/types/core/src/relay.d.ts +27 -1
- package/dist/types/core/src/transportSwitch.d.ts +7 -3
- package/dist/{verify-BoVhjvc_.js → verify-DpuVYnNs.js} +2 -2
- package/dist/{verify-BoVhjvc_.js.map → verify-DpuVYnNs.js.map} +1 -1
- package/package.json +1 -1
- package/dist/bitcoinAddress-BbPG0DF7.js.map +0 -1
- package/dist/pairedTransports-C0I24YFz.js.map +0 -1
|
@@ -149,7 +149,8 @@ export declare function openDidDhtPayload(did: string, payload: Uint8Array): Dec
|
|
|
149
149
|
/**
|
|
150
150
|
* Resolves a did:dht through Pkarr relays: one GET to each, all at once, and the newest packet that
|
|
151
151
|
* checks out wins (the highest sequence number; on a tie, the relay listed first), so a relay holding
|
|
152
|
-
* an older version cannot bring back a removed key or undo a deactivation.
|
|
152
|
+
* an older version cannot bring back a removed key or undo a deactivation. It waits for every relay
|
|
153
|
+
* that answers within the fetch's timeout, not only the first. Each answer is bounded to
|
|
153
154
|
* a BEP44 item, its signature checked against the DID's key and its records parsed strictly; a relay
|
|
154
155
|
* that has nothing, fails or serves a packet that does not check out does not count. A deactivated DID
|
|
155
156
|
* resolves (`metadata.deactivated`); everything else that goes wrong throws a `DidDhtError`.
|
|
@@ -30,6 +30,7 @@ export declare const ENGINE_ERRORS: {
|
|
|
30
30
|
readonly ecashBeingReceived: "This ecash is already being received";
|
|
31
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";
|
|
32
32
|
readonly ecashOtherUnit: "This ecash is in {unit}: only sat ecash can be redeemed here";
|
|
33
|
+
readonly ecashUnnamedUnit: "This ecash is in another unit: only sat ecash can be redeemed here";
|
|
33
34
|
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.";
|
|
34
35
|
readonly reviewedSatsGone: "The sats this payment was reviewed with went to another payment. Nothing was sent: review it again.";
|
|
35
36
|
readonly mintFailedQuote: "{host} could not take this payment right now, and no sats left your wallet: try again later. The mint said: {reason}";
|
|
@@ -101,6 +102,11 @@ export declare class EngineError extends Error {
|
|
|
101
102
|
/** The English text of `code` with its values in it, exactly as the engine writes it. */
|
|
102
103
|
export declare function engineText(code: EngineErrorCode, values?: EngineErrorValues): string;
|
|
103
104
|
export declare const engineError: (code: EngineErrorCode, values?: EngineErrorValues) => EngineError;
|
|
105
|
+
/**
|
|
106
|
+
* Why ecash of `unit` is not redeemed here. The unit is named only when it looks like one: a token's unit is whatever
|
|
107
|
+
* its sender wrote, and the line is the app's own (a contact's payment's refusal row, the CLI's answer).
|
|
108
|
+
*/
|
|
109
|
+
export declare const ecashUnitError: (unit: string) => EngineError;
|
|
104
110
|
/** The code and values of a text the engine wrote, or null for any other text (it is then shown as it is). */
|
|
105
111
|
export declare function parseEngineError(text: string): {
|
|
106
112
|
code: EngineErrorCode;
|
|
@@ -1022,6 +1022,16 @@ export declare class CommunitySession {
|
|
|
1022
1022
|
* (`reseal`) carries the first one's place inside: its author's are opened to tell.
|
|
1023
1023
|
*/
|
|
1024
1024
|
forget(id: string): void;
|
|
1025
|
+
/**
|
|
1026
|
+
* The frames whose reply quotes a message deleted for everyone (`gone`): the line of it (`r.s`) is sealed with them,
|
|
1027
|
+
* and opens with the epoch secret this profile keeps. Mine is sealed again with an empty line, in its place, time and
|
|
1028
|
+
* reply, and signed again: a member who holds the first drops it as seen, one who missed it gets the reply without
|
|
1029
|
+
* the line. A member's I cannot sign again: it goes, and its author hands it on. Either way the row that held the
|
|
1030
|
+
* first gives it up; mine is saved with the state from then on.
|
|
1031
|
+
*/
|
|
1032
|
+
private unquote;
|
|
1033
|
+
/** The key a stored frame is sealed with, when I hold its epoch's secret. */
|
|
1034
|
+
private messageKey;
|
|
1025
1035
|
/** The id of the message a stored frame is, by its first place when it was said again (and I can open it). */
|
|
1026
1036
|
private storedId;
|
|
1027
1037
|
private keep;
|
|
@@ -25,6 +25,12 @@ export declare const GROUP_LIMITS: {
|
|
|
25
25
|
/** Own messages kept for catch-up: count and total ciphertext bytes. */
|
|
26
26
|
readonly outlog: 32;
|
|
27
27
|
readonly outlogBytes: number;
|
|
28
|
+
/**
|
|
29
|
+
* Own messages past that log that members may not have taken (`GroupState.owed`): count and total ciphertext bytes.
|
|
30
|
+
* With the log, the 256 a member takes in one answer.
|
|
31
|
+
*/
|
|
32
|
+
readonly owed: 224;
|
|
33
|
+
readonly owedBytes: number;
|
|
28
34
|
/** Frames waiting for an epoch (or its secret) that has not arrived yet. */
|
|
29
35
|
readonly waiting: 64;
|
|
30
36
|
readonly waitingBytes: number;
|
|
@@ -302,6 +308,12 @@ export interface GroupState {
|
|
|
302
308
|
seqEpoch: number;
|
|
303
309
|
/** My own frames, newest last, for members who missed them. */
|
|
304
310
|
sent: GroupMessageFrame[];
|
|
311
|
+
/**
|
|
312
|
+
* My own frames that fell out of `sent` though members may not have taken them (said past the pace they apply,
|
|
313
|
+
* `AuthorPace`), oldest first, until a sync of each other member of their epoch shows it holds them. At most
|
|
314
|
+
* `GROUP_LIMITS.owed` and `owedBytes`. Absent in states from before they were kept.
|
|
315
|
+
*/
|
|
316
|
+
owed?: GroupMessageFrame[];
|
|
305
317
|
/**
|
|
306
318
|
* Other members' frames, in the order they arrived, for members who missed them. Absent in states from before revision
|
|
307
319
|
* 0.9. With an app that keeps each frame with its message (`GroupSession`'s `onRows`), only the ones from before it
|
|
@@ -505,6 +517,14 @@ export declare class GroupSession {
|
|
|
505
517
|
private namesTaken;
|
|
506
518
|
/** Messages, and apart from them edits, taken per author (`AuthorPace`). In memory only. */
|
|
507
519
|
private messagePace;
|
|
520
|
+
/**
|
|
521
|
+
* My own frames as members pace them (`OWN_BURST`), and those of mine in `sent` it did not take: one of them that falls
|
|
522
|
+
* out of `sent` goes to `owed`. Then, per frame of `owed`, the members whose sync showed they hold it. In memory only:
|
|
523
|
+
* after a start, each owed frame waits for a sync of every member.
|
|
524
|
+
*/
|
|
525
|
+
private ownPace;
|
|
526
|
+
private overPace;
|
|
527
|
+
private owedHeld;
|
|
508
528
|
private editPace;
|
|
509
529
|
private queue;
|
|
510
530
|
/** Metadata frames that name a commit or an epoch I do not have yet, one signed by the admin and one by anyone else (`waitMeta`): tried again when the chain moves. */
|
|
@@ -542,6 +562,12 @@ export declare class GroupSession {
|
|
|
542
562
|
* word, so it never counts as seen. In memory only: the syncs come again when the edges do.
|
|
543
563
|
*/
|
|
544
564
|
private heard;
|
|
565
|
+
/**
|
|
566
|
+
* Per author and epoch, the highest number of its own signed frames I did not take at its pace (`AuthorPace`): what
|
|
567
|
+
* `lacking` names, so the author is asked for it again (it keeps it, `GroupState.owed`). Every member refuses the
|
|
568
|
+
* same frames of a burst, all past the last one it took, so nothing else shows they are missing. In memory only.
|
|
569
|
+
*/
|
|
570
|
+
private refused;
|
|
545
571
|
/**
|
|
546
572
|
* Per member: until when what comes over its edge may be its answer to my sync (`syncFrame`), a catch-up and not a
|
|
547
573
|
* message written just now. Each frame of the answer keeps it open: it goes a slice at a time. In memory only.
|
|
@@ -644,6 +670,8 @@ export declare class GroupSession {
|
|
|
644
670
|
* What a sync names in `miss` for one sender now: per epoch, the newest `GROUP_LIMITS.miss` numbers that never arrived.
|
|
645
671
|
* And, for an epoch of which none arrived, the newest numbers another member said it has (`heard`): a member back
|
|
646
672
|
* after someone joined, whose author wrote 32 since (all its own answer holds), had nothing below them to ask for.
|
|
673
|
+
* And, first, the oldest of those past the highest seen up to the highest of its frames I refused at its pace
|
|
674
|
+
* (`refused`): its answer brings them oldest first, so what is named changes as they come.
|
|
647
675
|
*/
|
|
648
676
|
missOf(sender: string): Record<string, number[]>;
|
|
649
677
|
/**
|
|
@@ -780,15 +808,24 @@ export declare class GroupSession {
|
|
|
780
808
|
private nextSeq;
|
|
781
809
|
/** A text sealed and signed as my frame `n` of `epoch`, with its boxes; `o`: where it was first said (`resealBehind`). */
|
|
782
810
|
private seal;
|
|
783
|
-
/** Into my bounded log, for members who missed it. */
|
|
811
|
+
/** Into my bounded log, for members who missed it; one said past the pace members apply goes on to `owed` when it falls out. */
|
|
784
812
|
private logOwn;
|
|
813
|
+
private owe;
|
|
814
|
+
/** Drops from `owed` each frame every other member of its epoch has shown, in a sync, that it holds. */
|
|
815
|
+
private owedTaken;
|
|
785
816
|
/**
|
|
786
817
|
* My message `id` was deleted for everyone: its frame, and each copy said again, keep their place in my log (`nextSeq`,
|
|
787
818
|
* `couldRead`, the removal's copies) and lose what they said. The log is in the saved state beside the epochs' secrets,
|
|
788
819
|
* so the text stayed readable from the profile until 32 later sends pushed it out (`message delete --purge` promises
|
|
789
|
-
* it leaves the folder).
|
|
820
|
+
* it leaves the folder). A reply of mine that quotes it keeps its place and its reply, its line sealed again empty
|
|
821
|
+
* and signed whole again (`sig` does not cover the box). A member's frame of it, or quoting it, I kept to hand on goes:
|
|
822
|
+
* I cannot sign theirs, and its author hands it on. Saved soon, as a community's `forget`; `flush` writes it now.
|
|
790
823
|
*/
|
|
791
824
|
forget(id: string): void;
|
|
825
|
+
/** The reply a frame's box holds, when it quotes `id` with a line of it. */
|
|
826
|
+
private quoting;
|
|
827
|
+
/** My frame `f` without the line of `id` it quotes (`forget`); `f` itself when it quotes none. */
|
|
828
|
+
private unquoted;
|
|
792
829
|
/**
|
|
793
830
|
* Saves, then sends my frame to every other member of its epoch still in the group (`saved`: the caller saved it). One no edge took (none was up:
|
|
794
831
|
* my app just opened) is remembered (`alone`): I may be behind on the chain without knowing, and members let in
|
|
@@ -1020,7 +1057,7 @@ export declare class GroupSession {
|
|
|
1020
1057
|
* opens).
|
|
1021
1058
|
*/
|
|
1022
1059
|
private handOut;
|
|
1023
|
-
/** My own messages a member's sync says it lacks, from my bounded log, for the epochs it was a member of. */
|
|
1060
|
+
/** My own messages a member's sync says it lacks, from my bounded log (and `owed`), for the epochs it was a member of. */
|
|
1024
1061
|
private handOwn;
|
|
1025
1062
|
private ownLacked;
|
|
1026
1063
|
/** A frame of a message deleted for everyone (`hooks.removed`, or one of mine `forget` emptied): handed to nobody, its removal is what they get. */
|
|
@@ -35,6 +35,19 @@ export declare const IDENTITY_MAX_RECEIVED = 16;
|
|
|
35
35
|
/** `idp-*` frames a paired session reads from the contact per `IDENTITY_FRAME_WINDOW_MS`; the rest are dropped unread. */
|
|
36
36
|
export declare const IDENTITY_FRAME_LIMIT = 40;
|
|
37
37
|
export declare const IDENTITY_FRAME_WINDOW_MS = 60000;
|
|
38
|
+
/**
|
|
39
|
+
* `idp-*` frames this side sends a contact per `IDENTITY_SEND_WINDOW_MS`, so that the person's own shares and stops fit
|
|
40
|
+
* the contact's per-chat limits above and none is dropped unread there. Lower than the contact's count over a longer
|
|
41
|
+
* window: frames can arrive closer together than they left.
|
|
42
|
+
*/
|
|
43
|
+
export declare const IDENTITY_SEND_LIMIT: number;
|
|
44
|
+
export declare const IDENTITY_SEND_WINDOW_MS: number;
|
|
45
|
+
/**
|
|
46
|
+
* A request or withdraw the contact did not answer is sent again after this (ms), twice as long each time, at most
|
|
47
|
+
* `IDENTITY_RESENDS` times a connection; past that it waits for the next one, as before.
|
|
48
|
+
*/
|
|
49
|
+
export declare const IDENTITY_RESEND_MS = 60000;
|
|
50
|
+
export declare const IDENTITY_RESENDS = 4;
|
|
38
51
|
/**
|
|
39
52
|
* A proof this side holds verified, presented again with the same evidence between the same keys, is answered from that
|
|
40
53
|
* check while it is younger than this (seconds): the contact chooses how often it presents, and each check costs this
|
|
@@ -214,6 +227,11 @@ export interface IdentityExchangeOptions {
|
|
|
214
227
|
revoked?(statement: IdentityStatement): Promise<boolean>;
|
|
215
228
|
now?(): number;
|
|
216
229
|
onError?(error: string): void;
|
|
230
|
+
/**
|
|
231
|
+
* Off: every frame goes at once and nothing unanswered is sent again in a connection (for tests that play a contact
|
|
232
|
+
* sending past the limits). On by default: `IDENTITY_SEND_LIMIT`, `IDENTITY_RESEND_MS`.
|
|
233
|
+
*/
|
|
234
|
+
paced?: boolean;
|
|
217
235
|
}
|
|
218
236
|
export type IdentityStatus = "verified" | "expired" | "withdrawn" | "revoked" | "unconfirmed" | "previous-key";
|
|
219
237
|
/** What the verifier should show for a received proof right now. */
|
|
@@ -252,19 +270,44 @@ export declare class IdentityExchange {
|
|
|
252
270
|
private requested;
|
|
253
271
|
/** The nonces of the presentations in their provider's check now. */
|
|
254
272
|
private checking;
|
|
273
|
+
/**
|
|
274
|
+
* The nonces of the challenges sent on this connection. A presentation is signed for its session, so a challenge
|
|
275
|
+
* from a closed link that is not in its check now can no longer be answered.
|
|
276
|
+
*/
|
|
277
|
+
private issued;
|
|
255
278
|
/** When the contact's presentations were checked with their provider (seconds), for `IDENTITY_MAX_CHECKS_PER_HOUR`. */
|
|
256
279
|
private checks;
|
|
280
|
+
/** When this side sent its recent frames (ms), for `IDENTITY_SEND_LIMIT`. Kept across connections, as the contact's count is. */
|
|
281
|
+
private sentAt;
|
|
282
|
+
/** Hello, answers and presentations waiting for room in that window, in order (`proof`: a presentation's). */
|
|
283
|
+
private outbox;
|
|
284
|
+
/**
|
|
285
|
+
* This connection's request or withdraw per proof: when it (or its presentation) last went, how often, and whether its
|
|
286
|
+
* presentation went. Requests and withdraws are built from the ledger when their turn comes, so one stopped or
|
|
287
|
+
* answered meanwhile never goes.
|
|
288
|
+
*/
|
|
289
|
+
private attempts;
|
|
290
|
+
private timer;
|
|
257
291
|
constructor(options: IdentityExchangeOptions);
|
|
258
292
|
private now;
|
|
259
293
|
/** The ledger with one more step on the chat's timeline, in milliseconds (a test's clock, in seconds, when given). */
|
|
260
294
|
private log;
|
|
261
295
|
private incomingScope;
|
|
262
296
|
private send;
|
|
297
|
+
/** Sends one frame and counts it; false when the channel is gone (what waits is sent on the next connection). */
|
|
298
|
+
private transmit;
|
|
299
|
+
private static resendAfter;
|
|
300
|
+
/**
|
|
301
|
+
* Sends what fits the contact's limits now and sets a timer for the rest: the waiting answers first, then requests
|
|
302
|
+
* (at most `MAX_CHALLENGES` open, each keeping room in the window for its presentation) and withdraws, then the
|
|
303
|
+
* unanswered ones again once their time is up.
|
|
304
|
+
*/
|
|
305
|
+
private pump;
|
|
263
306
|
private shared;
|
|
264
307
|
private setShared;
|
|
265
308
|
/** The providers the contact said it verifies; undefined until its hello. */
|
|
266
309
|
get contactProviders(): readonly string[] | undefined;
|
|
267
|
-
/** The channel is ready: say what we verify, then send what the person queued while offline. */
|
|
310
|
+
/** The channel is ready: say what we verify, then send what the person queued while offline, paced (`pump`). */
|
|
268
311
|
ready(): void;
|
|
269
312
|
stop(): void;
|
|
270
313
|
/**
|
|
@@ -276,7 +319,6 @@ export declare class IdentityExchange {
|
|
|
276
319
|
private withoutExpired;
|
|
277
320
|
/** Share a proof of this profile with this contact: now if connected, else when it next is. */
|
|
278
321
|
share(id: string, connected: boolean): Promise<void>;
|
|
279
|
-
private request;
|
|
280
322
|
/** Stop sharing here. The contact is told (now or on reconnect); a copy it kept cannot be erased. */
|
|
281
323
|
withdraw(id: string, connected: boolean): Promise<void>;
|
|
282
324
|
/**
|
|
@@ -370,7 +370,7 @@ export declare class LinkSession {
|
|
|
370
370
|
* whose contacts are mostly away, for nothing those reads could find.
|
|
371
371
|
*/
|
|
372
372
|
private discoveryRecovered;
|
|
373
|
-
/** This side's packet goes out now, unless one already did. */
|
|
373
|
+
/** This side's packet goes out now, unless one already did (in this run, once it left DHT only: `presenceDue`). */
|
|
374
374
|
ensureAdvertised(): void;
|
|
375
375
|
/** This side's packet goes out again as it is: another writer of its key (a second device on a device code) may have replaced it. */
|
|
376
376
|
republish(): void;
|
|
@@ -27,6 +27,12 @@ export declare const LINK_PREVIEW_LIMITS: {
|
|
|
27
27
|
/** The preview as JSON. With a text of 16 KiB the message frame stays under the 60 KiB a session takes. */
|
|
28
28
|
readonly jsonChars: number;
|
|
29
29
|
};
|
|
30
|
+
/**
|
|
31
|
+
* Punctuation a sentence in Chinese, Japanese or Arabic puts right after a link, with no space: the ideographic comma
|
|
32
|
+
* and full stop, the full-width ! , : ; ? and brackets, the corner quotes, the Arabic comma, semicolon and question
|
|
33
|
+
* mark, the Urdu full stop. No address holds one as typed, so a link stops at the first.
|
|
34
|
+
*/
|
|
35
|
+
export declare const LINK_STOP_CHARS = "\u3001\u3002\u3008-\u3011\uFF01\uFF08\uFF09\uFF0C\uFF1A\uFF1B\uFF1F\u060C\u061B\u061F\u06D4";
|
|
30
36
|
/** What a link leaves out at its end: a sentence's punctuation ("…", "»", "”" too), never a path's "/". */
|
|
31
37
|
export declare const LINK_TRAILING: RegExp;
|
|
32
38
|
/** How many UTF-16 units of `url` before `end` are an emoji's or an invisible character's last code point (0: none). */
|
|
@@ -41,11 +47,17 @@ export declare function linkStop(url: string): string;
|
|
|
41
47
|
export declare function linkEnd(whole: string): string;
|
|
42
48
|
/**
|
|
43
49
|
* A payment link (`bitcoin:`, `monero:`…) ends as a web link does, but keeps an emoji at its end: its label or message
|
|
44
|
-
* is text written as it is ("…&label=Pizza 🍕"), cut at 140 characters wherever that falls.
|
|
50
|
+
* is text written as it is ("…&label=Pizza 🍕"), cut at 140 characters wherever that falls. A direction mark or
|
|
51
|
+
* isolate typed after it is still left out, so "bitcoin:bc1q…\u200f." pays bc1q….
|
|
45
52
|
*/
|
|
46
53
|
export declare function uriEnd(whole: string): string;
|
|
47
54
|
/** Characters of a link worth reading: a longer one is no address anyone shares, and is left as text. */
|
|
48
55
|
export declare const LINK_MAX_CHARS: number;
|
|
56
|
+
/**
|
|
57
|
+
* An http(s) link's run in a text, as a `RegExp` source: up to a space or a `LINK_STOP_CHARS` character, as the bubble
|
|
58
|
+
* reads it. A link written right after another one's "。" or "،", with no space, is a run of its own.
|
|
59
|
+
*/
|
|
60
|
+
export declare const LINK_RUN: string;
|
|
49
61
|
/** The http(s) links of a text, in order, each ending as the bubble ends it. */
|
|
50
62
|
export declare function linksIn(text: string): string[];
|
|
51
63
|
/**
|
|
@@ -8,5 +8,7 @@
|
|
|
8
8
|
type LinkTraceSink = (line: string) => void;
|
|
9
9
|
/** Where the lines go besides the console; `null` removes it. */
|
|
10
10
|
export declare function setLinkTraceSink(next: LinkTraceSink | null): void;
|
|
11
|
+
/** Whether the lines go anywhere: costly detail is gathered only then. */
|
|
12
|
+
export declare function linkTraceOn(): boolean;
|
|
11
13
|
export declare function traceLink(me: string, step: string, detail?: Record<string, unknown>): void;
|
|
12
14
|
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Names only a local network answers (RFC 6762, RFC 8375, ICANN's .internal, and the usual router and company ones).
|
|
3
|
+
* The same list as apps/ui/src/lib/localHost.ts and Desktop's apps/desktop/src/local_names.rs (a test there pins them).
|
|
4
|
+
*/
|
|
5
|
+
export declare const LOCAL_SUFFIXES: readonly ["localhost", "local", "internal", "lan", "home", "home.arpa", "localdomain", "intranet", "corp"];
|
|
6
|
+
/** Whether a lowercase host with no trailing dot is one of `LOCAL_SUFFIXES` or under one. */
|
|
7
|
+
export declare const underLocalSuffix: (host: string) => boolean;
|
|
@@ -46,6 +46,19 @@ export declare const BACKGROUND_WRITES_SHARE: number;
|
|
|
46
46
|
* only thing that peer is waiting for) would go out only once the polling slowed down, half a minute later.
|
|
47
47
|
*/
|
|
48
48
|
export declare const WRITE_FIRST_MS = 5000;
|
|
49
|
+
/**
|
|
50
|
+
* A community door's read (`door`: its knock bell, and its beacon and lobby while someone comes in) the budget refused
|
|
51
|
+
* on a relay goes first there when the minute frees a request: the group edges' reads of members that went away
|
|
52
|
+
* (`watch`), the groups' reads at a slow pace and the background reads wait this long after the refusal, while it is not
|
|
53
|
+
* read. Nor does it wait behind the packets queued for that relay (`catchUpLater`). Writes, the chats' reads and the
|
|
54
|
+
* reads of a link that signals (`urgent`: an edge's, the session that lets the joiner in) do not wait for it, and it
|
|
55
|
+
* takes nothing past the minute: only the order changes. A door whose edges watched the members that had just left
|
|
56
|
+
* (`WATCH_SHARE`) and offered to them spent each relay's minute on them (about three quarters of it), and took a freed
|
|
57
|
+
* request only when its own read came first: its bell, read every 4 to 6 s, answered the packet from before the knock
|
|
58
|
+
* 3 to 6 times in a row, and a joiner waited 18 to 23 s to be let in, 5 link joins in 24, against 3 to 8 s for the
|
|
59
|
+
* others (CLI lab, 2026-11-17).
|
|
60
|
+
*/
|
|
61
|
+
export declare const DOOR_FIRST_MS = 5000;
|
|
49
62
|
/**
|
|
50
63
|
* Once a 1:1 chat needs the relays (the budget refused one of its requests there, or it read urgently anywhere: it polls
|
|
51
64
|
* fast for a signal due any moment), group requests and background ones leave it the last this many of each minute (more
|
|
@@ -373,6 +386,8 @@ export declare class RelayTransport implements PkarrTransport {
|
|
|
373
386
|
private readonly groupsFullAt;
|
|
374
387
|
/** When a link's write was last refused on each relay (`chat <relay>`, `group <relay>`), while it waits for the budget. */
|
|
375
388
|
private readonly writeWaiting;
|
|
389
|
+
/** When a community door's read was last refused on each relay, while it waits for the budget (`DOOR_FIRST_MS`). */
|
|
390
|
+
private readonly doorWaiting;
|
|
376
391
|
/** Per relay, the keys whose edges' reads for an answer it last refused, and when, until one is read (`ANSWER_READ_FIRST_MS`). */
|
|
377
392
|
private readonly answerReadWaiting;
|
|
378
393
|
/**
|
|
@@ -397,6 +412,11 @@ export declare class RelayTransport implements PkarrTransport {
|
|
|
397
412
|
* (`readHeldBackFor`), how many times in a row, and since when (`READ_STARVED_MS`).
|
|
398
413
|
*/
|
|
399
414
|
private readonly heldBack;
|
|
415
|
+
/**
|
|
416
|
+
* Per relay, the requests of the last minute and who asked for each: kept only while the link trace is on, for the
|
|
417
|
+
* tally a held-back read traces (`read.held`), which says what spent the minute it waits for.
|
|
418
|
+
*/
|
|
419
|
+
private readonly spentBy;
|
|
400
420
|
/** When the relays last answered a read of each key, for `FRESH_READ_MS`. */
|
|
401
421
|
private readonly readAt;
|
|
402
422
|
private readonly freshReadMs;
|
|
@@ -577,6 +597,11 @@ export declare class RelayTransport implements PkarrTransport {
|
|
|
577
597
|
/** The last read of this key was answered 404 (`HEDGE_MISSING_MS`): a relay takes seconds to say so. */
|
|
578
598
|
lastReadMissing(pubKeyZ32: string): boolean;
|
|
579
599
|
readHeldBackFor(pubKeyZ32: string): number | undefined;
|
|
600
|
+
/**
|
|
601
|
+
* The link trace's line for a read the budget held back (`read.held`): who asked, for how long, whether it answered
|
|
602
|
+
* the packet already known, and per relay what spent the last minute (who asked, how many; the keys asked most).
|
|
603
|
+
*/
|
|
604
|
+
private traceHeld;
|
|
580
605
|
private heldBackUntil;
|
|
581
606
|
/** The relays answered a read of this key now; answers older than `FRESH_READ_MS` are dropped as the list grows. */
|
|
582
607
|
private answeredRead;
|
|
@@ -611,7 +636,8 @@ export declare class RelayTransport implements PkarrTransport {
|
|
|
611
636
|
* group reads and background requests, never a chat's. Background requests yield to a link that signals. A chat's
|
|
612
637
|
* signaling goes over the limit by its allowance (`SIGNALING_ALLOWANCE_SHARE`), and so do a few of its reads of a
|
|
613
638
|
* contact that just went away (`DEPARTED_READS`) or of an invite awaited (`AWAITED_READS`). `ownAllowance` false: what holds an edge's read for its answer
|
|
614
|
-
* without its own allowance (`ANSWER_READ_ALLOWANCE`).
|
|
639
|
+
* without its own allowance (`ANSWER_READ_ALLOWANCE`). `limitFree` true: all but the minute's limit and the writes
|
|
640
|
+
* waiting (they go first), what still holds it once the minute frees requests (`DOOR_FIRST_MS`).
|
|
615
641
|
*/
|
|
616
642
|
private heldFor;
|
|
617
643
|
/**
|
|
@@ -19,10 +19,14 @@ export interface SwitchPlan {
|
|
|
19
19
|
upgrade?: boolean;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
* The contact's policies read per window. A choice, a retry or a session's start each say one
|
|
23
|
-
*
|
|
22
|
+
* The contact's policies read per window. A choice, a retry or a session's start each say one; every one read may plan
|
|
23
|
+
* a move this side dials. Past that only the newest waits, read once the window has room.
|
|
24
|
+
* A person moving the chat back and forth as fast as it goes says one per move, and a move back to the transport just
|
|
25
|
+
* left waits for its old session to retire (`SWITCH_RETIRE_MS`): about 20 a minute. At 10, the 11th move in a minute
|
|
26
|
+
* waited for the window: 50 s when the side that chose plans the moves (its plan, for a policy the contact had not read
|
|
27
|
+
* yet, timed out after 30 s and was tried again 20 s later), 4 of 50 back-to-back moves between two CLIs.
|
|
24
28
|
*/
|
|
25
|
-
export declare const POLICY_RECEIVE_LIMIT =
|
|
29
|
+
export declare const POLICY_RECEIVE_LIMIT = 30, POLICY_RECEIVE_WINDOW_MS = 60000;
|
|
26
30
|
export declare const allowedTransports: (policy: TransportPolicy) => ("iroh/1" | "hyperdht/1" | "webrtc/1")[];
|
|
27
31
|
/** Runs only inside a participation-authenticated channel. Both roles may propose;
|
|
28
32
|
* the lower rendezvous key coordinates a revision-checked plan, never both dials.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $ as DEFAULT_RELAYS, C as IdentityCheckUnavailable, E as boundVerifiedIdentity, wt as normalizeRelayUrl } from "./bitcoinAddress-DifDz48H.js";
|
|
2
2
|
// ../browser/src/proofs/pkarrRelays.ts
|
|
3
3
|
/**
|
|
4
4
|
* The profile's Pkarr relays (Network settings), which a did:dht proof is read from, as every other Pkarr read: a
|
|
@@ -122,4 +122,4 @@ function boundedIdentityFetch(options = { online: () => true }) {
|
|
|
122
122
|
}
|
|
123
123
|
export { verifyIdentity as i, boundedIdentityFetch as n, descriptorProblems as r, availableSigners as t };
|
|
124
124
|
|
|
125
|
-
//# sourceMappingURL=verify-
|
|
125
|
+
//# sourceMappingURL=verify-DpuVYnNs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify-BoVhjvc_.js","names":[],"sources":["../../browser/src/proofs/pkarrRelays.ts","../../browser/src/proofs/verify.ts"],"sourcesContent":["import { DEFAULT_RELAYS, normalizeRelayUrl } from \"@ghostly/core\";\n\n/**\n * The profile's Pkarr relays (Network settings), which a did:dht proof is read from, as every other Pkarr read: a\n * person who replaced the list is never read from the defaults. The UI and the engine each set where to read it. Here,\n * not in the provider, so setting it does not load the providers.\n */\nlet source: () => readonly string[] | undefined = () => undefined;\nexport function setPkarrRelaySource(read: () => readonly string[] | undefined): void { source = read; }\nexport function pkarrRelays(): string[] {\n const relays = source();\n return relays?.length ? [...relays] : [...DEFAULT_RELAYS];\n}\n\n/** Whether `url` is under one of the profile's Pkarr relays (`<relay>/…`). */\nexport function isOwnPkarrRelayUrl(url: URL): boolean {\n if (url.username || url.password) return false;\n return pkarrRelays().map(normalizeRelayUrl).some(relay => relay !== null && url.href.startsWith(`${relay}/`));\n}\n","import { boundVerifiedIdentity, IdentityCheckUnavailable, IDENTITY_MAX_EVIDENCE, IDENTITY_MAX_VALIDITY, type IdentityStatement, type VerifiedIdentity } from \"@ghostly/core\";\nimport type { IdentityFetch, IdentityProofProvider, IdentitySigner, VerifyContext } from \"./contract\";\nimport { isOwnPkarrRelayUrl } from \"./pkarrRelays\";\n\nconst DAY = 86_400;\n\n/**\n * The checks every proof goes through, whatever its provider: known provider, validity within the\n * provider's limit, bounded evidence, strict parsing, the provider's own check, and the category rule\n * (a self-custodied proof proves exactly the subject it names; an attested one says who attests it).\n * The engine verifies a contact's proof, and the person's own proof before saving it, only through this.\n */\nexport async function verifyIdentity(providers: readonly IdentityProofProvider[], statement: IdentityStatement, evidence: unknown, ctx: VerifyContext): Promise<VerifiedIdentity> {\n const { binding } = statement;\n const provider = providers.find(p => p.id === binding.provider);\n if (!provider) throw new Error(\"This app cannot verify this kind of identity\");\n if (binding.expiresAt - binding.issuedAt > Math.min(provider.validity.maxDays * DAY, IDENTITY_MAX_VALIDITY)) throw new Error(\"The proof lasts longer than this kind of identity allows\");\n if (JSON.stringify(evidence ?? null).length > IDENTITY_MAX_EVIDENCE) throw new Error(\"Evidence too large\");\n const parsed = provider.parseEvidence(evidence);\n const verified = boundVerifiedIdentity(await provider.verify(statement, parsed, ctx));\n if (provider.category === \"self-custodied\" && verified.subject !== binding.subject) throw new Error(\"The evidence is for another identity\");\n if (provider.category === \"provider-attested\" && !verified.attester) throw new Error(\"The evidence does not say who attests it\");\n return verified;\n}\n\n/** Problems with a provider's descriptor, empty when it is well-formed. The registry and the contract suite use it. */\nexport function descriptorProblems(p: IdentityProofProvider): string[] {\n const problems: string[] = [];\n if (!/^[a-z][a-z0-9-]{0,31}$/.test(p.id)) problems.push(\"id must match ^[a-z][a-z0-9-]{0,31}$\");\n if (!p.label?.trim()) problems.push(\"label is empty\");\n if (!p.description?.trim()) problems.push(\"description is empty\");\n if (!p.privacy?.trim()) problems.push(\"privacy is empty: say what verify contacts\");\n if (p.category !== \"self-custodied\" && p.category !== \"provider-attested\") problems.push(\"category is unknown\");\n if (!p.platforms.length) problems.push(\"no platforms\");\n const { defaultDays, maxDays } = p.validity;\n if (!(Number.isInteger(defaultDays) && Number.isInteger(maxDays) && defaultDays >= 1 && defaultDays <= maxDays && maxDays * DAY <= IDENTITY_MAX_VALIDITY)) problems.push(\"validity must be whole days, 1 ≤ default ≤ max ≤ 400\");\n if (p.recheck && !(Number.isInteger(p.recheck.afterSeconds) && p.recheck.afterSeconds >= 60)) problems.push(\"recheck.afterSeconds must be at least 60\");\n if (p.recheck?.perHour !== undefined && !(Number.isInteger(p.recheck.perHour) && p.recheck.perHour >= 1)) problems.push(\"recheck.perHour must be a whole number, at least 1\");\n if (!p.signers.length) problems.push(\"no signers\");\n const ids = p.signers.map(s => s.id);\n if (new Set(ids).size !== ids.length) problems.push(\"signer ids are not unique\");\n for (const s of p.signers as readonly IdentitySigner<unknown>[]) {\n if (![\"in-app\", \"external-tool\", \"redirect\", \"publish\"].includes(s.kind)) problems.push(`signer ${s.id} has an unknown kind`);\n if (s.kind === \"in-app\" && typeof s.run !== \"function\") problems.push(`signer ${s.id} has no run()`);\n if (s.kind === \"external-tool\" && (typeof s.instructions !== \"function\" || typeof s.parse !== \"function\")) problems.push(`signer ${s.id} needs instructions() and parse()`);\n if (s.kind === \"redirect\" && typeof s.start !== \"function\") problems.push(`signer ${s.id} has no start()`);\n if (s.kind === \"publish\" && (typeof s.instructions !== \"function\" || typeof s.evidence !== \"function\")) problems.push(`signer ${s.id} needs instructions() and evidence()`);\n }\n return problems;\n}\n\n/** Signers of a provider that run on this platform and are available in this window. */\nexport function availableSigners<E>(p: IdentityProofProvider<E>, platform: IdentityProofProvider[\"platforms\"][number]): IdentitySigner<E>[] {\n return p.signers.filter(s => (s.platforms ?? p.platforms).includes(platform) && (s.available?.() ?? true));\n}\n\n/**\n * The engine's `ctx.fetch`: HTTPS GET only, no credentials or referrer, a time-out, a size cap,\n * redirects refused unless asked for.\n * `online` false refuses everything (the person turned the network off).\n * A did:dht read of the profile's own Pkarr relays (`ownPkarrRelay`) may be http://, through `relayFetcher`: those are\n * the relays the person chose, as the chats read them, not an address a contact named.\n */\nexport function boundedIdentityFetch(options: { online: () => boolean; timeoutMs?: number; fetcher?: typeof fetch; relayFetcher?: typeof fetch } = { online: () => true }): IdentityFetch {\n return async (url, { headers, maxBytes = 64 * 1024, signal, redirect = \"error\", ownPkarrRelay } = {}) => {\n if (!options.online()) throw new IdentityCheckUnavailable(\"Offline: this identity cannot be checked now\");\n const target = new URL(url);\n const ownRelay = ownPkarrRelay === true && isOwnPkarrRelayUrl(target);\n if (!ownRelay && (target.protocol !== \"https:\" || target.username || target.password)) throw new Error(\"Identity checks use HTTPS only\");\n const timeout = AbortSignal.timeout(options.timeoutMs ?? 10_000);\n const fetcher = (ownRelay ? options.relayFetcher : undefined) ?? options.fetcher ?? fetch;\n const response = await fetcher(target.href, {\n headers, signal: signal ? AbortSignal.any([signal, timeout]) : timeout,\n credentials: \"omit\", referrerPolicy: \"no-referrer\", cache: \"no-store\", redirect,\n });\n if (Number(response.headers.get(\"content-length\")) > maxBytes) throw new Error(\"Identity check response too large\");\n const reader = response.body?.getReader();\n const parts: Uint8Array[] = [];\n let length = 0;\n if (reader) {\n try {\n for (;;) {\n const { done, value } = await reader.read();\n if (done) break;\n length += value.length;\n if (length > maxBytes) throw new Error(\"Identity check response too large\");\n parts.push(value);\n }\n } finally { await reader.cancel().catch(() => {}); }\n }\n const bytes = new Uint8Array(length);\n let offset = 0;\n for (const part of parts) { bytes.set(part, offset); offset += part.length; }\n return { status: response.status, contentType: response.headers.get(\"content-type\") ?? \"\", text: new TextDecoder().decode(bytes), bytes };\n };\n}\n"],"mappings":";;;;;;;AAOA,IAAI,eAAoD,KAAA;AAExD,SAAgB,cAAwB;CACtC,MAAM,SAAS,OAAO;CACtB,OAAO,QAAQ,SAAS,CAAC,GAAG,MAAM,IAAI,CAAC,GAAG,cAAc;AAC1D;;AAGA,SAAgB,mBAAmB,KAAmB;CACpD,IAAI,IAAI,YAAY,IAAI,UAAU,OAAO;CACzC,OAAO,YAAY,CAAC,CAAC,IAAI,iBAAiB,CAAC,CAAC,MAAK,UAAS,UAAU,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D,MAAM,QAAQ,IAAI,WAAW,MAAM;EACnC,IAAI,SAAS;EACb,KAAK,MAAM,QAAQ,OAAO;GAAE,MAAM,IAAI,MAAM,MAAM;GAAG,UAAU,KAAK;EAAQ;EAC5E,OAAO;GAAE,QAAQ,SAAS;GAAQ,aAAa,SAAS,QAAQ,IAAI,cAAc,KAAK;GAAI,MAAM,IAAI,YAAY,CAAC,CAAC,OAAO,KAAK;GAAG;EAAM;CAC1I;AACF"}
|
|
1
|
+
{"version":3,"file":"verify-DpuVYnNs.js","names":[],"sources":["../../browser/src/proofs/pkarrRelays.ts","../../browser/src/proofs/verify.ts"],"sourcesContent":["import { DEFAULT_RELAYS, normalizeRelayUrl } from \"@ghostly/core\";\n\n/**\n * The profile's Pkarr relays (Network settings), which a did:dht proof is read from, as every other Pkarr read: a\n * person who replaced the list is never read from the defaults. The UI and the engine each set where to read it. Here,\n * not in the provider, so setting it does not load the providers.\n */\nlet source: () => readonly string[] | undefined = () => undefined;\nexport function setPkarrRelaySource(read: () => readonly string[] | undefined): void { source = read; }\nexport function pkarrRelays(): string[] {\n const relays = source();\n return relays?.length ? [...relays] : [...DEFAULT_RELAYS];\n}\n\n/** Whether `url` is under one of the profile's Pkarr relays (`<relay>/…`). */\nexport function isOwnPkarrRelayUrl(url: URL): boolean {\n if (url.username || url.password) return false;\n return pkarrRelays().map(normalizeRelayUrl).some(relay => relay !== null && url.href.startsWith(`${relay}/`));\n}\n","import { boundVerifiedIdentity, IdentityCheckUnavailable, IDENTITY_MAX_EVIDENCE, IDENTITY_MAX_VALIDITY, type IdentityStatement, type VerifiedIdentity } from \"@ghostly/core\";\nimport type { IdentityFetch, IdentityProofProvider, IdentitySigner, VerifyContext } from \"./contract\";\nimport { isOwnPkarrRelayUrl } from \"./pkarrRelays\";\n\nconst DAY = 86_400;\n\n/**\n * The checks every proof goes through, whatever its provider: known provider, validity within the\n * provider's limit, bounded evidence, strict parsing, the provider's own check, and the category rule\n * (a self-custodied proof proves exactly the subject it names; an attested one says who attests it).\n * The engine verifies a contact's proof, and the person's own proof before saving it, only through this.\n */\nexport async function verifyIdentity(providers: readonly IdentityProofProvider[], statement: IdentityStatement, evidence: unknown, ctx: VerifyContext): Promise<VerifiedIdentity> {\n const { binding } = statement;\n const provider = providers.find(p => p.id === binding.provider);\n if (!provider) throw new Error(\"This app cannot verify this kind of identity\");\n if (binding.expiresAt - binding.issuedAt > Math.min(provider.validity.maxDays * DAY, IDENTITY_MAX_VALIDITY)) throw new Error(\"The proof lasts longer than this kind of identity allows\");\n if (JSON.stringify(evidence ?? null).length > IDENTITY_MAX_EVIDENCE) throw new Error(\"Evidence too large\");\n const parsed = provider.parseEvidence(evidence);\n const verified = boundVerifiedIdentity(await provider.verify(statement, parsed, ctx));\n if (provider.category === \"self-custodied\" && verified.subject !== binding.subject) throw new Error(\"The evidence is for another identity\");\n if (provider.category === \"provider-attested\" && !verified.attester) throw new Error(\"The evidence does not say who attests it\");\n return verified;\n}\n\n/** Problems with a provider's descriptor, empty when it is well-formed. The registry and the contract suite use it. */\nexport function descriptorProblems(p: IdentityProofProvider): string[] {\n const problems: string[] = [];\n if (!/^[a-z][a-z0-9-]{0,31}$/.test(p.id)) problems.push(\"id must match ^[a-z][a-z0-9-]{0,31}$\");\n if (!p.label?.trim()) problems.push(\"label is empty\");\n if (!p.description?.trim()) problems.push(\"description is empty\");\n if (!p.privacy?.trim()) problems.push(\"privacy is empty: say what verify contacts\");\n if (p.category !== \"self-custodied\" && p.category !== \"provider-attested\") problems.push(\"category is unknown\");\n if (!p.platforms.length) problems.push(\"no platforms\");\n const { defaultDays, maxDays } = p.validity;\n if (!(Number.isInteger(defaultDays) && Number.isInteger(maxDays) && defaultDays >= 1 && defaultDays <= maxDays && maxDays * DAY <= IDENTITY_MAX_VALIDITY)) problems.push(\"validity must be whole days, 1 ≤ default ≤ max ≤ 400\");\n if (p.recheck && !(Number.isInteger(p.recheck.afterSeconds) && p.recheck.afterSeconds >= 60)) problems.push(\"recheck.afterSeconds must be at least 60\");\n if (p.recheck?.perHour !== undefined && !(Number.isInteger(p.recheck.perHour) && p.recheck.perHour >= 1)) problems.push(\"recheck.perHour must be a whole number, at least 1\");\n if (!p.signers.length) problems.push(\"no signers\");\n const ids = p.signers.map(s => s.id);\n if (new Set(ids).size !== ids.length) problems.push(\"signer ids are not unique\");\n for (const s of p.signers as readonly IdentitySigner<unknown>[]) {\n if (![\"in-app\", \"external-tool\", \"redirect\", \"publish\"].includes(s.kind)) problems.push(`signer ${s.id} has an unknown kind`);\n if (s.kind === \"in-app\" && typeof s.run !== \"function\") problems.push(`signer ${s.id} has no run()`);\n if (s.kind === \"external-tool\" && (typeof s.instructions !== \"function\" || typeof s.parse !== \"function\")) problems.push(`signer ${s.id} needs instructions() and parse()`);\n if (s.kind === \"redirect\" && typeof s.start !== \"function\") problems.push(`signer ${s.id} has no start()`);\n if (s.kind === \"publish\" && (typeof s.instructions !== \"function\" || typeof s.evidence !== \"function\")) problems.push(`signer ${s.id} needs instructions() and evidence()`);\n }\n return problems;\n}\n\n/** Signers of a provider that run on this platform and are available in this window. */\nexport function availableSigners<E>(p: IdentityProofProvider<E>, platform: IdentityProofProvider[\"platforms\"][number]): IdentitySigner<E>[] {\n return p.signers.filter(s => (s.platforms ?? p.platforms).includes(platform) && (s.available?.() ?? true));\n}\n\n/**\n * The engine's `ctx.fetch`: HTTPS GET only, no credentials or referrer, a time-out, a size cap,\n * redirects refused unless asked for.\n * `online` false refuses everything (the person turned the network off).\n * A did:dht read of the profile's own Pkarr relays (`ownPkarrRelay`) may be http://, through `relayFetcher`: those are\n * the relays the person chose, as the chats read them, not an address a contact named.\n */\nexport function boundedIdentityFetch(options: { online: () => boolean; timeoutMs?: number; fetcher?: typeof fetch; relayFetcher?: typeof fetch } = { online: () => true }): IdentityFetch {\n return async (url, { headers, maxBytes = 64 * 1024, signal, redirect = \"error\", ownPkarrRelay } = {}) => {\n if (!options.online()) throw new IdentityCheckUnavailable(\"Offline: this identity cannot be checked now\");\n const target = new URL(url);\n const ownRelay = ownPkarrRelay === true && isOwnPkarrRelayUrl(target);\n if (!ownRelay && (target.protocol !== \"https:\" || target.username || target.password)) throw new Error(\"Identity checks use HTTPS only\");\n const timeout = AbortSignal.timeout(options.timeoutMs ?? 10_000);\n const fetcher = (ownRelay ? options.relayFetcher : undefined) ?? options.fetcher ?? fetch;\n const response = await fetcher(target.href, {\n headers, signal: signal ? AbortSignal.any([signal, timeout]) : timeout,\n credentials: \"omit\", referrerPolicy: \"no-referrer\", cache: \"no-store\", redirect,\n });\n if (Number(response.headers.get(\"content-length\")) > maxBytes) throw new Error(\"Identity check response too large\");\n const reader = response.body?.getReader();\n const parts: Uint8Array[] = [];\n let length = 0;\n if (reader) {\n try {\n for (;;) {\n const { done, value } = await reader.read();\n if (done) break;\n length += value.length;\n if (length > maxBytes) throw new Error(\"Identity check response too large\");\n parts.push(value);\n }\n } finally { await reader.cancel().catch(() => {}); }\n }\n const bytes = new Uint8Array(length);\n let offset = 0;\n for (const part of parts) { bytes.set(part, offset); offset += part.length; }\n return { status: response.status, contentType: response.headers.get(\"content-type\") ?? \"\", text: new TextDecoder().decode(bytes), bytes };\n };\n}\n"],"mappings":";;;;;;;AAOA,IAAI,eAAoD,KAAA;AAExD,SAAgB,cAAwB;CACtC,MAAM,SAAS,OAAO;CACtB,OAAO,QAAQ,SAAS,CAAC,GAAG,MAAM,IAAI,CAAC,GAAG,cAAc;AAC1D;;AAGA,SAAgB,mBAAmB,KAAmB;CACpD,IAAI,IAAI,YAAY,IAAI,UAAU,OAAO;CACzC,OAAO,YAAY,CAAC,CAAC,IAAI,iBAAiB,CAAC,CAAC,MAAK,UAAS,UAAU,QAAQ,IAAI,KAAK,WAAW,GAAG,MAAM,EAAE,CAAC;AAC9G;;ACdA,IAAM,MAAM;;;;;;;AAQZ,eAAsB,eAAe,WAA6C,WAA8B,UAAmB,KAA+C;CAChL,MAAM,EAAE,YAAY;CACpB,MAAM,WAAW,UAAU,MAAK,MAAK,EAAE,OA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,cAAc,KAAK;GAAI,MAAM,IAAI,YAAY,CAAC,CAAC,OAAO,KAAK;GAAG;EAAM;CAC1I;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ghostlytools/sdk",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Build a wallet source, an identity proof, a mini-app or a client for Ghostly without reading its internals: the adapter contracts, their fakes and contract test suites, the plugin registry, and the mini-app API types (Apps run in Ghostly 1.2 and later).",
|
|
6
6
|
"license": "MIT",
|