@metamask/snaps-execution-environments 0.37.3-flask.1 → 0.38.0-flask.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -1
- package/dist/browserify/iframe/bundle.js +1 -1
- package/dist/browserify/node-process/bundle.js +1 -1
- package/dist/browserify/node-thread/bundle.js +1 -1
- package/dist/browserify/offscreen/bundle.js +2 -2
- package/dist/browserify/worker-executor/bundle.js +2 -2
- package/dist/browserify/worker-pool/bundle.js +3 -3
- package/dist/cjs/common/BaseSnapExecutor.js +14 -6
- package/dist/cjs/common/BaseSnapExecutor.js.map +1 -1
- package/dist/cjs/common/commands.js +2 -0
- package/dist/cjs/common/commands.js.map +1 -1
- package/dist/cjs/common/utils.js +0 -1
- package/dist/cjs/common/utils.js.map +1 -1
- package/dist/cjs/common/validation.js +0 -20
- package/dist/cjs/common/validation.js.map +1 -1
- package/dist/esm/common/BaseSnapExecutor.js +16 -8
- package/dist/esm/common/BaseSnapExecutor.js.map +1 -1
- package/dist/esm/common/commands.js +2 -0
- package/dist/esm/common/commands.js.map +1 -1
- package/dist/esm/common/utils.js +0 -1
- package/dist/esm/common/utils.js.map +1 -1
- package/dist/esm/common/validation.js +0 -23
- package/dist/esm/common/validation.js.map +1 -1
- package/dist/types/common/validation.d.ts +0 -8
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/common/utils.ts"],"sourcesContent":["import type { StreamProvider } from '@metamask/providers';\nimport type { RequestArguments } from '@metamask/providers/dist/BaseProvider';\nimport { assert, assertStruct, JsonStruct } from '@metamask/utils';\nimport { ethErrors } from 'eth-rpc-errors';\n\nimport { log } from '../logging';\n\n/**\n * Takes an error that was thrown, determines if it is\n * an error object. If it is then it will return that. Otherwise,\n * an error object is created with the original error message.\n *\n * @param originalError - The error that was originally thrown.\n * @returns An error object.\n */\nexport function constructError(originalError: unknown) {\n let _originalError: Error | undefined;\n if (originalError instanceof Error) {\n _originalError = originalError;\n } else if (typeof originalError === 'string') {\n _originalError = new Error(originalError);\n // The stack is useless in this case.\n delete _originalError.stack;\n }\n return _originalError;\n}\n\n/**\n * Make proxy for Promise and handle the teardown process properly.\n * If the teardown is called in the meanwhile, Promise result will not be\n * exposed to the snap anymore and warning will be logged to the console.\n *\n * @param originalPromise - Original promise.\n * @param teardownRef - Reference containing teardown count.\n * @param teardownRef.lastTeardown - Number of the last teardown.\n * @returns New proxy promise.\n */\nexport async function withTeardown<Type>(\n originalPromise: Promise<Type>,\n teardownRef: { lastTeardown: number },\n): Promise<Type> {\n const myTeardown = teardownRef.lastTeardown;\n return new Promise<Type>((resolve, reject) => {\n originalPromise\n .then((value) => {\n if (teardownRef.lastTeardown === myTeardown) {\n resolve(value);\n } else {\n log(\n 'Late promise received after Snap finished execution. Promise will be dropped.',\n );\n }\n })\n .catch((reason) => {\n if (teardownRef.lastTeardown === myTeardown) {\n reject(reason);\n } else {\n log(\n 'Late promise received after Snap finished execution. Promise will be dropped.',\n );\n }\n });\n });\n}\n\n/**\n * Returns a Proxy that narrows down (attenuates) the fields available on\n * the StreamProvider and replaces the request implementation.\n *\n * @param provider - Instance of a StreamProvider to be limited.\n * @param request - Custom attenuated request object.\n * @returns Proxy to the StreamProvider instance.\n */\nexport function proxyStreamProvider(\n provider: StreamProvider,\n request: unknown,\n): StreamProvider {\n // Proxy target is intentionally set to be an empty object, to ensure\n // that access to the prototype chain is not possible.\n const proxy = new Proxy(\n {},\n {\n has(_target: object, prop: string | symbol) {\n return (\n typeof prop === 'string' &&\n ['request', 'on', 'removeListener'].includes(prop)\n );\n },\n get(_target, prop: keyof StreamProvider) {\n if (prop === 'request') {\n return request;\n } else if (['on', 'removeListener'].includes(prop)) {\n return provider[prop];\n }\n\n return undefined;\n },\n },\n );\n\n return proxy as StreamProvider;\n}\n\n// We're blocking these RPC methods for v1, will revisit later.\nexport const BLOCKED_RPC_METHODS = Object.freeze([\n 'wallet_requestSnaps',\n 'wallet_requestPermissions',\n // We disallow all of these confirmations for now, since the screens are not ready for Snaps.\n 'eth_sendRawTransaction',\n 'eth_sendTransaction',\n '
|
|
1
|
+
{"version":3,"sources":["../../../src/common/utils.ts"],"sourcesContent":["import type { StreamProvider } from '@metamask/providers';\nimport type { RequestArguments } from '@metamask/providers/dist/BaseProvider';\nimport { assert, assertStruct, JsonStruct } from '@metamask/utils';\nimport { ethErrors } from 'eth-rpc-errors';\n\nimport { log } from '../logging';\n\n/**\n * Takes an error that was thrown, determines if it is\n * an error object. If it is then it will return that. Otherwise,\n * an error object is created with the original error message.\n *\n * @param originalError - The error that was originally thrown.\n * @returns An error object.\n */\nexport function constructError(originalError: unknown) {\n let _originalError: Error | undefined;\n if (originalError instanceof Error) {\n _originalError = originalError;\n } else if (typeof originalError === 'string') {\n _originalError = new Error(originalError);\n // The stack is useless in this case.\n delete _originalError.stack;\n }\n return _originalError;\n}\n\n/**\n * Make proxy for Promise and handle the teardown process properly.\n * If the teardown is called in the meanwhile, Promise result will not be\n * exposed to the snap anymore and warning will be logged to the console.\n *\n * @param originalPromise - Original promise.\n * @param teardownRef - Reference containing teardown count.\n * @param teardownRef.lastTeardown - Number of the last teardown.\n * @returns New proxy promise.\n */\nexport async function withTeardown<Type>(\n originalPromise: Promise<Type>,\n teardownRef: { lastTeardown: number },\n): Promise<Type> {\n const myTeardown = teardownRef.lastTeardown;\n return new Promise<Type>((resolve, reject) => {\n originalPromise\n .then((value) => {\n if (teardownRef.lastTeardown === myTeardown) {\n resolve(value);\n } else {\n log(\n 'Late promise received after Snap finished execution. Promise will be dropped.',\n );\n }\n })\n .catch((reason) => {\n if (teardownRef.lastTeardown === myTeardown) {\n reject(reason);\n } else {\n log(\n 'Late promise received after Snap finished execution. Promise will be dropped.',\n );\n }\n });\n });\n}\n\n/**\n * Returns a Proxy that narrows down (attenuates) the fields available on\n * the StreamProvider and replaces the request implementation.\n *\n * @param provider - Instance of a StreamProvider to be limited.\n * @param request - Custom attenuated request object.\n * @returns Proxy to the StreamProvider instance.\n */\nexport function proxyStreamProvider(\n provider: StreamProvider,\n request: unknown,\n): StreamProvider {\n // Proxy target is intentionally set to be an empty object, to ensure\n // that access to the prototype chain is not possible.\n const proxy = new Proxy(\n {},\n {\n has(_target: object, prop: string | symbol) {\n return (\n typeof prop === 'string' &&\n ['request', 'on', 'removeListener'].includes(prop)\n );\n },\n get(_target, prop: keyof StreamProvider) {\n if (prop === 'request') {\n return request;\n } else if (['on', 'removeListener'].includes(prop)) {\n return provider[prop];\n }\n\n return undefined;\n },\n },\n );\n\n return proxy as StreamProvider;\n}\n\n// We're blocking these RPC methods for v1, will revisit later.\nexport const BLOCKED_RPC_METHODS = Object.freeze([\n 'wallet_requestSnaps',\n 'wallet_requestPermissions',\n // We disallow all of these confirmations for now, since the screens are not ready for Snaps.\n 'eth_sendRawTransaction',\n 'eth_sendTransaction',\n 'eth_sign',\n 'eth_signTypedData',\n 'eth_signTypedData_v1',\n 'eth_signTypedData_v3',\n 'eth_signTypedData_v4',\n 'eth_decrypt',\n 'eth_getEncryptionPublicKey',\n 'wallet_addEthereumChain',\n 'wallet_switchEthereumChain',\n 'wallet_watchAsset',\n 'wallet_registerOnboarding',\n 'wallet_scanQRCode',\n]);\n\n/**\n * Asserts the validity of request arguments for a snap outbound request using the `snap.request` API.\n *\n * @param args - The arguments to validate.\n */\nexport function assertSnapOutboundRequest(args: RequestArguments) {\n // Disallow any non `wallet_` or `snap_` methods for separation of concerns.\n assert(\n String.prototype.startsWith.call(args.method, 'wallet_') ||\n String.prototype.startsWith.call(args.method, 'snap_'),\n 'The global Snap API only allows RPC methods starting with `wallet_*` and `snap_*`.',\n );\n assert(\n !BLOCKED_RPC_METHODS.includes(args.method),\n ethErrors.rpc.methodNotFound({\n data: {\n method: args.method,\n },\n }),\n );\n assertStruct(args, JsonStruct, 'Provided value is not JSON-RPC compatible');\n}\n\n/**\n * Asserts the validity of request arguments for an ethereum outbound request using the `ethereum.request` API.\n *\n * @param args - The arguments to validate.\n */\nexport function assertEthereumOutboundRequest(args: RequestArguments) {\n // Disallow snaps methods for separation of concerns.\n assert(\n !String.prototype.startsWith.call(args.method, 'snap_'),\n ethErrors.rpc.methodNotFound({\n data: {\n method: args.method,\n },\n }),\n );\n assert(\n !BLOCKED_RPC_METHODS.includes(args.method),\n ethErrors.rpc.methodNotFound({\n data: {\n method: args.method,\n },\n }),\n );\n assertStruct(args, JsonStruct, 'Provided value is not JSON-RPC compatible');\n}\n"],"names":["assert","assertStruct","JsonStruct","ethErrors","log","constructError","originalError","_originalError","Error","stack","withTeardown","originalPromise","teardownRef","myTeardown","lastTeardown","Promise","resolve","reject","then","value","catch","reason","proxyStreamProvider","provider","request","proxy","Proxy","has","_target","prop","includes","get","undefined","BLOCKED_RPC_METHODS","Object","freeze","assertSnapOutboundRequest","args","String","prototype","startsWith","call","method","rpc","methodNotFound","data","assertEthereumOutboundRequest"],"mappings":"AAEA,SAASA,MAAM,EAAEC,YAAY,EAAEC,UAAU,QAAQ,kBAAkB;AACnE,SAASC,SAAS,QAAQ,iBAAiB;AAE3C,SAASC,GAAG,QAAQ,aAAa;AAEjC;;;;;;;CAOC,GACD,OAAO,SAASC,eAAeC,aAAsB;IACnD,IAAIC;IACJ,IAAID,yBAAyBE,OAAO;QAClCD,iBAAiBD;IACnB,OAAO,IAAI,OAAOA,kBAAkB,UAAU;QAC5CC,iBAAiB,IAAIC,MAAMF;QAC3B,qCAAqC;QACrC,OAAOC,eAAeE,KAAK;IAC7B;IACA,OAAOF;AACT;AAEA;;;;;;;;;CASC,GACD,OAAO,eAAeG,aACpBC,eAA8B,EAC9BC,WAAqC;IAErC,MAAMC,aAAaD,YAAYE,YAAY;IAC3C,OAAO,IAAIC,QAAc,CAACC,SAASC;QACjCN,gBACGO,IAAI,CAAC,CAACC;YACL,IAAIP,YAAYE,YAAY,KAAKD,YAAY;gBAC3CG,QAAQG;YACV,OAAO;gBACLf,IACE;YAEJ;QACF,GACCgB,KAAK,CAAC,CAACC;YACN,IAAIT,YAAYE,YAAY,KAAKD,YAAY;gBAC3CI,OAAOI;YACT,OAAO;gBACLjB,IACE;YAEJ;QACF;IACJ;AACF;AAEA;;;;;;;CAOC,GACD,OAAO,SAASkB,oBACdC,QAAwB,EACxBC,OAAgB;IAEhB,qEAAqE;IACrE,sDAAsD;IACtD,MAAMC,QAAQ,IAAIC,MAChB,CAAC,GACD;QACEC,KAAIC,OAAe,EAAEC,IAAqB;YACxC,OACE,OAAOA,SAAS,YAChB;gBAAC;gBAAW;gBAAM;aAAiB,CAACC,QAAQ,CAACD;QAEjD;QACAE,KAAIH,OAAO,EAAEC,IAA0B;YACrC,IAAIA,SAAS,WAAW;gBACtB,OAAOL;YACT,OAAO,IAAI;gBAAC;gBAAM;aAAiB,CAACM,QAAQ,CAACD,OAAO;gBAClD,OAAON,QAAQ,CAACM,KAAK;YACvB;YAEA,OAAOG;QACT;IACF;IAGF,OAAOP;AACT;AAEA,+DAA+D;AAC/D,OAAO,MAAMQ,sBAAsBC,OAAOC,MAAM,CAAC;IAC/C;IACA;IACA,6FAA6F;IAC7F;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,SAASC,0BAA0BC,IAAsB;IAC9D,4EAA4E;IAC5ErC,OACEsC,OAAOC,SAAS,CAACC,UAAU,CAACC,IAAI,CAACJ,KAAKK,MAAM,EAAE,cAC5CJ,OAAOC,SAAS,CAACC,UAAU,CAACC,IAAI,CAACJ,KAAKK,MAAM,EAAE,UAChD;IAEF1C,OACE,CAACiC,oBAAoBH,QAAQ,CAACO,KAAKK,MAAM,GACzCvC,UAAUwC,GAAG,CAACC,cAAc,CAAC;QAC3BC,MAAM;YACJH,QAAQL,KAAKK,MAAM;QACrB;IACF;IAEFzC,aAAaoC,MAAMnC,YAAY;AACjC;AAEA;;;;CAIC,GACD,OAAO,SAAS4C,8BAA8BT,IAAsB;IAClE,qDAAqD;IACrDrC,OACE,CAACsC,OAAOC,SAAS,CAACC,UAAU,CAACC,IAAI,CAACJ,KAAKK,MAAM,EAAE,UAC/CvC,UAAUwC,GAAG,CAACC,cAAc,CAAC;QAC3BC,MAAM;YACJH,QAAQL,KAAKK,MAAM;QACrB;IACF;IAEF1C,OACE,CAACiC,oBAAoBH,QAAQ,CAACO,KAAKK,MAAM,GACzCvC,UAAUwC,GAAG,CAACC,cAAc,CAAC;QAC3BC,MAAM;YACJH,QAAQL,KAAKK,MAAM;QACrB;IACF;IAEFzC,aAAaoC,MAAMnC,YAAY;AACjC"}
|
|
@@ -1,29 +1,6 @@
|
|
|
1
1
|
import { ChainIdStruct, HandlerType } from '@metamask/snaps-utils';
|
|
2
2
|
import { assertStruct, JsonRpcIdStruct, JsonRpcRequestStruct, JsonRpcSuccessStruct, JsonStruct } from '@metamask/utils';
|
|
3
3
|
import { array, assign, enums, is, literal, nullable, object, omit, optional, record, string, tuple, union } from 'superstruct';
|
|
4
|
-
const VALIDATION_FUNCTIONS = {
|
|
5
|
-
[HandlerType.OnRpcRequest]: validateFunctionExport,
|
|
6
|
-
[HandlerType.OnTransaction]: validateFunctionExport,
|
|
7
|
-
[HandlerType.OnCronjob]: validateFunctionExport
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Validates a function export.
|
|
11
|
-
*
|
|
12
|
-
* @param snapExport - The export itself.
|
|
13
|
-
* @returns True if the export matches the expected shape, false otherwise.
|
|
14
|
-
*/ function validateFunctionExport(snapExport) {
|
|
15
|
-
return typeof snapExport === 'function';
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Validates a given snap export.
|
|
19
|
-
*
|
|
20
|
-
* @param type - The type of export expected.
|
|
21
|
-
* @param snapExport - The export itself.
|
|
22
|
-
* @returns True if the export matches the expected shape, false otherwise.
|
|
23
|
-
*/ export function validateExport(type, snapExport) {
|
|
24
|
-
const validationFunction = VALIDATION_FUNCTIONS[type];
|
|
25
|
-
return validationFunction?.(snapExport) ?? false;
|
|
26
|
-
}
|
|
27
4
|
export const JsonRpcRequestWithoutIdStruct = assign(omit(JsonRpcRequestStruct, [
|
|
28
5
|
'id'
|
|
29
6
|
]), object({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/common/validation.ts"],"sourcesContent":["import { ChainIdStruct, HandlerType } from '@metamask/snaps-utils';\nimport type { Json, JsonRpcSuccess } from '@metamask/utils';\nimport {\n assertStruct,\n JsonRpcIdStruct,\n JsonRpcRequestStruct,\n JsonRpcSuccessStruct,\n JsonStruct,\n} from '@metamask/utils';\nimport type { Infer } from 'superstruct';\nimport {\n array,\n assign,\n enums,\n is,\n literal,\n nullable,\n object,\n omit,\n optional,\n record,\n string,\n tuple,\n union,\n} from 'superstruct';\n\
|
|
1
|
+
{"version":3,"sources":["../../../src/common/validation.ts"],"sourcesContent":["import { ChainIdStruct, HandlerType } from '@metamask/snaps-utils';\nimport type { Json, JsonRpcSuccess } from '@metamask/utils';\nimport {\n assertStruct,\n JsonRpcIdStruct,\n JsonRpcRequestStruct,\n JsonRpcSuccessStruct,\n JsonStruct,\n} from '@metamask/utils';\nimport type { Infer } from 'superstruct';\nimport {\n array,\n assign,\n enums,\n is,\n literal,\n nullable,\n object,\n omit,\n optional,\n record,\n string,\n tuple,\n union,\n} from 'superstruct';\n\nexport const JsonRpcRequestWithoutIdStruct = assign(\n omit(JsonRpcRequestStruct, ['id']),\n object({\n id: optional(JsonRpcIdStruct),\n }),\n);\n\nexport type JsonRpcRequestWithoutId = Infer<\n typeof JsonRpcRequestWithoutIdStruct\n>;\n\nexport const EndowmentStruct = string();\nexport type Endowment = Infer<typeof EndowmentStruct>;\n\n/**\n * Check if the given value is an endowment.\n *\n * @param value - The value to check.\n * @returns Whether the value is an endowment.\n */\nexport function isEndowment(value: unknown): value is Endowment {\n return is(value, EndowmentStruct);\n}\n\n/**\n * Check if the given value is an array of endowments.\n *\n * @param value - The value to check.\n * @returns Whether the value is an array of endowments.\n */\nexport function isEndowmentsArray(value: unknown): value is Endowment[] {\n return Array.isArray(value) && value.every(isEndowment);\n}\n\nconst OkStruct = literal('OK');\n\nexport const PingRequestArgumentsStruct = optional(\n union([literal(undefined), array()]),\n);\n\nexport const TerminateRequestArgumentsStruct = union([\n literal(undefined),\n array(),\n]);\n\nexport const ExecuteSnapRequestArgumentsStruct = tuple([\n string(),\n string(),\n optional(array(EndowmentStruct)),\n]);\n\nexport const SnapRpcRequestArgumentsStruct = tuple([\n string(),\n enums(Object.values(HandlerType)),\n string(),\n assign(\n JsonRpcRequestWithoutIdStruct,\n object({\n params: optional(record(string(), JsonStruct)),\n }),\n ),\n]);\n\nexport type PingRequestArguments = Infer<typeof PingRequestArgumentsStruct>;\nexport type TerminateRequestArguments = Infer<\n typeof TerminateRequestArgumentsStruct\n>;\n\nexport type ExecuteSnapRequestArguments = Infer<\n typeof ExecuteSnapRequestArgumentsStruct\n>;\n\nexport type SnapRpcRequestArguments = Infer<\n typeof SnapRpcRequestArgumentsStruct\n>;\n\nexport type RequestArguments =\n | PingRequestArguments\n | TerminateRequestArguments\n | ExecuteSnapRequestArguments\n | SnapRpcRequestArguments;\n\nexport const OnTransactionRequestArgumentsStruct = object({\n // TODO: Improve `transaction` type.\n transaction: record(string(), JsonStruct),\n chainId: ChainIdStruct,\n transactionOrigin: nullable(string()),\n});\n\nexport type OnTransactionRequestArguments = Infer<\n typeof OnTransactionRequestArgumentsStruct\n>;\n\n/**\n * Asserts that the given value is a valid {@link OnTransactionRequestArguments}\n * object.\n *\n * @param value - The value to validate.\n * @throws If the value is not a valid {@link OnTransactionRequestArguments}\n * object.\n */\nexport function assertIsOnTransactionRequestArguments(\n value: unknown,\n): asserts value is OnTransactionRequestArguments {\n assertStruct(\n value,\n OnTransactionRequestArgumentsStruct,\n 'Invalid request params',\n );\n}\n\nconst OkResponseStruct = assign(\n JsonRpcSuccessStruct,\n object({\n result: OkStruct,\n }),\n);\n\nconst SnapRpcResponse = JsonRpcSuccessStruct;\n\nexport type OkResponse = Infer<typeof OkResponseStruct>;\nexport type SnapRpcResponse = Infer<typeof SnapRpcResponse>;\n\nexport type Response = OkResponse | SnapRpcResponse;\n\ntype RequestParams<Params extends unknown[] | undefined> =\n Params extends undefined ? [] : Params;\n\ntype RequestFunction<\n Args extends RequestArguments,\n ResponseType extends JsonRpcSuccess<Json>,\n> = (...args: RequestParams<Args>) => Promise<ResponseType['result']>;\n\nexport type Ping = RequestFunction<PingRequestArguments, OkResponse>;\nexport type Terminate = RequestFunction<TerminateRequestArguments, OkResponse>;\nexport type ExecuteSnap = RequestFunction<\n ExecuteSnapRequestArguments,\n OkResponse\n>;\nexport type SnapRpc = RequestFunction<SnapRpcRequestArguments, SnapRpcResponse>;\n"],"names":["ChainIdStruct","HandlerType","assertStruct","JsonRpcIdStruct","JsonRpcRequestStruct","JsonRpcSuccessStruct","JsonStruct","array","assign","enums","is","literal","nullable","object","omit","optional","record","string","tuple","union","JsonRpcRequestWithoutIdStruct","id","EndowmentStruct","isEndowment","value","isEndowmentsArray","Array","isArray","every","OkStruct","PingRequestArgumentsStruct","undefined","TerminateRequestArgumentsStruct","ExecuteSnapRequestArgumentsStruct","SnapRpcRequestArgumentsStruct","Object","values","params","OnTransactionRequestArgumentsStruct","transaction","chainId","transactionOrigin","assertIsOnTransactionRequestArguments","OkResponseStruct","result","SnapRpcResponse"],"mappings":"AAAA,SAASA,aAAa,EAAEC,WAAW,QAAQ,wBAAwB;AAEnE,SACEC,YAAY,EACZC,eAAe,EACfC,oBAAoB,EACpBC,oBAAoB,EACpBC,UAAU,QACL,kBAAkB;AAEzB,SACEC,KAAK,EACLC,MAAM,EACNC,KAAK,EACLC,EAAE,EACFC,OAAO,EACPC,QAAQ,EACRC,MAAM,EACNC,IAAI,EACJC,QAAQ,EACRC,MAAM,EACNC,MAAM,EACNC,KAAK,EACLC,KAAK,QACA,cAAc;AAErB,OAAO,MAAMC,gCAAgCZ,OAC3CM,KAAKV,sBAAsB;IAAC;CAAK,GACjCS,OAAO;IACLQ,IAAIN,SAASZ;AACf,IACA;AAMF,OAAO,MAAMmB,kBAAkBL,SAAS;AAGxC;;;;;CAKC,GACD,OAAO,SAASM,YAAYC,KAAc;IACxC,OAAOd,GAAGc,OAAOF;AACnB;AAEA;;;;;CAKC,GACD,OAAO,SAASG,kBAAkBD,KAAc;IAC9C,OAAOE,MAAMC,OAAO,CAACH,UAAUA,MAAMI,KAAK,CAACL;AAC7C;AAEA,MAAMM,WAAWlB,QAAQ;AAEzB,OAAO,MAAMmB,6BAA6Bf,SACxCI,MAAM;IAACR,QAAQoB;IAAYxB;CAAQ,GACnC;AAEF,OAAO,MAAMyB,kCAAkCb,MAAM;IACnDR,QAAQoB;IACRxB;CACD,EAAE;AAEH,OAAO,MAAM0B,oCAAoCf,MAAM;IACrDD;IACAA;IACAF,SAASR,MAAMe;CAChB,EAAE;AAEH,OAAO,MAAMY,gCAAgChB,MAAM;IACjDD;IACAR,MAAM0B,OAAOC,MAAM,CAACnC;IACpBgB;IACAT,OACEY,+BACAP,OAAO;QACLwB,QAAQtB,SAASC,OAAOC,UAAUX;IACpC;CAEH,EAAE;AAqBH,OAAO,MAAMgC,sCAAsCzB,OAAO;IACxD,oCAAoC;IACpC0B,aAAavB,OAAOC,UAAUX;IAC9BkC,SAASxC;IACTyC,mBAAmB7B,SAASK;AAC9B,GAAG;AAMH;;;;;;;CAOC,GACD,OAAO,SAASyB,sCACdlB,KAAc;IAEdtB,aACEsB,OACAc,qCACA;AAEJ;AAEA,MAAMK,mBAAmBnC,OACvBH,sBACAQ,OAAO;IACL+B,QAAQf;AACV;AAGF,MAAMgB,kBAAkBxC"}
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import { HandlerType } from '@metamask/snaps-utils';
|
|
2
2
|
import type { Json, JsonRpcSuccess } from '@metamask/utils';
|
|
3
3
|
import type { Infer } from 'superstruct';
|
|
4
|
-
/**
|
|
5
|
-
* Validates a given snap export.
|
|
6
|
-
*
|
|
7
|
-
* @param type - The type of export expected.
|
|
8
|
-
* @param snapExport - The export itself.
|
|
9
|
-
* @returns True if the export matches the expected shape, false otherwise.
|
|
10
|
-
*/
|
|
11
|
-
export declare function validateExport(type: HandlerType, snapExport: unknown): boolean;
|
|
12
4
|
export declare const JsonRpcRequestWithoutIdStruct: import("superstruct").Struct<{
|
|
13
5
|
method: string;
|
|
14
6
|
jsonrpc: "2.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/snaps-execution-environments",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.0-flask.1",
|
|
4
4
|
"description": "Snap sandbox environments for executing SES javascript",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@metamask/post-message-stream": "^6.1.2",
|
|
49
49
|
"@metamask/providers": "^11.0.0",
|
|
50
50
|
"@metamask/rpc-methods": "^0.37.2-flask.1",
|
|
51
|
-
"@metamask/snaps-utils": "^0.
|
|
51
|
+
"@metamask/snaps-utils": "^0.38.0-flask.1",
|
|
52
52
|
"@metamask/utils": "^6.0.1",
|
|
53
53
|
"eth-rpc-errors": "^4.0.3",
|
|
54
54
|
"json-rpc-engine": "^6.1.0",
|