@simplewebauthn/browser 12.0.0 → 13.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/bundle/index.es5.umd.min.js +2 -2
- package/dist/bundle/index.umd.min.js +2 -2
- package/esm/helpers/browserSupportsWebAuthn.d.ts +4 -0
- package/esm/helpers/browserSupportsWebAuthn.d.ts.map +1 -1
- package/esm/helpers/browserSupportsWebAuthn.js +4 -1
- package/esm/helpers/browserSupportsWebAuthnAutofill.d.ts.map +1 -1
- package/esm/helpers/toAuthenticatorAttachment.d.ts +1 -1
- package/esm/helpers/toAuthenticatorAttachment.d.ts.map +1 -1
- package/esm/helpers/toPublicKeyCredentialDescriptor.d.ts +1 -1
- package/esm/helpers/toPublicKeyCredentialDescriptor.d.ts.map +1 -1
- package/esm/helpers/webAuthnAbortService.d.ts +8 -0
- package/esm/helpers/webAuthnAbortService.d.ts.map +1 -1
- package/esm/helpers/webAuthnAbortService.js +0 -8
- package/esm/index.d.ts +10 -15
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +10 -14
- package/esm/methods/startAuthentication.d.ts +7 -7
- package/esm/methods/startAuthentication.d.ts.map +1 -1
- package/esm/methods/startRegistration.d.ts +6 -6
- package/esm/methods/startRegistration.d.ts.map +1 -1
- package/esm/types/dom.d.ts +329 -0
- package/esm/types/dom.d.ts.map +1 -0
- package/esm/types/dom.js +1 -0
- package/esm/types/index.d.ts +205 -0
- package/esm/types/index.d.ts.map +1 -0
- package/esm/types/index.js +1 -0
- package/package.json +2 -4
- package/script/helpers/browserSupportsWebAuthn.d.ts +4 -0
- package/script/helpers/browserSupportsWebAuthn.d.ts.map +1 -1
- package/script/helpers/browserSupportsWebAuthn.js +4 -1
- package/script/helpers/browserSupportsWebAuthnAutofill.d.ts.map +1 -1
- package/script/helpers/toAuthenticatorAttachment.d.ts +1 -1
- package/script/helpers/toAuthenticatorAttachment.d.ts.map +1 -1
- package/script/helpers/toPublicKeyCredentialDescriptor.d.ts +1 -1
- package/script/helpers/toPublicKeyCredentialDescriptor.d.ts.map +1 -1
- package/script/helpers/webAuthnAbortService.d.ts +8 -0
- package/script/helpers/webAuthnAbortService.d.ts.map +1 -1
- package/script/helpers/webAuthnAbortService.js +0 -8
- package/script/index.d.ts +10 -15
- package/script/index.d.ts.map +1 -1
- package/script/index.js +24 -23
- package/script/methods/startAuthentication.d.ts +7 -7
- package/script/methods/startAuthentication.d.ts.map +1 -1
- package/script/methods/startRegistration.d.ts +6 -6
- package/script/methods/startRegistration.d.ts.map +1 -1
- package/script/types/dom.d.ts +329 -0
- package/script/types/dom.d.ts.map +1 -0
- package/script/types/dom.js +2 -0
- package/script/types/index.d.ts +205 -0
- package/script/types/index.d.ts.map +1 -0
- package/script/types/index.js +2 -0
package/README.md
CHANGED
|
@@ -22,13 +22,13 @@ and **[JSR](https://jsr.io/@simplewebauthn/browser)**:
|
|
|
22
22
|
### Node LTS 20.x and higher
|
|
23
23
|
|
|
24
24
|
```sh
|
|
25
|
-
npm install @simplewebauthn/browser
|
|
25
|
+
npm install @simplewebauthn/browser
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
### Deno v1.43 and higher
|
|
29
29
|
|
|
30
30
|
```sh
|
|
31
|
-
deno add jsr:@simplewebauthn/browser
|
|
31
|
+
deno add jsr:@simplewebauthn/browser
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
### UMD
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* [@simplewebauthn/browser@
|
|
2
|
-
function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}!function(e,t){if("function"==typeof define&&define.amd)define("SimpleWebAuthnBrowser",["exports"],t);else if("undefined"!=typeof exports)t(exports);else{var r={exports:{}};t(r.exports),e.SimpleWebAuthnBrowser=r.exports}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(t){function r(){r=function(){return n};var t,n={},o=Object.prototype,i=o.hasOwnProperty,a=Object.defineProperty||function(e,t,r){e[t]=r.value},u="function"==typeof Symbol?Symbol:{},c=u.iterator||"@@iterator",s=u.asyncIterator||"@@asyncIterator",l=u.toStringTag||"@@toStringTag";function f(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{f({},"")}catch(t){f=function(e,t,r){return e[t]=r}}function p(e,t,r,n){var o=t&&t.prototype instanceof g?t:g,i=Object.create(o.prototype),u=new j(n||[]);return a(i,"_invoke",{value:T(e,r,u)}),i}function h(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}n.wrap=p;var d="suspendedStart",y="suspendedYield",b="executing",v="completed",w={};function g(){}function m(){}function E(){}var R={};f(R,c,(function(){return this}));var A=Object.getPrototypeOf,O=A&&A(A(L([])));O&&O!==o&&i.call(O,c)&&(R=O);var _=E.prototype=g.prototype=Object.create(R);function S(e){["next","throw","return"].forEach((function(t){f(e,t,(function(e){return this._invoke(t,e)}))}))}function P(t,r){function n(o,a,u,c){var s=h(t[o],t,a);if("throw"!==s.type){var l=s.arg,f=l.value;return f&&"object"==e(f)&&i.call(f,"__await")?r.resolve(f.__await).then((function(e){n("next",e,u,c)}),(function(e){n("throw",e,u,c)})):r.resolve(f).then((function(e){l.value=e,u(l)}),(function(e){return n("throw",e,u,c)}))}c(s.arg)}var o;a(this,"_invoke",{value:function(e,t){function i(){return new r((function(r,o){n(e,t,r,o)}))}return o=o?o.then(i,i):i()}})}function T(e,r,n){var o=d;return function(i,a){if(o===b)throw Error("Generator is already running");if(o===v){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var u=n.delegate;if(u){var c=x(u,n);if(c){if(c===w)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===d)throw o=v,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=b;var s=h(e,r,n);if("normal"===s.type){if(o=n.done?v:y,s.arg===w)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=v,n.method="throw",n.arg=s.arg)}}}function x(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),w;var i=h(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,w;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,w):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,w)}function I(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function N(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function j(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(I,this),this.reset(!0)}function L(r){if(r||""===r){var n=r[c];if(n)return n.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var o=-1,a=function e(){for(;++o<r.length;)if(i.call(r,o))return e.value=r[o],e.done=!1,e;return e.value=t,e.done=!0,e};return a.next=a}}throw new TypeError(e(r)+" is not iterable")}return m.prototype=E,a(_,"constructor",{value:E,configurable:!0}),a(E,"constructor",{value:m,configurable:!0}),m.displayName=f(E,l,"GeneratorFunction"),n.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===m||"GeneratorFunction"===(t.displayName||t.name))},n.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,E):(e.__proto__=E,f(e,l,"GeneratorFunction")),e.prototype=Object.create(_),e},n.awrap=function(e){return{__await:e}},S(P.prototype),f(P.prototype,s,(function(){return this})),n.AsyncIterator=P,n.async=function(e,t,r,o,i){void 0===i&&(i=Promise);var a=new P(p(e,t,r,o),i);return n.isGeneratorFunction(t)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},S(_),f(_,l,"Generator"),f(_,c,(function(){return this})),f(_,"toString",(function(){return"[object Generator]"})),n.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},n.values=L,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(N),!e)for(var r in this)"t"===r.charAt(0)&&i.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(n,o){return u.type="throw",u.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var c=i.call(a,"catchLoc"),s=i.call(a,"finallyLoc");if(c&&s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,w):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),w},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),N(r),w}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;N(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),w}},n}function n(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,o)}function o(e){return function(){var t=this,r=arguments;return new Promise((function(o,i){var a=e.apply(t,r);function u(e){n(a,o,i,u,c,"next",e)}function c(e){n(a,o,i,u,c,"throw",e)}u(void 0)}))}}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,b(n.key),n)}}function a(e,t,r){return t&&i(e.prototype,t),r&&i(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(t,r,n){return r=p(r),function(t,r){if(r&&("object"==e(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(t)}(t,l()?Reflect.construct(r,n||[],p(t).constructor):r.apply(t,n))}function s(e){var t="function"==typeof Map?new Map:void 0;return s=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return function(e,t,r){if(l())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var o=new(e.bind.apply(e,n));return r&&f(o,r.prototype),o}(e,arguments,p(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),f(r,e)},s(e)}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(l=function(){return!!e})()}function f(e,t){return f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},f(e,t)}function p(e){return p=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},p(e)}function h(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function d(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?h(Object(r),!0).forEach((function(t){y(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):h(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function y(e,t,r){return(t=b(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function b(t){var r=function(t,r){if("object"!=e(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var o=n.call(t,r||"default");if("object"!=e(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(t,"string");return"symbol"==e(r)?r:r+""}function v(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return w(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?w(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){u=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function w(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function g(e){var t,r="",n=v(new Uint8Array(e));try{for(n.s();!(t=n.n()).done;){var o=t.value;r+=String.fromCharCode(o)}}catch(e){n.e(e)}finally{n.f()}return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function m(e){for(var t=e.replace(/-/g,"+").replace(/_/g,"/"),r=(4-t.length%4)%4,n=t.padEnd(t.length+r,"="),o=atob(n),i=new ArrayBuffer(o.length),a=new Uint8Array(i),u=0;u<o.length;u++)a[u]=o.charCodeAt(u);return i}function E(){var e;return R.stubThis(void 0!==(null===(e=window)||void 0===e?void 0:e.PublicKeyCredential)&&"function"==typeof window.PublicKeyCredential)}Object.defineProperty(t,"__esModule",{value:!0}),t.WebAuthnError=t.WebAuthnAbortService=void 0,t.base64URLStringToBuffer=m,t.browserSupportsWebAuthn=E,t.browserSupportsWebAuthnAutofill=L,t.bufferToBase64URLString=g,t.platformAuthenticatorIsAvailable=function(){if(!E())return new Promise((function(e){return e(!1)}));return PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable()},t.startAuthentication=function(e){return U.apply(this,arguments)},t.startRegistration=function(e){return N.apply(this,arguments)};var R={stubThis:function(e){return e}};function A(e){var t=e.id;return d(d({},e),{},{id:m(t),transports:e.transports})}function O(e){return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}var _=t.WebAuthnError=function(e){function t(e){var r,n=e.message,o=e.code,i=e.cause,a=e.name;return u(this,t),r=c(this,t,[n,{cause:i}]),Object.defineProperty(r,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),r.name=null!=a?a:i.name,r.code=o,r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&f(e,t)}(t,e),a(t)}(s(Error));function S(e){var t=e.error,r=e.options,n=r.publicKey;if(!n)throw Error("options was missing required publicKey property");if("AbortError"===t.name){if(r.signal instanceof AbortSignal)return new _({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else if("ConstraintError"===t.name){var o,i,a;if(!0===(null===(o=n.authenticatorSelection)||void 0===o?void 0:o.requireResidentKey))return new _({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:t});if("conditional"===r.mediation&&"required"===(null===(i=n.authenticatorSelection)||void 0===i?void 0:i.userVerification))return new _({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:t});if("required"===(null===(a=n.authenticatorSelection)||void 0===a?void 0:a.userVerification))return new _({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:t})}else{if("InvalidStateError"===t.name)return new _({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:t});if("NotAllowedError"===t.name)return new _({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if("NotSupportedError"===t.name)return 0===n.pubKeyCredParams.filter((function(e){return"public-key"===e.type})).length?new _({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:t}):new _({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:t});if("SecurityError"===t.name){var u=window.location.hostname;if(!O(u))return new _({message:"".concat(window.location.hostname," is an invalid domain"),code:"ERROR_INVALID_DOMAIN",cause:t});if(n.rp.id!==u)return new _({message:'The RP ID "'.concat(n.rp.id,'" is invalid for this domain'),code:"ERROR_INVALID_RP_ID",cause:t})}else if("TypeError"===t.name){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new _({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:t})}else if("UnknownError"===t.name)return new _({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return t}var P=function(){return a((function e(){u(this,e),Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}),[{key:"createNewAbortSignal",value:function(){if(this.controller){var e=new Error("Cancelling existing WebAuthn API call for new one");e.name="AbortError",this.controller.abort(e)}var t=new AbortController;return this.controller=t,t.signal}},{key:"cancelCeremony",value:function(){if(this.controller){var e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}}])}(),T=t.WebAuthnAbortService=new P,x=["cross-platform","platform"];function I(e){if(e&&!(x.indexOf(e)<0))return e}function N(){return(N=o(r().mark((function e(t){var n,o,i,a,u,c,s,l,f,p,h,y,b,v,w,R,O;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=t.optionsJSON,i=t.useAutoRegister,a=void 0!==i&&i,E()){e.next=3;break}throw new Error("WebAuthn is not supported in this browser");case 3:return u=d(d({},o),{},{challenge:m(o.challenge),user:d(d({},o.user),{},{id:m(o.user.id)}),excludeCredentials:null===(n=o.excludeCredentials)||void 0===n?void 0:n.map(A)}),c={},a&&(c.mediation="conditional"),c.publicKey=u,c.signal=T.createNewAbortSignal(),e.prev=8,e.next=11,navigator.credentials.create(c);case 11:s=e.sent,e.next=17;break;case 14:throw e.prev=14,e.t0=e.catch(8),S({error:e.t0,options:c});case 17:if(s){e.next=19;break}throw new Error("Registration was not completed");case 19:if(f=(l=s).id,p=l.rawId,h=l.response,y=l.type,b=void 0,"function"==typeof h.getTransports&&(b=h.getTransports()),v=void 0,"function"==typeof h.getPublicKeyAlgorithm)try{v=h.getPublicKeyAlgorithm()}catch(e){j("getPublicKeyAlgorithm()",e)}if(w=void 0,"function"==typeof h.getPublicKey)try{null!==(R=h.getPublicKey())&&(w=g(R))}catch(e){j("getPublicKey()",e)}if("function"==typeof h.getAuthenticatorData)try{O=g(h.getAuthenticatorData())}catch(e){j("getAuthenticatorData()",e)}return e.abrupt("return",{id:f,rawId:g(p),response:{attestationObject:g(h.attestationObject),clientDataJSON:g(h.clientDataJSON),transports:b,publicKeyAlgorithm:v,publicKey:w,authenticatorData:O},type:y,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:I(s.authenticatorAttachment)});case 28:case"end":return e.stop()}}),e,null,[[8,14]])})))).apply(this,arguments)}function j(e,t){console.warn("The browser extension that intercepted this WebAuthn API call incorrectly implemented ".concat(e,". You should report this error to them.\n"),t)}function L(){if(!E())return C.stubThis(new Promise((function(e){return e(!1)})));var e=window.PublicKeyCredential;return void 0===(null==e?void 0:e.isConditionalMediationAvailable)?C.stubThis(new Promise((function(e){return e(!1)}))):C.stubThis(e.isConditionalMediationAvailable())}var C={stubThis:function(e){return e}};function D(e){var t=e.error,r=e.options,n=r.publicKey;if(!n)throw Error("options was missing required publicKey property");if("AbortError"===t.name){if(r.signal instanceof AbortSignal)return new _({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if("NotAllowedError"===t.name)return new _({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if("SecurityError"===t.name){var o=window.location.hostname;if(!O(o))return new _({message:"".concat(window.location.hostname," is an invalid domain"),code:"ERROR_INVALID_DOMAIN",cause:t});if(n.rpId!==o)return new _({message:'The RP ID "'.concat(n.rpId,'" is invalid for this domain'),code:"ERROR_INVALID_RP_ID",cause:t})}else if("UnknownError"===t.name)return new _({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return t}function U(){return(U=o(r().mark((function e(t){var n,o,i,a,u,c,s,l,f,p,h,y,b,v,w,R,O;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=t.optionsJSON,i=t.useBrowserAutofill,a=void 0!==i&&i,u=t.verifyBrowserAutofillInput,c=void 0===u||u,E()){e.next=3;break}throw new Error("WebAuthn is not supported in this browser");case 3:if(0!==(null===(n=o.allowCredentials)||void 0===n?void 0:n.length)&&(s=null===(l=o.allowCredentials)||void 0===l?void 0:l.map(A)),f=d(d({},o),{},{challenge:m(o.challenge),allowCredentials:s}),p={},!a){e.next=16;break}return e.next=9,L();case 9:if(e.sent){e.next=11;break}throw Error("Browser does not support WebAuthn autofill");case 11:if(!(document.querySelectorAll("input[autocomplete$='webauthn']").length<1&&c)){e.next=14;break}throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');case 14:p.mediation="conditional",f.allowCredentials=[];case 16:return p.publicKey=f,p.signal=T.createNewAbortSignal(),e.prev=18,e.next=21,navigator.credentials.get(p);case 21:h=e.sent,e.next=27;break;case 24:throw e.prev=24,e.t0=e.catch(18),D({error:e.t0,options:p});case 27:if(h){e.next=29;break}throw new Error("Authentication was not completed");case 29:return b=(y=h).id,v=y.rawId,w=y.response,R=y.type,O=void 0,w.userHandle&&(O=g(w.userHandle)),e.abrupt("return",{id:b,rawId:g(v),response:{authenticatorData:g(w.authenticatorData),clientDataJSON:g(w.clientDataJSON),signature:g(w.signature),userHandle:O},type:R,clientExtensionResults:h.getClientExtensionResults(),authenticatorAttachment:I(h.authenticatorAttachment)});case 33:case"end":return e.stop()}}),e,null,[[18,24]])})))).apply(this,arguments)}}));
|
|
1
|
+
/* [@simplewebauthn/browser@13.0.0] */
|
|
2
|
+
function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}!function(e,t){if("function"==typeof define&&define.amd)define("SimpleWebAuthnBrowser",["exports"],t);else if("undefined"!=typeof exports)t(exports);else{var r={exports:{}};t(r.exports),e.SimpleWebAuthnBrowser=r.exports}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(t){function r(){r=function(){return n};var t,n={},o=Object.prototype,i=o.hasOwnProperty,a=Object.defineProperty||function(e,t,r){e[t]=r.value},u="function"==typeof Symbol?Symbol:{},c=u.iterator||"@@iterator",s=u.asyncIterator||"@@asyncIterator",l=u.toStringTag||"@@toStringTag";function f(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{f({},"")}catch(t){f=function(e,t,r){return e[t]=r}}function p(e,t,r,n){var o=t&&t.prototype instanceof g?t:g,i=Object.create(o.prototype),u=new j(n||[]);return a(i,"_invoke",{value:T(e,r,u)}),i}function h(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}n.wrap=p;var d="suspendedStart",y="suspendedYield",b="executing",v="completed",w={};function g(){}function m(){}function E(){}var R={};f(R,c,(function(){return this}));var A=Object.getPrototypeOf,O=A&&A(A(L([])));O&&O!==o&&i.call(O,c)&&(R=O);var _=E.prototype=g.prototype=Object.create(R);function S(e){["next","throw","return"].forEach((function(t){f(e,t,(function(e){return this._invoke(t,e)}))}))}function P(t,r){function n(o,a,u,c){var s=h(t[o],t,a);if("throw"!==s.type){var l=s.arg,f=l.value;return f&&"object"==e(f)&&i.call(f,"__await")?r.resolve(f.__await).then((function(e){n("next",e,u,c)}),(function(e){n("throw",e,u,c)})):r.resolve(f).then((function(e){l.value=e,u(l)}),(function(e){return n("throw",e,u,c)}))}c(s.arg)}var o;a(this,"_invoke",{value:function(e,t){function i(){return new r((function(r,o){n(e,t,r,o)}))}return o=o?o.then(i,i):i()}})}function T(e,r,n){var o=d;return function(i,a){if(o===b)throw Error("Generator is already running");if(o===v){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var u=n.delegate;if(u){var c=I(u,n);if(c){if(c===w)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===d)throw o=v,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=b;var s=h(e,r,n);if("normal"===s.type){if(o=n.done?v:y,s.arg===w)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=v,n.method="throw",n.arg=s.arg)}}}function I(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,I(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),w;var i=h(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,w;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,w):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,w)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function N(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function j(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function L(r){if(r||""===r){var n=r[c];if(n)return n.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var o=-1,a=function e(){for(;++o<r.length;)if(i.call(r,o))return e.value=r[o],e.done=!1,e;return e.value=t,e.done=!0,e};return a.next=a}}throw new TypeError(e(r)+" is not iterable")}return m.prototype=E,a(_,"constructor",{value:E,configurable:!0}),a(E,"constructor",{value:m,configurable:!0}),m.displayName=f(E,l,"GeneratorFunction"),n.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===m||"GeneratorFunction"===(t.displayName||t.name))},n.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,E):(e.__proto__=E,f(e,l,"GeneratorFunction")),e.prototype=Object.create(_),e},n.awrap=function(e){return{__await:e}},S(P.prototype),f(P.prototype,s,(function(){return this})),n.AsyncIterator=P,n.async=function(e,t,r,o,i){void 0===i&&(i=Promise);var a=new P(p(e,t,r,o),i);return n.isGeneratorFunction(t)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},S(_),f(_,l,"Generator"),f(_,c,(function(){return this})),f(_,"toString",(function(){return"[object Generator]"})),n.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},n.values=L,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(N),!e)for(var r in this)"t"===r.charAt(0)&&i.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(n,o){return u.type="throw",u.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var c=i.call(a,"catchLoc"),s=i.call(a,"finallyLoc");if(c&&s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,w):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),w},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),N(r),w}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;N(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),w}},n}function n(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,o)}function o(e){return function(){var t=this,r=arguments;return new Promise((function(o,i){var a=e.apply(t,r);function u(e){n(a,o,i,u,c,"next",e)}function c(e){n(a,o,i,u,c,"throw",e)}u(void 0)}))}}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,b(n.key),n)}}function a(e,t,r){return t&&i(e.prototype,t),r&&i(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(t,r,n){return r=p(r),function(t,r){if(r&&("object"==e(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(t)}(t,l()?Reflect.construct(r,n||[],p(t).constructor):r.apply(t,n))}function s(e){var t="function"==typeof Map?new Map:void 0;return s=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return function(e,t,r){if(l())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var o=new(e.bind.apply(e,n));return r&&f(o,r.prototype),o}(e,arguments,p(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),f(r,e)},s(e)}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(l=function(){return!!e})()}function f(e,t){return f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},f(e,t)}function p(e){return p=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},p(e)}function h(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function d(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?h(Object(r),!0).forEach((function(t){y(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):h(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function y(e,t,r){return(t=b(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function b(t){var r=function(t,r){if("object"!=e(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var o=n.call(t,r||"default");if("object"!=e(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(t,"string");return"symbol"==e(r)?r:r+""}function v(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return w(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?w(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){u=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function w(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function g(e){var t,r="",n=v(new Uint8Array(e));try{for(n.s();!(t=n.n()).done;){var o=t.value;r+=String.fromCharCode(o)}}catch(e){n.e(e)}finally{n.f()}return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function m(e){for(var t=e.replace(/-/g,"+").replace(/_/g,"/"),r=(4-t.length%4)%4,n=t.padEnd(t.length+r,"="),o=atob(n),i=new ArrayBuffer(o.length),a=new Uint8Array(i),u=0;u<o.length;u++)a[u]=o.charCodeAt(u);return i}function E(){var e;return R.stubThis(void 0!==(null===(e=window)||void 0===e?void 0:e.PublicKeyCredential)&&"function"==typeof window.PublicKeyCredential)}Object.defineProperty(t,"__esModule",{value:!0}),t._browserSupportsWebAuthnInternals=t._browserSupportsWebAuthnAutofillInternals=t.WebAuthnError=t.WebAuthnAbortService=void 0,t.base64URLStringToBuffer=m,t.browserSupportsWebAuthn=E,t.browserSupportsWebAuthnAutofill=L,t.bufferToBase64URLString=g,t.platformAuthenticatorIsAvailable=function(){if(!E())return new Promise((function(e){return e(!1)}));return PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable()},t.startAuthentication=function(e){return U.apply(this,arguments)},t.startRegistration=function(e){return N.apply(this,arguments)};var R=t._browserSupportsWebAuthnInternals={stubThis:function(e){return e}};function A(e){var t=e.id;return d(d({},e),{},{id:m(t),transports:e.transports})}function O(e){return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}var _=t.WebAuthnError=function(e){function t(e){var r,n=e.message,o=e.code,i=e.cause,a=e.name;return u(this,t),r=c(this,t,[n,{cause:i}]),Object.defineProperty(r,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),r.name=null!=a?a:i.name,r.code=o,r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&f(e,t)}(t,e),a(t)}(s(Error));function S(e){var t=e.error,r=e.options,n=r.publicKey;if(!n)throw Error("options was missing required publicKey property");if("AbortError"===t.name){if(r.signal instanceof AbortSignal)return new _({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else if("ConstraintError"===t.name){var o,i,a;if(!0===(null===(o=n.authenticatorSelection)||void 0===o?void 0:o.requireResidentKey))return new _({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:t});if("conditional"===r.mediation&&"required"===(null===(i=n.authenticatorSelection)||void 0===i?void 0:i.userVerification))return new _({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:t});if("required"===(null===(a=n.authenticatorSelection)||void 0===a?void 0:a.userVerification))return new _({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:t})}else{if("InvalidStateError"===t.name)return new _({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:t});if("NotAllowedError"===t.name)return new _({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if("NotSupportedError"===t.name)return 0===n.pubKeyCredParams.filter((function(e){return"public-key"===e.type})).length?new _({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:t}):new _({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:t});if("SecurityError"===t.name){var u=window.location.hostname;if(!O(u))return new _({message:"".concat(window.location.hostname," is an invalid domain"),code:"ERROR_INVALID_DOMAIN",cause:t});if(n.rp.id!==u)return new _({message:'The RP ID "'.concat(n.rp.id,'" is invalid for this domain'),code:"ERROR_INVALID_RP_ID",cause:t})}else if("TypeError"===t.name){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new _({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:t})}else if("UnknownError"===t.name)return new _({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return t}var P=function(){return a((function e(){u(this,e),Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}),[{key:"createNewAbortSignal",value:function(){if(this.controller){var e=new Error("Cancelling existing WebAuthn API call for new one");e.name="AbortError",this.controller.abort(e)}var t=new AbortController;return this.controller=t,t.signal}},{key:"cancelCeremony",value:function(){if(this.controller){var e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}}])}(),T=t.WebAuthnAbortService=new P,I=["cross-platform","platform"];function x(e){if(e&&!(I.indexOf(e)<0))return e}function N(){return(N=o(r().mark((function e(t){var n,o,i,a,u,c,s,l,f,p,h,y,b,v,w,R,O;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=t.optionsJSON,i=t.useAutoRegister,a=void 0!==i&&i,E()){e.next=3;break}throw new Error("WebAuthn is not supported in this browser");case 3:return u=d(d({},o),{},{challenge:m(o.challenge),user:d(d({},o.user),{},{id:m(o.user.id)}),excludeCredentials:null===(n=o.excludeCredentials)||void 0===n?void 0:n.map(A)}),c={},a&&(c.mediation="conditional"),c.publicKey=u,c.signal=T.createNewAbortSignal(),e.prev=8,e.next=11,navigator.credentials.create(c);case 11:s=e.sent,e.next=17;break;case 14:throw e.prev=14,e.t0=e.catch(8),S({error:e.t0,options:c});case 17:if(s){e.next=19;break}throw new Error("Registration was not completed");case 19:if(f=(l=s).id,p=l.rawId,h=l.response,y=l.type,b=void 0,"function"==typeof h.getTransports&&(b=h.getTransports()),v=void 0,"function"==typeof h.getPublicKeyAlgorithm)try{v=h.getPublicKeyAlgorithm()}catch(e){j("getPublicKeyAlgorithm()",e)}if(w=void 0,"function"==typeof h.getPublicKey)try{null!==(R=h.getPublicKey())&&(w=g(R))}catch(e){j("getPublicKey()",e)}if("function"==typeof h.getAuthenticatorData)try{O=g(h.getAuthenticatorData())}catch(e){j("getAuthenticatorData()",e)}return e.abrupt("return",{id:f,rawId:g(p),response:{attestationObject:g(h.attestationObject),clientDataJSON:g(h.clientDataJSON),transports:b,publicKeyAlgorithm:v,publicKey:w,authenticatorData:O},type:y,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:x(s.authenticatorAttachment)});case 28:case"end":return e.stop()}}),e,null,[[8,14]])})))).apply(this,arguments)}function j(e,t){console.warn("The browser extension that intercepted this WebAuthn API call incorrectly implemented ".concat(e,". You should report this error to them.\n"),t)}function L(){if(!E())return C.stubThis(new Promise((function(e){return e(!1)})));var e=window.PublicKeyCredential;return void 0===(null==e?void 0:e.isConditionalMediationAvailable)?C.stubThis(new Promise((function(e){return e(!1)}))):C.stubThis(e.isConditionalMediationAvailable())}var C=t._browserSupportsWebAuthnAutofillInternals={stubThis:function(e){return e}};function D(e){var t=e.error,r=e.options,n=r.publicKey;if(!n)throw Error("options was missing required publicKey property");if("AbortError"===t.name){if(r.signal instanceof AbortSignal)return new _({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if("NotAllowedError"===t.name)return new _({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if("SecurityError"===t.name){var o=window.location.hostname;if(!O(o))return new _({message:"".concat(window.location.hostname," is an invalid domain"),code:"ERROR_INVALID_DOMAIN",cause:t});if(n.rpId!==o)return new _({message:'The RP ID "'.concat(n.rpId,'" is invalid for this domain'),code:"ERROR_INVALID_RP_ID",cause:t})}else if("UnknownError"===t.name)return new _({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return t}function U(){return(U=o(r().mark((function e(t){var n,o,i,a,u,c,s,l,f,p,h,y,b,v,w,R,O;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=t.optionsJSON,i=t.useBrowserAutofill,a=void 0!==i&&i,u=t.verifyBrowserAutofillInput,c=void 0===u||u,E()){e.next=3;break}throw new Error("WebAuthn is not supported in this browser");case 3:if(0!==(null===(n=o.allowCredentials)||void 0===n?void 0:n.length)&&(s=null===(l=o.allowCredentials)||void 0===l?void 0:l.map(A)),f=d(d({},o),{},{challenge:m(o.challenge),allowCredentials:s}),p={},!a){e.next=16;break}return e.next=9,L();case 9:if(e.sent){e.next=11;break}throw Error("Browser does not support WebAuthn autofill");case 11:if(!(document.querySelectorAll("input[autocomplete$='webauthn']").length<1&&c)){e.next=14;break}throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');case 14:p.mediation="conditional",f.allowCredentials=[];case 16:return p.publicKey=f,p.signal=T.createNewAbortSignal(),e.prev=18,e.next=21,navigator.credentials.get(p);case 21:h=e.sent,e.next=27;break;case 24:throw e.prev=24,e.t0=e.catch(18),D({error:e.t0,options:p});case 27:if(h){e.next=29;break}throw new Error("Authentication was not completed");case 29:return b=(y=h).id,v=y.rawId,w=y.response,R=y.type,O=void 0,w.userHandle&&(O=g(w.userHandle)),e.abrupt("return",{id:b,rawId:g(v),response:{authenticatorData:g(w.authenticatorData),clientDataJSON:g(w.clientDataJSON),signature:g(w.signature),userHandle:O},type:R,clientExtensionResults:h.getClientExtensionResults(),authenticatorAttachment:x(h.authenticatorAttachment)});case 33:case"end":return e.stop()}}),e,null,[[18,24]])})))).apply(this,arguments)}}));
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* [@simplewebauthn/browser@
|
|
2
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).SimpleWebAuthnBrowser={})}(this,(function(e){"use strict";function t(e){const t=new Uint8Array(e);let r="";for(const e of t)r+=String.fromCharCode(e);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function r(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),r=(4-t.length%4)%4,n=t.padEnd(t.length+r,"="),o=atob(n),i=new ArrayBuffer(o.length),a=new Uint8Array(i);for(let e=0;e<o.length;e++)a[e]=o.charCodeAt(e);return i}function n(){return o.stubThis(void 0!==globalThis?.PublicKeyCredential&&"function"==typeof globalThis.PublicKeyCredential)}const o={stubThis:e=>e};function i(e){const{id:t}=e;return{...e,id:r(t),transports:e.transports}}function a(e){return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}class s extends Error{constructor({message:e,code:t,cause:r,name:n}){super(e,{cause:r}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=n??r.name,this.code=t}}const
|
|
1
|
+
/* [@simplewebauthn/browser@13.0.0] */
|
|
2
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).SimpleWebAuthnBrowser={})}(this,(function(e){"use strict";function t(e){const t=new Uint8Array(e);let r="";for(const e of t)r+=String.fromCharCode(e);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function r(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),r=(4-t.length%4)%4,n=t.padEnd(t.length+r,"="),o=atob(n),i=new ArrayBuffer(o.length),a=new Uint8Array(i);for(let e=0;e<o.length;e++)a[e]=o.charCodeAt(e);return i}function n(){return o.stubThis(void 0!==globalThis?.PublicKeyCredential&&"function"==typeof globalThis.PublicKeyCredential)}const o={stubThis:e=>e};function i(e){const{id:t}=e;return{...e,id:r(t),transports:e.transports}}function a(e){return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}class s extends Error{constructor({message:e,code:t,cause:r,name:n}){super(e,{cause:r}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=n??r.name,this.code=t}}const l=new class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){const e=new Error("Cancelling existing WebAuthn API call for new one");e.name="AbortError",this.controller.abort(e)}const e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){const e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}},c=["cross-platform","platform"];function u(e){if(e&&!(c.indexOf(e)<0))return e}function d(e,t){console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${e}. You should report this error to them.\n`,t)}function h(){if(!n())return f.stubThis(new Promise((e=>e(!1))));const e=globalThis.PublicKeyCredential;return void 0===e?.isConditionalMediationAvailable?f.stubThis(new Promise((e=>e(!1)))):f.stubThis(e.isConditionalMediationAvailable())}const f={stubThis:e=>e};e.WebAuthnAbortService=l,e.WebAuthnError=s,e._browserSupportsWebAuthnAutofillInternals=f,e._browserSupportsWebAuthnInternals=o,e.base64URLStringToBuffer=r,e.browserSupportsWebAuthn=n,e.browserSupportsWebAuthnAutofill=h,e.bufferToBase64URLString=t,e.platformAuthenticatorIsAvailable=function(){return n()?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():new Promise((e=>e(!1)))},e.startAuthentication=async function(e){const{optionsJSON:o,useBrowserAutofill:c=!1,verifyBrowserAutofillInput:d=!0}=e;if(!n())throw new Error("WebAuthn is not supported in this browser");let f;0!==o.allowCredentials?.length&&(f=o.allowCredentials?.map(i));const p={...o,challenge:r(o.challenge),allowCredentials:f},R={};if(c){if(!await h())throw Error("Browser does not support WebAuthn autofill");if(document.querySelectorAll("input[autocomplete$='webauthn']").length<1&&d)throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');R.mediation="conditional",p.allowCredentials=[]}let b;R.publicKey=p,R.signal=l.createNewAbortSignal();try{b=await navigator.credentials.get(R)}catch(e){throw function({error:e,options:t}){const{publicKey:r}=t;if(!r)throw Error("options was missing required publicKey property");if("AbortError"===e.name){if(t.signal instanceof AbortSignal)return new s({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else{if("NotAllowedError"===e.name)return new s({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});if("SecurityError"===e.name){const t=globalThis.location.hostname;if(!a(t))return new s({message:`${globalThis.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e});if(r.rpId!==t)return new s({message:`The RP ID "${r.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else if("UnknownError"===e.name)return new s({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:e})}return e}({error:e,options:R})}if(!b)throw new Error("Authentication was not completed");const{id:g,rawId:A,response:E,type:w}=b;let m;return E.userHandle&&(m=t(E.userHandle)),{id:g,rawId:t(A),response:{authenticatorData:t(E.authenticatorData),clientDataJSON:t(E.clientDataJSON),signature:t(E.signature),userHandle:m},type:w,clientExtensionResults:b.getClientExtensionResults(),authenticatorAttachment:u(b.authenticatorAttachment)}},e.startRegistration=async function(e){const{optionsJSON:o,useAutoRegister:c=!1}=e;if(!n())throw new Error("WebAuthn is not supported in this browser");const h={...o,challenge:r(o.challenge),user:{...o.user,id:r(o.user.id)},excludeCredentials:o.excludeCredentials?.map(i)},f={};let p;c&&(f.mediation="conditional"),f.publicKey=h,f.signal=l.createNewAbortSignal();try{p=await navigator.credentials.create(f)}catch(e){throw function({error:e,options:t}){const{publicKey:r}=t;if(!r)throw Error("options was missing required publicKey property");if("AbortError"===e.name){if(t.signal instanceof AbortSignal)return new s({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else if("ConstraintError"===e.name){if(!0===r.authenticatorSelection?.requireResidentKey)return new s({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:e});if("conditional"===t.mediation&&"required"===r.authenticatorSelection?.userVerification)return new s({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:e});if("required"===r.authenticatorSelection?.userVerification)return new s({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:e})}else{if("InvalidStateError"===e.name)return new s({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:e});if("NotAllowedError"===e.name)return new s({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});if("NotSupportedError"===e.name)return 0===r.pubKeyCredParams.filter((e=>"public-key"===e.type)).length?new s({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:e}):new s({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:e});if("SecurityError"===e.name){const t=globalThis.location.hostname;if(!a(t))return new s({message:`${globalThis.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e});if(r.rp.id!==t)return new s({message:`The RP ID "${r.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else if("TypeError"===e.name){if(r.user.id.byteLength<1||r.user.id.byteLength>64)return new s({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:e})}else if("UnknownError"===e.name)return new s({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:e})}return e}({error:e,options:f})}if(!p)throw new Error("Registration was not completed");const{id:R,rawId:b,response:g,type:A}=p;let E,w,m,y;if("function"==typeof g.getTransports&&(E=g.getTransports()),"function"==typeof g.getPublicKeyAlgorithm)try{w=g.getPublicKeyAlgorithm()}catch(e){d("getPublicKeyAlgorithm()",e)}if("function"==typeof g.getPublicKey)try{const e=g.getPublicKey();null!==e&&(m=t(e))}catch(e){d("getPublicKey()",e)}if("function"==typeof g.getAuthenticatorData)try{y=t(g.getAuthenticatorData())}catch(e){d("getAuthenticatorData()",e)}return{id:R,rawId:t(b),response:{attestationObject:t(g.attestationObject),clientDataJSON:t(g.clientDataJSON),transports:E,publicKeyAlgorithm:w,publicKey:m,authenticatorData:y},type:A,clientExtensionResults:p.getClientExtensionResults(),authenticatorAttachment:u(p.authenticatorAttachment)}}}));
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
* Determine if the browser is capable of Webauthn
|
|
3
3
|
*/
|
|
4
4
|
export declare function browserSupportsWebAuthn(): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Make it possible to stub the return value during testing
|
|
7
|
+
* @ignore Don't include this in docs output
|
|
8
|
+
*/
|
|
5
9
|
export declare const _browserSupportsWebAuthnInternals: {
|
|
6
10
|
stubThis: (value: boolean) => boolean;
|
|
7
11
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browserSupportsWebAuthn.d.ts","sourceRoot":"","sources":["../../src/helpers/browserSupportsWebAuthn.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,OAAO,CAKjD;
|
|
1
|
+
{"version":3,"file":"browserSupportsWebAuthn.d.ts","sourceRoot":"","sources":["../../src/helpers/browserSupportsWebAuthn.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,OAAO,CAKjD;AAED;;;GAGG;AACH,eAAO,MAAM,iCAAiC;sBAC1B,OAAO;CAC1B,CAAC"}
|
|
@@ -5,7 +5,10 @@ export function browserSupportsWebAuthn() {
|
|
|
5
5
|
return _browserSupportsWebAuthnInternals.stubThis(globalThis?.PublicKeyCredential !== undefined &&
|
|
6
6
|
typeof globalThis.PublicKeyCredential === 'function');
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Make it possible to stub the return value during testing
|
|
10
|
+
* @ignore Don't include this in docs output
|
|
11
|
+
*/
|
|
9
12
|
export const _browserSupportsWebAuthnInternals = {
|
|
10
13
|
stubThis: (value) => value,
|
|
11
14
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browserSupportsWebAuthnAutofill.d.ts","sourceRoot":"","sources":["../../src/helpers/browserSupportsWebAuthnAutofill.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"browserSupportsWebAuthnAutofill.d.ts","sourceRoot":"","sources":["../../src/helpers/browserSupportsWebAuthnAutofill.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAgB,+BAA+B,IAAI,OAAO,CAAC,OAAO,CAAC,CAyBlE;AAGD,eAAO,MAAM,yCAAyC;sBAClC,OAAO,CAAC,OAAO,CAAC;CACnC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toAuthenticatorAttachment.d.ts","sourceRoot":"","sources":["../../src/helpers/toAuthenticatorAttachment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"toAuthenticatorAttachment.d.ts","sourceRoot":"","sources":["../../src/helpers/toAuthenticatorAttachment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAIjE;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,MAAM,GAAG,IAAI,GACxB,uBAAuB,GAAG,SAAS,CAUrC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { PublicKeyCredentialDescriptor, PublicKeyCredentialDescriptorJSON } from '
|
|
1
|
+
import type { PublicKeyCredentialDescriptor, PublicKeyCredentialDescriptorJSON } from '../types/index.js';
|
|
2
2
|
export declare function toPublicKeyCredentialDescriptor(descriptor: PublicKeyCredentialDescriptorJSON): PublicKeyCredentialDescriptor;
|
|
3
3
|
//# sourceMappingURL=toPublicKeyCredentialDescriptor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toPublicKeyCredentialDescriptor.d.ts","sourceRoot":"","sources":["../../src/helpers/toPublicKeyCredentialDescriptor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,6BAA6B,EAC7B,iCAAiC,EAClC,MAAM,
|
|
1
|
+
{"version":3,"file":"toPublicKeyCredentialDescriptor.d.ts","sourceRoot":"","sources":["../../src/helpers/toPublicKeyCredentialDescriptor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,6BAA6B,EAC7B,iCAAiC,EAClC,MAAM,mBAAmB,CAAC;AAG3B,wBAAgB,+BAA+B,CAC7C,UAAU,EAAE,iCAAiC,GAC5C,6BAA6B,CAa/B"}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
interface WebAuthnAbortService {
|
|
2
|
+
/**
|
|
3
|
+
* Prepare an abort signal that will help support multiple auth attempts without needing to
|
|
4
|
+
* reload the page. This is automatically called whenever `startRegistration()` and
|
|
5
|
+
* `startAuthentication()` are called.
|
|
6
|
+
*/
|
|
2
7
|
createNewAbortSignal(): AbortSignal;
|
|
8
|
+
/**
|
|
9
|
+
* Manually cancel any active WebAuthn registration or authentication attempt.
|
|
10
|
+
*/
|
|
3
11
|
cancelCeremony(): void;
|
|
4
12
|
}
|
|
5
13
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webAuthnAbortService.d.ts","sourceRoot":"","sources":["../../src/helpers/webAuthnAbortService.ts"],"names":[],"mappings":"AAAA,UAAU,oBAAoB;IAC5B,oBAAoB,IAAI,WAAW,CAAC;IACpC,cAAc,IAAI,IAAI,CAAC;CACxB;
|
|
1
|
+
{"version":3,"file":"webAuthnAbortService.d.ts","sourceRoot":"","sources":["../../src/helpers/webAuthnAbortService.ts"],"names":[],"mappings":"AAAA,UAAU,oBAAoB;IAC5B;;;;OAIG;IACH,oBAAoB,IAAI,WAAW,CAAC;IACpC;;OAEG;IACH,cAAc,IAAI,IAAI,CAAC;CACxB;AAkCD;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,EAAE,oBAAqD,CAAC"}
|
|
@@ -7,11 +7,6 @@ class BaseWebAuthnAbortService {
|
|
|
7
7
|
value: void 0
|
|
8
8
|
});
|
|
9
9
|
}
|
|
10
|
-
/**
|
|
11
|
-
* Prepare an abort signal that will help support multiple auth attempts without needing to
|
|
12
|
-
* reload the page. This is automatically called whenever `startRegistration()` and
|
|
13
|
-
* `startAuthentication()` are called.
|
|
14
|
-
*/
|
|
15
10
|
createNewAbortSignal() {
|
|
16
11
|
// Abort any existing calls to navigator.credentials.create() or navigator.credentials.get()
|
|
17
12
|
if (this.controller) {
|
|
@@ -23,9 +18,6 @@ class BaseWebAuthnAbortService {
|
|
|
23
18
|
this.controller = newController;
|
|
24
19
|
return newController.signal;
|
|
25
20
|
}
|
|
26
|
-
/**
|
|
27
|
-
* Manually cancel any active WebAuthn registration or authentication attempt.
|
|
28
|
-
*/
|
|
29
21
|
cancelCeremony() {
|
|
30
22
|
if (this.controller) {
|
|
31
23
|
const abortError = new Error('Manually cancelling existing WebAuthn API call');
|
package/esm/index.d.ts
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import { bufferToBase64URLString } from './helpers/bufferToBase64URLString.js';
|
|
12
|
-
import { WebAuthnAbortService } from './helpers/webAuthnAbortService.js';
|
|
13
|
-
import { WebAuthnError } from './helpers/webAuthnError.js';
|
|
14
|
-
export { base64URLStringToBuffer, browserSupportsWebAuthn, browserSupportsWebAuthnAutofill, bufferToBase64URLString, platformAuthenticatorIsAvailable, startAuthentication, startRegistration, WebAuthnAbortService, WebAuthnError, };
|
|
15
|
-
export type { WebAuthnErrorCode } from './helpers/webAuthnError.js';
|
|
1
|
+
export * from './methods/startRegistration.js';
|
|
2
|
+
export * from './methods/startAuthentication.js';
|
|
3
|
+
export * from './helpers/browserSupportsWebAuthn.js';
|
|
4
|
+
export * from './helpers/platformAuthenticatorIsAvailable.js';
|
|
5
|
+
export * from './helpers/browserSupportsWebAuthnAutofill.js';
|
|
6
|
+
export * from './helpers/base64URLStringToBuffer.js';
|
|
7
|
+
export * from './helpers/bufferToBase64URLString.js';
|
|
8
|
+
export * from './helpers/webAuthnAbortService.js';
|
|
9
|
+
export * from './helpers/webAuthnError.js';
|
|
10
|
+
export * from './types/index.js';
|
|
16
11
|
//# sourceMappingURL=index.d.ts.map
|
package/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,sCAAsC,CAAC;AACrD,cAAc,+CAA+C,CAAC;AAC9D,cAAc,8CAA8C,CAAC;AAC7D,cAAc,sCAAsC,CAAC;AACrD,cAAc,sCAAsC,CAAC;AACrD,cAAc,mCAAmC,CAAC;AAClD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kBAAkB,CAAC"}
|
package/esm/index.js
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import { bufferToBase64URLString } from './helpers/bufferToBase64URLString.js';
|
|
12
|
-
import { WebAuthnAbortService } from './helpers/webAuthnAbortService.js';
|
|
13
|
-
import { WebAuthnError } from './helpers/webAuthnError.js';
|
|
14
|
-
export { base64URLStringToBuffer, browserSupportsWebAuthn, browserSupportsWebAuthnAutofill, bufferToBase64URLString, platformAuthenticatorIsAvailable, startAuthentication, startRegistration, WebAuthnAbortService, WebAuthnError, };
|
|
1
|
+
export * from './methods/startRegistration.js';
|
|
2
|
+
export * from './methods/startAuthentication.js';
|
|
3
|
+
export * from './helpers/browserSupportsWebAuthn.js';
|
|
4
|
+
export * from './helpers/platformAuthenticatorIsAvailable.js';
|
|
5
|
+
export * from './helpers/browserSupportsWebAuthnAutofill.js';
|
|
6
|
+
export * from './helpers/base64URLStringToBuffer.js';
|
|
7
|
+
export * from './helpers/bufferToBase64URLString.js';
|
|
8
|
+
export * from './helpers/webAuthnAbortService.js';
|
|
9
|
+
export * from './helpers/webAuthnError.js';
|
|
10
|
+
export * from './types/index.js';
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import { AuthenticationResponseJSON, PublicKeyCredentialRequestOptionsJSON } from '
|
|
2
|
-
export type StartAuthenticationOpts =
|
|
3
|
-
optionsJSON: PublicKeyCredentialRequestOptionsJSON;
|
|
4
|
-
useBrowserAutofill?: boolean;
|
|
5
|
-
verifyBrowserAutofillInput?: boolean;
|
|
6
|
-
};
|
|
1
|
+
import type { AuthenticationResponseJSON, PublicKeyCredentialRequestOptionsJSON } from '../types/index.js';
|
|
2
|
+
export type StartAuthenticationOpts = Parameters<typeof startAuthentication>[0];
|
|
7
3
|
/**
|
|
8
4
|
* Begin authenticator "login" via WebAuthn assertion
|
|
9
5
|
*
|
|
@@ -11,5 +7,9 @@ export type StartAuthenticationOpts = {
|
|
|
11
7
|
* @param useBrowserAutofill (Optional) Initialize conditional UI to enable logging in via browser autofill prompts. Defaults to `false`.
|
|
12
8
|
* @param verifyBrowserAutofillInput (Optional) Ensure a suitable `<input>` element is present when `useBrowserAutofill` is `true`. Defaults to `true`.
|
|
13
9
|
*/
|
|
14
|
-
export declare function startAuthentication(options:
|
|
10
|
+
export declare function startAuthentication(options: {
|
|
11
|
+
optionsJSON: PublicKeyCredentialRequestOptionsJSON;
|
|
12
|
+
useBrowserAutofill?: boolean;
|
|
13
|
+
verifyBrowserAutofillInput?: boolean;
|
|
14
|
+
}): Promise<AuthenticationResponseJSON>;
|
|
15
15
|
//# sourceMappingURL=startAuthentication.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startAuthentication.d.ts","sourceRoot":"","sources":["../../src/methods/startAuthentication.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"startAuthentication.d.ts","sourceRoot":"","sources":["../../src/methods/startAuthentication.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,0BAA0B,EAC1B,qCAAqC,EACtC,MAAM,mBAAmB,CAAC;AAU3B,MAAM,MAAM,uBAAuB,GAAG,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;AAEhF;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE;IACP,WAAW,EAAE,qCAAqC,CAAC;IACnD,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,0BAA0B,CAAC,EAAE,OAAO,CAAC;CACtC,GACA,OAAO,CAAC,0BAA0B,CAAC,CAkGrC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { PublicKeyCredentialCreationOptionsJSON, RegistrationResponseJSON } from '
|
|
2
|
-
export type StartRegistrationOpts =
|
|
3
|
-
optionsJSON: PublicKeyCredentialCreationOptionsJSON;
|
|
4
|
-
useAutoRegister?: boolean;
|
|
5
|
-
};
|
|
1
|
+
import type { PublicKeyCredentialCreationOptionsJSON, RegistrationResponseJSON } from '../types/index.js';
|
|
2
|
+
export type StartRegistrationOpts = Parameters<typeof startRegistration>[0];
|
|
6
3
|
/**
|
|
7
4
|
* Begin authenticator "registration" via WebAuthn attestation
|
|
8
5
|
*
|
|
9
6
|
* @param optionsJSON Output from **@simplewebauthn/server**'s `generateRegistrationOptions()`
|
|
10
7
|
* @param useAutoRegister (Optional) Try to silently create a passkey with the password manager that the user just signed in with. Defaults to `false`.
|
|
11
8
|
*/
|
|
12
|
-
export declare function startRegistration(options:
|
|
9
|
+
export declare function startRegistration(options: {
|
|
10
|
+
optionsJSON: PublicKeyCredentialCreationOptionsJSON;
|
|
11
|
+
useAutoRegister?: boolean;
|
|
12
|
+
}): Promise<RegistrationResponseJSON>;
|
|
13
13
|
//# sourceMappingURL=startRegistration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startRegistration.d.ts","sourceRoot":"","sources":["../../src/methods/startRegistration.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"startRegistration.d.ts","sourceRoot":"","sources":["../../src/methods/startRegistration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,sCAAsC,EAEtC,wBAAwB,EACzB,MAAM,mBAAmB,CAAC;AAS3B,MAAM,MAAM,qBAAqB,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;AAE5E;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE;IACP,WAAW,EAAE,sCAAsC,CAAC;IACpD,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,GACA,OAAO,CAAC,wBAAwB,CAAC,CA6GnC"}
|