UNPKG

@dfinity/identity

Version:

JavaScript and TypeScript library to manage identity with the Internet Computer

51 lines (50 loc) 2.07 kB
import { type DerEncodedPublicKey, type PublicKey, type Signature, SignIdentity } from '@dfinity/agent'; export declare class CosePublicKey implements PublicKey { protected _cose: Uint8Array; protected _encodedKey: DerEncodedPublicKey; constructor(_cose: Uint8Array); toDer(): DerEncodedPublicKey; getCose(): Uint8Array; } /** * A SignIdentity that uses `navigator.credentials`. See https://webauthn.guide/ for * more information about WebAuthentication. */ export declare class WebAuthnIdentity extends SignIdentity { readonly rawId: Uint8Array; protected authenticatorAttachment: AuthenticatorAttachment | undefined; /** * Create an identity from a JSON serialization. * @param json - json to parse */ static fromJSON(json: string): WebAuthnIdentity; /** * Create an identity. * @param credentialCreationOptions an optional CredentialCreationOptions Challenge */ static create(credentialCreationOptions?: CredentialCreationOptions): Promise<WebAuthnIdentity>; protected _publicKey: CosePublicKey; constructor(rawId: Uint8Array, cose: Uint8Array, authenticatorAttachment: AuthenticatorAttachment | undefined); getPublicKey(): PublicKey; /** * WebAuthn level 3 spec introduces a new attribute on successful WebAuthn interactions, * see https://w3c.github.io/webauthn/#dom-publickeycredential-authenticatorattachment. * This attribute is already implemented for Chrome, Safari and Edge. * * Given the attribute is only available after a successful interaction, the information is * provided opportunistically and might also be `undefined`. */ getAuthenticatorAttachment(): AuthenticatorAttachment | undefined; sign(blob: Uint8Array): Promise<Signature>; /** * Allow for JSON serialization of all information needed to reuse this identity. */ toJSON(): JsonnableWebAuthnIdentity; } /** * ReturnType<WebAuthnIdentity.toJSON> */ export interface JsonnableWebAuthnIdentity { publicKey: string; rawId: string; }