@metamask/snaps-utils 7.2.0 → 7.4.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/CHANGELOG.md +18 -1
- package/dist/{chunk-4LELSKWG.js → chunk-3ZSYZX3I.js} +3 -3
- package/dist/chunk-4YAWNZXM.js +262 -0
- package/dist/chunk-4YAWNZXM.js.map +1 -0
- package/dist/{chunk-E5WSD47S.js → chunk-IAHW6IFC.js} +9 -3
- package/dist/chunk-IAHW6IFC.js.map +1 -0
- package/dist/{chunk-XNUUUOKX.js → chunk-KSRDEGBC.js} +6 -1
- package/dist/chunk-KSRDEGBC.js.map +1 -0
- package/dist/{chunk-I77AVJKV.mjs → chunk-L4DKSTK6.mjs} +5 -5
- package/dist/chunk-L4DKSTK6.mjs.map +1 -0
- package/dist/chunk-MJGSG5N2.mjs +262 -0
- package/dist/chunk-MJGSG5N2.mjs.map +1 -0
- package/dist/{chunk-D7Z3SN2N.js → chunk-N4KSSDO5.js} +3 -3
- package/dist/{chunk-HTS6HGUU.mjs → chunk-QNPXK3B3.mjs} +8 -2
- package/dist/chunk-QNPXK3B3.mjs.map +1 -0
- package/dist/{chunk-PBSBESZZ.mjs → chunk-RLA43SHY.mjs} +2 -2
- package/dist/{chunk-2OJY3BXD.mjs → chunk-UCRFECSX.mjs} +2 -2
- package/dist/{chunk-PBXAWRWW.mjs → chunk-X3XJN63W.mjs} +6 -1
- package/dist/chunk-X3XJN63W.mjs.map +1 -0
- package/dist/{chunk-3SOYDY4W.js → chunk-ZUSNAQJU.js} +4 -4
- package/dist/chunk-ZUSNAQJU.js.map +1 -0
- package/dist/derivation-paths.js +2 -2
- package/dist/derivation-paths.mjs +1 -1
- package/dist/handlers.js +2 -2
- package/dist/handlers.mjs +1 -1
- package/dist/index.executionenv.js +2 -2
- package/dist/index.executionenv.mjs +1 -1
- package/dist/index.js +18 -8
- package/dist/index.mjs +22 -12
- package/dist/manifest/index.js +4 -2
- package/dist/manifest/index.mjs +3 -1
- package/dist/manifest/manifest.js +3 -3
- package/dist/manifest/manifest.mjs +2 -2
- package/dist/manifest/node.js +5 -3
- package/dist/manifest/node.mjs +4 -2
- package/dist/manifest/validation.js +4 -2
- package/dist/manifest/validation.mjs +3 -1
- package/dist/node.js +19 -9
- package/dist/node.mjs +22 -12
- package/dist/npm.js +3 -3
- package/dist/npm.mjs +2 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/handlers.d.ts +89 -89
- package/dist/types/manifest/validation.d.ts +7 -11
- package/dist/types/ui.d.ts +51 -11
- package/dist/ui.js +10 -2
- package/dist/ui.mjs +13 -5
- package/dist/validation.js +3 -3
- package/dist/validation.mjs +2 -2
- package/package.json +4 -4
- package/dist/chunk-3SOYDY4W.js.map +0 -1
- package/dist/chunk-E5WSD47S.js.map +0 -1
- package/dist/chunk-HTS6HGUU.mjs.map +0 -1
- package/dist/chunk-I77AVJKV.mjs.map +0 -1
- package/dist/chunk-KP4ZAWMP.mjs +0 -80
- package/dist/chunk-KP4ZAWMP.mjs.map +0 -1
- package/dist/chunk-NDIITWO4.js +0 -80
- package/dist/chunk-NDIITWO4.js.map +0 -1
- package/dist/chunk-PBXAWRWW.mjs.map +0 -1
- package/dist/chunk-XNUUUOKX.js.map +0 -1
- /package/dist/{chunk-4LELSKWG.js.map → chunk-3ZSYZX3I.js.map} +0 -0
- /package/dist/{chunk-D7Z3SN2N.js.map → chunk-N4KSSDO5.js.map} +0 -0
- /package/dist/{chunk-PBSBESZZ.mjs.map → chunk-RLA43SHY.mjs.map} +0 -0
- /package/dist/{chunk-2OJY3BXD.mjs.map → chunk-UCRFECSX.mjs.map} +0 -0
package/dist/types/handlers.d.ts
CHANGED
|
@@ -55,7 +55,7 @@ export declare const SNAP_EXPORTS: {
|
|
|
55
55
|
};
|
|
56
56
|
readonly onUserInput: {
|
|
57
57
|
readonly type: HandlerType.OnUserInput;
|
|
58
|
-
readonly required:
|
|
58
|
+
readonly required: false;
|
|
59
59
|
readonly validator: (snapExport: unknown) => snapExport is OnUserInputHandler;
|
|
60
60
|
};
|
|
61
61
|
};
|
|
@@ -72,39 +72,7 @@ export declare const OnTransactionResponseWithIdStruct: import("superstruct").St
|
|
|
72
72
|
severity: import("superstruct").Struct<SeverityLevel | undefined, SeverityLevel>;
|
|
73
73
|
}>;
|
|
74
74
|
export declare const OnTransactionResponseWithContentStruct: import("superstruct").Struct<{
|
|
75
|
-
content: import("@metamask/snaps-sdk").Panel | {
|
|
76
|
-
type: import("@metamask/snaps-sdk").NodeType.Input;
|
|
77
|
-
name: string;
|
|
78
|
-
value?: string | undefined;
|
|
79
|
-
error?: string | undefined;
|
|
80
|
-
inputType?: "number" | "text" | "password" | undefined;
|
|
81
|
-
placeholder?: string | undefined;
|
|
82
|
-
label?: string | undefined;
|
|
83
|
-
} | {
|
|
84
|
-
value: string;
|
|
85
|
-
type: import("@metamask/snaps-sdk").NodeType.Button;
|
|
86
|
-
name?: string | undefined;
|
|
87
|
-
variant?: "primary" | "secondary" | undefined;
|
|
88
|
-
buttonType?: "button" | "submit" | undefined;
|
|
89
|
-
} | {
|
|
90
|
-
type: import("@metamask/snaps-sdk").NodeType.Form;
|
|
91
|
-
name: string;
|
|
92
|
-
children: ({
|
|
93
|
-
type: import("@metamask/snaps-sdk").NodeType.Input;
|
|
94
|
-
name: string;
|
|
95
|
-
value?: string | undefined;
|
|
96
|
-
error?: string | undefined;
|
|
97
|
-
inputType?: "number" | "text" | "password" | undefined;
|
|
98
|
-
placeholder?: string | undefined;
|
|
99
|
-
label?: string | undefined;
|
|
100
|
-
} | {
|
|
101
|
-
value: string;
|
|
102
|
-
type: import("@metamask/snaps-sdk").NodeType.Button;
|
|
103
|
-
name?: string | undefined;
|
|
104
|
-
variant?: "primary" | "secondary" | undefined;
|
|
105
|
-
buttonType?: "button" | "submit" | undefined;
|
|
106
|
-
})[];
|
|
107
|
-
} | {
|
|
75
|
+
content: import("@metamask/snaps-sdk/jsx-runtime").JSXElement | import("@metamask/snaps-sdk").Panel | {
|
|
108
76
|
value: string;
|
|
109
77
|
type: import("@metamask/snaps-sdk").NodeType.Copyable;
|
|
110
78
|
sensitive?: boolean | undefined;
|
|
@@ -140,17 +108,14 @@ export declare const OnTransactionResponseWithContentStruct: import("superstruct
|
|
|
140
108
|
type: import("@metamask/snaps-sdk").NodeType.Row;
|
|
141
109
|
label: string;
|
|
142
110
|
variant?: "default" | "warning" | "critical" | undefined;
|
|
143
|
-
}
|
|
144
|
-
severity?: SeverityLevel | undefined;
|
|
145
|
-
}, {
|
|
146
|
-
content: import("superstruct").Struct<import("@metamask/snaps-sdk").Panel | {
|
|
111
|
+
} | {
|
|
147
112
|
type: import("@metamask/snaps-sdk").NodeType.Input;
|
|
148
113
|
name: string;
|
|
149
114
|
value?: string | undefined;
|
|
150
115
|
error?: string | undefined;
|
|
151
|
-
inputType?: "number" | "text" | "password" | undefined;
|
|
152
116
|
placeholder?: string | undefined;
|
|
153
117
|
label?: string | undefined;
|
|
118
|
+
inputType?: "number" | "text" | "password" | undefined;
|
|
154
119
|
} | {
|
|
155
120
|
value: string;
|
|
156
121
|
type: import("@metamask/snaps-sdk").NodeType.Button;
|
|
@@ -165,9 +130,9 @@ export declare const OnTransactionResponseWithContentStruct: import("superstruct
|
|
|
165
130
|
name: string;
|
|
166
131
|
value?: string | undefined;
|
|
167
132
|
error?: string | undefined;
|
|
168
|
-
inputType?: "number" | "text" | "password" | undefined;
|
|
169
133
|
placeholder?: string | undefined;
|
|
170
134
|
label?: string | undefined;
|
|
135
|
+
inputType?: "number" | "text" | "password" | undefined;
|
|
171
136
|
} | {
|
|
172
137
|
value: string;
|
|
173
138
|
type: import("@metamask/snaps-sdk").NodeType.Button;
|
|
@@ -175,7 +140,10 @@ export declare const OnTransactionResponseWithContentStruct: import("superstruct
|
|
|
175
140
|
variant?: "primary" | "secondary" | undefined;
|
|
176
141
|
buttonType?: "button" | "submit" | undefined;
|
|
177
142
|
})[];
|
|
178
|
-
}
|
|
143
|
+
};
|
|
144
|
+
severity?: SeverityLevel | undefined;
|
|
145
|
+
}, {
|
|
146
|
+
content: import("superstruct").Struct<import("@metamask/snaps-sdk/jsx-runtime").JSXElement | import("@metamask/snaps-sdk").Panel | {
|
|
179
147
|
value: string;
|
|
180
148
|
type: import("@metamask/snaps-sdk").NodeType.Copyable;
|
|
181
149
|
sensitive?: boolean | undefined;
|
|
@@ -211,21 +179,14 @@ export declare const OnTransactionResponseWithContentStruct: import("superstruct
|
|
|
211
179
|
type: import("@metamask/snaps-sdk").NodeType.Row;
|
|
212
180
|
label: string;
|
|
213
181
|
variant?: "default" | "warning" | "critical" | undefined;
|
|
214
|
-
}
|
|
215
|
-
severity: import("superstruct").Struct<SeverityLevel | undefined, SeverityLevel>;
|
|
216
|
-
}>;
|
|
217
|
-
export declare const OnTransactionResponseStruct: import("superstruct").Struct<{
|
|
218
|
-
id: string;
|
|
219
|
-
severity?: SeverityLevel | undefined;
|
|
220
|
-
} | {
|
|
221
|
-
content: import("@metamask/snaps-sdk").Panel | {
|
|
182
|
+
} | {
|
|
222
183
|
type: import("@metamask/snaps-sdk").NodeType.Input;
|
|
223
184
|
name: string;
|
|
224
185
|
value?: string | undefined;
|
|
225
186
|
error?: string | undefined;
|
|
226
|
-
inputType?: "number" | "text" | "password" | undefined;
|
|
227
187
|
placeholder?: string | undefined;
|
|
228
188
|
label?: string | undefined;
|
|
189
|
+
inputType?: "number" | "text" | "password" | undefined;
|
|
229
190
|
} | {
|
|
230
191
|
value: string;
|
|
231
192
|
type: import("@metamask/snaps-sdk").NodeType.Button;
|
|
@@ -240,9 +201,9 @@ export declare const OnTransactionResponseStruct: import("superstruct").Struct<{
|
|
|
240
201
|
name: string;
|
|
241
202
|
value?: string | undefined;
|
|
242
203
|
error?: string | undefined;
|
|
243
|
-
inputType?: "number" | "text" | "password" | undefined;
|
|
244
204
|
placeholder?: string | undefined;
|
|
245
205
|
label?: string | undefined;
|
|
206
|
+
inputType?: "number" | "text" | "password" | undefined;
|
|
246
207
|
} | {
|
|
247
208
|
value: string;
|
|
248
209
|
type: import("@metamask/snaps-sdk").NodeType.Button;
|
|
@@ -250,7 +211,14 @@ export declare const OnTransactionResponseStruct: import("superstruct").Struct<{
|
|
|
250
211
|
variant?: "primary" | "secondary" | undefined;
|
|
251
212
|
buttonType?: "button" | "submit" | undefined;
|
|
252
213
|
})[];
|
|
253
|
-
}
|
|
214
|
+
}, null>;
|
|
215
|
+
severity: import("superstruct").Struct<SeverityLevel | undefined, SeverityLevel>;
|
|
216
|
+
}>;
|
|
217
|
+
export declare const OnTransactionResponseStruct: import("superstruct").Struct<{
|
|
218
|
+
id: string;
|
|
219
|
+
severity?: SeverityLevel | undefined;
|
|
220
|
+
} | {
|
|
221
|
+
content: import("@metamask/snaps-sdk/jsx-runtime").JSXElement | import("@metamask/snaps-sdk").Panel | {
|
|
254
222
|
value: string;
|
|
255
223
|
type: import("@metamask/snaps-sdk").NodeType.Copyable;
|
|
256
224
|
sensitive?: boolean | undefined;
|
|
@@ -286,21 +254,14 @@ export declare const OnTransactionResponseStruct: import("superstruct").Struct<{
|
|
|
286
254
|
type: import("@metamask/snaps-sdk").NodeType.Row;
|
|
287
255
|
label: string;
|
|
288
256
|
variant?: "default" | "warning" | "critical" | undefined;
|
|
289
|
-
}
|
|
290
|
-
severity?: SeverityLevel | undefined;
|
|
291
|
-
} | null, null>;
|
|
292
|
-
export declare const OnSignatureResponseStruct: import("superstruct").Struct<{
|
|
293
|
-
id: string;
|
|
294
|
-
severity?: SeverityLevel | undefined;
|
|
295
|
-
} | {
|
|
296
|
-
content: import("@metamask/snaps-sdk").Panel | {
|
|
257
|
+
} | {
|
|
297
258
|
type: import("@metamask/snaps-sdk").NodeType.Input;
|
|
298
259
|
name: string;
|
|
299
260
|
value?: string | undefined;
|
|
300
261
|
error?: string | undefined;
|
|
301
|
-
inputType?: "number" | "text" | "password" | undefined;
|
|
302
262
|
placeholder?: string | undefined;
|
|
303
263
|
label?: string | undefined;
|
|
264
|
+
inputType?: "number" | "text" | "password" | undefined;
|
|
304
265
|
} | {
|
|
305
266
|
value: string;
|
|
306
267
|
type: import("@metamask/snaps-sdk").NodeType.Button;
|
|
@@ -315,9 +276,9 @@ export declare const OnSignatureResponseStruct: import("superstruct").Struct<{
|
|
|
315
276
|
name: string;
|
|
316
277
|
value?: string | undefined;
|
|
317
278
|
error?: string | undefined;
|
|
318
|
-
inputType?: "number" | "text" | "password" | undefined;
|
|
319
279
|
placeholder?: string | undefined;
|
|
320
280
|
label?: string | undefined;
|
|
281
|
+
inputType?: "number" | "text" | "password" | undefined;
|
|
321
282
|
} | {
|
|
322
283
|
value: string;
|
|
323
284
|
type: import("@metamask/snaps-sdk").NodeType.Button;
|
|
@@ -325,7 +286,14 @@ export declare const OnSignatureResponseStruct: import("superstruct").Struct<{
|
|
|
325
286
|
variant?: "primary" | "secondary" | undefined;
|
|
326
287
|
buttonType?: "button" | "submit" | undefined;
|
|
327
288
|
})[];
|
|
328
|
-
}
|
|
289
|
+
};
|
|
290
|
+
severity?: SeverityLevel | undefined;
|
|
291
|
+
} | null, null>;
|
|
292
|
+
export declare const OnSignatureResponseStruct: import("superstruct").Struct<{
|
|
293
|
+
id: string;
|
|
294
|
+
severity?: SeverityLevel | undefined;
|
|
295
|
+
} | {
|
|
296
|
+
content: import("@metamask/snaps-sdk/jsx-runtime").JSXElement | import("@metamask/snaps-sdk").Panel | {
|
|
329
297
|
value: string;
|
|
330
298
|
type: import("@metamask/snaps-sdk").NodeType.Copyable;
|
|
331
299
|
sensitive?: boolean | undefined;
|
|
@@ -361,18 +329,14 @@ export declare const OnSignatureResponseStruct: import("superstruct").Struct<{
|
|
|
361
329
|
type: import("@metamask/snaps-sdk").NodeType.Row;
|
|
362
330
|
label: string;
|
|
363
331
|
variant?: "default" | "warning" | "critical" | undefined;
|
|
364
|
-
}
|
|
365
|
-
severity?: SeverityLevel | undefined;
|
|
366
|
-
} | null, null>;
|
|
367
|
-
export declare const OnHomePageResponseWithContentStruct: import("superstruct").Struct<{
|
|
368
|
-
content: import("@metamask/snaps-sdk").Panel | {
|
|
332
|
+
} | {
|
|
369
333
|
type: import("@metamask/snaps-sdk").NodeType.Input;
|
|
370
334
|
name: string;
|
|
371
335
|
value?: string | undefined;
|
|
372
336
|
error?: string | undefined;
|
|
373
|
-
inputType?: "number" | "text" | "password" | undefined;
|
|
374
337
|
placeholder?: string | undefined;
|
|
375
338
|
label?: string | undefined;
|
|
339
|
+
inputType?: "number" | "text" | "password" | undefined;
|
|
376
340
|
} | {
|
|
377
341
|
value: string;
|
|
378
342
|
type: import("@metamask/snaps-sdk").NodeType.Button;
|
|
@@ -387,9 +351,9 @@ export declare const OnHomePageResponseWithContentStruct: import("superstruct").
|
|
|
387
351
|
name: string;
|
|
388
352
|
value?: string | undefined;
|
|
389
353
|
error?: string | undefined;
|
|
390
|
-
inputType?: "number" | "text" | "password" | undefined;
|
|
391
354
|
placeholder?: string | undefined;
|
|
392
355
|
label?: string | undefined;
|
|
356
|
+
inputType?: "number" | "text" | "password" | undefined;
|
|
393
357
|
} | {
|
|
394
358
|
value: string;
|
|
395
359
|
type: import("@metamask/snaps-sdk").NodeType.Button;
|
|
@@ -397,7 +361,11 @@ export declare const OnHomePageResponseWithContentStruct: import("superstruct").
|
|
|
397
361
|
variant?: "primary" | "secondary" | undefined;
|
|
398
362
|
buttonType?: "button" | "submit" | undefined;
|
|
399
363
|
})[];
|
|
400
|
-
}
|
|
364
|
+
};
|
|
365
|
+
severity?: SeverityLevel | undefined;
|
|
366
|
+
} | null, null>;
|
|
367
|
+
export declare const OnHomePageResponseWithContentStruct: import("superstruct").Struct<{
|
|
368
|
+
content: import("@metamask/snaps-sdk/jsx-runtime").JSXElement | import("@metamask/snaps-sdk").Panel | {
|
|
401
369
|
value: string;
|
|
402
370
|
type: import("@metamask/snaps-sdk").NodeType.Copyable;
|
|
403
371
|
sensitive?: boolean | undefined;
|
|
@@ -433,16 +401,14 @@ export declare const OnHomePageResponseWithContentStruct: import("superstruct").
|
|
|
433
401
|
type: import("@metamask/snaps-sdk").NodeType.Row;
|
|
434
402
|
label: string;
|
|
435
403
|
variant?: "default" | "warning" | "critical" | undefined;
|
|
436
|
-
}
|
|
437
|
-
}, {
|
|
438
|
-
content: import("superstruct").Struct<import("@metamask/snaps-sdk").Panel | {
|
|
404
|
+
} | {
|
|
439
405
|
type: import("@metamask/snaps-sdk").NodeType.Input;
|
|
440
406
|
name: string;
|
|
441
407
|
value?: string | undefined;
|
|
442
408
|
error?: string | undefined;
|
|
443
|
-
inputType?: "number" | "text" | "password" | undefined;
|
|
444
409
|
placeholder?: string | undefined;
|
|
445
410
|
label?: string | undefined;
|
|
411
|
+
inputType?: "number" | "text" | "password" | undefined;
|
|
446
412
|
} | {
|
|
447
413
|
value: string;
|
|
448
414
|
type: import("@metamask/snaps-sdk").NodeType.Button;
|
|
@@ -457,9 +423,9 @@ export declare const OnHomePageResponseWithContentStruct: import("superstruct").
|
|
|
457
423
|
name: string;
|
|
458
424
|
value?: string | undefined;
|
|
459
425
|
error?: string | undefined;
|
|
460
|
-
inputType?: "number" | "text" | "password" | undefined;
|
|
461
426
|
placeholder?: string | undefined;
|
|
462
427
|
label?: string | undefined;
|
|
428
|
+
inputType?: "number" | "text" | "password" | undefined;
|
|
463
429
|
} | {
|
|
464
430
|
value: string;
|
|
465
431
|
type: import("@metamask/snaps-sdk").NodeType.Button;
|
|
@@ -467,7 +433,9 @@ export declare const OnHomePageResponseWithContentStruct: import("superstruct").
|
|
|
467
433
|
variant?: "primary" | "secondary" | undefined;
|
|
468
434
|
buttonType?: "button" | "submit" | undefined;
|
|
469
435
|
})[];
|
|
470
|
-
}
|
|
436
|
+
};
|
|
437
|
+
}, {
|
|
438
|
+
content: import("superstruct").Struct<import("@metamask/snaps-sdk/jsx-runtime").JSXElement | import("@metamask/snaps-sdk").Panel | {
|
|
471
439
|
value: string;
|
|
472
440
|
type: import("@metamask/snaps-sdk").NodeType.Copyable;
|
|
473
441
|
sensitive?: boolean | undefined;
|
|
@@ -503,22 +471,14 @@ export declare const OnHomePageResponseWithContentStruct: import("superstruct").
|
|
|
503
471
|
type: import("@metamask/snaps-sdk").NodeType.Row;
|
|
504
472
|
label: string;
|
|
505
473
|
variant?: "default" | "warning" | "critical" | undefined;
|
|
506
|
-
}
|
|
507
|
-
}>;
|
|
508
|
-
export declare const OnHomePageResponseWithIdStruct: import("superstruct").Struct<{
|
|
509
|
-
id: string;
|
|
510
|
-
}, {
|
|
511
|
-
id: import("superstruct").Struct<string, null>;
|
|
512
|
-
}>;
|
|
513
|
-
export declare const OnHomePageResponseStruct: import("superstruct").Struct<{
|
|
514
|
-
content: import("@metamask/snaps-sdk").Panel | {
|
|
474
|
+
} | {
|
|
515
475
|
type: import("@metamask/snaps-sdk").NodeType.Input;
|
|
516
476
|
name: string;
|
|
517
477
|
value?: string | undefined;
|
|
518
478
|
error?: string | undefined;
|
|
519
|
-
inputType?: "number" | "text" | "password" | undefined;
|
|
520
479
|
placeholder?: string | undefined;
|
|
521
480
|
label?: string | undefined;
|
|
481
|
+
inputType?: "number" | "text" | "password" | undefined;
|
|
522
482
|
} | {
|
|
523
483
|
value: string;
|
|
524
484
|
type: import("@metamask/snaps-sdk").NodeType.Button;
|
|
@@ -533,9 +493,9 @@ export declare const OnHomePageResponseStruct: import("superstruct").Struct<{
|
|
|
533
493
|
name: string;
|
|
534
494
|
value?: string | undefined;
|
|
535
495
|
error?: string | undefined;
|
|
536
|
-
inputType?: "number" | "text" | "password" | undefined;
|
|
537
496
|
placeholder?: string | undefined;
|
|
538
497
|
label?: string | undefined;
|
|
498
|
+
inputType?: "number" | "text" | "password" | undefined;
|
|
539
499
|
} | {
|
|
540
500
|
value: string;
|
|
541
501
|
type: import("@metamask/snaps-sdk").NodeType.Button;
|
|
@@ -543,7 +503,15 @@ export declare const OnHomePageResponseStruct: import("superstruct").Struct<{
|
|
|
543
503
|
variant?: "primary" | "secondary" | undefined;
|
|
544
504
|
buttonType?: "button" | "submit" | undefined;
|
|
545
505
|
})[];
|
|
546
|
-
}
|
|
506
|
+
}, null>;
|
|
507
|
+
}>;
|
|
508
|
+
export declare const OnHomePageResponseWithIdStruct: import("superstruct").Struct<{
|
|
509
|
+
id: string;
|
|
510
|
+
}, {
|
|
511
|
+
id: import("superstruct").Struct<string, null>;
|
|
512
|
+
}>;
|
|
513
|
+
export declare const OnHomePageResponseStruct: import("superstruct").Struct<{
|
|
514
|
+
content: import("@metamask/snaps-sdk/jsx-runtime").JSXElement | import("@metamask/snaps-sdk").Panel | {
|
|
547
515
|
value: string;
|
|
548
516
|
type: import("@metamask/snaps-sdk").NodeType.Copyable;
|
|
549
517
|
sensitive?: boolean | undefined;
|
|
@@ -579,6 +547,38 @@ export declare const OnHomePageResponseStruct: import("superstruct").Struct<{
|
|
|
579
547
|
type: import("@metamask/snaps-sdk").NodeType.Row;
|
|
580
548
|
label: string;
|
|
581
549
|
variant?: "default" | "warning" | "critical" | undefined;
|
|
550
|
+
} | {
|
|
551
|
+
type: import("@metamask/snaps-sdk").NodeType.Input;
|
|
552
|
+
name: string;
|
|
553
|
+
value?: string | undefined;
|
|
554
|
+
error?: string | undefined;
|
|
555
|
+
placeholder?: string | undefined;
|
|
556
|
+
label?: string | undefined;
|
|
557
|
+
inputType?: "number" | "text" | "password" | undefined;
|
|
558
|
+
} | {
|
|
559
|
+
value: string;
|
|
560
|
+
type: import("@metamask/snaps-sdk").NodeType.Button;
|
|
561
|
+
name?: string | undefined;
|
|
562
|
+
variant?: "primary" | "secondary" | undefined;
|
|
563
|
+
buttonType?: "button" | "submit" | undefined;
|
|
564
|
+
} | {
|
|
565
|
+
type: import("@metamask/snaps-sdk").NodeType.Form;
|
|
566
|
+
name: string;
|
|
567
|
+
children: ({
|
|
568
|
+
type: import("@metamask/snaps-sdk").NodeType.Input;
|
|
569
|
+
name: string;
|
|
570
|
+
value?: string | undefined;
|
|
571
|
+
error?: string | undefined;
|
|
572
|
+
placeholder?: string | undefined;
|
|
573
|
+
label?: string | undefined;
|
|
574
|
+
inputType?: "number" | "text" | "password" | undefined;
|
|
575
|
+
} | {
|
|
576
|
+
value: string;
|
|
577
|
+
type: import("@metamask/snaps-sdk").NodeType.Button;
|
|
578
|
+
name?: string | undefined;
|
|
579
|
+
variant?: "primary" | "secondary" | undefined;
|
|
580
|
+
buttonType?: "button" | "submit" | undefined;
|
|
581
|
+
})[];
|
|
582
582
|
};
|
|
583
583
|
} | {
|
|
584
584
|
id: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SupportedCurve } from '@metamask/key-tree';
|
|
1
2
|
import type { EmptyObject, InitialPermissions } from '@metamask/snaps-sdk';
|
|
2
3
|
import type { Describe, Infer, Struct } from 'superstruct';
|
|
3
4
|
import type { InferMatching } from '../structs';
|
|
@@ -7,29 +8,24 @@ export declare const bip32entropy: <Type extends {
|
|
|
7
8
|
path: string[];
|
|
8
9
|
curve: string;
|
|
9
10
|
}, Schema>(struct: Struct<Type, Schema>) => Struct<Type, Schema>;
|
|
11
|
+
export declare const CurveStruct: Describe<SupportedCurve>;
|
|
10
12
|
export declare const Bip32EntropyStruct: Struct<{
|
|
11
13
|
path: string[];
|
|
12
|
-
curve: "ed25519" | "secp256k1";
|
|
14
|
+
curve: "ed25519" | "ed25519Bip32" | "secp256k1";
|
|
13
15
|
}, {
|
|
14
16
|
path: Struct<string[], Struct<string, null>>;
|
|
15
|
-
curve:
|
|
16
|
-
ed25519: "ed25519";
|
|
17
|
-
secp256k1: "secp256k1";
|
|
18
|
-
}>;
|
|
17
|
+
curve: Describe<"ed25519" | "ed25519Bip32" | "secp256k1">;
|
|
19
18
|
}>;
|
|
20
19
|
export declare type Bip32Entropy = Infer<typeof Bip32EntropyStruct>;
|
|
21
20
|
export declare const SnapGetBip32EntropyPermissionsStruct: Struct<{
|
|
22
21
|
path: string[];
|
|
23
|
-
curve: "ed25519" | "secp256k1";
|
|
22
|
+
curve: "ed25519" | "ed25519Bip32" | "secp256k1";
|
|
24
23
|
}[], Struct<{
|
|
25
24
|
path: string[];
|
|
26
|
-
curve: "ed25519" | "secp256k1";
|
|
25
|
+
curve: "ed25519" | "ed25519Bip32" | "secp256k1";
|
|
27
26
|
}, {
|
|
28
27
|
path: Struct<string[], Struct<string, null>>;
|
|
29
|
-
curve:
|
|
30
|
-
ed25519: "ed25519";
|
|
31
|
-
secp256k1: "secp256k1";
|
|
32
|
-
}>;
|
|
28
|
+
curve: Describe<"ed25519" | "ed25519Bip32" | "secp256k1">;
|
|
33
29
|
}>>;
|
|
34
30
|
export declare const SemVerRangeStruct: Struct<string, null>;
|
|
35
31
|
export declare const SnapIdsStruct: Struct<Record<string, {
|
package/dist/types/ui.d.ts
CHANGED
|
@@ -1,6 +1,27 @@
|
|
|
1
|
-
import type { Component
|
|
1
|
+
import type { Component } from '@metamask/snaps-sdk';
|
|
2
|
+
import type { JSXElement, LinkElement, MaybeArray, StandardFormattingElement } from '@metamask/snaps-sdk/jsx';
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
+
* Get all text children from a markdown string.
|
|
5
|
+
*
|
|
6
|
+
* @param value - The markdown string.
|
|
7
|
+
* @returns The text children.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getTextChildren(value: string): (string | StandardFormattingElement | LinkElement)[];
|
|
10
|
+
/**
|
|
11
|
+
* Get a JSX element from a legacy UI component. This supports all legacy UI
|
|
12
|
+
* components, and maps them to their JSX equivalents where possible.
|
|
13
|
+
*
|
|
14
|
+
* This function validates the text size of the component, but does not validate
|
|
15
|
+
* the total size. The total size of the component should be validated before
|
|
16
|
+
* calling this function.
|
|
17
|
+
*
|
|
18
|
+
* @param legacyComponent - The legacy UI component.
|
|
19
|
+
* @returns The JSX element.
|
|
20
|
+
*/
|
|
21
|
+
export declare function getJsxElementFromComponent(legacyComponent: Component): JSXElement;
|
|
22
|
+
/**
|
|
23
|
+
* Search for Markdown links in a string and checks them against the phishing
|
|
24
|
+
* list.
|
|
4
25
|
*
|
|
5
26
|
* @param text - The text to verify.
|
|
6
27
|
* @param isOnPhishingList - The function that checks the link against the
|
|
@@ -9,15 +30,14 @@ import type { Component, NodeWithChildren } from '@metamask/snaps-sdk';
|
|
|
9
30
|
*/
|
|
10
31
|
export declare function validateTextLinks(text: string, isOnPhishingList: (url: string) => boolean): void;
|
|
11
32
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
33
|
+
* Walk a JSX tree and validate each {@link LinkElement} node against the
|
|
34
|
+
* phishing list.
|
|
14
35
|
*
|
|
15
|
-
* @param
|
|
36
|
+
* @param node - The JSX node to walk.
|
|
16
37
|
* @param isOnPhishingList - The function that checks the link against the
|
|
17
38
|
* phishing list.
|
|
18
|
-
* @throws If the component contains a link that is not allowed.
|
|
19
39
|
*/
|
|
20
|
-
export declare function
|
|
40
|
+
export declare function validateJsxLinks(node: JSXElement, isOnPhishingList: (url: string) => boolean): void;
|
|
21
41
|
/**
|
|
22
42
|
* Calculate the total length of all text in the component.
|
|
23
43
|
*
|
|
@@ -26,9 +46,29 @@ export declare function validateComponentLinks(component: Component, isOnPhishin
|
|
|
26
46
|
*/
|
|
27
47
|
export declare function getTotalTextLength(component: Component): number;
|
|
28
48
|
/**
|
|
29
|
-
* Check if a
|
|
49
|
+
* Check if a JSX element has children.
|
|
30
50
|
*
|
|
31
|
-
* @param
|
|
32
|
-
* @returns `true` if the
|
|
51
|
+
* @param element - A JSX element.
|
|
52
|
+
* @returns `true` if the element has children, `false` otherwise.
|
|
53
|
+
*/
|
|
54
|
+
export declare function hasChildren<Element extends JSXElement>(element: Element): element is Element & {
|
|
55
|
+
props: {
|
|
56
|
+
children: MaybeArray<JSXElement | string>;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Get the children of a JSX element as an array. If the element has only one
|
|
61
|
+
* child, the child is returned as an array.
|
|
62
|
+
*
|
|
63
|
+
* @param element - A JSX element.
|
|
64
|
+
* @returns The children of the element.
|
|
65
|
+
*/
|
|
66
|
+
export declare function getJsxChildren(element: JSXElement): (JSXElement | string)[];
|
|
67
|
+
/**
|
|
68
|
+
* Walk a JSX tree and call a callback on each node.
|
|
69
|
+
*
|
|
70
|
+
* @param node - The JSX node to walk.
|
|
71
|
+
* @param callback - The callback to call on each node.
|
|
72
|
+
* @returns The result of the callback, if any.
|
|
33
73
|
*/
|
|
34
|
-
export declare function
|
|
74
|
+
export declare function walkJsx<Value>(node: JSXElement | JSXElement[], callback: (node: JSXElement) => Value | undefined): Value | undefined;
|
package/dist/ui.js
CHANGED
|
@@ -3,12 +3,20 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
var _chunk4YAWNZXMjs = require('./chunk-4YAWNZXM.js');
|
|
7
11
|
require('./chunk-PHUTP7NB.js');
|
|
8
12
|
|
|
9
13
|
|
|
10
14
|
|
|
11
15
|
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
exports.getJsxChildren = _chunk4YAWNZXMjs.getJsxChildren; exports.getJsxElementFromComponent = _chunk4YAWNZXMjs.getJsxElementFromComponent; exports.getTextChildren = _chunk4YAWNZXMjs.getTextChildren; exports.getTotalTextLength = _chunk4YAWNZXMjs.getTotalTextLength; exports.hasChildren = _chunk4YAWNZXMjs.hasChildren; exports.validateJsxLinks = _chunk4YAWNZXMjs.validateJsxLinks; exports.validateTextLinks = _chunk4YAWNZXMjs.validateTextLinks; exports.walkJsx = _chunk4YAWNZXMjs.walkJsx;
|
|
14
22
|
//# sourceMappingURL=ui.js.map
|
package/dist/ui.mjs
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
|
+
getJsxChildren,
|
|
3
|
+
getJsxElementFromComponent,
|
|
4
|
+
getTextChildren,
|
|
2
5
|
getTotalTextLength,
|
|
3
6
|
hasChildren,
|
|
4
|
-
|
|
5
|
-
validateTextLinks
|
|
6
|
-
|
|
7
|
+
validateJsxLinks,
|
|
8
|
+
validateTextLinks,
|
|
9
|
+
walkJsx
|
|
10
|
+
} from "./chunk-MJGSG5N2.mjs";
|
|
7
11
|
import "./chunk-JMDSN227.mjs";
|
|
8
12
|
export {
|
|
13
|
+
getJsxChildren,
|
|
14
|
+
getJsxElementFromComponent,
|
|
15
|
+
getTextChildren,
|
|
9
16
|
getTotalTextLength,
|
|
10
17
|
hasChildren,
|
|
11
|
-
|
|
12
|
-
validateTextLinks
|
|
18
|
+
validateJsxLinks,
|
|
19
|
+
validateTextLinks,
|
|
20
|
+
walkJsx
|
|
13
21
|
};
|
|
14
22
|
//# sourceMappingURL=ui.mjs.map
|
package/dist/validation.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var _chunk3ZSYZX3Ijs = require('./chunk-3ZSYZX3I.js');
|
|
4
|
+
require('./chunk-IAHW6IFC.js');
|
|
5
5
|
require('./chunk-HVTYDKBO.js');
|
|
6
6
|
require('./chunk-M3KAAQFK.js');
|
|
7
7
|
require('./chunk-6LOYTBS3.js');
|
|
@@ -20,5 +20,5 @@ require('./chunk-NUCLSR2G.js');
|
|
|
20
20
|
require('./chunk-PHUTP7NB.js');
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
exports.validateFetchedSnap =
|
|
23
|
+
exports.validateFetchedSnap = _chunk3ZSYZX3Ijs.validateFetchedSnap;
|
|
24
24
|
//# sourceMappingURL=validation.js.map
|
package/dist/validation.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/snaps-utils",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.4.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/MetaMask/snaps.git"
|
|
@@ -52,13 +52,13 @@
|
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@babel/core": "^7.23.2",
|
|
54
54
|
"@babel/types": "^7.23.0",
|
|
55
|
-
"@metamask/base-controller": "^5.0.
|
|
56
|
-
"@metamask/key-tree": "^9.
|
|
55
|
+
"@metamask/base-controller": "^5.0.2",
|
|
56
|
+
"@metamask/key-tree": "^9.1.0",
|
|
57
57
|
"@metamask/permission-controller": "^9.0.2",
|
|
58
58
|
"@metamask/rpc-errors": "^6.2.1",
|
|
59
59
|
"@metamask/slip44": "^3.1.0",
|
|
60
60
|
"@metamask/snaps-registry": "^3.1.0",
|
|
61
|
-
"@metamask/snaps-sdk": "^4.0
|
|
61
|
+
"@metamask/snaps-sdk": "^4.2.0",
|
|
62
62
|
"@metamask/utils": "^8.3.0",
|
|
63
63
|
"@noble/hashes": "^1.3.1",
|
|
64
64
|
"@scure/base": "^1.1.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/handlers.ts"],"names":[],"mappings":";AAYA,SAAS,eAAe,uBAAuB;AAC/C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAWA,IAAM,eAAe;AAAA,EAC1B,kCAAyB,GAAG;AAAA,IAC1B;AAAA,IACA,UAAU;AAAA,IACV,WAAW,CAAC,eAA2D;AACrE,aAAO,OAAO,eAAe;AAAA,IAC/B;AAAA,EACF;AAAA,EACA,oCAA0B,GAAG;AAAA,IAC3B;AAAA,IACA,UAAU;AAAA,IACV,WAAW,CAAC,eAA4D;AACtE,aAAO,OAAO,eAAe;AAAA,IAC/B;AAAA,EACF;AAAA,EACA,4BAAsB,GAAG;AAAA,IACvB;AAAA,IACA,UAAU;AAAA,IACV,WAAW,CAAC,eAAwD;AAClE,aAAO,OAAO,eAAe;AAAA,IAC/B;AAAA,EACF;AAAA,EACA,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;AAAA,IACJ;AAAA,IACA;AAAA,EACF,CAAC;AACH;AAEO,IAAM,4BAA4B;AAElC,IAAM,sCAAsC,OAAO;AAAA,EACxD,SAAS;AACX,CAAC;AAEM,IAAM,iCAAiC,OAAO;AAAA,EACnD,IAAI,OAAO;AACb,CAAC;AAEM,IAAM,2BAA2B,MAAM;AAAA,EAC5C;AAAA,EACA;AACF,CAAC;AAEM,IAAM,0BAA0B,OAAO;AAAA,EAC5C,UAAU,OAAO;AAAA,EACjB,gBAAgB,OAAO;AACzB,CAAC;AAEM,IAAM,yBAAyB,OAAO;AAAA,EAC3C,UAAU,OAAO;AAAA,EACjB,iBAAiB,OAAO;AAC1B,CAAC;AAEM,IAAM,kCAAkC,OAAO;AAAA,EACpD,iBAAiB,KAAK,MAAM,uBAAuB,GAAG,GAAG,QAAQ;AACnE,CAAC;AAEM,IAAM,iCAAiC,OAAO;AAAA,EACnD,mBAAmB,KAAK,MAAM,sBAAsB,GAAG,GAAG,QAAQ;AACpE,CAAC;AAEM,IAAM,6BAA6B;AAAA,EACxC,MAAM,CAAC,iCAAiC,8BAA8B,CAAC;AACzE","sourcesContent":["import type {\n OnCronjobHandler,\n OnHomePageHandler,\n OnInstallHandler,\n OnKeyringRequestHandler,\n OnNameLookupHandler,\n OnRpcRequestHandler,\n OnSignatureHandler,\n OnTransactionHandler,\n OnUpdateHandler,\n OnUserInputHandler,\n} from '@metamask/snaps-sdk';\nimport { SeverityLevel, ComponentStruct } from '@metamask/snaps-sdk';\nimport {\n assign,\n literal,\n nullable,\n object,\n optional,\n string,\n array,\n size,\n union,\n} from 'superstruct';\n\nimport type { SnapHandler } from './handler-types';\nimport { HandlerType } from './handler-types';\n\nexport type SnapRpcHookArgs = {\n origin: string;\n handler: HandlerType;\n request: Record<string, unknown>;\n};\n\nexport const SNAP_EXPORTS = {\n [HandlerType.OnRpcRequest]: {\n type: HandlerType.OnRpcRequest,\n required: true,\n validator: (snapExport: unknown): snapExport is OnRpcRequestHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnTransaction]: {\n type: HandlerType.OnTransaction,\n required: true,\n validator: (snapExport: unknown): snapExport is OnTransactionHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnCronjob]: {\n type: HandlerType.OnCronjob,\n required: true,\n validator: (snapExport: unknown): snapExport is OnCronjobHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnNameLookup]: {\n type: HandlerType.OnNameLookup,\n required: true,\n validator: (snapExport: unknown): snapExport is OnNameLookupHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnInstall]: {\n type: HandlerType.OnInstall,\n required: false,\n validator: (snapExport: unknown): snapExport is OnInstallHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnUpdate]: {\n type: HandlerType.OnUpdate,\n required: false,\n validator: (snapExport: unknown): snapExport is OnUpdateHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnKeyringRequest]: {\n type: HandlerType.OnKeyringRequest,\n required: true,\n validator: (snapExport: unknown): snapExport is OnKeyringRequestHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnHomePage]: {\n type: HandlerType.OnHomePage,\n required: true,\n validator: (snapExport: unknown): snapExport is OnHomePageHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnSignature]: {\n type: HandlerType.OnSignature,\n required: true,\n validator: (snapExport: unknown): snapExport is OnSignatureHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnUserInput]: {\n type: HandlerType.OnUserInput,\n required: true,\n validator: (snapExport: unknown): snapExport is OnUserInputHandler => {\n return typeof snapExport === 'function';\n },\n },\n} as const;\n\nexport const OnTransactionSeverityResponseStruct = object({\n severity: optional(literal(SeverityLevel.Critical)),\n});\n\nexport const OnTransactionResponseWithIdStruct = assign(\n OnTransactionSeverityResponseStruct,\n object({\n id: string(),\n }),\n);\n\nexport const OnTransactionResponseWithContentStruct = assign(\n OnTransactionSeverityResponseStruct,\n object({\n content: ComponentStruct,\n }),\n);\n\nexport const OnTransactionResponseStruct = nullable(\n union([\n OnTransactionResponseWithContentStruct,\n OnTransactionResponseWithIdStruct,\n ]),\n);\n\nexport const OnSignatureResponseStruct = OnTransactionResponseStruct;\n\nexport const OnHomePageResponseWithContentStruct = object({\n content: ComponentStruct,\n});\n\nexport const OnHomePageResponseWithIdStruct = object({\n id: string(),\n});\n\nexport const OnHomePageResponseStruct = union([\n OnHomePageResponseWithContentStruct,\n OnHomePageResponseWithIdStruct,\n]);\n\nexport const AddressResolutionStruct = object({\n protocol: string(),\n resolvedDomain: string(),\n});\n\nexport const DomainResolutionStruct = object({\n protocol: string(),\n resolvedAddress: string(),\n});\n\nexport const AddressResolutionResponseStruct = object({\n resolvedDomains: size(array(AddressResolutionStruct), 1, Infinity),\n});\n\nexport const DomainResolutionResponseStruct = object({\n resolvedAddresses: size(array(DomainResolutionStruct), 1, Infinity),\n});\n\nexport const OnNameLookupResponseStruct = nullable(\n union([AddressResolutionResponseStruct, DomainResolutionResponseStruct]),\n);\n\n/**\n * Utility type for getting the handler function type from a handler type.\n */\nexport type HandlerFunction<Type extends SnapHandler> =\n Type['validator'] extends (snapExport: unknown) => snapExport is infer Handler\n ? Handler\n : never;\n\n/**\n * All the function-based handlers that a snap can implement.\n */\nexport type SnapFunctionExports = {\n [Key in keyof typeof SNAP_EXPORTS]?: HandlerFunction<\n (typeof SNAP_EXPORTS)[Key]\n >;\n};\n\n/**\n * All handlers that a snap can implement.\n */\nexport type SnapExports = SnapFunctionExports;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/manifest/validation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,+BAA+B;AAExC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA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SAAO,GAAG,OAAO,kBAAkB;AACrC;AAQO,SAAS,qBACd,OAC+B;AAC/B;AAAA,IACE;AAAA,IACA;AAAA,IACA,uCAA6B;AAAA,EAC/B;AACF;AASO,SAAS,mBAAmB,OAA8B;AAE/D,SAAO,OAAO,OAAO,kBAAkB;AACzC","sourcesContent":["import { isValidBIP32PathSegment } from '@metamask/key-tree';\nimport type { EmptyObject, InitialPermissions } from '@metamask/snaps-sdk';\nimport {\n assertStruct,\n ChecksumStruct,\n VersionStruct,\n isValidSemVerRange,\n inMilliseconds,\n Duration,\n} from '@metamask/utils';\nimport type { Describe, Infer, Struct } from 'superstruct';\nimport {\n array,\n boolean,\n create,\n enums,\n integer,\n is,\n literal,\n object,\n optional,\n refine,\n record,\n size,\n string,\n type,\n union,\n intersection,\n assign,\n} from 'superstruct';\n\nimport { isEqual } from '../array';\nimport { CronjobSpecificationArrayStruct } from '../cronjob';\nimport { SIP_6_MAGIC_VALUE, STATE_ENCRYPTION_MAGIC_VALUE } from '../entropy';\nimport { KeyringOriginsStruct, RpcOriginsStruct } from '../json-rpc';\nimport { ChainIdStruct } from '../namespace';\nimport { SnapIdStruct } from '../snaps';\nimport type { InferMatching } from '../structs';\nimport { NameStruct, NpmSnapFileNames, uri } from '../types';\n\n// BIP-43 purposes that cannot be used for entropy derivation. These are in the\n// string form, ending with `'`.\nconst FORBIDDEN_PURPOSES: string[] = [\n SIP_6_MAGIC_VALUE,\n STATE_ENCRYPTION_MAGIC_VALUE,\n];\n\nexport const FORBIDDEN_COIN_TYPES: number[] = [60];\nconst FORBIDDEN_PATHS: string[][] = FORBIDDEN_COIN_TYPES.map((coinType) => [\n 'm',\n \"44'\",\n `${coinType}'`,\n]);\n\nexport const Bip32PathStruct = refine(\n array(string()),\n 'BIP-32 path',\n (path: string[]) => {\n if (path.length === 0) {\n return 'Path must be a non-empty BIP-32 derivation path array';\n }\n\n if (path[0] !== 'm') {\n return 'Path must start with \"m\".';\n }\n\n if (path.length < 3) {\n return 'Paths must have a length of at least three.';\n }\n\n if (path.slice(1).some((part) => !isValidBIP32PathSegment(part))) {\n return 'Path must be a valid BIP-32 derivation path array.';\n }\n\n if (FORBIDDEN_PURPOSES.includes(path[1])) {\n return `The purpose \"${path[1]}\" is not allowed for entropy derivation.`;\n }\n\n if (\n FORBIDDEN_PATHS.some((forbiddenPath) =>\n isEqual(path.slice(0, forbiddenPath.length), forbiddenPath),\n )\n ) {\n return `The path \"${path.join(\n '/',\n )}\" is not allowed for entropy derivation.`;\n }\n\n return true;\n },\n);\n\nexport const bip32entropy = <\n Type extends { path: string[]; curve: string },\n Schema,\n>(\n struct: Struct<Type, Schema>,\n) =>\n refine(struct, 'BIP-32 entropy', (value) => {\n if (\n value.curve === 'ed25519' &&\n value.path.slice(1).some((part) => !part.endsWith(\"'\"))\n ) {\n return 'Ed25519 does not support unhardened paths.';\n }\n\n return true;\n });\n\n// Used outside @metamask/snap-utils\nexport const Bip32EntropyStruct = bip32entropy(\n type({\n path: Bip32PathStruct,\n curve: enums(['ed25519', 'secp256k1']),\n }),\n);\n\nexport type Bip32Entropy = Infer<typeof Bip32EntropyStruct>;\n\nexport const SnapGetBip32EntropyPermissionsStruct = size(\n array(Bip32EntropyStruct),\n 1,\n Infinity,\n);\n\nexport const SemVerRangeStruct = refine(string(), 'SemVer range', (value) => {\n if (isValidSemVerRange(value)) {\n return true;\n }\n return 'Expected a valid SemVer range.';\n});\n\nexport const SnapIdsStruct = refine(\n record(SnapIdStruct, object({ version: optional(SemVerRangeStruct) })),\n 'SnapIds',\n (value) => {\n if (Object.keys(value).length === 0) {\n return false;\n }\n\n return true;\n },\n);\n\nexport type SnapIds = Infer<typeof SnapIdsStruct>;\n\nexport const ChainIdsStruct = size(array(ChainIdStruct), 1, Infinity);\n\nexport const LookupMatchersStruct = union([\n object({\n tlds: size(array(string()), 1, Infinity),\n }),\n object({\n schemes: size(array(string()), 1, Infinity),\n }),\n object({\n tlds: size(array(string()), 1, Infinity),\n schemes: size(array(string()), 1, Infinity),\n }),\n]);\n\nexport const MINIMUM_REQUEST_TIMEOUT = inMilliseconds(5, Duration.Second);\nexport const MAXIMUM_REQUEST_TIMEOUT = inMilliseconds(3, Duration.Minute);\n\nexport const MaxRequestTimeStruct = size(\n integer(),\n MINIMUM_REQUEST_TIMEOUT,\n MAXIMUM_REQUEST_TIMEOUT,\n);\n\n// Utility type to union with for all handler structs\nexport const HandlerCaveatsStruct = object({\n maxRequestTime: optional(MaxRequestTimeStruct),\n});\n\nexport type HandlerCaveats = Infer<typeof HandlerCaveatsStruct>;\n\nexport const EmptyObjectStruct = object<EmptyObject>({}) as unknown as Struct<\n EmptyObject,\n null\n>;\n\n/* eslint-disable @typescript-eslint/naming-convention */\nexport const PermissionsStruct: Describe<InitialPermissions> = type({\n 'endowment:cronjob': optional(\n assign(\n HandlerCaveatsStruct,\n object({ jobs: CronjobSpecificationArrayStruct }),\n ),\n ),\n 'endowment:ethereum-provider': optional(EmptyObjectStruct),\n 'endowment:keyring': optional(\n assign(HandlerCaveatsStruct, KeyringOriginsStruct),\n ),\n 'endowment:lifecycle-hooks': optional(HandlerCaveatsStruct),\n 'endowment:name-lookup': optional(\n assign(\n HandlerCaveatsStruct,\n object({\n chains: optional(ChainIdsStruct),\n matchers: optional(LookupMatchersStruct),\n }),\n ),\n ),\n 'endowment:network-access': optional(EmptyObjectStruct),\n 'endowment:page-home': optional(HandlerCaveatsStruct),\n 'endowment:rpc': optional(assign(HandlerCaveatsStruct, RpcOriginsStruct)),\n 'endowment:signature-insight': optional(\n assign(\n HandlerCaveatsStruct,\n object({\n allowSignatureOrigin: optional(boolean()),\n }),\n ),\n ),\n 'endowment:transaction-insight': optional(\n assign(\n HandlerCaveatsStruct,\n object({\n allowTransactionOrigin: optional(boolean()),\n }),\n ),\n ),\n 'endowment:webassembly': optional(EmptyObjectStruct),\n snap_dialog: optional(EmptyObjectStruct),\n snap_manageState: optional(EmptyObjectStruct),\n snap_manageAccounts: optional(EmptyObjectStruct),\n snap_notify: optional(EmptyObjectStruct),\n snap_getBip32Entropy: optional(SnapGetBip32EntropyPermissionsStruct),\n snap_getBip32PublicKey: optional(SnapGetBip32EntropyPermissionsStruct),\n snap_getBip44Entropy: optional(\n size(\n array(object({ coinType: size(integer(), 0, 2 ** 32 - 1) })),\n 1,\n Infinity,\n ),\n ),\n snap_getEntropy: optional(EmptyObjectStruct),\n snap_getLocale: optional(EmptyObjectStruct),\n wallet_snap: optional(SnapIdsStruct),\n});\n/* eslint-enable @typescript-eslint/naming-convention */\n\nexport type SnapPermissions = InferMatching<\n typeof PermissionsStruct,\n InitialPermissions\n>;\n\nexport const SnapAuxilaryFilesStruct = array(string());\n\nexport const InitialConnectionsStruct = record(\n intersection([string(), uri()]),\n object({}),\n);\n\nexport type InitialConnections = Infer<typeof InitialConnectionsStruct>;\n\nexport const SnapManifestStruct = object({\n version: VersionStruct,\n description: size(string(), 1, 280),\n proposedName: size(string(), 1, 214),\n repository: optional(\n object({\n type: size(string(), 1, Infinity),\n url: size(string(), 1, Infinity),\n }),\n ),\n source: object({\n shasum: ChecksumStruct,\n location: object({\n npm: object({\n filePath: size(string(), 1, Infinity),\n iconPath: optional(size(string(), 1, Infinity)),\n packageName: NameStruct,\n registry: union([\n literal('https://registry.npmjs.org'),\n literal('https://registry.npmjs.org/'),\n ]),\n }),\n }),\n files: optional(SnapAuxilaryFilesStruct),\n locales: optional(SnapAuxilaryFilesStruct),\n }),\n initialConnections: optional(InitialConnectionsStruct),\n initialPermissions: PermissionsStruct,\n manifestVersion: literal('0.1'),\n $schema: optional(string()), // enables JSON-Schema linting in VSC and other IDEs\n});\n\nexport type SnapManifest = Infer<typeof SnapManifestStruct>;\n\n/**\n * Check if the given value is a valid {@link SnapManifest} object.\n *\n * @param value - The value to check.\n * @returns Whether the value is a valid {@link SnapManifest} object.\n */\nexport function isSnapManifest(value: unknown): value is SnapManifest {\n return is(value, SnapManifestStruct);\n}\n\n/**\n * Assert that the given value is a valid {@link SnapManifest} object.\n *\n * @param value - The value to check.\n * @throws If the value is not a valid {@link SnapManifest} object.\n */\nexport function assertIsSnapManifest(\n value: unknown,\n): asserts value is SnapManifest {\n assertStruct(\n value,\n SnapManifestStruct,\n `\"${NpmSnapFileNames.Manifest}\" is invalid`,\n );\n}\n\n/**\n * Creates a {@link SnapManifest} object from JSON.\n *\n * @param value - The value to check.\n * @throws If the value cannot be coerced to a {@link SnapManifest} object.\n * @returns The created {@link SnapManifest} object.\n */\nexport function createSnapManifest(value: unknown): SnapManifest {\n // TODO: Add a utility to prefix these errors similar to assertStruct\n return create(value, SnapManifestStruct);\n}\n"]}
|