@ghostlytools/sdk 1.11.1 → 1.11.3
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 +6 -3
- package/dist/app.js.map +1 -1
- package/dist/core.js +111 -18
- package/dist/core.js.map +1 -1
- package/dist/{fakes-LaWqqMv4.js → fakes-CK9Ra4X4.js} +3 -3
- package/dist/{fakes-LaWqqMv4.js.map → fakes-CK9Ra4X4.js.map} +1 -1
- package/dist/fakes.js +1 -1
- package/dist/index.js +3 -3
- package/dist/{keet-identity-key-CASfmXry.js → keet-identity-key-CDgu84Dj.js} +2 -2
- package/dist/{keet-identity-key-CASfmXry.js.map → keet-identity-key-CDgu84Dj.js.map} +1 -1
- package/dist/{src-BN4AAuHI.js → src-B9HeOlsG.js} +649 -184
- package/dist/src-B9HeOlsG.js.map +1 -0
- package/dist/testing.js +4 -4
- package/dist/types/browser/src/engine/paymentAdapters/providers/types.d.ts +6 -1
- package/dist/types/core/src/appStore.d.ts +5 -0
- package/dist/types/core/src/audioMetadata.d.ts +0 -23
- package/dist/types/core/src/catchUp.d.ts +2 -0
- package/dist/types/core/src/chatFiles.d.ts +6 -0
- package/dist/types/core/src/clipboardGuard.d.ts +24 -7
- package/dist/types/core/src/dhtDelivery.d.ts +13 -0
- package/dist/types/core/src/didDht.d.ts +6 -4
- package/dist/types/core/src/frames.d.ts +11 -0
- package/dist/types/core/src/ghostlink.d.ts +42 -2
- package/dist/types/core/src/groupSession.d.ts +13 -0
- package/dist/types/core/src/http.d.ts +16 -2
- package/dist/types/core/src/identity.d.ts +16 -1
- package/dist/types/core/src/identityProofs.d.ts +7 -0
- package/dist/types/core/src/index.d.ts +1 -0
- package/dist/types/core/src/linkPreview.d.ts +9 -2
- package/dist/types/core/src/miniApp.d.ts +5 -2
- package/dist/types/core/src/pairedAppRanges.d.ts +5 -0
- package/dist/types/core/src/pairedApps.d.ts +4 -2
- package/dist/types/core/src/relay.d.ts +17 -4
- package/dist/types/core/src/transport.d.ts +3 -1
- package/dist/types/core/src/videoMetadata.d.ts +8 -1
- package/dist/types/core/src/viewerGuard.d.ts +6 -0
- package/dist/{types-DvtCy3WB.js → types-DYLIIkU8.js} +2 -1
- package/dist/types-DYLIIkU8.js.map +1 -0
- package/dist/{verify-oCL662ms.js → verify-DZpnNeF7.js} +2 -2
- package/dist/{verify-oCL662ms.js.map → verify-DZpnNeF7.js.map} +1 -1
- package/package.json +1 -1
- package/dist/src-BN4AAuHI.js.map +0 -1
- package/dist/types-DvtCy3WB.js.map +0 -1
package/dist/testing.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { l as providerDescriptorProblems, o as isNothingSpentError } from "./types-
|
|
3
|
-
import { i as verifyIdentity, r as descriptorProblems } from "./verify-
|
|
4
|
-
import { _ as fakeAddress, a as fakeAccount, b as fakeOnchain, c as fakeKeySign, d as fakeRecord, f as fakeRecordText, g as TEST_PROVIDERS_FLAG, h as FakeOnchainProvider, i as TEST_IDENTITIES_FLAG, l as fakeKeySubject, m as FakeLightningProvider, n as FAKE_ISSUER, o as fakeAccountToken, p as testIdentitiesEnabled, r as FAKE_RECORD_HOST, s as fakeKey, t as FAKE_IDENTITY_PROVIDERS, u as fakeKeyring, v as fakeInvoice, x as testProvidersEnabled, y as fakeLightning } from "./fakes-
|
|
1
|
+
import { Ed as identityStatement, Na as decodeBolt11, Sd as emptyIdentityLedger, VT as createIdentity, ca as isBitcoinAddress, cd as IDENTITY_MAX_EVIDENCE, kd as newIdentityBinding, yd as IdentityExchange } from "./src-B9HeOlsG.js";
|
|
2
|
+
import { l as providerDescriptorProblems, o as isNothingSpentError } from "./types-DYLIIkU8.js";
|
|
3
|
+
import { i as verifyIdentity, r as descriptorProblems } from "./verify-DZpnNeF7.js";
|
|
4
|
+
import { _ as fakeAddress, a as fakeAccount, b as fakeOnchain, c as fakeKeySign, d as fakeRecord, f as fakeRecordText, g as TEST_PROVIDERS_FLAG, h as FakeOnchainProvider, i as TEST_IDENTITIES_FLAG, l as fakeKeySubject, m as FakeLightningProvider, n as FAKE_ISSUER, o as fakeAccountToken, p as testIdentitiesEnabled, r as FAKE_RECORD_HOST, s as fakeKey, t as FAKE_IDENTITY_PROVIDERS, u as fakeKeyring, v as fakeInvoice, x as testProvidersEnabled, y as fakeLightning } from "./fakes-CK9Ra4X4.js";
|
|
5
5
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
6
6
|
//#region ../browser/src/engine/paymentAdapters/providers/contractSuite.ts
|
|
7
7
|
var WAIT = 1e4;
|
|
@@ -98,6 +98,11 @@ export interface ProviderDescriptor<P> {
|
|
|
98
98
|
experimental?: boolean;
|
|
99
99
|
/** Checks the form before anything is contacted; throws a message fit for the person. */
|
|
100
100
|
validate?(settings: ProviderSettings, mode: WalletMode): void;
|
|
101
|
+
/**
|
|
102
|
+
* The wallet these (validated) settings reach, whatever their spelling: two sources with the same answer are one
|
|
103
|
+
* wallet, and the same balance. Absent: the same settings, byte for byte.
|
|
104
|
+
*/
|
|
105
|
+
wallet?(settings: ProviderSettings): string;
|
|
101
106
|
/** Connects. The engine then asks `info()` and refuses a network of the other mode. */
|
|
102
107
|
create(settings: ProviderSettings, host: ProviderHost): Promise<P>;
|
|
103
108
|
}
|
|
@@ -114,7 +119,7 @@ export declare const PROVIDER_ID: RegExp;
|
|
|
114
119
|
*/
|
|
115
120
|
export declare function providerDescriptorProblems(d: ProviderDescriptor<unknown>): string[];
|
|
116
121
|
/** The serializable part of a descriptor, for the UI (a function cannot cross the extension's port). */
|
|
117
|
-
export type ProviderDescriptorView = Omit<ProviderDescriptor<unknown>, "create" | "validate">;
|
|
122
|
+
export type ProviderDescriptorView = Omit<ProviderDescriptor<unknown>, "create" | "validate" | "wallet">;
|
|
118
123
|
/** Only these fields reach the UI, whatever else a provider module keeps on its descriptor. */
|
|
119
124
|
export declare const describeProvider: ({ id, label, kind, description, networks, platforms, fields, custodial, experimental }: ProviderDescriptor<unknown>) => ProviderDescriptorView;
|
|
120
125
|
/**
|
|
@@ -70,6 +70,11 @@ export interface AppFormatOptions {
|
|
|
70
70
|
}
|
|
71
71
|
/** Checks one entry of `apps`, which is also the whole of a `listing.json`. An unknown key is ignored unless `strict`. */
|
|
72
72
|
export declare function checkAppListing(value: unknown, options?: AppFormatOptions): Check;
|
|
73
|
+
/**
|
|
74
|
+
* The first object key `text` writes twice in one object, as JSON.parse reads it (`"title"` is `title`), or null.
|
|
75
|
+
* `text` is JSON that JSON.parse already took: one pass, each string read to its closing quote.
|
|
76
|
+
*/
|
|
77
|
+
export declare function repeatedJsonKey(text: string): string | null;
|
|
73
78
|
/**
|
|
74
79
|
* Reads a `listing.json`: JSON holding exactly one listing (written by hand in release 1.2, so not required canonical).
|
|
75
80
|
* A store reads it, as a writer: strict by default, so a misspelt key is refused before the owner signs the index (the
|
|
@@ -1,26 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* What an audio file leaves with. A recording made in another app, or a song a tagger went through, says more than its
|
|
3
|
-
* sound: a title or a file name that is where it was recorded (a phone's recorder names it after the place), a comment,
|
|
4
|
-
* a location tag, a picture, the date. The sender removes them before the file is stored and its digest computed, as
|
|
5
|
-
* pictures' and videos' are (pictureMetadata.ts, videoMetadata.ts), without decoding or re-encoding a sample, and the
|
|
6
|
-
* file keeps its size, so no offset in it moves and it plays as it did:
|
|
7
|
-
*
|
|
8
|
-
* - MP4 audio (M4A, a voice note recorded in MP4): videoMetadata.ts's box walk, its `udta` and `meta` emptied.
|
|
9
|
-
* - MP3 and AAC: an ID3v2 tag at the start becomes an empty one (its frames zeros: padding), one at the end (with its
|
|
10
|
-
* footer), an APEv2 tag's items, a Lyrics3v2 tag and an ID3v1 tag's fields become zeros.
|
|
11
|
-
* - FLAC: every metadata block but its stream info and seek table (a Vorbis comment, a picture, a cue sheet, an
|
|
12
|
-
* application's) becomes padding, zeroed.
|
|
13
|
-
* - Ogg Opus, Vorbis and Speex: the comment header keeps its vendor (the encoder's name) and has no comment, the bytes
|
|
14
|
-
* after it zeros; each page it changed has its checksum made again.
|
|
15
|
-
* - WAV: every chunk but its format, data and the ones of the sound itself (`fact`, `cue `, `smpl`, `inst`) becomes
|
|
16
|
-
* `JUNK`, zeroed (an INFO list, an `id3 ` chunk, a broadcast `bext` with its date and originator, XMP).
|
|
17
|
-
* - WebM and Matroska, audio or video: `Tags`, `Attachments`, `Chapters`, the title, the date, the file names and each
|
|
18
|
-
* track's name become `Void` elements (and the SeekHead's entries for them); the muxer's and the writing app's names
|
|
19
|
-
* are zeroed. Clusters, cues and track settings are kept as they are.
|
|
20
|
-
*
|
|
21
|
-
* Fail-closed: a file that is one of these by its bytes and whose tags cannot be removed (truncated, malformed) is
|
|
22
|
-
* refused with `NO_AUDIO_METADATA`, never sent as it was. Any other file goes as it is (other audio formats too).
|
|
23
|
-
*/
|
|
24
1
|
import { type VideoPatch, type VideoSource } from "./videoMetadata.js";
|
|
25
2
|
export declare const AUDIO_METADATA_LIMITS: {
|
|
26
3
|
/** The largest header, element or tag read whole (an Ogg comment header with a picture in it): past this the file is refused. */
|
|
@@ -53,6 +53,8 @@ export declare class CatchUpAnswers<F> {
|
|
|
53
53
|
* good. A frame the edge did not take ends the answer (the member asks again when its edge opens).
|
|
54
54
|
*/
|
|
55
55
|
handOut(to: string, frames: F[]): void;
|
|
56
|
+
/** Whether an answer to `to` still has frames to send, or sent ones its app has not said it handled yet (`hooks.handled`). */
|
|
57
|
+
busy(to: string): boolean;
|
|
56
58
|
/** The next slice of `rest` to `to`, as sent: undefined, and nothing left, when the edge did not take one. */
|
|
57
59
|
private sendSlice;
|
|
58
60
|
/** A slice's frames (`keys`) are on their way to `to` until `done`: its app handled them, or cannot say (`false`). */
|
|
@@ -316,6 +316,12 @@ export declare class ChatFiles {
|
|
|
316
316
|
private readonly moving;
|
|
317
317
|
/** Files that stopped sending for the chat's window alone: they go on once another's bytes are confirmed. */
|
|
318
318
|
private readonly held;
|
|
319
|
+
/**
|
|
320
|
+
* Files this side cancelled while no session carried the cancel (`pf-abort`), said on the next one. The session also
|
|
321
|
+
* goes for a moment when a move swaps it (its capabilities are agreed again): unsaid, the receiver showed the file
|
|
322
|
+
* moving, its bytes kept, until its idle nudge asked 30 s later.
|
|
323
|
+
*/
|
|
324
|
+
private readonly unsaid;
|
|
319
325
|
private attached;
|
|
320
326
|
private peerRoomValue;
|
|
321
327
|
/** What the chat's files may have in flight, sized by the path. */
|
|
@@ -3,15 +3,32 @@
|
|
|
3
3
|
* `clipboard-write`, but Chromium lets `document.execCommand("copy")` write the system clipboard for as long as a tap's
|
|
4
4
|
* activation lasts (seconds, from a timer too), and no sandbox token or permissions policy turns that off. So this
|
|
5
5
|
* script runs first in each of the app's pages (`guardViewerAnswer`) and in the bridge (apps/web/src/svc/bridge.ts):
|
|
6
|
-
* - `execCommand("copy")` and `execCommand("cut")` work only while
|
|
7
|
-
* dispatched
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* - `execCommand("copy")` and `execCommand("cut")` work only while one of the person's own inputs in that window is
|
|
7
|
+
* being dispatched (a trusted `pointerdown`, `pointerup`, `mousedown`, `mouseup`, `click`, `auxclick`, `dblclick`,
|
|
8
|
+
* `contextmenu`, `touchstart`, `touchend`, `keydown`, `keypress` or `keyup`; no script can fire one), or a trusted
|
|
9
|
+
* `submit` or `change` that began while such an input's window was open, and only within a second of that input
|
|
10
|
+
* (from its own `timeStamp`, or from its dispatch where that is later or on another clock): Chromium lets a copy
|
|
11
|
+
* write for seconds after a tap, and a page that spins in its own listener keeps the input being dispatched all
|
|
12
|
+
* that time, while the person may copy something of their own in Ghostly. That window opens as the input is
|
|
13
|
+
* dispatched and closes at the first callback the guard queued at any input that runs (a message on a channel of
|
|
14
|
+
* its own, a `user-blocking` task where `scheduler.postTask` exists, an animation frame), so it holds the input's
|
|
15
|
+
* own dispatch and its default action: the submit of a click on a submit button or of Enter in a field, the change
|
|
16
|
+
* of a checkbox. It also covers the rendering step right after the input: the animation frame callbacks the page
|
|
17
|
+
* asked for before the input run in the frame right after it, ahead of the guard's message and `user-blocking`
|
|
18
|
+
* task (and of its own frame callback, which closes the window there), so a `submit` or `change` one of them fires
|
|
19
|
+
* counts. A `submit` or `change` fired by script (`requestSubmit()`, `click()`) from a timer, a promise, a message
|
|
20
|
+
* or an animation frame asked for at or after the input, or outside any input, does not count. So a copy button, a
|
|
21
|
+
* form, a checkbox, a double click or the app's own context menu copies on the person's tap, and nothing else does
|
|
22
|
+
* (not on load, not from a timer or a promise after a tap). `execCommand("paste")` is refused. Every other command
|
|
23
|
+
* passes as it is. The wrapped `execCommand` is left fixed in place (not writable, not configurable), once per
|
|
24
|
+
* window;
|
|
10
25
|
* - runs in a frame's window before the page holds it, as the WebRTC guard does (`VIEWER_GUARD_SCRIPT`): what a frame
|
|
11
26
|
* element hands out is guarded first, the frames of the document and of its shadow trees are gone over as one loads
|
|
12
27
|
* (an empty frame's first load fires as it is put in the page) and as the page changes, each `srcdoc` frame gets
|
|
13
28
|
* this script first, a declarative shadow root the page's script would make is refused, and with `VIEWER_GUARD_CSP`
|
|
14
|
-
* a `javascript:` URL is refused (its own Trusted Types default policy; one passes every other string on as it is
|
|
29
|
+
* a `javascript:` URL is refused (its own Trusted Types default policy; one passes every other string on as it is,
|
|
30
|
+
* or, once the page made its own `default` policy, to that one's rules: the page's `createPolicy("default")` gets the
|
|
31
|
+
* guard's policy back with them, and the copy of itself it puts in a `srcdoc` frame skips them).
|
|
15
32
|
* A frame's window keeps what was run in it on its first, empty page when the page it loads is of the same origin (the
|
|
16
33
|
* bridge's guard reaches the app's frame then): there this script only watches the new document. Each document it
|
|
17
34
|
* watches is marked (`ghostlyClipboardGuard`, fixed in place): the bridge reads that to know the guard ran in the page
|
|
@@ -21,6 +38,6 @@
|
|
|
21
38
|
* inside a shadow tree written in the HTML the page itself sends, is out of its sight.
|
|
22
39
|
* No backslash, `${` or backtick in it.
|
|
23
40
|
*/
|
|
24
|
-
export declare const CLIPBOARD_GUARD_SCRIPT = "(function noClipboardWrites(w) {\n \"use strict\";\n try {\n const apply = w.Reflect.apply;\n const describe = w.Object.getOwnPropertyDescriptor;\n const define = w.Object.defineProperty;\n const proto = w.Document.prototype;\n const home = w.document;\n const exec = describe(proto, \"execCommand\");\n const fresh = !!exec && exec.configurable === true && typeof exec.value === \"function\";\n const watched = !!describe(home, \"ghostlyClipboardGuard\");\n if (!fresh && watched) return;\n if (!watched) define(home, \"ghostlyClipboardGuard\", { value: true });\n const own = \"<script>(\" + noClipboardWrites + \")(window)<\" + \"/script>\";\n const close = \"<\" + \"/script>\";\n const webRtc = \"<script>(function noWebRtc(\";\n const text = w.String;\n const lower = text.prototype.toLowerCase;\n const slice = text.prototype.slice;\n const index = text.prototype.indexOf;\n const listen = w.EventTarget.prototype.addEventListener;\n const shut = (inner) => {\n try { if (inner && inner !== w) noClipboardWrites(inner); } catch (e) {}\n };\n const count = describe(w, \"length\").get;\n const view = describe(proto, \"defaultView\").get;\n const sweep = () => {\n try { for (let i = apply(count, w, []); i-- > 0;) shut(w[i]); } catch (e) {}\n };\n const elements = w.Element.prototype;\n const getAttribute = elements.getAttribute;\n const setAttribute = elements.setAttribute;\n const removeAttribute = elements.removeAttribute;\n const attachShadow = elements.attachShadow;\n const size = describe(w.NodeList.prototype, \"length\").get;\n const first = (frame) => {\n const doc = apply(getAttribute, frame, [\"srcdoc\"]);\n if (doc === null) return;\n let at = 0;\n if (apply(slice, doc, [0, webRtc.length]) === webRtc) {\n const end = apply(index, doc, [close]);\n if (end >= 0) at = end + close.length;\n }\n if (apply(slice, doc, [at, at + 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 apply(listen, root, [\"load\", sweep, true]);\n scan();\n return root;\n };\n if (fresh) {\n const run = exec.value;\n const phase = describe(w.Event.prototype, \"eventPhase\").get;\n let tap = null;\n let trusted = null;\n const seen = (event) => {\n try {\n const found = describe(event, \"isTrusted\");\n if (found && found.get && apply(found.get, event, []) === true) { tap = event; trusted = found.get; }\n } catch (e) {}\n };\n const taps = [\"pointerdown\", \"pointerup\", \"mousedown\", \"mouseup\", \"click\", \"auxclick\", \"touchstart\", \"touchend\", \"keydown\", \"keyup\"];\n for (let i = 0; i < taps.length; i++) apply(listen, w, [taps[i], seen, true]);\n const tapping = () => {\n try { return tap !== null && apply(trusted, tap, []) === true && apply(phase, tap, []) !== 0; } catch (e) { return false; }\n };\n const guarded = function execCommand(command) {\n const name = apply(lower, text(command), []);\n if (name === \"paste\" || ((name === \"copy\" || name === \"cut\") && !tapping())) return false;\n const args = [name];\n for (let i = 1; i < arguments.length; i++) args[i] = arguments[i];\n return apply(run, this, args);\n };\n define(proto, \"execCommand\", { value: guarded, writable: false, enumerable: exec.enumerable, configurable: false });\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 reopen = proto.open;\n proto.open = function () {\n const got = apply(reopen, this, arguments);\n try { if (apply(view, this, []) === w) apply(listen, this, [\"load\", sweep, true]); } catch (e) {}\n return got;\n };\n const shadowed = (html) => apply(index, apply(lower, html, []), [\"shadowrootmode\"]) >= 0;\n const Refused = w.TypeError;\n const refuse = () => { throw new Refused(\"A declarative shadow root is not allowed here\"); };\n const parsers = [[elements, \"setHTMLUnsafe\"], [w.ShadowRoot && w.ShadowRoot.prototype, \"setHTMLUnsafe\"], [w.Document, \"parseHTMLUnsafe\"]];\n for (let i = 0; i < parsers.length; i++) {\n const owner = parsers[i][0];\n const name = parsers[i][1];\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 const writes = [\"write\", \"writeln\"];\n for (let i = 0; i < writes.length; i++) {\n const real = proto[writes[i]];\n if (typeof real !== \"function\") continue;\n proto[writes[i]] = function () {\n let checked = \"\";\n for (let j = 0; j < arguments.length; j++) checked += text(arguments[j]);\n if (shadowed(tail + checked)) refuse();\n tail = apply(slice, tail + checked, [-16]);\n return apply(real, this, [checked]);\n };\n }\n const kinds = [\"HTMLIFrameElement\", \"HTMLFrameElement\", \"HTMLObjectElement\", \"HTMLEmbedElement\"];\n const reads = [\"contentWindow\", \"contentDocument\", \"getSVGDocument\"];\n for (let k = 0; k < kinds.length; k++) {\n const owner = w[kinds[k]] && w[kinds[k]].prototype;\n for (let r = 0; r < reads.length; r++) {\n const name = reads[r];\n const found = owner && describe(owner, 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(owner, name, found); } catch (e) {}\n }\n }\n const inShadow = w.DocumentFragment.prototype.querySelectorAll;\n if (attachShadow) {\n elements.attachShadow = function () {\n const root = apply(attachShadow, this, arguments);\n try { watch(root, inShadow); } catch (e) {}\n return root;\n };\n }\n }\n if (!watched) watch(home, proto.querySelectorAll);\n } catch (e) {}\n})(window)";
|
|
41
|
+
export declare const CLIPBOARD_GUARD_SCRIPT = "(function noClipboardWrites(w) {\n \"use strict\";\n try {\n const apply = w.Reflect.apply;\n const describe = w.Object.getOwnPropertyDescriptor;\n const define = w.Object.defineProperty;\n const proto = w.Document.prototype;\n const home = w.document;\n const exec = describe(proto, \"execCommand\");\n const fresh = !!exec && exec.configurable === true && typeof exec.value === \"function\";\n const watched = !!describe(home, \"ghostlyClipboardGuard\");\n if (!fresh && watched) return;\n if (!watched) define(home, \"ghostlyClipboardGuard\", { value: true });\n const own = \"<script>(\" + noClipboardWrites + \")(window)<\" + \"/script>\";\n const close = \"<\" + \"/script>\";\n const webRtc = \"<script>(function noWebRtc(\";\n const text = w.String;\n const lower = text.prototype.toLowerCase;\n const slice = text.prototype.slice;\n const index = text.prototype.indexOf;\n const listen = w.EventTarget.prototype.addEventListener;\n const shut = (inner) => {\n try { if (inner && inner !== w) noClipboardWrites(inner); } catch (e) {}\n };\n const count = describe(w, \"length\").get;\n const view = describe(proto, \"defaultView\").get;\n const sweep = () => {\n try { for (let i = apply(count, w, []); i-- > 0;) shut(w[i]); } catch (e) {}\n };\n const elements = w.Element.prototype;\n const getAttribute = elements.getAttribute;\n const setAttribute = elements.setAttribute;\n const removeAttribute = elements.removeAttribute;\n const attachShadow = elements.attachShadow;\n const size = describe(w.NodeList.prototype, \"length\").get;\n let passing = false;\n const first = (frame) => {\n const doc = apply(getAttribute, frame, [\"srcdoc\"]);\n if (doc === null) return;\n let at = 0;\n if (apply(slice, doc, [0, webRtc.length]) === webRtc) {\n const end = apply(index, doc, [close]);\n if (end >= 0) at = end + close.length;\n }\n if (apply(slice, doc, [at, at + own.length]) === own) return;\n passing = true;\n try { apply(setAttribute, frame, [\"srcdoc\", own + doc]); } catch (e) { apply(removeAttribute, frame, [\"srcdoc\"]); }\n passing = false;\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 apply(listen, root, [\"load\", sweep, true]);\n scan();\n return root;\n };\n if (fresh) {\n const run = exec.value;\n const phase = describe(w.Event.prototype, \"eventPhase\").get;\n const trust = (event) => {\n try {\n const found = describe(event, \"isTrusted\");\n if (found && found.get && apply(found.get, event, []) === true) return found.get;\n } catch (e) {}\n return null;\n };\n const dispatching = (event, trusted) => {\n try { return apply(trusted, event, []) === true && apply(phase, event, []) !== 0; } catch (e) { return false; }\n };\n const stamp = describe(w.Event.prototype, \"timeStamp\");\n const clock = w.performance;\n const tick = clock && clock.now;\n const time = () => { try { return apply(tick, clock, []); } catch (e) { return NaN; } };\n const recent = (at) => time() - at <= 1000;\n const shutters = [];\n try {\n const channel = new w.MessageChannel();\n const post = w.MessagePort.prototype.postMessage;\n const out = channel.port2;\n channel.port1.onmessage = () => settle();\n shutters[0] = () => apply(post, out, [0]);\n } catch (e) {}\n try {\n const tasks = w.scheduler;\n const postTask = tasks && tasks.postTask;\n const urgent = { __proto__: null, priority: \"user-blocking\" };\n if (typeof postTask === \"function\") shutters[shutters.length] = () => { apply(postTask, tasks, [settle, urgent]); };\n } catch (e) {}\n try {\n const frame = w.requestAnimationFrame;\n if (typeof frame === \"function\") shutters[shutters.length] = () => { apply(frame, w, [settle]); };\n } catch (e) {}\n let tap = null;\n let trusted = null;\n let tapped = NaN;\n let open = 0;\n let follows = null;\n const settle = () => { open = 0; follows = null; };\n const seen = (event) => {\n const found = trust(event);\n if (found === null) return;\n let at = time();\n try {\n const given = apply(stamp.get, event, []);\n if (given >= 0 && given < at) at = given;\n } catch (e) {}\n tap = event;\n trusted = found;\n tapped = at;\n if (shutters.length === 0) return;\n open = 1;\n for (let i = 0; i < shutters.length; i++) { try { shutters[i](); } catch (e) {} }\n };\n const taps = [\"pointerdown\", \"pointerup\", \"mousedown\", \"mouseup\", \"click\", \"auxclick\", \"dblclick\", \"contextmenu\", \"touchstart\", \"touchend\", \"keydown\", \"keypress\", \"keyup\"];\n for (let i = 0; i < taps.length; i++) apply(listen, w, [taps[i], seen, true]);\n const followed = (event) => {\n if (open === 0) return;\n const found = trust(event);\n if (found !== null) follows = { event: event, trusted: found, at: tapped, next: follows };\n };\n apply(listen, w, [\"submit\", followed, true]);\n apply(listen, w, [\"change\", followed, true]);\n const tapping = () => {\n if (tap !== null && dispatching(tap, trusted) && recent(tapped)) return true;\n for (let f = follows; f !== null; f = f.next) if (dispatching(f.event, f.trusted) && recent(f.at)) return true;\n return false;\n };\n const guarded = function execCommand(command) {\n const name = apply(lower, text(command), []);\n if (name === \"paste\" || ((name === \"copy\" || name === \"cut\") && !tapping())) return false;\n const args = [name];\n for (let i = 1; i < arguments.length; i++) args[i] = arguments[i];\n return apply(run, this, args);\n };\n define(proto, \"execCommand\", { value: guarded, writable: false, enumerable: exec.enumerable, configurable: false });\n const types = w.trustedTypes;\n if (types && !types.defaultPolicy) {\n try {\n let rules = null;\n const rule = (kind) => (input, type, sink) => {\n if (kind === \"createScript\" && sink === \"Location href\") return null;\n if (passing || rules === null) return input;\n return rules[kind] ? apply(rules[kind], undefined, [input, type, sink]) : null;\n };\n const members = [\"createHTML\", \"createScript\", \"createScriptURL\"];\n const create = types.createPolicy;\n const policy = apply(create, types, [\"default\", { createHTML: rule(members[0]), createScript: rule(members[1]), createScriptURL: rule(members[2]) }]);\n const Mistyped = w.TypeError;\n w.Object.getPrototypeOf(types).createPolicy = function createPolicy(name, options) {\n if (this !== types || rules !== null || text(name) !== \"default\") return apply(create, this, arguments);\n const given = { createHTML: null, createScript: null, createScriptURL: null };\n for (let i = 0; i < members.length; i++) {\n const found = options ? options[members[i]] : undefined;\n if (found === undefined || found === null) continue;\n if (typeof found !== \"function\") throw new Mistyped(\"The policy's \" + members[i] + \" is not a function\");\n given[members[i]] = found;\n }\n rules = given;\n return policy;\n };\n } catch (e) {}\n }\n const reopen = proto.open;\n proto.open = function () {\n const got = apply(reopen, this, arguments);\n try { if (apply(view, this, []) === w) apply(listen, this, [\"load\", sweep, true]); } catch (e) {}\n return got;\n };\n const shadowed = (html) => apply(index, apply(lower, html, []), [\"shadowrootmode\"]) >= 0;\n const Refused = w.TypeError;\n const refuse = () => { throw new Refused(\"A declarative shadow root is not allowed here\"); };\n const parsers = [[elements, \"setHTMLUnsafe\"], [w.ShadowRoot && w.ShadowRoot.prototype, \"setHTMLUnsafe\"], [w.Document, \"parseHTMLUnsafe\"]];\n for (let i = 0; i < parsers.length; i++) {\n const owner = parsers[i][0];\n const name = parsers[i][1];\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 const writes = [\"write\", \"writeln\"];\n for (let i = 0; i < writes.length; i++) {\n const real = proto[writes[i]];\n if (typeof real !== \"function\") continue;\n proto[writes[i]] = function () {\n let checked = \"\";\n for (let j = 0; j < arguments.length; j++) checked += text(arguments[j]);\n if (shadowed(tail + checked)) refuse();\n tail = apply(slice, tail + checked, [-16]);\n return apply(real, this, [checked]);\n };\n }\n const kinds = [\"HTMLIFrameElement\", \"HTMLFrameElement\", \"HTMLObjectElement\", \"HTMLEmbedElement\"];\n const reads = [\"contentWindow\", \"contentDocument\", \"getSVGDocument\"];\n for (let k = 0; k < kinds.length; k++) {\n const owner = w[kinds[k]] && w[kinds[k]].prototype;\n for (let r = 0; r < reads.length; r++) {\n const name = reads[r];\n const found = owner && describe(owner, 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(owner, name, found); } catch (e) {}\n }\n }\n const inShadow = w.DocumentFragment.prototype.querySelectorAll;\n if (attachShadow) {\n elements.attachShadow = function () {\n const root = apply(attachShadow, this, arguments);\n try { watch(root, inShadow); } catch (e) {}\n return root;\n };\n }\n }\n if (!watched) watch(home, proto.querySelectorAll);\n } catch (e) {}\n})(window)";
|
|
25
42
|
/** `CLIPBOARD_GUARD_SCRIPT`'s hash, as a CSP source: the bridge's policy and a contact's own are given it. */
|
|
26
|
-
export declare const CLIPBOARD_GUARD_HASH = "'sha256-
|
|
43
|
+
export declare const CLIPBOARD_GUARD_HASH = "'sha256-ay9kpYD2BIflB8W9w+iAbo1krsFBwIJunUmXTACfhao='";
|
|
@@ -522,6 +522,19 @@ export declare class DhtDelivery {
|
|
|
522
522
|
private publishOnTick;
|
|
523
523
|
/** How long until the next read of the contact's mailbox (WISP 403, poll pace). */
|
|
524
524
|
get pollMs(): number;
|
|
525
|
+
/**
|
|
526
|
+
* The contact is on DHT only and this side is not: a live link waits on the contact's envelope saying it left, and
|
|
527
|
+
* nothing else of the contact's shows before it (no offer is read, no dial taken, while its mailbox says DHT only). Its
|
|
528
|
+
* reads that are not background ones (the chat open, a text awaiting its receipt) then say `departed`: a few may go over
|
|
529
|
+
* the relays' minute (`DEPARTED_READS` in relay.ts, per mailbox, every relay together, 6 at the open chat's 10 s pace).
|
|
530
|
+
* As plain reads, an extension that stayed on Automatic, its minute spent by what it did before, read nothing of its
|
|
531
|
+
* contact for 40 s after the contact left DHT only, and the matrix's chat stayed "On DHT · retrying live" (E2E full,
|
|
532
|
+
* 2026-11-07 and 11-08). No more reads than before: those it made anyway, the minute spent, go within the allowance.
|
|
533
|
+
* Not while this side is leaving DHT only itself (`signalReads` left, `leavingRead`): its read at the switch stays a
|
|
534
|
+
* plain one, the rest are signaling, so the few requests past a spent minute stay for the dialling side's read of the
|
|
535
|
+
* answer. As a departed read, the switch's took one, and both sides leaving went live in 34 s, against 10.
|
|
536
|
+
*/
|
|
537
|
+
private departedRead;
|
|
525
538
|
/**
|
|
526
539
|
* This side is DHT only, and nothing waits on the contact's mailbox: the contact, pinned, is away (nothing new of its
|
|
527
540
|
* own in `PRESENCE_WINDOW`; it puts a keep-alive every four minutes while there), no text of ours awaits its receipt,
|
|
@@ -124,7 +124,7 @@ export type DidDhtFetch = (url: string, options?: {
|
|
|
124
124
|
}) => Promise<DidDhtFetchResponse>;
|
|
125
125
|
export interface ResolveDidDhtOptions {
|
|
126
126
|
fetch: DidDhtFetch;
|
|
127
|
-
/** Pkarr relays (or did:dht gateways, which answer the same GET) to ask
|
|
127
|
+
/** Pkarr relays (or did:dht gateways, which answer the same GET) to ask, all of them. Default: `DEFAULT_RELAYS`. */
|
|
128
128
|
relays?: string[];
|
|
129
129
|
signal?: AbortSignal;
|
|
130
130
|
}
|
|
@@ -147,9 +147,11 @@ export declare function openDidDhtPayload(did: string, payload: Uint8Array): Dec
|
|
|
147
147
|
seq: bigint;
|
|
148
148
|
};
|
|
149
149
|
/**
|
|
150
|
-
* Resolves a did:dht through Pkarr relays: one GET
|
|
151
|
-
*
|
|
152
|
-
*
|
|
150
|
+
* Resolves a did:dht through Pkarr relays: one GET to each, all at once, and the newest packet that
|
|
151
|
+
* checks out wins (the highest sequence number; on a tie, the relay listed first), so a relay holding
|
|
152
|
+
* an older version cannot bring back a removed key or undo a deactivation. Each answer is bounded to
|
|
153
|
+
* a BEP44 item, its signature checked against the DID's key and its records parsed strictly; a relay
|
|
154
|
+
* that has nothing, fails or serves a packet that does not check out does not count. A deactivated DID
|
|
153
155
|
* resolves (`metadata.deactivated`); everything else that goes wrong throws a `DidDhtError`.
|
|
154
156
|
*/
|
|
155
157
|
export declare function resolveDidDht(did: string, options: ResolveDidDhtOptions): Promise<DidDhtResolution>;
|
|
@@ -22,6 +22,12 @@ export declare const LIMITS: {
|
|
|
22
22
|
readonly maxPathBytes: number;
|
|
23
23
|
/** Requests a host serves at once for one peer. */
|
|
24
24
|
readonly maxConcurrentRequestsPerPeer: 32;
|
|
25
|
+
/**
|
|
26
|
+
* Request-body bytes a host holds for one peer at once, from a body's first chunk until its local fetch settles.
|
|
27
|
+
* Past it a request is refused (`busy`). As much as a client's in-flight requests can carry, so only a peer that
|
|
28
|
+
* ignores that limit reaches it.
|
|
29
|
+
*/
|
|
30
|
+
readonly maxHostBodyBytesPerPeer: number;
|
|
25
31
|
/** Requests a client keeps in flight; the rest wait in a queue. */
|
|
26
32
|
readonly maxClientInFlight: 16;
|
|
27
33
|
/**
|
|
@@ -38,6 +44,11 @@ export declare const LIMITS: {
|
|
|
38
44
|
readonly maxStoredIncomingBytesPerPeer: number;
|
|
39
45
|
readonly requestTimeoutMs: 60000;
|
|
40
46
|
readonly bodyIdleTimeoutMs: 30000;
|
|
47
|
+
/**
|
|
48
|
+
* What a request body must bring in each `bodyIdleTimeoutMs` (unless it ends) to count as moving: a peer that sends a
|
|
49
|
+
* few bytes at a time is let go like one that stalls.
|
|
50
|
+
*/
|
|
51
|
+
readonly minRequestBodyBytesPerIdle: number;
|
|
41
52
|
/** Stop writing to the channel above this many buffered bytes. */
|
|
42
53
|
readonly sendHighWaterMark: number;
|
|
43
54
|
readonly sendLowWaterMark: number;
|
|
@@ -95,6 +95,14 @@ export declare const RACE_DIRECT_MS = 8000;
|
|
|
95
95
|
* over a relay stays there (no probing while live, WISP 100), where the answer would have made it direct.
|
|
96
96
|
*/
|
|
97
97
|
export declare const RACE_RELAYED_MS = 40000;
|
|
98
|
+
/**
|
|
99
|
+
* A relayed transport dialled ahead of the others (Automatic's Iroh through its relay, WISP 100 revision 2026-11-08) has
|
|
100
|
+
* this long before the next ranked one is dialled too, the first still going: whichever goes live first carries the
|
|
101
|
+
* chat. Through a relay that answers it connects well within it (0.1-0.9 s measured); one that reaches nobody (the
|
|
102
|
+
* relay down, the contact no longer on it) gives up only at Iroh's connect timeout, 20 s, and held the WebRTC offer back
|
|
103
|
+
* that long at every return: 26-30 s to live between two CLIs with the Iroh relay down, 4 s with WebRTC chosen.
|
|
104
|
+
*/
|
|
105
|
+
export declare const RELAYED_FIRST_MS = 3000;
|
|
98
106
|
/**
|
|
99
107
|
* A WebRTC offer this side made that was answered, and has not connected this long after the answer was applied: where
|
|
100
108
|
* a path exists ICE finds it in a second or two, so there is none (a VPN's NAT, a firewall that drops UDP, and no TURN
|
|
@@ -205,6 +213,17 @@ export interface IncomingMessage {
|
|
|
205
213
|
}
|
|
206
214
|
/** Largest `paired-message` frame sent with a preview: a session fails on a frame over 60 KiB (`PairedSession`). */
|
|
207
215
|
export declare const MAX_PAIRED_MESSAGE_FRAME: number;
|
|
216
|
+
/**
|
|
217
|
+
* Texts a contact's link takes: a burst per short window (a reconnect flushes every queued text at once) and a total
|
|
218
|
+
* per hour, both well above what a person or a bot sends. The rest go unconfirmed and come again (the sender's outbox
|
|
219
|
+
* resends with backoff), so a catch-up only slows.
|
|
220
|
+
*/
|
|
221
|
+
export declare const MESSAGE_RECEIVE_LIMITS: {
|
|
222
|
+
readonly burst: 200;
|
|
223
|
+
readonly burstWindowMs: 10000;
|
|
224
|
+
readonly hourly: 1800;
|
|
225
|
+
readonly hourWindowMs: 3600000;
|
|
226
|
+
};
|
|
208
227
|
/**
|
|
209
228
|
* A `paired-message` frame. The preview (`pv`) is left out when the frame would pass `MAX_PAIRED_MESSAGE_FRAME`
|
|
210
229
|
* with it: the text matters, the card does not. A reply (`r`, WISP 401 § Replies) is a few hundred bytes at most
|
|
@@ -788,6 +807,8 @@ export declare class GhostLink {
|
|
|
788
807
|
private readonly pinsReceived;
|
|
789
808
|
/** Edit frames the contact may send per window; the rest go unconfirmed and come again. */
|
|
790
809
|
private readonly editsReceived;
|
|
810
|
+
/** Text frames the contact may send per window (`MESSAGE_RECEIVE_LIMITS`); the rest go unconfirmed and come again. */
|
|
811
|
+
private readonly messagesReceived;
|
|
791
812
|
/** Call signals the contact may send per window; the rest are dropped. */
|
|
792
813
|
private readonly callsReceived;
|
|
793
814
|
/** WebRTC signals the contact may send on the session (`paired-rtc`) per window; the rest are dropped. */
|
|
@@ -844,7 +865,8 @@ export declare class GhostLink {
|
|
|
844
865
|
/**
|
|
845
866
|
* The WebRTC offer this side's dial made last, with fallback allowed: what a transport that comes up meanwhile joins.
|
|
846
867
|
* `resume`: the dial that made it is this side back after an absence, over WebRTC (`resuming`); `woke`: the absence
|
|
847
|
-
* was the app's in the background, not a restart (`resumeAfterAbsence`).
|
|
868
|
+
* was the app's in the background, not a restart (`resumeAfterAbsence`). `knockMissed`: the dial that made it followed a
|
|
869
|
+
* resume's knock that found nothing (`resumeKnockMissed`).
|
|
848
870
|
*/
|
|
849
871
|
private offered?;
|
|
850
872
|
/**
|
|
@@ -942,6 +964,8 @@ export declare class GhostLink {
|
|
|
942
964
|
private resumeWaitUntil;
|
|
943
965
|
/** The contact's other native transports were knocked on while this resume waited (`knockWhileResuming`). */
|
|
944
966
|
private resumeKnocked;
|
|
967
|
+
/** The resume's knock found nothing (`knock`): the next dial is still the resume's, made whatever the key. */
|
|
968
|
+
private resumeKnockMissed;
|
|
945
969
|
/** What the last live session ran on, kept after it ended: a wake resumes on it (`resumeAfterAbsence`). */
|
|
946
970
|
private lastLiveOn;
|
|
947
971
|
/** `resuming` is a wake's, not a restart's. */
|
|
@@ -1068,6 +1092,13 @@ export declare class GhostLink {
|
|
|
1068
1092
|
private open;
|
|
1069
1093
|
/** Closes what a switch replaced once the contact has had time to move too. */
|
|
1070
1094
|
private retire;
|
|
1095
|
+
/**
|
|
1096
|
+
* Where the receipt of a frame read on `channel` goes: that session while it carries the chat, the one now when a move
|
|
1097
|
+
* replaced it (or moved while the frame was shown), or nowhere.
|
|
1098
|
+
*/
|
|
1099
|
+
private answerOn;
|
|
1100
|
+
/** Counts one text the contact sent; false (and not counted) when either of `messagesReceived` is full. */
|
|
1101
|
+
private takeMessage;
|
|
1071
1102
|
/**
|
|
1072
1103
|
* The WebRTC session a switch moved off is still retiring (`SWITCH_RETIRE_MS`): its data link is open, and a new offer
|
|
1073
1104
|
* cannot go until it closes. Resolves once it has (at once when none is).
|
|
@@ -1197,6 +1228,11 @@ export declare class GhostLink {
|
|
|
1197
1228
|
* holds the old session and would notice only when its liveness gives up (a minute); a dial reaches it now and takes
|
|
1198
1229
|
* over (`attachReplacement`). Once only, and a knock that does not connect counts as no failure: the contact may
|
|
1199
1230
|
* simply be away. Two dials crossing are settled by key order (see `registerEndpoint`).
|
|
1231
|
+
*
|
|
1232
|
+
* A resume's knock that does not connect leaves its dial whatever the key to the next one (`resumeKnockMissed`), whose
|
|
1233
|
+
* offer knocks on the contact's other transports (`knockMissed`): a contact holding the old session over HyperDHT
|
|
1234
|
+
* announces no listener (endpoint.mjs), so the knock finds nothing, and the higher key waited for the contact to
|
|
1235
|
+
* notice (14.5-15.2 s between two CLI daemons, against 0.8-1.6 s with the lower key; under 5 s now).
|
|
1200
1236
|
*/
|
|
1201
1237
|
private knock;
|
|
1202
1238
|
/**
|
|
@@ -1295,7 +1331,11 @@ export declare class GhostLink {
|
|
|
1295
1331
|
private upgradesFromRelay;
|
|
1296
1332
|
/** The contact's newest packet is older than `EXPECT_PEER_MS`: it is not signalling, and reads at a slow pace. */
|
|
1297
1333
|
private contactQuiet;
|
|
1298
|
-
/**
|
|
1334
|
+
/**
|
|
1335
|
+
* The direct transports of an attempt that resumes to a quiet contact, knocked on while its offer stands (`scheduleRace`).
|
|
1336
|
+
* So are those of the dial after a resume's knock that found nothing (`knockMissed`), relayed ones too, whatever the
|
|
1337
|
+
* contact's newest packet: it holds the old session and reads offers at a live chat's pace.
|
|
1338
|
+
*/
|
|
1299
1339
|
private maybeKnockEarly;
|
|
1300
1340
|
/**
|
|
1301
1341
|
* Back after a restart on a native transport whose endpoint has not started yet (Iroh waits up to 10 s for its relay,
|
|
@@ -488,6 +488,12 @@ export declare class GroupSession {
|
|
|
488
488
|
* said it (`heardName`). In memory only; the records held start it.
|
|
489
489
|
*/
|
|
490
490
|
private readonly nickAt;
|
|
491
|
+
/**
|
|
492
|
+
* Member → the name an edge's empty one took away a moment ago (`setNick`), and when. The admin that removed me while
|
|
493
|
+
* I was away says no name on the edge it kept to tell me, as its app opens it, and the commit that removes me comes
|
|
494
|
+
* right after on that edge: that name comes back for the history I keep (`nameKept`). In memory only.
|
|
495
|
+
*/
|
|
496
|
+
private readonly unnamed;
|
|
491
497
|
/** The version of my name record last said to every member (`sayName`). In memory only: said again once per start. */
|
|
492
498
|
private nameSaid;
|
|
493
499
|
/** New name records taken per member, a few a minute (`GROUP_LIMITS.namesPerMember`). In memory only. */
|
|
@@ -673,6 +679,8 @@ export declare class GroupSession {
|
|
|
673
679
|
private commit;
|
|
674
680
|
/** Someone removed or gone is not handed on any more, whatever they sent while in the roster (WISP 902 § Catch-up). */
|
|
675
681
|
private pruneRelay;
|
|
682
|
+
/** An edit of an epoch I was not a member of (let in after it): kept and handed on unread (WISP 902 § Edits, "Carried unread"). */
|
|
683
|
+
private carriedUnread;
|
|
676
684
|
/** Whether a kept edit is a removal (WISP 400 § Delete for everyone): its box, under its epoch's key, says `rm`. */
|
|
677
685
|
private isRemovalEdit;
|
|
678
686
|
/**
|
|
@@ -712,6 +720,11 @@ export declare class GroupSession {
|
|
|
712
720
|
/** Told out of band (the admin's contact chat) that I was removed, before or instead of the commit. */
|
|
713
721
|
markRemoved(): Promise<void>;
|
|
714
722
|
private out;
|
|
723
|
+
/**
|
|
724
|
+
* Out of the group: a name an edge took away a moment before comes back, as the history I keep still shows it. The
|
|
725
|
+
* edge the admin kept to tell me I was removed says no name as it opens, just before the commit that removed me.
|
|
726
|
+
*/
|
|
727
|
+
private nameKept;
|
|
715
728
|
/**
|
|
716
729
|
* Encrypts and signs a text, keeps it for catch-up and sends it to every other member. `mentions`: places of the
|
|
717
730
|
* text that name members (everyone: the admin only); what does not hold is left out. `reply`: the message it
|
|
@@ -58,9 +58,18 @@ export declare const VIEWER_SERVICE_CSP = "default-src 'self' https: data: blob:
|
|
|
58
58
|
export declare const VIEWER_SERVICE_CSP_RELAY_ONLY = "default-src 'self' data: blob: 'unsafe-inline' 'unsafe-eval'; connect-src 'self'; form-action 'self'";
|
|
59
59
|
/** Ghostly's policy for a contact's app, by whether Hide my IP from contacts is on. */
|
|
60
60
|
export declare function viewerServicePolicy(relayOnly: boolean): string;
|
|
61
|
+
/**
|
|
62
|
+
* The browser features a contact's app in the extension's viewer tab may not use. Its tab is a site of its own, so
|
|
63
|
+
* what the person granted it (camera, microphone, location, a device) would be a site setting of the browser's, which
|
|
64
|
+
* no Delete chat, Clear all data or Delete profile reaches; denied here, the browser never asks and ignores a grant
|
|
65
|
+
* made before. The web app's view is a frame of another site, which gets none of them, and Desktop's window grants none.
|
|
66
|
+
*/
|
|
67
|
+
export declare const VIEWER_PERMISSIONS_POLICY: string;
|
|
61
68
|
/**
|
|
62
69
|
* `headers` with Ghostly's policy after the contact's own, all in one `content-security-policy` joined by commas: a
|
|
63
|
-
* browser enforces every policy of the list, so the contact's can narrow Ghostly's but never widen it.
|
|
70
|
+
* browser enforces every policy of the list, so the contact's can narrow Ghostly's but never widen it. The page's
|
|
71
|
+
* features are Ghostly's alone (`VIEWER_PERMISSIONS_POLICY`): a contact's permissions policy could allow them, and one
|
|
72
|
+
* the browser cannot read would void the whole header, Ghostly's part with it.
|
|
64
73
|
*/
|
|
65
74
|
export declare function withViewerPolicy(headers: HeaderList, relayOnly?: boolean): HeaderList;
|
|
66
75
|
/**
|
|
@@ -104,16 +113,21 @@ export declare class HttpHost {
|
|
|
104
113
|
* so a stream counts toward the limit until its fetch has settled.
|
|
105
114
|
*/
|
|
106
115
|
private readonly live;
|
|
116
|
+
/** Body bytes of the streams in `live`: a peer cannot make the host hold more than `maxHostBodyBytesPerPeer`. */
|
|
117
|
+
private heldBodyBytes;
|
|
107
118
|
constructor(channel: FrameChannel, getService: (id: string) => HostedHttpService | undefined, localFetch: LocalFetch);
|
|
108
119
|
get activeRequests(): number;
|
|
109
120
|
handleRequest(frame: HttpRequestFrame): void;
|
|
110
121
|
handleChunk(chunk: ChunkFrame): void;
|
|
111
122
|
handleReset(frame: ResetFrame): void;
|
|
112
123
|
closeAll(): void;
|
|
113
|
-
|
|
124
|
+
/** A body that brings less than `minRequestBodyBytesPerIdle` in a `bodyIdleTimeoutMs` is let go, even if it trickles. */
|
|
125
|
+
private watchPace;
|
|
114
126
|
/** Ids are reused after a reset, so a stream is current only if it is the one in the map. */
|
|
115
127
|
private isCurrent;
|
|
116
128
|
private end;
|
|
129
|
+
/** The stream no longer counts toward the limits: its body is dropped, or its local fetch has settled. */
|
|
130
|
+
private release;
|
|
117
131
|
private fail;
|
|
118
132
|
private run;
|
|
119
133
|
}
|
|
@@ -9,8 +9,23 @@ export interface Identity {
|
|
|
9
9
|
publicKey: Uint8Array;
|
|
10
10
|
pubKeyZ32: string;
|
|
11
11
|
}
|
|
12
|
-
/** How many public keys `identityFromSeed` keeps: a start with 50 chats and 20 groups derives about 400 distinct ones. */
|
|
12
|
+
/** How many public keys `identityFromSeed` keeps however long ago they were used: a start with 50 chats and 20 groups derives about 400 distinct ones. */
|
|
13
13
|
export declare const IDENTITY_MEMO_SIZE = 1024;
|
|
14
|
+
/**
|
|
15
|
+
* Past `IDENTITY_MEMO_SIZE`, a key is let go only once it has not been asked for this long: a start asks for all of a
|
|
16
|
+
* profile's keys within seconds (a 600-chat one, ~4,000 of them), then asks again for the running links' ones.
|
|
17
|
+
*/
|
|
18
|
+
export declare const IDENTITY_MEMO_IDLE_MS: number;
|
|
19
|
+
/** The most keys kept, used or not: ~410 bytes each in V8 (its id, its key and when it was used), ~6.7 MB in all. */
|
|
20
|
+
export declare const IDENTITY_MEMO_MAX = 16384;
|
|
21
|
+
/**
|
|
22
|
+
* A faster derivation of a seed's Ed25519 public key a host may give (the CLI gives node:crypto's, ~4x noble's): each
|
|
23
|
+
* process starts with an empty memo, so a one-shot command derives every chat's keys again. A throw, or an answer that
|
|
24
|
+
* is not 32 bytes, leaves the key to noble.
|
|
25
|
+
*/
|
|
26
|
+
export type PublicKeyFastPath = (seed: Uint8Array) => Uint8Array;
|
|
27
|
+
/** Gives (or, with `null`, takes back) the faster derivation of every public key `identityFromSeed` derives. */
|
|
28
|
+
export declare function setPublicKeyFastPath(derive: PublicKeyFastPath | null): void;
|
|
14
29
|
export declare function identityFromSeed(seed: Uint8Array): Identity;
|
|
15
30
|
export declare function identityFromSeedB64(seedB64: string): Identity;
|
|
16
31
|
export declare function createIdentity(): Identity;
|
|
@@ -140,6 +140,11 @@ export interface SharedIdentity {
|
|
|
140
140
|
id: string;
|
|
141
141
|
provider: string;
|
|
142
142
|
subject: string;
|
|
143
|
+
/**
|
|
144
|
+
* The identity the contact keeps it under (the provider's verified subject: an OIDC binding names the issuer, its
|
|
145
|
+
* account is the issuer and `sub`). Absent in older ledgers.
|
|
146
|
+
*/
|
|
147
|
+
account?: string;
|
|
143
148
|
/** queued: the person chose to share, the contact is not connected yet. */
|
|
144
149
|
status: "queued" | "pending" | "accepted" | "rejected" | "withdrawal-pending" | "withdrawn";
|
|
145
150
|
/** Seconds. When the status last changed. */
|
|
@@ -184,10 +189,12 @@ export interface IdentityLedger {
|
|
|
184
189
|
timeline?: IdentityTimelineEntry[];
|
|
185
190
|
}
|
|
186
191
|
export declare const emptyIdentityLedger: () => IdentityLedger;
|
|
192
|
+
/** `account`: the subject its provider verified (`VerifiedIdentity.subject`); the binding's subject when not given. */
|
|
187
193
|
export interface LocalIdentityProof {
|
|
188
194
|
statement: IdentityStatement;
|
|
189
195
|
evidence: unknown;
|
|
190
196
|
seed: Uint8Array;
|
|
197
|
+
account?: string;
|
|
191
198
|
}
|
|
192
199
|
export interface IdentityExchangeOptions {
|
|
193
200
|
/** This side's view of the authenticated channel; throws when there is none. */
|
|
@@ -84,6 +84,7 @@ export * from './sshsig.js';
|
|
|
84
84
|
export * from "./groupCrypto.js";
|
|
85
85
|
export * from "./groupCommits.js";
|
|
86
86
|
export * from "./groupSession.js";
|
|
87
|
+
export * from "./catchUp.js";
|
|
87
88
|
export * from "./groupMentions.js";
|
|
88
89
|
export * from "./groupWake.js";
|
|
89
90
|
export * from "./groupEdits.js";
|
|
@@ -29,14 +29,21 @@ export declare const LINK_PREVIEW_LIMITS: {
|
|
|
29
29
|
};
|
|
30
30
|
/** What a link leaves out at its end: a sentence's punctuation ("…", "»", "”" too), never a path's "/". */
|
|
31
31
|
export declare const LINK_TRAILING: RegExp;
|
|
32
|
+
/** How many UTF-16 units of `url` before `end` are an emoji's or an invisible character's last code point (0: none). */
|
|
33
|
+
export declare function linkTail(url: string, end: number): number;
|
|
32
34
|
/** A link up to the first `LINK_STOP`: "https://x.example/a。" opens /a, not /a%E3%80%82. */
|
|
33
35
|
export declare function linkStop(url: string): string;
|
|
34
36
|
/**
|
|
35
37
|
* A link ends where the sentence around it takes over: trailing punctuation ("see https://x.example/a.", in any of
|
|
36
|
-
* the app's languages) and a closing bracket or quote the link did not
|
|
37
|
-
* text. The same rule as the message bubble's links.
|
|
38
|
+
* the app's languages), an emoji or invisible character (`linkTail`) and a closing bracket or quote the link did not
|
|
39
|
+
* open ("(https://x.example/a)") are left as text. The same rule as the message bubble's links.
|
|
38
40
|
*/
|
|
39
41
|
export declare function linkEnd(whole: string): string;
|
|
42
|
+
/**
|
|
43
|
+
* A payment link (`bitcoin:`, `monero:`…) ends as a web link does, but keeps an emoji at its end: its label or message
|
|
44
|
+
* is text written as it is ("…&label=Pizza 🍕"), cut at 140 characters wherever that falls.
|
|
45
|
+
*/
|
|
46
|
+
export declare function uriEnd(whole: string): string;
|
|
40
47
|
/** Characters of a link worth reading: a longer one is no address anyone shares, and is left as text. */
|
|
41
48
|
export declare const LINK_MAX_CHARS: number;
|
|
42
49
|
/** The http(s) links of a text, in order, each ending as the bubble ends it. */
|
|
@@ -196,12 +196,15 @@ export type MiniAppEvent = {
|
|
|
196
196
|
};
|
|
197
197
|
/** Limits the broker enforces (and an app can plan for). */
|
|
198
198
|
export declare const MINI_APP_LIMITS: {
|
|
199
|
-
/**
|
|
199
|
+
/**
|
|
200
|
+
* One request, serialized: a stored value's 64 KiB with room for its key (256 bytes, at most six times that as JSON)
|
|
201
|
+
* and `{"id", "type", "args"}` around them.
|
|
202
|
+
*/
|
|
200
203
|
readonly requestBytes: number;
|
|
201
204
|
/** Requests per second, per app. */
|
|
202
205
|
readonly requestsPerSecond: 50;
|
|
203
206
|
/**
|
|
204
|
-
* Bytes of `file`, `files.read`, `files.list` and `
|
|
207
|
+
* Bytes of `file`, `files.read`, `files.list`, `remote.read` and `storage.keys` answers per second, per app, counted together: a whole bundle's
|
|
205
208
|
* worth. A request that starts under it is answered whole; past it the request is refused with `too-fast` until the
|
|
206
209
|
* second has gone.
|
|
207
210
|
*/
|
|
@@ -32,6 +32,11 @@ export declare const APP_RANGE_LIMITS: {
|
|
|
32
32
|
* are asked, so a cancelled one counts as the read it started. Twice the asking app's own budget (16 MiB a second).
|
|
33
33
|
*/
|
|
34
34
|
readonly bytesPerSecond: number;
|
|
35
|
+
/**
|
|
36
|
+
* The least one ask counts in `bytesPerSecond`, however few bytes it asked or the file held from its offset: each is
|
|
37
|
+
* a read on this device, so a contact gets at most 512 a second.
|
|
38
|
+
*/
|
|
39
|
+
readonly askFloorBytes: number;
|
|
35
40
|
};
|
|
36
41
|
/**
|
|
37
42
|
* What an `ar-err` says. `not-served`: no serve of that id (never given, or ended); `changed` and
|
|
@@ -138,13 +138,15 @@ export declare class AppSessions {
|
|
|
138
138
|
canSend(app: string, data: unknown): AppSendError | null;
|
|
139
139
|
/**
|
|
140
140
|
* The session ended, or `apps/1` is no longer agreed: what the peer had open is gone, and each such app hears a
|
|
141
|
-
* `close` with `offline`. This side's open apps stay, and say `open` again on the next session.
|
|
141
|
+
* `close` with `offline`. This side's open apps stay, and say `open` again on the next session. The rate windows
|
|
142
|
+
* stay too: they are the contact's per app, or turning `apps/1` off and on would give each app a new 50.
|
|
142
143
|
*/
|
|
143
144
|
sessionEnded(): AppFrameEvent[];
|
|
144
145
|
/**
|
|
145
146
|
* The session ended or was replaced, and another may follow at once: what the peer had open is held, not closed (no
|
|
146
147
|
* event now). Nothing is sent to a held app; an `open` on the next session takes it back, a `close` closes it, and
|
|
147
|
-
* `heldExpired` closes the rest once `graceMs` has passed since the suspension that held each.
|
|
148
|
+
* `heldExpired` closes the rest once `graceMs` has passed since the suspension that held each. The rate windows stay,
|
|
149
|
+
* as in `sessionEnded`.
|
|
148
150
|
*/
|
|
149
151
|
sessionSuspended(graceMs?: number): void;
|
|
150
152
|
/** Whether any of the peer's apps is held, waiting for its next session. */
|