@metamask/snaps-utils 5.2.0 → 6.1.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 +23 -3
- package/dist/cjs/caveats.js +6 -0
- package/dist/cjs/caveats.js.map +1 -1
- package/dist/cjs/eval-worker.js +3 -1
- package/dist/cjs/eval-worker.js.map +1 -1
- package/dist/cjs/handler-types.js +1 -0
- package/dist/cjs/handler-types.js.map +1 -1
- package/dist/cjs/handlers.js +74 -3
- package/dist/cjs/handlers.js.map +1 -1
- package/dist/cjs/icon.js +38 -9
- package/dist/cjs/icon.js.map +1 -1
- package/dist/cjs/manifest/manifest.js +8 -0
- package/dist/cjs/manifest/manifest.js.map +1 -1
- package/dist/cjs/manifest/validation.js +50 -14
- package/dist/cjs/manifest/validation.js.map +1 -1
- package/dist/cjs/post-process.js +1 -1
- package/dist/cjs/post-process.js.map +1 -1
- package/dist/cjs/structs.js +86 -17
- package/dist/cjs/structs.js.map +1 -1
- package/dist/esm/caveats.js +6 -0
- package/dist/esm/caveats.js.map +1 -1
- package/dist/esm/eval-worker.js +3 -1
- package/dist/esm/eval-worker.js.map +1 -1
- package/dist/esm/handler-types.js +1 -0
- package/dist/esm/handler-types.js.map +1 -1
- package/dist/esm/handlers.js +45 -4
- package/dist/esm/handlers.js.map +1 -1
- package/dist/esm/icon.js +43 -3
- package/dist/esm/icon.js.map +1 -1
- package/dist/esm/manifest/manifest.js +8 -0
- package/dist/esm/manifest/manifest.js.map +1 -1
- package/dist/esm/manifest/validation.js +38 -16
- package/dist/esm/manifest/validation.js.map +1 -1
- package/dist/esm/post-process.js +1 -1
- package/dist/esm/post-process.js.map +1 -1
- package/dist/esm/structs.js +133 -21
- package/dist/esm/structs.js.map +1 -1
- package/dist/types/caveats.d.ts +9 -1
- package/dist/types/handler-types.d.ts +2 -1
- package/dist/types/handlers.d.ts +349 -10
- package/dist/types/icon.d.ts +16 -1
- package/dist/types/localization.d.ts +33 -13
- package/dist/types/manifest/validation.d.ts +230 -75
- package/dist/types/post-process.d.ts +1 -1
- package/dist/types/structs.d.ts +61 -7
- package/package.json +5 -6
|
@@ -37,6 +37,23 @@ export declare const SnapIdsStruct: Struct<Record<string, {
|
|
|
37
37
|
}>, null>;
|
|
38
38
|
export declare type SnapIds = Infer<typeof SnapIdsStruct>;
|
|
39
39
|
export declare const ChainIdsStruct: Struct<`${string}:${string}`[], Struct<`${string}:${string}`, null>>;
|
|
40
|
+
export declare const LookupMatchersStruct: Struct<{
|
|
41
|
+
tlds: string[];
|
|
42
|
+
} | {
|
|
43
|
+
schemes: string[];
|
|
44
|
+
} | {
|
|
45
|
+
tlds: string[];
|
|
46
|
+
schemes: string[];
|
|
47
|
+
}, null>;
|
|
48
|
+
export declare const MINIMUM_REQUEST_TIMEOUT: number;
|
|
49
|
+
export declare const MAXIMUM_REQUEST_TIMEOUT: number;
|
|
50
|
+
export declare const MaxRequestTimeStruct: Struct<number, null>;
|
|
51
|
+
export declare const HandlerCaveatsStruct: Struct<{
|
|
52
|
+
maxRequestTime?: number | undefined;
|
|
53
|
+
}, {
|
|
54
|
+
maxRequestTime: Struct<number | undefined, null>;
|
|
55
|
+
}>;
|
|
56
|
+
export declare type HandlerCaveats = Infer<typeof HandlerCaveatsStruct>;
|
|
40
57
|
export declare const PermissionsStruct: Struct<{
|
|
41
58
|
snap_dialog?: {} | undefined;
|
|
42
59
|
snap_getBip32Entropy?: {
|
|
@@ -58,15 +75,6 @@ export declare const PermissionsStruct: Struct<{
|
|
|
58
75
|
wallet_snap?: Record<string, {
|
|
59
76
|
version?: string | undefined;
|
|
60
77
|
}> | undefined;
|
|
61
|
-
'endowment:ethereum-provider'?: {} | undefined;
|
|
62
|
-
'endowment:network-access'?: {} | undefined;
|
|
63
|
-
'endowment:webassembly'?: {} | undefined;
|
|
64
|
-
'endowment:signature-insight'?: {
|
|
65
|
-
allowSignatureOrigin?: boolean | undefined;
|
|
66
|
-
} | undefined;
|
|
67
|
-
'endowment:transaction-insight'?: {
|
|
68
|
-
allowTransactionOrigin?: boolean | undefined;
|
|
69
|
-
} | undefined;
|
|
70
78
|
'endowment:cronjob'?: {
|
|
71
79
|
jobs: {
|
|
72
80
|
request: {
|
|
@@ -77,31 +85,47 @@ export declare const PermissionsStruct: Struct<{
|
|
|
77
85
|
};
|
|
78
86
|
expression: string;
|
|
79
87
|
}[];
|
|
88
|
+
maxRequestTime?: number | undefined;
|
|
89
|
+
} | undefined;
|
|
90
|
+
'endowment:ethereum-provider'?: {} | undefined;
|
|
91
|
+
'endowment:keyring'?: {
|
|
92
|
+
allowedOrigins?: string[] | undefined;
|
|
93
|
+
maxRequestTime?: number | undefined;
|
|
94
|
+
} | undefined;
|
|
95
|
+
'endowment:lifecycle-hooks'?: {
|
|
96
|
+
maxRequestTime?: number | undefined;
|
|
97
|
+
} | undefined;
|
|
98
|
+
'endowment:name-lookup'?: {
|
|
99
|
+
chains?: `${string}:${string}`[] | undefined;
|
|
100
|
+
maxRequestTime?: number | undefined;
|
|
101
|
+
matchers?: {
|
|
102
|
+
tlds: string[];
|
|
103
|
+
} | {
|
|
104
|
+
schemes: string[];
|
|
105
|
+
} | {
|
|
106
|
+
tlds: string[];
|
|
107
|
+
schemes: string[];
|
|
108
|
+
} | undefined;
|
|
109
|
+
} | undefined;
|
|
110
|
+
'endowment:network-access'?: {} | undefined;
|
|
111
|
+
'endowment:page-home'?: {
|
|
112
|
+
maxRequestTime?: number | undefined;
|
|
80
113
|
} | undefined;
|
|
81
114
|
'endowment:rpc'?: {
|
|
82
115
|
dapps?: boolean | undefined;
|
|
83
116
|
snaps?: boolean | undefined;
|
|
84
117
|
allowedOrigins?: string[] | undefined;
|
|
85
118
|
} | undefined;
|
|
86
|
-
'endowment:
|
|
87
|
-
|
|
88
|
-
allowedOrigins?: string[] | undefined;
|
|
89
|
-
} | undefined;
|
|
90
|
-
snap_confirm?: {} | undefined;
|
|
91
|
-
}, {
|
|
92
|
-
'endowment:ethereum-provider': Struct<{} | undefined, {}>;
|
|
93
|
-
'endowment:network-access': Struct<{} | undefined, {}>;
|
|
94
|
-
'endowment:webassembly': Struct<{} | undefined, {}>;
|
|
95
|
-
'endowment:signature-insight': Struct<{
|
|
119
|
+
'endowment:signature-insight'?: {
|
|
120
|
+
maxRequestTime?: number | undefined;
|
|
96
121
|
allowSignatureOrigin?: boolean | undefined;
|
|
97
|
-
} | undefined
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
'endowment:transaction-insight': Struct<{
|
|
122
|
+
} | undefined;
|
|
123
|
+
'endowment:transaction-insight'?: {
|
|
124
|
+
maxRequestTime?: number | undefined;
|
|
101
125
|
allowTransactionOrigin?: boolean | undefined;
|
|
102
|
-
} | undefined
|
|
103
|
-
|
|
104
|
-
|
|
126
|
+
} | undefined;
|
|
127
|
+
'endowment:webassembly'?: {} | undefined;
|
|
128
|
+
}, {
|
|
105
129
|
'endowment:cronjob': Struct<{
|
|
106
130
|
jobs: {
|
|
107
131
|
request: {
|
|
@@ -112,6 +136,7 @@ export declare const PermissionsStruct: Struct<{
|
|
|
112
136
|
};
|
|
113
137
|
expression: string;
|
|
114
138
|
}[];
|
|
139
|
+
maxRequestTime?: number | undefined;
|
|
115
140
|
} | undefined, {
|
|
116
141
|
jobs: Struct<{
|
|
117
142
|
request: {
|
|
@@ -143,6 +168,49 @@ export declare const PermissionsStruct: Struct<{
|
|
|
143
168
|
params: Struct<Record<string, import("@metamask/snaps-sdk").Json> | import("@metamask/snaps-sdk").Json[] | undefined, null>;
|
|
144
169
|
}>;
|
|
145
170
|
}>>;
|
|
171
|
+
maxRequestTime: Struct<number | undefined, null>;
|
|
172
|
+
}>;
|
|
173
|
+
'endowment:ethereum-provider': Struct<{} | undefined, {}>;
|
|
174
|
+
'endowment:keyring': Struct<{
|
|
175
|
+
allowedOrigins?: string[] | undefined;
|
|
176
|
+
maxRequestTime?: number | undefined;
|
|
177
|
+
} | undefined, {
|
|
178
|
+
allowedOrigins: Struct<string[] | undefined, Struct<string, null>>;
|
|
179
|
+
maxRequestTime: Struct<number | undefined, null>;
|
|
180
|
+
}>;
|
|
181
|
+
'endowment:lifecycle-hooks': Struct<{
|
|
182
|
+
maxRequestTime?: number | undefined;
|
|
183
|
+
} | undefined, {
|
|
184
|
+
maxRequestTime: Struct<number | undefined, null>;
|
|
185
|
+
}>;
|
|
186
|
+
'endowment:name-lookup': Struct<{
|
|
187
|
+
chains?: `${string}:${string}`[] | undefined;
|
|
188
|
+
maxRequestTime?: number | undefined;
|
|
189
|
+
matchers?: {
|
|
190
|
+
tlds: string[];
|
|
191
|
+
} | {
|
|
192
|
+
schemes: string[];
|
|
193
|
+
} | {
|
|
194
|
+
tlds: string[];
|
|
195
|
+
schemes: string[];
|
|
196
|
+
} | undefined;
|
|
197
|
+
} | undefined, {
|
|
198
|
+
chains: Struct<`${string}:${string}`[] | undefined, Struct<`${string}:${string}`, null>>;
|
|
199
|
+
matchers: Struct<{
|
|
200
|
+
tlds: string[];
|
|
201
|
+
} | {
|
|
202
|
+
schemes: string[];
|
|
203
|
+
} | {
|
|
204
|
+
tlds: string[];
|
|
205
|
+
schemes: string[];
|
|
206
|
+
} | undefined, null>;
|
|
207
|
+
maxRequestTime: Struct<number | undefined, null>;
|
|
208
|
+
}>;
|
|
209
|
+
'endowment:network-access': Struct<{} | undefined, {}>;
|
|
210
|
+
'endowment:page-home': Struct<{
|
|
211
|
+
maxRequestTime?: number | undefined;
|
|
212
|
+
} | undefined, {
|
|
213
|
+
maxRequestTime: Struct<number | undefined, null>;
|
|
146
214
|
}>;
|
|
147
215
|
'endowment:rpc': Struct<{
|
|
148
216
|
dapps?: boolean | undefined;
|
|
@@ -153,14 +221,22 @@ export declare const PermissionsStruct: Struct<{
|
|
|
153
221
|
snaps: Struct<boolean | undefined, null>;
|
|
154
222
|
allowedOrigins: Struct<string[] | undefined, Struct<string, null>>;
|
|
155
223
|
}>;
|
|
156
|
-
'endowment:
|
|
157
|
-
|
|
158
|
-
|
|
224
|
+
'endowment:signature-insight': Struct<{
|
|
225
|
+
maxRequestTime?: number | undefined;
|
|
226
|
+
allowSignatureOrigin?: boolean | undefined;
|
|
159
227
|
} | undefined, {
|
|
160
|
-
|
|
228
|
+
allowSignatureOrigin: Struct<boolean | undefined, null>;
|
|
229
|
+
maxRequestTime: Struct<number | undefined, null>;
|
|
230
|
+
}>;
|
|
231
|
+
'endowment:transaction-insight': Struct<{
|
|
232
|
+
maxRequestTime?: number | undefined;
|
|
233
|
+
allowTransactionOrigin?: boolean | undefined;
|
|
234
|
+
} | undefined, {
|
|
235
|
+
allowTransactionOrigin: Struct<boolean | undefined, null>;
|
|
236
|
+
maxRequestTime: Struct<number | undefined, null>;
|
|
161
237
|
}>;
|
|
238
|
+
'endowment:webassembly': Struct<{} | undefined, {}>;
|
|
162
239
|
snap_dialog: Struct<{} | undefined, {}>;
|
|
163
|
-
snap_confirm: Struct<{} | undefined, {}>;
|
|
164
240
|
snap_manageState: Struct<{} | undefined, {}>;
|
|
165
241
|
snap_manageAccounts: Struct<{} | undefined, {}>;
|
|
166
242
|
snap_notify: Struct<{} | undefined, {}>;
|
|
@@ -245,15 +321,6 @@ export declare const SnapManifestStruct: Struct<{
|
|
|
245
321
|
wallet_snap?: Record<string, {
|
|
246
322
|
version?: string | undefined;
|
|
247
323
|
}> | undefined;
|
|
248
|
-
'endowment:ethereum-provider'?: {} | undefined;
|
|
249
|
-
'endowment:network-access'?: {} | undefined;
|
|
250
|
-
'endowment:webassembly'?: {} | undefined;
|
|
251
|
-
'endowment:signature-insight'?: {
|
|
252
|
-
allowSignatureOrigin?: boolean | undefined;
|
|
253
|
-
} | undefined;
|
|
254
|
-
'endowment:transaction-insight'?: {
|
|
255
|
-
allowTransactionOrigin?: boolean | undefined;
|
|
256
|
-
} | undefined;
|
|
257
324
|
'endowment:cronjob'?: {
|
|
258
325
|
jobs: {
|
|
259
326
|
request: {
|
|
@@ -264,17 +331,46 @@ export declare const SnapManifestStruct: Struct<{
|
|
|
264
331
|
};
|
|
265
332
|
expression: string;
|
|
266
333
|
}[];
|
|
334
|
+
maxRequestTime?: number | undefined;
|
|
335
|
+
} | undefined;
|
|
336
|
+
'endowment:ethereum-provider'?: {} | undefined;
|
|
337
|
+
'endowment:keyring'?: {
|
|
338
|
+
allowedOrigins?: string[] | undefined;
|
|
339
|
+
maxRequestTime?: number | undefined;
|
|
340
|
+
} | undefined;
|
|
341
|
+
'endowment:lifecycle-hooks'?: {
|
|
342
|
+
maxRequestTime?: number | undefined;
|
|
343
|
+
} | undefined;
|
|
344
|
+
'endowment:name-lookup'?: {
|
|
345
|
+
chains?: `${string}:${string}`[] | undefined;
|
|
346
|
+
maxRequestTime?: number | undefined;
|
|
347
|
+
matchers?: {
|
|
348
|
+
tlds: string[];
|
|
349
|
+
} | {
|
|
350
|
+
schemes: string[];
|
|
351
|
+
} | {
|
|
352
|
+
tlds: string[];
|
|
353
|
+
schemes: string[];
|
|
354
|
+
} | undefined;
|
|
355
|
+
} | undefined;
|
|
356
|
+
'endowment:network-access'?: {} | undefined;
|
|
357
|
+
'endowment:page-home'?: {
|
|
358
|
+
maxRequestTime?: number | undefined;
|
|
267
359
|
} | undefined;
|
|
268
360
|
'endowment:rpc'?: {
|
|
269
361
|
dapps?: boolean | undefined;
|
|
270
362
|
snaps?: boolean | undefined;
|
|
271
363
|
allowedOrigins?: string[] | undefined;
|
|
272
364
|
} | undefined;
|
|
273
|
-
'endowment:
|
|
274
|
-
|
|
275
|
-
|
|
365
|
+
'endowment:signature-insight'?: {
|
|
366
|
+
maxRequestTime?: number | undefined;
|
|
367
|
+
allowSignatureOrigin?: boolean | undefined;
|
|
276
368
|
} | undefined;
|
|
277
|
-
|
|
369
|
+
'endowment:transaction-insight'?: {
|
|
370
|
+
maxRequestTime?: number | undefined;
|
|
371
|
+
allowTransactionOrigin?: boolean | undefined;
|
|
372
|
+
} | undefined;
|
|
373
|
+
'endowment:webassembly'?: {} | undefined;
|
|
278
374
|
};
|
|
279
375
|
manifestVersion: "0.1";
|
|
280
376
|
repository?: {
|
|
@@ -353,15 +449,6 @@ export declare const SnapManifestStruct: Struct<{
|
|
|
353
449
|
wallet_snap?: Record<string, {
|
|
354
450
|
version?: string | undefined;
|
|
355
451
|
}> | undefined;
|
|
356
|
-
'endowment:ethereum-provider'?: {} | undefined;
|
|
357
|
-
'endowment:network-access'?: {} | undefined;
|
|
358
|
-
'endowment:webassembly'?: {} | undefined;
|
|
359
|
-
'endowment:signature-insight'?: {
|
|
360
|
-
allowSignatureOrigin?: boolean | undefined;
|
|
361
|
-
} | undefined;
|
|
362
|
-
'endowment:transaction-insight'?: {
|
|
363
|
-
allowTransactionOrigin?: boolean | undefined;
|
|
364
|
-
} | undefined;
|
|
365
452
|
'endowment:cronjob'?: {
|
|
366
453
|
jobs: {
|
|
367
454
|
request: {
|
|
@@ -372,31 +459,47 @@ export declare const SnapManifestStruct: Struct<{
|
|
|
372
459
|
};
|
|
373
460
|
expression: string;
|
|
374
461
|
}[];
|
|
462
|
+
maxRequestTime?: number | undefined;
|
|
463
|
+
} | undefined;
|
|
464
|
+
'endowment:ethereum-provider'?: {} | undefined;
|
|
465
|
+
'endowment:keyring'?: {
|
|
466
|
+
allowedOrigins?: string[] | undefined;
|
|
467
|
+
maxRequestTime?: number | undefined;
|
|
468
|
+
} | undefined;
|
|
469
|
+
'endowment:lifecycle-hooks'?: {
|
|
470
|
+
maxRequestTime?: number | undefined;
|
|
471
|
+
} | undefined;
|
|
472
|
+
'endowment:name-lookup'?: {
|
|
473
|
+
chains?: `${string}:${string}`[] | undefined;
|
|
474
|
+
maxRequestTime?: number | undefined;
|
|
475
|
+
matchers?: {
|
|
476
|
+
tlds: string[];
|
|
477
|
+
} | {
|
|
478
|
+
schemes: string[];
|
|
479
|
+
} | {
|
|
480
|
+
tlds: string[];
|
|
481
|
+
schemes: string[];
|
|
482
|
+
} | undefined;
|
|
483
|
+
} | undefined;
|
|
484
|
+
'endowment:network-access'?: {} | undefined;
|
|
485
|
+
'endowment:page-home'?: {
|
|
486
|
+
maxRequestTime?: number | undefined;
|
|
375
487
|
} | undefined;
|
|
376
488
|
'endowment:rpc'?: {
|
|
377
489
|
dapps?: boolean | undefined;
|
|
378
490
|
snaps?: boolean | undefined;
|
|
379
491
|
allowedOrigins?: string[] | undefined;
|
|
380
492
|
} | undefined;
|
|
381
|
-
'endowment:
|
|
382
|
-
|
|
383
|
-
allowedOrigins?: string[] | undefined;
|
|
384
|
-
} | undefined;
|
|
385
|
-
snap_confirm?: {} | undefined;
|
|
386
|
-
}, {
|
|
387
|
-
'endowment:ethereum-provider': Struct<{} | undefined, {}>;
|
|
388
|
-
'endowment:network-access': Struct<{} | undefined, {}>;
|
|
389
|
-
'endowment:webassembly': Struct<{} | undefined, {}>;
|
|
390
|
-
'endowment:signature-insight': Struct<{
|
|
493
|
+
'endowment:signature-insight'?: {
|
|
494
|
+
maxRequestTime?: number | undefined;
|
|
391
495
|
allowSignatureOrigin?: boolean | undefined;
|
|
392
|
-
} | undefined
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
'endowment:transaction-insight': Struct<{
|
|
496
|
+
} | undefined;
|
|
497
|
+
'endowment:transaction-insight'?: {
|
|
498
|
+
maxRequestTime?: number | undefined;
|
|
396
499
|
allowTransactionOrigin?: boolean | undefined;
|
|
397
|
-
} | undefined
|
|
398
|
-
|
|
399
|
-
|
|
500
|
+
} | undefined;
|
|
501
|
+
'endowment:webassembly'?: {} | undefined;
|
|
502
|
+
}, {
|
|
400
503
|
'endowment:cronjob': Struct<{
|
|
401
504
|
jobs: {
|
|
402
505
|
request: {
|
|
@@ -407,6 +510,7 @@ export declare const SnapManifestStruct: Struct<{
|
|
|
407
510
|
};
|
|
408
511
|
expression: string;
|
|
409
512
|
}[];
|
|
513
|
+
maxRequestTime?: number | undefined;
|
|
410
514
|
} | undefined, {
|
|
411
515
|
jobs: Struct<{
|
|
412
516
|
request: {
|
|
@@ -438,6 +542,49 @@ export declare const SnapManifestStruct: Struct<{
|
|
|
438
542
|
params: Struct<Record<string, import("@metamask/snaps-sdk").Json> | import("@metamask/snaps-sdk").Json[] | undefined, null>;
|
|
439
543
|
}>;
|
|
440
544
|
}>>;
|
|
545
|
+
maxRequestTime: Struct<number | undefined, null>;
|
|
546
|
+
}>;
|
|
547
|
+
'endowment:ethereum-provider': Struct<{} | undefined, {}>;
|
|
548
|
+
'endowment:keyring': Struct<{
|
|
549
|
+
allowedOrigins?: string[] | undefined;
|
|
550
|
+
maxRequestTime?: number | undefined;
|
|
551
|
+
} | undefined, {
|
|
552
|
+
allowedOrigins: Struct<string[] | undefined, Struct<string, null>>;
|
|
553
|
+
maxRequestTime: Struct<number | undefined, null>;
|
|
554
|
+
}>;
|
|
555
|
+
'endowment:lifecycle-hooks': Struct<{
|
|
556
|
+
maxRequestTime?: number | undefined;
|
|
557
|
+
} | undefined, {
|
|
558
|
+
maxRequestTime: Struct<number | undefined, null>;
|
|
559
|
+
}>;
|
|
560
|
+
'endowment:name-lookup': Struct<{
|
|
561
|
+
chains?: `${string}:${string}`[] | undefined;
|
|
562
|
+
maxRequestTime?: number | undefined;
|
|
563
|
+
matchers?: {
|
|
564
|
+
tlds: string[];
|
|
565
|
+
} | {
|
|
566
|
+
schemes: string[];
|
|
567
|
+
} | {
|
|
568
|
+
tlds: string[];
|
|
569
|
+
schemes: string[];
|
|
570
|
+
} | undefined;
|
|
571
|
+
} | undefined, {
|
|
572
|
+
chains: Struct<`${string}:${string}`[] | undefined, Struct<`${string}:${string}`, null>>;
|
|
573
|
+
matchers: Struct<{
|
|
574
|
+
tlds: string[];
|
|
575
|
+
} | {
|
|
576
|
+
schemes: string[];
|
|
577
|
+
} | {
|
|
578
|
+
tlds: string[];
|
|
579
|
+
schemes: string[];
|
|
580
|
+
} | undefined, null>;
|
|
581
|
+
maxRequestTime: Struct<number | undefined, null>;
|
|
582
|
+
}>;
|
|
583
|
+
'endowment:network-access': Struct<{} | undefined, {}>;
|
|
584
|
+
'endowment:page-home': Struct<{
|
|
585
|
+
maxRequestTime?: number | undefined;
|
|
586
|
+
} | undefined, {
|
|
587
|
+
maxRequestTime: Struct<number | undefined, null>;
|
|
441
588
|
}>;
|
|
442
589
|
'endowment:rpc': Struct<{
|
|
443
590
|
dapps?: boolean | undefined;
|
|
@@ -448,14 +595,22 @@ export declare const SnapManifestStruct: Struct<{
|
|
|
448
595
|
snaps: Struct<boolean | undefined, null>;
|
|
449
596
|
allowedOrigins: Struct<string[] | undefined, Struct<string, null>>;
|
|
450
597
|
}>;
|
|
451
|
-
'endowment:
|
|
452
|
-
|
|
453
|
-
|
|
598
|
+
'endowment:signature-insight': Struct<{
|
|
599
|
+
maxRequestTime?: number | undefined;
|
|
600
|
+
allowSignatureOrigin?: boolean | undefined;
|
|
454
601
|
} | undefined, {
|
|
455
|
-
|
|
602
|
+
allowSignatureOrigin: Struct<boolean | undefined, null>;
|
|
603
|
+
maxRequestTime: Struct<number | undefined, null>;
|
|
456
604
|
}>;
|
|
605
|
+
'endowment:transaction-insight': Struct<{
|
|
606
|
+
maxRequestTime?: number | undefined;
|
|
607
|
+
allowTransactionOrigin?: boolean | undefined;
|
|
608
|
+
} | undefined, {
|
|
609
|
+
allowTransactionOrigin: Struct<boolean | undefined, null>;
|
|
610
|
+
maxRequestTime: Struct<number | undefined, null>;
|
|
611
|
+
}>;
|
|
612
|
+
'endowment:webassembly': Struct<{} | undefined, {}>;
|
|
457
613
|
snap_dialog: Struct<{} | undefined, {}>;
|
|
458
|
-
snap_confirm: Struct<{} | undefined, {}>;
|
|
459
614
|
snap_manageState: Struct<{} | undefined, {}>;
|
|
460
615
|
snap_manageAccounts: Struct<{} | undefined, {}>;
|
|
461
616
|
snap_notify: Struct<{} | undefined, {}>;
|
|
@@ -42,7 +42,7 @@ export declare type PostProcessedBundle = {
|
|
|
42
42
|
warnings: PostProcessWarning[];
|
|
43
43
|
};
|
|
44
44
|
export declare enum PostProcessWarning {
|
|
45
|
-
UnsafeMathRandom = "`Math.random` was detected in the bundle. This is not a secure source of randomness."
|
|
45
|
+
UnsafeMathRandom = "`Math.random` was detected in the Snap bundle. This is not a secure source of randomness, and should not be used in a secure context. Use `crypto.getRandomValues` instead."
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
48
|
* Post process code with AST such that it can be evaluated in SES.
|
package/dist/types/structs.d.ts
CHANGED
|
@@ -55,13 +55,14 @@ export declare function file(): Struct<string, null>;
|
|
|
55
55
|
*/
|
|
56
56
|
export declare function named<Type, Schema>(name: string, struct: Struct<Type, Schema>): Struct<Type, Schema>;
|
|
57
57
|
export declare class SnapsStructError<Type, Schema> extends StructError {
|
|
58
|
-
constructor(struct: Struct<Type, Schema>, prefix: string, suffix: string, failure: StructError, failures: () => Generator<Failure
|
|
58
|
+
constructor(struct: Struct<Type, Schema>, prefix: string, suffix: string, failure: StructError, failures: () => Generator<Failure>, colorize?: boolean);
|
|
59
59
|
}
|
|
60
60
|
declare type GetErrorOptions<Type, Schema> = {
|
|
61
61
|
struct: Struct<Type, Schema>;
|
|
62
62
|
prefix: string;
|
|
63
63
|
suffix?: string;
|
|
64
64
|
error: StructError;
|
|
65
|
+
colorize?: boolean;
|
|
65
66
|
};
|
|
66
67
|
/**
|
|
67
68
|
* Converts an array to a generator function that yields the items in the
|
|
@@ -81,9 +82,10 @@ export declare function arrayToGenerator<Type>(array: Type[]): Generator<Type, v
|
|
|
81
82
|
* @param options.suffix - The suffix to add to the error message. Defaults to
|
|
82
83
|
* an empty string.
|
|
83
84
|
* @param options.error - The `superstruct` error to wrap.
|
|
85
|
+
* @param options.colorize - Whether to colorize the value. Defaults to `true`.
|
|
84
86
|
* @returns The `SnapsStructError`.
|
|
85
87
|
*/
|
|
86
|
-
export declare function getError<Type, Schema>({ struct, prefix, suffix, error, }: GetErrorOptions<Type, Schema>): SnapsStructError<Type, Schema>;
|
|
88
|
+
export declare function getError<Type, Schema>({ struct, prefix, suffix, error, colorize, }: GetErrorOptions<Type, Schema>): SnapsStructError<Type, Schema>;
|
|
87
89
|
/**
|
|
88
90
|
* A wrapper of `superstruct`'s `create` function that throws a
|
|
89
91
|
* `SnapsStructError` instead of a `StructError`. This is useful for improving
|
|
@@ -109,18 +111,20 @@ export declare function getStructFromPath<Type, Schema>(struct: Struct<Type, Sch
|
|
|
109
111
|
* Get the union struct names from a struct.
|
|
110
112
|
*
|
|
111
113
|
* @param struct - The struct.
|
|
114
|
+
* @param colorize - Whether to colorize the value. Defaults to `true`.
|
|
112
115
|
* @returns The union struct names, or `null` if the struct is not a union
|
|
113
116
|
* struct.
|
|
114
117
|
*/
|
|
115
|
-
export declare function getUnionStructNames<Type, Schema>(struct: Struct<Type, Schema
|
|
118
|
+
export declare function getUnionStructNames<Type, Schema>(struct: Struct<Type, Schema>, colorize?: boolean): string[] | null;
|
|
116
119
|
/**
|
|
117
|
-
* Get
|
|
120
|
+
* Get an error prefix from a `superstruct` failure. This is useful for
|
|
118
121
|
* formatting the error message returned by `superstruct`.
|
|
119
122
|
*
|
|
120
123
|
* @param failure - The `superstruct` failure.
|
|
124
|
+
* @param colorize - Whether to colorize the value. Defaults to `true`.
|
|
121
125
|
* @returns The error prefix.
|
|
122
126
|
*/
|
|
123
|
-
export declare function getStructErrorPrefix(failure: Failure): string;
|
|
127
|
+
export declare function getStructErrorPrefix(failure: Failure, colorize?: boolean): string;
|
|
124
128
|
/**
|
|
125
129
|
* Get a string describing the failure. This is similar to the `message`
|
|
126
130
|
* property of `superstruct`'s `Failure` type, but formats the value in a more
|
|
@@ -128,16 +132,66 @@ export declare function getStructErrorPrefix(failure: Failure): string;
|
|
|
128
132
|
*
|
|
129
133
|
* @param struct - The struct that caused the failure.
|
|
130
134
|
* @param failure - The `superstruct` failure.
|
|
135
|
+
* @param colorize - Whether to colorize the value. Defaults to `true`.
|
|
131
136
|
* @returns A string describing the failure.
|
|
132
137
|
*/
|
|
133
|
-
export declare function getStructFailureMessage<Type, Schema>(struct: Struct<Type, Schema>, failure: Failure): string;
|
|
138
|
+
export declare function getStructFailureMessage<Type, Schema>(struct: Struct<Type, Schema>, failure: Failure, colorize?: boolean): string;
|
|
134
139
|
/**
|
|
135
140
|
* Get a string describing the errors. This formats all the errors in a
|
|
136
141
|
* human-readable way.
|
|
137
142
|
*
|
|
138
143
|
* @param struct - The struct that caused the failures.
|
|
139
144
|
* @param failures - The `superstruct` failures.
|
|
145
|
+
* @param colorize - Whether to colorize the value. Defaults to `true`.
|
|
140
146
|
* @returns A string describing the errors.
|
|
141
147
|
*/
|
|
142
|
-
export declare function getStructErrorMessage<Type, Schema>(struct: Struct<Type, Schema>, failures: Failure[]): string;
|
|
148
|
+
export declare function getStructErrorMessage<Type, Schema>(struct: Struct<Type, Schema>, failures: Failure[], colorize?: boolean): string;
|
|
149
|
+
/**
|
|
150
|
+
* Validate a union struct, and throw readable errors if the value does not
|
|
151
|
+
* satisfy the struct. This is useful for improving the error messages returned
|
|
152
|
+
* by `superstruct`.
|
|
153
|
+
*
|
|
154
|
+
* @param value - The value to validate.
|
|
155
|
+
* @param struct - The `superstruct` union struct to validate the value against.
|
|
156
|
+
* This struct must be a union of object structs, and must have at least one
|
|
157
|
+
* shared key to validate against.
|
|
158
|
+
* @param structKey - The key to validate against. This key must be present in
|
|
159
|
+
* all the object structs in the union struct, and is expected to be a literal
|
|
160
|
+
* value.
|
|
161
|
+
* @param coerce - Whether to coerce the value to satisfy the struct. Defaults
|
|
162
|
+
* to `false`.
|
|
163
|
+
* @returns The validated value.
|
|
164
|
+
* @throws If the value does not satisfy the struct.
|
|
165
|
+
* @example
|
|
166
|
+
* const struct = union([
|
|
167
|
+
* object({ type: literal('a'), value: string() }),
|
|
168
|
+
* object({ type: literal('b'), value: number() }),
|
|
169
|
+
* object({ type: literal('c'), value: boolean() }),
|
|
170
|
+
* // ...
|
|
171
|
+
* ]);
|
|
172
|
+
*
|
|
173
|
+
* // At path: type — Expected the value to be one of: "a", "b", "c", but received: "d".
|
|
174
|
+
* validateUnion({ type: 'd', value: 'foo' }, struct, 'type');
|
|
175
|
+
*
|
|
176
|
+
* // At path: value — Expected a value of type string, but received: 42.
|
|
177
|
+
* validateUnion({ type: 'a', value: 42 }, struct, 'value');
|
|
178
|
+
*/
|
|
179
|
+
export declare function validateUnion<Type, Schema extends readonly Struct<any, any>[]>(value: unknown, struct: Struct<Type, Schema>, structKey: keyof Type, coerce?: boolean): any;
|
|
180
|
+
/**
|
|
181
|
+
* Create a value with the coercion logic of a union struct, and throw readable
|
|
182
|
+
* errors if the value does not satisfy the struct. This is useful for improving
|
|
183
|
+
* the error messages returned by `superstruct`.
|
|
184
|
+
*
|
|
185
|
+
* @param value - The value to validate.
|
|
186
|
+
* @param struct - The `superstruct` union struct to validate the value against.
|
|
187
|
+
* This struct must be a union of object structs, and must have at least one
|
|
188
|
+
* shared key to validate against.
|
|
189
|
+
* @param structKey - The key to validate against. This key must be present in
|
|
190
|
+
* all the object structs in the union struct, and is expected to be a literal
|
|
191
|
+
* value.
|
|
192
|
+
* @returns The validated value.
|
|
193
|
+
* @throws If the value does not satisfy the struct.
|
|
194
|
+
* @see validateUnion
|
|
195
|
+
*/
|
|
196
|
+
export declare function createUnion<Type, Schema extends readonly Struct<any, any>[]>(value: unknown, struct: Struct<Type, Schema>, structKey: keyof Type): any;
|
|
143
197
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/snaps-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/MetaMask/snaps.git"
|
|
@@ -69,11 +69,11 @@
|
|
|
69
69
|
"@babel/types": "^7.23.0",
|
|
70
70
|
"@metamask/base-controller": "^4.1.0",
|
|
71
71
|
"@metamask/key-tree": "^9.0.0",
|
|
72
|
-
"@metamask/permission-controller": "^
|
|
72
|
+
"@metamask/permission-controller": "^8.0.0",
|
|
73
73
|
"@metamask/rpc-errors": "^6.1.0",
|
|
74
74
|
"@metamask/slip44": "^3.1.0",
|
|
75
75
|
"@metamask/snaps-registry": "^3.0.0",
|
|
76
|
-
"@metamask/snaps-sdk": "^1.
|
|
76
|
+
"@metamask/snaps-sdk": "^2.1.0",
|
|
77
77
|
"@metamask/utils": "^8.3.0",
|
|
78
78
|
"@noble/hashes": "^1.3.1",
|
|
79
79
|
"@scure/base": "^1.1.1",
|
|
@@ -81,7 +81,6 @@
|
|
|
81
81
|
"cron-parser": "^4.5.0",
|
|
82
82
|
"fast-deep-equal": "^3.1.3",
|
|
83
83
|
"fast-json-stable-stringify": "^2.1.0",
|
|
84
|
-
"is-svg": "^4.4.0",
|
|
85
84
|
"rfdc": "^1.3.0",
|
|
86
85
|
"semver": "^7.5.4",
|
|
87
86
|
"ses": "^1.1.0",
|
|
@@ -91,13 +90,13 @@
|
|
|
91
90
|
"devDependencies": {
|
|
92
91
|
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
|
|
93
92
|
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
|
|
94
|
-
"@lavamoat/allow-scripts": "^3.0.
|
|
93
|
+
"@lavamoat/allow-scripts": "^3.0.2",
|
|
95
94
|
"@metamask/auto-changelog": "^3.4.4",
|
|
96
95
|
"@metamask/eslint-config": "^12.1.0",
|
|
97
96
|
"@metamask/eslint-config-jest": "^12.1.0",
|
|
98
97
|
"@metamask/eslint-config-nodejs": "^12.1.0",
|
|
99
98
|
"@metamask/eslint-config-typescript": "^12.1.0",
|
|
100
|
-
"@metamask/post-message-stream": "^
|
|
99
|
+
"@metamask/post-message-stream": "^8.0.0",
|
|
101
100
|
"@swc/cli": "^0.1.62",
|
|
102
101
|
"@swc/core": "1.3.78",
|
|
103
102
|
"@swc/jest": "^0.2.26",
|