@spencerboucher/switchyard 0.21.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/policies/worker.js +1335 -1235
- package/dist/switchyard.mjs +2517 -1820
- 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-Bh46F55q.js +2 -0
- package/web-dist/assets/{Checkbox-BnRsg6ki.js.map → Checkbox-Bh46F55q.js.map} +1 -1
- package/web-dist/assets/DangerZone-K_oXMpbq.js +2 -0
- package/web-dist/assets/{DangerZone-BicyqXv8.js.map → DangerZone-K_oXMpbq.js.map} +1 -1
- package/web-dist/assets/Field-DRcZixOF.js +2 -0
- package/web-dist/assets/{Field-DBm2uYcg.js.map → Field-DRcZixOF.js.map} +1 -1
- package/web-dist/assets/{Markdown-BijzTpiJ.js → Markdown-BaCvc-cI.js} +7 -7
- package/web-dist/assets/{Markdown-BijzTpiJ.js.map → Markdown-BaCvc-cI.js.map} +1 -1
- package/web-dist/assets/NavigationEditor-BfNZ411c.js +2 -0
- package/web-dist/assets/NavigationEditor-BfNZ411c.js.map +1 -0
- package/web-dist/assets/Overlay-wZFuaSA5.js +2 -0
- package/web-dist/assets/Overlay-wZFuaSA5.js.map +1 -0
- package/web-dist/assets/Priority-Ce4btFLm.js +2 -0
- package/web-dist/assets/{Priority-DAhFDJ7E.js.map → Priority-Ce4btFLm.js.map} +1 -1
- package/web-dist/assets/RadioCards-DR-fWNLB.js +2 -0
- package/web-dist/assets/RadioCards-DR-fWNLB.js.map +1 -0
- 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-CvbSg3M1.js +2 -0
- package/web-dist/assets/{Select-CDRJ35wi.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-B89oAK_3.js +2 -0
- package/web-dist/assets/{Switch-D5pVfZgf.js.map → Switch-B89oAK_3.js.map} +1 -1
- package/web-dist/assets/Tabs-CzGFkSHO.js +2 -0
- package/web-dist/assets/Tabs-CzGFkSHO.js.map +1 -0
- package/web-dist/assets/TextLink-irMcg7Xz.js +2 -0
- package/web-dist/assets/{TextLink-BGtYWCW9.js.map → TextLink-irMcg7Xz.js.map} +1 -1
- package/web-dist/assets/UINodeRenderer-_99GFFDS.js +4 -0
- package/web-dist/assets/UINodeRenderer-_99GFFDS.js.map +1 -0
- package/web-dist/assets/UnfilteredNote-iQIfVXkA.js +2 -0
- package/web-dist/assets/{UnfilteredNote-ddFROo9x.js.map → UnfilteredNote-iQIfVXkA.js.map} +1 -1
- package/web-dist/assets/api-CzS9UH7Q.js +2 -0
- package/web-dist/assets/api-CzS9UH7Q.js.map +1 -0
- package/web-dist/assets/{arrow-down-Dn3KG_JI.js → arrow-down-BKhm3D2d.js} +2 -2
- package/web-dist/assets/{arrow-down-Dn3KG_JI.js.map → arrow-down-BKhm3D2d.js.map} +1 -1
- package/web-dist/assets/{arrow-up-BiPtOqqy.js → arrow-up-poMxdOwI.js} +2 -2
- package/web-dist/assets/{arrow-up-BiPtOqqy.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-DWz_Lxch.js +2 -0
- package/web-dist/assets/{automations-ClK2gYj8.js.map → automations-DWz_Lxch.js.map} +1 -1
- package/web-dist/assets/board-BqGDwbGB.js +6 -0
- package/web-dist/assets/board-BqGDwbGB.js.map +1 -0
- package/web-dist/assets/{calendar-clock-DVlat602.js → calendar-clock-U5kMaB5u.js} +2 -2
- package/web-dist/assets/{calendar-clock-DVlat602.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-BM1IJI2z.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-B2OVQjr5.js → core.esm-CHa4oRMo.js} +2 -2
- package/web-dist/assets/{core.esm-B2OVQjr5.js.map → core.esm-CHa4oRMo.js.map} +1 -1
- package/web-dist/assets/describe-C5NtR2LE.js +5 -0
- package/web-dist/assets/{describe-DBhLxCUs.js.map → describe-C5NtR2LE.js.map} +1 -1
- package/web-dist/assets/enroll-DlZYKudD.js +2 -0
- package/web-dist/assets/{enroll-JhMxQuxw.js.map → enroll-DlZYKudD.js.map} +1 -1
- package/web-dist/assets/git-branch-CltFrgh4.js +2 -0
- package/web-dist/assets/git-branch-CltFrgh4.js.map +1 -0
- package/web-dist/assets/grip-vertical-QSdwyQ9C.js +2 -0
- package/web-dist/assets/grip-vertical-QSdwyQ9C.js.map +1 -0
- package/web-dist/assets/{hand-B6lvj014.js → hand-5eeZJSl_.js} +2 -2
- package/web-dist/assets/{hand-B6lvj014.js.map → hand-5eeZJSl_.js.map} +1 -1
- package/web-dist/assets/haptics-O69vKVoK.js +2 -0
- package/web-dist/assets/haptics-O69vKVoK.js.map +1 -0
- package/web-dist/assets/index-CbdB9RE5.js +17 -0
- package/web-dist/assets/index-CbdB9RE5.js.map +1 -0
- package/web-dist/assets/index-XQGPQuFK.css +2 -0
- package/web-dist/assets/{link-2-CCq9WzMy.js → link-2-DXaJEVgz.js} +2 -2
- package/web-dist/assets/{link-2-CCq9WzMy.js.map → link-2-DXaJEVgz.js.map} +1 -1
- package/web-dist/assets/logic-4hQwsm8w.js +4 -0
- package/web-dist/assets/logic-4hQwsm8w.js.map +1 -0
- package/web-dist/assets/logic-c8AsGwGr.js +2 -0
- package/web-dist/assets/{logic-BnSIy9_P.js.map → logic-c8AsGwGr.js.map} +1 -1
- package/web-dist/assets/more-RENHRep9.js +2 -0
- package/web-dist/assets/more-RENHRep9.js.map +1 -0
- package/web-dist/assets/pencil-DvO-Zlyh.js +2 -0
- package/web-dist/assets/pencil-DvO-Zlyh.js.map +1 -0
- package/web-dist/assets/{play-NHO6U6cY.js → play-CPNEXvVs.js} +2 -2
- package/web-dist/assets/{play-NHO6U6cY.js.map → play-CPNEXvVs.js.map} +1 -1
- package/web-dist/assets/{plus-C83uJhbf.js → plus-DC4JQpXX.js} +2 -2
- package/web-dist/assets/{plus-C83uJhbf.js.map → plus-DC4JQpXX.js.map} +1 -1
- package/web-dist/assets/policyLogic-CXFbVtEs.js +2 -0
- package/web-dist/assets/{policyLogic-Btk1SjgX.js.map → policyLogic-CXFbVtEs.js.map} +1 -1
- package/web-dist/assets/prefs-BTwRvULi.js +2 -0
- package/web-dist/assets/prefs-BTwRvULi.js.map +1 -0
- package/web-dist/assets/queue-C25GCl3M.js +2 -0
- package/web-dist/assets/{queue-gs6Ez_u3.js.map → queue-C25GCl3M.js.map} +1 -1
- package/web-dist/assets/{rotate-ccw-BRrlVEAQ.js → rotate-ccw-DuLdXOxM.js} +2 -2
- package/web-dist/assets/{rotate-ccw-BRrlVEAQ.js.map → rotate-ccw-DuLdXOxM.js.map} +1 -1
- package/web-dist/assets/{search-C5H14z0D.js → search-tZdcGLqS.js} +2 -2
- package/web-dist/assets/{search-C5H14z0D.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-CATQN_17.js → terminal-CEttp_7_.js} +2 -2
- package/web-dist/assets/{terminal-CATQN_17.js.map → terminal-CEttp_7_.js.map} +1 -1
- package/web-dist/assets/terminal-login-BceUiMHs.js +2 -0
- package/web-dist/assets/{terminal-login-DNyAyWlB.js.map → terminal-login-BceUiMHs.js.map} +1 -1
- package/web-dist/assets/useBreakpoint-CdYPa6z0.js +2 -0
- package/web-dist/assets/useBreakpoint-CdYPa6z0.js.map +1 -0
- package/web-dist/assets/useNow-CyygPGnv.js +2 -0
- package/web-dist/assets/{useNow-wwKWj7oX.js.map → useNow-CyygPGnv.js.map} +1 -1
- package/web-dist/assets/useResource-DQOWQ7YZ.js +2 -0
- package/web-dist/assets/useResource-DQOWQ7YZ.js.map +1 -0
- 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-D39MZMSb.js.map +1 -0
- package/web-dist/index.html +7 -8
- package/web-dist/sw.js +1 -1
- package/web-dist/sw.js.map +1 -1
- package/web-dist/assets/AutomationView-8yzlARUS.js +0 -2
- package/web-dist/assets/AutomationView-8yzlARUS.js.map +0 -1
- package/web-dist/assets/Button-C7TQGuSX.js +0 -2
- package/web-dist/assets/Button-C7TQGuSX.js.map +0 -1
- package/web-dist/assets/Card-DzHrwFrv.js +0 -2
- package/web-dist/assets/Card-DzHrwFrv.js.map +0 -1
- package/web-dist/assets/Checkbox-BnRsg6ki.js +0 -2
- package/web-dist/assets/DangerZone-BicyqXv8.js +0 -2
- package/web-dist/assets/Field-DBm2uYcg.js +0 -2
- package/web-dist/assets/Menu-BCTLk6pj.js +0 -2
- package/web-dist/assets/Menu-BCTLk6pj.js.map +0 -1
- package/web-dist/assets/Priority-DAhFDJ7E.js +0 -2
- package/web-dist/assets/ScopeSelect-CMmLEwNw.js +0 -2
- package/web-dist/assets/ScopeSelect-CMmLEwNw.js.map +0 -1
- package/web-dist/assets/SegmentedControl-Cvkz7C_A.js +0 -2
- package/web-dist/assets/SegmentedControl-Cvkz7C_A.js.map +0 -1
- package/web-dist/assets/Select-CDRJ35wi.js +0 -2
- package/web-dist/assets/Switch-D5pVfZgf.js +0 -2
- package/web-dist/assets/Tabs-D1t1tQzS.js +0 -2
- package/web-dist/assets/Tabs-D1t1tQzS.js.map +0 -1
- package/web-dist/assets/TextLink-BGtYWCW9.js +0 -2
- package/web-dist/assets/UINodeRenderer-CzoNfuWZ.js +0 -4
- package/web-dist/assets/UINodeRenderer-CzoNfuWZ.js.map +0 -1
- package/web-dist/assets/UnfilteredNote-ddFROo9x.js +0 -2
- package/web-dist/assets/api-hJ_Ikv1a.js +0 -2
- package/web-dist/assets/api-hJ_Ikv1a.js.map +0 -1
- package/web-dist/assets/attention-8UbWvCkj.js +0 -2
- package/web-dist/assets/attention-8UbWvCkj.js.map +0 -1
- package/web-dist/assets/automations-ClK2gYj8.js +0 -2
- package/web-dist/assets/board-4FKGJU8D.js +0 -6
- package/web-dist/assets/board-4FKGJU8D.js.map +0 -1
- package/web-dist/assets/check-CEnbWw4D.js +0 -2
- package/web-dist/assets/check-CEnbWw4D.js.map +0 -1
- package/web-dist/assets/chevron-right-BM1IJI2z.js +0 -2
- package/web-dist/assets/code-BD2TozC7.js +0 -25
- package/web-dist/assets/code-BD2TozC7.js.map +0 -1
- package/web-dist/assets/describe-DBhLxCUs.js +0 -5
- package/web-dist/assets/enroll-JhMxQuxw.js +0 -2
- package/web-dist/assets/external-link-B3hnazCa.js +0 -2
- package/web-dist/assets/external-link-B3hnazCa.js.map +0 -1
- package/web-dist/assets/index-Bc5JWkn9.js +0 -17
- package/web-dist/assets/index-Bc5JWkn9.js.map +0 -1
- package/web-dist/assets/index-C9iuCGwg.css +0 -2
- package/web-dist/assets/keyboardLayers-4IDHV-jq.js +0 -2
- package/web-dist/assets/keyboardLayers-4IDHV-jq.js.map +0 -1
- package/web-dist/assets/logic-BnSIy9_P.js +0 -2
- package/web-dist/assets/logic-DUKcqVPg.js +0 -4
- package/web-dist/assets/logic-DUKcqVPg.js.map +0 -1
- package/web-dist/assets/more-CUfPZ6AG.js +0 -2
- package/web-dist/assets/more-CUfPZ6AG.js.map +0 -1
- package/web-dist/assets/pencil-DeML-0z2.js +0 -2
- package/web-dist/assets/pencil-DeML-0z2.js.map +0 -1
- package/web-dist/assets/policyLogic-Btk1SjgX.js +0 -2
- package/web-dist/assets/queue-gs6Ez_u3.js +0 -2
- package/web-dist/assets/repo-T2dxdBnU.js +0 -2
- package/web-dist/assets/repo-T2dxdBnU.js.map +0 -1
- package/web-dist/assets/selection-DBzwvhnW.js +0 -7
- package/web-dist/assets/selection-DBzwvhnW.js.map +0 -1
- package/web-dist/assets/settings-DpK1_7vb.js +0 -12
- package/web-dist/assets/settings-DpK1_7vb.js.map +0 -1
- package/web-dist/assets/states-DL6w2pmK.js +0 -58
- package/web-dist/assets/states-DL6w2pmK.js.map +0 -1
- package/web-dist/assets/terminal-login-DNyAyWlB.js +0 -2
- package/web-dist/assets/timer-DFrvOKOy.js +0 -2
- package/web-dist/assets/timer-DFrvOKOy.js.map +0 -1
- package/web-dist/assets/useBreakpoint-BYCN9s8X.js +0 -2
- package/web-dist/assets/useBreakpoint-BYCN9s8X.js.map +0 -1
- package/web-dist/assets/useNow-wwKWj7oX.js +0 -2
- package/web-dist/assets/useResource-D_GOVIub.js +0 -2
- package/web-dist/assets/useResource-D_GOVIub.js.map +0 -1
- package/web-dist/assets/workboard-B89WFLVO.js +0 -3
- package/web-dist/assets/workboard-B89WFLVO.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logic-BnSIy9_P.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 ? \"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,gDAMA,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,MAAO,GAAG,CAAC,CAAC,QAAQ,KAAM,EAAE,CAChF,CCPA,SAAgBE,EAAwB,EAAiB,CAErD,IAAMC,EAASC,EAAgB,QAAQ,KAAM,GAAG,CAAC,CAAC,QAAQ,KAAM,GAAG,EAQ7DC,GAAa,EAAKF,EAAO,OAAS,GAAM,EACxCG,EAASH,EAAO,OAAOA,EAAO,OAASE,EAAW,GAAG,EAErDE,EAAS,KAAKD,CAAM,EAEpBP,EAAS,IAAI,YAAYQ,EAAO,MAAM,EACtCT,EAAQ,IAAI,WAAWC,CAAM,EACnC,IAAK,IAAIS,EAAI,EAAGA,EAAID,EAAO,OAAQ,IAC/B,EAAMC,GAAKD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AqB,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 ? \"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,MAAO,GAAG,CAAC,CAAC,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F,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"}
|
|
@@ -0,0 +1,2 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,CAAQ,UAAU,QAAU,CAAA,EAClC,YAAeU,EAAW,EAAI,EAC/B,SAAA,MAEO,CAAA,CACL,C,IACL,EAAAJ,EAAA,IAAA,CAAC,KAAD,CACE,aAAW,kBACX,SAAU,GACV,sBAAA,GACA,wBAAA,GACA,UAAU,wIAET,SAAAM,EAAK,KAAK,CAAE,KAAI,KAAI,QAAO,cAAa,KAAMC,EAAM,YACnD,EAAAP,EAAA,IAAA,CAAC,KAAD,CAAa,UAAU,yCACrB,UAAA,EAAAA,EAAA,KAAA,CAACZ,EAAD,CACM,KACJ,qBAAA,GACA,UAAU,wFAHZ,SAAA,EAKE,EAAAY,EAAA,IAAA,CAACO,EAAD,CAAM,cAAA,GAAY,UAAU,4BAA8B,CAAA,GAC1D,EAAAP,EAAA,KAAA,CAAC,OAAD,CAAM,UAAU,iBAAhB,SAAA,EACE,EAAAA,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,oBAAqB,SAAAQ,CAAY,CAAA,GACjD,EAAAR,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,oCAAqC,SAAAS,CAAkB,CAAA,CACnE,C,GACLC,IAAU,cAAe,EAAAV,EAAA,IAAA,CAACT,EAAD,CAAmB,QAAO,MAAM,gBAAkB,CAAA,GAC5E,EAAAS,EAAA,IAAA,CAACP,EAAD,CAAc,cAAA,GAAY,UAAU,6BAA+B,CAAA,CAC/D,C,EACJ,EAdKkB,CAcL,CACL,CACC,CAAA,EACH,CAACN,IACA,EAAAL,EAAA,IAAA,CAACb,EAAD,CAAQ,QAAQ,YAAY,YAAeS,EAAW,SAAS,CAAC,CAAC,YAAY,EAAI,EAAG,SAAA,oBAE5E,CAAA,GAEV,EAAAI,EAAA,IAAA,CAACR,EAAD,CACE,KAAMW,EACN,YAAeC,EAAW,EAAK,EAC/B,MAAM,kBACN,YAAY,qDACZ,QACE,EAAAJ,EAAA,IAAA,CAACb,EAAD,CAAQ,QAAQ,UAAU,YAAeiB,EAAW,EAAK,EAAG,SAAA,MAEpD,CAAA,EAGV,UAAA,EAAAJ,EAAA,IAAA,CAACF,EAAD,CAAmB,CAAA,CACd,CAAA,CACJ,C,EAET,C"}
|
|
@@ -0,0 +1,2 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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{
|
|
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{
|
|
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"}
|
|
@@ -0,0 +1,2 @@
|
|
|
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"}
|
|
@@ -0,0 +1,2 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefs-BTwRvULi.js","names":["__iconData","createLucideIcon","create","__iconData$1","Ellipsis","__iconData","SquareKanban","createJSONStorage","storage","getStorage","parse","str2","options","str","name","newValue","toThenable","result","fn","input","onFulfilled","onRejected","persist","state","currentState","persistedState","baseOptions","hasHydrated","hydrationVersion","hydrationListeners","finishHydrationListeners","config","args","set","get","api","setItem","savedSetState","configResult","stateFromStorage","hydrate","currentVersion","cb","postRehydrationCallback","deserializedStorageValue","migration","migrated","migratedState","migrationResult","e","newOptions","PANE_LIMITS","clampPane","l","pane","px","defaultSendWithEnter","migratePrefs","version","persisted","rest","collapseWork","usePrefs","key","value","s","view","_s","_p","_f","prefs","useFilter","setFilter","fallback","v"],"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/ellipsis.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/square-kanban.mjs","../../../../node_modules/.pnpm/zustand@5.0.16_@types+react@19.3.0_react@19.3.1/node_modules/zustand/esm/middleware.mjs","../../src/prefs.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: \"ellipsis\",\n size: 24,\n node: [\n [\"circle\", { cx: \"12\", cy: \"12\", r: \"1\", key: \"41hilf\" }],\n [\"circle\", { cx: \"19\", cy: \"12\", r: \"1\", key: \"1wjl8i\" }],\n [\"circle\", { cx: \"5\", cy: \"12\", r: \"1\", key: \"1pcz8c\" }]\n ],\n aliases: [\"more-horizontal\"]\n};\n__iconData.node;\nconst Ellipsis = createLucideIcon(__iconData);\n\nexport { __iconData, Ellipsis as default };\n//# sourceMappingURL=ellipsis.mjs.map\n","/**\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: \"square-kanban\",\n size: 24,\n node: [\n [\"rect\", { width: \"18\", height: \"18\", x: \"3\", y: \"3\", rx: \"2\", key: \"afitv7\" }],\n [\"path\", { d: \"M8 7v7\", key: \"1x2jlm\" }],\n [\"path\", { d: \"M12 7v4\", key: \"xawao1\" }],\n [\"path\", { d: \"M16 7v9\", key: \"1hp2iy\" }]\n ],\n aliases: [\"kanban-square\"]\n};\n__iconData.node;\nconst SquareKanban = createLucideIcon(__iconData);\n\nexport { __iconData, SquareKanban as default };\n//# sourceMappingURL=square-kanban.mjs.map\n","const reduxImpl = (reducer, initial) => (set, _get, api) => {\n api.dispatch = (action) => {\n set((state) => reducer(state, action), false, action);\n return action;\n };\n api.dispatchFromDevtools = true;\n return { dispatch: (...args) => api.dispatch(...args), ...initial };\n};\nconst redux = reduxImpl;\n\nconst shouldDispatchFromDevtools = (api) => !!api.dispatchFromDevtools && typeof api.dispatch === \"function\";\nconst trackedConnections = /* @__PURE__ */ new Map();\nconst getTrackedConnectionState = (name) => {\n const api = trackedConnections.get(name);\n if (!api) return {};\n return Object.fromEntries(\n Object.entries(api.stores).map(([key, api2]) => [key, api2.getState()])\n );\n};\nconst extractConnectionInformation = (store, extensionConnector, options) => {\n if (store === void 0) {\n return {\n type: \"untracked\",\n connection: extensionConnector.connect(options)\n };\n }\n const existingConnection = trackedConnections.get(options.name);\n if (existingConnection) {\n return { type: \"tracked\", store, ...existingConnection };\n }\n const newConnection = {\n connection: extensionConnector.connect(options),\n stores: {}\n };\n trackedConnections.set(options.name, newConnection);\n return { type: \"tracked\", store, ...newConnection };\n};\nconst removeStoreFromTrackedConnections = (name, store, api) => {\n if (store === void 0) return;\n const connectionInfo = trackedConnections.get(name);\n if ((connectionInfo == null ? void 0 : connectionInfo.stores[store]) !== api) return;\n delete connectionInfo.stores[store];\n if (Object.keys(connectionInfo.stores).length === 0) {\n trackedConnections.delete(name);\n }\n};\nconst v8StackLineRe = /^at (?:new |async )?(.+?) \\(/;\nconst geckoStackLineRe = /^([^@]+)@/;\nfunction findCallerName(stack) {\n var _a, _b, _c;\n if (!stack) return void 0;\n const traceLines = stack.split(\"\\n\");\n const apiSetStateLineIndex = traceLines.findIndex(\n (traceLine) => traceLine.includes(\"api.setState\")\n );\n if (apiSetStateLineIndex < 0) return void 0;\n const callerLine = ((_a = traceLines[apiSetStateLineIndex + 1]) == null ? void 0 : _a.trim()) || \"\";\n return ((_b = v8StackLineRe.exec(callerLine)) == null ? void 0 : _b[1]) || ((_c = geckoStackLineRe.exec(callerLine)) == null ? void 0 : _c[1]);\n}\nconst devtoolsImpl = (fn, devtoolsOptions = {}) => (set, get, api) => {\n const { enabled, anonymousActionType, store, ...options } = devtoolsOptions;\n let extensionConnector;\n try {\n extensionConnector = (enabled != null ? enabled : (import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") && window.__REDUX_DEVTOOLS_EXTENSION__;\n } catch (e) {\n }\n if (!extensionConnector) {\n return fn(set, get, api);\n }\n const { connection, ...connectionInformation } = extractConnectionInformation(store, extensionConnector, options);\n let isRecording = true;\n api.setState = ((state, replace, nameOrAction) => {\n const r = set(state, replace);\n if (!isRecording) return r;\n const action = nameOrAction === void 0 ? {\n type: anonymousActionType || findCallerName(new Error().stack) || \"anonymous\"\n } : typeof nameOrAction === \"string\" ? { type: nameOrAction } : nameOrAction;\n if (store === void 0) {\n connection == null ? void 0 : connection.send(action, get());\n return r;\n }\n connection == null ? void 0 : connection.send(\n {\n ...action,\n type: `${store}/${action.type}`\n },\n {\n ...getTrackedConnectionState(options.name),\n [store]: api.getState()\n }\n );\n return r;\n });\n let unsubscribeFromStore;\n api.devtools = {\n cleanup: () => {\n unsubscribeFromStore == null ? void 0 : unsubscribeFromStore();\n unsubscribeFromStore = void 0;\n removeStoreFromTrackedConnections(options.name, store, api);\n if ((store === void 0 || !trackedConnections.has(options.name)) && connection && typeof connection.unsubscribe === \"function\") {\n connection.unsubscribe();\n }\n }\n };\n const setStateFromDevtools = (...a) => {\n const originalIsRecording = isRecording;\n isRecording = false;\n set(...a);\n isRecording = originalIsRecording;\n };\n const initialState = fn(api.setState, get, api);\n if (connectionInformation.type === \"untracked\") {\n connection == null ? void 0 : connection.init(initialState);\n } else {\n connectionInformation.stores[connectionInformation.store] = api;\n connection == null ? void 0 : connection.init(\n Object.fromEntries(\n Object.entries(connectionInformation.stores).map(([key, store2]) => [\n key,\n key === connectionInformation.store ? initialState : store2.getState()\n ])\n )\n );\n }\n if (shouldDispatchFromDevtools(api)) {\n let didWarnAboutReservedActionType = false;\n const originalDispatch = api.dispatch;\n api.dispatch = (...args) => {\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\" && args[0].type === \"__setState\" && !didWarnAboutReservedActionType) {\n console.warn(\n '[zustand devtools middleware] \"__setState\" action type is reserved to set state from the devtools. Avoid using it.'\n );\n didWarnAboutReservedActionType = true;\n }\n originalDispatch(...args);\n };\n }\n unsubscribeFromStore = connection.subscribe((message) => {\n var _a;\n const reviver = typeof options.serialize === \"object\" ? options.serialize.reviver : void 0;\n switch (message.type) {\n case \"ACTION\":\n if (typeof message.payload !== \"string\") {\n console.error(\n \"[zustand devtools middleware] Unsupported action format\"\n );\n return;\n }\n return parseJsonThen(\n message.payload,\n reviver,\n (action) => {\n if (action.type === \"__setState\") {\n if (store === void 0) {\n setStateFromDevtools(action.state);\n return;\n }\n if (Object.keys(action.state).length !== 1) {\n console.error(\n `\n [zustand devtools middleware] Unsupported __setState action format.\n When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),\n and value of this only key should be a state object. Example: { \"type\": \"__setState\", \"state\": { \"abc123Store\": { \"foo\": \"bar\" } } }\n `\n );\n }\n const stateFromDevtools = action.state[store];\n if (stateFromDevtools === void 0 || stateFromDevtools === null) {\n return;\n }\n if (JSON.stringify(api.getState()) !== JSON.stringify(stateFromDevtools)) {\n setStateFromDevtools(stateFromDevtools);\n }\n return;\n }\n if (shouldDispatchFromDevtools(api)) {\n api.dispatch(action);\n }\n }\n );\n case \"DISPATCH\":\n switch (message.payload.type) {\n case \"RESET\":\n setStateFromDevtools(initialState);\n if (store === void 0) {\n return connection == null ? void 0 : connection.init(api.getState());\n }\n return connection == null ? void 0 : connection.init(getTrackedConnectionState(options.name));\n case \"COMMIT\":\n if (store === void 0) {\n connection == null ? void 0 : connection.init(api.getState());\n return;\n }\n return connection == null ? void 0 : connection.init(getTrackedConnectionState(options.name));\n case \"ROLLBACK\":\n return parseJsonThen(message.state, reviver, (state) => {\n if (store === void 0) {\n setStateFromDevtools(state);\n connection == null ? void 0 : connection.init(api.getState());\n return;\n }\n setStateFromDevtools(state[store]);\n connection == null ? void 0 : connection.init(getTrackedConnectionState(options.name));\n });\n case \"JUMP_TO_STATE\":\n case \"JUMP_TO_ACTION\":\n return parseJsonThen(message.state, reviver, (state) => {\n if (store === void 0) {\n setStateFromDevtools(state);\n return;\n }\n if (JSON.stringify(api.getState()) !== JSON.stringify(state[store])) {\n setStateFromDevtools(state[store]);\n }\n });\n case \"IMPORT_STATE\": {\n const { nextLiftedState } = message.payload;\n const lastComputedState = (_a = nextLiftedState.computedStates.slice(-1)[0]) == null ? void 0 : _a.state;\n if (!lastComputedState) return;\n if (store === void 0) {\n setStateFromDevtools(lastComputedState);\n } else {\n setStateFromDevtools(lastComputedState[store]);\n }\n connection == null ? void 0 : connection.send(\n null,\n // FIXME no-any\n nextLiftedState\n );\n return;\n }\n case \"PAUSE_RECORDING\":\n return isRecording = !isRecording;\n }\n return;\n }\n });\n return initialState;\n};\nconst devtools = devtoolsImpl;\nconst parseJsonThen = (stringified, reviver, fn) => {\n let parsed;\n try {\n parsed = JSON.parse(stringified, reviver);\n } catch (e) {\n console.error(\n \"[zustand devtools middleware] Could not parse the received json\",\n e\n );\n }\n if (parsed !== void 0) fn(parsed);\n};\n\nconst subscribeWithSelectorImpl = (fn) => (set, get, api) => {\n const origSubscribe = api.subscribe;\n api.subscribe = ((selector, optListener, options) => {\n let listener = selector;\n if (optListener) {\n const equalityFn = (options == null ? void 0 : options.equalityFn) || Object.is;\n let currentSlice = selector(api.getState());\n listener = (state) => {\n const nextSlice = selector(state);\n if (!equalityFn(currentSlice, nextSlice)) {\n const previousSlice = currentSlice;\n optListener(currentSlice = nextSlice, previousSlice);\n }\n };\n if (options == null ? void 0 : options.fireImmediately) {\n optListener(currentSlice, currentSlice);\n }\n }\n return origSubscribe(listener);\n });\n const initialState = fn(set, get, api);\n return initialState;\n};\nconst subscribeWithSelector = subscribeWithSelectorImpl;\n\nfunction combine(initialState, create) {\n return (...args) => Object.assign({}, initialState, create(...args));\n}\n\nfunction createJSONStorage(getStorage, options) {\n let storage;\n try {\n storage = getStorage();\n } catch (e) {\n return;\n }\n const persistStorage = {\n getItem: (name) => {\n var _a;\n const parse = (str2) => {\n if (str2 === null) {\n return null;\n }\n return JSON.parse(str2, options == null ? void 0 : options.reviver);\n };\n const str = (_a = storage.getItem(name)) != null ? _a : null;\n if (str instanceof Promise) {\n return str.then(parse);\n }\n return parse(str);\n },\n setItem: (name, newValue) => storage.setItem(name, JSON.stringify(newValue, options == null ? void 0 : options.replacer)),\n removeItem: (name) => storage.removeItem(name)\n };\n return persistStorage;\n}\nconst toThenable = (fn) => (input) => {\n try {\n const result = fn(input);\n if (result instanceof Promise) {\n return result;\n }\n return {\n then(onFulfilled) {\n return toThenable(onFulfilled)(result);\n },\n catch(_onRejected) {\n return this;\n }\n };\n } catch (e) {\n return {\n then(_onFulfilled) {\n return this;\n },\n catch(onRejected) {\n return toThenable(onRejected)(e);\n }\n };\n }\n};\nconst persistImpl = (config, baseOptions) => (set, get, api) => {\n let options = {\n storage: createJSONStorage(() => window.localStorage),\n partialize: (state) => state,\n version: 0,\n merge: (persistedState, currentState) => ({\n ...currentState,\n ...persistedState\n }),\n ...baseOptions\n };\n let hasHydrated = false;\n let hydrationVersion = 0;\n const hydrationListeners = /* @__PURE__ */ new Set();\n const finishHydrationListeners = /* @__PURE__ */ new Set();\n let storage = options.storage;\n if (!storage) {\n return config(\n (...args) => {\n console.warn(\n `[zustand persist middleware] Unable to update item '${options.name}', the given storage is currently unavailable.`\n );\n set(...args);\n },\n get,\n api\n );\n }\n const setItem = () => {\n const state = options.partialize({ ...get() });\n return storage.setItem(options.name, {\n state,\n version: options.version\n });\n };\n const savedSetState = api.setState;\n api.setState = (...args) => {\n savedSetState(...args);\n return setItem();\n };\n const configResult = config(\n (...args) => {\n set(...args);\n return setItem();\n },\n get,\n api\n );\n api.getInitialState = () => configResult;\n let stateFromStorage;\n const hydrate = () => {\n var _a, _b;\n if (!storage) return;\n const currentVersion = ++hydrationVersion;\n hasHydrated = false;\n hydrationListeners.forEach((cb) => {\n var _a2;\n return cb((_a2 = get()) != null ? _a2 : configResult);\n });\n const postRehydrationCallback = ((_b = options.onRehydrateStorage) == null ? void 0 : _b.call(options, (_a = get()) != null ? _a : configResult)) || void 0;\n return toThenable(storage.getItem.bind(storage))(options.name).then((deserializedStorageValue) => {\n if (deserializedStorageValue) {\n if (typeof deserializedStorageValue.version === \"number\" && deserializedStorageValue.version !== options.version) {\n if (options.migrate) {\n const migration = options.migrate(\n deserializedStorageValue.state,\n deserializedStorageValue.version\n );\n if (migration instanceof Promise) {\n return migration.then((result) => [true, result]);\n }\n return [true, migration];\n }\n console.error(\n `State loaded from storage couldn't be migrated since no migrate function was provided`\n );\n } else {\n return [false, deserializedStorageValue.state];\n }\n }\n return [false, void 0];\n }).then((migrationResult) => {\n var _a2;\n if (currentVersion !== hydrationVersion) {\n return;\n }\n const [migrated, migratedState] = migrationResult;\n stateFromStorage = options.merge(\n migratedState,\n (_a2 = get()) != null ? _a2 : configResult\n );\n set(stateFromStorage, true);\n if (migrated) {\n return setItem();\n }\n }).then(() => {\n if (currentVersion !== hydrationVersion) {\n return;\n }\n postRehydrationCallback == null ? void 0 : postRehydrationCallback(get(), void 0);\n stateFromStorage = get();\n hasHydrated = true;\n finishHydrationListeners.forEach((cb) => cb(stateFromStorage));\n }).catch((e) => {\n if (currentVersion !== hydrationVersion) {\n return;\n }\n postRehydrationCallback == null ? void 0 : postRehydrationCallback(void 0, e);\n });\n };\n api.persist = {\n setOptions: (newOptions) => {\n options = {\n ...options,\n ...newOptions\n };\n if (newOptions.storage) {\n storage = newOptions.storage;\n }\n },\n clearStorage: () => {\n ++hydrationVersion;\n storage == null ? void 0 : storage.removeItem(options.name);\n },\n getOptions: () => options,\n rehydrate: () => hydrate(),\n hasHydrated: () => hasHydrated,\n onHydrate: (cb) => {\n hydrationListeners.add(cb);\n return () => {\n hydrationListeners.delete(cb);\n };\n },\n onFinishHydration: (cb) => {\n finishHydrationListeners.add(cb);\n return () => {\n finishHydrationListeners.delete(cb);\n };\n }\n };\n if (!options.skipHydration) {\n hydrate();\n }\n return stateFromStorage || configResult;\n};\nconst persist = persistImpl;\n\nfunction ssrSafe(config, isSSR = typeof window === \"undefined\") {\n return (set, get, api) => {\n if (!isSSR) {\n return config(set, get, api);\n }\n const ssrSet = () => {\n throw new Error(\"Cannot set state of Zustand store in SSR\");\n };\n api.setState = ssrSet;\n return config(ssrSet, get, api);\n };\n}\n\nexport { combine, createJSONStorage, devtools, persist, redux, subscribeWithSelector, ssrSafe as unstable_ssrSafe };\n","import { create } from \"zustand\";\nimport { createJSONStorage, persist } from \"zustand/middleware\";\n\n/**\n * Per-device preferences persisted under `sy:prefs` (spec 10: filters,\n * selected project, pane sizes and last session persist per device).\n */\n\nexport const PANE_LIMITS = {\n navigator: { min: 220, max: 360, default: 264 },\n inspector: { min: 320, max: 600, default: 380 },\n boardColumn: { min: 288, max: 360, default: 320 },\n} as const;\n\nexport type PaneName = keyof typeof PANE_LIMITS;\n\nexport interface Prefs {\n /** Selected project for Board/Code filters; null means all projects. */\n selectedProjectId: string | null;\n /** Last opened session (Code view reopens it). */\n lastSessionId: string | null;\n /** Project of the last session created with New session (prefills the next one). */\n lastNewSessionProjectId: string | null;\n paneSizes: Record<PaneName, number>;\n inspectorCollapsed: boolean;\n /** Rail labels expanded (desktop/compact). */\n railExpanded: boolean;\n /** Desktop composer: Enter sends, Shift+Enter inserts a newline. */\n sendWithEnter: boolean;\n /** How much tool activity the transcript shows. */\n transcriptDetail: \"detailed\" | \"normal\" | \"summary\";\n /** What Send does while Pi works: queue the message, or steer now. */\n followUpMode: \"queue\" | \"steer\";\n /** Navigation-only Vim shortcuts; text editing and terminal input remain native. */\n vimNavigation: boolean;\n /** Order of the navigation destinations (rail, bottom bar, More); ids as in app/navigation. */\n navOrder: string[];\n /** How many of `navOrder` the phone's bottom bar shows; the rest are under More. */\n navBar: number;\n /** Free-form per-view filter state, keyed by view (e.g. \"board\", \"navigator\"). */\n filters: Record<string, unknown>;\n}\n\nexport interface PrefsStore extends Prefs {\n set<K extends keyof Prefs>(key: K, value: Prefs[K]): void;\n setPaneSize(pane: PaneName, px: number): void;\n setFilter<T>(view: string, value: T): void;\n}\n\nexport function clampPane(pane: PaneName, px: number): number {\n const l = PANE_LIMITS[pane];\n return Math.round(Math.min(l.max, Math.max(l.min, px)));\n}\n\nfunction defaultSendWithEnter(): boolean {\n if (typeof window === \"undefined\" || !window.matchMedia) return true;\n // Desktop (fine pointer, wide) defaults to Enter-to-send; touch devices use the Send button.\n return window.matchMedia(\"(min-width: 768px) and (pointer: fine)\").matches;\n}\n\n/**\n * Upgrade stored preferences. Version 2 replaced the \"Fold finished turns\" switch with the three\n * levels of tool activity: a device that had folding off keeps every tool call visible.\n */\nexport function migratePrefs(persisted: unknown, version: number): unknown {\n if (version >= 2 || persisted === null || typeof persisted !== \"object\") return persisted;\n const { collapseWork, ...rest } = persisted as Record<string, unknown>;\n return { ...rest, transcriptDetail: collapseWork === false ? \"detailed\" : \"normal\" };\n}\n\nexport const usePrefs = create<PrefsStore>()(\n persist(\n (set) => ({\n selectedProjectId: null,\n lastSessionId: null,\n lastNewSessionProjectId: null,\n paneSizes: {\n navigator: PANE_LIMITS.navigator.default,\n inspector: PANE_LIMITS.inspector.default,\n boardColumn: PANE_LIMITS.boardColumn.default,\n },\n inspectorCollapsed: false,\n railExpanded: false,\n sendWithEnter: defaultSendWithEnter(),\n transcriptDetail: \"normal\",\n followUpMode: \"queue\",\n vimNavigation: true,\n navOrder: [\"code\", \"board\", \"attention\", \"tasks\", \"queue\", \"automations\", \"settings\"],\n navBar: 3,\n filters: {},\n set: (key, value) => set({ [key]: value } as Partial<Prefs>),\n setPaneSize: (pane, px) =>\n set((s) => ({ paneSizes: { ...s.paneSizes, [pane]: clampPane(pane, px) } })),\n setFilter: (view, value) => set((s) => ({ filters: { ...s.filters, [view]: value } })),\n }),\n {\n name: \"sy:prefs\",\n version: 2,\n migrate: (persisted, version) => migratePrefs(persisted, version) as PrefsStore,\n storage: createJSONStorage(() => localStorage),\n partialize: ({ set: _s, setPaneSize: _p, setFilter: _f, ...prefs }) => prefs,\n },\n ),\n);\n\n/** Read a persisted filter for a view with a fallback. */\nexport function useFilter<T>(view: string, fallback: T): [T, (v: T) => void] {\n const value = usePrefs((s) => s.filters[view]) as T | undefined;\n const setFilter = usePrefs((s) => s.setFilter);\n return [value ?? fallback, (v: T) => setFilter(view, v)];\n}\n"],"ignoreList":[0,1,2],"mappings":"A,iDASA,IAAMA,EAAa,CACjB,KAAM,WACN,KAAM,GACN,KAAM,CACJ,CAAC,SAAU,CAAE,GAAI,KAAM,GAAI,KAAM,EAAG,IAAK,IAAK,QAAS,CAAC,EACxD,CAAC,SAAU,CAAE,GAAI,KAAM,GAAI,KAAM,EAAG,IAAK,IAAK,QAAS,CAAC,EACxD,CAAC,SAAU,CAAE,GAAI,IAAK,GAAI,KAAM,EAAG,IAAK,IAAK,QAAS,CAAC,CACzD,EACA,QAAS,CAAC,iBAAiB,CAC7B,EACAA,EAAW,KACX,IAAMI,EAAWH,EAAiBD,CAAU,ECXtCK,EAAa,CACjB,KAAM,gBACN,KAAM,GACN,KAAM,CACJ,CAAC,OAAQ,CAAE,MAAO,KAAM,OAAQ,KAAM,EAAG,IAAK,EAAG,IAAK,GAAI,IAAK,IAAK,QAAS,CAAC,EAC9E,CAAC,OAAQ,CAAE,EAAG,SAAU,IAAK,QAAS,CAAC,EACvC,CAAC,OAAQ,CAAE,EAAG,UAAW,IAAK,QAAS,CAAC,EACxC,CAAC,OAAQ,CAAE,EAAG,UAAW,IAAK,QAAS,CAAC,CAC1C,EACA,QAAS,CAAC,eAAe,CAC3B,EACAA,EAAW,KACX,IAAMC,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GAAMG,EAAE,QAAQC,EAAK,EACvCM,EAAYV,EAAU,GAAMG,EAAE,SAAS,EAC7C,MAAO,CAACD,GAASS,EAAW,GAASD,EAAUN,EAAMQ,CAAC,CAAC,CACzD,C"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{$t as e,D as t,T as n,W as r,_n as i,c as a,en as o,f as s,g as c,i as l,in as u,m as d,mn as f,n as p,p as m,r as h,s as g,t as _,u as v,vt as y,y as b}from"./states-CM1Zt9qO.js";import{C as x}from"./Overlay-wZFuaSA5.js";import{t as S}from"./calendar-clock-U5kMaB5u.js";import{r as C}from"./Priority-Ce4btFLm.js";import{i as w}from"./useResource-DQOWQ7YZ.js";import{B as T,a as E,m as D,t as O,x as k}from"./useNow-CyygPGnv.js";import{t as A}from"./link-2-DXaJEVgz.js";import{$ as j,K as M,gt as N,rt as P,st as F,t as I,yt as L}from"./index-CbdB9RE5.js";import{t as R}from"./UnfilteredNote-iQIfVXkA.js";var z={name:`folder-lock`,size:24,node:[[`rect`,{width:`8`,height:`5`,x:`14`,y:`17`,rx:`1`,key:`19aais`}],[`path`,{d:`M10 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v2.5`,key:`1w6v7t`}],[`path`,{d:`M20 17v-2a2 2 0 1 0-4 0v2`,key:`pwaxnr`}]]};z.node;var B=t(z),V={name:`gauge`,size:24,node:[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]};V.node;var H=t(V),U={name:`power-off`,size:24,node:[[`path`,{d:`M18.36 6.64A9 9 0 0 1 20.77 15`,key:`dxknvb`}],[`path`,{d:`M6.16 6.16a9 9 0 1 0 12.68 12.68`,key:`1x7qb5`}],[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};U.node;var W=t(U),G={name:`rotate-cw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]};G.node;var K=t(G),q=i(f(),1),J=d(),Y={dependency:A,host_offline:P,project_limit:H,workspace_occupied:B,scheduled_time:S,invalid_configuration:b,dispatch_paused:N,project_automation_disabled:W,not_ready:n,already_dispatched:F,retry_backoff:K};function X(){let t=O(),n=r(e=>e.tasks),i=r(e=>e.runs),s=r(e=>e.hydrated),c=o(t.error)&&t.error.status===404,l=!!t.data&&(!Array.isArray(t.data.running)||!Array.isArray(t.data.queued)),u=(0,q.useMemo)(()=>t.data&&!l?t.data.running.map(e=>({taskId:e.taskId,runId:e.runId,sessionId:e.sessionId})):Object.values(i).filter(e=>k(e)&&e.state!==`queued`).map(e=>({taskId:e.taskId,runId:e.id,sessionId:e.sessionId})),[t.data,i,l]),d=(0,q.useMemo)(()=>t.data&&!l?t.data.queued.map(e=>({taskId:e.taskId,eligibility:e.eligibility})):Object.values(n).filter(e=>e.state===`ready`&&!e.hiddenFromBoard).sort((e,t)=>e.priority-t.priority||e.position-t.position).map(e=>({taskId:e.id,eligibility:void 0})),[t.data,n,l]),f=!t.data&&t.loading&&!t.error||!s,m=!!t.error&&!c&&!t.data;return l?(0,J.jsx)(h,{title:`The coordinator sent a queue this version cannot read`,error:`GET /api/now returned an unexpected shape. Check that the web app and coordinator versions match.`}):(0,J.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col gap-4 px-4 pb-4 safe-pt-4 md:px-6`,children:[(0,J.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-center gap-3`,children:[(0,J.jsx)(`h1`,{className:`flex-1 text-lg font-semibold`,children:`Queue`}),(0,J.jsx)(E,{})]}),(0,J.jsx)(R,{what:`tasks`}),(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:`Pausing stops new work from starting. Runs already in progress keep going.`}),(0,J.jsx)(g,{subject:`queue`,show:!!t.data}),c&&(0,J.jsx)(v,{capability:`Queue explanations`,reason:`This coordinator does not report why queued tasks are waiting. The list below comes from local data.`}),t.error!=null&&!c&&(0,J.jsx)(p,{compact:!0,title:`Could not refresh running and queued work`,error:e(t.error),onRetry:t.reload}),f?(0,J.jsx)(a,{label:`Loading running and queued work…`}):m&&u.length===0&&d.length===0?null:u.length===0&&d.length===0?(0,J.jsx)(_,{icon:(0,J.jsx)(x,{className:`size-8`}),title:`Nothing running or queued`,description:`Move a task to Ready on the board and the dispatcher starts it when it is eligible.`,action:{label:`Go to Tasks`,to:I.tasks}}):(0,J.jsxs)(`section`,{"aria-label":`Running and queued tasks`,tabIndex:-1,"data-keyboard-scope":!0,"data-keyboard-default":!0,className:`grid min-w-0 grid-cols-1 gap-4 focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent xl:grid-cols-2 xl:items-start`,children:[(0,J.jsxs)(`section`,{"aria-labelledby":`now-running`,className:`flex min-w-0 flex-col gap-2`,children:[(0,J.jsxs)(`h2`,{id:`now-running`,className:`text-base font-semibold`,children:[`Running `,(0,J.jsxs)(`span`,{className:`text-sm font-normal text-muted`,children:[`(`,u.length,`)`]})]}),u.length===0?(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:`Nothing is running.`}):(0,J.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:u.map(e=>(0,J.jsx)(`li`,{children:(0,J.jsx)(Z,{taskId:e.taskId,runId:e.runId,sessionId:e.sessionId})},e.runId))})]}),(0,J.jsxs)(`section`,{"aria-labelledby":`now-queued`,className:`flex min-w-0 flex-col gap-2`,children:[(0,J.jsxs)(`h2`,{id:`now-queued`,className:`text-base font-semibold`,children:[`Queued `,(0,J.jsxs)(`span`,{className:`text-sm font-normal text-muted`,children:[`(`,d.length,`)`]})]}),d.length===0?(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:`No Ready tasks are waiting.`}):(0,J.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:d.map(e=>(0,J.jsx)(`li`,{children:(0,J.jsx)(Q,{task:n[e.taskId],taskId:e.taskId,eligibility:e.eligibility})},e.taskId))})]})]})]})}function Z({taskId:e,runId:t,sessionId:n}){let i=r(t=>t.tasks[e]),a=r(e=>e.runs[t]),o=r(e=>a?.hostId?e.hosts[a.hostId]:void 0),d=r(e=>i?e.projects[i.projectId]:void 0),f=!!o&&o.connectivity!==`connected`;return(0,J.jsxs)(`article`,{className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-surface p-3`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-2`,children:[a?(0,J.jsx)(j,{kind:`run`,value:a.state,size:`sm`}):(0,J.jsx)(j,{kind:`task`,value:`in_progress`,size:`sm`}),(0,J.jsx)(u,{to:I.task(e),"data-keyboard-item":!0,className:`min-w-0 flex-1 basis-48 font-medium break-words hover:underline`,children:i?.title??`Task`}),(n??i?.sessionId)&&(0,J.jsxs)(u,{to:I.session(n??i?.sessionId),className:s(`secondary`,`sm`),children:[(0,J.jsx)(w,{"aria-hidden":!0,className:`size-3.5`}),`Open session`]})]}),(0,J.jsx)(`p`,{className:`text-xs text-muted`,children:[d?.name,o?`on ${o.name}`:null,a?.attempt&&a.attempt>1?`attempt ${a.attempt}`:null,a?.startedAt?`started ${c(a.startedAt)}`:null,a?.controlMode===`human`?`you have control`:`automation`].filter(Boolean).join(` · `)}),a?.state===`uncertain`&&o&&(0,J.jsx)(`p`,{className:`text-sm text-warning`,children:(0,J.jsxs)(`span`,{className:`text-text`,children:[`Waiting for host `,o.name,` to confirm launch. It is never started elsewhere.`]})}),f&&o&&(0,J.jsx)(l,{compact:!0,hostName:o.name,connectivity:o.connectivity===`reconnecting`?`reconnecting`:`unreachable`,lastSeenAt:o.lastSeenAt})]})}function Q({task:t,taskId:n,eligibility:i}){let a=r(e=>t?e.projects[t.projectId]:void 0),[o,s]=(0,q.useState)(!1),c=(0,q.useId)(),l=i?i.eligible?L:Y[i.wait]:x,d=i?i.eligible?`Starting on ${i.hostName}`:D[i.wait]:`Waiting for dispatch`,f=i&&!i.eligible?i.message:null;return(0,J.jsxs)(`article`,{"data-testid":`now-queued-row`,className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-surface p-3 sm:flex-row sm:items-center`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,J.jsx)(u,{to:I.task(n),"data-keyboard-item":!0,className:`min-w-0 font-medium break-words hover:underline`,children:t?.title??`Task`}),a&&(0,J.jsx)(`span`,{className:`text-xs text-muted`,children:a.name}),(0,J.jsxs)(`p`,{className:`flex min-w-0 items-start gap-1.5 text-sm`,children:[(0,J.jsx)(l,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 ${i?.eligible?`text-success`:`text-warning`}`}),(0,J.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:d}),f&&f!==d?(0,J.jsxs)(`span`,{className:`text-muted`,children:[`: `,f]}):null]})]})]}),t&&(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,J.jsx)(`label`,{htmlFor:c,className:`text-sm text-muted`,children:`Priority`}),(0,J.jsx)(C,{id:c,width:`auto`,value:t.priority,disabled:o,onChange:async n=>{s(!0);try{await T(t.id,{priority:n}),M.success(`"${t.title}" is now ${y[n]} priority`)}catch(t){M.error(`Could not change priority: ${e(t)}`)}finally{s(!1)}}}),o&&(0,J.jsx)(m,{label:`Saving priority`})]})]})}export{X as default};
|
|
2
|
+
//# sourceMappingURL=queue-C25GCl3M.js.map
|