@ghostlytools/sdk 1.8.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.js +2 -2
- package/dist/{fakes-DSeGiDvk.js → fakes-Bx53XiDM.js} +2 -2
- package/dist/{fakes-DSeGiDvk.js.map → fakes-Bx53XiDM.js.map} +1 -1
- package/dist/fakes.js +1 -1
- package/dist/index.js +2 -2
- package/dist/{keet-identity-key-Db5KY0V1.js → keet-identity-key-D8ioYMkd.js} +2 -2
- package/dist/{keet-identity-key-Db5KY0V1.js.map → keet-identity-key-D8ioYMkd.js.map} +1 -1
- package/dist/{src-CfpOdLVf.js → src-Ch4NWeBg.js} +1279 -137
- package/dist/src-Ch4NWeBg.js.map +1 -0
- package/dist/testing.js +3 -3
- package/dist/types/core/src/chatFiles.d.ts +32 -2
- package/dist/types/core/src/ghostlink.d.ts +10 -0
- package/dist/types/core/src/groupCommunity.d.ts +23 -3
- package/dist/types/core/src/groupSession.d.ts +19 -21
- package/dist/types/core/src/groupSignals.d.ts +4 -0
- package/dist/types/core/src/image.d.ts +2 -0
- package/dist/types/core/src/index.d.ts +2 -0
- package/dist/types/core/src/pairedTransports.d.ts +14 -3
- package/dist/types/core/src/pictureMetadata.d.ts +25 -0
- package/dist/types/core/src/statusCards.d.ts +5 -0
- package/dist/types/core/src/videoMetadata.d.ts +16 -0
- package/dist/{verify-C-u4HILn.js → verify-Bi_Y5oat.js} +2 -2
- package/dist/{verify-C-u4HILn.js.map → verify-Bi_Y5oat.js.map} +1 -1
- package/package.json +1 -1
- package/dist/src-CfpOdLVf.js.map +0 -1
package/dist/testing.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Yu as IDENTITY_MAX_EVIDENCE, ad as IdentityExchange, dw as createIdentity, ia as isBitcoinAddress, ka as decodeBolt11, pd as newIdentityBinding, sd as emptyIdentityLedger, ud as identityStatement } from "./src-Ch4NWeBg.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-Bi_Y5oat.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-Bx53XiDM.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;
|
|
@@ -107,8 +107,20 @@ export declare const FILE_LIMITS: {
|
|
|
107
107
|
readonly stallMs: 60000;
|
|
108
108
|
/** A receiver makes what it stored durable, and records the point to resume from, this often. */
|
|
109
109
|
readonly checkpointBytes: number;
|
|
110
|
-
/**
|
|
110
|
+
/**
|
|
111
|
+
* A receiver confirms at least this often while writing, and the file's last bytes at once. Its writes are buffered
|
|
112
|
+
* and done at once, so confirming whenever they were all done too was confirming nearly every chunk: 6,400 confirms for
|
|
113
|
+
* 100 MiB, each a native call and a progress update on both sides. A host that batches them (`batchConfirms`) does not.
|
|
114
|
+
*/
|
|
111
115
|
readonly ackEveryBytes: number;
|
|
116
|
+
/**
|
|
117
|
+
* Batched (`ChatFilesHost.batchConfirms`), bytes stored and not confirmed are confirmed this long after the first of
|
|
118
|
+
* them was stored, at most. What a sender has in flight may be no more than `ackEveryBytes` (a window at its floor, one
|
|
119
|
+
* chunk while the path is measured), and bytes waiting here for a confirm are bytes it cannot send: on a slow or
|
|
120
|
+
* wavering path a confirm comes about every this long, as fast as the window needs. A round trip it measures is up to
|
|
121
|
+
* this much longer, well inside the queue it allows (`queueMs`).
|
|
122
|
+
*/
|
|
123
|
+
readonly ackWaitMs: 10;
|
|
112
124
|
/** A sender reads its file this much at a time. */
|
|
113
125
|
readonly readBytes: number;
|
|
114
126
|
/** The session refused a data frame (its send budget was full): the sender looks again after this long. */
|
|
@@ -235,6 +247,12 @@ export interface ChatFilesHost {
|
|
|
235
247
|
*/
|
|
236
248
|
resend?(record: FileTransferRecord, sent: number): boolean;
|
|
237
249
|
now?(): number;
|
|
250
|
+
/**
|
|
251
|
+
* Receiving, a confirm goes every `FILE_LIMITS.ackEveryBytes` stored, or `FILE_LIMITS.ackWaitMs` after the first
|
|
252
|
+
* bytes it would confirm, not whenever the writes are all done (nearly every chunk). Not for a group's edges: on a
|
|
253
|
+
* shared uplink an edge's window goes down to a chunk (`FileUplink.floor`), far less than a confirm's worth.
|
|
254
|
+
*/
|
|
255
|
+
batchConfirms?: boolean;
|
|
238
256
|
/**
|
|
239
257
|
* The uplink this chat's files share with others that leave the device by it (`FileUplink`): a group's edges, each
|
|
240
258
|
* a `ChatFiles` of its own, serving one file to several members at once. Absent: the uplink is this chat's alone.
|
|
@@ -302,6 +320,13 @@ export declare class ChatFiles {
|
|
|
302
320
|
private peerRoomValue;
|
|
303
321
|
/** What the chat's files may have in flight, sized by the path. */
|
|
304
322
|
private readonly pace;
|
|
323
|
+
/**
|
|
324
|
+
* What the chat's files had in flight just before the last confirm. A receiver confirms many chunks at once
|
|
325
|
+
* (`ackEveryBytes`), and the chunks sent for them go with that much in flight, the window: counted one by one, the
|
|
326
|
+
* first went with the window less a confirm, and read as a path carrying that little, it shrank the window and ended
|
|
327
|
+
* every trial of a larger one (a fifth of the rate on a wavering path). Confirmed chunk by chunk, it is what each sends with.
|
|
328
|
+
*/
|
|
329
|
+
private refill;
|
|
305
330
|
constructor(host: ChatFilesHost);
|
|
306
331
|
/** The floor of this chat's window: all of `minWindowBytes`, or its share of an uplink it shares (`FileUplink`). */
|
|
307
332
|
private floor;
|
|
@@ -374,7 +399,10 @@ export declare class ChatFiles {
|
|
|
374
399
|
* the windows of ten files and more at once overflowed the session's receive queue.
|
|
375
400
|
*/
|
|
376
401
|
private startIncoming;
|
|
377
|
-
/**
|
|
402
|
+
/**
|
|
403
|
+
* The next file waiting its turn, once one ends. The others were told they wait when they were queued: told again at
|
|
404
|
+
* each end, n files at once made about n²/2 frames, and their sender stored its record for each.
|
|
405
|
+
*/
|
|
378
406
|
private startNext;
|
|
379
407
|
private onOffer;
|
|
380
408
|
/**
|
|
@@ -386,6 +414,8 @@ export declare class ChatFiles {
|
|
|
386
414
|
/** An agreed file that ended here, offered again: taken again from the start. */
|
|
387
415
|
private retake;
|
|
388
416
|
private onData;
|
|
417
|
+
/** `pf-got` for what is stored and not confirmed yet. */
|
|
418
|
+
private confirm;
|
|
389
419
|
/** What was stored is durable, and a restart resumes from there. */
|
|
390
420
|
private checkpoint;
|
|
391
421
|
private checkpointNow;
|
|
@@ -1130,6 +1130,16 @@ export declare class GhostLink {
|
|
|
1130
1130
|
* simply be away. Two dials crossing are settled by key order (see `registerEndpoint`).
|
|
1131
1131
|
*/
|
|
1132
1132
|
private knock;
|
|
1133
|
+
/** The knock under way (`knock`): its transport, its attempt, and whether it was knocked again (`knockAgain`). */
|
|
1134
|
+
private knocking;
|
|
1135
|
+
/**
|
|
1136
|
+
* The endpoint of a knock still under way is back on its relay (`NativeEndpoint.onRelayBack`): it is knocked again, once,
|
|
1137
|
+
* beside the first, and the first live wins. An Android phone back from Doze knocked at once through an Iroh whose relay
|
|
1138
|
+
* was gone; Iroh found it again only seconds later (its reconnect backoff, up to 16 s), and what the knock sent meanwhile
|
|
1139
|
+
* went nowhere: QUIC sends it again seconds on, and the dial is given 20 s. Live again 4.4 s and 9.8 s after the
|
|
1140
|
+
* return (away 5 and 15 minutes), and once not over Iroh at all (the emulator with a CLI bot, 2026-11-01).
|
|
1141
|
+
*/
|
|
1142
|
+
private knockAgain;
|
|
1133
1143
|
canReleaseEndpoint(transport: PairedTransport): boolean;
|
|
1134
1144
|
releaseEndpoint(transport: PairedTransport): Promise<void>;
|
|
1135
1145
|
/** When the chat was last in use on its session: the contact's last frame of use, or the session's start. */
|
|
@@ -173,13 +173,22 @@ export declare function verifyCommunityCommit(raw: unknown, parent: CommunityCom
|
|
|
173
173
|
* handed: a `leave` in it is not held to the admission it ends, since a chain from before 2026-10-10 may hold a
|
|
174
174
|
* member's second leave under the one statement there was, and no newcomer could enter that group again.
|
|
175
175
|
*/
|
|
176
|
-
export declare function verifyCommunityChain(raw: unknown, groupId?: string): {
|
|
176
|
+
export declare function verifyCommunityChain(raw: unknown, groupId?: string): VerifiedChain | {
|
|
177
|
+
error: string;
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* `verifyCommunityChain` for a client whose engine shares its page's thread: the same checks, letting the thread go every
|
|
181
|
+
* `CHAIN_SLICE_MS` of them. One commit's signature takes ~2.6 ms in JavaScript on a desktop CPU, several times that on a
|
|
182
|
+
* phone, so a history near `COMMUNITY_LIMITS.chain` checked at once was an app that drew nothing for 5 s and more.
|
|
183
|
+
*/
|
|
184
|
+
export declare function verifyCommunityChainPaced(raw: unknown, groupId?: string): Promise<VerifiedChain | {
|
|
185
|
+
error: string;
|
|
186
|
+
}>;
|
|
187
|
+
type VerifiedChain = {
|
|
177
188
|
chain: CommunityCommit[];
|
|
178
189
|
roster: Roster;
|
|
179
190
|
entry: string;
|
|
180
191
|
rosters: Roster[];
|
|
181
|
-
} | {
|
|
182
|
-
error: string;
|
|
183
192
|
};
|
|
184
193
|
export interface CommunityMessageFrame {
|
|
185
194
|
t: "group-msg";
|
|
@@ -526,6 +535,16 @@ export declare class CommunitySession {
|
|
|
526
535
|
} | {
|
|
527
536
|
error: string;
|
|
528
537
|
};
|
|
538
|
+
/** `join`, its chain checked a slice at a time (`verifyCommunityChainPaced`): what an app sharing its page's thread calls. */
|
|
539
|
+
static joinPaced(link: {
|
|
540
|
+
g: string;
|
|
541
|
+
host: string;
|
|
542
|
+
}, pieces: unknown[], welcome: unknown, seedB64: string, now?: number): Promise<{
|
|
543
|
+
state: CommunityState;
|
|
544
|
+
} | {
|
|
545
|
+
error: string;
|
|
546
|
+
}>;
|
|
547
|
+
private static joinVerified;
|
|
529
548
|
get id(): string;
|
|
530
549
|
/** The name the admin gave the group, else the one it had when I got in (WISP 903 § Metadata). */
|
|
531
550
|
get name(): string;
|
|
@@ -899,3 +918,4 @@ export declare class CommunitySession {
|
|
|
899
918
|
private fork;
|
|
900
919
|
}
|
|
901
920
|
export declare function signCommunity(commit: Omit<CommunityCommit, "sig">, seed: Uint8Array): CommunityCommit;
|
|
921
|
+
export {};
|
|
@@ -431,16 +431,10 @@ export declare class GroupSession {
|
|
|
431
431
|
/** Set while a save of what received messages changed is due (`persistSoon`). */
|
|
432
432
|
private saveTimer;
|
|
433
433
|
/**
|
|
434
|
-
* The
|
|
435
|
-
*
|
|
434
|
+
* The removals of authors out of the roster that each member was handed (`editKey`), so an app that does not take
|
|
435
|
+
* them is not handed them again at every sync. In memory only.
|
|
436
436
|
*/
|
|
437
437
|
private leaversHanded;
|
|
438
|
-
/**
|
|
439
|
-
* The frames a commit took out of the logs (`pruneRelay`), newest last, and whether the app holds them with its
|
|
440
|
-
* messages: a removal's `left` mark can come after its commit, and what the leaver wrote is then kept again
|
|
441
|
-
* (`unprune`). In memory only: started again, the app's rows bring theirs back.
|
|
442
|
-
*/
|
|
443
|
-
private pruned;
|
|
444
438
|
/** Syncs answered per member, a few a minute (`GROUP_LIMITS.syncAnswers`). In memory only. */
|
|
445
439
|
private syncsAnswered;
|
|
446
440
|
/**
|
|
@@ -454,6 +448,8 @@ export declare class GroupSession {
|
|
|
454
448
|
* message written just now. Each frame of the answer keeps it open: it goes a slice at a time. In memory only.
|
|
455
449
|
*/
|
|
456
450
|
private readonly answering;
|
|
451
|
+
/** Per member ahead of me: the epoch its last sync said, up to which its answer to mine brings the chain. In memory only. */
|
|
452
|
+
private readonly syncedEpoch;
|
|
457
453
|
/** Catch-up answers still going out, a slice at a time (`handOut`). */
|
|
458
454
|
private readonly answers;
|
|
459
455
|
/**
|
|
@@ -555,8 +551,9 @@ export declare class GroupSession {
|
|
|
555
551
|
private serialize;
|
|
556
552
|
private persist;
|
|
557
553
|
/**
|
|
558
|
-
* A save within `GROUP_LIMITS.saveWithinMs`, for what a received message changes (what was seen,
|
|
559
|
-
* on): the state holds the whole hand-on log, and a member back in a busy
|
|
554
|
+
* A save within `GROUP_LIMITS.saveWithinMs`, for what a received message, commit or secret changes (what was seen,
|
|
555
|
+
* what is kept to hand on, the chain): the state holds the whole hand-on log and chain, and a member back in a busy
|
|
556
|
+
* group wrote all of it once per message, and once per commit.
|
|
560
557
|
* The message itself is stored before (`hooks.message`). An app killed before the save takes those frames again when
|
|
561
558
|
* it syncs: its store has the messages already, and the state then catches up.
|
|
562
559
|
*/
|
|
@@ -586,15 +583,10 @@ export declare class GroupSession {
|
|
|
586
583
|
/** A fresh secret without a membership change: whoever holds the old one and is not a member learns nothing new. */
|
|
587
584
|
rotate(now?: number): Promise<void>;
|
|
588
585
|
private commit;
|
|
589
|
-
/**
|
|
590
|
-
* Someone removed is not handed on any more, whatever they sent while in the roster; one who left still is, for the
|
|
591
|
-
* epochs before its leave (WISP 902 § Catch-up).
|
|
592
|
-
*/
|
|
586
|
+
/** Someone removed or gone is not handed on any more, whatever they sent while in the roster (WISP 902 § Catch-up). */
|
|
593
587
|
private pruneRelay;
|
|
594
588
|
/** Whether a kept edit is a removal (WISP 400 § Delete for everyone): its box, under its epoch's key, says `rm`. */
|
|
595
589
|
private isRemovalEdit;
|
|
596
|
-
/** The frames `pruneRelay` dropped that are handed on again now (a removal's `left` mark came after it), back in their logs. */
|
|
597
|
-
private unprune;
|
|
598
590
|
/** Another member's edit, kept to hand on: the latest per message; the oldest go once the log is full. False: one as new was kept. */
|
|
599
591
|
private keepEdit;
|
|
600
592
|
/** A frame of another member, kept to hand on; the oldest go once the log is full. */
|
|
@@ -742,8 +734,8 @@ export declare class GroupSession {
|
|
|
742
734
|
private commitUnlessTurnUnconfirmed;
|
|
743
735
|
/**
|
|
744
736
|
* A message, from its author's edge or handed on by another member. Handed on, it is taken only while both are in
|
|
745
|
-
* the roster (someone removed is neither heard from nor handed on, #300),
|
|
746
|
-
*
|
|
737
|
+
* the roster (someone removed or gone is neither heard from nor handed on, #300, `handsOn`), and its boxes only with
|
|
738
|
+
* the author's `xs`.
|
|
747
739
|
*/
|
|
748
740
|
private receiveMessage;
|
|
749
741
|
/**
|
|
@@ -778,12 +770,18 @@ export declare class GroupSession {
|
|
|
778
770
|
private park;
|
|
779
771
|
/** Whoever sent something I cannot read yet is ahead of me, or holds a secret I lack: ask, but not in a loop. */
|
|
780
772
|
private ask;
|
|
773
|
+
/**
|
|
774
|
+
* Whether my sync to `from` (the one my edge opened with) still waits for its answer, which has the chain from the
|
|
775
|
+
* epoch it said: asking again on reading its newer sync, or a commit of that answer, had each commit I missed sent
|
|
776
|
+
* twice, each with a secret sealed again (200 missed went as 400 frames, 1,456 when answers go a slice at a time).
|
|
777
|
+
*/
|
|
778
|
+
private awaitsAnswer;
|
|
781
779
|
private replayWaiting;
|
|
782
780
|
private receiveCommit;
|
|
783
781
|
/**
|
|
784
|
-
* Whether a frame of `author`
|
|
785
|
-
*
|
|
786
|
-
*
|
|
782
|
+
* Whether a frame of `author` is taken from another member, kept and handed on: only while its author is in the
|
|
783
|
+
* roster. One who left, as one removed, keeps its seed and the secrets of its epochs, and a copy of its state signs
|
|
784
|
+
* frames for them after the leave, dated as it likes: whether the admin marked its removal `left` changes nothing.
|
|
787
785
|
*/
|
|
788
786
|
private handsOn;
|
|
789
787
|
/** Keeps the admin's mark on a commit that took out a member who left (`GroupCommitFrame.left`) when it holds; true when new. */
|
|
@@ -74,6 +74,8 @@ export interface CarriedHooks {
|
|
|
74
74
|
taken: number;
|
|
75
75
|
sure: boolean;
|
|
76
76
|
};
|
|
77
|
+
/** Whether `carry` would hand a packet to any link now (none: every member that could pass it on is away). */
|
|
78
|
+
canCarry?(): boolean;
|
|
77
79
|
/** The edge's own data link is open: it carries everything, and nothing is handed to anyone. */
|
|
78
80
|
open(): boolean;
|
|
79
81
|
/** A carried packet of the member's is here and no read is under way: look now. */
|
|
@@ -115,6 +117,8 @@ export declare class CarriedTransport implements PkarrTransport {
|
|
|
115
117
|
private seen;
|
|
116
118
|
/** A read under way: resolved when a carried packet comes meanwhile. */
|
|
117
119
|
private waiting;
|
|
120
|
+
/** The records of a publish refused before they were signed, while nobody could carry them: signed when one can (`latest`). */
|
|
121
|
+
private unsigned;
|
|
118
122
|
/** The packet the relays have not got yet. */
|
|
119
123
|
private pending;
|
|
120
124
|
/** How many carried packets of the member's came: a deferral that ends with none more says no member reaches it. */
|
|
@@ -34,6 +34,8 @@ export declare function previewable(size: ImageMeta | undefined): boolean;
|
|
|
34
34
|
export declare function isImageMime(mime: string): boolean;
|
|
35
35
|
/** A peer's `image` description, or undefined when it is not one. It never refuses the file. */
|
|
36
36
|
export declare function parseImageMeta(value: unknown, mime?: string): ImageMeta | undefined;
|
|
37
|
+
/** The EXIF orientation in an APP1 segment's TIFF block (1 when it says none). */
|
|
38
|
+
export declare function exifOrientation(b: Uint8Array, tiff: number, end: number): number;
|
|
37
39
|
/**
|
|
38
40
|
* A picture's size as it is shown, read from its first bytes (PNG, JPEG, GIF, WebP), or undefined when they do not
|
|
39
41
|
* say. Only the header is read: a JPEG whose frame header, or a GIF whose first frame, sits past
|
|
@@ -34,6 +34,8 @@ export * from "./chatFiles.js";
|
|
|
34
34
|
export * from "./voice.js";
|
|
35
35
|
export * from "./video.js";
|
|
36
36
|
export * from "./image.js";
|
|
37
|
+
export * from "./pictureMetadata.js";
|
|
38
|
+
export * from "./videoMetadata.js";
|
|
37
39
|
export * from "./linkPreview.js";
|
|
38
40
|
export * from "./messageTime.js";
|
|
39
41
|
export * from "./payments.js";
|
|
@@ -21,6 +21,8 @@ export interface NativeEndpoint {
|
|
|
21
21
|
onConnection: ((connection: BoundChannel) => void) | null;
|
|
22
22
|
onDescriptor: (() => void) | null;
|
|
23
23
|
onUnavailable?: (() => void) | null;
|
|
24
|
+
/** The endpoint is connected to its relay again after it lost it (the native Iroh's home relay; nothing else says it). */
|
|
25
|
+
onRelayBack?: (() => void) | null;
|
|
24
26
|
}
|
|
25
27
|
export type TransportDescriptors = Partial<Record<NativeTransport, unknown>>;
|
|
26
28
|
/**
|
|
@@ -31,8 +33,9 @@ export type TransportDescriptors = Partial<Record<NativeTransport, unknown>>;
|
|
|
31
33
|
*
|
|
32
34
|
* So every relay URL is put in one spelling before it goes into an Iroh endpoint (the relays it homes on, a contact's
|
|
33
35
|
* descriptor before a dial), and which one depends on the endpoint:
|
|
34
|
-
* - `"dotted"`,
|
|
35
|
-
* compare two relays in.
|
|
36
|
+
* - `"dotted"`, n0's relays with their trailing dot: what native Iroh homes on by default (the Desktop), and the form
|
|
37
|
+
* to compare two relays in. Any other relay keeps its plain name here too: a relay behind a proxy (a Cloudflare
|
|
38
|
+
* tunnel) is found by its Host header, and the proxy answers the dotted name with 404.
|
|
36
39
|
* - `"plain"`, the name without it: the only one every browser opens. WebKit (Safari, the iPhone app) refuses a
|
|
37
40
|
* host name that ends in a dot, for `fetch` and for a WebSocket alike, so nothing a browser's Iroh is given has one.
|
|
38
41
|
*
|
|
@@ -48,10 +51,18 @@ export declare function irohDescriptor<T>(descriptor: T, spelling?: IrohRelaySpe
|
|
|
48
51
|
* as a test relay is (the same rule as the relay settings).
|
|
49
52
|
*/
|
|
50
53
|
export declare const RELAY_URL: RegExp;
|
|
54
|
+
/**
|
|
55
|
+
* A relay URL with more than its server's address in it: a login, a query or a fragment, which no relay setting takes
|
|
56
|
+
* (irohWeb.ts `irohRelayProblem`, hyperdhtRelay.ts `hyperdhtRelayProblem`). An older app named its HyperDHT relay as
|
|
57
|
+
* set, with them; such a descriptor is not dialed or kept, and the rest of what the contact told still is.
|
|
58
|
+
*/
|
|
59
|
+
export declare const RELAY_WITH_SECRETS: RegExp;
|
|
60
|
+
/** A relay URL a descriptor may name: `RELAY_URL`, with nothing but the server's address in it. */
|
|
61
|
+
export declare const relayUrl: (value: unknown) => value is string;
|
|
51
62
|
/**
|
|
52
63
|
* A contact's native descriptors as it tells them on a session (`paired-policy`, `paired-adapters`) or as this app
|
|
53
64
|
* kept them: only what the adapters dial, each field in the shape its adapter makes. The keys are 64 hex characters,
|
|
54
|
-
* a relay passes `
|
|
65
|
+
* a relay passes `relayUrl` (the rule its capability record is read by), an Iroh descriptor lists at most eight
|
|
55
66
|
* socket addresses. A descriptor that is anything else is left out, as one the contact never told; a field this app
|
|
56
67
|
* does not know is not kept.
|
|
57
68
|
*/
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const PICTURE_METADATA_LIMITS: {
|
|
2
|
+
/** The largest picture read whole to remove its metadata: past this it is refused. */
|
|
3
|
+
readonly maxBytes: number;
|
|
4
|
+
/** Bytes read first to tell a picture from another file. */
|
|
5
|
+
readonly headBytes: 64;
|
|
6
|
+
};
|
|
7
|
+
/** Why a picture is refused: its metadata could not be removed, so it does not go at all. */
|
|
8
|
+
export declare const NO_PICTURE_METADATA = "This picture cannot be sent: Ghostly could not remove the details saved in it, like where it was taken";
|
|
9
|
+
/**
|
|
10
|
+
* A picture's bytes without its metadata, as parts to put in a Blob; undefined when the file is not a picture this
|
|
11
|
+
* strips (by its bytes and its type), so it goes as it is. Throws `NO_PICTURE_METADATA` when it is one but its
|
|
12
|
+
* metadata cannot be removed.
|
|
13
|
+
*/
|
|
14
|
+
export declare function stripPictureMetadata(bytes: Uint8Array, mime: string): Uint8Array[] | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Whether a file is a picture whose metadata goes before it is sent, by its first `PICTURE_METADATA_LIMITS.headBytes`
|
|
17
|
+
* bytes or by its type: then it is read whole and stripped (`stripPictureMetadata`), else it goes as it is.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isStrippedPicture(head: Uint8Array, mime: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* `source` as it is sent: without its metadata when it is a picture (`stripPictureMetadata`), or undefined when it is
|
|
22
|
+
* not one and goes as it is. Only its first bytes are read for any other file. Throws `NO_PICTURE_METADATA` for a
|
|
23
|
+
* picture that cannot be stripped or is past `PICTURE_METADATA_LIMITS.maxBytes`; an error reading `source` as it is.
|
|
24
|
+
*/
|
|
25
|
+
export declare function withoutPictureMetadata(source: Blob, mime: string): Promise<Blob | undefined>;
|
|
@@ -232,6 +232,11 @@ export declare function cardLine(value: unknown, max: number): string | undefine
|
|
|
232
232
|
* `STATUS_CARD_LIMITS.url` characters. Returned as the parser writes it (a non-ASCII host in punycode).
|
|
233
233
|
*/
|
|
234
234
|
export declare function cardUrl(value: unknown): string | undefined;
|
|
235
|
+
/**
|
|
236
|
+
* The link an app card names, sent or read (WISP 405 § An app): a card's link without its query or fragment. A
|
|
237
|
+
* private file's read token rides in a query, and a card goes to a contact; a bundle is pinned by its digest, not its link.
|
|
238
|
+
*/
|
|
239
|
+
export declare function appCardUrl(value: unknown): string | undefined;
|
|
235
240
|
/** The host a card shows beside a link, so the reader sees where it goes before following it. */
|
|
236
241
|
export declare function cardLinkHost(url: string): string;
|
|
237
242
|
/** How much of a usage card's quota is left, 0 to 100: its own percent, else worked out from used of limit. */
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const VIDEO_METADATA_LIMITS: {
|
|
2
|
+
/** The largest `moov` or `moof` read whole, and the most bytes of a metadata track's chunk: past this the video is refused. */
|
|
3
|
+
readonly maxBoxBytes: number;
|
|
4
|
+
/** The most top-level boxes walked (a fragmented MP4 has two per fragment). */
|
|
5
|
+
readonly maxBoxes: 100000;
|
|
6
|
+
/** Bytes read first to tell a video from another file. */
|
|
7
|
+
readonly headBytes: 64;
|
|
8
|
+
};
|
|
9
|
+
/** Why a video is refused: its metadata could not be removed, so it does not go at all. */
|
|
10
|
+
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";
|
|
11
|
+
/**
|
|
12
|
+
* `source` as it is sent: an MP4 or QuickTime video without its metadata, made of `source`'s own bytes but for the
|
|
13
|
+
* boxes and samples zeroed; undefined when it goes as it is (not one of these videos, a file without a video track).
|
|
14
|
+
* Throws `NO_VIDEO_METADATA` for a video whose metadata cannot be removed; an error reading `source` as it is.
|
|
15
|
+
*/
|
|
16
|
+
export declare function withoutVideoMetadata(source: Blob, mime: string): Promise<Blob | undefined>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { od as boundVerifiedIdentity } from "./src-Ch4NWeBg.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-Bi_Y5oat.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify-
|
|
1
|
+
{"version":3,"file":"verify-Bi_Y5oat.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,oBA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AI,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.
|
|
3
|
+
"version": "1.9.0",
|
|
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",
|