hyperframes 0.8.216 → 0.8.219
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/{add-2RWN7JAI.js → add-2MXC4QCY.js} +14 -14
- package/dist/{agentPromptGenerator-RVE5RWTH.js → agentPromptGenerator-FIT75HWJ.js} +8 -8
- package/dist/{animatedGifPrep-I32BS5HI.js → animatedGifPrep-MFUNECD3.js} +8 -8
- package/dist/api.js +19 -19
- package/dist/{asset-YLZ5UGVE.js → asset-T6BI53SJ.js} +2 -2
- package/dist/{assetCataloger-B4KOZO3V.js → assetCataloger-DP4SHXWI.js} +9 -9
- package/dist/{audio-VUOJ7MOJ.js → audio-SRQLO7BP.js} +19 -19
- package/dist/{auth-3UL65CN7.js → auth-JONDB26P.js} +8 -7
- package/dist/{autoUpdate-FEK5AHLP.js → autoUpdate-YKJOOXCI.js} +3 -3
- package/dist/{backgroundChecks-VJSQ3REH.js → backgroundChecks-GSTIIVNR.js} +4 -4
- package/dist/backgroundChecksWorker.js +4 -4
- package/dist/{batchRender-NC6SUDYN.js → batchRender-ESAPNTE3.js} +4 -4
- package/dist/{beats-KSUZ23LE.js → beats-OOVMTM4B.js} +13 -13
- package/dist/{benchmark-TRVQ7EPQ.js → benchmark-WBFYHOSI.js} +11 -11
- package/dist/{browser-3LJ3SLQ4.js → browser-AZZAO24H.js} +7 -7
- package/dist/{bundleWithLocalizedFonts-Y7VGIRFK.js → bundleWithLocalizedFonts-GP4MD6DJ.js} +2 -2
- package/dist/{capture-NT2SOO5J.js → capture-MGRV5VWE.js} +17 -17
- package/dist/{capture-NC5OO4D2.js → capture-PN7GEEAB.js} +3 -3
- package/dist/{captureCompositionFrame-PAJRNURH.js → captureCompositionFrame-JYGGPKFZ.js} +13 -13
- package/dist/{catalog-BOGZ2BQD.js → catalog-D42NLFZT.js} +14 -14
- package/dist/{catch-up-FGF5SAEW.js → catch-up-TUL26VOB.js} +7 -7
- package/dist/{check-IG6NIMSC.js → check-DBBH7DI3.js} +40 -40
- package/dist/{checkAudio-6B2FKTIU.js → checkAudio-UJ7XTDRD.js} +12 -12
- package/dist/{checkBrowser-D6MZRCTH.js → checkBrowser-3YIZYXIR.js} +34 -34
- package/dist/{chunk-5XTOAZMR.js → chunk-2UT32TJS.js} +1 -1
- package/dist/{chunk-4MWUMT3T.js → chunk-33XQUQKN.js} +2 -2
- package/dist/{chunk-UGQFQDSV.js → chunk-35JKCWYI.js} +1 -1
- package/dist/{chunk-Q3OKLJ34.js → chunk-3KDODK5M.js} +5 -2
- package/dist/{chunk-I3VXWMQW.js → chunk-3MTNYVWM.js} +5 -5
- package/dist/{chunk-MYHAS5U2.js → chunk-3VIICMJF.js} +1 -1
- package/dist/{chunk-EJTVBW42.js → chunk-473HMKSC.js} +2 -2
- package/dist/{chunk-IVRKWQTX.js → chunk-4I7KQWZS.js} +1 -1
- package/dist/{chunk-JFFQWMNE.js → chunk-4OWVRHSV.js} +5 -5
- package/dist/{chunk-NWYJZAPP.js → chunk-542VETC5.js} +1 -1
- package/dist/{chunk-MU66MHZB.js → chunk-576ATOOU.js} +2 -2
- package/dist/{chunk-KYXBPFI7.js → chunk-5UIODBMI.js} +8 -5
- package/dist/{chunk-7P76YIVS.js → chunk-64MFJSGZ.js} +1 -1
- package/dist/{chunk-U54ZBLTF.js → chunk-7ZRXSZF6.js} +2 -2
- package/dist/{chunk-DYHAZFK3.js → chunk-AU7VGKCP.js} +1 -1
- package/dist/{chunk-VAS6HQX3.js → chunk-BIROA7JM.js} +32 -3
- package/dist/{chunk-BTYR7Y3Z.js → chunk-BKHRAHV6.js} +2 -2
- package/dist/{chunk-ZCHULPJZ.js → chunk-BLBMPEBX.js} +6 -0
- package/dist/{chunk-557ZJMFI.js → chunk-BRU66Q24.js} +2 -2
- package/dist/{chunk-FUSUFW2L.js → chunk-BRYOYBO5.js} +1 -1
- package/dist/{chunk-RN7RQBW3.js → chunk-BT5UT4XT.js} +2 -2
- package/dist/{chunk-3AOXAXTA.js → chunk-C2G23WQQ.js} +1 -1
- package/dist/{chunk-ACAU2AK2.js → chunk-CBZN5JIK.js} +4 -4
- package/dist/{chunk-UJEEURID.js → chunk-CPKBAMI3.js} +14 -14
- package/dist/{chunk-VPA5YKEY.js → chunk-DMUDI5IH.js} +2 -2
- package/dist/{chunk-RH5Y75UX.js → chunk-DOZGTBDV.js} +2 -2
- package/dist/{chunk-RKS7GO4O.js → chunk-DWMI7CKI.js} +1 -1
- package/dist/{chunk-GHROWWUN.js → chunk-DWTFLQ3P.js} +33 -6
- package/dist/{chunk-SBBYMUWY.js → chunk-FAIFPYRO.js} +1 -1
- package/dist/{chunk-MKL6JGDL.js → chunk-FC7QIE5X.js} +59 -23
- package/dist/{chunk-RIGQABEL.js → chunk-FWWJRJB5.js} +1 -1
- package/dist/{chunk-4EEVTNDU.js → chunk-G2E2DHH2.js} +3 -3
- package/dist/{chunk-QRIC4WOO.js → chunk-G7ZTD2KJ.js} +9 -3
- package/dist/{chunk-VDFY4FE5.js → chunk-GGDVZ7O4.js} +10 -10
- package/dist/{chunk-6LQL2BVD.js → chunk-GHWV6PIS.js} +1 -1
- package/dist/{chunk-QGMRSNG5.js → chunk-GP5X7V6U.js} +4 -3
- package/dist/{chunk-YT4DR2UT.js → chunk-IGZHC55Z.js} +7 -7
- package/dist/{chunk-2JV6FKNZ.js → chunk-ILCIWNPQ.js} +3 -3
- package/dist/{chunk-7VZEOCUY.js → chunk-J74ZUXVU.js} +1 -1
- package/dist/{chunk-MO6DJMZP.js → chunk-JH2AO4ZW.js} +2 -2
- package/dist/{chunk-4YIKQM4K.js → chunk-K5GGTJJV.js} +1 -1
- package/dist/{chunk-OWU2BURB.js → chunk-KENUKJRG.js} +2 -2
- package/dist/{chunk-ZRK7ZEWI.js → chunk-KK5MZQXG.js} +3 -3
- package/dist/{chunk-EB44YMQO.js → chunk-KUQOUWJ4.js} +3 -3
- package/dist/{chunk-BHWXSO6T.js → chunk-LGMRZWJS.js} +9 -3
- package/dist/{chunk-OFJTXNRS.js → chunk-LIWBGRPD.js} +3 -3
- package/dist/{chunk-JOZQFSOV.js → chunk-LJB2PF6K.js} +1 -1
- package/dist/{chunk-ROUK3OL2.js → chunk-LJUFR7G5.js} +7 -7
- package/dist/{chunk-UVXIJYZY.js → chunk-MESSJFK3.js} +249 -298
- package/dist/{chunk-JF3RF6GS.js → chunk-MHZB6QSC.js} +1 -1
- package/dist/{chunk-CBCZBHGK.js → chunk-NHXGFQWQ.js} +2 -2
- package/dist/{chunk-CX4TSC7T.js → chunk-NP2QEAEW.js} +38 -27
- package/dist/{chunk-URUUGFZD.js → chunk-O7YOS36L.js} +13 -6
- package/dist/{chunk-43USF7JF.js → chunk-QE5JXNSW.js} +24 -17
- package/dist/{chunk-TQSKEMSL.js → chunk-QEKP7XCN.js} +3 -3
- package/dist/{chunk-GTKUQUZ6.js → chunk-RYBFHEMZ.js} +1 -1
- package/dist/{chunk-7RPXLY6U.js → chunk-TCV7N2UY.js} +1 -1
- package/dist/{chunk-634HSJ3J.js → chunk-TK7THLRO.js} +10 -3
- package/dist/{chunk-RXQU3QM4.js → chunk-TNQ4SSTR.js} +9 -9
- package/dist/{chunk-LGZP4IR2.js → chunk-U2EUCTYQ.js} +4 -4
- package/dist/{chunk-DFA5GTRJ.js → chunk-UDBW6TK4.js} +1 -1
- package/dist/{chunk-6HJUC2VX.js → chunk-UGDLT4LZ.js} +3 -3
- package/dist/{chunk-SPFTXNKQ.js → chunk-UR6L2DXM.js} +20 -15
- package/dist/{chunk-KBTXAUCZ.js → chunk-UWV753SJ.js} +1 -1
- package/dist/chunk-VLA6UJGH.js +139 -0
- package/dist/{chunk-Z4W7ND2L.js → chunk-VO7IEWOH.js} +6 -6
- package/dist/{chunk-BYHG2T5X.js → chunk-VP5KECBU.js} +2 -2
- package/dist/{chunk-USQTLRSD.js → chunk-VTLIN7XN.js} +2 -2
- package/dist/{chunk-UIETUYFT.js → chunk-WUABYDXU.js} +1 -1
- package/dist/{chunk-TBEU55KU.js → chunk-XUOLKUE7.js} +1 -1
- package/dist/{chunk-3S2WWGJJ.js → chunk-XUTPVELE.js} +3 -3
- package/dist/{chunk-OPLEWQHF.js → chunk-XXLG7GCA.js} +1 -1
- package/dist/{chunk-PNE2Y42T.js → chunk-YATFRFNH.js} +1 -1
- package/dist/{chunk-PPMLF76Z.js → chunk-YSTBSLWY.js} +1 -1
- package/dist/{chunk-VZENYSX7.js → chunk-YXZ56JUN.js} +44 -33
- package/dist/{chunk-QETCWXRM.js → chunk-Z537IJJH.js} +4 -4
- package/dist/{clean-WPLBDRSW.js → clean-YERX334S.js} +20 -20
- package/dist/cli.js +57 -66
- package/dist/{cloud-VMSG2SJB.js → cloud-5XFWROJK.js} +4 -4
- package/dist/{cloudrun-AXB4G6X2.js → cloudrun-5XEDIP77.js} +5 -5
- package/dist/commands/layout-audit.browser.js +32 -2
- package/dist/{compare-NVW3E74E.js → compare-THYM62NL.js} +31 -31
- package/dist/{compiler-GHX7QLHL.js → compiler-SLKHXYCO.js} +4 -4
- package/dist/{component-ZQAP7CBI.js → component-N4FFNYA5.js} +3 -3
- package/dist/{compositions-FKHNCB6H.js → compositions-XCM3Z65K.js} +14 -14
- package/dist/{delete-XYC7FN6A.js → delete-6PIKDOKV.js} +7 -7
- package/dist/{deploy-DOJS666X.js → deploy-PT77AP6G.js} +1 -1
- package/dist/{dist-3Q2DNDSR.js → dist-VNOJCTQR.js} +3 -3
- package/dist/{dist-KXFW5H5Q.js → dist-XXBCSQYF.js} +2 -2
- package/dist/{doctor-7CUFMW3Y.js → doctor-KLDSXKUM.js} +14 -14
- package/dist/{dotEnv-RPHCAUBZ.js → dotEnv-BGFXSQOA.js} +7 -5
- package/dist/{events-KGXVDZV7.js → events-KEJFQQDQ.js} +6 -6
- package/dist/{events-K7HUJ4DO.js → events-OHISH3KL.js} +4 -4
- package/dist/{feedback-F7WLYJGJ.js → feedback-VTLWYGLQ.js} +26 -14
- package/dist/{ffmpeg-ZFHN4YZ2.js → ffmpeg-SG3AYA6M.js} +8 -8
- package/dist/{figma-7QKRKT5Q.js → figma-5AHFOYPG.js} +3 -3
- package/dist/fontLocalizeCli.js +11 -11
- package/dist/{get-XKPYG6IC.js → get-5VTBUZIR.js} +7 -7
- package/dist/{gpuPolicy-A74BROG6.js → gpuPolicy-ODODH5JV.js} +8 -8
- package/dist/{grade-compare-7SR62TE5.js → grade-compare-25HQJORH.js} +32 -32
- package/dist/{heifImagePrep-XTCBHE3B.js → heifImagePrep-SPBGWX2L.js} +9 -9
- package/dist/{help-B7CXC4J5.js → help-3AZ4ZSWZ.js} +1 -1
- package/dist/{history-3INEHHZ4.js → history-KZFZ2MJI.js} +9 -9
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +26 -26
- package/dist/hyperframes-player.global.js +1 -1
- package/dist/{info-J3U63EFT.js → info-XNYSD2SN.js} +10 -10
- package/dist/{init-2IEXXRG2.js → init-C76MX2UE.js} +31 -31
- package/dist/{inspect-IRJABR66.js → inspect-OWDJTC64.js} +32 -32
- package/dist/{installer-6JLQM6OJ.js → installer-OFIDWMYR.js} +5 -5
- package/dist/{keyframes-G2TSKZRL.js → keyframes-ZBIWACNT.js} +9 -9
- package/dist/{lambda-QFFFCFK3.js → lambda-XS3E4XSL.js} +12 -12
- package/dist/{layout-INRUYIDJ.js → layout-HLU3IVDX.js} +32 -32
- package/dist/{lint-BHPBD7Z3.js → lint-DUJ5PM56.js} +11 -11
- package/dist/{lintProject-SZIPPOJR.js → lintProject-I4XPWIQZ.js} +2 -2
- package/dist/{list-BGL5PH6J.js → list-KRDQLHDH.js} +7 -7
- package/dist/{localPage-MLFDX4Y6.js → localPage-KXNSCQIQ.js} +8 -8
- package/dist/{login-ABDL65L6.js → login-4P7LCOB5.js} +9 -8
- package/dist/{logout-CXGSSQ4Q.js → logout-6VFJ7WMW.js} +4 -4
- package/dist/{manager-LXWVBDLM.js → manager-I4ROBMYK.js} +1 -1
- package/dist/{manager-DEKPCPWH.js → manager-USFB6SE2.js} +9 -9
- package/dist/{media-treatment-BQDTCBIT.js → media-treatment-JOZB3MTT.js} +16 -16
- package/dist/{media-use-ZRHFRO46.js → media-use-ZNTB7W6N.js} +85 -10
- package/dist/{models-SJIA5QDV.js → models-RZRXHIER.js} +12 -12
- package/dist/{motionShot-46J3W5UJ.js → motionShot-3SHLRT3L.js} +17 -17
- package/dist/{normalize-audio-UXAJSQKI.js → normalize-audio-SL2ATLJM.js} +20 -14
- package/dist/{open-DHRYP3N3.js → open-TCGY4NB2.js} +14 -14
- package/dist/{parakeetRunner-WKMM4TYU.js → parakeetRunner-ZBO4LR7M.js} +14 -14
- package/dist/{pipeline-EIVKRUX2.js → pipeline-7D36B3FW.js} +11 -11
- package/dist/{play-J5A7KHNF.js → play-CTBPJFBX.js} +23 -23
- package/dist/{preflight-GKIQIXFQ.js → preflight-GFWIOUO3.js} +10 -10
- package/dist/{present-ZDXILGQJ.js → present-GXOHUNFP.js} +19 -19
- package/dist/{preview-A2MLHZFF.js → preview-BWCEXEII.js} +21 -21
- package/dist/{producer-NYWYRG4X.js → producer-UME4Q4HH.js} +1 -1
- package/dist/{projectConfig-DY6FHC7A.js → projectConfig-I6QNMRVV.js} +7 -7
- package/dist/{publication-N4WHPZOW.js → publication-JET7ZBWG.js} +3 -3
- package/dist/{publish-26W6VDND.js → publish-ZGW46SKV.js} +16 -16
- package/dist/{refresh-VJ4FQVH2.js → refresh-I6ITGHKL.js} +5 -4
- package/dist/{remove-background-JYUB75RB.js → remove-background-YSJ7XFPQ.js} +12 -12
- package/dist/{render-YPI6CDRS.js → render-33TSTTN7.js} +6 -6
- package/dist/{render-AQH2VMHO.js → render-Q2VLJGFV.js} +86 -42
- package/dist/{render-JZWO3VX3.js → render-QFIWTDK3.js} +23 -23
- package/dist/{render-batch-GR2Y3F2S.js → render-batch-SDDZ3LM7.js} +6 -6
- package/dist/renderSetupWorker.js +3 -3
- package/dist/{resolver-LTLSX6DR.js → resolver-VLOUQ7I6.js} +5 -5
- package/dist/{sherpa-2DJ33LQP.js → sherpa-YKK3LRSI.js} +13 -13
- package/dist/skills/hyperframes-cli/references/cloud.md +4 -4
- package/dist/skills/media-use/SKILL.md +3 -1
- package/dist/skills/media-use/audio/references/bgm.md +1 -1
- package/dist/skills/media-use/audio/references/requirements.md +9 -9
- package/dist/skills/media-use/audio/references/tts.md +11 -11
- package/dist/skills/media-use/audio/scripts/gemini-pipeline.test.mjs +1 -1
- package/dist/skills/media-use/audio/scripts/heygen-tts.mjs +1 -1
- package/dist/skills/media-use/audio/scripts/lib/audio-meta.test.mjs +1 -1
- package/dist/skills/media-use/audio/scripts/lib/heygen.mjs +23 -7
- package/dist/skills/media-use/audio/scripts/lib/heygen.test.mjs +68 -10
- package/dist/skills/media-use/audio/scripts/lib/tts.mjs +1 -1
- package/dist/skills/media-use/audio/scripts/lib/tts.test.mjs +2 -2
- package/dist/skills/media-use/references/operations.md +11 -9
- package/dist/skills/media-use/references/setup-providers.md +30 -30
- package/dist/skills/media-use/scripts/lib/heygen-cli.mjs +2 -2
- package/dist/skills/media-use/scripts/lib/telemetry.mjs +2 -1
- package/dist/skills/media-use/scripts/lib/telemetry.test.mjs +49 -4
- package/dist/{skills-OF7XMPKX.js → skills-5ENIWSB2.js} +8 -8
- package/dist/{skillsUpdateCheck-E3HPT4PS.js → skillsUpdateCheck-7GDJNW5A.js} +4 -4
- package/dist/{snapshot-6F5XK22M.js → snapshot-O3JXB3VM.js} +39 -42
- package/dist/{src-JUJFZ6GC.js → src-6T5KES5G.js} +7 -7
- package/dist/{src-UNN3TXHH.js → src-MT7UQJT5.js} +12 -10
- package/dist/{staticProjectServer-DLSH7DHS.js → staticProjectServer-UP22EGMU.js} +19 -19
- package/dist/{status-TJFZFDGS.js → status-63BKLDVW.js} +40 -11
- package/dist/studio/assets/{hyperframes-player-D38lr2hR.js → hyperframes-player-B83GGznX.js} +1 -1
- package/dist/studio/assets/{index-C-DCQ7nQ.js → index-B9gVTopE.js} +108 -108
- package/dist/studio/assets/{index-CJ28BLvq.js → index-Ca_tSAqR.js} +1 -1
- package/dist/studio/index.html +1 -1
- package/dist/{studio-api-5YATSN7H.js → studio-api-Q6KSNU77.js} +11 -11
- package/dist/{studioServer-O3FSLOUF.js → studioServer-44OR56TK.js} +53 -53
- package/dist/{telemetry-MMCJ2ORL.js → telemetry-2N7DLYCQ.js} +6 -6
- package/dist/{telemetry-CY7V7FIN.js → telemetry-QHYJJAJU.js} +1 -1
- package/dist/{timeline-ZBJTZK6E.js → timeline-MT56A3HB.js} +21 -21
- package/dist/{tokens-JFYRYRDK.js → tokens-V6O4I5IX.js} +2 -2
- package/dist/{transcribe-QUMMQM34.js → transcribe-GGV4YEF3.js} +12 -12
- package/dist/{transcribe-UVQQ3OMR.js → transcribe-ZCJ6WB6R.js} +20 -20
- package/dist/{updateCheck-VMMBGLTI.js → updateCheck-ZBBUGX3A.js} +3 -3
- package/dist/{upgrade-4VYNPIFQ.js → upgrade-L7SM3TPB.js} +3 -3
- package/dist/{urlDownloader-EAPV3CZL.js → urlDownloader-HTBT6K5N.js} +7 -7
- package/dist/{validate-JJG6Q6IH.js → validate-WXKYRV2E.js} +26 -26
- package/dist/{video-7MJZ7IYL.js → video-JH5WQC2I.js} +9 -9
- package/dist/warmCheck.js +40 -40
- package/package.json +1 -1
- 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
|
-
|
|
9
|
-
|
|
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/
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
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
|
};
|
|
@@ -9,10 +9,10 @@ import {
|
|
|
9
9
|
hasPreservedUnknownData,
|
|
10
10
|
readStore,
|
|
11
11
|
writeStore
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-MESSJFK3.js";
|
|
13
13
|
import {
|
|
14
14
|
credentialPath
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-VLA6UJGH.js";
|
|
16
16
|
|
|
17
17
|
// src/auth/user.ts
|
|
18
18
|
function isUserInfoEmpty(u) {
|