@simplewebauthn/browser 7.2.0 → 8.0.0-alpha.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/LICENSE.md +11 -14
- package/README.md +10 -6
- package/dist/bundle/index.es5.umd.min.js +2 -2
- package/dist/bundle/index.js +36 -13
- package/dist/bundle/index.umd.min.js +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/methods/startAuthentication.d.ts +1 -1
- package/jest-environment.js +2 -3
- package/package.json +15 -14
package/LICENSE.md
CHANGED
|
@@ -2,20 +2,17 @@ MIT License
|
|
|
2
2
|
|
|
3
3
|
Copyright (c) 2020 Matthew Miller
|
|
4
4
|
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
6
|
+
associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
7
|
+
including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
8
|
+
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
10
9
|
furnished to do so, subject to the following conditions:
|
|
11
10
|
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
12
|
+
portions of the Software.
|
|
14
13
|
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
|
15
|
+
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
16
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
|
|
17
|
+
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
18
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -23,16 +23,20 @@ npm install @simplewebauthn/browser
|
|
|
23
23
|
|
|
24
24
|
### UMD
|
|
25
25
|
|
|
26
|
-
This package can also be installed via **unpkg** by including the following script in your page's
|
|
26
|
+
This package can also be installed via **unpkg** by including the following script in your page's
|
|
27
|
+
`<head>` element. The library's methods will be available on the global **`SimpleWebAuthnBrowser`**
|
|
28
|
+
object.
|
|
27
29
|
|
|
28
|
-
> NOTE: The only difference between the two packages below is that the ES5 bundle includes
|
|
30
|
+
> NOTE: The only difference between the two packages below is that the ES5 bundle includes
|
|
31
|
+
> TypeScript's `tslib` runtime code. This adds some bundle size overhead, but _does_ enable use of
|
|
32
|
+
> `supportsWebAuthn()` in older browsers to show appropriate UI when WebAuthn is unavailable.
|
|
29
33
|
|
|
30
34
|
#### ES5
|
|
31
35
|
|
|
32
|
-
If you need to support WebAuthn feature detection in deprecated browsers like IE11 and Edge Legacy,
|
|
36
|
+
If you need to support WebAuthn feature detection in deprecated browsers like IE11 and Edge Legacy,
|
|
37
|
+
include the `ES5` version:
|
|
33
38
|
|
|
34
39
|
```html
|
|
35
|
-
|
|
36
40
|
<script src="https://unpkg.com/@simplewebauthn/browser/dist/bundle/index.es5.umd.min.js"></script>
|
|
37
41
|
```
|
|
38
42
|
|
|
@@ -41,10 +45,10 @@ If you need to support WebAuthn feature detection in deprecated browsers like IE
|
|
|
41
45
|
If you only need to support modern browsers, include the `ES2018` version:
|
|
42
46
|
|
|
43
47
|
```html
|
|
44
|
-
|
|
45
48
|
<script src="https://unpkg.com/@simplewebauthn/browser"></script>
|
|
46
49
|
```
|
|
47
50
|
|
|
48
51
|
## Usage
|
|
49
52
|
|
|
50
|
-
You can find in-depth documentation on this package here:
|
|
53
|
+
You can find in-depth documentation on this package here:
|
|
54
|
+
https://simplewebauthn.dev/docs/packages/browser
|
|
@@ -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";var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},t(e,n)};var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};function r(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))}function o(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}function i(e){var t,n,r=new Uint8Array(e),o="";try{for(var i=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(r),a=i.next();!a.done;a=i.next()){var s=a.value;o+=String.fromCharCode(s)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return btoa(o).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function a(e){for(var t=e.replace(/-/g,"+").replace(/_/g,"/"),n=(4-t.length%4)%4,r=t.padEnd(t.length+n,"="),o=atob(r),i=new ArrayBuffer(o.length),a=new Uint8Array(i),s=0;s<o.length;s++)a[s]=o.charCodeAt(s);return i}function s(){return void 0!==(null===window||void 0===window?void 0:window.PublicKeyCredential)&&"function"==typeof window.PublicKeyCredential}function u(e){var t=e.id;return n(n({},e),{id:a(t),transports:e.transports})}function c(e){return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}var l=function(e){function n(t){var n=t.message,r=t.code,o=t.cause,i=t.name,a=e.call(this,n,{cause:o})||this;return a.name=null!=i?i:o.name,a.code=r,a}return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(n,e),n}(Error);var d=new(function(){function e(){}return e.prototype.createNewAbortSignal=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},e}()),f=["cross-platform","platform"];function p(e){if(e&&!(f.indexOf(e)<0))return e}function h(){return r(this,void 0,void 0,(function(){var e;return o(this,(function(t){return[2,void 0!==(e=window.PublicKeyCredential).isConditionalMediationAvailable&&e.isConditionalMediationAvailable()]}))}))}e.browserSupportsWebAuthn=s,e.browserSupportsWebAuthnAutofill=h,e.platformAuthenticatorIsAvailable=function(){return r(this,void 0,void 0,(function(){return o(this,(function(e){return s()?[2,PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable()]:[2,!1]}))}))},e.startAuthentication=function(e,t){var f,w;return void 0===t&&(t=!1),r(this,void 0,void 0,(function(){var r,R,b,E,y,v,g,m,A;return o(this,(function(o){switch(o.label){case 0:if(!s())throw new Error("WebAuthn is not supported in this browser");return 0!==(null===(f=e.allowCredentials)||void 0===f?void 0:f.length)&&(r=null===(w=e.allowCredentials)||void 0===w?void 0:w.map(u)),R=n(n({},e),{challenge:a(e.challenge),allowCredentials:r}),b={},t?[4,h()]:[3,2];case 1:if(!o.sent())throw Error("Browser does not support WebAuthn autofill");if(document.querySelectorAll("input[autocomplete*='webauthn']").length<1)throw Error('No <input> with `"webauthn"` in its `autocomplete` attribute was detected');b.mediation="conditional",R.allowCredentials=[],o.label=2;case 2:b.publicKey=R,b.signal=d.createNewAbortSignal(),o.label=3;case 3:return o.trys.push([3,5,,6]),[4,navigator.credentials.get(b)];case 4:return E=o.sent(),[3,6];case 5:throw function(e){var t=e.error,n=e.options,r=n.publicKey;if(!r)throw Error("options was missing required publicKey property");if("AbortError"===t.name){if(n.signal instanceof AbortSignal)return new l({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if("NotAllowedError"===t.name)return new l({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if("SecurityError"===t.name){var o=window.location.hostname;if(!c(o))return new l({message:"".concat(window.location.hostname," is an invalid domain"),code:"ERROR_INVALID_DOMAIN",cause:t});if(r.rpId!==o)return new l({message:'The RP ID "'.concat(r.rpId,'" is invalid for this domain'),code:"ERROR_INVALID_RP_ID",cause:t})}else if("UnknownError"===t.name)return new l({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}({error:o.sent(),options:b});case 6:if(!E)throw new Error("Authentication was not completed");return y=E.id,v=E.rawId,g=E.response,m=E.type,A=void 0,g.userHandle&&(_=g.userHandle,A=new TextDecoder("utf-8").decode(_)),[2,{id:y,rawId:i(v),response:{authenticatorData:i(g.authenticatorData),clientDataJSON:i(g.clientDataJSON),signature:i(g.signature),userHandle:A},type:m,clientExtensionResults:E.getClientExtensionResults(),authenticatorAttachment:p(E.authenticatorAttachment)}]}var _}))}))},e.startRegistration=function(e){var t;return r(this,void 0,void 0,(function(){var r,f,h,w,R,b,E,y;return o(this,(function(o){switch(o.label){case 0:if(!s())throw new Error("WebAuthn is not supported in this browser");r=n(n({},e),{challenge:a(e.challenge),user:n(n({},e.user),{id:(v=e.user.id,(new TextEncoder).encode(v))}),excludeCredentials:null===(t=e.excludeCredentials)||void 0===t?void 0:t.map(u)}),(f={publicKey:r}).signal=d.createNewAbortSignal(),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,navigator.credentials.create(f)];case 2:return h=o.sent(),[3,4];case 3:throw function(e){var t,n,r=e.error,o=e.options,i=o.publicKey;if(!i)throw Error("options was missing required publicKey property");if("AbortError"===r.name){if(o.signal instanceof AbortSignal)return new l({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:r})}else if("ConstraintError"===r.name){if(!0===(null===(t=i.authenticatorSelection)||void 0===t?void 0:t.requireResidentKey))return new l({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:r});if("required"===(null===(n=i.authenticatorSelection)||void 0===n?void 0:n.userVerification))return new l({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:r})}else{if("InvalidStateError"===r.name)return new l({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:r});if("NotAllowedError"===r.name)return new l({message:r.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:r});if("NotSupportedError"===r.name)return 0===i.pubKeyCredParams.filter((function(e){return"public-key"===e.type})).length?new l({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:r}):new l({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:r});if("SecurityError"===r.name){var a=window.location.hostname;if(!c(a))return new l({message:"".concat(window.location.hostname," is an invalid domain"),code:"ERROR_INVALID_DOMAIN",cause:r});if(i.rp.id!==a)return new l({message:'The RP ID "'.concat(i.rp.id,'" is invalid for this domain'),code:"ERROR_INVALID_RP_ID",cause:r})}else if("TypeError"===r.name){if(i.user.id.byteLength<1||i.user.id.byteLength>64)return new l({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:r})}else if("UnknownError"===r.name)return new l({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:r})}return r}({error:o.sent(),options:f});case 4:if(!h)throw new Error("Registration was not completed");return w=h.id,R=h.rawId,b=h.response,E=h.type,y=void 0,"function"==typeof b.getTransports&&(y=b.getTransports()),[2,{id:w,rawId:i(R),response:{attestationObject:i(b.attestationObject),clientDataJSON:i(b.clientDataJSON),transports:y},type:E,clientExtensionResults:h.getClientExtensionResults(),authenticatorAttachment:p(h.authenticatorAttachment)}]}var v}))}))},Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
1
|
+
/* [@simplewebauthn/browser@8.0.0-alpha.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";var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},t(e,r)};var r=function(){return r=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)};function n(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function s(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}u((n=n.apply(e,t||[])).next())}))}function o(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function i(e){var t,r,n=new Uint8Array(e),o="";try{for(var i=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(n),a=i.next();!a.done;a=i.next()){var s=a.value;o+=String.fromCharCode(s)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}return btoa(o).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function a(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),s=0;s<o.length;s++)a[s]=o.charCodeAt(s);return i}function s(){return void 0!==(null===window||void 0===window?void 0:window.PublicKeyCredential)&&"function"==typeof window.PublicKeyCredential}function u(e){var t=e.id;return r(r({},e),{id:a(t),transports:e.transports})}function c(e){return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}"function"==typeof SuppressedError&&SuppressedError;var l=function(e){function r(t){var r=t.message,n=t.code,o=t.cause,i=t.name,a=e.call(this,r,{cause:o})||this;return a.name=null!=i?i:o.name,a.code=n,a}return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}(r,e),r}(Error);var d=new(function(){function e(){}return e.prototype.createNewAbortSignal=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},e}()),f=["cross-platform","platform"];function p(e){if(e&&!(f.indexOf(e)<0))return e}function h(){var e=window.PublicKeyCredential;return void 0===e.isConditionalMediationAvailable?new Promise((function(e){return e(!1)})):e.isConditionalMediationAvailable()}e.browserSupportsWebAuthn=s,e.browserSupportsWebAuthnAutofill=h,e.platformAuthenticatorIsAvailable=function(){return s()?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():new Promise((function(e){return e(!1)}))},e.startAuthentication=function(e,t){var f,w;return void 0===t&&(t=!1),n(this,void 0,void 0,(function(){var n,b,R,y,E,g,m,v,A;return o(this,(function(o){switch(o.label){case 0:if(!s())throw new Error("WebAuthn is not supported in this browser");return 0!==(null===(f=e.allowCredentials)||void 0===f?void 0:f.length)&&(n=null===(w=e.allowCredentials)||void 0===w?void 0:w.map(u)),b=r(r({},e),{challenge:a(e.challenge),allowCredentials:n}),R={},t?[4,h()]:[3,2];case 1:if(!o.sent())throw Error("Browser does not support WebAuthn autofill");if(document.querySelectorAll("input[autocomplete*='webauthn']").length<1)throw Error('No <input> with `"webauthn"` in its `autocomplete` attribute was detected');R.mediation="conditional",b.allowCredentials=[],o.label=2;case 2:R.publicKey=b,R.signal=d.createNewAbortSignal(),o.label=3;case 3:return o.trys.push([3,5,,6]),[4,navigator.credentials.get(R)];case 4:return y=o.sent(),[3,6];case 5:throw function(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 l({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if("NotAllowedError"===t.name)return new l({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if("SecurityError"===t.name){var o=window.location.hostname;if(!c(o))return new l({message:"".concat(window.location.hostname," is an invalid domain"),code:"ERROR_INVALID_DOMAIN",cause:t});if(n.rpId!==o)return new l({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 l({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}({error:o.sent(),options:R});case 6:if(!y)throw new Error("Authentication was not completed");return E=y.id,g=y.rawId,m=y.response,v=y.type,A=void 0,m.userHandle&&(_=m.userHandle,A=new TextDecoder("utf-8").decode(_)),[2,{id:E,rawId:i(g),response:{authenticatorData:i(m.authenticatorData),clientDataJSON:i(m.clientDataJSON),signature:i(m.signature),userHandle:A},type:v,clientExtensionResults:y.getClientExtensionResults(),authenticatorAttachment:p(y.authenticatorAttachment)}]}var _}))}))},e.startRegistration=function(e){var t;return n(this,void 0,void 0,(function(){var n,f,h,w,b,R,y,E,g,m,v,A;return o(this,(function(o){switch(o.label){case 0:if(!s())throw new Error("WebAuthn is not supported in this browser");n=r(r({},e),{challenge:a(e.challenge),user:r(r({},e.user),{id:(_=e.user.id,(new TextEncoder).encode(_))}),excludeCredentials:null===(t=e.excludeCredentials)||void 0===t?void 0:t.map(u)}),(f={publicKey:n}).signal=d.createNewAbortSignal(),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,navigator.credentials.create(f)];case 2:return h=o.sent(),[3,4];case 3:throw function(e){var t,r,n=e.error,o=e.options,i=o.publicKey;if(!i)throw Error("options was missing required publicKey property");if("AbortError"===n.name){if(o.signal instanceof AbortSignal)return new l({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:n})}else if("ConstraintError"===n.name){if(!0===(null===(t=i.authenticatorSelection)||void 0===t?void 0:t.requireResidentKey))return new l({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:n});if("required"===(null===(r=i.authenticatorSelection)||void 0===r?void 0:r.userVerification))return new l({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:n})}else{if("InvalidStateError"===n.name)return new l({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:n});if("NotAllowedError"===n.name)return new l({message:n.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:n});if("NotSupportedError"===n.name)return 0===i.pubKeyCredParams.filter((function(e){return"public-key"===e.type})).length?new l({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:n}):new l({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:n});if("SecurityError"===n.name){var a=window.location.hostname;if(!c(a))return new l({message:"".concat(window.location.hostname," is an invalid domain"),code:"ERROR_INVALID_DOMAIN",cause:n});if(i.rp.id!==a)return new l({message:'The RP ID "'.concat(i.rp.id,'" is invalid for this domain'),code:"ERROR_INVALID_RP_ID",cause:n})}else if("TypeError"===n.name){if(i.user.id.byteLength<1||i.user.id.byteLength>64)return new l({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:n})}else if("UnknownError"===n.name)return new l({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:n})}return n}({error:o.sent(),options:f});case 4:if(!h)throw new Error("Registration was not completed");return w=h.id,b=h.rawId,R=h.response,y=h.type,E=void 0,"function"==typeof R.getTransports&&(E=R.getTransports()),g=void 0,"function"==typeof R.getPublicKeyAlgorithm&&(g=R.getPublicKeyAlgorithm()),m=void 0,"function"==typeof R.getPublicKey&&null!==(v=R.getPublicKey())&&(m=i(v)),"function"==typeof R.getAuthenticatorData&&(A=i(R.getAuthenticatorData())),[2,{id:w,rawId:i(b),response:{attestationObject:i(R.attestationObject),clientDataJSON:i(R.clientDataJSON),transports:E,publicKeyAlgorithm:g,publicKey:m,authenticatorData:A},type:y,clientExtensionResults:h.getClientExtensionResults(),authenticatorAttachment:p(h.authenticatorAttachment)}]}var _}))}))},Object.defineProperty(e,"__esModule",{value:!0})}));
|
package/dist/bundle/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* [@simplewebauthn/browser@
|
|
1
|
+
/* [@simplewebauthn/browser@8.0.0-alpha.0] */
|
|
2
2
|
function utf8StringToBuffer(value) {
|
|
3
3
|
return new TextEncoder().encode(value);
|
|
4
4
|
}
|
|
@@ -27,7 +27,8 @@ function base64URLStringToBuffer(base64URLString) {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
function browserSupportsWebAuthn() {
|
|
30
|
-
return (window?.PublicKeyCredential !== undefined &&
|
|
30
|
+
return (window?.PublicKeyCredential !== undefined &&
|
|
31
|
+
typeof window.PublicKeyCredential === 'function');
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
function toPublicKeyCredentialDescriptor(descriptor) {
|
|
@@ -40,7 +41,8 @@ function toPublicKeyCredentialDescriptor(descriptor) {
|
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
function isValidDomain(hostname) {
|
|
43
|
-
return (hostname === 'localhost' ||
|
|
44
|
+
return (hostname === 'localhost' ||
|
|
45
|
+
/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(hostname));
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
class WebAuthnError extends Error {
|
|
@@ -86,7 +88,7 @@ function identifyRegistrationError({ error, options, }) {
|
|
|
86
88
|
return new WebAuthnError({
|
|
87
89
|
message: 'The authenticator was previously registered',
|
|
88
90
|
code: 'ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED',
|
|
89
|
-
cause: error
|
|
91
|
+
cause: error,
|
|
90
92
|
});
|
|
91
93
|
}
|
|
92
94
|
else if (error.name === 'NotAllowedError') {
|
|
@@ -97,7 +99,7 @@ function identifyRegistrationError({ error, options, }) {
|
|
|
97
99
|
});
|
|
98
100
|
}
|
|
99
101
|
else if (error.name === 'NotSupportedError') {
|
|
100
|
-
const validPubKeyCredParams = publicKey.pubKeyCredParams.filter(param => param.type === 'public-key');
|
|
102
|
+
const validPubKeyCredParams = publicKey.pubKeyCredParams.filter((param) => param.type === 'public-key');
|
|
101
103
|
if (validPubKeyCredParams.length === 0) {
|
|
102
104
|
return new WebAuthnError({
|
|
103
105
|
message: 'No entry in pubKeyCredParams was of type "public-key"',
|
|
@@ -117,7 +119,7 @@ function identifyRegistrationError({ error, options, }) {
|
|
|
117
119
|
return new WebAuthnError({
|
|
118
120
|
message: `${window.location.hostname} is an invalid domain`,
|
|
119
121
|
code: 'ERROR_INVALID_DOMAIN',
|
|
120
|
-
cause: error
|
|
122
|
+
cause: error,
|
|
121
123
|
});
|
|
122
124
|
}
|
|
123
125
|
else if (publicKey.rp.id !== effectiveDomain) {
|
|
@@ -203,6 +205,21 @@ async function startRegistration(creationOptionsJSON) {
|
|
|
203
205
|
if (typeof response.getTransports === 'function') {
|
|
204
206
|
transports = response.getTransports();
|
|
205
207
|
}
|
|
208
|
+
let responsePublicKeyAlgorithm = undefined;
|
|
209
|
+
if (typeof response.getPublicKeyAlgorithm === 'function') {
|
|
210
|
+
responsePublicKeyAlgorithm = response.getPublicKeyAlgorithm();
|
|
211
|
+
}
|
|
212
|
+
let responsePublicKey = undefined;
|
|
213
|
+
if (typeof response.getPublicKey === 'function') {
|
|
214
|
+
const _publicKey = response.getPublicKey();
|
|
215
|
+
if (_publicKey !== null) {
|
|
216
|
+
responsePublicKey = bufferToBase64URLString(_publicKey);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
let responseAuthenticatorData;
|
|
220
|
+
if (typeof response.getAuthenticatorData === 'function') {
|
|
221
|
+
responseAuthenticatorData = bufferToBase64URLString(response.getAuthenticatorData());
|
|
222
|
+
}
|
|
206
223
|
return {
|
|
207
224
|
id,
|
|
208
225
|
rawId: bufferToBase64URLString(rawId),
|
|
@@ -210,6 +227,9 @@ async function startRegistration(creationOptionsJSON) {
|
|
|
210
227
|
attestationObject: bufferToBase64URLString(response.attestationObject),
|
|
211
228
|
clientDataJSON: bufferToBase64URLString(response.clientDataJSON),
|
|
212
229
|
transports,
|
|
230
|
+
publicKeyAlgorithm: responsePublicKeyAlgorithm,
|
|
231
|
+
publicKey: responsePublicKey,
|
|
232
|
+
authenticatorData: responseAuthenticatorData,
|
|
213
233
|
},
|
|
214
234
|
type,
|
|
215
235
|
clientExtensionResults: credential.getClientExtensionResults(),
|
|
@@ -221,10 +241,13 @@ function bufferToUTF8String(value) {
|
|
|
221
241
|
return new TextDecoder('utf-8').decode(value);
|
|
222
242
|
}
|
|
223
243
|
|
|
224
|
-
|
|
225
|
-
const globalPublicKeyCredential = window
|
|
226
|
-
|
|
227
|
-
|
|
244
|
+
function browserSupportsWebAuthnAutofill() {
|
|
245
|
+
const globalPublicKeyCredential = window
|
|
246
|
+
.PublicKeyCredential;
|
|
247
|
+
if (globalPublicKeyCredential.isConditionalMediationAvailable === undefined) {
|
|
248
|
+
return new Promise((resolve) => resolve(false));
|
|
249
|
+
}
|
|
250
|
+
return globalPublicKeyCredential.isConditionalMediationAvailable();
|
|
228
251
|
}
|
|
229
252
|
|
|
230
253
|
function identifyAuthenticationError({ error, options, }) {
|
|
@@ -293,7 +316,7 @@ async function startAuthentication(requestOptionsJSON, useBrowserAutofill = fals
|
|
|
293
316
|
if (!(await browserSupportsWebAuthnAutofill())) {
|
|
294
317
|
throw Error('Browser does not support WebAuthn autofill');
|
|
295
318
|
}
|
|
296
|
-
const eligibleInputs = document.querySelectorAll(
|
|
319
|
+
const eligibleInputs = document.querySelectorAll('input[autocomplete*=\'webauthn\']');
|
|
297
320
|
if (eligibleInputs.length < 1) {
|
|
298
321
|
throw Error('No <input> with `"webauthn"` in its `autocomplete` attribute was detected');
|
|
299
322
|
}
|
|
@@ -332,9 +355,9 @@ async function startAuthentication(requestOptionsJSON, useBrowserAutofill = fals
|
|
|
332
355
|
};
|
|
333
356
|
}
|
|
334
357
|
|
|
335
|
-
|
|
358
|
+
function platformAuthenticatorIsAvailable() {
|
|
336
359
|
if (!browserSupportsWebAuthn()) {
|
|
337
|
-
return false;
|
|
360
|
+
return new Promise((resolve) => resolve(false));
|
|
338
361
|
}
|
|
339
362
|
return PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable();
|
|
340
363
|
}
|
|
@@ -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 n="";for(const e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function n(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=(4-t.length%4)%4,r=t.padEnd(t.length+n,"="),o=atob(r),a=new ArrayBuffer(o.length),i=new Uint8Array(a);for(let e=0;e<o.length;e++)i[e]=o.charCodeAt(e);return a}function r(){return void 0!==window?.PublicKeyCredential&&"function"==typeof window.PublicKeyCredential}function o(e){const{id:t}=e;return{...e,id:n(t),transports:e.transports}}function a(e){return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}class i extends Error{code;constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),this.name=r??n.name,this.code=t}}const s=new class{controller;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}},c=["cross-platform","platform"];function l(e){if(e&&!(c.indexOf(e)<0))return e}
|
|
1
|
+
/* [@simplewebauthn/browser@8.0.0-alpha.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 n="";for(const e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function n(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=(4-t.length%4)%4,r=t.padEnd(t.length+n,"="),o=atob(r),a=new ArrayBuffer(o.length),i=new Uint8Array(a);for(let e=0;e<o.length;e++)i[e]=o.charCodeAt(e);return a}function r(){return void 0!==window?.PublicKeyCredential&&"function"==typeof window.PublicKeyCredential}function o(e){const{id:t}=e;return{...e,id:n(t),transports:e.transports}}function a(e){return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}class i extends Error{code;constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),this.name=r??n.name,this.code=t}}const s=new class{controller;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}},c=["cross-platform","platform"];function l(e){if(e&&!(c.indexOf(e)<0))return e}function u(){const e=window.PublicKeyCredential;return void 0===e.isConditionalMediationAvailable?new Promise((e=>e(!1))):e.isConditionalMediationAvailable()}e.browserSupportsWebAuthn=r,e.browserSupportsWebAuthnAutofill=u,e.platformAuthenticatorIsAvailable=function(){return r()?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():new Promise((e=>e(!1)))},e.startAuthentication=async function(e,c=!1){if(!r())throw new Error("WebAuthn is not supported in this browser");let d;0!==e.allowCredentials?.length&&(d=e.allowCredentials?.map(o));const p={...e,challenge:n(e.challenge),allowCredentials:d},R={};if(c){if(!await u())throw Error("Browser does not support WebAuthn autofill");if(document.querySelectorAll("input[autocomplete*='webauthn']").length<1)throw Error('No <input> with `"webauthn"` in its `autocomplete` attribute was detected');R.mediation="conditional",p.allowCredentials=[]}let w;R.publicKey=p,R.signal=s.createNewAbortSignal();try{w=await navigator.credentials.get(R)}catch(e){throw function({error:e,options:t}){const{publicKey:n}=t;if(!n)throw Error("options was missing required publicKey property");if("AbortError"===e.name){if(t.signal instanceof AbortSignal)return new i({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else{if("NotAllowedError"===e.name)return new i({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});if("SecurityError"===e.name){const t=window.location.hostname;if(!a(t))return new i({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e});if(n.rpId!==t)return new i({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else if("UnknownError"===e.name)return new i({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(!w)throw new Error("Authentication was not completed");const{id:f,rawId:h,response:E,type:g}=w;let A;var m;return E.userHandle&&(m=E.userHandle,A=new TextDecoder("utf-8").decode(m)),{id:f,rawId:t(h),response:{authenticatorData:t(E.authenticatorData),clientDataJSON:t(E.clientDataJSON),signature:t(E.signature),userHandle:A},type:g,clientExtensionResults:w.getClientExtensionResults(),authenticatorAttachment:l(w.authenticatorAttachment)}},e.startRegistration=async function(e){if(!r())throw new Error("WebAuthn is not supported in this browser");var c;const u={publicKey:{...e,challenge:n(e.challenge),user:{...e.user,id:(c=e.user.id,(new TextEncoder).encode(c))},excludeCredentials:e.excludeCredentials?.map(o)}};let d;u.signal=s.createNewAbortSignal();try{d=await navigator.credentials.create(u)}catch(e){throw function({error:e,options:t}){const{publicKey:n}=t;if(!n)throw Error("options was missing required publicKey property");if("AbortError"===e.name){if(t.signal instanceof AbortSignal)return new i({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else if("ConstraintError"===e.name){if(!0===n.authenticatorSelection?.requireResidentKey)return new i({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:e});if("required"===n.authenticatorSelection?.userVerification)return new i({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 i({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:e});if("NotAllowedError"===e.name)return new i({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});if("NotSupportedError"===e.name)return 0===n.pubKeyCredParams.filter((e=>"public-key"===e.type)).length?new i({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:e}):new i({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=window.location.hostname;if(!a(t))return new i({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e});if(n.rp.id!==t)return new i({message:`The RP ID "${n.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else if("TypeError"===e.name){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new i({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 i({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:u})}if(!d)throw new Error("Registration was not completed");const{id:p,rawId:R,response:w,type:f}=d;let h,E,g,A;if("function"==typeof w.getTransports&&(h=w.getTransports()),"function"==typeof w.getPublicKeyAlgorithm&&(E=w.getPublicKeyAlgorithm()),"function"==typeof w.getPublicKey){const e=w.getPublicKey();null!==e&&(g=t(e))}return"function"==typeof w.getAuthenticatorData&&(A=t(w.getAuthenticatorData())),{id:p,rawId:t(R),response:{attestationObject:t(w.attestationObject),clientDataJSON:t(w.clientDataJSON),transports:h,publicKeyAlgorithm:E,publicKey:g,authenticatorData:A},type:f,clientExtensionResults:d.getClientExtensionResults(),authenticatorAttachment:l(d.authenticatorAttachment)}},Object.defineProperty(e,"__esModule",{value:!0})}));
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ import { startAuthentication } from './methods/startAuthentication';
|
|
|
3
3
|
import { browserSupportsWebAuthn } from './helpers/browserSupportsWebAuthn';
|
|
4
4
|
import { platformAuthenticatorIsAvailable } from './helpers/platformAuthenticatorIsAvailable';
|
|
5
5
|
import { browserSupportsWebAuthnAutofill } from './helpers/browserSupportsWebAuthnAutofill';
|
|
6
|
-
export {
|
|
6
|
+
export { browserSupportsWebAuthn, browserSupportsWebAuthnAutofill, platformAuthenticatorIsAvailable, startAuthentication, startRegistration, };
|
|
7
7
|
export type { WebAuthnErrorCode } from './helpers/webAuthnError';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AuthenticationResponseJSON, PublicKeyCredentialRequestOptionsJSON } from '@simplewebauthn/typescript-types';
|
|
2
2
|
export declare function startAuthentication(requestOptionsJSON: PublicKeyCredentialRequestOptionsJSON, useBrowserAutofill?: boolean): Promise<AuthenticationResponseJSON>;
|
package/jest-environment.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import Environment from 'jest-environment-jsdom';
|
|
1
|
+
import { TestEnvironment } from 'jest-environment-jsdom';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Set up a custom JSDOM-based test environment for Jest so we can add things JSDOM doesn't support
|
|
6
5
|
*/
|
|
7
|
-
class CustomTestEnvironment extends
|
|
6
|
+
class CustomTestEnvironment extends TestEnvironment {
|
|
8
7
|
async setup() {
|
|
9
8
|
await super.setup();
|
|
10
9
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplewebauthn/browser",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0-alpha.0",
|
|
4
4
|
"description": "SimpleWebAuthn for Browsers",
|
|
5
5
|
"main": "dist/bundle/index.js",
|
|
6
6
|
"unpkg": "dist/bundle/index.umd.min.js",
|
|
@@ -9,20 +9,13 @@
|
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
|
-
"url": "https://github.com/MasterKale/SimpleWebAuthn.git",
|
|
12
|
+
"url": "git+https://github.com/MasterKale/SimpleWebAuthn.git",
|
|
13
13
|
"directory": "packages/browser"
|
|
14
14
|
},
|
|
15
15
|
"homepage": "https://github.com/MasterKale/SimpleWebAuthn/tree/master/packages/browser#readme",
|
|
16
16
|
"publishConfig": {
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
19
|
-
"scripts": {
|
|
20
|
-
"build": "rimraf dist && rollup -c",
|
|
21
|
-
"test": "jest",
|
|
22
|
-
"test:watch": "jest --watch",
|
|
23
|
-
"test:coverage": "npm test -- --coverage",
|
|
24
|
-
"prepublish": "npm run build"
|
|
25
|
-
},
|
|
26
19
|
"keywords": [
|
|
27
20
|
"typescript",
|
|
28
21
|
"webauthn",
|
|
@@ -31,15 +24,23 @@
|
|
|
31
24
|
"umd"
|
|
32
25
|
],
|
|
33
26
|
"dependencies": {
|
|
34
|
-
"@simplewebauthn/typescript-types": "
|
|
27
|
+
"@simplewebauthn/typescript-types": "^8.0.0-alpha.0"
|
|
35
28
|
},
|
|
36
29
|
"devDependencies": {
|
|
37
30
|
"@rollup/plugin-node-resolve": "^13.0.0",
|
|
31
|
+
"@rollup/plugin-terser": "^0.4.3",
|
|
38
32
|
"@rollup/plugin-typescript": "^8.2.1",
|
|
39
33
|
"rollup": "^2.52.1",
|
|
40
|
-
"rollup-plugin-
|
|
41
|
-
"
|
|
34
|
+
"rollup-plugin-version-injector": "^1.3.3",
|
|
35
|
+
"tslib": "^2.6.2"
|
|
42
36
|
},
|
|
43
37
|
"type": "module",
|
|
44
|
-
"gitHead": "
|
|
45
|
-
|
|
38
|
+
"gitHead": "ba039fdd5fdff87f78d3bd246e9bea5f7aa39ccb",
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "rimraf dist && rollup -c",
|
|
41
|
+
"test": "jest",
|
|
42
|
+
"test:watch": "jest --watch",
|
|
43
|
+
"test:coverage": "npm test -- --coverage",
|
|
44
|
+
"prepublish": "npm run build"
|
|
45
|
+
}
|
|
46
|
+
}
|