@ghostlytools/sdk 1.10.6 → 1.11.1
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/app.js.map +1 -1
- package/dist/core.js +187 -2
- package/dist/core.js.map +1 -1
- package/dist/{fakes-BNNNkQqY.js → fakes-LaWqqMv4.js} +2 -2
- package/dist/{fakes-BNNNkQqY.js.map → fakes-LaWqqMv4.js.map} +1 -1
- package/dist/fakes.js +1 -1
- package/dist/index.js +2 -2
- package/dist/{keet-identity-key-DJbA1oSW.js → keet-identity-key-CASfmXry.js} +2 -2
- package/dist/{keet-identity-key-DJbA1oSW.js.map → keet-identity-key-CASfmXry.js.map} +1 -1
- package/dist/{src-C2bAufMs.js → src-BN4AAuHI.js} +1995 -313
- package/dist/src-BN4AAuHI.js.map +1 -0
- package/dist/testing.js +3 -3
- package/dist/types/core/src/audioMetadata.d.ts +46 -0
- package/dist/types/core/src/clipboardGuard.d.ts +26 -0
- package/dist/types/core/src/dhtDelivery.d.ts +20 -1
- package/dist/types/core/src/engineErrors.d.ts +2 -0
- package/dist/types/core/src/ghostlink.d.ts +47 -3
- package/dist/types/core/src/groupCommunity.d.ts +73 -4
- package/dist/types/core/src/groupSession.d.ts +13 -1
- package/dist/types/core/src/groupSignals.d.ts +2 -0
- package/dist/types/core/src/http.d.ts +23 -3
- package/dist/types/core/src/identityProofs.d.ts +7 -0
- package/dist/types/core/src/identityTimeline.d.ts +6 -0
- package/dist/types/core/src/index.d.ts +4 -0
- package/dist/types/core/src/link.d.ts +2 -0
- package/dist/types/core/src/miniApp.d.ts +2 -2
- package/dist/types/core/src/pairedAppRanges.d.ts +18 -7
- package/dist/types/core/src/pairedCalls.d.ts +10 -0
- package/dist/types/core/src/pairedCapabilities.d.ts +6 -1
- package/dist/types/core/src/pairedStatus.d.ts +117 -0
- package/dist/types/core/src/pairedTransports.d.ts +10 -4
- package/dist/types/core/src/pairedTyping.d.ts +2 -0
- package/dist/types/core/src/pairedWake.d.ts +36 -5
- package/dist/types/core/src/replies.d.ts +3 -3
- package/dist/types/core/src/transport.d.ts +3 -0
- package/dist/types/core/src/transportSwitch.d.ts +5 -1
- package/dist/types/core/src/videoMetadata.d.ts +8 -2
- package/dist/types/core/src/viewerGuard.d.ts +65 -0
- package/dist/{verify-CpIce6Bt.js → verify-oCL662ms.js} +2 -2
- package/dist/{verify-CpIce6Bt.js.map → verify-oCL662ms.js.map} +1 -1
- package/package.json +1 -1
- package/dist/src-C2bAufMs.js.map +0 -1
|
@@ -34,7 +34,7 @@ export declare const APP_RANGE_LIMITS: {
|
|
|
34
34
|
readonly bytesPerSecond: number;
|
|
35
35
|
};
|
|
36
36
|
/**
|
|
37
|
-
* What an `ar-err` says. `not-served`: no serve of that id
|
|
37
|
+
* What an `ar-err` says. `not-served`: no serve of that id (never given, or ended); `changed` and
|
|
38
38
|
* `gone`: the file under it, as `files.read` says them; `busy`: past the requests the server takes in flight. A
|
|
39
39
|
* later version may add one: an asker reads a code it does not know as a failure.
|
|
40
40
|
*/
|
|
@@ -131,12 +131,13 @@ export interface AppRangeTask {
|
|
|
131
131
|
}
|
|
132
132
|
/**
|
|
133
133
|
* The read lane of one chat, both ways (WISP 1200 § A read lane to the contact). As the side that serves it keeps the
|
|
134
|
-
* serve ids it gave out
|
|
134
|
+
* serve ids it gave out and answers the contact's `ar-get` for those only, at most
|
|
135
135
|
* `APP_RANGE_LIMITS.inFlight` per app and `bytesPerSecond` asked in all (`busy` past either); the bytes themselves
|
|
136
136
|
* are read and sent by the session, which calls `finish` or `fail` for each task. As the side that asks it sends at
|
|
137
137
|
* most `inFlight` requests per app, keeps
|
|
138
|
-
* the rest waiting, and puts each answer back together, in order, from the offset asked.
|
|
139
|
-
*
|
|
138
|
+
* the rest waiting, and puts each answer back together, in order, from the offset asked. Requests last one session
|
|
139
|
+
* (`suspend` ends them); serves last until the app closes on either side (`closeApp`) or the session ends for good
|
|
140
|
+
* (`reset`, which ends both). A task still being read counts until it is settled.
|
|
140
141
|
*/
|
|
141
142
|
export declare class AppRanges {
|
|
142
143
|
private readonly send;
|
|
@@ -163,13 +164,13 @@ export declare class AppRanges {
|
|
|
163
164
|
private takenBytes;
|
|
164
165
|
constructor(send: (frame: AppRangeFrame) => void, newServeId?: () => string, now?: () => number);
|
|
165
166
|
/**
|
|
166
|
-
* Lets the contact's `app` read `file`
|
|
167
|
-
* the id it has, so an app that serves again on each play holds one serve per file, not one per call.
|
|
167
|
+
* Lets the contact's `app` read `file` until the app closes: the serve id to tell it. A file the app serves already
|
|
168
|
+
* answers the id it has, so an app that serves again on each play holds one serve per file, not one per call.
|
|
168
169
|
*/
|
|
169
170
|
serve(app: string, file: string): string;
|
|
170
171
|
/** Ends one serve: requests under it still being sent stop. False when it was not served. */
|
|
171
172
|
unserve(serveId: string): boolean;
|
|
172
|
-
/** The serve ids `app` has given out
|
|
173
|
+
/** The serve ids `app` has given out and not ended (what the panel's "Sharing with" line shows). */
|
|
173
174
|
servesOf(app: string): string[];
|
|
174
175
|
/** An `ar-get` from the contact: the task to read and send, or null when it was refused (the refusal is sent) or dropped. */
|
|
175
176
|
receiveGet(frame: Extract<AppRangeFrame, {
|
|
@@ -210,6 +211,16 @@ export declare class AppRanges {
|
|
|
210
211
|
closeApp(app: string, error?: AppRangeReadError, stopped?: boolean): void;
|
|
211
212
|
/** The session ended: no serve id lasts into the next, and every request fails with `offline`. Tasks still being read keep their places into the next. */
|
|
212
213
|
reset(): void;
|
|
214
|
+
/**
|
|
215
|
+
* The session changed (a resume, a re-dial, a transport switch) and the apps are held across it: every request fails
|
|
216
|
+
* with `offline`, and the serve ids stay, for the next session, until the app closes on either side.
|
|
217
|
+
*/
|
|
218
|
+
suspend(): void;
|
|
219
|
+
/**
|
|
220
|
+
* What `app` was sending stops and what it asked fails with `error`. A task this side is still reading keeps its place
|
|
221
|
+
* until it is settled; only `stopped` (this side's app closed) frees them now.
|
|
222
|
+
*/
|
|
223
|
+
private endRequests;
|
|
213
224
|
/** Stops `task` and frees its request number; `draining` keeps it counted until it is settled. */
|
|
214
225
|
private drop;
|
|
215
226
|
/** Frees `task`'s place; false when it was no longer live (nothing to send for it). */
|
|
@@ -11,6 +11,16 @@
|
|
|
11
11
|
export declare const PAIRED_CALL_FRAME = "paired-call";
|
|
12
12
|
/** A compact offer with the eight candidates `parseCallSignal` accepts stays well under this. */
|
|
13
13
|
export declare const MAX_PAIRED_CALL_SIGNAL = 8192;
|
|
14
|
+
/**
|
|
15
|
+
* A receiver takes at most this many `paired-call` frames from a contact per `CALL_RATE_WINDOW_MS`, counted before they
|
|
16
|
+
* are read; the rest are dropped. A person's busiest minute is under half of it, 68 frames: three calls placed, each
|
|
17
|
+
* started over 4 times on a newer offer (`MAX_RESTARTS`) and hung up; two calls whose path was lost twice, restarted
|
|
18
|
+
* every 8 s for 30 s each time (`ICE_RESTART_RETRY_MS`, `RECONNECT_TIMEOUT_MS`); the camera and the screen turned on
|
|
19
|
+
* and off five times each; and the latest signal said again on ten new sessions. Only an app that loops its signals
|
|
20
|
+
* reaches it.
|
|
21
|
+
*/
|
|
22
|
+
export declare const CALL_RECEIVE_LIMIT = 150;
|
|
23
|
+
export declare const CALL_RATE_WINDOW_MS = 60000;
|
|
14
24
|
export interface PairedCallFrame {
|
|
15
25
|
t: typeof PAIRED_CALL_FRAME;
|
|
16
26
|
s: string;
|
|
@@ -27,6 +27,11 @@ export declare const FILES_CAPABILITY = "files/3";
|
|
|
27
27
|
export declare const FILES_BINARY_CAPABILITY = "files/4";
|
|
28
28
|
/** The typing indicator: `paired-typing` frames on this session, 1:1 chats only (WISP 401 § Typing, `pairedTyping.ts`). */
|
|
29
29
|
export declare const TYPING_CAPABILITY = "typing/1";
|
|
30
|
+
/**
|
|
31
|
+
* Presence and a set status: `paired-status` frames on this session, 1:1 chats only (WISP 401 § Presence and status,
|
|
32
|
+
* `pairedStatus.ts`).
|
|
33
|
+
*/
|
|
34
|
+
export declare const STATUS_CAPABILITY = "status/1";
|
|
30
35
|
/** Reactions to messages: `paired-reaction` frames on this session, 1:1 chats only (WISP 401 § Reactions, `reactions.ts`). */
|
|
31
36
|
export declare const REACTIONS_CAPABILITY = "react/1";
|
|
32
37
|
/** Editing sent texts: `paired-edit` frames on this session, 1:1 chats only (WISP 401 § Edits, `pairedEdits.ts`). */
|
|
@@ -68,7 +73,7 @@ export declare const APP_RANGES_CAPABILITY = "app-ranges/1";
|
|
|
68
73
|
* What only a device link offers (WISP 06, `deviceLink.ts`): the frames between a person's own devices. They are in
|
|
69
74
|
* the type so a device link can announce them, and not in `KNOWN_SESSION_CAPABILITIES`: no chat knows them.
|
|
70
75
|
*/
|
|
71
|
-
export type SessionCapability = DeviceCapability | typeof CALLS_CAPABILITY | typeof SERVICES_CAPABILITY | typeof FILES_CAPABILITY | typeof FILES_BINARY_CAPABILITY | typeof TYPING_CAPABILITY | typeof REACTIONS_CAPABILITY | typeof EDIT_CAPABILITY | typeof WAKE_SESSION_CAPABILITY | typeof PIN_CAPABILITY | typeof STATUS_CARD_CAPABILITY | typeof BUTTONS_CAPABILITY | typeof UPGRADE_CAPABILITY | typeof APPS_CAPABILITY | typeof APP_RANGES_CAPABILITY;
|
|
76
|
+
export type SessionCapability = DeviceCapability | typeof CALLS_CAPABILITY | typeof SERVICES_CAPABILITY | typeof FILES_CAPABILITY | typeof FILES_BINARY_CAPABILITY | typeof TYPING_CAPABILITY | typeof STATUS_CAPABILITY | typeof REACTIONS_CAPABILITY | typeof EDIT_CAPABILITY | typeof WAKE_SESSION_CAPABILITY | typeof PIN_CAPABILITY | typeof STATUS_CARD_CAPABILITY | typeof BUTTONS_CAPABILITY | typeof UPGRADE_CAPABILITY | typeof APPS_CAPABILITY | typeof APP_RANGES_CAPABILITY;
|
|
72
77
|
/** Every capability this app knows on a session: what `receive` reports changes of. */
|
|
73
78
|
export declare const KNOWN_SESSION_CAPABILITIES: readonly SessionCapability[];
|
|
74
79
|
export declare const SESSION_CAPABILITIES_FRAME = "paired-capabilities";
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Presence and a set status in a 1:1 chat (WISP 401 § Presence and status): whether the person is there, and a status
|
|
3
|
+
* they set (Slack-like), said to the contact on the live session only.
|
|
4
|
+
*
|
|
5
|
+
* {"t":"paired-status","p":"active"}
|
|
6
|
+
* {"t":"paired-status","p":"idle","s":{"a":"busy","e":"🍕","m":"At lunch","u":1762603600000}}
|
|
7
|
+
* {"t":"paired-status"}
|
|
8
|
+
*
|
|
9
|
+
* It needs `status/1` in `paired-capabilities` on both sides. Each frame is the whole state and replaces the one before.
|
|
10
|
+
* Like typing, it is presence, not a message: no message id (older apps drop it), never stored, held or put on the DHT.
|
|
11
|
+
* `p` is absent when the person does not share when they are online; `s` is absent when they set no status.
|
|
12
|
+
*/
|
|
13
|
+
export declare const STATUS_FRAME = "paired-status";
|
|
14
|
+
/** What a person can say they are: `dnd` is Do not disturb. */
|
|
15
|
+
export declare const STATUS_AVAILABILITIES: readonly ["available", "busy", "away", "dnd"];
|
|
16
|
+
export type StatusAvailability = (typeof STATUS_AVAILABILITIES)[number];
|
|
17
|
+
/** Whether the person uses the app now (`active`) or not for a while (`idle`). */
|
|
18
|
+
export declare const PRESENCES: readonly ["active", "idle"];
|
|
19
|
+
export type Presence = (typeof PRESENCES)[number];
|
|
20
|
+
/** Longest status text kept, in characters (code points). */
|
|
21
|
+
export declare const STATUS_TEXT_MAX = 60;
|
|
22
|
+
/** No input in the app for this long: the person is idle. */
|
|
23
|
+
export declare const STATUS_IDLE_AFTER_MS = 600000;
|
|
24
|
+
/** The sender says at most one frame per this; a change in between goes when it ends, the latest state only. */
|
|
25
|
+
export declare const STATUS_SEND_INTERVAL_MS = 5000;
|
|
26
|
+
/** The reader drops frames past this many per window: room above the sender's 12 a minute. */
|
|
27
|
+
export declare const STATUS_RATE_LIMIT = 15;
|
|
28
|
+
export declare const STATUS_RATE_WINDOW_MS = 60000;
|
|
29
|
+
/** A status a person set. Every field is optional; `until` is when it ends (Unix milliseconds). */
|
|
30
|
+
export interface PersonStatus {
|
|
31
|
+
availability?: StatusAvailability;
|
|
32
|
+
emoji?: string;
|
|
33
|
+
text?: string;
|
|
34
|
+
until?: number;
|
|
35
|
+
}
|
|
36
|
+
/** What one side says of itself: presence only when it shares it, a status only when it set one. */
|
|
37
|
+
export interface StatusState {
|
|
38
|
+
presence?: Presence;
|
|
39
|
+
status?: PersonStatus;
|
|
40
|
+
}
|
|
41
|
+
export type WireStatus = {
|
|
42
|
+
a?: StatusAvailability;
|
|
43
|
+
e?: string;
|
|
44
|
+
m?: string;
|
|
45
|
+
u?: number;
|
|
46
|
+
};
|
|
47
|
+
export type StatusFrame = {
|
|
48
|
+
t: typeof STATUS_FRAME;
|
|
49
|
+
p?: Presence;
|
|
50
|
+
s?: WireStatus;
|
|
51
|
+
};
|
|
52
|
+
/** A status text as it may be shown: one line, no invisible characters, no link or markup, at most 60 characters. */
|
|
53
|
+
export declare function sanitizeStatusText(value: unknown): string | undefined;
|
|
54
|
+
/** A status with each field checked; undefined when nothing is left of it. An unknown availability reads as available. */
|
|
55
|
+
export declare function personStatus(raw: {
|
|
56
|
+
availability?: unknown;
|
|
57
|
+
emoji?: unknown;
|
|
58
|
+
text?: unknown;
|
|
59
|
+
until?: unknown;
|
|
60
|
+
} | undefined): PersonStatus | undefined;
|
|
61
|
+
/** The status while it lasts: undefined once its `until` is past by this clock. */
|
|
62
|
+
export declare function liveStatus(status: PersonStatus | undefined, now?: number): PersonStatus | undefined;
|
|
63
|
+
/** A state with its fields checked. */
|
|
64
|
+
export declare function statusState(raw: StatusState): StatusState;
|
|
65
|
+
export declare function statusFrame(state: StatusState): StatusFrame;
|
|
66
|
+
/**
|
|
67
|
+
* The state a `paired-status` frame says, or null when it is malformed (then the reader keeps what it had): `s` not an
|
|
68
|
+
* object, or `p` or `s.a` present and not a string. A field that does not hold (an emoji that is not one, a text with a
|
|
69
|
+
* link, a bad `u`) is left out, not the frame.
|
|
70
|
+
*/
|
|
71
|
+
export declare function parseStatusFrame(frame: Record<string, unknown>): StatusState | null;
|
|
72
|
+
/** Two states say the same. */
|
|
73
|
+
export declare const sameStatusState: (a: StatusState, b: StatusState) => boolean;
|
|
74
|
+
/**
|
|
75
|
+
* This side's word: what it says, and when. One per chat. A new session owes the whole state (`reset`); a change owes
|
|
76
|
+
* it again. Frames go at most one per `STATUS_SEND_INTERVAL_MS`, across sessions, so the reader's window always has room.
|
|
77
|
+
*/
|
|
78
|
+
export declare class StatusSender {
|
|
79
|
+
private readonly now;
|
|
80
|
+
private state;
|
|
81
|
+
private owed;
|
|
82
|
+
private sentAt;
|
|
83
|
+
constructor(now?: () => number);
|
|
84
|
+
/** What this side says now. */
|
|
85
|
+
get current(): StatusState;
|
|
86
|
+
/** This side's presence or status changed: owed again when it says something new. */
|
|
87
|
+
set(state: StatusState): void;
|
|
88
|
+
/**
|
|
89
|
+
* On a session that agreed `status/1`: the frame to send now; or how long to wait before asking again (the interval
|
|
90
|
+
* has not passed); or null when nothing is owed.
|
|
91
|
+
*/
|
|
92
|
+
take(): {
|
|
93
|
+
frame: StatusFrame;
|
|
94
|
+
} | {
|
|
95
|
+
wait: number;
|
|
96
|
+
} | null;
|
|
97
|
+
/** The session ended: the next one is owed the whole state. */
|
|
98
|
+
reset(): void;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* The contact's word, with a rate limit. Presence ends with the session (`endSession`); the status stays until a new
|
|
102
|
+
* frame replaces it or its `until` passes (read through `peer`). `onChange` hears changes only.
|
|
103
|
+
*/
|
|
104
|
+
export declare class StatusReceiver {
|
|
105
|
+
private readonly onChange;
|
|
106
|
+
private readonly now;
|
|
107
|
+
private state;
|
|
108
|
+
private recent;
|
|
109
|
+
constructor(onChange: (state: StatusState) => void, now?: () => number);
|
|
110
|
+
/** What the contact says now, a status past its `until` left out. */
|
|
111
|
+
get peer(): StatusState;
|
|
112
|
+
/** A `paired-status` frame from the contact. False when it was dropped: malformed, or over the rate limit. */
|
|
113
|
+
receive(frame: Record<string, unknown>): boolean;
|
|
114
|
+
/** The session ended: the contact is not online any more; its status stands. */
|
|
115
|
+
endSession(): void;
|
|
116
|
+
private set;
|
|
117
|
+
}
|
|
@@ -85,11 +85,17 @@ export declare function relayedTransports(local: TransportDescriptors, remote: T
|
|
|
85
85
|
/** Symmetric rank sum; the fixed order breaks ties deterministically. Neither
|
|
86
86
|
* a remote list nor a preference can add an unavailable local adapter. A
|
|
87
87
|
* relayed transport ranks after every direct one: it is where a failed direct
|
|
88
|
-
* path goes, never ahead of one that works.
|
|
88
|
+
* path goes, never ahead of one that works. Iroh through its relay is the
|
|
89
|
+
* exception (WISP 100, revision 2026-11-08): it comes back almost at once after
|
|
90
|
+
* the app was away, and a browser's Iroh is never anything else. */
|
|
89
91
|
export declare function rankTransports(local: readonly string[], remote: readonly string[], relayed?: readonly string[]): PairedTransport[];
|
|
90
92
|
/**
|
|
91
|
-
* What a chat prefers when nobody chose (Automatic):
|
|
92
|
-
*
|
|
93
|
+
* What a chat prefers when nobody chose (Automatic): Iroh where the app has it, then WebRTC, then HyperDHT (WISP 100,
|
|
94
|
+
* revision 2026-11-08). Every app puts Iroh first, so the rank sum of two apps that both run it puts it first on both
|
|
95
|
+
* sides. With nothing at all, WebRTC, which the offer then leaves out.
|
|
96
|
+
* With Fallback off the chat may use only that one transport, and nothing moves it off a relayed Iroh then: WebRTC
|
|
97
|
+
* where the app has it, else the first transport it has (a Linux Desktop: WebKitGTK has no WebRTC), as before.
|
|
93
98
|
*/
|
|
94
|
-
export declare
|
|
99
|
+
export declare const AUTOMATIC_ORDER: readonly PairedTransport[];
|
|
100
|
+
export declare function automaticTransport(available: readonly PairedTransport[], fallback?: boolean): PairedTransport;
|
|
95
101
|
export declare function transportOrder(available: readonly PairedTransport[], preferred: PairedTransport, fallback: boolean): PairedTransport[];
|
|
@@ -52,6 +52,8 @@ export type TypingFrame = {
|
|
|
52
52
|
* holds a link or markup (it is plain text, never a way to put a link on the contact's screen).
|
|
53
53
|
*/
|
|
54
54
|
export declare function sanitizeTypingStatus(value: unknown): string | undefined;
|
|
55
|
+
/** A contact's line of plain text by the typing status's rules, at most `max` characters (a set status uses it too). */
|
|
56
|
+
export declare function plainStatusLine(value: unknown, max: number): string | undefined;
|
|
55
57
|
/** A kind as it arrived: anything this app does not know reads as plain typing. */
|
|
56
58
|
export declare function typingKindOf(value: unknown): TypingKind;
|
|
57
59
|
/** The activity as it goes on the wire and is shown: kind checked, status sanitized. */
|
|
@@ -13,7 +13,8 @@ import { type PushRequest, type PushTarget, type VapidKeys } from "./webPush.js"
|
|
|
13
13
|
* app shows "New message", opens on a tap, connects and fetches the message itself. The token is the contact's
|
|
14
14
|
* own name for this chat, different for every contact, so its app knows which chat (and whether it is muted)
|
|
15
15
|
* without the push service learning anything: every wake-up is padded to one size (`PUSH_PAD_BYTES`), so it sees that
|
|
16
|
-
* a push happened, and when; only the time to live and a call's repeats set a call or a device
|
|
16
|
+
* a push happened, and when; only the time to live and a call's repeats set a call, an online notice or a device
|
|
17
|
+
* handoff apart (an online notice has a handoff's time to live).
|
|
17
18
|
*
|
|
18
19
|
* It needs `wake/1` in `paired-capabilities` on both sides. The VAPID key pair belongs to that one subscription,
|
|
19
20
|
* so sharing its private half lets a contact post to that subscription and nothing else. Rotating it (a new
|
|
@@ -23,14 +24,24 @@ export { WAKE_SESSION_CAPABILITY as WAKE_CAPABILITY } from "./pairedCapabilities
|
|
|
23
24
|
export declare const WAKE_FRAME = "paired-wake";
|
|
24
25
|
/** At most one wake-up per contact in this long. A burst of messages is one push. */
|
|
25
26
|
export declare const WAKE_INTERVAL_MS: number;
|
|
27
|
+
/**
|
|
28
|
+
* A wake-up that did not reach the push service (no network, the push relay did not forward it, the push service
|
|
29
|
+
* answered 429 or 5xx) is not the contact's wake-up: the next one may go this long after it, not 5 minutes. Never a
|
|
30
|
+
* retry of that one; only a pause, so a relay that is refusing is not asked again on every message.
|
|
31
|
+
*/
|
|
32
|
+
export declare const WAKE_RETRY_MS = 30000;
|
|
26
33
|
/** A wake-up that has not reached the phone within this is no use: the push service may drop it. */
|
|
27
34
|
export declare const WAKE_TTL_SECONDS: number;
|
|
28
35
|
/** The VAPID subject push services ask for: who to contact about abuse. The project, never a person. */
|
|
29
36
|
export declare const WAKE_SUBJECT = "https://ghostly.tools";
|
|
30
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* What a contact shares: its push subscription, the key pair it was made with, and its token for this chat. `online`:
|
|
39
|
+
* it wants an online notice when this side comes online while its app is closed (`o: 1`, revision 2026-10-27).
|
|
40
|
+
*/
|
|
31
41
|
export interface WakeTarget extends PushTarget {
|
|
32
42
|
vapid: VapidKeys;
|
|
33
43
|
token: string;
|
|
44
|
+
online?: true;
|
|
34
45
|
}
|
|
35
46
|
export type WakeFrame = {
|
|
36
47
|
t: typeof WAKE_FRAME;
|
|
@@ -41,6 +52,7 @@ export type WakeFrame = {
|
|
|
41
52
|
vp: string;
|
|
42
53
|
vk: string;
|
|
43
54
|
k: string;
|
|
55
|
+
o?: 1;
|
|
44
56
|
} | null;
|
|
45
57
|
};
|
|
46
58
|
/** A fresh per-contact token: 16 random bytes, base64url. */
|
|
@@ -54,16 +66,30 @@ export declare function wakeFrame(target: WakeTarget | null): WakeFrame;
|
|
|
54
66
|
export declare function parseWakeFrame(frame: Record<string, unknown>): WakeTarget | null | undefined;
|
|
55
67
|
/**
|
|
56
68
|
* What a wake-up is for: a message waits, or a call does (the caller rings until the contact's app is live, then
|
|
57
|
-
* calls)
|
|
69
|
+
* calls), or this side just came online (revision 2026-10-27; only to a contact that asked, `online`). The receiving
|
|
70
|
+
* app picks its own words for each; the push says nothing more.
|
|
71
|
+
*/
|
|
72
|
+
export type WakeKind = "message" | "call" | "online";
|
|
73
|
+
/** At most one online notice per contact in this long, whatever the message wake-ups do. Kept across restarts. */
|
|
74
|
+
export declare const WAKE_ONLINE_INTERVAL_MS: number;
|
|
75
|
+
/** An online notice the phone gets later than this is stale: worse than none. */
|
|
76
|
+
export declare const WAKE_ONLINE_TTL_SECONDS: number;
|
|
77
|
+
/** How long after this side comes online it waits for the chat to go live before it says so: a live contact needs no push. */
|
|
78
|
+
export declare const WAKE_ONLINE_DELAY_MS = 30000;
|
|
79
|
+
/**
|
|
80
|
+
* Most online notices that go out in `WAKE_ONLINE_BATCH_MS`; the rest wait for the next one. A page posts its wake-ups
|
|
81
|
+
* through a push relay, which takes 30 a minute from one address: all at once, a profile with 30 contacts that asked
|
|
82
|
+
* spent the whole minute, and a call or message wake-up right after was refused.
|
|
58
83
|
*/
|
|
59
|
-
export
|
|
84
|
+
export declare const WAKE_ONLINE_BATCH = 10;
|
|
85
|
+
export declare const WAKE_ONLINE_BATCH_MS = 60000;
|
|
60
86
|
/** At most one call wake-up per contact in this long: a caller who tries again at once is not a new push. */
|
|
61
87
|
export declare const WAKE_CALL_INTERVAL_MS = 30000;
|
|
62
88
|
/** How long a caller waits for the woken contact's app to come live before giving up. */
|
|
63
89
|
export declare const WAKE_CALL_WAIT_MS = 60000;
|
|
64
90
|
/** A call wake-up is useless once the caller stopped waiting: the push service may drop it after this. */
|
|
65
91
|
export declare const WAKE_CALL_TTL_SECONDS = 60;
|
|
66
|
-
/** The wake-up's plaintext: the contact's token for this chat, and whether it is for a call. Nothing else. */
|
|
92
|
+
/** The wake-up's plaintext: the contact's token for this chat, and whether it is for a call or an online notice. Nothing else. */
|
|
67
93
|
export declare function wakePayload(token: string, kind?: WakeKind): Uint8Array;
|
|
68
94
|
/**
|
|
69
95
|
* A wake-up as the receiving service worker reads it: the token and its kind; null for anything else. `device`: one of
|
|
@@ -93,6 +119,11 @@ export declare class WakeLimiter {
|
|
|
93
119
|
constructor(interval?: number);
|
|
94
120
|
/** Whether a wake-up to `contact` may go now; if so, it counts as sent. */
|
|
95
121
|
take(contact: string, now?: number): boolean;
|
|
122
|
+
/**
|
|
123
|
+
* The wake-up taken at `takenAt` did not reach the push service: it does not count, and the next may go
|
|
124
|
+
* `retryMs` from now. Nothing changes when another was taken since, or the count started over.
|
|
125
|
+
*/
|
|
126
|
+
missed(contact: string, takenAt: number, retryMs?: number, now?: number): void;
|
|
96
127
|
/** The contact answered (it is live again): the next time it is away, it may be woken at once. */
|
|
97
128
|
reset(contact: string): void;
|
|
98
129
|
}
|
|
@@ -23,9 +23,9 @@ export declare const REPLY_ID: RegExp;
|
|
|
23
23
|
/** The two authors a paired chat has, from the reply author's side. */
|
|
24
24
|
export declare const PAIRED_REPLY_AUTHORS: readonly ["sender", "recipient"];
|
|
25
25
|
/**
|
|
26
|
-
* A line of a message to quote: plain text on one line (line breaks and runs of spaces become one space),
|
|
27
|
-
* control, invisible or direction characters (WISP 400, as for names), at most
|
|
28
|
-
* the last of them an ellipsis when it was cut.
|
|
26
|
+
* A line of a message to quote: plain text on one line (line breaks and runs of spaces become one space), its
|
|
27
|
+
* spoilers covered, without control, invisible or direction characters (WISP 400, as for names), at most
|
|
28
|
+
* `REPLY_LIMITS.snippet` code points, the last of them an ellipsis when it was cut.
|
|
29
29
|
*/
|
|
30
30
|
export declare function replySnippet(text: string): string;
|
|
31
31
|
/**
|
|
@@ -194,10 +194,13 @@ export interface PkarrTransport {
|
|
|
194
194
|
/**
|
|
195
195
|
* Where the DHT is reached directly (Desktop): the relays from Settings, and whether reads may use them too
|
|
196
196
|
* (`readRelays`, "Also use Pkarr relays"). Writes go to them either way, so browser contacts see this peer's packets.
|
|
197
|
+
* `dhtDirect: false` (Hide my IP from contacts, WISP 100 § Relay only): reads and writes go through the relays alone,
|
|
198
|
+
* and no UDP goes to a DHT node; absent leaves the DHT as it is.
|
|
197
199
|
*/
|
|
198
200
|
configure?(options: {
|
|
199
201
|
relays: string[];
|
|
200
202
|
readRelays: boolean;
|
|
203
|
+
dhtDirect?: boolean;
|
|
201
204
|
}): void;
|
|
202
205
|
/**
|
|
203
206
|
* The turn record's own read (WISP 06 § Publishing and reading): every source is asked, in parallel, and each
|
|
@@ -155,7 +155,11 @@ export declare class TransportSwitch {
|
|
|
155
155
|
/** Waiting for `target`, not failed, where the owner says why; an error state for an owner that does not. */
|
|
156
156
|
private unreached;
|
|
157
157
|
private choices;
|
|
158
|
-
/**
|
|
158
|
+
/**
|
|
159
|
+
* Nobody chose, the session is on a relayed transport, a direct one is ranked, and both sides move (`upgrade/1`). The
|
|
160
|
+
* first direct one, not the first ranked: Iroh through its relay ranks first so that a chat comes back over it at once
|
|
161
|
+
* (WISP 100, revision 2026-11-08), and the session then moves to the direct path, which carries files many times faster.
|
|
162
|
+
*/
|
|
159
163
|
private upgrading;
|
|
160
164
|
private isUpgrade;
|
|
161
165
|
/**
|
|
@@ -15,6 +15,12 @@ export interface VideoSource {
|
|
|
15
15
|
size: number;
|
|
16
16
|
read(offset: number, length: number): Promise<Uint8Array>;
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* `source` read a window at a time: a read that fits in `readAhead` bytes reads that many from where it starts, and
|
|
20
|
+
* the reads after it within them (the next boxes' headers, a fragment's `moof`) are served from it, as copies (they
|
|
21
|
+
* are changed in place). A Blob's read costs about the same whatever its size, so a fragment costs one, not three.
|
|
22
|
+
*/
|
|
23
|
+
export declare function readingAhead(source: VideoSource): VideoSource;
|
|
18
24
|
/** A part of a video replaced as it is sent, `start` to `end` of the file: by `bytes`, or by zeros. */
|
|
19
25
|
export interface VideoPatch {
|
|
20
26
|
start: number;
|
|
@@ -30,6 +36,6 @@ export declare function withoutVideoMetadata(source: Blob, mime: string): Promis
|
|
|
30
36
|
/**
|
|
31
37
|
* What `withoutVideoMetadata` changes in a video read from `source` (one not held in a Blob: a file kept in storage):
|
|
32
38
|
* the parts replaced, in order and apart, the rest of its bytes going as they are; undefined when it goes as it is.
|
|
33
|
-
* Throws `NO_VIDEO_METADATA` as it does.
|
|
39
|
+
* Throws `NO_VIDEO_METADATA` as it does. With `audio`, a movie without a video track (an M4A) is stripped too.
|
|
34
40
|
*/
|
|
35
|
-
export declare function videoMetadataPatches(file: VideoSource, mime: string): Promise<VideoPatch[] | undefined>;
|
|
41
|
+
export declare function videoMetadataPatches(file: VideoSource, mime: string, audio?: boolean): Promise<VideoPatch[] | undefined>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { HeaderList } from "./frames.js";
|
|
2
|
+
/**
|
|
3
|
+
* Hide my IP from contacts and a contact's shared app: no policy keeps a page off WebRTC (CSP does not cover ICE, its
|
|
4
|
+
* `webrtc 'block'` is not in Chromium or WebKit, and no permissions policy names it), and a `new RTCPeerConnection` with
|
|
5
|
+
* a STUN server the contact names shows that server this device's address. While the setting is on, this script runs
|
|
6
|
+
* first in the app's page: Desktop's window runs it in every frame itself, and the web runner puts it first in each
|
|
7
|
+
* HTML page (`guardViewerAnswer`). It:
|
|
8
|
+
* - deletes the WebRTC constructors (every `RTC…` and `webkitRTC…` name), as Desktop's app runner does;
|
|
9
|
+
* - opens every new window with `noopener`, so the page never holds a window it did not run in;
|
|
10
|
+
* - runs in a frame's window before the page holds it: what a frame element hands out (`contentWindow`,
|
|
11
|
+
* `contentDocument`, `getSVGDocument`) is guarded first, in a shadow tree too, and the frames of the document are
|
|
12
|
+
* gone over as one loads (an empty frame's first load fires as it is put in the page) and as the page changes;
|
|
13
|
+
* - puts itself first in each `srcdoc` frame, in the shadow trees the page makes too, and, with `VIEWER_GUARD_CSP`,
|
|
14
|
+
* refuses `javascript:` URLs (its own Trusted Types default policy: one passes every other string on as it is);
|
|
15
|
+
* - refuses a declarative shadow root the page's script would make (`setHTMLUnsafe`, `Document.parseHTMLUnsafe`,
|
|
16
|
+
* `document.write`, a write split in two too): its `srcdoc` frames would be out of the guard's sight;
|
|
17
|
+
* - listens for frames' loads again after `document.open()`, which takes every listener of the document away.
|
|
18
|
+
* It uses nothing the page can change after it ran (the page's own code runs later, in the same realm).
|
|
19
|
+
*
|
|
20
|
+
* What a script put in the page cannot do, so where the viewer does not run it per document this is not a guarantee:
|
|
21
|
+
* a frame's window read by its index (`window[0]`, never through the frame element) while the frame's page is still
|
|
22
|
+
* on its way, and a `srcdoc` frame inside a shadow tree written in the HTML the page itself sends, run before the
|
|
23
|
+
* guard is there.
|
|
24
|
+
* No backslash, `${` or backtick in it: Desktop's copy (`SERVICE_GUARD`, apps/desktop/src/viewer.rs) is the same text.
|
|
25
|
+
*/
|
|
26
|
+
export declare const VIEWER_GUARD_SCRIPT = "(function noWebRtc(w) {\n \"use strict\";\n try {\n const apply = Reflect.apply;\n const own = \"<script>(\" + noWebRtc + \")(window)<\" + \"/script>\";\n for (const name of Object.getOwnPropertyNames(w)) {\n if (/^(webkit)?RTC/.test(name)) { try { delete w[name]; } catch (e) {} }\n }\n if (w.trustedTypes && !w.trustedTypes.defaultPolicy) {\n try {\n w.trustedTypes.createPolicy(\"default\", {\n createHTML: (input) => input,\n createScript: (input, type, sink) => (sink === \"Location href\" ? null : input),\n createScriptURL: (input) => input,\n });\n } catch (e) {}\n }\n const open = w.open;\n const opener = function (url, target) {\n apply(open, this, [url === undefined ? \"\" : url, target === undefined ? \"_blank\" : target, \"noopener\"]);\n return null;\n };\n w.open = opener;\n const describe = Object.getOwnPropertyDescriptor;\n const define = Object.defineProperty;\n const shut = (inner) => {\n try { if (inner && inner !== w && (\"RTCPeerConnection\" in inner || \"webkitRTCPeerConnection\" in inner)) noWebRtc(inner); } catch (e) {}\n };\n const count = describe(w, \"length\").get;\n const view = describe(w.Document.prototype, \"defaultView\").get;\n const slice = String.prototype.slice;\n const sweep = () => {\n try { for (let i = apply(count, w, []); i-- > 0;) shut(w[i]); } catch (e) {}\n };\n const listen = w.EventTarget.prototype.addEventListener;\n const home = w.document;\n const reopen = w.Document.prototype.open;\n w.Document.prototype.open = function () {\n if (arguments.length > 2) return apply(opener, w, [arguments[0], arguments[1]]);\n const got = apply(reopen, this, arguments);\n if (this === home) { try { apply(listen, home, [\"load\", sweep, true]); } catch (e) {} }\n return got;\n };\n const text = String;\n const lower = String.prototype.toLowerCase;\n const index = String.prototype.indexOf;\n const Refused = w.TypeError;\n const shadowed = (html) => apply(index, apply(lower, html, []), [\"shadowrootmode\"]) >= 0;\n const refuse = () => { throw new Refused(\"A declarative shadow root is not allowed here\"); };\n for (const [owner, name] of [[w.Element.prototype, \"setHTMLUnsafe\"], [w.ShadowRoot && w.ShadowRoot.prototype, \"setHTMLUnsafe\"], [w.Document, \"parseHTMLUnsafe\"]]) {\n const real = owner && owner[name];\n if (typeof real !== \"function\") continue;\n owner[name] = function (html) {\n const checked = text(html);\n if (shadowed(checked)) refuse();\n return apply(real, this, arguments.length > 1 ? [checked, arguments[1]] : [checked]);\n };\n }\n let tail = \"\";\n for (const name of [\"write\", \"writeln\"]) {\n const real = w.Document.prototype[name];\n if (typeof real !== \"function\") continue;\n w.Document.prototype[name] = function () {\n let checked = \"\";\n for (let i = 0; i < arguments.length; i++) checked += text(arguments[i]);\n if (shadowed(tail + checked)) refuse();\n tail = apply(slice, tail + checked, [-16]);\n return apply(real, this, [checked]);\n };\n }\n for (const kind of [\"HTMLIFrameElement\", \"HTMLFrameElement\", \"HTMLObjectElement\", \"HTMLEmbedElement\"]) {\n const proto = w[kind] && w[kind].prototype;\n for (const name of [\"contentWindow\", \"contentDocument\", \"getSVGDocument\"]) {\n const found = proto && describe(proto, name);\n const key = found && found.get ? \"get\" : \"value\";\n if (!found || typeof found[key] !== \"function\") continue;\n const read = found[key];\n found[key] = function () {\n const got = apply(read, this, arguments);\n try { shut(name === \"contentWindow\" ? got : apply(view, got, [])); } catch (e) {}\n return got;\n };\n try { define(proto, name, found); } catch (e) {}\n }\n }\n const { getAttribute, setAttribute, removeAttribute, attachShadow } = w.Element.prototype;\n const size = describe(w.NodeList.prototype, \"length\").get;\n const first = (frame) => {\n const doc = apply(getAttribute, frame, [\"srcdoc\"]);\n if (doc === null || apply(slice, doc, [0, own.length]) === own) return;\n try { apply(setAttribute, frame, [\"srcdoc\", own + doc]); } catch (e) { apply(removeAttribute, frame, [\"srcdoc\"]); }\n };\n const Observer = w.MutationObserver;\n const observe = Observer.prototype.observe;\n const watch = (root, all) => {\n const scan = () => {\n try {\n const frames = apply(all, root, [\"iframe[srcdoc]\"]);\n for (let i = apply(size, frames, []); i-- > 0;) first(frames[i]);\n } catch (e) {}\n sweep();\n };\n apply(observe, new Observer(scan), [root, { subtree: true, childList: true, attributes: true, attributeFilter: [\"srcdoc\"] }]);\n scan();\n return root;\n };\n const inShadow = w.DocumentFragment.prototype.querySelectorAll;\n if (attachShadow) {\n w.Element.prototype.attachShadow = function () {\n const root = apply(attachShadow, this, arguments);\n try { watch(root, inShadow); } catch (e) {}\n return root;\n };\n }\n apply(listen, home, [\"load\", sweep, true]);\n watch(home, w.Document.prototype.querySelectorAll);\n } catch (e) {}\n})(window)";
|
|
27
|
+
/** `VIEWER_GUARD_SCRIPT`'s hash, as a CSP source: a contact's own policy that would refuse it is given it (`allowingViewerGuard`). */
|
|
28
|
+
export declare const VIEWER_GUARD_HASH = "'sha256-P3jYgJwfoJ/cAS31rQz7Tk99bBwsSeN2wDDqJubDMZw='";
|
|
29
|
+
/**
|
|
30
|
+
* With the guard, where it is put in the page and not run by the viewer in every frame: frames only from the app's own
|
|
31
|
+
* origin (a `data:` or `blob:` frame would run before the guard could), and Trusted Types, which hands each
|
|
32
|
+
* `javascript:` URL to the guard's policy before it runs.
|
|
33
|
+
*/
|
|
34
|
+
export declare const VIEWER_GUARD_CSP = "frame-src 'self'; object-src 'self'; require-trusted-types-for 'script'";
|
|
35
|
+
/** A script `guardViewerAnswer` puts first in each page, and its hash, as a CSP source. */
|
|
36
|
+
export interface PageGuard {
|
|
37
|
+
script: string;
|
|
38
|
+
hash: string;
|
|
39
|
+
}
|
|
40
|
+
/** The WebRTC guard, the one `guardViewerAnswer` puts in when it is given none. */
|
|
41
|
+
export declare const WEBRTC_GUARD: PageGuard;
|
|
42
|
+
/**
|
|
43
|
+
* A contact's `Content-Security-Policy` value (one policy or several, joined by commas), each given the guards' hashes
|
|
44
|
+
* where it would refuse an inline script: in the directive that governs `<script>` elements (`script-src-elem`, else
|
|
45
|
+
* `script-src`, else `default-src`), unless it lets every inline script run already. Nothing else of it changes.
|
|
46
|
+
*/
|
|
47
|
+
export declare function allowingViewerGuard(value: string, hashes?: readonly string[]): string;
|
|
48
|
+
/**
|
|
49
|
+
* Where the guard goes in an HTML page that starts with `head`: after a byte order mark, blank space, comments and the
|
|
50
|
+
* doctype (before them the page would turn to quirks mode), so before anything that can run or set a policy. Null when
|
|
51
|
+
* `head` ends before that is known and more is coming (`done` false).
|
|
52
|
+
*/
|
|
53
|
+
export declare function viewerGuardOffset(head: Uint8Array, done: boolean): number | null;
|
|
54
|
+
/**
|
|
55
|
+
* A contact's answer as a viewer serves it where it cannot run `guards` in every frame itself (the web runner; the
|
|
56
|
+
* WebRTC guard while Hide my IP from contacts is on, unless it is given others): the contact's policies take the guards'
|
|
57
|
+
* hashes (`allowingViewerGuard`) and `VIEWER_GUARD_CSP` goes along. A page (`destination`, null when the browser did not say)
|
|
58
|
+
* that is HTML gets the guards first in it, in their order; one they cannot be put in (another type, more than one type, a
|
|
59
|
+
* compressed, UTF-16 or ISO-2022-JP body, a type with a quote or a backslash in it, an escape byte before the guard's
|
|
60
|
+
* place) runs no script at all. Anything that is not a page passes as it was. The caller adds Ghostly's own policy as before.
|
|
61
|
+
*/
|
|
62
|
+
export declare function guardViewerAnswer(headers: HeaderList, body: AsyncIterable<Uint8Array>, destination: string | null, guards?: readonly PageGuard[]): Promise<{
|
|
63
|
+
headers: HeaderList;
|
|
64
|
+
body: AsyncIterable<Uint8Array>;
|
|
65
|
+
}>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { fd as IdentityCheckUnavailable, hd as boundVerifiedIdentity } from "./src-BN4AAuHI.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-oCL662ms.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify-
|
|
1
|
+
{"version":3,"file":"verify-oCL662ms.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,MAA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": "@ghostlytools/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.1",
|
|
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",
|