vercel 59.11.2 → 59.11.7

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 (154) hide show
  1. package/dist/chunks/{add-BKSHWTPX.js → add-KSJQYR5C.js} +23 -18
  2. package/dist/chunks/{add-RBW7QITR.js → add-PERLOALD.js} +37 -23
  3. package/dist/chunks/{add-HPLJZFM2.js → add-WU2QYHYL.js} +23 -18
  4. package/dist/chunks/{build-V4ZLAJWB.js → build-F3J6FLPD.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-2TSBB22D.js +14059 -0
  8. package/dist/chunks/chunk-332LMJLZ.js +16014 -0
  9. package/dist/chunks/{chunk-AYLY3ZVL.js → chunk-3VM7HWF6.js} +2 -2
  10. package/dist/chunks/chunk-4IALDGB7.js +22 -0
  11. package/dist/chunks/chunk-4IVSM24H.js +522 -0
  12. package/dist/chunks/{chunk-5XECIWME.js → chunk-5NF5HOBJ.js} +5 -3
  13. package/dist/chunks/chunk-6E6KPBXY.js +43 -0
  14. package/dist/chunks/chunk-7KROIXQM.js +59 -0
  15. package/dist/chunks/{chunk-ASBP32T6.js → chunk-7MRDIPJY.js} +1 -1
  16. package/dist/chunks/chunk-A5JZS6ZN.js +92 -0
  17. package/dist/chunks/{chunk-7ST552E3.js → chunk-AKLTIZCU.js} +1 -1
  18. package/dist/chunks/{chunk-26XDDLXM.js → chunk-ARU7VBKR.js} +2 -2
  19. package/dist/chunks/chunk-B5XLQKHI.js +849 -0
  20. package/dist/chunks/chunk-C762AAVU.js +137 -0
  21. package/dist/chunks/{chunk-WA2SJE5S.js → chunk-CEDN47PH.js} +4 -4
  22. package/dist/chunks/{chunk-ONRLTUP2.js → chunk-CNDPIHY5.js} +24 -22
  23. package/dist/chunks/{chunk-BMKU5KEL.js → chunk-CV5YC2EN.js} +1 -1
  24. package/dist/chunks/chunk-DBYHS3CK.js +257 -0
  25. package/dist/chunks/{chunk-HDBQPBL6.js → chunk-DSTNNQVV.js} +12 -8
  26. package/dist/chunks/{chunk-QAT3CW4G.js → chunk-EFYMIIER.js} +2 -2
  27. package/dist/chunks/{chunk-NBW3BWOJ.js → chunk-EPOLDWRA.js} +2 -2
  28. package/dist/chunks/{chunk-B4TXCKXE.js → chunk-EZQDYIVB.js} +10 -8
  29. package/dist/chunks/{chunk-2EAIC3SH.js → chunk-FL4JLNT2.js} +8 -8
  30. package/dist/chunks/chunk-FRVG4OW3.js +7438 -0
  31. package/dist/chunks/{chunk-FKDO3CM4.js → chunk-FVNJTRCE.js} +17 -13
  32. package/dist/chunks/chunk-FVT74RZ5.js +1536 -0
  33. package/dist/chunks/chunk-G3PXSXIB.js +18188 -0
  34. package/dist/chunks/chunk-G5FBSUL4.js +822 -0
  35. package/dist/chunks/{chunk-FRAXI2WT.js → chunk-GCVXKRR5.js} +3 -3
  36. package/dist/chunks/chunk-GHKJAK5V.js +1288 -0
  37. package/dist/chunks/{chunk-Q5K5DEOK.js → chunk-GUU4Z2AQ.js} +42 -28
  38. package/dist/chunks/{chunk-OQ3C5VXZ.js → chunk-GVNCVKCI.js} +4 -2
  39. package/dist/chunks/chunk-HB4UKFDO.js +1295 -0
  40. package/dist/chunks/chunk-HRXRELD3.js +338 -0
  41. package/dist/chunks/{chunk-IJ4X426J.js → chunk-IIMSID24.js} +1 -1
  42. package/dist/chunks/{chunk-O75LSD3C.js → chunk-JSD4EZL3.js} +1 -1
  43. package/dist/chunks/{chunk-7AEEQOD4.js → chunk-K3RED3VO.js} +1 -1
  44. package/dist/chunks/{chunk-RSEAADCE.js → chunk-KEKR7OCB.js} +6 -4
  45. package/dist/chunks/{chunk-3T7WSWZH.js → chunk-KFWQ3EFH.js} +1 -1
  46. package/dist/chunks/{chunk-L3UXB2CW.js → chunk-KW7BS25T.js} +1 -1
  47. package/dist/chunks/{chunk-RO44KX6Y.js → chunk-N4QHMXOO.js} +11 -7
  48. package/dist/chunks/{chunk-XRWOTCDO.js → chunk-ND5CF2H3.js} +1 -1
  49. package/dist/chunks/{chunk-RSJBU3ON.js → chunk-NSOYO6JQ.js} +35 -27
  50. package/dist/chunks/{chunk-RKDCNQ4S.js → chunk-NW34PW6V.js} +3 -105
  51. package/dist/chunks/{chunk-C5HKWXRR.js → chunk-OAMU5QO6.js} +1 -1
  52. package/dist/chunks/{chunk-MTWHQEXI.js → chunk-OIH6FP5Y.js} +5 -3
  53. package/dist/chunks/chunk-P7VSBDR4.js +827 -0
  54. package/dist/chunks/chunk-PEC3CQSK.js +90 -0
  55. package/dist/chunks/{chunk-QDV5LZ4Q.js → chunk-PFM75KY3.js} +12 -8
  56. package/dist/chunks/chunk-PJXMXMCO.js +81 -0
  57. package/dist/chunks/chunk-PNGVSHR3.js +40 -0
  58. package/dist/chunks/{chunk-TPATD2MM.js → chunk-QHS645AZ.js} +14 -6
  59. package/dist/chunks/{chunk-OTXE7MHI.js → chunk-QKX7WKIN.js} +8 -6
  60. package/dist/chunks/chunk-QOPTXV4G.js +417 -0
  61. package/dist/chunks/chunk-RN6V5ODW.js +114 -0
  62. package/dist/chunks/chunk-RVBZ64EQ.js +52 -0
  63. package/dist/chunks/chunk-SHFNEZVI.js +49 -0
  64. package/dist/chunks/{chunk-OO3OF6MK.js → chunk-TGNEG57M.js} +44 -15
  65. package/dist/chunks/{chunk-WNAKOXGK.js → chunk-TO7QZGYK.js} +1 -1
  66. package/dist/chunks/chunk-UARGTFCT.js +875 -0
  67. package/dist/chunks/{chunk-FWKSJYDV.js → chunk-UG2WOB5L.js} +1 -1
  68. package/dist/chunks/chunk-V4RMJKQP.js +36 -0
  69. package/dist/chunks/chunk-VT3Z7HF6.js +233 -0
  70. package/dist/chunks/chunk-VUS2JQB2.js +121 -0
  71. package/dist/chunks/{chunk-6CZZ3SH3.js → chunk-VYC45Q4Z.js} +2 -2
  72. package/dist/chunks/{chunk-4KVJ2M4J.js → chunk-WL6QYSGD.js} +78 -17
  73. package/dist/chunks/{chunk-FZRBF25Y.js → chunk-X7DBBZQD.js} +4 -4
  74. package/dist/chunks/{chunk-2NJJ2K5S.js → chunk-XD4DCYMX.js} +6 -6
  75. package/dist/chunks/{chunk-ZSFEACZU.js → chunk-XFF5TGRA.js} +1 -1
  76. package/dist/chunks/{chunk-6TBDHUXK.js → chunk-XIFATBH5.js} +21 -15
  77. package/dist/chunks/chunk-XNIZGCN5.js +58 -0
  78. package/dist/chunks/chunk-XPJLPUKO.js +117 -0
  79. package/dist/chunks/{chunk-FXD67VN5.js → chunk-XUAWTW4W.js} +1 -1
  80. package/dist/chunks/{chunk-I526H4AS.js → chunk-YS76T533.js} +2 -2
  81. package/dist/chunks/chunk-Z7JWYFOY.js +58 -0
  82. package/dist/chunks/{chunk-6JPVTPTU.js → chunk-ZBEECGFD.js} +3 -3
  83. package/dist/chunks/{chunk-52QYYTM5.js → chunk-ZDU2NODC.js} +3 -127
  84. package/dist/chunks/chunk-ZW6HETRE.js +97 -0
  85. package/dist/chunks/{clear-IYGWCNXT.js → clear-XUQO4ZTK.js} +23 -18
  86. package/dist/chunks/{compile-vercel-config-NEEBZRUJ.js → compile-vercel-config-D3ARNHTN.js} +8 -11
  87. package/dist/chunks/{config-6DS6BBR2.js → config-37OAE7QJ.js} +22 -17
  88. package/dist/chunks/{config-NTB5EMV4.js → config-MEDLXUVM.js} +23 -18
  89. package/dist/chunks/{delete-LLC2OGHA.js → delete-3N3YZZOF.js} +16 -12
  90. package/dist/chunks/{delete-LSGID5FV.js → delete-VSWDZ2SW.js} +19 -14
  91. package/dist/chunks/detect-projects-ODNU4PK2.js +18 -0
  92. package/dist/chunks/detect-services-TESZCQWG.js +40 -0
  93. package/dist/chunks/{disable-H4EXEQK7.js → disable-A4FLFMC7.js} +17 -13
  94. package/dist/chunks/{discard-FG6VKHWN.js → discard-CHGFULBZ.js} +17 -13
  95. package/dist/chunks/{edit-YE7D3CPJ.js → edit-JZ63AJYQ.js} +17 -13
  96. package/dist/chunks/{edit-BZJSGUHT.js → edit-MHSYAPDR.js} +19 -15
  97. package/dist/chunks/{enable-6ESD4QTE.js → enable-KD46SEC5.js} +17 -13
  98. package/dist/chunks/{exec-XH4K34JM.js → exec-4IPHZ55G.js} +9 -5
  99. package/dist/chunks/{export-QWSJROLG.js → export-42QZLBSN.js} +16 -13
  100. package/dist/chunks/{image-LTHQMKFG.js → image-GP4H73A2.js} +11 -8
  101. package/dist/chunks/{import-builders-6O7ILGQJ.js → import-builders-6TBLMPL2.js} +18 -13
  102. package/dist/chunks/{inspect-2C4ZSNYC.js → inspect-5FMWMY3C.js} +22 -18
  103. package/dist/chunks/{inspect-N6SMHV3Z.js → inspect-MUVK6MMT.js} +18 -14
  104. package/dist/chunks/{inspect-F7KCTHIL.js → inspect-Q3DWW7MC.js} +22 -18
  105. package/dist/chunks/{inspect-TWDPMXZ5.js → inspect-QFXAOUL4.js} +18 -14
  106. package/dist/chunks/{inspect-ICKNCDMT.js → inspect-RNTSYM6O.js} +18 -14
  107. package/dist/chunks/{list-NWTIJF3L.js → list-IHHIPXEC.js} +20 -16
  108. package/dist/chunks/{list-IPGQVBJO.js → list-JRNWLSO5.js} +16 -14
  109. package/dist/chunks/{list-DS7ZOUXA.js → list-XHD5DLEX.js} +23 -19
  110. package/dist/chunks/{login-F7A7ONKC.js → login-PCT6KFWY.js} +23 -18
  111. package/dist/chunks/{ls-NBDX3MKN.js → ls-GPEHEFCF.js} +24 -18
  112. package/dist/chunks/{ls-RNGO257R.js → ls-PF7F4PP4.js} +27 -23
  113. package/dist/chunks/{ls-XINES6PL.js → ls-PQZ2RIDX.js} +24 -18
  114. package/dist/chunks/{ls-D4TUDBIH.js → ls-SVOHC3XW.js} +24 -18
  115. package/dist/chunks/{ls-2QW3ZSM6.js → ls-TGHCCARZ.js} +24 -18
  116. package/dist/chunks/{ls-LSJEUPFX.js → ls-VRIH5WA3.js} +22 -15
  117. package/dist/chunks/{open-VRQDWZAW.js → open-E7DEKYDU.js} +18 -13
  118. package/dist/chunks/{permissions-6C5C7TEV.js → permissions-JKOONWVL.js} +14 -11
  119. package/dist/chunks/{publish-GVIZPNLN.js → publish-EDDELDE5.js} +17 -13
  120. package/dist/chunks/pull-646WEVDE.js +45 -0
  121. package/dist/chunks/{push-EFZ5P5Z6.js → push-LTNW5OVD.js} +23 -18
  122. package/dist/chunks/{query-GBS2PIT4.js → query-LU4N6KPO.js} +22 -19
  123. package/dist/chunks/{reorder-TN65IFRL.js → reorder-22PKJMZP.js} +17 -13
  124. package/dist/chunks/{reply-DYVEV3PY.js → reply-SF2EZMVZ.js} +17 -13
  125. package/dist/chunks/{resolve-JAWFBPUM.js → resolve-ZCZGXTOT.js} +16 -12
  126. package/dist/chunks/resolve-deployment-framework-preset-NPE6RLV3.js +36 -0
  127. package/dist/chunks/{restore-TJVMHUBQ.js → restore-VJAWZXB4.js} +17 -13
  128. package/dist/chunks/{rm-7XACNZ2U.js → rm-KN2QFCKO.js} +23 -18
  129. package/dist/chunks/{rm-REJVXALW.js → rm-KVEAJPRE.js} +23 -18
  130. package/dist/chunks/{rm-CBPNMSRP.js → rm-OSZ5FZUM.js} +23 -16
  131. package/dist/chunks/{rm-5B5VHWWN.js → rm-W722Q2AO.js} +21 -18
  132. package/dist/chunks/{rm-HQ5CYNJA.js → rm-WNPGTUBH.js} +23 -18
  133. package/dist/chunks/{routes-2OLIBRYX.js → routes-QVMBXOSX.js} +7 -3
  134. package/dist/chunks/{rule-inspect-ZSTDDFID.js → rule-inspect-25Z6SNX3.js} +28 -24
  135. package/dist/chunks/{rules-VGV4M4KY.js → rules-65LKAQ35.js} +15 -12
  136. package/dist/chunks/{schema-45SJNY5L.js → schema-7D6IGJEJ.js} +9 -7
  137. package/dist/chunks/{schema-GMTQOQCV.js → schema-NXCW4M75.js} +19 -17
  138. package/dist/chunks/{set-Z5FO2FCC.js → set-FYJVKMPV.js} +20 -13
  139. package/dist/chunks/setup-and-link-KXPZE32P.js +65 -0
  140. package/dist/chunks/{tags-SDRXWJ63.js → tags-ANIRP5E3.js} +10 -7
  141. package/dist/chunks/{types-JGANJ5EQ.js → types-4GAJ7XQQ.js} +9 -7
  142. package/dist/chunks/{update-JBQBC3IV.js → update-UT6CTKVG.js} +32 -19
  143. package/dist/commands/build/index.js +86 -49
  144. package/dist/commands/deploy/index.js +75 -66
  145. package/dist/commands/dev/index.js +98 -52
  146. package/dist/commands/env/index.js +67 -43
  147. package/dist/commands/link/index.js +48 -27
  148. package/dist/commands/list/index.js +33 -22
  149. package/dist/commands-bulk.js +1659 -1287
  150. package/dist/index.js +62 -40
  151. package/dist/version.mjs +1 -1
  152. package/package.json +46 -46
  153. package/dist/chunks/chunk-WYU64FLP.js +0 -62123
  154. package/dist/chunks/chunk-XNFHNTS2.js +0 -2939
@@ -7,13 +7,13 @@ const __dirname = __dirname_(__filename);
7
7
  import {
8
8
  parseRetryAfterHeaderAsMillis,
9
9
  require_bytes
10
- } from "./chunk-BMKU5KEL.js";
10
+ } from "./chunk-CV5YC2EN.js";
11
11
  import {
12
12
  getCommandName
13
13
  } from "./chunk-Q2DGFCO7.js";
14
14
  import {
15
15
  output_manager_default
16
- } from "./chunk-QFAS4OVW.js";
16
+ } from "./chunk-2JIX6UMI.js";
17
17
  import {
18
18
  require_source
19
19
  } from "./chunk-S7KYDPEM.js";
@@ -0,0 +1,22 @@
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
+
8
+ // src/util/native-install.ts
9
+ import { getDataPath } from "@vercel/cli-config";
10
+ import { resolve } from "path";
11
+ function isNativeBinaryInstall() {
12
+ return process.env.VERCEL_VC_NATIVE === "1";
13
+ }
14
+ function getInstallRoot() {
15
+ const root = process.env.VERCEL_INSTALL_DIR;
16
+ return root ? resolve(root) : getDataPath();
17
+ }
18
+
19
+ export {
20
+ isNativeBinaryInstall,
21
+ getInstallRoot
22
+ };
@@ -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-2TSBB22D.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
+ };
@@ -5,12 +5,14 @@ const require = __createRequire(import.meta.url);
5
5
  const __filename = __fileURLToPath(import.meta.url);
6
6
  const __dirname = __dirname_(__filename);
7
7
  import {
8
- require_end_of_stream,
8
+ require_end_of_stream
9
+ } from "./chunk-ZDU2NODC.js";
10
+ import {
9
11
  require_once
10
- } from "./chunk-52QYYTM5.js";
12
+ } from "./chunk-PEC3CQSK.js";
11
13
  import {
12
14
  require_signal_exit
13
- } from "./chunk-QFAS4OVW.js";
15
+ } from "./chunk-2JIX6UMI.js";
14
16
  import {
15
17
  __commonJS,
16
18
  __require
@@ -0,0 +1,43 @@
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
+ __commonJS
9
+ } from "./chunk-TZ2YI2VH.js";
10
+
11
+ // ../../node_modules/.pnpm/json-parse-better-errors@1.0.2/node_modules/json-parse-better-errors/index.js
12
+ var require_json_parse_better_errors = __commonJS({
13
+ "../../node_modules/.pnpm/json-parse-better-errors@1.0.2/node_modules/json-parse-better-errors/index.js"(exports, module) {
14
+ "use strict";
15
+ module.exports = parseJson;
16
+ function parseJson(txt, reviver, context) {
17
+ context = context || 20;
18
+ try {
19
+ return JSON.parse(txt, reviver);
20
+ } catch (e) {
21
+ if (typeof txt !== "string") {
22
+ const isEmptyArray = Array.isArray(txt) && txt.length === 0;
23
+ const errorMessage = "Cannot parse " + (isEmptyArray ? "an empty array" : String(txt));
24
+ throw new TypeError(errorMessage);
25
+ }
26
+ const syntaxErr = e.message.match(/^Unexpected token.*position\s+(\d+)/i);
27
+ const errIdx = syntaxErr ? +syntaxErr[1] : e.message.match(/^Unexpected end of JSON.*/i) ? txt.length - 1 : null;
28
+ if (errIdx != null) {
29
+ const start = errIdx <= context ? 0 : errIdx - context;
30
+ const end = errIdx + context >= txt.length ? txt.length : errIdx + context;
31
+ e.message += ` while parsing near '${start === 0 ? "" : "..."}${txt.slice(start, end)}${end === txt.length ? "" : "..."}'`;
32
+ } else {
33
+ e.message += ` while parsing '${txt.slice(0, context * 2)}'`;
34
+ }
35
+ throw e;
36
+ }
37
+ }
38
+ }
39
+ });
40
+
41
+ export {
42
+ require_json_parse_better_errors
43
+ };
@@ -0,0 +1,59 @@
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
+ printProjectNotFoundError
9
+ } from "./chunk-PJXMXMCO.js";
10
+ import {
11
+ detectExplicitScope
12
+ } from "./chunk-4IVSM24H.js";
13
+ import {
14
+ getLinkedProject
15
+ } from "./chunk-2TSBB22D.js";
16
+ import {
17
+ omitGlobalFlagsFromArgs
18
+ } from "./chunk-26CU4Q3C.js";
19
+
20
+ // src/util/projects/resolve-project-context.ts
21
+ function getInvokingCommandFromArgv(argv) {
22
+ const args = omitGlobalFlagsFromArgs(argv.slice(2));
23
+ const positionals = [];
24
+ for (const arg of args) {
25
+ if (arg.startsWith("-")) {
26
+ break;
27
+ }
28
+ positionals.push(arg);
29
+ }
30
+ return positionals.join(" ");
31
+ }
32
+ async function resolveProjectContext({
33
+ client,
34
+ cwd = client.cwd,
35
+ projectNameOrId,
36
+ commandName = "",
37
+ projectNotFoundHandling = "report"
38
+ }) {
39
+ const context = await getLinkedProject(client, {
40
+ cwd,
41
+ projectName: projectNameOrId,
42
+ projectNameIsExplicit: Boolean(projectNameOrId),
43
+ scopeIsExplicit: detectExplicitScope(client)
44
+ });
45
+ if (context.status === "not_linked" && projectNameOrId && projectNotFoundHandling === "report") {
46
+ await printProjectNotFoundError(
47
+ client,
48
+ projectNameOrId,
49
+ commandName || getInvokingCommandFromArgv(client.argv),
50
+ context.orgId
51
+ );
52
+ return { status: "error", exitCode: 1, orgId: context.orgId };
53
+ }
54
+ return context;
55
+ }
56
+
57
+ export {
58
+ resolveProjectContext
59
+ };
@@ -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
 
11
11
  // src/commands/metrics/output.ts
12
12
  function getRollupColumnName(metric, aggregation) {