vercel 59.11.2 → 59.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/dist/chunks/{add-BKSHWTPX.js → add-OO3JGLZW.js} +23 -18
  2. package/dist/chunks/{add-HPLJZFM2.js → add-RTXDASSS.js} +23 -18
  3. package/dist/chunks/add-XGO6LHMD.js +221 -0
  4. package/dist/chunks/{build-V4ZLAJWB.js → build-JINV2UD4.js} +23 -18
  5. package/dist/chunks/{chunk-NGGLYKNU.js → chunk-26CU4Q3C.js} +3 -115
  6. package/dist/chunks/{chunk-QFAS4OVW.js → chunk-2JIX6UMI.js} +3 -84
  7. package/dist/chunks/chunk-2NIDTSQJ.js +305 -0
  8. package/dist/chunks/chunk-32XSMM3W.js +49 -0
  9. package/dist/chunks/chunk-332LMJLZ.js +16014 -0
  10. package/dist/chunks/{chunk-RO44KX6Y.js → chunk-3BB2HOO2.js} +12 -7
  11. package/dist/chunks/{chunk-HDBQPBL6.js → chunk-3F25W3GA.js} +13 -9
  12. package/dist/chunks/{chunk-AYLY3ZVL.js → chunk-3VM7HWF6.js} +2 -2
  13. package/dist/chunks/chunk-4IALDGB7.js +22 -0
  14. package/dist/chunks/{chunk-MTWHQEXI.js → chunk-4TUMNBEE.js} +7 -5
  15. package/dist/chunks/{chunk-5XECIWME.js → chunk-5NF5HOBJ.js} +5 -3
  16. package/dist/chunks/chunk-6E6KPBXY.js +43 -0
  17. package/dist/chunks/{chunk-ASBP32T6.js → chunk-7MRDIPJY.js} +1 -1
  18. package/dist/chunks/chunk-ABSZNJQO.js +522 -0
  19. package/dist/chunks/{chunk-7ST552E3.js → chunk-AKLTIZCU.js} +1 -1
  20. package/dist/chunks/{chunk-ONRLTUP2.js → chunk-AV747POV.js} +43 -36
  21. package/dist/chunks/chunk-B5XLQKHI.js +849 -0
  22. package/dist/chunks/{chunk-BMKU5KEL.js → chunk-CV5YC2EN.js} +1 -1
  23. package/dist/chunks/{chunk-TPATD2MM.js → chunk-CZ5QQRXD.js} +14 -6
  24. package/dist/chunks/{chunk-2EAIC3SH.js → chunk-E47NARDE.js} +8 -8
  25. package/dist/chunks/{chunk-XM3LOQIX.js → chunk-EDMW7SBH.js} +76 -92
  26. package/dist/chunks/{chunk-QAT3CW4G.js → chunk-EFYMIIER.js} +2 -2
  27. package/dist/chunks/chunk-ELZ6WQQA.js +81 -0
  28. package/dist/chunks/{chunk-FKDO3CM4.js → chunk-EOLGLGXJ.js} +17 -13
  29. package/dist/chunks/chunk-FRVG4OW3.js +7438 -0
  30. package/dist/chunks/chunk-G5FBSUL4.js +822 -0
  31. package/dist/chunks/chunk-GDOUDU6O.js +74 -0
  32. package/dist/chunks/{chunk-OQ3C5VXZ.js → chunk-GVNCVKCI.js} +4 -2
  33. package/dist/chunks/chunk-HB4UKFDO.js +1295 -0
  34. package/dist/chunks/{chunk-FRAXI2WT.js → chunk-HD4DR3DA.js} +4 -3
  35. package/dist/chunks/{chunk-DWIC7MRV.js → chunk-HKHXKSXQ.js} +1 -1
  36. package/dist/chunks/{chunk-6JPVTPTU.js → chunk-HM24ZWQL.js} +4 -4
  37. package/dist/chunks/chunk-HR2MP4XF.js +324 -0
  38. package/dist/chunks/chunk-HRXRELD3.js +338 -0
  39. package/dist/chunks/{chunk-IJ4X426J.js → chunk-IIMSID24.js} +1 -1
  40. package/dist/chunks/{chunk-B4TXCKXE.js → chunk-JOXNBQ7W.js} +10 -8
  41. package/dist/chunks/{chunk-O75LSD3C.js → chunk-JSD4EZL3.js} +1 -1
  42. package/dist/chunks/{chunk-7AEEQOD4.js → chunk-K3RED3VO.js} +1 -1
  43. package/dist/chunks/chunk-KAF4WFF3.js +257 -0
  44. package/dist/chunks/{chunk-3T7WSWZH.js → chunk-KFWQ3EFH.js} +1 -1
  45. package/dist/chunks/{chunk-6CZZ3SH3.js → chunk-KNO327AW.js} +2 -2
  46. package/dist/chunks/{chunk-L3UXB2CW.js → chunk-KW7BS25T.js} +1 -1
  47. package/dist/chunks/{chunk-2NJJ2K5S.js → chunk-L6B6BRHH.js} +6 -6
  48. package/dist/chunks/{chunk-FZRBF25Y.js → chunk-LDV2R4P4.js} +4 -4
  49. package/dist/chunks/chunk-MADFAH3O.js +14059 -0
  50. package/dist/chunks/{chunk-OO3OF6MK.js → chunk-MDGPZHSM.js} +151 -26
  51. package/dist/chunks/{chunk-XRWOTCDO.js → chunk-ND5CF2H3.js} +1 -1
  52. package/dist/chunks/{chunk-6TBDHUXK.js → chunk-NDY3JDOU.js} +21 -15
  53. package/dist/chunks/{chunk-RKDCNQ4S.js → chunk-NW34PW6V.js} +3 -105
  54. package/dist/chunks/{chunk-C5HKWXRR.js → chunk-OAMU5QO6.js} +1 -1
  55. package/dist/chunks/{chunk-RSJBU3ON.js → chunk-OJHDGHOB.js} +35 -27
  56. package/dist/chunks/chunk-P7VSBDR4.js +827 -0
  57. package/dist/chunks/chunk-PEC3CQSK.js +90 -0
  58. package/dist/chunks/{chunk-KJBZ5ZST.js → chunk-PIMIVJYK.js} +1 -0
  59. package/dist/chunks/chunk-PNGVSHR3.js +40 -0
  60. package/dist/chunks/chunk-PP5GKSIX.js +137 -0
  61. package/dist/chunks/chunk-QB2UHSUB.js +58 -0
  62. package/dist/chunks/chunk-QIUK4Z7Q.js +79 -0
  63. package/dist/chunks/chunk-RN6V5ODW.js +114 -0
  64. package/dist/chunks/chunk-RNK3LXLR.js +1288 -0
  65. package/dist/chunks/chunk-RVBZ64EQ.js +52 -0
  66. package/dist/chunks/{chunk-WA2SJE5S.js → chunk-SWO66HE2.js} +4 -4
  67. package/dist/chunks/{chunk-NBW3BWOJ.js → chunk-TDGK45FB.js} +2 -2
  68. package/dist/chunks/{chunk-WNAKOXGK.js → chunk-TO7QZGYK.js} +1 -1
  69. package/dist/chunks/{chunk-QDV5LZ4Q.js → chunk-UA55I7M6.js} +12 -8
  70. package/dist/chunks/{chunk-FWKSJYDV.js → chunk-UG2WOB5L.js} +1 -1
  71. package/dist/chunks/chunk-UJPVHLL5.js +233 -0
  72. package/dist/chunks/chunk-V4RMJKQP.js +36 -0
  73. package/dist/chunks/chunk-VJSREJVM.js +875 -0
  74. package/dist/chunks/chunk-VUS2JQB2.js +121 -0
  75. package/dist/chunks/{chunk-4KVJ2M4J.js → chunk-WPBCUXMZ.js} +582 -37
  76. package/dist/chunks/chunk-WSZ5E4WH.js +92 -0
  77. package/dist/chunks/{chunk-Q5K5DEOK.js → chunk-WT2Y7FRD.js} +42 -28
  78. package/dist/chunks/chunk-WT6C2ALC.js +18188 -0
  79. package/dist/chunks/chunk-X6TGUHFD.js +59 -0
  80. package/dist/chunks/{chunk-ZSFEACZU.js → chunk-XFF5TGRA.js} +1 -1
  81. package/dist/chunks/chunk-XNIZGCN5.js +58 -0
  82. package/dist/chunks/chunk-XPJLPUKO.js +117 -0
  83. package/dist/chunks/{chunk-FXD67VN5.js → chunk-XUAWTW4W.js} +1 -1
  84. package/dist/chunks/chunk-YPMFZRTN.js +417 -0
  85. package/dist/chunks/chunk-YRESLJCW.js +1536 -0
  86. package/dist/chunks/{chunk-I526H4AS.js → chunk-YS76T533.js} +2 -2
  87. package/dist/chunks/{chunk-52QYYTM5.js → chunk-ZDU2NODC.js} +3 -127
  88. package/dist/chunks/chunk-ZW6HETRE.js +97 -0
  89. package/dist/chunks/{clear-IYGWCNXT.js → clear-GQTDYSKJ.js} +23 -18
  90. package/dist/chunks/{compile-vercel-config-NEEBZRUJ.js → compile-vercel-config-URVMKDVW.js} +8 -11
  91. package/dist/chunks/{config-6DS6BBR2.js → config-MSVQR5T6.js} +23 -18
  92. package/dist/chunks/{config-NTB5EMV4.js → config-OAXY4J6P.js} +23 -18
  93. package/dist/chunks/config-validator.mjs +1 -1
  94. package/dist/chunks/{delete-LSGID5FV.js → delete-57QO64HD.js} +19 -14
  95. package/dist/chunks/{delete-LLC2OGHA.js → delete-XN6ESD7C.js} +16 -12
  96. package/dist/chunks/detect-projects-ODNU4PK2.js +18 -0
  97. package/dist/chunks/detect-services-UPY4LTBZ.js +40 -0
  98. package/dist/chunks/{disable-H4EXEQK7.js → disable-BYI46V7B.js} +17 -13
  99. package/dist/chunks/{discard-FG6VKHWN.js → discard-IIQL44ZZ.js} +17 -13
  100. package/dist/chunks/{edit-BZJSGUHT.js → edit-BRNS3OR4.js} +19 -15
  101. package/dist/chunks/{edit-YE7D3CPJ.js → edit-JTW7XZH7.js} +17 -13
  102. package/dist/chunks/{enable-6ESD4QTE.js → enable-CH5FSQMR.js} +17 -13
  103. package/dist/chunks/{exec-XH4K34JM.js → exec-4IPHZ55G.js} +9 -5
  104. package/dist/chunks/{export-QWSJROLG.js → export-6WHQOWKM.js} +16 -13
  105. package/dist/chunks/{image-LTHQMKFG.js → image-ZSLYATWG.js} +11 -8
  106. package/dist/chunks/{import-builders-6O7ILGQJ.js → import-builders-FNMYJZGG.js} +18 -13
  107. package/dist/chunks/{inspect-2C4ZSNYC.js → inspect-4RDZSYWU.js} +27 -23
  108. package/dist/chunks/{inspect-N6SMHV3Z.js → inspect-7WQXZWET.js} +18 -14
  109. package/dist/chunks/{inspect-F7KCTHIL.js → inspect-CGXTNMMO.js} +19 -15
  110. package/dist/chunks/{inspect-ICKNCDMT.js → inspect-XJ7BYLZ5.js} +18 -14
  111. package/dist/chunks/{inspect-TWDPMXZ5.js → inspect-Z2MBTTB7.js} +18 -14
  112. package/dist/chunks/{list-NWTIJF3L.js → list-65LW6OTM.js} +20 -16
  113. package/dist/chunks/{list-DS7ZOUXA.js → list-7W3PHRB6.js} +25 -21
  114. package/dist/chunks/{list-IPGQVBJO.js → list-KS22Y57L.js} +16 -14
  115. package/dist/chunks/{login-F7A7ONKC.js → login-NXULVQZ2.js} +23 -18
  116. package/dist/chunks/{ls-2QW3ZSM6.js → ls-35EOVEIQ.js} +24 -18
  117. package/dist/chunks/{ls-XINES6PL.js → ls-5GKS5QRW.js} +24 -18
  118. package/dist/chunks/ls-ADYFYYIW.js +204 -0
  119. package/dist/chunks/{ls-D4TUDBIH.js → ls-DZYN3SNS.js} +24 -18
  120. package/dist/chunks/{ls-LSJEUPFX.js → ls-HVQOGBGV.js} +23 -16
  121. package/dist/chunks/{ls-NBDX3MKN.js → ls-I2PWG7YN.js} +24 -18
  122. package/dist/chunks/{open-VRQDWZAW.js → open-H34HXJHP.js} +18 -13
  123. package/dist/chunks/{permissions-6C5C7TEV.js → permissions-ZPPEPKVE.js} +14 -11
  124. package/dist/chunks/{publish-GVIZPNLN.js → publish-NRMKXHAU.js} +17 -13
  125. package/dist/chunks/pull-WUT3XTZX.js +45 -0
  126. package/dist/chunks/{push-EFZ5P5Z6.js → push-WFNCEA5J.js} +23 -18
  127. package/dist/chunks/{query-GBS2PIT4.js → query-2FQM3F7N.js} +23 -20
  128. package/dist/chunks/{reorder-TN65IFRL.js → reorder-GYCT7L3C.js} +17 -13
  129. package/dist/chunks/{reply-DYVEV3PY.js → reply-RFEXNYZ7.js} +17 -13
  130. package/dist/chunks/{resolve-JAWFBPUM.js → resolve-ZFGT7W6Z.js} +16 -12
  131. package/dist/chunks/resolve-deployment-framework-preset-NPE6RLV3.js +36 -0
  132. package/dist/chunks/{restore-TJVMHUBQ.js → restore-JAXPMYL5.js} +17 -13
  133. package/dist/chunks/rm-CLKQN5E4.js +162 -0
  134. package/dist/chunks/{rm-HQ5CYNJA.js → rm-JPV5V2SH.js} +23 -18
  135. package/dist/chunks/{rm-7XACNZ2U.js → rm-N7SGFQOA.js} +23 -18
  136. package/dist/chunks/{rm-REJVXALW.js → rm-UQJ4CZJH.js} +23 -18
  137. package/dist/chunks/{rm-CBPNMSRP.js → rm-ZUQ4U454.js} +24 -17
  138. package/dist/chunks/{routes-2OLIBRYX.js → routes-QVMBXOSX.js} +7 -3
  139. package/dist/chunks/rule-inspect-HI3YY7OY.js +123 -0
  140. package/dist/chunks/{rules-VGV4M4KY.js → rules-DA3Q64M4.js} +15 -12
  141. package/dist/chunks/{schema-GMTQOQCV.js → schema-R3C4CXJ6.js} +20 -18
  142. package/dist/chunks/schema-UYYFV3JB.js +381 -0
  143. package/dist/chunks/{set-Z5FO2FCC.js → set-TOJPGW4J.js} +21 -14
  144. package/dist/chunks/setup-and-link-DRYXQOH4.js +65 -0
  145. package/dist/chunks/{tags-SDRXWJ63.js → tags-TNLVFNVI.js} +10 -7
  146. package/dist/chunks/{types-JGANJ5EQ.js → types-4GAJ7XQQ.js} +9 -7
  147. package/dist/chunks/update-X6JB3NPI.js +224 -0
  148. package/dist/chunks/vlt-builder-importer-USCFHWPL.js +322 -0
  149. package/dist/commands/build/index.js +86 -49
  150. package/dist/commands/deploy/index.js +76 -67
  151. package/dist/commands/dev/index.js +98 -52
  152. package/dist/commands/env/index.js +68 -44
  153. package/dist/commands/link/index.js +49 -28
  154. package/dist/commands/list/index.js +33 -22
  155. package/dist/commands-bulk.js +8715 -3581
  156. package/dist/help.js +1 -1
  157. package/dist/index.js +74 -42
  158. package/dist/runtime-assets/node-preloads/next-dev-websocket.cjs +6 -0
  159. package/dist/version.mjs +1 -1
  160. package/package.json +52 -48
  161. package/dist/chunks/add-RBW7QITR.js +0 -219
  162. package/dist/chunks/chunk-26XDDLXM.js +0 -144
  163. package/dist/chunks/chunk-5GGUB4EO.js +0 -31
  164. package/dist/chunks/chunk-MXLA3VQS.js +0 -20
  165. package/dist/chunks/chunk-OTXE7MHI.js +0 -96
  166. package/dist/chunks/chunk-RSEAADCE.js +0 -138
  167. package/dist/chunks/chunk-WYU64FLP.js +0 -62123
  168. package/dist/chunks/chunk-XNFHNTS2.js +0 -2939
  169. package/dist/chunks/ls-RNGO257R.js +0 -193
  170. package/dist/chunks/rm-5B5VHWWN.js +0 -170
  171. package/dist/chunks/rule-inspect-ZSTDDFID.js +0 -281
  172. package/dist/chunks/schema-45SJNY5L.js +0 -427
  173. package/dist/chunks/update-JBQBC3IV.js +0 -233
@@ -0,0 +1,522 @@
1
+ import { createRequire as __createRequire } from 'node:module';
2
+ import { fileURLToPath as __fileURLToPath } from 'node:url';
3
+ import { dirname as __dirname_ } from 'node:path';
4
+ const require = __createRequire(import.meta.url);
5
+ const __filename = __fileURLToPath(import.meta.url);
6
+ const __dirname = __dirname_(__filename);
7
+ import {
8
+ fetch
9
+ } from "./chunk-XNIZGCN5.js";
10
+ import {
11
+ findProjectsFromPath,
12
+ getLinkFromDir,
13
+ getRepoLink,
14
+ getTeamByIdOrSlug,
15
+ getUser,
16
+ getVercelDirectory
17
+ } from "./chunk-MADFAH3O.js";
18
+ import {
19
+ InvalidToken,
20
+ TeamDeleted
21
+ } from "./chunk-CV5YC2EN.js";
22
+ import {
23
+ output_manager_default
24
+ } from "./chunk-2JIX6UMI.js";
25
+ import {
26
+ pkg_default
27
+ } from "./chunk-P4QNYOFB.js";
28
+
29
+ // src/util/ua.ts
30
+ import os from "os";
31
+ var ua_default = `${pkg_default.name} ${pkg_default.version} node-${process.version} ${os.platform()} (${os.arch()})`;
32
+
33
+ // src/util/oauth.ts
34
+ import { hostname } from "os";
35
+ var VERCEL_ISSUER = new URL("https://vercel.com");
36
+ var VERCEL_CLI_CLIENT_ID = "cl_HYyOPBNtFMfHhaUn9L4QPfTZz6TP47bp";
37
+ var userAgent = `${hostname()} @ ${ua_default}`;
38
+ var _as;
39
+ async function as() {
40
+ if (!_as) {
41
+ const discoveryResponse = await discoveryEndpointRequest(VERCEL_ISSUER);
42
+ const [discoveryResponseError, as2] = await processDiscoveryEndpointResponse(discoveryResponse);
43
+ if (discoveryResponseError) {
44
+ throw discoveryResponseError;
45
+ }
46
+ _as = as2;
47
+ }
48
+ return _as;
49
+ }
50
+ async function discoveryEndpointRequest(issuer) {
51
+ return await fetch(new URL(".well-known/openid-configuration", issuer), {
52
+ headers: { "Content-Type": "application/json", "user-agent": userAgent }
53
+ });
54
+ }
55
+ async function processDiscoveryEndpointResponse(response) {
56
+ const json = await response.json();
57
+ if (!response.ok) {
58
+ return [new Error("Discovery endpoint request failed")];
59
+ }
60
+ if (typeof json !== "object" || json === null || !canParseURL(json.issuer) || !canParseURL(json.device_authorization_endpoint) || !canParseURL(json.token_endpoint) || !canParseURL(json.revocation_endpoint) || !canParseURL(json.jwks_uri) || !canParseURL(json.introspection_endpoint)) {
61
+ return [new TypeError("Invalid discovery response")];
62
+ }
63
+ const issuer = new URL(json.issuer);
64
+ if (issuer.href !== VERCEL_ISSUER.href) {
65
+ return [new Error("Issuer mismatch")];
66
+ }
67
+ return [
68
+ null,
69
+ {
70
+ issuer,
71
+ device_authorization_endpoint: new URL(
72
+ json.device_authorization_endpoint
73
+ ),
74
+ token_endpoint: new URL(json.token_endpoint),
75
+ revocation_endpoint: new URL(json.revocation_endpoint),
76
+ jwks_uri: new URL(json.jwks_uri),
77
+ introspection_endpoint: new URL(json.introspection_endpoint)
78
+ }
79
+ ];
80
+ }
81
+ async function deviceAuthorizationRequest(options) {
82
+ const body = new URLSearchParams({
83
+ client_id: VERCEL_CLI_CLIENT_ID
84
+ });
85
+ if (options?.refresh_token) {
86
+ body.set("refresh_token", options.refresh_token);
87
+ if (options.acr_values) {
88
+ body.set("acr_values", options.acr_values);
89
+ }
90
+ } else {
91
+ body.set("scope", "openid offline_access");
92
+ }
93
+ return await fetch((await as()).device_authorization_endpoint, {
94
+ method: "POST",
95
+ headers: {
96
+ "Content-Type": "application/x-www-form-urlencoded",
97
+ "user-agent": userAgent
98
+ },
99
+ body
100
+ });
101
+ }
102
+ async function processDeviceAuthorizationResponse(response) {
103
+ const json = await response.json();
104
+ if (!response.ok) {
105
+ return [new OAuthError("Device authorization request failed", json)];
106
+ }
107
+ if (typeof json !== "object" || json === null)
108
+ return [new TypeError("Expected response to be an object")];
109
+ if (!("device_code" in json) || typeof json.device_code !== "string")
110
+ return [new TypeError("Expected `device_code` to be a string")];
111
+ if (!("user_code" in json) || typeof json.user_code !== "string")
112
+ return [new TypeError("Expected `user_code` to be a string")];
113
+ if (!("verification_uri" in json) || typeof json.verification_uri !== "string" || !canParseURL(json.verification_uri)) {
114
+ return [new TypeError("Expected `verification_uri` to be a string")];
115
+ }
116
+ if (!("verification_uri_complete" in json) || typeof json.verification_uri_complete !== "string" || !canParseURL(json.verification_uri_complete)) {
117
+ return [
118
+ new TypeError("Expected `verification_uri_complete` to be a string")
119
+ ];
120
+ }
121
+ if (!("expires_in" in json) || typeof json.expires_in !== "number")
122
+ return [new TypeError("Expected `expires_in` to be a number")];
123
+ if (!("interval" in json) || typeof json.interval !== "number")
124
+ return [new TypeError("Expected `interval` to be a number")];
125
+ return [
126
+ null,
127
+ {
128
+ device_code: json.device_code,
129
+ user_code: json.user_code,
130
+ verification_uri: json.verification_uri,
131
+ verification_uri_complete: json.verification_uri_complete,
132
+ expiresAt: Date.now() + json.expires_in * 1e3,
133
+ interval: json.interval
134
+ }
135
+ ];
136
+ }
137
+ async function deviceAccessTokenRequest(options) {
138
+ try {
139
+ return [
140
+ null,
141
+ await fetch((await as()).token_endpoint, {
142
+ method: "POST",
143
+ headers: {
144
+ "Content-Type": "application/x-www-form-urlencoded",
145
+ "user-agent": userAgent
146
+ },
147
+ body: new URLSearchParams({
148
+ client_id: VERCEL_CLI_CLIENT_ID,
149
+ grant_type: "urn:ietf:params:oauth:grant-type:device_code",
150
+ ...options
151
+ }),
152
+ signal: AbortSignal.timeout(10 * 1e3)
153
+ })
154
+ ];
155
+ } catch (error) {
156
+ if (error instanceof Error)
157
+ return [error];
158
+ return [
159
+ new Error("An unknown error occurred. See the logs for details.", {
160
+ cause: error
161
+ })
162
+ ];
163
+ }
164
+ }
165
+ async function processTokenResponse(response) {
166
+ const json = await response.json();
167
+ if (!response.ok) {
168
+ return [new OAuthError("Device access token request failed", json)];
169
+ }
170
+ if (typeof json !== "object" || json === null)
171
+ return [new TypeError("Expected response to be an object")];
172
+ if (!("access_token" in json) || typeof json.access_token !== "string")
173
+ return [new TypeError("Expected `access_token` to be a string")];
174
+ if (!("token_type" in json) || json.token_type !== "Bearer")
175
+ return [new TypeError('Expected `token_type` to be "Bearer"')];
176
+ if (!("expires_in" in json) || typeof json.expires_in !== "number")
177
+ return [new TypeError("Expected `expires_in` to be a number")];
178
+ if ("refresh_token" in json && (typeof json.refresh_token !== "string" || !json.refresh_token))
179
+ return [new TypeError("Expected `refresh_token` to be a string")];
180
+ if ("scope" in json && typeof json.scope !== "string")
181
+ return [new TypeError("Expected `scope` to be a string")];
182
+ return [null, json];
183
+ }
184
+ async function revocationRequest(options) {
185
+ return await fetch((await as()).revocation_endpoint, {
186
+ method: "POST",
187
+ headers: {
188
+ "Content-Type": "application/x-www-form-urlencoded",
189
+ "user-agent": userAgent
190
+ },
191
+ body: new URLSearchParams({ ...options, client_id: VERCEL_CLI_CLIENT_ID })
192
+ });
193
+ }
194
+ async function processRevocationResponse(response) {
195
+ if (response.ok)
196
+ return [null, null];
197
+ const json = await response.json();
198
+ return [new OAuthError("Revocation request failed", json)];
199
+ }
200
+ async function refreshTokenRequest(options) {
201
+ return await fetch((await as()).token_endpoint, {
202
+ method: "POST",
203
+ headers: {
204
+ "Content-Type": "application/x-www-form-urlencoded",
205
+ "user-agent": userAgent
206
+ },
207
+ body: new URLSearchParams({
208
+ client_id: VERCEL_CLI_CLIENT_ID,
209
+ grant_type: "refresh_token",
210
+ ...options
211
+ })
212
+ });
213
+ }
214
+ function processOAuthErrorResponse(json) {
215
+ if (typeof json !== "object" || json === null)
216
+ return new TypeError("Expected response to be an object");
217
+ if (!("error" in json) || typeof json.error !== "string")
218
+ return new TypeError("Expected `error` to be a string");
219
+ if ("error_description" in json && typeof json.error_description !== "string")
220
+ return new TypeError("Expected `error_description` to be a string");
221
+ if ("error_uri" in json && typeof json.error_uri !== "string")
222
+ return new TypeError("Expected `error_uri` to be a string");
223
+ return json;
224
+ }
225
+ var OAuthError = class extends Error {
226
+ constructor(message, response) {
227
+ var __super = (...args) => {
228
+ super(...args);
229
+ };
230
+ const error = processOAuthErrorResponse(response);
231
+ if (error instanceof TypeError) {
232
+ const message2 = `Unexpected server response: ${JSON.stringify(response)}`;
233
+ __super(message2);
234
+ this.cause = new Error(message2, { cause: error });
235
+ this.code = "server_error";
236
+ return;
237
+ }
238
+ let cause = error.error;
239
+ if (error.error_description)
240
+ cause += `: ${error.error_description}`;
241
+ if (error.error_uri)
242
+ cause += ` (${error.error_uri})`;
243
+ __super(message, { cause });
244
+ this.cause = new Error(cause);
245
+ this.code = error.error;
246
+ }
247
+ };
248
+ function isOAuthError(error) {
249
+ return error instanceof OAuthError;
250
+ }
251
+ function canParseURL(url) {
252
+ try {
253
+ return !!new URL(url);
254
+ } catch {
255
+ return false;
256
+ }
257
+ }
258
+ async function inspectTokenRequest(token) {
259
+ return fetch((await as()).introspection_endpoint, {
260
+ method: "POST",
261
+ headers: {
262
+ "Content-Type": "application/x-www-form-urlencoded",
263
+ "user-agent": userAgent
264
+ },
265
+ body: new URLSearchParams({ token })
266
+ });
267
+ }
268
+ async function processInspectTokenResponse(response) {
269
+ try {
270
+ const token = await response.json();
271
+ if (!token || typeof token !== "object" || !("active" in token)) {
272
+ throw new IntrospectionError("Invalid token introspection response");
273
+ }
274
+ return [null, token];
275
+ } catch (cause) {
276
+ return [new IntrospectionError("Could not introspect token.", { cause })];
277
+ }
278
+ }
279
+ var IntrospectionError = class extends Error {
280
+ constructor() {
281
+ super(...arguments);
282
+ this.name = "IntrospectionError";
283
+ }
284
+ };
285
+
286
+ // src/util/introspect-token.ts
287
+ var VERCEL_API_ORIGIN = "https://api.vercel.com";
288
+ async function introspectToken(client) {
289
+ const token = client.authConfig.token;
290
+ if (!token) {
291
+ throw new Error("No token to introspect");
292
+ }
293
+ if (new URL(client.apiUrl).origin !== VERCEL_API_ORIGIN) {
294
+ throw new Error(
295
+ "Token introspection is unavailable for custom API origins"
296
+ );
297
+ }
298
+ const [error, introspection] = await processInspectTokenResponse(
299
+ await inspectTokenRequest(token)
300
+ );
301
+ if (error) {
302
+ throw error;
303
+ }
304
+ return introspection;
305
+ }
306
+
307
+ // src/util/app.ts
308
+ function isAppPrincipalEnabled() {
309
+ return !!process.env["APP_PRINCIPAL_ENABLED"];
310
+ }
311
+ function resolveAppFromToken(token) {
312
+ if (!token.active || !token.client_id) {
313
+ return null;
314
+ }
315
+ return {
316
+ id: token.client_id,
317
+ name: token.client_name
318
+ };
319
+ }
320
+ async function resolveAppTokenScope(client, scope) {
321
+ const token = await introspectToken(client).catch(() => null);
322
+ const app = token ? resolveAppFromToken(token) : null;
323
+ const team = token?.team;
324
+ if (!app || !team) {
325
+ return false;
326
+ }
327
+ if (team.id !== scope && team.slug !== scope) {
328
+ return false;
329
+ }
330
+ client.config.currentTeam = team.id;
331
+ return true;
332
+ }
333
+
334
+ // src/util/get-scope.ts
335
+ import { relative } from "path";
336
+ async function getScope(client, opts = {}) {
337
+ const { user, app, token } = await getPrincipal(client);
338
+ const defaultTeamId = user?.version === "northstar" ? user.defaultTeamId : void 0;
339
+ const appTeamId = !user && app ? token?.team?.id : void 0;
340
+ if (!user && app && opts.getTeam === false) {
341
+ throw new Error(`App principal scope resolution requires a team lookup.`);
342
+ }
343
+ if (!user && app) {
344
+ client.config.currentTeam = appTeamId;
345
+ }
346
+ if (!client.config.currentTeam && defaultTeamId) {
347
+ client.config.currentTeam = defaultTeamId;
348
+ }
349
+ const teamId = client.config.currentTeam || defaultTeamId;
350
+ const team = teamId && opts.getTeam !== false ? await getTeam(client, teamId) : null;
351
+ const contextName = team?.slug || user?.username || user?.email;
352
+ if (!contextName) {
353
+ throw new Error(`Unable to determine context name`);
354
+ }
355
+ if (!opts.resolveLocalScope) {
356
+ return { contextName, team, user, app };
357
+ }
358
+ return resolveLocalScopeContext(client, { user, app, team });
359
+ }
360
+ async function getPrincipal(client) {
361
+ if (!isAppPrincipalEnabled()) {
362
+ return { user: await getUser(client), app: null, token: null };
363
+ }
364
+ const [userResult, tokenResult] = await Promise.allSettled([
365
+ getUser(client),
366
+ introspectToken(client)
367
+ ]);
368
+ const token = tokenResult.status === "fulfilled" ? tokenResult.value : null;
369
+ const app = token ? resolveAppFromToken(token) : null;
370
+ if (userResult.status === "rejected") {
371
+ const isAppToken = app && userResult.reason instanceof InvalidToken;
372
+ if (!isAppToken) {
373
+ throw userResult.reason;
374
+ }
375
+ }
376
+ const user = userResult.status === "fulfilled" ? userResult.value : null;
377
+ return { user, app, token };
378
+ }
379
+ async function resolveLocalScopeContext(client, { user, app, team }) {
380
+ const explicitScopeProvided = detectExplicitScope(client);
381
+ const globalTeamId = client.config.currentTeam;
382
+ const { localOrgId, linkedRepo, isCrossTeamRepo } = await findLocalLink(client);
383
+ const isAppPrincipal = !user && Boolean(app);
384
+ const effectiveLocalOrgId = isAppPrincipal ? void 0 : localOrgId;
385
+ const scopeMismatch = Boolean(
386
+ effectiveLocalOrgId && globalTeamId && globalTeamId !== effectiveLocalOrgId
387
+ );
388
+ if (!isAppPrincipal && !explicitScopeProvided && !effectiveLocalOrgId && isCrossTeamRepo) {
389
+ output_manager_default.warn(
390
+ `This repository has projects across multiple teams. Use \`--scope\` to specify which team, or \`cd\` into a project directory.`
391
+ );
392
+ }
393
+ const resolvedTeam = !explicitScopeProvided && effectiveLocalOrgId ? await applyLocalOrg(client, effectiveLocalOrgId) : team;
394
+ const { org, contextName } = resolveOrg(resolvedTeam, user);
395
+ return {
396
+ org,
397
+ contextName,
398
+ user,
399
+ team: resolvedTeam,
400
+ app,
401
+ globalTeam: team,
402
+ linkedRepo,
403
+ isCrossTeamRepo,
404
+ scopeMismatch,
405
+ explicitScopeProvided
406
+ };
407
+ }
408
+ async function applyLocalOrg(client, localOrgId) {
409
+ client.config.currentTeam = localOrgId.startsWith("team_") ? localOrgId : void 0;
410
+ return client.config.currentTeam ? await getTeamByIdOrSlug(client, client.config.currentTeam) : null;
411
+ }
412
+ async function getTeam(client, teamId) {
413
+ const team = await getTeamByIdOrSlug(client, teamId);
414
+ if (!team) {
415
+ throw new TeamDeleted();
416
+ }
417
+ return team;
418
+ }
419
+ function resolveOrg(team, user) {
420
+ if (team) {
421
+ return {
422
+ org: { type: "team", id: team.id, slug: team.slug },
423
+ contextName: team.slug
424
+ };
425
+ }
426
+ if (user) {
427
+ return {
428
+ org: { type: "user", id: user.id, slug: user.username },
429
+ contextName: user.username || user.email
430
+ };
431
+ }
432
+ throw new Error(
433
+ `Unable to determine scope: no team or personal account is available for this token. Use \`--scope\` to specify a team.`
434
+ );
435
+ }
436
+ async function findLocalLink(client) {
437
+ const [projectLink, repoLink] = await Promise.all([
438
+ findProjectLink(client),
439
+ findRepoLink(client)
440
+ ]);
441
+ return {
442
+ localOrgId: findLocalOrgId(client.cwd, projectLink, repoLink),
443
+ linkedRepo: repoLink?.repoConfig ? { repoConfig: repoLink.repoConfig, rootPath: repoLink.rootPath } : null,
444
+ isCrossTeamRepo: detectCrossTeamRepo(repoLink?.repoConfig)
445
+ };
446
+ }
447
+ async function findProjectLink(client) {
448
+ try {
449
+ return await getLinkFromDir(getVercelDirectory(client.cwd));
450
+ } catch (_error) {
451
+ return null;
452
+ }
453
+ }
454
+ async function findRepoLink(client) {
455
+ try {
456
+ return await getRepoLink(client, client.cwd);
457
+ } catch (_error) {
458
+ return null;
459
+ }
460
+ }
461
+ function findLocalOrgId(cwd, projectLink, repoLink) {
462
+ if (projectLink) {
463
+ return projectLink.orgId;
464
+ }
465
+ if (repoLink?.repoConfig) {
466
+ return findRepoOrgId(repoLink.repoConfig, relative(repoLink.rootPath, cwd));
467
+ }
468
+ return void 0;
469
+ }
470
+ function findRepoOrgId(repoConfig, pathFromRepoRoot) {
471
+ const projects = findProjectsFromPath(repoConfig.projects, pathFromRepoRoot);
472
+ const orgIds = new Set(projects.map((p) => p.orgId ?? repoConfig.orgId ?? ""));
473
+ if (orgIds.size !== 1) {
474
+ return void 0;
475
+ }
476
+ const [orgId] = orgIds;
477
+ return orgId || void 0;
478
+ }
479
+ function detectExplicitScope(client) {
480
+ const argv = client.argv;
481
+ for (const arg of argv) {
482
+ if (arg === "--") {
483
+ break;
484
+ }
485
+ if (arg === "--scope" || arg === "--team" || arg.startsWith("--scope=") || arg.startsWith("--team=") || arg === "-S" || arg === "-T") {
486
+ return true;
487
+ }
488
+ }
489
+ if (client.localConfig?.scope) {
490
+ return true;
491
+ }
492
+ return false;
493
+ }
494
+ function detectCrossTeamRepo(repoConfig) {
495
+ if (!repoConfig?.projects || repoConfig.projects.length < 2) {
496
+ return false;
497
+ }
498
+ const orgIds = /* @__PURE__ */ new Set();
499
+ for (const project of repoConfig.projects) {
500
+ const orgId = project.orgId ?? repoConfig.orgId;
501
+ if (orgId) {
502
+ orgIds.add(orgId);
503
+ }
504
+ }
505
+ return orgIds.size > 1;
506
+ }
507
+
508
+ export {
509
+ ua_default,
510
+ deviceAuthorizationRequest,
511
+ processDeviceAuthorizationResponse,
512
+ deviceAccessTokenRequest,
513
+ processTokenResponse,
514
+ revocationRequest,
515
+ processRevocationResponse,
516
+ refreshTokenRequest,
517
+ isOAuthError,
518
+ isAppPrincipalEnabled,
519
+ resolveAppTokenScope,
520
+ getScope,
521
+ detectExplicitScope
522
+ };
@@ -6,7 +6,7 @@ const __filename = __fileURLToPath(import.meta.url);
6
6
  const __dirname = __dirname_(__filename);
7
7
  import {
8
8
  output_manager_default
9
- } from "./chunk-QFAS4OVW.js";
9
+ } from "./chunk-2JIX6UMI.js";
10
10
  import {
11
11
  require_source
12
12
  } from "./chunk-S7KYDPEM.js";