hyperframes 0.8.216 → 0.8.218

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.
Files changed (212) hide show
  1. package/dist/{add-2RWN7JAI.js → add-6TACQX2U.js} +14 -14
  2. package/dist/{agentPromptGenerator-RVE5RWTH.js → agentPromptGenerator-2OHH7TQF.js} +8 -8
  3. package/dist/{animatedGifPrep-I32BS5HI.js → animatedGifPrep-3TCOKQRQ.js} +8 -8
  4. package/dist/api.js +19 -19
  5. package/dist/{asset-YLZ5UGVE.js → asset-XGF7DP6H.js} +2 -2
  6. package/dist/{assetCataloger-B4KOZO3V.js → assetCataloger-23H37VZ5.js} +9 -9
  7. package/dist/{audio-VUOJ7MOJ.js → audio-IIU2JTO2.js} +19 -19
  8. package/dist/{auth-3UL65CN7.js → auth-YXS6A6HO.js} +8 -7
  9. package/dist/{autoUpdate-FEK5AHLP.js → autoUpdate-25S52Q5S.js} +3 -3
  10. package/dist/{backgroundChecks-VJSQ3REH.js → backgroundChecks-I7EVP7FG.js} +4 -4
  11. package/dist/backgroundChecksWorker.js +4 -4
  12. package/dist/{batchRender-NC6SUDYN.js → batchRender-ESAPNTE3.js} +4 -4
  13. package/dist/{beats-KSUZ23LE.js → beats-STUURUTE.js} +13 -13
  14. package/dist/{benchmark-TRVQ7EPQ.js → benchmark-APCKXZV4.js} +11 -11
  15. package/dist/{browser-3LJ3SLQ4.js → browser-24AXY6XT.js} +6 -6
  16. package/dist/{bundleWithLocalizedFonts-Y7VGIRFK.js → bundleWithLocalizedFonts-D5DHHE3J.js} +2 -2
  17. package/dist/{capture-NC5OO4D2.js → capture-6DJ63B7N.js} +3 -3
  18. package/dist/{capture-NT2SOO5J.js → capture-CPDVGCHU.js} +16 -16
  19. package/dist/{captureCompositionFrame-PAJRNURH.js → captureCompositionFrame-UQWCB4GS.js} +13 -13
  20. package/dist/{catalog-BOGZ2BQD.js → catalog-Q23ML47J.js} +14 -14
  21. package/dist/{catch-up-FGF5SAEW.js → catch-up-RS3QCE4R.js} +7 -7
  22. package/dist/{check-IG6NIMSC.js → check-CTCEOX24.js} +40 -40
  23. package/dist/{checkAudio-6B2FKTIU.js → checkAudio-SINGW2W7.js} +12 -12
  24. package/dist/{checkBrowser-D6MZRCTH.js → checkBrowser-PDM2H472.js} +34 -34
  25. package/dist/{chunk-UGQFQDSV.js → chunk-35JKCWYI.js} +1 -1
  26. package/dist/{chunk-I3VXWMQW.js → chunk-3MTNYVWM.js} +5 -5
  27. package/dist/{chunk-3S2WWGJJ.js → chunk-3O6TQMFR.js} +3 -3
  28. package/dist/{chunk-MYHAS5U2.js → chunk-3VIICMJF.js} +1 -1
  29. package/dist/{chunk-IVRKWQTX.js → chunk-4I7KQWZS.js} +1 -1
  30. package/dist/{chunk-JFFQWMNE.js → chunk-4OWVRHSV.js} +5 -5
  31. package/dist/{chunk-URUUGFZD.js → chunk-4RHUYKVK.js} +3 -3
  32. package/dist/{chunk-RIGQABEL.js → chunk-562GRMWD.js} +1 -1
  33. package/dist/{chunk-MU66MHZB.js → chunk-576ATOOU.js} +2 -2
  34. package/dist/{chunk-OWU2BURB.js → chunk-5JMHTBGN.js} +2 -2
  35. package/dist/{chunk-KYXBPFI7.js → chunk-5UIODBMI.js} +8 -5
  36. package/dist/{chunk-SBBYMUWY.js → chunk-67YDBMLK.js} +1 -1
  37. package/dist/{chunk-5XTOAZMR.js → chunk-A5MVD5IH.js} +1 -1
  38. package/dist/{chunk-DYHAZFK3.js → chunk-AU7VGKCP.js} +1 -1
  39. package/dist/{chunk-VAS6HQX3.js → chunk-BIROA7JM.js} +32 -3
  40. package/dist/{chunk-ZCHULPJZ.js → chunk-BLBMPEBX.js} +6 -0
  41. package/dist/{chunk-TQSKEMSL.js → chunk-BMM6KPEK.js} +3 -3
  42. package/dist/{chunk-FUSUFW2L.js → chunk-BRYOYBO5.js} +1 -1
  43. package/dist/{chunk-RN7RQBW3.js → chunk-BT5UT4XT.js} +2 -2
  44. package/dist/{chunk-CX4TSC7T.js → chunk-BWP7C7WY.js} +38 -27
  45. package/dist/{chunk-3AOXAXTA.js → chunk-C2G23WQQ.js} +1 -1
  46. package/dist/{chunk-MKL6JGDL.js → chunk-CPLOVCBR.js} +56 -20
  47. package/dist/{chunk-4MWUMT3T.js → chunk-DFLWN6Y3.js} +2 -2
  48. package/dist/{chunk-RH5Y75UX.js → chunk-DOZGTBDV.js} +2 -2
  49. package/dist/{chunk-RKS7GO4O.js → chunk-DWMI7CKI.js} +1 -1
  50. package/dist/{chunk-GHROWWUN.js → chunk-DWTFLQ3P.js} +33 -6
  51. package/dist/{chunk-ACAU2AK2.js → chunk-FQUPVW7G.js} +4 -4
  52. package/dist/{chunk-4EEVTNDU.js → chunk-G2E2DHH2.js} +3 -3
  53. package/dist/{chunk-OFJTXNRS.js → chunk-GEOYME4I.js} +3 -3
  54. package/dist/{chunk-6LQL2BVD.js → chunk-GHWV6PIS.js} +1 -1
  55. package/dist/{chunk-BTYR7Y3Z.js → chunk-H6LEUSAT.js} +2 -2
  56. package/dist/{chunk-RXQU3QM4.js → chunk-HOTGBCX7.js} +9 -9
  57. package/dist/{chunk-NWYJZAPP.js → chunk-HTBHG63K.js} +1 -1
  58. package/dist/{chunk-DFA5GTRJ.js → chunk-IEC36WFL.js} +1 -1
  59. package/dist/{chunk-2JV6FKNZ.js → chunk-ILCIWNPQ.js} +3 -3
  60. package/dist/{chunk-7VZEOCUY.js → chunk-J74ZUXVU.js} +1 -1
  61. package/dist/{chunk-MO6DJMZP.js → chunk-JH2AO4ZW.js} +2 -2
  62. package/dist/{chunk-4YIKQM4K.js → chunk-K5GGTJJV.js} +1 -1
  63. package/dist/{chunk-EB44YMQO.js → chunk-KUQOUWJ4.js} +3 -3
  64. package/dist/{chunk-7P76YIVS.js → chunk-LBZVTVG6.js} +1 -1
  65. package/dist/{chunk-BHWXSO6T.js → chunk-LGMRZWJS.js} +9 -3
  66. package/dist/{chunk-JOZQFSOV.js → chunk-LJB2PF6K.js} +1 -1
  67. package/dist/{chunk-ZRK7ZEWI.js → chunk-LYK7IGH4.js} +3 -3
  68. package/dist/{chunk-UVXIJYZY.js → chunk-MESSJFK3.js} +249 -298
  69. package/dist/{chunk-JF3RF6GS.js → chunk-MHZB6QSC.js} +1 -1
  70. package/dist/{chunk-6HJUC2VX.js → chunk-NEPGYMT3.js} +2 -2
  71. package/dist/{chunk-CBCZBHGK.js → chunk-NHXGFQWQ.js} +2 -2
  72. package/dist/{chunk-Z4W7ND2L.js → chunk-P34BNDC3.js} +6 -6
  73. package/dist/{chunk-SPFTXNKQ.js → chunk-P5ANVBAG.js} +16 -15
  74. package/dist/{chunk-GTKUQUZ6.js → chunk-RYBFHEMZ.js} +1 -1
  75. package/dist/{chunk-557ZJMFI.js → chunk-SFBFRIKF.js} +2 -2
  76. package/dist/{chunk-43USF7JF.js → chunk-SJYWAEKF.js} +9 -9
  77. package/dist/{chunk-ROUK3OL2.js → chunk-SVJAW3N3.js} +7 -7
  78. package/dist/{chunk-VDFY4FE5.js → chunk-SZMW32YW.js} +9 -9
  79. package/dist/{chunk-7RPXLY6U.js → chunk-TCV7N2UY.js} +1 -1
  80. package/dist/{chunk-634HSJ3J.js → chunk-TK7THLRO.js} +10 -3
  81. package/dist/{chunk-LGZP4IR2.js → chunk-U2EUCTYQ.js} +4 -4
  82. package/dist/{chunk-KBTXAUCZ.js → chunk-UWV753SJ.js} +1 -1
  83. package/dist/chunk-VLA6UJGH.js +139 -0
  84. package/dist/{chunk-U54ZBLTF.js → chunk-VLMPZRZC.js} +2 -2
  85. package/dist/{chunk-Q3OKLJ34.js → chunk-VMTLGFAP.js} +2 -2
  86. package/dist/{chunk-BYHG2T5X.js → chunk-VP5KECBU.js} +2 -2
  87. package/dist/{chunk-USQTLRSD.js → chunk-VTLIN7XN.js} +2 -2
  88. package/dist/{chunk-TBEU55KU.js → chunk-WHISG7MU.js} +1 -1
  89. package/dist/{chunk-YT4DR2UT.js → chunk-WSAGYFYU.js} +7 -7
  90. package/dist/{chunk-UIETUYFT.js → chunk-WUABYDXU.js} +1 -1
  91. package/dist/{chunk-UJEEURID.js → chunk-X4SGGGSG.js} +13 -13
  92. package/dist/{chunk-VPA5YKEY.js → chunk-XC2DA2IA.js} +2 -2
  93. package/dist/{chunk-QETCWXRM.js → chunk-XKG4VTT5.js} +4 -4
  94. package/dist/{chunk-PNE2Y42T.js → chunk-YATFRFNH.js} +1 -1
  95. package/dist/{chunk-EJTVBW42.js → chunk-YBW7HTJK.js} +2 -2
  96. package/dist/{chunk-PPMLF76Z.js → chunk-YSTBSLWY.js} +1 -1
  97. package/dist/{chunk-VZENYSX7.js → chunk-YXZ56JUN.js} +44 -33
  98. package/dist/{chunk-OPLEWQHF.js → chunk-Z5N3BHCQ.js} +1 -1
  99. package/dist/{chunk-QGMRSNG5.js → chunk-ZJNN53CS.js} +4 -3
  100. package/dist/{clean-WPLBDRSW.js → clean-MMKLFZD6.js} +19 -19
  101. package/dist/cli.js +57 -66
  102. package/dist/{cloud-VMSG2SJB.js → cloud-PYPEVKTI.js} +4 -4
  103. package/dist/{cloudrun-AXB4G6X2.js → cloudrun-5XEDIP77.js} +5 -5
  104. package/dist/commands/layout-audit.browser.js +7 -1
  105. package/dist/{compare-NVW3E74E.js → compare-5FYV3HXW.js} +31 -31
  106. package/dist/{compiler-GHX7QLHL.js → compiler-DVUV3DGB.js} +4 -4
  107. package/dist/{component-ZQAP7CBI.js → component-6WPGKSED.js} +3 -3
  108. package/dist/{compositions-FKHNCB6H.js → compositions-KF7WTF4B.js} +14 -14
  109. package/dist/{delete-XYC7FN6A.js → delete-KZFID7WD.js} +7 -7
  110. package/dist/{deploy-DOJS666X.js → deploy-JU22XTWD.js} +1 -1
  111. package/dist/{dist-3Q2DNDSR.js → dist-VNOJCTQR.js} +3 -3
  112. package/dist/{dist-KXFW5H5Q.js → dist-XXBCSQYF.js} +2 -2
  113. package/dist/{doctor-7CUFMW3Y.js → doctor-PI6KAIR5.js} +13 -13
  114. package/dist/{dotEnv-RPHCAUBZ.js → dotEnv-BGFXSQOA.js} +7 -5
  115. package/dist/{events-K7HUJ4DO.js → events-DE5M7353.js} +4 -4
  116. package/dist/{events-KGXVDZV7.js → events-GTCDNRHF.js} +6 -6
  117. package/dist/{feedback-F7WLYJGJ.js → feedback-WBXTSD7V.js} +26 -14
  118. package/dist/{ffmpeg-ZFHN4YZ2.js → ffmpeg-32BKO53L.js} +8 -8
  119. package/dist/{figma-7QKRKT5Q.js → figma-4EX6IU6D.js} +3 -3
  120. package/dist/fontLocalizeCli.js +11 -11
  121. package/dist/{get-XKPYG6IC.js → get-IDFMBDVJ.js} +7 -7
  122. package/dist/{gpuPolicy-A74BROG6.js → gpuPolicy-XALYIHRC.js} +8 -8
  123. package/dist/{grade-compare-7SR62TE5.js → grade-compare-IR6C2BDN.js} +32 -32
  124. package/dist/{heifImagePrep-XTCBHE3B.js → heifImagePrep-UT4MVMZK.js} +9 -9
  125. package/dist/{help-B7CXC4J5.js → help-LNFTZ33U.js} +1 -1
  126. package/dist/{history-3INEHHZ4.js → history-CVMBLNPB.js} +9 -9
  127. package/dist/hyperframe.manifest.json +1 -1
  128. package/dist/hyperframe.runtime.iife.js +26 -26
  129. package/dist/hyperframes-player.global.js +1 -1
  130. package/dist/{info-J3U63EFT.js → info-ZR6NR7MT.js} +10 -10
  131. package/dist/{init-2IEXXRG2.js → init-3H4OWHAC.js} +31 -31
  132. package/dist/{inspect-IRJABR66.js → inspect-DQB42FQJ.js} +32 -32
  133. package/dist/{installer-6JLQM6OJ.js → installer-OFIDWMYR.js} +5 -5
  134. package/dist/{keyframes-G2TSKZRL.js → keyframes-U74BN76I.js} +9 -9
  135. package/dist/{lambda-QFFFCFK3.js → lambda-UPISIKLU.js} +12 -12
  136. package/dist/{layout-INRUYIDJ.js → layout-JCWBIDXF.js} +32 -32
  137. package/dist/{lint-BHPBD7Z3.js → lint-EELAY2XS.js} +11 -11
  138. package/dist/{lintProject-SZIPPOJR.js → lintProject-I4XPWIQZ.js} +2 -2
  139. package/dist/{list-BGL5PH6J.js → list-MDRTOKTA.js} +7 -7
  140. package/dist/{localPage-MLFDX4Y6.js → localPage-BRAEGIND.js} +8 -8
  141. package/dist/{login-ABDL65L6.js → login-SOWERHQ6.js} +9 -8
  142. package/dist/{logout-CXGSSQ4Q.js → logout-6VFJ7WMW.js} +4 -4
  143. package/dist/{manager-DEKPCPWH.js → manager-PZ3USUXJ.js} +9 -9
  144. package/dist/{media-treatment-BQDTCBIT.js → media-treatment-A4CYTZKY.js} +16 -16
  145. package/dist/{media-use-ZRHFRO46.js → media-use-ZNTB7W6N.js} +85 -10
  146. package/dist/{models-SJIA5QDV.js → models-3LT54WBS.js} +12 -12
  147. package/dist/{motionShot-46J3W5UJ.js → motionShot-QLD2PDVI.js} +16 -16
  148. package/dist/{normalize-audio-UXAJSQKI.js → normalize-audio-HMYHPUV4.js} +12 -12
  149. package/dist/{open-DHRYP3N3.js → open-CYR6L7BV.js} +14 -14
  150. package/dist/{parakeetRunner-WKMM4TYU.js → parakeetRunner-52GLM62X.js} +14 -14
  151. package/dist/{pipeline-EIVKRUX2.js → pipeline-KZW5KLBK.js} +11 -11
  152. package/dist/{play-J5A7KHNF.js → play-KSX3VWZ5.js} +23 -23
  153. package/dist/{preflight-GKIQIXFQ.js → preflight-YJZS7QKG.js} +9 -9
  154. package/dist/{present-ZDXILGQJ.js → present-4Q3DIPFX.js} +19 -19
  155. package/dist/{preview-A2MLHZFF.js → preview-XAKLHB7C.js} +21 -21
  156. package/dist/{producer-NYWYRG4X.js → producer-Q46KBQS7.js} +1 -1
  157. package/dist/{projectConfig-DY6FHC7A.js → projectConfig-I6QNMRVV.js} +7 -7
  158. package/dist/{publication-N4WHPZOW.js → publication-JET7ZBWG.js} +3 -3
  159. package/dist/{publish-26W6VDND.js → publish-ZGW46SKV.js} +16 -16
  160. package/dist/{refresh-VJ4FQVH2.js → refresh-I6ITGHKL.js} +5 -4
  161. package/dist/{remove-background-JYUB75RB.js → remove-background-ENOMPCPD.js} +12 -12
  162. package/dist/{render-YPI6CDRS.js → render-33TSTTN7.js} +6 -6
  163. package/dist/{render-AQH2VMHO.js → render-5W2OBXKB.js} +82 -38
  164. package/dist/{render-JZWO3VX3.js → render-MS2SUV7X.js} +23 -23
  165. package/dist/{render-batch-GR2Y3F2S.js → render-batch-SDDZ3LM7.js} +6 -6
  166. package/dist/renderSetupWorker.js +2 -2
  167. package/dist/{resolver-LTLSX6DR.js → resolver-VLOUQ7I6.js} +5 -5
  168. package/dist/{sherpa-2DJ33LQP.js → sherpa-BWAZ26Z4.js} +13 -13
  169. package/dist/skills/hyperframes-cli/references/cloud.md +4 -4
  170. package/dist/skills/media-use/SKILL.md +3 -1
  171. package/dist/skills/media-use/audio/references/bgm.md +1 -1
  172. package/dist/skills/media-use/audio/references/requirements.md +9 -9
  173. package/dist/skills/media-use/audio/references/tts.md +11 -11
  174. package/dist/skills/media-use/audio/scripts/gemini-pipeline.test.mjs +1 -1
  175. package/dist/skills/media-use/audio/scripts/heygen-tts.mjs +1 -1
  176. package/dist/skills/media-use/audio/scripts/lib/audio-meta.test.mjs +1 -1
  177. package/dist/skills/media-use/audio/scripts/lib/heygen.mjs +23 -7
  178. package/dist/skills/media-use/audio/scripts/lib/heygen.test.mjs +68 -10
  179. package/dist/skills/media-use/audio/scripts/lib/tts.mjs +1 -1
  180. package/dist/skills/media-use/audio/scripts/lib/tts.test.mjs +2 -2
  181. package/dist/skills/media-use/references/operations.md +11 -9
  182. package/dist/skills/media-use/references/setup-providers.md +30 -30
  183. package/dist/skills/media-use/scripts/lib/heygen-cli.mjs +2 -2
  184. package/dist/skills/media-use/scripts/lib/telemetry.mjs +2 -1
  185. package/dist/skills/media-use/scripts/lib/telemetry.test.mjs +49 -4
  186. package/dist/{skills-OF7XMPKX.js → skills-MSNOVAV2.js} +8 -8
  187. package/dist/{skillsUpdateCheck-E3HPT4PS.js → skillsUpdateCheck-KNXASTIY.js} +4 -4
  188. package/dist/{snapshot-6F5XK22M.js → snapshot-UVDTIQFA.js} +39 -42
  189. package/dist/{src-JUJFZ6GC.js → src-AA5O4QMT.js} +7 -7
  190. package/dist/{src-UNN3TXHH.js → src-ZMJBQF2Y.js} +12 -10
  191. package/dist/{staticProjectServer-DLSH7DHS.js → staticProjectServer-MVGWIOTX.js} +19 -19
  192. package/dist/{status-TJFZFDGS.js → status-63BKLDVW.js} +40 -11
  193. package/dist/studio/assets/{hyperframes-player-D38lr2hR.js → hyperframes-player-C6V-KPv8.js} +1 -1
  194. package/dist/studio/assets/{index-C-DCQ7nQ.js → index-BLgjf320.js} +108 -108
  195. package/dist/studio/assets/{index-CJ28BLvq.js → index-C_LGrLz-.js} +1 -1
  196. package/dist/studio/index.html +1 -1
  197. package/dist/{studio-api-5YATSN7H.js → studio-api-SW5MW272.js} +11 -11
  198. package/dist/{studioServer-O3FSLOUF.js → studioServer-SXYAQVII.js} +51 -51
  199. package/dist/{telemetry-MMCJ2ORL.js → telemetry-3JM3MQK2.js} +6 -6
  200. package/dist/{telemetry-CY7V7FIN.js → telemetry-QHYJJAJU.js} +1 -1
  201. package/dist/{timeline-ZBJTZK6E.js → timeline-G6MHJ4MV.js} +21 -21
  202. package/dist/{tokens-JFYRYRDK.js → tokens-ROE4XPZP.js} +2 -2
  203. package/dist/{transcribe-QUMMQM34.js → transcribe-EINIBALD.js} +12 -12
  204. package/dist/{transcribe-UVQQ3OMR.js → transcribe-RGWPXLJ3.js} +20 -20
  205. package/dist/{updateCheck-VMMBGLTI.js → updateCheck-4RS5TICZ.js} +3 -3
  206. package/dist/{upgrade-4VYNPIFQ.js → upgrade-7ULCD6M6.js} +3 -3
  207. package/dist/{urlDownloader-EAPV3CZL.js → urlDownloader-KQOGUGS6.js} +7 -7
  208. package/dist/{validate-JJG6Q6IH.js → validate-QXQ3WRA4.js} +26 -26
  209. package/dist/{video-7MJZ7IYL.js → video-DDKGIJLL.js} +9 -9
  210. package/dist/warmCheck.js +40 -40
  211. package/package.json +1 -1
  212. package/dist/chunk-4WEWHZZO.js +0 -24
@@ -5,8 +5,25 @@ var require = __hf_createRequire(import.meta.url);
5
5
  var __filename = __hf_fileURLToPath(import.meta.url);
6
6
  var __dirname = __hf_dirname(__filename);
7
7
  import {
8
- credentialPath
9
- } from "./chunk-4WEWHZZO.js";
8
+ ErrApi,
9
+ ErrDeviceAuthFailed,
10
+ ErrInvalidStore,
11
+ ErrLoginChanged,
12
+ ErrLoginExpired,
13
+ ErrNotConfigured,
14
+ ErrRefreshFailed,
15
+ ErrUnauthenticated,
16
+ assertOAuthIdentity,
17
+ authorizeEndpoint,
18
+ credentialPath,
19
+ deviceAuthorizationEndpoint,
20
+ isAuthError,
21
+ oauthEnvironment,
22
+ oauthIdentity,
23
+ resolveClientId,
24
+ revokeEndpoint,
25
+ tokenEndpoint
26
+ } from "./chunk-VLA6UJGH.js";
10
27
  import {
11
28
  c
12
29
  } from "./chunk-2GICKZ3I.js";
@@ -17,60 +34,138 @@ import {
17
34
  normalizeErrorMessage
18
35
  } from "./chunk-E63BDV4Z.js";
19
36
 
20
- // src/auth/errors.ts
21
- var AuthError = class extends Error {
22
- code;
23
- hint;
24
- constructor(code, message, hint) {
25
- super(message);
26
- this.name = "AuthError";
27
- this.code = code;
28
- this.hint = hint;
37
+ // src/auth/scrub.ts
38
+ var HEYGEN_KEY = /\b(hg|sk)_[A-Za-z0-9_-]{4,}/g;
39
+ var HEADER_LINE = /(authorization|x-api-key)[ \t]*[:=][ \t]*[^\r\n]+/gi;
40
+ var JWT = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
41
+ var SECRET_FIELDS = [
42
+ "access_token",
43
+ "refresh_token",
44
+ "code_verifier",
45
+ "client_secret",
46
+ "id_token",
47
+ "token",
48
+ "code"
49
+ ];
50
+ var FORM_FIELD = new RegExp(`\\b(${SECRET_FIELDS.join("|")})=[^&\\s"']+`, "gi");
51
+ var JSON_FIELD = new RegExp(`("(?:${SECRET_FIELDS.join("|")})"\\s*:\\s*)"[^"]*"`, "gi");
52
+ function scrubCredentials(s) {
53
+ return s.replace(HEYGEN_KEY, "$1_<redacted>").replace(HEADER_LINE, "$1: <redacted>").replace(JWT, "<jwt-redacted>").replace(FORM_FIELD, "$1=<redacted>").replace(JSON_FIELD, '$1"<redacted>"');
54
+ }
55
+
56
+ // src/auth/client.ts
57
+ var HEYGEN_CLI_SOURCE_HEADER = "X-HeyGen-Source";
58
+ var HEYGEN_CLI_SOURCE = "cli";
59
+ var HEYGEN_CLIENT_SOURCE_HEADER = "X-HeyGen-Client-Source";
60
+ var HEYGEN_CLIENT_SOURCE = "hyperframes";
61
+ function apiBaseUrl() {
62
+ const override = process.env["HEYGEN_API_URL"];
63
+ return override && override.length > 0 ? override.replace(/\/+$/, "") : `https://api.${oauthEnvironment() === "dev" ? "dev." : ""}heygen.com`;
64
+ }
65
+ var AuthClient = class {
66
+ base;
67
+ fetchImpl;
68
+ onRefresh;
69
+ constructor(opts = {}) {
70
+ this.base = (opts.baseUrl ?? apiBaseUrl()).replace(/\/+$/, "");
71
+ this.fetchImpl = opts.fetchImpl ?? fetch;
72
+ this.onRefresh = opts.onUnauthenticatedRefresh;
73
+ }
74
+ /**
75
+ * `GET /v3/users/me`. Throws `ErrUnauthenticated` on 401, `ErrApi`
76
+ * on any other non-2xx or non-JSON body.
77
+ *
78
+ * On OAuth 401 with a refresh hook configured, the request is
79
+ * retried once after refreshing the access token. The retry's
80
+ * outcome is what the caller sees — if the refresh itself fails
81
+ * (REFRESH_FAILED) or the retry still 401s, the user lands on a
82
+ * "please log in again" path upstream.
83
+ */
84
+ async getCurrentUser(credential) {
85
+ const url = `${this.base}/v3/users/me`;
86
+ return await this.fetchUser(url, credential, true);
87
+ }
88
+ // fallow-ignore-next-line complexity
89
+ async fetchUser(url, credential, allowRefresh) {
90
+ const headers = buildAuthHeaders(credential);
91
+ const res = await this.fetchImpl(url, { method: "GET", headers });
92
+ if (res.status === 401) {
93
+ if (allowRefresh && credential.type === "oauth" && credential.refresh_token && this.onRefresh) {
94
+ const refreshed = await this.tryRefresh(credential.refresh_token);
95
+ if (refreshed) {
96
+ const next = {
97
+ ...credential,
98
+ access_token: refreshed.access_token,
99
+ ...refreshed.refresh_token ? { refresh_token: refreshed.refresh_token } : {}
100
+ };
101
+ return await this.fetchUser(url, next, false);
102
+ }
103
+ }
104
+ const detail = await safeText(res);
105
+ throw ErrUnauthenticated(detail || `${res.status} ${res.statusText}`);
106
+ }
107
+ if (!res.ok) {
108
+ throw ErrApi(res.status, await safeText(res) || res.statusText);
109
+ }
110
+ let payload;
111
+ try {
112
+ payload = await res.json();
113
+ } catch (err) {
114
+ throw ErrApi(res.status, `non-JSON body: ${err.message}`);
115
+ }
116
+ return extractUserInfo(payload);
117
+ }
118
+ async tryRefresh(refresh_token) {
119
+ if (!this.onRefresh) return null;
120
+ try {
121
+ return await this.onRefresh(refresh_token);
122
+ } catch (err) {
123
+ if (isAuthError(err) && err.code === "REFRESH_FAILED") return null;
124
+ throw err;
125
+ }
29
126
  }
30
127
  };
31
- var ErrNotConfigured = () => new AuthError(
32
- "NOT_CONFIGURED",
33
- "No HeyGen credentials found",
34
- "Run `hyperframes auth login` to sign in."
35
- );
36
- var ErrInvalidStore = (detail) => new AuthError(
37
- "INVALID_STORE",
38
- `Credential file is unreadable: ${detail}`,
39
- "Delete ~/.heygen/credentials and run `hyperframes auth login` to re-create it."
40
- );
41
- var ErrUnauthenticated = (detail) => new AuthError(
42
- "UNAUTHENTICATED",
43
- detail ? `HeyGen rejected the credential: ${detail}` : "HeyGen rejected the credential",
44
- "Run `hyperframes auth login` to re-authenticate."
45
- );
46
- var ErrApi = (status, detail) => new AuthError("API_ERROR", `HeyGen API error (${status}): ${detail}`);
47
- var ErrOAuthNotConfigured = () => new AuthError(
48
- "OAUTH_NOT_CONFIGURED",
49
- "OAuth client is not configured",
50
- "Set HYPERFRAMES_OAUTH_CLIENT_ID, or run `hyperframes auth login --api-key`."
51
- );
52
- var ErrRefreshFailed = (detail) => new AuthError(
53
- "REFRESH_FAILED",
54
- detail ? `Failed to refresh OAuth tokens: ${detail}` : "Failed to refresh OAuth tokens",
55
- "Run `hyperframes auth login` to re-authenticate."
56
- );
57
- var ErrLoginExpired = () => new AuthError(
58
- "LOGIN_EXPIRED",
59
- "Your HeyGen login expired",
60
- "Run `hyperframes auth login` to sign in again."
61
- );
62
- var ErrLoginChanged = () => new AuthError(
63
- "LOGIN_CHANGED",
64
- "Your HeyGen login changed while this command ran",
65
- "Run the command again."
66
- );
67
- var ErrDeviceAuthFailed = (detail) => new AuthError(
68
- "DEVICE_AUTH_FAILED",
69
- `Device authorization failed: ${detail}`,
70
- "Run `hyperframes auth login --device` to start a new code."
71
- );
72
- function isAuthError(err) {
73
- return err instanceof AuthError;
128
+ function buildAuthHeaders(credential) {
129
+ if (credential.type === "oauth") {
130
+ return {
131
+ authorization: `Bearer ${credential.access_token}`,
132
+ [HEYGEN_CLI_SOURCE_HEADER]: HEYGEN_CLI_SOURCE,
133
+ [HEYGEN_CLIENT_SOURCE_HEADER]: HEYGEN_CLIENT_SOURCE
134
+ };
135
+ }
136
+ return { "x-api-key": credential.key, [HEYGEN_CLIENT_SOURCE_HEADER]: HEYGEN_CLIENT_SOURCE };
137
+ }
138
+ async function safeText(res) {
139
+ try {
140
+ const body = (await res.text()).slice(0, 500);
141
+ return scrubCredentials(body);
142
+ } catch {
143
+ return "";
144
+ }
145
+ }
146
+ function extractUserInfo(payload) {
147
+ if (!payload || typeof payload !== "object" || Array.isArray(payload)) return {};
148
+ const obj = payload;
149
+ const wrapped = obj["data"];
150
+ const data = wrapped && typeof wrapped === "object" && !Array.isArray(wrapped) ? wrapped : obj;
151
+ return {
152
+ username: pickString(data, "username"),
153
+ email: pickString(data, "email"),
154
+ first_name: pickString(data, "first_name"),
155
+ last_name: pickString(data, "last_name"),
156
+ billing_type: pickString(data, "billing_type"),
157
+ wallet: pickObject(data, "wallet"),
158
+ subscription: pickObject(data, "subscription"),
159
+ usage_based: pickObject(data, "usage_based")
160
+ };
161
+ }
162
+ function pickString(obj, key) {
163
+ const v = obj[key];
164
+ return typeof v === "string" ? v : void 0;
165
+ }
166
+ function pickObject(obj, key) {
167
+ const v = obj[key];
168
+ return v && typeof v === "object" && !Array.isArray(v) ? v : void 0;
74
169
  }
75
170
 
76
171
  // src/auth/store.ts
@@ -85,7 +180,9 @@ var KNOWN_OAUTH_KEYS = /* @__PURE__ */ new Set([
85
180
  "refresh_token",
86
181
  "expires_at",
87
182
  "scope",
88
- "token_type"
183
+ "token_type",
184
+ "client_id",
185
+ "token_endpoint"
89
186
  ]);
90
187
  var KNOWN_USER_KEYS = /* @__PURE__ */ new Set(["email", "first_name", "last_name", "username"]);
91
188
  async function readStore(path = credentialPath()) {
@@ -192,6 +289,8 @@ function assignOptionalStrings(out, obj, spec) {
192
289
  }
193
290
  }
194
291
  var OAUTH_OPTIONAL = [
292
+ ["client_id", "header_safe"],
293
+ ["token_endpoint", "non_empty"],
195
294
  ["refresh_token", "header_safe"],
196
295
  ["expires_at", "non_empty"],
197
296
  ["scope", "non_empty"],
@@ -289,6 +388,8 @@ function serializeOAuth(o) {
289
388
  if (o.expires_at) oauth["expires_at"] = o.expires_at;
290
389
  if (o.scope) oauth["scope"] = o.scope;
291
390
  if (o.token_type) oauth["token_type"] = o.token_type;
391
+ if (o.client_id) oauth["client_id"] = o.client_id;
392
+ if (o.token_endpoint) oauth["token_endpoint"] = o.token_endpoint;
292
393
  return oauth;
293
394
  }
294
395
  function serializeUser(u) {
@@ -305,214 +406,6 @@ function looksLikeApiKey(s) {
305
406
  return /^[!-~]+$/.test(s);
306
407
  }
307
408
 
308
- // src/auth/resolver.ts
309
- var ENV_CREDENTIAL_VAR = {
310
- env: "HEYGEN_API_KEY",
311
- env_alias: "HYPERFRAMES_API_KEY",
312
- env_oauth: "HEYGEN_ACCESS_TOKEN"
313
- };
314
- var envCredentialVar = (source) => source in ENV_CREDENTIAL_VAR ? ENV_CREDENTIAL_VAR[source] : void 0;
315
- var EXPIRY_SKEW_MS = 60 * 1e3;
316
- async function resolveCredential(opts = {}) {
317
- const now = (opts.now ?? (() => /* @__PURE__ */ new Date()))();
318
- const heygenEnv = headerSafeEnv(ENV_CREDENTIAL_VAR.env);
319
- if (heygenEnv) {
320
- return { type: "api_key", key: heygenEnv, source: "env" };
321
- }
322
- const hfEnv = headerSafeEnv(ENV_CREDENTIAL_VAR.env_alias);
323
- if (hfEnv) {
324
- return { type: "api_key", key: hfEnv, source: "env_alias" };
325
- }
326
- const accessToken = headerSafeEnv(ENV_CREDENTIAL_VAR.env_oauth);
327
- if (accessToken) {
328
- return { type: "oauth", access_token: accessToken, source: "env_oauth", refreshable: false };
329
- }
330
- const { credentials, source } = await readStore();
331
- if (source === "absent") throw ErrNotConfigured();
332
- const fileSource = source === "file_legacy" ? "file_legacy" : "file_json";
333
- const oauth = credentials.oauth ? pickOAuth(credentials.oauth, now, fileSource) : null;
334
- if (oauth) return oauth;
335
- if (credentials.api_key) {
336
- return { type: "api_key", key: credentials.api_key, source: fileSource };
337
- }
338
- throw credentials.oauth ? ErrLoginExpired() : ErrNotConfigured();
339
- }
340
- function headerSafeEnv(name) {
341
- const value = process.env[name];
342
- if (value && !isHeaderSafe(value)) {
343
- throw ErrInvalidStore(`${name} contains control characters`);
344
- }
345
- return value;
346
- }
347
- async function tryResolveCredential(opts = {}) {
348
- try {
349
- return await resolveCredential(opts);
350
- } catch (err) {
351
- if (isAuthError(err) && err.code === "NOT_CONFIGURED") {
352
- return null;
353
- }
354
- throw err;
355
- }
356
- }
357
- function pickOAuth(tokens, now, source) {
358
- const expiresAt = parseDate(tokens.expires_at);
359
- const expired = isTokenExpired(expiresAt, now);
360
- if (expired && !tokens.refresh_token) return null;
361
- const out = {
362
- type: "oauth",
363
- access_token: tokens.access_token,
364
- source,
365
- refreshable: expired && tokens.refresh_token !== void 0
366
- };
367
- if (tokens.refresh_token) out.refresh_token = tokens.refresh_token;
368
- if (expiresAt) out.expires_at = expiresAt;
369
- if (tokens.scope) out.scope = tokens.scope;
370
- return out;
371
- }
372
- function isTokenExpired(expiresAt, now) {
373
- return expiresAt !== void 0 && expiresAt.getTime() - EXPIRY_SKEW_MS < now.getTime();
374
- }
375
- function parseDate(s) {
376
- if (!s) return void 0;
377
- const d = new Date(s);
378
- return Number.isNaN(d.getTime()) ? void 0 : d;
379
- }
380
-
381
- // src/auth/scrub.ts
382
- var HEYGEN_KEY = /\b(hg|sk)_[A-Za-z0-9_-]{4,}/g;
383
- var HEADER_LINE = /(authorization|x-api-key)[ \t]*[:=][ \t]*[^\r\n]+/gi;
384
- var JWT = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
385
- var SECRET_FIELDS = [
386
- "access_token",
387
- "refresh_token",
388
- "code_verifier",
389
- "client_secret",
390
- "id_token",
391
- "token",
392
- "code"
393
- ];
394
- var FORM_FIELD = new RegExp(`\\b(${SECRET_FIELDS.join("|")})=[^&\\s"']+`, "gi");
395
- var JSON_FIELD = new RegExp(`("(?:${SECRET_FIELDS.join("|")})"\\s*:\\s*)"[^"]*"`, "gi");
396
- function scrubCredentials(s) {
397
- return s.replace(HEYGEN_KEY, "$1_<redacted>").replace(HEADER_LINE, "$1: <redacted>").replace(JWT, "<jwt-redacted>").replace(FORM_FIELD, "$1=<redacted>").replace(JSON_FIELD, '$1"<redacted>"');
398
- }
399
-
400
- // src/auth/client.ts
401
- var DEFAULT_BASE_URL = "https://api.heygen.com";
402
- var HEYGEN_CLI_SOURCE_HEADER = "X-HeyGen-Source";
403
- var HEYGEN_CLI_SOURCE = "cli";
404
- var HEYGEN_CLIENT_SOURCE_HEADER = "X-HeyGen-Client-Source";
405
- var HEYGEN_CLIENT_SOURCE = "hyperframes";
406
- function apiBaseUrl() {
407
- const override = process.env["HEYGEN_API_URL"];
408
- return override && override.length > 0 ? override.replace(/\/+$/, "") : DEFAULT_BASE_URL;
409
- }
410
- var AuthClient = class {
411
- base;
412
- fetchImpl;
413
- onRefresh;
414
- constructor(opts = {}) {
415
- this.base = (opts.baseUrl ?? apiBaseUrl()).replace(/\/+$/, "");
416
- this.fetchImpl = opts.fetchImpl ?? fetch;
417
- this.onRefresh = opts.onUnauthenticatedRefresh;
418
- }
419
- /**
420
- * `GET /v3/users/me`. Throws `ErrUnauthenticated` on 401, `ErrApi`
421
- * on any other non-2xx or non-JSON body.
422
- *
423
- * On OAuth 401 with a refresh hook configured, the request is
424
- * retried once after refreshing the access token. The retry's
425
- * outcome is what the caller sees — if the refresh itself fails
426
- * (REFRESH_FAILED) or the retry still 401s, the user lands on a
427
- * "please log in again" path upstream.
428
- */
429
- async getCurrentUser(credential) {
430
- const url = `${this.base}/v3/users/me`;
431
- return await this.fetchUser(url, credential, true);
432
- }
433
- // fallow-ignore-next-line complexity
434
- async fetchUser(url, credential, allowRefresh) {
435
- const headers = buildAuthHeaders(credential);
436
- const res = await this.fetchImpl(url, { method: "GET", headers });
437
- if (res.status === 401) {
438
- if (allowRefresh && credential.type === "oauth" && credential.refresh_token && this.onRefresh) {
439
- const refreshed = await this.tryRefresh(credential.refresh_token);
440
- if (refreshed) {
441
- const next = {
442
- ...credential,
443
- access_token: refreshed.access_token,
444
- ...refreshed.refresh_token ? { refresh_token: refreshed.refresh_token } : {}
445
- };
446
- return await this.fetchUser(url, next, false);
447
- }
448
- }
449
- const detail = await safeText(res);
450
- throw ErrUnauthenticated(detail || `${res.status} ${res.statusText}`);
451
- }
452
- if (!res.ok) {
453
- throw ErrApi(res.status, await safeText(res) || res.statusText);
454
- }
455
- let payload;
456
- try {
457
- payload = await res.json();
458
- } catch (err) {
459
- throw ErrApi(res.status, `non-JSON body: ${err.message}`);
460
- }
461
- return extractUserInfo(payload);
462
- }
463
- async tryRefresh(refresh_token) {
464
- if (!this.onRefresh) return null;
465
- try {
466
- return await this.onRefresh(refresh_token);
467
- } catch (err) {
468
- if (isAuthError(err) && err.code === "REFRESH_FAILED") return null;
469
- throw err;
470
- }
471
- }
472
- };
473
- function buildAuthHeaders(credential) {
474
- if (credential.type === "oauth") {
475
- return {
476
- authorization: `Bearer ${credential.access_token}`,
477
- [HEYGEN_CLI_SOURCE_HEADER]: HEYGEN_CLI_SOURCE,
478
- [HEYGEN_CLIENT_SOURCE_HEADER]: HEYGEN_CLIENT_SOURCE
479
- };
480
- }
481
- return { "x-api-key": credential.key, [HEYGEN_CLIENT_SOURCE_HEADER]: HEYGEN_CLIENT_SOURCE };
482
- }
483
- async function safeText(res) {
484
- try {
485
- const body = (await res.text()).slice(0, 500);
486
- return scrubCredentials(body);
487
- } catch {
488
- return "";
489
- }
490
- }
491
- function extractUserInfo(payload) {
492
- if (!payload || typeof payload !== "object" || Array.isArray(payload)) return {};
493
- const obj = payload;
494
- const wrapped = obj["data"];
495
- const data = wrapped && typeof wrapped === "object" && !Array.isArray(wrapped) ? wrapped : obj;
496
- return {
497
- username: pickString(data, "username"),
498
- email: pickString(data, "email"),
499
- first_name: pickString(data, "first_name"),
500
- last_name: pickString(data, "last_name"),
501
- billing_type: pickString(data, "billing_type"),
502
- wallet: pickObject(data, "wallet"),
503
- subscription: pickObject(data, "subscription"),
504
- usage_based: pickObject(data, "usage_based")
505
- };
506
- }
507
- function pickString(obj, key) {
508
- const v = obj[key];
509
- return typeof v === "string" ? v : void 0;
510
- }
511
- function pickObject(obj, key) {
512
- const v = obj[key];
513
- return v && typeof v === "object" && !Array.isArray(v) ? v : void 0;
514
- }
515
-
516
409
  // src/auth/pkce.ts
517
410
  import { createHash, randomBytes } from "crypto";
518
411
  var VERIFIER_BYTES = 64;
@@ -672,36 +565,13 @@ function printManualInstructions(url, detail) {
672
565
  // src/auth/oauth.ts
673
566
  var REVOKE_TIMEOUT_MS = 5e3;
674
567
  var MIN_EXPIRES_IN_SECONDS = 30;
675
- var DEFAULT_CLIENT_ID = "q2A2QRSke2LrFTPJhoDbHtXh";
676
568
  var DEFAULT_SCOPES = "openid profile email";
677
- var DEFAULT_AUTHORIZE_URL = "https://app.heygen.com/oauth/authorize";
678
- var DEFAULT_TOKEN_URL = "https://api2.heygen.com/v1/oauth/token";
679
- var DEFAULT_REVOKE_URL = "https://api2.heygen.com/v1/oauth/revoke";
680
- var DEFAULT_DEVICE_AUTHORIZATION_URL = "https://api2.heygen.com/v1/oauth/device_authorization";
681
569
  var DEVICE_CODE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:device_code";
682
570
  var MAX_DEVICE_FLOW_SECONDS = 30 * 60;
683
571
  var MIN_DEVICE_POLL_SECONDS = 5;
684
572
  var MAX_DEVICE_POLL_SECONDS = 60;
685
573
  var MAX_DEVICE_RESPONSE_BYTES = 64 * 1024;
686
574
  var DEVICE_REQUEST_TIMEOUT_MS = 15e3;
687
- function authorizeEndpoint() {
688
- return process.env["HYPERFRAMES_OAUTH_AUTHORIZE_URL"] || DEFAULT_AUTHORIZE_URL;
689
- }
690
- function tokenEndpoint() {
691
- return process.env["HYPERFRAMES_OAUTH_TOKEN_URL"] || DEFAULT_TOKEN_URL;
692
- }
693
- function revokeEndpoint() {
694
- return process.env["HYPERFRAMES_OAUTH_REVOKE_URL"] || DEFAULT_REVOKE_URL;
695
- }
696
- function deviceAuthorizationEndpoint() {
697
- return process.env["HYPERFRAMES_OAUTH_DEVICE_URL"] || DEFAULT_DEVICE_AUTHORIZATION_URL;
698
- }
699
- function resolveClientId() {
700
- const override = process.env["HYPERFRAMES_OAUTH_CLIENT_ID"];
701
- const id = override && override.length > 0 ? override : DEFAULT_CLIENT_ID;
702
- if (!id || id.length === 0) throw ErrOAuthNotConfigured();
703
- return id;
704
- }
705
575
  function assertOAuthConfiguredOrExit() {
706
576
  try {
707
577
  resolveClientId();
@@ -873,6 +743,9 @@ function retryAfterSeconds(response, nowMs) {
873
743
  return Math.min(Math.max(Math.ceil((retryAt - nowMs) / 1e3), 0), MAX_DEVICE_POLL_SECONDS);
874
744
  }
875
745
  async function refreshTokens(refresh_token, opts = {}) {
746
+ const { credentials } = await readStore();
747
+ if (credentials.oauth?.refresh_token !== refresh_token) throw ErrLoginChanged();
748
+ assertOAuthIdentity(credentials.oauth);
876
749
  const clientId = resolveClientId();
877
750
  const fetchImpl = opts.fetchImpl ?? fetch;
878
751
  const body = new URLSearchParams({
@@ -903,6 +776,10 @@ async function revokeTokens(token, opts = {}) {
903
776
  let clientId;
904
777
  try {
905
778
  clientId = resolveClientId();
779
+ const { credentials } = await readStore();
780
+ if (credentials.oauth && (credentials.oauth.access_token === token || credentials.oauth.refresh_token === token)) {
781
+ assertOAuthIdentity(credentials.oauth);
782
+ }
906
783
  } catch {
907
784
  return;
908
785
  }
@@ -1032,7 +909,7 @@ async function persistOAuth(tokens, opts = {}) {
1032
909
  if (opts.refreshed !== void 0 && existing.oauth?.refresh_token !== opts.refreshed) {
1033
910
  throw ErrLoginChanged();
1034
911
  }
1035
- const oauth = opts.refreshed !== void 0 ? { ...existing.oauth, ...tokens } : { ...tokens };
912
+ const oauth = opts.refreshed !== void 0 ? { ...existing.oauth, ...tokens, ...oauthIdentity() } : { ...tokens, ...oauthIdentity() };
1036
913
  await writeStore({ ...existing, oauth });
1037
914
  }
1038
915
  async function persistVerifiedOAuthSession(tokens, user) {
@@ -1044,7 +921,7 @@ async function persistVerifiedOAuthSession(tokens, user) {
1044
921
  }
1045
922
  const next = {
1046
923
  ...credentials,
1047
- oauth: { ...tokens }
924
+ oauth: { ...tokens, ...oauthIdentity() }
1048
925
  };
1049
926
  if (user.email || user.first_name || user.last_name || user.username) {
1050
927
  next.user = {
@@ -1190,26 +1067,100 @@ async function safeText2(res) {
1190
1067
  }
1191
1068
  }
1192
1069
 
1070
+ // src/auth/resolver.ts
1071
+ var ENV_CREDENTIAL_VAR = {
1072
+ env: "HEYGEN_API_KEY",
1073
+ env_alias: "HYPERFRAMES_API_KEY",
1074
+ env_oauth: "HEYGEN_ACCESS_TOKEN"
1075
+ };
1076
+ var envCredentialVar = (source) => source in ENV_CREDENTIAL_VAR ? ENV_CREDENTIAL_VAR[source] : void 0;
1077
+ var EXPIRY_SKEW_MS = 60 * 1e3;
1078
+ async function resolveCredential(opts = {}) {
1079
+ const now = (opts.now ?? (() => /* @__PURE__ */ new Date()))();
1080
+ const heygenEnv = headerSafeEnv(ENV_CREDENTIAL_VAR.env);
1081
+ if (heygenEnv) {
1082
+ return { type: "api_key", key: heygenEnv, source: "env" };
1083
+ }
1084
+ const hfEnv = headerSafeEnv(ENV_CREDENTIAL_VAR.env_alias);
1085
+ if (hfEnv) {
1086
+ return { type: "api_key", key: hfEnv, source: "env_alias" };
1087
+ }
1088
+ const accessToken = headerSafeEnv(ENV_CREDENTIAL_VAR.env_oauth);
1089
+ if (accessToken) {
1090
+ return { type: "oauth", access_token: accessToken, source: "env_oauth", refreshable: false };
1091
+ }
1092
+ const { credentials, source } = await readStore();
1093
+ if (source === "absent") throw ErrNotConfigured();
1094
+ const fileSource = source === "file_legacy" ? "file_legacy" : "file_json";
1095
+ if (credentials.oauth) assertOAuthIdentity(credentials.oauth);
1096
+ const oauth = credentials.oauth ? pickOAuth(credentials.oauth, now, fileSource) : null;
1097
+ if (oauth) return oauth;
1098
+ if (credentials.oauth) throw ErrLoginExpired();
1099
+ if (credentials.api_key) {
1100
+ return { type: "api_key", key: credentials.api_key, source: fileSource };
1101
+ }
1102
+ throw ErrNotConfigured();
1103
+ }
1104
+ function headerSafeEnv(name) {
1105
+ const value = process.env[name];
1106
+ if (value && !isHeaderSafe(value)) {
1107
+ throw ErrInvalidStore(`${name} contains control characters`);
1108
+ }
1109
+ return value;
1110
+ }
1111
+ async function tryResolveCredential(opts = {}) {
1112
+ try {
1113
+ return await resolveCredential(opts);
1114
+ } catch (err) {
1115
+ if (isAuthError(err) && err.code === "NOT_CONFIGURED") {
1116
+ return null;
1117
+ }
1118
+ throw err;
1119
+ }
1120
+ }
1121
+ function pickOAuth(tokens, now, source) {
1122
+ const expiresAt = parseDate(tokens.expires_at);
1123
+ const expired = isTokenExpired(expiresAt, now);
1124
+ if (expired && !tokens.refresh_token) return null;
1125
+ const out = {
1126
+ type: "oauth",
1127
+ access_token: tokens.access_token,
1128
+ source,
1129
+ refreshable: expired && tokens.refresh_token !== void 0
1130
+ };
1131
+ if (tokens.refresh_token) out.refresh_token = tokens.refresh_token;
1132
+ if (expiresAt) out.expires_at = expiresAt;
1133
+ if (tokens.scope) out.scope = tokens.scope;
1134
+ return out;
1135
+ }
1136
+ function isTokenExpired(expiresAt, now) {
1137
+ return expiresAt !== void 0 && expiresAt.getTime() - EXPIRY_SKEW_MS < now.getTime();
1138
+ }
1139
+ function parseDate(s) {
1140
+ if (!s) return void 0;
1141
+ const d = new Date(s);
1142
+ return Number.isNaN(d.getTime()) ? void 0 : d;
1143
+ }
1144
+
1193
1145
  export {
1194
- isAuthError,
1146
+ apiBaseUrl,
1147
+ AuthClient,
1148
+ buildAuthHeaders,
1195
1149
  readStore,
1196
1150
  writeStore,
1197
1151
  deleteStore,
1198
1152
  hasPreservedUnknownData,
1199
1153
  clearOAuth,
1200
1154
  isHeaderSafe,
1201
- ENV_CREDENTIAL_VAR,
1202
- envCredentialVar,
1203
- resolveCredential,
1204
- tryResolveCredential,
1205
- isTokenExpired,
1206
- apiBaseUrl,
1207
- AuthClient,
1208
- buildAuthHeaders,
1209
1155
  assertOAuthConfiguredOrExit,
1210
1156
  startAuthorizationCodeFlow,
1211
1157
  startDeviceAuthorizationFlow,
1212
1158
  refreshTokens,
1213
1159
  revokeTokens,
1214
- persistVerifiedOAuthSession
1160
+ persistVerifiedOAuthSession,
1161
+ ENV_CREDENTIAL_VAR,
1162
+ envCredentialVar,
1163
+ resolveCredential,
1164
+ tryResolveCredential,
1165
+ isTokenExpired
1215
1166
  };
@@ -10,7 +10,7 @@ import {
10
10
  } from "./chunk-CZGHFATT.js";
11
11
  import {
12
12
  findFfBinary
13
- } from "./chunk-VAS6HQX3.js";
13
+ } from "./chunk-BIROA7JM.js";
14
14
  import {
15
15
  cleanAssetUrl,
16
16
  collectSubCompositionSrcs,
@@ -11,7 +11,7 @@ import {
11
11
  distroLabel,
12
12
  getFFmpegInstallHint,
13
13
  parseLddMissingLibs
14
- } from "./chunk-BHWXSO6T.js";
14
+ } from "./chunk-LGMRZWJS.js";
15
15
  import {
16
16
  ensureBrowser,
17
17
  findBrowser
@@ -26,7 +26,7 @@ import {
26
26
  FFMPEG_PATH_ENV,
27
27
  FFPROBE_PATH_ENV,
28
28
  findFfBinary
29
- } from "./chunk-VAS6HQX3.js";
29
+ } from "./chunk-BIROA7JM.js";
30
30
  import {
31
31
  normalizeErrorMessage
32
32
  } from "./chunk-E63BDV4Z.js";
@@ -9,10 +9,10 @@ import {
9
9
  hasPreservedUnknownData,
10
10
  readStore,
11
11
  writeStore
12
- } from "./chunk-UVXIJYZY.js";
12
+ } from "./chunk-MESSJFK3.js";
13
13
  import {
14
14
  credentialPath
15
- } from "./chunk-4WEWHZZO.js";
15
+ } from "./chunk-VLA6UJGH.js";
16
16
 
17
17
  // src/auth/user.ts
18
18
  function isUserInfoEmpty(u) {