Skip to content

Commit

Permalink
Upgrade agent-js
Browse files Browse the repository at this point in the history
This PR upgrades `agent-js` to the latest version to fix a bug
related to WebAuthn registrations.
Fixes #2235.
  • Loading branch information
Frederik Rothenberger committed Mar 19, 2024
1 parent 728ad5a commit 27ecd0d
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 56 deletions.
92 changes: 54 additions & 38 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions src/frontend/src/crypto/ed25519.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { fromHex } from "@dfinity/agent";
import { Ed25519PublicKey } from "@dfinity/identity";
import { fromHexString } from "@dfinity/identity/lib/cjs/buffer";
import * as ed25519 from "./ed25519";

type TestVector = {
Expand Down Expand Up @@ -66,9 +66,9 @@ const testVectorsSLIP10 = [
test("derive Ed25519 via SLIP 0010", async () => {
await Promise.all(
testVectorsSLIP10.map(async (testVector: TestVector) => {
const seedBlob = fromHexString(testVector.seed);
const expectedPrivateKey = fromHexString(testVector.privateKey);
const expectedPublicKey = fromHexString(testVector.publicKey);
const seedBlob = fromHex(testVector.seed);
const expectedPrivateKey = fromHex(testVector.privateKey);
const expectedPublicKey = fromHex(testVector.publicKey);

const identity = await ed25519.fromSeedWithSlip0010(
new Uint8Array(seedBlob),
Expand Down
7 changes: 2 additions & 5 deletions src/frontend/src/crypto/mnemonic.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isUserNumber } from "$src/utils/userNumber";
import { toHexString } from "@dfinity/identity/lib/cjs/buffer";
import { toHex } from "@dfinity/agent";
import { entropyToMnemonic, validateMnemonic, wordlists } from "bip39";

/**
Expand All @@ -8,10 +8,7 @@ import { entropyToMnemonic, validateMnemonic, wordlists } from "bip39";
export function generate(): string {
const entropy = new Uint32Array(8); // NOTE: please change RECOVERYPHRASE_WORDCOUNT if this changes
crypto.getRandomValues(entropy);
return entropyToMnemonic(
toHexString(entropy.buffer),
RECOVERYPHRASE_WORDLIST
);
return entropyToMnemonic(toHex(entropy.buffer), RECOVERYPHRASE_WORDLIST);
}

/** How many words are expected in the recovery phrase */
Expand Down
3 changes: 1 addition & 2 deletions src/frontend/src/utils/iiConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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",
},
Expand Down
2 changes: 1 addition & 1 deletion src/vite-plugins/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down

0 comments on commit 27ecd0d

Please sign in to comment.