@ghostlytools/sdk 1.3.2 → 1.3.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/core.js +2 -2
- package/dist/{fakes-MnrUkwEP.js → fakes-BGm8YDy-.js} +36 -32
- package/dist/fakes-BGm8YDy-.js.map +1 -0
- package/dist/fakes.js +1 -1
- package/dist/index.js +2 -2
- package/dist/{keet-identity-key-BjeN0q1Z.js → keet-identity-key-CRb0ko1T.js} +2 -2
- package/dist/{keet-identity-key-BjeN0q1Z.js.map → keet-identity-key-CRb0ko1T.js.map} +1 -1
- package/dist/{src-yaRa2Opt.js → src-DhOMxijH.js} +336 -104
- package/dist/src-DhOMxijH.js.map +1 -0
- package/dist/testing.js +3 -3
- package/dist/types/browser/src/engine/paymentAdapters/providers/testing.d.ts +2 -2
- package/dist/types/browser/src/proofs/testing.d.ts +5 -5
- package/dist/types/browser/src/shared/features.d.ts +15 -0
- package/dist/types/core/src/bytes.d.ts +6 -0
- package/dist/types/core/src/datalink.d.ts +1 -1
- package/dist/types/core/src/ghostlink.d.ts +25 -2
- package/dist/types/core/src/groupCommits.d.ts +8 -1
- package/dist/types/core/src/groupFiles.d.ts +9 -0
- package/dist/types/core/src/groupSession.d.ts +22 -0
- package/dist/types/core/src/identity.d.ts +2 -0
- package/dist/types/core/src/identityProofs.d.ts +9 -0
- package/dist/types/core/src/image.d.ts +13 -0
- package/dist/types/core/src/pkdns.d.ts +5 -1
- package/dist/types/core/src/services.d.ts +8 -0
- package/dist/types/sdk/src/fakes.d.ts +3 -1
- package/dist/{verify-BfFDG-pJ.js → verify-J0ShO67L.js} +2 -2
- package/dist/{verify-BfFDG-pJ.js.map → verify-J0ShO67L.js.map} +1 -1
- package/package.json +1 -1
- package/dist/fakes-MnrUkwEP.js.map +0 -1
- package/dist/src-yaRa2Opt.js.map +0 -1
package/dist/testing.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Vi as isBitcoinAddress,
|
|
1
|
+
import { Vi as isBitcoinAddress, dx as createIdentity, fa as decodeBolt11, hu as emptyIdentityLedger, pu as IdentityExchange, ru as IDENTITY_MAX_EVIDENCE, vu as identityStatement, xu as newIdentityBinding } from "./src-DhOMxijH.js";
|
|
2
2
|
import { l as providerDescriptorProblems, o as isNothingSpentError } from "./types-DvtCy3WB.js";
|
|
3
|
-
import { i as verifyIdentity, r as descriptorProblems } from "./verify-
|
|
4
|
-
import { _ as fakeAddress, a as fakeAccount, b as fakeOnchain, c as fakeKeySign, d as fakeRecord, f as fakeRecordText, g as TEST_PROVIDERS_FLAG, h as FakeOnchainProvider, i as TEST_IDENTITIES_FLAG, l as fakeKeySubject, m as FakeLightningProvider, n as FAKE_ISSUER, o as fakeAccountToken, p as testIdentitiesEnabled, r as FAKE_RECORD_HOST, s as fakeKey, t as FAKE_IDENTITY_PROVIDERS, u as fakeKeyring, v as fakeInvoice, x as testProvidersEnabled, y as fakeLightning } from "./fakes-
|
|
3
|
+
import { i as verifyIdentity, r as descriptorProblems } from "./verify-J0ShO67L.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-BGm8YDy-.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;
|
|
@@ -2,8 +2,8 @@ import type { InvoiceStatus, LightningInvoice, LightningPayResult, LightningPaym
|
|
|
2
2
|
import type { OnchainBalance, OnchainPrepared, OnchainProvider, OnchainProviderDescriptor, OnchainSendRequest, OnchainTx, OnchainTxStatus } from "./onchain.js";
|
|
3
3
|
/**
|
|
4
4
|
* Fake providers, for unit tests and e2e: they hold regtest "sats" in memory, so they only ever show up in
|
|
5
|
-
* the Testnet mode, and only
|
|
6
|
-
* to the registry itself). No network, no money.
|
|
5
|
+
* the Testnet mode, and only in a dev or e2e build (`testBuild`) that has `localStorage["ghostly-test-providers"]
|
|
6
|
+
* === "1"` (or a test passes them to the registry itself); a release build ignores the key. No network, no money.
|
|
7
7
|
*
|
|
8
8
|
* `behaviour` drives the outcome of a spend:
|
|
9
9
|
* - settle: invoices are paid by themselves after `settleMs`; payments and broadcasts succeed.
|
|
@@ -2,7 +2,8 @@ import { type IdentityStatement } from "../../../core/src/index.js";
|
|
|
2
2
|
import type { IdentityProofProvider } from "./contract.js";
|
|
3
3
|
/**
|
|
4
4
|
* Fake identity providers, for unit tests and e2e. No network, no real accounts. They are in the
|
|
5
|
-
* registry only
|
|
5
|
+
* registry only in a dev or e2e build (`testBuild`) that has `localStorage["ghostly-test-identities"] === "1"`
|
|
6
|
+
* (or a test passes them itself); a release build ignores the key.
|
|
6
7
|
*
|
|
7
8
|
* - fake-key self-custodied: an Ed25519 key held by a fake in-app signer, or signed "outside" and pasted.
|
|
8
9
|
* - fake-account provider-attested: a fake issuer signs a token whose nonce is the statement id (like OIDC).
|
|
@@ -10,12 +11,11 @@ import type { IdentityProofProvider } from "./contract.js";
|
|
|
10
11
|
*/
|
|
11
12
|
export declare const TEST_IDENTITIES_FLAG = "ghostly-test-identities";
|
|
12
13
|
export declare const testIdentitiesEnabled: () => boolean;
|
|
13
|
-
/** The key behind the fake in-app signer. Tests may replace it. */
|
|
14
14
|
export declare const fakeKeyring: {
|
|
15
|
-
seed: Uint8Array
|
|
15
|
+
seed: Uint8Array;
|
|
16
16
|
};
|
|
17
|
-
export declare const fakeKeySubject: (seed?: Uint8Array<ArrayBufferLike>
|
|
18
|
-
export declare const fakeKeySign: (statement: IdentityStatement, seed?: Uint8Array<ArrayBufferLike>
|
|
17
|
+
export declare const fakeKeySubject: (seed?: Uint8Array<ArrayBufferLike>) => string;
|
|
18
|
+
export declare const fakeKeySign: (statement: IdentityStatement, seed?: Uint8Array<ArrayBufferLike>) => {
|
|
19
19
|
sig: string;
|
|
20
20
|
};
|
|
21
21
|
export interface FakeKeyEvidence {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Release policy: external identity experiments are retained for future work,
|
|
2
|
+
* but must not advertise capabilities, start network lookups, or expose cached
|
|
3
|
+
* external profiles. This does not gate Ghostly participation authentication. */
|
|
4
|
+
export declare const EXTERNAL_IDENTITIES_ENABLED: boolean;
|
|
5
|
+
/** Mini-apps (WISP 1200): `apps/1` on paired sessions and the engine's `app*` calls. On from release 1.2 (a version
|
|
6
|
+
* before 1.2.0 is never cut with it on: `RELEASE_GUARDS` in tools/scripts/changes.mjs). Off, nothing is offered to
|
|
7
|
+
* contacts and every call is refused; a host that runs no apps pins its engine off (`NodeOptions.apps`). */
|
|
8
|
+
export declare const APPS_ENABLED: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* A build that may be put into test mode: a development build (`import.meta.env.DEV`, which vitest also sets) or the
|
|
11
|
+
* e2e suite's build (`VITE_APPS_TEST`, fixed when the build is made, as the mini-app switch is). A release build is
|
|
12
|
+
* neither: Vite folds this to `false` there, so the storage flags the test fakes answer to are ignored. The fakes
|
|
13
|
+
* themselves are still in the bundle (the registries import them); plugins may still pass fakes to the registry.
|
|
14
|
+
*/
|
|
15
|
+
export declare const testBuild: () => boolean;
|
|
@@ -8,4 +8,10 @@ export declare function toBase64Url(bytes: Uint8Array): string;
|
|
|
8
8
|
export declare function fromBase64Url(str: string): Uint8Array;
|
|
9
9
|
export declare function toZ32(bytes: Uint8Array): string;
|
|
10
10
|
export declare function fromZ32(str: string): Uint8Array;
|
|
11
|
+
/**
|
|
12
|
+
* A 32-byte key written as the one z-base-32 spelling `toZ32` produces: 52 characters that decode to 32 bytes and
|
|
13
|
+
* encode back to the same string. The last character carries four zero padding bits, so each key has exactly one
|
|
14
|
+
* spelling and keys may be compared as strings (WISP 02). Any other spelling is not a key here.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isZ32Key(value: unknown): value is string;
|
|
11
17
|
export declare function randomBytes(length: number): Uint8Array;
|
|
@@ -71,7 +71,7 @@ export declare const CONNECT_TIMEOUT_MS = 90000;
|
|
|
71
71
|
* rather than 2 s (calls bug hunt, 2026-10-12).
|
|
72
72
|
*/
|
|
73
73
|
export declare const OFFER_HOST_GATHER_MS = 2000;
|
|
74
|
-
/** The data link keeps collecting this long after the candidate it waited for came (a call
|
|
74
|
+
/** The data link keeps collecting this long after the candidate it waited for came (a call too). */
|
|
75
75
|
export declare const DATA_SETTLE_MS = 150;
|
|
76
76
|
/**
|
|
77
77
|
* A connection with no candidate at all by then has stalled: Chromium, rarely and under load, gathers none, and an
|
|
@@ -693,6 +693,13 @@ export declare class GhostLink {
|
|
|
693
693
|
/** Edit frames the contact may send per window; the rest go unconfirmed and come again. */
|
|
694
694
|
private readonly editsReceived;
|
|
695
695
|
private readonly wakeReceived;
|
|
696
|
+
/**
|
|
697
|
+
* The contact's name and picture, each saved when it changes: said once a session and when changed, so a handful a
|
|
698
|
+
* minute each. Past that only the newest waits, read once the window has room again.
|
|
699
|
+
*/
|
|
700
|
+
private readonly peerSaid;
|
|
701
|
+
/** Identity-proof frames the contact may send per window; the rest are dropped before they are read. */
|
|
702
|
+
private readonly identityReceived;
|
|
696
703
|
private livenessTimer;
|
|
697
704
|
private peerAnswersPings;
|
|
698
705
|
/** When the ping awaiting its pong went, and the round trip last measured on this session. */
|
|
@@ -1048,8 +1055,9 @@ export declare class GhostLink {
|
|
|
1048
1055
|
canYieldEndpoint(transport: PairedTransport, idleMs: number): boolean;
|
|
1049
1056
|
/**
|
|
1050
1057
|
* Ends the idle live session on this transport and lets its listener go, for a chat in use that found every one
|
|
1051
|
-
* taken. The contact hears a goodbye
|
|
1052
|
-
*
|
|
1058
|
+
* taken. The contact hears a goodbye that says so (`yield`, `peerYielded`), rather than finding out when its pings go
|
|
1059
|
+
* unanswered, and does not watch for this app as for one that quit; the record then lists the transport undescribed,
|
|
1060
|
+
* so it stops dialling here. The chat goes on over the DHT (or WebRTC),
|
|
1053
1061
|
* and takes a listener again the same way once it is in use. False when the session may not end (see above).
|
|
1054
1062
|
*/
|
|
1055
1063
|
yieldEndpoint(transport: PairedTransport, idleMs: number): Promise<boolean>;
|
|
@@ -1565,6 +1573,14 @@ export declare class GhostLink {
|
|
|
1565
1573
|
* packet shows it back, the other looks fast for its dial or offer.
|
|
1566
1574
|
*/
|
|
1567
1575
|
private peerDeparted;
|
|
1576
|
+
/**
|
|
1577
|
+
* The contact gave this session's listener up to another chat (`yieldEndpoint`): its app is still there, and its
|
|
1578
|
+
* record now lists the transport undescribed, so there is nothing to dial and no return to watch for. The session
|
|
1579
|
+
* ends now, and the chat reads the contact at its own pace; the contact dials once it takes a listener back. Taken
|
|
1580
|
+
* as a goodbye, it was watched as an app that quit: 89 reads of its key in the 2 minutes after a yield on the
|
|
1581
|
+
* Desktop, against 6 at the background pace (bug hunt, 2026-10-15).
|
|
1582
|
+
*/
|
|
1583
|
+
private peerYielded;
|
|
1568
1584
|
/**
|
|
1569
1585
|
* A packet of the contact's not seen before, fresh, while nothing is live, soon after a live session ended: it is back
|
|
1570
1586
|
* (its app restarted), so the wait that the attempts since built up is over, and the next dial goes now. Once per
|
|
@@ -1597,6 +1613,13 @@ export declare class GhostLink {
|
|
|
1597
1613
|
* knocks on the contact's other transports as its offer goes out, which reaches the contact at once.
|
|
1598
1614
|
*/
|
|
1599
1615
|
private resumeAfterAbsence;
|
|
1616
|
+
/**
|
|
1617
|
+
* A name or picture the contact said, once it is one (reading it costs little; saving it is what counts): past the
|
|
1618
|
+
* window the newest waits for room on this session, so the last word still counts.
|
|
1619
|
+
*/
|
|
1620
|
+
private peerSays;
|
|
1621
|
+
/** What the contact said of itself and was still waiting goes with the session: the next one says it again. */
|
|
1622
|
+
private dropPeerSaid;
|
|
1600
1623
|
/** A ping on the session right after a wake, with `PONG_WAIT_MS` for its answer: none, and the session is dead. */
|
|
1601
1624
|
private probeAfterWake;
|
|
1602
1625
|
private detach;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isZ32Key } from "./bytes.js";
|
|
1
2
|
/**
|
|
2
3
|
* Membership of a `group-mesh/1` group is a chain of signed commits. Each
|
|
3
4
|
* commit carries the whole roster after it, so any member can name the roster
|
|
@@ -51,7 +52,13 @@ export declare const GROUP_MEMBER_CAP: {
|
|
|
51
52
|
export declare const GROUP_VERSION_LARGE = 3;
|
|
52
53
|
export declare const MAX_GROUP_CHAIN = 1024;
|
|
53
54
|
export declare const GROUP_ID: RegExp;
|
|
54
|
-
|
|
55
|
+
/**
|
|
56
|
+
* A member's key, in its one canonical spelling (`isZ32Key`): a roster names members by string, so a key respelled in
|
|
57
|
+
* its last character would be a second member for one key, and `publicKeyFromZ32` would throw on it past this check.
|
|
58
|
+
*/
|
|
59
|
+
export declare const MEMBER_KEY: {
|
|
60
|
+
test: typeof isZ32Key;
|
|
61
|
+
};
|
|
55
62
|
export declare function commitHash(commit: Omit<GroupCommit, "sig">): string;
|
|
56
63
|
/** What the confirmation tag covers: the commit with an empty tag. */
|
|
57
64
|
export declare function commitUntaggedHash(commit: Omit<GroupCommit, "sig" | "c">): string;
|
|
@@ -17,6 +17,10 @@ export declare const GROUP_FILE_LIMITS: {
|
|
|
17
17
|
readonly serveBytesPerDay: number;
|
|
18
18
|
/** Transfers a holder serves at once, all groups together. */
|
|
19
19
|
readonly serveAtOnce: 3;
|
|
20
|
+
/** Bytes a served transfer gets confirmed (or the rest of its file) for it to count as moving in `wantWaitMs`. */
|
|
21
|
+
readonly serveMoveBytes: number;
|
|
22
|
+
/** How long a served transfer keeps its place while all are taken and another member asks: past it, the place is theirs. */
|
|
23
|
+
readonly servePlaceMs: number;
|
|
20
24
|
/** File announcements a member sends to one group in a minute. */
|
|
21
25
|
readonly announcePerMinute: 8;
|
|
22
26
|
/** File announcements of one member of a group fetched by themselves in `announceWindowMs`; past it, kept for a Download. */
|
|
@@ -53,6 +57,11 @@ export declare const GROUP_FILE_LIMITS: {
|
|
|
53
57
|
/** File sessions opening at once, and open at once, all groups together. */
|
|
54
58
|
readonly sessionsOpening: 2;
|
|
55
59
|
readonly sessionsOpen: 4;
|
|
60
|
+
/**
|
|
61
|
+
* What a transfer must bring in `wantWaitMs` (or the rest of its file, when less) to count as moving: a holder that
|
|
62
|
+
* sends a few bytes at a time is left as one that stalls.
|
|
63
|
+
*/
|
|
64
|
+
readonly wantMoveBytes: number;
|
|
56
65
|
/** The longest file name and type kept from a description. */
|
|
57
66
|
readonly nameChars: 255;
|
|
58
67
|
readonly mimeChars: 255;
|
|
@@ -89,6 +89,9 @@ export declare const GROUP_READ_NOTE: string;
|
|
|
89
89
|
* of its own; the text is the caption, or a line an older app shows instead. `xs` covers it after `sc`, before `o`.
|
|
90
90
|
* `o`: where a message said again under a later epoch was first said (WISP 902 § Catch-up, "Frames said again"): that
|
|
91
91
|
* frame's epoch and sequence, in the clear like the header. `xs` covers it last, only when there is one.
|
|
92
|
+
* `nk`: the name the author's app says (WISP 902 § Messages, "The author's name"), sealed in a box of its own, and `ns`
|
|
93
|
+
* the author's signature over that box and the header. Outside `xs`: a member on an app from before that hands the frame
|
|
94
|
+
* on drops both, and the copy stays whole.
|
|
92
95
|
*/
|
|
93
96
|
export interface GroupMessageFrame {
|
|
94
97
|
t: "group-msg";
|
|
@@ -122,6 +125,11 @@ export interface GroupMessageFrame {
|
|
|
122
125
|
n: number;
|
|
123
126
|
};
|
|
124
127
|
xs?: string;
|
|
128
|
+
nk?: {
|
|
129
|
+
n: string;
|
|
130
|
+
c: string;
|
|
131
|
+
};
|
|
132
|
+
ns?: string;
|
|
125
133
|
}
|
|
126
134
|
/**
|
|
127
135
|
* An edit of message `<s>:<e>:<n>` by its author (WISP 902 § Edits): edit number `v`, the new text (and its mentions)
|
|
@@ -324,6 +332,11 @@ export interface GroupSessionHooks {
|
|
|
324
332
|
metaChanged?(by: string | undefined, change: GroupMetaChange, at: number): void;
|
|
325
333
|
/** The clock the limits read (the engine's, or a simulation's); the wall clock when absent. */
|
|
326
334
|
clock?(): number;
|
|
335
|
+
/**
|
|
336
|
+
* The name my app says to the group's members, sealed in each message I write (`nk`): past 16 members, most never
|
|
337
|
+
* hold an edge with me to hear it there. None when the person shares no name.
|
|
338
|
+
*/
|
|
339
|
+
nick?(): string | undefined;
|
|
327
340
|
/**
|
|
328
341
|
* The lowest sequence number this member sends at, in any epoch (WISP 06 § Raised counters): 0 for a profile that
|
|
329
342
|
* never took over or was never restored. A copy of a profile started from older state sends above every number the
|
|
@@ -395,6 +408,8 @@ export declare class GroupSession {
|
|
|
395
408
|
private asked;
|
|
396
409
|
/** The signed leave of each member I last passed on, kept for an admin that was away (`byesHeld`). In memory only. */
|
|
397
410
|
private byesPassed;
|
|
411
|
+
/** Member → when the name I hold for it was said: its message's time, or the moment an edge said it (`heardName`). In memory only. */
|
|
412
|
+
private readonly nickAt;
|
|
398
413
|
private queue;
|
|
399
414
|
/** One metadata frame that names a commit or an epoch I do not have yet: tried again when the chain moves. */
|
|
400
415
|
private pendingMeta;
|
|
@@ -692,6 +707,13 @@ export declare class GroupSession {
|
|
|
692
707
|
private receiveEdit;
|
|
693
708
|
private parkEdit;
|
|
694
709
|
private wholeSigned;
|
|
710
|
+
/**
|
|
711
|
+
* The author's name in a message (`nk`), when the author's signature over it (`ns`) holds: any copy, handed on or
|
|
712
|
+
* not, whole or not, since a member handing it on can only drop it. Taken only from a message newer than the one it
|
|
713
|
+
* last came in, or than the moment an edge last said it (`setNick`), so a catch-up's older pages never bring back a
|
|
714
|
+
* name the member changed since. Whether the name I hold changed.
|
|
715
|
+
*/
|
|
716
|
+
private heardName;
|
|
695
717
|
private openMentions;
|
|
696
718
|
/** A message's status card; a box that does not open, or a card that does not hold, is no card: the text shows. */
|
|
697
719
|
private openCard;
|
|
@@ -9,6 +9,8 @@ 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. */
|
|
13
|
+
export declare const IDENTITY_MEMO_SIZE = 1024;
|
|
12
14
|
export declare function identityFromSeed(seed: Uint8Array): Identity;
|
|
13
15
|
export declare function identityFromSeedB64(seedB64: string): Identity;
|
|
14
16
|
export declare function createIdentity(): Identity;
|
|
@@ -26,6 +26,15 @@ export declare const IDENTITY_CHALLENGE_WINDOW = 300;
|
|
|
26
26
|
export declare const IDENTITY_MAX_EVIDENCE: number;
|
|
27
27
|
/** A whole `idp-*` frame, serialized. */
|
|
28
28
|
export declare const IDENTITY_MAX_FRAME: number;
|
|
29
|
+
/**
|
|
30
|
+
* Proofs a verifier keeps from one contact. A newer proof of the same identity replaces the older one, and one no longer
|
|
31
|
+
* standing (withdrawn, revoked, expired) gives its place to a new one; past that a presentation is refused before it is
|
|
32
|
+
* checked, so a contact cannot make this side store, re-send to its pages and look up its proofs without end.
|
|
33
|
+
*/
|
|
34
|
+
export declare const IDENTITY_MAX_RECEIVED = 16;
|
|
35
|
+
/** `idp-*` frames a paired session reads from the contact per `IDENTITY_FRAME_WINDOW_MS`; the rest are dropped unread. */
|
|
36
|
+
export declare const IDENTITY_FRAME_LIMIT = 40;
|
|
37
|
+
export declare const IDENTITY_FRAME_WINDOW_MS = 60000;
|
|
29
38
|
export declare const IDENTITY_PROVIDER_ID: RegExp;
|
|
30
39
|
/** Printable ASCII without spaces, so the statement can be built but never needs parsing. */
|
|
31
40
|
export declare const IDENTITY_SUBJECT: RegExp;
|
|
@@ -16,7 +16,20 @@ export declare const IMAGE_LIMITS: {
|
|
|
16
16
|
readonly maxEdge: 65535;
|
|
17
17
|
/** How much of a file is read for its size: past a JPEG's EXIF, thumbnails and colour profile. */
|
|
18
18
|
readonly headBytes: number;
|
|
19
|
+
/**
|
|
20
|
+
* The most pixels a picture drawn in a chat may have: a 50-megapixel phone photo (8160 × 6120), about 200 MB once
|
|
21
|
+
* decoded. A few kilobytes can say far more (a PNG of 23000 × 23000 is 64 KB and 2 GB decoded): past this a picture
|
|
22
|
+
* is kept and saved, not drawn.
|
|
23
|
+
*/
|
|
24
|
+
readonly previewPixels: 50000000;
|
|
25
|
+
/** The longest side a picture drawn in a chat may have: a wide panorama. */
|
|
26
|
+
readonly previewEdge: 16384;
|
|
19
27
|
};
|
|
28
|
+
/**
|
|
29
|
+
* Whether a picture of this size, read from its own bytes (never from what its sender said), may be drawn: undefined
|
|
30
|
+
* (its bytes do not say) may not either, as what draws it would find its size only by decoding it.
|
|
31
|
+
*/
|
|
32
|
+
export declare function previewable(size: ImageMeta | undefined): boolean;
|
|
20
33
|
/** Whether a file is a picture, by its type. */
|
|
21
34
|
export declare function isImageMime(mime: string): boolean;
|
|
22
35
|
/** A peer's `image` description, or undefined when it is not one. It never refuses the file. */
|
|
@@ -9,7 +9,11 @@ export interface SvcbRecord {
|
|
|
9
9
|
}
|
|
10
10
|
/** Every SVCB and HTTPS record of a DNS packet, in packet order. Throws on a malformed one. */
|
|
11
11
|
export declare function decodeSvcbRecords(dnsPacket: Uint8Array): SvcbRecord[];
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* The homeserver a Pubky key's packet names: the z-base-32 key its `_pubky` record points at, or undefined. The target
|
|
14
|
+
* is read next as a key (`pubkyRecords` checks the homeserver's packet against it), so only a canonical one names a
|
|
15
|
+
* homeserver; a respelled one is none, not a lookup that fails as "no records".
|
|
16
|
+
*/
|
|
13
17
|
export declare function pubkyHomeserverOf(dnsPacket: Uint8Array, userZ32: string): string | undefined;
|
|
14
18
|
/** Where a homeserver answers browsers: a public host name and, when its record says so, a port. */
|
|
15
19
|
export interface HomeserverEndpoint {
|
|
@@ -14,6 +14,14 @@ export declare const MAX_SERVICES = 16;
|
|
|
14
14
|
/** What a peer that predates `_svc` offers implicitly. */
|
|
15
15
|
export declare const LEGACY_SERVICES: ServiceAd[];
|
|
16
16
|
export declare function isValidServiceId(id: string): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* The label that makes the origin a contact's app opens in this side's own (WISP 04): derived from the key this
|
|
19
|
+
* profile holds for the chat with that contact. Another profile on the device, a profile after "Clear all data", or
|
|
20
|
+
* one made again after a delete has another chat key, so another origin, and never finds the storage, cookies or
|
|
21
|
+
* session the app kept here. The contact already knows that key, so the label tells it nothing new.
|
|
22
|
+
*/
|
|
23
|
+
export declare function viewerTag(myPubKeyZ32: string): string;
|
|
24
|
+
export declare function isViewerTag(tag: string): boolean;
|
|
17
25
|
export declare function serviceIdFromName(name: string, taken?: Iterable<string>): string;
|
|
18
26
|
interface WireService {
|
|
19
27
|
i: string;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @ghostlytools/sdk/fakes: the fake adapters the app itself tests with, usable at run time (no vitest):
|
|
3
|
-
* in-memory regtest sats and test identities that hold nothing and reach nothing.
|
|
3
|
+
* in-memory regtest sats and test identities that hold nothing and reach nothing. `testProvidersEnabled` and
|
|
4
|
+
* `testIdentitiesEnabled` are the app's own switches, folded to false when this package is built: a plugin that
|
|
5
|
+
* wants the fakes in the app registers them itself.
|
|
4
6
|
*/
|
|
5
7
|
export { FakeLightningProvider, FakeOnchainProvider, fakeInvoice, fakeAddress, fakeLightning, fakeOnchain, TEST_PROVIDERS_FLAG, testProvidersEnabled, type FakeBehaviour, } from "../../browser/src/engine/paymentAdapters/providers/testing.js";
|
|
6
8
|
export { fakeKey, fakeAccount, fakeRecord, FAKE_IDENTITY_PROVIDERS, fakeKeyring, fakeKeySubject, fakeKeySign, fakeAccountToken, fakeRecordText, FAKE_ISSUER, FAKE_RECORD_HOST, TEST_IDENTITIES_FLAG, testIdentitiesEnabled, type FakeKeyEvidence, type FakeAccountEvidence, } from "../../browser/src/proofs/testing.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { mu as boundVerifiedIdentity } from "./src-DhOMxijH.js";
|
|
2
2
|
//#region ../browser/src/proofs/verify.ts
|
|
3
3
|
var DAY = 86400;
|
|
4
4
|
/**
|
|
@@ -103,4 +103,4 @@ function boundedIdentityFetch(options = { online: () => true }) {
|
|
|
103
103
|
//#endregion
|
|
104
104
|
export { verifyIdentity as i, boundedIdentityFetch as n, descriptorProblems as r, availableSigners as t };
|
|
105
105
|
|
|
106
|
-
//# sourceMappingURL=verify-
|
|
106
|
+
//# sourceMappingURL=verify-J0ShO67L.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify-
|
|
1
|
+
{"version":3,"file":"verify-J0ShO67L.js","names":[],"sources":["../../browser/src/proofs/verify.ts"],"sourcesContent":["import { boundVerifiedIdentity, IDENTITY_MAX_EVIDENCE, IDENTITY_MAX_VALIDITY, type IdentityStatement, type VerifiedIdentity } from \"@ghostly/core\";\nimport type { IdentityFetch, IdentityProofProvider, IdentitySigner, VerifyContext } from \"./contract\";\n\nconst DAY = 86_400;\n\n/**\n * The checks every proof goes through, whatever its provider: known provider, validity within the\n * provider's limit, bounded evidence, strict parsing, the provider's own check, and the category rule\n * (a self-custodied proof proves exactly the subject it names; an attested one says who attests it).\n * The engine verifies a contact's proof, and the person's own proof before saving it, only through this.\n */\nexport async function verifyIdentity(providers: readonly IdentityProofProvider[], statement: IdentityStatement, evidence: unknown, ctx: VerifyContext): Promise<VerifiedIdentity> {\n const { binding } = statement;\n const provider = providers.find(p => p.id === binding.provider);\n if (!provider) throw new Error(\"This app cannot verify this kind of identity\");\n if (binding.expiresAt - binding.issuedAt > Math.min(provider.validity.maxDays * DAY, IDENTITY_MAX_VALIDITY)) throw new Error(\"The proof lasts longer than this kind of identity allows\");\n if (JSON.stringify(evidence ?? null).length > IDENTITY_MAX_EVIDENCE) throw new Error(\"Evidence too large\");\n const parsed = provider.parseEvidence(evidence);\n const verified = boundVerifiedIdentity(await provider.verify(statement, parsed, ctx));\n if (provider.category === \"self-custodied\" && verified.subject !== binding.subject) throw new Error(\"The evidence is for another identity\");\n if (provider.category === \"provider-attested\" && !verified.attester) throw new Error(\"The evidence does not say who attests it\");\n return verified;\n}\n\n/** Problems with a provider's descriptor, empty when it is well-formed. The registry and the contract suite use it. */\nexport function descriptorProblems(p: IdentityProofProvider): string[] {\n const problems: string[] = [];\n if (!/^[a-z][a-z0-9-]{0,31}$/.test(p.id)) problems.push(\"id must match ^[a-z][a-z0-9-]{0,31}$\");\n if (!p.label?.trim()) problems.push(\"label is empty\");\n if (!p.description?.trim()) problems.push(\"description is empty\");\n if (!p.privacy?.trim()) problems.push(\"privacy is empty: say what verify contacts\");\n if (p.category !== \"self-custodied\" && p.category !== \"provider-attested\") problems.push(\"category is unknown\");\n if (!p.platforms.length) problems.push(\"no platforms\");\n const { defaultDays, maxDays } = p.validity;\n if (!(Number.isInteger(defaultDays) && Number.isInteger(maxDays) && defaultDays >= 1 && defaultDays <= maxDays && maxDays * DAY <= IDENTITY_MAX_VALIDITY)) problems.push(\"validity must be whole days, 1 ≤ default ≤ max ≤ 400\");\n if (p.recheck && !(Number.isInteger(p.recheck.afterSeconds) && p.recheck.afterSeconds >= 60)) problems.push(\"recheck.afterSeconds must be at least 60\");\n if (!p.signers.length) problems.push(\"no signers\");\n const ids = p.signers.map(s => s.id);\n if (new Set(ids).size !== ids.length) problems.push(\"signer ids are not unique\");\n for (const s of p.signers as readonly IdentitySigner<unknown>[]) {\n if (![\"in-app\", \"external-tool\", \"redirect\", \"publish\"].includes(s.kind)) problems.push(`signer ${s.id} has an unknown kind`);\n if (s.kind === \"in-app\" && typeof s.run !== \"function\") problems.push(`signer ${s.id} has no run()`);\n if (s.kind === \"external-tool\" && (typeof s.instructions !== \"function\" || typeof s.parse !== \"function\")) problems.push(`signer ${s.id} needs instructions() and parse()`);\n if (s.kind === \"redirect\" && typeof s.start !== \"function\") problems.push(`signer ${s.id} has no start()`);\n if (s.kind === \"publish\" && (typeof s.instructions !== \"function\" || typeof s.evidence !== \"function\")) problems.push(`signer ${s.id} needs instructions() and evidence()`);\n }\n return problems;\n}\n\n/** Signers of a provider that run on this platform and are available in this window. */\nexport function availableSigners<E>(p: IdentityProofProvider<E>, platform: IdentityProofProvider[\"platforms\"][number]): IdentitySigner<E>[] {\n return p.signers.filter(s => (s.platforms ?? p.platforms).includes(platform) && (s.available?.() ?? true));\n}\n\n/**\n * The engine's `ctx.fetch`: HTTPS GET only, no credentials or referrer, a time-out, a size cap,\n * redirects refused unless asked for.\n * `online` false refuses everything (the person turned the network off).\n */\nexport function boundedIdentityFetch(options: { online: () => boolean; timeoutMs?: number; fetcher?: typeof fetch } = { online: () => true }): IdentityFetch {\n return async (url, { headers, maxBytes = 64 * 1024, signal, redirect = \"error\" } = {}) => {\n if (!options.online()) throw new Error(\"Offline: this identity cannot be checked now\");\n const target = new URL(url);\n if (target.protocol !== \"https:\" || target.username || target.password) throw new Error(\"Identity checks use HTTPS only\");\n const timeout = AbortSignal.timeout(options.timeoutMs ?? 10_000);\n const response = await (options.fetcher ?? fetch)(target.href, {\n headers, signal: signal ? AbortSignal.any([signal, timeout]) : timeout,\n credentials: \"omit\", referrerPolicy: \"no-referrer\", cache: \"no-store\", redirect,\n });\n if (Number(response.headers.get(\"content-length\")) > maxBytes) throw new Error(\"Identity check response too large\");\n const reader = response.body?.getReader();\n const parts: Uint8Array[] = [];\n let length = 0;\n if (reader) {\n try {\n for (;;) {\n const { done, value } = await reader.read();\n if (done) break;\n length += value.length;\n if (length > maxBytes) throw new Error(\"Identity check response too large\");\n parts.push(value);\n }\n } finally { await reader.cancel().catch(() => {}); }\n }\n const bytes = new Uint8Array(length);\n let offset = 0;\n for (const part of parts) { bytes.set(part, offset); offset += part.length; }\n return { status: response.status, contentType: response.headers.get(\"content-type\") ?? \"\", text: new TextDecoder().decode(bytes), bytes };\n };\n}\n"],"mappings":";;AAGA,IAAM,MA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|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ghostlytools/sdk",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
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",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fakes-MnrUkwEP.js","names":["hex"],"sources":["../../browser/src/engine/paymentAdapters/providers/testing.ts","../../browser/src/proofs/testing.ts"],"sourcesContent":["import { sha256 } from \"@noble/hashes/sha2.js\";\nimport { bech32 } from \"@scure/base\";\nimport { decodeBolt11 } from \"@ghostly/core\";\nimport type { InvoiceStatus, LightningInvoice, LightningPayResult, LightningPaymentRef, LightningPaymentStatus, LightningProvider, LightningProviderDescriptor } from \"./lightning\";\nimport type { OnchainBalance, OnchainPrepared, OnchainProvider, OnchainProviderDescriptor, OnchainSendRequest, OnchainTx, OnchainTxStatus } from \"./onchain\";\nimport { NothingSpentError, type ProviderField, type ProviderSettings } from \"./types\";\n\n/**\n * Fake providers, for unit tests and e2e: they hold regtest \"sats\" in memory, so they only ever show up in\n * the Testnet mode, and only when `localStorage[\"ghostly-test-providers\"] === \"1\"` (or a test passes them\n * to the registry itself). No network, no money.\n *\n * `behaviour` drives the outcome of a spend:\n * - settle: invoices are paid by themselves after `settleMs`; payments and broadcasts succeed.\n * - refuse: a spend fails, provably before anything left (`NothingSpentError`).\n * - hang: a spend throws an unknown error, and the lookup later says it went through (a lost answer).\n */\nexport type FakeBehaviour = \"settle\" | \"refuse\" | \"hang\";\nexport const TEST_PROVIDERS_FLAG = \"ghostly-test-providers\";\n\nconst hex = (bytes: Uint8Array) => Array.from(bytes, (b) => b.toString(16).padStart(2, \"0\")).join(\"\");\nconst random = (n: number) => crypto.getRandomValues(new Uint8Array(n));\nconst uint = (value: number, length = 1) => {\n const out: number[] = [];\n for (let v = value; v > 0; v = Math.floor(v / 32)) out.unshift(v % 32);\n while (out.length < length) out.unshift(0);\n return out;\n};\n\n/** A BOLT 11 invoice on regtest with a real checksum and a blank signature: it decodes, nobody can pay it. */\nexport function fakeInvoice(amount: number, paymentHash: Uint8Array, memo = \"\", expirySeconds = 3600): string {\n const words = uint(Math.floor(Date.now() / 1000), 7);\n const field = (tag: number, data: number[]) => words.push(tag, data.length >> 5, data.length & 31, ...data);\n field(1, bech32.toWords(paymentHash));\n if (memo) field(13, bech32.toWords(new TextEncoder().encode(memo.slice(0, 100))));\n field(6, uint(expirySeconds));\n return bech32.encode(`lnbcrt${amount * 10}n`, [...words, ...new Array<number>(104).fill(0)], false);\n}\n\n/** A valid regtest P2WPKH address of nobody's. */\nexport const fakeAddress = () => bech32.encode(\"bcrt\", [0, ...bech32.toWords(random(20))]);\n\nconst FIELDS: ProviderField[] = [\n { name: \"alias\", label: \"Name\", kind: \"text\", optional: true, placeholder: \"Fake node\" },\n { name: \"token\", label: \"Access token\", kind: \"secret\", placeholder: \"anything\", help: \"Sealed like a real provider's secret; the fake only checks it is there.\" },\n { name: \"behaviour\", label: \"Spends\", kind: \"select\", optional: true, options: [{ value: \"settle\", label: \"Go through\" }, { value: \"refuse\", label: \"Are refused\" }, { value: \"hang\", label: \"Lose their answer\" }], defaults: { testnet: \"settle\" } },\n];\nconst validate = ({ secrets, config }: ProviderSettings) => {\n if (!secrets.token?.trim()) throw new Error(\"Enter an access token\");\n if (config.behaviour && ![\"settle\", \"refuse\", \"hang\"].includes(config.behaviour)) throw new Error(\"Unknown behaviour\");\n};\n\ninterface FakeOptions { alias?: string; behaviour?: FakeBehaviour; balance?: number; settleMs?: number; token?: string }\n\nexport class FakeLightningProvider implements LightningProvider {\n readonly capabilities = { receive: true, send: true, balance: true, lookup: true };\n readonly invoices = new Map<string, { invoice: LightningInvoice; paid: boolean }>();\n readonly payments = new Map<string, LightningPaymentStatus>();\n readonly paid: string[] = [];\n balance: number;\n behaviour: FakeBehaviour;\n closed = false;\n private timers: ReturnType<typeof setTimeout>[] = [];\n constructor(readonly options: FakeOptions = {}) { this.balance = options.balance ?? 100_000; this.behaviour = options.behaviour ?? \"settle\"; }\n async info() { return { network: \"regtest\" as const, alias: this.options.alias || \"Fake Lightning\", balance: this.balance }; }\n async createInvoice(amount: number, memo?: string): Promise<LightningInvoice> {\n const preimage = random(32), hash = sha256(preimage);\n const invoice: LightningInvoice = { invoice: fakeInvoice(amount, hash, memo), paymentHash: hex(hash), amount, expiresAt: Date.now() + 3600_000, ref: hex(preimage) };\n this.invoices.set(invoice.paymentHash, { invoice, paid: false });\n if (this.behaviour === \"settle\") this.timers.push(setTimeout(() => this.markPaid(invoice.paymentHash), this.options.settleMs ?? 1500));\n return invoice;\n }\n /** Someone paid this invoice. */\n markPaid(paymentHash: string) {\n const entry = this.invoices.get(paymentHash);\n if (!entry || entry.paid || this.closed) return;\n entry.paid = true; this.balance += entry.invoice.amount;\n }\n async invoiceStatus(invoice: LightningInvoice): Promise<InvoiceStatus> {\n const entry = this.invoices.get(invoice.paymentHash);\n if (entry?.paid) return { state: \"paid\", amount: entry.invoice.amount };\n return { state: invoice.expiresAt < Date.now() ? \"expired\" : \"open\" };\n }\n async estimateFee(_invoice: string, amount: number) { return Math.max(1, Math.ceil(amount / 100)); }\n async payInvoice(invoice: string, maxFee: number): Promise<LightningPayResult> {\n const decoded = decodeBolt11(invoice);\n if (!decoded?.paymentHash || decoded.amountSat === null) throw new NothingSpentError(\"Not an invoice this fake can pay\");\n const fee = Math.min(maxFee, Math.max(1, Math.ceil(decoded.amountSat / 100)));\n if (this.behaviour === \"refuse\") throw new NothingSpentError(\"No route (fake)\");\n if (this.balance < decoded.amountSat + fee) throw new NothingSpentError(\"Not enough sats in the fake wallet\");\n this.balance -= decoded.amountSat + fee;\n this.paid.push(decoded.paymentHash);\n this.payments.set(decoded.paymentHash, { state: \"paid\", fee, preimage: hex(random(32)) });\n if (this.behaviour === \"hang\") throw new Error(\"Connection lost (fake)\");\n return { state: \"paid\", fee, preimage: this.payments.get(decoded.paymentHash)!.preimage };\n }\n async paymentStatus(payment: LightningPaymentRef): Promise<LightningPaymentStatus> {\n return this.payments.get(payment.paymentHash) ?? { state: \"failed\" };\n }\n async close() { this.closed = true; for (const t of this.timers) clearTimeout(t); }\n}\n\nexport class FakeOnchainProvider implements OnchainProvider {\n readonly addresses: string[] = [];\n readonly broadcasts: string[] = [];\n readonly released: string[] = [];\n readonly txs = new Map<string, { prepared: OnchainPrepared; confirmations: number }>();\n confirmed: number;\n behaviour: FakeBehaviour;\n closed = false;\n constructor(readonly options: FakeOptions = {}) { this.confirmed = options.balance ?? 100_000; this.behaviour = options.behaviour ?? \"settle\"; }\n async info() { return { network: \"regtest\" as const, alias: this.options.alias || \"Fake Bitcoin wallet\" }; }\n async receiveAddress() { const address = fakeAddress(); this.addresses.push(address); return address; }\n async balance(): Promise<OnchainBalance> { return { confirmed: this.confirmed, unconfirmed: 0 }; }\n async prepareSend(request: OnchainSendRequest): Promise<OnchainPrepared> {\n const feeRate = request.feeRate ?? 2, fee = feeRate * 141;\n if (fee > request.feeCap) throw new Error(`The fee (${fee} sats) is above your limit`);\n if (this.confirmed < request.amount + fee) throw new Error(\"Not enough confirmed sats\");\n return { txid: hex(random(32)), address: request.address, amount: request.amount, fee, feeRate, signed: hex(random(64)) };\n }\n async broadcast(prepared: OnchainPrepared) {\n if (this.behaviour === \"refuse\") throw new NothingSpentError(\"Rejected by the node (fake)\");\n if (!this.txs.has(prepared.txid)) { this.confirmed -= prepared.amount + prepared.fee; this.txs.set(prepared.txid, { prepared, confirmations: 1 }); }\n this.broadcasts.push(prepared.txid);\n if (this.behaviour === \"hang\") throw new Error(\"Connection lost (fake)\");\n return prepared.txid;\n }\n async status(prepared: OnchainPrepared): Promise<OnchainTxStatus> {\n const tx = this.txs.get(prepared.txid);\n return tx ? { state: \"confirmed\", confirmations: tx.confirmations } : { state: \"missing\", confirmations: 0 };\n }\n async release(prepared: OnchainPrepared) { this.released.push(prepared.txid); }\n async history(limit: number): Promise<OnchainTx[]> {\n return [...this.txs.values()].reverse().slice(0, limit).map(({ prepared, confirmations }) => ({ txid: prepared.txid, amount: -prepared.amount, fee: prepared.fee, confirmations }));\n }\n async close() { this.closed = true; }\n}\n\nconst options = ({ config, secrets }: ProviderSettings): FakeOptions => ({ alias: config.alias, behaviour: (config.behaviour as FakeBehaviour) || \"settle\", token: secrets.token });\n\nexport const fakeLightning: LightningProviderDescriptor = {\n id: \"fake-lightning\",\n label: \"Fake Lightning (test)\",\n kind: \"lightning\",\n description: \"In-memory regtest node for tests. Holds nothing.\",\n networks: [\"regtest\"],\n platforms: [\"web\", \"extension\", \"desktop\"],\n fields: FIELDS,\n experimental: true,\n validate,\n async create(settings) { return new FakeLightningProvider(options(settings)); },\n};\n\nexport const fakeOnchain: OnchainProviderDescriptor = {\n id: \"fake-onchain\",\n label: \"Fake Bitcoin wallet (test)\",\n kind: \"onchain\",\n description: \"In-memory regtest wallet for tests. Holds nothing.\",\n networks: [\"regtest\"],\n platforms: [\"web\", \"extension\", \"desktop\"],\n fields: FIELDS,\n experimental: true,\n validate,\n async create(settings) { return new FakeOnchainProvider(options(settings)); },\n};\n\n/** Whether this browser asked for the fake providers (an e2e run sets it before the app starts). */\nexport function testProvidersEnabled(): boolean {\n try { return globalThis.localStorage?.getItem(TEST_PROVIDERS_FLAG) === \"1\"; } catch { return false; }\n}\n","import { ed25519 } from \"@noble/curves/ed25519.js\";\nimport { fromBase64Url, toBase64Url, utf8Decode, utf8Encode, type IdentityStatement } from \"@ghostly/core\";\nimport type { IdentityProofProvider } from \"./contract\";\n\n/**\n * Fake identity providers, for unit tests and e2e. No network, no real accounts. They are in the\n * registry only when `localStorage[\"ghostly-test-identities\"] === \"1\"` (or a test passes them itself).\n *\n * - fake-key self-custodied: an Ed25519 key held by a fake in-app signer, or signed \"outside\" and pasted.\n * - fake-account provider-attested: a fake issuer signs a token whose nonce is the statement id (like OIDC).\n * - fake-record self-custodied, published: a record the verifier fetches through `ctx.fetch` (like DNS).\n */\nexport const TEST_IDENTITIES_FLAG = \"ghostly-test-identities\";\nexport const testIdentitiesEnabled = () => { try { return globalThis.localStorage?.getItem(TEST_IDENTITIES_FLAG) === \"1\"; } catch { return false; } };\n\nconst HEX64 = /^[a-f0-9]{64}$/;\nconst hex = (b: Uint8Array) => Array.from(b, x => x.toString(16).padStart(2, \"0\")).join(\"\");\nconst unhex = (s: string) => Uint8Array.from(s.match(/../g)!, x => parseInt(x, 16));\nconst normalizeHexKey = (input: string) => { const v = input.trim().toLowerCase(); if (!HEX64.test(v)) throw new Error(\"Enter 64 hex characters\"); return v; };\nconst exactKeys = (raw: unknown, keys: string) => !!raw && typeof raw === \"object\" && !Array.isArray(raw) && Object.keys(raw).sort().join(\",\") === keys;\n\n/** The key behind the fake in-app signer. Tests may replace it. */\nexport const fakeKeyring = { seed: ed25519.utils.randomSecretKey() };\nexport const fakeKeySubject = (seed = fakeKeyring.seed) => hex(ed25519.getPublicKey(seed));\nexport const fakeKeySign = (statement: IdentityStatement, seed = fakeKeyring.seed) => ({ sig: toBase64Url(ed25519.sign(statement.bytes, seed)) });\n\nexport interface FakeKeyEvidence { sig: string }\nexport const fakeKey: IdentityProofProvider<FakeKeyEvidence> = {\n id: \"fake-key\", label: \"Test key\", category: \"self-custodied\",\n summary: \"Sign with the test key\", description: \"A test identity: an Ed25519 key held by this page. For tests only.\",\n platforms: [\"web\", \"extension\", \"desktop\"],\n subject: { label: \"Public key\", placeholder: \"64 hex characters\", normalize: normalizeHexKey, short: k => `${k.slice(0, 8)}…${k.slice(-4)}` },\n publicUri: k => `urn:ghostly-test:${k}`,\n validity: { defaultDays: 30, maxDays: 365 },\n privacy: \"Nothing: checked on this device.\",\n signers: [\n { id: \"fake-signer\", kind: \"in-app\", label: \"Test signer\", fields: [{ name: \"refuse\", label: \"Refuse\", kind: \"text\", optional: true }],\n run: async (ctx, work) => {\n ctx.signal.throwIfAborted();\n if (ctx.values.refuse) throw new Error(\"The test signer refused\");\n return work({ subject: async () => fakeKeySubject(), sign: async statement => fakeKeySign(statement) });\n } },\n { id: \"fake-tool\", kind: \"external-tool\", label: \"Sign outside Ghostly\",\n instructions: statement => ({ steps: [{ text: \"Sign this statement with your test key:\", copy: statement.text }], paste: { label: \"Signature (base64url)\" } }),\n parse: pasted => { const sig = pasted.trim(); if (!/^[A-Za-z0-9_-]{86}$/.test(sig)) throw new Error(\"That is not a test signature\"); return { sig }; } },\n ],\n parseEvidence(raw) {\n const e = raw as FakeKeyEvidence;\n if (!exactKeys(raw, \"sig\") || typeof e.sig !== \"string\" || !/^[A-Za-z0-9_-]{86}$/.test(e.sig)) throw new Error(\"Invalid test evidence\");\n return { sig: e.sig };\n },\n async verify(statement, evidence) {\n let ok: boolean;\n try { ok = ed25519.verify(fromBase64Url(evidence.sig), statement.bytes, unhex(statement.binding.subject)); } catch { ok = false; }\n if (!ok) throw new Error(\"Invalid test signature\");\n return { subject: statement.binding.subject, source: \"Test signature (Ed25519)\" };\n },\n};\n\n/** The fake issuer's key. Its public half is what fake-account trusts, like a provider's JWKS. */\nconst ISSUER_SEED = unhex(\"7a\".repeat(32));\nexport const FAKE_ISSUER = \"https://issuer.ghostly.test\";\nexport interface FakeAccountEvidence { token: string }\n/** What the fake login page signs: iss, sub, nonce (= statement id), iat. */\nexport function fakeAccountToken(statement: IdentityStatement, account = \"alice\", seed = ISSUER_SEED, iat = statement.binding.issuedAt): FakeAccountEvidence {\n const payload = toBase64Url(utf8Encode(JSON.stringify({ iss: FAKE_ISSUER, sub: account, nonce: statement.id, iat })));\n return { token: `${payload}.${toBase64Url(ed25519.sign(utf8Encode(payload), seed))}` };\n}\nexport const fakeAccount: IdentityProofProvider<FakeAccountEvidence> = {\n id: \"fake-account\", label: \"Test account\", category: \"provider-attested\",\n summary: \"Log in to the test issuer\", description: \"A test login provider that vouches for an account. For tests only.\",\n platforms: [\"web\", \"extension\", \"desktop\"],\n subject: { label: \"Provider\", options: [{ value: FAKE_ISSUER, label: \"Test issuer\" }],\n normalize: input => { if (input.trim() !== FAKE_ISSUER) throw new Error(\"Unknown test issuer\"); return FAKE_ISSUER; } },\n validity: { defaultDays: 30, maxDays: 90 },\n privacy: \"Nothing: the issuer's signature is checked on this device.\",\n signers: [{ id: \"fake-login\", kind: \"redirect\", label: \"Log in to the test issuer\",\n start: async (statement, ctx) => { ctx.signal.throwIfAborted(); return fakeAccountToken(statement, ctx.values.account || \"alice\"); } }],\n parseEvidence(raw) {\n const e = raw as FakeAccountEvidence;\n if (!exactKeys(raw, \"token\") || typeof e.token !== \"string\" || e.token.length > 2048 || !/^[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]{86}$/.test(e.token)) throw new Error(\"Invalid test token\");\n return { token: e.token };\n },\n async verify(statement, { token }) {\n const [payload, sig] = token.split(\".\");\n if (!ed25519.verify(fromBase64Url(sig), utf8Encode(payload), ed25519.getPublicKey(ISSUER_SEED))) throw new Error(\"Not signed by the test issuer\");\n const claims = JSON.parse(utf8Decode(fromBase64Url(payload))) as { iss: string; sub: string; nonce: string };\n if (claims.iss !== statement.binding.subject) throw new Error(\"Token from another issuer\");\n if (claims.nonce !== statement.id) throw new Error(\"Token for another statement\");\n if (typeof claims.sub !== \"string\" || !/^[a-z0-9]{1,64}$/.test(claims.sub)) throw new Error(\"Invalid account\");\n return { subject: `${claims.iss}#${claims.sub}`, attester: \"issuer.ghostly.test\", source: \"Token signed by the test issuer\",\n display: { name: claims.sub, source: \"Test issuer profile\", fetchedAt: statement.binding.issuedAt } };\n },\n};\n\n/** fake-record's records: subject → published text. The verifier reads `https://records.ghostly.test/<subject>`. */\nexport const FAKE_RECORD_HOST = \"https://records.ghostly.test/\";\nexport const fakeRecordText = (statement: IdentityStatement) => `ghostly-proof=${statement.id}`;\nexport const fakeRecord: IdentityProofProvider<Record<string, never>> = {\n id: \"fake-record\", label: \"Test record\", category: \"self-custodied\",\n summary: \"Publish a test record\", description: \"A test record published where the verifier looks it up, like DNS. For tests only.\",\n platforms: [\"web\", \"extension\", \"desktop\"],\n subject: { label: \"Name\", placeholder: \"alice\", normalize: input => { const v = input.trim().toLowerCase(); if (!/^[a-z0-9-]{1,63}$/.test(v)) throw new Error(\"Letters, digits and dashes\"); return v; } },\n validity: { defaultDays: 30, maxDays: 365 },\n recheck: { afterSeconds: 3600 },\n privacy: \"The verifier asks records.ghostly.test for the record: that server learns the name was checked.\",\n signers: [{ id: \"fake-publish\", kind: \"publish\", label: \"Publish a record\",\n instructions: statement => ({ steps: [{ text: `Publish this record for ${statement.binding.subject}:`, copy: fakeRecordText(statement) }] }),\n evidence: () => ({}) }],\n parseEvidence(raw) { if (!exactKeys(raw, \"\")) throw new Error(\"Invalid test evidence\"); return {}; },\n async verify(statement, _evidence, ctx) {\n const response = await ctx.fetch(`${FAKE_RECORD_HOST}${statement.binding.subject}`, { maxBytes: 4096, signal: ctx.signal });\n if (response.status !== 200 || !response.text.split(\"\\n\").includes(fakeRecordText(statement))) throw new Error(\"The record is not published\");\n return { subject: statement.binding.subject, source: \"Record published at records.ghostly.test\" };\n },\n};\n\nexport const FAKE_IDENTITY_PROVIDERS: readonly IdentityProofProvider[] = [fakeKey, fakeAccount, fakeRecord];\n"],"mappings":";;;;;;AAkBA,IAAa,sBAAsB;AAEnC,IAAMA,SAAO,UAAsB,MAAM,KAAK,QAAQ,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE;AACpG,IAAM,UAAU,MAAc,OAAO,gBAAgB,IAAI,WAAW,CAAC,CAAC;AACtE,IAAM,QAAQ,OAAe,SAAS,MAAM;CAC1C,MAAM,MAAgB,CAAC;CACvB,KAAK,IAAI,IAAI,OAAO,IAAI,GAAG,IAAI,KAAK,MAAM,IAAI,EAAE,GAAG,IAAI,QAAQ,IAAI,EAAE;CACrE,OAAO,IAAI,SAAS,QAAQ,IAAI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