@agimon-ai/po-cloudflare 0.0.2-alpha.76 → 0.0.2-alpha.78
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/dist/{approval-BlHIxC2J.js → approval-DRipNxVh.js} +4 -0
- package/dist/{approvalSession-UtzXVEB4.js → approvalSession-DPQQRkG4.js} +2 -2
- package/dist/assets/assets/{CodeEditorView-CaFk98Ji.js → CodeEditorView-CwDhkcuX.js} +2 -2
- package/dist/assets/assets/{abnfDiagram-WEYOIA3C-gzdpxFaJ.js → abnfDiagram-WEYOIA3C-x7ICShZ-.js} +2 -2
- package/dist/assets/assets/{architecture-WOLXFQ4H-TugrtWoO.js → architecture-WOLXFQ4H-BbNcuwIa.js} +1 -1
- package/dist/assets/assets/{architectureDiagram-ZHVYKT53-Xy_pnmaH.js → architectureDiagram-ZHVYKT53-BaKFNXDN.js} +2 -2
- package/dist/assets/assets/{blockDiagram-RJAE7QA3-pH1-jWYL.js → blockDiagram-RJAE7QA3-BpBDuUhc.js} +2 -2
- package/dist/assets/assets/{c4Diagram-XDPPPE54-CWmWk7y2.js → c4Diagram-XDPPPE54-CH1AYBxk.js} +2 -2
- package/dist/assets/assets/channel-DUu4-rZu.js +2 -0
- package/dist/assets/assets/{chunk-2E7WHVMD-C2O60zos.js → chunk-2E7WHVMD-zuvalEA0.js} +2 -2
- package/dist/assets/assets/{chunk-4EMNKR2T-CEHzGYY0.js → chunk-4EMNKR2T-Y1aujIa_.js} +2 -2
- package/dist/assets/assets/{chunk-55XCU76K-CjyzuqJm.js → chunk-55XCU76K-Cj_usw4a.js} +2 -2
- package/dist/assets/assets/{chunk-7S6XSTFO-Db8_vjDs.js → chunk-7S6XSTFO-CNv4j2oa.js} +2 -2
- package/dist/assets/assets/{chunk-AQDTSKZB-92c_fipW.js → chunk-AQDTSKZB-BgiafkbC.js} +2 -2
- package/dist/assets/assets/{chunk-DSNLSHJZ-DFGW_rzV.js → chunk-DSNLSHJZ-CEqk3yOv.js} +2 -2
- package/dist/assets/assets/{chunk-HAGFOTED-Cpx79XgA.js → chunk-HAGFOTED-w6XwPptZ.js} +2 -2
- package/dist/assets/assets/{chunk-HNE4Q36P-cz6K5cWs.js → chunk-HNE4Q36P-Du2F5NKF.js} +2 -2
- package/dist/assets/assets/{chunk-NQOKRVIF-Bhj8Cnrq.js → chunk-NQOKRVIF-e7LK2NBD.js} +2 -2
- package/dist/assets/assets/{chunk-UHW7PFBP-DugRZU3d.js → chunk-UHW7PFBP-CV1yEqMO.js} +2 -2
- package/dist/assets/assets/{chunk-VQ5W62QI-CFXU98Td.js → chunk-VQ5W62QI-Dz5nQ93K.js} +2 -2
- package/dist/assets/assets/{chunk-WQQL4CDK-BDYjxxgH.js → chunk-WQQL4CDK-CR_tliyN.js} +2 -2
- package/dist/assets/assets/chunk-XXDRQBXY-KxRgluI2.js +2 -0
- package/dist/assets/assets/{chunk-YZO67HFG-Bw3Zv3ms.js → chunk-YZO67HFG-DFykz1uM.js} +2 -2
- package/dist/assets/assets/{chunk-ZAUX2LTX-reWd5PI6.js → chunk-ZAUX2LTX-C-HZEj8t.js} +2 -2
- package/dist/assets/assets/{chunk-ZCHMQSOR-RCmNKJ0K.js → chunk-ZCHMQSOR-DhOusRJf.js} +2 -2
- package/dist/assets/assets/{classDiagram-v2-4MYWR3UA-DOBOI7kO.js → classDiagram-v2-4MYWR3UA-CODBKWcv.js} +2 -2
- package/dist/assets/assets/{cose-bilkent-JH36ORCC-Dnga9ThU.js → cose-bilkent-JH36ORCC-CQBDxRkG.js} +2 -2
- package/dist/assets/assets/{cynefin-EF2NZ3EQ-mbxppeTd.js → cynefin-EF2NZ3EQ-BqEZr_DI.js} +1 -1
- package/dist/assets/assets/{cynefinDiagram-WF24UDRP-D5uSCW7P.js → cynefinDiagram-WF24UDRP-CAFtVFnZ.js} +2 -2
- package/dist/assets/assets/{dagre-NK4GIZVX-D3Utujwv.js → dagre-NK4GIZVX-6EbIcHjw.js} +2 -2
- package/dist/assets/assets/{diagram-CBK3MWTC-Bg8QfzPb.js → diagram-CBK3MWTC-DxOPl4wX.js} +2 -2
- package/dist/assets/assets/{diagram-I5XIIV2D-NjETU96V.js → diagram-I5XIIV2D-Dn-nrQn0.js} +2 -2
- package/dist/assets/assets/{diagram-ODIL2UCW-BRY10xxY.js → diagram-ODIL2UCW-Df9GeJiZ.js} +2 -2
- package/dist/assets/assets/{diagram-PFBEJUXE-CO5Nfc2a.js → diagram-PFBEJUXE-CzsqYRcB.js} +2 -2
- package/dist/assets/assets/{diagram-RJA3I4VV-jxuLnXXk.js → diagram-RJA3I4VV-Chxf9kLz.js} +2 -2
- package/dist/assets/assets/{diagram-TYUNFSNR-B-dUsynt.js → diagram-TYUNFSNR-DsSL0naA.js} +2 -2
- package/dist/assets/assets/{dist-Bsp48Zck.js → dist-1eIdTf5S.js} +2 -2
- package/dist/assets/assets/{dist-JCg255PN.js → dist-B7Fq62ue.js} +2 -2
- package/dist/assets/assets/{dist-DtWJqHVb.js → dist-C-zBeZYG.js} +2 -2
- package/dist/assets/assets/{dist-BMmgMuDM.js → dist-CNPkFbM6.js} +2 -2
- package/dist/assets/assets/{dist-lOIB9DJk.js → dist-DHBIyPPx.js} +2 -2
- package/dist/assets/assets/{dist-9C1WeAys.js → dist-DR6uuD7b.js} +2 -2
- package/dist/assets/assets/{dist-C8son2cz.js → dist-Dul31jTx.js} +2 -2
- package/dist/assets/assets/{dist-CXebcDwS.js → dist-dedZfm22.js} +2 -2
- package/dist/assets/assets/{dist-CUuM0eUM.js → dist-zUhlfRuY.js} +2 -2
- package/dist/assets/assets/{ebnfDiagram-V4P3TTPT-KNVNlIfc.js → ebnfDiagram-V4P3TTPT-fUIcNhqL.js} +2 -2
- package/dist/assets/assets/{elk-QONTBCTQ-DsX7hxD1.js → elk-QONTBCTQ-BtFtt9dx.js} +2 -2
- package/dist/assets/assets/{erDiagram-KYQIGQAA-pjQN44eX.js → erDiagram-KYQIGQAA-8nTQgw_u.js} +2 -2
- package/dist/assets/assets/{eventmodeling-K75KTNOO-BCKz9w4V.js → eventmodeling-K75KTNOO-u--ksfW0.js} +1 -1
- package/dist/assets/assets/flowDiagram-IUGLLWBU-U-4ltU4o.js +1 -0
- package/dist/assets/assets/{ganttDiagram-R7GPNTJY-CeuiGYpW.js → ganttDiagram-R7GPNTJY-CWqNS4bm.js} +2 -2
- package/dist/assets/assets/{gitGraph-VSP46ZUC-BsN0Vwsr.js → gitGraph-VSP46ZUC-Dy9xUPnQ.js} +1 -1
- package/dist/assets/assets/{gitGraphDiagram-PDYL7XHY-ZIMBu3bo.js → gitGraphDiagram-PDYL7XHY-D9OwLXxL.js} +2 -2
- package/dist/assets/assets/{index-fYkh5qQp.js → index-Blt5rLZT.js} +90 -90
- package/dist/assets/assets/{info-OHQRW6UA-CJmrVYr6.js → info-OHQRW6UA-ByFo5VxO.js} +1 -1
- package/dist/assets/assets/{infoDiagram-MVDRKAX5-BsAIEQmU.js → infoDiagram-MVDRKAX5-DkV7tUak.js} +2 -2
- package/dist/assets/assets/{ishikawaDiagram-HPEHV2GE-BX_86A9r.js → ishikawaDiagram-HPEHV2GE-D62xVlJr.js} +2 -2
- package/dist/assets/assets/{journeyDiagram-BOSHW7O7-DVGI0WoP.js → journeyDiagram-BOSHW7O7-CmGrCQyD.js} +2 -2
- package/dist/assets/assets/{kanban-definition-FNSA4HC5-4RLBwWbL.js → kanban-definition-FNSA4HC5-CQ-96zcl.js} +2 -2
- package/dist/assets/assets/{line-BL8hbik-.js → line-LyW2S8xe.js} +2 -2
- package/dist/assets/assets/{linear-BWVrkBYc.js → linear-Df5iFoGG.js} +2 -2
- package/dist/assets/assets/{mermaid-parser.core-CMk5l3Wp.js → mermaid-parser.core-DwGEOVKN.js} +4 -4
- package/dist/assets/assets/{mermaid.core-DZuf73R_.js → mermaid.core-UZa2JDq1.js} +5 -5
- package/dist/assets/assets/{mindmap-definition-6OY57UG3-CPuk1tgo.js → mindmap-definition-6OY57UG3-DXZpBkD7.js} +2 -2
- package/dist/assets/assets/{packet-JDAUHWVQ-pVue6YBL.js → packet-JDAUHWVQ-DVu5opyp.js} +1 -1
- package/dist/assets/assets/{pegDiagram-ECIUJNBX-B8Ly6ehm.js → pegDiagram-ECIUJNBX-D2PGrJQR.js} +2 -2
- package/dist/assets/assets/{pie-XZMESJXO-DXAHc3bX.js → pie-XZMESJXO-CoJXcSM1.js} +1 -1
- package/dist/assets/assets/{pieDiagram-GNMPY74T-9nVo6xZM.js → pieDiagram-GNMPY74T-DlPni3lE.js} +2 -2
- package/dist/assets/assets/{quadrantDiagram-D57K4MC3-DbBqshQw.js → quadrantDiagram-D57K4MC3-tDWbeX9Y.js} +2 -2
- package/dist/assets/assets/{radar-ABXABTNO-CKPxbvS6.js → radar-ABXABTNO-CiE-yXqS.js} +1 -1
- package/dist/assets/assets/{railroad-I3PHUGI6-CULlMjWr.js → railroad-I3PHUGI6-Bt5352hi.js} +1 -1
- package/dist/assets/assets/{railroad-abnf-LNEFI6M7-BRjXoZsa.js → railroad-abnf-LNEFI6M7-BJH5rnqj.js} +1 -1
- package/dist/assets/assets/{railroad-ebnf-DWYD2UWJ-CD_uPeUF.js → railroad-ebnf-DWYD2UWJ-C0KftBWL.js} +1 -1
- package/dist/assets/assets/{railroad-peg-JR7BVNR7-Cv-b3SRa.js → railroad-peg-JR7BVNR7-CRa7U91X.js} +1 -1
- package/dist/assets/assets/{railroadDiagram-Y72NRBL7-DJ77wAhA.js → railroadDiagram-Y72NRBL7-fOs3RTR8.js} +2 -2
- package/dist/assets/assets/{requirementDiagram-EQYSW5RA-R7PFvkp-.js → requirementDiagram-EQYSW5RA-SvE7rYXk.js} +2 -2
- package/dist/assets/assets/{sankeyDiagram-SY24JHO5-DR2gLc8z.js → sankeyDiagram-SY24JHO5-nqR9ZUs4.js} +2 -2
- package/dist/assets/assets/{sequenceDiagram-BLEHNHQU-TwEQL0yK.js → sequenceDiagram-BLEHNHQU-CgEFMQSq.js} +2 -2
- package/dist/assets/assets/{src-Cv8dmcJt.js → src-B4g3Iold.js} +2 -2
- package/dist/assets/assets/{stateDiagram-v2-A6IESKWZ-ShloXczl.js → stateDiagram-v2-A6IESKWZ-C2jH_xDT.js} +2 -2
- package/dist/assets/assets/{swimlanes-B3ENRKFQ-D17E07lx.js → swimlanes-B3ENRKFQ-Dbf1mXvK.js} +2 -2
- package/dist/assets/assets/swimlanesDiagram-AYQRV4AK-Bc5KGsMc.js +9 -0
- package/dist/assets/assets/{timeline-definition-JXYKGLGB-BEvN2l_s.js → timeline-definition-JXYKGLGB-4u-pC3xz.js} +2 -2
- package/dist/assets/assets/{treeView-D4JQ5SDB-B0QcYOKz.js → treeView-D4JQ5SDB-CZmVi5-J.js} +1 -1
- package/dist/assets/assets/{treemap-SAJKECNS-CIGIJniE.js → treemap-SAJKECNS-BajhrENS.js} +1 -1
- package/dist/assets/assets/{usecaseDiagram-WPOLBNNX-DbS-GLv8.js → usecaseDiagram-WPOLBNNX-J1gh4d5h.js} +2 -2
- package/dist/assets/assets/{vennDiagram-Q3Y3IDCW-CEkmUNoT.js → vennDiagram-Q3Y3IDCW-CIRtS6C5.js} +2 -2
- package/dist/assets/assets/{wardley-7MLQ67FV-D9b-h7oE.js → wardley-7MLQ67FV-DjBwbtAb.js} +1 -1
- package/dist/assets/assets/{wardleyDiagram-IVAIDKWA-BoWIYn_M.js → wardleyDiagram-IVAIDKWA-Cui7ZUN1.js} +2 -2
- package/dist/assets/assets/{webpack-rEg3nylj.js → webpack-FJjN4adW.js} +2 -2
- package/dist/assets/assets/{xychartDiagram-4URNHDU4-xJdWE_nx.js → xychartDiagram-4URNHDU4-I-UzMoDZ.js} +2 -2
- package/dist/assets/bundle-asset-policy.json +1 -1
- package/dist/assets/index.html +1 -1
- package/dist/assets/plugins/chunks/po-web-runtime-C0B3uAoC.js +1 -0
- package/dist/assets/plugins/compositions.json +1 -1
- package/dist/assets/plugins/slots/{approval.09e72f36-B4Y8Wjzl.js → approval.dd60ec90-gfcirIrD.js} +1 -1
- package/dist/assets/plugins/slots/{artifacts.50b639bb-5Kf50LM1.js → artifacts.a078f1a5-B5YmdqFC.js} +1 -1
- package/dist/assets/plugins/slots/{author.ea449ace-BUAjd0RY.js → author.b2063a1b-QDThbn6B.js} +3 -3
- package/dist/assets/plugins/slots/{autocompact.6f428144-DUwf4L4s.js → autocompact.86aeccf4-DxTuE9o-.js} +1 -1
- package/dist/assets/plugins/slots/{backdrop-bamboo.6e4c928d-CT9PXrny.js → backdrop-bamboo.1a7d88ef-BfruoASs.js} +1 -1
- package/dist/assets/plugins/slots/{browse.fa1f1a50-ClrBioNv.js → browse.4b750f64-LwBuFuNb.js} +1 -1
- package/dist/assets/plugins/slots/{builtin-tools.75108f21-DmtavYBT.js → builtin-tools.0a7f0b8e-Cy2eN76-.js} +1 -1
- package/dist/assets/plugins/slots/{calendar.d8b70190-DmudDrcG.js → calendar.76ad65fa-CihobxD6.js} +1 -1
- package/dist/assets/plugins/slots/{codemode.c58fb583-BkVR1X2Y.js → codemode.ff16ac06-Dbjm7Efq.js} +1 -1
- package/dist/assets/plugins/slots/{domain.753f9f92-Bv-dlY79.js → domain.3ddea842-CJa-EzBA.js} +1 -1
- package/dist/assets/plugins/slots/{edit.804fec90-mJXCIk4G.js → edit.c5b0b072-Bp0bQ3N2.js} +1 -1
- package/dist/assets/plugins/slots/{files.66ffc636-CCRW8t1-.js → files.8ffcdcc0-re8nr2oz.js} +1 -1
- package/dist/assets/plugins/slots/{goal.45dffa01-q_Zh5QxW.js → goal.4524e2bf-C5mGe79a.js} +1 -1
- package/dist/assets/plugins/slots/{grep.98262cff-CTDwtVaK.js → grep.95f470b3-ClgsMgtm.js} +1 -1
- package/dist/assets/plugins/slots/{help.5fbd20f7-BBw7NYJI.js → help.dfbc8216-BGywkUKZ.js} +1 -1
- package/dist/assets/plugins/slots/{log.cb964209-BLY7IzD1.js → log.19bda339-6jMYUtlN.js} +1 -1
- package/dist/assets/plugins/slots/{mcp.82cc1ff5-5yoTabz8.js → mcp.ffbe405a-BnDP_LDU.js} +1 -1
- package/dist/assets/plugins/slots/{plan.3852ba52-DmdaEVVw.js → plan.2879a6ae-BXxVUfMI.js} +1 -1
- package/dist/assets/plugins/slots/{profile.ab16dcec-DOw3MhWl.js → profile.176710dd-Bc4Rwfhz.js} +1 -1
- package/dist/assets/plugins/slots/{prompts.ae48c07a-DQVmTxFZ.js → prompts.2c187969-CIBsOkp9.js} +1 -1
- package/dist/assets/plugins/slots/{read.4560591a-Bun0fKn1.js → read.1629d556-D-NY0ZCv.js} +1 -1
- package/dist/assets/plugins/slots/{runner.6e494d59-BDtBIqmQ.js → runner.962030e5-CCUVliK7.js} +1 -1
- package/dist/assets/plugins/slots/{scaffold.d87a6ee0-DZOiNwOS.js → scaffold.14b5f76b-DW44NU9X.js} +1 -1
- package/dist/assets/plugins/slots/{session-mcp.2be84084-DQpF2DkA.js → session-mcp.51089b63-Im-iuHcn.js} +1 -1
- package/dist/assets/plugins/slots/{sessions.6f47cb4c-y61JDvak.js → sessions.fc763f42-CL0PHuD4.js} +1 -1
- package/dist/assets/plugins/slots/{skill.62a0a1b3-C-mkriRv.js → skill.f5396fde-DHDfhNXW.js} +1 -1
- package/dist/assets/plugins/slots/{space.65a27e5a-Cr1HSI_z.js → space.d7bddb51-DFHblvL5.js} +1 -1
- package/dist/assets/plugins/slots/{subagents.8bb9992c-CrpR1Jhi.js → subagents.24539507-Db6YnHJd.js} +1 -1
- package/dist/assets/plugins/slots/{template-advanced.59f3f98a-CSuMHJ9x.js → template-advanced.292533fb-DyvcGxNV.js} +1 -1
- package/dist/assets/plugins/slots/{template-desktop.0f0b8491-C2ZheI0_.js → template-desktop.a1ef756c-5EQH-r7P.js} +1 -1
- package/dist/assets/plugins/slots/{template-elegant.0e3b0acf-Cq5Y_6VL.js → template-elegant.ceb23ac7-CrmEUE6V.js} +1 -1
- package/dist/assets/plugins/slots/{vault.3cbfcdc3-ZKO66wy8.js → vault.57fd9047-9cm8PfeP.js} +1 -1
- package/dist/assets/plugins/slots/{voice.a952113d-CsdoPA4G.js → voice.76006b18-BSC2gHHY.js} +1 -1
- package/dist/assets/plugins/slots/{web-search.65013836-C7W5RyLj.js → web-search.b025dda1-BMe5RM8K.js} +1 -1
- package/dist/assets/plugins/slots/{workflows.cbc5c5c0-BLNlHcfa.js → workflows.1fd6a554-CzFPuLnU.js} +1 -1
- package/dist/browser-BYWSPAEE.js +897 -0
- package/dist/{exports-Ct56PRB9.js → exports-BnHiOfC6.js} +1 -1
- package/dist/{index.edge-BRaAhap2.js → index.edge-By7eSfpp.js} +2 -2
- package/dist/sealedChannel-BeWNTWys.js +27 -0
- package/dist/{server-B3U0W7zD.js → server-1yS_uE-G.js} +1 -1
- package/dist/{server-CcKKktvn.js → server-B1kdSQrK.js} +1 -1
- package/dist/{server-fYfb0gN8.js → server-B3tod9fX.js} +3 -3
- package/dist/{server-BlbuM_IJ.js → server-BCuQ5v6n.js} +2 -2
- package/dist/{server-DAFM6HnJ.js → server-BGHoSIRR.js} +3 -3
- package/dist/{server-BUBijhBb.js → server-BN4AdrfM.js} +3 -3
- package/dist/{server-BSpJMYLb.js → server-Bl6gkrM7.js} +1 -1
- package/dist/{server-BPS6xFya.js → server-Bp5B4707.js} +1 -1
- package/dist/{server-D6-_DT9g.js → server-C-LM-7Mp.js} +1 -1
- package/dist/{server-CaFzaibK.js → server-Ca3X3h6Q.js} +1 -1
- package/dist/{server-CLRgSPVY.js → server-Cdrr9D-D.js} +1 -1
- package/dist/{server-BJssIIpm.js → server-Cj-2V-Z6.js} +1 -1
- package/dist/{server-Dnvp2U6V.js → server-CkEwZP4t.js} +1 -1
- package/dist/{server-DPG7BH6w.js → server-CodZPkK3.js} +1 -1
- package/dist/{server-7-DnO2Ww.js → server-CuKy4B95.js} +230 -117
- package/dist/{server-Dl3sng3O.js → server-D467psm_.js} +1 -1
- package/dist/{server-BUgDdcRW.js → server-DHAcLeIr.js} +1 -1
- package/dist/{server-HIbQWBba.js → server-DLZgrjI9.js} +9 -7
- package/dist/{server-BeAYfrzJ.js → server-DqEJjOJZ.js} +1 -1
- package/dist/{server-CKQwNrO8.js → server-DvXlixQN.js} +1 -1
- package/dist/{server-CMov-S5-.js → server-EyLWvUXw.js} +1 -1
- package/dist/{server-DMbdJzSQ.js → server-RF5gqssS.js} +1 -1
- package/dist/{server-BLcw1z6S.js → server-pp-NQWAR.js} +1 -1
- package/dist/{server-BqvkcVLn.js → server-rKR_yimq.js} +1 -1
- package/dist/{server-OzzJbeaS.js → server-sbfI6TAL.js} +2 -2
- package/dist/{type-DppaYz6F.js → type-1FxIJmfz.js} +2 -26
- package/dist/worker.js +80525 -80817
- package/package.json +49 -49
- package/dist/assets/assets/channel-CJxh7kPr.js +0 -2
- package/dist/assets/assets/chunk-XXDRQBXY-B7vCmBOn.js +0 -2
- package/dist/assets/assets/flowDiagram-IUGLLWBU-BU7xmb8h.js +0 -1
- package/dist/assets/assets/swimlanesDiagram-AYQRV4AK-i6-zDqZm.js +0 -9
- package/dist/assets/plugins/chunks/po-web-runtime-CQ9hLtG-.js +0 -1
- package/dist/browser-ks_k-6KA.js +0 -36
|
@@ -0,0 +1,897 @@
|
|
|
1
|
+
import { n as infoFor, r as isSealedEnvelope, t as MAX_MESSAGES_PER_KEY } from "./sealedChannel-BeWNTWys.js";
|
|
2
|
+
//#region ../../core/po-web-security/src/types/bundleManifest.ts
|
|
3
|
+
/**
|
|
4
|
+
* A signed description of cockpit assets for an independently trusted verifier.
|
|
5
|
+
*
|
|
6
|
+
* A manifest does not let a browser SPA defend itself against the server or TLS
|
|
7
|
+
* edge that supplied its executable code. Consumers need a separately trusted
|
|
8
|
+
* bootstrap and key before these signatures become a delivery guarantee.
|
|
9
|
+
*/
|
|
10
|
+
const BUNDLE_MANIFEST_ROUTE = "/bundle-manifest.json";
|
|
11
|
+
const WEB_ENTRY_PATH = "/index.html";
|
|
12
|
+
const NATIVE_MODULE_PATH = /^\/[A-Za-z0-9._-]+\.js$/u;
|
|
13
|
+
/** Domain-separation tag for an attestation. Starts with `p`, so it can never collide with a `2\n` manifest. */
|
|
14
|
+
const ATTESTATION_TAG = /^po\/[a-z0-9-]+\/v[1-9][0-9]*$/u;
|
|
15
|
+
const SHA256 = /^[0-9a-f]{64}$/u;
|
|
16
|
+
const BASE64URL$1 = /^[A-Za-z0-9_-]+$/u;
|
|
17
|
+
const CONTENT_TYPE = /^[a-z0-9][a-z0-9!#$&^_.+-]*\/[a-z0-9][a-z0-9!#$&^_.+-]*$/u;
|
|
18
|
+
function hasExactKeys(value, expected) {
|
|
19
|
+
const keys = Object.keys(value).sort();
|
|
20
|
+
return keys.length === expected.length && keys.every((key, index) => key === expected[index]);
|
|
21
|
+
}
|
|
22
|
+
function isSafeInteger(value, minimum) {
|
|
23
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= minimum;
|
|
24
|
+
}
|
|
25
|
+
function isSafeAssetPath(value) {
|
|
26
|
+
if (typeof value !== "string" || value.length < 2 || !value.startsWith("/")) return false;
|
|
27
|
+
if (value.includes("\\") || value.includes("\0") || value.includes("?") || value.includes("#")) return false;
|
|
28
|
+
if (/[^\x21-\x7e]/u.test(value) || value.includes("//") || /%(?![0-9a-f]{2})/iu.test(value)) return false;
|
|
29
|
+
if (/%(?:2e|2f|5c)/iu.test(value)) return false;
|
|
30
|
+
return value.split("/").slice(1).every((segment) => segment !== "" && segment !== "." && segment !== "..");
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The exact bytes of a tagged attestation: `UTF-8(tag + "\n" + JSON.stringify(fields))`. Fields are an
|
|
34
|
+
* ordered list of strings, so both sides build the same bytes without relying on object key order.
|
|
35
|
+
* Throws on a malformed tag or a non-string field.
|
|
36
|
+
*/
|
|
37
|
+
function attestationBytes(tag, fields) {
|
|
38
|
+
if (!ATTESTATION_TAG.test(tag)) throw new Error(`invalid attestation tag: ${tag}`);
|
|
39
|
+
if (!Array.isArray(fields) || !fields.every((field) => typeof field === "string")) throw new Error(`invalid attestation fields for ${tag}`);
|
|
40
|
+
return new TextEncoder().encode(`${tag}\n${JSON.stringify(fields)}`);
|
|
41
|
+
}
|
|
42
|
+
function matchesProfile(assets, paths, profile) {
|
|
43
|
+
if (profile === "web") return paths.has(WEB_ENTRY_PATH);
|
|
44
|
+
if (profile !== "native") return false;
|
|
45
|
+
return assets.every((entry) => NATIVE_MODULE_PATH.test(entry.path) && entry.contentType === "text/javascript" && entry.byteLength <= 4194304);
|
|
46
|
+
}
|
|
47
|
+
function isBundleManifest(value, profile = "web") {
|
|
48
|
+
if (typeof value !== "object" || value === null) return false;
|
|
49
|
+
if (!hasExactKeys(value, [
|
|
50
|
+
"assets",
|
|
51
|
+
"builtAt",
|
|
52
|
+
"revision",
|
|
53
|
+
"version"
|
|
54
|
+
])) return false;
|
|
55
|
+
const candidate = value;
|
|
56
|
+
if (candidate.version !== 2) return false;
|
|
57
|
+
if (!isSafeInteger(candidate.revision, 1) || !isSafeInteger(candidate.builtAt, 0)) return false;
|
|
58
|
+
if (!Array.isArray(candidate.assets) || candidate.assets.length === 0) return false;
|
|
59
|
+
const paths = /* @__PURE__ */ new Set();
|
|
60
|
+
for (const valueAsset of candidate.assets) {
|
|
61
|
+
if (typeof valueAsset !== "object" || valueAsset === null) return false;
|
|
62
|
+
if (!hasExactKeys(valueAsset, [
|
|
63
|
+
"byteLength",
|
|
64
|
+
"contentType",
|
|
65
|
+
"path",
|
|
66
|
+
"sha256"
|
|
67
|
+
])) return false;
|
|
68
|
+
const asset = valueAsset;
|
|
69
|
+
if (!isSafeAssetPath(asset.path) || paths.has(asset.path)) return false;
|
|
70
|
+
if (typeof asset.sha256 !== "string" || !SHA256.test(asset.sha256)) return false;
|
|
71
|
+
if (!isSafeInteger(asset.byteLength, 0)) return false;
|
|
72
|
+
if (typeof asset.contentType !== "string" || !CONTENT_TYPE.test(asset.contentType)) return false;
|
|
73
|
+
paths.add(asset.path);
|
|
74
|
+
}
|
|
75
|
+
return matchesProfile(candidate.assets, paths, profile);
|
|
76
|
+
}
|
|
77
|
+
function isSignedBundleManifest(value, profile = "web") {
|
|
78
|
+
if (typeof value !== "object" || value === null) return false;
|
|
79
|
+
if (!hasExactKeys(value, [
|
|
80
|
+
"manifest",
|
|
81
|
+
"publicKey",
|
|
82
|
+
"signature"
|
|
83
|
+
])) return false;
|
|
84
|
+
const candidate = value;
|
|
85
|
+
return isBundleManifest(candidate.manifest, profile) && typeof candidate.signature === "string" && candidate.signature.length === 86 && BASE64URL$1.test(candidate.signature) && typeof candidate.publicKey === "string" && candidate.publicKey.length <= 512 && BASE64URL$1.test(candidate.publicKey);
|
|
86
|
+
}
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region ../../core/po-web-security/src/services/serialQueue/index.ts
|
|
89
|
+
function createSerialQueue() {
|
|
90
|
+
/** The tail of the chain. Rejections are absorbed so one failure cannot stall the rest. */
|
|
91
|
+
let tail = Promise.resolve();
|
|
92
|
+
return { run(task) {
|
|
93
|
+
const result = tail.then(task, task);
|
|
94
|
+
tail = result.catch(() => void 0);
|
|
95
|
+
return result;
|
|
96
|
+
} };
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region ../../core/po-web-security/src/services/privateRelayFrame/index.ts
|
|
100
|
+
const PRIVATE_RELAY_MAX_PAYLOAD_BYTES = 65536;
|
|
101
|
+
const HEADER_BYTES = 10;
|
|
102
|
+
const VERSION = 1;
|
|
103
|
+
const MAX_UINT32 = 4294967295;
|
|
104
|
+
const kinds = [
|
|
105
|
+
"request",
|
|
106
|
+
"reply",
|
|
107
|
+
"chunk",
|
|
108
|
+
"end",
|
|
109
|
+
"cancel",
|
|
110
|
+
"credit"
|
|
111
|
+
];
|
|
112
|
+
function hasPayload(kind) {
|
|
113
|
+
return kind === "request" || kind === "reply" || kind === "chunk";
|
|
114
|
+
}
|
|
115
|
+
function validSequence(kind, sequence) {
|
|
116
|
+
if (!Number.isInteger(sequence) || sequence < 0 || sequence > MAX_UINT32) return false;
|
|
117
|
+
if (kind === "request" || kind === "reply") return sequence === 0;
|
|
118
|
+
return kind === "cancel" || sequence > 0;
|
|
119
|
+
}
|
|
120
|
+
/** Record size is independent of the HTTP body limit. A body is a sequence of bounded chunks. */
|
|
121
|
+
function encodePrivateRelayFrame(frame) {
|
|
122
|
+
const kind = kinds.indexOf(frame.kind);
|
|
123
|
+
const payload = "payload" in frame ? frame.payload : void 0;
|
|
124
|
+
const size = payload?.byteLength ?? 0;
|
|
125
|
+
if (kind < 0 || !Number.isInteger(frame.exchangeId) || frame.exchangeId < 1 || frame.exchangeId > MAX_UINT32 || !validSequence(frame.kind, frame.sequence) || hasPayload(frame.kind) !== size > 0 || size > 65536) throw new Error("Invalid private relay frame.");
|
|
126
|
+
const bytes = new Uint8Array(HEADER_BYTES + size);
|
|
127
|
+
const header = new DataView(bytes.buffer);
|
|
128
|
+
header.setUint8(0, VERSION);
|
|
129
|
+
header.setUint8(1, kind);
|
|
130
|
+
header.setUint32(2, frame.exchangeId);
|
|
131
|
+
header.setUint32(6, frame.sequence);
|
|
132
|
+
if (payload) bytes.set(payload, HEADER_BYTES);
|
|
133
|
+
return bytes;
|
|
134
|
+
}
|
|
135
|
+
/** Decode only after opening the authenticated channel. Ordering across records belongs to the exchange. */
|
|
136
|
+
function decodePrivateRelayFrame(bytes) {
|
|
137
|
+
const size = bytes.byteLength - HEADER_BYTES;
|
|
138
|
+
if (size < 0 || size > 65536) return void 0;
|
|
139
|
+
const header = new DataView(bytes.buffer, bytes.byteOffset, HEADER_BYTES);
|
|
140
|
+
if (header.getUint8(0) !== VERSION) return void 0;
|
|
141
|
+
const kind = kinds[header.getUint8(1)];
|
|
142
|
+
const exchangeId = header.getUint32(2);
|
|
143
|
+
const sequence = header.getUint32(6);
|
|
144
|
+
if (kind === void 0 || exchangeId === 0 || !validSequence(kind, sequence)) return void 0;
|
|
145
|
+
if (hasPayload(kind)) return size > 0 ? {
|
|
146
|
+
kind,
|
|
147
|
+
exchangeId,
|
|
148
|
+
sequence,
|
|
149
|
+
payload: bytes.subarray(HEADER_BYTES)
|
|
150
|
+
} : void 0;
|
|
151
|
+
return size === 0 ? {
|
|
152
|
+
kind,
|
|
153
|
+
exchangeId,
|
|
154
|
+
sequence
|
|
155
|
+
} : void 0;
|
|
156
|
+
}
|
|
157
|
+
//#endregion
|
|
158
|
+
//#region ../../core/po-web-security/src/services/browserBundleVerifier/index.ts
|
|
159
|
+
function decodeBase64Url(value) {
|
|
160
|
+
const standard = value.replaceAll("-", "+").replaceAll("_", "/");
|
|
161
|
+
const padded = standard.padEnd(Math.ceil(standard.length / 4) * 4, "=");
|
|
162
|
+
const binary = atob(padded);
|
|
163
|
+
const bytes = new Uint8Array(binary.length);
|
|
164
|
+
for (let index = 0; index < binary.length; index += 1) bytes[index] = binary.charCodeAt(index);
|
|
165
|
+
return bytes.buffer;
|
|
166
|
+
}
|
|
167
|
+
const P1363_SIGNATURE_LENGTH = 86;
|
|
168
|
+
const BASE64URL = /^[A-Za-z0-9_-]+$/u;
|
|
169
|
+
const MAX_SPKI_LENGTH = 512;
|
|
170
|
+
function importVerifyKey(spki) {
|
|
171
|
+
return crypto.subtle.importKey("spki", decodeBase64Url(spki), {
|
|
172
|
+
name: "ECDSA",
|
|
173
|
+
namedCurve: "P-256"
|
|
174
|
+
}, false, ["verify"]);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Verifies a tagged P-256 attestation against a separately trusted base64url SPKI. False for a malformed
|
|
178
|
+
* key or signature and for any signature mismatch; throws only on a malformed tag, which is a caller bug.
|
|
179
|
+
*/
|
|
180
|
+
async function verifyAttestation(spki, tag, fields, signature) {
|
|
181
|
+
const message = attestationBytes(tag, fields);
|
|
182
|
+
if (typeof spki !== "string" || spki.length === 0 || spki.length > MAX_SPKI_LENGTH || !BASE64URL.test(spki)) return false;
|
|
183
|
+
if (typeof signature !== "string" || signature.length !== P1363_SIGNATURE_LENGTH || !BASE64URL.test(signature)) return false;
|
|
184
|
+
try {
|
|
185
|
+
const key = await importVerifyKey(spki);
|
|
186
|
+
return await crypto.subtle.verify({
|
|
187
|
+
name: "ECDSA",
|
|
188
|
+
hash: "SHA-256"
|
|
189
|
+
}, key, decodeBase64Url(signature), message);
|
|
190
|
+
} catch {
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
//#endregion
|
|
195
|
+
//#region ../../core/po-web-security/src/services/browserSealedChannel/index.ts
|
|
196
|
+
/**
|
|
197
|
+
* The browser half of the sealed channel.
|
|
198
|
+
*
|
|
199
|
+
* Mirrors `nodeSealedChannel.ts` exactly, on WebCrypto instead of
|
|
200
|
+
* `node:crypto`. Two implementations rather than one because a shared one would
|
|
201
|
+
* drag node builtins into every browser bundle that imports it, and this
|
|
202
|
+
* package is imported by plugins that ship to the page. The envelope contract
|
|
203
|
+
* they both read lives in `../types/sealedChannel.ts`, and a round-trip test
|
|
204
|
+
* pins the two together so they cannot drift.
|
|
205
|
+
*/
|
|
206
|
+
const KEY_ALGORITHM = {
|
|
207
|
+
name: "ECDH",
|
|
208
|
+
namedCurve: "P-256"
|
|
209
|
+
};
|
|
210
|
+
const CIPHER = "AES-GCM";
|
|
211
|
+
const KEY_BITS = 256;
|
|
212
|
+
const TAG_BITS = 128;
|
|
213
|
+
const TAG_BYTES = 16;
|
|
214
|
+
const HKDF_SALT = "po/sealed/v1";
|
|
215
|
+
/** Undefined rather than a throw: a malformed field is a verdict, not an exception. */
|
|
216
|
+
function bytes(value) {
|
|
217
|
+
let binary;
|
|
218
|
+
try {
|
|
219
|
+
binary = atob(value.replaceAll("-", "+").replaceAll("_", "/"));
|
|
220
|
+
} catch {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
const out = new Uint8Array(new ArrayBuffer(binary.length));
|
|
224
|
+
for (let index = 0; index < binary.length; index += 1) out[index] = binary.charCodeAt(index);
|
|
225
|
+
return out;
|
|
226
|
+
}
|
|
227
|
+
function base64Url(value) {
|
|
228
|
+
let binary = "";
|
|
229
|
+
for (const byte of value) binary += String.fromCharCode(byte);
|
|
230
|
+
return btoa(binary).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
|
|
231
|
+
}
|
|
232
|
+
function view(value) {
|
|
233
|
+
const copy = new Uint8Array(new ArrayBuffer(value.length));
|
|
234
|
+
copy.set(value);
|
|
235
|
+
return copy.buffer;
|
|
236
|
+
}
|
|
237
|
+
async function derive(secret, direction) {
|
|
238
|
+
const material = await crypto.subtle.importKey("raw", secret, "HKDF", false, ["deriveKey"]);
|
|
239
|
+
return await crypto.subtle.deriveKey({
|
|
240
|
+
name: "HKDF",
|
|
241
|
+
hash: "SHA-256",
|
|
242
|
+
salt: view(new TextEncoder().encode(HKDF_SALT)),
|
|
243
|
+
info: view(new TextEncoder().encode(infoFor(direction)))
|
|
244
|
+
}, material, {
|
|
245
|
+
name: CIPHER,
|
|
246
|
+
length: KEY_BITS
|
|
247
|
+
}, false, ["encrypt", "decrypt"]);
|
|
248
|
+
}
|
|
249
|
+
function nonceFor(prefix, counter) {
|
|
250
|
+
const nonce = /* @__PURE__ */ new Uint8Array(12);
|
|
251
|
+
nonce.set(prefix.subarray(0, 4), 0);
|
|
252
|
+
new DataView(nonce.buffer).setBigUint64(4, counter, false);
|
|
253
|
+
return nonce;
|
|
254
|
+
}
|
|
255
|
+
function channelFrom(sendKey, receiveKey, noncePrefix) {
|
|
256
|
+
let sendCounter = 0n;
|
|
257
|
+
let highestReceived = -1n;
|
|
258
|
+
return {
|
|
259
|
+
async seal(plaintext) {
|
|
260
|
+
if (sendCounter >= BigInt(MAX_MESSAGES_PER_KEY)) return {
|
|
261
|
+
ok: false,
|
|
262
|
+
failure: "exhausted"
|
|
263
|
+
};
|
|
264
|
+
const nonce = nonceFor(noncePrefix, sendCounter);
|
|
265
|
+
const sealed = await crypto.subtle.encrypt({
|
|
266
|
+
name: CIPHER,
|
|
267
|
+
iv: view(nonce),
|
|
268
|
+
tagLength: TAG_BITS
|
|
269
|
+
}, sendKey, view(plaintext));
|
|
270
|
+
sendCounter += 1n;
|
|
271
|
+
return {
|
|
272
|
+
ok: true,
|
|
273
|
+
envelope: {
|
|
274
|
+
v: 1,
|
|
275
|
+
n: base64Url(nonce),
|
|
276
|
+
c: base64Url(new Uint8Array(sealed))
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
},
|
|
280
|
+
async open(envelope) {
|
|
281
|
+
const shape = envelope;
|
|
282
|
+
if (typeof shape?.n !== "string" || typeof shape.c !== "string") return {
|
|
283
|
+
ok: false,
|
|
284
|
+
failure: "malformed"
|
|
285
|
+
};
|
|
286
|
+
if (shape.v !== 1) return {
|
|
287
|
+
ok: false,
|
|
288
|
+
failure: "version"
|
|
289
|
+
};
|
|
290
|
+
if (!isSealedEnvelope(envelope)) return {
|
|
291
|
+
ok: false,
|
|
292
|
+
failure: "malformed"
|
|
293
|
+
};
|
|
294
|
+
const nonce = bytes(envelope.n);
|
|
295
|
+
const body = bytes(envelope.c);
|
|
296
|
+
if (nonce === void 0 || body === void 0) return {
|
|
297
|
+
ok: false,
|
|
298
|
+
failure: "malformed"
|
|
299
|
+
};
|
|
300
|
+
if (nonce.length !== 12 || body.length < TAG_BYTES) return {
|
|
301
|
+
ok: false,
|
|
302
|
+
failure: "malformed"
|
|
303
|
+
};
|
|
304
|
+
const counter = new DataView(view(nonce)).getBigUint64(4, false);
|
|
305
|
+
if (counter <= highestReceived) return {
|
|
306
|
+
ok: false,
|
|
307
|
+
failure: "replay"
|
|
308
|
+
};
|
|
309
|
+
let plaintext;
|
|
310
|
+
try {
|
|
311
|
+
plaintext = await crypto.subtle.decrypt({
|
|
312
|
+
name: CIPHER,
|
|
313
|
+
iv: view(nonce),
|
|
314
|
+
tagLength: TAG_BITS
|
|
315
|
+
}, receiveKey, view(body));
|
|
316
|
+
} catch {
|
|
317
|
+
return {
|
|
318
|
+
ok: false,
|
|
319
|
+
failure: "auth"
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
if (counter <= highestReceived) return {
|
|
323
|
+
ok: false,
|
|
324
|
+
failure: "replay"
|
|
325
|
+
};
|
|
326
|
+
highestReceived = counter;
|
|
327
|
+
return {
|
|
328
|
+
ok: true,
|
|
329
|
+
plaintext: new Uint8Array(plaintext)
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
/** Lets a client commit its key before the host signs both halves of a fresh exchange. */
|
|
335
|
+
async function prepareSealedChannel() {
|
|
336
|
+
const pair = await crypto.subtle.generateKey(KEY_ALGORITHM, false, ["deriveBits"]);
|
|
337
|
+
const publicKey = base64Url(new Uint8Array(await crypto.subtle.exportKey("raw", pair.publicKey)));
|
|
338
|
+
let used = false;
|
|
339
|
+
return {
|
|
340
|
+
publicKey,
|
|
341
|
+
async accept(hostPublicKey) {
|
|
342
|
+
if (used) return void 0;
|
|
343
|
+
used = true;
|
|
344
|
+
const hostKey = bytes(hostPublicKey);
|
|
345
|
+
if (!hostKey) return void 0;
|
|
346
|
+
const peer = await crypto.subtle.importKey("raw", view(hostKey), KEY_ALGORITHM, false, []);
|
|
347
|
+
const secret = await crypto.subtle.deriveBits({
|
|
348
|
+
name: "ECDH",
|
|
349
|
+
public: peer
|
|
350
|
+
}, pair.privateKey, KEY_BITS);
|
|
351
|
+
return channelFrom(await derive(secret, "c2s"), await derive(secret, "s2c"), /* @__PURE__ */ new Uint8Array(4));
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
new TextEncoder();
|
|
356
|
+
new TextDecoder();
|
|
357
|
+
//#endregion
|
|
358
|
+
//#region ../../core/po-web-security/src/services/privateRelay/index.ts
|
|
359
|
+
const MAX_METADATA = 16384;
|
|
360
|
+
const MAX_BODY = 134217728;
|
|
361
|
+
const PROTOCOL_ROUTE = "/api/remote/protocol";
|
|
362
|
+
const PROTOCOL_HEADER = "x-po-relay-protocol";
|
|
363
|
+
const MAX_EXCHANGES = 8;
|
|
364
|
+
const MAX_PENDING_RECORDS = 32;
|
|
365
|
+
const PRIVATE_RELAY_WIRE_BYTES = 131068;
|
|
366
|
+
const PRIVATE_RELAY_HANDSHAKE_MS = 1e4;
|
|
367
|
+
const relayEncoder = new TextEncoder();
|
|
368
|
+
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
369
|
+
function relayObject(input, limit) {
|
|
370
|
+
if ((typeof input === "string" ? input.length : input.byteLength) > limit) throw new Error("Private relay record too large.");
|
|
371
|
+
const value = JSON.parse(typeof input === "string" ? input : decoder.decode(input));
|
|
372
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("Invalid private relay record.");
|
|
373
|
+
return value;
|
|
374
|
+
}
|
|
375
|
+
function relayAddress(address) {
|
|
376
|
+
const url = new URL(address.origin);
|
|
377
|
+
if (url.protocol !== "https:" || url.origin !== address.origin || !/^\/api\/private-relay\/[\w-]{1,128}\/[\w.:-]{1,128}$/u.test(address.route)) throw new Error("Invalid private relay address.");
|
|
378
|
+
const endpoint = new URL(address.route, url);
|
|
379
|
+
if (endpoint.pathname !== address.route) throw new Error("Invalid private relay route.");
|
|
380
|
+
return endpoint;
|
|
381
|
+
}
|
|
382
|
+
function targetUrl(origin, target) {
|
|
383
|
+
if (typeof target !== "string" || !target.startsWith("/") || target.startsWith("//") || /[\\#\u0000-\u0020]/u.test(target)) throw new Error("Invalid private relay request target.");
|
|
384
|
+
const url = new URL(target, origin);
|
|
385
|
+
if (url.origin !== origin || url.pathname + url.search !== target) throw new Error("Invalid private relay request target.");
|
|
386
|
+
return url;
|
|
387
|
+
}
|
|
388
|
+
function bodyInfo(value) {
|
|
389
|
+
if (typeof value.body !== "boolean" || !Array.isArray(value.headers) || value.headers.length > 100 || !value.headers.every((entry) => Array.isArray(entry) && entry.length === 2 && entry.every((part) => typeof part === "string"))) throw new Error("Invalid private relay HTTP metadata.");
|
|
390
|
+
const headers = [];
|
|
391
|
+
new Headers(value.headers).forEach((content, name) => headers.push([name, content]));
|
|
392
|
+
return {
|
|
393
|
+
headers,
|
|
394
|
+
body: value.body
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
function metadata(value) {
|
|
398
|
+
const bytes = relayEncoder.encode(JSON.stringify(value));
|
|
399
|
+
if (bytes.byteLength > MAX_METADATA) throw new Error("Private relay HTTP metadata too large.");
|
|
400
|
+
return bytes;
|
|
401
|
+
}
|
|
402
|
+
const noBodyStatus = (status) => status === 204 || status === 205 || status === 304;
|
|
403
|
+
/** React Native's fetch polyfill has Body readers but no streaming Response constructor. */
|
|
404
|
+
function relayResponse(body, init) {
|
|
405
|
+
if (!body) return new Response(null, init);
|
|
406
|
+
const response = new Response(body, init);
|
|
407
|
+
if (response.body === body) return response;
|
|
408
|
+
let used = false;
|
|
409
|
+
const arrayBuffer = async () => {
|
|
410
|
+
if (used || body.locked) throw new TypeError("The response body has already been read.");
|
|
411
|
+
used = true;
|
|
412
|
+
const reader = body.getReader();
|
|
413
|
+
const chunks = [];
|
|
414
|
+
let size = 0;
|
|
415
|
+
try {
|
|
416
|
+
for (;;) {
|
|
417
|
+
const part = await reader.read();
|
|
418
|
+
if (part.done) break;
|
|
419
|
+
size += part.value.byteLength;
|
|
420
|
+
chunks.push(part.value);
|
|
421
|
+
}
|
|
422
|
+
} finally {
|
|
423
|
+
reader.releaseLock();
|
|
424
|
+
}
|
|
425
|
+
const bytes = new Uint8Array(size);
|
|
426
|
+
let offset = 0;
|
|
427
|
+
for (const chunk of chunks) {
|
|
428
|
+
bytes.set(chunk, offset);
|
|
429
|
+
offset += chunk.byteLength;
|
|
430
|
+
}
|
|
431
|
+
return bytes.buffer;
|
|
432
|
+
};
|
|
433
|
+
const text = async () => new TextDecoder().decode(await arrayBuffer());
|
|
434
|
+
Object.defineProperties(response, {
|
|
435
|
+
body: { value: body },
|
|
436
|
+
bodyUsed: { get: () => used || body.locked },
|
|
437
|
+
arrayBuffer: { value: arrayBuffer },
|
|
438
|
+
text: { value: text },
|
|
439
|
+
json: { value: async () => JSON.parse(await text()) },
|
|
440
|
+
blob: { value: async () => new Blob([await arrayBuffer()], { type: response.headers.get("content-type") ?? "" }) },
|
|
441
|
+
clone: { value: () => {
|
|
442
|
+
throw new TypeError("Cannot clone a streaming relay response on this platform.");
|
|
443
|
+
} }
|
|
444
|
+
});
|
|
445
|
+
return response;
|
|
446
|
+
}
|
|
447
|
+
/** Each receiver grants at most one chunk at a time. No unread body queue exists at the relay endpoint. */
|
|
448
|
+
function createPrivateRelayExchange(origin, channel, wire, serve) {
|
|
449
|
+
const incoming = createSerialQueue();
|
|
450
|
+
const outgoing = createSerialQueue();
|
|
451
|
+
const exchanges = /* @__PURE__ */ new Map();
|
|
452
|
+
let highestId = 0;
|
|
453
|
+
let receiving = 0;
|
|
454
|
+
let sending = 0;
|
|
455
|
+
let closed = false;
|
|
456
|
+
function finish(exchange, error) {
|
|
457
|
+
if (!exchanges.delete(exchange.id)) return;
|
|
458
|
+
clearTimeout(exchange.timer);
|
|
459
|
+
exchange.cleanup?.();
|
|
460
|
+
if (error) exchange.request?.reject(error);
|
|
461
|
+
if (error || exchange.incoming) {
|
|
462
|
+
const reason = error ?? /* @__PURE__ */ new Error("The host replied without reading the rest of the body.");
|
|
463
|
+
exchange.incoming?.controller?.error(reason);
|
|
464
|
+
exchange.abort.abort(reason);
|
|
465
|
+
}
|
|
466
|
+
exchange.outgoing?.reader.cancel(error).catch(() => void 0);
|
|
467
|
+
}
|
|
468
|
+
function dispose(error = /* @__PURE__ */ new Error("Private relay disconnected. The outcome of an in-flight write may be unknown.")) {
|
|
469
|
+
closed = true;
|
|
470
|
+
for (const exchange of exchanges.values()) finish(exchange, error);
|
|
471
|
+
}
|
|
472
|
+
function fail(error) {
|
|
473
|
+
if (closed) return;
|
|
474
|
+
const reason = error instanceof Error ? error : /* @__PURE__ */ new Error("Private relay failed.");
|
|
475
|
+
dispose(reason);
|
|
476
|
+
wire.fail(reason);
|
|
477
|
+
}
|
|
478
|
+
async function send(frame) {
|
|
479
|
+
if (closed) return;
|
|
480
|
+
if (++sending > MAX_PENDING_RECORDS) return fail(/* @__PURE__ */ new Error("Private relay send limit exceeded."));
|
|
481
|
+
await outgoing.run(async () => {
|
|
482
|
+
if (closed) return;
|
|
483
|
+
const sealed = await channel.seal(encodePrivateRelayFrame(frame));
|
|
484
|
+
if (!sealed.ok) throw new Error("Private relay could not encrypt a frame.");
|
|
485
|
+
if (!closed) wire.send(relayEncoder.encode(JSON.stringify(sealed.envelope)));
|
|
486
|
+
}).catch(fail).finally(() => {
|
|
487
|
+
sending -= 1;
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
function cancel(exchange, reason) {
|
|
491
|
+
if (!exchanges.has(exchange.id)) return;
|
|
492
|
+
send({
|
|
493
|
+
kind: "cancel",
|
|
494
|
+
exchangeId: exchange.id,
|
|
495
|
+
sequence: 0
|
|
496
|
+
});
|
|
497
|
+
finish(exchange, reason);
|
|
498
|
+
}
|
|
499
|
+
function touch(exchange) {
|
|
500
|
+
clearTimeout(exchange.timer);
|
|
501
|
+
if (!exchange.live) exchange.timer = setTimeout(() => cancel(exchange, /* @__PURE__ */ new Error("Private relay request timed out.")), 6e4);
|
|
502
|
+
}
|
|
503
|
+
function receiveBody(exchange) {
|
|
504
|
+
const body = {
|
|
505
|
+
expected: 1,
|
|
506
|
+
granted: false,
|
|
507
|
+
size: 0
|
|
508
|
+
};
|
|
509
|
+
body.stream = new ReadableStream({
|
|
510
|
+
start(controller) {
|
|
511
|
+
body.controller = controller;
|
|
512
|
+
},
|
|
513
|
+
pull() {
|
|
514
|
+
if (!exchanges.has(exchange.id) || body.granted) return;
|
|
515
|
+
body.granted = true;
|
|
516
|
+
touch(exchange);
|
|
517
|
+
return send({
|
|
518
|
+
kind: "credit",
|
|
519
|
+
exchangeId: exchange.id,
|
|
520
|
+
sequence: body.expected
|
|
521
|
+
});
|
|
522
|
+
},
|
|
523
|
+
cancel() {
|
|
524
|
+
if (!serve) cancel(exchange, /* @__PURE__ */ new Error("Private relay response cancelled."));
|
|
525
|
+
else body.controller = void 0;
|
|
526
|
+
}
|
|
527
|
+
}, { highWaterMark: 0 });
|
|
528
|
+
exchange.incoming = body;
|
|
529
|
+
return body.stream;
|
|
530
|
+
}
|
|
531
|
+
function offerBody(exchange, stream) {
|
|
532
|
+
if (stream) exchange.outgoing = {
|
|
533
|
+
reader: stream.getReader(),
|
|
534
|
+
sequence: 1,
|
|
535
|
+
busy: false,
|
|
536
|
+
size: 0
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
async function sendChunk(exchange, sequence) {
|
|
540
|
+
const body = exchange.outgoing;
|
|
541
|
+
if (!body || body.busy || body.sequence !== sequence) return fail(/* @__PURE__ */ new Error("Unexpected private relay credit."));
|
|
542
|
+
body.busy = true;
|
|
543
|
+
try {
|
|
544
|
+
while (!body.remaining?.byteLength) {
|
|
545
|
+
const part = await body.reader.read();
|
|
546
|
+
if (!exchanges.has(exchange.id)) return;
|
|
547
|
+
if (part.done) {
|
|
548
|
+
exchange.outgoing = void 0;
|
|
549
|
+
body.reader.releaseLock();
|
|
550
|
+
await send({
|
|
551
|
+
kind: "end",
|
|
552
|
+
exchangeId: exchange.id,
|
|
553
|
+
sequence
|
|
554
|
+
});
|
|
555
|
+
if (serve) finish(exchange);
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
558
|
+
body.size += part.value.byteLength;
|
|
559
|
+
if (body.size > MAX_BODY) throw new Error("Private relay body exceeds its size limit.");
|
|
560
|
+
body.remaining = part.value;
|
|
561
|
+
}
|
|
562
|
+
const payload = body.remaining.subarray(0, PRIVATE_RELAY_MAX_PAYLOAD_BYTES);
|
|
563
|
+
body.remaining = body.remaining.subarray(payload.byteLength);
|
|
564
|
+
body.sequence += 1;
|
|
565
|
+
body.busy = false;
|
|
566
|
+
await send({
|
|
567
|
+
kind: "chunk",
|
|
568
|
+
exchangeId: exchange.id,
|
|
569
|
+
sequence,
|
|
570
|
+
payload
|
|
571
|
+
});
|
|
572
|
+
} catch {
|
|
573
|
+
cancel(exchange, /* @__PURE__ */ new Error("Private relay body could not be sent."));
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
async function answer(exchange, request) {
|
|
577
|
+
try {
|
|
578
|
+
const response = await serve(request);
|
|
579
|
+
if (!exchanges.has(exchange.id)) {
|
|
580
|
+
await response.body?.cancel();
|
|
581
|
+
return;
|
|
582
|
+
}
|
|
583
|
+
const body = request.method === "HEAD" ? null : response.body;
|
|
584
|
+
if (request.method === "HEAD") response.body?.cancel().catch(() => void 0);
|
|
585
|
+
const payload = metadata({
|
|
586
|
+
status: response.status,
|
|
587
|
+
body: body !== null,
|
|
588
|
+
headers: [...response.headers]
|
|
589
|
+
});
|
|
590
|
+
exchange.live = exchange.protocol && !!body && response.status === 200 && response.headers.get(PROTOCOL_HEADER) === "1";
|
|
591
|
+
touch(exchange);
|
|
592
|
+
offerBody(exchange, body);
|
|
593
|
+
await send({
|
|
594
|
+
kind: "reply",
|
|
595
|
+
exchangeId: exchange.id,
|
|
596
|
+
sequence: 0,
|
|
597
|
+
payload
|
|
598
|
+
});
|
|
599
|
+
if (!body) finish(exchange);
|
|
600
|
+
} catch {
|
|
601
|
+
cancel(exchange, /* @__PURE__ */ new Error("The host could not complete the relay request."));
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
function dispatch(frame) {
|
|
605
|
+
if (frame.kind === "request") {
|
|
606
|
+
if (!serve || frame.exchangeId <= highestId || exchanges.size >= MAX_EXCHANGES) throw new Error("Unexpected private relay request.");
|
|
607
|
+
const value = relayObject(frame.payload, MAX_METADATA);
|
|
608
|
+
const info = bodyInfo(value);
|
|
609
|
+
const method = value.method;
|
|
610
|
+
if (typeof method !== "string" || !/^(?:GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS)$/u.test(method) || info.body && (method === "GET" || method === "HEAD")) throw new Error("Invalid private relay HTTP method.");
|
|
611
|
+
const target = targetUrl(origin, value.target);
|
|
612
|
+
highestId = frame.exchangeId;
|
|
613
|
+
const exchange = {
|
|
614
|
+
id: frame.exchangeId,
|
|
615
|
+
abort: new AbortController(),
|
|
616
|
+
protocol: method === "POST" && value.target === PROTOCOL_ROUTE
|
|
617
|
+
};
|
|
618
|
+
exchanges.set(exchange.id, exchange);
|
|
619
|
+
touch(exchange);
|
|
620
|
+
answer(exchange, new Request(target, {
|
|
621
|
+
method,
|
|
622
|
+
headers: info.headers,
|
|
623
|
+
body: info.body ? receiveBody(exchange) : null,
|
|
624
|
+
duplex: "half",
|
|
625
|
+
redirect: "error",
|
|
626
|
+
signal: exchange.abort.signal
|
|
627
|
+
}));
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
const exchange = exchanges.get(frame.exchangeId);
|
|
631
|
+
if (!exchange) {
|
|
632
|
+
if (frame.exchangeId <= highestId) return;
|
|
633
|
+
throw new Error("Unknown private relay exchange.");
|
|
634
|
+
}
|
|
635
|
+
touch(exchange);
|
|
636
|
+
if (frame.kind === "cancel") finish(exchange, /* @__PURE__ */ new Error("Private relay request ended before completion."));
|
|
637
|
+
else if (frame.kind === "credit") sendChunk(exchange, frame.sequence);
|
|
638
|
+
else if (frame.kind === "reply") {
|
|
639
|
+
if (!exchange.request || exchange.replied) throw new Error("Unexpected private relay reply.");
|
|
640
|
+
const value = relayObject(frame.payload, MAX_METADATA);
|
|
641
|
+
const info = bodyInfo(value);
|
|
642
|
+
const status = value.status;
|
|
643
|
+
if (typeof status !== "number" || !Number.isInteger(status) || status < 200 || status > 599 || info.body && (noBodyStatus(status) || exchange.request.method === "HEAD")) throw new Error("Invalid private relay HTTP status.");
|
|
644
|
+
exchange.replied = true;
|
|
645
|
+
exchange.live = exchange.protocol && info.body && status === 200 && new Headers(info.headers).get(PROTOCOL_HEADER) === "1";
|
|
646
|
+
touch(exchange);
|
|
647
|
+
exchange.request.resolve(relayResponse(info.body ? receiveBody(exchange) : null, {
|
|
648
|
+
status,
|
|
649
|
+
headers: info.headers
|
|
650
|
+
}));
|
|
651
|
+
if (!info.body) finish(exchange);
|
|
652
|
+
} else {
|
|
653
|
+
const body = exchange.incoming;
|
|
654
|
+
if (!body || !body.granted || frame.sequence !== body.expected) throw new Error("Invalid relay body sequence.");
|
|
655
|
+
body.granted = false;
|
|
656
|
+
body.expected += 1;
|
|
657
|
+
if (frame.kind === "chunk") {
|
|
658
|
+
body.size += frame.payload.byteLength;
|
|
659
|
+
if (body.size > MAX_BODY) throw new Error("Private relay body exceeds its size limit.");
|
|
660
|
+
body.controller?.enqueue(frame.payload);
|
|
661
|
+
} else {
|
|
662
|
+
body.controller?.close();
|
|
663
|
+
exchange.incoming = void 0;
|
|
664
|
+
if (!serve) finish(exchange);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
return {
|
|
669
|
+
receive(bytes) {
|
|
670
|
+
if (closed) return;
|
|
671
|
+
if (bytes.byteLength > 131068 || ++receiving > MAX_PENDING_RECORDS) {
|
|
672
|
+
fail(/* @__PURE__ */ new Error("Private relay receive limit exceeded."));
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
incoming.run(async () => {
|
|
676
|
+
if (closed) return;
|
|
677
|
+
const opened = await channel.open(relayObject(bytes, PRIVATE_RELAY_WIRE_BYTES));
|
|
678
|
+
if (closed) return;
|
|
679
|
+
const frame = opened.ok ? decodePrivateRelayFrame(opened.plaintext) : void 0;
|
|
680
|
+
if (!frame) throw new Error("Private relay frame authentication failed.");
|
|
681
|
+
dispatch(frame);
|
|
682
|
+
}).catch(fail).finally(() => {
|
|
683
|
+
receiving -= 1;
|
|
684
|
+
});
|
|
685
|
+
},
|
|
686
|
+
async fetch(request, bodyOverride) {
|
|
687
|
+
request.signal?.throwIfAborted();
|
|
688
|
+
if (closed || serve || exchanges.size >= MAX_EXCHANGES || highestId >= 4294967295) throw new Error("Private relay transport is unavailable or busy.");
|
|
689
|
+
const url = new URL(request.url);
|
|
690
|
+
if (url.origin !== origin || url.hash || url.username || url.password) throw new Error("Private relay request is not for this host.");
|
|
691
|
+
const target = url.pathname + url.search;
|
|
692
|
+
targetUrl(origin, target);
|
|
693
|
+
const headers = [];
|
|
694
|
+
request.headers.forEach((value, name) => headers.push([name, value]));
|
|
695
|
+
const body = bodyOverride ?? request.body ?? null;
|
|
696
|
+
const payload = metadata({
|
|
697
|
+
method: request.method,
|
|
698
|
+
target,
|
|
699
|
+
headers,
|
|
700
|
+
body: !!body
|
|
701
|
+
});
|
|
702
|
+
return await new Promise((resolve, reject) => {
|
|
703
|
+
const exchange = {
|
|
704
|
+
id: ++highestId,
|
|
705
|
+
abort: new AbortController(),
|
|
706
|
+
protocol: request.method === "POST" && target === PROTOCOL_ROUTE,
|
|
707
|
+
request: {
|
|
708
|
+
method: request.method,
|
|
709
|
+
resolve,
|
|
710
|
+
reject
|
|
711
|
+
}
|
|
712
|
+
};
|
|
713
|
+
offerBody(exchange, body);
|
|
714
|
+
const abort = () => cancel(exchange, /* @__PURE__ */ new Error("Private relay request aborted. The outcome of an in-flight write may be unknown."));
|
|
715
|
+
request.signal?.addEventListener("abort", abort, { once: true });
|
|
716
|
+
exchange.cleanup = () => request.signal?.removeEventListener("abort", abort);
|
|
717
|
+
exchanges.set(exchange.id, exchange);
|
|
718
|
+
touch(exchange);
|
|
719
|
+
send({
|
|
720
|
+
kind: "request",
|
|
721
|
+
exchangeId: exchange.id,
|
|
722
|
+
sequence: 0,
|
|
723
|
+
payload
|
|
724
|
+
});
|
|
725
|
+
});
|
|
726
|
+
},
|
|
727
|
+
dispose
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
//#endregion
|
|
731
|
+
//#region ../../core/po-web-security/src/services/privateRelay/client.ts
|
|
732
|
+
const MAX_BUFFERED_BYTES = 1048576;
|
|
733
|
+
const trustError = (message) => Object.assign(new Error(message), { code: "ERR_PO_RELAY_TRUST" });
|
|
734
|
+
/** Runs the same host proof on a socket already admitted and opened by the broker. */
|
|
735
|
+
function connectAdmittedPrivateRelay(options, socket) {
|
|
736
|
+
return connect(options, void 0, socket);
|
|
737
|
+
}
|
|
738
|
+
async function connect(options, dial, admitted) {
|
|
739
|
+
options.signal?.throwIfAborted();
|
|
740
|
+
const endpoint = relayAddress(options);
|
|
741
|
+
if (dial && !/^[\w-]{43}$/u.test(dial.capability)) throw trustError("Invalid private relay capability.");
|
|
742
|
+
endpoint.protocol = "wss:";
|
|
743
|
+
endpoint.search = "?role=client";
|
|
744
|
+
const client = await prepareSealedChannel();
|
|
745
|
+
const nonce = btoa(String.fromCharCode(...crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(32)))).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
|
|
746
|
+
options.signal?.throwIfAborted();
|
|
747
|
+
return await new Promise((resolve, reject) => {
|
|
748
|
+
const browserSocket = admitted ? void 0 : new ((dial?.Socket) ?? WebSocket)(endpoint.href);
|
|
749
|
+
const socket = admitted ?? browserSocket;
|
|
750
|
+
if (browserSocket) browserSocket.binaryType = "arraybuffer";
|
|
751
|
+
let phase = dial ? "join" : "channel";
|
|
752
|
+
let exchange;
|
|
753
|
+
let closed = false;
|
|
754
|
+
const timer = setTimeout(() => close(/* @__PURE__ */ new Error("Private relay connection timed out.")), PRIVATE_RELAY_HANDSHAKE_MS);
|
|
755
|
+
const abort = () => close(/* @__PURE__ */ new Error("Private relay connection cancelled."));
|
|
756
|
+
options.signal?.addEventListener("abort", abort, { once: true });
|
|
757
|
+
function clearHandshake() {
|
|
758
|
+
clearTimeout(timer);
|
|
759
|
+
options.signal?.removeEventListener("abort", abort);
|
|
760
|
+
}
|
|
761
|
+
function close(error = /* @__PURE__ */ new Error("Private relay disconnected. The outcome of an in-flight write may be unknown.")) {
|
|
762
|
+
if (closed) return;
|
|
763
|
+
closed = true;
|
|
764
|
+
clearHandshake();
|
|
765
|
+
exchange?.dispose(error);
|
|
766
|
+
reject(error);
|
|
767
|
+
socket.close();
|
|
768
|
+
}
|
|
769
|
+
function send(data) {
|
|
770
|
+
if (closed || socket.readyState !== 1 || (socket.bufferedAmount ?? 0) > MAX_BUFFERED_BYTES) throw new Error("Private relay socket unavailable.");
|
|
771
|
+
socket.send(Uint8Array.from(data).buffer);
|
|
772
|
+
}
|
|
773
|
+
const hello = () => send(relayEncoder.encode(JSON.stringify({
|
|
774
|
+
type: "hello",
|
|
775
|
+
clientKey: client.publicKey,
|
|
776
|
+
nonce
|
|
777
|
+
})));
|
|
778
|
+
async function receive(data) {
|
|
779
|
+
if (closed) return;
|
|
780
|
+
if (phase === "join") {
|
|
781
|
+
if (typeof data !== "string" || relayObject(data, 128).type !== "ready") throw trustError("Private relay join refused.");
|
|
782
|
+
phase = "channel";
|
|
783
|
+
hello();
|
|
784
|
+
return;
|
|
785
|
+
}
|
|
786
|
+
if (!(data instanceof ArrayBuffer)) throw new Error("Private relay refused a non-binary message.");
|
|
787
|
+
const bytes = new Uint8Array(data);
|
|
788
|
+
if (exchange) return exchange.receive(bytes);
|
|
789
|
+
if (phase !== "channel") throw new Error("Unexpected private relay handshake message.");
|
|
790
|
+
phase = "verifying";
|
|
791
|
+
const { type, hostKey, signature } = relayObject(bytes, 512);
|
|
792
|
+
if (type !== "channel" || typeof hostKey !== "string" || !/^[\w-]{87}$/u.test(hostKey) || typeof signature !== "string" || !await verifyAttestation(options.signer, "po/private-relay-channel/v1", [
|
|
793
|
+
options.origin,
|
|
794
|
+
options.route,
|
|
795
|
+
nonce,
|
|
796
|
+
client.publicKey,
|
|
797
|
+
hostKey
|
|
798
|
+
], signature)) throw trustError("Private relay host identity did not match the paired signer.");
|
|
799
|
+
const channel = await client.accept(hostKey);
|
|
800
|
+
if (!channel) throw new Error("Private relay could not establish encryption.");
|
|
801
|
+
if (closed) return;
|
|
802
|
+
clearHandshake();
|
|
803
|
+
const connected = createPrivateRelayExchange(options.origin, channel, {
|
|
804
|
+
send,
|
|
805
|
+
fail: close
|
|
806
|
+
});
|
|
807
|
+
exchange = connected;
|
|
808
|
+
resolve({
|
|
809
|
+
async fetch(input, init) {
|
|
810
|
+
if (typeof input === "string" && input.startsWith("//")) throw new Error("Invalid private relay request target.");
|
|
811
|
+
const target = typeof input === "string" && input.startsWith("/") ? new URL(input, options.origin) : input;
|
|
812
|
+
const stream = init?.body instanceof ReadableStream ? init.body : void 0;
|
|
813
|
+
const request = new Request(target, {
|
|
814
|
+
...init,
|
|
815
|
+
...stream ? { body: null } : {},
|
|
816
|
+
duplex: "half",
|
|
817
|
+
redirect: admitted ? "manual" : "error"
|
|
818
|
+
});
|
|
819
|
+
if (stream) return await connected.fetch(request, stream);
|
|
820
|
+
if (request.body === void 0 && request.method !== "GET" && request.method !== "HEAD") {
|
|
821
|
+
const body = new ReadableStream({ async start(controller) {
|
|
822
|
+
const bytes = new Uint8Array(await request.arrayBuffer());
|
|
823
|
+
if (bytes.byteLength) controller.enqueue(bytes);
|
|
824
|
+
controller.close();
|
|
825
|
+
} });
|
|
826
|
+
return await connected.fetch(request, body);
|
|
827
|
+
}
|
|
828
|
+
return await connected.fetch(request);
|
|
829
|
+
},
|
|
830
|
+
alive: () => !closed && socket.readyState === 1,
|
|
831
|
+
close: () => close()
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
const onMessage = ({ data }) => void receive(data).catch((error) => close(error instanceof Error ? error : void 0));
|
|
835
|
+
const onClose = (event) => close(event?.code === 1008 && !exchange ? trustError("Private relay join refused.") : void 0);
|
|
836
|
+
const onError = (code) => close(code === "ERR_PO_RELAY_TRUST" ? trustError("Private relay TLS or redirect refused.") : /* @__PURE__ */ new Error("Private relay connection failed."));
|
|
837
|
+
if (admitted) {
|
|
838
|
+
admitted.addEventListener("message", onMessage);
|
|
839
|
+
admitted.addEventListener("close", onClose);
|
|
840
|
+
admitted.addEventListener("error", () => onError());
|
|
841
|
+
try {
|
|
842
|
+
hello();
|
|
843
|
+
} catch (error) {
|
|
844
|
+
close(error instanceof Error ? error : void 0);
|
|
845
|
+
}
|
|
846
|
+
} else if (browserSocket && dial) {
|
|
847
|
+
browserSocket.onmessage = onMessage;
|
|
848
|
+
browserSocket.onclose = onClose;
|
|
849
|
+
browserSocket.onerror = (event) => onError("code" in event ? event.code : void 0);
|
|
850
|
+
browserSocket.onopen = () => {
|
|
851
|
+
if (closed) return;
|
|
852
|
+
try {
|
|
853
|
+
if (browserSocket.url !== endpoint.href) throw trustError("Private relay socket redirected.");
|
|
854
|
+
browserSocket.send(JSON.stringify({
|
|
855
|
+
type: "join",
|
|
856
|
+
capability: dial.capability
|
|
857
|
+
}));
|
|
858
|
+
} catch (error) {
|
|
859
|
+
close(error instanceof Error ? error : void 0);
|
|
860
|
+
}
|
|
861
|
+
};
|
|
862
|
+
}
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
//#endregion
|
|
866
|
+
//#region ../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/webAuthnAbortService.js
|
|
867
|
+
var BaseWebAuthnAbortService = class {
|
|
868
|
+
constructor() {
|
|
869
|
+
Object.defineProperty(this, "controller", {
|
|
870
|
+
enumerable: true,
|
|
871
|
+
configurable: true,
|
|
872
|
+
writable: true,
|
|
873
|
+
value: void 0
|
|
874
|
+
});
|
|
875
|
+
}
|
|
876
|
+
createNewAbortSignal() {
|
|
877
|
+
if (this.controller) {
|
|
878
|
+
const abortError = /* @__PURE__ */ new Error("Cancelling existing WebAuthn API call for new one");
|
|
879
|
+
abortError.name = "AbortError";
|
|
880
|
+
this.controller.abort(abortError);
|
|
881
|
+
}
|
|
882
|
+
const newController = new AbortController();
|
|
883
|
+
this.controller = newController;
|
|
884
|
+
return newController.signal;
|
|
885
|
+
}
|
|
886
|
+
cancelCeremony() {
|
|
887
|
+
if (this.controller) {
|
|
888
|
+
const abortError = /* @__PURE__ */ new Error("Manually cancelling existing WebAuthn API call");
|
|
889
|
+
abortError.name = "AbortError";
|
|
890
|
+
this.controller.abort(abortError);
|
|
891
|
+
this.controller = void 0;
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
};
|
|
895
|
+
new BaseWebAuthnAbortService();
|
|
896
|
+
//#endregion
|
|
897
|
+
export { isSignedBundleManifest as a, attestationBytes as i, verifyAttestation as n, BUNDLE_MANIFEST_ROUTE as r, connectAdmittedPrivateRelay as t };
|