@ghostlytools/sdk 0.0.0-stage → 1.2.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/README.md +13 -2
- package/dist/app.js +67 -0
- package/dist/app.js.map +1 -0
- package/dist/core.js +207 -0
- package/dist/core.js.map +1 -0
- package/dist/fakes-CBIuqo5e.js +536 -0
- package/dist/fakes-CBIuqo5e.js.map +1 -0
- package/dist/fakes.js +2 -0
- package/dist/index.js +179 -0
- package/dist/index.js.map +1 -0
- package/dist/keet-identity-key-BylxCPl4.js +76483 -0
- package/dist/keet-identity-key-BylxCPl4.js.map +1 -0
- package/dist/src-DCeLPsi-.js +31056 -0
- package/dist/src-DCeLPsi-.js.map +1 -0
- package/dist/testing.js +330 -0
- package/dist/testing.js.map +1 -0
- package/dist/types/browser/src/engine/paymentAdapters/providers/contractSuite.d.ts +41 -0
- package/dist/types/browser/src/engine/paymentAdapters/providers/lightning.d.ts +103 -0
- package/dist/types/browser/src/engine/paymentAdapters/providers/onchain.d.ts +88 -0
- package/dist/types/browser/src/engine/paymentAdapters/providers/testing.d.ts +89 -0
- package/dist/types/browser/src/engine/paymentAdapters/providers/types.d.ts +151 -0
- package/dist/types/browser/src/plugins/bundled.d.ts +8 -0
- package/dist/types/browser/src/plugins/registry.d.ts +57 -0
- package/dist/types/browser/src/proofs/contract.d.ts +262 -0
- package/dist/types/browser/src/proofs/contractSuite.d.ts +27 -0
- package/dist/types/browser/src/proofs/testing.d.ts +36 -0
- package/dist/types/browser/src/proofs/verify.d.ts +23 -0
- package/dist/types/browser/src/shared/mints.d.ts +50 -0
- package/dist/types/core/src/appBundle.d.ts +173 -0
- package/dist/types/core/src/appStatements.d.ts +142 -0
- package/dist/types/core/src/appStore.d.ts +133 -0
- package/dist/types/core/src/appUpdates.d.ts +88 -0
- package/dist/types/core/src/atprotoIdentity.d.ts +49 -0
- package/dist/types/core/src/atprotoRepo.d.ts +101 -0
- package/dist/types/core/src/avatar.d.ts +19 -0
- package/dist/types/core/src/bip322.d.ts +57 -0
- package/dist/types/core/src/bitcoinAddress.d.ts +5 -0
- package/dist/types/core/src/bitcoinMessage.d.ts +15 -0
- package/dist/types/core/src/bitcoinScript.d.ts +69 -0
- package/dist/types/core/src/bolt11.d.ts +30 -0
- package/dist/types/core/src/bytes.d.ts +11 -0
- package/dist/types/core/src/callSignal.d.ts +232 -0
- package/dist/types/core/src/canonicalJson.d.ts +22 -0
- package/dist/types/core/src/capsRecord.d.ts +234 -0
- package/dist/types/core/src/catchUp.d.ts +45 -0
- package/dist/types/core/src/chatFiles.d.ts +271 -0
- package/dist/types/core/src/clockWatch.d.ts +72 -0
- package/dist/types/core/src/communityRendezvous.d.ts +113 -0
- package/dist/types/core/src/crypto.d.ts +10 -0
- package/dist/types/core/src/datalink.d.ts +187 -0
- package/dist/types/core/src/deviceInvite.d.ts +51 -0
- package/dist/types/core/src/deviceLink.d.ts +70 -0
- package/dist/types/core/src/dhtDelivery.d.ts +403 -0
- package/dist/types/core/src/dhtFiles.d.ts +46 -0
- package/dist/types/core/src/did.d.ts +134 -0
- package/dist/types/core/src/didDht.d.ts +155 -0
- package/dist/types/core/src/directPath.d.ts +63 -0
- package/dist/types/core/src/dns.d.ts +41 -0
- package/dist/types/core/src/domainProofs.d.ts +88 -0
- package/dist/types/core/src/engineErrors.d.ts +90 -0
- package/dist/types/core/src/enroll.d.ts +98 -0
- package/dist/types/core/src/files.d.ts +73 -0
- package/dist/types/core/src/forwards.d.ts +12 -0
- package/dist/types/core/src/frames.d.ts +211 -0
- package/dist/types/core/src/ghostlink.d.ts +1510 -0
- package/dist/types/core/src/groupCommits.d.ts +103 -0
- package/dist/types/core/src/groupCommunity.d.ts +714 -0
- package/dist/types/core/src/groupCrypto.d.ts +60 -0
- package/dist/types/core/src/groupEdits.d.ts +67 -0
- package/dist/types/core/src/groupEntry.d.ts +61 -0
- package/dist/types/core/src/groupFiles.d.ts +106 -0
- package/dist/types/core/src/groupHubs.d.ts +61 -0
- package/dist/types/core/src/groupMentions.d.ts +27 -0
- package/dist/types/core/src/groupMeta.d.ts +162 -0
- package/dist/types/core/src/groupSession.d.ts +710 -0
- package/dist/types/core/src/groupSignals.d.ts +167 -0
- package/dist/types/core/src/groupTyping.d.ts +56 -0
- package/dist/types/core/src/groupWake.d.ts +68 -0
- package/dist/types/core/src/handoff.d.ts +255 -0
- package/dist/types/core/src/http.d.ts +125 -0
- package/dist/types/core/src/identity.d.ts +17 -0
- package/dist/types/core/src/identityProofs.d.ts +243 -0
- package/dist/types/core/src/identityTimeline.d.ts +72 -0
- package/dist/types/core/src/image.d.ts +33 -0
- package/dist/types/core/src/index.d.ts +100 -0
- package/dist/types/core/src/invite.d.ts +128 -0
- package/dist/types/core/src/link.d.ts +353 -0
- package/dist/types/core/src/linkPreview.d.ts +60 -0
- package/dist/types/core/src/linkTrace.d.ts +12 -0
- package/dist/types/core/src/lnurl.d.ts +99 -0
- package/dist/types/core/src/messageTime.d.ts +28 -0
- package/dist/types/core/src/miniApp.d.ts +141 -0
- package/dist/types/core/src/pairedApps.d.ts +151 -0
- package/dist/types/core/src/pairedCalls.d.ts +59 -0
- package/dist/types/core/src/pairedCapabilities.d.ts +101 -0
- package/dist/types/core/src/pairedEdits.d.ts +83 -0
- package/dist/types/core/src/pairedFiles.d.ts +30 -0
- package/dist/types/core/src/pairedHttp.d.ts +15 -0
- package/dist/types/core/src/pairedSession.d.ts +163 -0
- package/dist/types/core/src/pairedSignal.d.ts +17 -0
- package/dist/types/core/src/pairedTransports.d.ts +76 -0
- package/dist/types/core/src/pairedTyping.d.ts +130 -0
- package/dist/types/core/src/pairedWake.d.ts +109 -0
- package/dist/types/core/src/pairingProgress.d.ts +107 -0
- package/dist/types/core/src/paymentIntent.d.ts +111 -0
- package/dist/types/core/src/paymentUri.d.ts +34 -0
- package/dist/types/core/src/payments.d.ts +97 -0
- package/dist/types/core/src/peerProofs.d.ts +98 -0
- package/dist/types/core/src/pins.d.ts +73 -0
- package/dist/types/core/src/pkarr.d.ts +48 -0
- package/dist/types/core/src/pkdns.d.ts +35 -0
- package/dist/types/core/src/pubkyProofs.d.ts +25 -0
- package/dist/types/core/src/pubkyRing.d.ts +21 -0
- package/dist/types/core/src/reactions.d.ts +108 -0
- package/dist/types/core/src/records.d.ts +89 -0
- package/dist/types/core/src/relay.d.ts +437 -0
- package/dist/types/core/src/relayBreaker.d.ts +99 -0
- package/dist/types/core/src/replies.d.ts +41 -0
- package/dist/types/core/src/services.d.ts +35 -0
- package/dist/types/core/src/setUpdate.d.ts +53 -0
- package/dist/types/core/src/signal.d.ts +53 -0
- package/dist/types/core/src/signer.d.ts +13 -0
- package/dist/types/core/src/sparkAddress.d.ts +37 -0
- package/dist/types/core/src/sshsig.d.ts +74 -0
- package/dist/types/core/src/statusCards.d.ts +253 -0
- package/dist/types/core/src/storeForward.d.ts +144 -0
- package/dist/types/core/src/text.d.ts +20 -0
- package/dist/types/core/src/transport.d.ts +151 -0
- package/dist/types/core/src/transportSwitch.d.ts +160 -0
- package/dist/types/core/src/turnRead.d.ts +145 -0
- package/dist/types/core/src/turnRecord.d.ts +165 -0
- package/dist/types/core/src/version.d.ts +9 -0
- package/dist/types/core/src/video.d.ts +44 -0
- package/dist/types/core/src/voice.d.ts +88 -0
- package/dist/types/core/src/webPush.d.ts +58 -0
- package/dist/types/sdk/src/app.d.ts +23 -0
- package/dist/types/sdk/src/core.d.ts +7 -0
- package/dist/types/sdk/src/fakes.d.ts +6 -0
- package/dist/types/sdk/src/index.d.ts +26 -0
- package/dist/types/sdk/src/testing.d.ts +7 -0
- package/dist/types-DvtCy3WB.js +99 -0
- package/dist/types-DvtCy3WB.js.map +1 -0
- package/dist/verify-DBGw6wYt.js +106 -0
- package/dist/verify-DBGw6wYt.js.map +1 -0
- package/package.json +70 -4
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { type ChunkFrame, type FrameChannel, type HeaderList, type HttpRequestFrame, type HttpResponseFrame, type ResetFrame } from "./frames.js";
|
|
2
|
+
/**
|
|
3
|
+
* HTTP over the Ghostly data link (`ghostly-http/1`).
|
|
4
|
+
*
|
|
5
|
+
* The client names a service id and an origin-form path. The host owns the
|
|
6
|
+
* mapping from service id to a loopback target the user configured; nothing a
|
|
7
|
+
* remote peer sends can change where a request goes.
|
|
8
|
+
*/
|
|
9
|
+
export interface LocalTarget {
|
|
10
|
+
/** e.g. `http://localhost:3400` */
|
|
11
|
+
origin: string;
|
|
12
|
+
/** Path prefix without trailing slash, `""` for the root. */
|
|
13
|
+
basePath: string;
|
|
14
|
+
}
|
|
15
|
+
/** Accepts `localhost:3400`, `http://127.0.0.1:8080/app`, … and nothing that is not loopback. */
|
|
16
|
+
export declare function parseLocalTarget(input: string): LocalTarget;
|
|
17
|
+
export declare function formatLocalTarget(target: LocalTarget): string;
|
|
18
|
+
/**
|
|
19
|
+
* Resolves a peer-supplied path against the configured target. Returns null
|
|
20
|
+
* unless the result stays on the target origin and under its base path.
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveTargetUrl(target: LocalTarget, path: string): string | null;
|
|
23
|
+
export declare function sanitizeRequestHeaders(headers: HeaderList): HeaderList;
|
|
24
|
+
export declare function sanitizeResponseHeaders(headers: HeaderList, target: LocalTarget): HeaderList;
|
|
25
|
+
/**
|
|
26
|
+
* A contact's response headers as a viewer serves them to the page (the extension's viewer tab, Desktop's viewer
|
|
27
|
+
* window). The contact's app decides them, and the wire checks only that they are strings, so a header whose name
|
|
28
|
+
* is not a token or whose value carries CR, LF or NUL is dropped: it could otherwise add headers of its own. Each
|
|
29
|
+
* `Set-Cookie` stays on the exact origin it came from (no `Domain=`), and one holding several cookies on separate
|
|
30
|
+
* lines becomes one header per cookie.
|
|
31
|
+
*/
|
|
32
|
+
export declare function viewerResponseHeaders(headers: HeaderList): HeaderList;
|
|
33
|
+
/**
|
|
34
|
+
* Turns `http://localhost:3400/base/x` into `/x` so the client never learns or
|
|
35
|
+
* follows the local address. Null when the location is not on the target origin
|
|
36
|
+
* and under its base path.
|
|
37
|
+
*/
|
|
38
|
+
export declare function relativizeLocation(location: string, target: LocalTarget): string | null;
|
|
39
|
+
export interface HostedHttpService {
|
|
40
|
+
id: string;
|
|
41
|
+
target: LocalTarget;
|
|
42
|
+
}
|
|
43
|
+
export interface LocalRequest {
|
|
44
|
+
url: string;
|
|
45
|
+
method: string;
|
|
46
|
+
headers: HeaderList;
|
|
47
|
+
body: Uint8Array | null;
|
|
48
|
+
signal: AbortSignal;
|
|
49
|
+
}
|
|
50
|
+
export interface LocalResponse {
|
|
51
|
+
status: number;
|
|
52
|
+
headers: HeaderList;
|
|
53
|
+
body: AsyncIterable<Uint8Array> | Iterable<Uint8Array> | null;
|
|
54
|
+
/**
|
|
55
|
+
* Final URL when the local stack followed redirects itself (a browser's
|
|
56
|
+
* fetch: its manual mode hides where a redirect goes). Desktop never follows
|
|
57
|
+
* and returns the 3xx as it is.
|
|
58
|
+
*/
|
|
59
|
+
finalUrl?: string;
|
|
60
|
+
}
|
|
61
|
+
/** Performs the request against the local service. Browser: `fetch`. Desktop: the Rust side. */
|
|
62
|
+
export type LocalFetch = (request: LocalRequest) => Promise<LocalResponse>;
|
|
63
|
+
export declare class HttpHost {
|
|
64
|
+
private readonly channel;
|
|
65
|
+
private readonly getService;
|
|
66
|
+
private readonly localFetch;
|
|
67
|
+
private readonly streams;
|
|
68
|
+
/**
|
|
69
|
+
* Streams in the map plus those reset while their local fetch still runs. A
|
|
70
|
+
* local stack may not honour the abort signal (Desktop's Rust fetch doesn't),
|
|
71
|
+
* so a stream counts toward the limit until its fetch has settled.
|
|
72
|
+
*/
|
|
73
|
+
private readonly live;
|
|
74
|
+
constructor(channel: FrameChannel, getService: (id: string) => HostedHttpService | undefined, localFetch: LocalFetch);
|
|
75
|
+
get activeRequests(): number;
|
|
76
|
+
handleRequest(frame: HttpRequestFrame): void;
|
|
77
|
+
handleChunk(chunk: ChunkFrame): void;
|
|
78
|
+
handleReset(frame: ResetFrame): void;
|
|
79
|
+
closeAll(): void;
|
|
80
|
+
private armIdleTimer;
|
|
81
|
+
/** Ids are reused after a reset, so a stream is current only if it is the one in the map. */
|
|
82
|
+
private isCurrent;
|
|
83
|
+
private end;
|
|
84
|
+
private fail;
|
|
85
|
+
private run;
|
|
86
|
+
}
|
|
87
|
+
/** `LocalFetch` on top of the web `fetch` API, for any host that has one. */
|
|
88
|
+
export declare const webLocalFetch: LocalFetch;
|
|
89
|
+
export interface ClientRequest {
|
|
90
|
+
method: string;
|
|
91
|
+
path: string;
|
|
92
|
+
headers?: HeaderList;
|
|
93
|
+
body?: Uint8Array | null;
|
|
94
|
+
signal?: AbortSignal;
|
|
95
|
+
maxResponseBytes?: number;
|
|
96
|
+
}
|
|
97
|
+
export interface ClientResponse {
|
|
98
|
+
status: number;
|
|
99
|
+
headers: HeaderList;
|
|
100
|
+
body: AsyncIterable<Uint8Array>;
|
|
101
|
+
/** Collects the whole body, bounded by `maxResponseBytes`. */
|
|
102
|
+
bytes(): Promise<Uint8Array>;
|
|
103
|
+
}
|
|
104
|
+
export declare class GhostlyHttpError extends Error {
|
|
105
|
+
readonly code: string;
|
|
106
|
+
constructor(code: string, message: string);
|
|
107
|
+
}
|
|
108
|
+
export declare class HttpClient {
|
|
109
|
+
private readonly channel;
|
|
110
|
+
private nextId;
|
|
111
|
+
private readonly streams;
|
|
112
|
+
private readonly waiting;
|
|
113
|
+
private inFlight;
|
|
114
|
+
private closed;
|
|
115
|
+
constructor(channel: FrameChannel);
|
|
116
|
+
request(serviceId: string, request: ClientRequest): Promise<ClientResponse>;
|
|
117
|
+
handleResponse(frame: HttpResponseFrame): void;
|
|
118
|
+
handleChunk(chunk: ChunkFrame): void;
|
|
119
|
+
handleReset(frame: ResetFrame): void;
|
|
120
|
+
close(): void;
|
|
121
|
+
private armIdleTimer;
|
|
122
|
+
private finish;
|
|
123
|
+
private abort;
|
|
124
|
+
private release;
|
|
125
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Ghostly identity is an Ed25519 keypair. The public key, z-base-32 encoded,
|
|
3
|
+
* is the peer's Pkarr address. Today every link (chat) uses its own identity,
|
|
4
|
+
* exactly like Ghostly Desktop.
|
|
5
|
+
*/
|
|
6
|
+
export interface Identity {
|
|
7
|
+
seed: Uint8Array;
|
|
8
|
+
seedB64: string;
|
|
9
|
+
publicKey: Uint8Array;
|
|
10
|
+
pubKeyZ32: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function identityFromSeed(seed: Uint8Array): Identity;
|
|
13
|
+
export declare function identityFromSeedB64(seedB64: string): Identity;
|
|
14
|
+
export declare function createIdentity(): Identity;
|
|
15
|
+
export declare function publicKeyFromZ32(z32: string): Uint8Array;
|
|
16
|
+
export declare function sign(message: Uint8Array, seed: Uint8Array): Uint8Array;
|
|
17
|
+
export declare function verify(signature: Uint8Array, message: Uint8Array, publicKey: Uint8Array): boolean;
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { type IdentityTimelineEntry } from "./identityTimeline.js";
|
|
2
|
+
/**
|
|
3
|
+
* Identity proofs (WISP 300), provider-agnostic half.
|
|
4
|
+
*
|
|
5
|
+
* A proof is made once per profile: the external identity (a Nostr key, a domain, an SSH key, an
|
|
6
|
+
* OpenID Connect account…) signs or attests the canonical **statement** below, which authorizes a
|
|
7
|
+
* fresh Ed25519 **proof key** that only this profile holds. Sharing it with a contact is then a
|
|
8
|
+
* challenge-response on that contact's authenticated paired channel: the contact sends a fresh nonce,
|
|
9
|
+
* the proof key signs a **presentation** binding the proof to both participation keys, the
|
|
10
|
+
* conversation, the session and that nonce. A copy replayed to anyone else fails: wrong audience,
|
|
11
|
+
* unknown nonce, and nobody else has the proof key.
|
|
12
|
+
*
|
|
13
|
+
* Providers (browser side, `packages/browser/src/proofs/`) only know how to produce and check the
|
|
14
|
+
* evidence over the statement bytes; everything here is shared, so every provider signs the same bytes.
|
|
15
|
+
*/
|
|
16
|
+
export declare const IDENTITY_PROOF_CAPABILITY = "identity-proof/1";
|
|
17
|
+
/** Domain separation: the first words of every statement. */
|
|
18
|
+
export declare const IDENTITY_STATEMENT_PREFIX = "Ghostly identity proof v1";
|
|
19
|
+
/** No binding is valid for longer than this, whatever the provider allows. */
|
|
20
|
+
export declare const IDENTITY_MAX_VALIDITY: number;
|
|
21
|
+
/** A binding issued this far in the future is refused (seconds of clock disagreement tolerated). */
|
|
22
|
+
export declare const IDENTITY_CLOCK_SKEW = 300;
|
|
23
|
+
/** A contact's challenge must be answered within this many seconds. */
|
|
24
|
+
export declare const IDENTITY_CHALLENGE_WINDOW = 300;
|
|
25
|
+
/** Evidence, serialized as JSON, is at most this many characters. */
|
|
26
|
+
export declare const IDENTITY_MAX_EVIDENCE: number;
|
|
27
|
+
/** A whole `idp-*` frame, serialized. */
|
|
28
|
+
export declare const IDENTITY_MAX_FRAME: number;
|
|
29
|
+
export declare const IDENTITY_PROVIDER_ID: RegExp;
|
|
30
|
+
/** Printable ASCII without spaces, so the statement can be built but never needs parsing. */
|
|
31
|
+
export declare const IDENTITY_SUBJECT: RegExp;
|
|
32
|
+
/** What the external identity signs, as fields. `key` is the proof key (z-base-32 Ed25519). */
|
|
33
|
+
export interface IdentityBinding {
|
|
34
|
+
v: 1;
|
|
35
|
+
provider: string;
|
|
36
|
+
subject: string;
|
|
37
|
+
key: string;
|
|
38
|
+
issuedAt: number;
|
|
39
|
+
expiresAt: number;
|
|
40
|
+
nonce: string;
|
|
41
|
+
}
|
|
42
|
+
/** A binding with its exact bytes. Providers sign `text` (UTF-8 `bytes`) and never rebuild it. */
|
|
43
|
+
export interface IdentityStatement {
|
|
44
|
+
binding: IdentityBinding;
|
|
45
|
+
text: string;
|
|
46
|
+
bytes: Uint8Array;
|
|
47
|
+
/** SHA-256 of `bytes`, lowercase hex: the proof's id everywhere (storage, frames, OIDC nonce input). */
|
|
48
|
+
id: string;
|
|
49
|
+
}
|
|
50
|
+
/** What a provider's `verify` established. Stored by the verifier with the evidence. */
|
|
51
|
+
export interface VerifiedIdentity {
|
|
52
|
+
/** The identity that was proven, canonical. Self-custodied providers: exactly `binding.subject`. */
|
|
53
|
+
subject: string;
|
|
54
|
+
/** How it was checked, for people: "Nostr signature (BIP-340)", "ID token signed by accounts.google.com". */
|
|
55
|
+
source: string;
|
|
56
|
+
/** Provider-attested only: who vouches for `subject` (an issuer host). */
|
|
57
|
+
attester?: string;
|
|
58
|
+
/** Earlier than the binding's own expiry when the evidence says so (a key or certificate expiring). */
|
|
59
|
+
expiresAt?: number;
|
|
60
|
+
/** Optional name/picture carried by the evidence itself, with where it came from. */
|
|
61
|
+
display?: IdentityDisplay;
|
|
62
|
+
}
|
|
63
|
+
export interface IdentityDisplay {
|
|
64
|
+
name?: string;
|
|
65
|
+
/** A sanitized `data:image/…` URL, never a remote one. */
|
|
66
|
+
avatar?: string;
|
|
67
|
+
/** Where the person can see the identity (a profile page), https only. */
|
|
68
|
+
url?: string;
|
|
69
|
+
/** Where name/picture came from: "Nostr kind-0 metadata (self-described)". */
|
|
70
|
+
source: string;
|
|
71
|
+
fetchedAt: number;
|
|
72
|
+
}
|
|
73
|
+
export interface IdentityScope {
|
|
74
|
+
subject: string;
|
|
75
|
+
audience: string;
|
|
76
|
+
context: string;
|
|
77
|
+
session: string;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Early revocation: the proof key publishes, under its own Pkarr key, a TXT record naming the proof it
|
|
81
|
+
* revokes. Anyone holding a copy can look it up by the key in the binding; nothing else is published,
|
|
82
|
+
* and the key is random, so the record says nothing about the identity or its contacts.
|
|
83
|
+
*/
|
|
84
|
+
export declare const IDENTITY_REVOCATION_LABEL = "_ghostly-revoked";
|
|
85
|
+
export declare const identityRevocationValue: (id: string, at: number) => string;
|
|
86
|
+
/** True when these records (resolved and signature-checked under the proof key) revoke proof `id`. */
|
|
87
|
+
export declare function revokesIdentity(records: {
|
|
88
|
+
label: string;
|
|
89
|
+
value: string;
|
|
90
|
+
}[], id: string): boolean;
|
|
91
|
+
export declare function isIdentityBinding(value: unknown): value is IdentityBinding;
|
|
92
|
+
/**
|
|
93
|
+
* The canonical statement, one line, so it survives every tool and clipboard (no line-ending
|
|
94
|
+
* ambiguity). Every field is space-free and the order is fixed, so the text is injective.
|
|
95
|
+
*/
|
|
96
|
+
export declare function identityStatementText(b: IdentityBinding): string;
|
|
97
|
+
export declare function identityStatement(binding: IdentityBinding): IdentityStatement;
|
|
98
|
+
/** A new binding and the seed of its proof key. The seed stays in this profile; never share it. */
|
|
99
|
+
export declare function newIdentityBinding(options: {
|
|
100
|
+
provider: string;
|
|
101
|
+
subject: string;
|
|
102
|
+
validitySeconds: number;
|
|
103
|
+
now?: number;
|
|
104
|
+
}): {
|
|
105
|
+
binding: IdentityBinding;
|
|
106
|
+
seed: Uint8Array;
|
|
107
|
+
};
|
|
108
|
+
/** Bytes the proof key signs for one contact. `scope` is the presenter's view (subject = presenter). */
|
|
109
|
+
export declare function identityPresentationBytes(proofId: string, scope: IdentityScope, nonce: string, issuedAt: number): Uint8Array;
|
|
110
|
+
export declare function signIdentityPresentation(seed: Uint8Array, proofId: string, scope: IdentityScope, nonce: string, issuedAt: number): string;
|
|
111
|
+
export declare function verifyIdentityPresentation(key: string, sig: string, proofId: string, scope: IdentityScope, nonce: string, issuedAt: number): boolean;
|
|
112
|
+
/** Bounds a provider's result so a buggy provider cannot store or show arbitrary data. */
|
|
113
|
+
export declare function boundVerifiedIdentity(v: VerifiedIdentity): VerifiedIdentity;
|
|
114
|
+
/** Sharer side, one per proof shared in this conversation. */
|
|
115
|
+
export interface SharedIdentity {
|
|
116
|
+
id: string;
|
|
117
|
+
provider: string;
|
|
118
|
+
subject: string;
|
|
119
|
+
/** queued: the person chose to share, the contact is not connected yet. */
|
|
120
|
+
status: "queued" | "pending" | "accepted" | "rejected" | "withdrawal-pending" | "withdrawn";
|
|
121
|
+
/** Seconds. When the status last changed. */
|
|
122
|
+
at: number;
|
|
123
|
+
error?: string;
|
|
124
|
+
}
|
|
125
|
+
/** Verifier side: a contact's proof as this app checked it. */
|
|
126
|
+
export interface ReceivedIdentity {
|
|
127
|
+
id: string;
|
|
128
|
+
binding: IdentityBinding;
|
|
129
|
+
evidence: unknown;
|
|
130
|
+
verified: VerifiedIdentity;
|
|
131
|
+
/** The participation keys it was presented between (presenter, then this side). */
|
|
132
|
+
presenter: string;
|
|
133
|
+
audience: string;
|
|
134
|
+
context: string;
|
|
135
|
+
verifiedAt: number;
|
|
136
|
+
checkedAt: number;
|
|
137
|
+
/**
|
|
138
|
+
* unconfirmed: a re-check failed (the domain record is gone, the account cannot be confirmed).
|
|
139
|
+
* revoked: its proof key published a revocation (the person removed it from their profile).
|
|
140
|
+
*/
|
|
141
|
+
status: "verified" | "withdrawn" | "unconfirmed" | "revoked";
|
|
142
|
+
error?: string;
|
|
143
|
+
/** A name/picture looked up on the person's request (Nostr kind-0), with its source. */
|
|
144
|
+
display?: IdentityDisplay;
|
|
145
|
+
}
|
|
146
|
+
/** `id`: the proof the request named, kept here only (never sent) so the timeline can settle its entry. */
|
|
147
|
+
export interface IdentityChallenge {
|
|
148
|
+
nonce: string;
|
|
149
|
+
issuedAt: number;
|
|
150
|
+
provider: string;
|
|
151
|
+
id?: string;
|
|
152
|
+
}
|
|
153
|
+
export interface IdentityLedger {
|
|
154
|
+
challenges: IdentityChallenge[];
|
|
155
|
+
shared: SharedIdentity[];
|
|
156
|
+
received: ReceivedIdentity[];
|
|
157
|
+
/** What the chat's timeline shows of this exchange (identityTimeline.ts). Local only; absent in older ledgers. */
|
|
158
|
+
timeline?: IdentityTimelineEntry[];
|
|
159
|
+
}
|
|
160
|
+
export declare const emptyIdentityLedger: () => IdentityLedger;
|
|
161
|
+
export interface LocalIdentityProof {
|
|
162
|
+
statement: IdentityStatement;
|
|
163
|
+
evidence: unknown;
|
|
164
|
+
seed: Uint8Array;
|
|
165
|
+
}
|
|
166
|
+
export interface IdentityExchangeOptions {
|
|
167
|
+
/** This side's view of the authenticated channel; throws when there is none. */
|
|
168
|
+
scope(): IdentityScope;
|
|
169
|
+
send(frame: object): void;
|
|
170
|
+
storage: {
|
|
171
|
+
read(): IdentityLedger;
|
|
172
|
+
update(change: (ledger: IdentityLedger) => IdentityLedger): Promise<void>;
|
|
173
|
+
};
|
|
174
|
+
/** Providers this app can verify. */
|
|
175
|
+
providers(): readonly string[];
|
|
176
|
+
/** A proof of this profile, by id; undefined once removed. */
|
|
177
|
+
localProof(id: string): LocalIdentityProof | undefined | Promise<LocalIdentityProof | undefined>;
|
|
178
|
+
/** Parses and checks untrusted evidence for a statement (the registry's `verifyIdentity`). */
|
|
179
|
+
verify(statement: IdentityStatement, evidence: unknown): Promise<VerifiedIdentity>;
|
|
180
|
+
/** Looks up the proof key's revocation record. Resolves false when there is none or it cannot be read. */
|
|
181
|
+
revoked?(statement: IdentityStatement): Promise<boolean>;
|
|
182
|
+
now?(): number;
|
|
183
|
+
onError?(error: string): void;
|
|
184
|
+
}
|
|
185
|
+
export type IdentityStatus = "verified" | "expired" | "withdrawn" | "revoked" | "unconfirmed" | "previous-key";
|
|
186
|
+
/** What the verifier should show for a received proof right now. */
|
|
187
|
+
export declare function receivedIdentityStatus(r: ReceivedIdentity, presenter: string | undefined, audience: string | undefined, now?: number): IdentityStatus;
|
|
188
|
+
/**
|
|
189
|
+
* A check this side could not finish because of what its own network did: a host it refused to contact, a server
|
|
190
|
+
* that did not answer or answered an error. The message is for this side only. The contact is told the proof could
|
|
191
|
+
* not be checked, never which host, address or status was seen, so a proof cannot make a contact's app report on
|
|
192
|
+
* the network it sits in.
|
|
193
|
+
*/
|
|
194
|
+
export declare class IdentityCheckUnavailable extends Error {
|
|
195
|
+
constructor(message: string);
|
|
196
|
+
}
|
|
197
|
+
/** What the contact is told when the check failed with an IdentityCheckUnavailable. */
|
|
198
|
+
export declare const IDENTITY_CHECK_UNAVAILABLE = "Your contact's app could not check it. Try again later.";
|
|
199
|
+
/**
|
|
200
|
+
* The `idp-*` exchange of one conversation. Frames (all JSON, additive, over the paired channel,
|
|
201
|
+
* only when both offers carry `identity-proof/1`):
|
|
202
|
+
*
|
|
203
|
+
* idp-hello {providers} each side, when the channel is ready
|
|
204
|
+
* idp-request {id, provider} sharer → verifier: "give me a challenge for this proof"
|
|
205
|
+
* idp-challenge {id, nonce, issuedAt} verifier, after saving the nonce
|
|
206
|
+
* idp-present {nonce, issuedAt, binding, evidence, sig}
|
|
207
|
+
* idp-result {id, ok, error?} verifier, after saving the outcome
|
|
208
|
+
* idp-withdraw {id} / idp-withdrawn {id}
|
|
209
|
+
*/
|
|
210
|
+
export declare class IdentityExchange {
|
|
211
|
+
private options;
|
|
212
|
+
private peerProviders;
|
|
213
|
+
private requested;
|
|
214
|
+
constructor(options: IdentityExchangeOptions);
|
|
215
|
+
private now;
|
|
216
|
+
/** The ledger with one more step on the chat's timeline, in milliseconds (a test's clock, in seconds, when given). */
|
|
217
|
+
private log;
|
|
218
|
+
private incomingScope;
|
|
219
|
+
private send;
|
|
220
|
+
private shared;
|
|
221
|
+
private setShared;
|
|
222
|
+
/** The providers the contact said it verifies; undefined until its hello. */
|
|
223
|
+
get contactProviders(): readonly string[] | undefined;
|
|
224
|
+
/** The channel is ready: say what we verify, then send what the person queued while offline. */
|
|
225
|
+
ready(): void;
|
|
226
|
+
stop(): void;
|
|
227
|
+
/** Share a proof of this profile with this contact: now if connected, else when it next is. */
|
|
228
|
+
share(id: string, connected: boolean): Promise<void>;
|
|
229
|
+
private request;
|
|
230
|
+
/** Stop sharing here. The contact is told (now or on reconnect); a copy it kept cannot be erased. */
|
|
231
|
+
withdraw(id: string, connected: boolean): Promise<void>;
|
|
232
|
+
/**
|
|
233
|
+
* Run the checks again on a received proof: its revocation record, then (unless `revocationOnly`) the
|
|
234
|
+
* provider's check (a domain record may be gone).
|
|
235
|
+
*/
|
|
236
|
+
recheck(id: string, { revocationOnly }?: {
|
|
237
|
+
revocationOnly?: boolean | undefined;
|
|
238
|
+
}): Promise<ReceivedIdentity>;
|
|
239
|
+
receive(frame: Record<string, unknown>): Promise<void>;
|
|
240
|
+
private onRequest;
|
|
241
|
+
private onChallenge;
|
|
242
|
+
private onPresent;
|
|
243
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a chat's timeline shows of the identity-proof exchange (WISP 300, "In the conversation"): one entry when
|
|
3
|
+
* an identity is shared, on both sides, turning verified or failed as the exchange settles, and one when it stops
|
|
4
|
+
* (withdrawn by its owner, or found revoked). Local only: made from the exchange's own steps, stored with the
|
|
5
|
+
* chat's identity ledger, never sent. Nothing new goes on the wire.
|
|
6
|
+
*/
|
|
7
|
+
/** "mine": this side shared it. "theirs": the contact did. */
|
|
8
|
+
export type IdentityTimelineSide = "mine" | "theirs";
|
|
9
|
+
export type IdentityTimelineState = "verifying" | "verified" | "failed";
|
|
10
|
+
export interface IdentityTimelineEntry {
|
|
11
|
+
/** Unique in the chat: side, proof and how many entries that proof already had on that side. */
|
|
12
|
+
id: string;
|
|
13
|
+
/** The proof's id (identityStatement().id). */
|
|
14
|
+
proof: string;
|
|
15
|
+
side: IdentityTimelineSide;
|
|
16
|
+
kind: "shared" | "stopped";
|
|
17
|
+
provider: string;
|
|
18
|
+
/** The identity, once known: at once on the sharer's side, from the presentation on the contact's. */
|
|
19
|
+
subject?: string;
|
|
20
|
+
/** A share only: where the contact's check stands. */
|
|
21
|
+
state?: IdentityTimelineState;
|
|
22
|
+
/** A failed share: why, as the verifier said it. */
|
|
23
|
+
error?: string;
|
|
24
|
+
/** A stop only: its owner withdrew it here, or its proof key published a revocation. */
|
|
25
|
+
reason?: "withdrawn" | "revoked";
|
|
26
|
+
/** Milliseconds. When it happened; later steps of the same share leave it in place. */
|
|
27
|
+
at: number;
|
|
28
|
+
}
|
|
29
|
+
/** One step of the exchange, as the timeline needs it. */
|
|
30
|
+
export type IdentityTimelineEvent =
|
|
31
|
+
/** A share began: this side shared, or the contact asked for a challenge. `requested`: the id the request named. */
|
|
32
|
+
{
|
|
33
|
+
type: "shared";
|
|
34
|
+
side: IdentityTimelineSide;
|
|
35
|
+
proof: string;
|
|
36
|
+
provider: string;
|
|
37
|
+
subject?: string;
|
|
38
|
+
}
|
|
39
|
+
/** The contact's check settled. `requested`: the id the request named, when the presented proof is another. */
|
|
40
|
+
| {
|
|
41
|
+
type: "result";
|
|
42
|
+
side: IdentityTimelineSide;
|
|
43
|
+
proof: string;
|
|
44
|
+
requested?: string;
|
|
45
|
+
provider?: string;
|
|
46
|
+
subject?: string;
|
|
47
|
+
ok: boolean;
|
|
48
|
+
error?: string;
|
|
49
|
+
} | {
|
|
50
|
+
type: "stopped";
|
|
51
|
+
side: IdentityTimelineSide;
|
|
52
|
+
proof: string;
|
|
53
|
+
provider: string;
|
|
54
|
+
subject?: string;
|
|
55
|
+
reason: "withdrawn" | "revoked";
|
|
56
|
+
}
|
|
57
|
+
/** A share taken back before it ever left this side (queued, the contact never heard of it): its entry goes. */
|
|
58
|
+
| {
|
|
59
|
+
type: "unsent";
|
|
60
|
+
side: "mine";
|
|
61
|
+
proof: string;
|
|
62
|
+
};
|
|
63
|
+
/** Entries a chat keeps, newest last. */
|
|
64
|
+
export declare const IDENTITY_TIMELINE_MAX = 100;
|
|
65
|
+
/**
|
|
66
|
+
* The timeline after one step. A share already on it is updated in place, never repeated: a request sent again at
|
|
67
|
+
* a reconnect, a second share of a proof the contact already verified. A new attempt after a failure or a stop is
|
|
68
|
+
* a new entry. A stop is written once; a withdrawal later found revoked becomes a revocation in place.
|
|
69
|
+
*/
|
|
70
|
+
export declare function applyIdentityEvent(timeline: readonly IdentityTimelineEntry[], event: IdentityTimelineEvent, at: number): IdentityTimelineEntry[];
|
|
71
|
+
/** When the contact last shared an identity here (milliseconds), for the chat list: 0 when never. */
|
|
72
|
+
export declare function lastSharedWithMe(timeline: readonly IdentityTimelineEntry[] | undefined): number;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pictures. A picture is an ordinary file (files/2, files/3 or a held item) whose announcement may also carry an
|
|
3
|
+
* `image` description: its size in pixels as it is shown, so the receiver lays out its box before a byte of it has
|
|
4
|
+
* arrived and the chat does not move when it loads. A peer that does not know `image` ignores it and shows the
|
|
5
|
+
* picture as before; a bad description only means no box.
|
|
6
|
+
*
|
|
7
|
+
* The sender reads the size from the file's first bytes (`imageSize`): no decoding, the same on every platform.
|
|
8
|
+
*/
|
|
9
|
+
export interface ImageMeta {
|
|
10
|
+
/** Pixels, as it is shown (EXIF orientation applied). */
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
}
|
|
14
|
+
export declare const IMAGE_LIMITS: {
|
|
15
|
+
/** Pixels on either side: the most a JPEG can say, well past what anyone sends as a picture. */
|
|
16
|
+
readonly maxEdge: 65535;
|
|
17
|
+
/** How much of a file is read for its size: past a JPEG's EXIF, thumbnails and colour profile. */
|
|
18
|
+
readonly headBytes: number;
|
|
19
|
+
};
|
|
20
|
+
/** Whether a file is a picture, by its type. */
|
|
21
|
+
export declare function isImageMime(mime: string): boolean;
|
|
22
|
+
/** A peer's `image` description, or undefined when it is not one. It never refuses the file. */
|
|
23
|
+
export declare function parseImageMeta(value: unknown, mime?: string): ImageMeta | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* A picture's size as it is shown, read from its first bytes (PNG, JPEG, GIF, WebP), or undefined when they do not
|
|
26
|
+
* say. Only the header is read: a JPEG whose frame header sits past `IMAGE_LIMITS.headBytes` goes without.
|
|
27
|
+
*/
|
|
28
|
+
export declare function imageSize(head: Uint8Array): ImageMeta | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* The description a picture is sent with, read from the start of the file, or undefined when it is not a picture
|
|
31
|
+
* or its first bytes do not say (it then goes without one).
|
|
32
|
+
*/
|
|
33
|
+
export declare function readImageMeta(source: Blob, mime: string): Promise<ImageMeta | undefined>;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export * from "./bytes.js";
|
|
2
|
+
export * from "./text.js";
|
|
3
|
+
export * from "./avatar.js";
|
|
4
|
+
export * from "./crypto.js";
|
|
5
|
+
export * from "./identity.js";
|
|
6
|
+
export * from "./dns.js";
|
|
7
|
+
export * from "./pkarr.js";
|
|
8
|
+
export * from "./transport.js";
|
|
9
|
+
export * from "./relay.js";
|
|
10
|
+
export * from "./turnRecord.js";
|
|
11
|
+
export * from "./turnRead.js";
|
|
12
|
+
export * from "./signer.js";
|
|
13
|
+
export * from "./deviceLink.js";
|
|
14
|
+
export * from "./relayBreaker.js";
|
|
15
|
+
export * from "./invite.js";
|
|
16
|
+
export * from "./deviceInvite.js";
|
|
17
|
+
export * from "./enroll.js";
|
|
18
|
+
export * from "./setUpdate.js";
|
|
19
|
+
export * from "./handoff.js";
|
|
20
|
+
export * from "./services.js";
|
|
21
|
+
export * from "./records.js";
|
|
22
|
+
export * from "./callSignal.js";
|
|
23
|
+
export * from "./signal.js";
|
|
24
|
+
export * from "./frames.js";
|
|
25
|
+
export * from "./http.js";
|
|
26
|
+
export * from "./link.js";
|
|
27
|
+
export * from "./datalink.js";
|
|
28
|
+
export * from "./ghostlink.js";
|
|
29
|
+
export * from "./files.js";
|
|
30
|
+
export * from "./chatFiles.js";
|
|
31
|
+
export * from "./voice.js";
|
|
32
|
+
export * from "./video.js";
|
|
33
|
+
export * from "./image.js";
|
|
34
|
+
export * from "./linkPreview.js";
|
|
35
|
+
export * from "./messageTime.js";
|
|
36
|
+
export * from "./payments.js";
|
|
37
|
+
export * from "./bolt11.js";
|
|
38
|
+
export * from "./paymentUri.js";
|
|
39
|
+
export * from "./engineErrors.js";
|
|
40
|
+
export * from "./lnurl.js";
|
|
41
|
+
export * from "./version.js";
|
|
42
|
+
export * from "./pairedSession.js";
|
|
43
|
+
export * from "./pairedCapabilities.js";
|
|
44
|
+
export * from "./pairedCalls.js";
|
|
45
|
+
export * from "./pairedTyping.js";
|
|
46
|
+
export * from "./pairedApps.js";
|
|
47
|
+
export * from "./webPush.js";
|
|
48
|
+
export * from "./pairedWake.js";
|
|
49
|
+
export * from "./pairedEdits.js";
|
|
50
|
+
export * from "./pairedTransports.js";
|
|
51
|
+
export * from "./peerProofs.js";
|
|
52
|
+
export * from './domainProofs.js';
|
|
53
|
+
export * from './pkdns.js';
|
|
54
|
+
export * from './pubkyProofs.js';
|
|
55
|
+
export * from './pubkyRing.js';
|
|
56
|
+
export * from "./capsRecord.js";
|
|
57
|
+
export { DhtDelivery, peekDhtMailbox, DHT_TEXT_BYTES, DHT_MESSAGE_TTL, DHT_TEXT_REFUSED, DHT_FILE_REFUSED, DHT_FILE_TOO_LARGE, LIVE_POLL_MS, ACTIVE_DHT_POLL_MS, emptyDhtDeliveryState, type DeliveryMode, type DhtDeliveryState, type DhtDeliveryView, type DhtPacketFacts } from "./dhtDelivery.js";
|
|
58
|
+
export { DHT_FILE_CAPABILITY, dhtFileId, dhtFileElements, readDhtFile, type DhtFileAnnouncement, type DhtFileElement, type DhtFileMeta, type DhtFileOffer } from "./dhtFiles.js";
|
|
59
|
+
export * from "./storeForward.js";
|
|
60
|
+
export * from "./paymentIntent.js";
|
|
61
|
+
export * from "./bitcoinAddress.js";
|
|
62
|
+
export * from "./sparkAddress.js";
|
|
63
|
+
export * from "./identityProofs.js";
|
|
64
|
+
export * from "./identityTimeline.js";
|
|
65
|
+
export * from "./didDht.js";
|
|
66
|
+
export * from "./did.js";
|
|
67
|
+
export * from "./atprotoRepo.js";
|
|
68
|
+
export * from "./atprotoIdentity.js";
|
|
69
|
+
export * from "./bitcoinScript.js";
|
|
70
|
+
export * from "./bip322.js";
|
|
71
|
+
export * from "./bitcoinMessage.js";
|
|
72
|
+
export * from './sshsig.js';
|
|
73
|
+
export * from "./groupCrypto.js";
|
|
74
|
+
export * from "./groupCommits.js";
|
|
75
|
+
export * from "./groupSession.js";
|
|
76
|
+
export * from "./groupMentions.js";
|
|
77
|
+
export * from "./groupWake.js";
|
|
78
|
+
export * from "./groupEdits.js";
|
|
79
|
+
export * from "./replies.js";
|
|
80
|
+
export * from "./forwards.js";
|
|
81
|
+
export * from "./statusCards.js";
|
|
82
|
+
export * from "./reactions.js";
|
|
83
|
+
export * from "./pins.js";
|
|
84
|
+
export * from "./groupEntry.js";
|
|
85
|
+
export * from "./groupCommunity.js";
|
|
86
|
+
export * from "./communityRendezvous.js";
|
|
87
|
+
export * from "./groupHubs.js";
|
|
88
|
+
export * from "./groupSignals.js";
|
|
89
|
+
export * from "./groupMeta.js";
|
|
90
|
+
export * from "./groupTyping.js";
|
|
91
|
+
export * from "./groupFiles.js";
|
|
92
|
+
export * from "./pairingProgress.js";
|
|
93
|
+
export * from "./directPath.js";
|
|
94
|
+
export * from "./clockWatch.js";
|
|
95
|
+
export { setLinkTraceSink, traceLink } from "./linkTrace.js";
|
|
96
|
+
export * from "./canonicalJson.js";
|
|
97
|
+
export * from "./appStatements.js";
|
|
98
|
+
export * from "./appBundle.js";
|
|
99
|
+
export * from "./appStore.js";
|
|
100
|
+
export * from "./appUpdates.js";
|