From 5665486c8625360cacd63749932ef66ace304e0d Mon Sep 17 00:00:00 2001 From: Frederik Rothenberger Date: Tue, 19 Mar 2024 09:42:26 +0100 Subject: [PATCH] Upgrade agent-js --- package-lock.json | 92 +++++++++++++++---------- package.json | 12 ++-- src/frontend/src/crypto/ed25519.test.ts | 2 +- src/frontend/src/crypto/mnemonic.ts | 2 +- src/frontend/src/utils/iiConnection.ts | 3 +- src/vite-plugins/package.json | 2 +- 6 files changed, 64 insertions(+), 49 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7da2fe894b..56f7dc38fc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,13 +17,13 @@ "src/sig-verifier-js" ], "dependencies": { - "@dfinity/agent": "^0.19.2", - "@dfinity/auth-client": "^0.19.2", - "@dfinity/candid": "^0.19.2", - "@dfinity/identity": "^0.19.2", + "@dfinity/agent": "^1.1.0", + "@dfinity/auth-client": "^1.1.0", + "@dfinity/candid": "^1.1.0", + "@dfinity/identity": "^1.1.0", "@dfinity/internet-identity-vc-api": "*", - "@dfinity/principal": "^0.19.2", - "@dfinity/utils": "^0.0.20", + "@dfinity/principal": "^1.1.0", + "@dfinity/utils": "^2.1.2", "bip39": "^3.0.4", "buffer": "^6.0.3", "dompurify": "^3.0.6", @@ -844,49 +844,55 @@ } }, "node_modules/@dfinity/agent": { - "version": "0.19.3", - "license": "Apache-2.0", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@dfinity/agent/-/agent-1.1.0.tgz", + "integrity": "sha512-ISf9rtlSQIrlCSgw/wZgBjDo9tIISukL3RgmaK1+0KFF172uW5R5YLyQKmDnueOqRrZlZ3O031DxsO3bxLsPVw==", "dependencies": { + "@noble/curves": "^1.2.0", "@noble/hashes": "^1.3.1", "base64-arraybuffer": "^0.2.0", "borc": "^2.1.1", + "buffer": "^6.0.3", "simple-cbor": "^0.4.1" }, "peerDependencies": { - "@dfinity/candid": "^0.19.3", - "@dfinity/principal": "^0.19.3" + "@dfinity/candid": "^1.1.0", + "@dfinity/principal": "^1.1.0" } }, "node_modules/@dfinity/auth-client": { - "version": "0.19.3", - "license": "Apache-2.0", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@dfinity/auth-client/-/auth-client-1.1.0.tgz", + "integrity": "sha512-Q2JxvP1mh5QRrp0nzUww80GjUKKWpIfXNz5BV5V41/iC9V6RqtRpH0yY31pOQ6OfD4/a/TOKiq/IOUaj62Aa2Q==", "dependencies": { "idb": "^7.0.2" }, "peerDependencies": { - "@dfinity/agent": "^0.19.3", - "@dfinity/identity": "^0.19.3", - "@dfinity/principal": "^0.19.3" + "@dfinity/agent": "^1.1.0", + "@dfinity/identity": "^1.1.0", + "@dfinity/principal": "^1.1.0" } }, "node_modules/@dfinity/candid": { - "version": "0.19.3", - "license": "Apache-2.0", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@dfinity/candid/-/candid-1.1.0.tgz", + "integrity": "sha512-NnhTcOH3eKHj40WltgUwKjNU/WasVeDy0CSAt/TcIjuaUCDI+7BV40ifOG+8DWt/284R9JmtIOCWuN2H6CoeRQ==", "peerDependencies": { - "@dfinity/principal": "^0.19.3" + "@dfinity/principal": "^1.1.0" } }, "node_modules/@dfinity/identity": { - "version": "0.19.3", - "license": "Apache-2.0", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@dfinity/identity/-/identity-1.1.0.tgz", + "integrity": "sha512-fF7moXoUl92aKrxoQ3d1h6OSShcM140WNFPbDzF5DSTTgEDh2fSMvB2PLB/AQ4C3iZrTJ/w/IYVxhMT6gBgNbA==", "dependencies": { + "@noble/curves": "^1.2.0", "@noble/hashes": "^1.3.1", - "borc": "^2.1.1", - "tweetnacl": "^1.0.1" + "borc": "^2.1.1" }, "peerDependencies": { - "@dfinity/agent": "^0.19.3", - "@dfinity/principal": "^0.19.3", + "@dfinity/agent": "^1.1.0", + "@dfinity/principal": "^1.1.0", "@peculiar/webcrypto": "^1.4.0" } }, @@ -903,8 +909,9 @@ "link": true }, "node_modules/@dfinity/principal": { - "version": "0.19.3", - "license": "Apache-2.0", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-1.1.0.tgz", + "integrity": "sha512-+In7j19bwGtqsF5YrABZBn/DuZD9FRqPPViIIwrkttd6PeVwqKmW2lcMLGymjxUNLbnuZIbluLQnV78YYChLPg==", "dependencies": { "@noble/hashes": "^1.3.1" } @@ -914,12 +921,13 @@ "link": true }, "node_modules/@dfinity/utils": { - "version": "0.0.20", - "license": "Apache-2.0", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@dfinity/utils/-/utils-2.1.2.tgz", + "integrity": "sha512-iMbprcyLOQFhrvvb5b51acDvSsnXmMEpGBC/dwFNEDQBMPeX/rB3lm9HUOQf3ga1wOs20pYi4Rh42xVXhvmHdg==", "peerDependencies": { - "@dfinity/agent": "^0.19.1", - "@dfinity/candid": "^0.19.1", - "@dfinity/principal": "^0.19.1" + "@dfinity/agent": "^1.0.1", + "@dfinity/candid": "^1.0.1", + "@dfinity/principal": "^1.0.1" } }, "node_modules/@dfinity/vc_util_js": { @@ -1568,9 +1576,21 @@ "@jridgewell/sourcemap-codec": "1.4.14" } }, + "node_modules/@noble/curves": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.4.0.tgz", + "integrity": "sha512-p+4cb332SFCrReJkCYe8Xzm0OWi4Jji5jVdIZRL/PmacmDkFNw6MrrV+gGpiPxLHbV+zKFRywUWbaseT+tZRXg==", + "dependencies": { + "@noble/hashes": "1.4.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/@noble/hashes": { - "version": "1.3.2", - "license": "MIT", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.4.0.tgz", + "integrity": "sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==", "engines": { "node": ">= 16" }, @@ -12359,10 +12379,6 @@ "node": "*" } }, - "node_modules/tweetnacl": { - "version": "1.0.3", - "license": "Unlicense" - }, "node_modules/type-detect": { "version": "4.0.8", "dev": true, @@ -14681,7 +14697,7 @@ "hasInstallScript": true, "license": "SEE LICENSE IN LICENSE.md", "devDependencies": { - "@dfinity/utils": "^0.0.20", + "@dfinity/utils": "^2.1.2", "@types/html-minifier-terser": "^7.0.0", "html-minifier-terser": "^7.2.0", "typescript": "*", diff --git a/package.json b/package.json index e670d11be3..fd909bb0ba 100644 --- a/package.json +++ b/package.json @@ -57,13 +57,13 @@ "webdriverio": "8.32.3" }, "dependencies": { - "@dfinity/agent": "^0.19.2", - "@dfinity/auth-client": "^0.19.2", - "@dfinity/candid": "^0.19.2", - "@dfinity/identity": "^0.19.2", + "@dfinity/agent": "^1.1.0", + "@dfinity/auth-client": "^1.1.0", + "@dfinity/candid": "^1.1.0", + "@dfinity/identity": "^1.1.0", "@dfinity/internet-identity-vc-api": "*", - "@dfinity/principal": "^0.19.2", - "@dfinity/utils": "^0.0.20", + "@dfinity/principal": "^1.1.0", + "@dfinity/utils": "^2.1.2", "bip39": "^3.0.4", "buffer": "^6.0.3", "dompurify": "^3.0.6", diff --git a/src/frontend/src/crypto/ed25519.test.ts b/src/frontend/src/crypto/ed25519.test.ts index 1999de5271..9af23de542 100644 --- a/src/frontend/src/crypto/ed25519.test.ts +++ b/src/frontend/src/crypto/ed25519.test.ts @@ -1,5 +1,5 @@ +import { fromHexString } from "@dfinity/candid"; import { Ed25519PublicKey } from "@dfinity/identity"; -import { fromHexString } from "@dfinity/identity/lib/cjs/buffer"; import * as ed25519 from "./ed25519"; type TestVector = { diff --git a/src/frontend/src/crypto/mnemonic.ts b/src/frontend/src/crypto/mnemonic.ts index 75ea8fa988..9e539ef6c9 100644 --- a/src/frontend/src/crypto/mnemonic.ts +++ b/src/frontend/src/crypto/mnemonic.ts @@ -1,5 +1,5 @@ import { isUserNumber } from "$src/utils/userNumber"; -import { toHexString } from "@dfinity/identity/lib/cjs/buffer"; +import { toHexString } from "@dfinity/candid"; import { entropyToMnemonic, validateMnemonic, wordlists } from "bip39"; /** diff --git a/src/frontend/src/utils/iiConnection.ts b/src/frontend/src/utils/iiConnection.ts index 147852f0f9..9fc3d9999a 100644 --- a/src/frontend/src/utils/iiConnection.ts +++ b/src/frontend/src/utils/iiConnection.ts @@ -43,7 +43,6 @@ import { } from "@dfinity/identity"; import { Principal } from "@dfinity/principal"; import { isNullish, nonNullish } from "@dfinity/utils"; -import * as tweetnacl from "tweetnacl"; import { MultiWebAuthnIdentity } from "./multiWebAuthnIdentity"; import { RecoveryDevice, isRecoveryDevice } from "./recoveryDevice"; import { isWebAuthnCancel } from "./webAuthnErrorUtils"; @@ -719,7 +718,7 @@ export const creationOptions = ( name: "Internet Identity Service", }, user: { - id: tweetnacl.randomBytes(16), + id: window.crypto.getRandomValues(new Uint8Array(16)), name: "Internet Identity", displayName: "Internet Identity", }, diff --git a/src/vite-plugins/package.json b/src/vite-plugins/package.json index 4af4bf4fe2..93de60003d 100644 --- a/src/vite-plugins/package.json +++ b/src/vite-plugins/package.json @@ -25,7 +25,7 @@ "vite": "^4.5.2", "undici": "*", "vite-plugin-compression": "^0.5.1", - "@dfinity/utils": "^0.0.20", + "@dfinity/utils": "^2.1.2", "@types/html-minifier-terser": "^7.0.0", "html-minifier-terser": "^7.2.0" }