@metamask/snaps-utils 5.1.2 → 6.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/CHANGELOG.md +28 -3
- package/dist/cjs/caveats.js +9 -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 +2 -0
- package/dist/cjs/handler-types.js.map +1 -1
- package/dist/cjs/handlers.js +85 -3
- package/dist/cjs/handlers.js.map +1 -1
- package/dist/cjs/manifest/manifest.js +3 -2
- package/dist/cjs/manifest/manifest.js.map +1 -1
- package/dist/cjs/manifest/validation.js +61 -12
- package/dist/cjs/manifest/validation.js.map +1 -1
- package/dist/cjs/snaps.js.map +1 -1
- package/dist/cjs/structs.js +86 -17
- package/dist/cjs/structs.js.map +1 -1
- package/dist/esm/caveats.js +9 -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 +2 -0
- package/dist/esm/handler-types.js.map +1 -1
- package/dist/esm/handlers.js +53 -4
- package/dist/esm/handlers.js.map +1 -1
- package/dist/esm/manifest/manifest.js +3 -2
- package/dist/esm/manifest/manifest.js.map +1 -1
- package/dist/esm/manifest/validation.js +47 -15
- package/dist/esm/manifest/validation.js.map +1 -1
- package/dist/esm/snaps.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 +13 -1
- package/dist/types/handler-types.d.ts +3 -1
- package/dist/types/handlers.d.ts +427 -4
- package/dist/types/localization.d.ts +35 -9
- package/dist/types/manifest/validation.d.ts +239 -51
- package/dist/types/snaps.d.ts +12 -0
- package/dist/types/structs.d.ts +61 -7
- package/package.json +8 -8
|
@@ -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?: {
|
|
@@ -51,17 +68,13 @@ export declare const PermissionsStruct: Struct<{
|
|
|
51
68
|
coinType: number;
|
|
52
69
|
}[] | undefined;
|
|
53
70
|
snap_getEntropy?: {} | undefined;
|
|
71
|
+
snap_getLocale?: {} | undefined;
|
|
54
72
|
snap_manageAccounts?: {} | undefined;
|
|
55
73
|
snap_manageState?: {} | undefined;
|
|
56
74
|
snap_notify?: {} | undefined;
|
|
57
75
|
wallet_snap?: Record<string, {
|
|
58
76
|
version?: string | undefined;
|
|
59
77
|
}> | undefined;
|
|
60
|
-
'endowment:network-access'?: {} | undefined;
|
|
61
|
-
'endowment:webassembly'?: {} | undefined;
|
|
62
|
-
'endowment:transaction-insight'?: {
|
|
63
|
-
allowTransactionOrigin?: boolean | undefined;
|
|
64
|
-
} | undefined;
|
|
65
78
|
'endowment:cronjob'?: {
|
|
66
79
|
jobs: {
|
|
67
80
|
request: {
|
|
@@ -72,25 +85,47 @@ export declare const PermissionsStruct: Struct<{
|
|
|
72
85
|
};
|
|
73
86
|
expression: string;
|
|
74
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;
|
|
75
113
|
} | undefined;
|
|
76
114
|
'endowment:rpc'?: {
|
|
77
115
|
dapps?: boolean | undefined;
|
|
78
116
|
snaps?: boolean | undefined;
|
|
79
117
|
allowedOrigins?: string[] | undefined;
|
|
80
118
|
} | undefined;
|
|
81
|
-
'endowment:
|
|
82
|
-
|
|
83
|
-
|
|
119
|
+
'endowment:signature-insight'?: {
|
|
120
|
+
maxRequestTime?: number | undefined;
|
|
121
|
+
allowSignatureOrigin?: boolean | undefined;
|
|
84
122
|
} | undefined;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
'endowment:network-access': Struct<{} | undefined, {}>;
|
|
88
|
-
'endowment:webassembly': Struct<{} | undefined, {}>;
|
|
89
|
-
'endowment:transaction-insight': Struct<{
|
|
123
|
+
'endowment:transaction-insight'?: {
|
|
124
|
+
maxRequestTime?: number | undefined;
|
|
90
125
|
allowTransactionOrigin?: boolean | undefined;
|
|
91
|
-
} | undefined
|
|
92
|
-
|
|
93
|
-
|
|
126
|
+
} | undefined;
|
|
127
|
+
'endowment:webassembly'?: {} | undefined;
|
|
128
|
+
}, {
|
|
94
129
|
'endowment:cronjob': Struct<{
|
|
95
130
|
jobs: {
|
|
96
131
|
request: {
|
|
@@ -101,6 +136,7 @@ export declare const PermissionsStruct: Struct<{
|
|
|
101
136
|
};
|
|
102
137
|
expression: string;
|
|
103
138
|
}[];
|
|
139
|
+
maxRequestTime?: number | undefined;
|
|
104
140
|
} | undefined, {
|
|
105
141
|
jobs: Struct<{
|
|
106
142
|
request: {
|
|
@@ -132,6 +168,49 @@ export declare const PermissionsStruct: Struct<{
|
|
|
132
168
|
params: Struct<Record<string, import("@metamask/snaps-sdk").Json> | import("@metamask/snaps-sdk").Json[] | undefined, null>;
|
|
133
169
|
}>;
|
|
134
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>;
|
|
135
214
|
}>;
|
|
136
215
|
'endowment:rpc': Struct<{
|
|
137
216
|
dapps?: boolean | undefined;
|
|
@@ -142,14 +221,22 @@ export declare const PermissionsStruct: Struct<{
|
|
|
142
221
|
snaps: Struct<boolean | undefined, null>;
|
|
143
222
|
allowedOrigins: Struct<string[] | undefined, Struct<string, null>>;
|
|
144
223
|
}>;
|
|
145
|
-
'endowment:
|
|
146
|
-
|
|
147
|
-
|
|
224
|
+
'endowment:signature-insight': Struct<{
|
|
225
|
+
maxRequestTime?: number | undefined;
|
|
226
|
+
allowSignatureOrigin?: boolean | undefined;
|
|
148
227
|
} | undefined, {
|
|
149
|
-
|
|
228
|
+
allowSignatureOrigin: Struct<boolean | undefined, null>;
|
|
229
|
+
maxRequestTime: Struct<number | undefined, null>;
|
|
150
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>;
|
|
237
|
+
}>;
|
|
238
|
+
'endowment:webassembly': Struct<{} | undefined, {}>;
|
|
151
239
|
snap_dialog: Struct<{} | undefined, {}>;
|
|
152
|
-
snap_confirm: Struct<{} | undefined, {}>;
|
|
153
240
|
snap_manageState: Struct<{} | undefined, {}>;
|
|
154
241
|
snap_manageAccounts: Struct<{} | undefined, {}>;
|
|
155
242
|
snap_notify: Struct<{} | undefined, {}>;
|
|
@@ -187,12 +274,15 @@ export declare const PermissionsStruct: Struct<{
|
|
|
187
274
|
coinType: Struct<number, null>;
|
|
188
275
|
}>>;
|
|
189
276
|
snap_getEntropy: Struct<{} | undefined, {}>;
|
|
277
|
+
snap_getLocale: Struct<{} | undefined, {}>;
|
|
190
278
|
wallet_snap: Struct<Record<string, {
|
|
191
279
|
version?: string | undefined;
|
|
192
280
|
}> | undefined, null>;
|
|
193
281
|
}>;
|
|
194
282
|
export declare type SnapPermissions = InferMatching<typeof PermissionsStruct, InitialPermissions>;
|
|
195
283
|
export declare const SnapAuxilaryFilesStruct: Struct<string[], Struct<string, null>>;
|
|
284
|
+
export declare const InitialConnectionsStruct: Struct<Record<string & URL, {}>, null>;
|
|
285
|
+
export declare type InitialConnections = Infer<typeof InitialConnectionsStruct>;
|
|
196
286
|
export declare const SnapManifestStruct: Struct<{
|
|
197
287
|
description: string;
|
|
198
288
|
version: import("@metamask/utils").SemVerVersion;
|
|
@@ -224,17 +314,13 @@ export declare const SnapManifestStruct: Struct<{
|
|
|
224
314
|
coinType: number;
|
|
225
315
|
}[] | undefined;
|
|
226
316
|
snap_getEntropy?: {} | undefined;
|
|
317
|
+
snap_getLocale?: {} | undefined;
|
|
227
318
|
snap_manageAccounts?: {} | undefined;
|
|
228
319
|
snap_manageState?: {} | undefined;
|
|
229
320
|
snap_notify?: {} | undefined;
|
|
230
321
|
wallet_snap?: Record<string, {
|
|
231
322
|
version?: string | undefined;
|
|
232
323
|
}> | undefined;
|
|
233
|
-
'endowment:network-access'?: {} | undefined;
|
|
234
|
-
'endowment:webassembly'?: {} | undefined;
|
|
235
|
-
'endowment:transaction-insight'?: {
|
|
236
|
-
allowTransactionOrigin?: boolean | undefined;
|
|
237
|
-
} | undefined;
|
|
238
324
|
'endowment:cronjob'?: {
|
|
239
325
|
jobs: {
|
|
240
326
|
request: {
|
|
@@ -245,23 +331,53 @@ export declare const SnapManifestStruct: Struct<{
|
|
|
245
331
|
};
|
|
246
332
|
expression: string;
|
|
247
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;
|
|
248
359
|
} | undefined;
|
|
249
360
|
'endowment:rpc'?: {
|
|
250
361
|
dapps?: boolean | undefined;
|
|
251
362
|
snaps?: boolean | undefined;
|
|
252
363
|
allowedOrigins?: string[] | undefined;
|
|
253
364
|
} | undefined;
|
|
254
|
-
'endowment:
|
|
255
|
-
|
|
256
|
-
|
|
365
|
+
'endowment:signature-insight'?: {
|
|
366
|
+
maxRequestTime?: number | undefined;
|
|
367
|
+
allowSignatureOrigin?: boolean | undefined;
|
|
257
368
|
} | undefined;
|
|
258
|
-
|
|
369
|
+
'endowment:transaction-insight'?: {
|
|
370
|
+
maxRequestTime?: number | undefined;
|
|
371
|
+
allowTransactionOrigin?: boolean | undefined;
|
|
372
|
+
} | undefined;
|
|
373
|
+
'endowment:webassembly'?: {} | undefined;
|
|
259
374
|
};
|
|
260
375
|
manifestVersion: "0.1";
|
|
261
376
|
repository?: {
|
|
262
377
|
type: string;
|
|
263
378
|
url: string;
|
|
264
379
|
} | undefined;
|
|
380
|
+
initialConnections?: Record<string & URL, {}> | undefined;
|
|
265
381
|
$schema?: string | undefined;
|
|
266
382
|
}, {
|
|
267
383
|
version: Struct<import("@metamask/utils").SemVerVersion, null>;
|
|
@@ -311,6 +427,7 @@ export declare const SnapManifestStruct: Struct<{
|
|
|
311
427
|
files: Struct<string[] | undefined, Struct<string, null>>;
|
|
312
428
|
locales: Struct<string[] | undefined, Struct<string, null>>;
|
|
313
429
|
}>;
|
|
430
|
+
initialConnections: Struct<Record<string & URL, {}> | undefined, null>;
|
|
314
431
|
initialPermissions: Struct<{
|
|
315
432
|
snap_dialog?: {} | undefined;
|
|
316
433
|
snap_getBip32Entropy?: {
|
|
@@ -325,17 +442,13 @@ export declare const SnapManifestStruct: Struct<{
|
|
|
325
442
|
coinType: number;
|
|
326
443
|
}[] | undefined;
|
|
327
444
|
snap_getEntropy?: {} | undefined;
|
|
445
|
+
snap_getLocale?: {} | undefined;
|
|
328
446
|
snap_manageAccounts?: {} | undefined;
|
|
329
447
|
snap_manageState?: {} | undefined;
|
|
330
448
|
snap_notify?: {} | undefined;
|
|
331
449
|
wallet_snap?: Record<string, {
|
|
332
450
|
version?: string | undefined;
|
|
333
451
|
}> | undefined;
|
|
334
|
-
'endowment:network-access'?: {} | undefined;
|
|
335
|
-
'endowment:webassembly'?: {} | undefined;
|
|
336
|
-
'endowment:transaction-insight'?: {
|
|
337
|
-
allowTransactionOrigin?: boolean | undefined;
|
|
338
|
-
} | undefined;
|
|
339
452
|
'endowment:cronjob'?: {
|
|
340
453
|
jobs: {
|
|
341
454
|
request: {
|
|
@@ -346,25 +459,47 @@ export declare const SnapManifestStruct: Struct<{
|
|
|
346
459
|
};
|
|
347
460
|
expression: string;
|
|
348
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;
|
|
349
487
|
} | undefined;
|
|
350
488
|
'endowment:rpc'?: {
|
|
351
489
|
dapps?: boolean | undefined;
|
|
352
490
|
snaps?: boolean | undefined;
|
|
353
491
|
allowedOrigins?: string[] | undefined;
|
|
354
492
|
} | undefined;
|
|
355
|
-
'endowment:
|
|
356
|
-
|
|
357
|
-
|
|
493
|
+
'endowment:signature-insight'?: {
|
|
494
|
+
maxRequestTime?: number | undefined;
|
|
495
|
+
allowSignatureOrigin?: boolean | undefined;
|
|
358
496
|
} | undefined;
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
'endowment:network-access': Struct<{} | undefined, {}>;
|
|
362
|
-
'endowment:webassembly': Struct<{} | undefined, {}>;
|
|
363
|
-
'endowment:transaction-insight': Struct<{
|
|
497
|
+
'endowment:transaction-insight'?: {
|
|
498
|
+
maxRequestTime?: number | undefined;
|
|
364
499
|
allowTransactionOrigin?: boolean | undefined;
|
|
365
|
-
} | undefined
|
|
366
|
-
|
|
367
|
-
|
|
500
|
+
} | undefined;
|
|
501
|
+
'endowment:webassembly'?: {} | undefined;
|
|
502
|
+
}, {
|
|
368
503
|
'endowment:cronjob': Struct<{
|
|
369
504
|
jobs: {
|
|
370
505
|
request: {
|
|
@@ -375,6 +510,7 @@ export declare const SnapManifestStruct: Struct<{
|
|
|
375
510
|
};
|
|
376
511
|
expression: string;
|
|
377
512
|
}[];
|
|
513
|
+
maxRequestTime?: number | undefined;
|
|
378
514
|
} | undefined, {
|
|
379
515
|
jobs: Struct<{
|
|
380
516
|
request: {
|
|
@@ -406,6 +542,49 @@ export declare const SnapManifestStruct: Struct<{
|
|
|
406
542
|
params: Struct<Record<string, import("@metamask/snaps-sdk").Json> | import("@metamask/snaps-sdk").Json[] | undefined, null>;
|
|
407
543
|
}>;
|
|
408
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>;
|
|
409
588
|
}>;
|
|
410
589
|
'endowment:rpc': Struct<{
|
|
411
590
|
dapps?: boolean | undefined;
|
|
@@ -416,14 +595,22 @@ export declare const SnapManifestStruct: Struct<{
|
|
|
416
595
|
snaps: Struct<boolean | undefined, null>;
|
|
417
596
|
allowedOrigins: Struct<string[] | undefined, Struct<string, null>>;
|
|
418
597
|
}>;
|
|
419
|
-
'endowment:
|
|
420
|
-
|
|
421
|
-
|
|
598
|
+
'endowment:signature-insight': Struct<{
|
|
599
|
+
maxRequestTime?: number | undefined;
|
|
600
|
+
allowSignatureOrigin?: boolean | undefined;
|
|
422
601
|
} | undefined, {
|
|
423
|
-
|
|
602
|
+
allowSignatureOrigin: Struct<boolean | undefined, null>;
|
|
603
|
+
maxRequestTime: Struct<number | undefined, null>;
|
|
424
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, {}>;
|
|
425
613
|
snap_dialog: Struct<{} | undefined, {}>;
|
|
426
|
-
snap_confirm: Struct<{} | undefined, {}>;
|
|
427
614
|
snap_manageState: Struct<{} | undefined, {}>;
|
|
428
615
|
snap_manageAccounts: Struct<{} | undefined, {}>;
|
|
429
616
|
snap_notify: Struct<{} | undefined, {}>;
|
|
@@ -461,6 +648,7 @@ export declare const SnapManifestStruct: Struct<{
|
|
|
461
648
|
coinType: Struct<number, null>;
|
|
462
649
|
}>>;
|
|
463
650
|
snap_getEntropy: Struct<{} | undefined, {}>;
|
|
651
|
+
snap_getLocale: Struct<{} | undefined, {}>;
|
|
464
652
|
wallet_snap: Struct<Record<string, {
|
|
465
653
|
version?: string | undefined;
|
|
466
654
|
}> | undefined, null>;
|
package/dist/types/snaps.d.ts
CHANGED
|
@@ -79,6 +79,18 @@ export declare type Snap = TruncatedSnap & {
|
|
|
79
79
|
* Localization files which are used to translate the manifest.
|
|
80
80
|
*/
|
|
81
81
|
localizationFiles?: LocalizationFile[];
|
|
82
|
+
/**
|
|
83
|
+
* Flag to signal whether this snap was preinstalled or not.
|
|
84
|
+
*
|
|
85
|
+
* A lack of specifying this option will be deemed as not preinstalled.
|
|
86
|
+
*/
|
|
87
|
+
preinstalled?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Flag to signal whether this snap is removable or not.
|
|
90
|
+
*
|
|
91
|
+
* A lack of specifying this option will be deemed as removable.
|
|
92
|
+
*/
|
|
93
|
+
removable?: boolean;
|
|
82
94
|
};
|
|
83
95
|
export declare type TruncatedSnapFields = 'id' | 'initialPermissions' | 'version' | 'enabled' | 'blocked';
|
|
84
96
|
/**
|
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.0.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/MetaMask/snaps.git"
|
|
@@ -67,14 +67,14 @@
|
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"@babel/core": "^7.23.2",
|
|
69
69
|
"@babel/types": "^7.23.0",
|
|
70
|
-
"@metamask/base-controller": "^4.
|
|
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": "^
|
|
77
|
-
"@metamask/utils": "^8.
|
|
76
|
+
"@metamask/snaps-sdk": "^2.0.0",
|
|
77
|
+
"@metamask/utils": "^8.3.0",
|
|
78
78
|
"@noble/hashes": "^1.3.1",
|
|
79
79
|
"@scure/base": "^1.1.1",
|
|
80
80
|
"chalk": "^4.1.2",
|
|
@@ -84,20 +84,20 @@
|
|
|
84
84
|
"is-svg": "^4.4.0",
|
|
85
85
|
"rfdc": "^1.3.0",
|
|
86
86
|
"semver": "^7.5.4",
|
|
87
|
-
"ses": "^
|
|
87
|
+
"ses": "^1.1.0",
|
|
88
88
|
"superstruct": "^1.0.3",
|
|
89
89
|
"validate-npm-package-name": "^5.0.0"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
92
|
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
|
|
93
93
|
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
|
|
94
|
-
"@lavamoat/allow-scripts": "^
|
|
94
|
+
"@lavamoat/allow-scripts": "^3.0.0",
|
|
95
95
|
"@metamask/auto-changelog": "^3.4.4",
|
|
96
96
|
"@metamask/eslint-config": "^12.1.0",
|
|
97
97
|
"@metamask/eslint-config-jest": "^12.1.0",
|
|
98
98
|
"@metamask/eslint-config-nodejs": "^12.1.0",
|
|
99
99
|
"@metamask/eslint-config-typescript": "^12.1.0",
|
|
100
|
-
"@metamask/post-message-stream": "^
|
|
100
|
+
"@metamask/post-message-stream": "^8.0.0",
|
|
101
101
|
"@swc/cli": "^0.1.62",
|
|
102
102
|
"@swc/core": "1.3.78",
|
|
103
103
|
"@swc/jest": "^0.2.26",
|