@metamask/snaps-rpc-methods
Version:
MetaMask Snaps JSON-RPC method implementations
1 lines • 2.26 kB
Source Map (JSON)
{"version":3,"file":"network-access.mjs","sourceRoot":"","sources":["../../src/endowments/network-access.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,wCAAwC;AAE9E,OAAO,EAAE,cAAc,EAAE,mBAAe;AAExC,MAAM,cAAc,GAAG,cAAc,CAAC,aAAa,CAAC;AAWpD;;;;;;;GAOG;AACH,MAAM,oBAAoB,GAItB,CAAC,eAAqB,EAAE,EAAE;IAC5B,OAAO;QACL,cAAc,EAAE,cAAc,CAAC,SAAS;QACxC,UAAU,EAAE,cAAc;QAC1B,cAAc,EAAE,IAAI;QACpB,eAAe,EAAE,CAAC,cAAsC,EAAE,EAAE;YAC1D,OAAO,CAAC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;QACrD,CAAC;QACD,YAAY,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC;KACjC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,6BAA6B,GAAG,MAAM,CAAC,MAAM,CAAC;IACzD,UAAU,EAAE,cAAc;IAC1B,oBAAoB;CACZ,CAAC,CAAC","sourcesContent":["import type {\n EndowmentGetterParams,\n PermissionSpecificationBuilder,\n ValidPermissionSpecification,\n} from '@metamask/permission-controller';\nimport { PermissionType, SubjectType } from '@metamask/permission-controller';\n\nimport { SnapEndowments } from './enum';\n\nconst permissionName = SnapEndowments.NetworkAccess;\n\ntype NetworkAccessEndowmentSpecification = ValidPermissionSpecification<{\n permissionType: PermissionType.Endowment;\n targetName: typeof permissionName;\n endowmentGetter: (\n _options?: any,\n ) => ['fetch', 'Request', 'Headers', 'Response'];\n allowedCaveats: null;\n}>;\n\n/**\n * `endowment:network-access` returns the name of global browser API(s) that\n * enable network access. This is intended to populate the endowments of the\n * SES Compartment in which a Snap executes.\n *\n * @param _builderOptions - Optional specification builder options.\n * @returns The specification for the network endowment.\n */\nconst specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.Endowment,\n any,\n NetworkAccessEndowmentSpecification\n> = (_builderOptions?: any) => {\n return {\n permissionType: PermissionType.Endowment,\n targetName: permissionName,\n allowedCaveats: null,\n endowmentGetter: (_getterOptions?: EndowmentGetterParams) => {\n return ['fetch', 'Request', 'Headers', 'Response'];\n },\n subjectTypes: [SubjectType.Snap],\n };\n};\n\nexport const networkAccessEndowmentBuilder = Object.freeze({\n targetName: permissionName,\n specificationBuilder,\n} as const);\n"]}