@spencerboucher/switchyard 0.22.0 → 0.23.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 +11 -1
- package/dist/bridge/switchyard-terminal.js +2 -0
- package/dist/switchyard.mjs +21 -51
- package/package.json +1 -1
- package/web-dist/assets/AutomationView-BFZ5tGrI.js +2 -0
- package/web-dist/assets/AutomationView-BFZ5tGrI.js.map +1 -0
- package/web-dist/assets/{Checkbox-DR78wXsg.js → Checkbox-Bh46F55q.js} +2 -2
- package/web-dist/assets/{Checkbox-DR78wXsg.js.map → Checkbox-Bh46F55q.js.map} +1 -1
- package/web-dist/assets/{DangerZone-CBnW9h0p.js → DangerZone-K_oXMpbq.js} +2 -2
- package/web-dist/assets/{DangerZone-CBnW9h0p.js.map → DangerZone-K_oXMpbq.js.map} +1 -1
- package/web-dist/assets/Field-DRcZixOF.js +2 -0
- package/web-dist/assets/{Field-DS2BMoqA.js.map → Field-DRcZixOF.js.map} +1 -1
- package/web-dist/assets/{Markdown-BIO6MBTM.js → Markdown-BaCvc-cI.js} +5 -5
- package/web-dist/assets/{Markdown-BIO6MBTM.js.map → Markdown-BaCvc-cI.js.map} +1 -1
- package/web-dist/assets/{NavigationEditor-C0J7vDXL.js → NavigationEditor-BfNZ411c.js} +2 -2
- package/web-dist/assets/{NavigationEditor-C0J7vDXL.js.map → NavigationEditor-BfNZ411c.js.map} +1 -1
- package/web-dist/assets/{Overlay-DPZqU_vB.js → Overlay-wZFuaSA5.js} +2 -2
- package/web-dist/assets/{Overlay-DPZqU_vB.js.map → Overlay-wZFuaSA5.js.map} +1 -1
- package/web-dist/assets/{Priority-0hv1Vpg7.js → Priority-Ce4btFLm.js} +2 -2
- package/web-dist/assets/{Priority-0hv1Vpg7.js.map → Priority-Ce4btFLm.js.map} +1 -1
- package/web-dist/assets/{RadioCards-CN5xELnc.js → RadioCards-DR-fWNLB.js} +2 -2
- package/web-dist/assets/{RadioCards-CN5xELnc.js.map → RadioCards-DR-fWNLB.js.map} +1 -1
- package/web-dist/assets/ScopeSelect-B1RxBDV7.js +2 -0
- package/web-dist/assets/ScopeSelect-B1RxBDV7.js.map +1 -0
- package/web-dist/assets/SegmentedControl-M7WpGnaN.js +2 -0
- package/web-dist/assets/SegmentedControl-M7WpGnaN.js.map +1 -0
- package/web-dist/assets/{Select-CN7M29ap.js → Select-CvbSg3M1.js} +2 -2
- package/web-dist/assets/{Select-CN7M29ap.js.map → Select-CvbSg3M1.js.map} +1 -1
- package/web-dist/assets/StructuredValue-By3sh_00.js +5 -0
- package/web-dist/assets/StructuredValue-By3sh_00.js.map +1 -0
- package/web-dist/assets/{Switch-CZMY83Fw.js → Switch-B89oAK_3.js} +2 -2
- package/web-dist/assets/{Switch-CZMY83Fw.js.map → Switch-B89oAK_3.js.map} +1 -1
- package/web-dist/assets/Tabs-CzGFkSHO.js +2 -0
- package/web-dist/assets/{Tabs-_1w3hoAR.js.map → Tabs-CzGFkSHO.js.map} +1 -1
- package/web-dist/assets/TextLink-irMcg7Xz.js +2 -0
- package/web-dist/assets/{TextLink-BpF2vLiL.js.map → TextLink-irMcg7Xz.js.map} +1 -1
- package/web-dist/assets/{UINodeRenderer-DqIkLhF8.js → UINodeRenderer-_99GFFDS.js} +3 -3
- package/web-dist/assets/{UINodeRenderer-DqIkLhF8.js.map → UINodeRenderer-_99GFFDS.js.map} +1 -1
- package/web-dist/assets/{UnfilteredNote-22-Qjb-f.js → UnfilteredNote-iQIfVXkA.js} +2 -2
- package/web-dist/assets/{UnfilteredNote-22-Qjb-f.js.map → UnfilteredNote-iQIfVXkA.js.map} +1 -1
- package/web-dist/assets/api-CzS9UH7Q.js +2 -0
- package/web-dist/assets/{api-RftVSu44.js.map → api-CzS9UH7Q.js.map} +1 -1
- package/web-dist/assets/{arrow-down-CzjHSpfM.js → arrow-down-BKhm3D2d.js} +2 -2
- package/web-dist/assets/{arrow-down-CzjHSpfM.js.map → arrow-down-BKhm3D2d.js.map} +1 -1
- package/web-dist/assets/{arrow-up-B4YU8Bg0.js → arrow-up-poMxdOwI.js} +2 -2
- package/web-dist/assets/{arrow-up-B4YU8Bg0.js.map → arrow-up-poMxdOwI.js.map} +1 -1
- package/web-dist/assets/attention-UZIRcx_k.js +2 -0
- package/web-dist/assets/attention-UZIRcx_k.js.map +1 -0
- package/web-dist/assets/{automations-DnydDML9.js → automations-DWz_Lxch.js} +2 -2
- package/web-dist/assets/{automations-DnydDML9.js.map → automations-DWz_Lxch.js.map} +1 -1
- package/web-dist/assets/board-BqGDwbGB.js +6 -0
- package/web-dist/assets/{board-BPxxc8G4.js.map → board-BqGDwbGB.js.map} +1 -1
- package/web-dist/assets/{calendar-clock-B3bQkNKq.js → calendar-clock-U5kMaB5u.js} +2 -2
- package/web-dist/assets/{calendar-clock-B3bQkNKq.js.map → calendar-clock-U5kMaB5u.js.map} +1 -1
- package/web-dist/assets/chevron-right-B-aa_CvO.js +2 -0
- package/web-dist/assets/{chevron-right-DuAbbYQ-.js.map → chevron-right-B-aa_CvO.js.map} +1 -1
- package/web-dist/assets/code-Di_a0pVO.js +28 -0
- package/web-dist/assets/code-Di_a0pVO.js.map +1 -0
- package/web-dist/assets/{core.esm-BbOnWvFK.js → core.esm-CHa4oRMo.js} +2 -2
- package/web-dist/assets/{core.esm-BbOnWvFK.js.map → core.esm-CHa4oRMo.js.map} +1 -1
- package/web-dist/assets/{describe-DWsoiUix.js → describe-C5NtR2LE.js} +2 -2
- package/web-dist/assets/describe-C5NtR2LE.js.map +1 -0
- package/web-dist/assets/{enroll-CV77Sk6h.js → enroll-DlZYKudD.js} +2 -2
- package/web-dist/assets/{enroll-CV77Sk6h.js.map → enroll-DlZYKudD.js.map} +1 -1
- package/web-dist/assets/{git-branch-Dr8PvfHN.js → git-branch-CltFrgh4.js} +2 -2
- package/web-dist/assets/{git-branch-Dr8PvfHN.js.map → git-branch-CltFrgh4.js.map} +1 -1
- package/web-dist/assets/{grip-vertical-Bc5pJHHF.js → grip-vertical-QSdwyQ9C.js} +2 -2
- package/web-dist/assets/{grip-vertical-Bc5pJHHF.js.map → grip-vertical-QSdwyQ9C.js.map} +1 -1
- package/web-dist/assets/{hand-B2TrADIv.js → hand-5eeZJSl_.js} +2 -2
- package/web-dist/assets/{hand-B2TrADIv.js.map → hand-5eeZJSl_.js.map} +1 -1
- package/web-dist/assets/index-CbdB9RE5.js +17 -0
- package/web-dist/assets/{index-cmIcNnnF.js.map → index-CbdB9RE5.js.map} +1 -1
- package/web-dist/assets/index-XQGPQuFK.css +2 -0
- package/web-dist/assets/{link-2-M5ENDPWT.js → link-2-DXaJEVgz.js} +2 -2
- package/web-dist/assets/{link-2-M5ENDPWT.js.map → link-2-DXaJEVgz.js.map} +1 -1
- package/web-dist/assets/{logic-D_vBBkcD.js → logic-4hQwsm8w.js} +4 -4
- package/web-dist/assets/logic-4hQwsm8w.js.map +1 -0
- package/web-dist/assets/{logic-CG2E-voG.js → logic-c8AsGwGr.js} +2 -2
- package/web-dist/assets/{logic-CG2E-voG.js.map → logic-c8AsGwGr.js.map} +1 -1
- package/web-dist/assets/{more-CVjg2O5h.js → more-RENHRep9.js} +2 -2
- package/web-dist/assets/{more-CVjg2O5h.js.map → more-RENHRep9.js.map} +1 -1
- package/web-dist/assets/{pencil-y_4AgVa2.js → pencil-DvO-Zlyh.js} +2 -2
- package/web-dist/assets/{pencil-y_4AgVa2.js.map → pencil-DvO-Zlyh.js.map} +1 -1
- package/web-dist/assets/{play-CYKX2aVL.js → play-CPNEXvVs.js} +2 -2
- package/web-dist/assets/{play-CYKX2aVL.js.map → play-CPNEXvVs.js.map} +1 -1
- package/web-dist/assets/{plus-B6uH1yKa.js → plus-DC4JQpXX.js} +2 -2
- package/web-dist/assets/{plus-B6uH1yKa.js.map → plus-DC4JQpXX.js.map} +1 -1
- package/web-dist/assets/{policyLogic-CioD2rMm.js → policyLogic-CXFbVtEs.js} +2 -2
- package/web-dist/assets/{policyLogic-CioD2rMm.js.map → policyLogic-CXFbVtEs.js.map} +1 -1
- package/web-dist/assets/{prefs-V29Ms2ZL.js → prefs-BTwRvULi.js} +2 -2
- package/web-dist/assets/{prefs-V29Ms2ZL.js.map → prefs-BTwRvULi.js.map} +1 -1
- package/web-dist/assets/{queue-BGK9c062.js → queue-C25GCl3M.js} +2 -2
- package/web-dist/assets/{queue-BGK9c062.js.map → queue-C25GCl3M.js.map} +1 -1
- package/web-dist/assets/{rotate-ccw-DvfmNYNE.js → rotate-ccw-DuLdXOxM.js} +2 -2
- package/web-dist/assets/{rotate-ccw-DvfmNYNE.js.map → rotate-ccw-DuLdXOxM.js.map} +1 -1
- package/web-dist/assets/{search-GTFKEqAS.js → search-tZdcGLqS.js} +2 -2
- package/web-dist/assets/{search-GTFKEqAS.js.map → search-tZdcGLqS.js.map} +1 -1
- package/web-dist/assets/selection-BVtvp1aZ.js +9 -0
- package/web-dist/assets/selection-BVtvp1aZ.js.map +1 -0
- package/web-dist/assets/settings-BApavmGp.js +7 -0
- package/web-dist/assets/settings-BApavmGp.js.map +1 -0
- package/web-dist/assets/states-CM1Zt9qO.js +60 -0
- package/web-dist/assets/states-CM1Zt9qO.js.map +1 -0
- package/web-dist/assets/{terminal-DGVFZER3.js → terminal-CEttp_7_.js} +2 -2
- package/web-dist/assets/{terminal-DGVFZER3.js.map → terminal-CEttp_7_.js.map} +1 -1
- package/web-dist/assets/{terminal-login-Gy6aLzgC.js → terminal-login-BceUiMHs.js} +2 -2
- package/web-dist/assets/{terminal-login-Gy6aLzgC.js.map → terminal-login-BceUiMHs.js.map} +1 -1
- package/web-dist/assets/{useBreakpoint-DoLUoCMf.js → useBreakpoint-CdYPa6z0.js} +2 -2
- package/web-dist/assets/{useBreakpoint-DoLUoCMf.js.map → useBreakpoint-CdYPa6z0.js.map} +1 -1
- package/web-dist/assets/useNow-CyygPGnv.js +2 -0
- package/web-dist/assets/{useNow-BS_9T7IY.js.map → useNow-CyygPGnv.js.map} +1 -1
- package/web-dist/assets/{useResource-CPN6cDQ5.js → useResource-DQOWQ7YZ.js} +2 -2
- package/web-dist/assets/{useResource-CPN6cDQ5.js.map → useResource-DQOWQ7YZ.js.map} +1 -1
- package/web-dist/assets/useSwipeTabs-CJFQTmAs.js +2 -0
- package/web-dist/assets/useSwipeTabs-CJFQTmAs.js.map +1 -0
- package/web-dist/assets/workboard-D39MZMSb.js +3 -0
- package/web-dist/assets/{workboard-FE6bAMnW.js.map → workboard-D39MZMSb.js.map} +1 -1
- package/web-dist/index.html +7 -7
- package/web-dist/sw.js +1 -1
- package/web-dist/sw.js.map +1 -1
- package/web-dist/assets/AutomationView-DwZ_2m9J.js +0 -2
- package/web-dist/assets/AutomationView-DwZ_2m9J.js.map +0 -1
- package/web-dist/assets/Field-DS2BMoqA.js +0 -2
- package/web-dist/assets/ScopeSelect-BaJjip1Y.js +0 -2
- package/web-dist/assets/ScopeSelect-BaJjip1Y.js.map +0 -1
- package/web-dist/assets/SegmentedControl-CRmhE-Kn.js +0 -2
- package/web-dist/assets/SegmentedControl-CRmhE-Kn.js.map +0 -1
- package/web-dist/assets/Tabs-_1w3hoAR.js +0 -2
- package/web-dist/assets/TextLink-BpF2vLiL.js +0 -2
- package/web-dist/assets/api-RftVSu44.js +0 -2
- package/web-dist/assets/attention-CEgIsUuq.js +0 -2
- package/web-dist/assets/attention-CEgIsUuq.js.map +0 -1
- package/web-dist/assets/board-BPxxc8G4.js +0 -6
- package/web-dist/assets/chevron-right-DuAbbYQ-.js +0 -2
- package/web-dist/assets/code-D5IB7jTT.js +0 -28
- package/web-dist/assets/code-D5IB7jTT.js.map +0 -1
- package/web-dist/assets/describe-DWsoiUix.js.map +0 -1
- package/web-dist/assets/index-BXQwol8u.css +0 -2
- package/web-dist/assets/index-cmIcNnnF.js +0 -17
- package/web-dist/assets/logic-D_vBBkcD.js.map +0 -1
- package/web-dist/assets/repo-CuL_qbqU.js +0 -5
- package/web-dist/assets/repo-CuL_qbqU.js.map +0 -1
- package/web-dist/assets/selection-CAMJBh5A.js +0 -9
- package/web-dist/assets/selection-CAMJBh5A.js.map +0 -1
- package/web-dist/assets/settings-o7k_MPK7.js +0 -9
- package/web-dist/assets/settings-o7k_MPK7.js.map +0 -1
- package/web-dist/assets/states-BUWwUyu-.js +0 -60
- package/web-dist/assets/states-BUWwUyu-.js.map +0 -1
- package/web-dist/assets/useIndicator-BKqIsw2Q.js +0 -2
- package/web-dist/assets/useIndicator-BKqIsw2Q.js.map +0 -1
- package/web-dist/assets/useNow-BS_9T7IY.js +0 -2
- package/web-dist/assets/useSwipeTabs-XRK0_O6T.js +0 -2
- package/web-dist/assets/useSwipeTabs-XRK0_O6T.js.map +0 -1
- package/web-dist/assets/workboard-FE6bAMnW.js +0 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{fn as e,hn as t}from"./states-BUWwUyu-.js";function n(e){let t=new Uint8Array(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function r(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=(4-t.length%4)%4,r=t.padEnd(t.length+n,`=`),i=atob(r),a=new ArrayBuffer(i.length),o=new Uint8Array(a);for(let e=0;e<i.length;e++)o[e]=i.charCodeAt(e);return a}function i(){return a.stubThis(globalThis?.PublicKeyCredential!==void 0&&typeof globalThis.PublicKeyCredential==`function`)}var a={stubThis:e=>e};function o(e){let{id:t}=e;return{...e,id:r(t),transports:e.transports,type:e.type}}function s(e){return e===`localhost`||/^((xn--[a-z0-9-]+|[a-z0-9]+(-[a-z0-9]+)*)\.)+([a-z]{2,}|xn--[a-z0-9-]+)$/i.test(e)}var c=class extends Error{constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=r??n.name,this.code=t}};function l({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new c({message:`Registration ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`ConstraintError`){if(n.authenticatorSelection?.requireResidentKey===!0)return new c({message:`Discoverable credentials were required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT`,cause:e});if(t.mediation===`conditional`&&n.authenticatorSelection?.userVerification===`required`)return new c({message:`User verification was required during automatic registration but it could not be performed`,code:`ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE`,cause:e});if(n.authenticatorSelection?.userVerification===`required`)return new c({message:`User verification was required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT`,cause:e})}else if(e.name===`InvalidStateError`)return new c({message:`The authenticator was previously registered`,code:`ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED`,cause:e});else if(e.name===`NotAllowedError`)return new c({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`NotSupportedError`)return n.pubKeyCredParams.filter(e=>e.type===`public-key`).length===0?new c({message:`No entry in pubKeyCredParams was of type "public-key"`,code:`ERROR_MALFORMED_PUBKEYCREDPARAMS`,cause:e}):new c({message:`No available authenticator supported any of the specified pubKeyCredParams algorithms`,code:`ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!s(t))return new c({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rp.id!==t)return new c({message:`The RP ID "${n.rp.id}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`TypeError`){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new c({message:`User ID was not between 1 and 64 characters`,code:`ERROR_INVALID_USER_ID_LENGTH`,cause:e})}else if(e.name===`UnknownError`)return new c({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}var u=new class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let e=Error(`Cancelling existing WebAuthn API call for new one`);e.name=`AbortError`,this.controller.abort(e)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error(`Manually cancelling existing WebAuthn API call`);e.name=`AbortError`,this.controller.abort(e),this.controller=void 0}}},d=[`cross-platform`,`platform`];function f(e){if(e&&!(d.indexOf(e)<0))return e}async function p(e){!e.optionsJSON&&e.challenge&&(console.warn(`startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useAutoRegister:a=!1}=e;if(!i())throw Error(`WebAuthn is not supported in this browser`);let s={...t,challenge:r(t.challenge),user:{...t.user,id:r(t.user.id)},excludeCredentials:t.excludeCredentials?.map(o)},c={};a&&(c.mediation=`conditional`),c.publicKey=s,c.signal=u.createNewAbortSignal();let d;try{d=await navigator.credentials.create(c)}catch(e){throw l({error:e,options:c})}if(!d)throw Error(`Registration was not completed`);let{id:p,rawId:h,response:g,type:_}=d,v;typeof g.getTransports==`function`&&(v=g.getTransports());let y;if(typeof g.getPublicKeyAlgorithm==`function`)try{y=g.getPublicKeyAlgorithm()}catch(e){m(`getPublicKeyAlgorithm()`,e)}let b;if(typeof g.getPublicKey==`function`)try{let e=g.getPublicKey();e!==null&&(b=n(e))}catch(e){m(`getPublicKey()`,e)}let x;if(typeof g.getAuthenticatorData==`function`)try{x=n(g.getAuthenticatorData())}catch(e){m(`getAuthenticatorData()`,e)}return{id:p,rawId:n(h),response:{attestationObject:n(g.attestationObject),clientDataJSON:n(g.clientDataJSON),transports:v,publicKeyAlgorithm:y,publicKey:b,authenticatorData:x},type:_,clientExtensionResults:d.getClientExtensionResults(),authenticatorAttachment:f(d.authenticatorAttachment)}}function m(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(!i())return g.stubThis(new Promise(e=>e(!1)));let e=globalThis.PublicKeyCredential;return e?.isConditionalMediationAvailable===void 0?g.stubThis(new Promise(e=>e(!1))):g.stubThis(e.isConditionalMediationAvailable())}var g={stubThis:e=>e};function _({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new c({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new c({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!s(t))return new c({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new c({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`UnknownError`)return new c({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}async function v(e){!e.optionsJSON&&e.challenge&&(console.warn(`startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useBrowserAutofill:a=!1,verifyBrowserAutofillInput:s=!0}=e;if(!i())throw Error(`WebAuthn is not supported in this browser`);let c;t.allowCredentials?.length!==0&&(c=t.allowCredentials?.map(o));let l={...t,challenge:r(t.challenge),allowCredentials:c},d={};if(a){if(!await h())throw Error(`Browser does not support WebAuthn autofill`);if(document.querySelectorAll(`input[autocomplete$='webauthn']`).length<1&&s)throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');d.mediation=`conditional`,l.allowCredentials=[]}d.publicKey=l,d.signal=u.createNewAbortSignal();let p;try{p=await navigator.credentials.get(d)}catch(e){throw _({error:e,options:d})}if(!p)throw Error(`Authentication was not completed`);let{id:m,rawId:g,response:v,type:y}=p,b;return v.userHandle&&(b=n(v.userHandle)),{id:m,rawId:n(g),response:{authenticatorData:n(v.authenticatorData),clientDataJSON:n(v.clientDataJSON),signature:n(v.signature),userHandle:b},type:y,clientExtensionResults:p.getClientExtensionResults(),authenticatorAttachment:f(p.authenticatorAttachment)}}var y=t(e(),1);function b(e){return e instanceof Error&&(e.name===`NotAllowedError`||e.name===`AbortError`)}function x(){let[e,t]=(0,y.useState)(!1),n=(0,y.useRef)(0),r=(0,y.useRef)(!1),i=(0,y.useCallback)(e=>{r.current=e,t(e)},[]),a=(0,y.useCallback)(()=>{n.current++,u.cancelCeremony(),r.current=!1,t(!1)},[]),o=(0,y.useCallback)(async e=>{let t=++n.current;i(!0);try{let r=await e();return n.current===t?(i(!1),{ok:!0,value:r}):{ok:!1,canceled:!0}}catch(e){if(n.current!==t||(i(!1),b(e)))return{ok:!1,canceled:!0};throw e}},[i]);return(0,y.useEffect)(()=>()=>{r.current&&(n.current++,u.cancelCeremony())},[]),{waiting:e,run:o,cancel:a}}var S=2e3;function C(e){return{phase:`waiting`,startedAt:e,message:null}}function w(e,t){if(e.phase!==`waiting`)return e;if(t.type===`cancel`)return{...e,phase:`canceled`};if(t.now-e.startedAt>=6e5&&t.type!==`claim`)return{...e,phase:`timeout`};switch(t.type){case`tick`:return e;case`claim`:return t.result.status===`done`?{...e,phase:`done`}:t.now-e.startedAt>=6e5?{...e,phase:`timeout`}:e;case`claim_error`:return t.code===`unauthorized`||t.code===`invalid_request`?{...e,phase:`failed`,message:t.message}:e}}function T(e,t){return e.phase===`waiting`&&t}var E=`This account is not allowed to sign in to this server.`,D={enrollment_expired:"This sign-in link has expired. Links are valid for 10 minutes. Run `switchyard pair` on the server for a new one.",enrollment_used:"This sign-in link was already used. Each link signs in one browser. Run `switchyard pair` on the server for a new one.",invalid_request:`The sign-in request was rejected. Try again.`,network:`Could not reach the coordinator. Check your connection and try again.`,rate_limited:`Too many attempts. Wait a minute and try again.`,unsupported_capability:`This sign-in method is not available on this server.`,unauthorized:`That sign-in was not accepted. Try again, or use another sign-in method.`};function O(e,t){let n=t?.trim()||null;switch(e){case`forbidden`:return n??E;case`oidc_failed`:return`Single sign-on failed: ${n??`the identity provider returned an error.`}`;case`unsupported_capability`:return n??D.unsupported_capability;default:return D[e]??n??`Sign-in failed (${e}).`}}function k(e){switch(e){case`enrollment_expired`:return`Sign-in link expired`;case`enrollment_used`:return`Sign-in link already used`;case`forbidden`:return`Not allowed`;case`oidc_failed`:return`Single sign-on failed`;case`rate_limited`:return`Too many attempts`;default:return`Sign-in failed`}}function A(e=navigator.userAgent){let t=/iPhone/.test(e)?`iPhone`:/iPad/.test(e)||/Macintosh/.test(e)&&navigator.maxTouchPoints>1?`iPad`:/Android/.test(e)?`Android`:/Macintosh|Mac OS X/.test(e)?`Mac`:/Windows/.test(e)?`Windows`:/Linux/.test(e)?`Linux`:`device`;return`${/Edg\//.test(e)?`Edge`:/Firefox\/|FxiOS/.test(e)?`Firefox`:/Chrome\/|CriOS/.test(e)?`Chrome`:/Safari\//.test(e)?`Safari`:`Browser`} on ${t}`}export{k as a,C as c,p as d,i as f,O as i,x as l,S as n,w as o,A as r,T as s,D as t,v as u};
|
|
2
|
-
//# sourceMappingURL=logic-
|
|
1
|
+
import{_n as e,mn as t}from"./states-CM1Zt9qO.js";function n(e){let t=new Uint8Array(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function r(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=(4-t.length%4)%4,r=t.padEnd(t.length+n,`=`),i=atob(r),a=new ArrayBuffer(i.length),o=new Uint8Array(a);for(let e=0;e<i.length;e++)o[e]=i.charCodeAt(e);return a}function i(){return a.stubThis(globalThis?.PublicKeyCredential!==void 0&&typeof globalThis.PublicKeyCredential==`function`)}var a={stubThis:e=>e};function o(e){let{id:t}=e;return{...e,id:r(t),transports:e.transports,type:e.type}}function s(e){return e===`localhost`||/^((xn--[a-z0-9-]+|[a-z0-9]+(-[a-z0-9]+)*)\.)+([a-z]{2,}|xn--[a-z0-9-]+)$/i.test(e)}var c=class extends Error{constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=r??n.name,this.code=t}};function l({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new c({message:`Registration ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`ConstraintError`){if(n.authenticatorSelection?.requireResidentKey===!0)return new c({message:`Discoverable credentials were required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT`,cause:e});if(t.mediation===`conditional`&&n.authenticatorSelection?.userVerification===`required`)return new c({message:`User verification was required during automatic registration but it could not be performed`,code:`ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE`,cause:e});if(n.authenticatorSelection?.userVerification===`required`)return new c({message:`User verification was required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT`,cause:e})}else if(e.name===`InvalidStateError`)return new c({message:`The authenticator was previously registered`,code:`ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED`,cause:e});else if(e.name===`NotAllowedError`)return new c({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`NotSupportedError`)return n.pubKeyCredParams.filter(e=>e.type===`public-key`).length===0?new c({message:`No entry in pubKeyCredParams was of type "public-key"`,code:`ERROR_MALFORMED_PUBKEYCREDPARAMS`,cause:e}):new c({message:`No available authenticator supported any of the specified pubKeyCredParams algorithms`,code:`ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!s(t))return new c({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rp.id!==t)return new c({message:`The RP ID "${n.rp.id}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`TypeError`){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new c({message:`User ID was not between 1 and 64 characters`,code:`ERROR_INVALID_USER_ID_LENGTH`,cause:e})}else if(e.name===`UnknownError`)return new c({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}var u=new class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let e=Error(`Cancelling existing WebAuthn API call for new one`);e.name=`AbortError`,this.controller.abort(e)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error(`Manually cancelling existing WebAuthn API call`);e.name=`AbortError`,this.controller.abort(e),this.controller=void 0}}},d=[`cross-platform`,`platform`];function f(e){if(e&&!(d.indexOf(e)<0))return e}async function p(e){!e.optionsJSON&&e.challenge&&(console.warn(`startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useAutoRegister:a=!1}=e;if(!i())throw Error(`WebAuthn is not supported in this browser`);let s={...t,challenge:r(t.challenge),user:{...t.user,id:r(t.user.id)},excludeCredentials:t.excludeCredentials?.map(o)},c={};a&&(c.mediation=`conditional`),c.publicKey=s,c.signal=u.createNewAbortSignal();let d;try{d=await navigator.credentials.create(c)}catch(e){throw l({error:e,options:c})}if(!d)throw Error(`Registration was not completed`);let{id:p,rawId:h,response:g,type:_}=d,v;typeof g.getTransports==`function`&&(v=g.getTransports());let y;if(typeof g.getPublicKeyAlgorithm==`function`)try{y=g.getPublicKeyAlgorithm()}catch(e){m(`getPublicKeyAlgorithm()`,e)}let b;if(typeof g.getPublicKey==`function`)try{let e=g.getPublicKey();e!==null&&(b=n(e))}catch(e){m(`getPublicKey()`,e)}let x;if(typeof g.getAuthenticatorData==`function`)try{x=n(g.getAuthenticatorData())}catch(e){m(`getAuthenticatorData()`,e)}return{id:p,rawId:n(h),response:{attestationObject:n(g.attestationObject),clientDataJSON:n(g.clientDataJSON),transports:v,publicKeyAlgorithm:y,publicKey:b,authenticatorData:x},type:_,clientExtensionResults:d.getClientExtensionResults(),authenticatorAttachment:f(d.authenticatorAttachment)}}function m(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(!i())return g.stubThis(new Promise(e=>e(!1)));let e=globalThis.PublicKeyCredential;return e?.isConditionalMediationAvailable===void 0?g.stubThis(new Promise(e=>e(!1))):g.stubThis(e.isConditionalMediationAvailable())}var g={stubThis:e=>e};function _({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new c({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new c({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!s(t))return new c({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new c({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`UnknownError`)return new c({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}async function v(e){!e.optionsJSON&&e.challenge&&(console.warn(`startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useBrowserAutofill:a=!1,verifyBrowserAutofillInput:s=!0}=e;if(!i())throw Error(`WebAuthn is not supported in this browser`);let c;t.allowCredentials?.length!==0&&(c=t.allowCredentials?.map(o));let l={...t,challenge:r(t.challenge),allowCredentials:c},d={};if(a){if(!await h())throw Error(`Browser does not support WebAuthn autofill`);if(document.querySelectorAll(`input[autocomplete$='webauthn']`).length<1&&s)throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');d.mediation=`conditional`,l.allowCredentials=[]}d.publicKey=l,d.signal=u.createNewAbortSignal();let p;try{p=await navigator.credentials.get(d)}catch(e){throw _({error:e,options:d})}if(!p)throw Error(`Authentication was not completed`);let{id:m,rawId:g,response:v,type:y}=p,b;return v.userHandle&&(b=n(v.userHandle)),{id:m,rawId:n(g),response:{authenticatorData:n(v.authenticatorData),clientDataJSON:n(v.clientDataJSON),signature:n(v.signature),userHandle:b},type:y,clientExtensionResults:p.getClientExtensionResults(),authenticatorAttachment:f(p.authenticatorAttachment)}}var y=e(t(),1);function b(e){return e instanceof Error&&(e.name===`NotAllowedError`||e.name===`AbortError`)}function x(){let[e,t]=(0,y.useState)(!1),n=(0,y.useRef)(0),r=(0,y.useRef)(!1),i=(0,y.useCallback)(e=>{r.current=e,t(e)},[]),a=(0,y.useCallback)(()=>{n.current++,u.cancelCeremony(),r.current=!1,t(!1)},[]),o=(0,y.useCallback)(async e=>{let t=++n.current;i(!0);try{let r=await e();return n.current===t?(i(!1),{ok:!0,value:r}):{ok:!1,canceled:!0}}catch(e){if(n.current!==t||(i(!1),b(e)))return{ok:!1,canceled:!0};throw e}},[i]);return(0,y.useEffect)(()=>()=>{r.current&&(n.current++,u.cancelCeremony())},[]),{waiting:e,run:o,cancel:a}}var S=2e3;function C(e){return{phase:`waiting`,startedAt:e,message:null}}function w(e,t){if(e.phase!==`waiting`)return e;if(t.type===`cancel`)return{...e,phase:`canceled`};if(t.now-e.startedAt>=6e5&&t.type!==`claim`)return{...e,phase:`timeout`};switch(t.type){case`tick`:return e;case`claim`:return t.result.status===`done`?{...e,phase:`done`}:t.now-e.startedAt>=6e5?{...e,phase:`timeout`}:e;case`claim_error`:return t.code===`unauthorized`||t.code===`invalid_request`?{...e,phase:`failed`,message:t.message}:e}}function T(e,t){return e.phase===`waiting`&&t}var E=`This account is not allowed to sign in to this server.`,D={enrollment_expired:"This sign-in link has expired. Links are valid for 10 minutes. Run `switchyard pair` on the server for a new one.",enrollment_used:"This sign-in link was already used. Each link signs in one browser. Run `switchyard pair` on the server for a new one.",invalid_request:`The sign-in request was rejected. Try again.`,network:`Could not reach the coordinator. Check your connection and try again.`,rate_limited:`Too many attempts. Wait a minute and try again.`,unsupported_capability:`This sign-in method is not available on this server.`,unauthorized:`That sign-in was not accepted. Try again, or use another sign-in method.`};function O(e,t){let n=t?.trim()||null;switch(e){case`forbidden`:return n??E;case`oidc_failed`:return`Single sign-on failed: ${n??`the identity provider returned an error.`}`;case`unsupported_capability`:return n??D.unsupported_capability;default:return D[e]??n??`Sign-in failed (${e}).`}}function k(e){switch(e){case`enrollment_expired`:return`Sign-in link expired`;case`enrollment_used`:return`Sign-in link already used`;case`forbidden`:return`Not allowed`;case`oidc_failed`:return`Single sign-on failed`;case`rate_limited`:return`Too many attempts`;default:return`Sign-in failed`}}function A(e=navigator.userAgent){let t=/iPhone/.test(e)?`iPhone`:/iPad/.test(e)||/Macintosh/.test(e)&&navigator.maxTouchPoints>1?`iPad`:/Android/.test(e)?`Android`:/Macintosh|Mac OS X/.test(e)?`Mac`:/Windows/.test(e)?`Windows`:/Linux/.test(e)?`Linux`:`device`;return`${/Edg\//.test(e)?`Edge`:/Firefox\/|FxiOS/.test(e)?`Firefox`:/Chrome\/|CriOS/.test(e)?`Chrome`:/Safari\//.test(e)?`Safari`:`Browser`} on ${t}`}export{k as a,C as c,p as d,i as f,O as i,x as l,S as n,w as o,A as r,T as s,D as t,v as u};
|
|
2
|
+
//# sourceMappingURL=logic-c8AsGwGr.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logic-CG2E-voG.js","names":["useState","useRef","useCallback","require_react","__toESM","bufferToBase64URLString","bytes","buffer","str","charCode","base64URLStringToBuffer","base64","base64URLString","padLength","padded","binary","i","browserSupportsWebAuthn","_browserSupportsWebAuthnInternals","value","toPublicKeyCredentialDescriptor","descriptor","id","isValidDomain","hostname","WebAuthnError","message","name","cause","code","identifyRegistrationError","options","publicKey","error","param","effectiveDomain","WebAuthnAbortService","abortError","newController","attachments","toAuthenticatorAttachment","attachment","startRegistration","optionsJSON","createOptions","useAutoRegister","credential","err","transports","response","responsePublicKeyAlgorithm","warnOnBrokenImplementation","responsePublicKey","_publicKey","responseAuthenticatorData","rawId","methodName","browserSupportsWebAuthnAutofill","_browserSupportsWebAuthnAutofillInternals","resolve","globalPublicKeyCredential","identifyAuthenticationError","startAuthentication","allowCredentials","getOptions","useBrowserAutofill","verifyBrowserAutofillInput","userHandle","import_react","isCanceledCeremony","usePasskeyCeremony","waiting","setWaiting","token","waitingRef","set","v","cancel","run","mine","fn","HANDOFF_POLL_MS","startHandoff","now","handoffReduce","state","event","shouldPoll","visible","GENERIC_FORBIDDEN","ERROR_TEXT","enrollErrorText","d","detail","enrollErrorTitle","defaultDeviceName","device","ua"],"sources":["../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/bufferToBase64URLString.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/base64URLStringToBuffer.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/browserSupportsWebAuthn.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/toPublicKeyCredentialDescriptor.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/isValidDomain.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/webAuthnError.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/identifyRegistrationError.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/webAuthnAbortService.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/toAuthenticatorAttachment.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/methods/startRegistration.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/browserSupportsWebAuthnAutofill.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/identifyAuthenticationError.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/methods/startAuthentication.js","../../src/app/passkeyCeremony.ts","../../src/features/enroll/logic.ts"],"sourcesContent":["/**\n * Convert the given array buffer into a Base64URL-encoded string. Ideal for converting various\n * credential response ArrayBuffers to string for sending back to the server as JSON.\n *\n * Helper method to compliment `base64URLStringToBuffer`\n */\nexport function bufferToBase64URLString(buffer) {\n const bytes = new Uint8Array(buffer);\n let str = '';\n for (const charCode of bytes) {\n str += String.fromCharCode(charCode);\n }\n const base64String = btoa(str);\n return base64String.replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=/g, '');\n}\n","/**\n * Convert from a Base64URL-encoded string to an Array Buffer. Best used when converting a\n * credential ID from a JSON string to an ArrayBuffer, like in allowCredentials or\n * excludeCredentials\n *\n * Helper method to compliment `bufferToBase64URLString`\n */\nexport function base64URLStringToBuffer(base64URLString) {\n // Convert from Base64URL to Base64\n const base64 = base64URLString.replace(/-/g, '+').replace(/_/g, '/');\n /**\n * Pad with '=' until it's a multiple of four\n * (4 - (85 % 4 = 1) = 3) % 4 = 3 padding\n * (4 - (86 % 4 = 2) = 2) % 4 = 2 padding\n * (4 - (87 % 4 = 3) = 1) % 4 = 1 padding\n * (4 - (88 % 4 = 0) = 4) % 4 = 0 padding\n */\n const padLength = (4 - (base64.length % 4)) % 4;\n const padded = base64.padEnd(base64.length + padLength, '=');\n // Convert to a binary string\n const binary = atob(padded);\n // Convert binary string to buffer\n const buffer = new ArrayBuffer(binary.length);\n const bytes = new Uint8Array(buffer);\n for (let i = 0; i < binary.length; i++) {\n bytes[i] = binary.charCodeAt(i);\n }\n return buffer;\n}\n","/**\n * Determine if the browser is capable of Webauthn\n */\nexport function browserSupportsWebAuthn() {\n return _browserSupportsWebAuthnInternals.stubThis(globalThis?.PublicKeyCredential !== undefined &&\n typeof globalThis.PublicKeyCredential === 'function');\n}\n/**\n * Make it possible to stub the return value during testing\n * @ignore Don't include this in docs output\n */\nexport const _browserSupportsWebAuthnInternals = {\n stubThis: (value) => value,\n};\n","import { base64URLStringToBuffer } from './base64URLStringToBuffer.js';\nexport function toPublicKeyCredentialDescriptor(descriptor) {\n const { id } = descriptor;\n return {\n ...descriptor,\n id: base64URLStringToBuffer(id),\n transports: descriptor.transports,\n type: descriptor.type,\n };\n}\n","/**\n * A simple test to determine if a hostname is a properly-formatted domain name\n *\n * A \"valid domain\" is defined here: https://url.spec.whatwg.org/#valid-domain\n *\n * Regex was originally sourced from here, then remixed to add punycode support:\n * https://www.oreilly.com/library/view/regular-expressions-cookbook/9781449327453/ch08s15.html\n */\nexport function isValidDomain(hostname) {\n return (\n // Consider localhost valid as well since it's okay wrt Secure Contexts\n hostname === 'localhost' ||\n // Support punycode (ACE) or ascii labels and domains\n /^((xn--[a-z0-9-]+|[a-z0-9]+(-[a-z0-9]+)*)\\.)+([a-z]{2,}|xn--[a-z0-9-]+)$/i.test(hostname));\n}\n","/**\n * A custom Error used to return a more nuanced error detailing _why_ one of the eight documented\n * errors in the spec was raised after calling `navigator.credentials.create()` or\n * `navigator.credentials.get()`:\n *\n * - `AbortError`\n * - `ConstraintError`\n * - `InvalidStateError`\n * - `NotAllowedError`\n * - `NotSupportedError`\n * - `SecurityError`\n * - `TypeError`\n * - `UnknownError`\n *\n * Error messages were determined through investigation of the spec to determine under which\n * scenarios a given error would be raised.\n */\nexport class WebAuthnError extends Error {\n constructor({ message, code, cause, name, }) {\n // @ts-ignore: help Rollup understand that `cause` is okay to set\n super(message, { cause });\n Object.defineProperty(this, \"code\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n this.name = name ?? cause.name;\n this.code = code;\n }\n}\n","import { isValidDomain } from './isValidDomain.js';\nimport { WebAuthnError } from './webAuthnError.js';\n/**\n * Attempt to intuit _why_ an error was raised after calling `navigator.credentials.create()`\n */\nexport function identifyRegistrationError({ error, options, }) {\n const { publicKey } = options;\n if (!publicKey) {\n throw Error('options was missing required publicKey property');\n }\n if (error.name === 'AbortError') {\n if (options.signal instanceof AbortSignal) {\n // https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 16)\n return new WebAuthnError({\n message: 'Registration ceremony was sent an abort signal',\n code: 'ERROR_CEREMONY_ABORTED',\n cause: error,\n });\n }\n }\n else if (error.name === 'ConstraintError') {\n if (publicKey.authenticatorSelection?.requireResidentKey === true) {\n // https://www.w3.org/TR/webauthn-2/#sctn-op-make-cred (Step 4)\n return new WebAuthnError({\n message: 'Discoverable credentials were required but no available authenticator supported it',\n code: 'ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT',\n cause: error,\n });\n }\n else if (\n // @ts-ignore: `mediation` doesn't yet exist on CredentialCreationOptions but it's possible as of Sept 2024\n options.mediation === 'conditional' &&\n publicKey.authenticatorSelection?.userVerification === 'required') {\n // https://w3c.github.io/webauthn/#sctn-createCredential (Step 22.4)\n return new WebAuthnError({\n message: 'User verification was required during automatic registration but it could not be performed',\n code: 'ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE',\n cause: error,\n });\n }\n else if (publicKey.authenticatorSelection?.userVerification === 'required') {\n // https://www.w3.org/TR/webauthn-2/#sctn-op-make-cred (Step 5)\n return new WebAuthnError({\n message: 'User verification was required but no available authenticator supported it',\n code: 'ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT',\n cause: error,\n });\n }\n }\n else if (error.name === 'InvalidStateError') {\n // https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 20)\n // https://www.w3.org/TR/webauthn-2/#sctn-op-make-cred (Step 3)\n return new WebAuthnError({\n message: 'The authenticator was previously registered',\n code: 'ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED',\n cause: error,\n });\n }\n else if (error.name === 'NotAllowedError') {\n /**\n * Pass the error directly through. Platforms are overloading this error beyond what the spec\n * defines and we don't want to overwrite potentially useful error messages.\n */\n return new WebAuthnError({\n message: error.message,\n code: 'ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY',\n cause: error,\n });\n }\n else if (error.name === 'NotSupportedError') {\n const validPubKeyCredParams = publicKey.pubKeyCredParams.filter((param) => param.type === 'public-key');\n if (validPubKeyCredParams.length === 0) {\n // https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 10)\n return new WebAuthnError({\n message: 'No entry in pubKeyCredParams was of type \"public-key\"',\n code: 'ERROR_MALFORMED_PUBKEYCREDPARAMS',\n cause: error,\n });\n }\n // https://www.w3.org/TR/webauthn-2/#sctn-op-make-cred (Step 2)\n return new WebAuthnError({\n message: 'No available authenticator supported any of the specified pubKeyCredParams algorithms',\n code: 'ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG',\n cause: error,\n });\n }\n else if (error.name === 'SecurityError') {\n const effectiveDomain = globalThis.location.hostname;\n if (!isValidDomain(effectiveDomain)) {\n // https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 7)\n return new WebAuthnError({\n message: `${globalThis.location.hostname} is an invalid domain`,\n code: 'ERROR_INVALID_DOMAIN',\n cause: error,\n });\n }\n else if (publicKey.rp.id !== effectiveDomain) {\n // https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 8)\n return new WebAuthnError({\n message: `The RP ID \"${publicKey.rp.id}\" is invalid for this domain`,\n code: 'ERROR_INVALID_RP_ID',\n cause: error,\n });\n }\n }\n else if (error.name === 'TypeError') {\n if (publicKey.user.id.byteLength < 1 || publicKey.user.id.byteLength > 64) {\n // https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 5)\n return new WebAuthnError({\n message: 'User ID was not between 1 and 64 characters',\n code: 'ERROR_INVALID_USER_ID_LENGTH',\n cause: error,\n });\n }\n }\n else if (error.name === 'UnknownError') {\n // https://www.w3.org/TR/webauthn-2/#sctn-op-make-cred (Step 1)\n // https://www.w3.org/TR/webauthn-2/#sctn-op-make-cred (Step 8)\n return new WebAuthnError({\n message: 'The authenticator was unable to process the specified options, or could not create a new credential',\n code: 'ERROR_AUTHENTICATOR_GENERAL_ERROR',\n cause: error,\n });\n }\n return error;\n}\n","class BaseWebAuthnAbortService {\n constructor() {\n Object.defineProperty(this, \"controller\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n }\n createNewAbortSignal() {\n // Abort any existing calls to navigator.credentials.create() or navigator.credentials.get()\n if (this.controller) {\n const abortError = new Error('Cancelling existing WebAuthn API call for new one');\n abortError.name = 'AbortError';\n this.controller.abort(abortError);\n }\n const newController = new AbortController();\n this.controller = newController;\n return newController.signal;\n }\n cancelCeremony() {\n if (this.controller) {\n const abortError = new Error('Manually cancelling existing WebAuthn API call');\n abortError.name = 'AbortError';\n this.controller.abort(abortError);\n this.controller = undefined;\n }\n }\n}\n/**\n * A service singleton to help ensure that only a single WebAuthn ceremony is active at a time.\n *\n * Users of **@simplewebauthn/browser** shouldn't typically need to use this, but it can help e.g.\n * developers building projects that use client-side routing to better control the behavior of\n * their UX in response to router navigation events.\n */\nexport const WebAuthnAbortService = new BaseWebAuthnAbortService();\n","const attachments = ['cross-platform', 'platform'];\n/**\n * If possible coerce a `string` value into a known `AuthenticatorAttachment`\n */\nexport function toAuthenticatorAttachment(attachment) {\n if (!attachment) {\n return;\n }\n if (attachments.indexOf(attachment) < 0) {\n return;\n }\n return attachment;\n}\n","import { bufferToBase64URLString } from '../helpers/bufferToBase64URLString.js';\nimport { base64URLStringToBuffer } from '../helpers/base64URLStringToBuffer.js';\nimport { browserSupportsWebAuthn } from '../helpers/browserSupportsWebAuthn.js';\nimport { toPublicKeyCredentialDescriptor } from '../helpers/toPublicKeyCredentialDescriptor.js';\nimport { identifyRegistrationError } from '../helpers/identifyRegistrationError.js';\nimport { WebAuthnAbortService } from '../helpers/webAuthnAbortService.js';\nimport { toAuthenticatorAttachment } from '../helpers/toAuthenticatorAttachment.js';\n/**\n * Begin authenticator \"registration\" via WebAuthn attestation\n *\n * @param optionsJSON Output from **@simplewebauthn/server**'s `generateRegistrationOptions()`\n * @param useAutoRegister (Optional) Try to silently create a passkey with the password manager that the user just signed in with. Defaults to `false`.\n */\nexport async function startRegistration(options) {\n // @ts-ignore: Intentionally check for old call structure to warn about improper API call\n if (!options.optionsJSON && options.challenge) {\n console.warn('startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.');\n // @ts-ignore: Reassign the options, passed in as a positional argument, to the expected variable\n options = { optionsJSON: options };\n }\n const { optionsJSON, useAutoRegister = false } = options;\n if (!browserSupportsWebAuthn()) {\n throw new Error('WebAuthn is not supported in this browser');\n }\n // We need to convert some values to Uint8Arrays before passing the credentials to the navigator\n const publicKey = {\n ...optionsJSON,\n challenge: base64URLStringToBuffer(optionsJSON.challenge),\n user: {\n ...optionsJSON.user,\n id: base64URLStringToBuffer(optionsJSON.user.id),\n },\n excludeCredentials: optionsJSON.excludeCredentials?.map(toPublicKeyCredentialDescriptor),\n };\n // Prepare options for `.create()`\n const createOptions = {};\n /**\n * Try to use conditional create to register a passkey for the user with the password manager\n * the user just used to authenticate with. The user won't be shown any prominent UI by the\n * browser.\n */\n if (useAutoRegister) {\n // @ts-ignore: `mediation` doesn't yet exist on CredentialCreationOptions but it's possible as of Sept 2024\n createOptions.mediation = 'conditional';\n }\n // Finalize options\n createOptions.publicKey = publicKey;\n // Set up the ability to cancel this request if the user attempts another\n createOptions.signal = WebAuthnAbortService.createNewAbortSignal();\n // Wait for the user to complete attestation\n let credential;\n try {\n credential = (await navigator.credentials.create(\n // TODO: Newer versions of Deno require this casting, revisit once we're using Deno 2.6+\n createOptions));\n }\n catch (err) {\n throw identifyRegistrationError({ error: err, options: createOptions });\n }\n if (!credential) {\n throw new Error('Registration was not completed');\n }\n const { id, rawId, response, type } = credential;\n // Continue to play it safe with `getTransports()` for now, even when L3 types say it's required\n let transports = undefined;\n if (typeof response.getTransports === 'function') {\n transports = response.getTransports();\n }\n // L3 says this is required, but browser and webview support are still not guaranteed.\n let responsePublicKeyAlgorithm = undefined;\n if (typeof response.getPublicKeyAlgorithm === 'function') {\n try {\n responsePublicKeyAlgorithm = response.getPublicKeyAlgorithm();\n }\n catch (error) {\n warnOnBrokenImplementation('getPublicKeyAlgorithm()', error);\n }\n }\n let responsePublicKey = undefined;\n if (typeof response.getPublicKey === 'function') {\n try {\n const _publicKey = response.getPublicKey();\n if (_publicKey !== null) {\n responsePublicKey = bufferToBase64URLString(_publicKey);\n }\n }\n catch (error) {\n warnOnBrokenImplementation('getPublicKey()', error);\n }\n }\n // L3 says this is required, but browser and webview support are still not guaranteed.\n let responseAuthenticatorData;\n if (typeof response.getAuthenticatorData === 'function') {\n try {\n responseAuthenticatorData = bufferToBase64URLString(response.getAuthenticatorData());\n }\n catch (error) {\n warnOnBrokenImplementation('getAuthenticatorData()', error);\n }\n }\n return {\n id,\n rawId: bufferToBase64URLString(rawId),\n response: {\n attestationObject: bufferToBase64URLString(response.attestationObject),\n clientDataJSON: bufferToBase64URLString(response.clientDataJSON),\n transports,\n publicKeyAlgorithm: responsePublicKeyAlgorithm,\n publicKey: responsePublicKey,\n authenticatorData: responseAuthenticatorData,\n },\n type,\n clientExtensionResults: credential.getClientExtensionResults(),\n authenticatorAttachment: toAuthenticatorAttachment(credential.authenticatorAttachment),\n };\n}\n/**\n * Visibly warn when we detect an issue related to a passkey provider intercepting WebAuthn API\n * calls\n */\nfunction warnOnBrokenImplementation(methodName, cause) {\n console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${methodName}. You should report this error to them.\\n`, cause);\n}\n","import { browserSupportsWebAuthn } from './browserSupportsWebAuthn.js';\n/**\n * Determine if the browser supports conditional UI, so that WebAuthn credentials can\n * be shown to the user in the browser's typical password autofill popup.\n */\nexport function browserSupportsWebAuthnAutofill() {\n if (!browserSupportsWebAuthn()) {\n return _browserSupportsWebAuthnAutofillInternals.stubThis(new Promise((resolve) => resolve(false)));\n }\n /**\n * I don't like the `as unknown` here but there's a `declare var PublicKeyCredential` in\n * TS' DOM lib that's making it difficult for me to just go `as PublicKeyCredentialFuture` as I\n * want. I think I'm fine with this for now since it's _supposed_ to be temporary, until TS types\n * have a chance to catch up.\n */\n const globalPublicKeyCredential = globalThis\n .PublicKeyCredential;\n if (globalPublicKeyCredential?.isConditionalMediationAvailable === undefined) {\n return _browserSupportsWebAuthnAutofillInternals.stubThis(new Promise((resolve) => resolve(false)));\n }\n return _browserSupportsWebAuthnAutofillInternals.stubThis(globalPublicKeyCredential.isConditionalMediationAvailable());\n}\n// Make it possible to stub the return value during testing\nexport const _browserSupportsWebAuthnAutofillInternals = {\n stubThis: (value) => value,\n};\n","import { isValidDomain } from './isValidDomain.js';\nimport { WebAuthnError } from './webAuthnError.js';\n/**\n * Attempt to intuit _why_ an error was raised after calling `navigator.credentials.get()`\n */\nexport function identifyAuthenticationError({ error, options, }) {\n const { publicKey } = options;\n if (!publicKey) {\n throw Error('options was missing required publicKey property');\n }\n if (error.name === 'AbortError') {\n if (options.signal instanceof AbortSignal) {\n // https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 16)\n return new WebAuthnError({\n message: 'Authentication ceremony was sent an abort signal',\n code: 'ERROR_CEREMONY_ABORTED',\n cause: error,\n });\n }\n }\n else if (error.name === 'NotAllowedError') {\n /**\n * Pass the error directly through. Platforms are overloading this error beyond what the spec\n * defines and we don't want to overwrite potentially useful error messages.\n */\n return new WebAuthnError({\n message: error.message,\n code: 'ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY',\n cause: error,\n });\n }\n else if (error.name === 'SecurityError') {\n const effectiveDomain = globalThis.location.hostname;\n if (!isValidDomain(effectiveDomain)) {\n // https://www.w3.org/TR/webauthn-2/#sctn-discover-from-external-source (Step 5)\n return new WebAuthnError({\n message: `${globalThis.location.hostname} is an invalid domain`,\n code: 'ERROR_INVALID_DOMAIN',\n cause: error,\n });\n }\n else if (publicKey.rpId !== effectiveDomain) {\n // https://www.w3.org/TR/webauthn-2/#sctn-discover-from-external-source (Step 6)\n return new WebAuthnError({\n message: `The RP ID \"${publicKey.rpId}\" is invalid for this domain`,\n code: 'ERROR_INVALID_RP_ID',\n cause: error,\n });\n }\n }\n else if (error.name === 'UnknownError') {\n // https://www.w3.org/TR/webauthn-2/#sctn-op-get-assertion (Step 1)\n // https://www.w3.org/TR/webauthn-2/#sctn-op-get-assertion (Step 12)\n return new WebAuthnError({\n message: 'The authenticator was unable to process the specified options, or could not create a new assertion signature',\n code: 'ERROR_AUTHENTICATOR_GENERAL_ERROR',\n cause: error,\n });\n }\n return error;\n}\n","import { bufferToBase64URLString } from '../helpers/bufferToBase64URLString.js';\nimport { base64URLStringToBuffer } from '../helpers/base64URLStringToBuffer.js';\nimport { browserSupportsWebAuthn } from '../helpers/browserSupportsWebAuthn.js';\nimport { browserSupportsWebAuthnAutofill } from '../helpers/browserSupportsWebAuthnAutofill.js';\nimport { toPublicKeyCredentialDescriptor } from '../helpers/toPublicKeyCredentialDescriptor.js';\nimport { identifyAuthenticationError } from '../helpers/identifyAuthenticationError.js';\nimport { WebAuthnAbortService } from '../helpers/webAuthnAbortService.js';\nimport { toAuthenticatorAttachment } from '../helpers/toAuthenticatorAttachment.js';\n/**\n * Begin authenticator \"login\" via WebAuthn assertion\n *\n * @param optionsJSON Output from **@simplewebauthn/server**'s `generateAuthenticationOptions()`\n * @param useBrowserAutofill (Optional) Initialize conditional UI to enable logging in via browser autofill prompts. Defaults to `false`.\n * @param verifyBrowserAutofillInput (Optional) Ensure a suitable `<input>` element is present when `useBrowserAutofill` is `true`. Defaults to `true`.\n */\nexport async function startAuthentication(options) {\n // @ts-ignore: Intentionally check for old call structure to warn about improper API call\n if (!options.optionsJSON && options.challenge) {\n console.warn('startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.');\n // @ts-ignore: Reassign the options, passed in as a positional argument, to the expected variable\n options = { optionsJSON: options };\n }\n const { optionsJSON, useBrowserAutofill = false, verifyBrowserAutofillInput = true, } = options;\n if (!browserSupportsWebAuthn()) {\n throw new Error('WebAuthn is not supported in this browser');\n }\n // We need to avoid passing empty array to avoid blocking retrieval\n // of public key\n let allowCredentials;\n if (optionsJSON.allowCredentials?.length !== 0) {\n allowCredentials = optionsJSON.allowCredentials?.map(toPublicKeyCredentialDescriptor);\n }\n // We need to convert some values to Uint8Arrays before passing the credentials to the navigator\n const publicKey = {\n ...optionsJSON,\n challenge: base64URLStringToBuffer(optionsJSON.challenge),\n allowCredentials,\n };\n // Prepare options for `.get()`\n const getOptions = {};\n /**\n * Set up the page to prompt the user to select a credential for authentication via the browser's\n * input autofill mechanism.\n */\n if (useBrowserAutofill) {\n if (!(await browserSupportsWebAuthnAutofill())) {\n throw Error('Browser does not support WebAuthn autofill');\n }\n // Check for an <input> with \"webauthn\" in its `autocomplete` attribute\n const eligibleInputs = document.querySelectorAll(\"input[autocomplete$='webauthn']\");\n // WebAuthn autofill requires at least one valid input\n if (eligibleInputs.length < 1 && verifyBrowserAutofillInput) {\n throw Error('No <input> with \"webauthn\" as the only or last value in its `autocomplete` attribute was detected');\n }\n // `CredentialMediationRequirement` doesn't know about \"conditional\" yet as of\n // typescript@4.6.3\n getOptions.mediation = 'conditional';\n // Conditional UI requires an empty allow list\n publicKey.allowCredentials = [];\n }\n // Finalize options\n getOptions.publicKey = publicKey;\n // Set up the ability to cancel this request if the user attempts another\n getOptions.signal = WebAuthnAbortService.createNewAbortSignal();\n // Wait for the user to complete assertion\n let credential;\n try {\n credential = (await navigator.credentials.get(\n // TODO: Newer versions of Deno require this casting, revisit once we're using Deno 2.6+\n getOptions));\n }\n catch (err) {\n throw identifyAuthenticationError({ error: err, options: getOptions });\n }\n if (!credential) {\n throw new Error('Authentication was not completed');\n }\n const { id, rawId, response, type } = credential;\n let userHandle = undefined;\n if (response.userHandle) {\n userHandle = bufferToBase64URLString(response.userHandle);\n }\n // Convert values to base64 to make it easier to send back to the server\n return {\n id,\n rawId: bufferToBase64URLString(rawId),\n response: {\n authenticatorData: bufferToBase64URLString(response.authenticatorData),\n clientDataJSON: bufferToBase64URLString(response.clientDataJSON),\n signature: bufferToBase64URLString(response.signature),\n userHandle,\n },\n type,\n clientExtensionResults: credential.getClientExtensionResults(),\n authenticatorAttachment: toAuthenticatorAttachment(credential.authenticatorAttachment),\n };\n}\n","import { WebAuthnAbortService } from \"@simplewebauthn/browser\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\n/** A dismissed or aborted passkey prompt. */\nexport function isCanceledCeremony(err: unknown): boolean {\n return err instanceof Error && (err.name === \"NotAllowedError\" || err.name === \"AbortError\");\n}\n\n/**\n * Runs a WebAuthn ceremony the user can cancel at once. Some authenticator UIs never reject when\n * their popup closes, so Cancel does not wait for the browser: it resets and ignores the late result.\n */\nexport function usePasskeyCeremony() {\n const [waiting, setWaiting] = useState(false);\n const token = useRef(0);\n const waitingRef = useRef(false);\n\n const set = useCallback((v: boolean) => {\n waitingRef.current = v;\n setWaiting(v);\n }, []);\n\n const cancel = useCallback(() => {\n token.current++;\n WebAuthnAbortService.cancelCeremony();\n waitingRef.current = false;\n setWaiting(false);\n }, []);\n\n const run = useCallback(\n async <T>(\n fn: () => Promise<T>,\n ): Promise<{ ok: true; value: T } | { ok: false; canceled: true }> => {\n const mine = ++token.current;\n set(true);\n try {\n const value = await fn();\n if (token.current !== mine) return { ok: false, canceled: true };\n set(false);\n return { ok: true, value };\n } catch (err) {\n if (token.current !== mine) return { ok: false, canceled: true };\n set(false);\n if (isCanceledCeremony(err)) return { ok: false, canceled: true };\n throw err;\n }\n },\n [set],\n );\n\n useEffect(\n () => () => {\n if (waitingRef.current) {\n token.current++;\n WebAuthnAbortService.cancelCeremony();\n }\n },\n [],\n );\n\n return { waiting, run, cancel };\n}\n","import type { OidcClaimResponse } from \"@switchyard/protocol\";\n\n/** How often the PWA polls `POST /api/auth/oidc/claim` while the screen is visible. */\nexport const HANDOFF_POLL_MS = 2000;\n/** How long a handoff waits before giving up (the coordinator flow lives 10 minutes). */\nexport const HANDOFF_TIMEOUT_MS = 10 * 60 * 1000;\n\nexport type HandoffPhase = \"waiting\" | \"done\" | \"timeout\" | \"failed\" | \"canceled\";\n\nexport interface HandoffState {\n phase: HandoffPhase;\n startedAt: number;\n /** Set when `phase` is `failed`. */\n message: string | null;\n}\n\nexport type HandoffEvent =\n | { type: \"claim\"; result: OidcClaimResponse; now: number }\n | { type: \"claim_error\"; code: string; message: string; now: number }\n | { type: \"tick\"; now: number }\n | { type: \"cancel\" };\n\nexport function startHandoff(now: number): HandoffState {\n return { phase: \"waiting\", startedAt: now, message: null };\n}\n\n/**\n * Pure state machine for the PWA single sign-on handoff. Terminal phases\n * never change. A transient error (network, server hiccup) keeps waiting;\n * an expired or unknown flow (`unauthorized`, `invalid_request`) fails.\n */\nexport function handoffReduce(state: HandoffState, event: HandoffEvent): HandoffState {\n if (state.phase !== \"waiting\") return state;\n if (event.type === \"cancel\") return { ...state, phase: \"canceled\" };\n if (event.now - state.startedAt >= HANDOFF_TIMEOUT_MS && event.type !== \"claim\") {\n return { ...state, phase: \"timeout\" };\n }\n switch (event.type) {\n case \"tick\":\n return state;\n case \"claim\":\n if (event.result.status === \"done\") return { ...state, phase: \"done\" };\n return event.now - state.startedAt >= HANDOFF_TIMEOUT_MS\n ? { ...state, phase: \"timeout\" }\n : state;\n case \"claim_error\":\n if (event.code === \"unauthorized\" || event.code === \"invalid_request\") {\n return { ...state, phase: \"failed\", message: event.message };\n }\n return state;\n }\n}\n\n/** Whether a poll should run now: still waiting and the page is visible. */\nexport function shouldPoll(state: HandoffState, visible: boolean): boolean {\n return state.phase === \"waiting\" && visible;\n}\n\nconst GENERIC_FORBIDDEN = \"This account is not allowed to sign in to this server.\";\n\n/** Static texts for coordinator error codes shown on /sign-in. */\nexport const ERROR_TEXT: Record<string, string> = {\n enrollment_expired:\n \"This sign-in link has expired. Links are valid for 10 minutes. Run `switchyard pair` on the server for a new one.\",\n enrollment_used:\n \"This sign-in link was already used. Each link signs in one browser. Run `switchyard pair` on the server for a new one.\",\n invalid_request: \"The sign-in request was rejected. Try again.\",\n network: \"Could not reach the coordinator. Check your connection and try again.\",\n rate_limited: \"Too many attempts. Wait a minute and try again.\",\n unsupported_capability: \"This sign-in method is not available on this server.\",\n unauthorized: \"That sign-in was not accepted. Try again, or use another sign-in method.\",\n};\n\n/**\n * Message for an error code, with the coordinator's `detail` where it is the\n * useful part (`/sign-in?error=forbidden&detail=Signed in as ...`).\n */\nexport function enrollErrorText(code: string, detail?: string | null): string {\n const d = detail?.trim() || null;\n switch (code) {\n case \"forbidden\":\n return d ?? GENERIC_FORBIDDEN;\n case \"oidc_failed\":\n return `Single sign-on failed: ${d ?? \"the identity provider returned an error.\"}`;\n case \"unsupported_capability\":\n return d ?? (ERROR_TEXT.unsupported_capability as string);\n default:\n return ERROR_TEXT[code] ?? d ?? `Sign-in failed (${code}).`;\n }\n}\n\n/** Short heading for an error alert. */\nexport function enrollErrorTitle(code: string): string {\n switch (code) {\n case \"enrollment_expired\":\n return \"Sign-in link expired\";\n case \"enrollment_used\":\n return \"Sign-in link already used\";\n case \"forbidden\":\n return \"Not allowed\";\n case \"oidc_failed\":\n return \"Single sign-on failed\";\n case \"rate_limited\":\n return \"Too many attempts\";\n default:\n return \"Sign-in failed\";\n }\n}\n\n/** A readable default device name from the user agent, e.g. \"Safari on iPhone\". */\nexport function defaultDeviceName(ua: string = navigator.userAgent): string {\n const device = /iPhone/.test(ua)\n ? \"iPhone\"\n : /iPad/.test(ua) || (/Macintosh/.test(ua) && navigator.maxTouchPoints > 1)\n ? \"iPad\"\n : /Android/.test(ua)\n ? \"Android\"\n : /Macintosh|Mac OS X/.test(ua)\n ? \"Mac\"\n : /Windows/.test(ua)\n ? \"Windows\"\n : /Linux/.test(ua)\n ? \"Linux\"\n : \"device\";\n const browser = /Edg\\//.test(ua)\n ? \"Edge\"\n : /Firefox\\/|FxiOS/.test(ua)\n ? \"Firefox\"\n : /Chrome\\/|CriOS/.test(ua)\n ? \"Chrome\"\n : /Safari\\//.test(ua)\n ? \"Safari\"\n : \"Browser\";\n return `${browser} on ${device}`;\n}\n"],"ignoreList":[0,1,2,3,4,5,6,7,8,9,10,11,12],"mappings":"A,kDAMA,SAAgBK,EAAwB,EAAQ,CAC5C,IAAMC,EAAQ,IAAI,WAAWC,CAAM,EAC/BC,EAAM,GACV,IAAK,IAAMC,KAAYH,EACnB,GAAO,OAAO,aAAaG,CAAQ,EAGvC,OADqB,KAAKD,CACR,CAAC,CAAC,QAAQ,MAAO,GAAG,CAAC,CAAC,QAAQ,MAA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B/D,EAAK,GAC5D,CACF,CAGA,SAAgBiE,EAAiB,EAAsB,CACrD,OAAQjE,EAAR,CACE,IAAK,qBACH,MAAO,uBACT,IAAK,kBACH,MAAO,4BACT,IAAK,YACH,MAAO,cACT,IAAK,cACH,MAAO,wBACT,IAAK,eACH,MAAO,oBACT,QACE,MAAO,gBACX,CACF,CAGA,SAAgBkE,EAAkB,EAAa,UAAU,UAAmB,CAC1E,IAAMC,EAAS,SAAS,KAAKC,CAAE,EAC3B,SACA,OAAO,KAAKA,CAAE,GAAM,YAAY,KAAKA,CAAE,GAAK,UAAU,eAAiB,EACrE,OACA,UAAU,KAAKA,CAAE,EACf,UACA,qBAAqB,KAAKA,CAAE,EAC1B,MACA,UAAU,KAAKA,CAAE,EACf,UACA,QAAQ,KAAKA,CAAE,EACb,QACA,SAUd,MAAO,GATS,QAAQ,KAAKA,CAAE,EAC3B,OACA,kBAAkB,KAAKA,CAAE,EACvB,UACA,iBAAiB,KAAKA,CAAE,EACtB,SACA,WAAW,KAAKA,CAAE,EAChB,SACA,UACQ,MAAMD,GAC1B,C"}
|
|
1
|
+
{"version":3,"file":"logic-c8AsGwGr.js","names":["useState","useRef","useCallback","__toESM","require_react","bufferToBase64URLString","bytes","buffer","str","charCode","base64URLStringToBuffer","base64","base64URLString","padLength","padded","binary","i","browserSupportsWebAuthn","_browserSupportsWebAuthnInternals","value","toPublicKeyCredentialDescriptor","descriptor","id","isValidDomain","hostname","WebAuthnError","message","name","cause","code","identifyRegistrationError","options","publicKey","error","param","effectiveDomain","WebAuthnAbortService","abortError","newController","attachments","toAuthenticatorAttachment","attachment","startRegistration","optionsJSON","createOptions","useAutoRegister","credential","err","transports","response","responsePublicKeyAlgorithm","warnOnBrokenImplementation","responsePublicKey","_publicKey","responseAuthenticatorData","rawId","methodName","browserSupportsWebAuthnAutofill","_browserSupportsWebAuthnAutofillInternals","resolve","globalPublicKeyCredential","identifyAuthenticationError","startAuthentication","allowCredentials","getOptions","useBrowserAutofill","verifyBrowserAutofillInput","userHandle","import_react","isCanceledCeremony","usePasskeyCeremony","waiting","setWaiting","token","waitingRef","set","v","cancel","run","mine","fn","HANDOFF_POLL_MS","startHandoff","now","handoffReduce","state","event","shouldPoll","visible","GENERIC_FORBIDDEN","ERROR_TEXT","enrollErrorText","d","detail","enrollErrorTitle","defaultDeviceName","device","ua"],"sources":["../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/bufferToBase64URLString.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/base64URLStringToBuffer.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/browserSupportsWebAuthn.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/toPublicKeyCredentialDescriptor.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/isValidDomain.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/webAuthnError.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/identifyRegistrationError.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/webAuthnAbortService.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/toAuthenticatorAttachment.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/methods/startRegistration.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/browserSupportsWebAuthnAutofill.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/identifyAuthenticationError.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/methods/startAuthentication.js","../../src/app/passkeyCeremony.ts","../../src/features/enroll/logic.ts"],"sourcesContent":["/**\n * Convert the given array buffer into a Base64URL-encoded string. Ideal for converting various\n * credential response ArrayBuffers to string for sending back to the server as JSON.\n *\n * Helper method to compliment `base64URLStringToBuffer`\n */\nexport function bufferToBase64URLString(buffer) {\n const bytes = new Uint8Array(buffer);\n let str = '';\n for (const charCode of bytes) {\n str += String.fromCharCode(charCode);\n }\n const base64String = btoa(str);\n return base64String.replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=/g, '');\n}\n","/**\n * Convert from a Base64URL-encoded string to an Array Buffer. Best used when converting a\n * credential ID from a JSON string to an ArrayBuffer, like in allowCredentials or\n * excludeCredentials\n *\n * Helper method to compliment `bufferToBase64URLString`\n */\nexport function base64URLStringToBuffer(base64URLString) {\n // Convert from Base64URL to Base64\n const base64 = base64URLString.replace(/-/g, '+').replace(/_/g, '/');\n /**\n * Pad with '=' until it's a multiple of four\n * (4 - (85 % 4 = 1) = 3) % 4 = 3 padding\n * (4 - (86 % 4 = 2) = 2) % 4 = 2 padding\n * (4 - (87 % 4 = 3) = 1) % 4 = 1 padding\n * (4 - (88 % 4 = 0) = 4) % 4 = 0 padding\n */\n const padLength = (4 - (base64.length % 4)) % 4;\n const padded = base64.padEnd(base64.length + padLength, '=');\n // Convert to a binary string\n const binary = atob(padded);\n // Convert binary string to buffer\n const buffer = new ArrayBuffer(binary.length);\n const bytes = new Uint8Array(buffer);\n for (let i = 0; i < binary.length; i++) {\n bytes[i] = binary.charCodeAt(i);\n }\n return buffer;\n}\n","/**\n * Determine if the browser is capable of Webauthn\n */\nexport function browserSupportsWebAuthn() {\n return _browserSupportsWebAuthnInternals.stubThis(globalThis?.PublicKeyCredential !== undefined &&\n typeof globalThis.PublicKeyCredential === 'function');\n}\n/**\n * Make it possible to stub the return value during testing\n * @ignore Don't include this in docs output\n */\nexport const _browserSupportsWebAuthnInternals = {\n stubThis: (value) => value,\n};\n","import { base64URLStringToBuffer } from './base64URLStringToBuffer.js';\nexport function toPublicKeyCredentialDescriptor(descriptor) {\n const { id } = descriptor;\n return {\n ...descriptor,\n id: base64URLStringToBuffer(id),\n transports: descriptor.transports,\n type: descriptor.type,\n };\n}\n","/**\n * A simple test to determine if a hostname is a properly-formatted domain name\n *\n * A \"valid domain\" is defined here: https://url.spec.whatwg.org/#valid-domain\n *\n * Regex was originally sourced from here, then remixed to add punycode support:\n * https://www.oreilly.com/library/view/regular-expressions-cookbook/9781449327453/ch08s15.html\n */\nexport function isValidDomain(hostname) {\n return (\n // Consider localhost valid as well since it's okay wrt Secure Contexts\n hostname === 'localhost' ||\n // Support punycode (ACE) or ascii labels and domains\n /^((xn--[a-z0-9-]+|[a-z0-9]+(-[a-z0-9]+)*)\\.)+([a-z]{2,}|xn--[a-z0-9-]+)$/i.test(hostname));\n}\n","/**\n * A custom Error used to return a more nuanced error detailing _why_ one of the eight documented\n * errors in the spec was raised after calling `navigator.credentials.create()` or\n * `navigator.credentials.get()`:\n *\n * - `AbortError`\n * - `ConstraintError`\n * - `InvalidStateError`\n * - `NotAllowedError`\n * - `NotSupportedError`\n * - `SecurityError`\n * - `TypeError`\n * - `UnknownError`\n *\n * Error messages were determined through investigation of the spec to determine under which\n * scenarios a given error would be raised.\n */\nexport class WebAuthnError extends Error {\n constructor({ message, code, cause, name, }) {\n // @ts-ignore: help Rollup understand that `cause` is okay to set\n super(message, { cause });\n Object.defineProperty(this, \"code\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n this.name = name ?? cause.name;\n this.code = code;\n }\n}\n","import { isValidDomain } from './isValidDomain.js';\nimport { WebAuthnError } from './webAuthnError.js';\n/**\n * Attempt to intuit _why_ an error was raised after calling `navigator.credentials.create()`\n */\nexport function identifyRegistrationError({ error, options, }) {\n const { publicKey } = options;\n if (!publicKey) {\n throw Error('options was missing required publicKey property');\n }\n if (error.name === 'AbortError') {\n if (options.signal instanceof AbortSignal) {\n // https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 16)\n return new WebAuthnError({\n message: 'Registration ceremony was sent an abort signal',\n code: 'ERROR_CEREMONY_ABORTED',\n cause: error,\n });\n }\n }\n else if (error.name === 'ConstraintError') {\n if (publicKey.authenticatorSelection?.requireResidentKey === true) {\n // https://www.w3.org/TR/webauthn-2/#sctn-op-make-cred (Step 4)\n return new WebAuthnError({\n message: 'Discoverable credentials were required but no available authenticator supported it',\n code: 'ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT',\n cause: error,\n });\n }\n else if (\n // @ts-ignore: `mediation` doesn't yet exist on CredentialCreationOptions but it's possible as of Sept 2024\n options.mediation === 'conditional' &&\n publicKey.authenticatorSelection?.userVerification === 'required') {\n // https://w3c.github.io/webauthn/#sctn-createCredential (Step 22.4)\n return new WebAuthnError({\n message: 'User verification was required during automatic registration but it could not be performed',\n code: 'ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE',\n cause: error,\n });\n }\n else if (publicKey.authenticatorSelection?.userVerification === 'required') {\n // https://www.w3.org/TR/webauthn-2/#sctn-op-make-cred (Step 5)\n return new WebAuthnError({\n message: 'User verification was required but no available authenticator supported it',\n code: 'ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT',\n cause: error,\n });\n }\n }\n else if (error.name === 'InvalidStateError') {\n // https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 20)\n // https://www.w3.org/TR/webauthn-2/#sctn-op-make-cred (Step 3)\n return new WebAuthnError({\n message: 'The authenticator was previously registered',\n code: 'ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED',\n cause: error,\n });\n }\n else if (error.name === 'NotAllowedError') {\n /**\n * Pass the error directly through. Platforms are overloading this error beyond what the spec\n * defines and we don't want to overwrite potentially useful error messages.\n */\n return new WebAuthnError({\n message: error.message,\n code: 'ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY',\n cause: error,\n });\n }\n else if (error.name === 'NotSupportedError') {\n const validPubKeyCredParams = publicKey.pubKeyCredParams.filter((param) => param.type === 'public-key');\n if (validPubKeyCredParams.length === 0) {\n // https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 10)\n return new WebAuthnError({\n message: 'No entry in pubKeyCredParams was of type \"public-key\"',\n code: 'ERROR_MALFORMED_PUBKEYCREDPARAMS',\n cause: error,\n });\n }\n // https://www.w3.org/TR/webauthn-2/#sctn-op-make-cred (Step 2)\n return new WebAuthnError({\n message: 'No available authenticator supported any of the specified pubKeyCredParams algorithms',\n code: 'ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG',\n cause: error,\n });\n }\n else if (error.name === 'SecurityError') {\n const effectiveDomain = globalThis.location.hostname;\n if (!isValidDomain(effectiveDomain)) {\n // https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 7)\n return new WebAuthnError({\n message: `${globalThis.location.hostname} is an invalid domain`,\n code: 'ERROR_INVALID_DOMAIN',\n cause: error,\n });\n }\n else if (publicKey.rp.id !== effectiveDomain) {\n // https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 8)\n return new WebAuthnError({\n message: `The RP ID \"${publicKey.rp.id}\" is invalid for this domain`,\n code: 'ERROR_INVALID_RP_ID',\n cause: error,\n });\n }\n }\n else if (error.name === 'TypeError') {\n if (publicKey.user.id.byteLength < 1 || publicKey.user.id.byteLength > 64) {\n // https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 5)\n return new WebAuthnError({\n message: 'User ID was not between 1 and 64 characters',\n code: 'ERROR_INVALID_USER_ID_LENGTH',\n cause: error,\n });\n }\n }\n else if (error.name === 'UnknownError') {\n // https://www.w3.org/TR/webauthn-2/#sctn-op-make-cred (Step 1)\n // https://www.w3.org/TR/webauthn-2/#sctn-op-make-cred (Step 8)\n return new WebAuthnError({\n message: 'The authenticator was unable to process the specified options, or could not create a new credential',\n code: 'ERROR_AUTHENTICATOR_GENERAL_ERROR',\n cause: error,\n });\n }\n return error;\n}\n","class BaseWebAuthnAbortService {\n constructor() {\n Object.defineProperty(this, \"controller\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n }\n createNewAbortSignal() {\n // Abort any existing calls to navigator.credentials.create() or navigator.credentials.get()\n if (this.controller) {\n const abortError = new Error('Cancelling existing WebAuthn API call for new one');\n abortError.name = 'AbortError';\n this.controller.abort(abortError);\n }\n const newController = new AbortController();\n this.controller = newController;\n return newController.signal;\n }\n cancelCeremony() {\n if (this.controller) {\n const abortError = new Error('Manually cancelling existing WebAuthn API call');\n abortError.name = 'AbortError';\n this.controller.abort(abortError);\n this.controller = undefined;\n }\n }\n}\n/**\n * A service singleton to help ensure that only a single WebAuthn ceremony is active at a time.\n *\n * Users of **@simplewebauthn/browser** shouldn't typically need to use this, but it can help e.g.\n * developers building projects that use client-side routing to better control the behavior of\n * their UX in response to router navigation events.\n */\nexport const WebAuthnAbortService = new BaseWebAuthnAbortService();\n","const attachments = ['cross-platform', 'platform'];\n/**\n * If possible coerce a `string` value into a known `AuthenticatorAttachment`\n */\nexport function toAuthenticatorAttachment(attachment) {\n if (!attachment) {\n return;\n }\n if (attachments.indexOf(attachment) < 0) {\n return;\n }\n return attachment;\n}\n","import { bufferToBase64URLString } from '../helpers/bufferToBase64URLString.js';\nimport { base64URLStringToBuffer } from '../helpers/base64URLStringToBuffer.js';\nimport { browserSupportsWebAuthn } from '../helpers/browserSupportsWebAuthn.js';\nimport { toPublicKeyCredentialDescriptor } from '../helpers/toPublicKeyCredentialDescriptor.js';\nimport { identifyRegistrationError } from '../helpers/identifyRegistrationError.js';\nimport { WebAuthnAbortService } from '../helpers/webAuthnAbortService.js';\nimport { toAuthenticatorAttachment } from '../helpers/toAuthenticatorAttachment.js';\n/**\n * Begin authenticator \"registration\" via WebAuthn attestation\n *\n * @param optionsJSON Output from **@simplewebauthn/server**'s `generateRegistrationOptions()`\n * @param useAutoRegister (Optional) Try to silently create a passkey with the password manager that the user just signed in with. Defaults to `false`.\n */\nexport async function startRegistration(options) {\n // @ts-ignore: Intentionally check for old call structure to warn about improper API call\n if (!options.optionsJSON && options.challenge) {\n console.warn('startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.');\n // @ts-ignore: Reassign the options, passed in as a positional argument, to the expected variable\n options = { optionsJSON: options };\n }\n const { optionsJSON, useAutoRegister = false } = options;\n if (!browserSupportsWebAuthn()) {\n throw new Error('WebAuthn is not supported in this browser');\n }\n // We need to convert some values to Uint8Arrays before passing the credentials to the navigator\n const publicKey = {\n ...optionsJSON,\n challenge: base64URLStringToBuffer(optionsJSON.challenge),\n user: {\n ...optionsJSON.user,\n id: base64URLStringToBuffer(optionsJSON.user.id),\n },\n excludeCredentials: optionsJSON.excludeCredentials?.map(toPublicKeyCredentialDescriptor),\n };\n // Prepare options for `.create()`\n const createOptions = {};\n /**\n * Try to use conditional create to register a passkey for the user with the password manager\n * the user just used to authenticate with. The user won't be shown any prominent UI by the\n * browser.\n */\n if (useAutoRegister) {\n // @ts-ignore: `mediation` doesn't yet exist on CredentialCreationOptions but it's possible as of Sept 2024\n createOptions.mediation = 'conditional';\n }\n // Finalize options\n createOptions.publicKey = publicKey;\n // Set up the ability to cancel this request if the user attempts another\n createOptions.signal = WebAuthnAbortService.createNewAbortSignal();\n // Wait for the user to complete attestation\n let credential;\n try {\n credential = (await navigator.credentials.create(\n // TODO: Newer versions of Deno require this casting, revisit once we're using Deno 2.6+\n createOptions));\n }\n catch (err) {\n throw identifyRegistrationError({ error: err, options: createOptions });\n }\n if (!credential) {\n throw new Error('Registration was not completed');\n }\n const { id, rawId, response, type } = credential;\n // Continue to play it safe with `getTransports()` for now, even when L3 types say it's required\n let transports = undefined;\n if (typeof response.getTransports === 'function') {\n transports = response.getTransports();\n }\n // L3 says this is required, but browser and webview support are still not guaranteed.\n let responsePublicKeyAlgorithm = undefined;\n if (typeof response.getPublicKeyAlgorithm === 'function') {\n try {\n responsePublicKeyAlgorithm = response.getPublicKeyAlgorithm();\n }\n catch (error) {\n warnOnBrokenImplementation('getPublicKeyAlgorithm()', error);\n }\n }\n let responsePublicKey = undefined;\n if (typeof response.getPublicKey === 'function') {\n try {\n const _publicKey = response.getPublicKey();\n if (_publicKey !== null) {\n responsePublicKey = bufferToBase64URLString(_publicKey);\n }\n }\n catch (error) {\n warnOnBrokenImplementation('getPublicKey()', error);\n }\n }\n // L3 says this is required, but browser and webview support are still not guaranteed.\n let responseAuthenticatorData;\n if (typeof response.getAuthenticatorData === 'function') {\n try {\n responseAuthenticatorData = bufferToBase64URLString(response.getAuthenticatorData());\n }\n catch (error) {\n warnOnBrokenImplementation('getAuthenticatorData()', error);\n }\n }\n return {\n id,\n rawId: bufferToBase64URLString(rawId),\n response: {\n attestationObject: bufferToBase64URLString(response.attestationObject),\n clientDataJSON: bufferToBase64URLString(response.clientDataJSON),\n transports,\n publicKeyAlgorithm: responsePublicKeyAlgorithm,\n publicKey: responsePublicKey,\n authenticatorData: responseAuthenticatorData,\n },\n type,\n clientExtensionResults: credential.getClientExtensionResults(),\n authenticatorAttachment: toAuthenticatorAttachment(credential.authenticatorAttachment),\n };\n}\n/**\n * Visibly warn when we detect an issue related to a passkey provider intercepting WebAuthn API\n * calls\n */\nfunction warnOnBrokenImplementation(methodName, cause) {\n console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${methodName}. You should report this error to them.\\n`, cause);\n}\n","import { browserSupportsWebAuthn } from './browserSupportsWebAuthn.js';\n/**\n * Determine if the browser supports conditional UI, so that WebAuthn credentials can\n * be shown to the user in the browser's typical password autofill popup.\n */\nexport function browserSupportsWebAuthnAutofill() {\n if (!browserSupportsWebAuthn()) {\n return _browserSupportsWebAuthnAutofillInternals.stubThis(new Promise((resolve) => resolve(false)));\n }\n /**\n * I don't like the `as unknown` here but there's a `declare var PublicKeyCredential` in\n * TS' DOM lib that's making it difficult for me to just go `as PublicKeyCredentialFuture` as I\n * want. I think I'm fine with this for now since it's _supposed_ to be temporary, until TS types\n * have a chance to catch up.\n */\n const globalPublicKeyCredential = globalThis\n .PublicKeyCredential;\n if (globalPublicKeyCredential?.isConditionalMediationAvailable === undefined) {\n return _browserSupportsWebAuthnAutofillInternals.stubThis(new Promise((resolve) => resolve(false)));\n }\n return _browserSupportsWebAuthnAutofillInternals.stubThis(globalPublicKeyCredential.isConditionalMediationAvailable());\n}\n// Make it possible to stub the return value during testing\nexport const _browserSupportsWebAuthnAutofillInternals = {\n stubThis: (value) => value,\n};\n","import { isValidDomain } from './isValidDomain.js';\nimport { WebAuthnError } from './webAuthnError.js';\n/**\n * Attempt to intuit _why_ an error was raised after calling `navigator.credentials.get()`\n */\nexport function identifyAuthenticationError({ error, options, }) {\n const { publicKey } = options;\n if (!publicKey) {\n throw Error('options was missing required publicKey property');\n }\n if (error.name === 'AbortError') {\n if (options.signal instanceof AbortSignal) {\n // https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 16)\n return new WebAuthnError({\n message: 'Authentication ceremony was sent an abort signal',\n code: 'ERROR_CEREMONY_ABORTED',\n cause: error,\n });\n }\n }\n else if (error.name === 'NotAllowedError') {\n /**\n * Pass the error directly through. Platforms are overloading this error beyond what the spec\n * defines and we don't want to overwrite potentially useful error messages.\n */\n return new WebAuthnError({\n message: error.message,\n code: 'ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY',\n cause: error,\n });\n }\n else if (error.name === 'SecurityError') {\n const effectiveDomain = globalThis.location.hostname;\n if (!isValidDomain(effectiveDomain)) {\n // https://www.w3.org/TR/webauthn-2/#sctn-discover-from-external-source (Step 5)\n return new WebAuthnError({\n message: `${globalThis.location.hostname} is an invalid domain`,\n code: 'ERROR_INVALID_DOMAIN',\n cause: error,\n });\n }\n else if (publicKey.rpId !== effectiveDomain) {\n // https://www.w3.org/TR/webauthn-2/#sctn-discover-from-external-source (Step 6)\n return new WebAuthnError({\n message: `The RP ID \"${publicKey.rpId}\" is invalid for this domain`,\n code: 'ERROR_INVALID_RP_ID',\n cause: error,\n });\n }\n }\n else if (error.name === 'UnknownError') {\n // https://www.w3.org/TR/webauthn-2/#sctn-op-get-assertion (Step 1)\n // https://www.w3.org/TR/webauthn-2/#sctn-op-get-assertion (Step 12)\n return new WebAuthnError({\n message: 'The authenticator was unable to process the specified options, or could not create a new assertion signature',\n code: 'ERROR_AUTHENTICATOR_GENERAL_ERROR',\n cause: error,\n });\n }\n return error;\n}\n","import { bufferToBase64URLString } from '../helpers/bufferToBase64URLString.js';\nimport { base64URLStringToBuffer } from '../helpers/base64URLStringToBuffer.js';\nimport { browserSupportsWebAuthn } from '../helpers/browserSupportsWebAuthn.js';\nimport { browserSupportsWebAuthnAutofill } from '../helpers/browserSupportsWebAuthnAutofill.js';\nimport { toPublicKeyCredentialDescriptor } from '../helpers/toPublicKeyCredentialDescriptor.js';\nimport { identifyAuthenticationError } from '../helpers/identifyAuthenticationError.js';\nimport { WebAuthnAbortService } from '../helpers/webAuthnAbortService.js';\nimport { toAuthenticatorAttachment } from '../helpers/toAuthenticatorAttachment.js';\n/**\n * Begin authenticator \"login\" via WebAuthn assertion\n *\n * @param optionsJSON Output from **@simplewebauthn/server**'s `generateAuthenticationOptions()`\n * @param useBrowserAutofill (Optional) Initialize conditional UI to enable logging in via browser autofill prompts. Defaults to `false`.\n * @param verifyBrowserAutofillInput (Optional) Ensure a suitable `<input>` element is present when `useBrowserAutofill` is `true`. Defaults to `true`.\n */\nexport async function startAuthentication(options) {\n // @ts-ignore: Intentionally check for old call structure to warn about improper API call\n if (!options.optionsJSON && options.challenge) {\n console.warn('startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.');\n // @ts-ignore: Reassign the options, passed in as a positional argument, to the expected variable\n options = { optionsJSON: options };\n }\n const { optionsJSON, useBrowserAutofill = false, verifyBrowserAutofillInput = true, } = options;\n if (!browserSupportsWebAuthn()) {\n throw new Error('WebAuthn is not supported in this browser');\n }\n // We need to avoid passing empty array to avoid blocking retrieval\n // of public key\n let allowCredentials;\n if (optionsJSON.allowCredentials?.length !== 0) {\n allowCredentials = optionsJSON.allowCredentials?.map(toPublicKeyCredentialDescriptor);\n }\n // We need to convert some values to Uint8Arrays before passing the credentials to the navigator\n const publicKey = {\n ...optionsJSON,\n challenge: base64URLStringToBuffer(optionsJSON.challenge),\n allowCredentials,\n };\n // Prepare options for `.get()`\n const getOptions = {};\n /**\n * Set up the page to prompt the user to select a credential for authentication via the browser's\n * input autofill mechanism.\n */\n if (useBrowserAutofill) {\n if (!(await browserSupportsWebAuthnAutofill())) {\n throw Error('Browser does not support WebAuthn autofill');\n }\n // Check for an <input> with \"webauthn\" in its `autocomplete` attribute\n const eligibleInputs = document.querySelectorAll(\"input[autocomplete$='webauthn']\");\n // WebAuthn autofill requires at least one valid input\n if (eligibleInputs.length < 1 && verifyBrowserAutofillInput) {\n throw Error('No <input> with \"webauthn\" as the only or last value in its `autocomplete` attribute was detected');\n }\n // `CredentialMediationRequirement` doesn't know about \"conditional\" yet as of\n // typescript@4.6.3\n getOptions.mediation = 'conditional';\n // Conditional UI requires an empty allow list\n publicKey.allowCredentials = [];\n }\n // Finalize options\n getOptions.publicKey = publicKey;\n // Set up the ability to cancel this request if the user attempts another\n getOptions.signal = WebAuthnAbortService.createNewAbortSignal();\n // Wait for the user to complete assertion\n let credential;\n try {\n credential = (await navigator.credentials.get(\n // TODO: Newer versions of Deno require this casting, revisit once we're using Deno 2.6+\n getOptions));\n }\n catch (err) {\n throw identifyAuthenticationError({ error: err, options: getOptions });\n }\n if (!credential) {\n throw new Error('Authentication was not completed');\n }\n const { id, rawId, response, type } = credential;\n let userHandle = undefined;\n if (response.userHandle) {\n userHandle = bufferToBase64URLString(response.userHandle);\n }\n // Convert values to base64 to make it easier to send back to the server\n return {\n id,\n rawId: bufferToBase64URLString(rawId),\n response: {\n authenticatorData: bufferToBase64URLString(response.authenticatorData),\n clientDataJSON: bufferToBase64URLString(response.clientDataJSON),\n signature: bufferToBase64URLString(response.signature),\n userHandle,\n },\n type,\n clientExtensionResults: credential.getClientExtensionResults(),\n authenticatorAttachment: toAuthenticatorAttachment(credential.authenticatorAttachment),\n };\n}\n","import { WebAuthnAbortService } from \"@simplewebauthn/browser\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\n/** A dismissed or aborted passkey prompt. */\nexport function isCanceledCeremony(err: unknown): boolean {\n return err instanceof Error && (err.name === \"NotAllowedError\" || err.name === \"AbortError\");\n}\n\n/**\n * Runs a WebAuthn ceremony the user can cancel at once. Some authenticator UIs never reject when\n * their popup closes, so Cancel does not wait for the browser: it resets and ignores the late result.\n */\nexport function usePasskeyCeremony() {\n const [waiting, setWaiting] = useState(false);\n const token = useRef(0);\n const waitingRef = useRef(false);\n\n const set = useCallback((v: boolean) => {\n waitingRef.current = v;\n setWaiting(v);\n }, []);\n\n const cancel = useCallback(() => {\n token.current++;\n WebAuthnAbortService.cancelCeremony();\n waitingRef.current = false;\n setWaiting(false);\n }, []);\n\n const run = useCallback(\n async <T>(\n fn: () => Promise<T>,\n ): Promise<{ ok: true; value: T } | { ok: false; canceled: true }> => {\n const mine = ++token.current;\n set(true);\n try {\n const value = await fn();\n if (token.current !== mine) return { ok: false, canceled: true };\n set(false);\n return { ok: true, value };\n } catch (err) {\n if (token.current !== mine) return { ok: false, canceled: true };\n set(false);\n if (isCanceledCeremony(err)) return { ok: false, canceled: true };\n throw err;\n }\n },\n [set],\n );\n\n useEffect(\n () => () => {\n if (waitingRef.current) {\n token.current++;\n WebAuthnAbortService.cancelCeremony();\n }\n },\n [],\n );\n\n return { waiting, run, cancel };\n}\n","import type { OidcClaimResponse } from \"@switchyard/protocol\";\n\n/** How often the PWA polls `POST /api/auth/oidc/claim` while the screen is visible. */\nexport const HANDOFF_POLL_MS = 2000;\n/** How long a handoff waits before giving up (the coordinator flow lives 10 minutes). */\nexport const HANDOFF_TIMEOUT_MS = 10 * 60 * 1000;\n\nexport type HandoffPhase = \"waiting\" | \"done\" | \"timeout\" | \"failed\" | \"canceled\";\n\nexport interface HandoffState {\n phase: HandoffPhase;\n startedAt: number;\n /** Set when `phase` is `failed`. */\n message: string | null;\n}\n\nexport type HandoffEvent =\n | { type: \"claim\"; result: OidcClaimResponse; now: number }\n | { type: \"claim_error\"; code: string; message: string; now: number }\n | { type: \"tick\"; now: number }\n | { type: \"cancel\" };\n\nexport function startHandoff(now: number): HandoffState {\n return { phase: \"waiting\", startedAt: now, message: null };\n}\n\n/**\n * Pure state machine for the PWA single sign-on handoff. Terminal phases\n * never change. A transient error (network, server hiccup) keeps waiting;\n * an expired or unknown flow (`unauthorized`, `invalid_request`) fails.\n */\nexport function handoffReduce(state: HandoffState, event: HandoffEvent): HandoffState {\n if (state.phase !== \"waiting\") return state;\n if (event.type === \"cancel\") return { ...state, phase: \"canceled\" };\n if (event.now - state.startedAt >= HANDOFF_TIMEOUT_MS && event.type !== \"claim\") {\n return { ...state, phase: \"timeout\" };\n }\n switch (event.type) {\n case \"tick\":\n return state;\n case \"claim\":\n if (event.result.status === \"done\") return { ...state, phase: \"done\" };\n return event.now - state.startedAt >= HANDOFF_TIMEOUT_MS\n ? { ...state, phase: \"timeout\" }\n : state;\n case \"claim_error\":\n if (event.code === \"unauthorized\" || event.code === \"invalid_request\") {\n return { ...state, phase: \"failed\", message: event.message };\n }\n return state;\n }\n}\n\n/** Whether a poll should run now: still waiting and the page is visible. */\nexport function shouldPoll(state: HandoffState, visible: boolean): boolean {\n return state.phase === \"waiting\" && visible;\n}\n\nconst GENERIC_FORBIDDEN = \"This account is not allowed to sign in to this server.\";\n\n/** Static texts for coordinator error codes shown on /sign-in. */\nexport const ERROR_TEXT: Record<string, string> = {\n enrollment_expired:\n \"This sign-in link has expired. Links are valid for 10 minutes. Run `switchyard pair` on the server for a new one.\",\n enrollment_used:\n \"This sign-in link was already used. Each link signs in one browser. Run `switchyard pair` on the server for a new one.\",\n invalid_request: \"The sign-in request was rejected. Try again.\",\n network: \"Could not reach the coordinator. Check your connection and try again.\",\n rate_limited: \"Too many attempts. Wait a minute and try again.\",\n unsupported_capability: \"This sign-in method is not available on this server.\",\n unauthorized: \"That sign-in was not accepted. Try again, or use another sign-in method.\",\n};\n\n/**\n * Message for an error code, with the coordinator's `detail` where it is the\n * useful part (`/sign-in?error=forbidden&detail=Signed in as ...`).\n */\nexport function enrollErrorText(code: string, detail?: string | null): string {\n const d = detail?.trim() || null;\n switch (code) {\n case \"forbidden\":\n return d ?? GENERIC_FORBIDDEN;\n case \"oidc_failed\":\n return `Single sign-on failed: ${d ?? \"the identity provider returned an error.\"}`;\n case \"unsupported_capability\":\n return d ?? (ERROR_TEXT.unsupported_capability as string);\n default:\n return ERROR_TEXT[code] ?? d ?? `Sign-in failed (${code}).`;\n }\n}\n\n/** Short heading for an error alert. */\nexport function enrollErrorTitle(code: string): string {\n switch (code) {\n case \"enrollment_expired\":\n return \"Sign-in link expired\";\n case \"enrollment_used\":\n return \"Sign-in link already used\";\n case \"forbidden\":\n return \"Not allowed\";\n case \"oidc_failed\":\n return \"Single sign-on failed\";\n case \"rate_limited\":\n return \"Too many attempts\";\n default:\n return \"Sign-in failed\";\n }\n}\n\n/** A readable default device name from the user agent, e.g. \"Safari on iPhone\". */\nexport function defaultDeviceName(ua: string = navigator.userAgent): string {\n const device = /iPhone/.test(ua)\n ? \"iPhone\"\n : /iPad/.test(ua) || (/Macintosh/.test(ua) && navigator.maxTouchPoints > 1)\n ? \"iPad\"\n : /Android/.test(ua)\n ? \"Android\"\n : /Macintosh|Mac OS X/.test(ua)\n ? \"Mac\"\n : /Windows/.test(ua)\n ? \"Windows\"\n : /Linux/.test(ua)\n ? \"Linux\"\n : \"device\";\n const browser = /Edg\\//.test(ua)\n ? \"Edge\"\n : /Firefox\\/|FxiOS/.test(ua)\n ?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CACtC,CAEA,IAAMC,EAAoB,yDAGbC,EAAqC,CAChD,mBACE,oHACF,gBACE,yHACF,gBAAiB,+CACjB,QAAS,wEACT,aAAc,kDACd,uBAAwB,uDACxB,aAAc,0EAChB,EAMA,SAAgBC,EAAgB,EAAc,EAAgC,CAC5E,IAAMC,EAAIC,GAAQ,KAAK,GAAK,KAC5B,OAAQhE,EAAR,CACE,IAAK,YACH,OAAO+D,GAAKH,EACd,IAAK,cACH,MAAO,0BAA0BG,GAAK,6CACxC,IAAK,yBACH,OAAOA,GAAMF,EAAW,uBAC1B,QACE,OAAOA,EAAW7D,IAAS+D,GAAK,mBAAmB/D,EAAK,GAC5D,CACF,CAGA,SAAgBiE,EAAiB,EAAsB,CACrD,OAAQjE,EAAR,CACE,IAAK,qBACH,MAAO,uBACT,IAAK,kBACH,MAAO,4BACT,IAAK,YACH,MAAO,cACT,IAAK,cACH,MAAO,wBACT,IAAK,eACH,MAAO,oBACT,QACE,MAAO,gBACX,CACF,CAGA,SAAgBkE,EAAkB,EAAa,UAAU,UAAmB,CAC1E,IAAMC,EAAS,SAAS,KAAKC,CAAE,EAC3B,SACA,OAAO,KAAKA,CAAE,GAAM,YAAY,KAAKA,CAAE,GAAK,UAAU,eAAiB,EACrE,OACA,UAAU,KAAKA,CAAE,EACf,UACA,qBAAqB,KAAKA,CAAE,EAC1B,MACA,UAAU,KAAKA,CAAE,EACf,UACA,QAAQ,KAAKA,CAAE,EACb,QACA,SAUd,MAAO,GATS,QAAQ,KAAKA,CAAE,EAC3B,OACA,kBAAkB,KAAKA,CAAE,EACvB,UACA,iBAAiB,KAAKA,CAAE,EACtB,SACA,WAAW,KAAKA,CAAE,EAChB,SACA,UACQ,MAAMD,GAC1B,C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{A as e,
|
|
2
|
-
//# sourceMappingURL=more-
|
|
1
|
+
import{A as e,_n as t,d as n,in as r,m as i,mn as a}from"./states-CM1Zt9qO.js";import{b as o,i as s}from"./Overlay-wZFuaSA5.js";import{t as c}from"./chevron-right-B-aa_CvO.js";import{t as l}from"./pencil-DvO-Zlyh.js";import{t as u}from"./useBreakpoint-CdYPa6z0.js";import{H as d,m as f}from"./index-CbdB9RE5.js";import{t as p}from"./NavigationEditor-BfNZ411c.js";var m=t(a(),1),h=i();function g(){let{more:t}=f(),i=e(),[a,g]=(0,m.useState)(!1),_=u()===`mobile`;return(0,h.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col gap-3 px-4 pb-4 safe-pt-4`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`h1`,{className:`flex-1 text-lg font-semibold`,children:`More`}),(0,h.jsx)(n,{size:`sm`,variant:`ghost`,icon:(0,h.jsx)(l,{className:`size-4`}),onClick:()=>g(!0),children:`Edit`})]}),(0,h.jsx)(`ul`,{"aria-label":`More navigation`,tabIndex:-1,"data-keyboard-scope":!0,"data-keyboard-default":!0,className:`overflow-hidden rounded-lg border border-border bg-surface focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent`,children:t.map(({id:e,to:t,label:n,description:a,icon:s,badge:l})=>(0,h.jsx)(`li`,{className:`border-b border-border last:border-b-0`,children:(0,h.jsxs)(r,{to:t,"data-keyboard-item":!0,className:`tap flex min-h-14 items-center gap-3 px-4 py-2 hover:bg-surface-2 active:bg-surface-2`,children:[(0,h.jsx)(s,{"aria-hidden":!0,className:`size-5 shrink-0 text-muted`}),(0,h.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`span`,{className:`block font-medium`,children:n}),(0,h.jsx)(`span`,{className:`block truncate text-sm text-muted`,children:a})]}),l===`attention`&&(0,h.jsx)(o,{count:i,label:`need attention`}),(0,h.jsx)(c,{"aria-hidden":!0,className:`size-4 shrink-0 text-subtle`})]})},e))}),!_&&(0,h.jsx)(n,{variant:`secondary`,onClick:()=>d.getState().setHelpOpen(!0),children:`Keyboard shortcuts`}),(0,h.jsx)(s,{open:a,onClose:()=>g(!1),title:`Edit navigation`,description:`Choose the bottom bar and the order of every page.`,footer:(0,h.jsx)(n,{variant:`primary`,onClick:()=>g(!1),children:`Done`}),children:(0,h.jsx)(p,{})})]})}export{g as default};
|
|
2
|
+
//# sourceMappingURL=more-RENHRep9.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"more-
|
|
1
|
+
{"version":3,"file":"more-RENHRep9.js","names":["useState","useAttentionCount","__toESM","Button","Link","require_jsx_runtime","require_react","CountBadge","Sheet","ChevronRight","Pencil","useBreakpoint","usePalette","useNavLayout","NavigationEditor","import_react","import_jsx_runtime","MoreView","count","editing","setEditing","phone","more","Icon","label","description","badge","id"],"sources":["../../src/features/more/index.tsx"],"sourcesContent":["import { ChevronRight, Pencil } from \"lucide-react\";\nimport { useState } from \"react\";\nimport { Link } from \"react-router\";\nimport { NavigationEditor } from \"../../app/NavigationEditor\";\nimport { useNavLayout } from \"../../app/navigation\";\nimport { useBreakpoint } from \"../../app/useBreakpoint\";\nimport { CountBadge } from \"../../components/ui/Badge\";\nimport { Button } from \"../../components/ui/Button\";\nimport { Sheet } from \"../../components/ui/Overlay\";\nimport { useAttentionCount } from \"../../sync/store\";\nimport { usePalette } from \"../palette/registry\";\n\n/** Mobile \"More\": the destinations that are not in the bottom bar, and Edit to choose them. */\nexport default function MoreView() {\n const { more } = useNavLayout();\n const count = useAttentionCount();\n const [editing, setEditing] = useState(false);\n // Keyboard shortcuts only matter with a keyboard: not on a phone.\n const phone = useBreakpoint() === \"mobile\";\n return (\n <div className=\"mx-auto flex w-full max-w-xl flex-col gap-3 px-4 pb-4 safe-pt-4\">\n <div className=\"flex items-center gap-2\">\n <h1 className=\"flex-1 text-lg font-semibold\">More</h1>\n <Button\n size=\"sm\"\n variant=\"ghost\"\n icon={<Pencil className=\"size-4\" />}\n onClick={() => setEditing(true)}\n >\n Edit\n </Button>\n </div>\n <ul\n aria-label=\"More navigation\"\n tabIndex={-1}\n data-keyboard-scope\n data-keyboard-default\n className=\"overflow-hidden rounded-lg border border-border bg-surface focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent\"\n >\n {more.map(({ id, to, label, description, icon: Icon, badge }) => (\n <li key={id} className=\"border-b border-border last:border-b-0\">\n <Link\n to={to}\n data-keyboard-item\n className=\"tap flex min-h-14 items-center gap-3 px-4 py-2 hover:bg-surface-2 active:bg-surface-2\"\n >\n <Icon aria-hidden className=\"size-5 shrink-0 text-muted\" />\n <span className=\"min-w-0 flex-1\">\n <span className=\"block font-medium\">{label}</span>\n <span className=\"block truncate text-sm text-muted\">{description}</span>\n </span>\n {badge === \"attention\" && <CountBadge count={count} label=\"need attention\" />}\n <ChevronRight aria-hidden className=\"size-4 shrink-0 text-subtle\" />\n </Link>\n </li>\n ))}\n </ul>\n {!phone && (\n <Button variant=\"secondary\" onClick={() => usePalette.getState().setHelpOpen(true)}>\n Keyboard shortcuts\n </Button>\n )}\n <Sheet\n open={editing}\n onClose={() => setEditing(false)}\n title=\"Edit navigation\"\n description=\"Choose the bottom bar and the order of every page.\"\n footer={\n <Button variant=\"primary\" onClick={() => setEditing(false)}>\n Done\n </Button>\n }\n >\n <NavigationEditor />\n </Sheet>\n </div>\n );\n}\n"],"mappings":"A,gYAaA,SAAwBiB,GAAW,CACjC,GAAM,CAAE,QAASJ,EAAa,EACxBK,EAAQjB,EAAkB,EAC1B,CAACkB,EAASC,IAAA,EAAcpB,EAAAA,SAAAA,CAAS,EAAK,EAEtCqB,EAAQV,EAAc,IAAM,SAClC,OACE,EAAAK,EAAA,KAAA,CAAC,MAAD,CAAK,UAAU,kEAAf,SAAA,EACE,EAAAA,EAAA,KAAA,CAAC,MAAD,CAAK,UAAU,0BAAf,SAAA,EACE,EAAAA,EAAA,IAAA,CAAC,KAAD,CAAI,UAAU,+BAA+B,SAAA,MAAQ,CAAA,GACrD,EAAAA,EAAA,IAAA,CAACb,EAAD,CACE,KAAK,KACL,QAAQ,QACR,MAAM,EAAAa,EAAA,IAAA,CAACN,EAAD,CA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,CAAA,EAGV,UAAA,EAAAJ,EAAA,IAAA,CAACF,EAAD,CAAmB,CAAA,CACd,CAAA,CACJ,C,EAET,C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{D as e}from"./states-
|
|
2
|
-
//# sourceMappingURL=pencil-
|
|
1
|
+
import{D as e}from"./states-CM1Zt9qO.js";var t={name:`pencil`,size:24,node:[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]};t.node;var n=e(t);export{n as t};
|
|
2
|
+
//# sourceMappingURL=pencil-DvO-Zlyh.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pencil-
|
|
1
|
+
{"version":3,"file":"pencil-DvO-Zlyh.js","names":["createLucideIcon","__iconData","Pencil"],"sources":["../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/pencil.mjs"],"sourcesContent":["/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"pencil\",\n size: 24,\n node: [\n [\n \"path\",\n {\n d: \"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z\",\n key: \"1a8usu\"\n }\n ],\n [\"path\", { d: \"m15 5 4 4\", key: \"1mk7zo\" }]\n ]\n};\n__iconData.node;\nconst Pencil = createLucideIcon(__iconData);\n\nexport { __iconData, Pencil as default };\n//# sourceMappingURL=pencil.mjs.map\n"],"ignoreList":[0],"mappings":"A,yCASA,IAAMC,EAAa,CACjB,KAAM,SACN,KAAM,GACN,KAAM,CACJ,CACE,OACA,CACE,EAAG,mIACH,IAAK,QACP,CACF,EACA,CAAC,OAAQ,CAAE,EAAG,YAAa,IAAK,QAAS,CAAC,CAC5C,CACF,EACAA,EAAW,KACX,IAAMC,EAASF,EAAiBC,CAAU,E"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{D as e}from"./states-
|
|
2
|
-
//# sourceMappingURL=play-
|
|
1
|
+
import{D as e}from"./states-CM1Zt9qO.js";var t={name:`play`,size:24,node:[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]};t.node;var n=e(t);export{n as t};
|
|
2
|
+
//# sourceMappingURL=play-CPNEXvVs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"play-
|
|
1
|
+
{"version":3,"file":"play-CPNEXvVs.js","names":["createLucideIcon","__iconData","Play"],"sources":["../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/play.mjs"],"sourcesContent":["/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"play\",\n size: 24,\n node: [\n [\n \"path\",\n {\n d: \"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z\",\n key: \"10ikf1\"\n }\n ]\n ]\n};\n__iconData.node;\nconst Play = createLucideIcon(__iconData);\n\nexport { __iconData, Play as default };\n//# sourceMappingURL=play.mjs.map\n"],"ignoreList":[0],"mappings":"A,yCASA,IAAMC,EAAa,CACjB,KAAM,OACN,KAAM,GACN,KAAM,CACJ,CACE,OACA,CACE,EAAG,qFACH,IAAK,QACP,CACF,CACF,CACF,EACAA,EAAW,KACX,IAAMC,EAAOF,EAAiBC,CAAU,E"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{D as e}from"./states-
|
|
2
|
-
//# sourceMappingURL=plus-
|
|
1
|
+
import{D as e}from"./states-CM1Zt9qO.js";var t={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};t.node;var n=e(t);export{n as t};
|
|
2
|
+
//# sourceMappingURL=plus-DC4JQpXX.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plus-
|
|
1
|
+
{"version":3,"file":"plus-DC4JQpXX.js","names":["createLucideIcon","__iconData","Plus"],"sources":["../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/plus.mjs"],"sourcesContent":["/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"plus\",\n size: 24,\n node: [\n [\"path\", { d: \"M5 12h14\", key: \"1ays0h\" }],\n [\"path\", { d: \"M12 5v14\", key: \"s699le\" }]\n ]\n};\n__iconData.node;\nconst Plus = createLucideIcon(__iconData);\n\nexport { __iconData, Plus as default };\n//# sourceMappingURL=plus.mjs.map\n"],"ignoreList":[0],"mappings":"A,yCASA,IAAMC,EAAa,CACjB,KAAM,OACN,KAAM,GACN,KAAM,CACJ,CAAC,OAAQ,CAAE,EAAG,WAAY,IAAK,QAAS,CAAC,EACzC,CAAC,OAAQ,CAAE,EAAG,WAAY,IAAK,QAAS,CAAC,CAC3C,CACF,EACAA,EAAW,KACX,IAAMC,EAAOF,EAAiBC,CAAU,E"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=policyLogic-
|
|
1
|
+
import{At as e,D as t,Dt as n,Ot as r,jt as i}from"./states-CM1Zt9qO.js";var a={name:`trash`,size:24,node:[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],aliases:[`trash-2`]};a.node;var o=t(a),s=`${r} At 80% of a continuation budget, approval is required, including for cheap models. At 100%, the next continuation is stopped for expensive or unclassified models; explicitly cheap models have no hard budget stop. Missing or stale usage blocks continuation when a limit is configured. There is no mid-turn spending guarantee.`;function c(e){let t=e.bridge;if(t?.policyState===`active`){let e=t.policyPhases.map(e=>e===`tool_call`?`Tool call`:`API request`);return e.length?`Active: ${e.join(`, `)}`:`Not enforced: no active policy phases`}return t?.policyState===`initializing`?`Not enforced: protection initializing`:t?.policyState===`lost`?`Not enforced: protection connection lost`:`Not enforced: reload or restart this session to enable protection`}function l(e){return n.safeParse(e)}function u(e){return i.safeParse(e)}function d(t){return e.safeParse(t)}function f(e){return e===`ALLOW`?`Allow`:e===`ASK`?`Ask`:e===`DENY`?`Deny`:`No match`}export{d as a,u as i,c as n,f as o,l as r,o as s,s as t};
|
|
2
|
+
//# sourceMappingURL=policyLogic-CXFbVtEs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policyLogic-
|
|
1
|
+
{"version":3,"file":"policyLogic-CXFbVtEs.js","names":["PolicyTestRequest","createLucideIcon","CreatePolicyRuleRequest","POLICY_CAPABILITY_EXPLANATION","UpdatePolicySettingsRequest","__iconData","Trash","CONTINUATION_BUDGET_HELP","protectionLabel","bridge","session","phases","p","validateRule","input","validateSettings","validateTest","verdictLabel","verdict"],"sources":["../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/trash.mjs","../../src/features/settings/policyLogic.ts"],"sourcesContent":["/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"trash\",\n size: 24,\n node: [\n [\"path\", { d: \"M10 11v6\", key: \"nco0om\" }],\n [\"path\", { d: \"M14 11v6\", key: \"outv1u\" }],\n [\"path\", { d: \"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6\", key: \"miytrc\" }],\n [\"path\", { d: \"M3 6h18\", key: \"d0wm0j\" }],\n [\"path\", { d: \"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2\", key: \"e791ji\" }]\n ],\n aliases: [\"trash-2\"]\n};\n__iconData.node;\nconst Trash = createLucideIcon(__iconData);\n\nexport { __iconData, Trash as default };\n//# sourceMappingURL=trash.mjs.map\n","import {\n CreatePolicyRuleRequest,\n POLICY_CAPABILITY_EXPLANATION,\n PolicyTestRequest,\n type Session,\n UpdatePolicySettingsRequest,\n} from \"@switchyard/protocol\";\n\nexport const CONTINUATION_BUDGET_HELP = `${POLICY_CAPABILITY_EXPLANATION} At 80% of a continuation budget, approval is required, including for cheap models. At 100%, the next continuation is stopped for expensive or unclassified models; explicitly cheap models have no hard budget stop. Missing or stale usage blocks continuation when a limit is configured. There is no mid-turn spending guarantee.`;\n\nexport function protectionLabel(session: Pick<Session, \"bridge\">): string {\n const bridge = session.bridge;\n if (bridge?.policyState === \"active\") {\n const phases = bridge.policyPhases.map((p) =>\n p === \"tool_call\" ? \"Tool call\" : \"API request\",\n );\n return phases.length ? `Active: ${phases.join(\", \")}` : \"Not enforced: no active policy phases\";\n }\n if (bridge?.policyState === \"initializing\") return \"Not enforced: protection initializing\";\n if (bridge?.policyState === \"lost\") return \"Not enforced: protection connection lost\";\n return \"Not enforced: reload or restart this session to enable protection\";\n}\n\nexport function validateRule(input: unknown) {\n return CreatePolicyRuleRequest.safeParse(input);\n}\nexport function validateSettings(input: unknown) {\n return UpdatePolicySettingsRequest.safeParse(input);\n}\nexport function validateTest(input: unknown) {\n return PolicyTestRequest.safeParse(input);\n}\nexport function verdictLabel(verdict: \"ALLOW\" | \"ASK\" | \"DENY\" | null): string {\n return verdict === \"ALLOW\"\n ? \"Allow\"\n : verdict === \"ASK\"\n ? \"Ask\"\n : verdict === \"DENY\"\n ? \"Deny\"\n : \"No match\";\n}\n"],"ignoreList":[0],"mappings":"A,yEASA,IAAMK,EAAa,CACjB,KAAM,QACN,KAAM,GACN,KAAM,CACJ,CAAC,OAAQ,CAAE,EAAG,WAAY,IAAK,QAAS,CAAC,EACzC,CAAC,OAAQ,CAAE,EAAG,WAAY,IAAK,QAAS,CAAC,EACzC,CAAC,OAAQ,CAAE,EAAG,2CAA4C,IAAK,QAAS,CAAC,EACzE,CAAC,OAAQ,CAAE,EAAG,UAAW,IAAK,QAAS,CAAC,EACxC,CAAC,OAAQ,CAAE,EAAG,yCAA0C,IAAK,QAAS,CAAC,CACzE,EACA,QAAS,CAAC,SAAS,CACrB,EACAA,EAAW,KACX,IAAMC,EAAQL,EAAiBI,CAAU,ECd5BE,EAA2B,GAAGJ,EAA8B,uUAEzE,SAAgBK,EAAgB,EAA0C,CACxE,IAAMC,EAASC,EAAQ,OACvB,GAAID,GAAQ,cAAgB,SAAU,CACpC,IAAME,EAASF,EAAO,aAAa,IAAK,GACtCG,IAAM,YAAc,YAAc,aACpC,EACA,OAAOD,EAAO,OAAS,WAAWA,EAAO,KAAK,IAAI,IAAM,uCAC1D,CAGA,OAFIF,GAAQ,cAAgB,eAAuB,wCAC/CA,GAAQ,cAAgB,OAAe,2CACpC,mEACT,CAEA,SAAgBI,EAAa,EAAgB,CAC3C,OAAOX,EAAwB,UAAUY,CAAK,CAChD,CACA,SAAgBC,EAAiB,EAAgB,CAC/C,OAAOX,EAA4B,UAAUU,CAAK,CACpD,CACA,SAAgBE,EAAa,EAAgB,CAC3C,OAAOhB,EAAkB,UAAUc,CAAK,CAC1C,CACA,SAAgBG,EAAa,EAAkD,CAC7E,OAAOC,IAAY,QACf,QACAA,IAAY,MACV,MACAA,IAAY,OACV,OACA,UACV,C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{D as e,
|
|
2
|
-
//# sourceMappingURL=prefs-
|
|
1
|
+
import{D as e,nn as t}from"./states-CM1Zt9qO.js";var n={name:`ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]],aliases:[`more-horizontal`]};n.node;var r=e(n),i={name:`square-kanban`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 7v7`,key:`1x2jlm`}],[`path`,{d:`M12 7v4`,key:`xawao1`}],[`path`,{d:`M16 7v9`,key:`1hp2iy`}]],aliases:[`kanban-square`]};i.node;var a=e(i);function o(e,t){let n;try{n=e()}catch{return}return{getItem:e=>{let r=e=>e===null?null:JSON.parse(e,t?.reviver),i=n.getItem(e)??null;return i instanceof Promise?i.then(r):r(i)},setItem:(e,r)=>n.setItem(e,JSON.stringify(r,t?.replacer)),removeItem:e=>n.removeItem(e)}}var s=e=>t=>{try{let n=e(t);return n instanceof Promise?n:{then(e){return s(e)(n)},catch(e){return this}}}catch(e){return{then(e){return this},catch(t){return s(t)(e)}}}},c=(e,t)=>(n,r,i)=>{let a={storage:o(()=>window.localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},c=!1,l=0,u=new Set,d=new Set,f=a.storage;if(!f)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),n(...e)},r,i);let p=()=>{let e=a.partialize({...r()});return f.setItem(a.name,{state:e,version:a.version})},m=i.setState;i.setState=(...e)=>(m(...e),p());let h=e((...e)=>(n(...e),p()),r,i);i.getInitialState=()=>h;let g,_=()=>{if(!f)return;let e=++l;c=!1,u.forEach(e=>e(r()??h));let t=a.onRehydrateStorage?.call(a,r()??h)||void 0;return s(f.getItem.bind(f))(a.name).then(e=>{if(e){if(typeof e.version==`number`&&e.version!==a.version){if(a.migrate){let t=a.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error(`State loaded from storage couldn't be migrated since no migrate function was provided`)}else return[!1,e.state]}return[!1,void 0]}).then(t=>{if(e!==l)return;let[i,o]=t;if(g=a.merge(o,r()??h),n(g,!0),i)return p()}).then(()=>{e===l&&(t?.(r(),void 0),g=r(),c=!0,d.forEach(e=>e(g)))}).catch(n=>{e===l&&t?.(void 0,n)})};return i.persist={setOptions:e=>{a={...a,...e},e.storage&&(f=e.storage)},clearStorage:()=>{++l,f?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>_(),hasHydrated:()=>c,onHydrate:e=>(u.add(e),()=>{u.delete(e)}),onFinishHydration:e=>(d.add(e),()=>{d.delete(e)})},a.skipHydration||_(),g||h},l={navigator:{min:220,max:360,default:264},inspector:{min:320,max:600,default:380},boardColumn:{min:288,max:360,default:320}};function u(e,t){let n=l[e];return Math.round(Math.min(n.max,Math.max(n.min,t)))}function d(){return typeof window>`u`||!window.matchMedia||window.matchMedia(`(min-width: 768px) and (pointer: fine)`).matches}function f(e,t){if(t>=2||typeof e!=`object`||!e)return e;let{collapseWork:n,...r}=e;return{...r,transcriptDetail:n===!1?`detailed`:`normal`}}var p=t()(c(e=>({selectedProjectId:null,lastSessionId:null,lastNewSessionProjectId:null,paneSizes:{navigator:l.navigator.default,inspector:l.inspector.default,boardColumn:l.boardColumn.default},inspectorCollapsed:!1,railExpanded:!1,sendWithEnter:d(),transcriptDetail:`normal`,followUpMode:`queue`,vimNavigation:!0,navOrder:[`code`,`board`,`attention`,`tasks`,`queue`,`automations`,`settings`],navBar:3,filters:{},set:(t,n)=>e({[t]:n}),setPaneSize:(t,n)=>e(e=>({paneSizes:{...e.paneSizes,[t]:u(t,n)}})),setFilter:(t,n)=>e(e=>({filters:{...e.filters,[t]:n}}))}),{name:`sy:prefs`,version:2,migrate:(e,t)=>f(e,t),storage:o(()=>localStorage),partialize:({set:e,setPaneSize:t,setFilter:n,...r})=>r}));function m(e,t){let n=p(t=>t.filters[e]),r=p(e=>e.setFilter);return[n??t,t=>r(e,t)]}export{r as a,a as i,m as n,p as r,l as t};
|
|
2
|
+
//# sourceMappingURL=prefs-BTwRvULi.js.map
|