From 65fab90702e11dfb285ec3aa3c960a5d6b84bcea Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Mon, 5 Oct 2020 02:21:40 -0700 Subject: Create AuthenticatorAttestationResponseFuture type --- packages/typescript-types/src/index.ts | 35 ++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'packages/typescript-types') diff --git a/packages/typescript-types/src/index.ts b/packages/typescript-types/src/index.ts index bcecc64..23d2d99 100644 --- a/packages/typescript-types/src/index.ts +++ b/packages/typescript-types/src/index.ts @@ -7,9 +7,8 @@ * A variant of PublicKeyCredentialCreationOptions suitable for JSON transmission to the browser to * (eventually) get passed into navigator.credentials.create(...) in the browser. */ -export interface PublicKeyCredentialCreationOptionsJSON extends Omit< -PublicKeyCredentialCreationOptions, 'challenge' | 'user' | 'excludeCredentials' -> { +export interface PublicKeyCredentialCreationOptionsJSON + extends Omit { user: PublicKeyCredentialUserEntityJSON; challenge: Base64URLString; excludeCredentials: PublicKeyCredentialDescriptorJSON[]; @@ -19,22 +18,19 @@ PublicKeyCredentialCreationOptions, 'challenge' | 'user' | 'excludeCredentials' * A variant of PublicKeyCredentialRequestOptions suitable for JSON transmission to the browser to * (eventually) get passed into navigator.credentials.get(...) in the browser. */ -export interface PublicKeyCredentialRequestOptionsJSON extends Omit< -PublicKeyCredentialRequestOptions, 'challenge' |'allowCredentials' -> { +export interface PublicKeyCredentialRequestOptionsJSON + extends Omit { challenge: Base64URLString; allowCredentials: PublicKeyCredentialDescriptorJSON[]; } -export interface PublicKeyCredentialDescriptorJSON extends Omit< -PublicKeyCredentialDescriptor, 'id' -> { +export interface PublicKeyCredentialDescriptorJSON + extends Omit { id: Base64URLString; } -export interface PublicKeyCredentialUserEntityJSON extends Omit < -PublicKeyCredentialUserEntity, 'id' -> { +export interface PublicKeyCredentialUserEntityJSON + extends Omit { id: Base64URLString; } @@ -111,3 +107,18 @@ export type AuthenticatorDevice = { * An attempt to communicate that this isn't just any string, but a Base64URL-encoded string */ export type Base64URLString = string; + +/** + * AuthenticatorAttestationResponse in lib.dom.d.ts is outdated. Maintain an augmented version here + * so we can implement additional properties as the WebAuthn spec evolves. + * + * See https://www.w3.org/TR/webauthn-2/#iface-authenticatorattestationresponse + * + * Properties marked optional are not supported in all browsers. + */ +export interface AuthenticatorAttestationResponseFuture extends AuthenticatorAttestationResponse { + getTransports?: () => AuthenticatorTransport[]; + getAuthenticatorData?: () => ArrayBuffer; + getPublicKey?: () => ArrayBuffer; + getPublicKeyAlgorithm?: () => COSEAlgorithmIdentifier[]; +} -- cgit v1.2.3