@ghostlytools/cli 1.2.4 → 1.3.1
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 +25 -9
- package/dist/assets/api-Dq2QXQDk.js +4172 -0
- package/dist/assets/api-Dq2QXQDk.js.map +1 -0
- package/dist/assets/api-TiB5QSG9.js +3 -0
- package/dist/assets/apiKit-CA2x5GJF.js +200 -0
- package/dist/assets/apiKit-CA2x5GJF.js.map +1 -0
- package/dist/assets/apps-BxV9i_Y4.js +786 -0
- package/dist/assets/apps-BxV9i_Y4.js.map +1 -0
- package/dist/assets/apps-C-T8jeji.js +2 -0
- package/dist/assets/{arkade-CdnKGDbg.js → arkade-C_qDmHnm.js} +2 -2
- package/dist/assets/{arkade-CdnKGDbg.js.map → arkade-C_qDmHnm.js.map} +1 -1
- package/dist/assets/backup-Bugnn3Ue.js +2 -0
- package/dist/assets/backup-CnMN2oUK.js +731 -0
- package/dist/assets/backup-CnMN2oUK.js.map +1 -0
- package/dist/assets/bark_ffi_wasm_bg-EY2uc0Bx.js.map +1 -1
- package/dist/assets/bitcoind-CZchoh43.js +349 -0
- package/dist/assets/bitcoind-CZchoh43.js.map +1 -0
- package/dist/assets/bitcoindProvider-DGw3xBSa.js +97 -0
- package/dist/assets/bitcoindProvider-DGw3xBSa.js.map +1 -0
- package/dist/assets/bitcoindevkit_bg-B-iLWrmX.js.map +1 -1
- package/dist/assets/buttons-Bj7Vf7Pn.js +2 -0
- package/dist/assets/buttons-CvNBzh2S.js +496 -0
- package/dist/assets/buttons-CvNBzh2S.js.map +1 -0
- package/dist/assets/{endpoint-pgFkR2AS.js → endpoint-BOTFMpfS.js} +56 -18
- package/dist/assets/endpoint-BOTFMpfS.js.map +1 -0
- package/dist/assets/envelope-WjingYSc.js +90 -0
- package/dist/assets/envelope-WjingYSc.js.map +1 -0
- package/dist/assets/errors-DO5z6h_l.js +105 -0
- package/dist/assets/errors-DO5z6h_l.js.map +1 -0
- package/dist/assets/fedimint_client_wasm_bg-BtHHlFpp.js.map +1 -1
- package/dist/assets/{fileBytes-Dbifu5I5.js → fileBytes-CfSXjTFa.js} +2 -2
- package/dist/assets/{fileBytes-Dbifu5I5.js.map → fileBytes-CfSXjTFa.js.map} +1 -1
- package/dist/assets/fileBytes-CgbibpbV.js +2 -0
- package/dist/assets/{fileBytes-BcYZhNgF.js → fileBytes-Di7VZtmU.js} +6 -19
- package/dist/assets/fileBytes-Di7VZtmU.js.map +1 -0
- package/dist/assets/fileBytesIdb-CFP-DSkZ.js +2 -0
- package/dist/assets/{fileBytesIdb-DzSaqI0A.js → fileBytesIdb-D5u6H8X_.js} +4 -4
- package/dist/assets/{fileBytesIdb-DzSaqI0A.js.map → fileBytesIdb-D5u6H8X_.js.map} +1 -1
- package/dist/assets/{fileBytesOpfs-Dx8RZiV5.js → fileBytesOpfs-Dd1N4ERH.js} +3 -3
- package/dist/assets/{fileBytesOpfs-Dx8RZiV5.js.map → fileBytesOpfs-Dd1N4ERH.js.map} +1 -1
- package/dist/assets/groupFiles-IEUW3DQz.js +3202 -0
- package/dist/assets/groupFiles-IEUW3DQz.js.map +1 -0
- package/dist/assets/host-CWt-jtqz.js +4673 -0
- package/dist/assets/host-CWt-jtqz.js.map +1 -0
- package/dist/assets/hyperdhtRelay-BT_wRxab.js +21 -0
- package/dist/assets/hyperdhtRelay-BT_wRxab.js.map +1 -0
- package/dist/assets/{hyperdhtRelay-C1p0nkle.js → hyperdhtRelay-CPYwSLLS.js} +25 -10
- package/dist/assets/hyperdhtRelay-CPYwSLLS.js.map +1 -0
- package/dist/assets/{idb-CTF6LF5B.js → idb-B5L8wuOm.js} +7 -5
- package/dist/assets/idb-B5L8wuOm.js.map +1 -0
- package/dist/assets/irohWeb-4oChIOIp.js +544 -0
- package/dist/assets/irohWeb-4oChIOIp.js.map +1 -0
- package/dist/assets/{joinTrace-CO8mlhNO.js → joinTrace-CjRDFy85.js} +2 -7
- package/dist/assets/{joinTrace-CO8mlhNO.js.map → joinTrace-CjRDFy85.js.map} +1 -1
- package/dist/assets/joinTrace-D-fnt2p3.js +2 -0
- package/dist/assets/main-DbqcdShN.js +4409 -0
- package/dist/assets/main-DbqcdShN.js.map +1 -0
- package/dist/assets/{mainline-BH6s8HVi.js → mainline-ZkiOnevs.js} +11 -6
- package/dist/assets/mainline-ZkiOnevs.js.map +1 -0
- package/dist/assets/mints-BrlY773j.js +74 -0
- package/dist/assets/mints-BrlY773j.js.map +1 -0
- package/dist/assets/mints-CqTdA4Gk.js +2 -0
- package/dist/assets/networkReason-CetKkTPo.js +154 -0
- package/dist/assets/networkReason-CetKkTPo.js.map +1 -0
- package/dist/assets/nwc-CgkqyvsE.js +612 -0
- package/dist/assets/nwc-CgkqyvsE.js.map +1 -0
- package/dist/assets/nwcProvider-4eVz_8HP.js +77 -0
- package/dist/assets/nwcProvider-4eVz_8HP.js.map +1 -0
- package/dist/assets/privateFolder-Bk9C9oFv.js +38 -0
- package/dist/assets/privateFolder-Bk9C9oFv.js.map +1 -0
- package/dist/assets/profiles-BHc9pEYg.js +139 -0
- package/dist/assets/profiles-BHc9pEYg.js.map +1 -0
- package/dist/assets/registry-DlAKO0Fy.js +3793 -0
- package/dist/assets/registry-DlAKO0Fy.js.map +1 -0
- package/dist/assets/registry-OBJBnHVQ.js +2 -0
- package/dist/assets/resolve-CouHhCpJ.js +591 -0
- package/dist/assets/resolve-CouHhCpJ.js.map +1 -0
- package/dist/assets/{restoredRows-C_84q0Pd.js → restoredRows-Db3oUTko.js} +2 -2
- package/dist/assets/{restoredRows-C_84q0Pd.js.map → restoredRows-Db3oUTko.js.map} +1 -1
- package/dist/assets/{server-0zfNpABQ.js → server-Ss0gJ-nw.js} +1275 -1404
- package/dist/assets/server-Ss0gJ-nw.js.map +1 -0
- package/dist/assets/{src-CbLkHfz8.js → src-DDzSERyc.js} +882 -134
- package/dist/assets/src-DDzSERyc.js.map +1 -0
- package/dist/assets/turnRefs-B87dtrHM.js +323 -0
- package/dist/assets/turnRefs-B87dtrHM.js.map +1 -0
- package/dist/assets/types-C4_KafL_.js +122 -0
- package/dist/assets/types-C4_KafL_.js.map +1 -0
- package/dist/assets/{usdt-Qf4UuygS.js → usdt-Fj8CQO2z.js} +3 -3
- package/dist/assets/{usdt-Qf4UuygS.js.map → usdt-Fj8CQO2z.js.map} +1 -1
- package/dist/ghostly.mjs +4 -22077
- package/dist/ghostly.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/assets/endpoint-pgFkR2AS.js.map +0 -1
- package/dist/assets/fileBytes-BcYZhNgF.js.map +0 -1
- package/dist/assets/hyperdhtRelay-C1p0nkle.js.map +0 -1
- package/dist/assets/idb-CTF6LF5B.js.map +0 -1
- package/dist/assets/mainline-BH6s8HVi.js.map +0 -1
- package/dist/assets/rolldown-runtime-8H4AJuhK.js +0 -14
- package/dist/assets/server-0zfNpABQ.js.map +0 -1
- package/dist/assets/src-CbLkHfz8.js.map +0 -1
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { f as node, g as state, i as chatOrGroup, s as findGroup } from "./apiKit-CA2x5GJF.js";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
//#region src/engineMethods.ts
|
|
4
|
+
/**
|
|
5
|
+
* The engine's calls the daemon passes through as `engine.<method>` (WISP 1100 § Local control API): exactly the
|
|
6
|
+
* app's `EngineApi` (packages/browser/src/shared/rpc.ts; `engineMethods.test.ts` keeps the two equal), plus two
|
|
7
|
+
* reads every host has. Nothing else on the engine object is reachable.
|
|
8
|
+
*/
|
|
9
|
+
var ENGINE_METHODS = [
|
|
10
|
+
"usdtCreate",
|
|
11
|
+
"usdtUnlock",
|
|
12
|
+
"usdtReveal",
|
|
13
|
+
"usdtLock",
|
|
14
|
+
"usdtRefresh",
|
|
15
|
+
"usdtExportBackup",
|
|
16
|
+
"usdtRestoreBackup",
|
|
17
|
+
"arkCreate",
|
|
18
|
+
"arkUnlock",
|
|
19
|
+
"arkLock",
|
|
20
|
+
"arkBackup",
|
|
21
|
+
"arkExportBackup",
|
|
22
|
+
"arkRestoreBackup",
|
|
23
|
+
"arkRefresh",
|
|
24
|
+
"arkRecover",
|
|
25
|
+
"barkCreate",
|
|
26
|
+
"barkBackup",
|
|
27
|
+
"barkExportBackup",
|
|
28
|
+
"barkRestoreBackup",
|
|
29
|
+
"barkRefresh",
|
|
30
|
+
"barkBoard",
|
|
31
|
+
"fedimintPreview",
|
|
32
|
+
"fedimintJoin",
|
|
33
|
+
"fedimintLeave",
|
|
34
|
+
"fedimintRefresh",
|
|
35
|
+
"fedimintSpendNotes",
|
|
36
|
+
"fedimintReceiveNotes",
|
|
37
|
+
"fedimintInvoice",
|
|
38
|
+
"fedimintTakeBack",
|
|
39
|
+
"fedimintBackup",
|
|
40
|
+
"fedimintExportBackup",
|
|
41
|
+
"fedimintRestoreBackup",
|
|
42
|
+
"fedimintRestorePhrase",
|
|
43
|
+
"sparkCreate",
|
|
44
|
+
"sparkBackup",
|
|
45
|
+
"sparkExportBackup",
|
|
46
|
+
"sparkRestoreBackup",
|
|
47
|
+
"sparkRefresh",
|
|
48
|
+
"sparkUseForLightning",
|
|
49
|
+
"preparePayment",
|
|
50
|
+
"approvePayment",
|
|
51
|
+
"reconcilePayment",
|
|
52
|
+
"cancelPayment",
|
|
53
|
+
"refreshPublicProfiles",
|
|
54
|
+
"choosePublicProfile",
|
|
55
|
+
"preparePeerProof",
|
|
56
|
+
"submitPeerProof",
|
|
57
|
+
"withdrawPeerProof",
|
|
58
|
+
"beginIdentityProof",
|
|
59
|
+
"completeIdentityProof",
|
|
60
|
+
"cancelIdentityProof",
|
|
61
|
+
"removeIdentityProof",
|
|
62
|
+
"shareIdentityProof",
|
|
63
|
+
"withdrawIdentityProof",
|
|
64
|
+
"recheckIdentityProof",
|
|
65
|
+
"lookupIdentityDisplay",
|
|
66
|
+
"loadPublicProfile",
|
|
67
|
+
"loadPublicPosts",
|
|
68
|
+
"loadPublicGraph",
|
|
69
|
+
"loadPublicPostImage",
|
|
70
|
+
"clearProfileData",
|
|
71
|
+
"setDidListed",
|
|
72
|
+
"nostrLoadContact",
|
|
73
|
+
"nostrForgetContact",
|
|
74
|
+
"nostrLoadOwn",
|
|
75
|
+
"nostrLookup",
|
|
76
|
+
"nostrDraft",
|
|
77
|
+
"nostrPublish",
|
|
78
|
+
"createLink",
|
|
79
|
+
"takeInvite",
|
|
80
|
+
"joinLink",
|
|
81
|
+
"ensureLink",
|
|
82
|
+
"confirmPair",
|
|
83
|
+
"pollNow",
|
|
84
|
+
"removeLink",
|
|
85
|
+
"renameLink",
|
|
86
|
+
"setActiveLink",
|
|
87
|
+
"sendMessage",
|
|
88
|
+
"editMessage",
|
|
89
|
+
"retryMessage",
|
|
90
|
+
"react",
|
|
91
|
+
"pinMessage",
|
|
92
|
+
"appId",
|
|
93
|
+
"appOpen",
|
|
94
|
+
"appClose",
|
|
95
|
+
"appSend",
|
|
96
|
+
"messageDetails",
|
|
97
|
+
"deleteMessage",
|
|
98
|
+
"exportLinks",
|
|
99
|
+
"sendFile",
|
|
100
|
+
"forwardMessages",
|
|
101
|
+
"fileAction",
|
|
102
|
+
"setDeliveryMode",
|
|
103
|
+
"setTransportPreference",
|
|
104
|
+
"setChatTransport",
|
|
105
|
+
"setChatPaymentMethods",
|
|
106
|
+
"setChatHold",
|
|
107
|
+
"connect",
|
|
108
|
+
"walletAddMint",
|
|
109
|
+
"walletCreate",
|
|
110
|
+
"walletRemove",
|
|
111
|
+
"walletTestCoins",
|
|
112
|
+
"walletSetupRetry",
|
|
113
|
+
"walletSetupDismiss",
|
|
114
|
+
"wake",
|
|
115
|
+
"peekProfile",
|
|
116
|
+
"walletSetPrimaryMint",
|
|
117
|
+
"walletRemoveMint",
|
|
118
|
+
"walletReceiveLightning",
|
|
119
|
+
"walletQuoteInvoice",
|
|
120
|
+
"walletPayQuote",
|
|
121
|
+
"lnurlResolve",
|
|
122
|
+
"lnurlInvoice",
|
|
123
|
+
"checkPayment",
|
|
124
|
+
"lightningSetSource",
|
|
125
|
+
"lightningClearSource",
|
|
126
|
+
"lightningRetrySource",
|
|
127
|
+
"lightningReconfigureSource",
|
|
128
|
+
"lightningRefresh",
|
|
129
|
+
"lightningSetReceive",
|
|
130
|
+
"lightningRename",
|
|
131
|
+
"bitcoinSetSource",
|
|
132
|
+
"bitcoinClearSource",
|
|
133
|
+
"bitcoinRetrySource",
|
|
134
|
+
"bitcoinReconfigureSource",
|
|
135
|
+
"bitcoinReceiveAddress",
|
|
136
|
+
"bitcoinRefresh",
|
|
137
|
+
"walletReceiveToken",
|
|
138
|
+
"walletInspectCashu",
|
|
139
|
+
"walletExport",
|
|
140
|
+
"walletBackupReminder",
|
|
141
|
+
"sendPayment",
|
|
142
|
+
"requestPayment",
|
|
143
|
+
"requestGroupPayment",
|
|
144
|
+
"groupPaymentHello",
|
|
145
|
+
"askToPay",
|
|
146
|
+
"payRequest",
|
|
147
|
+
"reclaimPayment",
|
|
148
|
+
"disconnect",
|
|
149
|
+
"addService",
|
|
150
|
+
"removeService",
|
|
151
|
+
"setServiceEnabled",
|
|
152
|
+
"setServiceShared",
|
|
153
|
+
"updateSettings",
|
|
154
|
+
"setCallSignal",
|
|
155
|
+
"setTyping",
|
|
156
|
+
"setWakeSubscription",
|
|
157
|
+
"setWakeMuted",
|
|
158
|
+
"wakeForCall",
|
|
159
|
+
"setCallOn",
|
|
160
|
+
"wakeConfirm",
|
|
161
|
+
"setFastPoll",
|
|
162
|
+
"createGroup",
|
|
163
|
+
"inviteToGroup",
|
|
164
|
+
"acceptGroupInvitation",
|
|
165
|
+
"declineGroupInvitation",
|
|
166
|
+
"enableGroupLink",
|
|
167
|
+
"disableGroupLink",
|
|
168
|
+
"joinGroupByLink",
|
|
169
|
+
"sendGroupMessage",
|
|
170
|
+
"sendGroupFile",
|
|
171
|
+
"groupFileCheck",
|
|
172
|
+
"pressButton",
|
|
173
|
+
"groupMessages",
|
|
174
|
+
"messagePage",
|
|
175
|
+
"statusCardIndex",
|
|
176
|
+
"groupTaken",
|
|
177
|
+
"leaveGroup",
|
|
178
|
+
"removeGroupMember",
|
|
179
|
+
"makeGroupAdmin",
|
|
180
|
+
"setGroupHub",
|
|
181
|
+
"rotateGroup",
|
|
182
|
+
"setGroupPicture",
|
|
183
|
+
"renameGroup",
|
|
184
|
+
"setGroupTyping",
|
|
185
|
+
"forgetGroup",
|
|
186
|
+
"setGroupManage",
|
|
187
|
+
"deviceEnrollInvite",
|
|
188
|
+
"deviceEnrollConfirm",
|
|
189
|
+
"deviceEnrollCancel",
|
|
190
|
+
"deviceEnrollView",
|
|
191
|
+
"deviceEnrollJoin",
|
|
192
|
+
"deviceEnrollReady",
|
|
193
|
+
"deviceEnrollFinish",
|
|
194
|
+
"deviceEnrollRemove",
|
|
195
|
+
"deviceSet",
|
|
196
|
+
"devicePing",
|
|
197
|
+
"deviceHandoffVerifier",
|
|
198
|
+
"deviceHandoffPush",
|
|
199
|
+
"deviceHandoffPull",
|
|
200
|
+
"deviceHandoffAccept",
|
|
201
|
+
"deviceHandoffSettle",
|
|
202
|
+
"deviceHandoffCancel",
|
|
203
|
+
"deviceHandoffView",
|
|
204
|
+
"deviceHandoffAllow",
|
|
205
|
+
"deviceTakeoverInfo",
|
|
206
|
+
"deviceTakeover",
|
|
207
|
+
"deviceTurnPeek",
|
|
208
|
+
"deviceForkDiscard",
|
|
209
|
+
"deviceRestoreStartOwn",
|
|
210
|
+
"deviceRemove",
|
|
211
|
+
"deviceNewSecret",
|
|
212
|
+
"deviceSecretOfferDismiss",
|
|
213
|
+
"deviceSetNoticeSeen",
|
|
214
|
+
"deviceTurnCheck",
|
|
215
|
+
"devicePushState",
|
|
216
|
+
"devicePushSet",
|
|
217
|
+
"appList",
|
|
218
|
+
"appBuiltIns",
|
|
219
|
+
"appStoreList",
|
|
220
|
+
"appStorePreview",
|
|
221
|
+
"appStoreAdd",
|
|
222
|
+
"appStoreRemove",
|
|
223
|
+
"appStoreRefresh",
|
|
224
|
+
"appPreview",
|
|
225
|
+
"appInstall",
|
|
226
|
+
"appUpdateAccept",
|
|
227
|
+
"appCheckUpdates",
|
|
228
|
+
"appUninstall",
|
|
229
|
+
"appRunCheck",
|
|
230
|
+
"appFetchFiles",
|
|
231
|
+
"appEntry",
|
|
232
|
+
"appFile",
|
|
233
|
+
"appFileAt",
|
|
234
|
+
"appStorageGet",
|
|
235
|
+
"appStorageSet",
|
|
236
|
+
"appStorageDelete",
|
|
237
|
+
"appStorageKeys",
|
|
238
|
+
"appDataExport",
|
|
239
|
+
"appDataExportText"
|
|
240
|
+
];
|
|
241
|
+
/** Reads the hosts use outside `EngineApi`: the whole state, and one chat's stored messages. */
|
|
242
|
+
var ENGINE_READS = ["getState", "getMessages"];
|
|
243
|
+
/**
|
|
244
|
+
* Calls whose answer holds a secret (chat seeds, wallet phrases and keys, ecash, backups): the CLI prints their
|
|
245
|
+
* result only with `--show-secret`.
|
|
246
|
+
*/
|
|
247
|
+
var SECRET_RESULTS = /* @__PURE__ */ new Set([
|
|
248
|
+
"exportLinks",
|
|
249
|
+
"takeInvite",
|
|
250
|
+
"walletExport",
|
|
251
|
+
"usdtReveal",
|
|
252
|
+
"arkBackup",
|
|
253
|
+
"barkBackup",
|
|
254
|
+
"sparkBackup",
|
|
255
|
+
"fedimintBackup",
|
|
256
|
+
"usdtExportBackup",
|
|
257
|
+
"arkExportBackup",
|
|
258
|
+
"barkExportBackup",
|
|
259
|
+
"sparkExportBackup",
|
|
260
|
+
"fedimintExportBackup",
|
|
261
|
+
"fedimintSpendNotes"
|
|
262
|
+
]);
|
|
263
|
+
//#endregion
|
|
264
|
+
//#region src/turnRefs.ts
|
|
265
|
+
/**
|
|
266
|
+
* The id an agent turn names its message by (docs/CLI.md § Agent turns). A message is stored under an id its sender
|
|
267
|
+
* chose most of (`peer_<the id they sent>`), so a turn carries this one instead, made here from the chat (or group) and
|
|
268
|
+
* that id: `t_` and 32 hex digits, in which nobody can write a word. Every command that takes a message's id takes it.
|
|
269
|
+
*/
|
|
270
|
+
function turnRef(where, messageId) {
|
|
271
|
+
return "t_" + createHash("sha256").update(`${where}\n${messageId}`).digest("hex").slice(0, 32);
|
|
272
|
+
}
|
|
273
|
+
var TURN_REF = /^t_[0-9a-f]{32}$/;
|
|
274
|
+
var isRef = (value) => typeof value === "string" && TURN_REF.test(value);
|
|
275
|
+
/**
|
|
276
|
+
* `params` with each turn's id in `message`, `reply` and `messages` as the id its message is stored under: looked for
|
|
277
|
+
* among the chat's (or group's) newest messages first, where a turn's almost always is, then in all of them. One that
|
|
278
|
+
* names no message stays as given, and its command says so as for any unknown id.
|
|
279
|
+
*/
|
|
280
|
+
async function withStoredIds(ctx, params) {
|
|
281
|
+
const wanted = new Set([
|
|
282
|
+
params.message,
|
|
283
|
+
params.reply,
|
|
284
|
+
...Array.isArray(params.messages) ? params.messages : []
|
|
285
|
+
].filter(isRef));
|
|
286
|
+
if (!wanted.size) return params;
|
|
287
|
+
let target = null;
|
|
288
|
+
try {
|
|
289
|
+
if (typeof params.group === "string") {
|
|
290
|
+
const group = findGroup(state(ctx).groups, params.group);
|
|
291
|
+
target = {
|
|
292
|
+
id: group.id,
|
|
293
|
+
linkId: `group:${group.id}`,
|
|
294
|
+
group: true
|
|
295
|
+
};
|
|
296
|
+
} else if (typeof params.chat === "string") target = chatOrGroup(ctx, params.chat);
|
|
297
|
+
} catch {}
|
|
298
|
+
if (!target) return params;
|
|
299
|
+
const { id, linkId, group } = target;
|
|
300
|
+
const found = /* @__PURE__ */ new Map();
|
|
301
|
+
const look = (messages) => {
|
|
302
|
+
for (const message of messages) {
|
|
303
|
+
const ref = turnRef(id, message.id);
|
|
304
|
+
if (wanted.has(ref)) found.set(ref, message.id);
|
|
305
|
+
}
|
|
306
|
+
return found.size === wanted.size;
|
|
307
|
+
};
|
|
308
|
+
if (!look((await node(ctx).messagePage({
|
|
309
|
+
linkId,
|
|
310
|
+
limit: 200
|
|
311
|
+
})).messages)) look(group ? await node(ctx).groupMessages({ groupId: id }) : await node(ctx).getMessages(linkId));
|
|
312
|
+
const stored = (value) => isRef(value) ? found.get(value) ?? value : value;
|
|
313
|
+
return {
|
|
314
|
+
...params,
|
|
315
|
+
...params.message !== void 0 && { message: stored(params.message) },
|
|
316
|
+
...params.reply !== void 0 && { reply: stored(params.reply) },
|
|
317
|
+
...Array.isArray(params.messages) && { messages: params.messages.map(stored) }
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
//#endregion
|
|
321
|
+
export { SECRET_RESULTS as a, ENGINE_READS as i, withStoredIds as n, ENGINE_METHODS as r, turnRef as t };
|
|
322
|
+
|
|
323
|
+
//# sourceMappingURL=turnRefs-B87dtrHM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turnRefs-B87dtrHM.js","names":[],"sources":["../../src/engineMethods.ts","../../src/turnRefs.ts"],"sourcesContent":["/**\n * The engine's calls the daemon passes through as `engine.<method>` (WISP 1100 § Local control API): exactly the\n * app's `EngineApi` (packages/browser/src/shared/rpc.ts; `engineMethods.test.ts` keeps the two equal), plus two\n * reads every host has. Nothing else on the engine object is reachable.\n */\nexport const ENGINE_METHODS: readonly string[] = [\n \"usdtCreate\", \"usdtUnlock\", \"usdtReveal\", \"usdtLock\", \"usdtRefresh\", \"usdtExportBackup\", \"usdtRestoreBackup\",\n \"arkCreate\", \"arkUnlock\", \"arkLock\", \"arkBackup\", \"arkExportBackup\", \"arkRestoreBackup\", \"arkRefresh\", \"arkRecover\",\n \"barkCreate\", \"barkBackup\", \"barkExportBackup\", \"barkRestoreBackup\", \"barkRefresh\", \"barkBoard\", \"fedimintPreview\",\n \"fedimintJoin\", \"fedimintLeave\", \"fedimintRefresh\", \"fedimintSpendNotes\", \"fedimintReceiveNotes\", \"fedimintInvoice\",\n \"fedimintTakeBack\", \"fedimintBackup\", \"fedimintExportBackup\", \"fedimintRestoreBackup\", \"fedimintRestorePhrase\",\n \"sparkCreate\", \"sparkBackup\", \"sparkExportBackup\", \"sparkRestoreBackup\", \"sparkRefresh\", \"sparkUseForLightning\",\n \"preparePayment\", \"approvePayment\", \"reconcilePayment\", \"cancelPayment\", \"refreshPublicProfiles\",\n \"choosePublicProfile\", \"preparePeerProof\", \"submitPeerProof\", \"withdrawPeerProof\", \"beginIdentityProof\",\n \"completeIdentityProof\", \"cancelIdentityProof\", \"removeIdentityProof\", \"shareIdentityProof\",\n \"withdrawIdentityProof\", \"recheckIdentityProof\", \"lookupIdentityDisplay\", \"loadPublicProfile\", \"loadPublicPosts\",\n \"loadPublicGraph\", \"loadPublicPostImage\", \"clearProfileData\", \"setDidListed\", \"nostrLoadContact\", \"nostrForgetContact\", \"nostrLoadOwn\",\n \"nostrLookup\", \"nostrDraft\", \"nostrPublish\", \"createLink\", \"takeInvite\", \"joinLink\", \"ensureLink\", \"confirmPair\",\n \"pollNow\", \"removeLink\", \"renameLink\", \"setActiveLink\", \"sendMessage\", \"editMessage\", \"retryMessage\", \"react\", \"pinMessage\", \"appId\", \"appOpen\", \"appClose\", \"appSend\", \"messageDetails\",\n \"deleteMessage\", \"exportLinks\", \"sendFile\", \"forwardMessages\", \"fileAction\", \"setDeliveryMode\", \"setTransportPreference\",\n \"setChatTransport\", \"setChatPaymentMethods\", \"setChatHold\", \"connect\", \"walletAddMint\", \"walletCreate\",\n \"walletRemove\", \"walletTestCoins\", \"walletSetupRetry\", \"walletSetupDismiss\", \"wake\", \"peekProfile\", \"walletSetPrimaryMint\", \"walletRemoveMint\", \"walletReceiveLightning\",\n \"walletQuoteInvoice\", \"walletPayQuote\", \"lnurlResolve\", \"lnurlInvoice\", \"checkPayment\", \"lightningSetSource\",\n \"lightningClearSource\", \"lightningRetrySource\", \"lightningReconfigureSource\", \"lightningRefresh\",\n \"lightningSetReceive\", \"lightningRename\", \"bitcoinSetSource\", \"bitcoinClearSource\", \"bitcoinRetrySource\",\n \"bitcoinReconfigureSource\", \"bitcoinReceiveAddress\", \"bitcoinRefresh\", \"walletReceiveToken\", \"walletInspectCashu\",\n \"walletExport\", \"walletBackupReminder\", \"sendPayment\", \"requestPayment\", \"requestGroupPayment\", \"groupPaymentHello\", \"askToPay\",\n \"payRequest\", \"reclaimPayment\", \"disconnect\", \"addService\", \"removeService\", \"setServiceEnabled\",\n \"setServiceShared\", \"updateSettings\", \"setCallSignal\", \"setTyping\", \"setWakeSubscription\", \"setWakeMuted\", \"wakeForCall\", \"setCallOn\", \"wakeConfirm\", \"setFastPoll\", \"createGroup\", \"inviteToGroup\",\n \"acceptGroupInvitation\", \"declineGroupInvitation\", \"enableGroupLink\", \"disableGroupLink\", \"joinGroupByLink\",\n \"sendGroupMessage\", \"sendGroupFile\", \"groupFileCheck\", \"pressButton\", \"groupMessages\", \"messagePage\", \"statusCardIndex\", \"groupTaken\", \"leaveGroup\", \"removeGroupMember\", \"makeGroupAdmin\", \"setGroupHub\", \"rotateGroup\",\n \"setGroupPicture\", \"renameGroup\", \"setGroupTyping\", \"forgetGroup\", \"setGroupManage\",\n // One profile on several devices (WISP 06): a CLI profile is always on one device, so these answer `single` or refuse.\n \"deviceEnrollInvite\", \"deviceEnrollConfirm\", \"deviceEnrollCancel\", \"deviceEnrollView\", \"deviceEnrollJoin\", \"deviceEnrollReady\", \"deviceEnrollFinish\",\n \"deviceEnrollRemove\", \"deviceSet\", \"devicePing\", \"deviceHandoffVerifier\", \"deviceHandoffPush\", \"deviceHandoffPull\", \"deviceHandoffAccept\",\n \"deviceHandoffSettle\", \"deviceHandoffCancel\", \"deviceHandoffView\", \"deviceHandoffAllow\", \"deviceTakeoverInfo\", \"deviceTakeover\", \"deviceTurnPeek\", \"deviceForkDiscard\", \"deviceRestoreStartOwn\",\n \"deviceRemove\", \"deviceNewSecret\", \"deviceSecretOfferDismiss\", \"deviceSetNoticeSeen\", \"deviceTurnCheck\", \"devicePushState\", \"devicePushSet\",\n \"appList\", \"appBuiltIns\", \"appStoreList\", \"appStorePreview\", \"appStoreAdd\", \"appStoreRemove\", \"appStoreRefresh\", \"appPreview\", \"appInstall\",\n \"appUpdateAccept\", \"appCheckUpdates\", \"appUninstall\", \"appRunCheck\", \"appFetchFiles\", \"appEntry\", \"appFile\", \"appFileAt\", \"appStorageGet\", \"appStorageSet\",\n \"appStorageDelete\", \"appStorageKeys\", \"appDataExport\", \"appDataExportText\",\n];\n\n/** Reads the hosts use outside `EngineApi`: the whole state, and one chat's stored messages. */\nexport const ENGINE_READS: readonly string[] = [\"getState\", \"getMessages\"];\n\n/**\n * Calls whose answer holds a secret (chat seeds, wallet phrases and keys, ecash, backups): the CLI prints their\n * result only with `--show-secret`.\n */\nexport const SECRET_RESULTS: ReadonlySet<string> = new Set([\n \"exportLinks\", \"takeInvite\", \"walletExport\", \"usdtReveal\",\n \"arkBackup\", \"barkBackup\", \"sparkBackup\", \"fedimintBackup\",\n \"usdtExportBackup\", \"arkExportBackup\", \"barkExportBackup\", \"sparkExportBackup\", \"fedimintExportBackup\",\n \"fedimintSpendNotes\",\n]);\n","import { createHash } from \"node:crypto\";\nimport { chatOrGroup, findGroup, node, state, type ApiContext, type Params } from \"./apiKit\";\n\n/**\n * The id an agent turn names its message by (docs/CLI.md § Agent turns). A message is stored under an id its sender\n * chose most of (`peer_<the id they sent>`), so a turn carries this one instead, made here from the chat (or group) and\n * that id: `t_` and 32 hex digits, in which nobody can write a word. Every command that takes a message's id takes it.\n */\nexport function turnRef(where: string, messageId: string): string {\n return \"t_\" + createHash(\"sha256\").update(`${where}\\n${messageId}`).digest(\"hex\").slice(0, 32);\n}\n\nconst TURN_REF = /^t_[0-9a-f]{32}$/;\nconst isRef = (value: unknown): value is string => typeof value === \"string\" && TURN_REF.test(value);\n\n/**\n * `params` with each turn's id in `message`, `reply` and `messages` as the id its message is stored under: looked for\n * among the chat's (or group's) newest messages first, where a turn's almost always is, then in all of them. One that\n * names no message stays as given, and its command says so as for any unknown id.\n */\nexport async function withStoredIds(ctx: ApiContext, params: Params): Promise<Params> {\n const wanted = new Set([params.message, params.reply, ...(Array.isArray(params.messages) ? params.messages : [])].filter(isRef));\n if (!wanted.size) return params;\n let target: { id: string; linkId: string; group: boolean } | null = null;\n try {\n if (typeof params.group === \"string\") { const group = findGroup(state(ctx).groups, params.group); target = { id: group.id, linkId: `group:${group.id}`, group: true }; }\n else if (typeof params.chat === \"string\") target = chatOrGroup(ctx, params.chat);\n } catch { /* the command says what is wrong with its chat or group */ }\n if (!target) return params;\n const { id, linkId, group } = target;\n const found = new Map<string, string>();\n const look = (messages: readonly { id: string }[]) => {\n for (const message of messages) { const ref = turnRef(id, message.id); if (wanted.has(ref)) found.set(ref, message.id); }\n return found.size === wanted.size;\n };\n if (!look((await node(ctx).messagePage({ linkId, limit: 200 })).messages)) look(group ? await node(ctx).groupMessages({ groupId: id }) : await node(ctx).getMessages(linkId));\n const stored = (value: unknown) => (isRef(value) ? found.get(value) ?? value : value);\n return {\n ...params,\n ...(params.message !== undefined && { message: stored(params.message) }),\n ...(params.reply !== undefined && { reply: stored(params.reply) }),\n ...(Array.isArray(params.messages) && { messages: params.messages.map(stored) }),\n };\n}\n"],"mappings":";;;;;;;;AAKA,IAAa,iBAAoC;CAC/C;CAAc;CAAc;CAAc;CAAY;CAAe;CAAoB;CACzF;CAAa;CAAa;CAAW;CAAa;CAAmB;CAAoB;CAAc;CACvG;CAAc;CAAc;CAAoB;CAAqB;CAAe;CAAa;CACjG;CAAgB;CAAiB;CAAmB;CAAsB;CAAwB;CAClG;CAAoB;CAAkB;CAAwB;CAAyB;CACvF;CAAe;CAAe;CAAqB;CAAsB;CAAgB;CACzF;CAAkB;CAAkB;CAAoB;CAAiB;CACzE;CAAuB;CAAoB;CAAmB;CAAqB;CACnF;CAAyB;CAAuB;CAAuB;CACvE;CAAyB;CAAwB;CAAyB;CAAqB;CAC/F;CAAmB;CAAuB;CAAoB;CAAgB;CAAoB;CAAsB;CACxH;CAAe;CAAc;CAAgB;CAAc;CAAc;CAAY;CAAc;CACnG;CAAW;CAAc;CAAc;CAAiB;CAAe;CAAe;CAAgB;CAAS;CAAc;CAAS;CAAW;CAAY;CAAW;CACxK;CAAiB;CA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AAG,CAAC,CAAC,YAAY,MAAM,CAAC;CAC5K,MAAM,UAAU,UAAoB,MAAM,KAAK,IAAI,MAAM,IAAI,KAAK,KAAK,QAAQ;CAC/E,OAAO;EACL,GAAG;EACH,GAAI,OAAO,YAAY,KAAA,KAAa,EAAE,SAAS,OAAO,OAAO,OAAO,EAAE;EACtE,GAAI,OAAO,UAAU,KAAA,KAAa,EAAE,OAAO,OAAO,OAAO,KAAK,EAAE;EAChE,GAAI,MAAM,QAAQ,OAAO,QAAQ,KAAK,EAAE,UAAU,OAAO,SAAS,IAAI,MAAM,EAAE;CAChF;AACF"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
//#region ../browser/src/engine/paymentAdapters/providers/types.ts
|
|
2
|
+
var PROVIDER_PLATFORMS = [
|
|
3
|
+
"web",
|
|
4
|
+
"extension",
|
|
5
|
+
"desktop"
|
|
6
|
+
];
|
|
7
|
+
var PROVIDER_NETWORKS = [
|
|
8
|
+
"bitcoin",
|
|
9
|
+
"signet",
|
|
10
|
+
"testnet",
|
|
11
|
+
"regtest",
|
|
12
|
+
"mutinynet"
|
|
13
|
+
];
|
|
14
|
+
var networkMode = (network) => network === "bitcoin" ? "mainnet" : "testnet";
|
|
15
|
+
/** A provider can be offered here: it runs on this platform and on a network of this mode. */
|
|
16
|
+
var offeredIn = (descriptor, platform, mode) => descriptor.platforms.includes(platform) && descriptor.networks.some((network) => networkMode(network) === mode);
|
|
17
|
+
var FIELD_KINDS = [
|
|
18
|
+
"text",
|
|
19
|
+
"url",
|
|
20
|
+
"secret",
|
|
21
|
+
"select",
|
|
22
|
+
"textarea"
|
|
23
|
+
];
|
|
24
|
+
/** What is stored with the profile and sent on the wire in journals: stable, short, lowercase. */
|
|
25
|
+
var PROVIDER_ID = /^[a-z][a-z0-9-]{0,31}$/;
|
|
26
|
+
/**
|
|
27
|
+
* Problems with a provider descriptor, empty when it is well-formed. The registry refuses a descriptor
|
|
28
|
+
* with any; the contract suite checks the same list, so an author sees them before the app does.
|
|
29
|
+
*/
|
|
30
|
+
function providerDescriptorProblems(d) {
|
|
31
|
+
const problems = [];
|
|
32
|
+
if (!PROVIDER_ID.test(d.id ?? "")) problems.push("id must match ^[a-z][a-z0-9-]{0,31}$");
|
|
33
|
+
if (!d.label?.trim()) problems.push("label is empty");
|
|
34
|
+
if (d.kind !== "lightning" && d.kind !== "onchain") problems.push("kind must be lightning or onchain");
|
|
35
|
+
if (!d.description?.trim()) problems.push("description is empty: say what it is and who holds the money");
|
|
36
|
+
if (!Array.isArray(d.networks) || !d.networks.length) problems.push("no networks");
|
|
37
|
+
else for (const n of d.networks) if (!PROVIDER_NETWORKS.includes(n)) problems.push(`unknown network ${String(n)}`);
|
|
38
|
+
if (!Array.isArray(d.platforms) || !d.platforms.length) problems.push("no platforms");
|
|
39
|
+
else for (const p of d.platforms) if (!PROVIDER_PLATFORMS.includes(p)) problems.push(`unknown platform ${String(p)}`);
|
|
40
|
+
if (!Array.isArray(d.fields)) problems.push("fields must be a list (empty when there is nothing to configure)");
|
|
41
|
+
else {
|
|
42
|
+
const names = d.fields.map((f) => f.name);
|
|
43
|
+
if (new Set(names).size !== names.length) problems.push("field names are not unique");
|
|
44
|
+
for (const f of d.fields) {
|
|
45
|
+
if (!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(f.name ?? "")) problems.push(`field ${String(f.name)} has an invalid name`);
|
|
46
|
+
if (!f.label?.trim()) problems.push(`field ${f.name} has no label`);
|
|
47
|
+
if (!FIELD_KINDS.includes(f.kind)) problems.push(`field ${f.name} has an unknown kind`);
|
|
48
|
+
if (f.kind === "select" && !f.options?.length) problems.push(`field ${f.name} is a select without options`);
|
|
49
|
+
if (f.suggestions !== void 0 && (!Array.isArray(f.suggestions) || f.suggestions.some((o) => typeof o?.value !== "string" || typeof o?.label !== "string"))) problems.push(`field ${f.name} has malformed suggestions`);
|
|
50
|
+
if (f.changeable && (f.kind === "secret" || f.kind === "select")) problems.push(`field ${f.name} cannot be changeable: only a server address can`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (typeof d.create !== "function") problems.push("create is not a function");
|
|
54
|
+
if (d.validate !== void 0 && typeof d.validate !== "function") problems.push("validate is not a function");
|
|
55
|
+
return problems;
|
|
56
|
+
}
|
|
57
|
+
/** Only these fields reach the UI, whatever else a provider module keeps on its descriptor. */
|
|
58
|
+
var describeProvider = ({ id, label, kind, description, networks, platforms, fields, custodial, experimental }) => ({
|
|
59
|
+
id,
|
|
60
|
+
label,
|
|
61
|
+
kind,
|
|
62
|
+
description,
|
|
63
|
+
networks,
|
|
64
|
+
platforms,
|
|
65
|
+
fields,
|
|
66
|
+
custodial,
|
|
67
|
+
experimental
|
|
68
|
+
});
|
|
69
|
+
/**
|
|
70
|
+
* The provider proved that nothing left the wallet (refused before sending, no route found before any
|
|
71
|
+
* HTLC, a transaction that was never broadcast). Safe to try again, with this or another source.
|
|
72
|
+
*
|
|
73
|
+
* Any other error from a spend means the outcome is UNKNOWN: the payment may be in flight or done. It is
|
|
74
|
+
* recorded as such and only reconciled (asked about), never retried. When in doubt, do not throw this.
|
|
75
|
+
*/
|
|
76
|
+
var NothingSpentError = class extends Error {
|
|
77
|
+
constructor(message) {
|
|
78
|
+
super(message);
|
|
79
|
+
this.name = "NothingSpentError";
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* The source could not be reached: no answer, a time-out, a refused connection, a server error. The
|
|
84
|
+
* engine keeps trying by itself (with backoff) and shows the source as connecting meanwhile.
|
|
85
|
+
*/
|
|
86
|
+
var SourceUnreachableError = class extends Error {
|
|
87
|
+
constructor(message, cause) {
|
|
88
|
+
super(message);
|
|
89
|
+
this.name = "SourceUnreachableError";
|
|
90
|
+
if (cause !== void 0) Object.assign(this, { cause });
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* A setting of the source is wrong (a server on another network, a phrase that makes no wallet): trying
|
|
95
|
+
* again changes nothing until the setting does. The engine shows it as unavailable at once.
|
|
96
|
+
*/
|
|
97
|
+
var SourceConfigError = class extends Error {
|
|
98
|
+
constructor(message, cause) {
|
|
99
|
+
super(message);
|
|
100
|
+
this.name = "SourceConfigError";
|
|
101
|
+
if (cause !== void 0) Object.assign(this, { cause });
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
var sourceProblem = (error) => error instanceof Error && error.name === "SourceUnreachableError" ? "unreachable" : error instanceof Error && error.name === "SourceConfigError" ? "config" : "other";
|
|
105
|
+
/**
|
|
106
|
+
* Whether an error says nothing was spent. By name, not by class: a provider built outside the app (an
|
|
107
|
+
* SDK plugin bundled with its own copy of `NothingSpentError`) must be understood the same way.
|
|
108
|
+
*/
|
|
109
|
+
var isNothingSpentError = (error) => error instanceof NothingSpentError || error instanceof Error && error.name === "NothingSpentError";
|
|
110
|
+
/**
|
|
111
|
+
* An error message fit to show and store: every secret the source was given is blanked out, in case a
|
|
112
|
+
* library echoed a URI or a key back.
|
|
113
|
+
*/
|
|
114
|
+
function redact(error, secrets = {}) {
|
|
115
|
+
let message = error instanceof Error ? error.message : String(error);
|
|
116
|
+
for (const value of Object.values(secrets)) if (value && value.length >= 4) message = message.split(value).join("•••");
|
|
117
|
+
return message.slice(0, 300);
|
|
118
|
+
}
|
|
119
|
+
//#endregion
|
|
120
|
+
export { describeProvider as a, offeredIn as c, sourceProblem as d, SourceUnreachableError as i, providerDescriptorProblems as l, PROVIDER_PLATFORMS as n, isNothingSpentError as o, SourceConfigError as r, networkMode as s, NothingSpentError as t, redact as u };
|
|
121
|
+
|
|
122
|
+
//# sourceMappingURL=types-C4_KafL_.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-C4_KafL_.js","names":[],"sources":["../../../browser/src/engine/paymentAdapters/providers/types.ts"],"sourcesContent":["import type { BitcoinNetwork } from \"@ghostly/core\";\nimport type { WalletMode } from \"../../../shared/mints\";\n\n/**\n * What every wallet provider (a source of Lightning or of on-chain Bitcoin) shares: where it runs, how\n * it is configured, and the one distinction that keeps money safe. See PROVIDERS.md.\n */\n\n/** Where Ghostly runs: the web app, the browser extension (engine in an offscreen document), the Tauri app. */\nexport type ProviderPlatform = \"web\" | \"extension\" | \"desktop\";\nexport const PROVIDER_PLATFORMS: readonly ProviderPlatform[] = [\"web\", \"extension\", \"desktop\"];\nexport type ProviderKind = \"lightning\" | \"onchain\";\n/** The chain a provider's sats live on. Only `bitcoin` is real money; the others belong to the Testnet mode. */\nexport type ProviderNetwork = BitcoinNetwork;\nexport const PROVIDER_NETWORKS: readonly ProviderNetwork[] = [\"bitcoin\", \"signet\", \"testnet\", \"regtest\", \"mutinynet\"];\nexport const networkMode = (network: ProviderNetwork): WalletMode => (network === \"bitcoin\" ? \"mainnet\" : \"testnet\");\n\n/**\n * One field of a provider's configuration form. The wallet card renders these; a provider that needs\n * more registers its own form component instead (apps/ui/src/components/wallet/providers/forms.ts).\n * `secret` fields (an NWC URI, a macaroon, a rune, an API key, a password) are sealed before they are\n * stored, never shown again, never put in the engine state, and never logged.\n */\nexport interface ProviderField {\n name: string;\n label: string;\n kind: \"text\" | \"url\" | \"secret\" | \"select\" | \"textarea\";\n placeholder?: string;\n help?: string;\n optional?: boolean;\n /** `select` only. */\n options?: { value: string; label: string }[];\n /** Pre-filled per mode, e.g. a public test server for Testnet. */\n defaults?: Partial<Record<WalletMode, string>>;\n /**\n * Values offered under a `url` or `text` field (a list to pick from, anything may still be typed), each\n * only while the other fields hold `when`: e.g. a public Esplora server per network.\n */\n suggestions?: { value: string; label: string; when?: Record<string, string> }[];\n /**\n * A server address that can be changed on a saved source without its secrets being typed again, and\n * without changing whose money it is: an Esplora server of a BDK wallet (the wallet is the phrase). The\n * source's \"Change server\" edits these fields only. Never mark a field that picks another account (a\n * node's URL: another node is other money).\n */\n changeable?: boolean;\n}\n\n/** What the person typed, split by the field kinds: `config` is shown back, `secrets` never is. */\nexport interface ProviderSettings {\n config: Record<string, string>;\n secrets: Record<string, string>;\n}\n\n/** What the engine hands a provider's factory. */\nexport interface ProviderHost {\n platform: ProviderPlatform;\n /** The wallet mode the source is for: its provider must be on a network of this mode. */\n mode: WalletMode;\n /**\n * Reserved for the built-in Cashu mint source: the engine's own wallet. It is not part of the SDK, and\n * no other provider should read it.\n */\n cashu?: unknown;\n /** Reserved for the built-in Fedimint source: the engine's Fedimint wallet (its joined federations). Not part of the SDK. */\n fedimint?: unknown;\n /** Ends when the source is replaced, the mode switches or the engine stops: abort long waits on it. */\n signal: AbortSignal;\n /**\n * Desktop only: calls a command of the Tauri app (apps/desktop), for what a WebView cannot do (a pinned\n * certificate, no CORS, a raw socket). Absent on the web and in the extension.\n */\n invoke?: <T>(command: string, args: Record<string, unknown>) => Promise<T>;\n}\n\n/**\n * A provider module's export. Registering a provider is adding its module and one line in\n * `registry.ts`; everything else (storage, sealing, per-mode sources, the card, journals) is shared.\n */\nexport interface ProviderDescriptor<P> {\n id: string;\n label: string;\n kind: ProviderKind;\n /** One line under the name in the source picker: what it is and who holds the money. */\n description: string;\n /** Networks it can run on. A mode lists only providers with a network of that mode. */\n networks: readonly ProviderNetwork[];\n platforms: readonly ProviderPlatform[];\n fields: readonly ProviderField[];\n /** Custodial (someone else holds the sats) or still experimental: said in the picker. */\n custodial?: boolean;\n experimental?: boolean;\n /** Checks the form before anything is contacted; throws a message fit for the person. */\n validate?(settings: ProviderSettings, mode: WalletMode): void;\n /** Connects. The engine then asks `info()` and refuses a network of the other mode. */\n create(settings: ProviderSettings, host: ProviderHost): Promise<P>;\n}\n\n/** A provider can be offered here: it runs on this platform and on a network of this mode. */\nexport const offeredIn = (descriptor: { platforms: readonly ProviderPlatform[]; networks: readonly ProviderNetwork[] }, platform: ProviderPlatform, mode: WalletMode) =>\n descriptor.platforms.includes(platform) && descriptor.networks.some((network) => networkMode(network) === mode);\n\nconst FIELD_KINDS = [\"text\", \"url\", \"secret\", \"select\", \"textarea\"];\n/** What is stored with the profile and sent on the wire in journals: stable, short, lowercase. */\nexport const PROVIDER_ID = /^[a-z][a-z0-9-]{0,31}$/;\n\n/**\n * Problems with a provider descriptor, empty when it is well-formed. The registry refuses a descriptor\n * with any; the contract suite checks the same list, so an author sees them before the app does.\n */\nexport function providerDescriptorProblems(d: ProviderDescriptor<unknown>): string[] {\n const problems: string[] = [];\n if (!PROVIDER_ID.test(d.id ?? \"\")) problems.push(\"id must match ^[a-z][a-z0-9-]{0,31}$\");\n if (!d.label?.trim()) problems.push(\"label is empty\");\n if (d.kind !== \"lightning\" && d.kind !== \"onchain\") problems.push(\"kind must be lightning or onchain\");\n if (!d.description?.trim()) problems.push(\"description is empty: say what it is and who holds the money\");\n if (!Array.isArray(d.networks) || !d.networks.length) problems.push(\"no networks\");\n else for (const n of d.networks) if (!PROVIDER_NETWORKS.includes(n)) problems.push(`unknown network ${String(n)}`);\n if (!Array.isArray(d.platforms) || !d.platforms.length) problems.push(\"no platforms\");\n else for (const p of d.platforms) if (!PROVIDER_PLATFORMS.includes(p)) problems.push(`unknown platform ${String(p)}`);\n if (!Array.isArray(d.fields)) problems.push(\"fields must be a list (empty when there is nothing to configure)\");\n else {\n const names = d.fields.map((f) => f.name);\n if (new Set(names).size !== names.length) problems.push(\"field names are not unique\");\n for (const f of d.fields) {\n if (!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(f.name ?? \"\")) problems.push(`field ${String(f.name)} has an invalid name`);\n if (!f.label?.trim()) problems.push(`field ${f.name} has no label`);\n if (!FIELD_KINDS.includes(f.kind)) problems.push(`field ${f.name} has an unknown kind`);\n if (f.kind === \"select\" && !f.options?.length) problems.push(`field ${f.name} is a select without options`);\n if (f.suggestions !== undefined && (!Array.isArray(f.suggestions) || f.suggestions.some((o: { value?: unknown; label?: unknown } | undefined) => typeof o?.value !== \"string\" || typeof o?.label !== \"string\"))) problems.push(`field ${f.name} has malformed suggestions`);\n if (f.changeable && (f.kind === \"secret\" || f.kind === \"select\")) problems.push(`field ${f.name} cannot be changeable: only a server address can`);\n }\n }\n if (typeof d.create !== \"function\") problems.push(\"create is not a function\");\n if (d.validate !== undefined && typeof d.validate !== \"function\") problems.push(\"validate is not a function\");\n return problems;\n}\n\n/** The serializable part of a descriptor, for the UI (a function cannot cross the extension's port). */\nexport type ProviderDescriptorView = Omit<ProviderDescriptor<unknown>, \"create\" | \"validate\">;\n/** Only these fields reach the UI, whatever else a provider module keeps on its descriptor. */\nexport const describeProvider = ({ id, label, kind, description, networks, platforms, fields, custodial, experimental }: ProviderDescriptor<unknown>): ProviderDescriptorView =>\n ({ id, label, kind, description, networks, platforms, fields, custodial, experimental });\n\n/**\n * The provider proved that nothing left the wallet (refused before sending, no route found before any\n * HTLC, a transaction that was never broadcast). Safe to try again, with this or another source.\n *\n * Any other error from a spend means the outcome is UNKNOWN: the payment may be in flight or done. It is\n * recorded as such and only reconciled (asked about), never retried. When in doubt, do not throw this.\n */\nexport class NothingSpentError extends Error {\n constructor(message: string) { super(message); this.name = \"NothingSpentError\"; }\n}\n\n/**\n * The source could not be reached: no answer, a time-out, a refused connection, a server error. The\n * engine keeps trying by itself (with backoff) and shows the source as connecting meanwhile.\n */\nexport class SourceUnreachableError extends Error {\n constructor(message: string, cause?: unknown) { super(message); this.name = \"SourceUnreachableError\"; if (cause !== undefined) Object.assign(this, { cause }); }\n}\n\n/**\n * A setting of the source is wrong (a server on another network, a phrase that makes no wallet): trying\n * again changes nothing until the setting does. The engine shows it as unavailable at once.\n */\nexport class SourceConfigError extends Error {\n constructor(message: string, cause?: unknown) { super(message); this.name = \"SourceConfigError\"; if (cause !== undefined) Object.assign(this, { cause }); }\n}\n\n/** What went wrong connecting a source, by name (a plugin bundles its own copies of these classes). */\nexport type SourceProblem = \"unreachable\" | \"config\" | \"other\";\nexport const sourceProblem = (error: unknown): SourceProblem =>\n error instanceof Error && error.name === \"SourceUnreachableError\" ? \"unreachable\" : error instanceof Error && error.name === \"SourceConfigError\" ? \"config\" : \"other\";\n\n/**\n * Whether an error says nothing was spent. By name, not by class: a provider built outside the app (an\n * SDK plugin bundled with its own copy of `NothingSpentError`) must be understood the same way.\n */\nexport const isNothingSpentError = (error: unknown): error is NothingSpentError =>\n error instanceof NothingSpentError || (error instanceof Error && error.name === \"NothingSpentError\");\n\n/**\n * An error message fit to show and store: every secret the source was given is blanked out, in case a\n * library echoed a URI or a key back.\n */\nexport function redact(error: unknown, secrets: Record<string, string> = {}): string {\n let message = error instanceof Error ? error.message : String(error);\n for (const value of Object.values(secrets)) if (value && value.length >= 4) message = message.split(value).join(\"•••\");\n return message.slice(0, 300);\n}\n"],"mappings":";AAUA,IAAa,qBAAkD;CAAC;CAAO;CAAa;AAAS;AAI7F,IAAa,oBAAgD;CAAC;CAAW;CAAU;CAAW;CAAW;AAAW;AACpH,IAAa,eAAe,YAA0C,YAAY,YAAY,YAAY;;AAoF1G,IAAa,aAAa,YAA8F,UAA4B,SAClJ,WAAW,UAAU,SAAS,QAAQ,KAAK,WAAW,SAAS,MAAM,YAAY,YAAY,OAAO,MAAM,IAAI;AAEhH,IAAM,cAAc;CAAC;CAAQ;CAAO;CAAU;CAAU;AAAU;;AAElE,IAAa,cAAc;;;;;AAM3B,SAAgB,2BAA2B,GAA0C;CACnF,MAAM,WAAqB,CAAC;CAC5B,IAAI,CAAC,YAAY,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS,KAAK,sCAAsC;CACvF,IAAI,CAAC,EAAE,OAAO,KAAK,GAAG,SAAS,KAAK,gBAAgB;CACpD,IAAI,EAAE,SAAS,eAAe,EAAE,SAAS,WAAW,SAAS,KAAK,mCAAmC;CACrG,IAAI,CAAC,EAAE,aAAa,KAAK,GAAG,SAAS,KAAK,8DAA8D;CACxG,IAAI,CAAC,MAAM,QAAQ,EAAE,QAAQ,KAAK,CAAC,EAAE,SAAS,QAAQ,SAAS,KAAK,aAAa;MAC5E,KAAK,MAAM,KAAK,EAAE,UAAU,IAAI,CAAC,kBAAkB,SAAS,CAAC,GAAG,SAAS,KAAK,mBAAmB,OAAO,CAAC,GAAG;CACjH,IAAI,C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cn as SEPOLIA_TEST_USDT, dn as USDT_PUBLIC_RPC, gn as validatePaymentTarget, ln as SEPOLIA_TEST_USDT_FAUCET, sn as PaymentPreflightError, un as TEST_USDT_FAUCET_AMOUNT } from "./src-DDzSERyc.js";
|
|
2
|
+
import { a as sealSeed, n as rpcHost, o as unsealSeed, t as networkReason } from "./networkReason-CetKkTPo.js";
|
|
3
3
|
import { mnemonicToSeedSync } from "@scure/bip39";
|
|
4
4
|
import WalletManagerEvm from "@tetherto/wdk-wallet-evm";
|
|
5
5
|
import { Interface, Transaction, getAddress, keccak256 } from "ethers";
|
|
@@ -407,4 +407,4 @@ var UsdtAdapter = class UsdtAdapter {
|
|
|
407
407
|
//#endregion
|
|
408
408
|
export { UsdtAdapter, wireProvider };
|
|
409
409
|
|
|
410
|
-
//# sourceMappingURL=usdt-
|
|
410
|
+
//# sourceMappingURL=usdt-Fj8CQO2z.js.map
|