@ghostlytools/sdk 1.11.3 → 1.11.4
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-CK9Ra4X4.js → fakes-CXeeyI4Z.js} +2 -2
- package/dist/{fakes-CK9Ra4X4.js.map → fakes-CXeeyI4Z.js.map} +1 -1
- package/dist/fakes.js +1 -1
- package/dist/index.js +2 -2
- package/dist/{keet-identity-key-CDgu84Dj.js → keet-identity-key-DLXTTFZH.js} +1754 -86
- package/dist/keet-identity-key-DLXTTFZH.js.map +1 -0
- package/dist/{src-B9HeOlsG.js → src-CqAqFhh9.js} +825 -199
- package/dist/src-CqAqFhh9.js.map +1 -0
- package/dist/testing.js +3 -3
- package/dist/types/core/src/communityRendezvous.d.ts +5 -2
- package/dist/types/core/src/datalink.d.ts +10 -0
- package/dist/types/core/src/frames.d.ts +18 -0
- package/dist/types/core/src/ghostlink.d.ts +37 -0
- package/dist/types/core/src/groupCommunity.d.ts +13 -3
- package/dist/types/core/src/http.d.ts +26 -3
- package/dist/types/core/src/pairedAppRanges.d.ts +2 -0
- package/dist/types/core/src/videoMetadata.d.ts +7 -0
- package/dist/{verify-DZpnNeF7.js → verify-B9s82dbd.js} +2 -2
- package/dist/{verify-DZpnNeF7.js.map → verify-B9s82dbd.js.map} +1 -1
- package/package.json +1 -1
- package/dist/keet-identity-key-CDgu84Dj.js.map +0 -1
- package/dist/src-B9HeOlsG.js.map +0 -1
package/dist/testing.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Md as newIdentityBinding, Pa as decodeBolt11, Sd as IdentityExchange, Td as emptyIdentityLedger, WT as createIdentity, dd as IDENTITY_MAX_EVIDENCE, kd as identityStatement, la as isBitcoinAddress } from "./src-CqAqFhh9.js";
|
|
2
2
|
import { l as providerDescriptorProblems, o as isNothingSpentError } from "./types-DYLIIkU8.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-B9s82dbd.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-CXeeyI4Z.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;
|
|
@@ -117,8 +117,11 @@ export declare function freshHubs(hubs: Hub[], now?: number): Hub[];
|
|
|
117
117
|
export declare function hubRank(subject: string, hubKey: string): string;
|
|
118
118
|
export declare function rankHubs(subject: string, hubs: string[]): string[];
|
|
119
119
|
/**
|
|
120
|
-
* The hubs a member asks for edges:
|
|
121
|
-
*
|
|
120
|
+
* The hubs a member asks for edges: fresh ones with room, at most `hubsPerMember`, by rendezvous hashing weighted by
|
|
121
|
+
* the room each has left, so the members picking at once spread over the hubs in proportion to it. The members a
|
|
122
|
+
* closing hub carried all pick in the same second: each took the least loaded hub, all of them the same one, which
|
|
123
|
+
* opened their 12 or 16 edges at once on its relays' budget and brought none up for minutes, then the next hub did the
|
|
124
|
+
* same, and 6 of them stepped up as hubs with nobody on them (36 members, bug hunt, 2026-11-11).
|
|
122
125
|
*/
|
|
123
126
|
export declare function pickHubs(me: string, hubs: Hub[], now?: number, avoid?: ReadonlySet<string>): string[];
|
|
124
127
|
/** Should this member be a hub? Too few fresh hubs, or all full, and room in the beacon. */
|
|
@@ -133,6 +133,8 @@ export declare class DataLink {
|
|
|
133
133
|
private fullGather;
|
|
134
134
|
/** The offer or answer out has no public candidate (as it went: the connection's description gains any that come later). */
|
|
135
135
|
private sentLacksPublic;
|
|
136
|
+
/** Connections the gathering under way replaced for finding no candidate at all (`gathered`); 0 when none is under way. */
|
|
137
|
+
private gatherStalls;
|
|
136
138
|
private lastSignalTs;
|
|
137
139
|
/** The peer's description as this connection was given it: Chrome shows it as `remoteDescription` only once applied. */
|
|
138
140
|
private remoteSdp;
|
|
@@ -208,6 +210,14 @@ export declare class DataLink {
|
|
|
208
210
|
* candidate, a public port per STUN server, or (for the side that offered) candidates that read as reachable.
|
|
209
211
|
*/
|
|
210
212
|
private directEvidence;
|
|
213
|
+
/**
|
|
214
|
+
* The gathering under way found no candidate on every connection but the one it waits on now (`GATHER_ATTEMPTS` - 1
|
|
215
|
+
* stalls): ended from outside now (another transport went live, the contact's offer took its place), it says what
|
|
216
|
+
* one that ran out says, `no-public`. Saying nothing held the note back on a network that blocks direct connections:
|
|
217
|
+
* a browser there gathers none, its chats went live over Iroh before the third stall, and only a later attempt, if
|
|
218
|
+
* any came, said it (direct-blocked e2e, 2026-11-13).
|
|
219
|
+
*/
|
|
220
|
+
private get gatherStalled();
|
|
211
221
|
/**
|
|
212
222
|
* The attempt on this connection failed (it timed out, ICE failed or closed, its channel closed). An answer the
|
|
213
223
|
* offerer may not have read yet is made again for the same offer while it still stands (`REANSWERS`); anything
|
|
@@ -36,6 +36,24 @@ export declare const LIMITS: {
|
|
|
36
36
|
*/
|
|
37
37
|
readonly maxClientWaiting: 64;
|
|
38
38
|
readonly maxClientWaitingBodyBytes: number;
|
|
39
|
+
/**
|
|
40
|
+
* Response-body bytes a client holds for one response before whatever reads it took them. Past it, a response its
|
|
41
|
+
* reader takes nothing of for `unreadStallMs` is reset: its reader stalled. Four times what a host keeps buffered on
|
|
42
|
+
* the link (`sendHighWaterMark`), so a reader that keeps up never reaches it.
|
|
43
|
+
*/
|
|
44
|
+
readonly maxUnreadResponseBytes: number;
|
|
45
|
+
/**
|
|
46
|
+
* How long a reader past `maxUnreadResponseBytes` may take nothing before its response is reset. One that keeps
|
|
47
|
+
* reading, only slower than the link (a video playing as it arrives, a contact's app read through the web's services
|
|
48
|
+
* worker), is not cut: it holds up to the response's own bound.
|
|
49
|
+
*/
|
|
50
|
+
readonly unreadStallMs: 2000;
|
|
51
|
+
/**
|
|
52
|
+
* Response-body bytes a client holds for all its responses before their readers took them. Past it, a response over
|
|
53
|
+
* `maxUnreadResponseBytes` is reset at once, its reader's pace aside: one slow reader keeps its whole response (as
|
|
54
|
+
* much as `maxResponseBodyBytes`), but many cannot add up (a contact's app reading each answer a chunk at a time).
|
|
55
|
+
*/
|
|
56
|
+
readonly maxClientUnreadResponseBytes: number;
|
|
39
57
|
readonly maxChatMessageBytes: number;
|
|
40
58
|
readonly maxFileBytes: number;
|
|
41
59
|
/** Files a peer may be sending us at once. */
|
|
@@ -76,6 +76,12 @@ export declare const BLOCKED_DIAL_WAIT_MS = 10000;
|
|
|
76
76
|
* Desktop's knock 15 s in, and the Desktop dialled again only 30 s in).
|
|
77
77
|
*/
|
|
78
78
|
export declare const UNPROVEN_AUTH_MS = 15000;
|
|
79
|
+
/**
|
|
80
|
+
* Connections dialled in that authenticate at once beside the one waiting to take over (`contend`). Whoever read the
|
|
81
|
+
* endpoint and dials it over and over pushes out only the oldest of them: the contact's, a few round trips long, is
|
|
82
|
+
* pushed out only by this many dials within those round trips.
|
|
83
|
+
*/
|
|
84
|
+
export declare const DIALED_IN_CONTENDERS = 8;
|
|
79
85
|
/**
|
|
80
86
|
* A native connection this side dialled that has not authenticated this long after it opened, while the contact's
|
|
81
87
|
* record names a newer way to dial it: the dial went to an old address (the web app's Iroh homed on another relay after
|
|
@@ -723,6 +729,11 @@ export declare class GhostLink {
|
|
|
723
729
|
private readonly switcher;
|
|
724
730
|
/** `plan`: a switch both sides agreed; without one, a replacement the contact dialled (`attachReplacement`). */
|
|
725
731
|
private candidate;
|
|
732
|
+
/**
|
|
733
|
+
* Connections that authenticate beside a `candidate` dialled in and unproven (`contend`), oldest first: whichever
|
|
734
|
+
* authenticates first takes over, so one that never does neither holds the place nor takes it from the contact's.
|
|
735
|
+
*/
|
|
736
|
+
private contenders;
|
|
726
737
|
private candidateEpoch;
|
|
727
738
|
/** The native dial a transport change has in flight, per transport (`prepareSwitch`). */
|
|
728
739
|
private readonly switchDials;
|
|
@@ -877,6 +888,10 @@ export declare class GhostLink {
|
|
|
877
888
|
/** The attempt (its epoch) whose direct transports were knocked on as its offer went out (`knockEarly`), and whether that is under way. */
|
|
878
889
|
private knockedEarly;
|
|
879
890
|
private knockingEarly;
|
|
891
|
+
/** The attempt (its epoch) of a resume over WebRTC whose offer Iroh joined, its endpoint up only after the dial (`joinRace`). */
|
|
892
|
+
private irohJoinedResume;
|
|
893
|
+
/** The same for HyperDHT (direct, and already in the race's `afterRtc`). */
|
|
894
|
+
private hyperdhtJoinedResume;
|
|
880
895
|
/** When this side's offer's answer was applied (`RACE_ANSWERED_MS`); 0 while the data link is not connecting on it. */
|
|
881
896
|
private answeredAt;
|
|
882
897
|
/** This side's offer is out unanswered, or answered and not connected yet: what is ranked after WebRTC may race it. */
|
|
@@ -1072,6 +1087,12 @@ export declare class GhostLink {
|
|
|
1072
1087
|
get dhtDelivery(): DhtDeliveryView | undefined;
|
|
1073
1088
|
/** The chat is on screen: on the DHT its mailbox is read at the signaling pace (WISP 403, poll pace). */
|
|
1074
1089
|
setChatActive(active: boolean): void;
|
|
1090
|
+
/**
|
|
1091
|
+
* What `emitDeliveryState` said last, cleared by any other pairing state: every mailbox read and publication of a
|
|
1092
|
+
* DHT-only chat asks for it again, and one that changed nothing builds no engine state (bug hunt 1109-chat-perf).
|
|
1093
|
+
*/
|
|
1094
|
+
private saidDeliveryState;
|
|
1095
|
+
private sayPairingState;
|
|
1075
1096
|
private emitDeliveryState;
|
|
1076
1097
|
setDeliveryMode(mode: DeliveryMode): Promise<void>;
|
|
1077
1098
|
start(): void;
|
|
@@ -1351,6 +1372,11 @@ export declare class GhostLink {
|
|
|
1351
1372
|
* ranked what to try, and joins the race (and what the offer ending goes on to) if both sides allow it.
|
|
1352
1373
|
*/
|
|
1353
1374
|
private joinRace;
|
|
1375
|
+
/**
|
|
1376
|
+
* On Automatic with no choice standing, Iroh ranks ahead of WebRTC for this contact and can be dialled now (WISP 100,
|
|
1377
|
+
* revision 2026-11-08): where a resume over WebRTC goes on Iroh instead (`dial`).
|
|
1378
|
+
*/
|
|
1379
|
+
private irohRanksFirst;
|
|
1354
1380
|
/** WebRTC could not start an attempt here: it goes last in the dial order for `RTC_UNSTARTED_MS`, while another transport remains. */
|
|
1355
1381
|
private rtcUnstarted;
|
|
1356
1382
|
/**
|
|
@@ -1800,9 +1826,20 @@ export declare class GhostLink {
|
|
|
1800
1826
|
get contactAway(): boolean;
|
|
1801
1827
|
requirePaymentSupport(): Promise<void>;
|
|
1802
1828
|
private requireLegacyCapabilities;
|
|
1829
|
+
/** `closeRtc`: a WebRTC attempt under way beside a native session is this change's, and ends with it. */
|
|
1803
1830
|
private cancelCandidate;
|
|
1804
1831
|
private prepareSwitch;
|
|
1805
1832
|
private attachCandidate;
|
|
1833
|
+
/** The candidate waiting for `plan` (none: a replacement) was dialled in and has not authenticated yet. */
|
|
1834
|
+
private contendable;
|
|
1835
|
+
/**
|
|
1836
|
+
* A connection that authenticates beside the candidate held (`contenders`), or takes the place if none is. With
|
|
1837
|
+
* `DIALED_IN_CONTENDERS` waiting already, the oldest dialled in and unproven of them gives its place up.
|
|
1838
|
+
*/
|
|
1839
|
+
private contend;
|
|
1840
|
+
/** One of the `contenders` authenticated first: it takes the candidate's place, and the candidate held closes. */
|
|
1841
|
+
private promoteContender;
|
|
1842
|
+
private dropContenders;
|
|
1806
1843
|
/**
|
|
1807
1844
|
* Both sides dialled at once (two apps back after a restart, each knocking): the lower key's dial carries the chat, on
|
|
1808
1845
|
* both sides; the higher key's side takes it over as a replacement (`attachReplacement`). Here, on the lower key's
|
|
@@ -514,6 +514,11 @@ export declare function communityHasFrame(state: Pick<CommunityState, "seen" | "
|
|
|
514
514
|
h: string;
|
|
515
515
|
n: number;
|
|
516
516
|
}): boolean;
|
|
517
|
+
/**
|
|
518
|
+
* A `group-secret` or `group-entry` frame a hub routes for another member, rebuilt from its known fields when each has
|
|
519
|
+
* its real shape: what a hub remembers and hands on is no bigger than a real one. Null for anything else.
|
|
520
|
+
*/
|
|
521
|
+
export declare function routedCommunityFrame(raw: Record<string, unknown>): CommunitySecretFrame | CommunityEntryFrame | null;
|
|
517
522
|
/**
|
|
518
523
|
* One member's view of a community group: the branch it follows and the ones it knows, the
|
|
519
524
|
* secrets it holds, what it has seen, and the recent frames it keeps for others.
|
|
@@ -611,11 +616,16 @@ export declare class CommunitySession {
|
|
|
611
616
|
get myKey(): string;
|
|
612
617
|
get top(): CommunityCommit;
|
|
613
618
|
/**
|
|
614
|
-
* The top commit's hash
|
|
615
|
-
*
|
|
619
|
+
* The top commit's hash: a view reads it for each member (its roster, what each member's lines are missing), and
|
|
620
|
+
* hashing it every time cost tens of milliseconds per state in big communities.
|
|
616
621
|
*/
|
|
617
622
|
get topHash(): string;
|
|
618
|
-
|
|
623
|
+
/**
|
|
624
|
+
* A commit's hash, kept for the commit it was taken from (a commit never changes once made): every sync frame, sync
|
|
625
|
+
* answer and commit hashed the whole window again, about a tenth of the load test's CPU at 64 and 128 members.
|
|
626
|
+
*/
|
|
627
|
+
private hashOf;
|
|
628
|
+
private readonly hashes;
|
|
619
629
|
get epoch(): number;
|
|
620
630
|
get roster(): Roster;
|
|
621
631
|
get admin(): string | undefined;
|
|
@@ -21,7 +21,8 @@ export declare function formatLocalTarget(target: LocalTarget): string;
|
|
|
21
21
|
*/
|
|
22
22
|
export declare function resolveTargetUrl(target: LocalTarget, path: string): string | null;
|
|
23
23
|
export declare function sanitizeRequestHeaders(headers: HeaderList): HeaderList;
|
|
24
|
-
|
|
24
|
+
/** `from`: the local URL of the request answered, the one a relative `Location` is read against. */
|
|
25
|
+
export declare function sanitizeResponseHeaders(headers: HeaderList, target: LocalTarget, from?: string): HeaderList;
|
|
25
26
|
/**
|
|
26
27
|
* The contact's headers a viewer does not pass on: each makes the browser send something to a place it names, outside
|
|
27
28
|
* `connect-src` (violation and network-error reports, and the endpoints they go to; `Link` preloads, prefetches and
|
|
@@ -75,12 +76,20 @@ export declare function withViewerPolicy(headers: HeaderList, relayOnly?: boolea
|
|
|
75
76
|
/**
|
|
76
77
|
* Turns `http://localhost:3400/base/x` into `/x` so the client never learns or
|
|
77
78
|
* follows the local address. Null when the location is not on the target origin
|
|
78
|
-
* and under its base path.
|
|
79
|
+
* and under its base path. A relative one (`edit`, `?page=2`, `../x`) is read
|
|
80
|
+
* against `from`, the local URL of the request it answers, as a browser reads it;
|
|
81
|
+
* without one, against the base path.
|
|
79
82
|
*/
|
|
80
|
-
export declare function relativizeLocation(location: string, target: LocalTarget): string | null;
|
|
83
|
+
export declare function relativizeLocation(location: string, target: LocalTarget, from?: string): string | null;
|
|
81
84
|
export interface HostedHttpService {
|
|
82
85
|
id: string;
|
|
83
86
|
target: LocalTarget;
|
|
87
|
+
/**
|
|
88
|
+
* Aborts once this peer may no longer reach the service (stopped, removed,
|
|
89
|
+
* or the contact taken off its list): the requests still open are reset, not
|
|
90
|
+
* answered.
|
|
91
|
+
*/
|
|
92
|
+
revoked?: AbortSignal;
|
|
84
93
|
}
|
|
85
94
|
export interface LocalRequest {
|
|
86
95
|
url: string;
|
|
@@ -115,6 +124,8 @@ export declare class HttpHost {
|
|
|
115
124
|
private readonly live;
|
|
116
125
|
/** Body bytes of the streams in `live`: a peer cannot make the host hold more than `maxHostBodyBytesPerPeer`. */
|
|
117
126
|
private heldBodyBytes;
|
|
127
|
+
/** One listener per `revoked` signal of the open streams, not one per stream: a page opens dozens at once. */
|
|
128
|
+
private readonly revokedListeners;
|
|
118
129
|
constructor(channel: FrameChannel, getService: (id: string) => HostedHttpService | undefined, localFetch: LocalFetch);
|
|
119
130
|
get activeRequests(): number;
|
|
120
131
|
handleRequest(frame: HttpRequestFrame): void;
|
|
@@ -126,6 +137,8 @@ export declare class HttpHost {
|
|
|
126
137
|
/** Ids are reused after a reset, so a stream is current only if it is the one in the map. */
|
|
127
138
|
private isCurrent;
|
|
128
139
|
private end;
|
|
140
|
+
/** An answer still on its way would reach someone the app is no longer shared with: those streams are reset. */
|
|
141
|
+
private watchRevoked;
|
|
129
142
|
/** The stream no longer counts toward the limits: its body is dropped, or its local fetch has settled. */
|
|
130
143
|
private release;
|
|
131
144
|
private fail;
|
|
@@ -160,10 +173,20 @@ export declare class HttpClient {
|
|
|
160
173
|
private waitingBytes;
|
|
161
174
|
private inFlight;
|
|
162
175
|
private closed;
|
|
176
|
+
/** Response-body bytes all this client's responses hold before their readers took them. */
|
|
177
|
+
private readonly unread;
|
|
163
178
|
constructor(channel: FrameChannel);
|
|
164
179
|
request(serviceId: string, request: ClientRequest): Promise<ClientResponse>;
|
|
165
180
|
handleResponse(frame: HttpResponseFrame): void;
|
|
166
181
|
handleChunk(chunk: ChunkFrame): void;
|
|
182
|
+
/**
|
|
183
|
+
* Nothing tells the peer to slow down, and its last chunk frees the slot: a reader that stalls (a contact's page that
|
|
184
|
+
* never reads what it fetched) would have the whole body held here, one per request it leaves unread. Past the bound
|
|
185
|
+
* the reader gets `unreadStallMs`, as a link that hands over many chunks at once leaves it no turn: one that took
|
|
186
|
+
* something in it is looked at again, one that took nothing has the response reset and what it held let go.
|
|
187
|
+
*/
|
|
188
|
+
private checkUnread;
|
|
189
|
+
private dropUnread;
|
|
167
190
|
handleReset(frame: ResetFrame): void;
|
|
168
191
|
close(): void;
|
|
169
192
|
private armIdleTimer;
|
|
@@ -149,6 +149,8 @@ export declare class AppRanges {
|
|
|
149
149
|
private readonly newServeId;
|
|
150
150
|
private readonly now;
|
|
151
151
|
private readonly serves;
|
|
152
|
+
/** The same serves by app, then file: an app may serve 100,000 files, and walking `serves` for each was O(n²). */
|
|
153
|
+
private readonly servesByApp;
|
|
152
154
|
private readonly serving;
|
|
153
155
|
/**
|
|
154
156
|
* Tasks cancelled, unserved, or stopped by the contact's close or a session's end, that this side is still reading or
|
|
@@ -3,12 +3,18 @@ export declare const VIDEO_METADATA_LIMITS: {
|
|
|
3
3
|
readonly maxBoxBytes: number;
|
|
4
4
|
/** The most top-level boxes walked (a fragmented MP4 has two per fragment). */
|
|
5
5
|
readonly maxBoxes: 100000;
|
|
6
|
+
/** The most chunks of an AVI walked (one per frame and per piece of sound). */
|
|
7
|
+
readonly maxChunks: 4000000;
|
|
6
8
|
/** Bytes read first to tell a video from another file. */
|
|
7
9
|
readonly headBytes: 64;
|
|
8
10
|
/** Bytes read at once for a box's header or a small box, so the next headers and `moof`s are read with it. */
|
|
9
11
|
readonly readAhead: number;
|
|
10
12
|
/** The most a walk going on from its window reads at once (an Ogg's pages, a live WebM's blocks: the whole file). */
|
|
11
13
|
readonly readAheadMax: number;
|
|
14
|
+
/** The most bytes between two parts replaced that are read and sent with them as one part of the stripped video. */
|
|
15
|
+
readonly joinGap: number;
|
|
16
|
+
/** The most bytes of such a part. */
|
|
17
|
+
readonly joinedBytes: number;
|
|
12
18
|
};
|
|
13
19
|
/** Why a video is refused: its metadata could not be removed, so it does not go at all. */
|
|
14
20
|
export declare const NO_VIDEO_METADATA = "This video cannot be sent: Ghostly could not remove the details saved in it, like where it was recorded";
|
|
@@ -34,6 +40,7 @@ export interface VideoPatch {
|
|
|
34
40
|
end: number;
|
|
35
41
|
bytes?: Uint8Array;
|
|
36
42
|
}
|
|
43
|
+
export declare const isAsf: (head: Uint8Array) => boolean;
|
|
37
44
|
/**
|
|
38
45
|
* `source` as it is sent: an MP4 or QuickTime video without its metadata, made of `source`'s own bytes but for the
|
|
39
46
|
* boxes and samples zeroed; undefined when it goes as it is (not one of these videos, a file without a video track).
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { wd as boundVerifiedIdentity, xd as IdentityCheckUnavailable } from "./src-CqAqFhh9.js";
|
|
2
2
|
//#region ../browser/src/proofs/verify.ts
|
|
3
3
|
var DAY = 86400;
|
|
4
4
|
/**
|
|
@@ -104,4 +104,4 @@ function boundedIdentityFetch(options = { online: () => true }) {
|
|
|
104
104
|
//#endregion
|
|
105
105
|
export { verifyIdentity as i, boundedIdentityFetch as n, descriptorProblems as r, availableSigners as t };
|
|
106
106
|
|
|
107
|
-
//# sourceMappingURL=verify-
|
|
107
|
+
//# sourceMappingURL=verify-B9s82dbd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify-
|
|
1
|
+
{"version":3,"file":"verify-B9s82dbd.js","names":[],"sources":["../../browser/src/proofs/verify.ts"],"sourcesContent":["import { boundVerifiedIdentity, IdentityCheckUnavailable, 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.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 */\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 IdentityCheckUnavailable(\"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,SAAS,KAAK,sCAAsC;CAC9F,IAAI,CAAC,EAAE,OAAO,KAAK,GAAG,SAAS,KA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AC1C,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.11.
|
|
3
|
+
"version": "1.11.4",
|
|
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",
|