@dfinity/identity
Advanced tools
Comparing version 0.8.0 to 0.8.1
@@ -14,3 +14,3 @@ import { BinaryBlob, DerEncodedBlob, PublicKey, SignIdentity } from '@dfinity/agent'; | ||
export declare class WebAuthnIdentity extends SignIdentity { | ||
private _rawId; | ||
readonly rawId: BinaryBlob; | ||
/** | ||
@@ -23,6 +23,7 @@ * Create an identity from a JSON serialization. | ||
* Create an identity. | ||
* @param challenge an optional PublicKeyCredentialCreationOptions Challenge | ||
*/ | ||
static create(): Promise<WebAuthnIdentity>; | ||
static create(challenge?: PublicKeyCredentialCreationOptions['challenge']): Promise<WebAuthnIdentity>; | ||
protected _publicKey: CosePublicKey; | ||
protected constructor(_rawId: BinaryBlob, cose: BinaryBlob); | ||
protected constructor(rawId: BinaryBlob, cose: BinaryBlob); | ||
getPublicKey(): PublicKey; | ||
@@ -29,0 +30,0 @@ sign(blob: BinaryBlob): Promise<BinaryBlob>; |
@@ -99,4 +99,5 @@ "use strict"; | ||
* it, so we don't. | ||
* @param challenge an optional PublicKeyCredentialCreationOptions Challenge | ||
*/ | ||
async function _createCredential() { | ||
async function _createCredential(challenge) { | ||
const creds = (await navigator.credentials.create({ | ||
@@ -108,3 +109,3 @@ publicKey: { | ||
attestation: 'direct', | ||
challenge: _createChallengeBuffer(), | ||
challenge: challenge !== null && challenge !== void 0 ? challenge : _createChallengeBuffer(), | ||
pubKeyCredParams: [{ type: 'public-key', alg: PubKeyCoseAlgo.ECDSA_WITH_SHA256 }], | ||
@@ -141,5 +142,5 @@ rp: { | ||
class WebAuthnIdentity extends agent_1.SignIdentity { | ||
constructor(_rawId, cose) { | ||
constructor(rawId, cose) { | ||
super(); | ||
this._rawId = _rawId; | ||
this.rawId = rawId; | ||
this._publicKey = new CosePublicKey(cose); | ||
@@ -160,5 +161,6 @@ } | ||
* Create an identity. | ||
* @param challenge an optional PublicKeyCredentialCreationOptions Challenge | ||
*/ | ||
static async create() { | ||
const creds = await _createCredential(); | ||
static async create(challenge) { | ||
const creds = await _createCredential(challenge); | ||
if (!creds || creds.type !== 'public-key') { | ||
@@ -184,3 +186,3 @@ throw new Error('Could not create credentials.'); | ||
type: 'public-key', | ||
id: this._rawId, | ||
id: this.rawId, | ||
}, | ||
@@ -215,3 +217,3 @@ ], | ||
publicKey: this._publicKey.getCose().toString('hex'), | ||
rawId: this._rawId.toString('hex'), | ||
rawId: this.rawId.toString('hex'), | ||
}; | ||
@@ -218,0 +220,0 @@ } |
@@ -14,3 +14,3 @@ import { BinaryBlob, DerEncodedBlob, PublicKey, SignIdentity } from '@dfinity/agent'; | ||
export declare class WebAuthnIdentity extends SignIdentity { | ||
private _rawId; | ||
readonly rawId: BinaryBlob; | ||
/** | ||
@@ -23,6 +23,7 @@ * Create an identity from a JSON serialization. | ||
* Create an identity. | ||
* @param challenge an optional PublicKeyCredentialCreationOptions Challenge | ||
*/ | ||
static create(): Promise<WebAuthnIdentity>; | ||
static create(challenge?: PublicKeyCredentialCreationOptions['challenge']): Promise<WebAuthnIdentity>; | ||
protected _publicKey: CosePublicKey; | ||
protected constructor(_rawId: BinaryBlob, cose: BinaryBlob); | ||
protected constructor(rawId: BinaryBlob, cose: BinaryBlob); | ||
getPublicKey(): PublicKey; | ||
@@ -29,0 +30,0 @@ sign(blob: BinaryBlob): Promise<BinaryBlob>; |
@@ -73,4 +73,5 @@ import { blobFromHex, blobFromUint8Array, derBlobFromBlob, SignIdentity, } from '@dfinity/agent'; | ||
* it, so we don't. | ||
* @param challenge an optional PublicKeyCredentialCreationOptions Challenge | ||
*/ | ||
async function _createCredential() { | ||
async function _createCredential(challenge) { | ||
const creds = (await navigator.credentials.create({ | ||
@@ -82,3 +83,3 @@ publicKey: { | ||
attestation: 'direct', | ||
challenge: _createChallengeBuffer(), | ||
challenge: challenge !== null && challenge !== void 0 ? challenge : _createChallengeBuffer(), | ||
pubKeyCredParams: [{ type: 'public-key', alg: PubKeyCoseAlgo.ECDSA_WITH_SHA256 }], | ||
@@ -115,5 +116,5 @@ rp: { | ||
export class WebAuthnIdentity extends SignIdentity { | ||
constructor(_rawId, cose) { | ||
constructor(rawId, cose) { | ||
super(); | ||
this._rawId = _rawId; | ||
this.rawId = rawId; | ||
this._publicKey = new CosePublicKey(cose); | ||
@@ -134,5 +135,6 @@ } | ||
* Create an identity. | ||
* @param challenge an optional PublicKeyCredentialCreationOptions Challenge | ||
*/ | ||
static async create() { | ||
const creds = await _createCredential(); | ||
static async create(challenge) { | ||
const creds = await _createCredential(challenge); | ||
if (!creds || creds.type !== 'public-key') { | ||
@@ -158,3 +160,3 @@ throw new Error('Could not create credentials.'); | ||
type: 'public-key', | ||
id: this._rawId, | ||
id: this.rawId, | ||
}, | ||
@@ -189,3 +191,3 @@ ], | ||
publicKey: this._publicKey.getCose().toString('hex'), | ||
rawId: this._rawId.toString('hex'), | ||
rawId: this.rawId.toString('hex'), | ||
}; | ||
@@ -192,0 +194,0 @@ } |
{ | ||
"name": "@dfinity/identity", | ||
"version": "0.8.0", | ||
"version": "0.8.1", | ||
"author": "DFINITY Stiftung <sdk@dfinity.org>", | ||
@@ -42,3 +42,3 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@dfinity/agent": "^0.8.0", | ||
"@dfinity/agent": "^0.8.1", | ||
"bip39": "^3.0.2", | ||
@@ -45,0 +45,0 @@ "borc": "^2.1.1", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
298433
1823
Updated@dfinity/agent@^0.8.1