@ghostlytools/sdk 1.13.0 → 1.13.2
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-BIW3tpJG.js +4133 -0
- package/dist/bitcoinAddress-BIW3tpJG.js.map +1 -0
- package/dist/core.js +433 -2489
- package/dist/core.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/{pairedTransports-CkYMAoYN.js → pairedTransports-BcTRg3tp.js} +28 -304
- package/dist/pairedTransports-BcTRg3tp.js.map +1 -0
- package/dist/testing.js +2 -2
- package/dist/types/browser/src/proofs/contract.d.ts +5 -0
- package/dist/types/browser/src/proofs/pkarrRelays.d.ts +4 -0
- package/dist/types/browser/src/proofs/verify.d.ts +3 -0
- 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 +7 -0
- package/dist/types/core/src/deviceInvite.d.ts +16 -2
- package/dist/types/core/src/dhtDelivery.d.ts +2 -0
- package/dist/types/core/src/domainProofs.d.ts +2 -1
- package/dist/types/core/src/engineErrors.d.ts +6 -0
- package/dist/types/core/src/ghostlink.d.ts +30 -0
- package/dist/types/core/src/groupCommunity.d.ts +25 -1
- package/dist/types/core/src/groupSession.d.ts +22 -2
- package/dist/types/core/src/identityProofs.d.ts +39 -2
- package/dist/types/core/src/index.d.ts +1 -1
- 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/statusCards.d.ts +6 -0
- package/dist/types/core/src/transportSwitch.d.ts +7 -3
- package/dist/{verify-CSo7-43-.js → verify-DGJJAFTs.js} +24 -5
- package/dist/verify-DGJJAFTs.js.map +1 -0
- package/package.json +1 -1
- package/dist/bitcoinAddress-C2MAmcDT.js +0 -1225
- package/dist/bitcoinAddress-C2MAmcDT.js.map +0 -1
- package/dist/pairedTransports-CkYMAoYN.js.map +0 -1
- package/dist/verify-CSo7-43-.js.map +0 -1
|
@@ -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
|
/**
|
|
@@ -269,6 +269,12 @@ export declare function cardTimeUtc(ms: number): string;
|
|
|
269
269
|
* name when the sender knows it ("🗑 Task removed: Fix relay rotation"). An app without the `removed` kind shows it.
|
|
270
270
|
*/
|
|
271
271
|
export declare function removedCardText(of: RemovableKind, title?: string): string;
|
|
272
|
+
/**
|
|
273
|
+
* A message's text without the line that is its app card's link (`statusCardText` puts it on a line of its own for an
|
|
274
|
+
* older app): what a line quoting the message says where the card is not drawn, never the bundle's raw link. Any other
|
|
275
|
+
* message's text as it is.
|
|
276
|
+
*/
|
|
277
|
+
export declare function withoutAppLink(text: string, card: StatusCard | undefined): string;
|
|
272
278
|
/**
|
|
273
279
|
* The text a card's message carries: what an app without cards shows, the DHT floor carries, the chat list previews
|
|
274
280
|
* and search finds. Plain lines, the first naming the card, no bars or layout that would read badly elsewhere.
|
|
@@ -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,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $ as DEFAULT_RELAYS, C as IdentityCheckUnavailable, E as boundVerifiedIdentity, wt as normalizeRelayUrl } from "./bitcoinAddress-BIW3tpJG.js";
|
|
2
|
+
// ../browser/src/proofs/pkarrRelays.ts
|
|
3
|
+
/**
|
|
4
|
+
* The profile's Pkarr relays (Network settings), which a did:dht proof is read from, as every other Pkarr read: a
|
|
5
|
+
* person who replaced the list is never read from the defaults. The UI and the engine each set where to read it. Here,
|
|
6
|
+
* not in the provider, so setting it does not load the providers.
|
|
7
|
+
*/
|
|
8
|
+
var source = () => void 0;
|
|
9
|
+
function pkarrRelays() {
|
|
10
|
+
const relays = source();
|
|
11
|
+
return relays?.length ? [...relays] : [...DEFAULT_RELAYS];
|
|
12
|
+
}
|
|
13
|
+
/** Whether `url` is under one of the profile's Pkarr relays (`<relay>/…`). */
|
|
14
|
+
function isOwnPkarrRelayUrl(url) {
|
|
15
|
+
if (url.username || url.password) return false;
|
|
16
|
+
return pkarrRelays().map(normalizeRelayUrl).some((relay) => relay !== null && url.href.startsWith(`${relay}/`));
|
|
17
|
+
}
|
|
2
18
|
// ../browser/src/proofs/verify.ts
|
|
3
19
|
var DAY = 86400;
|
|
4
20
|
/**
|
|
@@ -57,14 +73,17 @@ function availableSigners(p, platform) {
|
|
|
57
73
|
* The engine's `ctx.fetch`: HTTPS GET only, no credentials or referrer, a time-out, a size cap,
|
|
58
74
|
* redirects refused unless asked for.
|
|
59
75
|
* `online` false refuses everything (the person turned the network off).
|
|
76
|
+
* A did:dht read of the profile's own Pkarr relays (`ownPkarrRelay`) may be http://, through `relayFetcher`: those are
|
|
77
|
+
* the relays the person chose, as the chats read them, not an address a contact named.
|
|
60
78
|
*/
|
|
61
79
|
function boundedIdentityFetch(options = { online: () => true }) {
|
|
62
|
-
return async (url, { headers, maxBytes = 65536, signal, redirect = "error" } = {}) => {
|
|
80
|
+
return async (url, { headers, maxBytes = 65536, signal, redirect = "error", ownPkarrRelay } = {}) => {
|
|
63
81
|
if (!options.online()) throw new IdentityCheckUnavailable("Offline: this identity cannot be checked now");
|
|
64
82
|
const target = new URL(url);
|
|
65
|
-
|
|
83
|
+
const ownRelay = ownPkarrRelay === true && isOwnPkarrRelayUrl(target);
|
|
84
|
+
if (!ownRelay && (target.protocol !== "https:" || target.username || target.password)) throw new Error("Identity checks use HTTPS only");
|
|
66
85
|
const timeout = AbortSignal.timeout(options.timeoutMs ?? 1e4);
|
|
67
|
-
const response = await (options.fetcher ?? fetch)(target.href, {
|
|
86
|
+
const response = await ((ownRelay ? options.relayFetcher : void 0) ?? options.fetcher ?? fetch)(target.href, {
|
|
68
87
|
headers,
|
|
69
88
|
signal: signal ? AbortSignal.any([signal, timeout]) : timeout,
|
|
70
89
|
credentials: "omit",
|
|
@@ -103,4 +122,4 @@ function boundedIdentityFetch(options = { online: () => true }) {
|
|
|
103
122
|
}
|
|
104
123
|
export { verifyIdentity as i, boundedIdentityFetch as n, descriptorProblems as r, availableSigners as t };
|
|
105
124
|
|
|
106
|
-
//# sourceMappingURL=verify-
|
|
125
|
+
//# sourceMappingURL=verify-DGJJAFTs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-DGJJAFTs.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,OAAO,QAAQ,QAAQ;CAC9D,IAAI,CAAC,UAAU,MAAM,IAAI,MAAM,8CAA8C;CAC7E,IAAI,QAAQ,YAAY,QAAQ,WAAW,KAAK,IAAI,SAAS,SAAS,UAAU,KAAA,MAA0B,GAAG,MAAM,IAAI,MAAM,0DAA0D;CACvL,IAAI,KAAK,UAAU,YAAY,IAAI,CAAC,CAAC,SAAA,OAAgC,MAAM,IAAI,MAAM,oBAAoB;CACzG,MAAM,SAAS,SAAS,cAAc,QAAQ;CAC9C,MAAM,WAAW,sBAAsB,MAAM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AAQ,QAAQ,aAAa,GAAM;EAE/D,MAAM,WAAW,QADA,WAAW,QAAQ,eAAe,KAAA,MAAc,QAAQ,WAAW,MAAA,CACrD,OAAO,MAAM;GAC1C;GAAS,QAAQ,SAAS,YAAY,IAAI,CAAC,QAAQ,OAAO,CAAC,IAAI;GAC/D,aAAa;GAAQ,gBAAgB;GAAe,OAAO;GAAY;EACzE,CAAC;EACD,IAAI,OAAO,SAAS,QAAQ,IAAI,gBAAgB,CAAC,IAAI,UAAU,MAAM,IAAI,MAAM,mCAAmC;EAClH,MAAM,SAAS,SAAS,MAAM,UAAU;EACxC,MAAM,QAAsB,CAAC;EAC7B,IAAI,SAAS;EACb,IAAI,QACF,IAAI;GACF,SAAS;IACP,MAAM,EAAE,MAAM,UAAU,MAAM,OAAO,KAAK;IAC1C,IAAI,MAAM;IACV,UAAU,MAAM;IAChB,IAAI,SAAS,UAAU,MAAM,IAAI,MAAM,mCAAmC;IAC1E,MAAM,KAAK,KAAK;GAClB;EACF,UAAU;GAAE,MAAM,OAAO,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC;EAAG;EAErD,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ghostlytools/sdk",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.2",
|
|
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",
|