UNPKG

@yubion-dev-team/yubion-fido2-server-sdk-client-js

Version:

This project is a client-side SDK to support WebAuthn API calls for YubiOn FIDO2 Server Service.

3 lines (2 loc) 2.68 kB
!function(e){"function"==typeof define&&define.amd?define(e):e()}(function(){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.convertCreationOptionsToBinary=function(e){if(PublicKeyCredential.parseCreationOptionsFromJSON)return PublicKeyCredential.parseCreationOptionsFromJSON(e);return{challenge:t(e.challenge),pubKeyCredParams:e.pubKeyCredParams,rp:{id:e.rp.id,name:e.rp.name},user:{id:t(e.user.id),name:e.user.name,displayName:e.user.displayName},attestation:e.attestation,authenticatorSelection:e.authenticatorSelection,excludeCredentials:e.excludeCredentials?.map(e=>({id:t(e.id),type:e.type,transports:e.transports})),extensions:e.extensions,timeout:e.timeout}},exports.convertPublicKeyCredentialToJsonable=function(t){if(t instanceof PublicKeyCredential&&t.toJSON)return t.toJSON();return e(t)},exports.convertRequestOptionsToBinary=function(e){if(PublicKeyCredential.parseRequestOptionsFromJSON)return PublicKeyCredential.parseRequestOptionsFromJSON(e);return{challenge:t(e.challenge),allowCredentials:e.allowCredentials?e.allowCredentials.map(e=>({id:t(e.id),type:e.type,transports:e.transports})):void 0,rpId:e.rpId,timeout:e.timeout,userVerification:e.userVerification,extensions:e.extensions}};const e=function(t){if(t instanceof Array){let n=[];for(let r of t)n.push(e(r));return n}if(t instanceof ArrayBuffer||t instanceof Uint8Array)return n(t);if(t instanceof PublicKeyCredential){const r={};r.id=t.id,r.rawId=n(t.rawId),r.type=t.type,r.response={},t.response instanceof AuthenticatorAssertionResponse?(r.response.clientDataJSON=n(t.response.clientDataJSON),r.response.authenticatorData=n(t.response.authenticatorData),r.response.signature=n(t.response.signature),t.response.userHandle&&(r.response.userHandle=n(t.response.userHandle))):t.response instanceof AuthenticatorAttestationResponse&&(r.response.attestationObject=n(t.response.attestationObject),r.response.clientDataJSON=n(t.response.clientDataJSON));const a=t.getClientExtensionResults();return a&&(r.clientExtensionResults=e(a)),"authenticatorAttachment"in t&&t.authenticatorAttachment&&(r.authenticatorAttachment=t.authenticatorAttachment),r}if(t instanceof Object){let n={};for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=e(t[r]));return n}return t};function t(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=atob(t),r=n.length,a=new Uint8Array(r);for(let e=0;e<r;e++)a[e]=n.charCodeAt(e);return a.buffer}function n(e){const t=new Uint8Array(e);let n="";for(let e=0;e<t.byteLength;e++)n+=String.fromCharCode(t[e]);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}}); //# sourceMappingURL=yubion-fido2-server-sdk-client.min.js.map