@ghostlytools/sdk 1.3.0 → 1.3.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/core.js +2 -2
- package/dist/{fakes-BlpK1WuW.js → fakes-MnrUkwEP.js} +2 -2
- package/dist/{fakes-BlpK1WuW.js.map → fakes-MnrUkwEP.js.map} +1 -1
- package/dist/fakes.js +1 -1
- package/dist/index.js +2 -2
- package/dist/{keet-identity-key-GE5nr3zt.js → keet-identity-key-BjeN0q1Z.js} +2 -2
- package/dist/{keet-identity-key-GE5nr3zt.js.map → keet-identity-key-BjeN0q1Z.js.map} +1 -1
- package/dist/{src-JQitqFJD.js → src-yaRa2Opt.js} +292 -167
- package/dist/src-yaRa2Opt.js.map +1 -0
- package/dist/testing.js +3 -3
- package/dist/types/core/src/dhtDelivery.d.ts +19 -2
- package/dist/types/core/src/ghostlink.d.ts +22 -2
- package/dist/types/core/src/groupCommits.d.ts +4 -0
- package/dist/types/core/src/groupCommunity.d.ts +6 -2
- package/dist/types/core/src/groupFiles.d.ts +10 -4
- package/dist/types/core/src/link.d.ts +4 -1
- package/dist/types/core/src/paymentIntent.d.ts +2 -0
- package/dist/types/core/src/relayBreaker.d.ts +4 -1
- package/dist/types/core/src/video.d.ts +2 -1
- package/dist/{verify-afQj9kHW.js → verify-BfFDG-pJ.js} +2 -2
- package/dist/{verify-afQj9kHW.js.map → verify-BfFDG-pJ.js.map} +1 -1
- package/package.json +1 -1
- package/dist/src-JQitqFJD.js.map +0 -1
package/dist/testing.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Vi as isBitcoinAddress, fa as decodeBolt11, fu as emptyIdentityLedger, hu as identityStatement, ix as createIdentity, tu as IDENTITY_MAX_EVIDENCE, uu as IdentityExchange, vu as newIdentityBinding } from "./src-yaRa2Opt.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-BfFDG-pJ.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-MnrUkwEP.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;
|
|
@@ -98,6 +98,12 @@ export interface DhtDeliveryState {
|
|
|
98
98
|
* "the invite was taken" from then on is not the contact's word (`sealedToAnother`).
|
|
99
99
|
*/
|
|
100
100
|
wasLive?: true;
|
|
101
|
+
/**
|
|
102
|
+
* This side joined, and pinned the inviter from an envelope it put out before anyone joined (sealed with the invite's
|
|
103
|
+
* key, not to this side): that envelope's sequence. Until the inviter shows it was there since (`DhtDelivery.unanswered`),
|
|
104
|
+
* the chat is read as an invite nobody used (`unusedInviteWait`), counted from the join.
|
|
105
|
+
*/
|
|
106
|
+
unanswered?: number;
|
|
101
107
|
}
|
|
102
108
|
export interface DhtDeliveryView {
|
|
103
109
|
mode: DeliveryMode;
|
|
@@ -240,10 +246,18 @@ export declare class DhtDelivery {
|
|
|
240
246
|
* burst of an app coming back (bug hunt r7a). A text, a receipt, a new mode or a new capability revision still go at once.
|
|
241
247
|
*/
|
|
242
248
|
firstControlAfterMs?: number;
|
|
243
|
-
/**
|
|
249
|
+
/**
|
|
250
|
+
* This side made the invite, or joined one, then: once no longer awaited, its mailbox is read less often while nobody
|
|
251
|
+
* uses it, or while its inviter never answered the join (`unanswered`) (`unusedInviteWait`).
|
|
252
|
+
*/
|
|
244
253
|
inviteMadeAt?: number;
|
|
245
254
|
});
|
|
246
255
|
get view(): DhtDeliveryView;
|
|
256
|
+
/**
|
|
257
|
+
* This side joined, and its inviter never answered (`DhtDeliveryState.unanswered`): no envelope of its newer than the
|
|
258
|
+
* one that pinned it, none sealed to this side, no text confirmed, never live (as `sealedToAnother` asks too).
|
|
259
|
+
*/
|
|
260
|
+
get unanswered(): boolean;
|
|
247
261
|
/**
|
|
248
262
|
* Something signed by a participation key other than the pinned one came in over the chat's invite-derived keys (this
|
|
249
263
|
* mailbox, the link's signals, a connection to an endpoint whose address a copy of the invite could read): ignored,
|
|
@@ -388,7 +402,10 @@ export declare class DhtDelivery {
|
|
|
388
402
|
private publishOnTick;
|
|
389
403
|
/** How long until the next read of the contact's mailbox (WISP 403, poll pace). */
|
|
390
404
|
get pollMs(): number;
|
|
391
|
-
/**
|
|
405
|
+
/**
|
|
406
|
+
* How long ago this side's invite was made (or joined), while nobody used it (or its inviter never answered,
|
|
407
|
+
* `unanswered`) and it is no longer awaited (`AWAITING_PEER_MS`).
|
|
408
|
+
*/
|
|
392
409
|
private unusedInviteAge;
|
|
393
410
|
private schedule;
|
|
394
411
|
}
|
|
@@ -186,6 +186,14 @@ export declare const MAX_PAIRED_MESSAGE_FRAME: number;
|
|
|
186
186
|
* WISP 405 · Status Cards), whose 8 KiB with the text's 16 stay well inside the frame.
|
|
187
187
|
*/
|
|
188
188
|
export declare function pairedMessageFrame(id: string, ts: number, m: string, preview?: LinkPreview, reply?: WireReply, forwarded?: number, card?: StatusCard): string;
|
|
189
|
+
/** A text whose `paired-message` frame would pass what a session takes: it never arrives, and is refused at send. */
|
|
190
|
+
export declare const PAIRED_FRAME_TOO_LARGE = "Message too long once encoded. Shorten it or send it as a file.";
|
|
191
|
+
/**
|
|
192
|
+
* The `paired-message` frame of this text fits a session (`SESSION_FRAME_MAX`, UTF-16 units of the JSON). Within 16 KiB
|
|
193
|
+
* of UTF-8 a text can still pass it: JSON writes each control character as six (`\u0001`). The preview is left out,
|
|
194
|
+
* as the frame drops one that does not fit.
|
|
195
|
+
*/
|
|
196
|
+
export declare function pairedMessageFits(ts: number, m: string, reply?: WireReply, forwarded?: number, card?: StatusCard): boolean;
|
|
189
197
|
/**
|
|
190
198
|
* The transport a chat is set to reach and is not on yet (WISP 100, "A chosen transport not reached yet"): waited for,
|
|
191
199
|
* never failed. `by`: whose choice names it (absent: a policy alone, such as Fallback off, limits the chat to it).
|
|
@@ -1092,6 +1100,8 @@ export declare class GhostLink {
|
|
|
1092
1100
|
* the attempt timed out and the next one raced, 32 to 66 s in (zero's VPN lab, 2026-10-13).
|
|
1093
1101
|
*/
|
|
1094
1102
|
private raceStandingOffer;
|
|
1103
|
+
/** The offer ends (`raceStandingOffer`), and with it going idle what is ranked after WebRTC is dialled (`dialAfterRtc`). */
|
|
1104
|
+
private endUnanswerableOffer;
|
|
1095
1105
|
/**
|
|
1096
1106
|
* Back after an absence, this side answers an offer the contact made while it was away (it dials whatever its key):
|
|
1097
1107
|
* the contact looks for that answer at the pace of an offer out a while (every 8 s on the relays), and its attempt may
|
|
@@ -1154,6 +1164,11 @@ export declare class GhostLink {
|
|
|
1154
1164
|
* offer (`attach`); the offer answered first, the native dial is closed.
|
|
1155
1165
|
*/
|
|
1156
1166
|
private race;
|
|
1167
|
+
/**
|
|
1168
|
+
* This side does not dial on its own: the contact's app does (the lower key), and none of what makes this side dial
|
|
1169
|
+
* anyway holds (a first pairing's role, a restart, WebRTC set aside). Its own dial, chosen by hand, is not retried.
|
|
1170
|
+
*/
|
|
1171
|
+
private awaitsContactDial;
|
|
1157
1172
|
/** A transport of the attempt under way did not connect. */
|
|
1158
1173
|
private attemptFailed;
|
|
1159
1174
|
/** The attempt under way ended without going live: kept as the last one, and told. `reason`: why, when nothing was tried. */
|
|
@@ -1392,7 +1407,9 @@ export declare class GhostLink {
|
|
|
1392
1407
|
* kept to send later. While the channel already holds a quarter of what it may queue (its send budget, or the high
|
|
1393
1408
|
* water mark of a WebRTC channel), the frame is refused with `too-fast`, so the chat's messages and pings never wait
|
|
1394
1409
|
* behind an app's data on a link slower than it sends (WISP 1200 § In a chat). While a file goes, that quarter sits
|
|
1395
|
-
* above what files may hold (`filesWritable`): files keep the channel at their own line for the whole transfer.
|
|
1410
|
+
* above what files may hold (`filesWritable`): files keep the channel at their own line for the whole transfer. While
|
|
1411
|
+
* the file waits for room, the app gets no further than `APP_AHEAD_OF_FILES` ahead of it, so it cannot refill the
|
|
1412
|
+
* channel each time it drains to files' line and keep the file from moving.
|
|
1396
1413
|
*/
|
|
1397
1414
|
sendAppData(app: string, data: unknown): AppSendError | null;
|
|
1398
1415
|
/** What the contact had open is gone (`apps/1` is no longer agreed, or this link stopped): each app hears it now. */
|
|
@@ -1415,7 +1432,10 @@ export declare class GhostLink {
|
|
|
1415
1432
|
* so a transfer follows the session it is on. False when files/3 cannot flow now, or the channel has no room.
|
|
1416
1433
|
*/
|
|
1417
1434
|
sendFileData(id: string, offset: number, data: Uint8Array): boolean;
|
|
1418
|
-
/**
|
|
1435
|
+
/**
|
|
1436
|
+
* Files on a channel: when they last wrote on it, how many wait for room, and how many bytes an app's data has sent
|
|
1437
|
+
* on it beyond theirs since. An app's data gets room above theirs.
|
|
1438
|
+
*/
|
|
1419
1439
|
private filesUse;
|
|
1420
1440
|
private filesUsing;
|
|
1421
1441
|
/**
|
|
@@ -59,6 +59,9 @@ export declare function signCommit(commit: Omit<GroupCommit, "sig">, seed: Uint8
|
|
|
59
59
|
export declare function rosterAdmin(roster: Roster): string | undefined;
|
|
60
60
|
export declare function rosterHas(roster: Roster, key: string): boolean;
|
|
61
61
|
export declare const sortRoster: (roster: Roster) => Roster;
|
|
62
|
+
declare function parseCommit(raw: unknown): GroupCommit | null;
|
|
63
|
+
/** Only shape, no signature or parent: a commit as kept, its fields alone (anything else it carried dropped); null when malformed. */
|
|
64
|
+
export declare const parseGroupCommit: typeof parseCommit;
|
|
62
65
|
/** The roster a commit must carry, given the previous one; null when the change is not allowed. */
|
|
63
66
|
export declare function expectedRoster(previous: Roster | null, kind: CommitKind, by: string, subject?: string): Roster | null;
|
|
64
67
|
/**
|
|
@@ -101,3 +104,4 @@ export declare const SAID_AGAIN: {
|
|
|
101
104
|
/** `alone` with `key` added last, keeping only keys still `present` (frames still in the log), the latest `kept`. */
|
|
102
105
|
export declare function rememberAlone(alone: readonly string[] | undefined, key: string, present: (key: string) => boolean): string[];
|
|
103
106
|
export declare const GROUP_ADMIN_OFF_ERROR = "Managing this group is off on this device. Turn on Manage groups from this device first.";
|
|
107
|
+
export {};
|
|
@@ -684,8 +684,12 @@ export declare class CommunitySession {
|
|
|
684
684
|
h: string;
|
|
685
685
|
n: number;
|
|
686
686
|
}): string;
|
|
687
|
-
/**
|
|
688
|
-
|
|
687
|
+
/**
|
|
688
|
+
* Where I am and what I have, for the member at the other end of an edge that just opened. `to`: that member, now
|
|
689
|
+
* asked: my answer to its own sync asks nothing more for a while. A second sync went, and its answer took the place of
|
|
690
|
+
* what was left of the first from its start: a member back after 256 messages was handed 288 (2026-10-14).
|
|
691
|
+
*/
|
|
692
|
+
syncFrame(to?: string): CommunitySyncFrame;
|
|
689
693
|
/**
|
|
690
694
|
* A frame from the edge of member `from` (the author, or a hub relaying it). Returns whether it
|
|
691
695
|
* was new and valid, so a hub knows to relay it on.
|
|
@@ -9,7 +9,7 @@ import { type VoiceMeta } from "./voice.js";
|
|
|
9
9
|
export declare const GROUP_FILE_LIMITS: {
|
|
10
10
|
/** The largest file a group takes. */
|
|
11
11
|
readonly maxBytes: number;
|
|
12
|
-
/** A file this size or smaller is fetched without asking
|
|
12
|
+
/** A file this size or smaller is fetched without asking, a voice message too (one recorded is well inside it). */
|
|
13
13
|
readonly autoBytes: number;
|
|
14
14
|
/** What a device keeps of a group's files it fetched without asking; past it, every file is asked about. */
|
|
15
15
|
readonly autoBytesPerGroup: number;
|
|
@@ -43,6 +43,11 @@ export declare const GROUP_FILE_LIMITS: {
|
|
|
43
43
|
* left for the next holder too.
|
|
44
44
|
*/
|
|
45
45
|
readonly wantWaitMs: 30000;
|
|
46
|
+
/**
|
|
47
|
+
* How long a served transfer with all its bytes confirmed waits for the member's word that its check passed once the
|
|
48
|
+
* member's next want has overtaken it.
|
|
49
|
+
*/
|
|
50
|
+
readonly doneWaitMs: 5000;
|
|
46
51
|
/** A file session closes this long after its last transfer ends. */
|
|
47
52
|
readonly sessionIdleMs: 60000;
|
|
48
53
|
/** File sessions opening at once, and open at once, all groups together. */
|
|
@@ -101,10 +106,11 @@ export declare function readGroupFileMeta(value: unknown): GroupFileMeta | null;
|
|
|
101
106
|
*/
|
|
102
107
|
export declare function groupFileFallback(file: Pick<GroupFileMeta, "name" | "size" | "voice" | "video">): string;
|
|
103
108
|
/**
|
|
104
|
-
* Whether a device fetches a file by itself (WISP 503 § Automatic and asked downloads):
|
|
105
|
-
*
|
|
109
|
+
* Whether a device fetches a file by itself (WISP 503 § Automatic and asked downloads): up to `autoBytes` while what
|
|
110
|
+
* it took that way from the group stays within `autoBytesPerGroup`. A voice message too: one recorded (15 minutes at
|
|
111
|
+
* most, about 3.6 MB) always fits, and a bigger file the author called a voice message is asked about like any other.
|
|
106
112
|
*/
|
|
107
|
-
export declare function fetchesByItself(file: Pick<GroupFileMeta, "size"
|
|
113
|
+
export declare function fetchesByItself(file: Pick<GroupFileMeta, "size">, keptAutomatically: number, limits?: {
|
|
108
114
|
autoBytes: number;
|
|
109
115
|
autoBytesPerGroup: number;
|
|
110
116
|
}): boolean;
|
|
@@ -178,7 +178,10 @@ export interface LinkSessionOptions {
|
|
|
178
178
|
* sent at once) went out for a minute (2026-10-08).
|
|
179
179
|
*/
|
|
180
180
|
awaitingSince?: number;
|
|
181
|
-
/**
|
|
181
|
+
/**
|
|
182
|
+
* Whether this is an invite this side made that nobody used yet, or one it joined whose inviter never answered: once no
|
|
183
|
+
* longer awaited, read less often while nobody is there (`unusedInviteWait`).
|
|
184
|
+
*/
|
|
182
185
|
invite?: () => boolean;
|
|
183
186
|
}
|
|
184
187
|
/** With `firstPublish: "after-first-poll"`, the first packet goes out by then whatever happened. */
|
|
@@ -108,4 +108,6 @@ export declare function parsePaymentAmount(value: string, decimals: number): num
|
|
|
108
108
|
export declare function formatPaymentAmount(value: number | string, decimals?: number): string;
|
|
109
109
|
export declare function assertTokenUnits(amount: number): void;
|
|
110
110
|
export declare function assertWholeSats(amount: number): void;
|
|
111
|
+
/** Arkade and Bark addresses are bech32m with `ark` on Bitcoin and `tark` on the test networks (one case only). */
|
|
112
|
+
export declare const arkAddressPrefix: (network: string) => "ark1" | "tark1";
|
|
111
113
|
export declare function validatePaymentTarget(value: unknown, now?: number): PaymentTarget;
|
|
@@ -87,7 +87,10 @@ export declare class RelayBreaker {
|
|
|
87
87
|
cancel(relay: string): void;
|
|
88
88
|
/** The relay answered: whatever was wrong is over. */
|
|
89
89
|
success(relay: string): void;
|
|
90
|
-
/**
|
|
90
|
+
/**
|
|
91
|
+
* The relay failed a request; a probe that fails trips it again at once. While it is left alone and no probe is out,
|
|
92
|
+
* a failure is a request sent before it tripped (a start burst): already counted in, it trips nothing again.
|
|
93
|
+
*/
|
|
91
94
|
failure(relay: string, kind: RelayFailure, reason: string): void;
|
|
92
95
|
private trip;
|
|
93
96
|
/** How long until a relay left alone is asked again: its wait, or the next probe while every relay of `relays` is left alone. */
|
|
@@ -37,7 +37,8 @@ export declare function isVideoMime(mime: string): boolean;
|
|
|
37
37
|
export declare function isPlayableVideoType(mime: string): boolean;
|
|
38
38
|
/**
|
|
39
39
|
* A peer's `video` description, or undefined when it is not one. It never refuses the file. A poster that is
|
|
40
|
-
* too large
|
|
40
|
+
* too large, not a JPEG, or says it is more pixels than a sender draws (`posterEdge`) is dropped on its own; the
|
|
41
|
+
* length and size are kept. It is shown before the file is accepted, so a few bytes must not ask for a huge bitmap.
|
|
41
42
|
*/
|
|
42
43
|
export declare function parseVideoMeta(value: unknown, mime?: string): VideoMeta | undefined;
|
|
43
44
|
/** `0:07`, `12:45`, `1:02:03`: as a player shows a video's length. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { du as boundVerifiedIdentity } from "./src-yaRa2Opt.js";
|
|
2
2
|
//#region ../browser/src/proofs/verify.ts
|
|
3
3
|
var DAY = 86400;
|
|
4
4
|
/**
|
|
@@ -103,4 +103,4 @@ function boundedIdentityFetch(options = { online: () => true }) {
|
|
|
103
103
|
//#endregion
|
|
104
104
|
export { verifyIdentity as i, boundedIdentityFetch as n, descriptorProblems as r, availableSigners as t };
|
|
105
105
|
|
|
106
|
-
//# sourceMappingURL=verify-
|
|
106
|
+
//# sourceMappingURL=verify-BfFDG-pJ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify-
|
|
1
|
+
{"version":3,"file":"verify-BfFDG-pJ.js","names":[],"sources":["../../browser/src/proofs/verify.ts"],"sourcesContent":["import { boundVerifiedIdentity, IDENTITY_MAX_EVIDENCE, IDENTITY_MAX_VALIDITY, type IdentityStatement, type VerifiedIdentity } from \"@ghostly/core\";\nimport type { IdentityFetch, IdentityProofProvider, IdentitySigner, VerifyContext } from \"./contract\";\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.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 */\nexport function boundedIdentityFetch(options: { online: () => boolean; timeoutMs?: number; fetcher?: typeof fetch } = { online: () => true }): IdentityFetch {\n return async (url, { headers, maxBytes = 64 * 1024, signal, redirect = \"error\" } = {}) => {\n if (!options.online()) throw new Error(\"Offline: this identity cannot be checked now\");\n const target = new URL(url);\n if (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 response = await (options.fetcher ?? fetch)(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":";;AAGA,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,SAAS,OAAO,WAAW,QAAQ,GAAG,CAAC;CACpF,IAAI,SAAS,aAAa,oBAAoB,SAAS,YAAY,QAAQ,SAAS,MAAM,IAAI,MAAM,sCAAsC;CAC1I,IAAI,SAAS,aAAa,uBAAuB,CAAC,SAAS,UAAU,MAAM,IAAI,MAAM,0CAA0C;CAC/H,OAAO;AACT;;AAGA,SAAgB,mBAAmB,GAAoC;CACrE,MAAM,WAAqB,CAAC;CAC5B,IAAI,CAAC,yBAAyB,KAAK,EAAE,EAAE,GAAG,SAA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AAI,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.3.
|
|
3
|
+
"version": "1.3.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",
|