Skip to content

Commit

Permalink
finalizing der transfer from @dfinity/identity
Browse files Browse the repository at this point in the history
  • Loading branch information
krpeacock committed Nov 2, 2023
1 parent a29dd77 commit a493bf8
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 10 deletions.
8 changes: 7 additions & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion packages/agent/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
3 changes: 2 additions & 1 deletion packages/identity-secp256k1/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
19 changes: 13 additions & 6 deletions packages/identity/src/identity/webauthn.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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),
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/identity/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit a493bf8

Please sign in to comment.