@wirecat/drive-cli 0.71.0 → 0.72.1
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/README.md +150 -71
- package/contracts/wirecat.json +77 -8
- package/dist/bin/drive.js +2 -2
- package/dist/bundle/agent-GOCD4ZW2.js +46 -0
- package/dist/bundle/{all-profiles-3QJG2NAN.js → all-profiles-PZVP3G73.js} +67 -25
- package/dist/bundle/{anthropic-PSWTEU6G.js → anthropic-PUOTKSYV.js} +9 -9
- package/dist/bundle/{app-server-PVTA6ABR.js → app-server-MKDCXRZM.js} +97 -79
- package/dist/bundle/{bun-LU5LP3JI.js → bun-NS5YLOQT.js} +2 -2
- package/dist/bundle/{bun-sqlite-PYMKLBRU.js → bun-sqlite-KSKWRLLO.js} +9 -9
- package/dist/bundle/{chunk-COOOO5B3.js → chunk-2CG3LUQS.js} +4 -4
- package/dist/bundle/{chunk-YVI5SQPY.js → chunk-2TVHFJKV.js} +1 -1
- package/dist/bundle/chunk-35FIJGTT.js +52 -0
- package/dist/bundle/chunk-35GROSBS.js +3233 -0
- package/dist/bundle/{chunk-D5TGYUVU.js → chunk-3CH7I452.js} +9 -60
- package/dist/bundle/{chunk-ICDCAQ6K.js → chunk-3QBRS3JT.js} +13 -9
- package/dist/bundle/chunk-3T7JIHSO.js +353 -0
- package/dist/bundle/{chunk-Q7DOMFJ4.js → chunk-3VIEGRBA.js} +6 -6
- package/dist/bundle/chunk-3YCUYFTD.js +2159 -0
- package/dist/bundle/{chunk-CJLVYIOP.js → chunk-3ZGWJYSG.js} +30 -21
- package/dist/bundle/{chunk-YPFWNVHV.js → chunk-43PCMVTZ.js} +2 -100
- package/dist/bundle/{chunk-OF422U5D.js → chunk-4DK55MLP.js} +402 -402
- package/dist/bundle/chunk-4HP6KGBI.js +32 -0
- package/dist/bundle/chunk-4P6D6CUS.js +282 -0
- package/dist/bundle/chunk-4ZAQMDLD.js +1308 -0
- package/dist/bundle/chunk-4ZTB7LS3.js +87 -0
- package/dist/bundle/{chunk-6W763DZN.js → chunk-54O5NJRC.js} +14 -13
- package/dist/bundle/{chunk-MNLL5YLM.js → chunk-5BHP4FVM.js} +2 -2
- package/dist/bundle/{chunk-ACUAV6VX.js → chunk-6JU4KLAZ.js} +108 -72
- package/dist/bundle/{chunk-YMJ6IDGT.js → chunk-6KND2DYT.js} +38 -8
- package/dist/bundle/{chunk-4HWJOU7N.js → chunk-7YPZPJTB.js} +1 -1
- package/dist/bundle/chunk-A5XNUMW7.js +108 -0
- package/dist/bundle/{chunk-X4TIMMKJ.js → chunk-AG34MPVN.js} +1 -1
- package/dist/bundle/chunk-B5V2U7IS.js +221 -0
- package/dist/bundle/chunk-B6JC5RS3.js +696 -0
- package/dist/bundle/chunk-BDZXGDGI.js +80 -0
- package/dist/bundle/{chunk-B5KSXHJ7.js → chunk-BMTMGMGE.js} +1 -1
- package/dist/bundle/{chunk-ZCR3IRZ2.js → chunk-CP2TZXAG.js} +16 -9
- package/dist/bundle/{chunk-TAUBRNC5.js → chunk-DOEP4EPW.js} +72 -59
- package/dist/bundle/chunk-DQSOYH6N.js +20 -0
- package/dist/bundle/{chunk-QETR5HIZ.js → chunk-E2TMWONO.js} +4385 -2684
- package/dist/bundle/chunk-E5EYJU5R.js +7 -0
- package/dist/bundle/chunk-ECYOTDJM.js +14 -0
- package/dist/bundle/{chunk-HL52XXZX.js → chunk-EXHTGQR2.js} +3 -4
- package/dist/bundle/chunk-F4BX7TH2.js +15 -0
- package/dist/bundle/{chunk-ASMMG72J.js → chunk-FJQO5OHR.js} +261 -565
- package/dist/bundle/{chunk-RJOQH5YY.js → chunk-FKP4T7A4.js} +111 -859
- package/dist/bundle/{chunk-JDV7HNNQ.js → chunk-FTL3WXZB.js} +13 -26
- package/dist/bundle/{chunk-FP54WSIR.js → chunk-G2CH4FRW.js} +4 -4
- package/dist/bundle/chunk-G2KKMQRN.js +30 -0
- package/dist/bundle/{chunk-NYECVHFH.js → chunk-G4NHRFS7.js} +755 -0
- package/dist/bundle/{chunk-Y2NWGNUB.js → chunk-G7SKXAVZ.js} +5 -5
- package/dist/bundle/{chunk-FT3LN3HP.js → chunk-GFI3UUIU.js} +1 -1
- package/dist/bundle/chunk-GTPPUBYU.js +1876 -0
- package/dist/bundle/{chunk-QFR2PNJN.js → chunk-GTROGY74.js} +12 -12
- package/dist/bundle/{chunk-UTO2GO4P.js → chunk-GYAPDUF5.js} +45 -66
- package/dist/bundle/{chunk-GBKNJWOZ.js → chunk-HCMEU7AF.js} +8 -8
- package/dist/bundle/{chunk-FJH7DJWK.js → chunk-HDGJ7IDE.js} +6 -6
- package/dist/bundle/{chunk-Z3KUSRCF.js → chunk-HMN26CVU.js} +2 -2
- package/dist/bundle/{chunk-I4RWW3UD.js → chunk-HOICQNJX.js} +20 -5
- package/dist/bundle/{chunk-P7CUM5IB.js → chunk-HPS2YGSZ.js} +1 -1
- package/dist/bundle/{chunk-HMS6EEQL.js → chunk-HSASPXRW.js} +3 -3
- package/dist/bundle/{chunk-KGYVHPGE.js → chunk-IABPGOMT.js} +2 -2
- package/dist/bundle/{chunk-4QNW4NK6.js → chunk-IBQZT2YD.js} +1 -1
- package/dist/bundle/{chunk-PRW6SYA3.js → chunk-IE3R46YN.js} +313 -257
- package/dist/bundle/{chunk-7PDHGZN4.js → chunk-IE6O7463.js} +4 -4
- package/dist/bundle/{chunk-3UGYFXH6.js → chunk-IPBYU43F.js} +192 -379
- package/dist/bundle/{chunk-RWDKMU74.js → chunk-IS7STZEB.js} +3 -3
- package/dist/bundle/{chunk-GOWXXYEF.js → chunk-IV77ZFF4.js} +4 -4
- package/dist/bundle/{chunk-6XFIITOG.js → chunk-JDGF3YYS.js} +4811 -3486
- package/dist/bundle/{chunk-GPQ44Y2R.js → chunk-JHAACT4I.js} +2 -2
- package/dist/bundle/{chunk-SERXSCN3.js → chunk-JRED7BNX.js} +337 -390
- package/dist/bundle/{chunk-MIA7P6FZ.js → chunk-JSYUB4SM.js} +6 -6
- package/dist/bundle/{chunk-RESDD3Q4.js → chunk-JVM75M4H.js} +16 -3
- package/dist/bundle/{chunk-XF4EXO2C.js → chunk-JZ65CQWK.js} +6 -6
- package/dist/bundle/{chunk-QNRRK3CN.js → chunk-KBR7OC5S.js} +2 -2
- package/dist/bundle/chunk-KI6OOW6D.js +123 -0
- package/dist/bundle/chunk-KOI5G7NM.js +388 -0
- package/dist/bundle/{chunk-ZZ32DXTH.js → chunk-KPBUJQKT.js} +1 -1
- package/dist/bundle/{chunk-2LHAVY4U.js → chunk-KVBGIZ2C.js} +1 -1
- package/dist/bundle/chunk-L7P3LUDQ.js +286 -0
- package/dist/bundle/{chunk-SAKO3P4H.js → chunk-LKUWH6KU.js} +1 -1
- package/dist/bundle/chunk-MA6U4XH2.js +36 -0
- package/dist/bundle/{chunk-TAFHYHKA.js → chunk-MA7ETVTZ.js} +43 -186
- package/dist/bundle/{chunk-KYKW2W6X.js → chunk-MDJUYCHT.js} +1 -1
- package/dist/bundle/chunk-MEYYH47C.js +25 -0
- package/dist/bundle/{chunk-Z56QFOBR.js → chunk-MGC2BAD2.js} +1 -1
- package/dist/bundle/chunk-NMQRSEZM.js +37 -0
- package/dist/bundle/{chunk-5DPV7X27.js → chunk-NTZWY5R3.js} +321 -0
- package/dist/bundle/{chunk-OJSBWP3F.js → chunk-OBDPKDGB.js} +69 -7
- package/dist/bundle/{chunk-WVDCCYS3.js → chunk-ODTBJGWQ.js} +17 -17
- package/dist/bundle/chunk-PB6ACIME.js +80 -0
- package/dist/bundle/{chunk-5D4AEUVA.js → chunk-PL5P7UKW.js} +434 -1
- package/dist/bundle/{chunk-72C4YOCH.js → chunk-PMAV3RNP.js} +7 -7
- package/dist/bundle/chunk-PSY67L73.js +783 -0
- package/dist/bundle/{chunk-6TNNT2MQ.js → chunk-PUVQOZ2N.js} +483 -176
- package/dist/bundle/{chunk-SDKQNOL5.js → chunk-QB7K6PIP.js} +6 -6
- package/dist/bundle/chunk-QK7GKFKB.js +188 -0
- package/dist/bundle/{chunk-4PA4DHYV.js → chunk-QMUWHKP5.js} +6 -6
- package/dist/bundle/chunk-QURQ2OU2.js +250 -0
- package/dist/bundle/{chunk-LXKYKRHD.js → chunk-R3EDZWXF.js} +8 -227
- package/dist/bundle/{chunk-KGERXYTV.js → chunk-RM4DO2WZ.js} +1 -1
- package/dist/bundle/chunk-S27UKJVL.js +730 -0
- package/dist/bundle/{chunk-22QQUKWA.js → chunk-S3SLDYTU.js} +1 -1
- package/dist/bundle/{chunk-FCS26CYQ.js → chunk-SAEBHENE.js} +4 -4
- package/dist/bundle/chunk-SM7Z2BQF.js +561 -0
- package/dist/bundle/{chunk-QXC6IEH6.js → chunk-SODB63MR.js} +201 -423
- package/dist/bundle/{chunk-2PUNKUYJ.js → chunk-SSFGSY77.js} +10320 -9907
- package/dist/bundle/{chunk-37MAA6F2.js → chunk-STUPCKAA.js} +11 -2221
- package/dist/bundle/{chunk-BKSQBBYG.js → chunk-SUQT4KI2.js} +9 -9
- package/dist/bundle/{chunk-YPNWIB6H.js → chunk-SWQDKO6D.js} +3 -3
- package/dist/bundle/chunk-SZ7XJZGH.js +2231 -0
- package/dist/bundle/{chunk-3N2OFXB5.js → chunk-T3OK6AYZ.js} +5 -5
- package/dist/bundle/{chunk-HKY7X6NY.js → chunk-TFIAD57H.js} +4 -4
- package/dist/bundle/chunk-TRYYWV7J.js +291 -0
- package/dist/bundle/{chunk-XMMFBPGC.js → chunk-TUL6MCTY.js} +3 -3
- package/dist/bundle/{chunk-6Y2BYFXQ.js → chunk-UC7JLE6J.js} +0 -7
- package/dist/bundle/{chunk-YJIGGUPI.js → chunk-UL5HSHFU.js} +4 -4
- package/dist/bundle/{chunk-3EBBLKIT.js → chunk-UT64BBEP.js} +4 -4
- package/dist/bundle/{chunk-26DHFMGZ.js → chunk-VBIZD5V5.js} +2 -2
- package/dist/bundle/chunk-VHTELRUA.js +50 -0
- package/dist/bundle/chunk-VOQICE3G.js +340 -0
- package/dist/bundle/{chunk-GZ2D4KXG.js → chunk-WDJRUNQN.js} +35 -12
- package/dist/bundle/{chunk-2UUWXPOB.js → chunk-X5CXANSA.js} +3 -3
- package/dist/bundle/{chunk-35SCQ4VI.js → chunk-X6HPQKAI.js} +43 -35
- package/dist/bundle/{chunk-COJSWDNU.js → chunk-XKWQDQ4B.js} +3 -3
- package/dist/bundle/{chunk-6SJOTNHF.js → chunk-XZEVHUKI.js} +6 -28
- package/dist/bundle/{chunk-JZHBZOJR.js → chunk-YE7DJB3F.js} +3 -3
- package/dist/bundle/chunk-YHWFF6DN.js +39 -0
- package/dist/bundle/{chunk-2BVVU7GG.js → chunk-YJVQ5GST.js} +1 -1
- package/dist/bundle/{chunk-ZM63SUHG.js → chunk-YRCGFSRR.js} +2 -2
- package/dist/bundle/{chunk-EOEU3AZN.js → chunk-ZNFXKFGF.js} +13 -13
- package/dist/bundle/{cli-556DERZL.js → cli-KXRWXGTS.js} +217 -114
- package/dist/bundle/command-contract-BGNT7MTQ.js +45 -0
- package/dist/bundle/{command-server-entry-AYLGNZWD.js → command-server-entry-7FZX74T6.js} +36 -34
- package/dist/bundle/{decode-QU24MWMN.js → decode-SZ6W34U3.js} +10 -10
- package/dist/bundle/{dispatch-4KODNOXV.js → dispatch-4KNSZ3PI.js} +10 -10
- package/dist/bundle/dist-PAKDDIBT.js +191 -0
- package/dist/bundle/drive.js +11 -11
- package/dist/bundle/{echarts-BXX4OQWC.js → echarts-ISH62J4E.js} +2 -2
- package/dist/bundle/{embed-KG27KG3D.js → embed-6ODGTZPK.js} +10 -10
- package/dist/bundle/{embedder-IPAVUQUV.js → embedder-6FY67FTQ.js} +15 -15
- package/dist/bundle/entry-2SA6ZX7E.js +25 -0
- package/dist/bundle/{failure-ESL7ETL4.js → failure-V3ILKUTX.js} +4 -4
- package/dist/bundle/first-run-ZNKPPD6M.js +31 -0
- package/dist/bundle/first-screen-WF6GYLPN.js +45 -0
- package/dist/bundle/google-QCADNPCQ.js +46 -0
- package/dist/bundle/{google-api-VCDBSNOW.js → google-api-ZTI3NKZX.js} +88 -73
- package/dist/bundle/grants-BPN5AGDK.js +133 -0
- package/dist/bundle/hast-util-from-html-X2DCPS3T.js +10531 -0
- package/dist/bundle/hast-util-to-html-VP6XLPKJ.js +998 -0
- package/dist/bundle/hast-util-to-mdast-IZ5PRX72.js +2272 -0
- package/dist/bundle/{identity-LOWMVGZY.js → identity-YX4IPGOO.js} +7 -6
- package/dist/bundle/{instructions-2VECIDXF.js → instructions-G5ZGHVFB.js} +1 -1
- package/dist/bundle/{login-7GBONT7V.js → login-CVX5VJX6.js} +96 -81
- package/dist/bundle/{mcp-O6ACR2DX.js → mcp-MQ2L5IIM.js} +2 -2
- package/dist/bundle/{mdast-util-from-markdown-FXEPSNER.js → mdast-util-from-markdown-HEZF7KJ4.js} +137 -195
- package/dist/bundle/mdast-util-gfm-AQW6R6MG.js +925 -0
- package/dist/bundle/mdast-util-to-hast-DF2QVIRV.js +879 -0
- package/dist/bundle/mdast-util-to-markdown-XYLXB3Z3.js +18 -0
- package/dist/bundle/meeting-combined-HKZJMJ6Q.js +28 -0
- package/dist/bundle/meeting-model-DSE4GRVE.js +29 -0
- package/dist/bundle/{meeting-semantic-G7PFOKU7.js → meeting-semantic-OHG2QN2G.js} +10 -10
- package/dist/bundle/{micromark-extension-gfm-GRL24TU6.js → micromark-extension-gfm-OE2GBORZ.js} +11 -78
- package/dist/bundle/{node-MPEQSFI3.js → node-NLJINXVQ.js} +2 -2
- package/dist/bundle/{node-sqlite-OLQMAYB4.js → node-sqlite-KDFQDYVZ.js} +10 -10
- package/dist/bundle/notes-search-3VBVSQ3R.js +70 -0
- package/dist/bundle/oauth-M3E62ZHC.js +22 -0
- package/dist/bundle/{open-OXTE672W.js → open-WVRUVBIZ.js} +8 -8
- package/dist/bundle/{openai-EB3TPIZY.js → openai-JJWOSJMV.js} +22 -21
- package/dist/bundle/{process-F6TKXWWA.js → process-LPVAYRO7.js} +1 -1
- package/dist/bundle/{program-4IFDZ7FM.js → program-ZJRIP25J.js} +276 -1149
- package/dist/bundle/{prompt-F5RRHPN2.js → prompt-XCDHTEAO.js} +8 -8
- package/dist/bundle/{reasons-UORHJDHK.js → reasons-REEEQDAZ.js} +6 -5
- package/dist/bundle/{recognize-DAVNZND3.js → recognize-OZLFDJAT.js} +7 -7
- package/dist/bundle/remote-MDPYVCZB.js +35 -0
- package/dist/bundle/{rerank-CND2GVLZ.js → rerank-FLZWJNHA.js} +11 -11
- package/dist/bundle/{serve-ZHSPUIGX.js → serve-5UV5VLRV.js} +19 -19
- package/dist/bundle/{server-YMAK4LHC.js → server-53A2X2MK.js} +89 -70
- package/dist/bundle/server-5GMURMDE.js +97 -0
- package/dist/bundle/{services-ZILSFJ6E.js → services-XSMH7BXB.js} +109 -89
- package/dist/bundle/{sqlite-runtime-S5VPMZQH.js → sqlite-runtime-E3L7ENFU.js} +9 -9
- package/dist/bundle/{start-CR6X25RT.js → start-4S2VNR4J.js} +7 -7
- package/dist/bundle/{state-YFPHVIIJ.js → state-TQI4JSH7.js} +9 -9
- package/dist/bundle/{store-CL4ZJZRI.js → store-GS7PU6PJ.js} +38 -23
- package/dist/bundle/{store-UODRT6X4.js → store-VYJPL7MW.js} +36 -25
- package/dist/bundle/store-maintenance-command-JJVYUZMG.js +85 -0
- package/dist/bundle/surface-JC4XVMZR.js +83 -0
- package/dist/bundle/tokens-KJQ5EAPW.js +133 -0
- package/dist/commands/documents.d.ts.map +1 -1
- package/dist/commands/documents.js +11 -1
- package/dist/commands/documents.js.map +1 -1
- package/dist/commands/remote.d.ts.map +1 -1
- package/dist/commands/remote.js +8 -22
- package/dist/commands/remote.js.map +1 -1
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +14 -4
- package/dist/commands/sync.js.map +1 -1
- package/dist/config.d.ts +5 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +5 -0
- package/dist/config.js.map +1 -1
- package/dist/first-screen.d.ts.map +1 -1
- package/dist/first-screen.js +2 -1
- package/dist/first-screen.js.map +1 -1
- package/dist/generated/manifest.d.ts +2 -1
- package/dist/generated/manifest.d.ts.map +1 -1
- package/dist/generated/manifest.js +782 -0
- package/dist/generated/manifest.js.map +1 -1
- package/dist/generated/types.d.ts +262 -58
- package/dist/generated/types.d.ts.map +1 -1
- package/dist/google.d.ts.map +1 -1
- package/dist/google.js +5 -5
- package/dist/google.js.map +1 -1
- package/dist/model.d.ts +5 -2
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js.map +1 -1
- package/dist/policy-keys.js +1 -1
- package/dist/policy-keys.js.map +1 -1
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +9 -4
- package/dist/program.js.map +1 -1
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +6 -1
- package/dist/state.js.map +1 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +2 -7
- package/dist/store.js.map +1 -1
- package/dist/supported.d.ts +2 -2
- package/dist/supported.d.ts.map +1 -1
- package/dist/supported.js +2 -3
- package/dist/supported.js.map +1 -1
- package/dist/sync.d.ts +2 -1
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +5 -2
- package/dist/sync.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
- package/scenarios/find-decision.md +1 -1
- package/skills/drive-cli/SKILL.md +4 -2
- package/dist/bundle/chunk-J5Q5FS2N.js +0 -593
- package/dist/bundle/chunk-L46C6HQ7.js +0 -729
- package/dist/bundle/chunk-UDMNY63V.js +0 -899
- package/dist/bundle/chunk-VKE77B3F.js +0 -2
- package/dist/bundle/command-contract-VRTOAV6W.js +0 -43
- package/dist/bundle/entry-MVXQETWS.js +0 -25
- package/dist/bundle/first-run-4UVLW2WR.js +0 -31
- package/dist/bundle/first-screen-JAKAIINI.js +0 -41
- package/dist/bundle/google-22NXXJX5.js +0 -45
- package/dist/bundle/grants-MQMTVCRQ.js +0 -118
- package/dist/bundle/mdast-util-gfm-SZM5GBDF.js +0 -2103
- package/dist/bundle/meeting-combined-LVP4AZKA.js +0 -27
- package/dist/bundle/meeting-model-RAY5XDXZ.js +0 -29
- package/dist/bundle/oauth-SGH2I2BY.js +0 -22
- package/dist/bundle/remote-D5EYYIAU.js +0 -35
- package/dist/bundle/server-DUVJWP3Q.js +0 -80
- package/dist/bundle/store-maintenance-command-DY5XIBWR.js +0 -72
- package/dist/bundle/tokens-AF7QOFOF.js +0 -118
|
@@ -1,899 +0,0 @@
|
|
|
1
|
-
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
-
const require = __bundleRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
activeProfile,
|
|
5
|
-
paths
|
|
6
|
-
} from "./chunk-J5Q5FS2N.js";
|
|
7
|
-
import {
|
|
8
|
-
READ_SCOPE,
|
|
9
|
-
WRITE_SCOPE
|
|
10
|
-
} from "./chunk-NYECVHFH.js";
|
|
11
|
-
import {
|
|
12
|
-
providerRequest
|
|
13
|
-
} from "./chunk-6XFIITOG.js";
|
|
14
|
-
import {
|
|
15
|
-
googleError
|
|
16
|
-
} from "./chunk-2BVVU7GG.js";
|
|
17
|
-
import {
|
|
18
|
-
withTimeLimit
|
|
19
|
-
} from "./chunk-QXC6IEH6.js";
|
|
20
|
-
import {
|
|
21
|
-
acquireLock
|
|
22
|
-
} from "./chunk-JDV7HNNQ.js";
|
|
23
|
-
import {
|
|
24
|
-
hostFetch
|
|
25
|
-
} from "./chunk-YMJ6IDGT.js";
|
|
26
|
-
import {
|
|
27
|
-
DESKTOP
|
|
28
|
-
} from "./chunk-ZM63SUHG.js";
|
|
29
|
-
import {
|
|
30
|
-
Credentials,
|
|
31
|
-
isMovedRun,
|
|
32
|
-
keyringService,
|
|
33
|
-
systemKeyring
|
|
34
|
-
} from "./chunk-CJLVYIOP.js";
|
|
35
|
-
import {
|
|
36
|
-
minLength,
|
|
37
|
-
nullable,
|
|
38
|
-
number,
|
|
39
|
-
object,
|
|
40
|
-
optional,
|
|
41
|
-
pipe,
|
|
42
|
-
safeParse,
|
|
43
|
-
string
|
|
44
|
-
} from "./chunk-OJSBWP3F.js";
|
|
45
|
-
import {
|
|
46
|
-
CliError,
|
|
47
|
-
isCliError
|
|
48
|
-
} from "./chunk-4QNW4NK6.js";
|
|
49
|
-
import {
|
|
50
|
-
__name
|
|
51
|
-
} from "./chunk-ZVVMGPBJ.js";
|
|
52
|
-
|
|
53
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/oauth/authorize.js
|
|
54
|
-
import { createHash, randomBytes } from "node:crypto";
|
|
55
|
-
import { createServer } from "node:http";
|
|
56
|
-
var DEFAULT_TIMEOUT_MS = 3e5;
|
|
57
|
-
var pkce = /* @__PURE__ */ __name(() => {
|
|
58
|
-
const codeVerifier = randomBytes(48).toString("base64url");
|
|
59
|
-
return { codeVerifier, codeChallenge: createHash("sha256").update(codeVerifier).digest("base64url") };
|
|
60
|
-
}, "pkce");
|
|
61
|
-
var queryOf = /* @__PURE__ */ __name((text2) => {
|
|
62
|
-
const trimmed = text2.trim();
|
|
63
|
-
const start = trimmed.indexOf("?");
|
|
64
|
-
return new URLSearchParams(start >= 0 ? trimmed.slice(start + 1).split("#")[0] : trimmed);
|
|
65
|
-
}, "queryOf");
|
|
66
|
-
var authorize = /* @__PURE__ */ __name(async (options) => {
|
|
67
|
-
const { provider } = options;
|
|
68
|
-
const cancelled = /* @__PURE__ */ __name(() => isCliError(options.signal?.reason) ? options.signal.reason : new CliError("cancelled", `${provider.name} sign-in was cancelled`), "cancelled");
|
|
69
|
-
if (options.signal?.aborted)
|
|
70
|
-
throw cancelled();
|
|
71
|
-
const { codeVerifier, codeChallenge } = pkce();
|
|
72
|
-
const paste = new AbortController();
|
|
73
|
-
let state = "";
|
|
74
|
-
let settled = false;
|
|
75
|
-
let accept = /* @__PURE__ */ __name(() => {
|
|
76
|
-
}, "accept");
|
|
77
|
-
let fail = /* @__PURE__ */ __name(() => {
|
|
78
|
-
}, "fail");
|
|
79
|
-
const code = new Promise((resolve, reject) => {
|
|
80
|
-
accept = /* @__PURE__ */ __name((value) => {
|
|
81
|
-
settled = true;
|
|
82
|
-
resolve(value);
|
|
83
|
-
}, "accept");
|
|
84
|
-
fail = /* @__PURE__ */ __name((error) => {
|
|
85
|
-
settled = true;
|
|
86
|
-
reject(error);
|
|
87
|
-
}, "fail");
|
|
88
|
-
});
|
|
89
|
-
void code.catch(() => {
|
|
90
|
-
});
|
|
91
|
-
const settle = /* @__PURE__ */ __name((query) => {
|
|
92
|
-
const value = query.get("code");
|
|
93
|
-
if (value)
|
|
94
|
-
accept(value);
|
|
95
|
-
else
|
|
96
|
-
fail(new CliError("authentication_error", `${provider.name} sign-in was declined`, { reason: "oauth.declined" }));
|
|
97
|
-
}, "settle");
|
|
98
|
-
const handler = /* @__PURE__ */ __name((request, response) => {
|
|
99
|
-
let url;
|
|
100
|
-
try {
|
|
101
|
-
url = new URL(request.url ?? "/", "http://127.0.0.1");
|
|
102
|
-
} catch {
|
|
103
|
-
response.writeHead(400).end();
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
if (request.method !== "GET" || url.pathname !== "/callback") {
|
|
107
|
-
response.writeHead(404).end();
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
if (settled || !state || url.searchParams.get("state") !== state) {
|
|
111
|
-
response.writeHead(400).end("This sign-in link does not belong to the waiting sign-in");
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
if (!url.searchParams.get("code") && !url.searchParams.get("error")) {
|
|
115
|
-
response.writeHead(400).end("Missing sign-in result");
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
response.end("Sign-in received; you can close this tab");
|
|
119
|
-
settle(url.searchParams);
|
|
120
|
-
}, "handler");
|
|
121
|
-
const server = createServer(handler);
|
|
122
|
-
const localhost = provider.redirect.kind === "loopback" && provider.redirect.host === "localhost";
|
|
123
|
-
const server6 = localhost ? createServer(handler) : void 0;
|
|
124
|
-
const onAbort = /* @__PURE__ */ __name(() => fail(cancelled()), "onAbort");
|
|
125
|
-
options.signal?.addEventListener("abort", onAbort, { once: true });
|
|
126
|
-
const timer = setTimeout(() => fail(new CliError("timeout", `${provider.name} sign-in timed out`, { reason: "oauth.timeout" })), options.timeoutMs ?? DEFAULT_TIMEOUT_MS);
|
|
127
|
-
try {
|
|
128
|
-
await new Promise((resolve, reject) => {
|
|
129
|
-
server.once("error", reject);
|
|
130
|
-
server.listen(0, "127.0.0.1", resolve);
|
|
131
|
-
});
|
|
132
|
-
const address = server.address();
|
|
133
|
-
if (!address || typeof address === "string")
|
|
134
|
-
throw new CliError("configuration_error", "could not start the local sign-in listener");
|
|
135
|
-
if (server6) {
|
|
136
|
-
server6.on("error", () => {
|
|
137
|
-
});
|
|
138
|
-
await new Promise((resolve) => {
|
|
139
|
-
server6.once("error", () => resolve());
|
|
140
|
-
server6.listen(address.port, "::1", () => resolve());
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
const random = randomBytes(32).toString("base64url");
|
|
144
|
-
const relay = provider.redirect.kind === "relay";
|
|
145
|
-
state = relay ? `${address.port}.${random}` : random;
|
|
146
|
-
const redirectUri = provider.redirect.kind === "relay" ? provider.redirect.url : `http://${localhost ? "localhost" : "127.0.0.1"}:${address.port}/callback`;
|
|
147
|
-
const url = new URL(provider.authorizeUrl);
|
|
148
|
-
for (const [key, value] of Object.entries({
|
|
149
|
-
...provider.authorizeParams,
|
|
150
|
-
response_type: "code",
|
|
151
|
-
client_id: provider.client.clientId,
|
|
152
|
-
redirect_uri: redirectUri,
|
|
153
|
-
...options.scopes.length ? { scope: options.scopes.join(" ") } : {},
|
|
154
|
-
state,
|
|
155
|
-
code_challenge: codeChallenge,
|
|
156
|
-
code_challenge_method: "S256"
|
|
157
|
-
}))
|
|
158
|
-
url.searchParams.set(key, value);
|
|
159
|
-
options.showUrl?.(url.toString());
|
|
160
|
-
options.readPaste?.(paste.signal).then((text2) => {
|
|
161
|
-
if (settled)
|
|
162
|
-
return;
|
|
163
|
-
const query = queryOf(text2);
|
|
164
|
-
if (query.get("state") !== state || !query.get("code") && !query.get("error"))
|
|
165
|
-
fail(new CliError("authentication_error", "the pasted sign-in result does not match this sign-in", {
|
|
166
|
-
reason: "oauth.mismatch"
|
|
167
|
-
}));
|
|
168
|
-
else
|
|
169
|
-
settle(query);
|
|
170
|
-
}).catch(() => {
|
|
171
|
-
});
|
|
172
|
-
void Promise.resolve().then(() => options.openBrowser(url.toString())).catch(() => {
|
|
173
|
-
if (!options.readPaste && !options.showUrl)
|
|
174
|
-
fail(new CliError("configuration_error", "could not open the browser, and no sign-in link can be shown"));
|
|
175
|
-
});
|
|
176
|
-
return { code: await code, redirectUri, codeVerifier };
|
|
177
|
-
} finally {
|
|
178
|
-
clearTimeout(timer);
|
|
179
|
-
options.signal?.removeEventListener("abort", onAbort);
|
|
180
|
-
paste.abort();
|
|
181
|
-
for (const each of server6 ? [server, server6] : [server]) {
|
|
182
|
-
each.closeAllConnections();
|
|
183
|
-
if (each.listening)
|
|
184
|
-
await new Promise((resolve) => each.close(() => resolve()));
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}, "authorize");
|
|
188
|
-
|
|
189
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/oauth/keeper.js
|
|
190
|
-
import { createHash as createHash2 } from "node:crypto";
|
|
191
|
-
import { join } from "node:path";
|
|
192
|
-
import { setTimeout as delay } from "node:timers/promises";
|
|
193
|
-
|
|
194
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/oauth/requests.js
|
|
195
|
-
var REQUEST_LIMIT_MS = 3e4;
|
|
196
|
-
var TOKEN_LOG_EVENT = "oauth.token";
|
|
197
|
-
var object2 = /* @__PURE__ */ __name((value) => {
|
|
198
|
-
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
199
|
-
throw new Error("not an object");
|
|
200
|
-
return value;
|
|
201
|
-
}, "object");
|
|
202
|
-
var requestSignal = /* @__PURE__ */ __name((deadline, signal) => signal ? AbortSignal.any([signal, deadline]) : deadline, "requestSignal");
|
|
203
|
-
var cancelledBy = /* @__PURE__ */ __name((signal) => {
|
|
204
|
-
if (!signal?.aborted)
|
|
205
|
-
return;
|
|
206
|
-
throw isCliError(signal.reason) ? signal.reason : new CliError("cancelled", "sign-in was cancelled");
|
|
207
|
-
}, "cancelledBy");
|
|
208
|
-
var post = /* @__PURE__ */ __name(async (url, body, context, deadline) => {
|
|
209
|
-
cancelledBy(context.signal);
|
|
210
|
-
try {
|
|
211
|
-
return await context.fetch(url, {
|
|
212
|
-
method: "POST",
|
|
213
|
-
headers: { "content-type": "application/x-www-form-urlencoded", accept: "application/json" },
|
|
214
|
-
body,
|
|
215
|
-
signal: requestSignal(deadline, context.signal),
|
|
216
|
-
redirect: "error"
|
|
217
|
-
});
|
|
218
|
-
} catch {
|
|
219
|
-
cancelledBy(context.signal);
|
|
220
|
-
return void 0;
|
|
221
|
-
}
|
|
222
|
-
}, "post");
|
|
223
|
-
var clientFields = /* @__PURE__ */ __name(({ client }) => ({
|
|
224
|
-
client_id: client.clientId,
|
|
225
|
-
...client.clientSecret ? { client_secret: client.clientSecret } : {}
|
|
226
|
-
}), "clientFields");
|
|
227
|
-
var requestTokens = /* @__PURE__ */ __name((provider, params, context) => withTimeLimit(REQUEST_LIMIT_MS, (deadline) => exchangeTokens(provider, params, context, deadline)), "requestTokens");
|
|
228
|
-
var exchangeTokens = /* @__PURE__ */ __name(async (provider, params, context, deadline) => {
|
|
229
|
-
const operation = params.grant_type ?? "unknown";
|
|
230
|
-
const record = /* @__PURE__ */ __name((level, fields) => context.log?.[level]({ event: TOKEN_LOG_EVENT, provider: provider.id, operation, pid: process.pid, ...fields }), "record");
|
|
231
|
-
const again = `run ${context.signInCommand} again`;
|
|
232
|
-
const response = await post(provider.tokenUrl, new URLSearchParams({ ...params, ...clientFields(context) }), context, deadline);
|
|
233
|
-
if (!response) {
|
|
234
|
-
record("warn", { outcome: "no_response" });
|
|
235
|
-
throw new CliError("outcome_unknown", `${provider.name} token request did not finish; ${again} if it keeps failing`, {
|
|
236
|
-
reason: "oauth.no-response"
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
if (!response.ok) {
|
|
240
|
-
record("warn", { outcome: "rejected", status: response.status });
|
|
241
|
-
if (response.status === 429 || response.status >= 500)
|
|
242
|
-
throw new CliError("provider_unavailable", `${provider.name} token request failed (HTTP ${response.status})`, {
|
|
243
|
-
status: response.status,
|
|
244
|
-
retryable: true,
|
|
245
|
-
reason: "oauth.unavailable"
|
|
246
|
-
});
|
|
247
|
-
throw new CliError("authentication_error", `${provider.name} sign-in was refused (HTTP ${response.status}); ${again}`, {
|
|
248
|
-
status: response.status,
|
|
249
|
-
reason: "oauth.expired"
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
let body;
|
|
253
|
-
try {
|
|
254
|
-
body = object2(await response.json());
|
|
255
|
-
} catch {
|
|
256
|
-
record("error", { outcome: "unreadable_response", status: response.status });
|
|
257
|
-
throw new CliError("invalid_response", `${provider.name} returned an unreadable token response; ${again}`, {
|
|
258
|
-
reason: "oauth.invalid-response"
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
const previous = context.previous;
|
|
262
|
-
const refreshToken = typeof body.refresh_token === "string" && body.refresh_token ? body.refresh_token : previous?.refreshToken;
|
|
263
|
-
const expiresIn = body.expires_in;
|
|
264
|
-
if (typeof body.access_token !== "string" || !body.access_token || expiresIn !== void 0 && (typeof expiresIn !== "number" || !Number.isFinite(expiresIn) || expiresIn <= 0) || body.scope !== void 0 && typeof body.scope !== "string" || body.token_type !== void 0 && typeof body.token_type !== "string") {
|
|
265
|
-
record("error", { outcome: "invalid_response", status: response.status });
|
|
266
|
-
throw new CliError("invalid_response", `${provider.name} returned an invalid token response; ${again}`, {
|
|
267
|
-
reason: "oauth.invalid-response"
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
if (!refreshToken) {
|
|
271
|
-
record("error", { outcome: "no_refresh_token", status: response.status });
|
|
272
|
-
throw new CliError("authentication_error", `${provider.name} returned no offline refresh token; ${again}`, {
|
|
273
|
-
reason: "oauth.failed"
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
const scopes = typeof body.scope === "string" ? body.scope.split(/\s+/).filter(Boolean) : previous?.scopes ?? [];
|
|
277
|
-
const tokenType = typeof body.token_type === "string" ? body.token_type : previous?.tokenType;
|
|
278
|
-
record("info", {
|
|
279
|
-
outcome: "received",
|
|
280
|
-
status: response.status,
|
|
281
|
-
...previous ? { rotated: refreshToken !== previous.refreshToken } : {}
|
|
282
|
-
});
|
|
283
|
-
return {
|
|
284
|
-
accessToken: body.access_token,
|
|
285
|
-
refreshToken,
|
|
286
|
-
...typeof expiresIn === "number" ? { expiresAt: context.now() + expiresIn * 1e3 } : {},
|
|
287
|
-
scopes,
|
|
288
|
-
...tokenType ? { tokenType } : {}
|
|
289
|
-
};
|
|
290
|
-
}, "exchangeTokens");
|
|
291
|
-
var alreadyRevoked = /* @__PURE__ */ __name(async (response) => {
|
|
292
|
-
if (response.status !== 400)
|
|
293
|
-
return false;
|
|
294
|
-
try {
|
|
295
|
-
return object2(JSON.parse(await response.text())).error === "invalid_token";
|
|
296
|
-
} catch {
|
|
297
|
-
return false;
|
|
298
|
-
}
|
|
299
|
-
}, "alreadyRevoked");
|
|
300
|
-
var revokeToken = /* @__PURE__ */ __name(async (provider, tokens, context) => {
|
|
301
|
-
if (provider.revoke)
|
|
302
|
-
return provider.revoke(tokens, context);
|
|
303
|
-
if (!provider.revokeUrl)
|
|
304
|
-
throw new CliError("validation_error", `${provider.name} declares no way to revoke a sign-in`);
|
|
305
|
-
const { revokeUrl } = provider;
|
|
306
|
-
const form = new URLSearchParams({ token: tokens.refreshToken, ...clientFields(context) });
|
|
307
|
-
const { response, gone } = await withTimeLimit(REQUEST_LIMIT_MS, async (deadline) => {
|
|
308
|
-
const response2 = await post(revokeUrl, form, context, deadline);
|
|
309
|
-
return { response: response2, gone: response2 ? await alreadyRevoked(response2) : false };
|
|
310
|
-
});
|
|
311
|
-
const done = response?.ok || gone;
|
|
312
|
-
context.log?.[done ? "info" : "warn"]({
|
|
313
|
-
event: TOKEN_LOG_EVENT,
|
|
314
|
-
provider: provider.id,
|
|
315
|
-
operation: "revoke",
|
|
316
|
-
pid: process.pid,
|
|
317
|
-
outcome: response?.ok ? "revoked" : gone ? "already_revoked" : response ? "rejected" : "no_response",
|
|
318
|
-
...response ? { status: response.status } : {}
|
|
319
|
-
});
|
|
320
|
-
if (!done)
|
|
321
|
-
throw new CliError("outcome_unknown", `${provider.name} did not confirm the revoke`, {
|
|
322
|
-
reason: "oauth.revoke-failed",
|
|
323
|
-
...response ? { status: response.status } : {}
|
|
324
|
-
});
|
|
325
|
-
}, "revokeToken");
|
|
326
|
-
|
|
327
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/oauth/keeper.js
|
|
328
|
-
var inFlight = /* @__PURE__ */ new Map();
|
|
329
|
-
var refreshedInMemory = /* @__PURE__ */ new Map();
|
|
330
|
-
var tokenKeeper = /* @__PURE__ */ __name((options) => {
|
|
331
|
-
const { provider, storage, signal, log } = options;
|
|
332
|
-
const now = options.now ?? Date.now;
|
|
333
|
-
const fresh = /* @__PURE__ */ __name((tokens2) => Boolean(tokens2.accessToken) && tokens2.expiresAt !== void 0 && tokens2.expiresAt > now() + (options.freshForMs ?? 6e4), "fresh");
|
|
334
|
-
const lockPath = join(options.lockDir, `oauth-${createHash2("sha256").update(storage.key).digest("hex").slice(0, 16)}.lock`);
|
|
335
|
-
const clientOf = /* @__PURE__ */ __name((stored) => {
|
|
336
|
-
const saved = stored?.client;
|
|
337
|
-
if (!saved || saved.clientSecret || saved.clientId !== provider.client.clientId)
|
|
338
|
-
return saved ?? provider.client;
|
|
339
|
-
return provider.client;
|
|
340
|
-
}, "clientOf");
|
|
341
|
-
const context = /* @__PURE__ */ __name((client, previous) => ({
|
|
342
|
-
fetch: options.fetch,
|
|
343
|
-
client,
|
|
344
|
-
now,
|
|
345
|
-
signInCommand: options.signInCommand,
|
|
346
|
-
...signal ? { signal } : {},
|
|
347
|
-
...log ? { log } : {},
|
|
348
|
-
...previous ? { previous } : {}
|
|
349
|
-
}), "context");
|
|
350
|
-
const exchange = /* @__PURE__ */ __name((params, ctx) => provider.exchange ? provider.exchange(params, ctx) : requestTokens(provider, params, ctx), "exchange");
|
|
351
|
-
const notSignedIn = /* @__PURE__ */ __name(() => new CliError("authentication_error", `not signed in to ${provider.name}; run ${options.signInCommand}`, {
|
|
352
|
-
reason: "session.missing"
|
|
353
|
-
}), "notSignedIn");
|
|
354
|
-
const busy = /* @__PURE__ */ __name((error) => isCliError(error) && error.details.reason === "file.locked", "busy");
|
|
355
|
-
const acquire = /* @__PURE__ */ __name(async () => {
|
|
356
|
-
const started = performance.now();
|
|
357
|
-
let waiting = false;
|
|
358
|
-
for (; ; ) {
|
|
359
|
-
try {
|
|
360
|
-
return await acquireLock(lockPath, signal ? { signal } : {});
|
|
361
|
-
} catch (error) {
|
|
362
|
-
if (!busy(error))
|
|
363
|
-
throw error;
|
|
364
|
-
if (!waiting) {
|
|
365
|
-
waiting = true;
|
|
366
|
-
log?.info({
|
|
367
|
-
event: TOKEN_LOG_EVENT,
|
|
368
|
-
provider: provider.id,
|
|
369
|
-
operation: "lock",
|
|
370
|
-
outcome: "waiting",
|
|
371
|
-
pid: process.pid
|
|
372
|
-
});
|
|
373
|
-
}
|
|
374
|
-
if (performance.now() - started > (options.lockWaitMs ?? 45e3))
|
|
375
|
-
throw new CliError("provider_unavailable", `another process holds this ${provider.name} sign-in; retry`, {
|
|
376
|
-
reason: "oauth.locked",
|
|
377
|
-
retryable: true
|
|
378
|
-
});
|
|
379
|
-
await delay(options.lockRetryMs ?? 50, void 0, signal ? { signal } : {}).catch(() => {
|
|
380
|
-
throw new CliError("cancelled", `${provider.name} sign-in was cancelled`);
|
|
381
|
-
});
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
}, "acquire");
|
|
385
|
-
const locked = /* @__PURE__ */ __name(async (work) => {
|
|
386
|
-
const lock = await acquire();
|
|
387
|
-
try {
|
|
388
|
-
return await work();
|
|
389
|
-
} finally {
|
|
390
|
-
await lock.release().catch(() => {
|
|
391
|
-
});
|
|
392
|
-
}
|
|
393
|
-
}, "locked");
|
|
394
|
-
const shared = /* @__PURE__ */ __name((work) => {
|
|
395
|
-
const running = inFlight.get(lockPath);
|
|
396
|
-
if (running)
|
|
397
|
-
return running;
|
|
398
|
-
const started = locked(work).finally(() => inFlight.delete(lockPath));
|
|
399
|
-
inFlight.set(lockPath, started);
|
|
400
|
-
return started;
|
|
401
|
-
}, "shared");
|
|
402
|
-
const remembered = /* @__PURE__ */ __name((saved) => {
|
|
403
|
-
const kept = refreshedInMemory.get(lockPath);
|
|
404
|
-
return kept && fresh(kept) && kept.refreshToken === saved.refreshToken ? kept : void 0;
|
|
405
|
-
}, "remembered");
|
|
406
|
-
const forget = /* @__PURE__ */ __name(() => refreshedInMemory.delete(lockPath), "forget");
|
|
407
|
-
let answered;
|
|
408
|
-
const answer = /* @__PURE__ */ __name((given) => {
|
|
409
|
-
answered = given;
|
|
410
|
-
return given;
|
|
411
|
-
}, "answer");
|
|
412
|
-
const tokens = /* @__PURE__ */ __name(async ({ refresh = false } = {}) => {
|
|
413
|
-
const seen = storage.read();
|
|
414
|
-
if (!seen)
|
|
415
|
-
throw notSignedIn();
|
|
416
|
-
if (!refresh) {
|
|
417
|
-
const kept = remembered(seen.tokens);
|
|
418
|
-
if (kept)
|
|
419
|
-
return answer(kept);
|
|
420
|
-
if (fresh(seen.tokens))
|
|
421
|
-
return answer(seen.tokens);
|
|
422
|
-
}
|
|
423
|
-
const refused = answered ?? remembered(seen.tokens) ?? seen.tokens;
|
|
424
|
-
return answer(await shared(async () => {
|
|
425
|
-
const current = storage.read();
|
|
426
|
-
if (!current)
|
|
427
|
-
throw notSignedIn();
|
|
428
|
-
const latest = remembered(current.tokens) ?? current.tokens;
|
|
429
|
-
if (refresh) {
|
|
430
|
-
if (latest.accessToken !== refused.accessToken && fresh(latest))
|
|
431
|
-
return latest;
|
|
432
|
-
} else {
|
|
433
|
-
if (latest !== current.tokens)
|
|
434
|
-
return latest;
|
|
435
|
-
if (fresh(current.tokens) || current.tokens.refreshToken !== seen.tokens.refreshToken)
|
|
436
|
-
return current.tokens;
|
|
437
|
-
}
|
|
438
|
-
if (storage.moved && storage.rotating)
|
|
439
|
-
throw new CliError("authentication_error", `the sign-in to ${provider.name} needs a refresh, which a run with moved folders never makes: the provider rotates its refresh token, and the owner's own sign-in would keep a dead one; run this in the normal run, or sign in again there`, { reason: "oauth.moved-rotating" });
|
|
440
|
-
const client = clientOf(current);
|
|
441
|
-
const refreshed = await exchange({ grant_type: "refresh_token", refresh_token: current.tokens.refreshToken }, context(client, current.tokens));
|
|
442
|
-
if (storage.moved && refreshed.refreshToken === current.tokens.refreshToken)
|
|
443
|
-
refreshedInMemory.set(lockPath, refreshed);
|
|
444
|
-
else
|
|
445
|
-
storage.write({ tokens: refreshed, client });
|
|
446
|
-
return refreshed;
|
|
447
|
-
}));
|
|
448
|
-
}, "tokens");
|
|
449
|
-
return {
|
|
450
|
-
tokens,
|
|
451
|
-
accessToken: /* @__PURE__ */ __name(async (tokensOptions) => {
|
|
452
|
-
const current = await tokens(tokensOptions);
|
|
453
|
-
if (!current.accessToken)
|
|
454
|
-
throw notSignedIn();
|
|
455
|
-
return current.accessToken;
|
|
456
|
-
}, "accessToken"),
|
|
457
|
-
signIn: /* @__PURE__ */ __name(async ({ accept, ...authorizeOptions }) => {
|
|
458
|
-
storage.probe();
|
|
459
|
-
const authorization = await authorize({ ...authorizeOptions, provider, ...signal ? { signal } : {} });
|
|
460
|
-
const client = provider.client;
|
|
461
|
-
const received = await exchange({
|
|
462
|
-
grant_type: "authorization_code",
|
|
463
|
-
code: authorization.code,
|
|
464
|
-
redirect_uri: authorization.redirectUri,
|
|
465
|
-
code_verifier: authorization.codeVerifier
|
|
466
|
-
}, context(client));
|
|
467
|
-
const extra = await accept?.(received) ?? void 0;
|
|
468
|
-
await locked(async () => {
|
|
469
|
-
forget();
|
|
470
|
-
storage.write({ tokens: received, client, ...extra ? { extra } : {} }, { signIn: true });
|
|
471
|
-
});
|
|
472
|
-
return { scopes: received.scopes };
|
|
473
|
-
}, "signIn"),
|
|
474
|
-
save: /* @__PURE__ */ __name((saved, extra) => locked(async () => {
|
|
475
|
-
forget();
|
|
476
|
-
storage.write({ tokens: saved, client: clientOf(storage.read()), ...extra ? { extra } : {} }, { signIn: true });
|
|
477
|
-
}), "save"),
|
|
478
|
-
signOut: /* @__PURE__ */ __name(({ revoke = false } = {}) => locked(async () => {
|
|
479
|
-
forget();
|
|
480
|
-
const current = storage.read();
|
|
481
|
-
let revoked = false;
|
|
482
|
-
if (revoke && current) {
|
|
483
|
-
await revokeToken(provider, current.tokens, context(clientOf(current)));
|
|
484
|
-
revoked = true;
|
|
485
|
-
}
|
|
486
|
-
return { revoked, removed: storage.remove() };
|
|
487
|
-
}), "signOut")
|
|
488
|
-
};
|
|
489
|
-
}, "tokenKeeper");
|
|
490
|
-
|
|
491
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/oauth/provider.js
|
|
492
|
-
var googleProvider = /* @__PURE__ */ __name((client, { loginHint } = {}) => ({
|
|
493
|
-
id: "google",
|
|
494
|
-
name: "Google",
|
|
495
|
-
authorizeUrl: "https://accounts.google.com/o/oauth2/v2/auth",
|
|
496
|
-
tokenUrl: "https://oauth2.googleapis.com/token",
|
|
497
|
-
revokeUrl: "https://oauth2.googleapis.com/revoke",
|
|
498
|
-
client,
|
|
499
|
-
redirect: { kind: "loopback" },
|
|
500
|
-
// Without offline access Google returns no refresh token; without consent it does not return one again.
|
|
501
|
-
authorizeParams: {
|
|
502
|
-
access_type: "offline",
|
|
503
|
-
prompt: "select_account consent",
|
|
504
|
-
...loginHint ? { login_hint: loginHint } : {}
|
|
505
|
-
}
|
|
506
|
-
}), "googleProvider");
|
|
507
|
-
|
|
508
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/oauth/storage.js
|
|
509
|
-
var invalid = /* @__PURE__ */ __name(() => new CliError("authentication_error", "the saved sign-in cannot be read; sign in again", { reason: "oauth.invalid" }), "invalid");
|
|
510
|
-
var parse = /* @__PURE__ */ __name((raw) => {
|
|
511
|
-
let value;
|
|
512
|
-
try {
|
|
513
|
-
value = JSON.parse(raw);
|
|
514
|
-
} catch {
|
|
515
|
-
throw invalid();
|
|
516
|
-
}
|
|
517
|
-
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
518
|
-
throw invalid();
|
|
519
|
-
return value;
|
|
520
|
-
}, "parse");
|
|
521
|
-
var text = /* @__PURE__ */ __name((value) => typeof value === "string" && value ? value : void 0, "text");
|
|
522
|
-
var finite = /* @__PURE__ */ __name((value) => typeof value === "number" && Number.isFinite(value) ? value : void 0, "finite");
|
|
523
|
-
var previousOf = /* @__PURE__ */ __name((raw) => {
|
|
524
|
-
if (raw === void 0)
|
|
525
|
-
return {};
|
|
526
|
-
try {
|
|
527
|
-
return parse(raw);
|
|
528
|
-
} catch {
|
|
529
|
-
return {};
|
|
530
|
-
}
|
|
531
|
-
}, "previousOf");
|
|
532
|
-
var defined = /* @__PURE__ */ __name((value) => Object.fromEntries(Object.entries(value).filter(([, field]) => field !== void 0)), "defined");
|
|
533
|
-
var standardCodec = /* @__PURE__ */ __name((providerId) => ({
|
|
534
|
-
decode: /* @__PURE__ */ __name((raw) => {
|
|
535
|
-
const value = parse(raw);
|
|
536
|
-
const refreshToken = text(value.refreshToken);
|
|
537
|
-
const clientId = text(value.clientId);
|
|
538
|
-
if (value.version !== 1 || value.provider !== providerId || !refreshToken || !clientId)
|
|
539
|
-
throw invalid();
|
|
540
|
-
if (!Array.isArray(value.scopes) || !value.scopes.every((scope) => typeof scope === "string"))
|
|
541
|
-
throw invalid();
|
|
542
|
-
const source = text(value.clientSource);
|
|
543
|
-
return {
|
|
544
|
-
client: defined({ clientId, clientSecret: text(value.clientSecret), source }),
|
|
545
|
-
tokens: defined({
|
|
546
|
-
accessToken: text(value.accessToken),
|
|
547
|
-
refreshToken,
|
|
548
|
-
expiresAt: finite(value.expiresAt),
|
|
549
|
-
scopes: value.scopes,
|
|
550
|
-
tokenType: text(value.tokenType)
|
|
551
|
-
})
|
|
552
|
-
};
|
|
553
|
-
}, "decode"),
|
|
554
|
-
encode: /* @__PURE__ */ __name(({ tokens, client, previous, extra }) => JSON.stringify(defined({
|
|
555
|
-
...previousOf(previous),
|
|
556
|
-
...extra,
|
|
557
|
-
version: 1,
|
|
558
|
-
provider: providerId,
|
|
559
|
-
clientId: client.clientId,
|
|
560
|
-
// Only WireCat's secret, which is public: a later release may ship another default app, and a refresh needs
|
|
561
|
-
// the secret of the app that signed in. An owner's own secret stays where the owner keeps it.
|
|
562
|
-
clientSecret: client.source === "constants" ? client.clientSecret : void 0,
|
|
563
|
-
clientSource: client.source,
|
|
564
|
-
accessToken: tokens.accessToken,
|
|
565
|
-
refreshToken: tokens.refreshToken,
|
|
566
|
-
expiresAt: tokens.expiresAt,
|
|
567
|
-
scopes: tokens.scopes,
|
|
568
|
-
tokenType: tokens.tokenType
|
|
569
|
-
})), "encode")
|
|
570
|
-
}), "standardCodec");
|
|
571
|
-
var driveSessionCodec = {
|
|
572
|
-
decode: /* @__PURE__ */ __name((raw) => {
|
|
573
|
-
const value = parse(raw);
|
|
574
|
-
const tokens = value.tokens;
|
|
575
|
-
if (typeof tokens !== "object" || tokens === null || Array.isArray(tokens))
|
|
576
|
-
throw invalid();
|
|
577
|
-
const fields = tokens;
|
|
578
|
-
const refreshToken = text(fields.refresh_token);
|
|
579
|
-
const clientId = text(value.clientId);
|
|
580
|
-
if (!refreshToken || !clientId || typeof value.principal !== "string")
|
|
581
|
-
throw invalid();
|
|
582
|
-
return {
|
|
583
|
-
client: defined({
|
|
584
|
-
clientId,
|
|
585
|
-
clientSecret: text(value.clientSecret),
|
|
586
|
-
source: text(value.clientSource)
|
|
587
|
-
}),
|
|
588
|
-
tokens: defined({
|
|
589
|
-
accessToken: text(fields.access_token),
|
|
590
|
-
refreshToken,
|
|
591
|
-
expiresAt: finite(fields.expiry_date),
|
|
592
|
-
scopes: typeof fields.scope === "string" ? fields.scope.split(/\s+/).filter(Boolean) : [],
|
|
593
|
-
tokenType: text(fields.token_type)
|
|
594
|
-
})
|
|
595
|
-
};
|
|
596
|
-
}, "decode"),
|
|
597
|
-
encode: /* @__PURE__ */ __name(({ tokens, client, previous, extra }) => {
|
|
598
|
-
const before = previousOf(previous);
|
|
599
|
-
const oldTokens = typeof before.tokens === "object" && before.tokens !== null ? before.tokens : {};
|
|
600
|
-
const session = {
|
|
601
|
-
...before,
|
|
602
|
-
...extra,
|
|
603
|
-
clientId: client.clientId,
|
|
604
|
-
...client.clientSecret ? { clientSecret: client.clientSecret } : {},
|
|
605
|
-
...client.source ? { clientSource: client.source } : {},
|
|
606
|
-
tokens: defined({
|
|
607
|
-
...oldTokens,
|
|
608
|
-
access_token: tokens.accessToken,
|
|
609
|
-
refresh_token: tokens.refreshToken,
|
|
610
|
-
expiry_date: tokens.expiresAt,
|
|
611
|
-
...tokens.scopes.length ? { scope: tokens.scopes.join(" ") } : {},
|
|
612
|
-
token_type: tokens.tokenType
|
|
613
|
-
})
|
|
614
|
-
};
|
|
615
|
-
if (typeof session.principal !== "string")
|
|
616
|
-
throw new CliError("configuration_error", "drive's sign-in entry needs the account's principal");
|
|
617
|
-
return JSON.stringify(session);
|
|
618
|
-
}, "encode")
|
|
619
|
-
};
|
|
620
|
-
var googleStandard = standardCodec("google");
|
|
621
|
-
var keyringFailure = /* @__PURE__ */ __name((thrown, secret) => {
|
|
622
|
-
const failure = new CliError("configuration_error", "could not reach the saved sign-in; use an available keyring or file storage", { reason: "oauth.not-saved" });
|
|
623
|
-
const words = thrown instanceof Error ? thrown.message : String(thrown);
|
|
624
|
-
failure.cause = new Error(secret ? words.replaceAll(secret, "[secret]") : words);
|
|
625
|
-
return failure;
|
|
626
|
-
}, "keyringFailure");
|
|
627
|
-
var credentialStorage = /* @__PURE__ */ __name((options) => {
|
|
628
|
-
if (!options.credentials.keyring)
|
|
629
|
-
throw new CliError("configuration_error", "a sign-in store needs its keyring passed in, never a default");
|
|
630
|
-
const credentials2 = new Credentials(options.credentials);
|
|
631
|
-
const { account, codec } = options;
|
|
632
|
-
const moved = options.credentials.isolated === true || options.credentials.keyring === systemKeyring && isMovedRun({ appName: options.credentials.service, env: options.credentials.env ?? process.env });
|
|
633
|
-
const service = keyringService(options.credentials.service, options.credentials.configDir, options.credentials.isolated);
|
|
634
|
-
const raw = /* @__PURE__ */ __name((name) => {
|
|
635
|
-
try {
|
|
636
|
-
return credentials2.read(name)?.secret;
|
|
637
|
-
} catch (error) {
|
|
638
|
-
throw keyringFailure(error);
|
|
639
|
-
}
|
|
640
|
-
}, "raw");
|
|
641
|
-
const save = /* @__PURE__ */ __name((value, writeOptions) => {
|
|
642
|
-
try {
|
|
643
|
-
credentials2.write(account, value, writeOptions);
|
|
644
|
-
} catch (error) {
|
|
645
|
-
throw keyringFailure(error, value);
|
|
646
|
-
}
|
|
647
|
-
}, "save");
|
|
648
|
-
const current = /* @__PURE__ */ __name(() => {
|
|
649
|
-
const own = raw(account);
|
|
650
|
-
if (own !== void 0)
|
|
651
|
-
return own;
|
|
652
|
-
for (const legacy of options.legacyAccounts ?? []) {
|
|
653
|
-
const found = raw(legacy);
|
|
654
|
-
if (found === void 0)
|
|
655
|
-
continue;
|
|
656
|
-
codec.decode(found);
|
|
657
|
-
if (!moved)
|
|
658
|
-
save(found);
|
|
659
|
-
return found;
|
|
660
|
-
}
|
|
661
|
-
return void 0;
|
|
662
|
-
}, "current");
|
|
663
|
-
return {
|
|
664
|
-
key: `${service}\0${account}`,
|
|
665
|
-
moved,
|
|
666
|
-
...codec.rotating ? { rotating: true } : {},
|
|
667
|
-
probe: /* @__PURE__ */ __name(() => {
|
|
668
|
-
raw(account);
|
|
669
|
-
}, "probe"),
|
|
670
|
-
read: /* @__PURE__ */ __name(() => {
|
|
671
|
-
const value = current();
|
|
672
|
-
return value === void 0 ? void 0 : codec.decode(value);
|
|
673
|
-
}, "read"),
|
|
674
|
-
write: /* @__PURE__ */ __name((input, writeOptions) => save(codec.encode({ ...input, previous: raw(account), ...writeOptions?.signIn ? { signIn: true } : {} }), writeOptions), "write"),
|
|
675
|
-
remove: /* @__PURE__ */ __name(() => {
|
|
676
|
-
try {
|
|
677
|
-
return credentials2.remove(account);
|
|
678
|
-
} catch (error) {
|
|
679
|
-
throw keyringFailure(error);
|
|
680
|
-
}
|
|
681
|
-
}, "remove")
|
|
682
|
-
};
|
|
683
|
-
}, "credentialStorage");
|
|
684
|
-
|
|
685
|
-
// dist/tokens.js
|
|
686
|
-
import { OAuth2Client } from "google-auth-library";
|
|
687
|
-
var Session = object({
|
|
688
|
-
principal: string(),
|
|
689
|
-
clientId: string(),
|
|
690
|
-
clientSecret: optional(string()),
|
|
691
|
-
tokens: object({
|
|
692
|
-
access_token: optional(nullable(string())),
|
|
693
|
-
refresh_token: pipe(string(), minLength(1)),
|
|
694
|
-
expiry_date: optional(nullable(number())),
|
|
695
|
-
scope: optional(string()),
|
|
696
|
-
token_type: optional(nullable(string()))
|
|
697
|
-
})
|
|
698
|
-
});
|
|
699
|
-
var viaDeclaredHosts = /* @__PURE__ */ __name((timeoutMs) => (input, init) => hostFetch({ hosts: DESKTOP.hosts, ...timeoutMs ? { timeoutMs } : {} })(input, init), "viaDeclaredHosts");
|
|
700
|
-
var googleFetch = viaDeclaredHosts();
|
|
701
|
-
var sdkFetch = viaDeclaredHosts(24 * 60 * 6e4);
|
|
702
|
-
var transporterOptions = /* @__PURE__ */ __name((signal) => ({
|
|
703
|
-
timeout: 3e4,
|
|
704
|
-
fetchImplementation: sdkFetch,
|
|
705
|
-
...signal ? { signal } : {}
|
|
706
|
-
}), "transporterOptions");
|
|
707
|
-
var credentialOptions = /* @__PURE__ */ __name((env, storage, keyring) => ({
|
|
708
|
-
configDir: paths(env).config,
|
|
709
|
-
service: "drive-cli",
|
|
710
|
-
// The keyring falls back to the private file by itself (WC-SECR-4); `file` skips the keyring.
|
|
711
|
-
storage: storage === "keyring" ? "auto" : storage,
|
|
712
|
-
env,
|
|
713
|
-
isolated: isMovedRun({ appName: "drive-cli", prefix: "DRIVE", env }),
|
|
714
|
-
...keyring ? { keyring } : {}
|
|
715
|
-
}), "credentialOptions");
|
|
716
|
-
var credentials = /* @__PURE__ */ __name((env, storage, keyring) => new Credentials(credentialOptions(env, storage, keyring)), "credentials");
|
|
717
|
-
var notSaved = /* @__PURE__ */ __name(() => new CliError("configuration_error", "could not save Google sign-in: the private credentials file cannot be read; move it aside and sign in again", { reason: "oauth.not-saved" }), "notSaved");
|
|
718
|
-
var saveSession = /* @__PURE__ */ __name((env, name, session, storage, keyring) => {
|
|
719
|
-
try {
|
|
720
|
-
credentials(env, storage, keyring).write(name, JSON.stringify(session));
|
|
721
|
-
} catch {
|
|
722
|
-
throw notSaved();
|
|
723
|
-
}
|
|
724
|
-
}, "saveSession");
|
|
725
|
-
var sessionKeeper = /* @__PURE__ */ __name((options) => tokenKeeper({
|
|
726
|
-
provider: googleProvider(options.client),
|
|
727
|
-
storage: credentialStorage({
|
|
728
|
-
credentials: { ...credentialOptions(options.env, options.storage), keyring: options.keyring ?? systemKeyring },
|
|
729
|
-
account: options.name,
|
|
730
|
-
codec: driveSessionCodec
|
|
731
|
-
}),
|
|
732
|
-
lockDir: paths(options.env).config,
|
|
733
|
-
fetch: options.fetch ?? googleFetch,
|
|
734
|
-
signInCommand: `drive ${options.name} session start`,
|
|
735
|
-
// Above the client's own 5-minute early refresh, so a token it asks to replace is replaced.
|
|
736
|
-
freshForMs: 6 * 6e4,
|
|
737
|
-
...options.signal ? { signal: options.signal } : {}
|
|
738
|
-
}), "sessionKeeper");
|
|
739
|
-
var authorizedClient = /* @__PURE__ */ __name((env, name, keyring, signal) => {
|
|
740
|
-
const profile = activeProfile(env, name);
|
|
741
|
-
const unreadable = /* @__PURE__ */ __name(() => new CliError("authentication_error", `could not load Google sign-in \u2014 run drive ${name} session start again`, {
|
|
742
|
-
reason: "oauth.expired"
|
|
743
|
-
}), "unreadable");
|
|
744
|
-
let secret;
|
|
745
|
-
try {
|
|
746
|
-
secret = credentials(env, profile.storage, keyring).read(name)?.secret;
|
|
747
|
-
} catch {
|
|
748
|
-
throw unreadable();
|
|
749
|
-
}
|
|
750
|
-
if (!secret)
|
|
751
|
-
throw new CliError("authentication_error", `this profile has no saved Google sign-in \u2014 run drive ${name} session start`, {
|
|
752
|
-
reason: "session.missing"
|
|
753
|
-
});
|
|
754
|
-
let parsed;
|
|
755
|
-
try {
|
|
756
|
-
parsed = safeParse(Session, JSON.parse(secret));
|
|
757
|
-
} catch {
|
|
758
|
-
throw unreadable();
|
|
759
|
-
}
|
|
760
|
-
if (!parsed.success || parsed.output.principal !== profile.principal)
|
|
761
|
-
throw new CliError("authentication_error", "saved sign-in is invalid or belongs to another account", {
|
|
762
|
-
reason: "oauth.expired"
|
|
763
|
-
});
|
|
764
|
-
const session = parsed.output;
|
|
765
|
-
const keeper = sessionKeeper({
|
|
766
|
-
env,
|
|
767
|
-
name,
|
|
768
|
-
storage: profile.storage,
|
|
769
|
-
client: { clientId: session.clientId, ...session.clientSecret ? { clientSecret: session.clientSecret } : {} },
|
|
770
|
-
...keyring ? { keyring } : {},
|
|
771
|
-
...signal ? { signal } : {}
|
|
772
|
-
});
|
|
773
|
-
const client = new OAuth2Client({
|
|
774
|
-
clientId: session.clientId,
|
|
775
|
-
clientSecret: session.clientSecret,
|
|
776
|
-
transporterOptions: transporterOptions(signal)
|
|
777
|
-
});
|
|
778
|
-
client.refreshHandler = async () => {
|
|
779
|
-
try {
|
|
780
|
-
const tokens = await keeper.tokens();
|
|
781
|
-
if (!tokens.accessToken || tokens.expiresAt === void 0)
|
|
782
|
-
throw new Error("no access token");
|
|
783
|
-
return { access_token: tokens.accessToken, expiry_date: tokens.expiresAt };
|
|
784
|
-
} catch (error) {
|
|
785
|
-
if (isCliError(error) && error.code !== "authentication_error")
|
|
786
|
-
throw error;
|
|
787
|
-
throw new CliError("authentication_error", `Google sign-in expired \u2014 run drive ${name} session start again`, {
|
|
788
|
-
reason: "oauth.expired"
|
|
789
|
-
});
|
|
790
|
-
}
|
|
791
|
-
};
|
|
792
|
-
const { refresh_token: _refresh, ...current } = session.tokens;
|
|
793
|
-
client.setCredentials(current);
|
|
794
|
-
return observeRequests(client);
|
|
795
|
-
}, "authorizedClient");
|
|
796
|
-
var covers = /* @__PURE__ */ __name((granted, required) => granted.includes(required) || required === READ_SCOPE && granted.includes(WRITE_SCOPE), "covers");
|
|
797
|
-
var grantedScopes = /* @__PURE__ */ __name((env, name, keyring) => {
|
|
798
|
-
try {
|
|
799
|
-
const secret = credentials(env, activeProfile(env, name).storage, keyring).read(name)?.secret;
|
|
800
|
-
const parsed = secret ? safeParse(Session, JSON.parse(secret)) : void 0;
|
|
801
|
-
if (!parsed?.success)
|
|
802
|
-
return [];
|
|
803
|
-
return parsed.output.tokens.scope?.split(/\s+/).filter(Boolean);
|
|
804
|
-
} catch {
|
|
805
|
-
return [];
|
|
806
|
-
}
|
|
807
|
-
}, "grantedScopes");
|
|
808
|
-
var checkAuthorization = /* @__PURE__ */ __name(async (client, required = READ_SCOPE) => {
|
|
809
|
-
try {
|
|
810
|
-
const { token } = await client.getAccessToken();
|
|
811
|
-
if (!token)
|
|
812
|
-
throw new CliError("authentication_error", "Google returned no access token");
|
|
813
|
-
const info = await client.getTokenInfo(token);
|
|
814
|
-
if (!covers(info.scopes, required))
|
|
815
|
-
throw new CliError("permission_error", "sign-in lacks the required permission; run drive <profile> session start --grant write, activity or apps when needed", { reason: "oauth.scope-missing" });
|
|
816
|
-
} catch (error) {
|
|
817
|
-
throw googleError(error);
|
|
818
|
-
}
|
|
819
|
-
}, "checkAuthorization");
|
|
820
|
-
var WORD = /^[a-z][a-z_]{0,23}$/;
|
|
821
|
-
var VERB = /^[a-z][A-Za-z]{0,31}$/;
|
|
822
|
-
var segment = /* @__PURE__ */ __name((part) => {
|
|
823
|
-
if (/^v\d+$/.test(part) || WORD.test(part))
|
|
824
|
-
return part;
|
|
825
|
-
const verb = part.split(":")[1];
|
|
826
|
-
return verb !== void 0 && VERB.test(verb) ? `:id:${verb}` : ":id";
|
|
827
|
-
}, "segment");
|
|
828
|
-
var operationOf = /* @__PURE__ */ __name((method, url) => {
|
|
829
|
-
let path = "";
|
|
830
|
-
try {
|
|
831
|
-
path = new URL(String(url ?? "")).pathname;
|
|
832
|
-
} catch {
|
|
833
|
-
}
|
|
834
|
-
const template = path.split("/").filter(Boolean).map((part) => segment(decodeURIComponent(part))).join("/");
|
|
835
|
-
return `${(method ?? "GET").toUpperCase()} /${template}`;
|
|
836
|
-
}, "operationOf");
|
|
837
|
-
var reasonOf = /* @__PURE__ */ __name((data) => {
|
|
838
|
-
const error = data?.error;
|
|
839
|
-
const reason = error?.errors?.[0]?.reason ?? error?.status;
|
|
840
|
-
return typeof reason === "string" ? reason : void 0;
|
|
841
|
-
}, "reasonOf");
|
|
842
|
-
var observeRequests = /* @__PURE__ */ __name((client) => {
|
|
843
|
-
const transporter = client.transporter;
|
|
844
|
-
const request = transporter.request.bind(transporter);
|
|
845
|
-
transporter.request = (async (options) => {
|
|
846
|
-
const method = (options.method ?? "GET").toUpperCase();
|
|
847
|
-
const operation = operationOf(method, options.url);
|
|
848
|
-
const call = { method, endpointTemplate: operation.slice(method.length + 1), transport: "http" };
|
|
849
|
-
let ended;
|
|
850
|
-
const adapter = /* @__PURE__ */ __name(async (prepared, next) => {
|
|
851
|
-
const attempt = (prepared.retryConfig?.currentRetryAttempt ?? 0) + 1;
|
|
852
|
-
const waitMs = ended === void 0 ? void 0 : Math.round(performance.now() - ended);
|
|
853
|
-
const answered = providerRequest(operation, void 0, {
|
|
854
|
-
...call,
|
|
855
|
-
attempt,
|
|
856
|
-
...waitMs === void 0 ? {} : { waitMs }
|
|
857
|
-
});
|
|
858
|
-
try {
|
|
859
|
-
const response = await (options.adapter ? options.adapter(prepared, next) : next(prepared));
|
|
860
|
-
const failed = !(prepared.validateStatus?.(response.status) ?? response.status < 400);
|
|
861
|
-
const providerError = failed ? reasonOf(response.data) : void 0;
|
|
862
|
-
answered({
|
|
863
|
-
status: response.status,
|
|
864
|
-
...failed ? { errorCode: "provider_error" } : {},
|
|
865
|
-
...providerError ? { providerError } : {}
|
|
866
|
-
});
|
|
867
|
-
return response;
|
|
868
|
-
} catch (error) {
|
|
869
|
-
answered({ error, errorCode: googleError(error).code });
|
|
870
|
-
throw error;
|
|
871
|
-
} finally {
|
|
872
|
-
ended = performance.now();
|
|
873
|
-
}
|
|
874
|
-
}, "adapter");
|
|
875
|
-
try {
|
|
876
|
-
return await request({ ...options, adapter });
|
|
877
|
-
} catch (error) {
|
|
878
|
-
if (ended === void 0)
|
|
879
|
-
providerRequest(operation, void 0, { ...call, attempt: 1 })({ error, errorCode: googleError(error).code });
|
|
880
|
-
throw error;
|
|
881
|
-
}
|
|
882
|
-
});
|
|
883
|
-
return client;
|
|
884
|
-
}, "observeRequests");
|
|
885
|
-
|
|
886
|
-
export {
|
|
887
|
-
googleFetch,
|
|
888
|
-
transporterOptions,
|
|
889
|
-
credentials,
|
|
890
|
-
notSaved,
|
|
891
|
-
saveSession,
|
|
892
|
-
sessionKeeper,
|
|
893
|
-
authorizedClient,
|
|
894
|
-
covers,
|
|
895
|
-
grantedScopes,
|
|
896
|
-
checkAuthorization,
|
|
897
|
-
operationOf,
|
|
898
|
-
observeRequests
|
|
899
|
-
};
|