tenjin-cli 0.1.0-alpha.33 → 0.1.0-alpha.35
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/NOTICE.md +110 -0
- package/README.md +87 -81
- package/dist/{_esm-BIN7VY2L.js → _esm-2KST7HQ7.js} +7 -7
- package/dist/alive-5TV22PNF.js +51 -0
- package/dist/auth-XI7BJFLW.js +47 -0
- package/dist/{auto-update-Y24UL56V.js → auto-update-7L24KDWA.js} +4 -5
- package/dist/balance-DFHC6XEU.js +71 -0
- package/dist/{ccip-DHDFKTQV.js → ccip-HOW3DZYF.js} +4 -4
- package/dist/chunk-24XKUN2S.js +202 -0
- package/dist/chunk-24XKUN2S.js.map +1 -0
- package/dist/chunk-2L7TDGLV.js +56 -0
- package/dist/chunk-2L7TDGLV.js.map +1 -0
- package/dist/{chunk-C2Q76BVM.js → chunk-2U7H35IP.js} +29 -7
- package/dist/chunk-2U7H35IP.js.map +1 -0
- package/dist/chunk-2W4DQQUU.js +176 -0
- package/dist/chunk-2W4DQQUU.js.map +1 -0
- package/dist/{chunk-LRW6S53P.js → chunk-34SAECKZ.js} +35 -11
- package/dist/chunk-34SAECKZ.js.map +1 -0
- package/dist/{chunk-2I4QTOLB.js → chunk-3MZ7DYRO.js} +1 -1
- package/dist/chunk-3MZ7DYRO.js.map +1 -0
- package/dist/{chunk-RVPYTUP4.js → chunk-3Y2EHT4F.js} +13 -9
- package/dist/chunk-3Y2EHT4F.js.map +1 -0
- package/dist/chunk-3Y6BHIN6.js +169 -0
- package/dist/chunk-3Y6BHIN6.js.map +1 -0
- package/dist/{chunk-4K7TQHNP.js → chunk-3YPL6T3P.js} +17 -33
- package/dist/chunk-3YPL6T3P.js.map +1 -0
- package/dist/{chunk-E7SW44LM.js → chunk-44MVIRZH.js} +121 -6
- package/dist/chunk-44MVIRZH.js.map +1 -0
- package/dist/chunk-45MMSBHA.js +321 -0
- package/dist/chunk-45MMSBHA.js.map +1 -0
- package/dist/{chunk-3FMZGI7I.js → chunk-4CE6TMI5.js} +1 -1
- package/dist/chunk-4CE6TMI5.js.map +1 -0
- package/dist/{chunk-QXP3Z3JN.js → chunk-4MBCJFY4.js} +35 -3
- package/dist/chunk-4MBCJFY4.js.map +1 -0
- package/dist/chunk-4TPL54KW.js +227 -0
- package/dist/chunk-4TPL54KW.js.map +1 -0
- package/dist/chunk-54ELBTKE.js +1615 -0
- package/dist/chunk-54ELBTKE.js.map +1 -0
- package/dist/{chunk-NDGZDTSJ.js → chunk-5F4OB5B3.js} +115 -57
- package/dist/chunk-5F4OB5B3.js.map +1 -0
- package/dist/chunk-5HN4KVQU.js +3348 -0
- package/dist/chunk-5HN4KVQU.js.map +1 -0
- package/dist/{chunk-ZDZERB6L.js → chunk-5J4E5GYI.js} +572 -407
- package/dist/chunk-5J4E5GYI.js.map +1 -0
- package/dist/{chunk-ZNNXRNFD.js → chunk-5N4GGUBN.js} +48 -6
- package/dist/chunk-5N4GGUBN.js.map +1 -0
- package/dist/chunk-5USBZ2MU.js +58 -0
- package/dist/chunk-5USBZ2MU.js.map +1 -0
- package/dist/chunk-64WOMNYR.js +183 -0
- package/dist/chunk-64WOMNYR.js.map +1 -0
- package/dist/{chunk-ILNIZ5I2.js → chunk-65RS4LQS.js} +1825 -1715
- package/dist/chunk-65RS4LQS.js.map +1 -0
- package/dist/{chunk-IE7P2BZE.js → chunk-6QMDUDF2.js} +3 -3
- package/dist/{chunk-IADZOXKN.js → chunk-7SLOTLO7.js} +19 -697
- package/dist/chunk-7SLOTLO7.js.map +1 -0
- package/dist/{chunk-WFSPCCVW.js → chunk-7V25UAQO.js} +99 -99
- package/dist/{chunk-WFSPCCVW.js.map → chunk-7V25UAQO.js.map} +1 -1
- package/dist/chunk-BGA4DO5M.js +719 -0
- package/dist/chunk-BGA4DO5M.js.map +1 -0
- package/dist/chunk-BVP7YK2J.js +706 -0
- package/dist/chunk-BVP7YK2J.js.map +1 -0
- package/dist/chunk-C265QIMJ.js +83 -0
- package/dist/chunk-C265QIMJ.js.map +1 -0
- package/dist/{chunk-XQJXNMSB.js → chunk-CRG54LEB.js} +1 -1
- package/dist/chunk-CRG54LEB.js.map +1 -0
- package/dist/{chunk-KG3D7FIF.js → chunk-CZJOMUBP.js} +2 -2
- package/dist/{chunk-36RVGZNY.js → chunk-D6M3ZK66.js} +22 -39
- package/dist/chunk-D6M3ZK66.js.map +1 -0
- package/dist/{chunk-3UCIG4TG.js → chunk-DI4QAGRZ.js} +1 -11
- package/dist/chunk-DI4QAGRZ.js.map +1 -0
- package/dist/{chunk-JKKAIPTU.js → chunk-DIH2G3YG.js} +47 -10
- package/dist/chunk-DIH2G3YG.js.map +1 -0
- package/dist/chunk-DJ36BM62.js +78 -0
- package/dist/chunk-DJ36BM62.js.map +1 -0
- package/dist/chunk-DTEWAVNE.js +114 -0
- package/dist/chunk-DTEWAVNE.js.map +1 -0
- package/dist/chunk-F2KJAJ7T.js +13 -0
- package/dist/chunk-F2KJAJ7T.js.map +1 -0
- package/dist/{chunk-BF4XHEQK.js → chunk-F3QPGYOY.js} +6 -6
- package/dist/chunk-F3QPGYOY.js.map +1 -0
- package/dist/{chunk-3GNJXKIT.js → chunk-F43CV6UC.js} +2 -2
- package/dist/{chunk-J57UC3DD.js → chunk-FKVJKLPI.js} +3 -3
- package/dist/{chunk-V2LQLN5H.js → chunk-FYFHH7V5.js} +59 -8
- package/dist/{chunk-V2LQLN5H.js.map → chunk-FYFHH7V5.js.map} +1 -1
- package/dist/chunk-GAJC4BQZ.js +1096 -0
- package/dist/chunk-GAJC4BQZ.js.map +1 -0
- package/dist/{chunk-DOQGNFHM.js → chunk-GH5UKMZD.js} +2 -12
- package/dist/{chunk-DOQGNFHM.js.map → chunk-GH5UKMZD.js.map} +1 -1
- package/dist/{chunk-WYXUQGOL.js → chunk-HAZAN4UM.js} +7 -6
- package/dist/chunk-HAZAN4UM.js.map +1 -0
- package/dist/chunk-HI5XQOX2.js +393 -0
- package/dist/chunk-HI5XQOX2.js.map +1 -0
- package/dist/chunk-HKGUKAQW.js +488 -0
- package/dist/chunk-HKGUKAQW.js.map +1 -0
- package/dist/{chunk-SO3XRZPX.js → chunk-HPRVFJPM.js} +6 -6
- package/dist/{chunk-L6JEXB3E.js → chunk-HQR4BWKX.js} +3 -131
- package/dist/chunk-HQR4BWKX.js.map +1 -0
- package/dist/chunk-HZKANST2.js +177 -0
- package/dist/chunk-HZKANST2.js.map +1 -0
- package/dist/{chunk-UUGOUOVT.js → chunk-I557SAOM.js} +8 -2
- package/dist/chunk-I557SAOM.js.map +1 -0
- package/dist/{chunk-TC2WZLSC.js → chunk-IGLWLH73.js} +8 -7
- package/dist/chunk-IGLWLH73.js.map +1 -0
- package/dist/chunk-ILWCKCOI.js +58 -0
- package/dist/chunk-ILWCKCOI.js.map +1 -0
- package/dist/{chunk-2GP3HRYK.js → chunk-INSIW65E.js} +182 -182
- package/dist/{chunk-MPZUYCAP.js → chunk-IULCDMVG.js} +12 -1
- package/dist/chunk-IULCDMVG.js.map +1 -0
- package/dist/{chunk-INTFHMU4.js → chunk-IVNSUAVC.js} +25 -26
- package/dist/chunk-IVNSUAVC.js.map +1 -0
- package/dist/chunk-JDQZCREI.js +87 -0
- package/dist/chunk-JDQZCREI.js.map +1 -0
- package/dist/chunk-JHFFUVON.js +1050 -0
- package/dist/chunk-JHFFUVON.js.map +1 -0
- package/dist/{chunk-RL5UUDT4.js → chunk-JNUKLSMZ.js} +3 -3
- package/dist/chunk-JTILUN4W.js +2933 -0
- package/dist/chunk-JTILUN4W.js.map +1 -0
- package/dist/{chunk-OJNTCYQQ.js → chunk-JTX3BUDK.js} +37 -53
- package/dist/chunk-JTX3BUDK.js.map +1 -0
- package/dist/{chunk-X5ZBP3IY.js → chunk-JUUBBBY5.js} +2 -2
- package/dist/chunk-JUUBBBY5.js.map +1 -0
- package/dist/chunk-JWAK7JQB.js +15 -0
- package/dist/chunk-JWAK7JQB.js.map +1 -0
- package/dist/{chunk-UXZONNEQ.js → chunk-K5KNGC4I.js} +34 -31
- package/dist/chunk-K5KNGC4I.js.map +1 -0
- package/dist/chunk-KAQ4Q3TO.js +135 -0
- package/dist/chunk-KAQ4Q3TO.js.map +1 -0
- package/dist/chunk-KFVJYLVL.js +125 -0
- package/dist/chunk-KFVJYLVL.js.map +1 -0
- package/dist/chunk-KGUE5AVX.js +69 -0
- package/dist/chunk-KGUE5AVX.js.map +1 -0
- package/dist/{chunk-FVIGCDSV.js → chunk-KLDMLWXT.js} +11 -85
- package/dist/chunk-KLDMLWXT.js.map +1 -0
- package/dist/chunk-KNKDMTHU.js +453 -0
- package/dist/chunk-KNKDMTHU.js.map +1 -0
- package/dist/chunk-LDA6TAYQ.js +95 -0
- package/dist/chunk-LDA6TAYQ.js.map +1 -0
- package/dist/chunk-LWSSIZOY.js +347 -0
- package/dist/chunk-LWSSIZOY.js.map +1 -0
- package/dist/{chunk-ZURZHELF.js → chunk-MAHNZA6C.js} +158 -41
- package/dist/chunk-MAHNZA6C.js.map +1 -0
- package/dist/chunk-MEWZCIA6.js +220 -0
- package/dist/chunk-MEWZCIA6.js.map +1 -0
- package/dist/{chunk-2SNUOHAT.js → chunk-MEZJ3I63.js} +49 -1
- package/dist/chunk-MEZJ3I63.js.map +1 -0
- package/dist/chunk-MJDO4EXD.js +353 -0
- package/dist/chunk-MJDO4EXD.js.map +1 -0
- package/dist/chunk-NJA6NT3A.js +6595 -0
- package/dist/chunk-NJA6NT3A.js.map +1 -0
- package/dist/{chunk-LHHMV4GU.js → chunk-NVSKJPRC.js} +1 -1
- package/dist/{chunk-LHHMV4GU.js.map → chunk-NVSKJPRC.js.map} +1 -1
- package/dist/{chunk-4YOZGGTZ.js → chunk-OC7K2DVZ.js} +5 -5
- package/dist/chunk-OC7K2DVZ.js.map +1 -0
- package/dist/chunk-ODRPASFP.js +2078 -0
- package/dist/chunk-ODRPASFP.js.map +1 -0
- package/dist/chunk-OJJFANO6.js +133 -0
- package/dist/chunk-OJJFANO6.js.map +1 -0
- package/dist/{chunk-JNJWBTU2.js → chunk-OQWPRFAC.js} +332 -882
- package/dist/chunk-OQWPRFAC.js.map +1 -0
- package/dist/chunk-P4I7BFNJ.js +11 -0
- package/dist/chunk-P4I7BFNJ.js.map +1 -0
- package/dist/{chunk-SNNSAGMT.js → chunk-P6YQWIT2.js} +4058 -4039
- package/dist/chunk-P6YQWIT2.js.map +1 -0
- package/dist/{chunk-JRGFKVAZ.js → chunk-PETQ5WEA.js} +2 -2
- package/dist/{chunk-HMWYAUA6.js → chunk-Q6RSJCXB.js} +29 -69
- package/dist/chunk-Q6RSJCXB.js.map +1 -0
- package/dist/{chunk-U3IKUGRP.js → chunk-QKEUKBRK.js} +17 -23
- package/dist/chunk-QKEUKBRK.js.map +1 -0
- package/dist/{chunk-2RWB7RKE.js → chunk-QKYUCITR.js} +174 -5814
- package/dist/chunk-QKYUCITR.js.map +1 -0
- package/dist/chunk-QQDPRTLP.js +127 -0
- package/dist/chunk-QQDPRTLP.js.map +1 -0
- package/dist/chunk-QQYCYAKI.js +79 -0
- package/dist/chunk-QQYCYAKI.js.map +1 -0
- package/dist/chunk-R4KDH477.js +1064 -0
- package/dist/chunk-R4KDH477.js.map +1 -0
- package/dist/chunk-R5TR2DIK.js +119 -0
- package/dist/chunk-R5TR2DIK.js.map +1 -0
- package/dist/chunk-R62PKTAG.js +66 -0
- package/dist/chunk-R62PKTAG.js.map +1 -0
- package/dist/{chunk-BFDQ4WNW.js → chunk-RFZA7PSM.js} +4 -5
- package/dist/chunk-RFZA7PSM.js.map +1 -0
- package/dist/chunk-RGCPELQN.js +219 -0
- package/dist/chunk-RGCPELQN.js.map +1 -0
- package/dist/chunk-RGVCOG2S.js +910 -0
- package/dist/chunk-RGVCOG2S.js.map +1 -0
- package/dist/chunk-SOLNJ3AZ.js +209 -0
- package/dist/chunk-SOLNJ3AZ.js.map +1 -0
- package/dist/chunk-TFT2X7SH.js +77 -0
- package/dist/chunk-TFT2X7SH.js.map +1 -0
- package/dist/chunk-TUCKEEXE.js +2 -0
- package/dist/chunk-TVWCLUBI.js +293 -0
- package/dist/chunk-TVWCLUBI.js.map +1 -0
- package/dist/chunk-U4TRWSVE.js +78 -0
- package/dist/chunk-U4TRWSVE.js.map +1 -0
- package/dist/chunk-UIB33QQP.js +379 -0
- package/dist/chunk-UIB33QQP.js.map +1 -0
- package/dist/chunk-V6GIVALQ.js +1889 -0
- package/dist/chunk-V6GIVALQ.js.map +1 -0
- package/dist/chunk-VHXCPXUS.js +366 -0
- package/dist/chunk-VHXCPXUS.js.map +1 -0
- package/dist/{chunk-HGZEPQUT.js → chunk-VU6GMWF6.js} +17 -8
- package/dist/chunk-VU6GMWF6.js.map +1 -0
- package/dist/chunk-VWZYE3NC.js +8415 -0
- package/dist/chunk-VWZYE3NC.js.map +1 -0
- package/dist/{chunk-AGMVASXZ.js → chunk-W2GXIARJ.js} +88 -11
- package/dist/chunk-W2GXIARJ.js.map +1 -0
- package/dist/chunk-W4G3K3V7.js +288 -0
- package/dist/chunk-W4G3K3V7.js.map +1 -0
- package/dist/chunk-W74LJ5OT.js +588 -0
- package/dist/chunk-W74LJ5OT.js.map +1 -0
- package/dist/chunk-W7ELYLYK.js +233 -0
- package/dist/chunk-W7ELYLYK.js.map +1 -0
- package/dist/{chunk-BPMWXTFX.js → chunk-WFZX352D.js} +7 -7
- package/dist/chunk-WXA3WTPF.js +20 -0
- package/dist/chunk-WXA3WTPF.js.map +1 -0
- package/dist/chunk-XRGFH7FI.js +454 -0
- package/dist/chunk-XRGFH7FI.js.map +1 -0
- package/dist/chunk-XSCGUO2U.js +330 -0
- package/dist/chunk-XSCGUO2U.js.map +1 -0
- package/dist/chunk-XWROSMI5.js +1039 -0
- package/dist/chunk-XWROSMI5.js.map +1 -0
- package/dist/chunk-Y2EXZ47H.js +40 -0
- package/dist/chunk-Y2EXZ47H.js.map +1 -0
- package/dist/chunk-YJGEVBKZ.js +47 -0
- package/dist/chunk-YJGEVBKZ.js.map +1 -0
- package/dist/{chunk-6CMM6YCB.js → chunk-YWWMISDY.js} +2 -2
- package/dist/{chunk-WXA2BWTE.js → chunk-ZCT5DJ3G.js} +2 -48
- package/dist/chunk-ZCT5DJ3G.js.map +1 -0
- package/dist/chunk-ZEYA2WWX.js +982 -0
- package/dist/chunk-ZEYA2WWX.js.map +1 -0
- package/dist/chunk-ZRC7Z5X3.js +82 -0
- package/dist/chunk-ZRC7Z5X3.js.map +1 -0
- package/dist/{chunk-3AIHRXKO.js → chunk-ZS7JIUJ3.js} +12 -10
- package/dist/chunk-ZS7JIUJ3.js.map +1 -0
- package/dist/{clack-EZ7TDWQU.js → clack-Q4RNC5VE.js} +2 -6
- package/dist/{claude-cli-2YKABJJZ.js → claude-cli-GIIHOBGT.js} +4 -2
- package/dist/claude-install-BAUSJMW3.js +64 -0
- package/dist/{cli-E36SPKBW.js → cli-QY4KKA3D.js} +632 -150
- package/dist/cli-QY4KKA3D.js.map +1 -0
- package/dist/client-3YQKORVK.js +710 -0
- package/dist/client-3YQKORVK.js.map +1 -0
- package/dist/{codex-event-ZO2GEFE6.js → codex-event-EUTCAOTQ.js} +3 -5
- package/dist/{codex-host-KECJVTA2.js → codex-host-ZON3S6HU.js} +7 -7
- package/dist/{codex-install-HQZDGFXW.js → codex-install-HZV2DOAB.js} +242 -88
- package/dist/codex-install-HZV2DOAB.js.map +1 -0
- package/dist/config-QZOBMTEL.js +57 -0
- package/dist/config-names-Z5NZD5R2.js +224 -0
- package/dist/config-names-Z5NZD5R2.js.map +1 -0
- package/dist/config-rules-YOYHS6YL.js +55 -0
- package/dist/config-subagents-WQV2ZAD5.js +362 -0
- package/dist/config-subagents-WQV2ZAD5.js.map +1 -0
- package/dist/connect-YDWTYU4B.js +1020 -0
- package/dist/connect-YDWTYU4B.js.map +1 -0
- package/dist/core-0a66n3e7-TTP554XV.js +127 -0
- package/dist/core-0a66n3e7-TTP554XV.js.map +1 -0
- package/dist/core-0bmnpbz2-C2JIRVZO.js +10790 -0
- package/dist/core-0bmnpbz2-C2JIRVZO.js.map +1 -0
- package/dist/core-9je8ee1j-74DGHWPV.js +30 -0
- package/dist/core-9je8ee1j-74DGHWPV.js.map +1 -0
- package/dist/core-wadgcjfh-TSZFQZGH.js +666 -0
- package/dist/core-wadgcjfh-TSZFQZGH.js.map +1 -0
- package/dist/core-zg882d22-LKV5DZYW.js +37 -0
- package/dist/core-zg882d22-LKV5DZYW.js.map +1 -0
- package/dist/decision-QSKHOGCO.js +145 -0
- package/dist/{doctor-I6XQEKWD.js → doctor-ZWJXRD75.js} +162 -148
- package/dist/doctor-ZWJXRD75.js.map +1 -0
- package/dist/{env-proxy-R6ZMLQTT.js → env-proxy-XLSLHBKQ.js} +2 -2
- package/dist/{ethersCompat-Df4a6QIZ-X6YZWAML.js → ethersCompat-Df4a6QIZ-K3DMHR6Y.js} +5 -5
- package/dist/explicit-ME2NRADQ.js +371 -0
- package/dist/explicit-ME2NRADQ.js.map +1 -0
- package/dist/flush-stdio-NYIJ3QXT.js +18 -0
- package/dist/fund-VF7TLDJH.js +722 -0
- package/dist/fund-VF7TLDJH.js.map +1 -0
- package/dist/hook-command-VZ27MGWO.js +49 -0
- package/dist/hosts/claude/.claude-plugin/marketplace.json +2 -2
- package/dist/hosts/claude/tenjin/.claude-plugin/plugin.json +2 -2
- package/dist/hosts/claude/tenjin/hooks/hook-data.ts +152 -0
- package/dist/hosts/claude/tenjin/hooks/hooks.json +7 -0
- package/dist/hosts/claude/tenjin/hooks/model-viewer.tsx +2987 -0
- package/dist/hosts/claude/tenjin/hooks/register.tsx +527 -56
- package/dist/hosts/claude/tenjin/skills/tenjin-pay/SKILL.md +14 -4
- package/dist/hosts/claude/tenjin/types/index.d.ts +144 -1
- package/dist/{hosts-DVQJ32QC.js → hosts-3EMTVM4H.js} +7 -6
- package/dist/index.js +18 -15
- package/dist/index.js.map +1 -1
- package/dist/install-ZA7L2UF3.js +115 -0
- package/dist/install-funding-JDGYTF72.js +30 -0
- package/dist/install-identity-FFAYEFLX.js +30 -0
- package/dist/{install-wallet-5M4OTYLX.js → install-wallet-2SFOVE3Q.js} +68 -53
- package/dist/install-wallet-2SFOVE3Q.js.map +1 -0
- package/dist/mcp-36S6MK3C.js +67642 -0
- package/dist/mcp-36S6MK3C.js.map +1 -0
- package/dist/new-install-5L4GY3LN.js +51 -0
- package/dist/{package-IJFGMWEV.js → package-BONDXSV3.js} +2 -2
- package/dist/{passphrase-IFTDS3CU.js → passphrase-T4ULBN4M.js} +16 -12
- package/dist/{paths-XCSAKISU.js → paths-O2KDWZ76.js} +18 -28
- package/dist/pay-CMV5KL74.js +74 -0
- package/dist/{payments-HFPPWHTV.js → payments-Z6UBZL4Z.js} +36 -26
- package/dist/payments-Z6UBZL4Z.js.map +1 -0
- package/dist/reclaim-subagent-credit-ABSF67SJ.js +105 -0
- package/dist/reclaim-subagent-credit-ABSF67SJ.js.map +1 -0
- package/dist/{redact-D7ASVWKL.js → redact-LOTHE5TS.js} +2 -8
- package/dist/redact-LOTHE5TS.js.map +1 -0
- package/dist/routing-quote-AHLAREXR.js +40 -0
- package/dist/routing-quote-AHLAREXR.js.map +1 -0
- package/dist/run-JH7ELYAM.js +88 -0
- package/dist/run-JH7ELYAM.js.map +1 -0
- package/dist/runtime-2GX4ALJP.js +410 -0
- package/dist/runtime-2GX4ALJP.js.map +1 -0
- package/dist/runtime-activate-IDQ2NCSP.js +39 -0
- package/dist/runtime-activate-IDQ2NCSP.js.map +1 -0
- package/dist/{runtime-fetch-ZSSSK72Y.js → runtime-fetch-6LOBHBEN.js} +4 -4
- package/dist/runtime-fetch-6LOBHBEN.js.map +1 -0
- package/dist/runtime-launchers-YAPKCBHV.js +31 -0
- package/dist/runtime-launchers-YAPKCBHV.js.map +1 -0
- package/dist/{runtime-layout-WIDILZ6K.js → runtime-layout-QHZQJV7C.js} +5 -4
- package/dist/runtime-layout-QHZQJV7C.js.map +1 -0
- package/dist/runtime-place-4POL4KK4.js +37 -0
- package/dist/runtime-place-4POL4KK4.js.map +1 -0
- package/dist/runtime-provenance-MNJGVBV2.js +12 -0
- package/dist/runtime-provenance-MNJGVBV2.js.map +1 -0
- package/dist/{secp256k1-ZZZT2CAX.js → secp256k1-N5P2GVGF.js} +3 -3
- package/dist/secp256k1-N5P2GVGF.js.map +1 -0
- package/dist/{send-GCVEAQKL.js → send-ELXFKEKY.js} +35 -32
- package/dist/send-ELXFKEKY.js.map +1 -0
- package/dist/status-FXUFWJDM.js +404 -0
- package/dist/status-FXUFWJDM.js.map +1 -0
- package/dist/{status-line-OPCXDHL2.js → status-line-IH5JBWBC.js} +51 -43
- package/dist/status-line-IH5JBWBC.js.map +1 -0
- package/dist/streamableHttp-CP2ZQBIK.js +768 -0
- package/dist/streamableHttp-CP2ZQBIK.js.map +1 -0
- package/dist/{uninstall-BAWRBXXQ.js → uninstall-LJZUKM4D.js} +76 -76
- package/dist/uninstall-LJZUKM4D.js.map +1 -0
- package/dist/update-EUIX72IX.js +68 -0
- package/dist/update-EUIX72IX.js.map +1 -0
- package/dist/usage-EKDC7LUC.js +180 -0
- package/dist/usage-EKDC7LUC.js.map +1 -0
- package/dist/{usdc-VG4CIOUK.js → usdc-YIHK2OMC.js} +8 -12
- package/dist/usdc-YIHK2OMC.js.map +1 -0
- package/dist/{viemAdapter-By13KInL-DOFTEIJV.js → viemAdapter-By13KInL-PRLSIESK.js} +5 -5
- package/dist/viemAdapter-By13KInL-PRLSIESK.js.map +1 -0
- package/dist/wallet-HSW757W6.js +80 -0
- package/dist/wallet-HSW757W6.js.map +1 -0
- package/dist/wallet-kdf-worker.mjs +1433 -818
- package/docs/agent-permissions.md +88 -155
- package/docs/router-reference.md +236 -0
- package/docs/safety-model.md +31 -33
- package/docs/subagents-internals.md +97 -0
- package/docs/subagents.md +348 -0
- package/docs/troubleshooting.md +10 -6
- package/package.json +12 -8
- package/scripts/installers/install.sh +7 -1
- package/dist/alive-GSOWKUOY.js +0 -38
- package/dist/chunk-2I4QTOLB.js.map +0 -1
- package/dist/chunk-2M2VPI2E.js +0 -560
- package/dist/chunk-2M2VPI2E.js.map +0 -1
- package/dist/chunk-2RWB7RKE.js.map +0 -1
- package/dist/chunk-2SNUOHAT.js.map +0 -1
- package/dist/chunk-3623BLPV.js +0 -184
- package/dist/chunk-3623BLPV.js.map +0 -1
- package/dist/chunk-36RVGZNY.js.map +0 -1
- package/dist/chunk-3AIHRXKO.js.map +0 -1
- package/dist/chunk-3FMZGI7I.js.map +0 -1
- package/dist/chunk-3UCIG4TG.js.map +0 -1
- package/dist/chunk-4K7TQHNP.js.map +0 -1
- package/dist/chunk-4LMUQMBH.js +0 -29
- package/dist/chunk-4LMUQMBH.js.map +0 -1
- package/dist/chunk-4USCZ2NI.js +0 -228
- package/dist/chunk-4USCZ2NI.js.map +0 -1
- package/dist/chunk-4YOZGGTZ.js.map +0 -1
- package/dist/chunk-62KNUYWD.js +0 -111
- package/dist/chunk-62KNUYWD.js.map +0 -1
- package/dist/chunk-A5GKIG5O.js +0 -2037
- package/dist/chunk-A5GKIG5O.js.map +0 -1
- package/dist/chunk-AGMVASXZ.js.map +0 -1
- package/dist/chunk-BF4XHEQK.js.map +0 -1
- package/dist/chunk-BFDQ4WNW.js.map +0 -1
- package/dist/chunk-C2Q76BVM.js.map +0 -1
- package/dist/chunk-CEXSOI5R.js +0 -808
- package/dist/chunk-CEXSOI5R.js.map +0 -1
- package/dist/chunk-E7SW44LM.js.map +0 -1
- package/dist/chunk-EDJWHDDL.js +0 -33
- package/dist/chunk-EDJWHDDL.js.map +0 -1
- package/dist/chunk-FVIGCDSV.js.map +0 -1
- package/dist/chunk-GTTUCOPD.js +0 -105
- package/dist/chunk-GTTUCOPD.js.map +0 -1
- package/dist/chunk-HDPUXS3Z.js +0 -122
- package/dist/chunk-HDPUXS3Z.js.map +0 -1
- package/dist/chunk-HGGWCP7W.js +0 -120
- package/dist/chunk-HGGWCP7W.js.map +0 -1
- package/dist/chunk-HGZEPQUT.js.map +0 -1
- package/dist/chunk-HMWYAUA6.js.map +0 -1
- package/dist/chunk-IADZOXKN.js.map +0 -1
- package/dist/chunk-ILNIZ5I2.js.map +0 -1
- package/dist/chunk-INTFHMU4.js.map +0 -1
- package/dist/chunk-JKKAIPTU.js.map +0 -1
- package/dist/chunk-JNJWBTU2.js.map +0 -1
- package/dist/chunk-KM7RY2ZS.js +0 -246
- package/dist/chunk-KM7RY2ZS.js.map +0 -1
- package/dist/chunk-KOGZDMHO.js +0 -21
- package/dist/chunk-KOGZDMHO.js.map +0 -1
- package/dist/chunk-L6JEXB3E.js.map +0 -1
- package/dist/chunk-LRW6S53P.js.map +0 -1
- package/dist/chunk-LXAYUOXI.js +0 -511
- package/dist/chunk-LXAYUOXI.js.map +0 -1
- package/dist/chunk-MEFB5KHA.js +0 -59
- package/dist/chunk-MEFB5KHA.js.map +0 -1
- package/dist/chunk-MPZUYCAP.js.map +0 -1
- package/dist/chunk-NDGZDTSJ.js.map +0 -1
- package/dist/chunk-OJNTCYQQ.js.map +0 -1
- package/dist/chunk-P3LFTKE7.js +0 -58
- package/dist/chunk-P3LFTKE7.js.map +0 -1
- package/dist/chunk-QXP3Z3JN.js.map +0 -1
- package/dist/chunk-RVPYTUP4.js.map +0 -1
- package/dist/chunk-SNNSAGMT.js.map +0 -1
- package/dist/chunk-TC2WZLSC.js.map +0 -1
- package/dist/chunk-TKPF35W6.js +0 -29
- package/dist/chunk-TKPF35W6.js.map +0 -1
- package/dist/chunk-U3IKUGRP.js.map +0 -1
- package/dist/chunk-UUGOUOVT.js.map +0 -1
- package/dist/chunk-UXZONNEQ.js.map +0 -1
- package/dist/chunk-WXA2BWTE.js.map +0 -1
- package/dist/chunk-WYXUQGOL.js.map +0 -1
- package/dist/chunk-X5ZBP3IY.js.map +0 -1
- package/dist/chunk-XKESD27X.js +0 -10
- package/dist/chunk-XKESD27X.js.map +0 -1
- package/dist/chunk-XQJXNMSB.js.map +0 -1
- package/dist/chunk-Y527D4TV.js +0 -56
- package/dist/chunk-Y527D4TV.js.map +0 -1
- package/dist/chunk-ZDZERB6L.js.map +0 -1
- package/dist/chunk-ZNNXRNFD.js.map +0 -1
- package/dist/chunk-ZURZHELF.js.map +0 -1
- package/dist/cli-E36SPKBW.js.map +0 -1
- package/dist/codex-install-HQZDGFXW.js.map +0 -1
- package/dist/config-HY2E4GGW.js +0 -55
- package/dist/doctor-I6XQEKWD.js.map +0 -1
- package/dist/fund-2QRO7OJL.js +0 -378
- package/dist/fund-2QRO7OJL.js.map +0 -1
- package/dist/hook-command-2UBCSZG6.js +0 -43
- package/dist/install-ILUX5C4A.js +0 -107
- package/dist/install-identity-TZKGY6LQ.js +0 -31
- package/dist/install-wallet-5M4OTYLX.js.map +0 -1
- package/dist/mcp-LE4DUS22.js +0 -14127
- package/dist/mcp-LE4DUS22.js.map +0 -1
- package/dist/pay-WCG3IH4R.js +0 -55
- package/dist/payments-HFPPWHTV.js.map +0 -1
- package/dist/plugin-registration-PZFI5GZW.js +0 -68
- package/dist/runtime-UZOKSUZX.js +0 -1321
- package/dist/runtime-UZOKSUZX.js.map +0 -1
- package/dist/send-GCVEAQKL.js.map +0 -1
- package/dist/status-HCVAOCN7.js +0 -150
- package/dist/status-HCVAOCN7.js.map +0 -1
- package/dist/status-line-OPCXDHL2.js.map +0 -1
- package/dist/uninstall-BAWRBXXQ.js.map +0 -1
- package/dist/update-CACXLQLR.js +0 -56
- package/dist/wallet-QL4UUXEZ.js +0 -55
- /package/dist/{_esm-BIN7VY2L.js.map → _esm-2KST7HQ7.js.map} +0 -0
- /package/dist/{alive-GSOWKUOY.js.map → alive-5TV22PNF.js.map} +0 -0
- /package/dist/{auto-update-Y24UL56V.js.map → auth-XI7BJFLW.js.map} +0 -0
- /package/dist/{ccip-DHDFKTQV.js.map → auto-update-7L24KDWA.js.map} +0 -0
- /package/dist/{clack-EZ7TDWQU.js.map → balance-DFHC6XEU.js.map} +0 -0
- /package/dist/{claude-cli-2YKABJJZ.js.map → ccip-HOW3DZYF.js.map} +0 -0
- /package/dist/{chunk-IE7P2BZE.js.map → chunk-6QMDUDF2.js.map} +0 -0
- /package/dist/{chunk-KG3D7FIF.js.map → chunk-CZJOMUBP.js.map} +0 -0
- /package/dist/{chunk-3GNJXKIT.js.map → chunk-F43CV6UC.js.map} +0 -0
- /package/dist/{chunk-J57UC3DD.js.map → chunk-FKVJKLPI.js.map} +0 -0
- /package/dist/{chunk-SO3XRZPX.js.map → chunk-HPRVFJPM.js.map} +0 -0
- /package/dist/{chunk-2GP3HRYK.js.map → chunk-INSIW65E.js.map} +0 -0
- /package/dist/{chunk-RL5UUDT4.js.map → chunk-JNUKLSMZ.js.map} +0 -0
- /package/dist/{chunk-JRGFKVAZ.js.map → chunk-PETQ5WEA.js.map} +0 -0
- /package/dist/{codex-event-ZO2GEFE6.js.map → chunk-TUCKEEXE.js.map} +0 -0
- /package/dist/{chunk-BPMWXTFX.js.map → chunk-WFZX352D.js.map} +0 -0
- /package/dist/{chunk-6CMM6YCB.js.map → chunk-YWWMISDY.js.map} +0 -0
- /package/dist/{codex-host-KECJVTA2.js.map → clack-Q4RNC5VE.js.map} +0 -0
- /package/dist/{config-HY2E4GGW.js.map → claude-cli-GIIHOBGT.js.map} +0 -0
- /package/dist/{env-proxy-R6ZMLQTT.js.map → claude-install-BAUSJMW3.js.map} +0 -0
- /package/dist/{ethersCompat-Df4a6QIZ-X6YZWAML.js.map → codex-event-EUTCAOTQ.js.map} +0 -0
- /package/dist/{hook-command-2UBCSZG6.js.map → codex-host-ZON3S6HU.js.map} +0 -0
- /package/dist/{hosts-DVQJ32QC.js.map → config-QZOBMTEL.js.map} +0 -0
- /package/dist/{install-ILUX5C4A.js.map → config-rules-YOYHS6YL.js.map} +0 -0
- /package/dist/{install-identity-TZKGY6LQ.js.map → decision-QSKHOGCO.js.map} +0 -0
- /package/dist/{package-IJFGMWEV.js.map → env-proxy-XLSLHBKQ.js.map} +0 -0
- /package/dist/{passphrase-IFTDS3CU.js.map → ethersCompat-Df4a6QIZ-K3DMHR6Y.js.map} +0 -0
- /package/dist/{paths-XCSAKISU.js.map → flush-stdio-NYIJ3QXT.js.map} +0 -0
- /package/dist/{pay-WCG3IH4R.js.map → hook-command-VZ27MGWO.js.map} +0 -0
- /package/dist/{plugin-registration-PZFI5GZW.js.map → hosts-3EMTVM4H.js.map} +0 -0
- /package/dist/{redact-D7ASVWKL.js.map → install-ZA7L2UF3.js.map} +0 -0
- /package/dist/{runtime-fetch-ZSSSK72Y.js.map → install-funding-JDGYTF72.js.map} +0 -0
- /package/dist/{runtime-layout-WIDILZ6K.js.map → install-identity-FFAYEFLX.js.map} +0 -0
- /package/dist/{secp256k1-ZZZT2CAX.js.map → new-install-5L4GY3LN.js.map} +0 -0
- /package/dist/{update-CACXLQLR.js.map → package-BONDXSV3.js.map} +0 -0
- /package/dist/{usdc-VG4CIOUK.js.map → passphrase-T4ULBN4M.js.map} +0 -0
- /package/dist/{viemAdapter-By13KInL-DOFTEIJV.js.map → paths-O2KDWZ76.js.map} +0 -0
- /package/dist/{wallet-QL4UUXEZ.js.map → pay-CMV5KL74.js.map} +0 -0
|
@@ -0,0 +1,1096 @@
|
|
|
1
|
+
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
LATEST_PROTOCOL_VERSION
|
|
4
|
+
} from "./chunk-54ELBTKE.js";
|
|
5
|
+
import {
|
|
6
|
+
NEVER,
|
|
7
|
+
ZodIssueCode,
|
|
8
|
+
any,
|
|
9
|
+
array,
|
|
10
|
+
boolean,
|
|
11
|
+
coerce_exports,
|
|
12
|
+
literal,
|
|
13
|
+
looseObject,
|
|
14
|
+
number,
|
|
15
|
+
object,
|
|
16
|
+
string,
|
|
17
|
+
url
|
|
18
|
+
} from "./chunk-P6YQWIT2.js";
|
|
19
|
+
|
|
20
|
+
// node_modules/.pnpm/pkce-challenge@5.0.1/node_modules/pkce-challenge/dist/index.node.js
|
|
21
|
+
var crypto;
|
|
22
|
+
crypto = globalThis.crypto?.webcrypto ?? // Node.js [18-16] REPL
|
|
23
|
+
globalThis.crypto ?? // Node.js >18
|
|
24
|
+
import("node:crypto").then((m) => m.webcrypto);
|
|
25
|
+
async function getRandomValues(size) {
|
|
26
|
+
return (await crypto).getRandomValues(new Uint8Array(size));
|
|
27
|
+
}
|
|
28
|
+
async function random(size) {
|
|
29
|
+
const mask = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~";
|
|
30
|
+
const evenDistCutoff = Math.pow(2, 8) - Math.pow(2, 8) % mask.length;
|
|
31
|
+
let result = "";
|
|
32
|
+
while (result.length < size) {
|
|
33
|
+
const randomBytes = await getRandomValues(size - result.length);
|
|
34
|
+
for (const randomByte of randomBytes) {
|
|
35
|
+
if (randomByte < evenDistCutoff) {
|
|
36
|
+
result += mask[randomByte % mask.length];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
async function generateVerifier(length) {
|
|
43
|
+
return await random(length);
|
|
44
|
+
}
|
|
45
|
+
async function generateChallenge(code_verifier) {
|
|
46
|
+
const buffer = await (await crypto).subtle.digest("SHA-256", new TextEncoder().encode(code_verifier));
|
|
47
|
+
return btoa(String.fromCharCode(...new Uint8Array(buffer))).replace(/\//g, "_").replace(/\+/g, "-").replace(/=/g, "");
|
|
48
|
+
}
|
|
49
|
+
async function pkceChallenge(length) {
|
|
50
|
+
if (!length)
|
|
51
|
+
length = 43;
|
|
52
|
+
if (length < 43 || length > 128) {
|
|
53
|
+
throw `Expected a length between 43 and 128. Received ${length}.`;
|
|
54
|
+
}
|
|
55
|
+
const verifier = await generateVerifier(length);
|
|
56
|
+
const challenge = await generateChallenge(verifier);
|
|
57
|
+
return {
|
|
58
|
+
code_verifier: verifier,
|
|
59
|
+
code_challenge: challenge
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.0_zod@4.6.7/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth.js
|
|
64
|
+
var SafeUrlSchema = url().superRefine((val, ctx) => {
|
|
65
|
+
if (!URL.canParse(val)) {
|
|
66
|
+
ctx.addIssue({
|
|
67
|
+
code: ZodIssueCode.custom,
|
|
68
|
+
message: "URL must be parseable",
|
|
69
|
+
fatal: true
|
|
70
|
+
});
|
|
71
|
+
return NEVER;
|
|
72
|
+
}
|
|
73
|
+
}).refine((url2) => {
|
|
74
|
+
const u = new URL(url2);
|
|
75
|
+
return u.protocol !== "javascript:" && u.protocol !== "data:" && u.protocol !== "vbscript:";
|
|
76
|
+
}, { message: "URL cannot use javascript:, data:, or vbscript: scheme" });
|
|
77
|
+
var OAuthProtectedResourceMetadataSchema = looseObject({
|
|
78
|
+
resource: string().url(),
|
|
79
|
+
authorization_servers: array(SafeUrlSchema).optional(),
|
|
80
|
+
jwks_uri: string().url().optional(),
|
|
81
|
+
scopes_supported: array(string()).optional(),
|
|
82
|
+
bearer_methods_supported: array(string()).optional(),
|
|
83
|
+
resource_signing_alg_values_supported: array(string()).optional(),
|
|
84
|
+
resource_name: string().optional(),
|
|
85
|
+
resource_documentation: string().optional(),
|
|
86
|
+
resource_policy_uri: string().url().optional(),
|
|
87
|
+
resource_tos_uri: string().url().optional(),
|
|
88
|
+
tls_client_certificate_bound_access_tokens: boolean().optional(),
|
|
89
|
+
authorization_details_types_supported: array(string()).optional(),
|
|
90
|
+
dpop_signing_alg_values_supported: array(string()).optional(),
|
|
91
|
+
dpop_bound_access_tokens_required: boolean().optional()
|
|
92
|
+
});
|
|
93
|
+
var OAuthMetadataSchema = looseObject({
|
|
94
|
+
issuer: string(),
|
|
95
|
+
authorization_endpoint: SafeUrlSchema,
|
|
96
|
+
token_endpoint: SafeUrlSchema,
|
|
97
|
+
registration_endpoint: SafeUrlSchema.optional(),
|
|
98
|
+
scopes_supported: array(string()).optional(),
|
|
99
|
+
response_types_supported: array(string()),
|
|
100
|
+
response_modes_supported: array(string()).optional(),
|
|
101
|
+
grant_types_supported: array(string()).optional(),
|
|
102
|
+
token_endpoint_auth_methods_supported: array(string()).optional(),
|
|
103
|
+
token_endpoint_auth_signing_alg_values_supported: array(string()).optional(),
|
|
104
|
+
service_documentation: SafeUrlSchema.optional(),
|
|
105
|
+
revocation_endpoint: SafeUrlSchema.optional(),
|
|
106
|
+
revocation_endpoint_auth_methods_supported: array(string()).optional(),
|
|
107
|
+
revocation_endpoint_auth_signing_alg_values_supported: array(string()).optional(),
|
|
108
|
+
introspection_endpoint: string().optional(),
|
|
109
|
+
introspection_endpoint_auth_methods_supported: array(string()).optional(),
|
|
110
|
+
introspection_endpoint_auth_signing_alg_values_supported: array(string()).optional(),
|
|
111
|
+
code_challenge_methods_supported: array(string()).optional(),
|
|
112
|
+
client_id_metadata_document_supported: boolean().optional()
|
|
113
|
+
});
|
|
114
|
+
var OpenIdProviderMetadataSchema = looseObject({
|
|
115
|
+
issuer: string(),
|
|
116
|
+
authorization_endpoint: SafeUrlSchema,
|
|
117
|
+
token_endpoint: SafeUrlSchema,
|
|
118
|
+
userinfo_endpoint: SafeUrlSchema.optional(),
|
|
119
|
+
jwks_uri: SafeUrlSchema,
|
|
120
|
+
registration_endpoint: SafeUrlSchema.optional(),
|
|
121
|
+
scopes_supported: array(string()).optional(),
|
|
122
|
+
response_types_supported: array(string()),
|
|
123
|
+
response_modes_supported: array(string()).optional(),
|
|
124
|
+
grant_types_supported: array(string()).optional(),
|
|
125
|
+
acr_values_supported: array(string()).optional(),
|
|
126
|
+
subject_types_supported: array(string()),
|
|
127
|
+
id_token_signing_alg_values_supported: array(string()),
|
|
128
|
+
id_token_encryption_alg_values_supported: array(string()).optional(),
|
|
129
|
+
id_token_encryption_enc_values_supported: array(string()).optional(),
|
|
130
|
+
userinfo_signing_alg_values_supported: array(string()).optional(),
|
|
131
|
+
userinfo_encryption_alg_values_supported: array(string()).optional(),
|
|
132
|
+
userinfo_encryption_enc_values_supported: array(string()).optional(),
|
|
133
|
+
request_object_signing_alg_values_supported: array(string()).optional(),
|
|
134
|
+
request_object_encryption_alg_values_supported: array(string()).optional(),
|
|
135
|
+
request_object_encryption_enc_values_supported: array(string()).optional(),
|
|
136
|
+
token_endpoint_auth_methods_supported: array(string()).optional(),
|
|
137
|
+
token_endpoint_auth_signing_alg_values_supported: array(string()).optional(),
|
|
138
|
+
display_values_supported: array(string()).optional(),
|
|
139
|
+
claim_types_supported: array(string()).optional(),
|
|
140
|
+
claims_supported: array(string()).optional(),
|
|
141
|
+
service_documentation: string().optional(),
|
|
142
|
+
claims_locales_supported: array(string()).optional(),
|
|
143
|
+
ui_locales_supported: array(string()).optional(),
|
|
144
|
+
claims_parameter_supported: boolean().optional(),
|
|
145
|
+
request_parameter_supported: boolean().optional(),
|
|
146
|
+
request_uri_parameter_supported: boolean().optional(),
|
|
147
|
+
require_request_uri_registration: boolean().optional(),
|
|
148
|
+
op_policy_uri: SafeUrlSchema.optional(),
|
|
149
|
+
op_tos_uri: SafeUrlSchema.optional(),
|
|
150
|
+
client_id_metadata_document_supported: boolean().optional()
|
|
151
|
+
});
|
|
152
|
+
var OpenIdProviderDiscoveryMetadataSchema = object({
|
|
153
|
+
...OpenIdProviderMetadataSchema.shape,
|
|
154
|
+
...OAuthMetadataSchema.pick({
|
|
155
|
+
code_challenge_methods_supported: true
|
|
156
|
+
}).shape
|
|
157
|
+
});
|
|
158
|
+
var OAuthTokensSchema = object({
|
|
159
|
+
access_token: string(),
|
|
160
|
+
id_token: string().optional(),
|
|
161
|
+
// Optional for OAuth 2.1, but necessary in OpenID Connect
|
|
162
|
+
token_type: string(),
|
|
163
|
+
expires_in: coerce_exports.number().optional(),
|
|
164
|
+
scope: string().optional(),
|
|
165
|
+
refresh_token: string().optional(),
|
|
166
|
+
/**
|
|
167
|
+
* Not part of the wire format: the authorization server this value was obtained from, added by
|
|
168
|
+
* the client's `auth()` before it is stored and compared when it is read back.
|
|
169
|
+
*/
|
|
170
|
+
issuer: string().optional().catch(void 0)
|
|
171
|
+
}).strip();
|
|
172
|
+
var OAuthErrorResponseSchema = object({
|
|
173
|
+
error: string(),
|
|
174
|
+
error_description: string().optional(),
|
|
175
|
+
error_uri: string().optional()
|
|
176
|
+
});
|
|
177
|
+
var OptionalSafeUrlSchema = SafeUrlSchema.optional().or(literal("").transform(() => void 0));
|
|
178
|
+
var OAuthClientMetadataSchema = object({
|
|
179
|
+
redirect_uris: array(SafeUrlSchema),
|
|
180
|
+
token_endpoint_auth_method: string().optional(),
|
|
181
|
+
grant_types: array(string()).optional(),
|
|
182
|
+
response_types: array(string()).optional(),
|
|
183
|
+
client_name: string().optional(),
|
|
184
|
+
client_uri: SafeUrlSchema.optional(),
|
|
185
|
+
logo_uri: OptionalSafeUrlSchema,
|
|
186
|
+
scope: string().optional(),
|
|
187
|
+
contacts: array(string()).optional(),
|
|
188
|
+
tos_uri: OptionalSafeUrlSchema,
|
|
189
|
+
policy_uri: string().optional(),
|
|
190
|
+
jwks_uri: SafeUrlSchema.optional(),
|
|
191
|
+
jwks: any().optional(),
|
|
192
|
+
software_id: string().optional(),
|
|
193
|
+
software_version: string().optional(),
|
|
194
|
+
software_statement: string().optional()
|
|
195
|
+
}).strip();
|
|
196
|
+
var OAuthClientInformationSchema = object({
|
|
197
|
+
client_id: string(),
|
|
198
|
+
client_secret: string().optional(),
|
|
199
|
+
client_id_issued_at: number().optional(),
|
|
200
|
+
client_secret_expires_at: number().optional(),
|
|
201
|
+
/**
|
|
202
|
+
* Not part of the wire format: the authorization server this value was obtained from, added by
|
|
203
|
+
* the client's `auth()` before it is stored and compared when it is read back.
|
|
204
|
+
*/
|
|
205
|
+
issuer: string().optional().catch(void 0)
|
|
206
|
+
}).strip();
|
|
207
|
+
var OAuthClientInformationFullSchema = OAuthClientMetadataSchema.merge(OAuthClientInformationSchema);
|
|
208
|
+
var OAuthClientRegistrationErrorSchema = object({
|
|
209
|
+
error: string(),
|
|
210
|
+
error_description: string().optional()
|
|
211
|
+
}).strip();
|
|
212
|
+
var OAuthTokenRevocationRequestSchema = object({
|
|
213
|
+
token: string(),
|
|
214
|
+
token_type_hint: string().optional()
|
|
215
|
+
}).strip();
|
|
216
|
+
|
|
217
|
+
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.0_zod@4.6.7/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth-utils.js
|
|
218
|
+
function resourceUrlFromServerUrl(url2) {
|
|
219
|
+
const resourceURL = typeof url2 === "string" ? new URL(url2) : new URL(url2.href);
|
|
220
|
+
resourceURL.hash = "";
|
|
221
|
+
return resourceURL;
|
|
222
|
+
}
|
|
223
|
+
function checkResourceAllowed({ requestedResource, configuredResource }) {
|
|
224
|
+
const requested = typeof requestedResource === "string" ? new URL(requestedResource) : new URL(requestedResource.href);
|
|
225
|
+
const configured = typeof configuredResource === "string" ? new URL(configuredResource) : new URL(configuredResource.href);
|
|
226
|
+
if (requested.origin !== configured.origin) {
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
if (requested.pathname.length < configured.pathname.length) {
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
const requestedPath = requested.pathname.endsWith("/") ? requested.pathname : requested.pathname + "/";
|
|
233
|
+
const configuredPath = configured.pathname.endsWith("/") ? configured.pathname : configured.pathname + "/";
|
|
234
|
+
return requestedPath.startsWith(configuredPath);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.0_zod@4.6.7/node_modules/@modelcontextprotocol/sdk/dist/esm/server/auth/errors.js
|
|
238
|
+
var OAuthError = class extends Error {
|
|
239
|
+
constructor(message, errorUri) {
|
|
240
|
+
super(message);
|
|
241
|
+
this.errorUri = errorUri;
|
|
242
|
+
this.name = this.constructor.name;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Converts the error to a standard OAuth error response object
|
|
246
|
+
*/
|
|
247
|
+
toResponseObject() {
|
|
248
|
+
const response = {
|
|
249
|
+
error: this.errorCode,
|
|
250
|
+
error_description: this.message
|
|
251
|
+
};
|
|
252
|
+
if (this.errorUri) {
|
|
253
|
+
response.error_uri = this.errorUri;
|
|
254
|
+
}
|
|
255
|
+
return response;
|
|
256
|
+
}
|
|
257
|
+
get errorCode() {
|
|
258
|
+
return this.constructor.errorCode;
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
var InvalidRequestError = class extends OAuthError {
|
|
262
|
+
};
|
|
263
|
+
InvalidRequestError.errorCode = "invalid_request";
|
|
264
|
+
var InvalidClientError = class extends OAuthError {
|
|
265
|
+
};
|
|
266
|
+
InvalidClientError.errorCode = "invalid_client";
|
|
267
|
+
var InvalidGrantError = class extends OAuthError {
|
|
268
|
+
};
|
|
269
|
+
InvalidGrantError.errorCode = "invalid_grant";
|
|
270
|
+
var UnauthorizedClientError = class extends OAuthError {
|
|
271
|
+
};
|
|
272
|
+
UnauthorizedClientError.errorCode = "unauthorized_client";
|
|
273
|
+
var UnsupportedGrantTypeError = class extends OAuthError {
|
|
274
|
+
};
|
|
275
|
+
UnsupportedGrantTypeError.errorCode = "unsupported_grant_type";
|
|
276
|
+
var InvalidScopeError = class extends OAuthError {
|
|
277
|
+
};
|
|
278
|
+
InvalidScopeError.errorCode = "invalid_scope";
|
|
279
|
+
var AccessDeniedError = class extends OAuthError {
|
|
280
|
+
};
|
|
281
|
+
AccessDeniedError.errorCode = "access_denied";
|
|
282
|
+
var ServerError = class extends OAuthError {
|
|
283
|
+
};
|
|
284
|
+
ServerError.errorCode = "server_error";
|
|
285
|
+
var TemporarilyUnavailableError = class extends OAuthError {
|
|
286
|
+
};
|
|
287
|
+
TemporarilyUnavailableError.errorCode = "temporarily_unavailable";
|
|
288
|
+
var UnsupportedResponseTypeError = class extends OAuthError {
|
|
289
|
+
};
|
|
290
|
+
UnsupportedResponseTypeError.errorCode = "unsupported_response_type";
|
|
291
|
+
var UnsupportedTokenTypeError = class extends OAuthError {
|
|
292
|
+
};
|
|
293
|
+
UnsupportedTokenTypeError.errorCode = "unsupported_token_type";
|
|
294
|
+
var InvalidTokenError = class extends OAuthError {
|
|
295
|
+
};
|
|
296
|
+
InvalidTokenError.errorCode = "invalid_token";
|
|
297
|
+
var MethodNotAllowedError = class extends OAuthError {
|
|
298
|
+
};
|
|
299
|
+
MethodNotAllowedError.errorCode = "method_not_allowed";
|
|
300
|
+
var TooManyRequestsError = class extends OAuthError {
|
|
301
|
+
};
|
|
302
|
+
TooManyRequestsError.errorCode = "too_many_requests";
|
|
303
|
+
var InvalidClientMetadataError = class extends OAuthError {
|
|
304
|
+
};
|
|
305
|
+
InvalidClientMetadataError.errorCode = "invalid_client_metadata";
|
|
306
|
+
var InsufficientScopeError = class extends OAuthError {
|
|
307
|
+
};
|
|
308
|
+
InsufficientScopeError.errorCode = "insufficient_scope";
|
|
309
|
+
var InvalidTargetError = class extends OAuthError {
|
|
310
|
+
};
|
|
311
|
+
InvalidTargetError.errorCode = "invalid_target";
|
|
312
|
+
var OAUTH_ERRORS = {
|
|
313
|
+
[InvalidRequestError.errorCode]: InvalidRequestError,
|
|
314
|
+
[InvalidClientError.errorCode]: InvalidClientError,
|
|
315
|
+
[InvalidGrantError.errorCode]: InvalidGrantError,
|
|
316
|
+
[UnauthorizedClientError.errorCode]: UnauthorizedClientError,
|
|
317
|
+
[UnsupportedGrantTypeError.errorCode]: UnsupportedGrantTypeError,
|
|
318
|
+
[InvalidScopeError.errorCode]: InvalidScopeError,
|
|
319
|
+
[AccessDeniedError.errorCode]: AccessDeniedError,
|
|
320
|
+
[ServerError.errorCode]: ServerError,
|
|
321
|
+
[TemporarilyUnavailableError.errorCode]: TemporarilyUnavailableError,
|
|
322
|
+
[UnsupportedResponseTypeError.errorCode]: UnsupportedResponseTypeError,
|
|
323
|
+
[UnsupportedTokenTypeError.errorCode]: UnsupportedTokenTypeError,
|
|
324
|
+
[InvalidTokenError.errorCode]: InvalidTokenError,
|
|
325
|
+
[MethodNotAllowedError.errorCode]: MethodNotAllowedError,
|
|
326
|
+
[TooManyRequestsError.errorCode]: TooManyRequestsError,
|
|
327
|
+
[InvalidClientMetadataError.errorCode]: InvalidClientMetadataError,
|
|
328
|
+
[InsufficientScopeError.errorCode]: InsufficientScopeError,
|
|
329
|
+
[InvalidTargetError.errorCode]: InvalidTargetError
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.0_zod@4.6.7/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/transport.js
|
|
333
|
+
function normalizeHeaders(headers) {
|
|
334
|
+
if (!headers)
|
|
335
|
+
return {};
|
|
336
|
+
if (headers instanceof Headers) {
|
|
337
|
+
return Object.fromEntries(headers.entries());
|
|
338
|
+
}
|
|
339
|
+
if (Array.isArray(headers)) {
|
|
340
|
+
return Object.fromEntries(headers);
|
|
341
|
+
}
|
|
342
|
+
return { ...headers };
|
|
343
|
+
}
|
|
344
|
+
function createFetchWithInit(baseFetch = fetch, baseInit) {
|
|
345
|
+
if (!baseInit) {
|
|
346
|
+
return baseFetch;
|
|
347
|
+
}
|
|
348
|
+
return async (url2, init) => {
|
|
349
|
+
const mergedInit = {
|
|
350
|
+
...baseInit,
|
|
351
|
+
...init,
|
|
352
|
+
// Headers need special handling - merge instead of replace
|
|
353
|
+
headers: init?.headers ? { ...normalizeHeaders(baseInit.headers), ...normalizeHeaders(init.headers) } : baseInit.headers
|
|
354
|
+
};
|
|
355
|
+
return baseFetch(url2, mergedInit);
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
var MAX_REDIRECTS = 5;
|
|
359
|
+
var REDIRECT_STATUSES = [301, 302, 303, 307, 308];
|
|
360
|
+
function isWithinOrigin(from, to) {
|
|
361
|
+
if (from.protocol === to.protocol && from.hostname === to.hostname && from.port === to.port) {
|
|
362
|
+
return true;
|
|
363
|
+
}
|
|
364
|
+
return from.hostname === to.hostname && from.protocol === "http:" && from.port === "" && to.protocol === "https:" && to.port === "";
|
|
365
|
+
}
|
|
366
|
+
function redirectTarget(response, requestUrl) {
|
|
367
|
+
const location = REDIRECT_STATUSES.includes(response.status) ? response.headers.get("location") : null;
|
|
368
|
+
try {
|
|
369
|
+
return location ? new URL(location, requestUrl) : void 0;
|
|
370
|
+
} catch {
|
|
371
|
+
return void 0;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
function followWithinOrigin(baseFetch, url2, init, response, followed = 0) {
|
|
375
|
+
const target = redirectTarget(response, url2);
|
|
376
|
+
const keepsMethod = response.status === 307 || response.status === 308 || (init?.method ?? "GET").toUpperCase() === "GET";
|
|
377
|
+
if (!target || followed === MAX_REDIRECTS || !keepsMethod) {
|
|
378
|
+
return void 0;
|
|
379
|
+
}
|
|
380
|
+
const from = new URL(url2);
|
|
381
|
+
const addsUserinfo = (target.username || target.password) && (target.username !== from.username || target.password !== from.password);
|
|
382
|
+
if (addsUserinfo || !isWithinOrigin(from, target)) {
|
|
383
|
+
return void 0;
|
|
384
|
+
}
|
|
385
|
+
return Promise.resolve(response.body?.cancel()).then(() => baseFetch(target, { ...init, redirect: "manual" })).then((next) => followWithinOrigin(baseFetch, target, init, next, followed + 1) ?? next);
|
|
386
|
+
}
|
|
387
|
+
var followingFetches = /* @__PURE__ */ new WeakSet();
|
|
388
|
+
function fetchLeavingRedirects(baseFetch) {
|
|
389
|
+
const following = (url2, init) => (baseFetch ?? fetch)(url2, init);
|
|
390
|
+
followingFetches.add(following);
|
|
391
|
+
return following;
|
|
392
|
+
}
|
|
393
|
+
function fetchWithinOrigin(baseFetch = fetch) {
|
|
394
|
+
if (followingFetches.has(baseFetch)) {
|
|
395
|
+
return baseFetch;
|
|
396
|
+
}
|
|
397
|
+
return (url2, init) => {
|
|
398
|
+
if (init?.redirect === "error" || init?.redirect === "manual") {
|
|
399
|
+
return baseFetch(url2, init);
|
|
400
|
+
}
|
|
401
|
+
return Promise.resolve(baseFetch(url2, { ...init, redirect: "manual" })).then((response) => followWithinOrigin(baseFetch, url2, init, response) ?? response);
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
function unfollowedRedirect(response, requestUrl) {
|
|
405
|
+
if (response.type === "opaqueredirect") {
|
|
406
|
+
return "Redirect not followed: this runtime does not expose the redirect target";
|
|
407
|
+
}
|
|
408
|
+
const from = response.url || requestUrl;
|
|
409
|
+
const target = redirectTarget(response, from);
|
|
410
|
+
if (!target) {
|
|
411
|
+
return void 0;
|
|
412
|
+
}
|
|
413
|
+
target.username = target.password = target.search = target.hash = "";
|
|
414
|
+
if (target.protocol === "http:" && new URL(from).protocol === "https:") {
|
|
415
|
+
target.protocol = "https:";
|
|
416
|
+
return `Redirect to plain http not followed; try ${target.href} instead`;
|
|
417
|
+
}
|
|
418
|
+
return `Redirect to ${target.href} not followed`;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.0_zod@4.6.7/node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth.js
|
|
422
|
+
var UnauthorizedError = class extends Error {
|
|
423
|
+
constructor(message) {
|
|
424
|
+
super(message ?? "Unauthorized");
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
function isClientAuthMethod(method) {
|
|
428
|
+
return ["client_secret_basic", "client_secret_post", "none"].includes(method);
|
|
429
|
+
}
|
|
430
|
+
var AUTHORIZATION_CODE_RESPONSE_TYPE = "code";
|
|
431
|
+
var AUTHORIZATION_CODE_CHALLENGE_METHOD = "S256";
|
|
432
|
+
function selectClientAuthMethod(clientInformation, supportedMethods) {
|
|
433
|
+
const hasClientSecret = clientInformation.client_secret !== void 0;
|
|
434
|
+
if ("token_endpoint_auth_method" in clientInformation && clientInformation.token_endpoint_auth_method && isClientAuthMethod(clientInformation.token_endpoint_auth_method) && (supportedMethods.length === 0 || supportedMethods.includes(clientInformation.token_endpoint_auth_method))) {
|
|
435
|
+
return clientInformation.token_endpoint_auth_method;
|
|
436
|
+
}
|
|
437
|
+
if (supportedMethods.length === 0) {
|
|
438
|
+
return hasClientSecret ? "client_secret_basic" : "none";
|
|
439
|
+
}
|
|
440
|
+
if (hasClientSecret && supportedMethods.includes("client_secret_basic")) {
|
|
441
|
+
return "client_secret_basic";
|
|
442
|
+
}
|
|
443
|
+
if (hasClientSecret && supportedMethods.includes("client_secret_post")) {
|
|
444
|
+
return "client_secret_post";
|
|
445
|
+
}
|
|
446
|
+
if (supportedMethods.includes("none")) {
|
|
447
|
+
return "none";
|
|
448
|
+
}
|
|
449
|
+
return hasClientSecret ? "client_secret_post" : "none";
|
|
450
|
+
}
|
|
451
|
+
function applyClientAuthentication(method, clientInformation, headers, params) {
|
|
452
|
+
const { client_id, client_secret } = clientInformation;
|
|
453
|
+
switch (method) {
|
|
454
|
+
case "client_secret_basic":
|
|
455
|
+
applyBasicAuth(client_id, client_secret, headers);
|
|
456
|
+
return;
|
|
457
|
+
case "client_secret_post":
|
|
458
|
+
applyPostAuth(client_id, client_secret, params);
|
|
459
|
+
return;
|
|
460
|
+
case "none":
|
|
461
|
+
applyPublicAuth(client_id, params);
|
|
462
|
+
return;
|
|
463
|
+
default:
|
|
464
|
+
throw new Error(`Unsupported client authentication method: ${method}`);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
function applyBasicAuth(clientId, clientSecret, headers) {
|
|
468
|
+
if (!clientSecret) {
|
|
469
|
+
throw new Error("client_secret_basic authentication requires a client_secret");
|
|
470
|
+
}
|
|
471
|
+
const credentials = btoa(`${clientId}:${clientSecret}`);
|
|
472
|
+
headers.set("Authorization", `Basic ${credentials}`);
|
|
473
|
+
}
|
|
474
|
+
function applyPostAuth(clientId, clientSecret, params) {
|
|
475
|
+
params.set("client_id", clientId);
|
|
476
|
+
if (clientSecret) {
|
|
477
|
+
params.set("client_secret", clientSecret);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
function applyPublicAuth(clientId, params) {
|
|
481
|
+
params.set("client_id", clientId);
|
|
482
|
+
}
|
|
483
|
+
async function parseErrorResponse(input) {
|
|
484
|
+
const statusCode = input instanceof Response ? input.status : void 0;
|
|
485
|
+
const body = input instanceof Response ? await input.text() : input;
|
|
486
|
+
try {
|
|
487
|
+
const result = OAuthErrorResponseSchema.parse(JSON.parse(body));
|
|
488
|
+
const { error, error_description, error_uri } = result;
|
|
489
|
+
const errorClass = OAUTH_ERRORS[error] || ServerError;
|
|
490
|
+
return new errorClass(error_description || "", error_uri);
|
|
491
|
+
} catch (error) {
|
|
492
|
+
const redirect = input instanceof Response ? unfollowedRedirect(input, input.url) : void 0;
|
|
493
|
+
const errorMessage = `${statusCode ? `HTTP ${statusCode}: ` : ""}${redirect ?? `Invalid OAuth error response: ${error}. Raw body: ${body}`}`;
|
|
494
|
+
return new ServerError(errorMessage);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
function issuersMatch(a, b) {
|
|
498
|
+
let [x, y] = [a, b];
|
|
499
|
+
try {
|
|
500
|
+
[x, y] = [new URL(a).href, new URL(b).href];
|
|
501
|
+
} catch {
|
|
502
|
+
}
|
|
503
|
+
return x === y || x.endsWith("/") && x.slice(0, -1) === y || y.endsWith("/") && y.slice(0, -1) === x;
|
|
504
|
+
}
|
|
505
|
+
function discardIfIssuerMismatch(stored, issuer) {
|
|
506
|
+
if (!stored)
|
|
507
|
+
return void 0;
|
|
508
|
+
if (typeof stored.issuer !== "string")
|
|
509
|
+
return stored.issuer == null ? stored : { ...stored, issuer: void 0 };
|
|
510
|
+
return issuersMatch(stored.issuer, issuer) ? stored : void 0;
|
|
511
|
+
}
|
|
512
|
+
var TokenResponseSchema = OAuthTokensSchema.omit({ issuer: true });
|
|
513
|
+
var RegistrationResponseSchema = OAuthClientInformationFullSchema.omit({ issuer: true });
|
|
514
|
+
function boundElsewhereError(stored, issuer) {
|
|
515
|
+
return new Error(`OAuth client information is bound to authorization server ${stored.issuer} and is not presented to ${issuer}. Clear the stored client information, or correct \`expectedIssuer\`, if the authorization server has moved.`);
|
|
516
|
+
}
|
|
517
|
+
async function auth(provider, options) {
|
|
518
|
+
try {
|
|
519
|
+
return await authInternal(provider, options);
|
|
520
|
+
} catch (error) {
|
|
521
|
+
if (error instanceof InvalidClientError || error instanceof UnauthorizedClientError) {
|
|
522
|
+
await provider.invalidateCredentials?.("all");
|
|
523
|
+
return await authInternal(provider, options);
|
|
524
|
+
} else if (error instanceof InvalidGrantError) {
|
|
525
|
+
await provider.invalidateCredentials?.("tokens");
|
|
526
|
+
return await authInternal(provider, options);
|
|
527
|
+
}
|
|
528
|
+
throw error;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
async function authInternal(provider, { serverUrl, authorizationCode, scope, resourceMetadataUrl, fetchFn }) {
|
|
532
|
+
const cachedState = await provider.discoveryState?.();
|
|
533
|
+
let resourceMetadata;
|
|
534
|
+
let authorizationServerUrl;
|
|
535
|
+
let metadata;
|
|
536
|
+
let effectiveResourceMetadataUrl = resourceMetadataUrl;
|
|
537
|
+
if (!effectiveResourceMetadataUrl && cachedState?.resourceMetadataUrl) {
|
|
538
|
+
effectiveResourceMetadataUrl = new URL(cachedState.resourceMetadataUrl);
|
|
539
|
+
}
|
|
540
|
+
if (cachedState?.authorizationServerUrl) {
|
|
541
|
+
authorizationServerUrl = cachedState.authorizationServerUrl;
|
|
542
|
+
resourceMetadata = cachedState.resourceMetadata;
|
|
543
|
+
metadata = cachedState.authorizationServerMetadata ?? await discoverAuthorizationServerMetadata(authorizationServerUrl, { fetchFn });
|
|
544
|
+
if (!resourceMetadata) {
|
|
545
|
+
try {
|
|
546
|
+
resourceMetadata = await discoverOAuthProtectedResourceMetadata(serverUrl, { resourceMetadataUrl: effectiveResourceMetadataUrl }, fetchFn);
|
|
547
|
+
} catch {
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
if (metadata !== cachedState.authorizationServerMetadata || resourceMetadata !== cachedState.resourceMetadata) {
|
|
551
|
+
await provider.saveDiscoveryState?.({
|
|
552
|
+
authorizationServerUrl: String(authorizationServerUrl),
|
|
553
|
+
resourceMetadataUrl: effectiveResourceMetadataUrl?.toString(),
|
|
554
|
+
resourceMetadata,
|
|
555
|
+
authorizationServerMetadata: metadata
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
} else {
|
|
559
|
+
const serverInfo = await discoverOAuthServerInfo(serverUrl, { resourceMetadataUrl: effectiveResourceMetadataUrl, fetchFn });
|
|
560
|
+
authorizationServerUrl = serverInfo.authorizationServerUrl;
|
|
561
|
+
metadata = serverInfo.authorizationServerMetadata;
|
|
562
|
+
resourceMetadata = serverInfo.resourceMetadata;
|
|
563
|
+
await provider.saveDiscoveryState?.({
|
|
564
|
+
authorizationServerUrl: String(authorizationServerUrl),
|
|
565
|
+
resourceMetadataUrl: effectiveResourceMetadataUrl?.toString(),
|
|
566
|
+
resourceMetadata,
|
|
567
|
+
authorizationServerMetadata: metadata
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
const issuer = String(authorizationServerUrl);
|
|
571
|
+
const selectedResource = await selectResourceURL(serverUrl, provider, resourceMetadata);
|
|
572
|
+
const resource = selectedResource && resourceMetadata && !provider.validateResourceURL ? resourceMetadata.resource : selectedResource;
|
|
573
|
+
const resolvedScope = scope || resourceMetadata?.scopes_supported?.join(" ") || provider.clientMetadata.scope;
|
|
574
|
+
const storedClientInformation = await Promise.resolve(provider.clientInformation());
|
|
575
|
+
let clientInformation = discardIfIssuerMismatch(storedClientInformation, issuer);
|
|
576
|
+
const canRegisterAgain = provider.saveClientInformation !== void 0 && !!provider.redirectUrl;
|
|
577
|
+
if (storedClientInformation && !clientInformation && !canRegisterAgain) {
|
|
578
|
+
throw boundElsewhereError(storedClientInformation, issuer);
|
|
579
|
+
}
|
|
580
|
+
const unstampedClientInformation = clientInformation?.issuer == null ? clientInformation : void 0;
|
|
581
|
+
const bindClientInformation = async () => {
|
|
582
|
+
try {
|
|
583
|
+
if (unstampedClientInformation)
|
|
584
|
+
await provider.saveClientInformation?.({ ...unstampedClientInformation, issuer });
|
|
585
|
+
} catch {
|
|
586
|
+
}
|
|
587
|
+
};
|
|
588
|
+
if (!clientInformation) {
|
|
589
|
+
if (authorizationCode !== void 0) {
|
|
590
|
+
throw new Error("Existing OAuth client information is required when exchanging an authorization code");
|
|
591
|
+
}
|
|
592
|
+
const supportsUrlBasedClientId = metadata?.client_id_metadata_document_supported === true;
|
|
593
|
+
const clientMetadataUrl = provider.clientMetadataUrl;
|
|
594
|
+
if (clientMetadataUrl && !isHttpsUrl(clientMetadataUrl)) {
|
|
595
|
+
throw new InvalidClientMetadataError(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${clientMetadataUrl}`);
|
|
596
|
+
}
|
|
597
|
+
const shouldUseUrlBasedClientId = supportsUrlBasedClientId && clientMetadataUrl;
|
|
598
|
+
if (shouldUseUrlBasedClientId) {
|
|
599
|
+
clientInformation = { client_id: clientMetadataUrl, issuer };
|
|
600
|
+
await provider.saveClientInformation?.(clientInformation);
|
|
601
|
+
} else {
|
|
602
|
+
if (!provider.saveClientInformation) {
|
|
603
|
+
throw new Error("OAuth client information must be saveable for dynamic registration");
|
|
604
|
+
}
|
|
605
|
+
const fullInformation = await registerClient(authorizationServerUrl, {
|
|
606
|
+
metadata,
|
|
607
|
+
clientMetadata: provider.clientMetadata,
|
|
608
|
+
scope: resolvedScope,
|
|
609
|
+
fetchFn
|
|
610
|
+
});
|
|
611
|
+
clientInformation = { ...fullInformation, issuer };
|
|
612
|
+
await provider.saveClientInformation(clientInformation);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
const nonInteractiveFlow = !provider.redirectUrl;
|
|
616
|
+
if (authorizationCode !== void 0 || nonInteractiveFlow) {
|
|
617
|
+
const tokens2 = await fetchToken(provider, authorizationServerUrl, {
|
|
618
|
+
metadata,
|
|
619
|
+
resource,
|
|
620
|
+
authorizationCode,
|
|
621
|
+
fetchFn
|
|
622
|
+
});
|
|
623
|
+
await bindClientInformation();
|
|
624
|
+
await provider.saveTokens({ ...tokens2, issuer });
|
|
625
|
+
return "AUTHORIZED";
|
|
626
|
+
}
|
|
627
|
+
const tokens = discardIfIssuerMismatch(await provider.tokens(), issuer);
|
|
628
|
+
if (tokens?.refresh_token && tokens.issuer == null) {
|
|
629
|
+
console.warn("[mcp-sdk] stored OAuth tokens have no 'issuer' property (saved by an earlier version, or by a provider that does not keep it) and are used as-is; make sure your OAuthClientProvider stores what saveTokens() and saveClientInformation() receive unchanged.");
|
|
630
|
+
}
|
|
631
|
+
if (tokens?.refresh_token) {
|
|
632
|
+
try {
|
|
633
|
+
const newTokens = await refreshAuthorization(authorizationServerUrl, {
|
|
634
|
+
metadata,
|
|
635
|
+
clientInformation,
|
|
636
|
+
refreshToken: tokens.refresh_token,
|
|
637
|
+
resource,
|
|
638
|
+
addClientAuthentication: provider.addClientAuthentication,
|
|
639
|
+
fetchFn
|
|
640
|
+
});
|
|
641
|
+
await bindClientInformation();
|
|
642
|
+
await provider.saveTokens({ ...newTokens, issuer });
|
|
643
|
+
return "AUTHORIZED";
|
|
644
|
+
} catch (error) {
|
|
645
|
+
if (!(error instanceof OAuthError) || error instanceof ServerError) {
|
|
646
|
+
} else {
|
|
647
|
+
throw error;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
const state = provider.state ? await provider.state() : void 0;
|
|
652
|
+
const { authorizationUrl, codeVerifier } = await startAuthorization(authorizationServerUrl, {
|
|
653
|
+
metadata,
|
|
654
|
+
clientInformation,
|
|
655
|
+
state,
|
|
656
|
+
redirectUrl: provider.redirectUrl,
|
|
657
|
+
scope: resolvedScope,
|
|
658
|
+
resource
|
|
659
|
+
});
|
|
660
|
+
await provider.saveCodeVerifier(codeVerifier);
|
|
661
|
+
await provider.redirectToAuthorization(authorizationUrl);
|
|
662
|
+
return "REDIRECT";
|
|
663
|
+
}
|
|
664
|
+
function isHttpsUrl(value) {
|
|
665
|
+
if (!value)
|
|
666
|
+
return false;
|
|
667
|
+
try {
|
|
668
|
+
const url2 = new URL(value);
|
|
669
|
+
return url2.protocol === "https:" && url2.pathname !== "/";
|
|
670
|
+
} catch {
|
|
671
|
+
return false;
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
async function selectResourceURL(serverUrl, provider, resourceMetadata) {
|
|
675
|
+
const defaultResource = resourceUrlFromServerUrl(serverUrl);
|
|
676
|
+
if (provider.validateResourceURL) {
|
|
677
|
+
return await provider.validateResourceURL(defaultResource, resourceMetadata?.resource);
|
|
678
|
+
}
|
|
679
|
+
if (!resourceMetadata) {
|
|
680
|
+
return void 0;
|
|
681
|
+
}
|
|
682
|
+
if (!checkResourceAllowed({ requestedResource: defaultResource, configuredResource: resourceMetadata.resource })) {
|
|
683
|
+
throw new Error(`Protected resource ${resourceMetadata.resource} does not match expected ${defaultResource} (or origin)`);
|
|
684
|
+
}
|
|
685
|
+
return new URL(resourceMetadata.resource);
|
|
686
|
+
}
|
|
687
|
+
function extractWWWAuthenticateParams(res) {
|
|
688
|
+
const authenticateHeader = res.headers.get("WWW-Authenticate");
|
|
689
|
+
if (!authenticateHeader) {
|
|
690
|
+
return {};
|
|
691
|
+
}
|
|
692
|
+
const [type, scheme] = authenticateHeader.split(" ");
|
|
693
|
+
if (type.toLowerCase() !== "bearer" || !scheme) {
|
|
694
|
+
return {};
|
|
695
|
+
}
|
|
696
|
+
const resourceMetadataMatch = extractFieldFromWwwAuth(res, "resource_metadata") || void 0;
|
|
697
|
+
let resourceMetadataUrl;
|
|
698
|
+
if (resourceMetadataMatch) {
|
|
699
|
+
try {
|
|
700
|
+
resourceMetadataUrl = new URL(resourceMetadataMatch);
|
|
701
|
+
} catch {
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
const scope = extractFieldFromWwwAuth(res, "scope") || void 0;
|
|
705
|
+
const error = extractFieldFromWwwAuth(res, "error") || void 0;
|
|
706
|
+
return {
|
|
707
|
+
resourceMetadataUrl,
|
|
708
|
+
scope,
|
|
709
|
+
error
|
|
710
|
+
};
|
|
711
|
+
}
|
|
712
|
+
function extractFieldFromWwwAuth(response, fieldName) {
|
|
713
|
+
const wwwAuthHeader = response.headers.get("WWW-Authenticate");
|
|
714
|
+
if (!wwwAuthHeader) {
|
|
715
|
+
return null;
|
|
716
|
+
}
|
|
717
|
+
const pattern = new RegExp(`${fieldName}=(?:"([^"]+)"|([^\\s,]+))`);
|
|
718
|
+
const match = wwwAuthHeader.match(pattern);
|
|
719
|
+
if (match) {
|
|
720
|
+
return match[1] || match[2];
|
|
721
|
+
}
|
|
722
|
+
return null;
|
|
723
|
+
}
|
|
724
|
+
function extractResourceMetadataUrl(res) {
|
|
725
|
+
const authenticateHeader = res.headers.get("WWW-Authenticate");
|
|
726
|
+
if (!authenticateHeader) {
|
|
727
|
+
return void 0;
|
|
728
|
+
}
|
|
729
|
+
const [type, scheme] = authenticateHeader.split(" ");
|
|
730
|
+
if (type.toLowerCase() !== "bearer" || !scheme) {
|
|
731
|
+
return void 0;
|
|
732
|
+
}
|
|
733
|
+
const regex = /resource_metadata="([^"]*)"/;
|
|
734
|
+
const match = regex.exec(authenticateHeader);
|
|
735
|
+
if (!match) {
|
|
736
|
+
return void 0;
|
|
737
|
+
}
|
|
738
|
+
try {
|
|
739
|
+
return new URL(match[1]);
|
|
740
|
+
} catch {
|
|
741
|
+
return void 0;
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
async function discoverOAuthProtectedResourceMetadata(serverUrl, opts, fetchFn = fetch) {
|
|
745
|
+
const response = await discoverMetadataWithFallback(serverUrl, "oauth-protected-resource", fetchFn, {
|
|
746
|
+
protocolVersion: opts?.protocolVersion,
|
|
747
|
+
metadataUrl: opts?.resourceMetadataUrl
|
|
748
|
+
});
|
|
749
|
+
if (!response || response.status === 404) {
|
|
750
|
+
await response?.body?.cancel();
|
|
751
|
+
throw new Error(`Resource server does not implement OAuth 2.0 Protected Resource Metadata.`);
|
|
752
|
+
}
|
|
753
|
+
if (!response.ok) {
|
|
754
|
+
await response.body?.cancel();
|
|
755
|
+
throw new Error(`HTTP ${response.status} trying to load well-known OAuth protected resource metadata.`);
|
|
756
|
+
}
|
|
757
|
+
return OAuthProtectedResourceMetadataSchema.parse(await response.json());
|
|
758
|
+
}
|
|
759
|
+
async function fetchWithCorsRetry(url2, headers, fetchFn = fetch) {
|
|
760
|
+
try {
|
|
761
|
+
return await fetchWithinOrigin(fetchFn)(url2, { headers });
|
|
762
|
+
} catch (error) {
|
|
763
|
+
if (error instanceof TypeError) {
|
|
764
|
+
if (headers) {
|
|
765
|
+
return fetchWithCorsRetry(url2, void 0, fetchFn);
|
|
766
|
+
} else {
|
|
767
|
+
return void 0;
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
throw error;
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
function buildWellKnownPath(wellKnownPrefix, pathname = "", options = {}) {
|
|
774
|
+
if (pathname.endsWith("/")) {
|
|
775
|
+
pathname = pathname.slice(0, -1);
|
|
776
|
+
}
|
|
777
|
+
return options.prependPathname ? `${pathname}/.well-known/${wellKnownPrefix}` : `/.well-known/${wellKnownPrefix}${pathname}`;
|
|
778
|
+
}
|
|
779
|
+
async function tryMetadataDiscovery(url2, protocolVersion, fetchFn = fetch) {
|
|
780
|
+
const headers = {
|
|
781
|
+
"MCP-Protocol-Version": protocolVersion
|
|
782
|
+
};
|
|
783
|
+
return await fetchWithCorsRetry(url2, headers, fetchFn);
|
|
784
|
+
}
|
|
785
|
+
function shouldAttemptFallback(response, pathname) {
|
|
786
|
+
return !response || !response.ok && response.status < 500 && pathname !== "/";
|
|
787
|
+
}
|
|
788
|
+
async function discoverMetadataWithFallback(serverUrl, wellKnownType, fetchFn, opts) {
|
|
789
|
+
const issuer = new URL(serverUrl);
|
|
790
|
+
const protocolVersion = opts?.protocolVersion ?? LATEST_PROTOCOL_VERSION;
|
|
791
|
+
let url2;
|
|
792
|
+
if (opts?.metadataUrl) {
|
|
793
|
+
url2 = new URL(opts.metadataUrl);
|
|
794
|
+
} else {
|
|
795
|
+
const wellKnownPath = buildWellKnownPath(wellKnownType, issuer.pathname);
|
|
796
|
+
url2 = new URL(wellKnownPath, opts?.metadataServerUrl ?? issuer);
|
|
797
|
+
url2.search = issuer.search;
|
|
798
|
+
}
|
|
799
|
+
let response = await tryMetadataDiscovery(url2, protocolVersion, fetchFn);
|
|
800
|
+
if (!opts?.metadataUrl && shouldAttemptFallback(response, issuer.pathname)) {
|
|
801
|
+
const rootUrl = new URL(`/.well-known/${wellKnownType}`, issuer);
|
|
802
|
+
response = await tryMetadataDiscovery(rootUrl, protocolVersion, fetchFn);
|
|
803
|
+
}
|
|
804
|
+
return response;
|
|
805
|
+
}
|
|
806
|
+
async function discoverOAuthMetadata(issuer, { authorizationServerUrl, protocolVersion } = {}, fetchFn = fetch) {
|
|
807
|
+
if (typeof issuer === "string") {
|
|
808
|
+
issuer = new URL(issuer);
|
|
809
|
+
}
|
|
810
|
+
if (!authorizationServerUrl) {
|
|
811
|
+
authorizationServerUrl = issuer;
|
|
812
|
+
}
|
|
813
|
+
if (typeof authorizationServerUrl === "string") {
|
|
814
|
+
authorizationServerUrl = new URL(authorizationServerUrl);
|
|
815
|
+
}
|
|
816
|
+
protocolVersion ?? (protocolVersion = LATEST_PROTOCOL_VERSION);
|
|
817
|
+
const response = await discoverMetadataWithFallback(authorizationServerUrl, "oauth-authorization-server", fetchFn, {
|
|
818
|
+
protocolVersion,
|
|
819
|
+
metadataServerUrl: authorizationServerUrl
|
|
820
|
+
});
|
|
821
|
+
if (!response || response.status === 404) {
|
|
822
|
+
await response?.body?.cancel();
|
|
823
|
+
return void 0;
|
|
824
|
+
}
|
|
825
|
+
if (!response.ok) {
|
|
826
|
+
await response.body?.cancel();
|
|
827
|
+
throw new Error(`HTTP ${response.status} trying to load well-known OAuth metadata`);
|
|
828
|
+
}
|
|
829
|
+
return OAuthMetadataSchema.parse(await response.json());
|
|
830
|
+
}
|
|
831
|
+
function buildDiscoveryUrls(authorizationServerUrl) {
|
|
832
|
+
const url2 = typeof authorizationServerUrl === "string" ? new URL(authorizationServerUrl) : authorizationServerUrl;
|
|
833
|
+
const hasPath = url2.pathname !== "/";
|
|
834
|
+
const urlsToTry = [];
|
|
835
|
+
if (!hasPath) {
|
|
836
|
+
urlsToTry.push({
|
|
837
|
+
url: new URL("/.well-known/oauth-authorization-server", url2.origin),
|
|
838
|
+
type: "oauth"
|
|
839
|
+
});
|
|
840
|
+
urlsToTry.push({
|
|
841
|
+
url: new URL(`/.well-known/openid-configuration`, url2.origin),
|
|
842
|
+
type: "oidc"
|
|
843
|
+
});
|
|
844
|
+
return urlsToTry;
|
|
845
|
+
}
|
|
846
|
+
let pathname = url2.pathname;
|
|
847
|
+
if (pathname.endsWith("/")) {
|
|
848
|
+
pathname = pathname.slice(0, -1);
|
|
849
|
+
}
|
|
850
|
+
urlsToTry.push({
|
|
851
|
+
url: new URL(`/.well-known/oauth-authorization-server${pathname}`, url2.origin),
|
|
852
|
+
type: "oauth"
|
|
853
|
+
});
|
|
854
|
+
urlsToTry.push({
|
|
855
|
+
url: new URL(`/.well-known/openid-configuration${pathname}`, url2.origin),
|
|
856
|
+
type: "oidc"
|
|
857
|
+
});
|
|
858
|
+
urlsToTry.push({
|
|
859
|
+
url: new URL(`${pathname}/.well-known/openid-configuration`, url2.origin),
|
|
860
|
+
type: "oidc"
|
|
861
|
+
});
|
|
862
|
+
return urlsToTry;
|
|
863
|
+
}
|
|
864
|
+
async function discoverAuthorizationServerMetadata(authorizationServerUrl, { fetchFn = fetch, protocolVersion = LATEST_PROTOCOL_VERSION } = {}) {
|
|
865
|
+
const headers = {
|
|
866
|
+
"MCP-Protocol-Version": protocolVersion,
|
|
867
|
+
Accept: "application/json"
|
|
868
|
+
};
|
|
869
|
+
const urlsToTry = buildDiscoveryUrls(authorizationServerUrl);
|
|
870
|
+
for (const { url: endpointUrl, type } of urlsToTry) {
|
|
871
|
+
const response = await fetchWithCorsRetry(endpointUrl, headers, fetchFn);
|
|
872
|
+
if (!response) {
|
|
873
|
+
continue;
|
|
874
|
+
}
|
|
875
|
+
if (!response.ok) {
|
|
876
|
+
await response.body?.cancel();
|
|
877
|
+
if (response.status < 500) {
|
|
878
|
+
continue;
|
|
879
|
+
}
|
|
880
|
+
throw new Error(`HTTP ${response.status} trying to load ${type === "oauth" ? "OAuth" : "OpenID provider"} metadata from ${endpointUrl}`);
|
|
881
|
+
}
|
|
882
|
+
if (type === "oauth") {
|
|
883
|
+
return OAuthMetadataSchema.parse(await response.json());
|
|
884
|
+
} else {
|
|
885
|
+
return OpenIdProviderDiscoveryMetadataSchema.parse(await response.json());
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
return void 0;
|
|
889
|
+
}
|
|
890
|
+
async function discoverOAuthServerInfo(serverUrl, opts) {
|
|
891
|
+
let resourceMetadata;
|
|
892
|
+
let authorizationServerUrl;
|
|
893
|
+
try {
|
|
894
|
+
resourceMetadata = await discoverOAuthProtectedResourceMetadata(serverUrl, { resourceMetadataUrl: opts?.resourceMetadataUrl }, opts?.fetchFn);
|
|
895
|
+
if (resourceMetadata.authorization_servers && resourceMetadata.authorization_servers.length > 0) {
|
|
896
|
+
authorizationServerUrl = resourceMetadata.authorization_servers[0];
|
|
897
|
+
}
|
|
898
|
+
} catch {
|
|
899
|
+
}
|
|
900
|
+
if (!authorizationServerUrl) {
|
|
901
|
+
authorizationServerUrl = String(new URL("/", serverUrl));
|
|
902
|
+
}
|
|
903
|
+
const authorizationServerMetadata = await discoverAuthorizationServerMetadata(authorizationServerUrl, { fetchFn: opts?.fetchFn });
|
|
904
|
+
return {
|
|
905
|
+
authorizationServerUrl,
|
|
906
|
+
authorizationServerMetadata,
|
|
907
|
+
resourceMetadata
|
|
908
|
+
};
|
|
909
|
+
}
|
|
910
|
+
function resourceIndicatorToString(resource) {
|
|
911
|
+
return typeof resource === "string" ? resource : resource.href;
|
|
912
|
+
}
|
|
913
|
+
async function startAuthorization(authorizationServerUrl, { metadata, clientInformation, redirectUrl, scope, state, resource }) {
|
|
914
|
+
let authorizationUrl;
|
|
915
|
+
if (metadata) {
|
|
916
|
+
authorizationUrl = new URL(metadata.authorization_endpoint);
|
|
917
|
+
if (!metadata.response_types_supported.includes(AUTHORIZATION_CODE_RESPONSE_TYPE)) {
|
|
918
|
+
throw new Error(`Incompatible auth server: does not support response type ${AUTHORIZATION_CODE_RESPONSE_TYPE}`);
|
|
919
|
+
}
|
|
920
|
+
if (metadata.code_challenge_methods_supported && !metadata.code_challenge_methods_supported.includes(AUTHORIZATION_CODE_CHALLENGE_METHOD)) {
|
|
921
|
+
throw new Error(`Incompatible auth server: does not support code challenge method ${AUTHORIZATION_CODE_CHALLENGE_METHOD}`);
|
|
922
|
+
}
|
|
923
|
+
} else {
|
|
924
|
+
authorizationUrl = new URL("/authorize", authorizationServerUrl);
|
|
925
|
+
}
|
|
926
|
+
const challenge = await pkceChallenge();
|
|
927
|
+
const codeVerifier = challenge.code_verifier;
|
|
928
|
+
const codeChallenge = challenge.code_challenge;
|
|
929
|
+
authorizationUrl.searchParams.set("response_type", AUTHORIZATION_CODE_RESPONSE_TYPE);
|
|
930
|
+
authorizationUrl.searchParams.set("client_id", clientInformation.client_id);
|
|
931
|
+
authorizationUrl.searchParams.set("code_challenge", codeChallenge);
|
|
932
|
+
authorizationUrl.searchParams.set("code_challenge_method", AUTHORIZATION_CODE_CHALLENGE_METHOD);
|
|
933
|
+
authorizationUrl.searchParams.set("redirect_uri", String(redirectUrl));
|
|
934
|
+
if (state) {
|
|
935
|
+
authorizationUrl.searchParams.set("state", state);
|
|
936
|
+
}
|
|
937
|
+
if (scope) {
|
|
938
|
+
authorizationUrl.searchParams.set("scope", scope);
|
|
939
|
+
}
|
|
940
|
+
if (scope?.includes("offline_access")) {
|
|
941
|
+
authorizationUrl.searchParams.append("prompt", "consent");
|
|
942
|
+
}
|
|
943
|
+
if (resource) {
|
|
944
|
+
authorizationUrl.searchParams.set("resource", resourceIndicatorToString(resource));
|
|
945
|
+
}
|
|
946
|
+
return { authorizationUrl, codeVerifier };
|
|
947
|
+
}
|
|
948
|
+
function prepareAuthorizationCodeRequest(authorizationCode, codeVerifier, redirectUri) {
|
|
949
|
+
return new URLSearchParams({
|
|
950
|
+
grant_type: "authorization_code",
|
|
951
|
+
code: authorizationCode,
|
|
952
|
+
code_verifier: codeVerifier,
|
|
953
|
+
redirect_uri: String(redirectUri)
|
|
954
|
+
});
|
|
955
|
+
}
|
|
956
|
+
async function executeTokenRequest(authorizationServerUrl, { metadata, tokenRequestParams, clientInformation, addClientAuthentication, resource, fetchFn }) {
|
|
957
|
+
const tokenUrl = metadata?.token_endpoint ? new URL(metadata.token_endpoint) : new URL("/token", authorizationServerUrl);
|
|
958
|
+
const headers = new Headers({
|
|
959
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
960
|
+
Accept: "application/json"
|
|
961
|
+
});
|
|
962
|
+
if (resource) {
|
|
963
|
+
tokenRequestParams.set("resource", resourceIndicatorToString(resource));
|
|
964
|
+
}
|
|
965
|
+
if (addClientAuthentication) {
|
|
966
|
+
await addClientAuthentication(headers, tokenRequestParams, tokenUrl, metadata);
|
|
967
|
+
} else if (clientInformation) {
|
|
968
|
+
const supportedMethods = metadata?.token_endpoint_auth_methods_supported ?? [];
|
|
969
|
+
const authMethod = selectClientAuthMethod(clientInformation, supportedMethods);
|
|
970
|
+
applyClientAuthentication(authMethod, clientInformation, headers, tokenRequestParams);
|
|
971
|
+
}
|
|
972
|
+
const response = await fetchWithinOrigin(fetchFn ?? fetch)(tokenUrl, {
|
|
973
|
+
method: "POST",
|
|
974
|
+
headers,
|
|
975
|
+
body: tokenRequestParams
|
|
976
|
+
});
|
|
977
|
+
if (!response.ok) {
|
|
978
|
+
throw await parseErrorResponse(response);
|
|
979
|
+
}
|
|
980
|
+
return TokenResponseSchema.parse(await response.json());
|
|
981
|
+
}
|
|
982
|
+
async function exchangeAuthorization(authorizationServerUrl, { metadata, clientInformation, authorizationCode, codeVerifier, redirectUri, resource, addClientAuthentication, fetchFn }) {
|
|
983
|
+
const tokenRequestParams = prepareAuthorizationCodeRequest(authorizationCode, codeVerifier, redirectUri);
|
|
984
|
+
return executeTokenRequest(authorizationServerUrl, {
|
|
985
|
+
metadata,
|
|
986
|
+
tokenRequestParams,
|
|
987
|
+
clientInformation,
|
|
988
|
+
addClientAuthentication,
|
|
989
|
+
resource,
|
|
990
|
+
fetchFn
|
|
991
|
+
});
|
|
992
|
+
}
|
|
993
|
+
async function refreshAuthorization(authorizationServerUrl, { metadata, clientInformation, refreshToken, resource, addClientAuthentication, fetchFn }) {
|
|
994
|
+
const tokenRequestParams = new URLSearchParams({
|
|
995
|
+
grant_type: "refresh_token",
|
|
996
|
+
refresh_token: refreshToken
|
|
997
|
+
});
|
|
998
|
+
const tokens = await executeTokenRequest(authorizationServerUrl, {
|
|
999
|
+
metadata,
|
|
1000
|
+
tokenRequestParams,
|
|
1001
|
+
clientInformation,
|
|
1002
|
+
addClientAuthentication,
|
|
1003
|
+
resource,
|
|
1004
|
+
fetchFn
|
|
1005
|
+
});
|
|
1006
|
+
return { refresh_token: refreshToken, ...tokens };
|
|
1007
|
+
}
|
|
1008
|
+
async function fetchToken(provider, authorizationServerUrl, { metadata, resource, authorizationCode, fetchFn } = {}) {
|
|
1009
|
+
const readClientInformation = async () => {
|
|
1010
|
+
const storedClientInformation = await provider.clientInformation();
|
|
1011
|
+
const checked = discardIfIssuerMismatch(storedClientInformation, String(authorizationServerUrl));
|
|
1012
|
+
if (storedClientInformation && !checked) {
|
|
1013
|
+
throw boundElsewhereError(storedClientInformation, String(authorizationServerUrl));
|
|
1014
|
+
}
|
|
1015
|
+
return checked;
|
|
1016
|
+
};
|
|
1017
|
+
let clientInformation = await readClientInformation();
|
|
1018
|
+
const scope = provider.clientMetadata.scope;
|
|
1019
|
+
let tokenRequestParams;
|
|
1020
|
+
if (provider.prepareTokenRequest) {
|
|
1021
|
+
tokenRequestParams = await provider.prepareTokenRequest(scope);
|
|
1022
|
+
}
|
|
1023
|
+
if (!tokenRequestParams) {
|
|
1024
|
+
if (!authorizationCode) {
|
|
1025
|
+
throw new Error("Either provider.prepareTokenRequest() or authorizationCode is required");
|
|
1026
|
+
}
|
|
1027
|
+
if (!provider.redirectUrl) {
|
|
1028
|
+
throw new Error("redirectUrl is required for authorization_code flow");
|
|
1029
|
+
}
|
|
1030
|
+
const codeVerifier = await provider.codeVerifier();
|
|
1031
|
+
tokenRequestParams = prepareAuthorizationCodeRequest(authorizationCode, codeVerifier, provider.redirectUrl);
|
|
1032
|
+
}
|
|
1033
|
+
clientInformation ?? (clientInformation = await readClientInformation());
|
|
1034
|
+
return executeTokenRequest(authorizationServerUrl, {
|
|
1035
|
+
metadata,
|
|
1036
|
+
tokenRequestParams,
|
|
1037
|
+
clientInformation,
|
|
1038
|
+
addClientAuthentication: provider.addClientAuthentication,
|
|
1039
|
+
resource,
|
|
1040
|
+
fetchFn
|
|
1041
|
+
});
|
|
1042
|
+
}
|
|
1043
|
+
async function registerClient(authorizationServerUrl, { metadata, clientMetadata, scope, fetchFn }) {
|
|
1044
|
+
let registrationUrl;
|
|
1045
|
+
if (metadata) {
|
|
1046
|
+
if (!metadata.registration_endpoint) {
|
|
1047
|
+
throw new Error("Incompatible auth server: does not support dynamic client registration");
|
|
1048
|
+
}
|
|
1049
|
+
registrationUrl = new URL(metadata.registration_endpoint);
|
|
1050
|
+
} else {
|
|
1051
|
+
registrationUrl = new URL("/register", authorizationServerUrl);
|
|
1052
|
+
}
|
|
1053
|
+
const response = await fetchWithinOrigin(fetchFn ?? fetch)(registrationUrl, {
|
|
1054
|
+
method: "POST",
|
|
1055
|
+
headers: {
|
|
1056
|
+
"Content-Type": "application/json"
|
|
1057
|
+
},
|
|
1058
|
+
body: JSON.stringify({
|
|
1059
|
+
...clientMetadata,
|
|
1060
|
+
...scope !== void 0 ? { scope } : {}
|
|
1061
|
+
})
|
|
1062
|
+
});
|
|
1063
|
+
if (!response.ok) {
|
|
1064
|
+
throw await parseErrorResponse(response);
|
|
1065
|
+
}
|
|
1066
|
+
return RegistrationResponseSchema.parse(await response.json());
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
export {
|
|
1070
|
+
normalizeHeaders,
|
|
1071
|
+
createFetchWithInit,
|
|
1072
|
+
followWithinOrigin,
|
|
1073
|
+
fetchLeavingRedirects,
|
|
1074
|
+
fetchWithinOrigin,
|
|
1075
|
+
unfollowedRedirect,
|
|
1076
|
+
UnauthorizedError,
|
|
1077
|
+
selectClientAuthMethod,
|
|
1078
|
+
parseErrorResponse,
|
|
1079
|
+
auth,
|
|
1080
|
+
isHttpsUrl,
|
|
1081
|
+
selectResourceURL,
|
|
1082
|
+
extractWWWAuthenticateParams,
|
|
1083
|
+
extractResourceMetadataUrl,
|
|
1084
|
+
discoverOAuthProtectedResourceMetadata,
|
|
1085
|
+
discoverOAuthMetadata,
|
|
1086
|
+
buildDiscoveryUrls,
|
|
1087
|
+
discoverAuthorizationServerMetadata,
|
|
1088
|
+
discoverOAuthServerInfo,
|
|
1089
|
+
startAuthorization,
|
|
1090
|
+
prepareAuthorizationCodeRequest,
|
|
1091
|
+
exchangeAuthorization,
|
|
1092
|
+
refreshAuthorization,
|
|
1093
|
+
fetchToken,
|
|
1094
|
+
registerClient
|
|
1095
|
+
};
|
|
1096
|
+
//# sourceMappingURL=chunk-GAJC4BQZ.js.map
|