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
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
safeBase64Encode
|
|
4
|
+
} from "./chunk-RGVCOG2S.js";
|
|
2
5
|
import {
|
|
3
6
|
a,
|
|
4
7
|
c,
|
|
@@ -12,10 +15,13 @@ import {
|
|
|
12
15
|
s,
|
|
13
16
|
t2 as t,
|
|
14
17
|
u
|
|
15
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-JNUKLSMZ.js";
|
|
19
|
+
import {
|
|
20
|
+
sanitizeForTerminal
|
|
21
|
+
} from "./chunk-KLDMLWXT.js";
|
|
16
22
|
import {
|
|
17
23
|
external_exports
|
|
18
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-P6YQWIT2.js";
|
|
19
25
|
import {
|
|
20
26
|
__commonJS,
|
|
21
27
|
__require,
|
|
@@ -2247,885 +2253,157 @@ var require_nacl_fast = __commonJS({
|
|
|
2247
2253
|
}
|
|
2248
2254
|
});
|
|
2249
2255
|
|
|
2250
|
-
// node_modules/.pnpm/@
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
var OptionalAny = external_exports.record(external_exports.unknown()).optional().nullable();
|
|
2254
|
-
var NetworkSchemaV1 = NonEmptyString;
|
|
2255
|
-
var NetworkSchemaV2 = external_exports.string().min(3).refine((val) => val.includes(":"), {
|
|
2256
|
-
message: "Network must be in CAIP-2 format (e.g., 'eip155:84532')"
|
|
2257
|
-
});
|
|
2258
|
-
var NetworkSchema = external_exports.union([NetworkSchemaV1, NetworkSchemaV2]);
|
|
2259
|
-
var PRINTABLE_ASCII_REGEX = /^[\x20-\x7e]+$/;
|
|
2260
|
-
var ResourceInfoSchema = external_exports.object({
|
|
2261
|
-
url: NonEmptyString,
|
|
2262
|
-
description: external_exports.string().nullish().transform((v) => v ?? void 0),
|
|
2263
|
-
mimeType: external_exports.string().nullish().transform((v) => v ?? void 0),
|
|
2264
|
-
serviceName: external_exports.string().min(1).max(32).regex(PRINTABLE_ASCII_REGEX).nullish().transform((v) => v ?? void 0),
|
|
2265
|
-
tags: external_exports.array(external_exports.string().min(1).max(32).regex(PRINTABLE_ASCII_REGEX)).max(5).nullish().transform((v) => v ?? void 0),
|
|
2266
|
-
iconUrl: external_exports.string().max(2048).nullish().transform((v) => v ?? void 0)
|
|
2267
|
-
});
|
|
2268
|
-
var PaymentRequirementsV1Schema = external_exports.object({
|
|
2269
|
-
scheme: NonEmptyString,
|
|
2270
|
-
network: NetworkSchemaV1,
|
|
2271
|
-
maxAmountRequired: NonEmptyString,
|
|
2272
|
-
resource: NonEmptyString,
|
|
2273
|
-
// URL string in V1
|
|
2274
|
-
description: external_exports.string(),
|
|
2275
|
-
mimeType: external_exports.string().optional(),
|
|
2276
|
-
outputSchema: Any.optional().nullable(),
|
|
2277
|
-
payTo: NonEmptyString,
|
|
2278
|
-
maxTimeoutSeconds: external_exports.number().positive(),
|
|
2279
|
-
asset: NonEmptyString,
|
|
2280
|
-
extra: OptionalAny
|
|
2281
|
-
});
|
|
2282
|
-
var PaymentRequiredV1Schema = external_exports.object({
|
|
2283
|
-
x402Version: external_exports.literal(1),
|
|
2284
|
-
error: external_exports.string().optional(),
|
|
2285
|
-
accepts: external_exports.array(PaymentRequirementsV1Schema).min(1)
|
|
2286
|
-
});
|
|
2287
|
-
var PaymentPayloadV1Schema = external_exports.object({
|
|
2288
|
-
x402Version: external_exports.literal(1),
|
|
2289
|
-
scheme: NonEmptyString,
|
|
2290
|
-
network: NetworkSchemaV1,
|
|
2291
|
-
payload: Any
|
|
2292
|
-
});
|
|
2293
|
-
var PaymentRequirementsV2Schema = external_exports.object({
|
|
2294
|
-
scheme: NonEmptyString,
|
|
2295
|
-
network: NetworkSchemaV2,
|
|
2296
|
-
amount: NonEmptyString,
|
|
2297
|
-
asset: NonEmptyString,
|
|
2298
|
-
payTo: NonEmptyString,
|
|
2299
|
-
maxTimeoutSeconds: external_exports.number().positive(),
|
|
2300
|
-
extra: OptionalAny
|
|
2301
|
-
});
|
|
2302
|
-
var PaymentRequiredV2Schema = external_exports.object({
|
|
2303
|
-
x402Version: external_exports.literal(2),
|
|
2304
|
-
error: external_exports.string().nullish().transform((v) => v ?? void 0),
|
|
2305
|
-
resource: ResourceInfoSchema,
|
|
2306
|
-
accepts: external_exports.array(PaymentRequirementsV2Schema).min(1),
|
|
2307
|
-
extensions: OptionalAny
|
|
2308
|
-
});
|
|
2309
|
-
var PaymentPayloadV2Schema = external_exports.object({
|
|
2310
|
-
x402Version: external_exports.literal(2),
|
|
2311
|
-
resource: ResourceInfoSchema.nullish().transform((v) => v ?? void 0),
|
|
2312
|
-
accepted: PaymentRequirementsV2Schema,
|
|
2313
|
-
payload: Any,
|
|
2314
|
-
extensions: OptionalAny
|
|
2315
|
-
});
|
|
2316
|
-
var PaymentRequirementsSchema = external_exports.union([
|
|
2317
|
-
PaymentRequirementsV1Schema,
|
|
2318
|
-
PaymentRequirementsV2Schema
|
|
2319
|
-
]);
|
|
2320
|
-
var PaymentRequiredSchema = external_exports.discriminatedUnion("x402Version", [
|
|
2321
|
-
PaymentRequiredV1Schema,
|
|
2322
|
-
PaymentRequiredV2Schema
|
|
2323
|
-
]);
|
|
2324
|
-
var PaymentPayloadSchema = external_exports.discriminatedUnion("x402Version", [
|
|
2325
|
-
PaymentPayloadV1Schema,
|
|
2326
|
-
PaymentPayloadV2Schema
|
|
2327
|
-
]);
|
|
2328
|
-
|
|
2329
|
-
// node_modules/.pnpm/@x402+core@2.28.0/node_modules/@x402/core/dist/esm/chunk-VE37GDG2.mjs
|
|
2330
|
-
var x402Version = 2;
|
|
2331
|
-
|
|
2332
|
-
// node_modules/.pnpm/@x402+core@2.28.0/node_modules/@x402/core/dist/esm/chunk-MA7F3CLI.mjs
|
|
2333
|
-
var VerifyError = class extends Error {
|
|
2334
|
-
/**
|
|
2335
|
-
* Creates a VerifyError from a failed verification response.
|
|
2336
|
-
*
|
|
2337
|
-
* @param statusCode - HTTP status code from the facilitator
|
|
2338
|
-
* @param response - The verify response containing failure details
|
|
2339
|
-
*/
|
|
2340
|
-
constructor(statusCode, response) {
|
|
2341
|
-
const reason = response.invalidReason || "unknown reason";
|
|
2342
|
-
const message = response.invalidMessage;
|
|
2343
|
-
super(message ? `${reason}: ${message}` : reason);
|
|
2344
|
-
this.name = "VerifyError";
|
|
2345
|
-
this.statusCode = statusCode;
|
|
2346
|
-
this.invalidReason = response.invalidReason;
|
|
2347
|
-
this.invalidMessage = response.invalidMessage;
|
|
2348
|
-
this.payer = response.payer;
|
|
2349
|
-
}
|
|
2350
|
-
};
|
|
2351
|
-
var SettleError = class extends Error {
|
|
2352
|
-
/**
|
|
2353
|
-
* Creates a SettleError from a failed settlement response.
|
|
2354
|
-
*
|
|
2355
|
-
* @param statusCode - HTTP status code from the facilitator
|
|
2356
|
-
* @param response - The settle response containing error details
|
|
2357
|
-
*/
|
|
2358
|
-
constructor(statusCode, response) {
|
|
2359
|
-
const reason = response.errorReason || "unknown reason";
|
|
2360
|
-
const message = response.errorMessage;
|
|
2361
|
-
super(message ? `${reason}: ${message}` : reason);
|
|
2362
|
-
this.name = "SettleError";
|
|
2363
|
-
this.statusCode = statusCode;
|
|
2364
|
-
this.errorReason = response.errorReason;
|
|
2365
|
-
this.errorMessage = response.errorMessage;
|
|
2366
|
-
this.payer = response.payer;
|
|
2367
|
-
this.transaction = response.transaction;
|
|
2368
|
-
this.network = response.network;
|
|
2369
|
-
}
|
|
2370
|
-
};
|
|
2371
|
-
var FacilitatorResponseError = class extends Error {
|
|
2372
|
-
/**
|
|
2373
|
-
* Creates a FacilitatorResponseError for malformed facilitator responses.
|
|
2374
|
-
*
|
|
2375
|
-
* @param message - The boundary error message
|
|
2376
|
-
*/
|
|
2377
|
-
constructor(message) {
|
|
2378
|
-
super(message);
|
|
2379
|
-
this.name = "FacilitatorResponseError";
|
|
2380
|
-
}
|
|
2381
|
-
};
|
|
2382
|
-
var FacilitatorTimeoutError = class extends FacilitatorResponseError {
|
|
2383
|
-
/**
|
|
2384
|
-
* Creates a FacilitatorTimeoutError.
|
|
2385
|
-
*
|
|
2386
|
-
* @param operation - The facilitator operation that timed out
|
|
2387
|
-
* @param timeoutMs - The configured timeout in milliseconds
|
|
2388
|
-
*/
|
|
2389
|
-
constructor(operation, timeoutMs) {
|
|
2390
|
-
super(`Facilitator ${operation} request timed out after ${timeoutMs}ms`);
|
|
2391
|
-
this.name = "FacilitatorTimeoutError";
|
|
2392
|
-
this.operation = operation;
|
|
2393
|
-
this.timeoutMs = timeoutMs;
|
|
2394
|
-
}
|
|
2395
|
-
};
|
|
2396
|
-
|
|
2397
|
-
// node_modules/.pnpm/@x402+core@2.28.0/node_modules/@x402/core/dist/esm/chunk-XW2CWVLZ.mjs
|
|
2398
|
-
function numberToDecimalString(n2) {
|
|
2399
|
-
const str = n2.toString();
|
|
2400
|
-
if (!/[eE]/.test(str)) return str;
|
|
2401
|
-
const [significand, exponentStr] = str.split(/[eE]/);
|
|
2402
|
-
const exp = parseInt(exponentStr, 10);
|
|
2403
|
-
const negative = significand.startsWith("-");
|
|
2404
|
-
const abs = negative ? significand.slice(1) : significand;
|
|
2405
|
-
const [intDigits, fracDigits = ""] = abs.split(".");
|
|
2406
|
-
const allDigits = intDigits + fracDigits;
|
|
2407
|
-
const decimalPos = intDigits.length + exp;
|
|
2408
|
-
let result;
|
|
2409
|
-
if (decimalPos <= 0) {
|
|
2410
|
-
result = "0." + "0".repeat(-decimalPos) + allDigits;
|
|
2411
|
-
} else if (decimalPos >= allDigits.length) {
|
|
2412
|
-
result = allDigits + "0".repeat(decimalPos - allDigits.length);
|
|
2413
|
-
} else {
|
|
2414
|
-
result = allDigits.slice(0, decimalPos) + "." + allDigits.slice(decimalPos);
|
|
2415
|
-
}
|
|
2416
|
-
return (negative ? "-" : "") + result;
|
|
2256
|
+
// node_modules/.pnpm/@scure+base@1.2.6/node_modules/@scure/base/lib/esm/index.js
|
|
2257
|
+
function isBytes(a4) {
|
|
2258
|
+
return a4 instanceof Uint8Array || ArrayBuffer.isView(a4) && a4.constructor.name === "Uint8Array";
|
|
2417
2259
|
}
|
|
2418
|
-
function
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2260
|
+
function isArrayOf(isString, arr) {
|
|
2261
|
+
if (!Array.isArray(arr))
|
|
2262
|
+
return false;
|
|
2263
|
+
if (arr.length === 0)
|
|
2264
|
+
return true;
|
|
2265
|
+
if (isString) {
|
|
2266
|
+
return arr.every((item) => typeof item === "string");
|
|
2267
|
+
} else {
|
|
2268
|
+
return arr.every((item) => Number.isSafeInteger(item));
|
|
2422
2269
|
}
|
|
2423
|
-
return cleaned;
|
|
2424
2270
|
}
|
|
2425
|
-
function
|
|
2426
|
-
if (typeof
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
}
|
|
2430
|
-
return { amount: numberToDecimalString(money) };
|
|
2431
|
-
}
|
|
2432
|
-
const trimmed = money.trim();
|
|
2433
|
-
const match = trimmed.match(/^\$?\s*(-?\d+(?:\.\d+)?)(?:\s+([A-Za-z][A-Za-z0-9.]*))?$/);
|
|
2434
|
-
if (!match) {
|
|
2435
|
-
throw new Error(`Invalid money format: ${money}`);
|
|
2436
|
-
}
|
|
2437
|
-
const amount = parseMoneyString(match[1]);
|
|
2438
|
-
const rawSymbol = match[2];
|
|
2439
|
-
if (!rawSymbol || rawSymbol.toUpperCase() === "USD") {
|
|
2440
|
-
return { amount };
|
|
2441
|
-
}
|
|
2442
|
-
return { amount, symbol: rawSymbol.toUpperCase() };
|
|
2271
|
+
function astr(label, input) {
|
|
2272
|
+
if (typeof input !== "string")
|
|
2273
|
+
throw new Error(`${label}: string expected`);
|
|
2274
|
+
return true;
|
|
2443
2275
|
}
|
|
2444
|
-
function
|
|
2445
|
-
if (
|
|
2446
|
-
throw new Error(
|
|
2447
|
-
`Invalid amount: ${decimalAmount} \u2014 use decimal notation, not scientific notation`
|
|
2448
|
-
);
|
|
2449
|
-
}
|
|
2450
|
-
if (!/^-?\d+\.?\d*$/.test(decimalAmount)) {
|
|
2451
|
-
throw new Error(`Invalid amount: ${decimalAmount}`);
|
|
2452
|
-
}
|
|
2453
|
-
const [intPart, decPart = ""] = decimalAmount.split(".");
|
|
2454
|
-
const paddedDec = decPart.padEnd(decimals, "0").slice(0, decimals);
|
|
2455
|
-
return (intPart + paddedDec).replace(/^0+/, "") || "0";
|
|
2276
|
+
function anumber(n2) {
|
|
2277
|
+
if (!Number.isSafeInteger(n2))
|
|
2278
|
+
throw new Error(`invalid integer: ${n2}`);
|
|
2456
2279
|
}
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
return new RegExp(`^${source}$`);
|
|
2461
|
-
};
|
|
2462
|
-
var networkMatchesPattern = (pattern, network) => {
|
|
2463
|
-
return networkPatternToRegExp(pattern).test(network);
|
|
2464
|
-
};
|
|
2465
|
-
var findSchemesByNetwork = (map, network) => {
|
|
2466
|
-
let implementationsByScheme = map.get(network);
|
|
2467
|
-
if (!implementationsByScheme) {
|
|
2468
|
-
for (const [registeredNetworkPattern, implementations] of map.entries()) {
|
|
2469
|
-
if (networkMatchesPattern(registeredNetworkPattern, network)) {
|
|
2470
|
-
implementationsByScheme = implementations;
|
|
2471
|
-
break;
|
|
2472
|
-
}
|
|
2473
|
-
}
|
|
2474
|
-
}
|
|
2475
|
-
return implementationsByScheme;
|
|
2476
|
-
};
|
|
2477
|
-
var findByNetworkAndScheme = (map, scheme, network) => {
|
|
2478
|
-
return findSchemesByNetwork(map, network)?.get(scheme);
|
|
2479
|
-
};
|
|
2480
|
-
var Base64EncodedRegex = /^[A-Za-z0-9+/]*={0,2}$/;
|
|
2481
|
-
function safeBase64Encode(data) {
|
|
2482
|
-
if (typeof globalThis !== "undefined" && typeof globalThis.btoa === "function") {
|
|
2483
|
-
const bytes = new TextEncoder().encode(data);
|
|
2484
|
-
const binaryString = Array.from(bytes, (byte) => String.fromCharCode(byte)).join("");
|
|
2485
|
-
return globalThis.btoa(binaryString);
|
|
2486
|
-
}
|
|
2487
|
-
return Buffer.from(data, "utf8").toString("base64");
|
|
2280
|
+
function aArr(input) {
|
|
2281
|
+
if (!Array.isArray(input))
|
|
2282
|
+
throw new Error("array expected");
|
|
2488
2283
|
}
|
|
2489
|
-
function
|
|
2490
|
-
if (
|
|
2491
|
-
|
|
2492
|
-
const bytes = new Uint8Array(binaryString.length);
|
|
2493
|
-
for (let i3 = 0; i3 < binaryString.length; i3++) {
|
|
2494
|
-
bytes[i3] = binaryString.charCodeAt(i3);
|
|
2495
|
-
}
|
|
2496
|
-
const decoder = new TextDecoder("utf-8");
|
|
2497
|
-
return decoder.decode(bytes);
|
|
2498
|
-
}
|
|
2499
|
-
return Buffer.from(data, "base64").toString("utf-8");
|
|
2284
|
+
function astrArr(label, input) {
|
|
2285
|
+
if (!isArrayOf(true, input))
|
|
2286
|
+
throw new Error(`${label}: array of strings expected`);
|
|
2500
2287
|
}
|
|
2501
|
-
function
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
if (typeof obj !== "object") return JSON.stringify(obj);
|
|
2505
|
-
if (Array.isArray(obj)) {
|
|
2506
|
-
return JSON.stringify(
|
|
2507
|
-
obj.map(
|
|
2508
|
-
(item) => typeof item === "object" && item !== null ? JSON.parse(normalize(item)) : item
|
|
2509
|
-
)
|
|
2510
|
-
);
|
|
2511
|
-
}
|
|
2512
|
-
const sorted = {};
|
|
2513
|
-
Object.keys(obj).sort().forEach((key) => {
|
|
2514
|
-
const value = obj[key];
|
|
2515
|
-
sorted[key] = typeof value === "object" && value !== null ? JSON.parse(normalize(value)) : value;
|
|
2516
|
-
});
|
|
2517
|
-
return JSON.stringify(sorted);
|
|
2518
|
-
};
|
|
2519
|
-
try {
|
|
2520
|
-
return normalize(obj1) === normalize(obj2);
|
|
2521
|
-
} catch {
|
|
2522
|
-
return JSON.stringify(obj1) === JSON.stringify(obj2);
|
|
2523
|
-
}
|
|
2288
|
+
function anumArr(label, input) {
|
|
2289
|
+
if (!isArrayOf(false, input))
|
|
2290
|
+
throw new Error(`${label}: array of numbers expected`);
|
|
2524
2291
|
}
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
}
|
|
2532
|
-
return [value];
|
|
2292
|
+
// @__NO_SIDE_EFFECTS__
|
|
2293
|
+
function chain(...args) {
|
|
2294
|
+
const id = (a4) => a4;
|
|
2295
|
+
const wrap = (a4, b) => (c2) => a4(b(c2));
|
|
2296
|
+
const encode = args.map((x) => x.encode).reduceRight(wrap, id);
|
|
2297
|
+
const decode = args.map((x) => x.decode).reduce(wrap, id);
|
|
2298
|
+
return { encode, decode };
|
|
2533
2299
|
}
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
if (delay === null || delay <= 0) {
|
|
2559
|
-
delay = GET_SUPPORTED_RETRY_DELAY_MS * Math.pow(2, attempt);
|
|
2560
|
-
}
|
|
2561
|
-
return Math.min(delay, MAX_RETRY_DELAY_MS);
|
|
2562
|
-
}
|
|
2563
|
-
var verifyResponseSchema = external_exports.object({
|
|
2564
|
-
isValid: external_exports.boolean(),
|
|
2565
|
-
invalidReason: external_exports.string().nullish().transform((v) => v ?? void 0),
|
|
2566
|
-
invalidMessage: external_exports.string().nullish().transform((v) => v ?? void 0),
|
|
2567
|
-
payer: external_exports.string().nullish().transform((v) => v ?? void 0),
|
|
2568
|
-
extensions: external_exports.record(external_exports.string(), external_exports.unknown()).nullish().transform((v) => v ?? void 0),
|
|
2569
|
-
extra: external_exports.record(external_exports.string(), external_exports.unknown()).nullish().transform((v) => v ?? void 0)
|
|
2570
|
-
});
|
|
2571
|
-
var settleResponseSchema = external_exports.object({
|
|
2572
|
-
success: external_exports.boolean(),
|
|
2573
|
-
errorReason: external_exports.string().nullish().transform((v) => v ?? void 0),
|
|
2574
|
-
errorMessage: external_exports.string().nullish().transform((v) => v ?? void 0),
|
|
2575
|
-
payer: external_exports.string().nullish().transform((v) => v ?? void 0),
|
|
2576
|
-
transaction: external_exports.string(),
|
|
2577
|
-
network: external_exports.custom((value) => typeof value === "string"),
|
|
2578
|
-
amount: external_exports.string().nullish().transform((v) => v ?? void 0),
|
|
2579
|
-
extensions: external_exports.record(external_exports.string(), external_exports.unknown()).nullish().transform((v) => v ?? void 0),
|
|
2580
|
-
extra: external_exports.record(external_exports.string(), external_exports.unknown()).nullish().transform((v) => v ?? void 0)
|
|
2581
|
-
});
|
|
2582
|
-
var supportedKindSchema = external_exports.object({
|
|
2583
|
-
x402Version: external_exports.number(),
|
|
2584
|
-
scheme: external_exports.string(),
|
|
2585
|
-
network: external_exports.custom(
|
|
2586
|
-
(value) => typeof value === "string"
|
|
2587
|
-
),
|
|
2588
|
-
extra: external_exports.record(external_exports.string(), external_exports.unknown()).nullish().transform((v) => v ?? void 0)
|
|
2589
|
-
});
|
|
2590
|
-
var supportedResponseSchema = external_exports.object({
|
|
2591
|
-
kinds: external_exports.array(supportedKindSchema),
|
|
2592
|
-
extensions: external_exports.array(external_exports.string()).default([]),
|
|
2593
|
-
signers: external_exports.record(external_exports.string(), external_exports.array(external_exports.string())).default({})
|
|
2594
|
-
});
|
|
2595
|
-
function responseExcerpt(text, limit = 200) {
|
|
2596
|
-
const compact = text.trim().replace(/\s+/g, " ");
|
|
2597
|
-
if (!compact) {
|
|
2598
|
-
return "<empty response>";
|
|
2599
|
-
}
|
|
2600
|
-
if (compact.length <= limit) {
|
|
2601
|
-
return compact;
|
|
2602
|
-
}
|
|
2603
|
-
return `${compact.slice(0, limit - 3)}...`;
|
|
2604
|
-
}
|
|
2605
|
-
function isAbortOrTimeoutError(error) {
|
|
2606
|
-
let current = error;
|
|
2607
|
-
for (let depth = 0; depth < 10 && current !== null && typeof current === "object"; depth++) {
|
|
2608
|
-
const name = current.name;
|
|
2609
|
-
if (name === "TimeoutError" || name === "AbortError") {
|
|
2610
|
-
return true;
|
|
2611
|
-
}
|
|
2612
|
-
current = current.cause;
|
|
2613
|
-
}
|
|
2614
|
-
return false;
|
|
2615
|
-
}
|
|
2616
|
-
var EXTENSION_RESPONSE_LOG_FIELD_ALLOWLIST = ["status", "rejectedReason", "reason", "code"];
|
|
2617
|
-
function extractExtensionResponsesHeader(response) {
|
|
2618
|
-
const header = response.headers.get("EXTENSION-RESPONSES");
|
|
2619
|
-
if (!header) return void 0;
|
|
2620
|
-
try {
|
|
2621
|
-
const decoded = JSON.parse(safeBase64Decode(header));
|
|
2622
|
-
if (!decoded || typeof decoded !== "object" || Array.isArray(decoded)) {
|
|
2623
|
-
return void 0;
|
|
2300
|
+
// @__NO_SIDE_EFFECTS__
|
|
2301
|
+
function alphabet(letters) {
|
|
2302
|
+
const lettersA = typeof letters === "string" ? letters.split("") : letters;
|
|
2303
|
+
const len = lettersA.length;
|
|
2304
|
+
astrArr("alphabet", lettersA);
|
|
2305
|
+
const indexes = new Map(lettersA.map((l3, i3) => [l3, i3]));
|
|
2306
|
+
return {
|
|
2307
|
+
encode: (digits) => {
|
|
2308
|
+
aArr(digits);
|
|
2309
|
+
return digits.map((i3) => {
|
|
2310
|
+
if (!Number.isSafeInteger(i3) || i3 < 0 || i3 >= len)
|
|
2311
|
+
throw new Error(`alphabet.encode: digit index outside alphabet "${i3}". Allowed: ${letters}`);
|
|
2312
|
+
return lettersA[i3];
|
|
2313
|
+
});
|
|
2314
|
+
},
|
|
2315
|
+
decode: (input) => {
|
|
2316
|
+
aArr(input);
|
|
2317
|
+
return input.map((letter) => {
|
|
2318
|
+
astr("alphabet.decode", letter);
|
|
2319
|
+
const i3 = indexes.get(letter);
|
|
2320
|
+
if (i3 === void 0)
|
|
2321
|
+
throw new Error(`Unknown letter: "${letter}". Allowed: ${letters}`);
|
|
2322
|
+
return i3;
|
|
2323
|
+
});
|
|
2624
2324
|
}
|
|
2625
|
-
|
|
2626
|
-
} catch {
|
|
2627
|
-
return void 0;
|
|
2628
|
-
}
|
|
2325
|
+
};
|
|
2629
2326
|
}
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
}
|
|
2642
|
-
}
|
|
2643
|
-
sanitized[extensionKey] = filtered;
|
|
2327
|
+
// @__NO_SIDE_EFFECTS__
|
|
2328
|
+
function join(separator = "") {
|
|
2329
|
+
astr("join", separator);
|
|
2330
|
+
return {
|
|
2331
|
+
encode: (from) => {
|
|
2332
|
+
astrArr("join.decode", from);
|
|
2333
|
+
return from.join(separator);
|
|
2334
|
+
},
|
|
2335
|
+
decode: (to) => {
|
|
2336
|
+
astr("join.decode", to);
|
|
2337
|
+
return to.split(separator);
|
|
2644
2338
|
}
|
|
2645
|
-
|
|
2646
|
-
} catch {
|
|
2647
|
-
}
|
|
2648
|
-
}
|
|
2649
|
-
function attachExtensionResponsesFromHeader(result, response) {
|
|
2650
|
-
const headerExtensions = extractExtensionResponsesHeader(response);
|
|
2651
|
-
logExtensionResponsesHeader(response, headerExtensions);
|
|
2652
|
-
if (headerExtensions) {
|
|
2653
|
-
result.extensionResponses = headerExtensions;
|
|
2654
|
-
}
|
|
2655
|
-
return result;
|
|
2656
|
-
}
|
|
2657
|
-
async function parseSuccessResponse(response, schema, operation) {
|
|
2658
|
-
const text = await response.text();
|
|
2659
|
-
let data;
|
|
2660
|
-
try {
|
|
2661
|
-
data = JSON.parse(text);
|
|
2662
|
-
} catch {
|
|
2663
|
-
throw new FacilitatorResponseError(
|
|
2664
|
-
`Facilitator ${operation} returned invalid JSON: ${responseExcerpt(text)}`
|
|
2665
|
-
);
|
|
2666
|
-
}
|
|
2667
|
-
const parsed = schema.safeParse(data);
|
|
2668
|
-
if (!parsed.success) {
|
|
2669
|
-
throw new FacilitatorResponseError(
|
|
2670
|
-
`Facilitator ${operation} returned invalid data: ${responseExcerpt(text)}`
|
|
2671
|
-
);
|
|
2672
|
-
}
|
|
2673
|
-
return parsed.data;
|
|
2339
|
+
};
|
|
2674
2340
|
}
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
"Content-Type": "application/json"
|
|
2702
|
-
};
|
|
2703
|
-
if (this._createAuthHeaders) {
|
|
2704
|
-
const authHeaders = await this.createAuthHeaders("verify");
|
|
2705
|
-
headers = { ...headers, ...authHeaders.headers };
|
|
2706
|
-
}
|
|
2707
|
-
return this.withRequestTimeout("verify", async (signal) => {
|
|
2708
|
-
const response = await fetch(`${this.url}/verify`, {
|
|
2709
|
-
method: "POST",
|
|
2710
|
-
headers,
|
|
2711
|
-
redirect: "follow",
|
|
2712
|
-
body: JSON.stringify({
|
|
2713
|
-
x402Version: paymentPayload.x402Version,
|
|
2714
|
-
paymentPayload: this.toJsonSafe(paymentPayload),
|
|
2715
|
-
paymentRequirements: this.toJsonSafe(paymentRequirements)
|
|
2716
|
-
}),
|
|
2717
|
-
signal
|
|
2718
|
-
});
|
|
2719
|
-
if (!response.ok) {
|
|
2720
|
-
const text = await response.text();
|
|
2721
|
-
let data;
|
|
2722
|
-
try {
|
|
2723
|
-
data = JSON.parse(text);
|
|
2724
|
-
} catch {
|
|
2725
|
-
throw new Error(
|
|
2726
|
-
`Facilitator verify failed (${response.status}): ${responseExcerpt(text)}`
|
|
2727
|
-
);
|
|
2728
|
-
}
|
|
2729
|
-
if (typeof data === "object" && data !== null && "isValid" in data) {
|
|
2730
|
-
throw new VerifyError(response.status, data);
|
|
2731
|
-
}
|
|
2732
|
-
throw new Error(
|
|
2733
|
-
`Facilitator verify failed (${response.status}): ${responseExcerpt(JSON.stringify(data))}`
|
|
2734
|
-
);
|
|
2735
|
-
}
|
|
2736
|
-
const verifyResult = await parseSuccessResponse(response, verifyResponseSchema, "verify");
|
|
2737
|
-
return attachExtensionResponsesFromHeader(verifyResult, response);
|
|
2738
|
-
});
|
|
2739
|
-
}
|
|
2740
|
-
/**
|
|
2741
|
-
* Settle a payment with the facilitator
|
|
2742
|
-
*
|
|
2743
|
-
* @param paymentPayload - The payment to settle
|
|
2744
|
-
* @param paymentRequirements - The requirements for settlement
|
|
2745
|
-
* @returns Settlement response
|
|
2746
|
-
*/
|
|
2747
|
-
async settle(paymentPayload, paymentRequirements) {
|
|
2748
|
-
let headers = {
|
|
2749
|
-
"Content-Type": "application/json"
|
|
2750
|
-
};
|
|
2751
|
-
if (this._createAuthHeaders) {
|
|
2752
|
-
const authHeaders = await this.createAuthHeaders("settle");
|
|
2753
|
-
headers = { ...headers, ...authHeaders.headers };
|
|
2754
|
-
}
|
|
2755
|
-
return this.withRequestTimeout("settle", async (signal) => {
|
|
2756
|
-
const response = await fetch(`${this.url}/settle`, {
|
|
2757
|
-
method: "POST",
|
|
2758
|
-
headers,
|
|
2759
|
-
redirect: "follow",
|
|
2760
|
-
body: JSON.stringify({
|
|
2761
|
-
x402Version: paymentPayload.x402Version,
|
|
2762
|
-
paymentPayload: this.toJsonSafe(paymentPayload),
|
|
2763
|
-
paymentRequirements: this.toJsonSafe(paymentRequirements)
|
|
2764
|
-
}),
|
|
2765
|
-
signal
|
|
2766
|
-
});
|
|
2767
|
-
if (!response.ok) {
|
|
2768
|
-
const text = await response.text();
|
|
2769
|
-
let data;
|
|
2770
|
-
try {
|
|
2771
|
-
data = JSON.parse(text);
|
|
2772
|
-
} catch {
|
|
2773
|
-
throw new Error(
|
|
2774
|
-
`Facilitator settle failed (${response.status}): ${responseExcerpt(text)}`
|
|
2775
|
-
);
|
|
2776
|
-
}
|
|
2777
|
-
if (typeof data === "object" && data !== null && "success" in data) {
|
|
2778
|
-
throw new SettleError(response.status, data);
|
|
2779
|
-
}
|
|
2780
|
-
throw new Error(
|
|
2781
|
-
`Facilitator settle failed (${response.status}): ${responseExcerpt(JSON.stringify(data))}`
|
|
2782
|
-
);
|
|
2783
|
-
}
|
|
2784
|
-
const settleResult = await parseSuccessResponse(response, settleResponseSchema, "settle");
|
|
2785
|
-
return attachExtensionResponsesFromHeader(settleResult, response);
|
|
2786
|
-
});
|
|
2787
|
-
}
|
|
2788
|
-
/**
|
|
2789
|
-
* Get supported payment kinds and extensions from the facilitator.
|
|
2790
|
-
* Retries with exponential backoff on 429 rate limit errors.
|
|
2791
|
-
*
|
|
2792
|
-
* @returns Supported payment kinds and extensions
|
|
2793
|
-
*/
|
|
2794
|
-
async getSupported() {
|
|
2795
|
-
let headers = {
|
|
2796
|
-
"Content-Type": "application/json"
|
|
2797
|
-
};
|
|
2798
|
-
if (this._createAuthHeaders) {
|
|
2799
|
-
const authHeaders = await this.createAuthHeaders("supported");
|
|
2800
|
-
headers = { ...headers, ...authHeaders.headers };
|
|
2801
|
-
}
|
|
2802
|
-
let lastError = null;
|
|
2803
|
-
for (let attempt = 0; attempt < GET_SUPPORTED_RETRIES; attempt++) {
|
|
2804
|
-
const outcome = await this.withRequestTimeout("supported", async (signal) => {
|
|
2805
|
-
const response = await fetch(`${this.url}/supported`, {
|
|
2806
|
-
method: "GET",
|
|
2807
|
-
headers,
|
|
2808
|
-
redirect: "follow",
|
|
2809
|
-
signal
|
|
2810
|
-
});
|
|
2811
|
-
if (response.ok) {
|
|
2812
|
-
return {
|
|
2813
|
-
kind: "success",
|
|
2814
|
-
value: await parseSuccessResponse(response, supportedResponseSchema, "supported")
|
|
2815
|
-
};
|
|
2816
|
-
}
|
|
2817
|
-
const errorText = await response.text().catch((cause) => {
|
|
2818
|
-
if (isAbortOrTimeoutError(cause)) {
|
|
2819
|
-
throw cause;
|
|
2820
|
-
}
|
|
2821
|
-
return response.statusText;
|
|
2822
|
-
});
|
|
2823
|
-
return {
|
|
2824
|
-
kind: "http-error",
|
|
2825
|
-
status: response.status,
|
|
2826
|
-
retryAfter: response.headers.get("Retry-After"),
|
|
2827
|
-
error: new Error(
|
|
2828
|
-
`Facilitator getSupported failed (${response.status}): ${responseExcerpt(errorText)}`
|
|
2829
|
-
)
|
|
2830
|
-
};
|
|
2831
|
-
});
|
|
2832
|
-
if (outcome.kind === "success") {
|
|
2833
|
-
return outcome.value;
|
|
2341
|
+
function convertRadix(data, from, to) {
|
|
2342
|
+
if (from < 2)
|
|
2343
|
+
throw new Error(`convertRadix: invalid from=${from}, base cannot be less than 2`);
|
|
2344
|
+
if (to < 2)
|
|
2345
|
+
throw new Error(`convertRadix: invalid to=${to}, base cannot be less than 2`);
|
|
2346
|
+
aArr(data);
|
|
2347
|
+
if (!data.length)
|
|
2348
|
+
return [];
|
|
2349
|
+
let pos = 0;
|
|
2350
|
+
const res = [];
|
|
2351
|
+
const digits = Array.from(data, (d) => {
|
|
2352
|
+
anumber(d);
|
|
2353
|
+
if (d < 0 || d >= from)
|
|
2354
|
+
throw new Error(`invalid integer: ${d}`);
|
|
2355
|
+
return d;
|
|
2356
|
+
});
|
|
2357
|
+
const dlen = digits.length;
|
|
2358
|
+
while (true) {
|
|
2359
|
+
let carry = 0;
|
|
2360
|
+
let done = true;
|
|
2361
|
+
for (let i3 = pos; i3 < dlen; i3++) {
|
|
2362
|
+
const digit = digits[i3];
|
|
2363
|
+
const fromCarry = from * carry;
|
|
2364
|
+
const digitBase = fromCarry + digit;
|
|
2365
|
+
if (!Number.isSafeInteger(digitBase) || fromCarry / from !== carry || digitBase - digit !== fromCarry) {
|
|
2366
|
+
throw new Error("convertRadix: carry overflow");
|
|
2834
2367
|
}
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2368
|
+
const div = digitBase / to;
|
|
2369
|
+
carry = digitBase % to;
|
|
2370
|
+
const rounded = Math.floor(div);
|
|
2371
|
+
digits[i3] = rounded;
|
|
2372
|
+
if (!Number.isSafeInteger(rounded) || rounded * to + carry !== digitBase)
|
|
2373
|
+
throw new Error("convertRadix: carry overflow");
|
|
2374
|
+
if (!done)
|
|
2839
2375
|
continue;
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
}
|
|
2845
|
-
/**
|
|
2846
|
-
* Creates authentication headers for a specific path.
|
|
2847
|
-
*
|
|
2848
|
-
* @param path - The path to create authentication headers for (e.g., "verify", "settle", "supported")
|
|
2849
|
-
* @returns An object containing the authentication headers for the specified path
|
|
2850
|
-
*/
|
|
2851
|
-
async createAuthHeaders(path) {
|
|
2852
|
-
if (!this._createAuthHeaders) {
|
|
2853
|
-
return { headers: {} };
|
|
2854
|
-
}
|
|
2855
|
-
const authHeaders = await this._createAuthHeaders();
|
|
2856
|
-
const isHeaderObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2857
|
-
const hasPathKey = ["verify", "settle", "supported", "bazaar"].some(
|
|
2858
|
-
(key) => isHeaderObject(authHeaders[key])
|
|
2859
|
-
);
|
|
2860
|
-
const looksFlat = !hasPathKey && Object.values(authHeaders).some((value) => !isHeaderObject(value));
|
|
2861
|
-
if (looksFlat) {
|
|
2862
|
-
throw new Error(
|
|
2863
|
-
'createAuthHeaders must return an object keyed by facilitator path, e.g. { verify: { Authorization: "..." }, settle: { ... }, supported: { ... } }, but received a flat headers object. See https://github.com/x402-foundation/x402/issues/2762'
|
|
2864
|
-
);
|
|
2865
|
-
}
|
|
2866
|
-
const headersForPath = authHeaders[path];
|
|
2867
|
-
return {
|
|
2868
|
-
headers: isHeaderObject(headersForPath) ? headersForPath : {}
|
|
2869
|
-
};
|
|
2870
|
-
}
|
|
2871
|
-
/**
|
|
2872
|
-
* Runs a single facilitator HTTP attempt under this client's request deadline.
|
|
2873
|
-
* The provided signal must be passed to `fetch` so the deadline also covers
|
|
2874
|
-
* response-body consumption.
|
|
2875
|
-
*
|
|
2876
|
-
* @param operation - The facilitator operation name ("verify", "settle", "supported")
|
|
2877
|
-
* @param run - The attempt to execute with the deadline's AbortSignal
|
|
2878
|
-
* @returns The attempt's result
|
|
2879
|
-
* @throws FacilitatorTimeoutError when the deadline elapses before completion
|
|
2880
|
-
*/
|
|
2881
|
-
async withRequestTimeout(operation, run) {
|
|
2882
|
-
const signal = AbortSignal.timeout(this.timeoutMs);
|
|
2883
|
-
try {
|
|
2884
|
-
return await run(signal);
|
|
2885
|
-
} catch (error) {
|
|
2886
|
-
if (signal.aborted && isAbortOrTimeoutError(error)) {
|
|
2887
|
-
throw new FacilitatorTimeoutError(operation, this.timeoutMs);
|
|
2888
|
-
}
|
|
2889
|
-
throw error;
|
|
2890
|
-
}
|
|
2891
|
-
}
|
|
2892
|
-
/**
|
|
2893
|
-
* Helper to convert objects to JSON-safe format.
|
|
2894
|
-
* Handles BigInt and other non-JSON types.
|
|
2895
|
-
*
|
|
2896
|
-
* @param obj - The object to convert
|
|
2897
|
-
* @returns The JSON-safe representation of the object
|
|
2898
|
-
*/
|
|
2899
|
-
toJsonSafe(obj) {
|
|
2900
|
-
return JSON.parse(
|
|
2901
|
-
JSON.stringify(obj, (_, value) => typeof value === "bigint" ? value.toString() : value)
|
|
2902
|
-
);
|
|
2903
|
-
}
|
|
2904
|
-
};
|
|
2905
|
-
var x402HTTPClient = class {
|
|
2906
|
-
/**
|
|
2907
|
-
* Creates a new x402HTTPClient instance.
|
|
2908
|
-
*
|
|
2909
|
-
* @param client - The underlying x402Client for payment logic
|
|
2910
|
-
*/
|
|
2911
|
-
constructor(client) {
|
|
2912
|
-
this.client = client;
|
|
2913
|
-
this.paymentRequiredHooks = [];
|
|
2914
|
-
}
|
|
2915
|
-
/**
|
|
2916
|
-
* Register a hook to handle 402 responses before payment.
|
|
2917
|
-
* Hooks run in order; first to return headers wins.
|
|
2918
|
-
*
|
|
2919
|
-
* @param hook - The hook function to register
|
|
2920
|
-
* @returns This instance for chaining
|
|
2921
|
-
*/
|
|
2922
|
-
onPaymentRequired(hook) {
|
|
2923
|
-
this.paymentRequiredHooks.push(hook);
|
|
2924
|
-
return this;
|
|
2925
|
-
}
|
|
2926
|
-
/**
|
|
2927
|
-
* Run hooks and return headers if any hook provides them.
|
|
2928
|
-
*
|
|
2929
|
-
* @param paymentRequired - The payment required response from the server
|
|
2930
|
-
* @param requestUrl - The URL of the request that received the payment required response
|
|
2931
|
-
* @returns Headers to use for retry, or null to proceed to payment
|
|
2932
|
-
*/
|
|
2933
|
-
async handlePaymentRequired(paymentRequired, requestUrl) {
|
|
2934
|
-
for (const hook of this.getPaymentRequiredHooks(paymentRequired)) {
|
|
2935
|
-
const result = await hook({ paymentRequired, requestUrl });
|
|
2936
|
-
if (result?.headers) {
|
|
2937
|
-
return result.headers;
|
|
2938
|
-
}
|
|
2939
|
-
}
|
|
2940
|
-
return null;
|
|
2941
|
-
}
|
|
2942
|
-
/**
|
|
2943
|
-
* Encodes a payment payload into appropriate HTTP headers based on version.
|
|
2944
|
-
*
|
|
2945
|
-
* @param paymentPayload - The payment payload to encode
|
|
2946
|
-
* @returns HTTP headers containing the encoded payment signature
|
|
2947
|
-
*/
|
|
2948
|
-
encodePaymentSignatureHeader(paymentPayload) {
|
|
2949
|
-
switch (paymentPayload.x402Version) {
|
|
2950
|
-
case 2:
|
|
2951
|
-
return {
|
|
2952
|
-
"PAYMENT-SIGNATURE": encodePaymentSignatureHeader(paymentPayload)
|
|
2953
|
-
};
|
|
2954
|
-
case 1:
|
|
2955
|
-
return {
|
|
2956
|
-
"X-PAYMENT": encodePaymentSignatureHeader(paymentPayload)
|
|
2957
|
-
};
|
|
2958
|
-
default:
|
|
2959
|
-
throw new Error(
|
|
2960
|
-
`Unsupported x402 version: ${paymentPayload.x402Version}`
|
|
2961
|
-
);
|
|
2962
|
-
}
|
|
2963
|
-
}
|
|
2964
|
-
/**
|
|
2965
|
-
* Extracts payment required information from HTTP response.
|
|
2966
|
-
*
|
|
2967
|
-
* @param getHeader - Function to retrieve header value by name (case-insensitive)
|
|
2968
|
-
* @param body - Optional response body for v1 compatibility
|
|
2969
|
-
* @returns The payment required object
|
|
2970
|
-
*/
|
|
2971
|
-
getPaymentRequiredResponse(getHeader, body) {
|
|
2972
|
-
const paymentRequired = getHeader("PAYMENT-REQUIRED");
|
|
2973
|
-
if (paymentRequired) {
|
|
2974
|
-
return decodePaymentRequiredHeader(paymentRequired);
|
|
2975
|
-
}
|
|
2976
|
-
if (body && body instanceof Object && "x402Version" in body && body.x402Version === 1) {
|
|
2977
|
-
return body;
|
|
2978
|
-
}
|
|
2979
|
-
throw new Error("Invalid payment required response");
|
|
2980
|
-
}
|
|
2981
|
-
/**
|
|
2982
|
-
* Extracts payment settlement response from HTTP headers.
|
|
2983
|
-
*
|
|
2984
|
-
* @param getHeader - Function to retrieve header value by name (case-insensitive)
|
|
2985
|
-
* @returns The settlement response object
|
|
2986
|
-
*/
|
|
2987
|
-
getPaymentSettleResponse(getHeader) {
|
|
2988
|
-
const paymentResponse = getHeader("PAYMENT-RESPONSE");
|
|
2989
|
-
if (paymentResponse) {
|
|
2990
|
-
return decodePaymentResponseHeader(paymentResponse);
|
|
2376
|
+
else if (!rounded)
|
|
2377
|
+
pos = i3;
|
|
2378
|
+
else
|
|
2379
|
+
done = false;
|
|
2991
2380
|
}
|
|
2992
|
-
|
|
2993
|
-
if (
|
|
2994
|
-
|
|
2995
|
-
}
|
|
2996
|
-
throw new Error("Payment response header not found");
|
|
2997
|
-
}
|
|
2998
|
-
/**
|
|
2999
|
-
* Creates a payment payload for the given payment requirements.
|
|
3000
|
-
* Delegates to the underlying x402Client.
|
|
3001
|
-
*
|
|
3002
|
-
* @param paymentRequired - The payment required response from the server
|
|
3003
|
-
* @returns Promise resolving to the payment payload
|
|
3004
|
-
*/
|
|
3005
|
-
async createPaymentPayload(paymentRequired) {
|
|
3006
|
-
return this.client.createPaymentPayload(paymentRequired);
|
|
3007
|
-
}
|
|
3008
|
-
/**
|
|
3009
|
-
* Parses response headers into protocol types, fires payment response hooks (v2 only),
|
|
3010
|
-
* and returns whether a hook signaled recovery.
|
|
3011
|
-
*
|
|
3012
|
-
* Called by transport wrappers (fetch, axios) after the paid request completes.
|
|
3013
|
-
*
|
|
3014
|
-
* @param paymentPayload - The payload that was sent with the request
|
|
3015
|
-
* @param getHeader - Function to retrieve a response header by name
|
|
3016
|
-
* @param status - The HTTP status code of the response
|
|
3017
|
-
* @returns Whether a hook recovered and the parsed settle response (if any)
|
|
3018
|
-
*/
|
|
3019
|
-
async processPaymentResult(paymentPayload, getHeader, status) {
|
|
3020
|
-
let settleResponse;
|
|
3021
|
-
try {
|
|
3022
|
-
settleResponse = this.getPaymentSettleResponse(getHeader);
|
|
3023
|
-
} catch {
|
|
3024
|
-
}
|
|
3025
|
-
if (paymentPayload.x402Version === 1) {
|
|
3026
|
-
return { recovered: false, settleResponse };
|
|
3027
|
-
}
|
|
3028
|
-
let paymentRequired;
|
|
3029
|
-
if (!settleResponse && status === 402) {
|
|
3030
|
-
try {
|
|
3031
|
-
paymentRequired = this.getPaymentRequiredResponse(getHeader);
|
|
3032
|
-
} catch {
|
|
3033
|
-
}
|
|
3034
|
-
}
|
|
3035
|
-
const requirements = paymentPayload.accepted;
|
|
3036
|
-
if (!requirements) {
|
|
3037
|
-
throw new Error("Invalid x402 v2 payment payload: missing `accepted`");
|
|
3038
|
-
}
|
|
3039
|
-
const ctx = {
|
|
3040
|
-
paymentPayload,
|
|
3041
|
-
requirements,
|
|
3042
|
-
...settleResponse ? { settleResponse } : {},
|
|
3043
|
-
...paymentRequired ? { paymentRequired } : {}
|
|
3044
|
-
};
|
|
3045
|
-
const result = await this.client.handlePaymentResponse(ctx);
|
|
3046
|
-
return { recovered: result?.recovered === true, settleResponse };
|
|
3047
|
-
}
|
|
3048
|
-
/**
|
|
3049
|
-
* Parses HTTP status, headers, and body into an `HTTPResourceResponse`.
|
|
3050
|
-
*
|
|
3051
|
-
* Decodes the x402 payment header into `header`: the `PAYMENT-RESPONSE`
|
|
3052
|
-
* settlement if present, otherwise the `PAYMENT-REQUIRED` declaration on
|
|
3053
|
-
* 402 responses (whose `error` field carries the server's failure reason).
|
|
3054
|
-
*
|
|
3055
|
-
* @param args - Normalized response inputs from any HTTP transport
|
|
3056
|
-
* @param args.status - HTTP response status code
|
|
3057
|
-
* @param args.getHeader - Callback to read response headers by name
|
|
3058
|
-
* @param args.body - Response body payload
|
|
3059
|
-
* @returns The parsed status, body, and decoded payment header
|
|
3060
|
-
*/
|
|
3061
|
-
parsePaymentResult(args) {
|
|
3062
|
-
const { status, getHeader, body } = args;
|
|
3063
|
-
let header;
|
|
3064
|
-
try {
|
|
3065
|
-
header = this.getPaymentSettleResponse(getHeader);
|
|
3066
|
-
} catch {
|
|
3067
|
-
if (status === 402) {
|
|
3068
|
-
try {
|
|
3069
|
-
header = this.getPaymentRequiredResponse(getHeader, body);
|
|
3070
|
-
} catch {
|
|
3071
|
-
}
|
|
3072
|
-
}
|
|
3073
|
-
}
|
|
3074
|
-
let paymentStatus = "none";
|
|
3075
|
-
if (header && !("success" in header)) {
|
|
3076
|
-
paymentStatus = "payment_required";
|
|
3077
|
-
}
|
|
3078
|
-
if (header && "success" in header) {
|
|
3079
|
-
paymentStatus = header.success ? "settled" : "settle_failed";
|
|
3080
|
-
}
|
|
3081
|
-
return { status, paymentStatus, body, header };
|
|
2381
|
+
res.push(carry);
|
|
2382
|
+
if (done)
|
|
2383
|
+
break;
|
|
3082
2384
|
}
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
* @param response - The fetch Response to process
|
|
3087
|
-
* @returns The parsed status, body, and decoded payment header
|
|
3088
|
-
*/
|
|
3089
|
-
async processResponse(response) {
|
|
3090
|
-
const getHeader = (name) => response.headers.get(name);
|
|
3091
|
-
const contentType = response.headers.get("content-type") ?? "";
|
|
3092
|
-
const body = contentType.includes("application/json") ? await response.json() : await response.text();
|
|
3093
|
-
return this.parsePaymentResult({ status: response.status, getHeader, body });
|
|
3094
|
-
}
|
|
3095
|
-
/**
|
|
3096
|
-
* Manual HTTP hooks run before extension hooks scoped to the 402 response.
|
|
3097
|
-
*
|
|
3098
|
-
* @param paymentRequired - The payment required response from the server
|
|
3099
|
-
* @returns Hooks in invocation order
|
|
3100
|
-
*/
|
|
3101
|
-
getPaymentRequiredHooks(paymentRequired) {
|
|
3102
|
-
const hooks = [...this.paymentRequiredHooks];
|
|
3103
|
-
const declaredExtensions = paymentRequired.extensions;
|
|
3104
|
-
if (!declaredExtensions) return hooks;
|
|
3105
|
-
for (const extension of this.client.getExtensions()) {
|
|
3106
|
-
const httpExtension = extension;
|
|
3107
|
-
const hook = httpExtension.transportHooks?.http?.onPaymentRequired;
|
|
3108
|
-
if (!hook || !(extension.key in declaredExtensions)) continue;
|
|
3109
|
-
hooks.push((context) => hook(declaredExtensions[extension.key], context));
|
|
3110
|
-
}
|
|
3111
|
-
return hooks;
|
|
3112
|
-
}
|
|
3113
|
-
};
|
|
3114
|
-
function encodePaymentSignatureHeader(paymentPayload) {
|
|
3115
|
-
return safeBase64Encode(JSON.stringify(paymentPayload));
|
|
2385
|
+
for (let i3 = 0; i3 < data.length - 1 && data[i3] === 0; i3++)
|
|
2386
|
+
res.push(0);
|
|
2387
|
+
return res.reverse();
|
|
3116
2388
|
}
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
return
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
2389
|
+
// @__NO_SIDE_EFFECTS__
|
|
2390
|
+
function radix(num) {
|
|
2391
|
+
anumber(num);
|
|
2392
|
+
const _256 = 2 ** 8;
|
|
2393
|
+
return {
|
|
2394
|
+
encode: (bytes) => {
|
|
2395
|
+
if (!isBytes(bytes))
|
|
2396
|
+
throw new Error("radix.encode input should be Uint8Array");
|
|
2397
|
+
return convertRadix(Array.from(bytes), _256, num);
|
|
2398
|
+
},
|
|
2399
|
+
decode: (digits) => {
|
|
2400
|
+
anumArr("radix.decode", digits);
|
|
2401
|
+
return Uint8Array.from(convertRadix(digits, num, _256));
|
|
2402
|
+
}
|
|
2403
|
+
};
|
|
3128
2404
|
}
|
|
2405
|
+
var genBase58 = /* @__NO_SIDE_EFFECTS__ */ (abc) => /* @__PURE__ */ chain(/* @__PURE__ */ radix(58), /* @__PURE__ */ alphabet(abc), /* @__PURE__ */ join(""));
|
|
2406
|
+
var base58 = /* @__PURE__ */ genBase58("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
|
|
3129
2407
|
|
|
3130
2408
|
// node_modules/.pnpm/@x402+extensions@2.28.0_typescript@6.0.3/node_modules/@x402/extensions/dist/esm/chunk-7HYFQDVS.mjs
|
|
3131
2409
|
var import_tweetnacl = __toESM(require_nacl_fast(), 1);
|
|
@@ -3139,7 +2417,7 @@ async function C(e) {
|
|
|
3139
2417
|
let { provider: t2 } = e, r2 = c();
|
|
3140
2418
|
if (r2) {
|
|
3141
2419
|
if (t2 && !r2.checkContractWalletSignature) {
|
|
3142
|
-
let { tryAutoDetectEthers: e2 } = await import("./ethersCompat-Df4a6QIZ-
|
|
2420
|
+
let { tryAutoDetectEthers: e2 } = await import("./ethersCompat-Df4a6QIZ-K3DMHR6Y.js").then((e3) => e3.n), n2 = await e2(t2);
|
|
3143
2421
|
if (n2) return {
|
|
3144
2422
|
...r2,
|
|
3145
2423
|
checkContractWalletSignature: n2.checkContractWalletSignature
|
|
@@ -3147,7 +2425,7 @@ async function C(e) {
|
|
|
3147
2425
|
}
|
|
3148
2426
|
return r2;
|
|
3149
2427
|
}
|
|
3150
|
-
let { tryAutoDetectEthers: i3 } = await import("./ethersCompat-Df4a6QIZ-
|
|
2428
|
+
let { tryAutoDetectEthers: i3 } = await import("./ethersCompat-Df4a6QIZ-K3DMHR6Y.js").then((e2) => e2.n), o = await i3(t2);
|
|
3151
2429
|
if (o) return o;
|
|
3152
2430
|
throw new r(i2.MISSING_CONFIG, "SiweConfig via configure(), opts.config, or auto-detection", "No config found");
|
|
3153
2431
|
}
|
|
@@ -3405,6 +2683,24 @@ function formatSIWSMessage(info, address) {
|
|
|
3405
2683
|
}
|
|
3406
2684
|
return lines.join("\n");
|
|
3407
2685
|
}
|
|
2686
|
+
function encodeBase58(bytes) {
|
|
2687
|
+
return base58.encode(bytes);
|
|
2688
|
+
}
|
|
2689
|
+
function isSolanaSigner(signer) {
|
|
2690
|
+
if ("signMessages" in signer && typeof signer.signMessages === "function") {
|
|
2691
|
+
return true;
|
|
2692
|
+
}
|
|
2693
|
+
if ("publicKey" in signer && signer.publicKey) {
|
|
2694
|
+
const pk = signer.publicKey;
|
|
2695
|
+
if (typeof pk === "object" && pk !== null && "toBase58" in pk) {
|
|
2696
|
+
return true;
|
|
2697
|
+
}
|
|
2698
|
+
if (typeof pk === "string" && !pk.startsWith("0x")) {
|
|
2699
|
+
return true;
|
|
2700
|
+
}
|
|
2701
|
+
}
|
|
2702
|
+
return false;
|
|
2703
|
+
}
|
|
3408
2704
|
var DEFAULT_MAX_AGE_MS = 5 * 60 * 1e3;
|
|
3409
2705
|
function extractEVMChainId(chainId) {
|
|
3410
2706
|
const match = /^eip155:(\d+)$/.exec(chainId);
|
|
@@ -3431,6 +2727,45 @@ function formatSIWEMessage(info, address) {
|
|
|
3431
2727
|
});
|
|
3432
2728
|
return siweMessage.prepareMessage();
|
|
3433
2729
|
}
|
|
2730
|
+
function getEVMAddress(signer) {
|
|
2731
|
+
if (signer.account?.address) {
|
|
2732
|
+
return signer.account.address;
|
|
2733
|
+
}
|
|
2734
|
+
if (signer.address) {
|
|
2735
|
+
return signer.address;
|
|
2736
|
+
}
|
|
2737
|
+
throw new Error("EVM signer missing address");
|
|
2738
|
+
}
|
|
2739
|
+
function getSolanaAddress(signer) {
|
|
2740
|
+
if ("address" in signer && signer.address) {
|
|
2741
|
+
return signer.address;
|
|
2742
|
+
}
|
|
2743
|
+
if ("publicKey" in signer) {
|
|
2744
|
+
const pk = signer.publicKey;
|
|
2745
|
+
return typeof pk === "string" ? pk : pk.toBase58();
|
|
2746
|
+
}
|
|
2747
|
+
throw new Error("Solana signer missing address or publicKey");
|
|
2748
|
+
}
|
|
2749
|
+
async function signEVMMessage(message, signer) {
|
|
2750
|
+
if (signer.account) {
|
|
2751
|
+
return signer.signMessage({ message, account: signer.account });
|
|
2752
|
+
}
|
|
2753
|
+
return signer.signMessage({ message });
|
|
2754
|
+
}
|
|
2755
|
+
async function signSolanaMessage(message, signer) {
|
|
2756
|
+
const messageBytes = new TextEncoder().encode(message);
|
|
2757
|
+
if ("signMessages" in signer) {
|
|
2758
|
+
const results = await signer.signMessages([{ content: messageBytes, signatures: {} }]);
|
|
2759
|
+
const sigDict = results[0];
|
|
2760
|
+
const signatureBytes = Object.values(sigDict)[0];
|
|
2761
|
+
return encodeBase58(signatureBytes);
|
|
2762
|
+
}
|
|
2763
|
+
if ("signMessage" in signer) {
|
|
2764
|
+
const signatureBytes = await signer.signMessage(messageBytes);
|
|
2765
|
+
return encodeBase58(signatureBytes);
|
|
2766
|
+
}
|
|
2767
|
+
throw new Error("Solana signer missing signMessage or signMessages method");
|
|
2768
|
+
}
|
|
3434
2769
|
function createSIWxMessage(serverInfo, address) {
|
|
3435
2770
|
if (serverInfo.chainId.startsWith("eip155:")) {
|
|
3436
2771
|
return formatSIWEMessage(serverInfo, address);
|
|
@@ -3442,13 +2777,83 @@ function createSIWxMessage(serverInfo, address) {
|
|
|
3442
2777
|
`Unsupported chain namespace: ${serverInfo.chainId}. Supported: eip155:* (EVM), solana:* (Solana)`
|
|
3443
2778
|
);
|
|
3444
2779
|
}
|
|
2780
|
+
function assertSIWxChallengeBoundToOrigin(info, responseUrl) {
|
|
2781
|
+
const origin = typeof responseUrl === "string" ? new URL(responseUrl) : responseUrl;
|
|
2782
|
+
if (info.domain !== origin.host) {
|
|
2783
|
+
throw new Error(
|
|
2784
|
+
`SIWX challenge domain "${info.domain}" does not match response origin host "${origin.host}"`
|
|
2785
|
+
);
|
|
2786
|
+
}
|
|
2787
|
+
let uriOrigin;
|
|
2788
|
+
try {
|
|
2789
|
+
uriOrigin = new URL(info.uri).origin;
|
|
2790
|
+
} catch {
|
|
2791
|
+
throw new Error(`SIWX challenge uri "${info.uri}" is not a valid URL`);
|
|
2792
|
+
}
|
|
2793
|
+
if (uriOrigin !== origin.origin) {
|
|
2794
|
+
throw new Error(
|
|
2795
|
+
`SIWX challenge uri origin "${uriOrigin}" does not match response origin "${origin.origin}"`
|
|
2796
|
+
);
|
|
2797
|
+
}
|
|
2798
|
+
}
|
|
2799
|
+
async function createSIWxPayload(serverExtension, signer, requestUrl) {
|
|
2800
|
+
assertSIWxChallengeBoundToOrigin(serverExtension, requestUrl);
|
|
2801
|
+
const isSolana = serverExtension.chainId.startsWith("solana:");
|
|
2802
|
+
const address = isSolana ? getSolanaAddress(signer) : getEVMAddress(signer);
|
|
2803
|
+
const message = createSIWxMessage(serverExtension, address);
|
|
2804
|
+
const signature = isSolana ? await signSolanaMessage(message, signer) : await signEVMMessage(message, signer);
|
|
2805
|
+
return {
|
|
2806
|
+
domain: serverExtension.domain,
|
|
2807
|
+
address,
|
|
2808
|
+
statement: serverExtension.statement,
|
|
2809
|
+
uri: serverExtension.uri,
|
|
2810
|
+
version: serverExtension.version,
|
|
2811
|
+
chainId: serverExtension.chainId,
|
|
2812
|
+
type: serverExtension.type,
|
|
2813
|
+
nonce: serverExtension.nonce,
|
|
2814
|
+
issuedAt: serverExtension.issuedAt,
|
|
2815
|
+
expirationTime: serverExtension.expirationTime,
|
|
2816
|
+
notBefore: serverExtension.notBefore,
|
|
2817
|
+
requestId: serverExtension.requestId,
|
|
2818
|
+
resources: serverExtension.resources,
|
|
2819
|
+
signatureScheme: serverExtension.signatureScheme,
|
|
2820
|
+
signature
|
|
2821
|
+
};
|
|
2822
|
+
}
|
|
3445
2823
|
function encodeSIWxHeader(payload) {
|
|
3446
2824
|
return safeBase64Encode(JSON.stringify(payload));
|
|
3447
2825
|
}
|
|
2826
|
+
function createSIWxClientHook(signer) {
|
|
2827
|
+
const signerIsSolana = isSolanaSigner(signer);
|
|
2828
|
+
const expectedSignatureType = signerIsSolana ? "ed25519" : "eip191";
|
|
2829
|
+
return async (context) => {
|
|
2830
|
+
const extensions = context.paymentRequired.extensions ?? {};
|
|
2831
|
+
const siwxExtension = extensions[SIGN_IN_WITH_X];
|
|
2832
|
+
if (!siwxExtension?.supportedChains) return;
|
|
2833
|
+
try {
|
|
2834
|
+
const matchingChain = siwxExtension.supportedChains.find(
|
|
2835
|
+
(chain2) => chain2.type === expectedSignatureType
|
|
2836
|
+
);
|
|
2837
|
+
if (!matchingChain) {
|
|
2838
|
+
return;
|
|
2839
|
+
}
|
|
2840
|
+
const completeInfo = {
|
|
2841
|
+
...siwxExtension.info,
|
|
2842
|
+
chainId: matchingChain.chainId,
|
|
2843
|
+
type: matchingChain.type
|
|
2844
|
+
};
|
|
2845
|
+
const payload = await createSIWxPayload(completeInfo, signer, context.requestUrl);
|
|
2846
|
+
const header = encodeSIWxHeader(payload);
|
|
2847
|
+
return { headers: { [SIGN_IN_WITH_X]: header } };
|
|
2848
|
+
} catch {
|
|
2849
|
+
}
|
|
2850
|
+
};
|
|
2851
|
+
}
|
|
3448
2852
|
|
|
3449
2853
|
// src/lib/siwx.ts
|
|
3450
2854
|
import { randomUUID } from "node:crypto";
|
|
3451
2855
|
var SIWX_HEADER = "SIGN-IN-WITH-X";
|
|
2856
|
+
var SIWX_CHAIN_ID = "eip155:8453";
|
|
3452
2857
|
async function buildSiwxHeader(signer, opts) {
|
|
3453
2858
|
const url = new URL(opts.baseUrl);
|
|
3454
2859
|
const now = Date.now();
|
|
@@ -3462,8 +2867,7 @@ async function buildSiwxHeader(signer, opts) {
|
|
|
3462
2867
|
nonce: randomUUID().replace(/-/g, ""),
|
|
3463
2868
|
issuedAt: new Date(now).toISOString(),
|
|
3464
2869
|
expirationTime: new Date(now + (opts.ttlMs ?? 864e5)).toISOString(),
|
|
3465
|
-
statement:
|
|
3466
|
-
...opts.resources !== void 0 && opts.resources.length > 0 ? { resources: opts.resources } : {}
|
|
2870
|
+
statement: "Sign in to Tenjin."
|
|
3467
2871
|
};
|
|
3468
2872
|
const message = createSIWxMessage(info, signer.address);
|
|
3469
2873
|
const signature = await signer.signMessage({ message });
|
|
@@ -3474,24 +2878,70 @@ async function buildSiwxHeader(signer, opts) {
|
|
|
3474
2878
|
signature
|
|
3475
2879
|
});
|
|
3476
2880
|
}
|
|
2881
|
+
function signInOnlyChallenge(challenge) {
|
|
2882
|
+
if (typeof challenge !== "object" || challenge === null) return void 0;
|
|
2883
|
+
if (!Array.isArray(challenge.accepts) || challenge.accepts.length > 0) return void 0;
|
|
2884
|
+
const extension = challenge.extensions?.[SIGN_IN_WITH_X];
|
|
2885
|
+
const info = extension?.info;
|
|
2886
|
+
if (info === void 0 || info === null || typeof info !== "object") return void 0;
|
|
2887
|
+
if (typeof info.domain !== "string" || typeof info.uri !== "string") return void 0;
|
|
2888
|
+
if (typeof info.nonce !== "string" || !Array.isArray(extension?.supportedChains)) {
|
|
2889
|
+
return void 0;
|
|
2890
|
+
}
|
|
2891
|
+
return extension;
|
|
2892
|
+
}
|
|
2893
|
+
function named(value) {
|
|
2894
|
+
return sanitizeForTerminal(String(value)).slice(0, 200);
|
|
2895
|
+
}
|
|
2896
|
+
async function answerSignInChallenge(challenge, extension, url, wallet) {
|
|
2897
|
+
const target = new URL(url);
|
|
2898
|
+
try {
|
|
2899
|
+
assertSIWxChallengeBoundToOrigin(extension.info, target);
|
|
2900
|
+
} catch {
|
|
2901
|
+
return {
|
|
2902
|
+
refused: "origin",
|
|
2903
|
+
reason: `its challenge names ${named(extension.info.domain)} and ${named(extension.info.uri)}, which do not match the responding origin`
|
|
2904
|
+
};
|
|
2905
|
+
}
|
|
2906
|
+
const unpaid = {
|
|
2907
|
+
refused: "unpaid",
|
|
2908
|
+
reason: `this wallet has not paid ${target.host}`
|
|
2909
|
+
};
|
|
2910
|
+
const address = await wallet.address();
|
|
2911
|
+
const paid = await wallet.paidHost(target.host, address);
|
|
2912
|
+
if (paid === "payer_unknown") {
|
|
2913
|
+
return {
|
|
2914
|
+
refused: "payer_unknown",
|
|
2915
|
+
reason: `this machine's record of its payment to ${target.host} does not say which wallet paid, so it is not proof that this one did`
|
|
2916
|
+
};
|
|
2917
|
+
}
|
|
2918
|
+
if (paid !== "paid") return unpaid;
|
|
2919
|
+
const signer = await wallet.signer();
|
|
2920
|
+
if (signer.address.toLowerCase() !== address.toLowerCase()) return unpaid;
|
|
2921
|
+
const answered = await createSIWxClientHook(signer)({
|
|
2922
|
+
paymentRequired: challenge,
|
|
2923
|
+
requestUrl: url
|
|
2924
|
+
});
|
|
2925
|
+
if (answered === void 0 || Object.keys(answered.headers).length === 0) {
|
|
2926
|
+
return {
|
|
2927
|
+
refused: "unsigned",
|
|
2928
|
+
reason: "its challenge could not be signed: it names no eip191 chain, or its fields are not a valid sign-in message"
|
|
2929
|
+
};
|
|
2930
|
+
}
|
|
2931
|
+
return { headers: answered.headers };
|
|
2932
|
+
}
|
|
3477
2933
|
|
|
3478
2934
|
export {
|
|
3479
|
-
parseMoney,
|
|
3480
|
-
convertToTokenAmount,
|
|
3481
|
-
networkMatchesPattern,
|
|
3482
|
-
findSchemesByNetwork,
|
|
3483
|
-
findByNetworkAndScheme,
|
|
3484
|
-
deepEqual,
|
|
3485
|
-
toComparableArray,
|
|
3486
|
-
ADDITIVE_ARRAY_INFO_FIELDS,
|
|
3487
|
-
PaymentRequirementsV2Schema,
|
|
3488
|
-
x402Version,
|
|
3489
|
-
HTTPFacilitatorClient,
|
|
3490
|
-
x402HTTPClient,
|
|
3491
|
-
decodePaymentRequiredHeader,
|
|
3492
|
-
decodePaymentResponseHeader,
|
|
3493
2935
|
SIGN_IN_WITH_X,
|
|
3494
2936
|
SIWX_HEADER,
|
|
3495
|
-
|
|
2937
|
+
SIWX_CHAIN_ID,
|
|
2938
|
+
buildSiwxHeader,
|
|
2939
|
+
signInOnlyChallenge,
|
|
2940
|
+
answerSignInChallenge
|
|
3496
2941
|
};
|
|
3497
|
-
|
|
2942
|
+
/*! Bundled license information:
|
|
2943
|
+
|
|
2944
|
+
@scure/base/lib/esm/index.js:
|
|
2945
|
+
(*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
2946
|
+
*/
|
|
2947
|
+
//# sourceMappingURL=chunk-OQWPRFAC.js.map
|