@leather.io/provider 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Leather Wallet LLC [a subsidiary of Nassau Machines]
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,16 @@
1
+ import { RpcRequests } from '@leather.io/rpc';
2
+
3
+ type Platform = 'mobile' | 'extension';
4
+
5
+ interface initInpageProviderArgs {
6
+ onDispatch(rpcRequest: RpcRequests): void;
7
+ env: {
8
+ branch: string;
9
+ commitSha: string;
10
+ version: string;
11
+ platform: Platform;
12
+ };
13
+ }
14
+ declare function initInpageProvider({ onDispatch, env }: initInpageProviderArgs): void;
15
+
16
+ export { initInpageProvider };
package/dist/index.js ADDED
@@ -0,0 +1,368 @@
1
+ // src/add-leather-to-providers.ts
2
+ function addLeatherToProviders() {
3
+ const win = window;
4
+ if (!win.btc_providers) win.btc_providers = [];
5
+ win.btc_providers.push({
6
+ id: "LeatherProvider",
7
+ name: "Leather",
8
+ icon: "data:image/svg;base64,PHN2ZyB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCIgdmlld0JveD0iMCAwIDEyOCAxMjgiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSIxMjgiIGhlaWdodD0iMTI4IiByeD0iMjYuODM4NyIgZmlsbD0iIzEyMTAwRiIvPgo8cGF0aCBkPSJNNzQuOTE3MSA1Mi43MTE0QzgyLjQ3NjYgNTEuNTQwOCA5My40MDg3IDQzLjU4MDQgOTMuNDA4NyAzNy4zNzYxQzkzLjQwODcgMzUuNTAzMSA5MS44OTY4IDM0LjIxNTQgODkuNjg3MSAzNC4yMTU0Qzg1LjUwMDQgMzQuMjE1NCA3OC40MDYxIDQwLjUzNjggNzQuOTE3MSA1Mi43MTE0Wk0zOS45MTEgODMuNDk5MUMzMC4wMjU2IDgzLjQ5OTEgMjkuMjExNSA5My4zMzI0IDM5LjA5NjkgOTMuMzMyNEM0My41MTYzIDkzLjMzMjQgNDguODY2MSA5MS41NzY0IDUxLjY1NzMgODguNDE1N0M0Ny41ODY4IDg0LjkwMzggNDQuMjE0MSA4My40OTkxIDM5LjkxMSA4My40OTkxWk0xMDIuODI5IDc5LjI4NDhDMTAzLjQxIDk1Ljc5MDcgOTUuMDM2OSAxMDUuMDM5IDgwLjg0ODQgMTA1LjAzOUM3Mi40NzQ4IDEwNS4wMzkgNjguMjg4MSAxMDEuODc4IDU5LjMzMyA5Ni4wMjQ4QzU0LjY4MSAxMDEuMTc2IDQ1Ljg0MjMgMTA1LjAzOSAzOC41MTU0IDEwNS4wMzlDMTMuMjc4NSAxMDUuMDM5IDE0LjMyNTIgNzIuODQ2MyA0MC4wMjczIDcyLjg0NjNDNDUuMzc3MSA3Mi44NDYzIDQ5LjkxMjggNzQuMjUxMSA1NS43Mjc3IDc3Ljg4TDU5LjU2NTYgNjQuNDE3N0M0My43NDg5IDYwLjA4NjQgMzUuODQwNSA0Ny45MTE4IDQzLjYzMjYgMzAuNDY5M0g1Ni4xOTI5QzQ5LjIxNSA0Mi4wNTg2IDUzLjk4MzIgNTEuNjU3OCA2Mi44MjIgNTIuNzExNEM2Ny41OTAzIDM1LjczNzIgNzcuODI0NiAyMi41MDkgOTEuNDMxNiAyMi41MDlDOTkuMTA3NCAyMi41MDkgMTA1LjE1NSAyNy41NDI4IDEwNS4xNTUgMzYuNjczN0MxMDUuMTU1IDUxLjMwNjYgODYuMDgxOSA2My4yNDcxIDcxLjY2MDcgNjQuNDE3N0w2NS43Mjk1IDg1LjM3MjFDNzIuNDc0OCA5My4yMTUzIDkxLjE5OSAxMDAuODI0IDkxLjE5OSA3OS4yODQ4SDEwMi44MjlaIiBmaWxsPSIjRjdGNUYzIi8+Cjwvc3ZnPgo=",
9
+ webUrl: "https://leather.io",
10
+ chromeWebStoreUrl: "https://chromewebstore.google.com/detail/leather/ldinpeekobnhjjdofggfgjlcehhmanlj",
11
+ methods: [
12
+ "open",
13
+ "getInfo",
14
+ "supportedMethods",
15
+ "openSwap",
16
+ "getAddresses",
17
+ "stx_updateProfile",
18
+ "stx_signMessage",
19
+ "stx_transferStx",
20
+ "stx_transferSip10Ft",
21
+ "stx_signTransaction",
22
+ "stx_signStructuredMessage",
23
+ "stx_getAddresses",
24
+ "stx_deployContract",
25
+ "stx_callContract",
26
+ "signPsbt",
27
+ "signMessage",
28
+ "sendTransfer"
29
+ // Better to import a type than a variable from @leather.io/rpc to save a lot of space in the injected provider script
30
+ ]
31
+ });
32
+ }
33
+
34
+ // src/legacy-requests.ts
35
+ var MESSAGE_SOURCE = "stacks-wallet";
36
+ function isValidEvent(event, method) {
37
+ const { data } = event;
38
+ const correctSource = data.source === MESSAGE_SOURCE;
39
+ const correctMethod = data.method === method;
40
+ return correctSource && correctMethod && !!data.payload;
41
+ }
42
+ async function callAndReceive(methodName, opts = {}) {
43
+ return new Promise((resolve, reject) => {
44
+ const timeout = setTimeout(() => {
45
+ reject("Unable to get response from Blockstack extension");
46
+ }, 1e3);
47
+ function waitForResponse(event) {
48
+ if (event.data.source === "blockstack-extension" && event.data.method === `${methodName}Response`) {
49
+ clearTimeout(timeout);
50
+ window.removeEventListener("message", waitForResponse);
51
+ resolve(event.data);
52
+ }
53
+ }
54
+ window.addEventListener("message", waitForResponse);
55
+ window.postMessage(
56
+ {
57
+ method: methodName,
58
+ source: "blockstack-app",
59
+ ...opts
60
+ },
61
+ window.location.origin
62
+ );
63
+ });
64
+ }
65
+ function placeholderLegacyRequests() {
66
+ return {
67
+ getURL: () => {
68
+ throw new Error("This function i deprecated");
69
+ },
70
+ structuredDataSignatureRequest: () => {
71
+ throw new Error("This function is deprecated");
72
+ },
73
+ signatureRequest: () => {
74
+ throw new Error("This function is deprecated");
75
+ },
76
+ authenticationRequest: () => {
77
+ throw new Error("This function is deprecated");
78
+ },
79
+ transactionRequest: () => {
80
+ throw new Error("This function is deprecated");
81
+ },
82
+ psbtRequest: () => {
83
+ throw new Error("This function is deprecated");
84
+ },
85
+ profileUpdateRequest: () => {
86
+ throw new Error("This function is deprecated");
87
+ }
88
+ };
89
+ }
90
+ function legacyRequests() {
91
+ return {
92
+ getURL: async () => {
93
+ const { url } = await callAndReceive("getURL");
94
+ return url;
95
+ },
96
+ structuredDataSignatureRequest: async (signatureRequest) => {
97
+ const event = new CustomEvent(
98
+ "hiroWalletStructuredDataSignatureRequest" /* structuredDataSignatureRequest */,
99
+ {
100
+ detail: { signatureRequest }
101
+ }
102
+ );
103
+ document.dispatchEvent(event);
104
+ return new Promise((resolve, reject) => {
105
+ function handleMessage(event2) {
106
+ if (!isValidEvent(event2, "hiroWalletSignatureResponse" /* signatureResponse */)) return;
107
+ if (event2.data.payload?.signatureRequest !== signatureRequest) return;
108
+ window.removeEventListener("message", handleMessage);
109
+ if (event2.data.payload.signatureResponse === "cancel") {
110
+ reject(event2.data.payload.signatureResponse);
111
+ return;
112
+ }
113
+ if (typeof event2.data.payload.signatureResponse !== "string") {
114
+ resolve(event2.data.payload.signatureResponse);
115
+ }
116
+ }
117
+ window.addEventListener("message", handleMessage);
118
+ });
119
+ },
120
+ signatureRequest: async (signatureRequest) => {
121
+ const event = new CustomEvent("hiroWalletSignatureRequest" /* signatureRequest */, {
122
+ detail: { signatureRequest }
123
+ });
124
+ document.dispatchEvent(event);
125
+ return new Promise((resolve, reject) => {
126
+ function handleMessage(event2) {
127
+ if (!isValidEvent(event2, "hiroWalletSignatureResponse" /* signatureResponse */)) return;
128
+ if (event2.data.payload?.signatureRequest !== signatureRequest) return;
129
+ window.removeEventListener("message", handleMessage);
130
+ if (event2.data.payload.signatureResponse === "cancel") {
131
+ reject(event2.data.payload.signatureResponse);
132
+ return;
133
+ }
134
+ if (typeof event2.data.payload.signatureResponse !== "string") {
135
+ resolve(event2.data.payload.signatureResponse);
136
+ }
137
+ }
138
+ window.addEventListener("message", handleMessage);
139
+ });
140
+ },
141
+ authenticationRequest: async (authenticationRequest) => {
142
+ console.warn(`
143
+ WARNING: Legacy Leather request detected
144
+
145
+ Leather now uses an RPC-style API, that can be used directly,
146
+ rather than through libraries such as Stacks Connect. For example,
147
+ to get a user's addresses, you should use the
148
+ LeatherProvider.request('getAddresses') method.
149
+
150
+ See our docs for more information https://leather.gitbook.io/
151
+ `);
152
+ const event = new CustomEvent(
153
+ "hiroWalletStacksAuthenticationRequest" /* authenticationRequest */,
154
+ {
155
+ detail: { authenticationRequest }
156
+ }
157
+ );
158
+ document.dispatchEvent(event);
159
+ return new Promise((resolve, reject) => {
160
+ function handleMessage(event2) {
161
+ if (!isValidEvent(event2, "hiroWalletAuthenticationResponse" /* authenticationResponse */)) return;
162
+ if (event2.data.payload?.authenticationRequest !== authenticationRequest) return;
163
+ window.removeEventListener("message", handleMessage);
164
+ if (event2.data.payload.authenticationResponse === "cancel") {
165
+ reject(event2.data.payload.authenticationResponse);
166
+ return;
167
+ }
168
+ resolve(event2.data.payload.authenticationResponse);
169
+ }
170
+ window.addEventListener("message", handleMessage);
171
+ });
172
+ },
173
+ transactionRequest: async (transactionRequest) => {
174
+ const event = new CustomEvent(
175
+ "hiroWalletStacksTransactionRequest" /* transactionRequest */,
176
+ {
177
+ detail: { transactionRequest }
178
+ }
179
+ );
180
+ document.dispatchEvent(event);
181
+ return new Promise((resolve, reject) => {
182
+ function handleMessage(event2) {
183
+ if (!isValidEvent(event2, "hiroWalletTransactionResponse" /* transactionResponse */)) return;
184
+ if (event2.data.payload?.transactionRequest !== transactionRequest) return;
185
+ window.removeEventListener("message", handleMessage);
186
+ if (event2.data.payload.transactionResponse === "cancel") {
187
+ reject(event2.data.payload.transactionResponse);
188
+ return;
189
+ }
190
+ if (typeof event2.data.payload.transactionResponse !== "string") {
191
+ resolve(event2.data.payload.transactionResponse);
192
+ }
193
+ }
194
+ window.addEventListener("message", handleMessage);
195
+ });
196
+ },
197
+ psbtRequest: async (psbtRequest) => {
198
+ const event = new CustomEvent("hiroWalletPsbtRequest" /* psbtRequest */, {
199
+ detail: { psbtRequest }
200
+ });
201
+ document.dispatchEvent(event);
202
+ return new Promise((resolve, reject) => {
203
+ function handleMessage(event2) {
204
+ if (!isValidEvent(event2, "hiroWalletPsbtResponse" /* psbtResponse */)) return;
205
+ if (event2.data.payload?.psbtRequest !== psbtRequest) return;
206
+ window.removeEventListener("message", handleMessage);
207
+ if (event2.data.payload.psbtResponse === "cancel") {
208
+ reject(event2.data.payload.psbtResponse);
209
+ return;
210
+ }
211
+ if (typeof event2.data.payload.psbtResponse !== "string") {
212
+ resolve(event2.data.payload.psbtResponse);
213
+ }
214
+ }
215
+ window.addEventListener("message", handleMessage);
216
+ });
217
+ },
218
+ profileUpdateRequest: async (profileUpdateRequest) => {
219
+ const event = new CustomEvent(
220
+ "hiroWalletProfileUpdateRequest" /* profileUpdateRequest */,
221
+ {
222
+ detail: { profileUpdateRequest }
223
+ }
224
+ );
225
+ document.dispatchEvent(event);
226
+ return new Promise((resolve, reject) => {
227
+ function handleMessage(event2) {
228
+ if (!isValidEvent(event2, "hiroWalletProfileUpdateResponse" /* profileUpdateResponse */)) return;
229
+ if (event2.data.payload?.profileUpdateRequest !== profileUpdateRequest) return;
230
+ window.removeEventListener("message", handleMessage);
231
+ if (event2.data.payload.profileUpdateResponse === "cancel") {
232
+ reject(event2.data.payload.profileUpdateResponse);
233
+ return;
234
+ }
235
+ if (typeof event2.data.payload.profileUpdateResponse !== "string") {
236
+ resolve(event2.data.payload.profileUpdateResponse);
237
+ }
238
+ }
239
+ window.addEventListener("message", handleMessage);
240
+ });
241
+ }
242
+ };
243
+ }
244
+ function getLegacyRequests(platform) {
245
+ switch (platform) {
246
+ case "extension":
247
+ return legacyRequests();
248
+ case "mobile":
249
+ default:
250
+ return placeholderLegacyRequests();
251
+ }
252
+ }
253
+
254
+ // src/index.ts
255
+ function initInpageProvider({ onDispatch, env }) {
256
+ addLeatherToProviders();
257
+ const provider = {
258
+ isLeather: true,
259
+ ...getLegacyRequests(env.platform),
260
+ getProductInfo() {
261
+ return {
262
+ version: env.version,
263
+ name: "Leather",
264
+ meta: {
265
+ tag: env.branch,
266
+ commit: env.commitSha
267
+ }
268
+ };
269
+ },
270
+ request(method, params) {
271
+ const id = crypto.randomUUID();
272
+ const rpcRequest = {
273
+ jsonrpc: "2.0",
274
+ id,
275
+ method,
276
+ params: params ?? {}
277
+ };
278
+ onDispatch(rpcRequest);
279
+ return new Promise((resolve, reject) => {
280
+ function handleMessage(event) {
281
+ const response = typeof event.data === "object" ? event.data : JSON.parse(event.data);
282
+ if (response.id !== id) return;
283
+ window.removeEventListener("message", handleMessage);
284
+ if ("error" in response) return reject(response);
285
+ return resolve(response);
286
+ }
287
+ window.addEventListener("message", handleMessage);
288
+ });
289
+ }
290
+ };
291
+ function consoleDeprecationNotice(text) {
292
+ console.warn(`Deprecation warning: ${text}`);
293
+ }
294
+ function warnAboutDeprecatedProvider(legacyProvider) {
295
+ return Object.fromEntries(
296
+ Object.entries(legacyProvider).map(([key, value]) => {
297
+ if (typeof value === "function") {
298
+ return [
299
+ key,
300
+ (...args) => {
301
+ switch (key) {
302
+ case "authenticationRequest":
303
+ consoleDeprecationNotice(
304
+ `Use LeatherProvider.request('getAddresses') instead, see docs https://leather.gitbook.io/developers/bitcoin/connect-users/get-addresses`
305
+ );
306
+ break;
307
+ case "psbtRequest":
308
+ consoleDeprecationNotice(
309
+ `Use LeatherProvider.request('signPsbt') instead, see docs https://leather.gitbook.io/developers/bitcoin/sign-transactions/partially-signed-bitcoin-transactions-psbts`
310
+ );
311
+ break;
312
+ case "structuredDataSignatureRequest":
313
+ case "signatureRequest":
314
+ consoleDeprecationNotice(
315
+ `Use LeatherProvider.request('stx_signMessage') instead`
316
+ );
317
+ break;
318
+ default:
319
+ consoleDeprecationNotice(
320
+ "The provider object is deprecated. Use `LeatherProvider` instead"
321
+ );
322
+ }
323
+ return value(...args);
324
+ }
325
+ ];
326
+ }
327
+ return [key, value];
328
+ })
329
+ );
330
+ }
331
+ try {
332
+ Object.defineProperty(window, "StacksProvider", {
333
+ get: () => warnAboutDeprecatedProvider(provider),
334
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
335
+ set: () => {
336
+ }
337
+ });
338
+ } catch {
339
+ console.log("Unable to set StacksProvider");
340
+ }
341
+ try {
342
+ Object.defineProperty(window, "HiroWalletProvider", {
343
+ get: () => warnAboutDeprecatedProvider(provider),
344
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
345
+ set: () => {
346
+ }
347
+ });
348
+ } catch {
349
+ console.log("Unable to set HiroWalletProvider");
350
+ }
351
+ try {
352
+ Object.defineProperty(window, "LeatherProvider", {
353
+ get: () => provider,
354
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
355
+ set: () => {
356
+ }
357
+ });
358
+ } catch {
359
+ console.warn("Unable to set LeatherProvider");
360
+ }
361
+ if (typeof window.btc === "undefined") {
362
+ window.btc = warnAboutDeprecatedProvider(provider);
363
+ }
364
+ }
365
+ export {
366
+ initInpageProvider
367
+ };
368
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/add-leather-to-providers.ts","../src/legacy-requests.ts","../src/index.ts"],"sourcesContent":["import type { RpcMethodNames } from '@leather.io/rpc';\n\ninterface WalletProvider {\n id: string;\n name: string;\n icon: string;\n webUrl?: string;\n chromeWebStoreUrl?: string;\n mozillaAddOnsUrl?: string;\n googlePlayStoreUrl?: string;\n iOSAppStoreUrl?: string;\n methods?: string[];\n}\n\n// https://wbips.netlify.app/wbips/WBIP004\nexport function addLeatherToProviders() {\n const win = window as unknown as Window & { btc_providers?: WalletProvider[] };\n\n if (!win.btc_providers) win.btc_providers = [];\n\n win.btc_providers.push({\n id: 'LeatherProvider',\n name: 'Leather',\n icon: 'data:image/svg;base64,PHN2ZyB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCIgdmlld0JveD0iMCAwIDEyOCAxMjgiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSIxMjgiIGhlaWdodD0iMTI4IiByeD0iMjYuODM4NyIgZmlsbD0iIzEyMTAwRiIvPgo8cGF0aCBkPSJNNzQuOTE3MSA1Mi43MTE0QzgyLjQ3NjYgNTEuNTQwOCA5My40MDg3IDQzLjU4MDQgOTMuNDA4NyAzNy4zNzYxQzkzLjQwODcgMzUuNTAzMSA5MS44OTY4IDM0LjIxNTQgODkuNjg3MSAzNC4yMTU0Qzg1LjUwMDQgMzQuMjE1NCA3OC40MDYxIDQwLjUzNjggNzQuOTE3MSA1Mi43MTE0Wk0zOS45MTEgODMuNDk5MUMzMC4wMjU2IDgzLjQ5OTEgMjkuMjExNSA5My4zMzI0IDM5LjA5NjkgOTMuMzMyNEM0My41MTYzIDkzLjMzMjQgNDguODY2MSA5MS41NzY0IDUxLjY1NzMgODguNDE1N0M0Ny41ODY4IDg0LjkwMzggNDQuMjE0MSA4My40OTkxIDM5LjkxMSA4My40OTkxWk0xMDIuODI5IDc5LjI4NDhDMTAzLjQxIDk1Ljc5MDcgOTUuMDM2OSAxMDUuMDM5IDgwLjg0ODQgMTA1LjAzOUM3Mi40NzQ4IDEwNS4wMzkgNjguMjg4MSAxMDEuODc4IDU5LjMzMyA5Ni4wMjQ4QzU0LjY4MSAxMDEuMTc2IDQ1Ljg0MjMgMTA1LjAzOSAzOC41MTU0IDEwNS4wMzlDMTMuMjc4NSAxMDUuMDM5IDE0LjMyNTIgNzIuODQ2MyA0MC4wMjczIDcyLjg0NjNDNDUuMzc3MSA3Mi44NDYzIDQ5LjkxMjggNzQuMjUxMSA1NS43Mjc3IDc3Ljg4TDU5LjU2NTYgNjQuNDE3N0M0My43NDg5IDYwLjA4NjQgMzUuODQwNSA0Ny45MTE4IDQzLjYzMjYgMzAuNDY5M0g1Ni4xOTI5QzQ5LjIxNSA0Mi4wNTg2IDUzLjk4MzIgNTEuNjU3OCA2Mi44MjIgNTIuNzExNEM2Ny41OTAzIDM1LjczNzIgNzcuODI0NiAyMi41MDkgOTEuNDMxNiAyMi41MDlDOTkuMTA3NCAyMi41MDkgMTA1LjE1NSAyNy41NDI4IDEwNS4xNTUgMzYuNjczN0MxMDUuMTU1IDUxLjMwNjYgODYuMDgxOSA2My4yNDcxIDcxLjY2MDcgNjQuNDE3N0w2NS43Mjk1IDg1LjM3MjFDNzIuNDc0OCA5My4yMTUzIDkxLjE5OSAxMDAuODI0IDkxLjE5OSA3OS4yODQ4SDEwMi44MjlaIiBmaWxsPSIjRjdGNUYzIi8+Cjwvc3ZnPgo=',\n\n webUrl: 'https://leather.io',\n\n chromeWebStoreUrl:\n 'https://chromewebstore.google.com/detail/leather/ldinpeekobnhjjdofggfgjlcehhmanlj',\n\n methods: [\n 'open',\n 'getInfo',\n 'supportedMethods',\n 'openSwap',\n 'getAddresses',\n 'stx_updateProfile',\n 'stx_signMessage',\n 'stx_transferStx',\n 'stx_transferSip10Ft',\n 'stx_signTransaction',\n 'stx_signStructuredMessage',\n 'stx_getAddresses',\n 'stx_deployContract',\n 'stx_callContract',\n 'signPsbt',\n 'signMessage',\n 'sendTransfer',\n // Better to import a type than a variable from @leather.io/rpc to save a lot of space in the injected provider script\n ] satisfies RpcMethodNames[],\n });\n}\n","import { StacksProvider } from '@stacks/connect';\nimport {\n FinishedTxPayload,\n PsbtData,\n SignatureData,\n SponsoredFinishedTxPayload,\n} from '@stacks/connect-jwt';\nimport { PublicProfile } from '@stacks/profile';\n\nimport type { Platform } from './types';\n\n/**\n * Inpage Script (LeatherProvider) <-> Content Script\n */\nenum DomEventName {\n request = 'request',\n authenticationRequest = 'hiroWalletStacksAuthenticationRequest',\n signatureRequest = 'hiroWalletSignatureRequest',\n structuredDataSignatureRequest = 'hiroWalletStructuredDataSignatureRequest',\n transactionRequest = 'hiroWalletStacksTransactionRequest',\n profileUpdateRequest = 'hiroWalletProfileUpdateRequest',\n psbtRequest = 'hiroWalletPsbtRequest',\n}\n\ninterface AuthenticationRequestEventDetails {\n authenticationRequest: string;\n}\n\ninterface SignatureRequestEventDetails {\n signatureRequest: string;\n}\n\ninterface TransactionRequestEventDetails {\n transactionRequest: string;\n}\n\ninterface ProfileUpdateRequestEventDetails {\n profileUpdateRequest: string;\n}\n\ninterface PsbtRequestEventDetails {\n psbtRequest: string;\n}\n\nconst MESSAGE_SOURCE = 'stacks-wallet';\n\nenum ExternalMethods {\n transactionRequest = 'hiroWalletTransactionRequest',\n transactionResponse = 'hiroWalletTransactionResponse',\n authenticationRequest = 'hiroWalletAuthenticationRequest',\n authenticationResponse = 'hiroWalletAuthenticationResponse',\n signatureRequest = 'hiroWalletSignatureRequest',\n signatureResponse = 'hiroWalletSignatureResponse',\n structuredDataSignatureRequest = 'hiroWalletStructuredDataSignatureRequest',\n structuredDataSignatureResponse = 'hiroWalletStructuredDataSignatureResponse',\n profileUpdateRequest = 'hiroWalletProfileUpdateRequest',\n profileUpdateResponse = 'hiroWalletProfileUpdateResponse',\n psbtRequest = 'hiroWalletPsbtRequest',\n psbtResponse = 'hiroWalletPsbtResponse',\n}\n\nenum InternalMethods {\n RequestDerivedStxAccounts = 'RequestDerivedStxAccounts',\n OriginatingTabClosed = 'OriginatingTabClosed',\n AccountChanged = 'AccountChanged',\n AddressMonitorUpdated = 'AddressMonitorUpdated',\n}\n\ntype ExtensionMethods = ExternalMethods | InternalMethods;\n\ninterface BaseMessage {\n source: typeof MESSAGE_SOURCE;\n method: ExtensionMethods;\n}\n\n/**\n * Content Script <-> Background Script\n */\ninterface Message<Methods extends ExtensionMethods, Payload = undefined> extends BaseMessage {\n method: Methods;\n payload: Payload;\n}\n\ntype AuthenticationResponseMessage = Message<\n ExternalMethods.authenticationResponse,\n {\n authenticationRequest: string;\n authenticationResponse: string;\n }\n>;\n\ntype SignatureResponseMessage = Message<\n ExternalMethods.signatureResponse,\n {\n signatureRequest: string;\n signatureResponse: SignatureData | string;\n }\n>;\n\ntype ProfileUpdateResponseMessage = Message<\n ExternalMethods.profileUpdateResponse,\n {\n profileUpdateRequest: string;\n profileUpdateResponse: PublicProfile | string;\n }\n>;\n\ntype PsbtResponseMessage = Message<\n ExternalMethods.psbtResponse,\n {\n psbtRequest: string;\n psbtResponse: PsbtData | string;\n }\n>;\n\ntype TxResult = SponsoredFinishedTxPayload | FinishedTxPayload;\n\ntype TransactionResponseMessage = Message<\n ExternalMethods.transactionResponse,\n {\n transactionRequest: string;\n transactionResponse: TxResult | string;\n }\n>;\n\ntype LegacyMessageToContentScript =\n | AuthenticationResponseMessage\n | TransactionResponseMessage\n | SignatureResponseMessage\n | ProfileUpdateResponseMessage\n | PsbtResponseMessage;\n\nfunction isValidEvent(event: MessageEvent, method: LegacyMessageToContentScript['method']) {\n const { data } = event;\n const correctSource = data.source === MESSAGE_SOURCE;\n const correctMethod = data.method === method;\n return correctSource && correctMethod && !!data.payload;\n}\n\ntype CallableMethods = keyof typeof ExternalMethods;\n\ninterface ExtensionResponse {\n source: 'blockstack-extension';\n method: CallableMethods;\n [key: string]: any;\n}\n\nasync function callAndReceive(\n methodName: CallableMethods | 'getURL',\n opts: any = {}\n): Promise<ExtensionResponse> {\n return new Promise((resolve, reject) => {\n const timeout = setTimeout(() => {\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n reject('Unable to get response from Blockstack extension');\n }, 1000);\n function waitForResponse(event: MessageEvent) {\n if (\n event.data.source === 'blockstack-extension' &&\n event.data.method === `${methodName}Response`\n ) {\n clearTimeout(timeout);\n window.removeEventListener('message', waitForResponse);\n resolve(event.data);\n }\n }\n window.addEventListener('message', waitForResponse);\n window.postMessage(\n {\n method: methodName,\n source: 'blockstack-app',\n ...opts,\n },\n window.location.origin\n );\n });\n}\n\ntype LegacyRequests = Omit<StacksProvider, 'request' | 'getProductInfo'>;\n\nfunction placeholderLegacyRequests(): LegacyRequests {\n return {\n getURL: () => {\n // TODO: deprecated\n throw new Error('This function i deprecated');\n },\n structuredDataSignatureRequest: () => {\n // TODO: deprecated\n throw new Error('This function is deprecated');\n },\n\n signatureRequest: () => {\n // TODO: deprecated\n throw new Error('This function is deprecated');\n },\n\n authenticationRequest: () => {\n // TODO: deprecated\n throw new Error('This function is deprecated');\n },\n\n transactionRequest: () => {\n // TODO: deprecated\n throw new Error('This function is deprecated');\n },\n psbtRequest: () => {\n // TODO: deprecated\n throw new Error('This function is deprecated');\n },\n profileUpdateRequest: () => {\n // TODO: deprecated\n throw new Error('This function is deprecated');\n },\n };\n}\n\nfunction legacyRequests(): LegacyRequests {\n return {\n getURL: async () => {\n const { url } = await callAndReceive('getURL');\n return url;\n },\n structuredDataSignatureRequest: async signatureRequest => {\n const event = new CustomEvent<SignatureRequestEventDetails>(\n DomEventName.structuredDataSignatureRequest,\n {\n detail: { signatureRequest },\n }\n );\n document.dispatchEvent(event);\n return new Promise((resolve, reject) => {\n function handleMessage(event: MessageEvent<SignatureResponseMessage>) {\n if (!isValidEvent(event, ExternalMethods.signatureResponse)) return;\n if (event.data.payload?.signatureRequest !== signatureRequest) return;\n window.removeEventListener('message', handleMessage);\n if (event.data.payload.signatureResponse === 'cancel') {\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n reject(event.data.payload.signatureResponse);\n return;\n }\n if (typeof event.data.payload.signatureResponse !== 'string') {\n resolve(event.data.payload.signatureResponse);\n }\n }\n window.addEventListener('message', handleMessage);\n });\n },\n\n signatureRequest: async signatureRequest => {\n const event = new CustomEvent<SignatureRequestEventDetails>(DomEventName.signatureRequest, {\n detail: { signatureRequest },\n });\n document.dispatchEvent(event);\n return new Promise((resolve, reject) => {\n function handleMessage(event: MessageEvent<SignatureResponseMessage>) {\n if (!isValidEvent(event, ExternalMethods.signatureResponse)) return;\n if (event.data.payload?.signatureRequest !== signatureRequest) return;\n window.removeEventListener('message', handleMessage);\n if (event.data.payload.signatureResponse === 'cancel') {\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n reject(event.data.payload.signatureResponse);\n return;\n }\n if (typeof event.data.payload.signatureResponse !== 'string') {\n resolve(event.data.payload.signatureResponse);\n }\n }\n window.addEventListener('message', handleMessage);\n });\n },\n\n authenticationRequest: async authenticationRequest => {\n // eslint-disable-next-line no-console\n console.warn(`\n WARNING: Legacy Leather request detected\n\n Leather now uses an RPC-style API, that can be used directly,\n rather than through libraries such as Stacks Connect. For example,\n to get a user's addresses, you should use the\n LeatherProvider.request('getAddresses') method.\n\n See our docs for more information https://leather.gitbook.io/\n `);\n const event = new CustomEvent<AuthenticationRequestEventDetails>(\n DomEventName.authenticationRequest,\n {\n detail: { authenticationRequest },\n }\n );\n document.dispatchEvent(event);\n return new Promise((resolve, reject) => {\n function handleMessage(event: MessageEvent<AuthenticationResponseMessage>) {\n if (!isValidEvent(event, ExternalMethods.authenticationResponse)) return;\n if (event.data.payload?.authenticationRequest !== authenticationRequest) return;\n window.removeEventListener('message', handleMessage);\n if (event.data.payload.authenticationResponse === 'cancel') {\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n reject(event.data.payload.authenticationResponse);\n return;\n }\n resolve(event.data.payload.authenticationResponse);\n }\n window.addEventListener('message', handleMessage);\n });\n },\n\n transactionRequest: async transactionRequest => {\n const event = new CustomEvent<TransactionRequestEventDetails>(\n DomEventName.transactionRequest,\n {\n detail: { transactionRequest },\n }\n );\n document.dispatchEvent(event);\n return new Promise((resolve, reject) => {\n function handleMessage(event: MessageEvent<TransactionResponseMessage>) {\n if (!isValidEvent(event, ExternalMethods.transactionResponse)) return;\n if (event.data.payload?.transactionRequest !== transactionRequest) return;\n window.removeEventListener('message', handleMessage);\n if (event.data.payload.transactionResponse === 'cancel') {\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n reject(event.data.payload.transactionResponse);\n return;\n }\n if (typeof event.data.payload.transactionResponse !== 'string') {\n resolve(event.data.payload.transactionResponse);\n }\n }\n window.addEventListener('message', handleMessage);\n });\n },\n psbtRequest: async psbtRequest => {\n const event = new CustomEvent<PsbtRequestEventDetails>(DomEventName.psbtRequest, {\n detail: { psbtRequest },\n });\n document.dispatchEvent(event);\n return new Promise((resolve, reject) => {\n function handleMessage(event: MessageEvent<PsbtResponseMessage>) {\n if (!isValidEvent(event, ExternalMethods.psbtResponse)) return;\n if (event.data.payload?.psbtRequest !== psbtRequest) return;\n window.removeEventListener('message', handleMessage);\n if (event.data.payload.psbtResponse === 'cancel') {\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n reject(event.data.payload.psbtResponse);\n return;\n }\n if (typeof event.data.payload.psbtResponse !== 'string') {\n resolve(event.data.payload.psbtResponse);\n }\n }\n window.addEventListener('message', handleMessage);\n });\n },\n profileUpdateRequest: async profileUpdateRequest => {\n const event = new CustomEvent<ProfileUpdateRequestEventDetails>(\n DomEventName.profileUpdateRequest,\n {\n detail: { profileUpdateRequest },\n }\n );\n document.dispatchEvent(event);\n return new Promise((resolve, reject) => {\n function handleMessage(event: MessageEvent<ProfileUpdateResponseMessage>) {\n if (!isValidEvent(event, ExternalMethods.profileUpdateResponse)) return;\n if (event.data.payload?.profileUpdateRequest !== profileUpdateRequest) return;\n window.removeEventListener('message', handleMessage);\n if (event.data.payload.profileUpdateResponse === 'cancel') {\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n reject(event.data.payload.profileUpdateResponse);\n return;\n }\n if (typeof event.data.payload.profileUpdateResponse !== 'string') {\n resolve(event.data.payload.profileUpdateResponse);\n }\n }\n window.addEventListener('message', handleMessage);\n });\n },\n };\n}\n\nexport function getLegacyRequests(platform: Platform) {\n switch (platform) {\n case 'extension':\n return legacyRequests();\n case 'mobile':\n default:\n return placeholderLegacyRequests();\n }\n}\n","import type { StacksProvider } from '@stacks/connect';\n\nimport {\n type LeatherRpcMethodMap,\n type RpcMethodNames,\n type RpcParameter,\n RpcRequests,\n type RpcResponses,\n} from '@leather.io/rpc';\n\nimport { addLeatherToProviders } from './add-leather-to-providers';\nimport { getLegacyRequests } from './legacy-requests';\nimport { Platform } from './types';\n\ninterface initInpageProviderArgs {\n onDispatch(rpcRequest: RpcRequests): void;\n env: { branch: string; commitSha: string; version: string; platform: Platform };\n}\n\nexport function initInpageProvider({ onDispatch, env }: initInpageProviderArgs) {\n addLeatherToProviders();\n\n interface LeatherProviderOverrides extends StacksProvider {\n isLeather: true;\n }\n\n const provider: LeatherProviderOverrides = {\n isLeather: true,\n\n ...getLegacyRequests(env.platform),\n\n getProductInfo() {\n return {\n version: env.version,\n name: 'Leather',\n meta: {\n tag: env.branch,\n commit: env.commitSha,\n },\n };\n },\n\n request(\n method: RpcMethodNames,\n params?: RpcParameter\n ): Promise<LeatherRpcMethodMap[RpcMethodNames]['response']> {\n const id: string = crypto.randomUUID();\n const rpcRequest: RpcRequests = {\n jsonrpc: '2.0',\n id,\n method,\n params: (params ?? {}) as any,\n };\n\n onDispatch(rpcRequest);\n\n return new Promise((resolve, reject) => {\n function handleMessage(event: MessageEvent<RpcResponses>) {\n const response =\n typeof event.data === 'object' ? event.data : JSON.parse(event.data as any);\n if (response.id !== id) return;\n window.removeEventListener('message', handleMessage);\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n if ('error' in response) return reject(response);\n return resolve(response);\n }\n window.addEventListener('message', handleMessage);\n });\n },\n };\n\n function consoleDeprecationNotice(text: string) {\n // eslint-disable-next-line no-console\n console.warn(`Deprecation warning: ${text}`);\n }\n\n function warnAboutDeprecatedProvider(legacyProvider: object) {\n return Object.fromEntries(\n Object.entries(legacyProvider).map(([key, value]) => {\n if (typeof value === 'function') {\n return [\n key,\n (...args: any[]) => {\n switch (key) {\n case 'authenticationRequest':\n consoleDeprecationNotice(\n `Use LeatherProvider.request('getAddresses') instead, see docs https://leather.gitbook.io/developers/bitcoin/connect-users/get-addresses`\n );\n break;\n case 'psbtRequest':\n consoleDeprecationNotice(\n `Use LeatherProvider.request('signPsbt') instead, see docs https://leather.gitbook.io/developers/bitcoin/sign-transactions/partially-signed-bitcoin-transactions-psbts`\n );\n break;\n case 'structuredDataSignatureRequest':\n case 'signatureRequest':\n consoleDeprecationNotice(\n `Use LeatherProvider.request('stx_signMessage') instead`\n );\n break;\n default:\n consoleDeprecationNotice(\n 'The provider object is deprecated. Use `LeatherProvider` instead'\n );\n }\n\n return value(...args);\n },\n ];\n }\n return [key, value];\n })\n );\n }\n\n try {\n // Makes properties immutable to contend with other wallets that use agressive\n // \"prioritisation\" default settings. As other wallet's use this approach,\n // Leather has to use it too, so that the browsers' own internal logic being\n // used to determine content script exeuction order. A more fair way to\n // contend over shared provider space. `StacksProvider` should be considered\n // deprecated and each wallet use their own provider namespace.\n Object.defineProperty(window, 'StacksProvider', {\n get: () => warnAboutDeprecatedProvider(provider),\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n set: () => {},\n });\n } catch {\n // eslint-disable-next-line no-console\n console.log('Unable to set StacksProvider');\n }\n\n try {\n Object.defineProperty(window, 'HiroWalletProvider', {\n get: () => warnAboutDeprecatedProvider(provider),\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n set: () => {},\n });\n } catch {\n // eslint-disable-next-line no-console\n console.log('Unable to set HiroWalletProvider');\n }\n\n try {\n Object.defineProperty(window, 'LeatherProvider', {\n get: () => provider,\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n set: () => {},\n });\n } catch {\n // eslint-disable-next-line no-console\n console.warn('Unable to set LeatherProvider');\n }\n\n // Legacy product provider objects\n if (typeof (window as any).btc === 'undefined') {\n (window as any).btc = warnAboutDeprecatedProvider(provider);\n }\n}\n"],"mappings":";AAeO,SAAS,wBAAwB;AACtC,QAAM,MAAM;AAEZ,MAAI,CAAC,IAAI,cAAe,KAAI,gBAAgB,CAAC;AAE7C,MAAI,cAAc,KAAK;AAAA,IACrB,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,MAAM;AAAA,IAEN,QAAQ;AAAA,IAER,mBACE;AAAA,IAEF,SAAS;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,IAEF;AAAA,EACF,CAAC;AACH;;;ACPA,IAAM,iBAAiB;AAwFvB,SAAS,aAAa,OAAqB,QAAgD;AACzF,QAAM,EAAE,KAAK,IAAI;AACjB,QAAM,gBAAgB,KAAK,WAAW;AACtC,QAAM,gBAAgB,KAAK,WAAW;AACtC,SAAO,iBAAiB,iBAAiB,CAAC,CAAC,KAAK;AAClD;AAUA,eAAe,eACb,YACA,OAAY,CAAC,GACe;AAC5B,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,UAAM,UAAU,WAAW,MAAM;AAE/B,aAAO,kDAAkD;AAAA,IAC3D,GAAG,GAAI;AACP,aAAS,gBAAgB,OAAqB;AAC5C,UACE,MAAM,KAAK,WAAW,0BACtB,M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SAAgB;AAClB,sBAAQ,KAAK;AAAA,gBACX,KAAK;AACH;AAAA,oBACE;AAAA,kBACF;AACA;AAAA,gBACF,KAAK;AACH;AAAA,oBACE;AAAA,kBACF;AACA;AAAA,gBACF,KAAK;AAAA,gBACL,KAAK;AACH;AAAA,oBACE;AAAA,kBACF;AACA;AAAA,gBACF;AACE;AAAA,oBACE;AAAA,kBACF;AAAA,cACJ;AAEA,qBAAO,MAAM,GAAG,IAAI;AAAA,YACtB;AAAA,UACF;AAAA,QACF;AACA,eAAO,CAAC,KAAK,KAAK;AAAA,MACpB,CAAC;AAAA,IACH;AAAA,EACF;AAEA,MAAI;AAOF,WAAO,eAAe,QAAQ,kBAAkB;AAAA,MAC9C,KAAK,MAAM,4BAA4B,QAAQ;AAAA;AAAA,MAE/C,KAAK,MAAM;AAAA,MAAC;AAAA,IACd,CAAC;AAAA,EACH,QAAQ;AAEN,YAAQ,IAAI,8BAA8B;AAAA,EAC5C;AAEA,MAAI;AACF,WAAO,eAAe,QAAQ,sBAAsB;AAAA,MAClD,KAAK,MAAM,4BAA4B,QAAQ;AAAA;AAAA,MAE/C,KAAK,MAAM;AAAA,MAAC;AAAA,IACd,CAAC;AAAA,EACH,QAAQ;AAEN,YAAQ,IAAI,kCAAkC;AAAA,EAChD;AAEA,MAAI;AACF,WAAO,eAAe,QAAQ,mBAAmB;AAAA,MAC/C,KAAK,MAAM;AAAA;AAAA,MAEX,KAAK,MAAM;AAAA,MAAC;AAAA,IACd,CAAC;AAAA,EACH,QAAQ;AAEN,YAAQ,KAAK,+BAA+B;AAAA,EAC9C;AAGA,MAAI,OAAQ,OAAe,QAAQ,aAAa;AAC9C,IAAC,OAAe,MAAM,4BAA4B,QAAQ;AAAA,EAC5D;AACF;","names":["event"]}
@@ -0,0 +1,7 @@
1
+ declare const _default: (_: {
2
+ branch: string;
3
+ commitSha: string;
4
+ version: string;
5
+ }) => string;
6
+
7
+ export { _default as default };