diff --git a/package-lock.json b/package-lock.json index 140baaf71..b3b4e8308 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18762,6 +18762,11 @@ "node": ">= 0.8.0" } }, + "node_modules/tweetnacl": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz", + "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==" + }, "node_modules/tx2": { "version": "1.0.5", "dev": true, @@ -20843,7 +20848,8 @@ "@noble/hashes": "^1.3.1", "bip39": "^3.0.4", "bs58check": "^2.1.2", - "secp256k1": "^4.0.3" + "secp256k1": "^4.0.3", + "tweetnacl": "^1.0.3" }, "devDependencies": { "@types/bs58check": "^2.1.0", diff --git a/packages/agent/tsconfig.json b/packages/agent/tsconfig.json index 325cd0b3b..5d74a0447 100644 --- a/packages/agent/tsconfig.json +++ b/packages/agent/tsconfig.json @@ -24,5 +24,5 @@ "tsBuildInfoFile": "./build_info.json" }, "include": ["types/*", "src/**/*.ts", "../candid/src/utils/bls.test.ts"], - "exclude": ["**/src/**/__certificates__/**"] + "exclude": ["**/src/**/__certificates__/**", "**/src/**/*.test.ts"] } diff --git a/packages/identity-secp256k1/package.json b/packages/identity-secp256k1/package.json index 9d10f62a0..8afd28583 100644 --- a/packages/identity-secp256k1/package.json +++ b/packages/identity-secp256k1/package.json @@ -18,7 +18,8 @@ "@noble/hashes": "^1.3.1", "bip39": "^3.0.4", "bs58check": "^2.1.2", - "secp256k1": "^4.0.3" + "secp256k1": "^4.0.3", + "tweetnacl": "^1.0.3" }, "devDependencies": { "@types/bs58check": "^2.1.0", diff --git a/packages/identity/src/identity/webauthn.ts b/packages/identity/src/identity/webauthn.ts index 47ecd8a9e..63216465a 100644 --- a/packages/identity/src/identity/webauthn.ts +++ b/packages/identity/src/identity/webauthn.ts @@ -1,8 +1,15 @@ -import { DerEncodedPublicKey, PublicKey, Signature, SignIdentity } from '@dfinity/agent'; +import { + DerEncodedPublicKey, + PublicKey, + Signature, + SignIdentity, + wrapDER, + DER_COSE_OID, + fromHex, + toHex, +} from '@dfinity/agent'; import borc from 'borc'; -import { fromHexString, toHexString } from '../buffer'; import { randomBytes } from '@noble/hashes/utils'; -import { DER_COSE_OID, wrapDER } from './der'; function _coseToDerEncodedBlob(cose: ArrayBuffer): DerEncodedPublicKey { return wrapDER(cose, DER_COSE_OID).buffer as DerEncodedPublicKey; @@ -132,7 +139,7 @@ export class WebAuthnIdentity extends SignIdentity { throw new Error('Invalid JSON string.'); } - return new this(fromHexString(rawId), fromHexString(publicKey), undefined); + return new this(fromHex(rawId), fromHex(publicKey), undefined); } /** @@ -234,8 +241,8 @@ export class WebAuthnIdentity extends SignIdentity { */ public toJSON(): JsonnableWebAuthnIdentity { return { - publicKey: toHexString(this._publicKey.getCose()), - rawId: toHexString(this.rawId), + publicKey: toHex(this._publicKey.getCose()), + rawId: toHex(this.rawId), }; } } diff --git a/packages/identity/src/index.ts b/packages/identity/src/index.ts index e00d8780e..a07f304a6 100644 --- a/packages/identity/src/index.ts +++ b/packages/identity/src/index.ts @@ -2,7 +2,7 @@ export { Ed25519KeyIdentity, Ed25519PublicKey } from './identity/ed25519'; export * from './identity/ecdsa'; export * from './identity/delegation'; export { WebAuthnIdentity } from './identity/webauthn'; -export { wrapDER, unwrapDER, DER_COSE_OID, ED25519_OID } from './identity/der'; +export { wrapDER, unwrapDER, DER_COSE_OID, ED25519_OID } from '@dfinity/agent'; /** * @deprecated due to size of dependencies. Use `@dfinity/identity-secp256k1` instead.