diff --git a/.depcheckrc.yml b/.depcheckrc.yml index f7c189f91464..50c309973fe3 100644 --- a/.depcheckrc.yml +++ b/.depcheckrc.yml @@ -19,6 +19,7 @@ ignores: - '@metamask/forwarder' - '@metamask/test-dapp' - '@metamask/design-tokens' # Only imported in index.css + - '@tsconfig/node14' # required dynamically by TS, used in tsconfig.json - '@sentry/cli' # invoked as `sentry-cli` - 'chromedriver' - 'depcheck' # ooo meta diff --git a/.eslintrc.js b/.eslintrc.js index 84b68eadae56..98a57e0791be 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -7,8 +7,9 @@ module.exports = { ignorePatterns: [ 'app/vendor/**', 'builds/**/*', - 'dist/**/*', 'development/chromereload.js', + 'dist/**/*', + 'node_modules/**/*', ], overrides: [ /** @@ -41,6 +42,7 @@ module.exports = { path.resolve(__dirname, '.eslintrc.base.js'), path.resolve(__dirname, '.eslintrc.node.js'), path.resolve(__dirname, '.eslintrc.babel.js'), + path.resolve(__dirname, '.eslintrc.typescript-compat.js'), ], parserOptions: { sourceType: 'module', @@ -50,6 +52,23 @@ module.exports = { // trust that all of the files specified above are indeed modules. 'import/unambiguous': 'off', }, + settings: { + 'import/resolver': { + // When determining the location of a `require()` call, use Node's + // resolution algorithm, then fall back to TypeScript's. This allows + // TypeScript files (which Node's algorithm doesn't recognize) to be + // imported from JavaScript files, while also preventing issues when + // using packages like `prop-types` (where we would otherwise get "No + // default export found in imported module 'prop-types'" from + // TypeScript because imports work differently there). + node: {}, + typescript: { + // Always try to resolve types under `/@types` directory even + // it doesn't contain any source code, like `@types/unist` + alwaysTryTypes: true, + }, + }, + }, }, /** * Modules (ES module syntax) @@ -75,10 +94,82 @@ module.exports = { path.resolve(__dirname, '.eslintrc.base.js'), path.resolve(__dirname, '.eslintrc.node.js'), path.resolve(__dirname, '.eslintrc.babel.js'), + path.resolve(__dirname, '.eslintrc.typescript-compat.js'), ], parserOptions: { sourceType: 'module', }, + settings: { + 'import/resolver': { + // When determining the location of an `import`, use Node's resolution + // algorithm, then fall back to TypeScript's. This allows TypeScript + // files (which Node's algorithm doesn't recognize) to be imported + // from JavaScript files, while also preventing issues when using + // packages like `prop-types` (where we would otherwise get "No + // default export found in imported module 'prop-types'" from + // TypeScript because imports work differently there). + node: {}, + typescript: { + // Always try to resolve types under `/@types` directory even + // it doesn't contain any source code, like `@types/unist` + alwaysTryTypes: true, + }, + }, + }, + }, + /** + * TypeScript files + */ + { + files: ['*.{ts,tsx}'], + extends: [ + path.resolve(__dirname, '.eslintrc.base.js'), + '@metamask/eslint-config-typescript', + path.resolve(__dirname, '.eslintrc.typescript-compat.js'), + ], + rules: { + // Turn these off, as it's recommended by typescript-eslint. + // See: + 'import/named': 'off', + 'import/namespace': 'off', + 'import/default': 'off', + 'import/no-named-as-default-member': 'off', + + // Disabled due to incompatibility with Record. + // See: + '@typescript-eslint/consistent-type-definitions': 'off', + + // Modified to include the 'ignoreRestSiblings' option. + // TODO: Migrate this rule change back into `@metamask/eslint-config` + '@typescript-eslint/no-unused-vars': [ + 'error', + { + vars: 'all', + args: 'all', + argsIgnorePattern: '[_]+', + ignoreRestSiblings: true, + }, + ], + }, + settings: { + 'import/resolver': { + // When determining the location of an `import`, prefer TypeScript's + // resolution algorithm. Note that due to how we've configured + // TypeScript in `tsconfig.json`, we are able to import JavaScript + // files from TypeScript files. + typescript: { + // Always try to resolve types under `/@types` directory even + // it doesn't contain any source code, like `@types/unist` + alwaysTryTypes: true, + }, + }, + }, + }, + { + files: ['*.d.ts'], + parserOptions: { + sourceType: 'script', + }, }, /** diff --git a/.eslintrc.typescript-compat.js b/.eslintrc.typescript-compat.js new file mode 100644 index 000000000000..564c025df0da --- /dev/null +++ b/.eslintrc.typescript-compat.js @@ -0,0 +1,8 @@ +module.exports = { + settings: { + 'import/extensions': ['.js', '.ts', '.tsx'], + 'import/parsers': { + '@typescript-eslint/parser': ['.ts', '.tsx'], + }, + }, +}; diff --git a/.gitignore b/.gitignore index 21c882a97d6c..6935373146d2 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,6 @@ notes.txt .nyc_output .metamaskrc + +# TypeScript +tsout/ diff --git a/development/build/index.js b/development/build/index.js index dd0e7b4c9d28..51252501b962 100755 --- a/development/build/index.js +++ b/development/build/index.js @@ -39,9 +39,11 @@ require('@babel/eslint-parser'); require('@babel/eslint-plugin'); require('@metamask/eslint-config'); require('@metamask/eslint-config-nodejs'); +require('@typescript-eslint/parser'); require('eslint'); require('eslint-config-prettier'); require('eslint-import-resolver-node'); +require('eslint-import-resolver-typescript'); require('eslint-plugin-import'); require('eslint-plugin-jsdoc'); require('eslint-plugin-node'); diff --git a/jsconfig.json b/jsconfig.json deleted file mode 100644 index 28d588ea99a0..000000000000 --- a/jsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "compilerOptions": { - "target": "ES6", - "module": "commonjs" - }, - "include": ["ui/**/*.js", "app/**/*.js", "shared/**/*.js"] -} diff --git a/lavamoat/build-system/policy-override.json b/lavamoat/build-system/policy-override.json index 282e26ff024f..c453b71b8f8c 100644 --- a/lavamoat/build-system/policy-override.json +++ b/lavamoat/build-system/policy-override.json @@ -19,6 +19,8 @@ "@babel/eslint-plugin": true, "@metamask/eslint-config": true, "@metamask/eslint-config-nodejs": true, + "@metamask/eslint-config-typescript": true, + "@typescript-eslint/eslint-plugin": true, "eslint": true, "eslint-config-prettier": true, "eslint-plugin-import": true, @@ -29,20 +31,58 @@ "eslint-plugin-react-hooks": true } }, + "@typescript-eslint/eslint-plugin": { + "packages": { + "@typescript-eslint/experimental-utils": true, + "@typescript-eslint/scope-manager": true, + "debug": true, + "eslint": true, + "ignore": true, + "regexpp": true, + "semver": true, + "tsutils": true, + "typescript": true + } + }, + "@typescript-eslint/experimental-utils": { + "builtin": { + "path": true + }, + "packages": { + "@typescript-eslint/scope-manager": true, + "@typescript-eslint/types": true, + "eslint": true, + "eslint-scope": true, + "eslint-utils": true + } + }, + "@typescript-eslint/scope-manager": { + "packages": { + "@typescript-eslint/types": true, + "@typescript-eslint/visitor-keys": true + } + }, + "@typescript-eslint/visitor-keys": { + "packages": { + "eslint-visitor-keys": true + } + }, "eslint-module-utils": { "packages": { + "@babel/eslint-parser": true, + "@typescript-eslint/parser": true, "eslint-import-resolver-node": true, - "@babel/eslint-parser": true + "eslint-import-resolver-typescript": true } }, - "node-sass": { - "native": true - }, "module-deps": { "packages": { "loose-envify": true } }, + "node-sass": { + "native": true + }, "sass": { "env": "unfrozen", "builtin": { @@ -51,6 +91,17 @@ "globals": { "Buffer": true } + }, + "tsutils": { + "packages": { + "typescript": true, + "tslib": true + } + }, + "typescript": { + "globals": { + "globalThis": true + } } } } diff --git a/lavamoat/build-system/policy.json b/lavamoat/build-system/policy.json index 7d6167325244..8a9b1a5f076c 100644 --- a/lavamoat/build-system/policy.json +++ b/lavamoat/build-system/policy.json @@ -964,6 +964,48 @@ "unist-util-find-all-after": true } }, + "@typescript-eslint/parser": { + "packages": { + "@typescript-eslint/scope-manager": true, + "@typescript-eslint/typescript-estree": true, + "debug": true, + "typescript": true + } + }, + "@typescript-eslint/scope-manager": { + "packages": { + "@typescript-eslint/types": true, + "@typescript-eslint/visitor-keys": true + } + }, + "@typescript-eslint/typescript-estree": { + "builtin": { + "fs": true, + "path": true + }, + "globals": { + "console.log": true, + "console.warn": true, + "new": true, + "process": true, + "target": true + }, + "packages": { + "@typescript-eslint/types": true, + "@typescript-eslint/visitor-keys": true, + "debug": true, + "globby": true, + "is-glob": true, + "semver": true, + "tsutils": true, + "typescript": true + } + }, + "@typescript-eslint/visitor-keys": { + "packages": { + "eslint-visitor-keys": true + } + }, "JSONStream": { "globals": { "Buffer": true @@ -1982,6 +2024,22 @@ "resolve": true } }, + "eslint-import-resolver-typescript": { + "builtin": { + "path": true + }, + "globals": { + "console.warn": true, + "process.cwd": true + }, + "packages": { + "debug": true, + "glob": true, + "is-glob": true, + "resolve": true, + "tsconfig-paths": true + } + }, "eslint-module-utils": { "builtin": { "crypto.createHash": true, @@ -2518,12 +2576,7 @@ "builtin": { "assert": true, "events.EventEmitter": true, - "fs.lstat": true, - "fs.lstatSync": true, - "fs.readdir": true, - "fs.readdirSync": true, - "fs.stat": true, - "fs.statSync": true, + "fs": true, "path.join": true, "path.resolve": true, "util": true @@ -5056,17 +5109,41 @@ "builtin": { "fs.existsSync": true, "fs.lstatSync": true, + "fs.readFile": true, "fs.readFileSync": true, + "fs.stat": true, "fs.statSync": true, + "module._resolveFilename": true, + "module.builtinModules": true, "path.dirname": true, + "path.isAbsolute": true, "path.join": true, - "path.resolve": true + "path.resolve": true, + "path.sep": true + }, + "globals": { + "console.warn": true, + "process.argv.slice": true, + "process.cwd": true, + "process.env": true }, "packages": { "json5": true, + "minimist": true, "strip-bom": true } }, + "tslib": { + "globals": { + "define": true + } + }, + "tsutils": { + "packages": { + "tslib": true, + "typescript": true + } + }, "type-check": { "packages": { "prelude-ls": true @@ -5084,29 +5161,19 @@ "builtin": { "buffer.Buffer": true, "crypto": true, - "fs.closeSync": true, - "fs.mkdirSync": true, - "fs.openSync": true, - "fs.readFileSync": true, - "fs.readdirSync": true, - "fs.realpathSync": true, - "fs.statSync": true, - "fs.unlinkSync": true, - "fs.unwatchFile": true, - "fs.utimesSync": true, - "fs.watch": true, - "fs.watchFile": true, - "fs.writeFileSync": true, - "fs.writeSync": true, + "fs": true, "inspector": true, "os.EOL": true, "os.platform": true, "path.dirname": true, "path.join": true, - "path.resolve": true + "path.resolve": true, + "perf_hooks.PerformanceObserver": true, + "perf_hooks.performance": true }, "globals": { "Intl": true, + "PerformanceObserver": true, "TypeScript": "write", "__dirname": true, "__filename": true, @@ -5115,7 +5182,6 @@ "console.log": true, "gc": true, "globalThis": "write", - "onProfilerEvent": true, "performance": true, "process": true, "setTimeout": true, diff --git a/package.json b/package.json index 780c62a746a2..5d8b6666fcb8 100644 --- a/package.json +++ b/package.json @@ -37,16 +37,21 @@ "test:coverage:jest": "yarn test:unit:jest --coverage --maxWorkers=2", "ganache:start": "./development/run-ganache.sh", "sentry:publish": "node ./development/sentry-publish.js", - "lint:prettier": "prettier '**/*.json'", - "lint": "yarn lint:prettier --check '**/*.json' && eslint . --ext js,snap --cache && yarn lint:styles", - "lint:fix": "yarn lint:prettier --write '**/*.json' && eslint . --ext js --cache --fix && yarn lint:styles --fix", + "lint": "yarn lint:prettier && yarn lint:eslint && yarn lint:tsc && yarn lint:styles", + "lint:fix": "yarn lint:prettier:fix && yarn lint:eslint:fix && yarn lint:styles:fix", + "lint:prettier": "prettier '**/*.json' --check", + "lint:prettier:fix": "prettier '**/*.json' --write", "lint:changed": "{ git ls-files --others --exclude-standard ; git diff-index --name-only --diff-filter=d HEAD ; } | grep --regexp='[.]js$' | tr '\\n' '\\0' | xargs -0 eslint", "lint:changed:fix": "{ git ls-files --others --exclude-standard ; git diff-index --name-only --diff-filter=d HEAD ; } | grep --regexp='[.]js$' | tr '\\n' '\\0' | xargs -0 eslint --fix", "lint:changelog": "auto-changelog validate", "lint:changelog:rc": "auto-changelog validate --rc", + "lint:eslint": "eslint . --ext js,ts,tsx,snap --cache", + "lint:eslint:fix": "yarn lint:eslint --fix", + "lint:lockfile": "lockfile-lint --path yarn.lock --allowed-hosts npm yarn github.com codeload.github.com --empty-hostname false --allowed-schemes \"https:\" \"git+https:\"", "lint:shellcheck": "./development/shellcheck.sh", "lint:styles": "stylelint '*/**/*.scss'", - "lint:lockfile": "lockfile-lint --path yarn.lock --allowed-hosts npm yarn github.com codeload.github.com --empty-hostname false --allowed-schemes \"https:\" \"git+https:\"", + "lint:styles:fix": "yarn lint:styles --fix", + "lint:tsc": "tsc --project tsconfig.json --noEmit", "validate-source-maps": "node ./development/sourcemap-validator.js", "verify-locales": "node ./development/verify-locale-strings.js", "verify-locales:fix": "node ./development/verify-locale-strings.js --fix", @@ -244,6 +249,7 @@ "@metamask/eslint-config-jest": "^9.0.0", "@metamask/eslint-config-mocha": "^9.0.0", "@metamask/eslint-config-nodejs": "^9.0.0", + "@metamask/eslint-config-typescript": "^9.0.1", "@metamask/forwarder": "^1.1.0", "@metamask/test-dapp": "^5.0.0", "@sentry/cli": "^1.58.0", @@ -264,7 +270,10 @@ "@testing-library/react": "^10.4.8", "@testing-library/react-hooks": "^3.2.1", "@testing-library/user-event": "^14.0.0-beta.12", + "@tsconfig/node14": "^1.0.1", "@types/react": "^16.9.53", + "@typescript-eslint/eslint-plugin": "^4.20.0", + "@typescript-eslint/parser": "^4.20.0", "addons-linter": "1.14.0", "babelify": "^10.0.0", "bify-module-groups": "^1.0.0", @@ -287,6 +296,7 @@ "eslint": "^7.23.0", "eslint-config-prettier": "^8.1.0", "eslint-import-resolver-node": "^0.3.4", + "eslint-import-resolver-typescript": "^2.5.0", "eslint-plugin-import": "^2.22.1", "eslint-plugin-jest": "^24.3.4", "eslint-plugin-jsdoc": "^37.0.3", @@ -357,6 +367,7 @@ "terser": "^5.7.0", "through2": "^4.0.2", "ttest": "^2.1.1", + "typescript": "~4.4.0", "vinyl": "^2.2.1", "vinyl-buffer": "^1.0.1", "vinyl-source-stream": "^2.0.0", diff --git a/patches/@keystonehq+bc-ur-registry+0.4.4.patch b/patches/@keystonehq+bc-ur-registry+0.4.4.patch new file mode 100644 index 000000000000..eec0a3388e85 --- /dev/null +++ b/patches/@keystonehq+bc-ur-registry+0.4.4.patch @@ -0,0 +1,1830 @@ +diff --git a/node_modules/@keystonehq/bc-ur-registry/src/Bytes.ts b/node_modules/@keystonehq/bc-ur-registry/src/Bytes.ts +deleted file mode 100644 +index a5f9f7d..0000000 +--- a/node_modules/@keystonehq/bc-ur-registry/src/Bytes.ts ++++ /dev/null +@@ -1,34 +0,0 @@ +-import { decodeToDataItem, DataItem } from './lib'; +-import { RegistryItem } from './RegistryItem'; +-import { RegistryTypes } from './RegistryType'; +- +-export class Bytes extends RegistryItem { +- getRegistryType = () => { +- return RegistryTypes.BYTES; +- }; +- +- constructor(private bytes: Buffer) { +- super(); +- } +- +- getData = () => this.bytes; +- +- toDataItem = () => { +- return new DataItem(this.bytes); +- }; +- +- public static fromDataItem = (dataItem: DataItem) => { +- const bytes = dataItem.getData(); +- if (!bytes) { +- throw new Error( +- `#[ur-registry][Bytes][fn.fromDataItem]: decoded [dataItem][#data] is undefined: ${dataItem}`, +- ); +- } +- return new Bytes(bytes); +- }; +- +- public static fromCBOR = (_cborPayload: Buffer) => { +- const dataItem = decodeToDataItem(_cborPayload); +- return Bytes.fromDataItem(dataItem); +- }; +-} +diff --git a/node_modules/@keystonehq/bc-ur-registry/src/CryptoAccount.ts b/node_modules/@keystonehq/bc-ur-registry/src/CryptoAccount.ts +deleted file mode 100644 +index 753e535..0000000 +--- a/node_modules/@keystonehq/bc-ur-registry/src/CryptoAccount.ts ++++ /dev/null +@@ -1,57 +0,0 @@ +-import { CryptoOutput } from '.'; +-import { decodeToDataItem, DataItem } from './lib'; +-import { RegistryItem } from './RegistryItem'; +-import { RegistryTypes } from './RegistryType'; +- +-enum Keys { +- masterFingerprint = 1, +- outputDescriptors, +-} +- +-export class CryptoAccount extends RegistryItem { +- getRegistryType = () => { +- return RegistryTypes.CRYPTO_ACCOUNT; +- }; +- +- constructor( +- private masterFingerprint: Buffer, +- private outputDescriptors: CryptoOutput[], +- ) { +- super(); +- } +- +- public getMasterFingerprint = () => this.masterFingerprint; +- public getOutputDescriptors = () => this.outputDescriptors; +- +- public toDataItem = () => { +- const map = {}; +- if (this.masterFingerprint) { +- map[Keys.masterFingerprint] = this.masterFingerprint.readUInt32BE(0); +- } +- if (this.outputDescriptors) { +- map[Keys.outputDescriptors] = this.outputDescriptors.map((item) => +- item.toDataItem(), +- ); +- } +- return new DataItem(map); +- }; +- +- public static fromDataItem = (dataItem: DataItem) => { +- const map = dataItem.getData(); +- const masterFingerprint = Buffer.alloc(4); +- const _masterFingerprint = map[Keys.masterFingerprint]; +- if (_masterFingerprint) { +- masterFingerprint.writeUInt32BE(_masterFingerprint, 0); +- } +- const outputDescriptors = map[Keys.outputDescriptors] as DataItem[]; +- const cryptoOutputs = outputDescriptors.map((item) => +- CryptoOutput.fromDataItem(item), +- ); +- return new CryptoAccount(masterFingerprint, cryptoOutputs); +- }; +- +- public static fromCBOR = (_cborPayload: Buffer) => { +- const dataItem = decodeToDataItem(_cborPayload); +- return CryptoAccount.fromDataItem(dataItem); +- }; +-} +diff --git a/node_modules/@keystonehq/bc-ur-registry/src/CryptoCoinInfo.ts b/node_modules/@keystonehq/bc-ur-registry/src/CryptoCoinInfo.ts +deleted file mode 100644 +index 0201682..0000000 +--- a/node_modules/@keystonehq/bc-ur-registry/src/CryptoCoinInfo.ts ++++ /dev/null +@@ -1,58 +0,0 @@ +-import { decodeToDataItem, DataItem } from './lib'; +-import { RegistryItem } from './RegistryItem'; +-import { RegistryTypes } from './RegistryType'; +- +-enum Keys { +- type = '1', +- network = '2', +-} +- +-export enum Type { +- bitcoin = 0, +-} +- +-export enum Network { +- mainnet, +- testnet, +-} +- +-export class CryptoCoinInfo extends RegistryItem { +- getRegistryType = () => { +- return RegistryTypes.CRYPTO_COIN_INFO; +- }; +- +- constructor(private type?: Type, private network?: Network) { +- super(); +- } +- +- public getType = () => { +- return this.type || Type.bitcoin; +- }; +- +- public getNetwork = () => { +- return this.network || Network.mainnet; +- }; +- +- public toDataItem = () => { +- const map = {}; +- if (this.type) { +- map[Keys.type] = this.type; +- } +- if (this.network) { +- map[Keys.network] = this.network; +- } +- return new DataItem(map); +- }; +- +- public static fromDataItem = (dataItem: DataItem) => { +- const map = dataItem.getData(); +- const type = map[Keys.type]; +- const network = map[Keys.network]; +- return new CryptoCoinInfo(type, network); +- }; +- +- public static fromCBOR = (_cborPayload: Buffer) => { +- const dataItem = decodeToDataItem(_cborPayload); +- return CryptoCoinInfo.fromDataItem(dataItem); +- }; +-} +diff --git a/node_modules/@keystonehq/bc-ur-registry/src/CryptoECKey.ts b/node_modules/@keystonehq/bc-ur-registry/src/CryptoECKey.ts +deleted file mode 100644 +index 1e964fc..0000000 +--- a/node_modules/@keystonehq/bc-ur-registry/src/CryptoECKey.ts ++++ /dev/null +@@ -1,59 +0,0 @@ +-import { decodeToDataItem, DataItem } from './lib'; +-import { RegistryItem } from './RegistryItem'; +-import { RegistryTypes } from './RegistryType'; +- +-enum Keys { +- curve = 1, +- private, +- data, +-} +- +-export class CryptoECKey extends RegistryItem { +- private data: Buffer; +- private curve: number; +- private privateKey: boolean; +- constructor(args: { data: Buffer; curve?: number; privateKey?: boolean }) { +- super(); +- this.data = args.data; +- this.curve = args.curve; +- this.privateKey = args.privateKey; +- } +- +- public getCurve = () => this.curve || 0; +- public isPrivateKey = () => this.privateKey || false; +- public getData = () => this.data; +- +- getRegistryType = () => { +- return RegistryTypes.CRYPTO_ECKEY; +- }; +- +- toDataItem = () => { +- const map = {}; +- if (this.curve) { +- map[Keys.curve] = this.curve; +- } +- if (this.privateKey !== undefined) { +- map[Keys.private] = this.privateKey; +- } +- map[Keys.data] = this.data; +- return new DataItem(map); +- }; +- +- static fromDataItem = (dataItem: DataItem) => { +- const map = dataItem.getData(); +- const curve = map[Keys.curve]; +- const privateKey = map[Keys.private]; +- const data = map[Keys.data]; +- if (!data) { +- throw new Error( +- `#[ur-registry][CryptoECKey][fn.fromDataItem]: decoded [dataItem][#data.data] is undefined: ${dataItem}`, +- ); +- } +- return new CryptoECKey({ data, curve, privateKey }); +- }; +- +- public static fromCBOR = (_cborPayload: Buffer) => { +- const dataItem = decodeToDataItem(_cborPayload); +- return CryptoECKey.fromDataItem(dataItem); +- }; +-} +diff --git a/node_modules/@keystonehq/bc-ur-registry/src/CryptoHDKey.ts b/node_modules/@keystonehq/bc-ur-registry/src/CryptoHDKey.ts +deleted file mode 100644 +index bbfd331..0000000 +--- a/node_modules/@keystonehq/bc-ur-registry/src/CryptoHDKey.ts ++++ /dev/null +@@ -1,210 +0,0 @@ +-import { encode } from 'bs58check'; +-import { CryptoCoinInfo } from './CryptoCoinInfo'; +-import { CryptoKeypath } from './CryptoKeypath'; +-import { decodeToDataItem, DataItem } from './lib'; +-import { RegistryItem } from './RegistryItem'; +-import { RegistryTypes } from './RegistryType'; +- +-enum Keys { +- is_master = 1, +- is_private, +- key_data, +- chain_code, +- use_info, +- origin, +- children, +- parent_fingerprint, +- name, +- note, +-} +- +-type MasterKeyProps = { +- isMaster: true; +- key: Buffer; +- chainCode: Buffer; +-}; +- +-type DeriveKeyProps = { +- isMaster: false; +- isPrivateKey?: boolean; +- key: Buffer; +- chainCode?: Buffer; +- useInfo?: CryptoCoinInfo; +- origin?: CryptoKeypath; +- children?: CryptoKeypath; +- parentFingerprint?: Buffer; +- name?: string; +- note?: string; +-}; +-export class CryptoHDKey extends RegistryItem { +- private master: boolean; +- private privateKey: boolean; +- private key: Buffer; +- private chainCode: Buffer; +- private useInfo: CryptoCoinInfo; +- private origin: CryptoKeypath; +- private children: CryptoKeypath; +- private parentFingerprint: Buffer; +- private name: string; +- private note: string; +- +- public getKey = () => this.key; +- public getChainCode = () => this.chainCode; +- public isMaster = () => this.master; +- public isPrivateKey = () => !!this.privateKey; +- public getUseInfo = () => this.useInfo; +- public getOrigin = () => this.origin; +- public getChildren = () => this.children; +- public getParentFingerprint = () => this.parentFingerprint; +- public getName = () => this.name; +- public getNote = () => this.note; +- public getBip32Key = () => { +- let version: Buffer; +- let depth: number; +- let index: number; +- let parentFingerprint: Buffer = Buffer.alloc(4).fill(0); +- if(this.isMaster()) { +- // version bytes defined on https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#serialization-format +- version = Buffer.from("0488ADE4", "hex") +- depth = 0; +- index = 0; +- } else { +- depth = this.getOrigin().getComponents().length || this.getOrigin().getDepth(); +- const paths = this.getOrigin().getComponents(); +- const lastPath = paths[paths.length - 1]; +- if(lastPath) { +- index = lastPath.isHardened() ? lastPath.getIndex()! + 0x80000000 : lastPath.getIndex()!; +- parentFingerprint = this.getParentFingerprint(); +- } +- if(this.isPrivateKey()) { +- version = Buffer.from('0488ADE4', 'hex'); +- } else { +- version = Buffer.from('0488B21E', 'hex'); +- } +- } +- const depthBuffer = Buffer.alloc(1); +- depthBuffer.writeUInt8(depth, 0); +- const indexBuffer = Buffer.alloc(4); +- indexBuffer.writeUInt32BE(index, 0); +- const chainCode = this.getChainCode(); +- const key = this.getKey(); +- return encode(Buffer.concat([version, depthBuffer, parentFingerprint, indexBuffer, chainCode, key])); +- } +- +- public getRegistryType = () => { +- return RegistryTypes.CRYPTO_HDKEY; +- }; +- +- constructor(args: DeriveKeyProps | MasterKeyProps) { +- super(); +- if (args.isMaster) { +- this.setupMasterKey(args); +- } else { +- this.setupDeriveKey(args as DeriveKeyProps); +- } +- } +- +- private setupMasterKey = (args: MasterKeyProps) => { +- this.master = true; +- this.key = args.key; +- this.chainCode = args.chainCode; +- }; +- +- private setupDeriveKey = (args: DeriveKeyProps) => { +- this.master = false; +- this.privateKey = args.isPrivateKey; +- this.key = args.key; +- this.chainCode = args.chainCode; +- this.useInfo = args.useInfo; +- this.origin = args.origin; +- this.children = args.children; +- this.parentFingerprint = args.parentFingerprint; +- this.name = args.name; +- this.note = args.note; +- }; +- +- public toDataItem = () => { +- const map = {}; +- if (this.master) { +- map[Keys.is_master] = true; +- map[Keys.key_data] = this.key; +- map[Keys.chain_code] = this.chainCode; +- } else { +- if (this.privateKey !== undefined) { +- map[Keys.is_private] = this.privateKey; +- } +- map[Keys.key_data] = this.key; +- if (this.chainCode) { +- map[Keys.chain_code] = this.chainCode; +- } +- if (this.useInfo) { +- const useInfo = this.useInfo.toDataItem(); +- useInfo.setTag(this.useInfo.getRegistryType().getTag()); +- map[Keys.use_info] = useInfo; +- } +- if (this.origin) { +- const origin = this.origin.toDataItem(); +- origin.setTag(this.origin.getRegistryType().getTag()); +- map[Keys.origin] = origin; +- } +- if (this.children) { +- const children = this.children.toDataItem(); +- children.setTag(this.children.getRegistryType().getTag()); +- map[Keys.children] = children; +- } +- if (this.parentFingerprint) { +- map[Keys.parent_fingerprint] = this.parentFingerprint.readUInt32BE(0); +- } +- if (this.name !== undefined) { +- map[Keys.name] = this.name; +- } +- if (this.note !== undefined) { +- map[Keys.note] = this.note; +- } +- } +- return new DataItem(map); +- }; +- +- public static fromDataItem = (dataItem: DataItem) => { +- const map = dataItem.getData(); +- const isMaster = !!map[Keys.is_master]; +- const isPrivateKey = map[Keys.is_private]; +- const key = map[Keys.key_data]; +- const chainCode = map[Keys.chain_code]; +- const useInfo = map[Keys.use_info] +- ? CryptoCoinInfo.fromDataItem(map[Keys.use_info]) +- : undefined; +- const origin = map[Keys.origin] +- ? CryptoKeypath.fromDataItem(map[Keys.origin]) +- : undefined; +- const children = map[Keys.children] +- ? CryptoKeypath.fromDataItem(map[Keys.children]) +- : undefined; +- let _parentFingerprint = map[Keys.parent_fingerprint]; +- let parentFingerprint: Buffer; +- if (_parentFingerprint) { +- parentFingerprint = Buffer.alloc(4); +- parentFingerprint.writeUInt32BE(_parentFingerprint, 0); +- } +- const name = map[Keys.name]; +- const note = map[Keys.note]; +- +- return new CryptoHDKey({ +- isMaster, +- isPrivateKey, +- key, +- chainCode, +- useInfo, +- origin, +- children, +- parentFingerprint, +- name, +- note, +- }); +- }; +- +- public static fromCBOR = (_cborPayload: Buffer) => { +- const dataItem = decodeToDataItem(_cborPayload); +- return CryptoHDKey.fromDataItem(dataItem); +- }; +-} +diff --git a/node_modules/@keystonehq/bc-ur-registry/src/CryptoKeypath.ts b/node_modules/@keystonehq/bc-ur-registry/src/CryptoKeypath.ts +deleted file mode 100644 +index 4babe91..0000000 +--- a/node_modules/@keystonehq/bc-ur-registry/src/CryptoKeypath.ts ++++ /dev/null +@@ -1,95 +0,0 @@ +-import { decodeToDataItem, DataItem } from './lib'; +-import { PathComponent } from './PathComponent'; +-import { RegistryItem } from './RegistryItem'; +-import { RegistryTypes } from './RegistryType'; +- +-enum Keys { +- components = 1, +- source_fingerprint, +- depth, +-} +- +-export class CryptoKeypath extends RegistryItem { +- getRegistryType = () => { +- return RegistryTypes.CRYPTO_KEYPATH; +- }; +- +- constructor( +- private components: PathComponent[] = [], +- private sourceFingerprint?: Buffer, +- private depth?: number, +- ) { +- super(); +- } +- +- public getPath = () => { +- if (this.components.length === 0) { +- return undefined; +- } +- +- const components = this.components.map((component) => { +- return `${component.isWildcard() ? '*' : component.getIndex()}${ +- component.isHardened() ? "'" : '' +- }`; +- }); +- return components.join('/'); +- }; +- +- public getComponents = () => this.components; +- public getSourceFingerprint = () => this.sourceFingerprint; +- public getDepth = () => this.depth; +- +- toDataItem = () => { +- const map: Record = {}; +- const components = []; +- this.components && +- this.components.forEach((component) => { +- if (component.isWildcard()) { +- components.push([]); +- } else { +- components.push(component.getIndex()); +- } +- components.push(component.isHardened() ? true : false); +- }); +- map[Keys.components] = components; +- if (this.sourceFingerprint) { +- map[Keys.source_fingerprint] = this.sourceFingerprint.readUInt32BE(0); +- } +- if (this.depth !== undefined) { +- map[Keys.depth] = this.depth; +- } +- return new DataItem(map); +- }; +- +- static fromDataItem = (dataItem: DataItem) => { +- const map: Record = dataItem.getData(); +- const pathComponents: PathComponent[] = []; +- const components = map[Keys.components] as any[]; +- if (components) { +- for (let i = 0; i < components.length; i += 2) { +- const isHardened = components[i + 1]; +- const path = components[i]; +- if (typeof path === 'number') { +- pathComponents.push( +- new PathComponent({ index: path, hardened: isHardened }), +- ); +- } else { +- pathComponents.push(new PathComponent({ hardened: isHardened })); +- } +- } +- } +- const _sourceFingerprint = map[Keys.source_fingerprint]; +- let sourceFingerprint: Buffer; +- if (_sourceFingerprint) { +- sourceFingerprint = Buffer.alloc(4); +- sourceFingerprint.writeUInt32BE(_sourceFingerprint, 0); +- } +- const depth = map[Keys.depth]; +- return new CryptoKeypath(pathComponents, sourceFingerprint, depth); +- }; +- +- public static fromCBOR = (_cborPayload: Buffer) => { +- const dataItem = decodeToDataItem(_cborPayload); +- return CryptoKeypath.fromDataItem(dataItem); +- }; +-} +diff --git a/node_modules/@keystonehq/bc-ur-registry/src/CryptoOutput.ts b/node_modules/@keystonehq/bc-ur-registry/src/CryptoOutput.ts +deleted file mode 100644 +index cd3009c..0000000 +--- a/node_modules/@keystonehq/bc-ur-registry/src/CryptoOutput.ts ++++ /dev/null +@@ -1,114 +0,0 @@ +-import { CryptoECKey } from './CryptoECKey'; +-import { CryptoHDKey } from './CryptoHDKey'; +-import { decodeToDataItem, DataItem } from './lib'; +-import { MultiKey } from './MultiKey'; +-import { RegistryItem } from './RegistryItem'; +-import { RegistryTypes } from './RegistryType'; +-import { ScriptExpression, ScriptExpressions } from './ScriptExpression'; +- +-export class CryptoOutput extends RegistryItem { +- public getRegistryType = () => { +- return RegistryTypes.CRYPTO_OUTPUT; +- }; +- +- constructor( +- private scriptExpressions: ScriptExpression[], +- private cryptoKey: CryptoHDKey | CryptoECKey | MultiKey, +- ) { +- super(); +- } +- +- public getCryptoKey = () => this.cryptoKey; +- public getHDKey = () => { +- if (this.cryptoKey instanceof CryptoHDKey) { +- return this.cryptoKey as CryptoHDKey; +- } else { +- return undefined; +- } +- }; +- public getECKey = () => { +- if (this.cryptoKey instanceof CryptoECKey) { +- return this.cryptoKey as CryptoECKey; +- } else { +- return undefined; +- } +- }; +- +- public getMultiKey = () => { +- if (this.cryptoKey instanceof MultiKey) { +- return this.cryptoKey as MultiKey; +- } else { +- return undefined; +- } +- }; +- +- public getScriptExpressions = () => this.scriptExpressions; +- +- toDataItem = () => { +- let dataItem = this.cryptoKey.toDataItem(); +- if ( +- this.cryptoKey instanceof CryptoECKey || +- this.cryptoKey instanceof CryptoHDKey +- ) { +- dataItem.setTag(this.cryptoKey.getRegistryType().getTag()); +- } +- +- const clonedSe = [...this.scriptExpressions]; +- +- clonedSe.reverse().forEach((se) => { +- const tagValue = se.getTag(); +- if (dataItem.getTag() === undefined) { +- dataItem.setTag(tagValue); +- } else { +- dataItem = new DataItem(dataItem, tagValue); +- } +- }); +- +- return dataItem; +- }; +- +- public static fromDataItem = (dataItem: DataItem) => { +- const scriptExpressions: ScriptExpression[] = []; +- let _dataItem = dataItem; +- while (true) { +- let _tag = _dataItem.getTag() || undefined; +- const se = ScriptExpression.fromTag(_tag); +- if (se) { +- scriptExpressions.push(se); +- if (_dataItem.getData() instanceof DataItem) { +- _dataItem = _dataItem.getData(); +- _tag = _dataItem.getTag(); +- } else { +- break; +- } +- } else { +- break; +- } +- } +- const seLength = scriptExpressions.length; +- const isMultiKey = +- seLength > 0 && +- (scriptExpressions[seLength - 1].getExpression() === +- ScriptExpressions.MULTISIG.getExpression() || +- scriptExpressions[seLength - 1].getExpression() === +- ScriptExpressions.SORTED_MULTISIG.getExpression()); +- //TODO: judge is multi key by scriptExpressions +- if (isMultiKey) { +- const multiKey = MultiKey.fromDataItem(_dataItem); +- return new CryptoOutput(scriptExpressions, multiKey); +- } +- +- if (_dataItem.getTag() === RegistryTypes.CRYPTO_HDKEY.getTag()) { +- const cryptoHDKey = CryptoHDKey.fromDataItem(_dataItem); +- return new CryptoOutput(scriptExpressions, cryptoHDKey); +- } else { +- const cryptoECKey = CryptoECKey.fromDataItem(_dataItem); +- return new CryptoOutput(scriptExpressions, cryptoECKey); +- } +- }; +- +- public static fromCBOR = (_cborPayload: Buffer) => { +- const dataItem = decodeToDataItem(_cborPayload); +- return CryptoOutput.fromDataItem(dataItem); +- }; +-} +diff --git a/node_modules/@keystonehq/bc-ur-registry/src/CryptoPSBT.ts b/node_modules/@keystonehq/bc-ur-registry/src/CryptoPSBT.ts +deleted file mode 100644 +index 626b647..0000000 +--- a/node_modules/@keystonehq/bc-ur-registry/src/CryptoPSBT.ts ++++ /dev/null +@@ -1,32 +0,0 @@ +-import { decodeToDataItem, DataItem } from './lib'; +-import { RegistryItem } from './RegistryItem'; +-import { RegistryTypes } from './RegistryType'; +- +-export class CryptoPSBT extends RegistryItem { +- getRegistryType = () => RegistryTypes.CRYPTO_PSBT; +- +- constructor(private psbt: Buffer) { +- super(); +- } +- +- public getPSBT = () => this.psbt; +- +- public toDataItem = () => { +- return new DataItem(this.psbt); +- }; +- +- public static fromDataItem = (dataItem: DataItem) => { +- const psbt = dataItem.getData(); +- if (!psbt) { +- throw new Error( +- `#[ur-registry][CryptoPSBT][fn.fromDataItem]: decoded [dataItem][#data] is undefined: ${dataItem}`, +- ); +- } +- return new CryptoPSBT(psbt); +- }; +- +- public static fromCBOR = (_cborPayload: Buffer) => { +- const dataItem = decodeToDataItem(_cborPayload); +- return CryptoPSBT.fromDataItem(dataItem); +- }; +-} +diff --git a/node_modules/@keystonehq/bc-ur-registry/src/Decoder/index.ts b/node_modules/@keystonehq/bc-ur-registry/src/Decoder/index.ts +deleted file mode 100644 +index 0460694..0000000 +--- a/node_modules/@keystonehq/bc-ur-registry/src/Decoder/index.ts ++++ /dev/null +@@ -1,40 +0,0 @@ +-import { URDecoder } from '@ngraveio/bc-ur'; +-import { +- Bytes, +- CryptoAccount, +- CryptoCoinInfo, +- CryptoECKey, +- CryptoHDKey, +- CryptoKeypath, +- CryptoOutput, +- CryptoPSBT, +-} from '..'; +-import { RegistryTypes } from '../RegistryType'; +- +-export class URRegistryDecoder extends URDecoder { +- public resultRegistryType = () => { +- const ur = this.resultUR(); +- switch (ur.type) { +- case RegistryTypes.BYTES.getType(): +- return Bytes.fromCBOR(ur.cbor); +- case RegistryTypes.CRYPTO_HDKEY.getType(): +- return CryptoHDKey.fromCBOR(ur.cbor); +- case RegistryTypes.CRYPTO_KEYPATH.getType(): +- return CryptoKeypath.fromCBOR(ur.cbor); +- case RegistryTypes.CRYPTO_COIN_INFO.getType(): +- return CryptoCoinInfo.fromCBOR(ur.cbor); +- case RegistryTypes.CRYPTO_ECKEY.getType(): +- return CryptoECKey.fromCBOR(ur.cbor); +- case RegistryTypes.CRYPTO_OUTPUT.getType(): +- return CryptoOutput.fromCBOR(ur.cbor); +- case RegistryTypes.CRYPTO_PSBT.getType(): +- return CryptoPSBT.fromCBOR(ur.cbor); +- case RegistryTypes.CRYPTO_ACCOUNT.getType(): +- return CryptoAccount.fromCBOR(ur.cbor); +- default: +- throw new Error( +- `#[ur-registry][Decoder][fn.resultRegistryType]: registry type ${ur.type} is not supported now`, +- ); +- } +- }; +-} +diff --git a/node_modules/@keystonehq/bc-ur-registry/src/MultiKey.ts b/node_modules/@keystonehq/bc-ur-registry/src/MultiKey.ts +deleted file mode 100644 +index 0522fbd..0000000 +--- a/node_modules/@keystonehq/bc-ur-registry/src/MultiKey.ts ++++ /dev/null +@@ -1,54 +0,0 @@ +-import { CryptoECKey } from './CryptoECKey'; +-import { CryptoHDKey } from './CryptoHDKey'; +-import { DataItem } from './lib/DataItem'; +-import { RegistryItem } from './RegistryItem'; +-import { RegistryType, RegistryTypes } from './RegistryType'; +- +-enum Keys { +- threshold = 1, +- keys, +-} +- +-export class MultiKey extends RegistryItem { +- getRegistryType: () => RegistryType; +- +- constructor( +- private threshold: number, +- private ecKeys: CryptoECKey[], +- private hdKeys: CryptoHDKey[], +- ) { +- super(); +- } +- +- getThreshold = () => this.threshold; +- getEcKeys = () => this.ecKeys as CryptoECKey[]; +- getHdKeys = () => this.hdKeys as CryptoHDKey[]; +- +- toDataItem = () => { +- const map = {}; +- map[Keys.threshold] = this.threshold; +- const keys: DataItem[] = [...this.ecKeys, ...this.hdKeys].map((k) => { +- const dataItem = k.toDataItem(); +- dataItem.setTag(k.getRegistryType().getTag()); +- return dataItem; +- }); +- map[Keys.keys] = keys; +- return new DataItem(map); +- }; +- +- static fromDataItem = (dataItem: DataItem) => { +- const map = dataItem.getData(); +- const threshold = map[Keys.threshold]; +- const keys = map[Keys.keys] as DataItem[]; +- const ecKeys = []; +- const hdKeys = []; +- keys.forEach((k) => { +- if (k.getTag() === RegistryTypes.CRYPTO_HDKEY.getTag()) { +- hdKeys.push(CryptoHDKey.fromDataItem(k)); +- } else if (k.getTag() === RegistryTypes.CRYPTO_ECKEY.getTag()) { +- ecKeys.push(CryptoECKey.fromDataItem(k)); +- } +- }); +- return new MultiKey(threshold, ecKeys, hdKeys); +- }; +-} +diff --git a/node_modules/@keystonehq/bc-ur-registry/src/PathComponent.ts b/node_modules/@keystonehq/bc-ur-registry/src/PathComponent.ts +deleted file mode 100644 +index d41cb06..0000000 +--- a/node_modules/@keystonehq/bc-ur-registry/src/PathComponent.ts ++++ /dev/null +@@ -1,28 +0,0 @@ +-export class PathComponent { +- public static readonly HARDENED_BIT = 0x80000000; +- +- private index?: number; +- private wildcard: boolean; +- private hardened: boolean; +- +- constructor(args: { index?: number; hardened: boolean }) { +- this.index = args.index; +- this.hardened = args.hardened; +- +- if (this.index !== undefined) { +- this.wildcard = false; +- } else { +- this.wildcard = true; +- } +- +- if (this.index && (this.index & PathComponent.HARDENED_BIT) !== 0) { +- throw new Error( +- `#[ur-registry][PathComponent][fn.constructor]: Invalid index ${this.index} - most significant bit cannot be set`, +- ); +- } +- } +- +- public getIndex = () => this.index; +- public isWildcard = () => this.wildcard; +- public isHardened = () => this.hardened; +-} +diff --git a/node_modules/@keystonehq/bc-ur-registry/src/RegistryItem.ts b/node_modules/@keystonehq/bc-ur-registry/src/RegistryItem.ts +deleted file mode 100644 +index 99139f7..0000000 +--- a/node_modules/@keystonehq/bc-ur-registry/src/RegistryItem.ts ++++ /dev/null +@@ -1,35 +0,0 @@ +-import { UR, UREncoder } from '@ngraveio/bc-ur'; +-import { encodeDataItem, DataItem } from './lib'; +-import { RegistryType } from './RegistryType'; +- +-export abstract class RegistryItem { +- abstract getRegistryType: () => RegistryType; +- abstract toDataItem: () => DataItem; +- public toCBOR = () => { +- if (this.toDataItem() === undefined) { +- throw new Error( +- `#[ur-registry][RegistryItem][fn.toCBOR]: registry ${this.getRegistryType()}'s method toDataItem returns undefined`, +- ); +- } +- return encodeDataItem(this.toDataItem()); +- }; +- +- public toUR = () => { +- return new UR(this.toCBOR(), this.getRegistryType().getType()); +- }; +- +- public toUREncoder = ( +- maxFragmentLength?: number, +- firstSeqNum?: number, +- minFragmentLength?: number, +- ) => { +- const ur = this.toUR(); +- const urEncoder = new UREncoder( +- ur, +- maxFragmentLength, +- firstSeqNum, +- minFragmentLength, +- ); +- return urEncoder; +- }; +-} +diff --git a/node_modules/@keystonehq/bc-ur-registry/src/RegistryType.ts b/node_modules/@keystonehq/bc-ur-registry/src/RegistryType.ts +deleted file mode 100644 +index 64637bc..0000000 +--- a/node_modules/@keystonehq/bc-ur-registry/src/RegistryType.ts ++++ /dev/null +@@ -1,20 +0,0 @@ +-// cbor registry types: https://github.com/BlockchainCommons/Research/blob/master/papers/bcr-2020-006-urtypes.md +-// Map +- +-export class RegistryType { +- constructor(private type: string, private tag?: number) {} +- getTag = () => this.tag; +- getType = () => this.type; +-} +- +-export const RegistryTypes = { +- UUID: new RegistryType('uuid', 37), +- BYTES: new RegistryType('bytes', undefined), +- CRYPTO_HDKEY: new RegistryType('crypto-hdkey', 303), +- CRYPTO_KEYPATH: new RegistryType('crypto-keypath', 304), +- CRYPTO_COIN_INFO: new RegistryType('crypto-coin-info', 305), +- CRYPTO_ECKEY: new RegistryType('crypto-eckey', 306), +- CRYPTO_OUTPUT: new RegistryType('crypto-output', 308), +- CRYPTO_PSBT: new RegistryType('crypto-psbt', 310), +- CRYPTO_ACCOUNT: new RegistryType('crypto-account', 311), +-}; +diff --git a/node_modules/@keystonehq/bc-ur-registry/src/ScriptExpression.ts b/node_modules/@keystonehq/bc-ur-registry/src/ScriptExpression.ts +deleted file mode 100644 +index fdd3f05..0000000 +--- a/node_modules/@keystonehq/bc-ur-registry/src/ScriptExpression.ts ++++ /dev/null +@@ -1,26 +0,0 @@ +-export class ScriptExpression { +- constructor(private tag: number, private expression: string) {} +- +- public getTag = () => this.tag; +- public getExpression = () => this.expression; +- +- public static fromTag = (tag: number) => { +- const se = Object.values(ScriptExpressions).find( +- (se) => se.getTag() === tag, +- ); +- return se; +- }; +-} +- +-export const ScriptExpressions = { +- SCRIPT_HASH: new ScriptExpression(400, 'sh'), +- WITNESS_SCRIPT_HASH: new ScriptExpression(401, 'wsh'), +- PUBLIC_KEY: new ScriptExpression(402, 'pk'), +- PUBLIC_KEY_HASH: new ScriptExpression(403, 'pkh'), +- WITNESS_PUBLIC_KEY_HASH: new ScriptExpression(404, 'wpkh'), +- COMBO: new ScriptExpression(405, 'combo'), +- MULTISIG: new ScriptExpression(406, 'multi'), +- SORTED_MULTISIG: new ScriptExpression(407, 'sorted'), +- ADDRESS: new ScriptExpression(307, 'addr'), +- RAW_SCRIPT: new ScriptExpression(408, 'raw'), +-}; +diff --git a/node_modules/@keystonehq/bc-ur-registry/src/index.ts b/node_modules/@keystonehq/bc-ur-registry/src/index.ts +deleted file mode 100644 +index 172a1e5..0000000 +--- a/node_modules/@keystonehq/bc-ur-registry/src/index.ts ++++ /dev/null +@@ -1,89 +0,0 @@ +-import './patchCBOR'; +- +-import { CryptoHDKey } from './CryptoHDKey'; +-import { CryptoKeypath } from './CryptoKeypath'; +-import { +- CryptoCoinInfo, +- Type as CryptoCoinInfoType, +- Network as CryptoCoinInfoNetwork, +-} from './CryptoCoinInfo'; +-import { CryptoECKey } from './CryptoECKey'; +-import { Bytes } from './Bytes'; +-import { CryptoOutput } from './CryptoOutput'; +-import { CryptoPSBT } from './CryptoPSBT'; +-import { CryptoAccount } from './CryptoAccount'; +-import { URRegistryDecoder } from './Decoder'; +- +-import { MultiKey } from './MultiKey'; +- +-import { ScriptExpressions } from './ScriptExpression'; +-import { PathComponent } from './PathComponent'; +- +-import { RegistryTypes, RegistryType } from './RegistryType'; +- +-import { +- addReader, +- addSemanticDecode, +- addSemanticEncode, +- addWriter, +- decodeToDataItem, +- encodeDataItem, +-} from './lib'; +- +-export { DataItem } from './lib'; +-export { RegistryItem } from './RegistryItem'; +- +-import { patchTags } from './utils'; +- +-const URlib = { +- URRegistryDecoder, +- Bytes, +- CryptoAccount, +- CryptoHDKey, +- CryptoKeypath, +- CryptoCoinInfo, +- CryptoCoinInfoType, +- CryptoCoinInfoNetwork, +- CryptoECKey, +- CryptoOutput, +- CryptoPSBT, +- MultiKey, +- ScriptExpressions, +- PathComponent, +-}; +- +-const cbor = { +- addReader, +- addSemanticDecode, +- addSemanticEncode, +- addWriter, +- patchTags, +-}; +- +-const extend = { +- RegistryTypes, +- RegistryType, +- decodeToDataItem, +- encodeDataItem, +- cbor, +-}; +- +-export { +- URRegistryDecoder, +- Bytes, +- CryptoAccount, +- CryptoHDKey, +- CryptoKeypath, +- CryptoCoinInfo, +- CryptoCoinInfoType, +- CryptoCoinInfoNetwork, +- CryptoECKey, +- CryptoOutput, +- CryptoPSBT, +- MultiKey, +- ScriptExpressions, +- PathComponent, +- extend, +-}; +- +-export default URlib; +diff --git a/node_modules/@keystonehq/bc-ur-registry/src/lib/DataItem.ts b/node_modules/@keystonehq/bc-ur-registry/src/lib/DataItem.ts +deleted file mode 100644 +index 9727f7e..0000000 +--- a/node_modules/@keystonehq/bc-ur-registry/src/lib/DataItem.ts ++++ /dev/null +@@ -1,25 +0,0 @@ +-export class DataItem { +- private tag?: number; +- private data: any; +- +- constructor(data: any, tag?: number) { +- this.data = data; +- this.tag = tag; +- } +- +- public setTag = (tag?: number) => { +- this.tag = tag; +- }; +- +- public clearTag = () => { +- this.tag = undefined; +- }; +- +- public getTag = () => { +- return this.tag; +- }; +- +- public getData = () => { +- return this.data; +- }; +-} +diff --git a/node_modules/@keystonehq/bc-ur-registry/src/lib/cbor-sync.js b/node_modules/@keystonehq/bc-ur-registry/src/lib/cbor-sync.js +deleted file mode 100644 +index 63e5b3a..0000000 +--- a/node_modules/@keystonehq/bc-ur-registry/src/lib/cbor-sync.js ++++ /dev/null +@@ -1,695 +0,0 @@ +-(function (global, factory) { +- if (typeof define === 'function' && define.amd) { +- define([], factory); +- } else if (typeof module !== 'undefined' && module.exports) { +- module.exports = factory(); +- } else { +- global.CBOR = factory(); +- } +-})(this, function () { +- const { DataItem } = require('./DataItem'); +- var CBOR = (function () { +- function BinaryHex(hex) { +- this.$hex = hex; +- } +- BinaryHex.prototype = { +- length: function () { +- return this.$hex.length / 2; +- }, +- toString: function (format) { +- if (!format || format === 'hex' || format === 16) return this.$hex; +- if (format === 'utf-8') { +- var encoded = ''; +- for (var i = 0; i < this.$hex.length; i += 2) { +- encoded += '%' + this.$hex.substring(i, i + 2); +- } +- return decodeURIComponent(encoded); +- } +- if (format === 'latin') { +- var encoded = []; +- for (var i = 0; i < this.$hex.length; i += 2) { +- encoded.push(parseInt(this.$hex.substring(i, i + 2), 16)); +- } +- return String.fromCharCode.apply(String, encoded); +- } +- throw new Error('Unrecognised format: ' + format); +- }, +- }; +- BinaryHex.fromLatinString = function (latinString) { +- var hex = ''; +- for (var i = 0; i < latinString.length; i++) { +- var pair = latinString.charCodeAt(i).toString(16); +- if (pair.length === 1) pair = '0' + pair; +- hex += pair; +- } +- return new BinaryHex(hex); +- }; +- BinaryHex.fromUtf8String = function (utf8String) { +- var encoded = encodeURIComponent(utf8String); +- var hex = ''; +- for (var i = 0; i < encoded.length; i++) { +- if (encoded.charAt(i) === '%') { +- hex += encoded.substring(i + 1, i + 3); +- i += 2; +- } else { +- var hexPair = encoded.charCodeAt(i).toString(16); +- if (hexPair.length < 2) hexPair = '0' + hexPair; +- hex += hexPair; +- } +- } +- return new BinaryHex(hex); +- }; +- +- var semanticEncoders = []; +- var semanticDecoders = {}; +- +- var notImplemented = function (label) { +- return function () { +- throw new Error(label + ' not implemented'); +- }; +- }; +- +- function Reader() {} +- Reader.prototype = { +- peekByte: notImplemented('peekByte'), +- readByte: notImplemented('readByte'), +- readChunk: notImplemented('readChunk'), +- readFloat16: function () { +- var half = this.readUint16(); +- var exponent = (half & 0x7fff) >> 10; +- var mantissa = half & 0x3ff; +- var negative = half & 0x8000; +- if (exponent === 0x1f) { +- if (mantissa === 0) { +- return negative ? -Infinity : Infinity; +- } +- return NaN; +- } +- var magnitude = exponent +- ? Math.pow(2, exponent - 25) * (1024 + mantissa) +- : Math.pow(2, -24) * mantissa; +- return negative ? -magnitude : magnitude; +- }, +- readFloat32: function () { +- var intValue = this.readUint32(); +- var exponent = (intValue & 0x7fffffff) >> 23; +- var mantissa = intValue & 0x7fffff; +- var negative = intValue & 0x80000000; +- if (exponent === 0xff) { +- if (mantissa === 0) { +- return negative ? -Infinity : Infinity; +- } +- return NaN; +- } +- var magnitude = exponent +- ? Math.pow(2, exponent - 23 - 127) * (8388608 + mantissa) +- : Math.pow(2, -23 - 126) * mantissa; +- return negative ? -magnitude : magnitude; +- }, +- readFloat64: function () { +- var int1 = this.readUint32(), +- int2 = this.readUint32(); +- var exponent = (int1 >> 20) & 0x7ff; +- var mantissa = (int1 & 0xfffff) * 4294967296 + int2; +- var negative = int1 & 0x80000000; +- if (exponent === 0x7ff) { +- if (mantissa === 0) { +- return negative ? -Infinity : Infinity; +- } +- return NaN; +- } +- var magnitude = exponent +- ? Math.pow(2, exponent - 52 - 1023) * (4503599627370496 + mantissa) +- : Math.pow(2, -52 - 1022) * mantissa; +- return negative ? -magnitude : magnitude; +- }, +- readUint16: function () { +- return this.readByte() * 256 + this.readByte(); +- }, +- readUint32: function () { +- return this.readUint16() * 65536 + this.readUint16(); +- }, +- readUint64: function () { +- return this.readUint32() * 4294967296 + this.readUint32(); +- }, +- }; +- function Writer() {} +- Writer.prototype = { +- writeByte: notImplemented('writeByte'), +- result: notImplemented('result'), +- writeFloat16: notImplemented('writeFloat16'), +- writeFloat32: notImplemented('writeFloat32'), +- writeFloat64: notImplemented('writeFloat64'), +- writeUint16: function (value) { +- this.writeByte((value >> 8) & 0xff); +- this.writeByte(value & 0xff); +- }, +- writeUint32: function (value) { +- this.writeUint16((value >> 16) & 0xffff); +- this.writeUint16(value & 0xffff); +- }, +- writeUint64: function (value) { +- if (value >= 9007199254740992 || value <= -9007199254740992) { +- throw new Error( +- 'Cannot encode Uint64 of: ' + +- value + +- ' magnitude to big (floating point errors)', +- ); +- } +- this.writeUint32(Math.floor(value / 4294967296)); +- this.writeUint32(value % 4294967296); +- }, +- writeString: notImplemented('writeString'), +- canWriteBinary: function (chunk) { +- return false; +- }, +- writeBinary: notImplemented('writeChunk'), +- }; +- +- function readHeaderRaw(reader) { +- var firstByte = reader.readByte(); +- var majorType = firstByte >> 5, +- value = firstByte & 0x1f; +- return { type: majorType, value: value }; +- } +- +- function valueFromHeader(header, reader) { +- var value = header.value; +- if (value < 24) { +- return value; +- } else if (value == 24) { +- return reader.readByte(); +- } else if (value == 25) { +- return reader.readUint16(); +- } else if (value == 26) { +- return reader.readUint32(); +- } else if (value == 27) { +- return reader.readUint64(); +- } else if (value == 31) { +- // special value for non-terminating arrays/objects +- return null; +- } +- notImplemented('Additional info: ' + value)(); +- } +- +- function writeHeaderRaw(type, value, writer) { +- writer.writeByte((type << 5) | value); +- } +- +- function writeHeader(type, value, writer) { +- var firstByte = type << 5; +- if (value < 24) { +- writer.writeByte(firstByte | value); +- } else if (value < 256) { +- writer.writeByte(firstByte | 24); +- writer.writeByte(value); +- } else if (value < 65536) { +- writer.writeByte(firstByte | 25); +- writer.writeUint16(value); +- } else if (value < 4294967296) { +- writer.writeByte(firstByte | 26); +- writer.writeUint32(value); +- } else { +- writer.writeByte(firstByte | 27); +- writer.writeUint64(value); +- } +- } +- +- var stopCode = new Error(); // Just a unique object, that won't compare strictly equal to anything else +- +- function decodeReader(reader) { +- var header = readHeaderRaw(reader); +- switch (header.type) { +- case 0: +- return valueFromHeader(header, reader); +- case 1: +- return -1 - valueFromHeader(header, reader); +- case 2: +- return reader.readChunk(valueFromHeader(header, reader)); +- case 3: +- var buffer = reader.readChunk(valueFromHeader(header, reader)); +- return buffer.toString('utf-8'); +- case 4: +- case 5: +- var arrayLength = valueFromHeader(header, reader); +- var result = []; +- if (arrayLength !== null) { +- if (header.type === 5) { +- arrayLength *= 2; +- } +- for (var i = 0; i < arrayLength; i++) { +- result[i] = decodeReader(reader); +- } +- } else { +- var item; +- while ((item = decodeReader(reader)) !== stopCode) { +- result.push(item); +- } +- } +- if (header.type === 5) { +- var objResult = {}; +- for (var i = 0; i < result.length; i += 2) { +- objResult[result[i]] = result[i + 1]; +- } +- return objResult; +- } else { +- return result; +- } +- case 6: +- var tag = valueFromHeader(header, reader); +- var decoder = semanticDecoders[tag]; +- var result = decodeReader(reader); +- return decoder ? decoder(result) : result; +- case 7: +- if (header.value === 25) { +- return reader.readFloat16(); +- } else if (header.value === 26) { +- return reader.readFloat32(); +- } else if (header.value === 27) { +- return reader.readFloat64(); +- } +- switch (valueFromHeader(header, reader)) { +- case 20: +- return false; +- case 21: +- return true; +- case 22: +- return null; +- case 23: +- return undefined; +- case null: +- return stopCode; +- default: +- throw new Error('Unknown fixed value: ' + header.value); +- } +- default: +- throw new Error('Unsupported header: ' + JSON.stringify(header)); +- } +- throw new Error('not implemented yet'); +- } +- +- function encodeWriter(data, writer) { +- for (var i = 0; i < semanticEncoders.length; i++) { +- var replacement = semanticEncoders[i].fn(data); +- if (replacement !== undefined) { +- writeHeader(6, semanticEncoders[i].tag, writer); +- return encodeWriter(replacement, writer); +- } +- } +- +- if (data && typeof data.toCBOR === 'function') { +- data = data.toCBOR(); +- } +- +- if (data === false) { +- writeHeader(7, 20, writer); +- } else if (data === true) { +- writeHeader(7, 21, writer); +- } else if (data === null) { +- writeHeader(7, 22, writer); +- } else if (data === undefined) { +- writeHeader(7, 23, writer); +- } else if (typeof data === 'number') { +- if ( +- Math.floor(data) === data && +- data < 9007199254740992 && +- data > -9007199254740992 +- ) { +- // Integer +- if (data < 0) { +- writeHeader(1, -1 - data, writer); +- } else { +- writeHeader(0, data, writer); +- } +- } else { +- writeHeaderRaw(7, 27, writer); +- writer.writeFloat64(data); +- } +- } else if (typeof data === 'string') { +- writer.writeString(data, function (length) { +- writeHeader(3, length, writer); +- }); +- } else if (writer.canWriteBinary(data)) { +- writer.writeBinary(data, function (length) { +- writeHeader(2, length, writer); +- }); +- } else if (typeof data === 'object') { +- if (api.config.useToJSON && typeof data.toJSON === 'function') { +- data = data.toJSON(); +- } +- if (Array.isArray(data)) { +- writeHeader(4, data.length, writer); +- for (var i = 0; i < data.length; i++) { +- encodeWriter(data[i], writer); +- } +- } else { +- var keys = Object.keys(data); +- writeHeader(5, keys.length, writer); +- for (var i = 0; i < keys.length; i++) { +- const number = parseInt(keys[i]); +- if (isNaN(number)) { +- encodeWriter(keys[i], writer); +- encodeWriter(data[keys[i]], writer); +- } else { +- encodeWriter(number, writer); +- encodeWriter(data[keys[i]], writer); +- } +- } +- } +- } else { +- throw new Error('CBOR encoding not supported: ' + data); +- } +- } +- +- var readerFunctions = []; +- var writerFunctions = []; +- +- var api = { +- config: { +- useToJSON: true, +- }, +- addWriter: function (format, writerFunction) { +- if (typeof format === 'string') { +- writerFunctions.push(function (f) { +- if (format === f) return writerFunction(f); +- }); +- } else { +- writerFunctions.push(format); +- } +- }, +- addReader: function (format, readerFunction) { +- if (typeof format === 'string') { +- readerFunctions.push(function (data, f) { +- if (format === f) return readerFunction(data, f); +- }); +- } else { +- readerFunctions.push(format); +- } +- }, +- encode: function (data, format) { +- for (var i = 0; i < writerFunctions.length; i++) { +- var func = writerFunctions[i]; +- var writer = func(format); +- if (writer) { +- encodeWriter(data, writer); +- return writer.result(); +- } +- } +- throw new Error('Unsupported output format: ' + format); +- }, +- // DataItem: {getData: () => any} +- encodeDataItem: function (data, format) { +- for (var i = 0; i < writerFunctions.length; i++) { +- var func = writerFunctions[i]; +- var writer = func(format); +- if (writer) { +- if (data.getTag() !== undefined) { +- encodeWriter(data, writer); +- return writer.result(); +- } else { +- encodeWriter(data.getData(), writer); +- return writer.result(); +- } +- } +- } +- throw new Error('Unsupported output format: ' + format); +- }, +- decode: function (data, format) { +- for (var i = 0; i < readerFunctions.length; i++) { +- var func = readerFunctions[i]; +- var reader = func(data, format); +- if (reader) { +- return decodeReader(reader); +- } +- } +- throw new Error('Unsupported input format: ' + format); +- }, +- decodeToDataItem: function (data, format) { +- for (var i = 0; i < readerFunctions.length; i++) { +- var func = readerFunctions[i]; +- var reader = func(data, format); +- if (reader) { +- const result = decodeReader(reader); +- if (result instanceof DataItem) { +- return result; +- } else { +- return new DataItem(result); +- } +- } +- } +- throw new Error('Unsupported input format: ' + format); +- }, +- addSemanticEncode: function (tag, fn) { +- if (typeof tag !== 'number' || tag % 1 !== 0 || tag < 0) { +- throw new Error('Tag must be a positive integer'); +- } +- semanticEncoders.push({ tag: tag, fn: fn }); +- return this; +- }, +- addSemanticDecode: function (tag, fn) { +- if (typeof tag !== 'number' || tag % 1 !== 0 || tag < 0) { +- throw new Error('Tag must be a positive integer'); +- } +- semanticDecoders[tag] = fn; +- return this; +- }, +- Reader: Reader, +- Writer: Writer, +- }; +- +- /** Node.js Buffers **/ +- function BufferReader(buffer) { +- this.buffer = buffer; +- this.pos = 0; +- } +- BufferReader.prototype = Object.create(Reader.prototype); +- BufferReader.prototype.peekByte = function () { +- return this.buffer[this.pos]; +- }; +- BufferReader.prototype.readByte = function () { +- return this.buffer[this.pos++]; +- }; +- BufferReader.prototype.readUint16 = function () { +- var result = this.buffer.readUInt16BE(this.pos); +- this.pos += 2; +- return result; +- }; +- BufferReader.prototype.readUint32 = function () { +- var result = this.buffer.readUInt32BE(this.pos); +- this.pos += 4; +- return result; +- }; +- BufferReader.prototype.readFloat32 = function () { +- var result = this.buffer.readFloatBE(this.pos); +- this.pos += 4; +- return result; +- }; +- BufferReader.prototype.readFloat64 = function () { +- var result = this.buffer.readDoubleBE(this.pos); +- this.pos += 8; +- return result; +- }; +- BufferReader.prototype.readChunk = function (length) { +- var result = Buffer.alloc(length); +- this.buffer.copy(result, 0, this.pos, (this.pos += length)); +- return result; +- }; +- +- function BufferWriter(stringFormat) { +- this.byteLength = 0; +- this.defaultBufferLength = 16384; // 16k +- this.latestBuffer = Buffer.alloc(this.defaultBufferLength); +- this.latestBufferOffset = 0; +- this.completeBuffers = []; +- this.stringFormat = stringFormat; +- } +- BufferWriter.prototype = Object.create(Writer.prototype); +- BufferWriter.prototype.writeByte = function (value) { +- this.latestBuffer[this.latestBufferOffset++] = value; +- if (this.latestBufferOffset >= this.latestBuffer.length) { +- this.completeBuffers.push(this.latestBuffer); +- this.latestBuffer = Buffer.alloc(this.defaultBufferLength); +- this.latestBufferOffset = 0; +- } +- this.byteLength++; +- }; +- BufferWriter.prototype.writeFloat32 = function (value) { +- var buffer = Buffer.alloc(4); +- buffer.writeFloatBE(value, 0); +- this.writeBuffer(buffer); +- }; +- BufferWriter.prototype.writeFloat64 = function (value) { +- var buffer = Buffer.alloc(8); +- buffer.writeDoubleBE(value, 0); +- this.writeBuffer(buffer); +- }; +- BufferWriter.prototype.writeString = function (string, lengthFunc) { +- var buffer = Buffer.from(string, 'utf-8'); +- lengthFunc(buffer.length); +- this.writeBuffer(buffer); +- }; +- BufferWriter.prototype.canWriteBinary = function (data) { +- return data instanceof Buffer; +- }; +- BufferWriter.prototype.writeBinary = function (buffer, lengthFunc) { +- lengthFunc(buffer.length); +- this.writeBuffer(buffer); +- }; +- BufferWriter.prototype.writeBuffer = function (chunk) { +- if (!(chunk instanceof Buffer)) +- throw new TypeError('BufferWriter only accepts Buffers'); +- if (!this.latestBufferOffset) { +- this.completeBuffers.push(chunk); +- } else if ( +- this.latestBuffer.length - this.latestBufferOffset >= +- chunk.length +- ) { +- chunk.copy(this.latestBuffer, this.latestBufferOffset); +- this.latestBufferOffset += chunk.length; +- if (this.latestBufferOffset >= this.latestBuffer.length) { +- this.completeBuffers.push(this.latestBuffer); +- this.latestBuffer = Buffer.alloc(this.defaultBufferLength); +- this.latestBufferOffset = 0; +- } +- } else { +- this.completeBuffers.push( +- this.latestBuffer.slice(0, this.latestBufferOffset), +- ); +- this.completeBuffers.push(chunk); +- this.latestBuffer = Buffer.alloc(this.defaultBufferLength); +- this.latestBufferOffset = 0; +- } +- this.byteLength += chunk.length; +- }; +- BufferWriter.prototype.result = function () { +- // Copies them all into a single Buffer +- var result = Buffer.alloc(this.byteLength); +- var offset = 0; +- for (var i = 0; i < this.completeBuffers.length; i++) { +- var buffer = this.completeBuffers[i]; +- buffer.copy(result, offset, 0, buffer.length); +- offset += buffer.length; +- } +- if (this.latestBufferOffset) { +- this.latestBuffer.copy(result, offset, 0, this.latestBufferOffset); +- } +- +- if (this.stringFormat) return result.toString(this.stringFormat); +- return result; +- }; +- +- if (typeof Buffer === 'function') { +- api.addReader(function (data, format) { +- if (data instanceof Buffer) { +- return new BufferReader(data); +- } +- if (format === 'hex' || format === 'base64') { +- var buffer = Buffer.from(data, format); +- return new BufferReader(buffer); +- } +- }); +- api.addWriter(function (format) { +- if (!format || format === 'buffer') { +- return new BufferWriter(); +- } else if (format === 'hex' || format === 'base64') { +- return new BufferWriter(format); +- } +- }); +- } +- +- /** Hex-encoding (and Latin1) for browser **/ +- function HexReader(hex) { +- this.hex = hex; +- this.pos = 0; +- } +- HexReader.prototype = Object.create(Reader.prototype); +- HexReader.prototype.peekByte = function () { +- var pair = this.hex.substring(this.pos, 2); +- return parseInt(pair, 16); +- }; +- HexReader.prototype.readByte = function () { +- var pair = this.hex.substring(this.pos, this.pos + 2); +- this.pos += 2; +- return parseInt(pair, 16); +- }; +- HexReader.prototype.readChunk = function (length) { +- var hex = this.hex.substring(this.pos, this.pos + length * 2); +- this.pos += length * 2; +- if (typeof Buffer === 'function') return Buffer.from(hex, 'hex'); +- return new BinaryHex(hex); +- }; +- +- function HexWriter(finalFormat) { +- this.$hex = ''; +- this.finalFormat = finalFormat || 'hex'; +- } +- HexWriter.prototype = Object.create(Writer.prototype); +- HexWriter.prototype.writeByte = function (value) { +- if (value < 0 || value > 255) +- throw new Error('Byte value out of range: ' + value); +- var hex = value.toString(16); +- if (hex.length == 1) { +- hex = '0' + hex; +- } +- this.$hex += hex; +- }; +- HexWriter.prototype.canWriteBinary = function (chunk) { +- return ( +- chunk instanceof BinaryHex || +- (typeof Buffer === 'function' && chunk instanceof Buffer) +- ); +- }; +- HexWriter.prototype.writeBinary = function (chunk, lengthFunction) { +- if (chunk instanceof BinaryHex) { +- lengthFunction(chunk.length()); +- this.$hex += chunk.$hex; +- } else if (typeof Buffer === 'function' && chunk instanceof Buffer) { +- lengthFunction(chunk.length); +- this.$hex += chunk.toString('hex'); +- } else { +- throw new TypeError('HexWriter only accepts BinaryHex or Buffers'); +- } +- }; +- HexWriter.prototype.result = function () { +- if (this.finalFormat === 'buffer' && typeof Buffer === 'function') { +- return Buffer.from(this.$hex, 'hex'); +- } +- return new BinaryHex(this.$hex).toString(this.finalFormat); +- }; +- HexWriter.prototype.writeString = function (string, lengthFunction) { +- var buffer = BinaryHex.fromUtf8String(string); +- lengthFunction(buffer.length()); +- this.$hex += buffer.$hex; +- }; +- +- api.addReader(function (data, format) { +- if (data instanceof BinaryHex || data.$hex) { +- return new HexReader(data.$hex); +- } +- if (format === 'hex') { +- return new HexReader(data); +- } +- }); +- api.addWriter(function (format) { +- if (format === 'hex') { +- return new HexWriter(); +- } +- }); +- +- return api; +- })(); +- +- CBOR.addSemanticEncode(0, function (data) { +- if (data instanceof Date) { +- return data.toISOString(); +- } +- }) +- .addSemanticDecode(0, function (isoString) { +- return new Date(isoString); +- }) +- .addSemanticDecode(1, function (isoString) { +- return new Date(isoString); +- }); +- +- return CBOR; +-}); +diff --git a/node_modules/@keystonehq/bc-ur-registry/src/lib/index.ts b/node_modules/@keystonehq/bc-ur-registry/src/lib/index.ts +deleted file mode 100644 +index deb0156..0000000 +--- a/node_modules/@keystonehq/bc-ur-registry/src/lib/index.ts ++++ /dev/null +@@ -1,9 +0,0 @@ +-export { +- encodeDataItem, +- decodeToDataItem, +- addSemanticDecode, +- addSemanticEncode, +- addReader, +- addWriter, +-} from './cbor-sync'; +-export { DataItem } from './DataItem'; +diff --git a/node_modules/@keystonehq/bc-ur-registry/src/patchCBOR.ts b/node_modules/@keystonehq/bc-ur-registry/src/patchCBOR.ts +deleted file mode 100644 +index b9909a7..0000000 +--- a/node_modules/@keystonehq/bc-ur-registry/src/patchCBOR.ts ++++ /dev/null +@@ -1,11 +0,0 @@ +-import { patchTags } from './utils'; +-import { RegistryTypes } from './RegistryType'; +-import { ScriptExpressions } from './ScriptExpression'; +- +-const registryTags = Object.values(RegistryTypes) +- .filter((r) => !!r.getTag()) +- .map((r) => r.getTag()); +-const scriptExpressionTags = Object.values(ScriptExpressions).map((se) => +- se.getTag(), +-); +-patchTags(registryTags.concat(scriptExpressionTags)); +diff --git a/node_modules/@keystonehq/bc-ur-registry/src/utils.ts b/node_modules/@keystonehq/bc-ur-registry/src/utils.ts +deleted file mode 100644 +index ee39b78..0000000 +--- a/node_modules/@keystonehq/bc-ur-registry/src/utils.ts ++++ /dev/null +@@ -1,19 +0,0 @@ +-import { addSemanticDecode, addSemanticEncode, DataItem } from './lib'; +- +-const alreadyPatchedTag = []; +-export const patchTags = (tags: number[]) => { +- tags.forEach((tag) => { +- if (alreadyPatchedTag.find((i) => i === tag)) return; +- addSemanticEncode(tag, (data: any) => { +- if (data instanceof DataItem) { +- if (data.getTag() === tag) { +- return data.getData(); +- } +- } +- }); +- addSemanticDecode(tag, (data: any) => { +- return new DataItem(data, tag); +- }); +- alreadyPatchedTag.push(tag); +- }); +-}; diff --git a/patches/await-semaphore+0.1.3.patch b/patches/await-semaphore+0.1.3.patch new file mode 100644 index 000000000000..f130d85de1b5 --- /dev/null +++ b/patches/await-semaphore+0.1.3.patch @@ -0,0 +1,68 @@ +diff --git a/node_modules/await-semaphore/index.ts b/node_modules/await-semaphore/index.ts +deleted file mode 100644 +index 69ce92a..0000000 +--- a/node_modules/await-semaphore/index.ts ++++ /dev/null +@@ -1,62 +0,0 @@ +-export class Semaphore { +- private tasks: (() => void)[] = []; +- count: number; +- +- constructor(count: number) { +- this.count = count; +- } +- +- private sched() { +- if (this.count > 0 && this.tasks.length > 0) { +- this.count--; +- let next = this.tasks.shift(); +- if (next === undefined) { +- throw "Unexpected undefined value in tasks list"; +- } +- +- next(); +- } +- } +- +- public acquire() { +- return new Promise<() => void>((res, rej) => { +- var task = () => { +- var released = false; +- res(() => { +- if (!released) { +- released = true; +- this.count++; +- this.sched(); +- } +- }); +- }; +- this.tasks.push(task); +- if (process && process.nextTick) { +- process.nextTick(this.sched.bind(this)); +- } else { +- setImmediate(this.sched.bind(this)); +- } +- }); +- } +- +- public use(f: () => Promise) { +- return this.acquire() +- .then(release => { +- return f() +- .then((res) => { +- release(); +- return res; +- }) +- .catch((err) => { +- release(); +- throw err; +- }); +- }); +- } +-} +- +-export class Mutex extends Semaphore { +- constructor() { +- super(1); +- } +-} diff --git a/patches/eslint-import-resolver-typescript+2.5.0.patch b/patches/eslint-import-resolver-typescript+2.5.0.patch new file mode 100644 index 000000000000..163ff663e9c0 --- /dev/null +++ b/patches/eslint-import-resolver-typescript+2.5.0.patch @@ -0,0 +1,29 @@ +diff --git a/node_modules/eslint-import-resolver-typescript/lib/cjs.js b/node_modules/eslint-import-resolver-typescript/lib/cjs.js +index 5aeddb5..1fe0cbf 100644 +--- a/node_modules/eslint-import-resolver-typescript/lib/cjs.js ++++ b/node_modules/eslint-import-resolver-typescript/lib/cjs.js +@@ -49,13 +49,19 @@ function __spreadArray(to, from) { + + var IMPORTER_NAME = 'eslint-import-resolver-typescript'; + var log = debug__default['default'](IMPORTER_NAME); +-var defaultExtensions = __spreadArray(__spreadArray([ ++/** ++ * In the original version of this package, `Object.keys(require.extensions)` ++ * gets added to `defaultExtensions`. `require.extensions` resolves to undefined ++ * when this file is run through LavaMoat, and ESLint emits a warning that ++ * `require.extensions` is deprecated anyway. So we hardcode this list here. ++ */ ++var defaultExtensions = [ + '.ts', + '.tsx', +- '.d.ts' +-], Object.keys(require.extensions)), [ +- '.jsx', +-]); ++ '.d.ts', ++ '.js', ++ '.jsx' ++]; + var interfaceVersion = 2; + /** + * @param {string} source the module to resolve; i.e './some-module' diff --git a/patches/typescript+4.4.4.patch b/patches/typescript+4.4.4.patch new file mode 100644 index 000000000000..e86cadadba6d --- /dev/null +++ b/patches/typescript+4.4.4.patch @@ -0,0 +1,250 @@ +diff --git a/node_modules/typescript/lib/typescript.js b/node_modules/typescript/lib/typescript.js +index 323de6f..367063a 100644 +--- a/node_modules/typescript/lib/typescript.js ++++ b/node_modules/typescript/lib/typescript.js +@@ -24,11 +24,58 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { + return to.concat(ar || Array.prototype.slice.call(from)); + }; + var __assign = (this && this.__assign) || function () { +- __assign = Object.assign || function(t) { ++ __assign = function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; +- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) +- t[p] = s[p]; ++ for (var p in s) { ++ if (Object.prototype.hasOwnProperty.call(s, p)) { ++ /** ++ * In the original version of this package, this was: ++ * ++ * t[p] = s[p] ++ * ++ * Unfortunately LavaMoat trips up on this, so we have to change ++ * it. ++ * ++ * Internally LavaMoat uses `lockdown` (part of SES, which is ++ * part of Endo) to freeze modifications to "intrinsics" — core ++ * things like `Object.prototype`, `Function.prototype`, etc. ++ * This will cause code which is responsible for said ++ * modifications to fail at runtime, because it makes the ++ * properties of these intrinsics non-writable. ++ * ++ * The reason we have to change *this* code is that later on, ++ * this `__assign` function is used to merge two objects, and ++ * one of those objects contains a `constructor` property. As we ++ * know, `constructor` is a special property, as it's a property ++ * on `Object.prototype` that stores the constructor used to ++ * create that object. But when used in this context, there is ++ * nothing inherently special about it – it's just a property on ++ * an object we're setting. Unfortunately, that's not how it's ++ * being treated. Because `lockdown` freezes `Object.prototype`, ++ * `Object.prototype.constructor` is non-writable, and due to a ++ * "mistake" in the ES5 spec [1], that means `constructor` on ++ * *any* object is non-writable too. So an error is thrown when ++ * this code is executed. ++ * ++ * There is a way to get around this, which is to configure ++ * `lockdown` with the option `overrideTaming: 'severe'`. ++ * The mechanics of this option, as well as more information ++ * about the "mistake" this option solves, are explained here ++ * [2]. Unfortunately, we cannot enable this option because ++ * LavaMoat is the one running `lockdown` here [3]. So to work ++ * around this, we use `Object.defineProperty` to define the ++ * property we want. As this does not use property assignment ++ * (`object[key] = value`) but rather defines the property more ++ * directly, this bypasses the "override mistake". ++ * ++ * [1]: https://web.archive.org/web/20141230041441/http://wiki.ecmascript.org/doku.php?id=strawman:fixing_override_mistake ++ * [2]: https://github.com/endojs/endo/blob/864f086f87e1e7ef78a401a7550ff0aeb664bba0/packages/ses/src/enable-property-overrides.js#L28 ++ * [3]: https://github.com/LavaMoat/LavaMoat/blob/7c15bf8ba34ba1a9ceb3ffe591b1b2bfb084bead/packages/core/src/kernelTemplate.js#L32-L43 ++ */ ++ Object.defineProperty(t, p, Object.getOwnPropertyDescriptor(s, p)) ++ } ++ } + } + return t; + }; +@@ -9820,87 +9867,94 @@ var ts; + } + ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; + /** @internal */ +- ts.textToKeywordObj = (_a = { +- abstract: 126 /* AbstractKeyword */, +- any: 129 /* AnyKeyword */, +- as: 127 /* AsKeyword */, +- asserts: 128 /* AssertsKeyword */, +- bigint: 156 /* BigIntKeyword */, +- boolean: 132 /* BooleanKeyword */, +- break: 81 /* BreakKeyword */, +- case: 82 /* CaseKeyword */, +- catch: 83 /* CatchKeyword */, +- class: 84 /* ClassKeyword */, +- continue: 86 /* ContinueKeyword */, +- const: 85 /* ConstKeyword */ +- }, +- _a["" + "constructor"] = 133 /* ConstructorKeyword */, +- _a.debugger = 87 /* DebuggerKeyword */, +- _a.declare = 134 /* DeclareKeyword */, +- _a.default = 88 /* DefaultKeyword */, +- _a.delete = 89 /* DeleteKeyword */, +- _a.do = 90 /* DoKeyword */, +- _a.else = 91 /* ElseKeyword */, +- _a.enum = 92 /* EnumKeyword */, +- _a.export = 93 /* ExportKeyword */, +- _a.extends = 94 /* ExtendsKeyword */, +- _a.false = 95 /* FalseKeyword */, +- _a.finally = 96 /* FinallyKeyword */, +- _a.for = 97 /* ForKeyword */, +- _a.from = 154 /* FromKeyword */, +- _a.function = 98 /* FunctionKeyword */, +- _a.get = 135 /* GetKeyword */, +- _a.if = 99 /* IfKeyword */, +- _a.implements = 117 /* ImplementsKeyword */, +- _a.import = 100 /* ImportKeyword */, +- _a.in = 101 /* InKeyword */, +- _a.infer = 136 /* InferKeyword */, +- _a.instanceof = 102 /* InstanceOfKeyword */, +- _a.interface = 118 /* InterfaceKeyword */, +- _a.intrinsic = 137 /* IntrinsicKeyword */, +- _a.is = 138 /* IsKeyword */, +- _a.keyof = 139 /* KeyOfKeyword */, +- _a.let = 119 /* LetKeyword */, +- _a.module = 140 /* ModuleKeyword */, +- _a.namespace = 141 /* NamespaceKeyword */, +- _a.never = 142 /* NeverKeyword */, +- _a.new = 103 /* NewKeyword */, +- _a.null = 104 /* NullKeyword */, +- _a.number = 145 /* NumberKeyword */, +- _a.object = 146 /* ObjectKeyword */, +- _a.package = 120 /* PackageKeyword */, +- _a.private = 121 /* PrivateKeyword */, +- _a.protected = 122 /* ProtectedKeyword */, +- _a.public = 123 /* PublicKeyword */, +- _a.override = 157 /* OverrideKeyword */, +- _a.readonly = 143 /* ReadonlyKeyword */, +- _a.require = 144 /* RequireKeyword */, +- _a.global = 155 /* GlobalKeyword */, +- _a.return = 105 /* ReturnKeyword */, +- _a.set = 147 /* SetKeyword */, +- _a.static = 124 /* StaticKeyword */, +- _a.string = 148 /* StringKeyword */, +- _a.super = 106 /* SuperKeyword */, +- _a.switch = 107 /* SwitchKeyword */, +- _a.symbol = 149 /* SymbolKeyword */, +- _a.this = 108 /* ThisKeyword */, +- _a.throw = 109 /* ThrowKeyword */, +- _a.true = 110 /* TrueKeyword */, +- _a.try = 111 /* TryKeyword */, +- _a.type = 150 /* TypeKeyword */, +- _a.typeof = 112 /* TypeOfKeyword */, +- _a.undefined = 151 /* UndefinedKeyword */, +- _a.unique = 152 /* UniqueKeyword */, +- _a.unknown = 153 /* UnknownKeyword */, +- _a.var = 113 /* VarKeyword */, +- _a.void = 114 /* VoidKeyword */, +- _a.while = 115 /* WhileKeyword */, +- _a.with = 116 /* WithKeyword */, +- _a.yield = 125 /* YieldKeyword */, +- _a.async = 130 /* AsyncKeyword */, +- _a.await = 131 /* AwaitKeyword */, +- _a.of = 158 /* OfKeyword */, +- _a); ++ /** ++ * In the original version of this package, this object was built by ++ * initializing one object and then adding more properties to that object. ++ * This ends up throwing an error when this code is executed due to ++ * the same issue as explained at the top of this file: essentially, ++ * the `constructor` property of any object cannot be set due to the ++ * "override mistake". The fix for this is to just build one big object. ++ */ ++ ts.textToKeywordObj = { ++ abstract: 126 /* AbstractKeyword */, ++ any: 129 /* AnyKeyword */, ++ as: 127 /* AsKeyword */, ++ asserts: 128 /* AssertsKeyword */, ++ bigint: 156 /* BigIntKeyword */, ++ boolean: 132 /* BooleanKeyword */, ++ break: 81 /* BreakKeyword */, ++ case: 82 /* CaseKeyword */, ++ catch: 83 /* CatchKeyword */, ++ class: 84 /* ClassKeyword */, ++ continue: 86 /* ContinueKeyword */, ++ const: 85 /* ConstKeyword */, ++ ["constructor"]: 133 /* ConstructorKeyword */, ++ debugger: 87 /* DebuggerKeyword */, ++ declare: 134 /* DeclareKeyword */, ++ default: 88 /* DefaultKeyword */, ++ delete: 89 /* DeleteKeyword */, ++ do: 90 /* DoKeyword */, ++ else: 91 /* ElseKeyword */, ++ enum: 92 /* EnumKeyword */, ++ export: 93 /* ExportKeyword */, ++ extends: 94 /* ExtendsKeyword */, ++ false: 95 /* FalseKeyword */, ++ finally: 96 /* FinallyKeyword */, ++ for: 97 /* ForKeyword */, ++ from: 154 /* FromKeyword */, ++ function: 98 /* FunctionKeyword */, ++ get: 135 /* GetKeyword */, ++ if: 99 /* IfKeyword */, ++ implements: 117 /* ImplementsKeyword */, ++ import: 100 /* ImportKeyword */, ++ in: 101 /* InKeyword */, ++ infer: 136 /* InferKeyword */, ++ instanceof: 102 /* InstanceOfKeyword */, ++ interface: 118 /* InterfaceKeyword */, ++ intrinsic: 137 /* IntrinsicKeyword */, ++ is: 138 /* IsKeyword */, ++ keyof: 139 /* KeyOfKeyword */, ++ let: 119 /* LetKeyword */, ++ module: 140 /* ModuleKeyword */, ++ namespace: 141 /* NamespaceKeyword */, ++ never: 142 /* NeverKeyword */, ++ new: 103 /* NewKeyword */, ++ null: 104 /* NullKeyword */, ++ number: 145 /* NumberKeyword */, ++ object: 146 /* ObjectKeyword */, ++ package: 120 /* PackageKeyword */, ++ private: 121 /* PrivateKeyword */, ++ protected: 122 /* ProtectedKeyword */, ++ public: 123 /* PublicKeyword */, ++ override: 157 /* OverrideKeyword */, ++ readonly: 143 /* ReadonlyKeyword */, ++ require: 144 /* RequireKeyword */, ++ global: 155 /* GlobalKeyword */, ++ return: 105 /* ReturnKeyword */, ++ set: 147 /* SetKeyword */, ++ static: 124 /* StaticKeyword */, ++ string: 148 /* StringKeyword */, ++ super: 106 /* SuperKeyword */, ++ switch: 107 /* SwitchKeyword */, ++ symbol: 149 /* SymbolKeyword */, ++ this: 108 /* ThisKeyword */, ++ throw: 109 /* ThrowKeyword */, ++ true: 110 /* TrueKeyword */, ++ try: 111 /* TryKeyword */, ++ type: 150 /* TypeKeyword */, ++ typeof: 112 /* TypeOfKeyword */, ++ undefined: 151 /* UndefinedKeyword */, ++ unique: 152 /* UniqueKeyword */, ++ unknown: 153 /* UnknownKeyword */, ++ var: 113 /* VarKeyword */, ++ void: 114 /* VoidKeyword */, ++ while: 115 /* WhileKeyword */, ++ with: 116 /* WithKeyword */, ++ yield: 125 /* YieldKeyword */, ++ async: 130 /* AsyncKeyword */, ++ await: 131 /* AwaitKeyword */, ++ of: 158 /* OfKeyword */ ++ }; + var textToKeyword = new ts.Map(ts.getEntries(ts.textToKeywordObj)); + var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, ts.textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 29 /* LessThanToken */, ">": 31 /* GreaterThanToken */, "<=": 32 /* LessThanEqualsToken */, ">=": 33 /* GreaterThanEqualsToken */, "==": 34 /* EqualsEqualsToken */, "!=": 35 /* ExclamationEqualsToken */, "===": 36 /* EqualsEqualsEqualsToken */, "!==": 37 /* ExclamationEqualsEqualsToken */, "=>": 38 /* EqualsGreaterThanToken */, "+": 39 /* PlusToken */, "-": 40 /* MinusToken */, "**": 42 /* AsteriskAsteriskToken */, "*": 41 /* AsteriskToken */, "/": 43 /* SlashToken */, "%": 44 /* PercentToken */, "++": 45 /* PlusPlusToken */, "--": 46 /* MinusMinusToken */, "<<": 47 /* LessThanLessThanToken */, ">": 48 /* GreaterThanGreaterThanToken */, ">>>": 49 /* GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* AmpersandToken */, "|": 51 /* BarToken */, "^": 52 /* CaretToken */, "!": 53 /* ExclamationToken */, "~": 54 /* TildeToken */, "&&": 55 /* AmpersandAmpersandToken */, "||": 56 /* BarBarToken */, "?": 57 /* QuestionToken */, "??": 60 /* QuestionQuestionToken */, "?.": 28 /* QuestionDotToken */, ":": 58 /* ColonToken */, "=": 63 /* EqualsToken */, "+=": 64 /* PlusEqualsToken */, "-=": 65 /* MinusEqualsToken */, "*=": 66 /* AsteriskEqualsToken */, "**=": 67 /* AsteriskAsteriskEqualsToken */, "/=": 68 /* SlashEqualsToken */, "%=": 69 /* PercentEqualsToken */, "<<=": 70 /* LessThanLessThanEqualsToken */, ">>=": 71 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 73 /* AmpersandEqualsToken */, "|=": 74 /* BarEqualsToken */, "^=": 78 /* CaretEqualsToken */, "||=": 75 /* BarBarEqualsToken */, "&&=": 76 /* AmpersandAmpersandEqualsToken */, "??=": 77 /* QuestionQuestionEqualsToken */, "@": 59 /* AtToken */, "#": 62 /* HashToken */, "`": 61 /* BacktickToken */ }))); + /* +@@ -159858,6 +159912,7 @@ var ts; + delete Object.prototype.__magic__; + } + catch (error) { ++ throw error; + // In IE8, Object.defineProperty only works on DOM objects. + // If we hit this code path, assume `window` exists. + //@ts-ignore diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 000000000000..34389d567ecb --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "allowJs": true, + "allowSyntheticDefaultImports": true, + "inlineSources": true, + "isolatedModules": true, + "jsx": "react", + "lib": ["dom", "es2020"], + "moduleResolution": "node", + "noEmitOnError": true, + "outDir": "tsout", + "rootDir": ".", + "sourceMap": true, + "strict": true + }, + "exclude": [ + "**/*.test.js", + "**/*.test.ts", + "**/*.test.tsx", + ".storybook/**/*", + "builds/**/*", + "dist/**/*", + "node_modules/**" + ], + "extends": "@tsconfig/node14/tsconfig.json" +} diff --git a/yarn.lock b/yarn.lock index 5b7bd96e29cf..77e6f996a264 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2807,6 +2807,11 @@ resolved "https://registry.yarnpkg.com/@metamask/eslint-config-nodejs/-/eslint-config-nodejs-9.0.0.tgz#ec737a47c04febfb921ce844362d875ca2cae9e7" integrity sha512-kPUrMPdpGeapbdG+LxysnDNzM9SlBNUvqVl1XoKnOGjo1pbZXB8hOI36PT3IlR1qa2FJumKYfgDSu7JLmOLxqQ== +"@metamask/eslint-config-typescript@^9.0.1": + version "9.0.1" + resolved "https://registry.yarnpkg.com/@metamask/eslint-config-typescript/-/eslint-config-typescript-9.0.1.tgz#900d53579ce074734ac9bf4e3f66fc20b92bd6af" + integrity sha512-+W7MXCoq8Q29wvkAv0ycwKB82xMbl+LfkUoM8oWN4n7vyMDXgcgbNjY7ug+quJPZfDTJJ7fxgPmG8m4LrkEImw== + "@metamask/eslint-config@^9.0.0": version "9.0.0" resolved "https://registry.yarnpkg.com/@metamask/eslint-config/-/eslint-config-9.0.0.tgz#22d4911b705f7e4e566efbdda0e37912da33e30f" @@ -4344,6 +4349,11 @@ dependencies: node-gyp-build "4.3.0" +"@tsconfig/node14@^1.0.1": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.1.tgz#95f2d167ffb9b8d2068b0b235302fafd4df711f2" + integrity sha512-509r2+yARFfHHE7T6Puu2jjkoycftovhXRqW328PDXTVGKihlb1P8Z9mMZH04ebyajfRY7dedfGynlrFHJUQCg== + "@types/aria-query@^4.2.0": version "4.2.0" resolved "https://registry.yarnpkg.com/@types/aria-query/-/aria-query-4.2.0.tgz#14264692a9d6e2fa4db3df5e56e94b5e25647ac0" @@ -4530,7 +4540,7 @@ jest-diff "^26.0.0" pretty-format "^26.0.0" -"@types/json-schema@^7.0.3", "@types/json-schema@^7.0.4", "@types/json-schema@^7.0.5", "@types/json-schema@^7.0.6": +"@types/json-schema@^7.0.4", "@types/json-schema@^7.0.5", "@types/json-schema@^7.0.6", "@types/json-schema@^7.0.7": version "7.0.9" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.9.tgz#97edc9037ea0c38585320b28964dde3b39e4660d" integrity sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ== @@ -4832,76 +4842,74 @@ dependencies: "@types/node" "*" -"@typescript-eslint/experimental-utils@^4.0.1": - version "4.21.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.21.0.tgz#0b0bb7c15d379140a660c003bdbafa71ae9134b6" - integrity sha512-cEbgosW/tUFvKmkg3cU7LBoZhvUs+ZPVM9alb25XvR0dal4qHL3SiUqHNrzoWSxaXA9gsifrYrS1xdDV6w/gIA== +"@typescript-eslint/eslint-plugin@^4.20.0": + version "4.33.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.33.0.tgz#c24dc7c8069c7706bc40d99f6fa87edcb2005276" + integrity sha512-aINiAxGVdOl1eJyVjaWn/YcVAq4Gi/Yo35qHGCnqbWVz61g39D0h23veY/MA0rFFGfxK7TySg2uwDeNv+JgVpg== dependencies: - "@types/json-schema" "^7.0.3" - "@typescript-eslint/scope-manager" "4.21.0" - "@typescript-eslint/types" "4.21.0" - "@typescript-eslint/typescript-estree" "4.21.0" - eslint-scope "^5.0.0" - eslint-utils "^2.0.0" + "@typescript-eslint/experimental-utils" "4.33.0" + "@typescript-eslint/scope-manager" "4.33.0" + debug "^4.3.1" + functional-red-black-tree "^1.0.1" + ignore "^5.1.8" + regexpp "^3.1.0" + semver "^7.3.5" + tsutils "^3.21.0" -"@typescript-eslint/scope-manager@4.21.0": - version "4.21.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.21.0.tgz#c81b661c4b8af1ec0c010d847a8f9ab76ab95b4d" - integrity sha512-kfOjF0w1Ix7+a5T1knOw00f7uAP9Gx44+OEsNQi0PvvTPLYeXJlsCJ4tYnDj5PQEYfpcgOH5yBlw7K+UEI9Agw== +"@typescript-eslint/experimental-utils@4.33.0", "@typescript-eslint/experimental-utils@^4.0.1": + version "4.33.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.33.0.tgz#6f2a786a4209fa2222989e9380b5331b2810f7fd" + integrity sha512-zeQjOoES5JFjTnAhI5QY7ZviczMzDptls15GFsI6jyUOq0kOf9+WonkhtlIhh0RgHRnqj5gdNxW5j1EvAyYg6Q== dependencies: - "@typescript-eslint/types" "4.21.0" - "@typescript-eslint/visitor-keys" "4.21.0" - -"@typescript-eslint/types@4.21.0": - version "4.21.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.21.0.tgz#abdc3463bda5d31156984fa5bc316789c960edef" - integrity sha512-+OQaupjGVVc8iXbt6M1oZMwyKQNehAfLYJJ3SdvnofK2qcjfor9pEM62rVjBknhowTkh+2HF+/KdRAc/wGBN2w== + "@types/json-schema" "^7.0.7" + "@typescript-eslint/scope-manager" "4.33.0" + "@typescript-eslint/types" "4.33.0" + "@typescript-eslint/typescript-estree" "4.33.0" + eslint-scope "^5.1.1" + eslint-utils "^3.0.0" -"@typescript-eslint/types@4.31.1": - version "4.31.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.31.1.tgz#5f255b695627a13401d2fdba5f7138bc79450d66" - integrity sha512-kixltt51ZJGKENNW88IY5MYqTBA8FR0Md8QdGbJD2pKZ+D5IvxjTYDNtJPDxFBiXmka2aJsITdB1BtO1fsgmsQ== +"@typescript-eslint/parser@^4.20.0": + version "4.33.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.33.0.tgz#dfe797570d9694e560528d18eecad86c8c744899" + integrity sha512-ZohdsbXadjGBSK0/r+d87X0SBmKzOq4/S5nzK6SBgJspFo9/CUDJ7hjayuze+JK7CZQLDMroqytp7pOcFKTxZA== + dependencies: + "@typescript-eslint/scope-manager" "4.33.0" + "@typescript-eslint/types" "4.33.0" + "@typescript-eslint/typescript-estree" "4.33.0" + debug "^4.3.1" -"@typescript-eslint/typescript-estree@4.21.0": - version "4.21.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.21.0.tgz#3817bd91857beeaeff90f69f1f112ea58d350b0a" - integrity sha512-ZD3M7yLaVGVYLw4nkkoGKumb7Rog7QID9YOWobFDMQKNl+vPxqVIW/uDk+MDeGc+OHcoG2nJ2HphwiPNajKw3w== +"@typescript-eslint/scope-manager@4.33.0": + version "4.33.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.33.0.tgz#d38e49280d983e8772e29121cf8c6e9221f280a3" + integrity sha512-5IfJHpgTsTZuONKbODctL4kKuQje/bzBRkwHE8UOZ4f89Zeddg+EGZs8PD8NcN4LdM3ygHWYB3ukPAYjvl/qbQ== dependencies: - "@typescript-eslint/types" "4.21.0" - "@typescript-eslint/visitor-keys" "4.21.0" - debug "^4.1.1" - globby "^11.0.1" - is-glob "^4.0.1" - semver "^7.3.2" - tsutils "^3.17.1" + "@typescript-eslint/types" "4.33.0" + "@typescript-eslint/visitor-keys" "4.33.0" -"@typescript-eslint/typescript-estree@^4.8.2": - version "4.31.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.31.1.tgz#4a04d5232cf1031232b7124a9c0310b577a62d17" - integrity sha512-EGHkbsUvjFrvRnusk6yFGqrqMBTue5E5ROnS5puj3laGQPasVUgwhrxfcgkdHNFECHAewpvELE1Gjv0XO3mdWg== +"@typescript-eslint/types@4.33.0": + version "4.33.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.33.0.tgz#a1e59036a3b53ae8430ceebf2a919dc7f9af6d72" + integrity sha512-zKp7CjQzLQImXEpLt2BUw1tvOMPfNoTAfb8l51evhYbOEEzdWyQNmHWWGPR6hwKJDAi+1VXSBmnhL9kyVTTOuQ== + +"@typescript-eslint/typescript-estree@4.33.0", "@typescript-eslint/typescript-estree@^4.8.2": + version "4.33.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.33.0.tgz#0dfb51c2908f68c5c08d82aefeaf166a17c24609" + integrity sha512-rkWRY1MPFzjwnEVHsxGemDzqqddw2QbTJlICPD9p9I9LfsO8fdmfQPOX3uKfUaGRDFJbfrtm/sXhVXN4E+bzCA== dependencies: - "@typescript-eslint/types" "4.31.1" - "@typescript-eslint/visitor-keys" "4.31.1" + "@typescript-eslint/types" "4.33.0" + "@typescript-eslint/visitor-keys" "4.33.0" debug "^4.3.1" globby "^11.0.3" is-glob "^4.0.1" semver "^7.3.5" tsutils "^3.21.0" -"@typescript-eslint/visitor-keys@4.21.0": - version "4.21.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.21.0.tgz#990a9acdc124331f5863c2cf21c88ba65233cd8d" - integrity sha512-dH22dROWGi5Z6p+Igc8bLVLmwy7vEe8r+8c+raPQU0LxgogPUrRAtRGtvBWmlr9waTu3n+QLt/qrS/hWzk1x5w== +"@typescript-eslint/visitor-keys@4.33.0": + version "4.33.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.33.0.tgz#2a22f77a41604289b7a186586e9ec48ca92ef1dd" + integrity sha512-uqi/2aSz9g2ftcHWf8uLPJA70rUv6yuMW5Bohw+bwcuzaxQIHaKFZCKGoGXIrc9vkTJ3+0txM73K0Hq3d5wgIg== dependencies: - "@typescript-eslint/types" "4.21.0" - eslint-visitor-keys "^2.0.0" - -"@typescript-eslint/visitor-keys@4.31.1": - version "4.31.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.31.1.tgz#f2e7a14c7f20c4ae07d7fc3c5878c4441a1da9cc" - integrity sha512-PCncP8hEqKw6SOJY+3St4LVtoZpPPn+Zlpm7KW5xnviMhdqcsBty4Lsg4J/VECpJjw1CkROaZhH4B8M1OfnXTQ== - dependencies: - "@typescript-eslint/types" "4.31.1" + "@typescript-eslint/types" "4.33.0" eslint-visitor-keys "^2.0.0" "@vue/compiler-core@3.1.4": @@ -10700,6 +10708,17 @@ eslint-import-resolver-node@^0.3.4: debug "^2.6.9" resolve "^1.13.1" +eslint-import-resolver-typescript@^2.5.0: + version "2.5.0" + resolved "https://registry.yarnpkg.com/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-2.5.0.tgz#07661966b272d14ba97f597b51e1a588f9722f0a" + integrity sha512-qZ6e5CFr+I7K4VVhQu3M/9xGv9/YmwsEXrsm3nimw8vWaVHRDrQRp26BgCypTxBp3vUp4o5aVEJRiy0F2DFddQ== + dependencies: + debug "^4.3.1" + glob "^7.1.7" + is-glob "^4.0.1" + resolve "^1.20.0" + tsconfig-paths "^3.9.0" + eslint-module-utils@^2.6.0: version "2.6.0" resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.6.0.tgz#579ebd094f56af7797d19c9866c9c9486629bfa6" @@ -10827,7 +10846,7 @@ eslint-scope@^4.0.3: esrecurse "^4.1.0" estraverse "^4.1.1" -eslint-scope@^5.0.0, eslint-scope@^5.1.0, eslint-scope@^5.1.1: +eslint-scope@^5.1.0, eslint-scope@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" integrity sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw== @@ -10849,6 +10868,13 @@ eslint-utils@^2.0.0, eslint-utils@^2.1.0: dependencies: eslint-visitor-keys "^1.1.0" +eslint-utils@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-3.0.0.tgz#8aebaface7345bb33559db0a1f13a1d2d48c3672" + integrity sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA== + dependencies: + eslint-visitor-keys "^2.0.0" + eslint-visitor-keys@1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz#e2a82cea84ff246ad6fb57f9bde5b46621459ec2" @@ -13292,10 +13318,10 @@ glob@7.1.4: once "^1.3.0" path-is-absolute "^1.0.0" -glob@^7.0.0, glob@^7.0.3, glob@^7.1.0, glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4, glob@^7.1.6: - version "7.1.6" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" - integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA== +glob@^7.0.0, glob@^7.0.3, glob@^7.1.0, glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4, glob@^7.1.6, glob@^7.1.7: + version "7.2.0" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023" + integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q== dependencies: fs.realpath "^1.0.0" inflight "^1.0.4" @@ -26663,7 +26689,7 @@ tsscmp@1.0.6: resolved "https://registry.yarnpkg.com/tsscmp/-/tsscmp-1.0.6.tgz#85b99583ac3589ec4bfef825b5000aa911d605eb" integrity sha512-LxhtAkPDTkVCMQjt2h6eBVY28KCjikZqZfMcC15YBeNjkgUpdCfBu5HoiOTDu86v6smE8yOjyEktJ8hlbANHQA== -tsutils@^3.17.1, tsutils@^3.21.0: +tsutils@^3.21.0: version "3.21.0" resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623" integrity sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA== @@ -26804,6 +26830,11 @@ typescript@^3.9.7: resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.10.tgz#70f3910ac7a51ed6bef79da7800690b19bf778b8" integrity sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q== +typescript@~4.4.0: + version "4.4.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.4.tgz#2cd01a1a1f160704d3101fd5a58ff0f9fcb8030c" + integrity sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA== + typical@^5.0.0: version "5.1.0" resolved "https://registry.yarnpkg.com/typical/-/typical-5.1.0.tgz#7116ca103caf2574985fc84fbaa8fd0ee5ea1684"