@ghostlytools/sdk 0.0.0-stage → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/README.md +13 -2
  2. package/dist/app.js +72 -0
  3. package/dist/app.js.map +1 -0
  4. package/dist/core.js +207 -0
  5. package/dist/core.js.map +1 -0
  6. package/dist/fakes-JOzOFxn3.js +536 -0
  7. package/dist/fakes-JOzOFxn3.js.map +1 -0
  8. package/dist/fakes.js +2 -0
  9. package/dist/index.js +179 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/keet-identity-key-BLli1rE4.js +76483 -0
  12. package/dist/keet-identity-key-BLli1rE4.js.map +1 -0
  13. package/dist/src-BqHTnRWH.js +31296 -0
  14. package/dist/src-BqHTnRWH.js.map +1 -0
  15. package/dist/testing.js +330 -0
  16. package/dist/testing.js.map +1 -0
  17. package/dist/types/browser/src/engine/paymentAdapters/providers/contractSuite.d.ts +41 -0
  18. package/dist/types/browser/src/engine/paymentAdapters/providers/lightning.d.ts +103 -0
  19. package/dist/types/browser/src/engine/paymentAdapters/providers/onchain.d.ts +88 -0
  20. package/dist/types/browser/src/engine/paymentAdapters/providers/testing.d.ts +89 -0
  21. package/dist/types/browser/src/engine/paymentAdapters/providers/types.d.ts +151 -0
  22. package/dist/types/browser/src/plugins/bundled.d.ts +8 -0
  23. package/dist/types/browser/src/plugins/registry.d.ts +57 -0
  24. package/dist/types/browser/src/proofs/contract.d.ts +262 -0
  25. package/dist/types/browser/src/proofs/contractSuite.d.ts +27 -0
  26. package/dist/types/browser/src/proofs/testing.d.ts +36 -0
  27. package/dist/types/browser/src/proofs/verify.d.ts +23 -0
  28. package/dist/types/browser/src/shared/mints.d.ts +50 -0
  29. package/dist/types/core/src/appBundle.d.ts +173 -0
  30. package/dist/types/core/src/appStatements.d.ts +142 -0
  31. package/dist/types/core/src/appStore.d.ts +133 -0
  32. package/dist/types/core/src/appUpdates.d.ts +88 -0
  33. package/dist/types/core/src/atprotoIdentity.d.ts +49 -0
  34. package/dist/types/core/src/atprotoRepo.d.ts +101 -0
  35. package/dist/types/core/src/avatar.d.ts +19 -0
  36. package/dist/types/core/src/bip322.d.ts +57 -0
  37. package/dist/types/core/src/bitcoinAddress.d.ts +5 -0
  38. package/dist/types/core/src/bitcoinMessage.d.ts +15 -0
  39. package/dist/types/core/src/bitcoinScript.d.ts +69 -0
  40. package/dist/types/core/src/bolt11.d.ts +30 -0
  41. package/dist/types/core/src/bytes.d.ts +11 -0
  42. package/dist/types/core/src/callSignal.d.ts +232 -0
  43. package/dist/types/core/src/canonicalJson.d.ts +22 -0
  44. package/dist/types/core/src/capsRecord.d.ts +234 -0
  45. package/dist/types/core/src/catchUp.d.ts +45 -0
  46. package/dist/types/core/src/chatFiles.d.ts +271 -0
  47. package/dist/types/core/src/clockWatch.d.ts +72 -0
  48. package/dist/types/core/src/communityRendezvous.d.ts +113 -0
  49. package/dist/types/core/src/crypto.d.ts +10 -0
  50. package/dist/types/core/src/datalink.d.ts +187 -0
  51. package/dist/types/core/src/deviceInvite.d.ts +51 -0
  52. package/dist/types/core/src/deviceLink.d.ts +70 -0
  53. package/dist/types/core/src/dhtDelivery.d.ts +407 -0
  54. package/dist/types/core/src/dhtFiles.d.ts +46 -0
  55. package/dist/types/core/src/did.d.ts +134 -0
  56. package/dist/types/core/src/didDht.d.ts +155 -0
  57. package/dist/types/core/src/directPath.d.ts +63 -0
  58. package/dist/types/core/src/dns.d.ts +41 -0
  59. package/dist/types/core/src/domainProofs.d.ts +88 -0
  60. package/dist/types/core/src/engineErrors.d.ts +91 -0
  61. package/dist/types/core/src/enroll.d.ts +98 -0
  62. package/dist/types/core/src/files.d.ts +73 -0
  63. package/dist/types/core/src/forwards.d.ts +12 -0
  64. package/dist/types/core/src/frames.d.ts +211 -0
  65. package/dist/types/core/src/ghostlink.d.ts +1532 -0
  66. package/dist/types/core/src/groupCommits.d.ts +103 -0
  67. package/dist/types/core/src/groupCommunity.d.ts +720 -0
  68. package/dist/types/core/src/groupCrypto.d.ts +60 -0
  69. package/dist/types/core/src/groupEdits.d.ts +67 -0
  70. package/dist/types/core/src/groupEntry.d.ts +61 -0
  71. package/dist/types/core/src/groupFiles.d.ts +106 -0
  72. package/dist/types/core/src/groupHubs.d.ts +61 -0
  73. package/dist/types/core/src/groupMentions.d.ts +27 -0
  74. package/dist/types/core/src/groupMeta.d.ts +162 -0
  75. package/dist/types/core/src/groupSession.d.ts +728 -0
  76. package/dist/types/core/src/groupSignals.d.ts +167 -0
  77. package/dist/types/core/src/groupTyping.d.ts +56 -0
  78. package/dist/types/core/src/groupWake.d.ts +68 -0
  79. package/dist/types/core/src/handoff.d.ts +255 -0
  80. package/dist/types/core/src/http.d.ts +125 -0
  81. package/dist/types/core/src/identity.d.ts +17 -0
  82. package/dist/types/core/src/identityProofs.d.ts +243 -0
  83. package/dist/types/core/src/identityTimeline.d.ts +72 -0
  84. package/dist/types/core/src/image.d.ts +33 -0
  85. package/dist/types/core/src/index.d.ts +100 -0
  86. package/dist/types/core/src/invite.d.ts +128 -0
  87. package/dist/types/core/src/link.d.ts +353 -0
  88. package/dist/types/core/src/linkPreview.d.ts +60 -0
  89. package/dist/types/core/src/linkTrace.d.ts +12 -0
  90. package/dist/types/core/src/lnurl.d.ts +99 -0
  91. package/dist/types/core/src/messageTime.d.ts +28 -0
  92. package/dist/types/core/src/miniApp.d.ts +146 -0
  93. package/dist/types/core/src/pairedApps.d.ts +151 -0
  94. package/dist/types/core/src/pairedCalls.d.ts +59 -0
  95. package/dist/types/core/src/pairedCapabilities.d.ts +101 -0
  96. package/dist/types/core/src/pairedEdits.d.ts +83 -0
  97. package/dist/types/core/src/pairedFiles.d.ts +30 -0
  98. package/dist/types/core/src/pairedHttp.d.ts +15 -0
  99. package/dist/types/core/src/pairedSession.d.ts +163 -0
  100. package/dist/types/core/src/pairedSignal.d.ts +17 -0
  101. package/dist/types/core/src/pairedTransports.d.ts +76 -0
  102. package/dist/types/core/src/pairedTyping.d.ts +130 -0
  103. package/dist/types/core/src/pairedWake.d.ts +109 -0
  104. package/dist/types/core/src/pairingProgress.d.ts +107 -0
  105. package/dist/types/core/src/paymentIntent.d.ts +111 -0
  106. package/dist/types/core/src/paymentUri.d.ts +34 -0
  107. package/dist/types/core/src/payments.d.ts +97 -0
  108. package/dist/types/core/src/peerProofs.d.ts +98 -0
  109. package/dist/types/core/src/pins.d.ts +73 -0
  110. package/dist/types/core/src/pkarr.d.ts +48 -0
  111. package/dist/types/core/src/pkdns.d.ts +35 -0
  112. package/dist/types/core/src/pubkyProofs.d.ts +25 -0
  113. package/dist/types/core/src/pubkyRing.d.ts +21 -0
  114. package/dist/types/core/src/reactions.d.ts +108 -0
  115. package/dist/types/core/src/records.d.ts +89 -0
  116. package/dist/types/core/src/relay.d.ts +459 -0
  117. package/dist/types/core/src/relayBreaker.d.ts +99 -0
  118. package/dist/types/core/src/replies.d.ts +41 -0
  119. package/dist/types/core/src/services.d.ts +35 -0
  120. package/dist/types/core/src/setUpdate.d.ts +53 -0
  121. package/dist/types/core/src/signal.d.ts +53 -0
  122. package/dist/types/core/src/signer.d.ts +13 -0
  123. package/dist/types/core/src/sparkAddress.d.ts +37 -0
  124. package/dist/types/core/src/sshsig.d.ts +74 -0
  125. package/dist/types/core/src/statusCards.d.ts +253 -0
  126. package/dist/types/core/src/storeForward.d.ts +144 -0
  127. package/dist/types/core/src/text.d.ts +20 -0
  128. package/dist/types/core/src/transport.d.ts +158 -0
  129. package/dist/types/core/src/transportSwitch.d.ts +160 -0
  130. package/dist/types/core/src/turnRead.d.ts +145 -0
  131. package/dist/types/core/src/turnRecord.d.ts +165 -0
  132. package/dist/types/core/src/version.d.ts +9 -0
  133. package/dist/types/core/src/video.d.ts +44 -0
  134. package/dist/types/core/src/voice.d.ts +88 -0
  135. package/dist/types/core/src/webPush.d.ts +58 -0
  136. package/dist/types/sdk/src/app.d.ts +23 -0
  137. package/dist/types/sdk/src/core.d.ts +7 -0
  138. package/dist/types/sdk/src/fakes.d.ts +6 -0
  139. package/dist/types/sdk/src/index.d.ts +26 -0
  140. package/dist/types/sdk/src/testing.d.ts +7 -0
  141. package/dist/types-DvtCy3WB.js +99 -0
  142. package/dist/types-DvtCy3WB.js.map +1 -0
  143. package/dist/verify-RjMx7eW6.js +106 -0
  144. package/dist/verify-RjMx7eW6.js.map +1 -0
  145. package/package.json +70 -4
@@ -0,0 +1,211 @@
1
+ /**
2
+ * Framing on the `ghostly/1` DataChannel (ordered, reliable).
3
+ *
4
+ * - Text messages are control frames: compact JSON with a `t` discriminator,
5
+ * the same shape Ghostly already uses for `_msgs` and `_call`.
6
+ * - Binary messages are body chunks that belong to a stream opened by a
7
+ * control frame: `<kind u8><stream id u32 BE><flags u8><payload>`.
8
+ *
9
+ * Everything here handles data from the remote peer and must never trust it.
10
+ */
11
+ export declare const LIMITS: {
12
+ /** Largest control frame accepted, headers included. */
13
+ readonly maxControlFrameBytes: number;
14
+ /** Longest payment endpoint value (a Cashu token, an invoice) a payment frame may carry; a longer one is dropped. */
15
+ readonly maxPaymentEndpointChars: number;
16
+ /** Largest DataChannel message sent. 16 KiB is safe across WebRTC stacks. */
17
+ readonly maxChunkMessageBytes: number;
18
+ readonly maxRequestBodyBytes: number;
19
+ readonly maxResponseBodyBytes: number;
20
+ readonly maxHeaderCount: 128;
21
+ readonly maxHeaderValueBytes: number;
22
+ readonly maxPathBytes: number;
23
+ /** Requests a host serves at once for one peer. */
24
+ readonly maxConcurrentRequestsPerPeer: 32;
25
+ /** Requests a client keeps in flight; the rest wait in a queue. */
26
+ readonly maxClientInFlight: 16;
27
+ readonly maxChatMessageBytes: number;
28
+ readonly maxFileBytes: number;
29
+ /** Files a peer may be sending us at once. */
30
+ readonly maxIncomingFilesPerPeer: 3;
31
+ /** Received bytes kept for one peer, in flight included. Past it new files are refused. */
32
+ readonly maxStoredIncomingBytesPerPeer: number;
33
+ readonly requestTimeoutMs: 60000;
34
+ readonly bodyIdleTimeoutMs: 30000;
35
+ /** Stop writing to the channel above this many buffered bytes. */
36
+ readonly sendHighWaterMark: number;
37
+ readonly sendLowWaterMark: number;
38
+ };
39
+ export declare const PROTOCOL_VERSION = 1;
40
+ export declare const CHUNK_KIND: {
41
+ readonly requestBody: 1;
42
+ readonly responseBody: 2;
43
+ readonly fileBody: 3;
44
+ };
45
+ export type ChunkKind = (typeof CHUNK_KIND)[keyof typeof CHUNK_KIND];
46
+ export declare const CHUNK_FLAG_END = 1;
47
+ export declare const MAX_CHUNK_PAYLOAD_BYTES: number;
48
+ export type HeaderList = [string, string][];
49
+ /** First frame in each direction once the channel opens. */
50
+ export interface HelloFrame {
51
+ t: "hello";
52
+ v: number;
53
+ /** Authoritative service list, same wire shape as the `_svc` record. */
54
+ svc: unknown;
55
+ nick?: string;
56
+ }
57
+ /** Chat message. Used instead of `_msgs` while the data link is up. */
58
+ export interface ChatFrame {
59
+ t: "m";
60
+ ts: number;
61
+ m: string;
62
+ }
63
+ /** A `_call` signal, sent here as well so a connected peer rings without waiting for its next poll. */
64
+ export interface CallFrame {
65
+ t: "call";
66
+ s: string;
67
+ }
68
+ /** Updated service list while connected. */
69
+ export interface ServicesFrame {
70
+ t: "svc";
71
+ svc: unknown;
72
+ }
73
+ export interface HttpRequestFrame {
74
+ t: "req";
75
+ id: number;
76
+ /** Service id. The host maps it to a target; the peer never names a URL. */
77
+ s: string;
78
+ m: string;
79
+ /** Origin-form path with query, e.g. `/api/items?page=2` */
80
+ p: string;
81
+ h: HeaderList;
82
+ /** True when request body chunks follow. */
83
+ b: boolean;
84
+ }
85
+ export interface HttpResponseFrame {
86
+ t: "res";
87
+ id: number;
88
+ st: number;
89
+ h: HeaderList;
90
+ /** True when response body chunks follow. */
91
+ b: boolean;
92
+ }
93
+ /** Announces a file; its bytes follow as `fileBody` chunks on stream `id`. */
94
+ export interface FileFrame {
95
+ t: "file";
96
+ id: number;
97
+ /** File id chosen by the sender, unique within the link. */
98
+ f: string;
99
+ ts: number;
100
+ n: string;
101
+ /** Size in bytes. The transfer fails unless exactly this many arrive. */
102
+ s: number;
103
+ m: string;
104
+ }
105
+ /**
106
+ * A way to get paid, in Paykit's terms: a Payment Endpoint Identifier
107
+ * (`btc-lightning-bolt11`, `cashu`, …) and its payload (an invoice, the mints
108
+ * accepted, …). See `payments.ts`.
109
+ */
110
+ export type WireEndpoint = [identifier: string, payload: string];
111
+ /** Payment Request: the sender asks to be paid. */
112
+ export interface PayRequestFrame {
113
+ t: "pay-req";
114
+ /** Request id, chosen by the payee. */
115
+ id: string;
116
+ ts: number;
117
+ /** Decimal amount as text, and its asset (`sat`). */
118
+ v: string;
119
+ u: string;
120
+ memo?: string;
121
+ e: WireEndpoint[];
122
+ /** The `pay-ask` this answers, if any. */
123
+ a?: string;
124
+ /**
125
+ * `mainnet` (real money) or `testnet` (test coins): what pays it. Absent from apps before wallets had their own
126
+ * network; the endpoints tell then (a test mint, a test chain).
127
+ */
128
+ n?: "mainnet" | "testnet";
129
+ }
130
+ /** A payer asking to pay: the payee answers with a `pay-req` whose `a` is this id. */
131
+ export interface PayAskFrame {
132
+ t: "pay-ask";
133
+ id: string;
134
+ ts: number;
135
+ v: string;
136
+ u: string;
137
+ m: "arkade" | "usdt" | "bark" | "bitcoin" | "fedimint" | "spark";
138
+ memo?: string;
139
+ /** The network the payer will pay from: the payee answers from its wallet of that network. */
140
+ n?: "mainnet" | "testnet";
141
+ }
142
+ /** A payment that travels in band, such as an ecash token. */
143
+ export interface PayFrame {
144
+ t: "pay";
145
+ id: string;
146
+ ts: number;
147
+ /** The request this settles, if any. */
148
+ rid?: string;
149
+ v: string;
150
+ u: string;
151
+ memo?: string;
152
+ /** The endpoint used and the payment itself. */
153
+ e: WireEndpoint;
154
+ }
155
+ /** What became of a payment or a request: the payee's receipt, or a refusal. */
156
+ export interface PayResultFrame {
157
+ t: "pay-res";
158
+ /** Id of the `pay` or `pay-req` frame this answers. */
159
+ id: string;
160
+ ok: boolean;
161
+ /** Amount credited, when it differs from what was sent (fees). */
162
+ v?: string;
163
+ err?: string;
164
+ /** On the payee's own `pay-req`: closed for good, never to be paid (its wallet was removed). */
165
+ c?: true;
166
+ }
167
+ /** Aborts a stream in either direction. */
168
+ export interface ResetFrame {
169
+ t: "rst";
170
+ id: number;
171
+ /** Which stream: `q` a request I sent, `s` a response I am sending, `f` a file (either side). */
172
+ d: "q" | "s" | "f";
173
+ e: string;
174
+ }
175
+ export interface PingFrame {
176
+ t: "ping" | "pong";
177
+ ts: number;
178
+ }
179
+ export type ControlFrame = PayAskFrame | HelloFrame | ChatFrame | CallFrame | ServicesFrame | HttpRequestFrame | HttpResponseFrame | FileFrame | PayRequestFrame | PayFrame | PayResultFrame | ResetFrame | PingFrame;
180
+ export interface ChunkFrame {
181
+ kind: ChunkKind;
182
+ id: number;
183
+ end: boolean;
184
+ payload: Uint8Array;
185
+ }
186
+ export declare function encodeControl(frame: ControlFrame): string;
187
+ /** Returns null for anything malformed; callers drop the frame. */
188
+ export declare function decodeControl(text: string): ControlFrame | null;
189
+ export declare function encodeChunk(chunk: ChunkFrame): Uint8Array;
190
+ export declare function decodeChunk(data: Uint8Array): ChunkFrame | null;
191
+ /**
192
+ * The slice of RTCDataChannel the protocol needs. Tests use an in-memory pair,
193
+ * platforms wrap a real channel with `wrapDataChannel`.
194
+ */
195
+ export interface FrameChannel {
196
+ send(data: string | Uint8Array): void;
197
+ readonly bufferedAmount: number;
198
+ /** Resolves once the send buffer has drained below the low water mark. */
199
+ drained(): Promise<void>;
200
+ /**
201
+ * Bytes the channel queues before `send` throws (the native and iroh channels). Absent: it buffers freely, as a
202
+ * WebRTC data channel does, and a sender only keeps under `LIMITS.sendHighWaterMark`.
203
+ */
204
+ readonly sendBudget?: number;
205
+ close(): void;
206
+ onMessage: ((data: string | Uint8Array) => void) | null;
207
+ onClose: (() => void) | null;
208
+ }
209
+ export declare function wrapDataChannel(dc: RTCDataChannel): FrameChannel;
210
+ /** Writes a body as chunks, honouring backpressure. Always ends with an END chunk. */
211
+ export declare function sendBody(channel: FrameChannel, kind: ChunkKind, id: number, body: AsyncIterable<Uint8Array> | Iterable<Uint8Array>, isCancelled?: () => boolean): Promise<void>;