@ghostlytools/sdk 1.10.5 → 1.11.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.
Files changed (38) hide show
  1. package/dist/app.js.map +1 -1
  2. package/dist/core.js +2 -2
  3. package/dist/{fakes-BNNNkQqY.js → fakes-Cu6mpUKs.js} +2 -2
  4. package/dist/{fakes-BNNNkQqY.js.map → fakes-Cu6mpUKs.js.map} +1 -1
  5. package/dist/fakes.js +1 -1
  6. package/dist/index.js +2 -2
  7. package/dist/{keet-identity-key-DJbA1oSW.js → keet-identity-key-DHlSH_39.js} +2 -2
  8. package/dist/{keet-identity-key-DJbA1oSW.js.map → keet-identity-key-DHlSH_39.js.map} +1 -1
  9. package/dist/{src-C2bAufMs.js → src-i6IUh-ng.js} +1198 -152
  10. package/dist/src-i6IUh-ng.js.map +1 -0
  11. package/dist/testing.js +3 -3
  12. package/dist/types/core/src/dhtDelivery.d.ts +20 -1
  13. package/dist/types/core/src/engineErrors.d.ts +2 -0
  14. package/dist/types/core/src/ghostlink.d.ts +47 -3
  15. package/dist/types/core/src/groupCommunity.d.ts +66 -3
  16. package/dist/types/core/src/groupSession.d.ts +6 -0
  17. package/dist/types/core/src/groupSignals.d.ts +2 -0
  18. package/dist/types/core/src/http.d.ts +23 -3
  19. package/dist/types/core/src/identityProofs.d.ts +7 -0
  20. package/dist/types/core/src/identityTimeline.d.ts +6 -0
  21. package/dist/types/core/src/index.d.ts +2 -0
  22. package/dist/types/core/src/link.d.ts +2 -0
  23. package/dist/types/core/src/miniApp.d.ts +2 -2
  24. package/dist/types/core/src/pairedAppRanges.d.ts +18 -7
  25. package/dist/types/core/src/pairedCalls.d.ts +10 -0
  26. package/dist/types/core/src/pairedCapabilities.d.ts +6 -1
  27. package/dist/types/core/src/pairedStatus.d.ts +117 -0
  28. package/dist/types/core/src/pairedTransports.d.ts +10 -4
  29. package/dist/types/core/src/pairedTyping.d.ts +2 -0
  30. package/dist/types/core/src/pairedWake.d.ts +36 -5
  31. package/dist/types/core/src/replies.d.ts +3 -3
  32. package/dist/types/core/src/transport.d.ts +3 -0
  33. package/dist/types/core/src/transportSwitch.d.ts +5 -1
  34. package/dist/types/core/src/viewerGuard.d.ts +58 -0
  35. package/dist/{verify-CpIce6Bt.js → verify-BoaDPIrS.js} +2 -2
  36. package/dist/{verify-CpIce6Bt.js.map → verify-BoaDPIrS.js.map} +1 -1
  37. package/package.json +1 -1
  38. package/dist/src-C2bAufMs.js.map +0 -1
@@ -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): WebRTC where the app has it, else the first transport it has
92
- * (a Linux Desktop: WebKitGTK has no WebRTC). With nothing at all, WebRTC, which the offer then leaves out.
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 function automaticTransport(available: readonly PairedTransport[]): PairedTransport;
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 handoff apart.
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
- /** What a contact shares: its push subscription, the key pair it was made with, and its token for this chat. */
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). The receiving app picks its own words for each; the push says nothing more.
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 type WakeKind = "message" | "call";
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), without
27
- * control, invisible or direction characters (WISP 400, as for names), at most `REPLY_LIMITS.snippet` code points,
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
- /** Nobody chose, the session is on a relayed transport, a direct one ranks first, and both sides move (`upgrade/1`). */
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
  /**
@@ -0,0 +1,58 @@
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
+ /**
36
+ * A contact's `Content-Security-Policy` value (one policy or several, joined by commas), each given the guard's hash
37
+ * where it would refuse an inline script: in the directive that governs `<script>` elements (`script-src-elem`, else
38
+ * `script-src`, else `default-src`), unless it lets every inline script run already. Nothing else of it changes.
39
+ */
40
+ export declare function allowingViewerGuard(value: string): string;
41
+ /**
42
+ * Where the guard goes in an HTML page that starts with `head`: after a byte order mark, blank space, comments and the
43
+ * doctype (before them the page would turn to quirks mode), so before anything that can run or set a policy. Null when
44
+ * `head` ends before that is known and more is coming (`done` false).
45
+ */
46
+ export declare function viewerGuardOffset(head: Uint8Array, done: boolean): number | null;
47
+ /**
48
+ * A contact's answer as a viewer serves it while Hide my IP from contacts is on, where the viewer cannot run the guard
49
+ * in every frame itself (the web runner): the contact's policies take the guard's hash
50
+ * (`allowingViewerGuard`) and `VIEWER_GUARD_CSP` goes along. A page (`destination`, null when the browser did not say)
51
+ * that is HTML gets the guard first in it; one the guard cannot be put in (another type, more than one type, a
52
+ * 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
53
+ * 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.
54
+ */
55
+ export declare function guardViewerAnswer(headers: HeaderList, body: AsyncIterable<Uint8Array>, destination: string | null): Promise<{
56
+ headers: HeaderList;
57
+ body: AsyncIterable<Uint8Array>;
58
+ }>;
@@ -1,4 +1,4 @@
1
- import { Fu as boundVerifiedIdentity, Mu as IdentityCheckUnavailable } from "./src-C2bAufMs.js";
1
+ import { sd as IdentityCheckUnavailable, ud as boundVerifiedIdentity } from "./src-i6IUh-ng.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-CpIce6Bt.js.map
107
+ //# sourceMappingURL=verify-BoaDPIrS.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"verify-CpIce6Bt.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,y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AC;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"}
1
+ {"version":3,"file":"verify-BoaDPIrS.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,KAAK,gBAAgB;CACpD,IAAI,CAAC,EAAE,aAAa,KAAK,GAAG,SAAS,KAAK,sBAAsB;CAChE,IAAI,CAAC,EAAE,SAAS,K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AAK;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.10.5",
3
+ "version": "1.11.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",