@metamask/snaps-utils 7.0.4 → 7.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.
Files changed (58) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/dist/{chunk-2IWSQJKQ.mjs → chunk-2M6G46W6.mjs} +1 -1
  3. package/dist/chunk-2M6G46W6.mjs.map +1 -0
  4. package/dist/{chunk-HKJDVWVO.js → chunk-7EDRFEUH.js} +11 -11
  5. package/dist/{chunk-LTWLSRSR.js → chunk-E5WSD47S.js} +3 -3
  6. package/dist/{chunk-RQVVWCOW.mjs → chunk-E6U344HR.mjs} +3 -3
  7. package/dist/{chunk-6F2DZTGM.mjs → chunk-HTS6HGUU.mjs} +2 -2
  8. package/dist/{chunk-TG4BDSYJ.js → chunk-HVTYDKBO.js} +1 -1
  9. package/dist/chunk-HVTYDKBO.js.map +1 -0
  10. package/dist/{chunk-HDZ3BJBL.mjs → chunk-KP4ZAWMP.mjs} +8 -4
  11. package/dist/chunk-KP4ZAWMP.mjs.map +1 -0
  12. package/dist/{chunk-OK2Q2GT7.js → chunk-MKTAIEG7.js} +5 -5
  13. package/dist/{chunk-EX4PPLND.js → chunk-NDIITWO4.js} +7 -3
  14. package/dist/chunk-NDIITWO4.js.map +1 -0
  15. package/dist/{chunk-QX6MAFJU.mjs → chunk-PBXAWRWW.mjs} +6 -1
  16. package/dist/chunk-PBXAWRWW.mjs.map +1 -0
  17. package/dist/{chunk-2PCPD5XY.js → chunk-XNUUUOKX.js} +6 -1
  18. package/dist/chunk-XNUUUOKX.js.map +1 -0
  19. package/dist/{chunk-ZO24JBZA.mjs → chunk-YP3ZXUME.mjs} +3 -3
  20. package/dist/derivation-paths.js +2 -2
  21. package/dist/derivation-paths.mjs +1 -1
  22. package/dist/index.js +8 -6
  23. package/dist/index.mjs +7 -5
  24. package/dist/manifest/index.js +3 -3
  25. package/dist/manifest/index.mjs +2 -2
  26. package/dist/manifest/manifest.js +4 -4
  27. package/dist/manifest/manifest.mjs +3 -3
  28. package/dist/manifest/node.js +4 -4
  29. package/dist/manifest/node.mjs +3 -3
  30. package/dist/manifest/validation.js +3 -3
  31. package/dist/manifest/validation.mjs +2 -2
  32. package/dist/node.js +9 -7
  33. package/dist/node.mjs +8 -6
  34. package/dist/npm.js +4 -4
  35. package/dist/npm.mjs +3 -3
  36. package/dist/snaps.js +2 -2
  37. package/dist/snaps.mjs +1 -1
  38. package/dist/tsconfig.build.tsbuildinfo +1 -1
  39. package/dist/types/handlers.d.ts +87 -87
  40. package/dist/types/snaps.d.ts +5 -1
  41. package/dist/types/ui.d.ts +8 -1
  42. package/dist/ui.js +4 -2
  43. package/dist/ui.mjs +3 -1
  44. package/dist/validation.js +4 -4
  45. package/dist/validation.mjs +3 -3
  46. package/package.json +3 -3
  47. package/dist/chunk-2IWSQJKQ.mjs.map +0 -1
  48. package/dist/chunk-2PCPD5XY.js.map +0 -1
  49. package/dist/chunk-EX4PPLND.js.map +0 -1
  50. package/dist/chunk-HDZ3BJBL.mjs.map +0 -1
  51. package/dist/chunk-QX6MAFJU.mjs.map +0 -1
  52. package/dist/chunk-TG4BDSYJ.js.map +0 -1
  53. /package/dist/{chunk-HKJDVWVO.js.map → chunk-7EDRFEUH.js.map} +0 -0
  54. /package/dist/{chunk-LTWLSRSR.js.map → chunk-E5WSD47S.js.map} +0 -0
  55. /package/dist/{chunk-RQVVWCOW.mjs.map → chunk-E6U344HR.mjs.map} +0 -0
  56. /package/dist/{chunk-6F2DZTGM.mjs.map → chunk-HTS6HGUU.mjs.map} +0 -0
  57. /package/dist/{chunk-OK2Q2GT7.js.map → chunk-MKTAIEG7.js.map} +0 -0
  58. /package/dist/{chunk-ZO24JBZA.mjs.map → chunk-YP3ZXUME.mjs.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [7.1.0]
10
+ ### Added
11
+ - Add derivation path for Nimiq ([#2309](https://github.com/MetaMask/snaps/pull/2309))
12
+
13
+ ### Fixed
14
+ - Disable GitHub flavored Markdown when lexing ([#2317](https://github.com/MetaMask/snaps/pull/2317))
15
+
9
16
  ## [7.0.4]
10
17
  ### Changed
11
18
  - Bump MetaMask dependencies ([#2270](https://github.com/MetaMask/snaps/pull/2270))
@@ -206,7 +213,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
206
213
  - The version of the package no longer needs to match the version of all other
207
214
  MetaMask Snaps packages.
208
215
 
209
- [Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@7.0.4...HEAD
216
+ [Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@7.1.0...HEAD
217
+ [7.1.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@7.0.4...@metamask/snaps-utils@7.1.0
210
218
  [7.0.4]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@7.0.3...@metamask/snaps-utils@7.0.4
211
219
  [7.0.3]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@7.0.2...@metamask/snaps-utils@7.0.3
212
220
  [7.0.2]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@7.0.1...@metamask/snaps-utils@7.0.2
@@ -190,4 +190,4 @@ export {
190
190
  isSnapPermitted,
191
191
  verifyRequestedSnapPermissions
192
192
  };
193
- //# sourceMappingURL=chunk-2IWSQJKQ.mjs.map
193
+ //# sourceMappingURL=chunk-2M6G46W6.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/snaps.ts"],"sourcesContent":["import type {\n Caveat,\n SubjectPermissions,\n PermissionConstraint,\n} from '@metamask/permission-controller';\nimport type { BlockReason } from '@metamask/snaps-registry';\nimport type { SnapId, Snap as TruncatedSnap } from '@metamask/snaps-sdk';\nimport type { Json } from '@metamask/utils';\nimport { assert, isObject, assertStruct } from '@metamask/utils';\nimport { base64 } from '@scure/base';\nimport stableStringify from 'fast-json-stable-stringify';\nimport type { Struct } from 'superstruct';\nimport {\n empty,\n enums,\n intersection,\n literal,\n pattern,\n refine,\n string,\n union,\n validate,\n} from 'superstruct';\nimport validateNPMPackage from 'validate-npm-package-name';\n\nimport { SnapCaveatType } from './caveats';\nimport { checksumFiles } from './checksum';\nimport type { LocalizationFile } from './localization';\nimport type {\n InitialConnections,\n SnapManifest,\n SnapPermissions,\n} from './manifest/validation';\nimport type { FetchedSnapFiles, SnapsPermissionRequest } from './types';\nimport { SnapIdPrefixes, SnapValidationFailureReason, uri } from './types';\nimport type { VirtualFile } from './virtual-file';\n\n// This RegEx matches valid npm package names (with some exceptions) and space-\n// separated alphanumerical words, optionally with dashes and underscores.\n// The RegEx consists of two parts. The first part matches space-separated\n// words. It is based on the following Stackoverflow answer:\n// https://stackoverflow.com/a/34974982\n// The second part, after the pipe operator, is the same RegEx used for the\n// `name` field of the official package.json JSON Schema, except that we allow\n// mixed-case letters. It was originally copied from:\n// https://github.com/SchemaStore/schemastore/blob/81a16897c1dabfd98c72242a5fd62eb080ff76d8/src/schemas/json/package.json#L132-L138\nexport const PROPOSED_NAME_REGEX =\n /^(?:[A-Za-z0-9-_]+( [A-Za-z0-9-_]+)*)|(?:(?:@[A-Za-z0-9-*~][A-Za-z0-9-*._~]*\\/)?[A-Za-z0-9-~][A-Za-z0-9-._~]*)$/u;\n\nexport enum SnapStatus {\n Installing = 'installing',\n Updating = 'updating',\n Running = 'running',\n Stopped = 'stopped',\n Crashed = 'crashed',\n}\n\nexport enum SnapStatusEvents {\n Start = 'START',\n Stop = 'STOP',\n Crash = 'CRASH',\n Update = 'UPDATE',\n}\n\nexport type StatusContext = { snapId: SnapId };\nexport type StatusEvents = { type: SnapStatusEvents };\nexport type StatusStates = {\n value: SnapStatus;\n context: StatusContext;\n};\nexport type Status = StatusStates['value'];\n\nexport type VersionHistory = {\n origin: string;\n version: string;\n // Unix timestamp\n date: number;\n};\n\nexport type SnapAuxilaryFile = {\n path: string;\n // Value here should be stored as base64\n value: string;\n};\n\nexport type PersistedSnap = Snap;\n\n/**\n * A Snap as it exists in {@link SnapController} state.\n */\nexport type Snap = TruncatedSnap & {\n /**\n * The initial connections of the Snap, optional, requested on installation.\n */\n initialConnections?: InitialConnections;\n /**\n * The initial permissions of the Snap, which will be requested when it is\n * installed.\n */\n initialPermissions: SnapPermissions;\n\n /**\n * The source code of the Snap.\n */\n sourceCode: string;\n\n /**\n * The Snap's manifest file.\n */\n manifest: SnapManifest;\n\n /**\n * Information detailing why the snap is blocked.\n */\n blockInformation?: BlockReason;\n\n /**\n * The current status of the Snap, e.g. whether it's running or stopped.\n */\n status: Status;\n\n /**\n * The version history of the Snap.\n * Can be used to derive when the Snap was installed, when it was updated to a certain version and who requested the change.\n */\n versionHistory: VersionHistory[];\n\n /**\n * Static auxiliary files that can be loaded at runtime.\n */\n auxiliaryFiles?: SnapAuxilaryFile[];\n\n /**\n * Localization files which are used to translate the manifest.\n */\n localizationFiles?: LocalizationFile[];\n\n /**\n * Flag to signal whether this snap was preinstalled or not.\n *\n * A lack of specifying this option will be deemed as not preinstalled.\n */\n preinstalled?: boolean;\n\n /**\n * Flag to signal whether this snap is removable or not.\n *\n * A lack of specifying this option will be deemed as removable.\n */\n removable?: boolean;\n};\n\nexport type TruncatedSnapFields =\n | 'id'\n | 'initialPermissions'\n | 'version'\n | 'enabled'\n | 'blocked';\n\n/**\n * An error indicating that a Snap validation failure is programmatically\n * fixable during development.\n */\nexport class ProgrammaticallyFixableSnapError extends Error {\n reason: SnapValidationFailureReason;\n\n constructor(message: string, reason: SnapValidationFailureReason) {\n super(message);\n this.reason = reason;\n }\n}\n\n/**\n * Gets a checksummable manifest by removing the shasum property and reserializing the JSON using a deterministic algorithm.\n *\n * @param manifest - The manifest itself.\n * @returns A virtual file containing the checksummable manifest.\n */\nfunction getChecksummableManifest(\n manifest: VirtualFile<SnapManifest>,\n): VirtualFile {\n const manifestCopy = manifest.clone() as VirtualFile<any>;\n delete manifestCopy.result.source.shasum;\n\n // We use fast-json-stable-stringify to deterministically serialize the JSON\n // This is required before checksumming so we get reproducible checksums across platforms etc\n manifestCopy.value = stableStringify(manifestCopy.result);\n return manifestCopy;\n}\n\n/**\n * Calculates the Base64-encoded SHA-256 digest of all required Snap files.\n *\n * @param files - All required Snap files to be included in the checksum.\n * @returns The Base64-encoded SHA-256 digest of the source code.\n */\nexport async function getSnapChecksum(\n files: FetchedSnapFiles,\n): Promise<string> {\n const { manifest, sourceCode, svgIcon, auxiliaryFiles, localizationFiles } =\n files;\n\n const all = [\n getChecksummableManifest(manifest),\n sourceCode,\n svgIcon,\n ...auxiliaryFiles,\n ...localizationFiles,\n ].filter((file) => file !== undefined);\n\n return base64.encode(await checksumFiles(all as VirtualFile[]));\n}\n\n/**\n * Checks whether the `source.shasum` property of a Snap manifest matches the\n * shasum of the snap.\n *\n * @param files - All required Snap files to be included in the checksum.\n * @param errorMessage - The error message to throw if validation fails.\n */\nexport async function validateSnapShasum(\n files: FetchedSnapFiles,\n errorMessage = 'Invalid Snap manifest: manifest shasum does not match computed shasum.',\n): Promise<void> {\n if (files.manifest.result.source.shasum !== (await getSnapChecksum(files))) {\n throw new ProgrammaticallyFixableSnapError(\n errorMessage,\n SnapValidationFailureReason.ShasumMismatch,\n );\n }\n}\n\nexport const LOCALHOST_HOSTNAMES = ['localhost', '127.0.0.1', '[::1]'] as const;\n\n// Require snap ids to only consist of printable ASCII characters\nexport const BaseSnapIdStruct = pattern(string(), /^[\\x21-\\x7E]*$/u);\n\nconst LocalSnapIdSubUrlStruct = uri({\n protocol: enums(['http:', 'https:']),\n hostname: enums(LOCALHOST_HOSTNAMES),\n hash: empty(string()),\n search: empty(string()),\n});\n\nexport const LocalSnapIdStruct = refine(\n BaseSnapIdStruct,\n 'local Snap Id',\n (value) => {\n if (!value.startsWith(SnapIdPrefixes.local)) {\n return `Expected local snap ID, got \"${value}\".`;\n }\n\n const [error] = validate(\n value.slice(SnapIdPrefixes.local.length),\n LocalSnapIdSubUrlStruct,\n );\n return error ?? true;\n },\n);\nexport const NpmSnapIdStruct = intersection([\n BaseSnapIdStruct,\n uri({\n protocol: literal(SnapIdPrefixes.npm),\n pathname: refine(string(), 'package name', function* (value) {\n const normalized = value.startsWith('/') ? value.slice(1) : value;\n const { errors, validForNewPackages, warnings } =\n validateNPMPackage(normalized);\n if (!validForNewPackages) {\n if (errors === undefined) {\n assert(warnings !== undefined);\n yield* warnings;\n } else {\n yield* errors;\n }\n }\n return true;\n }),\n search: empty(string()),\n hash: empty(string()),\n }),\n]) as unknown as Struct<string, null>;\n\nexport const HttpSnapIdStruct = intersection([\n BaseSnapIdStruct,\n uri({\n protocol: enums(['http:', 'https:']),\n search: empty(string()),\n hash: empty(string()),\n }),\n]) as unknown as Struct<string, null>;\n\nexport const SnapIdStruct = union([NpmSnapIdStruct, LocalSnapIdStruct]);\n\n/**\n * Extracts the snap prefix from a snap ID.\n *\n * @param snapId - The snap ID to extract the prefix from.\n * @returns The snap prefix from a snap id, e.g. `npm:`.\n */\nexport function getSnapPrefix(snapId: string): SnapIdPrefixes {\n const prefix = Object.values(SnapIdPrefixes).find((possiblePrefix) =>\n snapId.startsWith(possiblePrefix),\n );\n if (prefix !== undefined) {\n return prefix;\n }\n throw new Error(`Invalid or no prefix found for \"${snapId}\"`);\n}\n\n/**\n * Strips snap prefix from a full snap ID.\n *\n * @param snapId - The snap ID to strip.\n * @returns The stripped snap ID.\n */\nexport function stripSnapPrefix(snapId: string): string {\n return snapId.replace(getSnapPrefix(snapId), '');\n}\n\n/**\n * Assert that the given value is a valid snap ID.\n *\n * @param value - The value to check.\n * @throws If the value is not a valid snap ID.\n */\nexport function assertIsValidSnapId(value: unknown): asserts value is SnapId {\n assertStruct(value, SnapIdStruct, 'Invalid snap ID');\n}\n\n/**\n * Typeguard to ensure a chainId follows the CAIP-2 standard.\n *\n * @param chainId - The chainId being tested.\n * @returns `true` if the value is a valid CAIP chain id, and `false` otherwise.\n */\nexport function isCaipChainId(chainId: unknown): chainId is string {\n return (\n typeof chainId === 'string' &&\n /^(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-a-zA-Z0-9]{1,32})$/u.test(\n chainId,\n )\n );\n}\n\n/**\n * Utility function to check if an origin has permission (and caveat) for a particular snap.\n *\n * @param permissions - An origin's permissions object.\n * @param snapId - The id of the snap.\n * @returns A boolean based on if an origin has the specified snap.\n */\nexport function isSnapPermitted(\n permissions: SubjectPermissions<PermissionConstraint>,\n snapId: SnapId,\n) {\n return Boolean(\n (\n (\n (permissions?.wallet_snap?.caveats?.find(\n (caveat) => caveat.type === SnapCaveatType.SnapIds,\n ) ?? {}) as Caveat<string, Json>\n ).value as Record<string, unknown>\n )?.[snapId],\n );\n}\n\n/**\n * Checks whether the passed in requestedPermissions is a valid\n * permission request for a `wallet_snap` permission.\n *\n * @param requestedPermissions - The requested permissions.\n * @throws If the criteria is not met.\n */\nexport function verifyRequestedSnapPermissions(\n requestedPermissions: unknown,\n): asserts requestedPermissions is SnapsPermissionRequest {\n assert(\n isObject(requestedPermissions),\n 'Requested permissions must be an object.',\n );\n\n const { wallet_snap: walletSnapPermission } = requestedPermissions;\n\n assert(\n isObject(walletSnapPermission),\n 'wallet_snap is missing from the requested permissions.',\n );\n\n const { caveats } = walletSnapPermission;\n\n assert(\n Array.isArray(caveats) && caveats.length === 1,\n 'wallet_snap must have a caveat property with a single-item array value.',\n );\n\n const [caveat] = caveats;\n\n assert(\n isObject(caveat) &&\n caveat.type === SnapCaveatType.SnapIds &&\n isObject(caveat.value),\n `The requested permissions do not have a valid ${SnapCaveatType.SnapIds} caveat.`,\n );\n}\n\nexport type { Snap as TruncatedSnap } from '@metamask/snaps-sdk';\n"],"mappings":";;;;;;;;;AAQA,SAAS,QAAQ,UAAU,oBAAoB;AAC/C,SAAS,cAAc;AACvB,OAAO,qBAAqB;AAE5B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;A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iBAAiB,CAAC;AAQ/D,SAAS,cAAc,QAAgC;AAC5D,QAAM,SAAS,OAAO,OAAO,cAAc,EAAE;AAAA,IAAK,CAAC,mBACjD,OAAO,WAAW,cAAc;AAAA,EAClC;AACA,MAAI,WAAW,QAAW;AACxB,WAAO;AAAA,EACT;AACA,QAAM,IAAI,MAAM,mCAAmC,MAAM,GAAG;AAC9D;AAQO,SAAS,gBAAgB,QAAwB;AACtD,SAAO,OAAO,QAAQ,cAAc,MAAM,GAAG,EAAE;AACjD;AAQO,SAAS,oBAAoB,OAAyC;AAC3E,eAAa,OAAO,cAAc,iBAAiB;AACrD;AAQO,SAAS,cAAc,SAAqC;AACjE,SACE,OAAO,YAAY,YACnB,mEAAmE;AAAA,IACjE;AAAA,EACF;AAEJ;AASO,SAAS,gBACd,aACA,QACA;AACA,SAAO;AAAA,KAGA,aAAa,aAAa,SAAS;AAAA,MAClC,CAAC,WAAW,OAAO;AAAA,IACrB,KAAK,CAAC,GACN,QACA,MAAM;AAAA,EACZ;AACF;AASO,SAAS,+BACd,sBACwD;AACxD;AAAA,IACE,SAAS,oBAAoB;AAAA,IAC7B;AAAA,EACF;AAEA,QAAM,EAAE,aAAa,qBAAqB,IAAI;AAE9C;AAAA,IACE,SAAS,oBAAoB;AAAA,IAC7B;AAAA,EACF;AAEA,QAAM,EAAE,QAAQ,IAAI;AAEpB;AAAA,IACE,MAAM,QAAQ,OAAO,KAAK,QAAQ,WAAW;AAAA,IAC7C;AAAA,EACF;AAEA,QAAM,CAAC,MAAM,IAAI;AAEjB;AAAA,IACE,SAAS,MAAM,KACb,OAAO,oCACP,SAAS,OAAO,KAAK;AAAA,IACvB,wEAAuE;AAAA,EACzE;AACF;","names":["SnapStatus","SnapStatusEvents"]}
@@ -1,11 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
2
 
3
- var _chunkLTWLSRSRjs = require('./chunk-LTWLSRSR.js');
3
+ var _chunkE5WSD47Sjs = require('./chunk-E5WSD47S.js');
4
4
 
5
5
 
6
6
 
7
7
 
8
- var _chunkTG4BDSYJjs = require('./chunk-TG4BDSYJ.js');
8
+ var _chunkHVTYDKBOjs = require('./chunk-HVTYDKBO.js');
9
9
 
10
10
 
11
11
 
@@ -83,7 +83,7 @@ async function checkManifest(basePath, writeManifest = true, sourceCode, writeFi
83
83
  try {
84
84
  ({ manifest } = await validateNpmSnap(snapFiles));
85
85
  } catch (error) {
86
- if (error instanceof _chunkTG4BDSYJjs.ProgrammaticallyFixableSnapError) {
86
+ if (error instanceof _chunkHVTYDKBOjs.ProgrammaticallyFixableSnapError) {
87
87
  errors.push(error.message);
88
88
  const partiallyValidatedFiles = snapFiles;
89
89
  let isInvalid = true;
@@ -102,7 +102,7 @@ async function checkManifest(basePath, writeManifest = true, sourceCode, writeFi
102
102
  isInvalid = false;
103
103
  } catch (nextValidationError) {
104
104
  currentError = nextValidationError;
105
- if (!(nextValidationError instanceof _chunkTG4BDSYJjs.ProgrammaticallyFixableSnapError) || attempts === maxAttempts && !isInvalid) {
105
+ if (!(nextValidationError instanceof _chunkHVTYDKBOjs.ProgrammaticallyFixableSnapError) || attempts === maxAttempts && !isInvalid) {
106
106
  throw new Error(
107
107
  `Internal error: Failed to fix manifest. This is a bug, please report it. Reason:
108
108
  ${error.message}`
@@ -180,7 +180,7 @@ async function fixManifest(snapFiles, error) {
180
180
  manifestCopy.repository = packageJson.result.repository ? _chunkNUCLSR2Gjs.deepClone.call(void 0, packageJson.result.repository) : void 0;
181
181
  break;
182
182
  case '"shasum" field mismatch' /* ShasumMismatch */:
183
- manifestCopy.source.shasum = await _chunkTG4BDSYJjs.getSnapChecksum.call(void 0, snapFiles);
183
+ manifestCopy.source.shasum = await _chunkHVTYDKBOjs.getSnapChecksum.call(void 0, snapFiles);
184
184
  break;
185
185
  default:
186
186
  _utils.assertExhaustive.call(void 0, error.reason);
@@ -287,13 +287,13 @@ async function validateNpmSnapManifest({
287
287
  const manifestPackageVersion = manifest.result.version;
288
288
  const manifestRepository = manifest.result.repository;
289
289
  if (packageJsonName !== manifestPackageName) {
290
- throw new (0, _chunkTG4BDSYJjs.ProgrammaticallyFixableSnapError)(
290
+ throw new (0, _chunkHVTYDKBOjs.ProgrammaticallyFixableSnapError)(
291
291
  `"${"snap.manifest.json" /* Manifest */}" npm package name ("${manifestPackageName}") does not match the "${"package.json" /* PackageJson */}" "name" field ("${packageJsonName}").`,
292
292
  '"name" field mismatch' /* NameMismatch */
293
293
  );
294
294
  }
295
295
  if (packageJsonVersion !== manifestPackageVersion) {
296
- throw new (0, _chunkTG4BDSYJjs.ProgrammaticallyFixableSnapError)(
296
+ throw new (0, _chunkHVTYDKBOjs.ProgrammaticallyFixableSnapError)(
297
297
  `"${"snap.manifest.json" /* Manifest */}" npm package version ("${manifestPackageVersion}") does not match the "${"package.json" /* PackageJson */}" "version" field ("${packageJsonVersion}").`,
298
298
  '"version" field mismatch' /* VersionMismatch */
299
299
  );
@@ -303,12 +303,12 @@ async function validateNpmSnapManifest({
303
303
  // or `null` in the Snap manifest due to TS@<4.4 issues.
304
304
  (packageJsonRepository || manifestRepository) && !_fastdeepequal2.default.call(void 0, packageJsonRepository, manifestRepository)
305
305
  ) {
306
- throw new (0, _chunkTG4BDSYJjs.ProgrammaticallyFixableSnapError)(
306
+ throw new (0, _chunkHVTYDKBOjs.ProgrammaticallyFixableSnapError)(
307
307
  `"${"snap.manifest.json" /* Manifest */}" "repository" field does not match the "${"package.json" /* PackageJson */}" "repository" field.`,
308
308
  '"repository" field mismatch' /* RepositoryMismatch */
309
309
  );
310
310
  }
311
- await _chunkTG4BDSYJjs.validateSnapShasum.call(void 0,
311
+ await _chunkHVTYDKBOjs.validateSnapShasum.call(void 0,
312
312
  { manifest, sourceCode, svgIcon, auxiliaryFiles, localizationFiles },
313
313
  `"${"snap.manifest.json" /* Manifest */}" "shasum" field does not match computed shasum.`
314
314
  );
@@ -342,7 +342,7 @@ async function validateNpmSnap(snapFiles, errorPrefix) {
342
342
  localizationFiles
343
343
  } = snapFiles;
344
344
  try {
345
- _chunkLTWLSRSRjs.assertIsSnapManifest.call(void 0, manifest.result);
345
+ _chunkE5WSD47Sjs.assertIsSnapManifest.call(void 0, manifest.result);
346
346
  } catch (error) {
347
347
  throw new Error(`${errorPrefix ?? ""}${error.message}`);
348
348
  }
@@ -406,4 +406,4 @@ async function validateNpmSnap(snapFiles, errorPrefix) {
406
406
 
407
407
 
408
408
  exports.EXPECTED_SNAP_FILES = EXPECTED_SNAP_FILES; exports.SnapFileNameFromKey = SnapFileNameFromKey; exports.validateNpmSnap = validateNpmSnap; exports.checkManifest = checkManifest; exports.fixManifest = fixManifest; exports.getSnapSourceCode = getSnapSourceCode; exports.getSnapIcon = getSnapIcon; exports.getSnapFilePaths = getSnapFilePaths; exports.getSnapFiles = getSnapFiles; exports.getWritableManifest = getWritableManifest; exports.validateNpmSnapManifest = validateNpmSnapManifest;
409
- //# sourceMappingURL=chunk-HKJDVWVO.js.map
409
+ //# sourceMappingURL=chunk-7EDRFEUH.js.map
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkTG4BDSYJjs = require('./chunk-TG4BDSYJ.js');
3
+ var _chunkHVTYDKBOjs = require('./chunk-HVTYDKBO.js');
4
4
 
5
5
 
6
6
  var _chunk6LOYTBS3js = require('./chunk-6LOYTBS3.js');
@@ -115,7 +115,7 @@ var SemVerRangeStruct = _superstruct.refine.call(void 0, _superstruct.string.cal
115
115
  return "Expected a valid SemVer range.";
116
116
  });
117
117
  var SnapIdsStruct = _superstruct.refine.call(void 0,
118
- _superstruct.record.call(void 0, _chunkTG4BDSYJjs.SnapIdStruct, _superstruct.object.call(void 0, { version: _superstruct.optional.call(void 0, SemVerRangeStruct) })),
118
+ _superstruct.record.call(void 0, _chunkHVTYDKBOjs.SnapIdStruct, _superstruct.object.call(void 0, { version: _superstruct.optional.call(void 0, SemVerRangeStruct) })),
119
119
  "SnapIds",
120
120
  (value) => {
121
121
  if (Object.keys(value).length === 0) {
@@ -280,4 +280,4 @@ function createSnapManifest(value) {
280
280
 
281
281
 
282
282
  exports.FORBIDDEN_COIN_TYPES = FORBIDDEN_COIN_TYPES; exports.Bip32PathStruct = Bip32PathStruct; exports.bip32entropy = bip32entropy; exports.Bip32EntropyStruct = Bip32EntropyStruct; exports.SnapGetBip32EntropyPermissionsStruct = SnapGetBip32EntropyPermissionsStruct; exports.SemVerRangeStruct = SemVerRangeStruct; exports.SnapIdsStruct = SnapIdsStruct; exports.ChainIdsStruct = ChainIdsStruct; exports.LookupMatchersStruct = LookupMatchersStruct; exports.MINIMUM_REQUEST_TIMEOUT = MINIMUM_REQUEST_TIMEOUT; exports.MAXIMUM_REQUEST_TIMEOUT = MAXIMUM_REQUEST_TIMEOUT; exports.MaxRequestTimeStruct = MaxRequestTimeStruct; exports.HandlerCaveatsStruct = HandlerCaveatsStruct; exports.EmptyObjectStruct = EmptyObjectStruct; exports.PermissionsStruct = PermissionsStruct; exports.SnapAuxilaryFilesStruct = SnapAuxilaryFilesStruct; exports.InitialConnectionsStruct = InitialConnectionsStruct; exports.SnapManifestStruct = SnapManifestStruct; exports.isSnapManifest = isSnapManifest; exports.assertIsSnapManifest = assertIsSnapManifest; exports.createSnapManifest = createSnapManifest;
283
- //# sourceMappingURL=chunk-LTWLSRSR.js.map
283
+ //# sourceMappingURL=chunk-E5WSD47S.js.map
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  assertIsSnapManifest
3
- } from "./chunk-6F2DZTGM.mjs";
3
+ } from "./chunk-HTS6HGUU.mjs";
4
4
  import {
5
5
  validateSnapShasum
6
- } from "./chunk-2IWSQJKQ.mjs";
6
+ } from "./chunk-2M6G46W6.mjs";
7
7
  import {
8
8
  assertIsSnapIcon
9
9
  } from "./chunk-MNCFAD4E.mjs";
@@ -27,4 +27,4 @@ async function validateFetchedSnap(files) {
27
27
  export {
28
28
  validateFetchedSnap
29
29
  };
30
- //# sourceMappingURL=chunk-RQVVWCOW.mjs.map
30
+ //# sourceMappingURL=chunk-E6U344HR.mjs.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  SnapIdStruct
3
- } from "./chunk-2IWSQJKQ.mjs";
3
+ } from "./chunk-2M6G46W6.mjs";
4
4
  import {
5
5
  ChainIdStruct
6
6
  } from "./chunk-EXUEHPZ4.mjs";
@@ -280,4 +280,4 @@ export {
280
280
  assertIsSnapManifest,
281
281
  createSnapManifest
282
282
  };
283
- //# sourceMappingURL=chunk-6F2DZTGM.mjs.map
283
+ //# sourceMappingURL=chunk-HTS6HGUU.mjs.map
@@ -190,4 +190,4 @@ function verifyRequestedSnapPermissions(requestedPermissions) {
190
190
 
191
191
 
192
192
  exports.PROPOSED_NAME_REGEX = PROPOSED_NAME_REGEX; exports.SnapStatus = SnapStatus; exports.SnapStatusEvents = SnapStatusEvents; exports.ProgrammaticallyFixableSnapError = ProgrammaticallyFixableSnapError; exports.getSnapChecksum = getSnapChecksum; exports.validateSnapShasum = validateSnapShasum; exports.LOCALHOST_HOSTNAMES = LOCALHOST_HOSTNAMES; exports.BaseSnapIdStruct = BaseSnapIdStruct; exports.LocalSnapIdStruct = LocalSnapIdStruct; exports.NpmSnapIdStruct = NpmSnapIdStruct; exports.HttpSnapIdStruct = HttpSnapIdStruct; exports.SnapIdStruct = SnapIdStruct; exports.getSnapPrefix = getSnapPrefix; exports.stripSnapPrefix = stripSnapPrefix; exports.assertIsValidSnapId = assertIsValidSnapId; exports.isCaipChainId = isCaipChainId; exports.isSnapPermitted = isSnapPermitted; exports.verifyRequestedSnapPermissions = verifyRequestedSnapPermissions;
193
- //# sourceMappingURL=chunk-TG4BDSYJ.js.map
193
+ //# sourceMappingURL=chunk-HVTYDKBO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/snaps.ts"],"names":["SnapStatus","SnapStatusEvents"],"mappings":";;;;;;;;;AAQA,SAAS,QAAQ,UAA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raint,\n} from '@metamask/permission-controller';\nimport type { BlockReason } from '@metamask/snaps-registry';\nimport type { SnapId, Snap as TruncatedSnap } from '@metamask/snaps-sdk';\nimport type { Json } from '@metamask/utils';\nimport { assert, isObject, assertStruct } from '@metamask/utils';\nimport { base64 } from '@scure/base';\nimport stableStringify from 'fast-json-stable-stringify';\nimport type { Struct } from 'superstruct';\nimport {\n empty,\n enums,\n intersection,\n literal,\n pattern,\n refine,\n string,\n union,\n validate,\n} from 'superstruct';\nimport validateNPMPackage from 'validate-npm-package-name';\n\nimport { SnapCaveatType } from './caveats';\nimport { checksumFiles } from './checksum';\nimport type { LocalizationFile } from './localization';\nimport type {\n InitialConnections,\n SnapManifest,\n SnapPermissions,\n} from './manifest/validation';\nimport type { FetchedSnapFiles, SnapsPermissionRequest } from './types';\nimport { SnapIdPrefixes, SnapValidationFailureReason, uri } from './types';\nimport type { VirtualFile } from './virtual-file';\n\n// This RegEx matches valid npm package names (with some exceptions) and space-\n// separated alphanumerical words, optionally with dashes and underscores.\n// The RegEx consists of two parts. The first part matches space-separated\n// words. It is based on the following Stackoverflow answer:\n// https://stackoverflow.com/a/34974982\n// The second part, after the pipe operator, is the same RegEx used for the\n// `name` field of the official package.json JSON Schema, except that we allow\n// mixed-case letters. It was originally copied from:\n// https://github.com/SchemaStore/schemastore/blob/81a16897c1dabfd98c72242a5fd62eb080ff76d8/src/schemas/json/package.json#L132-L138\nexport const PROPOSED_NAME_REGEX =\n /^(?:[A-Za-z0-9-_]+( [A-Za-z0-9-_]+)*)|(?:(?:@[A-Za-z0-9-*~][A-Za-z0-9-*._~]*\\/)?[A-Za-z0-9-~][A-Za-z0-9-._~]*)$/u;\n\nexport enum SnapStatus {\n Installing = 'installing',\n Updating = 'updating',\n Running = 'running',\n Stopped = 'stopped',\n Crashed = 'crashed',\n}\n\nexport enum SnapStatusEvents {\n Start = 'START',\n Stop = 'STOP',\n Crash = 'CRASH',\n Update = 'UPDATE',\n}\n\nexport type StatusContext = { snapId: SnapId };\nexport type StatusEvents = { type: SnapStatusEvents };\nexport type StatusStates = {\n value: SnapStatus;\n context: StatusContext;\n};\nexport type Status = StatusStates['value'];\n\nexport type VersionHistory = {\n origin: string;\n version: string;\n // Unix timestamp\n date: number;\n};\n\nexport type SnapAuxilaryFile = {\n path: string;\n // Value here should be stored as base64\n value: string;\n};\n\nexport type PersistedSnap = Snap;\n\n/**\n * A Snap as it exists in {@link SnapController} state.\n */\nexport type Snap = TruncatedSnap & {\n /**\n * The initial connections of the Snap, optional, requested on installation.\n */\n initialConnections?: InitialConnections;\n /**\n * The initial permissions of the Snap, which will be requested when it is\n * installed.\n */\n initialPermissions: SnapPermissions;\n\n /**\n * The source code of the Snap.\n */\n sourceCode: string;\n\n /**\n * The Snap's manifest file.\n */\n manifest: SnapManifest;\n\n /**\n * Information detailing why the snap is blocked.\n */\n blockInformation?: BlockReason;\n\n /**\n * The current status of the Snap, e.g. whether it's running or stopped.\n */\n status: Status;\n\n /**\n * The version history of the Snap.\n * Can be used to derive when the Snap was installed, when it was updated to a certain version and who requested the change.\n */\n versionHistory: VersionHistory[];\n\n /**\n * Static auxiliary files that can be loaded at runtime.\n */\n auxiliaryFiles?: SnapAuxilaryFile[];\n\n /**\n * Localization files which are used to translate the manifest.\n */\n localizationFiles?: LocalizationFile[];\n\n /**\n * Flag to signal whether this snap was preinstalled or not.\n *\n * A lack of specifying this option will be deemed as not preinstalled.\n */\n preinstalled?: boolean;\n\n /**\n * Flag to signal whether this snap is removable or not.\n *\n * A lack of specifying this option will be deemed as removable.\n */\n removable?: boolean;\n};\n\nexport type TruncatedSnapFields =\n | 'id'\n | 'initialPermissions'\n | 'version'\n | 'enabled'\n | 'blocked';\n\n/**\n * An error indicating that a Snap validation failure is programmatically\n * fixable during development.\n */\nexport class ProgrammaticallyFixableSnapError extends Error {\n reason: SnapValidationFailureReason;\n\n constructor(message: string, reason: SnapValidationFailureReason) {\n super(message);\n this.reason = reason;\n }\n}\n\n/**\n * Gets a checksummable manifest by removing the shasum property and reserializing the JSON using a deterministic algorithm.\n *\n * @param manifest - The manifest itself.\n * @returns A virtual file containing the checksummable manifest.\n */\nfunction getChecksummableManifest(\n manifest: VirtualFile<SnapManifest>,\n): VirtualFile {\n const manifestCopy = manifest.clone() as VirtualFile<any>;\n delete manifestCopy.result.source.shasum;\n\n // We use fast-json-stable-stringify to deterministically serialize the JSON\n // This is required before checksumming so we get reproducible checksums across platforms etc\n manifestCopy.value = stableStringify(manifestCopy.result);\n return manifestCopy;\n}\n\n/**\n * Calculates the Base64-encoded SHA-256 digest of all required Snap files.\n *\n * @param files - All required Snap files to be included in the checksum.\n * @returns The Base64-encoded SHA-256 digest of the source code.\n */\nexport async function getSnapChecksum(\n files: FetchedSnapFiles,\n): Promise<string> {\n const { manifest, sourceCode, svgIcon, auxiliaryFiles, localizationFiles } =\n files;\n\n const all = [\n getChecksummableManifest(manifest),\n sourceCode,\n svgIcon,\n ...auxiliaryFiles,\n ...localizationFiles,\n ].filter((file) => file !== undefined);\n\n return base64.encode(await checksumFiles(all as VirtualFile[]));\n}\n\n/**\n * Checks whether the `source.shasum` property of a Snap manifest matches the\n * shasum of the snap.\n *\n * @param files - All required Snap files to be included in the checksum.\n * @param errorMessage - The error message to throw if validation fails.\n */\nexport async function validateSnapShasum(\n files: FetchedSnapFiles,\n errorMessage = 'Invalid Snap manifest: manifest shasum does not match computed shasum.',\n): Promise<void> {\n if (files.manifest.result.source.shasum !== (await getSnapChecksum(files))) {\n throw new ProgrammaticallyFixableSnapError(\n errorMessage,\n SnapValidationFailureReason.ShasumMismatch,\n );\n }\n}\n\nexport const LOCALHOST_HOSTNAMES = ['localhost', '127.0.0.1', '[::1]'] as const;\n\n// Require snap ids to only consist of printable ASCII characters\nexport const BaseSnapIdStruct = pattern(string(), /^[\\x21-\\x7E]*$/u);\n\nconst LocalSnapIdSubUrlStruct = uri({\n protocol: enums(['http:', 'https:']),\n hostname: enums(LOCALHOST_HOSTNAMES),\n hash: empty(string()),\n search: empty(string()),\n});\n\nexport const LocalSnapIdStruct = refine(\n BaseSnapIdStruct,\n 'local Snap Id',\n (value) => {\n if (!value.startsWith(SnapIdPrefixes.local)) {\n return `Expected local snap ID, got \"${value}\".`;\n }\n\n const [error] = validate(\n value.slice(SnapIdPrefixes.local.length),\n LocalSnapIdSubUrlStruct,\n );\n return error ?? true;\n },\n);\nexport const NpmSnapIdStruct = intersection([\n BaseSnapIdStruct,\n uri({\n protocol: literal(SnapIdPrefixes.npm),\n pathname: refine(string(), 'package name', function* (value) {\n const normalized = value.startsWith('/') ? value.slice(1) : value;\n const { errors, validForNewPackages, warnings } =\n validateNPMPackage(normalized);\n if (!validForNewPackages) {\n if (errors === undefined) {\n assert(warnings !== undefined);\n yield* warnings;\n } else {\n yield* errors;\n }\n }\n return true;\n }),\n search: empty(string()),\n hash: empty(string()),\n }),\n]) as unknown as Struct<string, null>;\n\nexport const HttpSnapIdStruct = intersection([\n BaseSnapIdStruct,\n uri({\n protocol: enums(['http:', 'https:']),\n search: empty(string()),\n hash: empty(string()),\n }),\n]) as unknown as Struct<string, null>;\n\nexport const SnapIdStruct = union([NpmSnapIdStruct, LocalSnapIdStruct]);\n\n/**\n * Extracts the snap prefix from a snap ID.\n *\n * @param snapId - The snap ID to extract the prefix from.\n * @returns The snap prefix from a snap id, e.g. `npm:`.\n */\nexport function getSnapPrefix(snapId: string): SnapIdPrefixes {\n const prefix = Object.values(SnapIdPrefixes).find((possiblePrefix) =>\n snapId.startsWith(possiblePrefix),\n );\n if (prefix !== undefined) {\n return prefix;\n }\n throw new Error(`Invalid or no prefix found for \"${snapId}\"`);\n}\n\n/**\n * Strips snap prefix from a full snap ID.\n *\n * @param snapId - The snap ID to strip.\n * @returns The stripped snap ID.\n */\nexport function stripSnapPrefix(snapId: string): string {\n return snapId.replace(getSnapPrefix(snapId), '');\n}\n\n/**\n * Assert that the given value is a valid snap ID.\n *\n * @param value - The value to check.\n * @throws If the value is not a valid snap ID.\n */\nexport function assertIsValidSnapId(value: unknown): asserts value is SnapId {\n assertStruct(value, SnapIdStruct, 'Invalid snap ID');\n}\n\n/**\n * Typeguard to ensure a chainId follows the CAIP-2 standard.\n *\n * @param chainId - The chainId being tested.\n * @returns `true` if the value is a valid CAIP chain id, and `false` otherwise.\n */\nexport function isCaipChainId(chainId: unknown): chainId is string {\n return (\n typeof chainId === 'string' &&\n /^(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-a-zA-Z0-9]{1,32})$/u.test(\n chainId,\n )\n );\n}\n\n/**\n * Utility function to check if an origin has permission (and caveat) for a particular snap.\n *\n * @param permissions - An origin's permissions object.\n * @param snapId - The id of the snap.\n * @returns A boolean based on if an origin has the specified snap.\n */\nexport function isSnapPermitted(\n permissions: SubjectPermissions<PermissionConstraint>,\n snapId: SnapId,\n) {\n return Boolean(\n (\n (\n (permissions?.wallet_snap?.caveats?.find(\n (caveat) => caveat.type === SnapCaveatType.SnapIds,\n ) ?? {}) as Caveat<string, Json>\n ).value as Record<string, unknown>\n )?.[snapId],\n );\n}\n\n/**\n * Checks whether the passed in requestedPermissions is a valid\n * permission request for a `wallet_snap` permission.\n *\n * @param requestedPermissions - The requested permissions.\n * @throws If the criteria is not met.\n */\nexport function verifyRequestedSnapPermissions(\n requestedPermissions: unknown,\n): asserts requestedPermissions is SnapsPermissionRequest {\n assert(\n isObject(requestedPermissions),\n 'Requested permissions must be an object.',\n );\n\n const { wallet_snap: walletSnapPermission } = requestedPermissions;\n\n assert(\n isObject(walletSnapPermission),\n 'wallet_snap is missing from the requested permissions.',\n );\n\n const { caveats } = walletSnapPermission;\n\n assert(\n Array.isArray(caveats) && caveats.length === 1,\n 'wallet_snap must have a caveat property with a single-item array value.',\n );\n\n const [caveat] = caveats;\n\n assert(\n isObject(caveat) &&\n caveat.type === SnapCaveatType.SnapIds &&\n isObject(caveat.value),\n `The requested permissions do not have a valid ${SnapCaveatType.SnapIds} caveat.`,\n );\n}\n\nexport type { Snap as TruncatedSnap } from '@metamask/snaps-sdk';\n"]}
@@ -1,10 +1,10 @@
1
1
  // src/ui.ts
2
2
  import { NodeType } from "@metamask/snaps-sdk";
3
- import { assert, AssertionError } from "@metamask/utils";
3
+ import { assert, AssertionError, hasProperty } from "@metamask/utils";
4
4
  import { lexer, walkTokens } from "marked";
5
5
  var ALLOWED_PROTOCOLS = ["https:", "mailto:"];
6
6
  function getMarkdownLinks(text) {
7
- const tokens = lexer(text);
7
+ const tokens = lexer(text, { gfm: false });
8
8
  const links = [];
9
9
  walkTokens(tokens, (token) => {
10
10
  if (token.type === "link") {
@@ -67,10 +67,14 @@ function getTotalTextLength(component) {
67
67
  return 0;
68
68
  }
69
69
  }
70
+ function hasChildren(component) {
71
+ return hasProperty(component, "children");
72
+ }
70
73
 
71
74
  export {
72
75
  validateTextLinks,
73
76
  validateComponentLinks,
74
- getTotalTextLength
77
+ getTotalTextLength,
78
+ hasChildren
75
79
  };
76
- //# sourceMappingURL=chunk-HDZ3BJBL.mjs.map
80
+ //# sourceMappingURL=chunk-KP4ZAWMP.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ui.ts"],"sourcesContent":["import type { Component, NodeWithChildren } from '@metamask/snaps-sdk';\nimport { NodeType } from '@metamask/snaps-sdk';\nimport { assert, AssertionError, hasProperty } from '@metamask/utils';\nimport type { Tokens } from 'marked';\nimport { lexer, walkTokens } from 'marked';\n\nconst ALLOWED_PROTOCOLS = ['https:', 'mailto:'];\n\n/**\n * Extract all links from a Markdown text string using the `marked` lexer.\n *\n * @param text - The markdown text string.\n * @returns A list of URLs linked to in the string.\n */\nfunction getMarkdownLinks(text: string) {\n const tokens = lexer(text, { gfm: false });\n const links: (Tokens.Link | Tokens.Generic)[] = [];\n\n // Walk the lexed tokens and collect all link tokens\n walkTokens(tokens, (token) => {\n if (token.type === 'link') {\n links.push(token);\n }\n });\n\n return links.map((link) => link?.href).filter(Boolean);\n}\n\n/**\n * Searches for markdown links in a string and checks them against the phishing list.\n *\n * @param text - The text to verify.\n * @param isOnPhishingList - The function that checks the link against the\n * phishing list.\n * @throws If the text contains a link that is not allowed.\n */\nexport function validateTextLinks(\n text: string,\n isOnPhishingList: (url: string) => boolean,\n) {\n const links = getMarkdownLinks(text);\n\n for (const link of links) {\n try {\n const url = new URL(link);\n assert(\n ALLOWED_PROTOCOLS.includes(url.protocol),\n `Protocol must be one of: ${ALLOWED_PROTOCOLS.join(', ')}.`,\n );\n\n const hostname =\n url.protocol === 'mailto:' ? url.pathname.split('@')[1] : url.hostname;\n\n assert(!isOnPhishingList(hostname), 'The specified URL is not allowed.');\n } catch (error) {\n throw new Error(\n `Invalid URL: ${\n error instanceof AssertionError\n ? error.message\n : 'Unable to parse URL.'\n }`,\n );\n }\n }\n}\n\n/**\n * Search for links in UI components and check that the URL they are trying to\n * pass in is not in the phishing list.\n *\n * @param component - The custom UI component.\n * @param isOnPhishingList - The function that checks the link against the\n * phishing list.\n * @throws If the component contains a link that is not allowed.\n */\nexport function validateComponentLinks(\n component: Component,\n isOnPhishingList: (url: string) => boolean,\n) {\n const { type } = component;\n switch (type) {\n case NodeType.Panel:\n component.children.forEach((node) =>\n validateComponentLinks(node, isOnPhishingList),\n );\n break;\n case NodeType.Row:\n validateComponentLinks(component.value, isOnPhishingList);\n break;\n case NodeType.Text:\n validateTextLinks(component.value, isOnPhishingList);\n break;\n default:\n break;\n }\n}\n\n/**\n * Calculate the total length of all text in the component.\n *\n * @param component - A custom UI component.\n * @returns The total length of all text components in the component.\n */\nexport function getTotalTextLength(component: Component): number {\n const { type } = component;\n\n switch (type) {\n case NodeType.Panel:\n return component.children.reduce<number>(\n // This is a bug in TypeScript: https://github.com/microsoft/TypeScript/issues/48313\n // eslint-disable-next-line @typescript-eslint/restrict-plus-operands\n (sum, node) => sum + getTotalTextLength(node),\n 0,\n );\n case NodeType.Row:\n return getTotalTextLength(component.value);\n case NodeType.Text:\n return component.value.length;\n default:\n return 0;\n }\n}\n\n/**\n * Check if a component has children.\n *\n * @param component - A custom UI component.\n * @returns `true` if the component has children, `false` otherwise.\n */\nexport function hasChildren(\n component: Component,\n): component is NodeWithChildren {\n return hasProperty(component, 'children');\n}\n"],"mappings":";AACA,SAAS,gBAAgB;AACzB,SAAS,QAAQ,gBAAgB,mBAAmB;AAEpD,SAAS,OAAO,kBAAkB;AAElC,IAAM,oBAAoB,CAAC,UAAU,SAAS;AAQ9C,SAAS,iBAAiB,MAAc;AACtC,QAAM,SAAS,MAAM,MAAM,EAAE,KAAK,MAAM,CAAC;AACzC,QAAM,QAA0C,CAAC;AAGjD,aAAW,QAAQ,CAAC,UAAU;AAC5B,QAAI,MAAM,SAAS,QAAQ;AACzB,YAAM,KAAK,KAAK;AAAA,IAClB;AAAA,EACF,CAAC;AAED,SAAO,MAAM,IAAI,CAAC,SAAS,MAAM,IAAI,EAAE,OAAO,OAAO;AACvD;AAUO,SAAS,kBACd,MACA,kBACA;AACA,QAAM,QAAQ,iBAAiB,IAAI;AAEnC,aAAW,QAAQ,OAAO;AACxB,QAAI;AACF,YAAM,MAAM,IAAI,IAAI,IAAI;AACxB;AAAA,QACE,kBAAkB,SAAS,IAAI,QAAQ;AAAA,QACvC,4BAA4B,kBAAkB,KAAK,IAAI,CAAC;AAAA,MAC1D;AAEA,YAAM,WACJ,IAAI,aAAa,YAAY,IAAI,SAAS,MAAM,GAAG,EAAE,CAAC,IAAI,IAAI;AAEhE,aAAO,CAAC,iBAAiB,QAAQ,GAAG,mCAAmC;AAAA,IACzE,SAAS,OAAO;AACd,YAAM,IAAI;AAAA,QACR,gBACE,iBAAiB,iBACb,MAAM,UACN,sBACN;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAWO,SAAS,uBACd,WACA,kBACA;AACA,QAAM,EAAE,KAAK,IAAI;AACjB,UAAQ,MAAM;AAAA,IACZ,KAAK,SAAS;AACZ,gBAAU,SAAS;AAAA,QAAQ,CAAC,SAC1B,uBAAuB,MAAM,gBAAgB;AAAA,MAC/C;AACA;AAAA,IACF,KAAK,SAAS;AACZ,6BAAuB,UAAU,OAAO,gBAAgB;AACxD;AAAA,IACF,KAAK,SAAS;AACZ,wBAAkB,UAAU,OAAO,gBAAgB;AACnD;AAAA,IACF;AACE;AAAA,EACJ;AACF;AAQO,SAAS,mBAAmB,WAA8B;AAC/D,QAAM,EAAE,KAAK,IAAI;AAEjB,UAAQ,MAAM;AAAA,IACZ,KAAK,SAAS;AACZ,aAAO,UAAU,SAAS;AAAA;AAAA;AAAA,QAGxB,CAAC,KAAK,SAAS,MAAM,mBAAmB,IAAI;AAAA,QAC5C;AAAA,MACF;AAAA,IACF,KAAK,SAAS;AACZ,aAAO,mBAAmB,UAAU,KAAK;AAAA,IAC3C,KAAK,SAAS;AACZ,aAAO,UAAU,MAAM;AAAA,IACzB;AACE,aAAO;AAAA,EACX;AACF;AAQO,SAAS,YACd,WAC+B;AAC/B,SAAO,YAAY,WAAW,UAAU;AAC1C;","names":[]}
@@ -1,9 +1,9 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkLTWLSRSRjs = require('./chunk-LTWLSRSR.js');
3
+ var _chunkE5WSD47Sjs = require('./chunk-E5WSD47S.js');
4
4
 
5
5
 
6
- var _chunkTG4BDSYJjs = require('./chunk-TG4BDSYJ.js');
6
+ var _chunkHVTYDKBOjs = require('./chunk-HVTYDKBO.js');
7
7
 
8
8
 
9
9
  var _chunkM3KAAQFKjs = require('./chunk-M3KAAQFK.js');
@@ -13,8 +13,8 @@ var _chunkAFQY2CNYjs = require('./chunk-AFQY2CNY.js');
13
13
 
14
14
  // src/validation.ts
15
15
  async function validateFetchedSnap(files) {
16
- _chunkLTWLSRSRjs.assertIsSnapManifest.call(void 0, files.manifest.result);
17
- await _chunkTG4BDSYJjs.validateSnapShasum.call(void 0, files);
16
+ _chunkE5WSD47Sjs.assertIsSnapManifest.call(void 0, files.manifest.result);
17
+ await _chunkHVTYDKBOjs.validateSnapShasum.call(void 0, files);
18
18
  _chunkAFQY2CNYjs.validateSnapManifestLocalizations.call(void 0,
19
19
  files.manifest.result,
20
20
  files.localizationFiles.map((file) => file.result)
@@ -27,4 +27,4 @@ async function validateFetchedSnap(files) {
27
27
 
28
28
 
29
29
  exports.validateFetchedSnap = validateFetchedSnap;
30
- //# sourceMappingURL=chunk-OK2Q2GT7.js.map
30
+ //# sourceMappingURL=chunk-MKTAIEG7.js.map
@@ -4,7 +4,7 @@ var _utils = require('@metamask/utils');
4
4
  var _marked = require('marked');
5
5
  var ALLOWED_PROTOCOLS = ["https:", "mailto:"];
6
6
  function getMarkdownLinks(text) {
7
- const tokens = _marked.lexer.call(void 0, text);
7
+ const tokens = _marked.lexer.call(void 0, text, { gfm: false });
8
8
  const links = [];
9
9
  _marked.walkTokens.call(void 0, tokens, (token) => {
10
10
  if (token.type === "link") {
@@ -67,10 +67,14 @@ function getTotalTextLength(component) {
67
67
  return 0;
68
68
  }
69
69
  }
70
+ function hasChildren(component) {
71
+ return _utils.hasProperty.call(void 0, component, "children");
72
+ }
73
+
70
74
 
71
75
 
72
76
 
73
77
 
74
78
 
75
- exports.validateTextLinks = validateTextLinks; exports.validateComponentLinks = validateComponentLinks; exports.getTotalTextLength = getTotalTextLength;
76
- //# sourceMappingURL=chunk-EX4PPLND.js.map
79
+ exports.validateTextLinks = validateTextLinks; exports.validateComponentLinks = validateComponentLinks; exports.getTotalTextLength = getTotalTextLength; exports.hasChildren = hasChildren;
80
+ //# sourceMappingURL=chunk-NDIITWO4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ui.ts"],"names":[],"mappings":";AACA,SAAS,gBAAgB;AACzB,SAAS,QAAQ,gBAAgB,mBAAmB;AAEpD,SAAS,OAAO,kBAAkB;AAElC,IAAM,oBAAoB,CAAC,UAAU,SAAS;AAQ9C,SAAS,iBAAiB,MAAc;AACtC,QAAM,SAAS,MAAM,MAAM,EAAE,KAAK,MAAM,CAAC;AACzC,QAAM,QAA0C,CAAC;AAGjD,aAAW,QAAQ,CAAC,UAAU;AAC5B,QAAI,MAAM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AO,mBAAmB,UAAU,KAAK;AAAA,IAC3C,KAAK,SAAS;AACZ,aAAO,UAAU,MAAM;AAAA,IACzB;AACE,aAAO;AAAA,EACX;AACF;AAQO,SAAS,YACd,WAC+B;AAC/B,SAAO,YAAY,WAAW,UAAU;AAC1C","sourcesContent":["import type { Component, NodeWithChildren } from '@metamask/snaps-sdk';\nimport { NodeType } from '@metamask/snaps-sdk';\nimport { assert, AssertionError, hasProperty } from '@metamask/utils';\nimport type { Tokens } from 'marked';\nimport { lexer, walkTokens } from 'marked';\n\nconst ALLOWED_PROTOCOLS = ['https:', 'mailto:'];\n\n/**\n * Extract all links from a Markdown text string using the `marked` lexer.\n *\n * @param text - The markdown text string.\n * @returns A list of URLs linked to in the string.\n */\nfunction getMarkdownLinks(text: string) {\n const tokens = lexer(text, { gfm: false });\n const links: (Tokens.Link | Tokens.Generic)[] = [];\n\n // Walk the lexed tokens and collect all link tokens\n walkTokens(tokens, (token) => {\n if (token.type === 'link') {\n links.push(token);\n }\n });\n\n return links.map((link) => link?.href).filter(Boolean);\n}\n\n/**\n * Searches for markdown links in a string and checks them against the phishing list.\n *\n * @param text - The text to verify.\n * @param isOnPhishingList - The function that checks the link against the\n * phishing list.\n * @throws If the text contains a link that is not allowed.\n */\nexport function validateTextLinks(\n text: string,\n isOnPhishingList: (url: string) => boolean,\n) {\n const links = getMarkdownLinks(text);\n\n for (const link of links) {\n try {\n const url = new URL(link);\n assert(\n ALLOWED_PROTOCOLS.includes(url.protocol),\n `Protocol must be one of: ${ALLOWED_PROTOCOLS.join(', ')}.`,\n );\n\n const hostname =\n url.protocol === 'mailto:' ? url.pathname.split('@')[1] : url.hostname;\n\n assert(!isOnPhishingList(hostname), 'The specified URL is not allowed.');\n } catch (error) {\n throw new Error(\n `Invalid URL: ${\n error instanceof AssertionError\n ? error.message\n : 'Unable to parse URL.'\n }`,\n );\n }\n }\n}\n\n/**\n * Search for links in UI components and check that the URL they are trying to\n * pass in is not in the phishing list.\n *\n * @param component - The custom UI component.\n * @param isOnPhishingList - The function that checks the link against the\n * phishing list.\n * @throws If the component contains a link that is not allowed.\n */\nexport function validateComponentLinks(\n component: Component,\n isOnPhishingList: (url: string) => boolean,\n) {\n const { type } = component;\n switch (type) {\n case NodeType.Panel:\n component.children.forEach((node) =>\n validateComponentLinks(node, isOnPhishingList),\n );\n break;\n case NodeType.Row:\n validateComponentLinks(component.value, isOnPhishingList);\n break;\n case NodeType.Text:\n validateTextLinks(component.value, isOnPhishingList);\n break;\n default:\n break;\n }\n}\n\n/**\n * Calculate the total length of all text in the component.\n *\n * @param component - A custom UI component.\n * @returns The total length of all text components in the component.\n */\nexport function getTotalTextLength(component: Component): number {\n const { type } = component;\n\n switch (type) {\n case NodeType.Panel:\n return component.children.reduce<number>(\n // This is a bug in TypeScript: https://github.com/microsoft/TypeScript/issues/48313\n // eslint-disable-next-line @typescript-eslint/restrict-plus-operands\n (sum, node) => sum + getTotalTextLength(node),\n 0,\n );\n case NodeType.Row:\n return getTotalTextLength(component.value);\n case NodeType.Text:\n return component.value.length;\n default:\n return 0;\n }\n}\n\n/**\n * Check if a component has children.\n *\n * @param component - A custom UI component.\n * @returns `true` if the component has children, `false` otherwise.\n */\nexport function hasChildren(\n component: Component,\n): component is NodeWithChildren {\n return hasProperty(component, 'children');\n}\n"]}
@@ -130,6 +130,11 @@ var SNAPS_DERIVATION_PATHS = [
130
130
  curve: "secp256k1",
131
131
  name: "Mina"
132
132
  },
133
+ {
134
+ path: ["m", `44'`, `242'`],
135
+ curve: "ed25519",
136
+ name: "Nimiq"
137
+ },
133
138
  {
134
139
  path: ["m", `44'`, `1729'`, `0'`, `0'`],
135
140
  curve: "ed25519",
@@ -166,4 +171,4 @@ export {
166
171
  getSnapDerivationPathName,
167
172
  getSlip44ProtocolName
168
173
  };
169
- //# sourceMappingURL=chunk-QX6MAFJU.mjs.map
174
+ //# sourceMappingURL=chunk-PBXAWRWW.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/derivation-paths.ts"],"sourcesContent":["import type { SupportedCurve } from '@metamask/key-tree';\nimport slip44 from '@metamask/slip44';\n\nimport { isEqual } from './array';\n\nexport type SnapsDerivationPath = {\n path: ['m', ...string[]];\n curve: SupportedCurve;\n name: string;\n};\n\nexport const SNAPS_DERIVATION_PATHS: SnapsDerivationPath[] = [\n {\n path: ['m', `44'`, `0'`],\n curve: 'ed25519',\n name: 'Test BIP-32 Path (ed25519)',\n },\n {\n path: ['m', `44'`, `1'`],\n curve: 'secp256k1',\n name: 'Testnet',\n },\n {\n path: ['m', `44'`, `0'`],\n curve: 'secp256k1',\n name: 'Bitcoin Legacy',\n },\n {\n path: ['m', `49'`, `0'`],\n curve: 'secp256k1',\n name: 'Bitcoin Nested SegWit',\n },\n {\n path: ['m', `49'`, `1'`],\n curve: 'secp256k1',\n name: 'Bitcoin Testnet Nested SegWit',\n },\n {\n path: ['m', `84'`, `0'`],\n curve: 'secp256k1',\n name: 'Bitcoin Native SegWit',\n },\n {\n path: ['m', `84'`, `1'`],\n curve: 'secp256k1',\n name: 'Bitcoin Testnet Native SegWit',\n },\n {\n path: ['m', `44'`, `501'`],\n curve: 'ed25519',\n name: 'Solana',\n },\n {\n path: ['m', `44'`, `501'`, \"0'\", \"0'\"],\n curve: 'ed25519',\n name: 'Solana',\n },\n {\n path: ['m', `44'`, `2'`],\n curve: 'secp256k1',\n name: 'Litecoin',\n },\n {\n path: ['m', `44'`, `3'`],\n curve: 'secp256k1',\n name: 'Dogecoin',\n },\n {\n path: ['m', `44'`, `60'`],\n curve: 'secp256k1',\n name: 'Ethereum',\n },\n {\n path: ['m', `44'`, `118'`],\n curve: 'secp256k1',\n name: 'Atom',\n },\n {\n path: ['m', `44'`, `145'`],\n curve: 'secp256k1',\n name: 'Bitcoin Cash',\n },\n {\n path: ['m', `44'`, `637'`],\n curve: 'ed25519',\n name: 'Aptos',\n },\n {\n path: ['m', `44'`, `714'`],\n curve: 'secp256k1',\n name: 'Binance (BNB)',\n },\n {\n path: ['m', `44'`, `784'`],\n curve: 'ed25519',\n name: 'Sui',\n },\n {\n path: ['m', `44'`, `931'`],\n curve: 'secp256k1',\n name: 'THORChain (RUNE)',\n },\n {\n path: ['m', `44'`, `330'`],\n curve: 'secp256k1',\n name: 'Terra (LUNA)',\n },\n {\n path: ['m', `44'`, `459'`],\n curve: 'secp256k1',\n name: 'Kava',\n },\n {\n path: ['m', `44'`, `529'`],\n curve: 'secp256k1',\n name: 'Secret Network',\n },\n {\n path: ['m', `44'`, `397'`, `0'`],\n curve: 'ed25519',\n name: 'NEAR Protocol',\n },\n {\n path: ['m', `44'`, `1'`, `0'`],\n curve: 'ed25519',\n name: 'Testnet',\n },\n {\n path: ['m', `44'`, `472'`],\n curve: 'ed25519',\n name: 'Arweave',\n },\n {\n path: ['m', `44'`, `12586'`],\n curve: 'secp256k1',\n name: 'Mina',\n },\n {\n path: ['m', `44'`, `242'`],\n curve: 'ed25519',\n name: 'Nimiq',\n },\n {\n path: ['m', `44'`, `1729'`, `0'`, `0'`],\n curve: 'ed25519',\n name: 'Tezos',\n },\n {\n path: ['m', `1789'`, `0'`],\n curve: 'ed25519',\n name: 'Vega',\n },\n];\n\n/**\n * Gets the name of a derivation path supported by snaps.\n *\n * @param path - The derivation path.\n * @param curve - The curve used to derive the keys.\n * @returns The name of the derivation path, otherwise null.\n */\nexport function getSnapDerivationPathName(\n path: SnapsDerivationPath['path'],\n curve: SupportedCurve,\n): string | null {\n const pathMetadata = SNAPS_DERIVATION_PATHS.find(\n (derivationPath) =>\n derivationPath.curve === curve && isEqual(derivationPath.path, path),\n );\n\n if (pathMetadata) {\n return pathMetadata.name;\n }\n\n // If the curve is secp256k1 and the path is a valid BIP44 path\n // we try looking for the network/protocol name in SLIP44\n if (\n curve === 'secp256k1' &&\n path[0] === 'm' &&\n path[1] === `44'` &&\n path[2].endsWith(`'`)\n ) {\n const coinType = path[2].slice(0, -1);\n return getSlip44ProtocolName(coinType) ?? null;\n }\n\n return null;\n}\n\n/**\n * Gets the name of the SLIP-44 protocol corresponding to the specified\n * `coin_type`.\n *\n * @param coinType - The SLIP-44 `coin_type` value whose name\n * to retrieve.\n * @returns The name of the protocol, otherwise null.\n */\nexport function getSlip44ProtocolName(coinType: number | string) {\n if (String(coinType) === '1') {\n return 'Test Networks';\n }\n\n return slip44[coinType as keyof typeof slip44]?.name ?? null;\n}\n"],"mappings":";;;;;AACA,OAAO,YAAY;AAUZ,IAAM,yBAAgD;AAAA,EAC3D;AAAA,IACE,MAAM,CAAC,KAAK,OAAO,IAAI;AAAA,IACvB,OAAO;AAAA,IACP,MAAM;AAAA,EACR;AAAA,EACA;AAAA,IACE,MAAM,CAAC,KAAK,OAAO,IAAI;AAAA,IACvB,OAAO;AAAA,IACP,MAAM;AAAA,EACR;AAAA,EACA;AAAA,IACE,MAAM,CAAC,KAAK,OAAO,IAAI;AAAA,IACvB,OAAO;AAAA,IACP,MAAM;AAAA,EACR;AAAA,EACA;AAAA,IACE,MAAM,CAAC,KAAK,OAAO,IAAI;AAAA,IACvB,OAAO;AAAA,IACP,MAAM;AAAA,EACR;AAAA,EACA;AAAA,IACE,MAAM,CAAC,KAAK,OAAO,IAAI;AAAA,IACvB,OAAO;AAAA,IACP,MAAM;AAAA,EACR;AAAA,EACA;AAAA,IACE,MAAM,CAAC,KAAK,OAAO,IAAI;AAAA,IACvB,OAAO;AAAA,IACP,MAAM;AAAA,EACR;AAAA,EACA;AAAA,IACE,MAAM,CAAC,KAAK,OAAO,IAAI;AAAA,IACvB,OAAO;AAAA,IACP,MAAM;AAAA,EACR;AAAA,EACA;AAAA,IACE,MAAM,CAAC,KAAK,OAAO,MAAM;AAAA,IACzB,OAAO;AAAA,IACP,MAAM;AAAA,EACR;AAAA,EACA;AAAA,IACE,MAAM,CAAC,KAAK,OAAO,QAAQ,MAAM,IAAI;AAAA,IACrC,OAAO;AAAA,IACP,MAAM;AAAA,EACR;AAAA,EACA;AAAA,IACE,MAAM,CAAC,KAAK,OAAO,IAAI;AAAA,IACv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 {
134
+ path: ["m", `44'`, `242'`],
135
+ curve: "ed25519",
136
+ name: "Nimiq"
137
+ },
133
138
  {
134
139
  path: ["m", `44'`, `1729'`, `0'`, `0'`],
135
140
  curve: "ed25519",
@@ -166,4 +171,4 @@ function getSlip44ProtocolName(coinType) {
166
171
 
167
172
 
168
173
  exports.SNAPS_DERIVATION_PATHS = SNAPS_DERIVATION_PATHS; exports.getSnapDerivationPathName = getSnapDerivationPathName; exports.getSlip44ProtocolName = getSlip44ProtocolName;
169
- //# sourceMappingURL=chunk-2PCPD5XY.js.map
174
+ //# sourceMappingURL=chunk-XNUUUOKX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/derivation-paths.ts"],"names":[],"mappings":";;;;;AACA,OAAO,YAAY;AAUZ,IAAM,yBAAgD;AAAA,EAC3D;AAAA,IACE,MAAM,CAAC,KAAK,OAAO,IAAI;AAAA,IACvB,OAAO;AAAA,IACP,MAAM;AAAA,EACR;AAAA,EACA;AAAA,IACE,MAAM,CAAC,KAAK,OAAO,IAAI;AAAA,IACvB,OAAO;AAAA,IACP,MAAM;AAAA,EACR;AAAA,EACA;AAAA,IACE,MAAM,CAAC,KAAK,OAAO,IAAI;AAAA,IACvB,OAAO;AAAA,IACP,MAAM;AAAA,EACR;AAAA,EACA;AAAA,IACE,MAAM,CAAC,KAAK,OAAO,IAAI;AAAA,IACvB,OAAO;AAAA,IACP,MAAM;AAAA,EACR;AAAA,EACA;AAAA,IACE,MAAM,CAAC,KAAK,OAAO,IAAI;AAAA,IACvB,OAAO;AAAA,IACP,MAAM;AAAA,EACR;AAAA,EACA;AAAA,IACE,MAAM,CAAC,KAAK,OAAO,IAAI;AAAA,IACvB,OAAO;AAAA,IACP,MAAM;AAAA,EACR;AAAA,EACA;AAAA,IACE,MAAM,CAAC,KAAK,OAAO,IAAI;AAAA,IACvB,OAAO;AAAA,IACP,MAAM;AAAA,EACR;AAAA,EACA;AAAA,IACE,MAAM,CAAC,KAAK,OAAO,MAAM;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B,UAA2B;AAC/D,MAAI,OAAO,QAAQ,MAAM,KAAK;AAC5B,WAAO;AAAA,EACT;AAEA,SAAO,OAAO,QAA+B,GAAG,QAAQ;AAC1D","sourcesContent":["import type { SupportedCurve } from '@metamask/key-tree';\nimport slip44 from '@metamask/slip44';\n\nimport { isEqual } from './array';\n\nexport type SnapsDerivationPath = {\n path: ['m', ...string[]];\n curve: SupportedCurve;\n name: string;\n};\n\nexport const SNAPS_DERIVATION_PATHS: SnapsDerivationPath[] = [\n {\n path: ['m', `44'`, `0'`],\n curve: 'ed25519',\n name: 'Test BIP-32 Path (ed25519)',\n },\n {\n path: ['m', `44'`, `1'`],\n curve: 'secp256k1',\n name: 'Testnet',\n },\n {\n path: ['m', `44'`, `0'`],\n curve: 'secp256k1',\n name: 'Bitcoin Legacy',\n },\n {\n path: ['m', `49'`, `0'`],\n curve: 'secp256k1',\n name: 'Bitcoin Nested SegWit',\n },\n {\n path: ['m', `49'`, `1'`],\n curve: 'secp256k1',\n name: 'Bitcoin Testnet Nested SegWit',\n },\n {\n path: ['m', `84'`, `0'`],\n curve: 'secp256k1',\n name: 'Bitcoin Native SegWit',\n },\n {\n path: ['m', `84'`, `1'`],\n curve: 'secp256k1',\n name: 'Bitcoin Testnet Native SegWit',\n },\n {\n path: ['m', `44'`, `501'`],\n curve: 'ed25519',\n name: 'Solana',\n },\n {\n path: ['m', `44'`, `501'`, \"0'\", \"0'\"],\n curve: 'ed25519',\n name: 'Solana',\n },\n {\n path: ['m', `44'`, `2'`],\n curve: 'secp256k1',\n name: 'Litecoin',\n },\n {\n path: ['m', `44'`, `3'`],\n curve: 'secp256k1',\n name: 'Dogecoin',\n },\n {\n path: ['m', `44'`, `60'`],\n curve: 'secp256k1',\n name: 'Ethereum',\n },\n {\n path: ['m', `44'`, `118'`],\n curve: 'secp256k1',\n name: 'Atom',\n },\n {\n path: ['m', `44'`, `145'`],\n curve: 'secp256k1',\n name: 'Bitcoin Cash',\n },\n {\n path: ['m', `44'`, `637'`],\n curve: 'ed25519',\n name: 'Aptos',\n },\n {\n path: ['m', `44'`, `714'`],\n curve: 'secp256k1',\n name: 'Binance (BNB)',\n },\n {\n path: ['m', `44'`, `784'`],\n curve: 'ed25519',\n name: 'Sui',\n },\n {\n path: ['m', `44'`, `931'`],\n curve: 'secp256k1',\n name: 'THORChain (RUNE)',\n },\n {\n path: ['m', `44'`, `330'`],\n curve: 'secp256k1',\n name: 'Terra (LUNA)',\n },\n {\n path: ['m', `44'`, `459'`],\n curve: 'secp256k1',\n name: 'Kava',\n },\n {\n path: ['m', `44'`, `529'`],\n curve: 'secp256k1',\n name: 'Secret Network',\n },\n {\n path: ['m', `44'`, `397'`, `0'`],\n curve: 'ed25519',\n name: 'NEAR Protocol',\n },\n {\n path: ['m', `44'`, `1'`, `0'`],\n curve: 'ed25519',\n name: 'Testnet',\n },\n {\n path: ['m', `44'`, `472'`],\n curve: 'ed25519',\n name: 'Arweave',\n },\n {\n path: ['m', `44'`, `12586'`],\n curve: 'secp256k1',\n name: 'Mina',\n },\n {\n path: ['m', `44'`, `242'`],\n curve: 'ed25519',\n name: 'Nimiq',\n },\n {\n path: ['m', `44'`, `1729'`, `0'`, `0'`],\n curve: 'ed25519',\n name: 'Tezos',\n },\n {\n path: ['m', `1789'`, `0'`],\n curve: 'ed25519',\n name: 'Vega',\n },\n];\n\n/**\n * Gets the name of a derivation path supported by snaps.\n *\n * @param path - The derivation path.\n * @param curve - The curve used to derive the keys.\n * @returns The name of the derivation path, otherwise null.\n */\nexport function getSnapDerivationPathName(\n path: SnapsDerivationPath['path'],\n curve: SupportedCurve,\n): string | null {\n const pathMetadata = SNAPS_DERIVATION_PATHS.find(\n (derivationPath) =>\n derivationPath.curve === curve && isEqual(derivationPath.path, path),\n );\n\n if (pathMetadata) {\n return pathMetadata.name;\n }\n\n // If the curve is secp256k1 and the path is a valid BIP44 path\n // we try looking for the network/protocol name in SLIP44\n if (\n curve === 'secp256k1' &&\n path[0] === 'm' &&\n path[1] === `44'` &&\n path[2].endsWith(`'`)\n ) {\n const coinType = path[2].slice(0, -1);\n return getSlip44ProtocolName(coinType) ?? null;\n }\n\n return null;\n}\n\n/**\n * Gets the name of the SLIP-44 protocol corresponding to the specified\n * `coin_type`.\n *\n * @param coinType - The SLIP-44 `coin_type` value whose name\n * to retrieve.\n * @returns The name of the protocol, otherwise null.\n */\nexport function getSlip44ProtocolName(coinType: number | string) {\n if (String(coinType) === '1') {\n return 'Test Networks';\n }\n\n return slip44[coinType as keyof typeof slip44]?.name ?? null;\n}\n"]}
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  assertIsSnapManifest
3
- } from "./chunk-6F2DZTGM.mjs";
3
+ } from "./chunk-HTS6HGUU.mjs";
4
4
  import {
5
5
  ProgrammaticallyFixableSnapError,
6
6
  getSnapChecksum,
7
7
  validateSnapShasum
8
- } from "./chunk-2IWSQJKQ.mjs";
8
+ } from "./chunk-2M6G46W6.mjs";
9
9
  import {
10
10
  assertIsSnapIcon,
11
11
  getSvgDimensions
@@ -406,4 +406,4 @@ export {
406
406
  getWritableManifest,
407
407
  validateNpmSnapManifest
408
408
  };
409
- //# sourceMappingURL=chunk-ZO24JBZA.mjs.map
409
+ //# sourceMappingURL=chunk-YP3ZXUME.mjs.map
@@ -2,12 +2,12 @@
2
2
 
3
3
 
4
4
 
5
- var _chunk2PCPD5XYjs = require('./chunk-2PCPD5XY.js');
5
+ var _chunkXNUUUOKXjs = require('./chunk-XNUUUOKX.js');
6
6
  require('./chunk-T3YY4JIJ.js');
7
7
  require('./chunk-PHUTP7NB.js');
8
8
 
9
9
 
10
10
 
11
11
 
12
- exports.SNAPS_DERIVATION_PATHS = _chunk2PCPD5XYjs.SNAPS_DERIVATION_PATHS; exports.getSlip44ProtocolName = _chunk2PCPD5XYjs.getSlip44ProtocolName; exports.getSnapDerivationPathName = _chunk2PCPD5XYjs.getSnapDerivationPathName;
12
+ exports.SNAPS_DERIVATION_PATHS = _chunkXNUUUOKXjs.SNAPS_DERIVATION_PATHS; exports.getSlip44ProtocolName = _chunkXNUUUOKXjs.getSlip44ProtocolName; exports.getSnapDerivationPathName = _chunkXNUUUOKXjs.getSnapDerivationPathName;
13
13
  //# sourceMappingURL=derivation-paths.js.map
@@ -2,7 +2,7 @@ import {
2
2
  SNAPS_DERIVATION_PATHS,
3
3
  getSlip44ProtocolName,
4
4
  getSnapDerivationPathName
5
- } from "./chunk-QX6MAFJU.mjs";
5
+ } from "./chunk-PBXAWRWW.mjs";
6
6
  import "./chunk-P252LKUT.mjs";
7
7
  import "./chunk-JMDSN227.mjs";
8
8
  export {
package/dist/index.js CHANGED
@@ -20,10 +20,11 @@ var _chunkIJX3CXOYjs = require('./chunk-IJX3CXOY.js');
20
20
 
21
21
 
22
22
 
23
- var _chunkEX4PPLNDjs = require('./chunk-EX4PPLND.js');
24
23
 
24
+ var _chunkNDIITWO4js = require('./chunk-NDIITWO4.js');
25
25
 
26
- var _chunkOK2Q2GT7js = require('./chunk-OK2Q2GT7.js');
26
+
27
+ var _chunkMKTAIEG7js = require('./chunk-MKTAIEG7.js');
27
28
 
28
29
 
29
30
 
@@ -52,7 +53,7 @@ require('./chunk-4CMD46B2.js');
52
53
 
53
54
 
54
55
 
55
- var _chunkLTWLSRSRjs = require('./chunk-LTWLSRSR.js');
56
+ var _chunkE5WSD47Sjs = require('./chunk-E5WSD47S.js');
56
57
 
57
58
 
58
59
  var _chunkAOGVLPQZjs = require('./chunk-AOGVLPQZ.js');
@@ -75,7 +76,7 @@ var _chunkAOGVLPQZjs = require('./chunk-AOGVLPQZ.js');
75
76
 
76
77
 
77
78
 
78
- var _chunkTG4BDSYJjs = require('./chunk-TG4BDSYJ.js');
79
+ var _chunkHVTYDKBOjs = require('./chunk-HVTYDKBO.js');
79
80
  require('./chunk-M3KAAQFK.js');
80
81
 
81
82
 
@@ -158,7 +159,7 @@ var _chunkAFQY2CNYjs = require('./chunk-AFQY2CNY.js');
158
159
 
159
160
 
160
161
 
161
- var _chunk2PCPD5XYjs = require('./chunk-2PCPD5XY.js');
162
+ var _chunkXNUUUOKXjs = require('./chunk-XNUUUOKX.js');
162
163
 
163
164
 
164
165
 
@@ -376,5 +377,6 @@ require('./chunk-PHUTP7NB.js');
376
377
 
377
378
 
378
379
 
379
- exports.ACCOUNT_ADDRESS_REGEX = _chunk6LOYTBS3js.ACCOUNT_ADDRESS_REGEX; exports.ACCOUNT_ID_REGEX = _chunk6LOYTBS3js.ACCOUNT_ID_REGEX; exports.AccountAddressStruct = _chunk6LOYTBS3js.AccountAddressStruct; exports.AccountIdArrayStruct = _chunk6LOYTBS3js.AccountIdArrayStruct; exports.AccountIdStruct = _chunk6LOYTBS3js.AccountIdStruct; exports.AddressResolutionResponseStruct = _chunk3SOYDY4Wjs.AddressResolutionResponseStruct; exports.AddressResolutionStruct = _chunk3SOYDY4Wjs.AddressResolutionStruct; exports.BaseSnapIdStruct = _chunkTG4BDSYJjs.BaseSnapIdStruct; exports.Bip32EntropyStruct = _chunkLTWLSRSRjs.Bip32EntropyStruct; exports.Bip32PathStruct = _chunkLTWLSRSRjs.Bip32PathStruct; exports.CHAIN_ID_REGEX = _chunk6LOYTBS3js.CHAIN_ID_REGEX; exports.ChainIdStringStruct = _chunk6LOYTBS3js.ChainIdStringStruct; exports.ChainIdStruct = _chunk6LOYTBS3js.ChainIdStruct; exports.ChainIdsStruct = _chunkLTWLSRSRjs.ChainIdsStruct; exports.ChainStruct = _chunk6LOYTBS3js.ChainStruct; exports.CronExpressionStruct = _chunk2LBN5T56js.CronExpressionStruct; exports.CronjobRpcRequestStruct = _chunk2LBN5T56js.CronjobRpcRequestStruct; exports.CronjobSpecificationArrayStruct = _chunk2LBN5T56js.CronjobSpecificationArrayStruct; exports.CronjobSpecificationStruct = _chunk2LBN5T56js.CronjobSpecificationStruct; exports.DEFAULT_ENDOWMENTS = _chunkN722KRZWjs.DEFAULT_ENDOWMENTS; exports.DEFAULT_REQUESTED_SNAP_VERSION = _chunkIPOE62V4js.DEFAULT_REQUESTED_SNAP_VERSION; exports.DomainResolutionResponseStruct = _chunk3SOYDY4Wjs.DomainResolutionResponseStruct; exports.DomainResolutionStruct = _chunk3SOYDY4Wjs.DomainResolutionStruct; exports.EmptyObjectStruct = _chunkLTWLSRSRjs.EmptyObjectStruct; exports.FORBIDDEN_COIN_TYPES = _chunkLTWLSRSRjs.FORBIDDEN_COIN_TYPES; exports.HandlerCaveatsStruct = _chunkLTWLSRSRjs.HandlerCaveatsStruct; exports.HandlerType = _chunkLEKZPKS2js.HandlerType; exports.HttpSnapIdStruct = _chunkTG4BDSYJjs.HttpSnapIdStruct; exports.InitialConnectionsStruct = _chunkLTWLSRSRjs.InitialConnectionsStruct; exports.KeyringOriginsStruct = _chunkCQRPSEH3js.KeyringOriginsStruct; exports.LOCALHOST_HOSTNAMES = _chunkTG4BDSYJjs.LOCALHOST_HOSTNAMES; exports.LOCALIZABLE_FIELDS = _chunkAFQY2CNYjs.LOCALIZABLE_FIELDS; exports.LimitedString = _chunk6LOYTBS3js.LimitedString; exports.LocalSnapIdStruct = _chunkTG4BDSYJjs.LocalSnapIdStruct; exports.LocalizationFileStruct = _chunkAFQY2CNYjs.LocalizationFileStruct; exports.LookupMatchersStruct = _chunkLTWLSRSRjs.LookupMatchersStruct; exports.MAXIMUM_REQUEST_TIMEOUT = _chunkLTWLSRSRjs.MAXIMUM_REQUEST_TIMEOUT; exports.MINIMUM_REQUEST_TIMEOUT = _chunkLTWLSRSRjs.MINIMUM_REQUEST_TIMEOUT; exports.MaxRequestTimeStruct = _chunkLTWLSRSRjs.MaxRequestTimeStruct; exports.NameStruct = _chunkCMOSYNZRjs.NameStruct; exports.NamespaceIdStruct = _chunk6LOYTBS3js.NamespaceIdStruct; exports.NamespaceStruct = _chunk6LOYTBS3js.NamespaceStruct; exports.NpmSnapFileNames = _chunkCMOSYNZRjs.NpmSnapFileNames; exports.NpmSnapIdStruct = _chunkTG4BDSYJjs.NpmSnapIdStruct; exports.NpmSnapPackageJsonStruct = _chunkCMOSYNZRjs.NpmSnapPackageJsonStruct; exports.OnHomePageResponseStruct = _chunk3SOYDY4Wjs.OnHomePageResponseStruct; exports.OnHomePageResponseWithContentStruct = _chunk3SOYDY4Wjs.OnHomePageResponseWithContentStruct; exports.OnHomePageResponseWithIdStruct = _chunk3SOYDY4Wjs.OnHomePageResponseWithIdStruct; exports.OnNameLookupResponseStruct = _chunk3SOYDY4Wjs.OnNameLookupResponseStruct; exports.OnSignatureResponseStruct = _chunk3SOYDY4Wjs.OnSignatureResponseStruct; exports.OnTransactionResponseStruct = _chunk3SOYDY4Wjs.OnTransactionResponseStruct; exports.OnTransactionResponseWithContentStruct = _chunk3SOYDY4Wjs.OnTransactionResponseWithContentStruct; exports.OnTransactionResponseWithIdStruct = _chunk3SOYDY4Wjs.OnTransactionResponseWithIdStruct; exports.OnTransactionSeverityResponseStruct = _chunk3SOYDY4Wjs.OnTransactionSeverityResponseStruct; exports.PROPOSED_NAME_REGEX = _chunkTG4BDSYJjs.PROPOSED_NAME_REGEX; exports.PermissionsStruct = _chunkLTWLSRSRjs.PermissionsStruct; exports.ProgrammaticallyFixableSnapError = _chunkTG4BDSYJjs.ProgrammaticallyFixableSnapError; exports.RpcOriginsStruct = _chunkCQRPSEH3js.RpcOriginsStruct; exports.SIP_6_MAGIC_VALUE = _chunkZT3KKTS2js.SIP_6_MAGIC_VALUE; exports.SNAPS_DERIVATION_PATHS = _chunk2PCPD5XYjs.SNAPS_DERIVATION_PATHS; exports.SNAP_ERROR_WRAPPER_CODE = _chunkK6BCBPXFjs.SNAP_ERROR_WRAPPER_CODE; exports.SNAP_ERROR_WRAPPER_MESSAGE = _chunkK6BCBPXFjs.SNAP_ERROR_WRAPPER_MESSAGE; exports.SNAP_EXPORTS = _chunk3SOYDY4Wjs.SNAP_EXPORTS; exports.SNAP_EXPORT_NAMES = _chunkLEKZPKS2js.SNAP_EXPORT_NAMES; exports.SNAP_STREAM_NAMES = _chunkCMOSYNZRjs.SNAP_STREAM_NAMES; exports.STATE_ENCRYPTION_MAGIC_VALUE = _chunkZT3KKTS2js.STATE_ENCRYPTION_MAGIC_VALUE; exports.SemVerRangeStruct = _chunkLTWLSRSRjs.SemVerRangeStruct; exports.SnapAuxilaryFilesStruct = _chunkLTWLSRSRjs.SnapAuxilaryFilesStruct; exports.SnapCaveatType = _chunkASZWZ7JTjs.SnapCaveatType; exports.SnapGetBip32EntropyPermissionsStruct = _chunkLTWLSRSRjs.SnapGetBip32EntropyPermissionsStruct; exports.SnapIdPrefixes = _chunkCMOSYNZRjs.SnapIdPrefixes; exports.SnapIdStruct = _chunkTG4BDSYJjs.SnapIdStruct; exports.SnapIdsStruct = _chunkLTWLSRSRjs.SnapIdsStruct; exports.SnapManifestStruct = _chunkLTWLSRSRjs.SnapManifestStruct; exports.SnapStatus = _chunkTG4BDSYJjs.SnapStatus; exports.SnapStatusEvents = _chunkTG4BDSYJjs.SnapStatusEvents; exports.SnapValidationFailureReason = _chunkCMOSYNZRjs.SnapValidationFailureReason; exports.SnapsStructError = _chunkA6E325SZjs.SnapsStructError; exports.TRANSLATION_REGEX = _chunkAFQY2CNYjs.TRANSLATION_REGEX; exports.VirtualFile = _chunkHJYRGKCXjs.VirtualFile; exports.WALLET_SNAP_PERMISSION_KEY = _chunkCMOSYNZRjs.WALLET_SNAP_PERMISSION_KEY; exports.WrappedSnapError = _chunkK6BCBPXFjs.WrappedSnapError; exports.arrayToGenerator = _chunkA6E325SZjs.arrayToGenerator; exports.assertIsJsonRpcSuccess = _chunkCQRPSEH3js.assertIsJsonRpcSuccess; exports.assertIsKeyringOrigins = _chunkCQRPSEH3js.assertIsKeyringOrigins; exports.assertIsNpmSnapPackageJson = _chunkCMOSYNZRjs.assertIsNpmSnapPackageJson; exports.assertIsRpcOrigins = _chunkCQRPSEH3js.assertIsRpcOrigins; exports.assertIsSnapManifest = _chunkLTWLSRSRjs.assertIsSnapManifest; exports.assertIsValidSnapId = _chunkTG4BDSYJjs.assertIsValidSnapId; exports.bip32entropy = _chunkLTWLSRSRjs.bip32entropy; exports.checksum = _chunkMLOQHUOYjs.checksum; exports.checksumFiles = _chunkMLOQHUOYjs.checksumFiles; exports.createFromStruct = _chunkA6E325SZjs.createFromStruct; exports.createSnapManifest = _chunkLTWLSRSRjs.createSnapManifest; exports.createUnion = _chunkA6E325SZjs.createUnion; exports.createWindow = _chunkPLBSSUVYjs.createWindow; exports.decodeBase64 = _chunkIHQPAJ2Bjs.decodeBase64; exports.deepClone = _chunkNUCLSR2Gjs.deepClone; exports.encodeAuxiliaryFile = _chunkIXBJNVHKjs.encodeAuxiliaryFile; exports.encodeBase64 = _chunkIHQPAJ2Bjs.encodeBase64; exports.getBytes = _chunk473MIETWjs.getBytes; exports.getError = _chunkA6E325SZjs.getError; exports.getLocalizationFile = _chunkAFQY2CNYjs.getLocalizationFile; exports.getLocalizedSnapManifest = _chunkAFQY2CNYjs.getLocalizedSnapManifest; exports.getSlip44ProtocolName = _chunk2PCPD5XYjs.getSlip44ProtocolName; exports.getSnapChecksum = _chunkTG4BDSYJjs.getSnapChecksum; exports.getSnapDerivationPathName = _chunk2PCPD5XYjs.getSnapDerivationPathName; exports.getSnapPrefix = _chunkTG4BDSYJjs.getSnapPrefix; exports.getStructErrorMessage = _chunkA6E325SZjs.getStructErrorMessage; exports.getStructErrorPrefix = _chunkA6E325SZjs.getStructErrorPrefix; exports.getStructFailureMessage = _chunkA6E325SZjs.getStructFailureMessage; exports.getStructFromPath = _chunkA6E325SZjs.getStructFromPath; exports.getTargetVersion = _chunkIPOE62V4js.getTargetVersion; exports.getTotalTextLength = _chunkEX4PPLNDjs.getTotalTextLength; exports.getUnionStructNames = _chunkA6E325SZjs.getUnionStructNames; exports.getValidatedLocalizationFiles = _chunkAFQY2CNYjs.getValidatedLocalizationFiles; exports.indent = _chunkIJX3CXOYjs.indent; exports.isAccountId = _chunk6LOYTBS3js.isAccountId; exports.isAccountIdArray = _chunk6LOYTBS3js.isAccountIdArray; exports.isCaipChainId = _chunkTG4BDSYJjs.isCaipChainId; exports.isChainId = _chunk6LOYTBS3js.isChainId; exports.isCronjobSpecification = _chunk2LBN5T56js.isCronjobSpecification; exports.isCronjobSpecificationArray = _chunk2LBN5T56js.isCronjobSpecificationArray; exports.isEqual = _chunkT3YY4JIJjs.isEqual; exports.isNamespace = _chunk6LOYTBS3js.isNamespace; exports.isNamespaceId = _chunk6LOYTBS3js.isNamespaceId; exports.isNpmSnapPackageJson = _chunkCMOSYNZRjs.isNpmSnapPackageJson; exports.isOriginAllowed = _chunkCQRPSEH3js.isOriginAllowed; exports.isSerializedSnapError = _chunkK6BCBPXFjs.isSerializedSnapError; exports.isSnapError = _chunkK6BCBPXFjs.isSnapError; exports.isSnapManifest = _chunkLTWLSRSRjs.isSnapManifest; exports.isSnapPermitted = _chunkTG4BDSYJjs.isSnapPermitted; exports.isValidUrl = _chunkCMOSYNZRjs.isValidUrl; exports.isWrappedSnapError = _chunkK6BCBPXFjs.isWrappedSnapError; exports.logError = _chunkE3BDBG6Tjs.logError; exports.logInfo = _chunkE3BDBG6Tjs.logInfo; exports.logWarning = _chunkE3BDBG6Tjs.logWarning; exports.named = _chunkA6E325SZjs.named; exports.normalizeRelative = _chunkAOGVLPQZjs.normalizeRelative; exports.parseAccountId = _chunk6LOYTBS3js.parseAccountId; exports.parseChainId = _chunk6LOYTBS3js.parseChainId; exports.parseCronExpression = _chunk2LBN5T56js.parseCronExpression; exports.parseJson = _chunkHF7HUZ5Zjs.parseJson; exports.resolveVersionRange = _chunkIPOE62V4js.resolveVersionRange; exports.snapsLogger = _chunkE3BDBG6Tjs.snapsLogger; exports.stripSnapPrefix = _chunkTG4BDSYJjs.stripSnapPrefix; exports.translate = _chunkAFQY2CNYjs.translate; exports.unwrapError = _chunkK6BCBPXFjs.unwrapError; exports.uri = _chunkCMOSYNZRjs.uri; exports.validateComponentLinks = _chunkEX4PPLNDjs.validateComponentLinks; exports.validateFetchedSnap = _chunkOK2Q2GT7js.validateFetchedSnap; exports.validateSnapManifestLocalizations = _chunkAFQY2CNYjs.validateSnapManifestLocalizations; exports.validateSnapShasum = _chunkTG4BDSYJjs.validateSnapShasum; exports.validateTextLinks = _chunkEX4PPLNDjs.validateTextLinks; exports.validateUnion = _chunkA6E325SZjs.validateUnion; exports.verifyRequestedSnapPermissions = _chunkTG4BDSYJjs.verifyRequestedSnapPermissions;
380
+
381
+ exports.ACCOUNT_ADDRESS_REGEX = _chunk6LOYTBS3js.ACCOUNT_ADDRESS_REGEX; exports.ACCOUNT_ID_REGEX = _chunk6LOYTBS3js.ACCOUNT_ID_REGEX; exports.AccountAddressStruct = _chunk6LOYTBS3js.AccountAddressStruct; exports.AccountIdArrayStruct = _chunk6LOYTBS3js.AccountIdArrayStruct; exports.AccountIdStruct = _chunk6LOYTBS3js.AccountIdStruct; exports.AddressResolutionResponseStruct = _chunk3SOYDY4Wjs.AddressResolutionResponseStruct; exports.AddressResolutionStruct = _chunk3SOYDY4Wjs.AddressResolutionStruct; exports.BaseSnapIdStruct = _chunkHVTYDKBOjs.BaseSnapIdStruct; exports.Bip32EntropyStruct = _chunkE5WSD47Sjs.Bip32EntropyStruct; exports.Bip32PathStruct = _chunkE5WSD47Sjs.Bip32PathStruct; exports.CHAIN_ID_REGEX = _chunk6LOYTBS3js.CHAIN_ID_REGEX; exports.ChainIdStringStruct = _chunk6LOYTBS3js.ChainIdStringStruct; exports.ChainIdStruct = _chunk6LOYTBS3js.ChainIdStruct; exports.ChainIdsStruct = _chunkE5WSD47Sjs.ChainIdsStruct; exports.ChainStruct = _chunk6LOYTBS3js.ChainStruct; exports.CronExpressionStruct = _chunk2LBN5T56js.CronExpressionStruct; exports.CronjobRpcRequestStruct = _chunk2LBN5T56js.CronjobRpcRequestStruct; exports.CronjobSpecificationArrayStruct = _chunk2LBN5T56js.CronjobSpecificationArrayStruct; exports.CronjobSpecificationStruct = _chunk2LBN5T56js.CronjobSpecificationStruct; exports.DEFAULT_ENDOWMENTS = _chunkN722KRZWjs.DEFAULT_ENDOWMENTS; exports.DEFAULT_REQUESTED_SNAP_VERSION = _chunkIPOE62V4js.DEFAULT_REQUESTED_SNAP_VERSION; exports.DomainResolutionResponseStruct = _chunk3SOYDY4Wjs.DomainResolutionResponseStruct; exports.DomainResolutionStruct = _chunk3SOYDY4Wjs.DomainResolutionStruct; exports.EmptyObjectStruct = _chunkE5WSD47Sjs.EmptyObjectStruct; exports.FORBIDDEN_COIN_TYPES = _chunkE5WSD47Sjs.FORBIDDEN_COIN_TYPES; exports.HandlerCaveatsStruct = _chunkE5WSD47Sjs.HandlerCaveatsStruct; exports.HandlerType = _chunkLEKZPKS2js.HandlerType; exports.HttpSnapIdStruct = _chunkHVTYDKBOjs.HttpSnapIdStruct; exports.InitialConnectionsStruct = _chunkE5WSD47Sjs.InitialConnectionsStruct; exports.KeyringOriginsStruct = _chunkCQRPSEH3js.KeyringOriginsStruct; exports.LOCALHOST_HOSTNAMES = _chunkHVTYDKBOjs.LOCALHOST_HOSTNAMES; exports.LOCALIZABLE_FIELDS = _chunkAFQY2CNYjs.LOCALIZABLE_FIELDS; exports.LimitedString = _chunk6LOYTBS3js.LimitedString; exports.LocalSnapIdStruct = _chunkHVTYDKBOjs.LocalSnapIdStruct; exports.LocalizationFileStruct = _chunkAFQY2CNYjs.LocalizationFileStruct; exports.LookupMatchersStruct = _chunkE5WSD47Sjs.LookupMatchersStruct; exports.MAXIMUM_REQUEST_TIMEOUT = _chunkE5WSD47Sjs.MAXIMUM_REQUEST_TIMEOUT; exports.MINIMUM_REQUEST_TIMEOUT = _chunkE5WSD47Sjs.MINIMUM_REQUEST_TIMEOUT; exports.MaxRequestTimeStruct = _chunkE5WSD47Sjs.MaxRequestTimeStruct; exports.NameStruct = _chunkCMOSYNZRjs.NameStruct; exports.NamespaceIdStruct = _chunk6LOYTBS3js.NamespaceIdStruct; exports.NamespaceStruct = _chunk6LOYTBS3js.NamespaceStruct; exports.NpmSnapFileNames = _chunkCMOSYNZRjs.NpmSnapFileNames; exports.NpmSnapIdStruct = _chunkHVTYDKBOjs.NpmSnapIdStruct; exports.NpmSnapPackageJsonStruct = _chunkCMOSYNZRjs.NpmSnapPackageJsonStruct; exports.OnHomePageResponseStruct = _chunk3SOYDY4Wjs.OnHomePageResponseStruct; exports.OnHomePageResponseWithContentStruct = _chunk3SOYDY4Wjs.OnHomePageResponseWithContentStruct; exports.OnHomePageResponseWithIdStruct = _chunk3SOYDY4Wjs.OnHomePageResponseWithIdStruct; exports.OnNameLookupResponseStruct = _chunk3SOYDY4Wjs.OnNameLookupResponseStruct; exports.OnSignatureResponseStruct = _chunk3SOYDY4Wjs.OnSignatureResponseStruct; exports.OnTransactionResponseStruct = _chunk3SOYDY4Wjs.OnTransactionResponseStruct; exports.OnTransactionResponseWithContentStruct = _chunk3SOYDY4Wjs.OnTransactionResponseWithContentStruct; exports.OnTransactionResponseWithIdStruct = _chunk3SOYDY4Wjs.OnTransactionResponseWithIdStruct; exports.OnTransactionSeverityResponseStruct = _chunk3SOYDY4Wjs.OnTransactionSeverityResponseStruct; exports.PROPOSED_NAME_REGEX = _chunkHVTYDKBOjs.PROPOSED_NAME_REGEX; exports.PermissionsStruct = _chunkE5WSD47Sjs.PermissionsStruct; exports.ProgrammaticallyFixableSnapError = _chunkHVTYDKBOjs.ProgrammaticallyFixableSnapError; exports.RpcOriginsStruct = _chunkCQRPSEH3js.RpcOriginsStruct; exports.SIP_6_MAGIC_VALUE = _chunkZT3KKTS2js.SIP_6_MAGIC_VALUE; exports.SNAPS_DERIVATION_PATHS = _chunkXNUUUOKXjs.SNAPS_DERIVATION_PATHS; exports.SNAP_ERROR_WRAPPER_CODE = _chunkK6BCBPXFjs.SNAP_ERROR_WRAPPER_CODE; exports.SNAP_ERROR_WRAPPER_MESSAGE = _chunkK6BCBPXFjs.SNAP_ERROR_WRAPPER_MESSAGE; exports.SNAP_EXPORTS = _chunk3SOYDY4Wjs.SNAP_EXPORTS; exports.SNAP_EXPORT_NAMES = _chunkLEKZPKS2js.SNAP_EXPORT_NAMES; exports.SNAP_STREAM_NAMES = _chunkCMOSYNZRjs.SNAP_STREAM_NAMES; exports.STATE_ENCRYPTION_MAGIC_VALUE = _chunkZT3KKTS2js.STATE_ENCRYPTION_MAGIC_VALUE; exports.SemVerRangeStruct = _chunkE5WSD47Sjs.SemVerRangeStruct; exports.SnapAuxilaryFilesStruct = _chunkE5WSD47Sjs.SnapAuxilaryFilesStruct; exports.SnapCaveatType = _chunkASZWZ7JTjs.SnapCaveatType; exports.SnapGetBip32EntropyPermissionsStruct = _chunkE5WSD47Sjs.SnapGetBip32EntropyPermissionsStruct; exports.SnapIdPrefixes = _chunkCMOSYNZRjs.SnapIdPrefixes; exports.SnapIdStruct = _chunkHVTYDKBOjs.SnapIdStruct; exports.SnapIdsStruct = _chunkE5WSD47Sjs.SnapIdsStruct; exports.SnapManifestStruct = _chunkE5WSD47Sjs.SnapManifestStruct; exports.SnapStatus = _chunkHVTYDKBOjs.SnapStatus; exports.SnapStatusEvents = _chunkHVTYDKBOjs.SnapStatusEvents; exports.SnapValidationFailureReason = _chunkCMOSYNZRjs.SnapValidationFailureReason; exports.SnapsStructError = _chunkA6E325SZjs.SnapsStructError; exports.TRANSLATION_REGEX = _chunkAFQY2CNYjs.TRANSLATION_REGEX; exports.VirtualFile = _chunkHJYRGKCXjs.VirtualFile; exports.WALLET_SNAP_PERMISSION_KEY = _chunkCMOSYNZRjs.WALLET_SNAP_PERMISSION_KEY; exports.WrappedSnapError = _chunkK6BCBPXFjs.WrappedSnapError; exports.arrayToGenerator = _chunkA6E325SZjs.arrayToGenerator; exports.assertIsJsonRpcSuccess = _chunkCQRPSEH3js.assertIsJsonRpcSuccess; exports.assertIsKeyringOrigins = _chunkCQRPSEH3js.assertIsKeyringOrigins; exports.assertIsNpmSnapPackageJson = _chunkCMOSYNZRjs.assertIsNpmSnapPackageJson; exports.assertIsRpcOrigins = _chunkCQRPSEH3js.assertIsRpcOrigins; exports.assertIsSnapManifest = _chunkE5WSD47Sjs.assertIsSnapManifest; exports.assertIsValidSnapId = _chunkHVTYDKBOjs.assertIsValidSnapId; exports.bip32entropy = _chunkE5WSD47Sjs.bip32entropy; exports.checksum = _chunkMLOQHUOYjs.checksum; exports.checksumFiles = _chunkMLOQHUOYjs.checksumFiles; exports.createFromStruct = _chunkA6E325SZjs.createFromStruct; exports.createSnapManifest = _chunkE5WSD47Sjs.createSnapManifest; exports.createUnion = _chunkA6E325SZjs.createUnion; exports.createWindow = _chunkPLBSSUVYjs.createWindow; exports.decodeBase64 = _chunkIHQPAJ2Bjs.decodeBase64; exports.deepClone = _chunkNUCLSR2Gjs.deepClone; exports.encodeAuxiliaryFile = _chunkIXBJNVHKjs.encodeAuxiliaryFile; exports.encodeBase64 = _chunkIHQPAJ2Bjs.encodeBase64; exports.getBytes = _chunk473MIETWjs.getBytes; exports.getError = _chunkA6E325SZjs.getError; exports.getLocalizationFile = _chunkAFQY2CNYjs.getLocalizationFile; exports.getLocalizedSnapManifest = _chunkAFQY2CNYjs.getLocalizedSnapManifest; exports.getSlip44ProtocolName = _chunkXNUUUOKXjs.getSlip44ProtocolName; exports.getSnapChecksum = _chunkHVTYDKBOjs.getSnapChecksum; exports.getSnapDerivationPathName = _chunkXNUUUOKXjs.getSnapDerivationPathName; exports.getSnapPrefix = _chunkHVTYDKBOjs.getSnapPrefix; exports.getStructErrorMessage = _chunkA6E325SZjs.getStructErrorMessage; exports.getStructErrorPrefix = _chunkA6E325SZjs.getStructErrorPrefix; exports.getStructFailureMessage = _chunkA6E325SZjs.getStructFailureMessage; exports.getStructFromPath = _chunkA6E325SZjs.getStructFromPath; exports.getTargetVersion = _chunkIPOE62V4js.getTargetVersion; exports.getTotalTextLength = _chunkNDIITWO4js.getTotalTextLength; exports.getUnionStructNames = _chunkA6E325SZjs.getUnionStructNames; exports.getValidatedLocalizationFiles = _chunkAFQY2CNYjs.getValidatedLocalizationFiles; exports.hasChildren = _chunkNDIITWO4js.hasChildren; exports.indent = _chunkIJX3CXOYjs.indent; exports.isAccountId = _chunk6LOYTBS3js.isAccountId; exports.isAccountIdArray = _chunk6LOYTBS3js.isAccountIdArray; exports.isCaipChainId = _chunkHVTYDKBOjs.isCaipChainId; exports.isChainId = _chunk6LOYTBS3js.isChainId; exports.isCronjobSpecification = _chunk2LBN5T56js.isCronjobSpecification; exports.isCronjobSpecificationArray = _chunk2LBN5T56js.isCronjobSpecificationArray; exports.isEqual = _chunkT3YY4JIJjs.isEqual; exports.isNamespace = _chunk6LOYTBS3js.isNamespace; exports.isNamespaceId = _chunk6LOYTBS3js.isNamespaceId; exports.isNpmSnapPackageJson = _chunkCMOSYNZRjs.isNpmSnapPackageJson; exports.isOriginAllowed = _chunkCQRPSEH3js.isOriginAllowed; exports.isSerializedSnapError = _chunkK6BCBPXFjs.isSerializedSnapError; exports.isSnapError = _chunkK6BCBPXFjs.isSnapError; exports.isSnapManifest = _chunkE5WSD47Sjs.isSnapManifest; exports.isSnapPermitted = _chunkHVTYDKBOjs.isSnapPermitted; exports.isValidUrl = _chunkCMOSYNZRjs.isValidUrl; exports.isWrappedSnapError = _chunkK6BCBPXFjs.isWrappedSnapError; exports.logError = _chunkE3BDBG6Tjs.logError; exports.logInfo = _chunkE3BDBG6Tjs.logInfo; exports.logWarning = _chunkE3BDBG6Tjs.logWarning; exports.named = _chunkA6E325SZjs.named; exports.normalizeRelative = _chunkAOGVLPQZjs.normalizeRelative; exports.parseAccountId = _chunk6LOYTBS3js.parseAccountId; exports.parseChainId = _chunk6LOYTBS3js.parseChainId; exports.parseCronExpression = _chunk2LBN5T56js.parseCronExpression; exports.parseJson = _chunkHF7HUZ5Zjs.parseJson; exports.resolveVersionRange = _chunkIPOE62V4js.resolveVersionRange; exports.snapsLogger = _chunkE3BDBG6Tjs.snapsLogger; exports.stripSnapPrefix = _chunkHVTYDKBOjs.stripSnapPrefix; exports.translate = _chunkAFQY2CNYjs.translate; exports.unwrapError = _chunkK6BCBPXFjs.unwrapError; exports.uri = _chunkCMOSYNZRjs.uri; exports.validateComponentLinks = _chunkNDIITWO4js.validateComponentLinks; exports.validateFetchedSnap = _chunkMKTAIEG7js.validateFetchedSnap; exports.validateSnapManifestLocalizations = _chunkAFQY2CNYjs.validateSnapManifestLocalizations; exports.validateSnapShasum = _chunkHVTYDKBOjs.validateSnapShasum; exports.validateTextLinks = _chunkNDIITWO4js.validateTextLinks; exports.validateUnion = _chunkA6E325SZjs.validateUnion; exports.verifyRequestedSnapPermissions = _chunkHVTYDKBOjs.verifyRequestedSnapPermissions;
380
382
  //# sourceMappingURL=index.js.map