diff options
author | Matthew Miller <matthew@millerti.me> | 2020-05-26 22:02:03 -0700 |
---|---|---|
committer | Matthew Miller <matthew@millerti.me> | 2020-05-26 22:02:03 -0700 |
commit | b12a0712365e044a21dafcbb6dcb52633a72d5f3 (patch) | |
tree | 1126b7d84129e26ffa8df6351ea1e447d0644a3b /packages/typescript-types/src | |
parent | 2374c09f8444b8a80ce8429f2654ce1b3b92c346 (diff) |
Refactor types to extend existing WebAuthn types
Diffstat (limited to 'packages/typescript-types/src')
-rw-r--r-- | packages/typescript-types/src/index.ts | 66 |
1 files changed, 22 insertions, 44 deletions
diff --git a/packages/typescript-types/src/index.ts b/packages/typescript-types/src/index.ts index 353623e..920fd7c 100644 --- a/packages/typescript-types/src/index.ts +++ b/packages/typescript-types/src/index.ts @@ -1,56 +1,27 @@ /** * A variant of PublicKeyCredentialCreationOptions suitable for JSON transmission to the browser to * (eventually) get passed into navigator.credentials.create(...) in the browser. - * - * Noteworthy values: - * @param challenge A random string of characters. Will be converted to a Uint8Array in the browser - * @param user.id Your unique, internal ID for the user. Will be converted to a Uint8Array in the - * browser */ -export type PublicKeyCredentialCreationOptionsJSON = { - publicKey: { - challenge: string; - // The organization registering and authenticating the user - rp: { - name: string; - id: string; - }; - user: { - id: string; - name: string; - displayName: string; - }; - pubKeyCredParams: [ - { - alg: -7; - type: 'public-key'; - }, - ]; - timeout?: number; - attestation: 'direct' | 'indirect'; - excludeCredentials: PublicKeyCredentialDescriptorJSON[]; - }; -}; +export interface PublicKeyCredentialCreationOptionsJSON extends Omit< +PublicKeyCredentialCreationOptions, 'challenge' | 'user' | 'excludeCredentials' +> { + // Will be converted to a Uint8Array in the browser + user: PublicKeyCredentialUserEntityJSON; + challenge: string; + excludeCredentials: PublicKeyCredentialDescriptorJSON[]; +} /** * A variant of PublicKeyCredentialRequestOptions suitable for JSON transmission to the browser to * (eventually) get passed into navigator.credentials.get(...) in the browser. - * - * Noteworthy values: - * @param challenge A random string of characters. Will be converted to a Uint8Array in the browser - * @param allowCredentials.id Base64-encoded credentialId. Will be converted to a Uint8Array in the - * browser */ -export type PublicKeyCredentialRequestOptionsJSON = { - publicKey: { - challenge: string; - allowCredentials: PublicKeyCredentialDescriptorJSON[]; - // extensions?: AuthenticationExtensionsClientInputs, - rpId?: string; - timeout?: number; - userVerification?: UserVerificationRequirement; - }; -}; +export interface PublicKeyCredentialRequestOptionsJSON extends Omit< +PublicKeyCredentialRequestOptions, 'challenge' |'allowCredentials' +> { + // Will be converted to a Uint8Array in the browser + challenge: string; + allowCredentials: PublicKeyCredentialDescriptorJSON[]; +} export interface PublicKeyCredentialDescriptorJSON extends Omit< PublicKeyCredentialDescriptor, 'id' @@ -59,6 +30,13 @@ PublicKeyCredentialDescriptor, 'id' id: string; } +export interface PublicKeyCredentialUserEntityJSON extends Omit < +PublicKeyCredentialUserEntity, 'id' +> { + // Should be a Base64-encoded credential ID. Will be converted to a Uint8Array in the browser + id: string; +} + /** * The value returned from navigator.credentials.create() */ |