@hot-updater/console 1.2.0-rc.12 → 1.2.0-rc.13
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/.output/nitro.json +1 -1
- package/.output/public/assets/{-native-builds-search-C-TGpFAm.js → -native-builds-search-DC2PutLU.js} +1 -1
- package/.output/public/assets/{ConsoleFeatureUnavailable-CUtcXuY2.js → ConsoleFeatureUnavailable-oMmbaqF6.js} +1 -1
- package/.output/public/assets/{EventDetails-Dl2RvPAk.js → EventDetails-ly7ygfdH.js} +1 -1
- package/.output/public/assets/{HashValueDisplay-6lNRxDJX.js → HashValueDisplay-BNoXZADg.js} +1 -1
- package/.output/public/assets/{InsightsPageHeader-DHhqY3DT.js → InsightsPageHeader-q2FgL8xS.js} +1 -1
- package/.output/public/assets/RolloutPercentageBadge-frllRncE.js +1 -0
- package/.output/public/assets/{StoreSubmission-ViTkW4eJ.js → StoreSubmission-D8BGGGgn.js} +1 -1
- package/.output/public/assets/api-BEEYDSCX.js +1 -0
- package/.output/public/assets/{api-keys-FueRkF9q.js → api-keys-B0N3SixL.js} +1 -1
- package/.output/public/assets/api-keys-DFAOfU4U.js +1 -0
- package/.output/public/assets/{index-DH9-mB8D.js → index-t0CToN0S.js} +3 -3
- package/.output/public/assets/insights-B0_8xNxr.js +1 -0
- package/.output/public/assets/{insights-B-0odqpt.js → insights-BbIzm_QG.js} +2 -2
- package/.output/public/assets/insights-BtmYg4vg.js +2 -0
- package/.output/public/assets/{insights-search-DghCbEnk.js → insights-search-B5cZsP6C.js} +1 -1
- package/.output/public/assets/{insights-usage-rpc-CKQH0pUS.js → insights-usage-rpc-zut_JaSS.js} +1 -1
- package/.output/public/assets/insights_.distribution-DLxq-IKU.js +1 -0
- package/.output/public/assets/insights_.distribution-izFBYfJL.js +2 -0
- package/.output/public/assets/{insights_.distribution-dvk6vYDM.js → insights_.distribution-rdeyNhH2.js} +1 -1
- package/.output/public/assets/{installations-B674P5Z5.js → installations-BRS-vuRJ.js} +2 -2
- package/.output/public/assets/installations-CWx7vYY5.js +1 -0
- package/.output/public/assets/{installations-BWxczZ2t.js → installations-Ce_dTa35.js} +1 -1
- package/.output/public/assets/native-builds-Br0onFRc.js +2 -0
- package/.output/public/assets/native-builds-CDYL3y0I.js +1 -0
- package/.output/public/assets/native-builds-DEWHul-_.js +1 -0
- package/.output/public/assets/native-builds_._buildId-D1XEPQ-V.js +1 -0
- package/.output/public/assets/native-builds_._buildId-x-uu1Vbr.js +2 -0
- package/.output/public/assets/{remote-config-B7ujqhLa.js → remote-config-Bw6sErCV.js} +3 -3
- package/.output/public/assets/{remote-config-WjpozBG5.js → remote-config-DQguWTMa.js} +1 -1
- package/.output/public/assets/remote-config-S3xj8r3x.js +1 -0
- package/.output/public/assets/{routes-CCD33Azv.js → routes-Dw8zgqXz.js} +2 -2
- package/.output/public/assets/routes-nKCEKnhh.js +1 -0
- package/.output/server/{__23tanstack-start-server-fn-resolver-C19x6erS.mjs → __23tanstack-start-server-fn-resolver-DI0OnlQe.mjs} +58 -46
- package/.output/server/_libs/@tanstack/react-router-ssr-query+[...].mjs +1 -1
- package/.output/server/_libs/_.mjs +2 -0
- package/.output/server/_ssr/{-native-builds-search-CwNcoXf4.mjs → -native-builds-search-Cl8EZ0Ud.mjs} +2 -2
- package/.output/server/_ssr/{BundleIdDisplay-Bf-L37zf.mjs → BundleIdDisplay-SAvC-NlE.mjs} +2 -2
- package/.output/server/_ssr/{ConsoleFeatureUnavailable-iNGya64h.mjs → ConsoleFeatureUnavailable-BgHEoZ36.mjs} +6 -6
- package/.output/server/_ssr/{EventDetails-CZofL6Hn.mjs → EventDetails-VaS25yjE.mjs} +7 -7
- package/.output/server/_ssr/{HashValueDisplay-DC1TLS-8.mjs → HashValueDisplay-BGc-x_l8.mjs} +2 -2
- package/.output/server/_ssr/{InsightsPageHeader-sVotAhl0.mjs → InsightsPageHeader-gMuNJt-f.mjs} +7 -7
- package/.output/server/_ssr/{NotFoundPage-COb0erGp.mjs → NotFoundPage-DsRI-J4h.mjs} +2 -2
- package/.output/server/_ssr/{PlatformIcon-CFLiTjh1.mjs → PlatformIcon-BsU0d0jN.mjs} +1 -1
- package/.output/server/_ssr/{RolloutPercentageBadge-BFBh0QWv.mjs → RolloutPercentageBadge-axz7VuIZ.mjs} +3 -3
- package/.output/server/_ssr/{StoreSubmission-Bvfq8pWk.mjs → StoreSubmission-BqXKtpqW.mjs} +5 -5
- package/.output/server/_ssr/{alert-dialog-C-Mck8_M.mjs → alert-dialog-lury59vV.mjs} +1 -1
- package/.output/server/_ssr/{api-oJajV-DG.mjs → api-BQ8ztUgU.mjs} +99 -22
- package/.output/server/_ssr/{api-keys-CcqDkOcC.mjs → api-keys-CHATVpa9.mjs} +2 -2
- package/.output/server/_ssr/{api-keys-B0L1sj-W.mjs → api-keys-DVChzF3r.mjs} +8 -8
- package/.output/server/_ssr/{api-keys-rpc-Do6Rbl0V.mjs → api-keys-rpc-DXPJTfdr.mjs} +4 -4
- package/.output/server/_ssr/{api-rpc-DE0zy7iY.mjs → api-rpc-BexxmTM9.mjs} +43 -18
- package/.output/server/_ssr/{auth-rpc-0I_10FKy.mjs → auth-rpc-BgNCvy2L.mjs} +5 -5
- package/.output/server/_ssr/{auth.server-cdIC1rxo.mjs → auth.server-43UW34Rd.mjs} +165 -149
- package/.output/server/_ssr/{badge-BZZCX8Wn.mjs → badge-BYB825vl.mjs} +1 -1
- package/.output/server/_ssr/{bundleActivity-MLrjNJCT.mjs → bundleActivity-BGVvqWx7.mjs} +1 -1
- package/.output/server/_ssr/{config.server-CydWUX0c.mjs → config.server-QRTmD4Hf.mjs} +4 -4
- package/.output/server/_ssr/{console-access-y52SJdFn.mjs → console-access-E91fYTIB.mjs} +2 -2
- package/.output/server/_ssr/{console-features-BTV-XuhQ.mjs → console-features-CgdQJQlX.mjs} +1 -1
- package/.output/server/_ssr/{console-features-api-BDrXaElT.mjs → console-features-api-CLRjxvy2.mjs} +5 -5
- package/.output/server/_ssr/{console-features-rpc-C9kKIDeK.mjs → console-features-rpc-C2rJ0u6i.mjs} +4 -4
- package/.output/server/_ssr/{createServerRpc-BVvRVOz5.mjs → createServerRpc-DJZel12M.mjs} +1 -1
- package/.output/server/_ssr/{databaseConfig-B_Bg7qS5.mjs → databaseConfig-XAvDetmn.mjs} +1 -1
- package/.output/server/_ssr/{databaseJsonValue-kS7cvEtz.mjs → databaseJsonValue-DuUoft8j.mjs} +1 -1
- package/.output/server/_ssr/{databaseRows-B6H8Cmgq.mjs → databaseRows-BtRVBD0C.mjs} +3 -3
- package/.output/server/_ssr/{dialog-DKsDLcYQ.mjs → dialog-CcF1pxfR.mjs} +1 -1
- package/.output/server/_ssr/{dist-TEpM_UAD.mjs → dist-B6-irDRA.mjs} +1 -1
- package/.output/server/_ssr/{downloadBundle-DCmr7vsj.mjs → downloadBundle-BX8ODCZT.mjs} +1 -1
- package/.output/server/_ssr/{empty-D-mnqnCP.mjs → empty-DkiJ7nWt.mjs} +2 -2
- package/.output/server/_ssr/{empty-plugin-adapters-zrZ0xs6n.mjs → empty-plugin-adapters-BYBYBaxo.mjs} +1 -1
- package/.output/server/_ssr/{failureReports-Cn_zU9S8.mjs → failureReports-C_CmBF4x.mjs} +3 -3
- package/.output/server/_ssr/{field-Bbw5SS9L.mjs → field-CHlDI06h.mjs} +2 -2
- package/.output/server/_ssr/{getBundleChildren-rtkEEJw5.mjs → getBundleChildren-BJTufthT.mjs} +2 -2
- package/.output/server/_ssr/{git-CTA8Aqr0.mjs → git-WSg7LY17.mjs} +2 -2
- package/.output/server/_ssr/{input-group-DXofNRNJ.mjs → input-group-BPZ4UtB5.mjs} +1 -1
- package/.output/server/_ssr/{insights-Dm2UdEf_.mjs → insights-B3YetvBK.mjs} +5 -5
- package/.output/server/_ssr/{insights-C7rhyg61.mjs → insights-CEABWFk4.mjs} +26 -26
- package/.output/server/_ssr/{insights-D6kIjZuE.mjs → insights-Dn32lJ18.mjs} +2 -2
- package/.output/server/_ssr/{insights-api-DNmt4PWL.mjs → insights-api-CYPf5853.mjs} +5 -5
- package/.output/server/_ssr/{insights-errors-7BCwFybo.mjs → insights-errors-Bz3sWNZm.mjs} +2 -2
- package/.output/server/_ssr/{insights-failures-B9VPkzZE.mjs → insights-failures-DNQ9qVVf.mjs} +2 -2
- package/.output/server/_ssr/{insights-failures-rpc-DkrdYXJk.mjs → insights-failures-rpc-CxPpBR1K.mjs} +11 -11
- package/.output/server/_ssr/{insights-recovery-BtXVU3ro.mjs → insights-recovery-DOkpqnQ8.mjs} +1 -1
- package/.output/server/_ssr/{insights-recovery-rpc-DWLnLF_s.mjs → insights-recovery-rpc-CwnQMTE3.mjs} +7 -7
- package/.output/server/_ssr/{insights-rpc-CdYYZ7lE.mjs → insights-rpc-CKd5ATFI.mjs} +4 -4
- package/.output/server/_ssr/{insights-search-HVXIz64-.mjs → insights-search-B_92_iEj.mjs} +4 -4
- package/.output/server/_ssr/{insights-usage-DiGnuxW8.mjs → insights-usage-4KDIN3Kg.mjs} +1 -1
- package/.output/server/_ssr/{insights-usage-rpc-CLHS5JhI.mjs → insights-usage-rpc-D90uHpJJ.mjs} +7 -7
- package/.output/server/_ssr/{insights-usage-rpc-BCMRZErp.mjs → insights-usage-rpc-RIMNhPtj.mjs} +4 -4
- package/.output/server/_ssr/{insightsUsage-ClAmoUz8.mjs → insightsUsage-DmQdJZqT.mjs} +3 -3
- package/.output/server/_ssr/{insights_.distribution-zbVsH0TU.mjs → insights_.distribution-D42mHSe0.mjs} +14 -14
- package/.output/server/_ssr/{insights_.distribution-3NzANTBS.mjs → insights_.distribution-D4QWsHNo.mjs} +5 -5
- package/.output/server/_ssr/{insights_.distribution-BTbT0Z4H.mjs → insights_.distribution-DwjIdjQi.mjs} +2 -2
- package/.output/server/_ssr/{installations-BsCupWHx.mjs → installations-BIu66J6Q.mjs} +2 -2
- package/.output/server/_ssr/{installations-3XOT2V1j.mjs → installations-CfmO_V_R.mjs} +4 -4
- package/.output/server/_ssr/{installations-CpjqEYh_.mjs → installations-DyzKzWuv.mjs} +11 -11
- package/.output/server/_ssr/{listReleases-D_GY00SQ.mjs → listReleases-CQEceg8j.mjs} +1 -1
- package/.output/server/_ssr/{request-guard-CPdRBuGW.mjs → local-console-Dtxlsav0.mjs} +2 -9
- package/.output/server/_ssr/native-artifact-H1MDP0Jz.mjs +593 -0
- package/.output/server/_ssr/{native-builds-CehTsEwY.mjs → native-builds-BCp8ICrn.mjs} +3 -3
- package/.output/server/_ssr/{native-builds-vYKOMlhp.mjs → native-builds-CqFeXByK.mjs} +17 -13
- package/.output/server/_ssr/{native-builds-DhXL5zf_.mjs → native-builds-qj346atQ.mjs} +49 -12
- package/.output/server/_ssr/{native-builds_._buildId-BHxp9NcZ.mjs → native-builds_._buildId-BAxkkEFo.mjs} +600 -168
- package/.output/server/_ssr/{native-builds_._buildId-euhJ0EI7.mjs → native-builds_._buildId-C8gsW-Rh.mjs} +3 -3
- package/.output/server/_ssr/nativeBuildDevice-nU480p5A.mjs +230 -0
- package/.output/server/_ssr/nativeBuildDownloadLink-c3tcq3G5.mjs +96 -0
- package/.output/server/_ssr/nativeBuildInstall-B-_lHDsS.mjs +203 -0
- package/.output/server/_ssr/nativeBuildQr-C5AFtpmE.mjs +115 -0
- package/.output/server/_ssr/{nativeBuilds-B_7BPjt_.mjs → nativeBuilds-CbxOJDhO.mjs} +61 -29
- package/.output/server/_ssr/{plugins-RIryUNWj.mjs → plugins-CX7wutet.mjs} +6 -6
- package/.output/server/_ssr/publicConsoleBase-3IHSHvqd.mjs +27 -0
- package/.output/server/_ssr/{qr-code-C7kNRIDX.mjs → qr-code-pENFuyy9.mjs} +1 -1
- package/.output/server/_ssr/{release-adoption-DoAtNPED.mjs → release-adoption-C7sUFDwa.mjs} +2 -2
- package/.output/server/_ssr/{release-adoption-rpc-BF8svHjV.mjs → release-adoption-rpc-BBwJO2hu.mjs} +9 -9
- package/.output/server/_ssr/{releaseAdoption-a2byXMfz.mjs → releaseAdoption-LLYlRnUB.mjs} +4 -4
- package/.output/server/_ssr/{releaseCatalogCompiler-DLcean2k.mjs → releaseCatalogCompiler-D9dAMI17.mjs} +3 -3
- package/.output/server/_ssr/{releaseManagement-DHUux2az.mjs → releaseManagement-EPhok_Py.mjs} +1 -1
- package/.output/server/_ssr/{releaseReachability-DZOK_dH-.mjs → releaseReachability-DaZ7ifUF.mjs} +2 -2
- package/.output/server/_ssr/{remote-config-Bn-BZgDt.mjs → remote-config-B1g7vrQD.mjs} +2 -2
- package/.output/server/_ssr/{remote-config-ofOYh91b.mjs → remote-config-BDijmvj1.mjs} +2 -2
- package/.output/server/_ssr/{remote-config-DdukdePk.mjs → remote-config-DjeXVIcr.mjs} +18 -18
- package/.output/server/_ssr/{remote-config-rpc-CzSU_Gwg.mjs → remote-config-rpc-B7bzKw4N.mjs} +5 -5
- package/.output/server/_ssr/request-guard-BPLyogIN.mjs +11 -0
- package/.output/server/_ssr/{router-BQikCEhb.mjs → router-DhxgFNWn.mjs} +101 -50
- package/.output/server/_ssr/{routes-Brx45XtQ.mjs → routes-BC-rBuu_.mjs} +25 -25
- package/.output/server/_ssr/{routes-CTo-A_dj.mjs → routes-BDriEBtF.mjs} +12 -12
- package/.output/server/_ssr/{runtime.server-BdMY1blX.mjs → runtime.server-BsTTLV-B.mjs} +4 -4
- package/.output/server/_ssr/{schema-ChlRtZIo.mjs → schema-3oDJJFWa.mjs} +1 -1
- package/.output/server/_ssr/{schema-migration-rpc-BcwNAFZJ.mjs → schema-migration-rpc-CNMqY0RE.mjs} +4 -4
- package/.output/server/_ssr/{select-Dk_Yv0IG.mjs → select-hFD2e3Bh.mjs} +1 -1
- package/.output/server/_ssr/{server-b1jUGuT2.mjs → server-D_hG9iIq.mjs} +6 -6
- package/.output/server/_ssr/{sidebar-CsRdKfb2.mjs → sidebar-Dmq4j1qr.mjs} +2 -2
- package/.output/server/_ssr/ssr.mjs +1 -1
- package/.output/server/_ssr/{start-BvDsQehg.mjs → start-RjhaPVFE.mjs} +2 -2
- package/.output/server/_ssr/{switch-DpYvZqIf.mjs → switch-CkNsEp9k.mjs} +2 -2
- package/.output/server/_ssr/{table-BAP-tdNn.mjs → table-CTtXogFJ.mjs} +1 -1
- package/.output/server/_ssr/{tabs-DGN9JEGV.mjs → tabs-BTKDM4AJ.mjs} +2 -2
- package/.output/server/_ssr/{updateFailures-n-tGv90S.mjs → updateFailures-DPYzv9bE.mjs} +3 -3
- package/.output/server/_ssr/{uuidv7-BIF4nb_q.mjs → uuidv7-CmHbryZT.mjs} +2 -2
- package/.output/server/_ssr/{version-CQ98ZBpL-CWSkTT9J.mjs → version-CQ98ZBpL-NmbU0MD2.mjs} +1 -1
- package/.output/server/_tanstack-start-manifest_v-BuGAtKIu.mjs +189 -0
- package/.output/server/index.mjs +275 -275
- package/package.json +7 -7
- package/src/components/features/native-builds/BuiltInBundleCard.tsx +82 -33
- package/src/components/features/native-builds/InstallCard.tsx +246 -46
- package/src/components/features/native-builds/IosInstall.tsx +300 -0
- package/src/components/features/native-builds/NativeBuildsTable.tsx +3 -0
- package/src/components/features/native-builds/PatchesCard.tsx +3 -2
- package/src/components/features/native-builds/ReleaseNativeBuildLink.tsx +4 -4
- package/src/components/features/native-builds/ServedNowCard.tsx +33 -1
- package/src/components/features/native-builds/StoreSubmission.tsx +1 -1
- package/src/lib/api-rpc.ts +55 -6
- package/src/lib/api.ts +85 -12
- package/src/lib/native-builds.ts +73 -11
- package/src/lib/server/local-console.ts +1 -1
- package/src/lib/server/nativeBuildDevice.ts +274 -0
- package/src/lib/server/nativeBuildDownloadLink.ts +193 -0
- package/src/lib/server/nativeBuildInstall.ts +355 -0
- package/src/lib/server/nativeBuildQr.ts +114 -24
- package/src/lib/server/nativeBuilds.ts +87 -33
- package/src/lib/server/plistText.ts +17 -0
- package/src/lib/server/publicConsoleBase.ts +17 -0
- package/src/routeTree.gen.ts +114 -0
- package/src/routes/[_]hot-updater/native-builds/$buildId/device-response.ts +17 -0
- package/src/routes/[_]hot-updater/native-builds/$buildId/device.ts +17 -0
- package/src/routes/[_]hot-updater/native-builds/$buildId/device[.]mobileconfig.ts +17 -0
- package/src/routes/[_]hot-updater/native-builds/$buildId/manifest[.]plist.ts +22 -0
- package/src/routes/[_]hot-updater/native-builds/preview-qr.ts +14 -0
- package/src/routes/api/native-builds/$buildId/download.ts +22 -1
- package/.output/public/assets/RolloutPercentageBadge-Cxogpi8F.js +0 -1
- package/.output/public/assets/api-P2g8dCNg.js +0 -1
- package/.output/public/assets/api-keys-DWQC2q6y.js +0 -1
- package/.output/public/assets/insights-BSVGfxSL.js +0 -1
- package/.output/public/assets/insights-NK5B6ReS.js +0 -2
- package/.output/public/assets/insights_.distribution-CJvgwcVZ.js +0 -2
- package/.output/public/assets/insights_.distribution-DblZM0mO.js +0 -1
- package/.output/public/assets/installations-Dv4kWQYz.js +0 -1
- package/.output/public/assets/native-builds-BGgFQTDW.js +0 -2
- package/.output/public/assets/native-builds-BOC71grI.js +0 -1
- package/.output/public/assets/native-builds-CxomzFqe.js +0 -1
- package/.output/public/assets/native-builds_._buildId-DD58_Phd.js +0 -1
- package/.output/public/assets/native-builds_._buildId-DvQDKnUQ.js +0 -2
- package/.output/public/assets/remote-config-gXeH6PBW.js +0 -1
- package/.output/public/assets/routes-BDdBIxYS.js +0 -1
- package/.output/server/_ssr/nativeBuildQr-84cnFQPX.mjs +0 -59
- package/.output/server/_tanstack-start-manifest_v-uhJWytDm.mjs +0 -184
- /package/.output/public/assets/{NotFoundPage-DZ3DxyRA.js → NotFoundPage-fiaucvsO.js} +0 -0
- /package/.output/public/assets/{PlatformIcon-BBWQlWm9.js → PlatformIcon-DCTtCP5t.js} +0 -0
- /package/.output/public/assets/{alert-dialog-BqYScr9y.js → alert-dialog-Z_RNBrFc.js} +0 -0
- /package/.output/public/assets/{badge-DWFcDWho.js → badge-UNnTz4Dl.js} +0 -0
- /package/.output/public/assets/{dialog-CNUPxNxH.js → dialog-C2U9bINi.js} +0 -0
- /package/.output/public/assets/{dist-CPlO6ko9.js → dist-UQUhRoJi.js} +0 -0
- /package/.output/public/assets/{empty-B3Uwdd6k.js → empty-PAp07lsC.js} +0 -0
- /package/.output/public/assets/{field-D-2-mnNh.js → field-DhKRWFG5.js} +0 -0
- /package/.output/public/assets/{history-DqHlgSuV.js → history-DakJoeSM.js} +0 -0
- /package/.output/public/assets/{input-group-D3OUBk4n.js → input-group-BJfBVqeI.js} +0 -0
- /package/.output/public/assets/{key-round-DwNKkHhy.js → key-round-DzBe6DHr.js} +0 -0
- /package/.output/public/assets/{list--NIee1FZ.js → list-B6GeoQ_b.js} +0 -0
- /package/.output/public/assets/{plus-BReVKct-.js → plus-BVhOauU3.js} +0 -0
- /package/.output/public/assets/{refresh-cw-B9HHjLej.js → refresh-cw-C6svDMfM.js} +0 -0
- /package/.output/public/assets/{relativeTime-YQt84dYr.js → relativeTime-BscR0TsX.js} +0 -0
- /package/.output/public/assets/{rotate-cw-Cv2aVbYr.js → rotate-cw-CxFW64IG.js} +0 -0
- /package/.output/public/assets/{search-BCel4Oy6.js → search-bIYGuFCt.js} +0 -0
- /package/.output/public/assets/{smartphone-CMaSy_ir.js → smartphone-Bn5FtEwt.js} +0 -0
- /package/.output/public/assets/{switch-BpdiHL_t.js → switch-DtUu1RCw.js} +0 -0
- /package/.output/public/assets/{table-Bpy3SvSo.js → table-B22H8-RL.js} +0 -0
- /package/.output/public/assets/{tabs-Xmt7tZeG.js → tabs-Fgz3sA51.js} +0 -0
- /package/.output/public/assets/{undo-2-CUX96_BG.js → undo-2-7gOxArtb.js} +0 -0
- /package/.output/public/assets/{uuidv7-zXMtwR9Q.js → uuidv7-BLyD3pAM.js} +0 -0
- /package/.output/public/assets/{valueToPercent-BLwGy_xK.js → valueToPercent-DRLgSP0P.js} +0 -0
package/src/lib/native-builds.ts
CHANGED
|
@@ -31,10 +31,78 @@ export const platformLabel = (platform: "ios" | "android") =>
|
|
|
31
31
|
export const nativeBuildDownloadPath = (id: string) =>
|
|
32
32
|
`/api/native-builds/${encodeURIComponent(id)}/download`;
|
|
33
33
|
|
|
34
|
+
/** The query parameter of a signed download link: its token. */
|
|
35
|
+
export const NATIVE_BUILD_DOWNLOAD_TOKEN_PARAM = "t";
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A build's signed download link, under the console's path on the page's own
|
|
39
|
+
* address, whatever the page, so it opens where the person who copied it
|
|
40
|
+
* reached the console.
|
|
41
|
+
*/
|
|
42
|
+
export const nativeBuildSignedDownloadUrl = (
|
|
43
|
+
location: { readonly origin: string; readonly pathname: string },
|
|
44
|
+
id: string,
|
|
45
|
+
token: string,
|
|
46
|
+
) => {
|
|
47
|
+
return `${location.origin}${consolePathOf(location, id)}${nativeBuildDownloadPath(id)}?${NATIVE_BUILD_DOWNLOAD_TOKEN_PARAM}=${encodeURIComponent(token)}`;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The console's own path, from a page of build `id` under it: empty at the
|
|
52
|
+
* root of its host.
|
|
53
|
+
*/
|
|
54
|
+
export const consolePathOf = (
|
|
55
|
+
location: { readonly pathname: string },
|
|
56
|
+
id: string,
|
|
57
|
+
) => {
|
|
58
|
+
const page = nativeBuildDetailPath(id);
|
|
59
|
+
return location.pathname.endsWith(page)
|
|
60
|
+
? location.pathname.slice(0, -page.length)
|
|
61
|
+
: "";
|
|
62
|
+
};
|
|
63
|
+
|
|
34
64
|
/** The console page of one native build. */
|
|
35
65
|
export const nativeBuildDetailPath = (id: string) =>
|
|
36
66
|
`/native-builds/${encodeURIComponent(id)}`;
|
|
37
67
|
|
|
68
|
+
/**
|
|
69
|
+
* How long an Install button's link works. It sits in the `itms-services` URL,
|
|
70
|
+
* Safari's history and the installer's logs, and its holder can fetch the IPA
|
|
71
|
+
* with every UDID in its profile, so it lasts only as long as an install takes.
|
|
72
|
+
*/
|
|
73
|
+
export const NATIVE_BUILD_INSTALL_LINK_TTL_MS = 60 * 60 * 1000;
|
|
74
|
+
|
|
75
|
+
/** The phone's own copy of its UDID, which the Console's server never keeps. */
|
|
76
|
+
export const IOS_UDID_STORAGE_KEY = "hot-updater-ios-udid";
|
|
77
|
+
|
|
78
|
+
/** A device's UDID: 40 hex digits, or 8 and 16 joined by a hyphen. */
|
|
79
|
+
export const IOS_UDID_PATTERN = /^(?:[0-9a-f]{40}|[0-9a-f]{8}-[0-9a-f]{16})$/iu;
|
|
80
|
+
|
|
81
|
+
/** The route that hands an iPhone the profile that reads its UDID. */
|
|
82
|
+
export const nativeBuildDeviceProfilePath = (id: string) =>
|
|
83
|
+
`/_hot-updater/native-builds/${encodeURIComponent(id)}/device.mobileconfig`;
|
|
84
|
+
|
|
85
|
+
/** The route of a build's install manifest, as `itms-services` opens it. */
|
|
86
|
+
export const nativeBuildManifestPath = (id: string) =>
|
|
87
|
+
`/_hot-updater/native-builds/${encodeURIComponent(id)}/manifest.plist`;
|
|
88
|
+
|
|
89
|
+
/** The command a maintainer runs to register an iPhone. */
|
|
90
|
+
export const nativeBuildDeviceAddCommand = (udid: string) =>
|
|
91
|
+
`npx hot-updater native-build devices add --udid ${udid} --name "Teammate's iPhone"`;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* What an iPhone opens to install a build: the manifest's URL, signed with a
|
|
95
|
+
* token that also lets the installer download the IPA.
|
|
96
|
+
*/
|
|
97
|
+
export const nativeBuildItmsUrl = (
|
|
98
|
+
location: { readonly origin: string; readonly pathname: string },
|
|
99
|
+
id: string,
|
|
100
|
+
token: string,
|
|
101
|
+
) => {
|
|
102
|
+
const manifest = `${location.origin}${consolePathOf(location, id)}${nativeBuildManifestPath(id)}?${NATIVE_BUILD_DOWNLOAD_TOKEN_PARAM}=${encodeURIComponent(token)}`;
|
|
103
|
+
return `itms-services://?action=download-manifest&url=${encodeURIComponent(manifest)}`;
|
|
104
|
+
};
|
|
105
|
+
|
|
38
106
|
const CHANNEL_ID_PREFIX = "channel:";
|
|
39
107
|
|
|
40
108
|
/** A channel row's ID, `channel:` and its channel key. */
|
|
@@ -148,15 +216,9 @@ export const formatByteSize = (bytes: number): string => {
|
|
|
148
216
|
};
|
|
149
217
|
|
|
150
218
|
/**
|
|
151
|
-
* The
|
|
152
|
-
*
|
|
219
|
+
* The command that downloads a simulator build or an APK, installs it on the
|
|
220
|
+
* booted simulator or the connected device, and opens it, in the project with
|
|
221
|
+
* its `hot-updater.config.ts`.
|
|
153
222
|
*/
|
|
154
|
-
export const
|
|
155
|
-
|
|
156
|
-
const app = archive.replace(/\.zip$/, "");
|
|
157
|
-
return `unzip -o ${shellQuote(archive)} && xcrun simctl install booted ${shellQuote(app)}`;
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
/** The command that installs a downloaded APK on an Android device or emulator. */
|
|
161
|
-
export const apkInstallCommand = (build: NativeBuildRow) =>
|
|
162
|
-
`adb install -r ${shellQuote(nativeBuildFileName(build))}`;
|
|
223
|
+
export const nativeBuildInstallCommand = (build: NativeBuildRow) =>
|
|
224
|
+
`npx hot-updater native-build install ${shellQuote(build.id)}`;
|
|
@@ -25,7 +25,7 @@ export interface LocalConsoleGuardOptions {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/** Compares in time that depends only on the lengths. */
|
|
28
|
-
const sameSecret = (given: string, expected: string): boolean => {
|
|
28
|
+
export const sameSecret = (given: string, expected: string): boolean => {
|
|
29
29
|
if (given.length !== expected.length) return false;
|
|
30
30
|
let difference = 0;
|
|
31
31
|
for (let index = 0; index < given.length; index += 1) {
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { isUUIDv7 } from "@hot-updater/protocol";
|
|
2
|
+
import { readProfileServiceUdid } from "@hot-updater/protocol/native-artifact";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
IOS_UDID_PATTERN,
|
|
6
|
+
IOS_UDID_STORAGE_KEY,
|
|
7
|
+
nativeBuildDeviceAddCommand,
|
|
8
|
+
nativeBuildDeviceProfilePath,
|
|
9
|
+
} from "../native-builds";
|
|
10
|
+
import { escapePlistText } from "./plistText";
|
|
11
|
+
import { publicConsoleBase } from "./publicConsoleBase";
|
|
12
|
+
|
|
13
|
+
/** The most a Profile Service answer holds: a plist and a device's certificates. */
|
|
14
|
+
const MAX_RESPONSE_BYTES = 64 * 1024;
|
|
15
|
+
|
|
16
|
+
const devicePagePath = (id: string) =>
|
|
17
|
+
`/_hot-updater/native-builds/${encodeURIComponent(id)}/device`;
|
|
18
|
+
|
|
19
|
+
const deviceResponsePath = (id: string) => `${devicePagePath(id)}-response`;
|
|
20
|
+
|
|
21
|
+
const refusal = (status: number, message: string) =>
|
|
22
|
+
new Response(message, {
|
|
23
|
+
status,
|
|
24
|
+
headers: {
|
|
25
|
+
"cache-control": "no-store",
|
|
26
|
+
"content-type": "text/plain; charset=utf-8",
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const methodRefusal = (allow: string) => {
|
|
31
|
+
const response = refusal(405, "Method Not Allowed");
|
|
32
|
+
response.headers.set("allow", allow);
|
|
33
|
+
return response;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The profile an iPhone installs to report its UDID, at `/_hot-updater/
|
|
38
|
+
* native-builds/<id>/device.mobileconfig`, without a session, since Settings
|
|
39
|
+
* has none. It reads nothing, so it says nothing about the build: the ID is only
|
|
40
|
+
* where the callback's page links back to. It asks for the UDID alone, and iOS
|
|
41
|
+
* keeps no profile afterwards. Anyone can fetch it and learn only their own UDID.
|
|
42
|
+
*
|
|
43
|
+
* - 400: the ID isn't a UUIDv7, or the Console isn't on HTTPS, which iOS needs;
|
|
44
|
+
* - 405: a method other than GET or HEAD.
|
|
45
|
+
*/
|
|
46
|
+
export const serveDeviceProfile = (request: Request, id: string): Response => {
|
|
47
|
+
if (request.method !== "GET" && request.method !== "HEAD") {
|
|
48
|
+
return methodRefusal("GET, HEAD");
|
|
49
|
+
}
|
|
50
|
+
if (!isUUIDv7(id)) return refusal(400, "Open this from a build's page.");
|
|
51
|
+
const base = publicConsoleBase(request, nativeBuildDeviceProfilePath(id));
|
|
52
|
+
if (!base.startsWith("https://")) {
|
|
53
|
+
return refusal(
|
|
54
|
+
400,
|
|
55
|
+
"An iPhone needs this Console on HTTPS with a certificate it trusts.",
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
const host = new URL(base).host;
|
|
59
|
+
const profile = `<?xml version="1.0" encoding="UTF-8"?>
|
|
60
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
61
|
+
<plist version="1.0">
|
|
62
|
+
<dict>
|
|
63
|
+
<key>PayloadContent</key>
|
|
64
|
+
<dict>
|
|
65
|
+
<key>URL</key>
|
|
66
|
+
<string>${escapePlistText(`${base}${deviceResponsePath(id)}`)}</string>
|
|
67
|
+
<key>DeviceAttributes</key>
|
|
68
|
+
<array>
|
|
69
|
+
<string>UDID</string>
|
|
70
|
+
</array>
|
|
71
|
+
<key>Challenge</key>
|
|
72
|
+
<string>hot-updater</string>
|
|
73
|
+
</dict>
|
|
74
|
+
<key>PayloadOrganization</key>
|
|
75
|
+
<string>Hot Updater</string>
|
|
76
|
+
<key>PayloadDisplayName</key>
|
|
77
|
+
<string>Check this iPhone</string>
|
|
78
|
+
<key>PayloadDescription</key>
|
|
79
|
+
<string>Sends this iPhone's ID (UDID) to ${escapePlistText(host)}, to check whether a build can install on it. Nothing stays installed.</string>
|
|
80
|
+
<key>PayloadIdentifier</key>
|
|
81
|
+
<string>dev.hot-updater.check-this-iphone</string>
|
|
82
|
+
<key>PayloadUUID</key>
|
|
83
|
+
<string>6D3F4C0E-52C4-4C8B-9E0A-7B1E5A0C2F11</string>
|
|
84
|
+
<key>PayloadVersion</key>
|
|
85
|
+
<integer>1</integer>
|
|
86
|
+
<key>PayloadType</key>
|
|
87
|
+
<string>Profile Service</string>
|
|
88
|
+
</dict>
|
|
89
|
+
</plist>
|
|
90
|
+
`;
|
|
91
|
+
return new Response(request.method === "HEAD" ? null : profile, {
|
|
92
|
+
headers: {
|
|
93
|
+
"cache-control": "no-store",
|
|
94
|
+
"content-type": "application/x-apple-aspen-config",
|
|
95
|
+
"x-content-type-options": "nosniff",
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/** A request's body, or null past `limit` bytes, which are never buffered. */
|
|
101
|
+
const readBoundedBody = async (
|
|
102
|
+
request: Request,
|
|
103
|
+
limit: number,
|
|
104
|
+
): Promise<Uint8Array | null> => {
|
|
105
|
+
if (Number(request.headers.get("content-length") ?? 0) > limit) {
|
|
106
|
+
await request.body?.cancel().catch(() => {});
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
const reader = request.body?.getReader();
|
|
110
|
+
if (reader === undefined) return new Uint8Array(0);
|
|
111
|
+
const body = new Uint8Array(limit);
|
|
112
|
+
let length = 0;
|
|
113
|
+
try {
|
|
114
|
+
for (;;) {
|
|
115
|
+
const { done, value } = await reader.read();
|
|
116
|
+
if (done) return body.subarray(0, length);
|
|
117
|
+
if (length + value.byteLength > limit) return null;
|
|
118
|
+
body.set(value, length);
|
|
119
|
+
length += value.byteLength;
|
|
120
|
+
}
|
|
121
|
+
} finally {
|
|
122
|
+
await reader.cancel().catch(() => {});
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Where iOS posts the device's answer, without a session, since Settings has
|
|
128
|
+
* none. It takes the UDID's text and verifies no signature: nothing automated
|
|
129
|
+
* trusts it, and a forged one only shows on the forger's own screen. A maintainer
|
|
130
|
+
* decides whether a UDID is registered. It reads and stores nothing, and sends
|
|
131
|
+
* the UDID in a fragment, which never reaches a server again. iOS asks for a 301.
|
|
132
|
+
*
|
|
133
|
+
* - 400: no well-formed UDID;
|
|
134
|
+
* - 405: a method other than POST;
|
|
135
|
+
* - 413: a body over 64 KiB.
|
|
136
|
+
*/
|
|
137
|
+
export const receiveDeviceResponse = async (
|
|
138
|
+
request: Request,
|
|
139
|
+
id: string,
|
|
140
|
+
): Promise<Response> => {
|
|
141
|
+
if (request.method !== "POST") return methodRefusal("POST");
|
|
142
|
+
if (!isUUIDv7(id)) return refusal(400, "Open this from a build's page.");
|
|
143
|
+
const body = await readBoundedBody(request, MAX_RESPONSE_BYTES);
|
|
144
|
+
if (body === null) return refusal(413, "This answer is too large.");
|
|
145
|
+
const udid = readProfileServiceUdid(body);
|
|
146
|
+
if (udid === null) return refusal(400, "This answer has no device ID.");
|
|
147
|
+
const base = publicConsoleBase(request, deviceResponsePath(id));
|
|
148
|
+
return new Response(null, {
|
|
149
|
+
status: 301,
|
|
150
|
+
headers: {
|
|
151
|
+
"cache-control": "no-store",
|
|
152
|
+
location: `${base}${devicePagePath(id)}#udid=${encodeURIComponent(udid)}`,
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const page = ({
|
|
158
|
+
buildId,
|
|
159
|
+
nonce,
|
|
160
|
+
}: {
|
|
161
|
+
readonly buildId: string;
|
|
162
|
+
readonly nonce: string;
|
|
163
|
+
}) => {
|
|
164
|
+
const [commandStart, commandEnd] =
|
|
165
|
+
nativeBuildDeviceAddCommand("UDID").split("UDID");
|
|
166
|
+
const script = JSON.stringify({
|
|
167
|
+
pattern: IOS_UDID_PATTERN.source,
|
|
168
|
+
key: IOS_UDID_STORAGE_KEY,
|
|
169
|
+
commandStart,
|
|
170
|
+
commandEnd,
|
|
171
|
+
}).replaceAll("<", "\\u003c");
|
|
172
|
+
return `<!doctype html>
|
|
173
|
+
<html lang="en">
|
|
174
|
+
<head>
|
|
175
|
+
<meta charset="utf-8">
|
|
176
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
|
177
|
+
<meta name="color-scheme" content="dark light">
|
|
178
|
+
<meta name="robots" content="noindex">
|
|
179
|
+
<title>This iPhone's ID</title>
|
|
180
|
+
<style nonce="${nonce}">
|
|
181
|
+
:root { color-scheme: dark light; --bg: oklch(1 0 0); --fg: oklch(0.147 0.004 49.25); --muted: oklch(0.553 0.013 58.071); --line: oklch(0.923 0.003 48.717); --panel: oklch(0.97 0.001 106.424); --primary: oklch(0.646 0.222 41.116); --on-primary: oklch(0.98 0.016 73.684); --radius: 0.45rem; }
|
|
182
|
+
@media (prefers-color-scheme: dark) { :root { --bg: oklch(0.147 0.004 49.25); --fg: oklch(0.985 0.001 106.423); --muted: oklch(0.709 0.01 56.259); --line: oklch(1 0 0 / 10%); --panel: oklch(0.268 0.007 34.298); --primary: oklch(0.705 0.213 47.604); } }
|
|
183
|
+
* { box-sizing: border-box; }
|
|
184
|
+
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.5 -apple-system, system-ui, sans-serif; }
|
|
185
|
+
main { display: flex; flex-direction: column; gap: 16px; max-width: 32rem; margin: 0 auto; padding: 32px 16px calc(32px + env(safe-area-inset-bottom)); }
|
|
186
|
+
h1 { margin: 0; font-size: 22px; line-height: 1.25; }
|
|
187
|
+
p { margin: 0; color: var(--muted); font-size: 15px; }
|
|
188
|
+
.warning { color: var(--fg); font-weight: 600; }
|
|
189
|
+
code { display: block; padding: 12px; overflow-wrap: anywhere; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); font: 14px/1.4 ui-monospace, Menlo, monospace; }
|
|
190
|
+
button, a.action { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 44px; padding: 8px 16px; border-radius: var(--radius); font: inherit; font-weight: 600; text-decoration: none; }
|
|
191
|
+
button { border: 0; background: var(--primary); color: var(--on-primary); }
|
|
192
|
+
a.action { border: 1px solid var(--line); color: var(--fg); }
|
|
193
|
+
[hidden] { display: none; }
|
|
194
|
+
</style>
|
|
195
|
+
</head>
|
|
196
|
+
<body>
|
|
197
|
+
<main>
|
|
198
|
+
<div id="found" hidden>
|
|
199
|
+
<h1>This iPhone's ID</h1>
|
|
200
|
+
</div>
|
|
201
|
+
<div id="missing" hidden>
|
|
202
|
+
<h1>No iPhone ID here</h1>
|
|
203
|
+
</div>
|
|
204
|
+
<code id="udid" hidden translate="no"></code>
|
|
205
|
+
<p class="warning" id="warning" hidden>Send this only if this is your iPhone.</p>
|
|
206
|
+
<p id="next" hidden>A maintainer runs this command to register the iPhone, then rebuilds. Open the build again afterwards to install it.</p>
|
|
207
|
+
<code id="command" hidden translate="no"></code>
|
|
208
|
+
<button id="copy" type="button" hidden>Copy command</button>
|
|
209
|
+
<p id="retry" hidden>Open the build's page in Safari and check this iPhone again. On a Mac, Finder shows an iPhone's ID, which a maintainer can register with native-build devices add.</p>
|
|
210
|
+
<a class="action" href="../../../native-builds/${encodeURIComponent(buildId)}">Back to the build</a>
|
|
211
|
+
</main>
|
|
212
|
+
<script nonce="${nonce}">
|
|
213
|
+
(function () {
|
|
214
|
+
var c = ${script};
|
|
215
|
+
var pattern = new RegExp(c.pattern, "i");
|
|
216
|
+
var show = function (id) { document.getElementById(id).hidden = false; };
|
|
217
|
+
var stored = function () { try { return localStorage.getItem(c.key); } catch (e) { return null; } };
|
|
218
|
+
var fromLink = new URLSearchParams(location.hash.slice(1)).get("udid");
|
|
219
|
+
var udid = fromLink && pattern.test(fromLink) ? fromLink : stored();
|
|
220
|
+
if (location.hash) history.replaceState(null, "", location.pathname);
|
|
221
|
+
if (!udid || !pattern.test(udid)) { show("missing"); show("retry"); return; }
|
|
222
|
+
try { localStorage.setItem(c.key, udid); } catch (e) {}
|
|
223
|
+
var command = c.commandStart + udid + c.commandEnd;
|
|
224
|
+
document.getElementById("udid").textContent = udid;
|
|
225
|
+
document.getElementById("command").textContent = command;
|
|
226
|
+
["found", "udid", "warning", "next", "command", "copy"].forEach(show);
|
|
227
|
+
var button = document.getElementById("copy");
|
|
228
|
+
button.addEventListener("click", function () {
|
|
229
|
+
navigator.clipboard.writeText(command).then(function () {
|
|
230
|
+
button.textContent = "Copied";
|
|
231
|
+
}, function () {
|
|
232
|
+
getSelection().selectAllChildren(document.getElementById("command"));
|
|
233
|
+
button.textContent = "Select and copy above";
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
})();
|
|
237
|
+
</script>
|
|
238
|
+
</body>
|
|
239
|
+
</html>
|
|
240
|
+
`;
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* The page the callback lands on: the UDID, one command and a copy button,
|
|
245
|
+
* kept in the phone's `localStorage` for the build's page. It takes no session
|
|
246
|
+
* and reads nothing, so Safari with no Console sign-in shows it too, and it
|
|
247
|
+
* works however long a rebuild takes. The UDID comes from the fragment and stays
|
|
248
|
+
* in the browser; a crafted link can show any text, which is why the page asks
|
|
249
|
+
* who the iPhone belongs to.
|
|
250
|
+
*
|
|
251
|
+
* - 400: the ID isn't a UUIDv7;
|
|
252
|
+
* - 405: a method other than GET or HEAD.
|
|
253
|
+
*/
|
|
254
|
+
export const serveDevicePage = (request: Request, id: string): Response => {
|
|
255
|
+
if (request.method !== "GET" && request.method !== "HEAD") {
|
|
256
|
+
return methodRefusal("GET, HEAD");
|
|
257
|
+
}
|
|
258
|
+
if (!isUUIDv7(id)) return refusal(400, "Open this from a build's page.");
|
|
259
|
+
const nonce = btoa(
|
|
260
|
+
String.fromCharCode(...crypto.getRandomValues(new Uint8Array(16))),
|
|
261
|
+
);
|
|
262
|
+
return new Response(
|
|
263
|
+
request.method === "HEAD" ? null : page({ buildId: id, nonce }),
|
|
264
|
+
{
|
|
265
|
+
headers: {
|
|
266
|
+
"cache-control": "no-store",
|
|
267
|
+
"content-security-policy": `default-src 'none'; script-src 'nonce-${nonce}'; style-src 'nonce-${nonce}'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'`,
|
|
268
|
+
"content-type": "text/html; charset=utf-8",
|
|
269
|
+
"referrer-policy": "no-referrer",
|
|
270
|
+
"x-content-type-options": "nosniff",
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
);
|
|
274
|
+
};
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { getRequest } from "@tanstack/react-start/server";
|
|
2
|
+
|
|
3
|
+
import { sameSecret } from "./local-console";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* How long a signed download link works. A link holds its own expiry and the
|
|
7
|
+
* Console stores nothing, so a new one never ends an older one.
|
|
8
|
+
*/
|
|
9
|
+
export const NATIVE_BUILD_DOWNLOAD_LINK_TTL_MS = 30 * 24 * 60 * 60 * 1000;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The Console's secret, which a hosted Console already has for its sessions:
|
|
13
|
+
* a host's guide lists it. Links sign with a key derived from it, so a link
|
|
14
|
+
* is never a signature the sessions could take, and rotating it ends both.
|
|
15
|
+
*/
|
|
16
|
+
export const CONSOLE_SECRET_ENV = "BETTER_AUTH_SECRET";
|
|
17
|
+
|
|
18
|
+
/** The length the Console's deployment guide asks of the secret. */
|
|
19
|
+
const MIN_SECRET_LENGTH = 32;
|
|
20
|
+
|
|
21
|
+
/** Separates the links' key from every other use of the Console's secret. */
|
|
22
|
+
const KEY_CONTEXT = "hot-updater/console/signed-links/v1";
|
|
23
|
+
|
|
24
|
+
/** What a link grants, so a token for anything else never verifies as one. */
|
|
25
|
+
const DOWNLOAD_PURPOSE = "native-build-download";
|
|
26
|
+
|
|
27
|
+
/** `<expiry in Unix seconds>.<HMAC-SHA256, base64url>`. */
|
|
28
|
+
const TOKEN_PATTERN = /^(\d{1,12})\.([A-Za-z0-9_-]{43})$/u;
|
|
29
|
+
|
|
30
|
+
const encoder = new TextEncoder();
|
|
31
|
+
|
|
32
|
+
const hmac = async (key: BufferSource, message: string) =>
|
|
33
|
+
new Uint8Array(
|
|
34
|
+
await crypto.subtle.sign(
|
|
35
|
+
"HMAC",
|
|
36
|
+
await crypto.subtle.importKey(
|
|
37
|
+
"raw",
|
|
38
|
+
key,
|
|
39
|
+
{ name: "HMAC", hash: "SHA-256" },
|
|
40
|
+
false,
|
|
41
|
+
["sign"],
|
|
42
|
+
),
|
|
43
|
+
encoder.encode(message),
|
|
44
|
+
),
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const base64Url = (bytes: Uint8Array) =>
|
|
48
|
+
btoa(String.fromCharCode(...bytes))
|
|
49
|
+
.replaceAll("+", "-")
|
|
50
|
+
.replaceAll("/", "_")
|
|
51
|
+
.replaceAll("=", "");
|
|
52
|
+
|
|
53
|
+
const signatureOf = async (
|
|
54
|
+
secret: string,
|
|
55
|
+
buildId: string,
|
|
56
|
+
expiresAtSeconds: string,
|
|
57
|
+
) =>
|
|
58
|
+
base64Url(
|
|
59
|
+
await hmac(
|
|
60
|
+
await hmac(encoder.encode(secret), KEY_CONTEXT),
|
|
61
|
+
`${DOWNLOAD_PURPOSE}\n${buildId}\n${expiresAtSeconds}`,
|
|
62
|
+
),
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The Console's secret from the host's environment, or undefined without one
|
|
67
|
+
* long enough to sign with. A Worker's secrets come with the request.
|
|
68
|
+
*/
|
|
69
|
+
export const readConsoleSecret = (request: Request): string | undefined => {
|
|
70
|
+
const { runtime } = request as Request & {
|
|
71
|
+
readonly runtime?: {
|
|
72
|
+
readonly cloudflare?: { readonly env?: Record<string, unknown> };
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
const value =
|
|
76
|
+
runtime?.cloudflare?.env?.[CONSOLE_SECRET_ENV] ??
|
|
77
|
+
(typeof process === "undefined"
|
|
78
|
+
? undefined
|
|
79
|
+
: process.env[CONSOLE_SECRET_ENV]);
|
|
80
|
+
const secret = typeof value === "string" ? value.trim() : "";
|
|
81
|
+
return secret.length >= MIN_SECRET_LENGTH ? secret : undefined;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/** A token that lets its bearer download one build until `expiresAtMs`. */
|
|
85
|
+
export const createNativeBuildDownloadToken = async (
|
|
86
|
+
secret: string,
|
|
87
|
+
buildId: string,
|
|
88
|
+
expiresAtMs: number,
|
|
89
|
+
): Promise<string> => {
|
|
90
|
+
const expiresAtSeconds = String(Math.floor(expiresAtMs / 1000));
|
|
91
|
+
return `${expiresAtSeconds}.${await signatureOf(secret, buildId, expiresAtSeconds)}`;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Whether a token lets its bearer download `buildId` now. The expiry counts
|
|
96
|
+
* only under a signature that holds, so `expired` says nothing to a forger.
|
|
97
|
+
*/
|
|
98
|
+
export const verifyNativeBuildDownloadToken = async (
|
|
99
|
+
secret: string,
|
|
100
|
+
buildId: string,
|
|
101
|
+
token: string,
|
|
102
|
+
now: number = Date.now(),
|
|
103
|
+
): Promise<"valid" | "expired" | "invalid"> => {
|
|
104
|
+
const match = TOKEN_PATTERN.exec(token);
|
|
105
|
+
if (match === null) return "invalid";
|
|
106
|
+
const [, expiresAtSeconds, signature] = match as unknown as [
|
|
107
|
+
string,
|
|
108
|
+
string,
|
|
109
|
+
string,
|
|
110
|
+
];
|
|
111
|
+
// Compares base64url text rather than decoded bytes: a signature's last
|
|
112
|
+
// character carries unused bits, so a changed one could decode the same.
|
|
113
|
+
if (
|
|
114
|
+
!sameSecret(signature, await signatureOf(secret, buildId, expiresAtSeconds))
|
|
115
|
+
) {
|
|
116
|
+
return "invalid";
|
|
117
|
+
}
|
|
118
|
+
return now >= Number(expiresAtSeconds) * 1000 ? "expired" : "valid";
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const refusal = (message: string) =>
|
|
122
|
+
new Response(message, {
|
|
123
|
+
status: 403,
|
|
124
|
+
headers: {
|
|
125
|
+
"cache-control": "no-store",
|
|
126
|
+
"content-type": "text/plain; charset=utf-8",
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* The 403 for a download link's token, or undefined when it lets its bearer
|
|
132
|
+
* download `buildId`. The answer never repeats the token.
|
|
133
|
+
*/
|
|
134
|
+
export const refuseNativeBuildDownloadToken = async (
|
|
135
|
+
request: Request,
|
|
136
|
+
buildId: string,
|
|
137
|
+
token: string,
|
|
138
|
+
): Promise<Response | undefined> => {
|
|
139
|
+
const secret = readConsoleSecret(request);
|
|
140
|
+
if (secret === undefined) {
|
|
141
|
+
return refusal(
|
|
142
|
+
`This Console can't check download links. Set ${CONSOLE_SECRET_ENV} on it.`,
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
switch (await verifyNativeBuildDownloadToken(secret, buildId, token)) {
|
|
146
|
+
case "valid":
|
|
147
|
+
return undefined;
|
|
148
|
+
case "expired":
|
|
149
|
+
return refusal(
|
|
150
|
+
"This download link has expired. Open the build's Console page for a new one.",
|
|
151
|
+
);
|
|
152
|
+
case "invalid":
|
|
153
|
+
return refusal(
|
|
154
|
+
"This download link isn't valid. Open the build's Console page for a new one.",
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export type NativeBuildDownloadLinkResult =
|
|
160
|
+
| {
|
|
161
|
+
readonly status: "issued";
|
|
162
|
+
/** The `t` query parameter of the build's download route. */
|
|
163
|
+
readonly token: string;
|
|
164
|
+
readonly expiresAt: string;
|
|
165
|
+
}
|
|
166
|
+
/** The local console's lock asks for its session on every route. */
|
|
167
|
+
| { readonly status: "local-console" }
|
|
168
|
+
| { readonly status: "no-secret"; readonly secretName: string };
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* A new signed download link's token, for a caller the Console already let
|
|
172
|
+
* in. It reads nothing and stores nothing.
|
|
173
|
+
*/
|
|
174
|
+
export const issueNativeBuildDownloadLink = async (
|
|
175
|
+
buildId: string,
|
|
176
|
+
request: Request = getRequest(),
|
|
177
|
+
now: number = Date.now(),
|
|
178
|
+
ttlMs: number = NATIVE_BUILD_DOWNLOAD_LINK_TTL_MS,
|
|
179
|
+
): Promise<NativeBuildDownloadLinkResult> => {
|
|
180
|
+
const { default: localConsoleGuard } =
|
|
181
|
+
await import("virtual:hot-updater-console/request-guard");
|
|
182
|
+
if (localConsoleGuard !== undefined) return { status: "local-console" };
|
|
183
|
+
const secret = readConsoleSecret(request);
|
|
184
|
+
if (secret === undefined) {
|
|
185
|
+
return { status: "no-secret", secretName: CONSOLE_SECRET_ENV };
|
|
186
|
+
}
|
|
187
|
+
const expiresAt = now + ttlMs;
|
|
188
|
+
return {
|
|
189
|
+
status: "issued",
|
|
190
|
+
token: await createNativeBuildDownloadToken(secret, buildId, expiresAt),
|
|
191
|
+
expiresAt: new Date(expiresAt).toISOString(),
|
|
192
|
+
};
|
|
193
|
+
};
|