diff --git a/README.md b/README.md index 6370607bf..9bb5ae9e3 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,17 @@ Until we have an internal process and centrally owned canister, docs can be rele Note - you may need to ask to be added as a controller for the wallet that owns the docs until this job is moved to CI +### Deprecation + +We retain deprecated packages in the packages directory for historical purposes. To deprecate a package, follow these steps + +- Remove all contents except the package.json, license, and readme +- Add a note to the README saying `**Warning** this package is deprecated` +- Remove unnecessary content, dependencies, and metadata from the package.json +- add a `"deprecation"` tag to the package.json with instructions you want users to follow in migrating +- remove the package as a workspace from the root `package.json` +- the next time that agent-js releases, manually publish a new version of newly deprecated packages by incrementing the patch version and running `npm publish` + ### GitHub Actions GitHub Actions for this repo are configured in [./.github/workflows](./.github/workflows). diff --git a/demos/ledgerhq/.gitignore b/demos/ledgerhq/.gitignore deleted file mode 100644 index 849ddff3b..000000000 --- a/demos/ledgerhq/.gitignore +++ /dev/null @@ -1 +0,0 @@ -dist/ diff --git a/demos/ledgerhq/README.md b/demos/ledgerhq/README.md deleted file mode 100644 index c74ccf803..000000000 --- a/demos/ledgerhq/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# ledgerhq, agent-js - -## Development - -### Getting Started - -1. Ensure all dependencies are installed: `npm install` -2. Run the development server `npm run develop` -3. Visit the running site at http://localhost:8080 diff --git a/demos/ledgerhq/package.json b/demos/ledgerhq/package.json deleted file mode 100644 index 86d13bb62..000000000 --- a/demos/ledgerhq/package.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "name": "ic-agent-ledgerhq-app", - "private": true, - "dependencies": { - "@dfinity/agent": "^0.14.1", - "@dfinity/authentication": "^0.14.1", - "@dfinity/identity": "^0.14.1", - "@dfinity/identity-ledgerhq": "^0.14.1", - "@dfinity/principal": "^0.14.1", - "assert": "^2.0.0", - "buffer": "^6.0.3", - "events": "^3.2.0", - "html-webpack-plugin": "^5.1.0", - "process": "^0.11.10", - "protobufjs": "^6.10.2", - "stream-browserify": "^3.0.0", - "ts-node": "^10.8.2", - "util": "^0.12.3", - "webpack": "^5.24.1", - "webpack-cli": "^4.5.0", - "webpack-dev-server": "^4.0.0-beta.0" - }, - "scripts": { - "build": "webpack", - "develop": "webpack-dev-server", - "lint:fix": "npm run lint -- --fix", - "publish:release": "", - "test:coverage": "", - "test": "" - }, - "version": "0.14.1", - "devDependencies": { - "esbuild": "^0.15.16", - "size-limit": "^8.1.0" - } -} diff --git a/demos/ledgerhq/src/index.html b/demos/ledgerhq/src/index.html deleted file mode 100644 index d1623c830..000000000 --- a/demos/ledgerhq/src/index.html +++ /dev/null @@ -1,163 +0,0 @@ - - - - - -

Ledger Hardware Wallet Support

-
-
    -
  1. Connect your Ledger Nano X/S with a usb cable.
  2. -
  3. Enter your PIN code.
  4. -
  5. Open the Dfinity app on the Ledger device.
  6. -
  7. - Connect and get the Principal: - -
  8. -
-
- -
-

Principal Id

-   -
-
-

Actions:

-
  • - - Show the Principal on the device. -
  • -
    - -
    -

    Send message (Proto)

    - -

    Replica URL

    - - -

    Canister ID

    - - -

    Method

    - - -

    Proto Schema

    - - -

    Proto Argument (in JSON, using camelCase)

    - - - -

    Response (in JSON)

    - - - -
    -
    - - diff --git a/demos/ledgerhq/src/main.js b/demos/ledgerhq/src/main.js deleted file mode 100644 index 1078d460b..000000000 --- a/demos/ledgerhq/src/main.js +++ /dev/null @@ -1,105 +0,0 @@ -function toHex(arr) { - // Convert to hexadecimal - // padd with leading 0 if <16 - function i2hex(i) { - return ('0' + i.toString(16)).slice(-2); - } - - return Array.from(arr).map(i2hex).join(''); -} - -async function loadProtobuf(schema, typeName) { - const protobufjs = await import('protobufjs'); - const pbRoot = new protobufjs.Root(); - - const oldFetch = protobufjs.Root.prototype.fetch; - pbRoot.fetch = (path, cb) => { - if (path !== 'schema.proto') { - return oldFetch.call(this, path, cb); - } else { - cb(null, schema); - } - }; - - const root = await protobufjs.load('schema.proto', pbRoot); - return root.lookupType(typeName); -} - -async function encodeProtobuf(schema, typeName, value) { - const messageType = await loadProtobuf(schema, typeName); - - // Encode. - const maybeError = messageType.verify(JSON.parse(value)); - - if (maybeError) { - throw maybeError; - } - - const message = messageType.encode(JSON.parse(value)).finish(); - return new Uint8Array(message); -} - -async function decodeProtobuf(schema, typeName, value) { - const messageType = await loadProtobuf(schema, typeName); - return await messageType.decode(value); -} - -// Disable all buttons that should only be when connected. -for (const el of document.getElementsByClassName('connected-only')) { - el.disabled = true; -} - -let identity = undefined; - -document.getElementById('connectLedgerBtn').addEventListener('click', async () => { - const { LedgerIdentity } = await import('@dfinity/identity-ledgerhq'); - identity = await LedgerIdentity.create(); - - document.getElementById('ledgerPrincipal').innerText = `${identity.getPrincipal().toText()}`; - for (const el of document.getElementsByClassName('connected-only')) { - el.disabled = false; - } -}); - -document.getElementById('checkAddressBtn').addEventListener('click', async () => { - await identity.showAddressAndPubKeyOnDevice(); -}); - -document.getElementById('sendBtn').addEventListener('click', async () => { - const { blobFromUint8Array, HttpAgent, makeNonceTransform, polling } = await import( - '@dfinity/agent' - ); - - const schemaText = document.getElementById('schema').value; - const valueText = document.getElementById('value').value; - const messageTypeName = document.getElementById('requestType').value; - - const payload = await encodeProtobuf(schemaText, messageTypeName, valueText); - console.log(toHex(payload)); - - const host = document.getElementById('hostUrl').value; - const canisterId = document.getElementById('canisterId').value; - - // Need to run a replica locally which has ledger canister running on it - const agent = new HttpAgent({ host, identity }); - - const resp = await agent.call(canisterId, { - methodName: document.getElementById('methodName').value, - arg: blobFromUint8Array(payload), - }); - - const result = await polling.pollForResponse( - agent, - canisterId, - resp.requestId, - polling.strategy.defaultStrategy(), - ); - - console.log(toHex(result)); - - // const result = new Uint8Array([8, 8]); - const responseTypeName = document.getElementById('responseType').value; - const responsePayload = await decodeProtobuf(schemaText, responseTypeName, result); - - document.getElementById('responseJson').innerText = JSON.stringify(responsePayload); -}); diff --git a/demos/ledgerhq/webpack.config.js b/demos/ledgerhq/webpack.config.js deleted file mode 100644 index aeeeae1e6..000000000 --- a/demos/ledgerhq/webpack.config.js +++ /dev/null @@ -1,57 +0,0 @@ -const path = require('path'); -const HtmlWebpackPlugin = require('html-webpack-plugin'); -const webpack = require('webpack'); - -module.exports = { - entry: { - main: path.join(__dirname, 'src/main.js'), - }, - mode: 'production', - target: 'web', - output: { - path: path.join(__dirname, 'dist'), - filename: '[name].bundle.js', - }, - optimization: { - splitChunks: { - chunks: 'all', - minSize: 20000, - maxSize: 200000, - minRemainingSize: 0, - minChunks: 1, - maxAsyncRequests: 30, - maxInitialRequests: 30, - enforceSizeThreshold: 50000, - cacheGroups: { - default: { - minChunks: 2, - priority: -20, - reuseExistingChunk: true, - }, - }, - }, - }, - resolve: { - alias: { - process: 'process/browser', - }, - fallback: { - assert: require.resolve('assert/'), - buffer: require.resolve('buffer/'), - events: require.resolve('events/'), - stream: require.resolve('stream-browserify/'), - util: require.resolve('util/'), - }, - }, - devtool: 'source-map', - plugins: [ - new HtmlWebpackPlugin({ - template: 'src/index.html', - filename: 'index.html', - }), - new webpack.ProvidePlugin({ - Buffer: [require.resolve('buffer/'), 'Buffer'], - process: require.resolve('process/browser'), - }), - ], -}; diff --git a/demos/sample-javascript/package.json b/demos/sample-javascript/package.json index 183639ad8..4ad462c39 100644 --- a/demos/sample-javascript/package.json +++ b/demos/sample-javascript/package.json @@ -27,6 +27,7 @@ }, "version": "0.14.1", "devDependencies": { + "buffer": "^6.0.3", "esbuild": "^0.15.16", "size-limit": "^8.1.0" } diff --git a/demos/sample-javascript/webpack.config.js b/demos/sample-javascript/webpack.config.js index 84503fdcf..642d6ebd0 100644 --- a/demos/sample-javascript/webpack.config.js +++ b/demos/sample-javascript/webpack.config.js @@ -43,6 +43,7 @@ module.exports = { }, fallback: { assert: require.resolve('assert/'), + buffer: require.resolve('buffer/'), events: require.resolve('events/'), stream: require.resolve('stream-browserify/'), util: require.resolve('util/'), diff --git a/docs/generated/changelog.html b/docs/generated/changelog.html index 240bd8b9d..bc746281c 100644 --- a/docs/generated/changelog.html +++ b/docs/generated/changelog.html @@ -12,6 +12,21 @@

    Agent-JS Changelog

    Version x.x.x

    diff --git a/docs/generated/index.html b/docs/generated/index.html index dba4e1973..e2cb4afcf 100644 --- a/docs/generated/index.html +++ b/docs/generated/index.html @@ -26,7 +26,7 @@

    Agent JS Docs Output

    Candid Auth-Client Asset Manager - Authentication + Authentication (deprecated) Identity Identity (LedgerHQ)
    diff --git a/package-lock.json b/package-lock.json index 479d00c01..c93a53dd6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -43,8 +43,6 @@ "packages/agent", "packages/bls-verify", "packages/identity", - "packages/identity-ledgerhq", - "packages/authentication", "packages/auth-client", "packages/assets", "e2e/node", @@ -57,6 +55,7 @@ "demos/ledgerhq": { "name": "ic-agent-ledgerhq-app", "version": "0.14.1", + "extraneous": true, "dependencies": { "@dfinity/agent": "^0.14.1", "@dfinity/authentication": "^0.14.1", @@ -101,6 +100,7 @@ "webpack-dev-server": "^4.0.0-beta.0" }, "devDependencies": { + "buffer": "^6.0.3", "esbuild": "^0.15.16", "size-limit": "^8.1.0" } @@ -1748,6 +1748,7 @@ "version": "7.19.0", "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.19.0.tgz", "integrity": "sha512-eR8Lo9hnDS7tqkO7NsV+mKvCmv5boaXFSZ70DnfhcgiEne8hv9oCEd36Klw74EtizEqLsy4YnW8UWwpBVolHZA==", + "dev": true, "dependencies": { "regenerator-runtime": "^0.13.4" }, @@ -1937,10 +1938,6 @@ "resolved": "packages/identity", "link": true }, - "node_modules/@dfinity/identity-ledgerhq": { - "resolved": "packages/identity-ledgerhq", - "link": true - }, "node_modules/@dfinity/principal": { "resolved": "packages/principal", "link": true @@ -2840,62 +2837,6 @@ "@jridgewell/sourcemap-codec": "^1.4.10" } }, - "node_modules/@ledgerhq/devices": { - "version": "5.51.1", - "resolved": "https://registry.npmjs.org/@ledgerhq/devices/-/devices-5.51.1.tgz", - "integrity": "sha512-4w+P0VkbjzEXC7kv8T1GJ/9AVaP9I6uasMZ/JcdwZBS3qwvKo5A5z9uGhP5c7TvItzcmPb44b5Mw2kT+WjUuAA==", - "dependencies": { - "@ledgerhq/errors": "^5.50.0", - "@ledgerhq/logs": "^5.50.0", - "rxjs": "6", - "semver": "^7.3.5" - } - }, - "node_modules/@ledgerhq/devices/node_modules/semver": { - "version": "7.3.7", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", - "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/@ledgerhq/errors": { - "version": "5.50.0", - "resolved": "https://registry.npmjs.org/@ledgerhq/errors/-/errors-5.50.0.tgz", - "integrity": "sha512-gu6aJ/BHuRlpU7kgVpy2vcYk6atjB4iauP2ymF7Gk0ez0Y/6VSMVSJvubeEQN+IV60+OBK0JgeIZG7OiHaw8ow==" - }, - "node_modules/@ledgerhq/hw-transport": { - "version": "5.51.1", - "resolved": "https://registry.npmjs.org/@ledgerhq/hw-transport/-/hw-transport-5.51.1.tgz", - "integrity": "sha512-6wDYdbWrw9VwHIcoDnqWBaDFyviyjZWv6H9vz9Vyhe4Qd7TIFmbTl/eWs6hZvtZBza9K8y7zD8ChHwRI4s9tSw==", - "dependencies": { - "@ledgerhq/devices": "^5.51.1", - "@ledgerhq/errors": "^5.50.0", - "events": "^3.3.0" - } - }, - "node_modules/@ledgerhq/hw-transport-webhid": { - "version": "5.51.1", - "resolved": "https://registry.npmjs.org/@ledgerhq/hw-transport-webhid/-/hw-transport-webhid-5.51.1.tgz", - "integrity": "sha512-w/2qSU0vwFY+D/4ucuYRViO7iS3Uuxmj9sI/Iiqkoiax9Xppb0/6H5m3ffKv6iPMmRYbgwCgXorqx4SLLSD8Kg==", - "dependencies": { - "@ledgerhq/devices": "^5.51.1", - "@ledgerhq/errors": "^5.50.0", - "@ledgerhq/hw-transport": "^5.51.1", - "@ledgerhq/logs": "^5.50.0" - } - }, - "node_modules/@ledgerhq/logs": { - "version": "5.50.0", - "resolved": "https://registry.npmjs.org/@ledgerhq/logs/-/logs-5.50.0.tgz", - "integrity": "sha512-swKHYCOZUGyVt4ge0u8a7AwNcA//h4nx5wIi0sruGye1IJ5Cva0GyK9L2/WdX+kWVTKp92ZiEo1df31lrWGPgA==" - }, "node_modules/@leichtgewicht/ip-codec": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/@leichtgewicht/ip-codec/-/ip-codec-2.0.4.tgz", @@ -5228,60 +5169,6 @@ "debug": "^4.3.1" } }, - "node_modules/@protobufjs/aspromise": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz", - "integrity": "sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==" - }, - "node_modules/@protobufjs/base64": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@protobufjs/base64/-/base64-1.1.2.tgz", - "integrity": "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==" - }, - "node_modules/@protobufjs/codegen": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@protobufjs/codegen/-/codegen-2.0.4.tgz", - "integrity": "sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==" - }, - "node_modules/@protobufjs/eventemitter": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz", - "integrity": "sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q==" - }, - "node_modules/@protobufjs/fetch": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@protobufjs/fetch/-/fetch-1.1.0.tgz", - "integrity": "sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ==", - "dependencies": { - "@protobufjs/aspromise": "^1.1.1", - "@protobufjs/inquire": "^1.1.0" - } - }, - "node_modules/@protobufjs/float": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@protobufjs/float/-/float-1.0.2.tgz", - "integrity": "sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==" - }, - "node_modules/@protobufjs/inquire": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@protobufjs/inquire/-/inquire-1.1.0.tgz", - "integrity": "sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q==" - }, - "node_modules/@protobufjs/path": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@protobufjs/path/-/path-1.1.2.tgz", - "integrity": "sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==" - }, - "node_modules/@protobufjs/pool": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@protobufjs/pool/-/pool-1.1.0.tgz", - "integrity": "sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==" - }, - "node_modules/@protobufjs/utf8": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz", - "integrity": "sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==" - }, "node_modules/@sinclair/typebox": { "version": "0.24.35", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.24.35.tgz", @@ -5664,19 +5551,6 @@ "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==" }, - "node_modules/@types/ledgerhq__hw-transport": { - "version": "4.21.4", - "resolved": "https://registry.npmjs.org/@types/ledgerhq__hw-transport/-/ledgerhq__hw-transport-4.21.4.tgz", - "integrity": "sha512-vep+6yZnGv6owAthIY0w3f72w4dJIb4+yE5PCHveInTlZE9wukvU6Wc5Eig0OUUxcdhTazzeZx1xUaNVLqyQSg==", - "dependencies": { - "@types/node": "*" - } - }, - "node_modules/@types/long": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.2.tgz", - "integrity": "sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA==" - }, "node_modules/@types/mime": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/@types/mime/-/mime-3.0.1.tgz", @@ -6232,17 +6106,6 @@ "resolved": "https://registry.npmjs.org/@xtuc/long/-/long-4.2.2.tgz", "integrity": "sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==" }, - "node_modules/@zondax/ledger-dfinity": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/@zondax/ledger-dfinity/-/ledger-dfinity-0.2.1.tgz", - "integrity": "sha512-QrVYh/BnupGQfK1BoviS9pmYm+4lR/VyzF0jRT4WAZuPn51Kgc/X7Iseh+VCZ9AgrgBve4fZJVDujRktKo/gnA==", - "deprecated": "This package has been deprecated. Please migrate to @zondax/ledger-icp", - "dependencies": { - "@babel/runtime": "^7.13.9", - "@ledgerhq/hw-transport": "^5.45.0", - "@types/ledgerhq__hw-transport": "^4.21.3" - } - }, "node_modules/@zxing/text-encoding": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/@zxing/text-encoding/-/text-encoding-0.9.0.tgz", @@ -7377,6 +7240,7 @@ "version": "6.0.3", "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "dev": true, "funding": [ { "type": "github", @@ -11586,10 +11450,6 @@ "url": "https://github.com/sponsors/typicode" } }, - "node_modules/ic-agent-ledgerhq-app": { - "resolved": "demos/ledgerhq", - "link": true - }, "node_modules/ic-agent-sample-javascript-app": { "resolved": "demos/sample-javascript", "link": true @@ -14413,11 +14273,6 @@ "node": ">=8" } }, - "node_modules/long": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", - "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" - }, "node_modules/lower-case": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz", @@ -16389,31 +16244,6 @@ "node": ">= 6" } }, - "node_modules/protobufjs": { - "version": "6.11.3", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.11.3.tgz", - "integrity": "sha512-xL96WDdCZYdU7Slin569tFX712BxsxslWwAfAhCYjQKGTq7dAU91Lomy6nLLhh/dyGhk/YH4TwTSRxTzhuHyZg==", - "hasInstallScript": true, - "dependencies": { - "@protobufjs/aspromise": "^1.1.2", - "@protobufjs/base64": "^1.1.2", - "@protobufjs/codegen": "^2.0.4", - "@protobufjs/eventemitter": "^1.1.0", - "@protobufjs/fetch": "^1.1.0", - "@protobufjs/float": "^1.0.2", - "@protobufjs/inquire": "^1.1.0", - "@protobufjs/path": "^1.1.2", - "@protobufjs/pool": "^1.1.0", - "@protobufjs/utf8": "^1.1.0", - "@types/long": "^4.0.1", - "@types/node": ">=13.7.0", - "long": "^4.0.0" - }, - "bin": { - "pbjs": "bin/pbjs", - "pbts": "bin/pbts" - } - }, "node_modules/proxy-addr": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", @@ -16770,7 +16600,8 @@ "node_modules/regenerator-runtime": { "version": "0.13.9", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz", - "integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==" + "integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==", + "dev": true }, "node_modules/regenerator-transform": { "version": "0.15.0", @@ -17102,22 +16933,6 @@ } ] }, - "node_modules/rxjs": { - "version": "6.6.7", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz", - "integrity": "sha512-hTdwr+7yYNIT5n4AMYp85KA6yw2Va0FLa3Rguvbpa4W3I5xynaBZo41cM3XM+4Q6fRMj3sBYIR1VAmZMXYJvRQ==", - "dependencies": { - "tslib": "^1.9.0" - }, - "engines": { - "npm": ">=2.0.0" - } - }, - "node_modules/rxjs/node_modules/tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" - }, "node_modules/safari-14-idb-fix": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/safari-14-idb-fix/-/safari-14-idb-fix-3.0.0.tgz", @@ -19978,7 +19793,6 @@ }, "peerDependencies": { "@dfinity/agent": "^0.14.1", - "@dfinity/authentication": "^0.14.1", "@dfinity/identity": "^0.14.1", "@dfinity/principal": "^0.14.1" } @@ -20065,12 +19879,48 @@ "packages/authentication": { "name": "@dfinity/authentication", "version": "0.14.1", + "deprecated": "This package has been deprecated. isDelegationValid has been migrated to @dfinity/identity", + "license": "Apache-2.0", + "dependencies": { + "@dfinity/identity": "^0.14.1" + } + }, + "packages/bls-verify": { + "name": "@dfinity/bls-verify", + "version": "0.14.1", "license": "Apache-2.0", "dependencies": { - "stream": "^0.0.2" + "amcl-js": "file:src/vendor/amcl-js" + }, + "devDependencies": { + "esbuild": "^0.15.16", + "size-limit": "^8.1.0" + } + }, + "packages/bls-verify/src/vendor/amcl-js": { + "version": "3.0.0", + "license": "Apache License 2.0", + "dependencies": { + "prompt": "^1.0.0" + } + }, + "packages/bls-verify/vendor/miracl": { + "name": "amcl-js", + "version": "3.0.0", + "extraneous": true, + "license": "Apache License 2.0", + "dependencies": { + "prompt": "^1.0.0" + } + }, + "packages/candid": { + "name": "@dfinity/candid", + "version": "0.14.1", + "license": "Apache-2.0", + "dependencies": { + "ts-node": "^10.8.2" }, "devDependencies": { - "@trust/webcrypto": "^0.9.2", "@types/jest": "^28.1.4", "@typescript-eslint/eslint-plugin": "^5.30.5", "@typescript-eslint/parser": "^5.30.5", @@ -20078,22 +19928,149 @@ "eslint": "^8.19.0", "eslint-plugin-jsdoc": "^39.3.3", "jest": "^28.1.2", + "jest-diff": "^27.3.1", + "prettier": "^2.0.5", "size-limit": "^8.1.0", "text-encoding": "^0.7.0", "ts-jest": "^28.0.5", - "ts-node": "^10.8.2", "tslint": "^5.20.0", "typedoc": "^0.22.11", "typescript": "^4.7.4", "whatwg-fetch": "^3.0.0" + } + }, + "packages/candid/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "packages/candid/node_modules/glob": { + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz", + "integrity": "sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^5.0.1", + "once": "^1.3.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "packages/candid/node_modules/minimatch": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz", + "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "packages/candid/node_modules/shiki": { + "version": "0.10.1", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.10.1.tgz", + "integrity": "sha512-VsY7QJVzU51j5o1+DguUd+6vmCmZ5v/6gYu4vyYAhzjuNQU6P/vmSy4uQaOhvje031qQMiW0d2BwgMH52vqMng==", + "dev": true, + "dependencies": { + "jsonc-parser": "^3.0.0", + "vscode-oniguruma": "^1.6.1", + "vscode-textmate": "5.2.0" + } + }, + "packages/candid/node_modules/typedoc": { + "version": "0.22.18", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.18.tgz", + "integrity": "sha512-NK9RlLhRUGMvc6Rw5USEYgT4DVAUFk7IF7Q6MYfpJ88KnTZP7EneEa4RcP+tX1auAcz7QT1Iy0bUSZBYYHdoyA==", + "dev": true, + "dependencies": { + "glob": "^8.0.3", + "lunr": "^2.3.9", + "marked": "^4.0.16", + "minimatch": "^5.1.0", + "shiki": "^0.10.1" + }, + "bin": { + "typedoc": "bin/typedoc" + }, + "engines": { + "node": ">= 12.10.0" + }, + "peerDependencies": { + "typescript": "4.0.x || 4.1.x || 4.2.x || 4.3.x || 4.4.x || 4.5.x || 4.6.x || 4.7.x" + } + }, + "packages/candid/node_modules/vscode-textmate": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-5.2.0.tgz", + "integrity": "sha512-Uw5ooOQxRASHgu6C7GVvUxisKXfSgW4oFlO+aa+PAkgmH89O3CXxEEzNRNtHSqtXFTl0nAC1uYj0GMSH27uwtQ==", + "dev": true + }, + "packages/identity": { + "name": "@dfinity/identity", + "version": "0.14.1", + "license": "Apache-2.0", + "dependencies": { + "@peculiar/webcrypto": "^1.4.0", + "bip39": "^3.0.4", + "borc": "^2.1.1", + "bs58check": "^2.1.2", + "js-sha256": "^0.9.0", + "secp256k1": "^4.0.2", + "stream": "^0.0.2", + "ts-node": "^10.8.2", + "tweetnacl": "^1.0.1" + }, + "devDependencies": { + "@types/bs58check": "^2.1.0", + "@types/hdkey": "^2.0.1", + "@types/jest": "^28.1.4", + "@types/secp256k1": "^4.0.3", + "@types/webappsec-credential-management": "^0.6.2", + "@typescript-eslint/eslint-plugin": "^5.30.5", + "@typescript-eslint/parser": "^5.30.5", + "esbuild": "^0.15.16", + "eslint": "^8.19.0", + "eslint-plugin-jsdoc": "^39.3.3", + "idb-keyval": "^6.2.0", + "jest": "^28.1.2", + "size-limit": "^8.1.0", + "text-encoding": "^0.7.0", + "ts-jest": "^28.0.5", + "tslint": "^5.20.1", + "typedoc": "^0.22.11", + "typescript": "^4.7.4", + "whatwg-fetch": "^3.0.0" }, "peerDependencies": { "@dfinity/agent": "^0.14.1", - "@dfinity/identity": "^0.14.1", - "@dfinity/principal": "^0.14.1" + "@dfinity/principal": "^0.14.1", + "crypto-browserify": "^3.12.0" + } + }, + "packages/identity-ledgerhq": { + "name": "@dfinity/identity-ledgerhq", + "version": "0.14.1", + "deprecated": "This package has been deprecated. Please use the `@zondax/ledger-icp` package instead.", + "extraneous": true, + "license": "Apache-2.0", + "dependencies": { + "@zondax/ledger-icp": "^0.6.1" } }, - "packages/authentication/node_modules/brace-expansion": { + "packages/identity/node_modules/brace-expansion": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", @@ -20102,7 +20079,7 @@ "balanced-match": "^1.0.0" } }, - "packages/authentication/node_modules/glob": { + "packages/identity/node_modules/glob": { "version": "8.0.3", "resolved": "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz", "integrity": "sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==", @@ -20121,7 +20098,7 @@ "url": "https://github.com/sponsors/isaacs" } }, - "packages/authentication/node_modules/minimatch": { + "packages/identity/node_modules/minimatch": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz", "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==", @@ -20133,7 +20110,7 @@ "node": ">=10" } }, - "packages/authentication/node_modules/shiki": { + "packages/identity/node_modules/shiki": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.10.1.tgz", "integrity": "sha512-VsY7QJVzU51j5o1+DguUd+6vmCmZ5v/6gYu4vyYAhzjuNQU6P/vmSy4uQaOhvje031qQMiW0d2BwgMH52vqMng==", @@ -20144,375 +20121,7 @@ "vscode-textmate": "5.2.0" } }, - "packages/authentication/node_modules/typedoc": { - "version": "0.22.18", - "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.18.tgz", - "integrity": "sha512-NK9RlLhRUGMvc6Rw5USEYgT4DVAUFk7IF7Q6MYfpJ88KnTZP7EneEa4RcP+tX1auAcz7QT1Iy0bUSZBYYHdoyA==", - "dev": true, - "dependencies": { - "glob": "^8.0.3", - "lunr": "^2.3.9", - "marked": "^4.0.16", - "minimatch": "^5.1.0", - "shiki": "^0.10.1" - }, - "bin": { - "typedoc": "bin/typedoc" - }, - "engines": { - "node": ">= 12.10.0" - }, - "peerDependencies": { - "typescript": "4.0.x || 4.1.x || 4.2.x || 4.3.x || 4.4.x || 4.5.x || 4.6.x || 4.7.x" - } - }, - "packages/authentication/node_modules/vscode-textmate": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-5.2.0.tgz", - "integrity": "sha512-Uw5ooOQxRASHgu6C7GVvUxisKXfSgW4oFlO+aa+PAkgmH89O3CXxEEzNRNtHSqtXFTl0nAC1uYj0GMSH27uwtQ==", - "dev": true - }, - "packages/bls-verify": { - "name": "@dfinity/bls-verify", - "version": "0.14.1", - "license": "Apache-2.0", - "dependencies": { - "amcl-js": "file:src/vendor/amcl-js" - }, - "devDependencies": { - "esbuild": "^0.15.16", - "size-limit": "^8.1.0" - } - }, - "packages/bls-verify/src/vendor/amcl-js": { - "version": "3.0.0", - "license": "Apache License 2.0", - "dependencies": { - "prompt": "^1.0.0" - } - }, - "packages/bls-verify/vendor/miracl": { - "name": "amcl-js", - "version": "3.0.0", - "extraneous": true, - "license": "Apache License 2.0", - "dependencies": { - "prompt": "^1.0.0" - } - }, - "packages/candid": { - "name": "@dfinity/candid", - "version": "0.14.1", - "license": "Apache-2.0", - "dependencies": { - "ts-node": "^10.8.2" - }, - "devDependencies": { - "@types/jest": "^28.1.4", - "@typescript-eslint/eslint-plugin": "^5.30.5", - "@typescript-eslint/parser": "^5.30.5", - "esbuild": "^0.15.16", - "eslint": "^8.19.0", - "eslint-plugin-jsdoc": "^39.3.3", - "jest": "^28.1.2", - "jest-diff": "^27.3.1", - "prettier": "^2.0.5", - "size-limit": "^8.1.0", - "text-encoding": "^0.7.0", - "ts-jest": "^28.0.5", - "tslint": "^5.20.0", - "typedoc": "^0.22.11", - "typescript": "^4.7.4", - "whatwg-fetch": "^3.0.0" - } - }, - "packages/candid/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "packages/candid/node_modules/glob": { - "version": "8.0.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz", - "integrity": "sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==", - "dev": true, - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^5.0.1", - "once": "^1.3.0" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "packages/candid/node_modules/minimatch": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz", - "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==", - "dev": true, - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=10" - } - }, - "packages/candid/node_modules/shiki": { - "version": "0.10.1", - "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.10.1.tgz", - "integrity": "sha512-VsY7QJVzU51j5o1+DguUd+6vmCmZ5v/6gYu4vyYAhzjuNQU6P/vmSy4uQaOhvje031qQMiW0d2BwgMH52vqMng==", - "dev": true, - "dependencies": { - "jsonc-parser": "^3.0.0", - "vscode-oniguruma": "^1.6.1", - "vscode-textmate": "5.2.0" - } - }, - "packages/candid/node_modules/typedoc": { - "version": "0.22.18", - "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.18.tgz", - "integrity": "sha512-NK9RlLhRUGMvc6Rw5USEYgT4DVAUFk7IF7Q6MYfpJ88KnTZP7EneEa4RcP+tX1auAcz7QT1Iy0bUSZBYYHdoyA==", - "dev": true, - "dependencies": { - "glob": "^8.0.3", - "lunr": "^2.3.9", - "marked": "^4.0.16", - "minimatch": "^5.1.0", - "shiki": "^0.10.1" - }, - "bin": { - "typedoc": "bin/typedoc" - }, - "engines": { - "node": ">= 12.10.0" - }, - "peerDependencies": { - "typescript": "4.0.x || 4.1.x || 4.2.x || 4.3.x || 4.4.x || 4.5.x || 4.6.x || 4.7.x" - } - }, - "packages/candid/node_modules/vscode-textmate": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-5.2.0.tgz", - "integrity": "sha512-Uw5ooOQxRASHgu6C7GVvUxisKXfSgW4oFlO+aa+PAkgmH89O3CXxEEzNRNtHSqtXFTl0nAC1uYj0GMSH27uwtQ==", - "dev": true - }, - "packages/identity": { - "name": "@dfinity/identity", - "version": "0.14.1", - "license": "Apache-2.0", - "dependencies": { - "@peculiar/webcrypto": "^1.4.0", - "bip39": "^3.0.4", - "borc": "^2.1.1", - "bs58check": "^2.1.2", - "js-sha256": "^0.9.0", - "secp256k1": "^4.0.2", - "stream": "^0.0.2", - "ts-node": "^10.8.2", - "tweetnacl": "^1.0.1" - }, - "devDependencies": { - "@types/bs58check": "^2.1.0", - "@types/hdkey": "^2.0.1", - "@types/jest": "^28.1.4", - "@types/secp256k1": "^4.0.3", - "@types/webappsec-credential-management": "^0.6.2", - "@typescript-eslint/eslint-plugin": "^5.30.5", - "@typescript-eslint/parser": "^5.30.5", - "esbuild": "^0.15.16", - "eslint": "^8.19.0", - "eslint-plugin-jsdoc": "^39.3.3", - "idb-keyval": "^6.2.0", - "jest": "^28.1.2", - "size-limit": "^8.1.0", - "text-encoding": "^0.7.0", - "ts-jest": "^28.0.5", - "tslint": "^5.20.1", - "typedoc": "^0.22.11", - "typescript": "^4.7.4", - "whatwg-fetch": "^3.0.0" - }, - "peerDependencies": { - "@dfinity/agent": "^0.14.1", - "@dfinity/principal": "^0.14.1", - "crypto-browserify": "^3.12.0" - } - }, - "packages/identity-ledgerhq": { - "name": "@dfinity/identity-ledgerhq", - "version": "0.14.1", - "license": "Apache-2.0", - "dependencies": { - "@ledgerhq/hw-transport": "^5.49.0", - "@ledgerhq/hw-transport-webhid": "^5.49.0", - "@zondax/ledger-dfinity": "0.2.1", - "buffer": "6.0.3", - "ts-node": "^10.8.2" - }, - "devDependencies": { - "@trust/webcrypto": "^0.9.2", - "@types/jest": "^28.1.4", - "@types/ledgerhq__hw-transport": "^4.21.3", - "@typescript-eslint/eslint-plugin": "^5.30.5", - "@typescript-eslint/parser": "^5.30.5", - "esbuild": "^0.15.16", - "eslint": "^8.19.0", - "eslint-plugin-jsdoc": "^39.3.3", - "jest": "^28.1.2", - "size-limit": "^8.1.0", - "text-encoding": "^0.7.0", - "ts-jest": "^28.0.5", - "tslint": "^5.20.0", - "typedoc": "^0.22.11", - "typescript": "^4.7.4", - "whatwg-fetch": "^3.0.0" - }, - "peerDependencies": { - "@dfinity/agent": "^0.14.1", - "@dfinity/identity": "^0.14.1", - "@dfinity/principal": "^0.14.1" - } - }, - "packages/identity-ledgerhq/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "packages/identity-ledgerhq/node_modules/glob": { - "version": "8.0.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz", - "integrity": "sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==", - "dev": true, - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^5.0.1", - "once": "^1.3.0" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "packages/identity-ledgerhq/node_modules/minimatch": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz", - "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==", - "dev": true, - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=10" - } - }, - "packages/identity-ledgerhq/node_modules/shiki": { - "version": "0.10.1", - "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.10.1.tgz", - "integrity": "sha512-VsY7QJVzU51j5o1+DguUd+6vmCmZ5v/6gYu4vyYAhzjuNQU6P/vmSy4uQaOhvje031qQMiW0d2BwgMH52vqMng==", - "dev": true, - "dependencies": { - "jsonc-parser": "^3.0.0", - "vscode-oniguruma": "^1.6.1", - "vscode-textmate": "5.2.0" - } - }, - "packages/identity-ledgerhq/node_modules/typedoc": { - "version": "0.22.18", - "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.18.tgz", - "integrity": "sha512-NK9RlLhRUGMvc6Rw5USEYgT4DVAUFk7IF7Q6MYfpJ88KnTZP7EneEa4RcP+tX1auAcz7QT1Iy0bUSZBYYHdoyA==", - "dev": true, - "dependencies": { - "glob": "^8.0.3", - "lunr": "^2.3.9", - "marked": "^4.0.16", - "minimatch": "^5.1.0", - "shiki": "^0.10.1" - }, - "bin": { - "typedoc": "bin/typedoc" - }, - "engines": { - "node": ">= 12.10.0" - }, - "peerDependencies": { - "typescript": "4.0.x || 4.1.x || 4.2.x || 4.3.x || 4.4.x || 4.5.x || 4.6.x || 4.7.x" - } - }, - "packages/identity-ledgerhq/node_modules/vscode-textmate": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-5.2.0.tgz", - "integrity": "sha512-Uw5ooOQxRASHgu6C7GVvUxisKXfSgW4oFlO+aa+PAkgmH89O3CXxEEzNRNtHSqtXFTl0nAC1uYj0GMSH27uwtQ==", - "dev": true - }, - "packages/identity/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "packages/identity/node_modules/glob": { - "version": "8.0.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz", - "integrity": "sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==", - "dev": true, - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^5.0.1", - "once": "^1.3.0" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "packages/identity/node_modules/minimatch": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz", - "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==", - "dev": true, - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=10" - } - }, - "packages/identity/node_modules/shiki": { - "version": "0.10.1", - "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.10.1.tgz", - "integrity": "sha512-VsY7QJVzU51j5o1+DguUd+6vmCmZ5v/6gYu4vyYAhzjuNQU6P/vmSy4uQaOhvje031qQMiW0d2BwgMH52vqMng==", - "dev": true, - "dependencies": { - "jsonc-parser": "^3.0.0", - "vscode-oniguruma": "^1.6.1", - "vscode-textmate": "5.2.0" - } - }, - "packages/identity/node_modules/typedoc": { + "packages/identity/node_modules/typedoc": { "version": "0.22.18", "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.18.tgz", "integrity": "sha512-NK9RlLhRUGMvc6Rw5USEYgT4DVAUFk7IF7Q6MYfpJ88KnTZP7EneEa4RcP+tX1auAcz7QT1Iy0bUSZBYYHdoyA==", @@ -21727,6 +21336,7 @@ "version": "7.19.0", "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.19.0.tgz", "integrity": "sha512-eR8Lo9hnDS7tqkO7NsV+mKvCmv5boaXFSZ70DnfhcgiEne8hv9oCEd36Klw74EtizEqLsy4YnW8UWwpBVolHZA==", + "dev": true, "requires": { "regenerator-runtime": "^0.13.4" } @@ -22148,86 +21758,7 @@ "@dfinity/authentication": { "version": "file:packages/authentication", "requires": { - "@trust/webcrypto": "^0.9.2", - "@types/jest": "^28.1.4", - "@typescript-eslint/eslint-plugin": "^5.30.5", - "@typescript-eslint/parser": "^5.30.5", - "esbuild": "^0.15.16", - "eslint": "^8.19.0", - "eslint-plugin-jsdoc": "^39.3.3", - "jest": "^28.1.2", - "size-limit": "^8.1.0", - "stream": "^0.0.2", - "text-encoding": "^0.7.0", - "ts-jest": "^28.0.5", - "ts-node": "^10.8.2", - "tslint": "^5.20.0", - "typedoc": "^0.22.11", - "typescript": "^4.7.4", - "whatwg-fetch": "^3.0.0" - }, - "dependencies": { - "brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "requires": { - "balanced-match": "^1.0.0" - } - }, - "glob": { - "version": "8.0.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz", - "integrity": "sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^5.0.1", - "once": "^1.3.0" - } - }, - "minimatch": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz", - "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==", - "dev": true, - "requires": { - "brace-expansion": "^2.0.1" - } - }, - "shiki": { - "version": "0.10.1", - "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.10.1.tgz", - "integrity": "sha512-VsY7QJVzU51j5o1+DguUd+6vmCmZ5v/6gYu4vyYAhzjuNQU6P/vmSy4uQaOhvje031qQMiW0d2BwgMH52vqMng==", - "dev": true, - "requires": { - "jsonc-parser": "^3.0.0", - "vscode-oniguruma": "^1.6.1", - "vscode-textmate": "5.2.0" - } - }, - "typedoc": { - "version": "0.22.18", - "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.18.tgz", - "integrity": "sha512-NK9RlLhRUGMvc6Rw5USEYgT4DVAUFk7IF7Q6MYfpJ88KnTZP7EneEa4RcP+tX1auAcz7QT1Iy0bUSZBYYHdoyA==", - "dev": true, - "requires": { - "glob": "^8.0.3", - "lunr": "^2.3.9", - "marked": "^4.0.16", - "minimatch": "^5.1.0", - "shiki": "^0.10.1" - } - }, - "vscode-textmate": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-5.2.0.tgz", - "integrity": "sha512-Uw5ooOQxRASHgu6C7GVvUxisKXfSgW4oFlO+aa+PAkgmH89O3CXxEEzNRNtHSqtXFTl0nAC1uYj0GMSH27uwtQ==", - "dev": true - } + "@dfinity/identity": "^0.14.1" } }, "@dfinity/bls-verify": { @@ -22419,95 +21950,6 @@ } } }, - "@dfinity/identity-ledgerhq": { - "version": "file:packages/identity-ledgerhq", - "requires": { - "@ledgerhq/hw-transport": "^5.49.0", - "@ledgerhq/hw-transport-webhid": "^5.49.0", - "@trust/webcrypto": "^0.9.2", - "@types/jest": "^28.1.4", - "@types/ledgerhq__hw-transport": "^4.21.3", - "@typescript-eslint/eslint-plugin": "^5.30.5", - "@typescript-eslint/parser": "^5.30.5", - "@zondax/ledger-dfinity": "0.2.1", - "buffer": "6.0.3", - "esbuild": "^0.15.16", - "eslint": "^8.19.0", - "eslint-plugin-jsdoc": "^39.3.3", - "jest": "^28.1.2", - "size-limit": "^8.1.0", - "text-encoding": "^0.7.0", - "ts-jest": "^28.0.5", - "ts-node": "^10.8.2", - "tslint": "^5.20.0", - "typedoc": "^0.22.11", - "typescript": "^4.7.4", - "whatwg-fetch": "^3.0.0" - }, - "dependencies": { - "brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "requires": { - "balanced-match": "^1.0.0" - } - }, - "glob": { - "version": "8.0.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz", - "integrity": "sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^5.0.1", - "once": "^1.3.0" - } - }, - "minimatch": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz", - "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==", - "dev": true, - "requires": { - "brace-expansion": "^2.0.1" - } - }, - "shiki": { - "version": "0.10.1", - "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.10.1.tgz", - "integrity": "sha512-VsY7QJVzU51j5o1+DguUd+6vmCmZ5v/6gYu4vyYAhzjuNQU6P/vmSy4uQaOhvje031qQMiW0d2BwgMH52vqMng==", - "dev": true, - "requires": { - "jsonc-parser": "^3.0.0", - "vscode-oniguruma": "^1.6.1", - "vscode-textmate": "5.2.0" - } - }, - "typedoc": { - "version": "0.22.18", - "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.18.tgz", - "integrity": "sha512-NK9RlLhRUGMvc6Rw5USEYgT4DVAUFk7IF7Q6MYfpJ88KnTZP7EneEa4RcP+tX1auAcz7QT1Iy0bUSZBYYHdoyA==", - "dev": true, - "requires": { - "glob": "^8.0.3", - "lunr": "^2.3.9", - "marked": "^4.0.16", - "minimatch": "^5.1.0", - "shiki": "^0.10.1" - } - }, - "vscode-textmate": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-5.2.0.tgz", - "integrity": "sha512-Uw5ooOQxRASHgu6C7GVvUxisKXfSgW4oFlO+aa+PAkgmH89O3CXxEEzNRNtHSqtXFTl0nAC1uYj0GMSH27uwtQ==", - "dev": true - } - } - }, "@dfinity/principal": { "version": "file:packages/principal", "requires": { @@ -23293,58 +22735,6 @@ "@jridgewell/sourcemap-codec": "^1.4.10" } }, - "@ledgerhq/devices": { - "version": "5.51.1", - "resolved": "https://registry.npmjs.org/@ledgerhq/devices/-/devices-5.51.1.tgz", - "integrity": "sha512-4w+P0VkbjzEXC7kv8T1GJ/9AVaP9I6uasMZ/JcdwZBS3qwvKo5A5z9uGhP5c7TvItzcmPb44b5Mw2kT+WjUuAA==", - "requires": { - "@ledgerhq/errors": "^5.50.0", - "@ledgerhq/logs": "^5.50.0", - "rxjs": "6", - "semver": "^7.3.5" - }, - "dependencies": { - "semver": { - "version": "7.3.7", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", - "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", - "requires": { - "lru-cache": "^6.0.0" - } - } - } - }, - "@ledgerhq/errors": { - "version": "5.50.0", - "resolved": "https://registry.npmjs.org/@ledgerhq/errors/-/errors-5.50.0.tgz", - "integrity": "sha512-gu6aJ/BHuRlpU7kgVpy2vcYk6atjB4iauP2ymF7Gk0ez0Y/6VSMVSJvubeEQN+IV60+OBK0JgeIZG7OiHaw8ow==" - }, - "@ledgerhq/hw-transport": { - "version": "5.51.1", - "resolved": "https://registry.npmjs.org/@ledgerhq/hw-transport/-/hw-transport-5.51.1.tgz", - "integrity": "sha512-6wDYdbWrw9VwHIcoDnqWBaDFyviyjZWv6H9vz9Vyhe4Qd7TIFmbTl/eWs6hZvtZBza9K8y7zD8ChHwRI4s9tSw==", - "requires": { - "@ledgerhq/devices": "^5.51.1", - "@ledgerhq/errors": "^5.50.0", - "events": "^3.3.0" - } - }, - "@ledgerhq/hw-transport-webhid": { - "version": "5.51.1", - "resolved": "https://registry.npmjs.org/@ledgerhq/hw-transport-webhid/-/hw-transport-webhid-5.51.1.tgz", - "integrity": "sha512-w/2qSU0vwFY+D/4ucuYRViO7iS3Uuxmj9sI/Iiqkoiax9Xppb0/6H5m3ffKv6iPMmRYbgwCgXorqx4SLLSD8Kg==", - "requires": { - "@ledgerhq/devices": "^5.51.1", - "@ledgerhq/errors": "^5.50.0", - "@ledgerhq/hw-transport": "^5.51.1", - "@ledgerhq/logs": "^5.50.0" - } - }, - "@ledgerhq/logs": { - "version": "5.50.0", - "resolved": "https://registry.npmjs.org/@ledgerhq/logs/-/logs-5.50.0.tgz", - "integrity": "sha512-swKHYCOZUGyVt4ge0u8a7AwNcA//h4nx5wIi0sruGye1IJ5Cva0GyK9L2/WdX+kWVTKp92ZiEo1df31lrWGPgA==" - }, "@leichtgewicht/ip-codec": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/@leichtgewicht/ip-codec/-/ip-codec-2.0.4.tgz", @@ -24918,60 +24308,6 @@ "debug": "^4.3.1" } }, - "@protobufjs/aspromise": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz", - "integrity": "sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==" - }, - "@protobufjs/base64": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@protobufjs/base64/-/base64-1.1.2.tgz", - "integrity": "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==" - }, - "@protobufjs/codegen": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@protobufjs/codegen/-/codegen-2.0.4.tgz", - "integrity": "sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==" - }, - "@protobufjs/eventemitter": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz", - "integrity": "sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q==" - }, - "@protobufjs/fetch": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@protobufjs/fetch/-/fetch-1.1.0.tgz", - "integrity": "sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ==", - "requires": { - "@protobufjs/aspromise": "^1.1.1", - "@protobufjs/inquire": "^1.1.0" - } - }, - "@protobufjs/float": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@protobufjs/float/-/float-1.0.2.tgz", - "integrity": "sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==" - }, - "@protobufjs/inquire": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@protobufjs/inquire/-/inquire-1.1.0.tgz", - "integrity": "sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q==" - }, - "@protobufjs/path": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@protobufjs/path/-/path-1.1.2.tgz", - "integrity": "sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==" - }, - "@protobufjs/pool": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@protobufjs/pool/-/pool-1.1.0.tgz", - "integrity": "sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==" - }, - "@protobufjs/utf8": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz", - "integrity": "sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==" - }, "@sinclair/typebox": { "version": "0.24.35", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.24.35.tgz", @@ -25329,19 +24665,6 @@ "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==" }, - "@types/ledgerhq__hw-transport": { - "version": "4.21.4", - "resolved": "https://registry.npmjs.org/@types/ledgerhq__hw-transport/-/ledgerhq__hw-transport-4.21.4.tgz", - "integrity": "sha512-vep+6yZnGv6owAthIY0w3f72w4dJIb4+yE5PCHveInTlZE9wukvU6Wc5Eig0OUUxcdhTazzeZx1xUaNVLqyQSg==", - "requires": { - "@types/node": "*" - } - }, - "@types/long": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.2.tgz", - "integrity": "sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA==" - }, "@types/mime": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/@types/mime/-/mime-3.0.1.tgz", @@ -25787,16 +25110,6 @@ "resolved": "https://registry.npmjs.org/@xtuc/long/-/long-4.2.2.tgz", "integrity": "sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==" }, - "@zondax/ledger-dfinity": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/@zondax/ledger-dfinity/-/ledger-dfinity-0.2.1.tgz", - "integrity": "sha512-QrVYh/BnupGQfK1BoviS9pmYm+4lR/VyzF0jRT4WAZuPn51Kgc/X7Iseh+VCZ9AgrgBve4fZJVDujRktKo/gnA==", - "requires": { - "@babel/runtime": "^7.13.9", - "@ledgerhq/hw-transport": "^5.45.0", - "@types/ledgerhq__hw-transport": "^4.21.3" - } - }, "@zxing/text-encoding": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/@zxing/text-encoding/-/text-encoding-0.9.0.tgz", @@ -26678,6 +25991,7 @@ "version": "6.0.3", "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "dev": true, "requires": { "base64-js": "^1.3.1", "ieee754": "^1.2.1" @@ -29733,30 +29047,6 @@ "integrity": "sha512-xs7/chUH/CKdOCs7Zy0Aev9e/dKOMZf3K1Az1nar3tzlv0jfqnYtu235bstsWTmXOR0EfINrPa97yy4Lz6RiKw==", "dev": true }, - "ic-agent-ledgerhq-app": { - "version": "file:demos/ledgerhq", - "requires": { - "@dfinity/agent": "^0.14.1", - "@dfinity/authentication": "^0.14.1", - "@dfinity/identity": "^0.14.1", - "@dfinity/identity-ledgerhq": "^0.14.1", - "@dfinity/principal": "^0.14.1", - "assert": "^2.0.0", - "buffer": "^6.0.3", - "esbuild": "^0.15.16", - "events": "^3.2.0", - "html-webpack-plugin": "^5.1.0", - "process": "^0.11.10", - "protobufjs": "^6.10.2", - "size-limit": "^8.1.0", - "stream-browserify": "^3.0.0", - "ts-node": "^10.8.2", - "util": "^0.12.3", - "webpack": "^5.24.1", - "webpack-cli": "^4.5.0", - "webpack-dev-server": "^4.0.0-beta.0" - } - }, "ic-agent-sample-javascript-app": { "version": "file:demos/sample-javascript", "requires": { @@ -29765,6 +29055,7 @@ "@dfinity/identity": "^0.14.1", "@dfinity/principal": "^0.14.1", "assert": "^2.0.0", + "buffer": "*", "esbuild": "^0.15.16", "events": "^3.2.0", "html-webpack-plugin": "^5.1.0", @@ -31815,11 +31106,6 @@ } } }, - "long": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", - "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" - }, "lower-case": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz", @@ -33309,26 +32595,6 @@ "sisteransi": "^1.0.5" } }, - "protobufjs": { - "version": "6.11.3", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.11.3.tgz", - "integrity": "sha512-xL96WDdCZYdU7Slin569tFX712BxsxslWwAfAhCYjQKGTq7dAU91Lomy6nLLhh/dyGhk/YH4TwTSRxTzhuHyZg==", - "requires": { - "@protobufjs/aspromise": "^1.1.2", - "@protobufjs/base64": "^1.1.2", - "@protobufjs/codegen": "^2.0.4", - "@protobufjs/eventemitter": "^1.1.0", - "@protobufjs/fetch": "^1.1.0", - "@protobufjs/float": "^1.0.2", - "@protobufjs/inquire": "^1.1.0", - "@protobufjs/path": "^1.1.2", - "@protobufjs/pool": "^1.1.0", - "@protobufjs/utf8": "^1.1.0", - "@types/long": "^4.0.1", - "@types/node": ">=13.7.0", - "long": "^4.0.0" - } - }, "proxy-addr": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", @@ -33628,7 +32894,8 @@ "regenerator-runtime": { "version": "0.13.9", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz", - "integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==" + "integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==", + "dev": true }, "regenerator-transform": { "version": "0.15.0", @@ -33858,21 +33125,6 @@ "integrity": "sha512-Arc4hUN896vjkqCYrUXquBFtRZdv1PfLbTYP71efP6butxyQ0kWpiNJyAgsxscmQg1cqvHY32/UCBzXedTpU2g==", "dev": true }, - "rxjs": { - "version": "6.6.7", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz", - "integrity": "sha512-hTdwr+7yYNIT5n4AMYp85KA6yw2Va0FLa3Rguvbpa4W3I5xynaBZo41cM3XM+4Q6fRMj3sBYIR1VAmZMXYJvRQ==", - "requires": { - "tslib": "^1.9.0" - }, - "dependencies": { - "tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" - } - } - }, "safari-14-idb-fix": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/safari-14-idb-fix/-/safari-14-idb-fix-3.0.0.tgz", diff --git a/package.json b/package.json index 830368436..75e90e23b 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,6 @@ "packages/agent", "packages/bls-verify", "packages/identity", - "packages/identity-ledgerhq", - "packages/authentication", "packages/auth-client", "packages/assets", "e2e/node", @@ -95,11 +93,6 @@ "path": "./packages/assets/dist/index.js", "limit": "100 kB" }, - { - "name": "@dfinity/authentication", - "path": "./packages/authentication/dist/index.js", - "limit": "320 kB" - }, { "name": "@dfinity/identity", "path": "./packages/identity/dist/index.js", diff --git a/packages/agent/src/auth.ts b/packages/agent/src/auth.ts index 72fc0c967..85620bd37 100644 --- a/packages/agent/src/auth.ts +++ b/packages/agent/src/auth.ts @@ -132,7 +132,7 @@ export interface PublicKeyIdentityDescriptor { export type IdentityDescriptor = AnonymousIdentityDescriptor | PublicKeyIdentityDescriptor; /** - * Create an IdentityDescriptor from a @dfinity/authentication Identity + * Create an IdentityDescriptor from a @dfinity/identity Identity * @param identity - identity describe in returned descriptor */ export function createIdentityDescriptor( diff --git a/packages/auth-client/README.md b/packages/auth-client/README.md index c1cac2c1c..1b8b25dd5 100644 --- a/packages/auth-client/README.md +++ b/packages/auth-client/README.md @@ -139,5 +139,5 @@ In this code, we create an `authClient` with an idle timeout of 30 minutes. When After the user logs in, we can set the new identity in the actor without reloading the page. -Note: depends on [@dfinity/agent](https://www.npmjs.com/package/@dfinity/agent), [@dfinity/authentication](https://www.npmjs.com/package/@dfinity/authentication), and +Note: depends on [@dfinity/agent](https://www.npmjs.com/package/@dfinity/agent) and [@dfinity/identity](https://www.npmjs.com/package/@dfinity/identity). diff --git a/packages/auth-client/jest.config.ts b/packages/auth-client/jest.config.ts index ef75088cc..9a2ec4387 100644 --- a/packages/auth-client/jest.config.ts +++ b/packages/auth-client/jest.config.ts @@ -12,7 +12,6 @@ module.exports = { '^.+\\.ts$': 'ts-jest', }, collectCoverageFrom: ['src/**/*.{ts,tsx}'], - name: packageName, displayName: packageName, globals: { window: {}, diff --git a/packages/auth-client/package.json b/packages/auth-client/package.json index 9a059bb60..834a131b0 100644 --- a/packages/auth-client/package.json +++ b/packages/auth-client/package.json @@ -48,7 +48,6 @@ }, "peerDependencies": { "@dfinity/agent": "^0.14.1", - "@dfinity/authentication": "^0.14.1", "@dfinity/identity": "^0.14.1", "@dfinity/principal": "^0.14.1" }, diff --git a/packages/auth-client/src/index.ts b/packages/auth-client/src/index.ts index 8625e9cc1..1c49f2341 100644 --- a/packages/auth-client/src/index.ts +++ b/packages/auth-client/src/index.ts @@ -6,10 +6,10 @@ import { Signature, SignIdentity, } from '@dfinity/agent'; -import { isDelegationValid } from '@dfinity/authentication'; import { Delegation, DelegationChain, + isDelegationValid, DelegationIdentity, Ed25519KeyIdentity, } from '@dfinity/identity'; diff --git a/packages/authentication/.gitignore b/packages/authentication/.gitignore deleted file mode 100644 index 40ba0014d..000000000 --- a/packages/authentication/.gitignore +++ /dev/null @@ -1,17 +0,0 @@ -build_info.json -node_modules/ -dist/ -**/*.js -**/*.js.map -**/*.d.ts - -# generated docs -/docs/reference - -# Cannot ignore .d.ts files in types/ -!types/**/*.d.ts - -# Cannot ignore setup files for webpack and jest, which are still JavaScript. -!webpack.config.js -!jest.config.js -!test-setup.js diff --git a/packages/authentication/.npmignore b/packages/authentication/.npmignore deleted file mode 100644 index eb725972f..000000000 --- a/packages/authentication/.npmignore +++ /dev/null @@ -1,11 +0,0 @@ -# We work with a safelist here, so block everything that's not permitted, and add packages -# that are. -** - -!lib/** -!types/**/*.d.ts -!package.json -!README.md - -# The following line further removes all test files (which matches .js and .d.ts). -lib/**/*.test.* diff --git a/packages/authentication/README.md b/packages/authentication/README.md index 12bb15390..571b626cb 100644 --- a/packages/authentication/README.md +++ b/packages/authentication/README.md @@ -1,5 +1,8 @@ # @dfinity/authentication +**Warning** +this package is deprecated + JavaScript and TypeScript library to support manage Identities and enable simple Web Authentication flows for applications on the [Internet Computer](https://dfinity.org/) Visit the [Dfinity Forum](https://forum.dfinity.org/) and [SDK Documentation](https://sdk.dfinity.org/docs/index.html) for more information and support building on the Internet Computer. diff --git a/packages/authentication/docs/how-to-add-authentication-to-canister-ui.md b/packages/authentication/docs/how-to-add-authentication-to-canister-ui.md deleted file mode 100644 index 265aa55ab..000000000 --- a/packages/authentication/docs/how-to-add-authentication-to-canister-ui.md +++ /dev/null @@ -1,84 +0,0 @@ -# How to Add Authentication to a Canister User Interface - -We'll start from a fresh project. - -1. Create a new `dfx` project - ``` - dfx new authentication_docs_demo - cd authentication_docs_demo - ``` -1. Install `@dfinity/authentication` npm package - ``` - npm install @dfinity/authentication@0.0.0-pre.identity-provider.9 - ``` -1. `import { authenticator } from "@dfinity/authentication";` -1. To request that the end-user authenticate, call `authenticator.sendAuthenticationRequest` - ```javascript - import { authenticator, Ed25519KeyIdentity } from '@dfinity/authentication'; - if (confirm('Do you want to Authenticate?')) { - login(); - } - function readSession(session) { - const stored = localStorage.getItem('session'); - if (!stored) { - return null; - } - try { - const parsed = JSON.parse(); - return { - ...parsed, - identity: Ed25519KeyIdentity.fromJSON(parsed.identity), - }; - } catch (error) { - throw error; - } - } - function writeSession(session) { - localStorage.setItem('session', JSON.stringify(session)); - } - function login() { - const entropy = crypto.getRandomValues(new Uint8Array(32)); - const sessionIdentity = Ed25519KeyIdentity.generate(entropy); - const session = { - authenticationResponse: undefined, - identity: sessionIdentity, - }; - writeSession(session); - authenticator.sendAuthenticationRequest({ - scope: [], - session, - }); - } - ``` -1. After the authentication, the end-user will be redirected back to your page with an `access_token` in the URL query string. Call `authenticator.useSession` to (try to) process it. - - ```javascript - const session = readSession(); - if (session.authenticationResponse) { - authenticator.useSession(session); - } else { - if (/access_token/.test(location.search)) { - writeSession({ - ...session, - authenticationResponse: location.toString(), - }); - authenticator.useSession(readSession()); - } - } - ``` - -1. If your DOM element needs to know about authenticated identities: - ```javascript - import { IdentityRequestedEvent } from '@dfinity/authentication'; - document.body.dispatchEvent( - IdentityRequestedEvent({ - bubbles: true, - compose: true, // use this inside shadow roots - onIdentity: identity => { - console.log('new @dfinity/authentication identity', identity); - }, - }), - ); - ``` - -## Example Apps diff --git a/packages/authentication/docs/ic-id-protocol.md b/packages/authentication/docs/ic-id-protocol.md deleted file mode 100644 index 28f7b84f6..000000000 --- a/packages/authentication/docs/ic-id-protocol.md +++ /dev/null @@ -1,368 +0,0 @@ -# Internet Computer Identity Protocol - -aka ic-id-protocol - -## Abstract - -ic-id-protocol describes how Internet Computer Canisters can interact with an Identity Provider implementing this protocol in order to enable authentication, sessions, and thence personalization of the Internet Computer Canisters they develop and publish to the Internet Computers for end-users to make use of. - -This protocol is not novel and strives to be a conventional example of a system using the [The OAuth 2.0 Authorization Framework][1] (i.e. 'OAuth2'). This is to maximize compatability with existing developer knowledge and tools. Where OAuth2 is not sufficiently perscriptive to drive implementation (it's a framework, not a protocol), we will prefer to leverage existing terms defined in [OpenID Connect Core 1.0][2] instead of defining new duplicative terms. - -## Introduction - -The ic-id-protocol can be used by a software component to: - -- request that the end-user provide your app with proof of ownership over a cryptographic keyPair -- request an AuthenticationResponse whose contents can be used to make Internet Computer Protocol requests with [Authentication](https://sdk.dfinity.org/docs/interface-spec/#authentication), including requesting an access token that only has the capability of interacting with an enuemrated set of Canisters. - -System components communicate in this protocol by passing messages via HTTP. System components and the end-user communicate using a web user-agent's HTTP requests and responses. - -### Terms - -- Relying Party (aka 'RP'): see https://en.wikipedia.org/wiki/Relying_party - -- Identity Provider (aka 'IDP'): see https://en.wikipedia.org/wiki/Identity_provider - -- Session:
    Continuous period of time during which an End-User accesses a Relying Party relying on the Authentication of the End-User performed by the OpenID Provider.
    --https://openid.net/specs/openid-connect-session-1_0.html#Terminology - -- Session KeyPair: keyPair that identifies a Session - -[1]: https://tools.ietf.org/html/rfc6749 -[2]: https://openid.net/specs/openid-connect-core-1_0.html - -### Summary - -At a high level, this is how an RP requests end-user Authentication using ic-id-protocol. - -- Assumption: end-user is visiting an RP for the first time -- A Relying Party (aka 'RP') (e.g. an IC Canister) creates a new ed25519 keyPair to identify an authentication Session of end-user interaction with the RP, and stores this Session KeyPair somewhere durable. -- RP builds AuthenticationRequest whose `login_hint` corresponds to the Session KeyPair Public Key -- RP sends AuthenticationRequest to IDP via end-user's web user-agent -- end-user Authenticates with RP, consents to delegate limitd authority to the Session -- IDP sends AuthenticationResponse to RP via end-user's web user-agent -- RP receives AuthenticationResponse access*token, decodes it, and combines the contents with the Session KeyPair \_Private* Key in order to make signed, [Authenticated](https://sdk.dfinity.org/docs/interface-spec/#authentication) Internet Computer requests. - -See below "Relation to OAuth2" for a sequence diagram that corresponds to this story. - -## Authentication - -### Relation to OAuth2 - -The overall authentication process is most similar to the OAuth2 Implicit Grant Flow. - -> The implicit grant is a simplified authorization code flow optimized -> for clients implemented in a browser using a scripting language such -> as JavaScript. In the implicit flow, instead of issuing the client -> an authorization code, the client is issued an access token directly -> (as the result of the resource owner authorization). The grant type -> is implicit, as no intermediate credentials (such as an authorization -> code) are issued (and later used to obtain an access token). -> -> -- https://tools.ietf.org/html/rfc6749#section-1.3.2 - -From [OAuth2#4.2 Implicit Grant](https://tools.ietf.org/html/rfc6749#section-4.2): - -``` -The implicit grant type is used to obtain access tokens (it does not -support the issuance of refresh tokens) and is optimized for public -clients known to operate a particular redirection URI. These clients -are typically implemented in a browser using a scripting language -such as JavaScript. - -Since this is a redirection-based flow, the client must be capable of -interacting with the resource owner's user-agent (typically a web -browser) and capable of receiving incoming requests (via redirection) -from the authorization server. - -Unlike the authorization code grant type, in which the client makes -separate requests for authorization and for an access token, the -client receives the access token as the result of the authorization -request. - -The implicit grant type does not include client authentication, and -relies on the presence of the resource owner and the registration of -the redirection URI. Because the access token is encoded into the -redirection URI, it may be exposed to the resource owner and other -applications residing on the same device. - - +----------+ - | Resource | - | Owner | - | | - +----------+ - ^ - | - (B) - +----|-----+ Client Identifier +---------------+ - | -+----(A)-- & Redirection URI --->| | - | User- | | Authorization | - | Agent -|----(B)-- User authenticates -->| Server | - | | | | - | |<---(C)--- Redirection URI ----<| | - | | with Access Token +---------------+ - | | in Fragment - | | +---------------+ - | |----(D)--- Redirection URI ---->| Web-Hosted | - | | without Fragment | Client | - | | | Resource | - | (F) |<---(E)------- Script ---------<| | - | | +---------------+ - +-|--------+ - | | - (A) (G) Access Token - | | - ^ v - +---------+ - | | - | Client | - | | - +---------+ - - Note: The lines illustrating steps (A) and (B) are broken into two - parts as they pass through the user-agent. - - Figure 4: Implicit Grant Flow - - The flow illustrated in Figure 4 includes the following steps: - - (A) The client initiates the flow by directing the resource owner's - user-agent to the authorization endpoint. The client includes - its client identifier, requested scope, local state, and a - redirection URI to which the authorization server will send the - user-agent back once access is granted (or denied). - - (B) The authorization server authenticates the resource owner (via - the user-agent) and establishes whether the resource owner - grants or denies the client's access request. - - (C) Assuming the resource owner grants access, the authorization - server redirects the user-agent back to the client using the - redirection URI provided earlier. The redirection URI includes - the access token in the URI fragment. - - (D) The user-agent follows the redirection instructions by making a - request to the web-hosted client resource (which does not - include the fragment per [RFC2616]). The user-agent retains the - fragment information locally. - - (E) The web-hosted client resource returns a web page (typically an - HTML document with an embedded script) capable of accessing the - full redirection URI including the fragment retained by the - user-agent, and extracting the access token (and other - parameters) contained in the fragment. - - (F) The user-agent executes the script provided by the web-hosted - client resource locally, which extracts the access token. - - (G) The user-agent passes the access token to the client. - - See Sections 1.3.2 and 9 for background on using the implicit grant. - See Sections 10.3 and 10.16 for important security considerations - when using the implicit grant. -``` - -## Messages - -### AuthenticationRequest - -Similar to: - -- https://tools.ietf.org/html/rfc6749#section-4.2.1 - -Differences from the above: - -- `redirect_uri` is required -- `scope` is required, and includes extra documentation about the interpretation of this space-delimited-string parameter for requesting authorization for scoped capabilities to specific Internet Computer Canisters on behalf of the end-user (access tokens authorized to interact with all canisters are not supported yet to maximize end-user safety) - -Prefer terms defined here before defining new ones: - -- https://openid.net/specs/openid-connect-core-1_0.html#ImplicitAuthRequest - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    NamespaceNameRequiredDefinitionExamples
    OAuth2response_typeValue must be set to "token"
    token
    OAuth2client_id - Unique identifier of the RP requesting authentication. If the RP is an internet computer canister, use a unique identifier like https://{canister}.ic0.app -
    https://agujh-y3paa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q.ic0.app/
    OAuth2redirect_uri -

    URI that the IDP should send the AuthenticationResponse to. See OAuth2#3.1.2 Redirection Endpoint

    -

    - If the RP is an Internet Computer Canister, you can just use the Canister URL. You can set the redirect_uri path component (e.g. `/` or `/.well-known/ic-id-protocol/redirect_uri`) to anything you want, as long as your canister handles the response. -

    -
    https://agujh-y3paa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q.ic0.app/.well-known/ic-id-protocol/redirect_uri
    OIDClogin_hint - Public Key of a Session KeyPair controlled by the RP. This Public Key will be delegated to for a limited period of time, and with authorization to control only an enumerated set of canisters. The resulting delegation will be encoded in the AuthenticationResponse's access_token. -
    OAuth2state -
    -

    -

    An opaque value used by the client to maintain - state between the request and callback. The authorization - server includes this value when redirecting the user-agent back - to the client. The parameter SHOULD be used for preventing - cross-site request forgery as described in Section 10.12 [of OAuth2].
    -

    -

    - One additional common use case for state is to encode the intended destination of the end-user within the RP. This can be used by the RP when handling the AuthenticationResponse. After otherwise fully receiving the AuthenticationResponse, the RP can parse the intended destination out of the echoed state, then redirect the user to their destination with an authentication session. This pattern is described here. -

    -
    -
    -
      -
    • destination=/rp-destination-path
    • -
    • gibberish-opqaue-string
    • -
    -
    - -### AuthenticationResponseSuccess - -Similar to: - -- https://tools.ietf.org/html/rfc6749#section-4.2.2 - -Differences from the above: - -- none so far - -Prefer terms defined here before defining new ones: - -- https://openid.net/specs/openid-connect-core-1_0.html#ImplicitAuthResponse - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    NamespaceNameRequiredDefinitionExamples
    OAuth2access_tokenThe access token issued by the authorization server.
    OAuth2token_typeThis will be the string "Bearer"Bearer
    OAuth2expires_in -
    - The lifetime in seconds of the access token. For - example, the value "3600" denotes that the access token will - expire in one hour from the time the response was generated. - If omitted, the authorization server SHOULD provide the - expiration time via other means or document the default value. -
    - --OAuth2 -
    OAuth2state - REQUIRED if the "state" parameter was present in the client - authorization request. The exact value received from the - client. -
    - -### AuthenticationResponseError - -See [OAuth2#4.2.2.1 Error Response](https://tools.ietf.org/html/rfc6749#section-4.2.2.1) for the parameters of the AuthenticationErrorResponse. - -#### Error Kinds - -Errors that are idiosyncratic to the ic-id-protocol will have distinct `error_uri` parameter values. - -The following table is a registry of these errors: - - - - - - - - -
    error_urierror_description example
    - -(the table is empty) - -## Known Implementations - -Identity Provider - -- @dfinity/identity-provider - - test environment (no SLA): https://identity-provider.sdk-test.dfinity.network/ - not yet fully compliant, but soon will be - - source: https://github.com/dfinity/agent-js/tree/identity-provider/2021-01-04/packages/identity-provider - -Relying Party - -- @dfinity/identity-provider-rp-demo - - test environment (no SLA): https://identity-provider.sdk-test.dfinity.network/relying-party-demo - - source: https://github.com/dfinity/agent-js/tree/identity-provider/2021-01-04/packages/identity-provider/src/relying-party-demo -- webauthn_tester: - - test environment (no SLA): https://pbh67-jaaaa-aaaab-aaavq-cai.ic0.app/ - - source: https://github.com/dfinity/webauthn_tester -- ic-whoami: - - source: https://github.com/gobengo/ic-whoami - -Other Tools - -- none yet - -## Acknowledgements - -- https://dfinity.org -- https://cseweb.ucsd.edu/~btackmann/ - Researcher for broader Internet Computer Authentication architecture, of which this is a small enabling protocol. Thanks for your patience, education, hard work, and for meeting at odd hours so many times due to time zone differences. diff --git a/packages/authentication/jest.config.ts b/packages/authentication/jest.config.ts deleted file mode 100644 index 1a9ad56f4..000000000 --- a/packages/authentication/jest.config.ts +++ /dev/null @@ -1,18 +0,0 @@ -import baseConfig from '../../jest.config.base'; -const packageName = 'authentication'; - -module.exports = { - ...baseConfig, - roots: [`/packages/${packageName}`], - bail: false, - moduleDirectories: ['node_modules'], - modulePaths: [`/packages/${packageName}/src/`], - setupFiles: [`/packages/${packageName}/test-setup.ts`], - transform: { - '^.+\\.ts$': 'ts-jest', - }, - collectCoverageFrom: ['src/**/*.{ts,tsx}'], - name: packageName, - displayName: packageName, - rootDir: '../..', -}; diff --git a/packages/authentication/package.json b/packages/authentication/package.json index 4fbdac934..4cb77c242 100644 --- a/packages/authentication/package.json +++ b/packages/authentication/package.json @@ -4,79 +4,13 @@ "author": "DFINITY Stiftung ", "license": "Apache-2.0", "description": "JavaScript and TypeScript library to manage identity and authentication with the Internet Computer", - "homepage": "https://smartcontracts.org", - "repository": { - "type": "git", - "url": "https://github.com/dfinity/agent-js.git", - "directory": "packages/authentication" - }, - "bugs": { - "url": "https://github.com/dfinity/agent-js/issues" - }, - "keywords": [ - "internet computer", - "ic", - "dfinity", - "canister", - "webauthn", - "identity", - "principal", - "authentication", - "dfx", - "candid", - "motoko", - "javascript", - "typescript", - "blockchain", - "crypto", - "distributed", - "api" - ], + "deprecated": "This package has been deprecated. isDelegationValid has been migrated to @dfinity/identity", "main": "./lib/cjs/index.js", - "module": "./lib/esm/index.js", - "unpkg": "./lib/esm/index", "scripts": { - "build": "tsc -b && tsc -p tsconfig-cjs.json", - "bundle": "esbuild --bundle src/index.ts --outfile=dist/index.js", - "size-limit": "size-limit", - "lint": "eslint 'src' --ext '.js,.jsx,.ts,.tsx'", - "lint:fix": "npm run lint -- --fix", - "make:docs/reference": "typedoc src/index.ts --out ../../docs/generated/authentication --excludeInternal", - "release": "npm publish", - "test": "jest", - "test:coverage": "jest --verbose --collectCoverage" - }, - "peerDependencies": { - "@dfinity/agent": "^0.14.1", - "@dfinity/identity": "^0.14.1", - "@dfinity/principal": "^0.14.1" - }, - "devDependencies": { - "@trust/webcrypto": "^0.9.2", - "@types/jest": "^28.1.4", - "@typescript-eslint/eslint-plugin": "^5.30.5", - "@typescript-eslint/parser": "^5.30.5", - "esbuild": "^0.15.16", - "eslint": "^8.19.0", - "eslint-plugin-jsdoc": "^39.3.3", - "jest": "^28.1.2", - "size-limit": "^8.1.0", - "text-encoding": "^0.7.0", - "ts-jest": "^28.0.5", - "ts-node": "^10.8.2", - "tslint": "^5.20.0", - "typedoc": "^0.22.11", - "typescript": "^4.7.4", - "whatwg-fetch": "^3.0.0" + "build": "", + "test": "" }, "dependencies": { - "stream": "^0.0.2" - }, - "size-limit": [ - { - "path": "./dist/index.js", - "limit": "380 kB", - "webpack": false - } - ] + "@dfinity/identity": "^0.14.1" + } } diff --git a/packages/authentication/src/index.test.ts b/packages/authentication/src/index.test.ts deleted file mode 100644 index ceec3fbe4..000000000 --- a/packages/authentication/src/index.test.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Need this to setup the proper ArrayBuffer type (otherwise in Jest ArrayBuffer isn't - * an instance of ArrayBuffer). - * @jest-environment node - */ -import { DelegationChain, Ed25519KeyIdentity } from '@dfinity/identity'; -import { isDelegationValid } from './index'; - -describe('isDelegationValid', () => { - test('checks expiration', async () => { - const root = Ed25519KeyIdentity.generate(); - const session = Ed25519KeyIdentity.generate(); - const future = new Date(Date.now() + 1000); - const past = new Date(Date.now() - 1000); - - // Create a valid delegation. - expect( - isDelegationValid(await DelegationChain.create(root, session.getPublicKey(), future)), - ).toBe(true); - expect( - isDelegationValid(await DelegationChain.create(root, session.getPublicKey(), past)), - ).toBe(false); - }); -}); diff --git a/packages/authentication/src/index.ts b/packages/authentication/src/index.ts deleted file mode 100644 index ec16d8e19..000000000 --- a/packages/authentication/src/index.ts +++ /dev/null @@ -1,183 +0,0 @@ -import { PublicKey } from '@dfinity/agent'; -import { DelegationChain } from '@dfinity/identity'; -import { Principal } from '@dfinity/principal'; - -const DEFAULT_IDENTITY_PROVIDER_URL = 'https://auth.ic0.app/authorize'; - -function toHexString(bytes: ArrayBuffer): string { - return new Uint8Array(bytes).reduce((str, byte) => str + byte.toString(16).padStart(2, '0'), ''); -} - -function _getDefaultLocation() { - if (typeof window === 'undefined') { - throw new Error('Could not find default location.'); - } - - return window.location.origin; -} - -/** - * Options for {@link createAuthenticationRequestUrl}. All these options may be limited - * further by the identity provider, or an error can happen. - */ -export interface CreateUrlOptions { - /** - * The public key to delegate to. This should be the public key of the session key. - */ - publicKey: PublicKey; - - /** - * The scope of the delegation. This must contain at least one key and a maximum - * of four. This is validated in {@link createAuthenticationRequestUrl} but also - * will be validated as part of the identity provider. - */ - scope: Array; - - /** - * The URI to redirect to, after authentication. By default, `window.location.origin`. - */ - redirectUri?: string; - - /** - * The URL base to use for the identity provider. - * By default, this is "https://auth.ic0.app/authorize". - */ - identityProvider?: URL | string; -} - -/** - * List of things to check for a delegation chain validity. - */ -export interface DelegationValidChecks { - /** - * Check that the scope is amongst the scopes that this delegation has access to. - */ - scope?: Principal | string | Array; -} - -/** - * A parsed access token. - */ -export type AccessToken = string & { _BRAND: 'access_token' }; - -/** - * Create a URL that can be used to redirect the browser to request authentication (e.g. using - * the authentication provider). Will throw if some options are invalid. - * @param options An option with all options for the authentication request. - */ -export function createAuthenticationRequestUrl(options: CreateUrlOptions): URL { - const url = new URL(options.identityProvider?.toString() ?? DEFAULT_IDENTITY_PROVIDER_URL); - url.searchParams.set('response_type', 'token'); - url.searchParams.set('login_hint', toHexString(options.publicKey.toDer())); - url.searchParams.set('redirect_uri', options.redirectUri ?? _getDefaultLocation()); - url.searchParams.set( - 'scope', - options.scope - .map(p => { - if (typeof p === 'string') { - return Principal.fromText(p); - } else { - return p; - } - }) - .map(p => p.toString()) - .join(' '), - ); - url.searchParams.set('state', ''); - - return url; -} - -/** - * Returns an AccessToken from the Window object. This cannot be used in Node, instead use - * the {@link getAccessTokenFromURL} function. - * - * An access token is needed to create a DelegationChain object. - */ -export function getAccessTokenFromWindow(): AccessToken | null { - if (typeof window === 'undefined') { - return null; - } - return getAccessTokenFromURL(new URL(window.location.href)); -} - -/** - * Analyze a URL and try to extract an AccessToken from it. - * @param url The URL to look into. - */ -export function getAccessTokenFromURL(url: URL | string): AccessToken | null { - // Remove the `#` at the start. - const hashParams = new URLSearchParams(new URL(url.toString()).hash.substr(1)); - return hashParams.get('access_token') as AccessToken | null; -} - -/** - * Create a DelegationChain from an AccessToken extracted from a redirect URL. - * @param accessToken The access token extracted from a redirect URL. - */ -export function createDelegationChainFromAccessToken(accessToken: AccessToken): DelegationChain { - // Transform the HEXADECIMAL string into the JSON it represents. - if (/[^0-9a-fA-F]/.test(accessToken) || accessToken.length % 2) { - throw new Error('Invalid hexadecimal string for accessToken.'); - } - const chainJson = [...accessToken] - .reduce((acc, curr, i) => { - // tslint:disable-next-line:no-bitwise - acc[(i / 2) | 0] = (acc[(i / 2) | 0] || '') + curr; - return acc; - }, [] as string[]) - .map(x => Number.parseInt(x, 16)) - .map(x => String.fromCharCode(x)) - .join(''); - - return DelegationChain.fromJSON(chainJson); -} - -/** - * Analyze a DelegationChain and validate that it's valid, ie. not expired and apply to the - * scope. - * @param chain The chain to validate. - * @param checks Various checks to validate on the chain. - */ -export function isDelegationValid(chain: DelegationChain, checks?: DelegationValidChecks): boolean { - // Verify that the no delegation is expired. If any are in the chain, returns false. - for (const { delegation } of chain.delegations) { - // prettier-ignore - if (+new Date(Number(delegation.expiration / BigInt(1000000))) <= +Date.now()) { - return false; - } - } - - // Check the scopes. - const scopes: Principal[] = []; - const maybeScope = checks?.scope; - if (maybeScope) { - if (Array.isArray(maybeScope)) { - scopes.push(...maybeScope.map(s => (typeof s === 'string' ? Principal.fromText(s) : s))); - } else { - scopes.push(typeof maybeScope === 'string' ? Principal.fromText(maybeScope) : maybeScope); - } - } - - for (const s of scopes) { - const scope = s.toText(); - for (const { delegation } of chain.delegations) { - if (delegation.targets === undefined) { - continue; - } - - let none = true; - for (const target of delegation.targets) { - if (target.toText() === scope) { - none = false; - break; - } - } - if (none) { - return false; - } - } - } - - return true; -} diff --git a/packages/authentication/test-setup.ts b/packages/authentication/test-setup.ts deleted file mode 100644 index 1c75fe535..000000000 --- a/packages/authentication/test-setup.ts +++ /dev/null @@ -1,14 +0,0 @@ -// This file may be used to polyfill features that aren't available in the test -// environment, i.e. JSDom. -// -// We sometimes need to do this because our target browsers are expected to have -// a feature that JSDom doesn't. -// -// Note that we can use webpack configuration to make some features available to -// Node.js in a similar way. - -global.crypto = require('@trust/webcrypto'); -global.TextEncoder = require('text-encoding').TextEncoder; -global.TextDecoder = require('text-encoding').TextDecoder; -global.MessageChannel = require('worker_threads').MessageChannel; -require('whatwg-fetch'); diff --git a/packages/authentication/tsconfig-cjs.json b/packages/authentication/tsconfig-cjs.json deleted file mode 100644 index 945c51f27..000000000 --- a/packages/authentication/tsconfig-cjs.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "module": "CommonJS", - "outDir": "./lib/cjs" - } -} diff --git a/packages/authentication/tsconfig.json b/packages/authentication/tsconfig.json deleted file mode 100644 index 20d177373..000000000 --- a/packages/authentication/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "allowJs": false, - "baseUrl": "./", - "composite": true, - "declaration": true, - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "incremental": true, - "module": "ES2020", - "moduleResolution": "node", - "outDir": "./lib/esm", - "resolveJsonModule": true, - "rootDir": "./src", - "sourceMap": true, - "inlineSources": true, - "strict": true, - "target": "es2017" - }, - "include": ["types/*", "src/**/*"], - "references": [{ "path": "../agent" }, { "path": "../identity" }] -} diff --git a/packages/authentication/tslint.json b/packages/authentication/tslint.json deleted file mode 100644 index cc4c57b34..000000000 --- a/packages/authentication/tslint.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "defaultSeverity": "error", - "extends": ["tslint:recommended"], - "jsRules": {}, - "linterOptions": { - "exclude": ["src/IDL.js", "src/IDL.test.js"] - }, - "rules": { - "max-classes-per-file": false, - "interface-name": [true, "never-prefix"], - "no-consecutive-blank-lines": [true, 2], - "no-empty": [true, "allow-empty-functions"], - "no-switch-case-fall-through": true, - "object-literal-sort-keys": false, - "max-line-length": [true, 100], - "quotemark": [true, "single"], - "arrow-parens": [true, "ban-single-arg-parens"], - "space-before-function-paren": [false], - "variable-name": { - "options": ["ban-keywords", "check-format", "allow-leading-underscore", "allow-pascal-case"] - } - }, - "rulesDirectory": [] -} diff --git a/packages/authentication/types/borc.d.ts b/packages/authentication/types/borc.d.ts deleted file mode 100644 index 325b17644..000000000 --- a/packages/authentication/types/borc.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -declare module 'borc' { - import { Buffer } from 'buffer/'; - - class Decoder { - constructor(opts: { size: number; tags: Record any> }); - - decodeFirst(input: ArrayBuffer): any; - } - - export function decodeFirst(input: ArrayBuffer): any; - - export function encode(o: any): Buffer; - - class Tagged { - tag: number; - value: any; - constructor(tag: Number, value: any); - } -} diff --git a/packages/candid/jest.config.ts b/packages/candid/jest.config.ts index 798d17718..02e05f950 100644 --- a/packages/candid/jest.config.ts +++ b/packages/candid/jest.config.ts @@ -12,7 +12,6 @@ module.exports = { '^.+\\.ts$': 'ts-jest', }, collectCoverageFrom: ['src/**/*.{ts,tsx}'], - name: packageName, displayName: packageName, rootDir: '../..', }; diff --git a/packages/identity-ledgerhq/.gitignore b/packages/identity-ledgerhq/.gitignore deleted file mode 100644 index 1919435be..000000000 --- a/packages/identity-ledgerhq/.gitignore +++ /dev/null @@ -1,17 +0,0 @@ -build_info.json -node_modules/ -dist/ -lib/**/*.js -lib/**/*.js.map -lib/**/*.d.ts - -# generated docs -/docs/reference - -# Cannot ignore .d.ts files in types/ -!types/**/*.d.ts - -# Cannot ignore setup files for webpack and jest, which are still JavaScript. -!webpack.config.js -!jest.config.js -!test-setup.js diff --git a/packages/identity-ledgerhq/.npmignore b/packages/identity-ledgerhq/.npmignore deleted file mode 100644 index eb725972f..000000000 --- a/packages/identity-ledgerhq/.npmignore +++ /dev/null @@ -1,11 +0,0 @@ -# We work with a safelist here, so block everything that's not permitted, and add packages -# that are. -** - -!lib/** -!types/**/*.d.ts -!package.json -!README.md - -# The following line further removes all test files (which matches .js and .d.ts). -lib/**/*.test.* diff --git a/packages/identity-ledgerhq/README.md b/packages/identity-ledgerhq/README.md index 22c6fd8df..3918da3df 100644 --- a/packages/identity-ledgerhq/README.md +++ b/packages/identity-ledgerhq/README.md @@ -1,5 +1,8 @@ # @dfinity/identity-ledgerhq +**warning** +This package has been deprecated. Please use the `@zondax/ledger-icp` package instead. + TypeScript library to support a Hardware Ledger Wallet identity for applications on the [Internet Computer](https://dfinity.org/). Visit the [Dfinity Forum](https://forum.dfinity.org/) and [SDK Documentation](https://sdk.dfinity.org/docs/index.html) for more information and support building on the Internet Computer. diff --git a/packages/identity-ledgerhq/jest.config.ts b/packages/identity-ledgerhq/jest.config.ts deleted file mode 100644 index 1a9ad56f4..000000000 --- a/packages/identity-ledgerhq/jest.config.ts +++ /dev/null @@ -1,18 +0,0 @@ -import baseConfig from '../../jest.config.base'; -const packageName = 'authentication'; - -module.exports = { - ...baseConfig, - roots: [`/packages/${packageName}`], - bail: false, - moduleDirectories: ['node_modules'], - modulePaths: [`/packages/${packageName}/src/`], - setupFiles: [`/packages/${packageName}/test-setup.ts`], - transform: { - '^.+\\.ts$': 'ts-jest', - }, - collectCoverageFrom: ['src/**/*.{ts,tsx}'], - name: packageName, - displayName: packageName, - rootDir: '../..', -}; diff --git a/packages/identity-ledgerhq/package.json b/packages/identity-ledgerhq/package.json index f60da5294..3ae3e50cc 100644 --- a/packages/identity-ledgerhq/package.json +++ b/packages/identity-ledgerhq/package.json @@ -4,77 +4,13 @@ "author": "DFINITY Stiftung ", "license": "Apache-2.0", "description": "JavaScript and TypeScript library to manage identity and authentication with the Internet Computer", - "homepage": "https://smartcontracts.org", - "repository": { - "type": "git", - "url": "https://github.com/dfinity/agent-js.git", - "directory": "packages/identity-ledgerhq" - }, - "bugs": { - "url": "https://github.com/dfinity/agent-js/issues" - }, - "keywords": [ - "internet computer", - "ic", - "dfinity", - "canister", - "ledgerhq", - "ledger", - "identity", - "principal", - "authentication", - "dfx", - "candid", - "motoko", - "javascript", - "typescript", - "blockchain", - "crypto", - "distributed", - "api" - ], + "deprecated": "This package has been deprecated. Please use the `@zondax/ledger-icp` package instead.", "main": "./lib/cjs/index.js", - "module": "./lib/esm/index.js", - "unpkg": "./lib/esm/index", "scripts": { - "build": "tsc -b && tsc -p tsconfig-cjs.json", - "build:watch": "tsc -b --watch", - "bundle": "npm run build", - "lint": "eslint 'src' --ext '.js,.jsx,.ts,.tsx'", - "lint:fix": "npm run lint -- --fix", - "make:docs/reference": "typedoc src/index.ts --out ../../docs/generated/identity-ledgerhq --excludeInternal", - "release": "npm publish", - "test": "jest", - "test:coverage": "jest --verbose --collectCoverage" - }, - "peerDependencies": { - "@dfinity/agent": "^0.14.1", - "@dfinity/identity": "^0.14.1", - "@dfinity/principal": "^0.14.1" + "build": "", + "test": "" }, "dependencies": { - "@ledgerhq/hw-transport": "^5.49.0", - "@ledgerhq/hw-transport-webhid": "^5.49.0", - "@zondax/ledger-dfinity": "0.2.1", - "buffer": "6.0.3", - "ts-node": "^10.8.2" - }, - "devDependencies": { - "@trust/webcrypto": "^0.9.2", - "@types/jest": "^28.1.4", - "@types/ledgerhq__hw-transport": "^4.21.3", - "@typescript-eslint/eslint-plugin": "^5.30.5", - "@typescript-eslint/parser": "^5.30.5", - "esbuild": "^0.15.16", - "eslint": "^8.19.0", - "eslint-plugin-jsdoc": "^39.3.3", - "jest": "^28.1.2", - "size-limit": "^8.1.0", - "text-encoding": "^0.7.0", - "ts-jest": "^28.0.5", - "tslint": "^5.20.0", - "typedoc": "^0.22.11", - "typescript": "^4.7.4", - "whatwg-fetch": "^3.0.0" + "@zondax/ledger-icp": "^0.6.1" } } diff --git a/packages/identity-ledgerhq/src/identity/ledger.ts b/packages/identity-ledgerhq/src/identity/ledger.ts deleted file mode 100644 index c8e6d13a0..000000000 --- a/packages/identity-ledgerhq/src/identity/ledger.ts +++ /dev/null @@ -1,101 +0,0 @@ -import { - CallRequest, - Cbor, - HttpAgentRequest, - PublicKey, - ReadRequest, - Signature, - SignIdentity, -} from '@dfinity/agent'; -import { Principal } from '@dfinity/principal'; -import DfinityApp, { ResponseSign } from '@zondax/ledger-dfinity'; -import { Buffer } from 'buffer/'; -import { Secp256k1PublicKey } from './secp256k1'; - -/** - * Convert the HttpAgentRequest body into cbor which can be signed by the Ledger Hardware Wallet. - * @param request - body of the HttpAgentRequest - */ -function _prepareCborForLedger(request: ReadRequest | CallRequest): ArrayBuffer { - return Cbor.encode({ content: request }); -} - -/** - * A Hardware Ledger Internet Computer Agent identity. - */ -export class LedgerIdentity extends SignIdentity { - /** - * Create a LedgerIdentity using the Web USB transport. - * @param derivePath The derivation path. - */ - public static async create(derivePath = `m/44'/223'/0'/0/0`): Promise { - const TransportClass = (await import('@ledgerhq/hw-transport-webhid')).default; - const transport = await TransportClass.create(); - const app = new DfinityApp(transport); - - const resp = await app.getAddressAndPubKey(derivePath); - // This type doesn't have the right fields in it, so we have to manually type it. - const principal = (resp as unknown as { principalText: string }).principalText; - const publicKey = Secp256k1PublicKey.fromRaw(resp.publicKey); - const address = resp.address; - - if (principal !== Principal.selfAuthenticating(new Uint8Array(publicKey.toDer())).toText()) { - throw new Error('Principal returned by device does not match public key.'); - } - - return new this(app, derivePath, publicKey, address.buffer); - } - - private constructor( - private readonly _app: DfinityApp, - public readonly derivePath: string, - private readonly _publicKey: Secp256k1PublicKey, - private readonly _address: ArrayBuffer, - ) { - super(); - } - - /** - * Required by Ledger.com that the user should be able to press a Button in UI - * and verify the address/pubkey are the same as on the device screen. - */ - public async showAddressAndPubKeyOnDevice(): Promise { - await this._app.showAddressAndPubKey(this.derivePath); - } - - public getPublicKey(): PublicKey { - return this._publicKey; - } - - public async sign(blob: ArrayBuffer): Promise { - // Force an `as any` because the types are compatible but TypeScript cannot figure it out. - const resp: ResponseSign = await this._app.sign(this.derivePath, Buffer.from(blob) as any); - const signatureRS = resp.signatureRS; - if (!signatureRS) { - throw new Error( - `A ledger error happened during signature:\n` + - `Code: ${resp.returnCode}\n` + - `Message: ${JSON.stringify(resp.errorMessage)}\n`, - ); - } - - if (signatureRS?.byteLength !== 64) { - throw new Error(`Signature must be 64 bytes long (is ${signatureRS.length})`); - } - - return signatureRS.buffer as Signature; - } - - public async transformRequest(request: HttpAgentRequest): Promise { - const { body, ...fields } = request; - const signature = await this.sign(_prepareCborForLedger(body)); - return { - ...fields, - body: { - content: body, - sender_pubkey: this._publicKey.toDer(), - sender_sig: signature, - }, - }; - } -} diff --git a/packages/identity-ledgerhq/src/identity/ledger_hq__hw_transport_webhid.d.ts b/packages/identity-ledgerhq/src/identity/ledger_hq__hw_transport_webhid.d.ts deleted file mode 100644 index edd3c6163..000000000 --- a/packages/identity-ledgerhq/src/identity/ledger_hq__hw_transport_webhid.d.ts +++ /dev/null @@ -1 +0,0 @@ -declare module '@ledgerhq/hw-transport-webhid'; diff --git a/packages/identity-ledgerhq/src/identity/secp256k1.test.ts b/packages/identity-ledgerhq/src/identity/secp256k1.test.ts deleted file mode 100644 index be50f834b..000000000 --- a/packages/identity-ledgerhq/src/identity/secp256k1.test.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { blobFromHex } from '@dfinity/candid'; -import { Secp256k1PublicKey } from './secp256k1'; - -const testVectors: Array<[string, string]> = [ - [ - '0410d34980a51af89d3331ad5fa80fe30d8868ad87526460b3b3e15596ee58e812422987d8589ba61098264df5bb9c2d3ff6fe061746b4b31a44ec26636632b835', - '3056301006072A8648CE3D020106052B8104000A0342000410d34980a51af89d3331ad5fa80fe30d8868ad87526460b3b3e15596ee58e812422987d8589ba61098264df5bb9c2d3ff6fe061746b4b31a44ec26636632b835', - ], -]; - -test('DER encoding of secp256k1 keys', async () => { - testVectors.forEach(([rawPublicKeyHex, derEncodedPublicKeyHex]) => { - const publicKey = Secp256k1PublicKey.fromRaw(blobFromHex(rawPublicKeyHex)); - const expectedDerPublicKey = blobFromHex(derEncodedPublicKeyHex); - expect(publicKey.toDer()).toEqual(expectedDerPublicKey); - }); -}); - -test('DER decoding of ED25519 keys', async () => { - testVectors.forEach(([rawPublicKeyHex, derEncodedPublicKeyHex]) => { - const derPublicKey = blobFromHex(derEncodedPublicKeyHex); - const expectedPublicKey = blobFromHex(rawPublicKeyHex); - expect(Secp256k1PublicKey.fromDer(derPublicKey).toRaw()).toEqual(expectedPublicKey); - }); -}); - -test('DER encoding of invalid keys', async () => { - // Too short - expect(() => { - Secp256k1PublicKey.fromRaw( - blobFromHex( - '0410d34980a51af89d3331ad5fa80fe30d8868ad87526460b3b3e15596ee58e812422987d8589ba61098264df5bb9c2d3ff6fe061746b4b31a44ec26636632b8', - ), - ).toDer(); - }).toThrow(); - - // Too long - expect(() => { - Secp256k1PublicKey.fromRaw( - blobFromHex( - '0410d34980a51af89d3331ad5fa80fe30d8868ad87526460b3b3e15596ee58e812422987d8589ba61098264df5bb9c2d3ff6fe061746b4b31a44ec26636632b83500', - ), - ).toDer(); - }).toThrow(); -}); - -test('DER decoding of invalid keys', async () => { - // Too short - expect(() => { - Secp256k1PublicKey.fromDer( - blobFromHex( - '3056301006072A8648CE3D020106052B8104000A034200' + - '0410d34980a51af89d3331ad5fa80fe30d8868ad87526460b3b3e15596ee58e812422987d8589ba61098264df5bb9c2d3ff6fe061746b4b31a44ec26636632b8', - ), - ); - }).toThrow(); - - // Too long - expect(() => { - Secp256k1PublicKey.fromDer( - blobFromHex( - '3056301006072A8648CE3D020106052B8104000A034200' + - '0410d34980a51af89d3331ad5fa80fe30d8868ad87526460b3b3e15596ee58e812422987d8589ba61098264df5bb9c2d3ff6fe061746b4b31a44ec26636632b83500', - ), - ); - }).toThrow(); - - // Invalid DER-encoding - expect(() => { - Secp256k1PublicKey.fromDer( - blobFromHex( - '2056301006072A8648CE3D020106052B8104000A0342000410d34980a51af89d3331ad5fa80fe30d8868ad87526460b3b3e15596ee58e812422987d8589ba61098264df5bb9c2d3ff6fe061746b4b31a44ec26636632b835', - ), - ); - }).toThrow(); -}); diff --git a/packages/identity-ledgerhq/src/identity/secp256k1.ts b/packages/identity-ledgerhq/src/identity/secp256k1.ts deleted file mode 100644 index 4a26a256d..000000000 --- a/packages/identity-ledgerhq/src/identity/secp256k1.ts +++ /dev/null @@ -1,95 +0,0 @@ -import { DerEncodedPublicKey, PublicKey } from '@dfinity/agent'; - -function equals(b1: ArrayBuffer, b2: ArrayBuffer): boolean { - if (b1.byteLength !== b2.byteLength) { - return false; - } - - const u1 = new Uint8Array(b1); - const u2 = new Uint8Array(b2); - for (let i = 0; i < u1.length; i++) { - if (u1[i] !== u2[i]) { - return false; - } - } - return true; -} - -// This implementation is adjusted from the Ed25519PublicKey. -// The RAW_KEY_LENGTH and DER_PREFIX are modified accordingly -export class Secp256k1PublicKey implements PublicKey { - public static fromRaw(rawKey: ArrayBuffer): Secp256k1PublicKey { - return new Secp256k1PublicKey(rawKey); - } - - public static fromDer(derKey: DerEncodedPublicKey): Secp256k1PublicKey { - return new Secp256k1PublicKey(this.derDecode(derKey)); - } - - // The length of secp256k1 public keys is always 65 bytes. - private static RAW_KEY_LENGTH = 65; - - // Adding this prefix to a raw public key is sufficient to DER-encode it. - // prettier-ignore - private static DER_PREFIX = Uint8Array.from([ - 0x30, 0x56, // SEQUENCE - 0x30, 0x10, // SEQUENCE - 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, // OID ECDSA - 0x06, 0x05, 0x2b, 0x81, 0x04, 0x00, 0x0a, // OID secp256k1 - 0x03, 0x42, // BIT STRING - 0x00, // no padding - ]); - - private static derEncode(publicKey: ArrayBuffer): DerEncodedPublicKey { - if (publicKey.byteLength !== Secp256k1PublicKey.RAW_KEY_LENGTH) { - const bl = publicKey.byteLength; - throw new TypeError( - `secp256k1 public key must be ${Secp256k1PublicKey.RAW_KEY_LENGTH} bytes long (is ${bl})`, - ); - } - - const derPublicKey = Uint8Array.from([ - ...Secp256k1PublicKey.DER_PREFIX, - ...new Uint8Array(publicKey), - ]); - - return derPublicKey.buffer as DerEncodedPublicKey; - } - - private static derDecode(key: DerEncodedPublicKey): ArrayBuffer { - const expectedLength = Secp256k1PublicKey.DER_PREFIX.length + Secp256k1PublicKey.RAW_KEY_LENGTH; - if (key.byteLength !== expectedLength) { - const bl = key.byteLength; - throw new TypeError( - `secp256k1 DER-encoded public key must be ${expectedLength} bytes long (is ${bl})`, - ); - } - - const rawKey = key.slice(0, Secp256k1PublicKey.DER_PREFIX.length); - if (!equals(this.derEncode(rawKey), key)) { - throw new TypeError( - 'secp256k1 DER-encoded public key is invalid. A valid secp256k1 DER-encoded public key ' + - `must have the following prefix: ${Secp256k1PublicKey.DER_PREFIX}`, - ); - } - - return rawKey; - } - - private readonly rawKey: ArrayBuffer; - private readonly derKey: DerEncodedPublicKey; - - // `fromRaw` and `fromDer` should be used for instantiation, not this constructor. - private constructor(key: ArrayBuffer) { - this.rawKey = key; - this.derKey = Secp256k1PublicKey.derEncode(key); - } - - public toDer(): DerEncodedPublicKey { - return this.derKey; - } - - public toRaw(): ArrayBuffer { - return this.rawKey; - } -} diff --git a/packages/identity-ledgerhq/src/index.ts b/packages/identity-ledgerhq/src/index.ts deleted file mode 100644 index 751f0f2c0..000000000 --- a/packages/identity-ledgerhq/src/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './identity/ledger'; -export * from './identity/secp256k1'; diff --git a/packages/identity-ledgerhq/test-setup.ts b/packages/identity-ledgerhq/test-setup.ts deleted file mode 100644 index 1c75fe535..000000000 --- a/packages/identity-ledgerhq/test-setup.ts +++ /dev/null @@ -1,14 +0,0 @@ -// This file may be used to polyfill features that aren't available in the test -// environment, i.e. JSDom. -// -// We sometimes need to do this because our target browsers are expected to have -// a feature that JSDom doesn't. -// -// Note that we can use webpack configuration to make some features available to -// Node.js in a similar way. - -global.crypto = require('@trust/webcrypto'); -global.TextEncoder = require('text-encoding').TextEncoder; -global.TextDecoder = require('text-encoding').TextDecoder; -global.MessageChannel = require('worker_threads').MessageChannel; -require('whatwg-fetch'); diff --git a/packages/identity-ledgerhq/tsconfig-cjs.json b/packages/identity-ledgerhq/tsconfig-cjs.json deleted file mode 100644 index 945c51f27..000000000 --- a/packages/identity-ledgerhq/tsconfig-cjs.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "module": "CommonJS", - "outDir": "./lib/cjs" - } -} diff --git a/packages/identity-ledgerhq/tsconfig.json b/packages/identity-ledgerhq/tsconfig.json deleted file mode 100644 index 861311726..000000000 --- a/packages/identity-ledgerhq/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "allowJs": false, - "baseUrl": "./", - "composite": true, - "declaration": true, - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "incremental": true, - "module": "ES2020", - "moduleResolution": "node", - "outDir": "./lib/esm", - "resolveJsonModule": true, - "rootDir": "./src", - "sourceMap": true, - "inlineSources": true, - "strict": true, - "target": "es2017" - }, - "include": ["types/*", "src/**/*"], - "references": [{ "path": "../agent" }] -} diff --git a/packages/identity-ledgerhq/tslint.json b/packages/identity-ledgerhq/tslint.json deleted file mode 100644 index cc4c57b34..000000000 --- a/packages/identity-ledgerhq/tslint.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "defaultSeverity": "error", - "extends": ["tslint:recommended"], - "jsRules": {}, - "linterOptions": { - "exclude": ["src/IDL.js", "src/IDL.test.js"] - }, - "rules": { - "max-classes-per-file": false, - "interface-name": [true, "never-prefix"], - "no-consecutive-blank-lines": [true, 2], - "no-empty": [true, "allow-empty-functions"], - "no-switch-case-fall-through": true, - "object-literal-sort-keys": false, - "max-line-length": [true, 100], - "quotemark": [true, "single"], - "arrow-parens": [true, "ban-single-arg-parens"], - "space-before-function-paren": [false], - "variable-name": { - "options": ["ban-keywords", "check-format", "allow-leading-underscore", "allow-pascal-case"] - } - }, - "rulesDirectory": [] -} diff --git a/packages/identity-ledgerhq/types/borc.d.ts b/packages/identity-ledgerhq/types/borc.d.ts deleted file mode 100644 index 325b17644..000000000 --- a/packages/identity-ledgerhq/types/borc.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -declare module 'borc' { - import { Buffer } from 'buffer/'; - - class Decoder { - constructor(opts: { size: number; tags: Record any> }); - - decodeFirst(input: ArrayBuffer): any; - } - - export function decodeFirst(input: ArrayBuffer): any; - - export function encode(o: any): Buffer; - - class Tagged { - tag: number; - value: any; - constructor(tag: Number, value: any); - } -} diff --git a/packages/identity/jest.config.ts b/packages/identity/jest.config.ts index 0e15a23b8..69601ee80 100644 --- a/packages/identity/jest.config.ts +++ b/packages/identity/jest.config.ts @@ -12,7 +12,6 @@ module.exports = { '^.+\\.ts$': 'ts-jest', }, collectCoverageFrom: ['src/**/*.{ts,tsx}'], - name: packageName, displayName: packageName, rootDir: '../..', }; diff --git a/packages/identity/src/identity/delegation.ts b/packages/identity/src/identity/delegation.ts index 1dd7c39c2..055a97887 100644 --- a/packages/identity/src/identity/delegation.ts +++ b/packages/identity/src/identity/delegation.ts @@ -316,3 +316,62 @@ export class DelegationIdentity extends SignIdentity { }; } } + +/** + * List of things to check for a delegation chain validity. + */ +export interface DelegationValidChecks { + /** + * Check that the scope is amongst the scopes that this delegation has access to. + */ + scope?: Principal | string | Array; +} + +/** + * Analyze a DelegationChain and validate that it's valid, ie. not expired and apply to the + * scope. + * @param chain The chain to validate. + * @param checks Various checks to validate on the chain. + */ +export function isDelegationValid(chain: DelegationChain, checks?: DelegationValidChecks): boolean { + // Verify that the no delegation is expired. If any are in the chain, returns false. + for (const { delegation } of chain.delegations) { + // prettier-ignore + if (+new Date(Number(delegation.expiration / BigInt(1000000))) <= +Date.now()) { + return false; + } + } + + // Check the scopes. + const scopes: Principal[] = []; + const maybeScope = checks?.scope; + if (maybeScope) { + if (Array.isArray(maybeScope)) { + scopes.push(...maybeScope.map(s => (typeof s === 'string' ? Principal.fromText(s) : s))); + } else { + scopes.push(typeof maybeScope === 'string' ? Principal.fromText(maybeScope) : maybeScope); + } + } + + for (const s of scopes) { + const scope = s.toText(); + for (const { delegation } of chain.delegations) { + if (delegation.targets === undefined) { + continue; + } + + let none = true; + for (const target of delegation.targets) { + if (target.toText() === scope) { + none = false; + break; + } + } + if (none) { + return false; + } + } + } + + return true; +} diff --git a/packages/identity/src/index.ts b/packages/identity/src/index.ts index 2f4b0e567..24b5c3f79 100644 --- a/packages/identity/src/index.ts +++ b/packages/identity/src/index.ts @@ -1,11 +1,6 @@ export { Ed25519KeyIdentity, Ed25519PublicKey } from './identity/ed25519'; export * from './identity/ecdsa'; export { Secp256k1KeyIdentity, Secp256k1PublicKey } from './identity/secp256k1'; -export { - Delegation, - DelegationIdentity, - DelegationChain, - SignedDelegation, -} from './identity/delegation'; +export * from './identity/delegation'; export { WebAuthnIdentity } from './identity/webauthn'; export { wrapDER, unwrapDER, DER_COSE_OID, ED25519_OID } from './identity/der'; diff --git a/packages/principal/jest.config.ts b/packages/principal/jest.config.ts index b07265b10..020230ae8 100644 --- a/packages/principal/jest.config.ts +++ b/packages/principal/jest.config.ts @@ -12,7 +12,6 @@ module.exports = { '^.+\\.ts$': 'ts-jest', }, collectCoverageFrom: ['src/**/*.{ts,tsx}'], - name: packageName, displayName: packageName, rootDir: '../..', };