@vercel/sandbox 1.9.0 → 1.9.2

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 (190) hide show
  1. package/README.md +8 -0
  2. package/dist/_virtual/rolldown_runtime.cjs +29 -0
  3. package/dist/api-client/api-client.cjs +375 -0
  4. package/dist/api-client/api-client.cjs.map +1 -0
  5. package/dist/api-client/api-client.d.cts +403 -0
  6. package/dist/api-client/api-client.d.ts +397 -392
  7. package/dist/api-client/api-client.js +365 -405
  8. package/dist/api-client/api-client.js.map +1 -1
  9. package/dist/api-client/api-error.cjs +31 -0
  10. package/dist/api-client/api-error.cjs.map +1 -0
  11. package/dist/api-client/api-error.d.cts +27 -0
  12. package/dist/api-client/api-error.d.ts +19 -16
  13. package/dist/api-client/api-error.js +27 -32
  14. package/dist/api-client/api-error.js.map +1 -1
  15. package/dist/api-client/base-client.cjs +113 -0
  16. package/dist/api-client/base-client.cjs.map +1 -0
  17. package/dist/api-client/base-client.d.cts +38 -0
  18. package/dist/api-client/base-client.d.ts +31 -36
  19. package/dist/api-client/base-client.js +101 -118
  20. package/dist/api-client/base-client.js.map +1 -1
  21. package/dist/api-client/file-writer.cjs +62 -0
  22. package/dist/api-client/file-writer.cjs.map +1 -0
  23. package/dist/api-client/file-writer.d.cts +66 -0
  24. package/dist/api-client/file-writer.d.ts +56 -52
  25. package/dist/api-client/file-writer.js +57 -61
  26. package/dist/api-client/file-writer.js.map +1 -1
  27. package/dist/api-client/index.cjs +2 -0
  28. package/dist/api-client/index.d.ts +2 -2
  29. package/dist/api-client/index.js +4 -21
  30. package/dist/api-client/validators.cjs +149 -0
  31. package/dist/api-client/validators.cjs.map +1 -0
  32. package/dist/api-client/validators.d.cts +1677 -0
  33. package/dist/api-client/validators.d.ts +1501 -2412
  34. package/dist/api-client/validators.js +124 -154
  35. package/dist/api-client/validators.js.map +1 -1
  36. package/dist/api-client/with-retry.cjs +89 -0
  37. package/dist/api-client/with-retry.cjs.map +1 -0
  38. package/dist/api-client/with-retry.d.cts +10 -0
  39. package/dist/api-client/with-retry.d.ts +9 -13
  40. package/dist/api-client/with-retry.js +81 -102
  41. package/dist/api-client/with-retry.js.map +1 -1
  42. package/dist/auth/api.cjs +29 -0
  43. package/dist/auth/api.cjs.map +1 -0
  44. package/dist/auth/api.js +26 -25
  45. package/dist/auth/api.js.map +1 -1
  46. package/dist/auth/error.cjs +13 -0
  47. package/dist/auth/error.cjs.map +1 -0
  48. package/dist/auth/error.js +11 -11
  49. package/dist/auth/error.js.map +1 -1
  50. package/dist/auth/file.cjs +64 -0
  51. package/dist/auth/file.cjs.map +1 -0
  52. package/dist/auth/file.d.cts +26 -0
  53. package/dist/auth/file.d.ts +19 -15
  54. package/dist/auth/file.js +49 -64
  55. package/dist/auth/file.js.map +1 -1
  56. package/dist/auth/index.cjs +12 -0
  57. package/dist/auth/index.d.cts +5 -0
  58. package/dist/auth/index.d.ts +5 -6
  59. package/dist/auth/index.js +6 -27
  60. package/dist/auth/linked-project.cjs +38 -0
  61. package/dist/auth/linked-project.cjs.map +1 -0
  62. package/dist/auth/linked-project.js +30 -64
  63. package/dist/auth/linked-project.js.map +1 -1
  64. package/dist/auth/oauth.cjs +205 -0
  65. package/dist/auth/oauth.cjs.map +1 -0
  66. package/dist/auth/oauth.d.cts +135 -0
  67. package/dist/auth/oauth.d.ts +113 -109
  68. package/dist/auth/oauth.js +185 -252
  69. package/dist/auth/oauth.js.map +1 -1
  70. package/dist/auth/poll-for-token.cjs +82 -0
  71. package/dist/auth/poll-for-token.cjs.map +1 -0
  72. package/dist/auth/poll-for-token.d.cts +28 -0
  73. package/dist/auth/poll-for-token.d.ts +23 -15
  74. package/dist/auth/poll-for-token.js +79 -64
  75. package/dist/auth/poll-for-token.js.map +1 -1
  76. package/dist/auth/project.cjs +80 -0
  77. package/dist/auth/project.cjs.map +1 -0
  78. package/dist/auth/project.d.cts +44 -0
  79. package/dist/auth/project.d.ts +12 -8
  80. package/dist/auth/project.js +70 -72
  81. package/dist/auth/project.js.map +1 -1
  82. package/dist/auth/zod.cjs +22 -0
  83. package/dist/auth/zod.cjs.map +1 -0
  84. package/dist/auth/zod.js +18 -17
  85. package/dist/auth/zod.js.map +1 -1
  86. package/dist/command.cjs +328 -0
  87. package/dist/command.cjs.map +1 -0
  88. package/dist/command.d.cts +289 -0
  89. package/dist/command.d.ts +265 -171
  90. package/dist/command.js +323 -226
  91. package/dist/command.js.map +1 -1
  92. package/dist/constants.d.cts +5 -0
  93. package/dist/constants.d.ts +5 -1
  94. package/dist/index.cjs +11 -0
  95. package/dist/index.d.cts +6 -0
  96. package/dist/index.d.ts +6 -5
  97. package/dist/index.js +6 -15
  98. package/dist/network-policy.d.cts +100 -0
  99. package/dist/network-policy.d.ts +32 -28
  100. package/dist/sandbox.cjs +543 -0
  101. package/dist/sandbox.cjs.map +1 -0
  102. package/dist/sandbox.d.cts +538 -0
  103. package/dist/sandbox.d.ts +521 -479
  104. package/dist/sandbox.js +539 -512
  105. package/dist/sandbox.js.map +1 -1
  106. package/dist/snapshot.cjs +116 -0
  107. package/dist/snapshot.cjs.map +1 -0
  108. package/dist/snapshot.d.cts +109 -0
  109. package/dist/snapshot.d.ts +100 -92
  110. package/dist/snapshot.js +114 -114
  111. package/dist/snapshot.js.map +1 -1
  112. package/dist/utils/array.cjs +17 -0
  113. package/dist/utils/array.cjs.map +1 -0
  114. package/dist/utils/array.js +12 -15
  115. package/dist/utils/array.js.map +1 -1
  116. package/dist/utils/consume-readable.cjs +18 -0
  117. package/dist/utils/consume-readable.cjs.map +1 -0
  118. package/dist/utils/consume-readable.js +13 -12
  119. package/dist/utils/consume-readable.js.map +1 -1
  120. package/dist/utils/decode-base64-url.cjs +15 -0
  121. package/dist/utils/decode-base64-url.cjs.map +1 -0
  122. package/dist/utils/decode-base64-url.js +10 -9
  123. package/dist/utils/decode-base64-url.js.map +1 -1
  124. package/dist/utils/dev-credentials.cjs +142 -0
  125. package/dist/utils/dev-credentials.cjs.map +1 -0
  126. package/dist/utils/dev-credentials.js +126 -184
  127. package/dist/utils/dev-credentials.js.map +1 -1
  128. package/dist/utils/get-credentials.cjs +123 -0
  129. package/dist/utils/get-credentials.cjs.map +1 -0
  130. package/dist/utils/get-credentials.d.cts +21 -0
  131. package/dist/utils/get-credentials.d.ts +19 -61
  132. package/dist/utils/get-credentials.js +106 -140
  133. package/dist/utils/get-credentials.js.map +1 -1
  134. package/dist/utils/log.cjs +25 -0
  135. package/dist/utils/log.cjs.map +1 -0
  136. package/dist/utils/log.js +15 -17
  137. package/dist/utils/log.js.map +1 -1
  138. package/dist/utils/network-policy.cjs +65 -0
  139. package/dist/utils/network-policy.cjs.map +1 -0
  140. package/dist/utils/network-policy.js +58 -77
  141. package/dist/utils/network-policy.js.map +1 -1
  142. package/dist/utils/normalizePath.cjs +27 -0
  143. package/dist/utils/normalizePath.cjs.map +1 -0
  144. package/dist/utils/normalizePath.js +21 -28
  145. package/dist/utils/normalizePath.js.map +1 -1
  146. package/dist/utils/resolveSignal.cjs +20 -0
  147. package/dist/utils/resolveSignal.cjs.map +1 -0
  148. package/dist/utils/resolveSignal.d.cts +15 -0
  149. package/dist/utils/resolveSignal.d.ts +12 -10
  150. package/dist/utils/resolveSignal.js +14 -17
  151. package/dist/utils/resolveSignal.js.map +1 -1
  152. package/dist/utils/sandbox-snapshot.cjs +14 -0
  153. package/dist/utils/sandbox-snapshot.cjs.map +1 -0
  154. package/dist/utils/sandbox-snapshot.d.cts +10 -0
  155. package/dist/utils/sandbox-snapshot.d.ts +11 -0
  156. package/dist/utils/sandbox-snapshot.js +14 -0
  157. package/dist/utils/sandbox-snapshot.js.map +1 -0
  158. package/dist/utils/types.cjs +13 -0
  159. package/dist/utils/types.cjs.map +1 -0
  160. package/dist/utils/types.d.cts +11 -0
  161. package/dist/utils/types.d.ts +5 -7
  162. package/dist/utils/types.js +8 -8
  163. package/dist/utils/types.js.map +1 -1
  164. package/dist/version.cjs +7 -0
  165. package/dist/version.cjs.map +1 -0
  166. package/dist/version.js +5 -5
  167. package/dist/version.js.map +1 -1
  168. package/package.json +23 -3
  169. package/dist/api-client/index.js.map +0 -1
  170. package/dist/auth/api.d.ts +0 -6
  171. package/dist/auth/error.d.ts +0 -11
  172. package/dist/auth/index.js.map +0 -1
  173. package/dist/auth/linked-project.d.ts +0 -10
  174. package/dist/auth/zod.d.ts +0 -5
  175. package/dist/constants.js +0 -3
  176. package/dist/constants.js.map +0 -1
  177. package/dist/index.js.map +0 -1
  178. package/dist/network-policy.js +0 -3
  179. package/dist/network-policy.js.map +0 -1
  180. package/dist/utils/array.d.ts +0 -9
  181. package/dist/utils/consume-readable.d.ts +0 -5
  182. package/dist/utils/convert-sandbox.d.ts +0 -6
  183. package/dist/utils/convert-sandbox.js +0 -14
  184. package/dist/utils/convert-sandbox.js.map +0 -1
  185. package/dist/utils/decode-base64-url.d.ts +0 -7
  186. package/dist/utils/dev-credentials.d.ts +0 -37
  187. package/dist/utils/log.d.ts +0 -2
  188. package/dist/utils/network-policy.d.ts +0 -7
  189. package/dist/utils/normalizePath.d.ts +0 -17
  190. package/dist/version.d.ts +0 -1
@@ -1,108 +1,87 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.withRetry = withRetry;
7
- const api_error_1 = require("./api-error");
8
- const promises_1 = require("node:timers/promises");
9
- const async_retry_1 = __importDefault(require("async-retry"));
1
+ import { APIError } from "./api-error.js";
2
+ import { setTimeout } from "node:timers/promises";
3
+ import retry from "async-retry";
4
+
5
+ //#region src/api-client/with-retry.ts
10
6
  /**
11
- * Wraps a fetch function with retry logic. The retry logic will retry
12
- * on network errors, 429 responses and 5xx responses. The retry logic
13
- * will not retry on 4xx responses.
14
- *
15
- * @param rawFetch The fetch function to wrap.
16
- * @returns The wrapped fetch function.
17
- */
7
+ * Wraps a fetch function with retry logic. The retry logic will retry
8
+ * on network errors, 429 responses and 5xx responses. The retry logic
9
+ * will not retry on 4xx responses.
10
+ *
11
+ * @param rawFetch The fetch function to wrap.
12
+ * @returns The wrapped fetch function.
13
+ */
18
14
  function withRetry(rawFetch) {
19
- return async (url, opts = {}) => {
20
- /**
21
- * Timeouts by default will be [10, 60, 360, 2160, 12960]
22
- * before randomization is added.
23
- */
24
- const retryOpts = Object.assign({
25
- minTimeout: 10,
26
- retries: 5,
27
- factor: 6,
28
- maxRetryAfter: 20,
29
- }, opts.retry);
30
- if (opts.onRetry) {
31
- retryOpts.onRetry = (error, attempts) => {
32
- opts.onRetry(error, opts);
33
- if (opts.retry && opts.retry.onRetry) {
34
- opts.retry.onRetry(error, attempts);
35
- }
36
- };
37
- }
38
- try {
39
- return (await (0, async_retry_1.default)(async (bail) => {
40
- try {
41
- if (opts.signal?.aborted) {
42
- return bail(opts.signal.reason || new Error("Request aborted"));
43
- }
44
- const response = await rawFetch(url, opts);
45
- /**
46
- * When the response is 429 we will try to parse the Retry-After
47
- * header. If the header exists we will try to parse it and, if
48
- * the wait time is higher than the maximum defined, we respond.
49
- * Otherwise we wait for the time given in the header and throw
50
- * to retry.
51
- */
52
- if (response.status === 429) {
53
- const retryAfter = parseInt(response.headers.get("retry-after") || "", 10);
54
- if (retryAfter && !isNaN(retryAfter)) {
55
- if (retryAfter > retryOpts.maxRetryAfter) {
56
- return response;
57
- }
58
- await (0, promises_1.setTimeout)(retryAfter * 1e3);
59
- }
60
- throw new api_error_1.APIError(response);
61
- }
62
- /**
63
- * If the response is a a retryable error, we throw in
64
- * order to retry.
65
- */
66
- if (response.status >= 500 && response.status < 600) {
67
- throw new api_error_1.APIError(response);
68
- }
69
- return response;
70
- }
71
- catch (error) {
72
- /**
73
- * If the request was aborted using the AbortController
74
- * we bail from retrying throwing the original error.
75
- */
76
- if (isAbortError(error)) {
77
- return bail(error);
78
- }
79
- /**
80
- * If the signal was aborted meanwhile we were
81
- * waiting, we bail from retrying.
82
- */
83
- if (opts.signal?.aborted) {
84
- return bail(opts.signal.reason || new Error("Request aborted"));
85
- }
86
- throw error;
87
- }
88
- }, retryOpts));
89
- }
90
- catch (error) {
91
- /**
92
- * The ResponseError is only intended for retries so in case we
93
- * ran out of attempts we will respond with the last response
94
- * we obtained.
95
- */
96
- if (error instanceof api_error_1.APIError) {
97
- return error.response;
98
- }
99
- throw error;
100
- }
101
- };
15
+ return async (url, opts = {}) => {
16
+ /**
17
+ * Timeouts by default will be [10, 60, 360, 2160, 12960]
18
+ * before randomization is added.
19
+ */
20
+ const retryOpts = Object.assign({
21
+ minTimeout: 10,
22
+ retries: 5,
23
+ factor: 6,
24
+ maxRetryAfter: 20
25
+ }, opts.retry);
26
+ if (opts.onRetry) retryOpts.onRetry = (error, attempts) => {
27
+ opts.onRetry(error, opts);
28
+ if (opts.retry && opts.retry.onRetry) opts.retry.onRetry(error, attempts);
29
+ };
30
+ try {
31
+ return await retry(async (bail) => {
32
+ try {
33
+ if (opts.signal?.aborted) return bail(opts.signal.reason || /* @__PURE__ */ new Error("Request aborted"));
34
+ const response = await rawFetch(url, opts);
35
+ /**
36
+ * When the response is 429 we will try to parse the Retry-After
37
+ * header. If the header exists we will try to parse it and, if
38
+ * the wait time is higher than the maximum defined, we respond.
39
+ * Otherwise we wait for the time given in the header and throw
40
+ * to retry.
41
+ */
42
+ if (response.status === 429) {
43
+ const retryAfter = parseInt(response.headers.get("retry-after") || "", 10);
44
+ if (retryAfter && !isNaN(retryAfter)) {
45
+ if (retryAfter > retryOpts.maxRetryAfter) return response;
46
+ await setTimeout(retryAfter * 1e3);
47
+ }
48
+ throw new APIError(response);
49
+ }
50
+ /**
51
+ * If the response is a a retryable error, we throw in
52
+ * order to retry.
53
+ */
54
+ if (response.status >= 500 && response.status < 600) throw new APIError(response);
55
+ return response;
56
+ } catch (error) {
57
+ /**
58
+ * If the request was aborted using the AbortController
59
+ * we bail from retrying throwing the original error.
60
+ */
61
+ if (isAbortError(error)) return bail(error);
62
+ /**
63
+ * If the signal was aborted meanwhile we were
64
+ * waiting, we bail from retrying.
65
+ */
66
+ if (opts.signal?.aborted) return bail(opts.signal.reason || /* @__PURE__ */ new Error("Request aborted"));
67
+ throw error;
68
+ }
69
+ }, retryOpts);
70
+ } catch (error) {
71
+ /**
72
+ * The ResponseError is only intended for retries so in case we
73
+ * ran out of attempts we will respond with the last response
74
+ * we obtained.
75
+ */
76
+ if (error instanceof APIError) return error.response;
77
+ throw error;
78
+ }
79
+ };
102
80
  }
103
81
  function isAbortError(error) {
104
- return (error !== undefined &&
105
- error !== null &&
106
- error.name === "AbortError");
82
+ return error !== void 0 && error !== null && error.name === "AbortError";
107
83
  }
84
+
85
+ //#endregion
86
+ export { withRetry };
108
87
  //# sourceMappingURL=with-retry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"with-retry.js","sourceRoot":"","sources":["../../src/api-client/with-retry.ts"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"with-retry.js","names":[],"sources":["../../src/api-client/with-retry.ts"],"sourcesContent":["import type { Options as RetryOptions } from \"async-retry\";\nimport { APIError } from \"./api-error.js\";\nimport { setTimeout } from \"node:timers/promises\";\nimport retry from \"async-retry\";\n\nexport interface RequestOptions {\n onRetry?(error: any, options: RequestOptions): void;\n retry?: Partial<RetryOptions>;\n}\n\n/**\n * Wraps a fetch function with retry logic. The retry logic will retry\n * on network errors, 429 responses and 5xx responses. The retry logic\n * will not retry on 4xx responses.\n *\n * @param rawFetch The fetch function to wrap.\n * @returns The wrapped fetch function.\n */\nexport function withRetry<T extends RequestInit>(\n rawFetch: (url: URL | string, init?: T) => Promise<Response>,\n) {\n return async (\n url: URL | string,\n opts: T & RequestOptions = <T & RequestOptions>{},\n ) => {\n /**\n * Timeouts by default will be [10, 60, 360, 2160, 12960]\n * before randomization is added.\n */\n const retryOpts = Object.assign(\n {\n minTimeout: 10,\n retries: 5,\n factor: 6,\n maxRetryAfter: 20,\n },\n opts.retry,\n );\n\n if (opts.onRetry) {\n retryOpts.onRetry = (error, attempts) => {\n opts.onRetry!(error, opts);\n if (opts.retry && opts.retry.onRetry) {\n opts.retry.onRetry(error, attempts);\n }\n };\n }\n\n try {\n return (await retry(async (bail) => {\n try {\n if (opts.signal?.aborted) {\n return bail(opts.signal.reason || new Error(\"Request aborted\"));\n }\n const response = await rawFetch(url, opts);\n\n /**\n * When the response is 429 we will try to parse the Retry-After\n * header. If the header exists we will try to parse it and, if\n * the wait time is higher than the maximum defined, we respond.\n * Otherwise we wait for the time given in the header and throw\n * to retry.\n */\n if (response.status === 429) {\n const retryAfter = parseInt(\n response.headers.get(\"retry-after\") || \"\",\n 10,\n );\n\n if (retryAfter && !isNaN(retryAfter)) {\n if (retryAfter > retryOpts.maxRetryAfter) {\n return response;\n }\n\n await setTimeout(retryAfter * 1e3);\n }\n\n throw new APIError(response);\n }\n\n /**\n * If the response is a a retryable error, we throw in\n * order to retry.\n */\n if (response.status >= 500 && response.status < 600) {\n throw new APIError(response);\n }\n\n return response;\n } catch (error) {\n /**\n * If the request was aborted using the AbortController\n * we bail from retrying throwing the original error.\n */\n if (isAbortError(error)) {\n return bail(error);\n }\n\n /**\n * If the signal was aborted meanwhile we were\n * waiting, we bail from retrying.\n */\n if (opts.signal?.aborted) {\n return bail(opts.signal.reason || new Error(\"Request aborted\"));\n }\n\n throw error;\n }\n }, retryOpts)) as Response;\n } catch (error) {\n /**\n * The ResponseError is only intended for retries so in case we\n * ran out of attempts we will respond with the last response\n * we obtained.\n */\n if (error instanceof APIError) {\n return error.response;\n }\n\n throw error;\n }\n };\n}\n\nfunction isAbortError(error: unknown): error is Error {\n return (\n error !== undefined &&\n error !== null &&\n (error as Error).name === \"AbortError\"\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAkBA,SAAgB,UACd,UACA;AACA,QAAO,OACL,KACA,OAA+C,EAAE,KAC9C;;;;;EAKH,MAAM,YAAY,OAAO,OACvB;GACE,YAAY;GACZ,SAAS;GACT,QAAQ;GACR,eAAe;GAChB,EACD,KAAK,MACN;AAED,MAAI,KAAK,QACP,WAAU,WAAW,OAAO,aAAa;AACvC,QAAK,QAAS,OAAO,KAAK;AAC1B,OAAI,KAAK,SAAS,KAAK,MAAM,QAC3B,MAAK,MAAM,QAAQ,OAAO,SAAS;;AAKzC,MAAI;AACF,UAAQ,MAAM,MAAM,OAAO,SAAS;AAClC,QAAI;AACF,SAAI,KAAK,QAAQ,QACf,QAAO,KAAK,KAAK,OAAO,0BAAU,IAAI,MAAM,kBAAkB,CAAC;KAEjE,MAAM,WAAW,MAAM,SAAS,KAAK,KAAK;;;;;;;;AAS1C,SAAI,SAAS,WAAW,KAAK;MAC3B,MAAM,aAAa,SACjB,SAAS,QAAQ,IAAI,cAAc,IAAI,IACvC,GACD;AAED,UAAI,cAAc,CAAC,MAAM,WAAW,EAAE;AACpC,WAAI,aAAa,UAAU,cACzB,QAAO;AAGT,aAAM,WAAW,aAAa,IAAI;;AAGpC,YAAM,IAAI,SAAS,SAAS;;;;;;AAO9B,SAAI,SAAS,UAAU,OAAO,SAAS,SAAS,IAC9C,OAAM,IAAI,SAAS,SAAS;AAG9B,YAAO;aACA,OAAO;;;;;AAKd,SAAI,aAAa,MAAM,CACrB,QAAO,KAAK,MAAM;;;;;AAOpB,SAAI,KAAK,QAAQ,QACf,QAAO,KAAK,KAAK,OAAO,0BAAU,IAAI,MAAM,kBAAkB,CAAC;AAGjE,WAAM;;MAEP,UAAU;WACN,OAAO;;;;;;AAMd,OAAI,iBAAiB,SACnB,QAAO,MAAM;AAGf,SAAM;;;;AAKZ,SAAS,aAAa,OAAgC;AACpD,QACE,UAAU,UACV,UAAU,QACT,MAAgB,SAAS"}
@@ -0,0 +1,29 @@
1
+ const require_error = require('./error.cjs');
2
+
3
+ //#region src/auth/api.ts
4
+ async function fetchApi(opts) {
5
+ const x = await fetch(`https://api.vercel.com${opts.endpoint}`, {
6
+ method: opts.method,
7
+ body: opts.body,
8
+ headers: {
9
+ Authorization: `Bearer ${opts.token}`,
10
+ "Content-Type": "application/json"
11
+ }
12
+ });
13
+ if (!x.ok) {
14
+ let message = await x.text();
15
+ try {
16
+ const { error } = JSON.parse(message);
17
+ message = `${error.code.toUpperCase()}: ${error.message}`;
18
+ } catch {}
19
+ throw new require_error.NotOk({
20
+ responseText: message,
21
+ statusCode: x.status
22
+ });
23
+ }
24
+ return await x.json();
25
+ }
26
+
27
+ //#endregion
28
+ exports.fetchApi = fetchApi;
29
+ //# sourceMappingURL=api.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.cjs","names":["NotOk"],"sources":["../../src/auth/api.ts"],"sourcesContent":["import { NotOk } from \"./error.js\";\n\nexport async function fetchApi(opts: {\n token: string;\n endpoint: string;\n method?: string;\n body?: string;\n}): Promise<unknown> {\n const x = await fetch(`https://api.vercel.com${opts.endpoint}`, {\n method: opts.method,\n body: opts.body,\n headers: {\n Authorization: `Bearer ${opts.token}`,\n \"Content-Type\": \"application/json\",\n },\n });\n if (!x.ok) {\n let message = await x.text();\n\n try {\n const { error } = JSON.parse(message);\n message = `${error.code.toUpperCase()}: ${error.message}`;\n } catch {}\n\n throw new NotOk({\n responseText: message,\n statusCode: x.status,\n });\n }\n return (await x.json()) as unknown;\n}\n"],"mappings":";;;AAEA,eAAsB,SAAS,MAKV;CACnB,MAAM,IAAI,MAAM,MAAM,yBAAyB,KAAK,YAAY;EAC9D,QAAQ,KAAK;EACb,MAAM,KAAK;EACX,SAAS;GACP,eAAe,UAAU,KAAK;GAC9B,gBAAgB;GACjB;EACF,CAAC;AACF,KAAI,CAAC,EAAE,IAAI;EACT,IAAI,UAAU,MAAM,EAAE,MAAM;AAE5B,MAAI;GACF,MAAM,EAAE,UAAU,KAAK,MAAM,QAAQ;AACrC,aAAU,GAAG,MAAM,KAAK,aAAa,CAAC,IAAI,MAAM;UAC1C;AAER,QAAM,IAAIA,oBAAM;GACd,cAAc;GACd,YAAY,EAAE;GACf,CAAC;;AAEJ,QAAQ,MAAM,EAAE,MAAM"}
package/dist/auth/api.js CHANGED
@@ -1,28 +1,29 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchApi = fetchApi;
4
- const error_1 = require("./error");
1
+ import { NotOk } from "./error.js";
2
+
3
+ //#region src/auth/api.ts
5
4
  async function fetchApi(opts) {
6
- const x = await fetch(`https://api.vercel.com${opts.endpoint}`, {
7
- method: opts.method,
8
- body: opts.body,
9
- headers: {
10
- Authorization: `Bearer ${opts.token}`,
11
- "Content-Type": "application/json",
12
- },
13
- });
14
- if (!x.ok) {
15
- let message = await x.text();
16
- try {
17
- const { error } = JSON.parse(message);
18
- message = `${error.code.toUpperCase()}: ${error.message}`;
19
- }
20
- catch { }
21
- throw new error_1.NotOk({
22
- responseText: message,
23
- statusCode: x.status,
24
- });
25
- }
26
- return (await x.json());
5
+ const x = await fetch(`https://api.vercel.com${opts.endpoint}`, {
6
+ method: opts.method,
7
+ body: opts.body,
8
+ headers: {
9
+ Authorization: `Bearer ${opts.token}`,
10
+ "Content-Type": "application/json"
11
+ }
12
+ });
13
+ if (!x.ok) {
14
+ let message = await x.text();
15
+ try {
16
+ const { error } = JSON.parse(message);
17
+ message = `${error.code.toUpperCase()}: ${error.message}`;
18
+ } catch {}
19
+ throw new NotOk({
20
+ responseText: message,
21
+ statusCode: x.status
22
+ });
23
+ }
24
+ return await x.json();
27
25
  }
26
+
27
+ //#endregion
28
+ export { fetchApi };
28
29
  //# sourceMappingURL=api.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/auth/api.ts"],"names":[],"mappings":";;AAEA,4BA4BC;AA9BD,mCAAgC;AAEzB,KAAK,UAAU,QAAQ,CAAC,IAK9B;IACC,MAAM,CAAC,GAAG,MAAM,KAAK,CAAC,yBAAyB,IAAI,CAAC,QAAQ,EAAE,EAAE;QAC9D,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,IAAI,CAAC,KAAK,EAAE;YACrC,cAAc,EAAE,kBAAkB;SACnC;KACF,CAAC,CAAC;IACH,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QACV,IAAI,OAAO,GAAG,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;QAE7B,IAAI,CAAC;YACH,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACtC,OAAO,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;QAC5D,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;QAEV,MAAM,IAAI,aAAK,CAAC;YACd,YAAY,EAAE,OAAO;YACrB,UAAU,EAAE,CAAC,CAAC,MAAM;SACrB,CAAC,CAAC;IACL,CAAC;IACD,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAY,CAAC;AACrC,CAAC"}
1
+ {"version":3,"file":"api.js","names":[],"sources":["../../src/auth/api.ts"],"sourcesContent":["import { NotOk } from \"./error.js\";\n\nexport async function fetchApi(opts: {\n token: string;\n endpoint: string;\n method?: string;\n body?: string;\n}): Promise<unknown> {\n const x = await fetch(`https://api.vercel.com${opts.endpoint}`, {\n method: opts.method,\n body: opts.body,\n headers: {\n Authorization: `Bearer ${opts.token}`,\n \"Content-Type\": \"application/json\",\n },\n });\n if (!x.ok) {\n let message = await x.text();\n\n try {\n const { error } = JSON.parse(message);\n message = `${error.code.toUpperCase()}: ${error.message}`;\n } catch {}\n\n throw new NotOk({\n responseText: message,\n statusCode: x.status,\n });\n }\n return (await x.json()) as unknown;\n}\n"],"mappings":";;;AAEA,eAAsB,SAAS,MAKV;CACnB,MAAM,IAAI,MAAM,MAAM,yBAAyB,KAAK,YAAY;EAC9D,QAAQ,KAAK;EACb,MAAM,KAAK;EACX,SAAS;GACP,eAAe,UAAU,KAAK;GAC9B,gBAAgB;GACjB;EACF,CAAC;AACF,KAAI,CAAC,EAAE,IAAI;EACT,IAAI,UAAU,MAAM,EAAE,MAAM;AAE5B,MAAI;GACF,MAAM,EAAE,UAAU,KAAK,MAAM,QAAQ;AACrC,aAAU,GAAG,MAAM,KAAK,aAAa,CAAC,IAAI,MAAM;UAC1C;AAER,QAAM,IAAI,MAAM;GACd,cAAc;GACd,YAAY,EAAE;GACf,CAAC;;AAEJ,QAAQ,MAAM,EAAE,MAAM"}
@@ -0,0 +1,13 @@
1
+
2
+ //#region src/auth/error.ts
3
+ var NotOk = class extends Error {
4
+ constructor(response) {
5
+ super(`HTTP ${response.statusCode}: ${response.responseText}`);
6
+ this.name = "NotOk";
7
+ this.response = response;
8
+ }
9
+ };
10
+
11
+ //#endregion
12
+ exports.NotOk = NotOk;
13
+ //# sourceMappingURL=error.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.cjs","names":[],"sources":["../../src/auth/error.ts"],"sourcesContent":["export class NotOk extends Error {\n name = \"NotOk\";\n response: { statusCode: number; responseText: string };\n constructor(response: { statusCode: number; responseText: string }) {\n super(`HTTP ${response.statusCode}: ${response.responseText}`);\n this.response = response;\n }\n}\n"],"mappings":";;AAAA,IAAa,QAAb,cAA2B,MAAM;CAG/B,YAAY,UAAwD;AAClE,QAAM,QAAQ,SAAS,WAAW,IAAI,SAAS,eAAe;OAHhE,OAAO;AAIL,OAAK,WAAW"}
@@ -1,12 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NotOk = void 0;
4
- class NotOk extends Error {
5
- constructor(response) {
6
- super(`HTTP ${response.statusCode}: ${response.responseText}`);
7
- this.name = "NotOk";
8
- this.response = response;
9
- }
10
- }
11
- exports.NotOk = NotOk;
1
+ //#region src/auth/error.ts
2
+ var NotOk = class extends Error {
3
+ constructor(response) {
4
+ super(`HTTP ${response.statusCode}: ${response.responseText}`);
5
+ this.name = "NotOk";
6
+ this.response = response;
7
+ }
8
+ };
9
+
10
+ //#endregion
11
+ export { NotOk };
12
12
  //# sourceMappingURL=error.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/auth/error.ts"],"names":[],"mappings":";;;AAAA,MAAa,KAAM,SAAQ,KAAK;IAG9B,YAAY,QAAsD;QAChE,KAAK,CAAC,QAAQ,QAAQ,CAAC,UAAU,KAAK,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAC;QAHjE,SAAI,GAAG,OAAO,CAAC;QAIb,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AAPD,sBAOC"}
1
+ {"version":3,"file":"error.js","names":[],"sources":["../../src/auth/error.ts"],"sourcesContent":["export class NotOk extends Error {\n name = \"NotOk\";\n response: { statusCode: number; responseText: string };\n constructor(response: { statusCode: number; responseText: string }) {\n super(`HTTP ${response.statusCode}: ${response.responseText}`);\n this.response = response;\n }\n}\n"],"mappings":";AAAA,IAAa,QAAb,cAA2B,MAAM;CAG/B,YAAY,UAAwD;AAClE,QAAM,QAAQ,SAAS,WAAW,IAAI,SAAS,eAAe;OAHhE,OAAO;AAIL,OAAK,WAAW"}
@@ -0,0 +1,64 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_zod = require('./zod.cjs');
3
+ let zod = require("zod");
4
+ let node_path = require("node:path");
5
+ node_path = require_rolldown_runtime.__toESM(node_path);
6
+ let node_fs = require("node:fs");
7
+ node_fs = require_rolldown_runtime.__toESM(node_fs);
8
+ let node_os = require("node:os");
9
+ let xdg_app_paths = require("xdg-app-paths");
10
+ xdg_app_paths = require_rolldown_runtime.__toESM(xdg_app_paths);
11
+
12
+ //#region src/auth/file.ts
13
+ const ZodDate = zod.z.number().transform((seconds) => /* @__PURE__ */ new Date(seconds * 1e3));
14
+ const AuthFile = zod.z.object({
15
+ token: zod.z.string().min(1).optional(),
16
+ refreshToken: zod.z.string().min(1).optional(),
17
+ expiresAt: ZodDate.optional()
18
+ });
19
+ const StoredAuthFile = require_zod.json.pipe(AuthFile);
20
+ const isDirectory = (path$1) => {
21
+ try {
22
+ return node_fs.default.lstatSync(path$1).isDirectory();
23
+ } catch (_) {
24
+ return false;
25
+ }
26
+ };
27
+ /**
28
+ * Returns in which directory the config should be present.
29
+ *
30
+ * @internal The `VERCEL_AUTH_CONFIG_DIR` env var is for testing purposes only
31
+ * and is not part of the public API.
32
+ */
33
+ const getGlobalPathConfig = () => {
34
+ if (process.env.VERCEL_AUTH_CONFIG_DIR) return process.env.VERCEL_AUTH_CONFIG_DIR;
35
+ const vercelDirectories = (0, xdg_app_paths.default)("com.vercel.cli").dataDirs();
36
+ return [
37
+ ...vercelDirectories,
38
+ node_path.default.join((0, node_os.homedir)(), ".now"),
39
+ ...(0, xdg_app_paths.default)("now").dataDirs()
40
+ ].find((configPath) => isDirectory(configPath)) || vercelDirectories[0];
41
+ };
42
+ const getAuth = () => {
43
+ try {
44
+ const pathname = node_path.default.join(getGlobalPathConfig(), "auth.json");
45
+ return StoredAuthFile.parse(node_fs.default.readFileSync(pathname, "utf8"));
46
+ } catch {
47
+ return null;
48
+ }
49
+ };
50
+ function updateAuthConfig(config) {
51
+ const pathname = node_path.default.join(getGlobalPathConfig(), "auth.json");
52
+ node_fs.default.mkdirSync(node_path.default.dirname(pathname), { recursive: true });
53
+ const content = {
54
+ token: config.token,
55
+ expiresAt: config.expiresAt && Math.round(config.expiresAt.getTime() / 1e3),
56
+ refreshToken: config.refreshToken
57
+ };
58
+ node_fs.default.writeFileSync(pathname, JSON.stringify(content) + "\n");
59
+ }
60
+
61
+ //#endregion
62
+ exports.getAuth = getAuth;
63
+ exports.updateAuthConfig = updateAuthConfig;
64
+ //# sourceMappingURL=file.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.cjs","names":["z","json","fs","path"],"sources":["../../src/auth/file.ts"],"sourcesContent":["import path from \"node:path\";\nimport fs from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport XDGAppPaths from \"xdg-app-paths\";\nimport { z } from \"zod\";\nimport { json } from \"./zod.js\";\n\nconst ZodDate = z.number().transform((seconds) => new Date(seconds * 1000));\n\nconst AuthFile = z.object({\n token: z.string().min(1).optional(),\n refreshToken: z.string().min(1).optional(),\n expiresAt: ZodDate.optional(),\n});\n\nconst StoredAuthFile = json.pipe(AuthFile);\n\ntype AuthFile = z.infer<typeof AuthFile>;\n\n// Returns whether a directory exists\nconst isDirectory = (path: string): boolean => {\n try {\n return fs.lstatSync(path).isDirectory();\n } catch (_) {\n // We don't care which kind of error occured, it isn't a directory anyway.\n return false;\n }\n};\n\n/**\n * Returns in which directory the config should be present.\n *\n * @internal The `VERCEL_AUTH_CONFIG_DIR` env var is for testing purposes only\n * and is not part of the public API.\n */\nconst getGlobalPathConfig = (): string => {\n if (process.env.VERCEL_AUTH_CONFIG_DIR) {\n return process.env.VERCEL_AUTH_CONFIG_DIR;\n }\n\n const vercelDirectories = XDGAppPaths(\"com.vercel.cli\").dataDirs();\n\n const possibleConfigPaths = [\n ...vercelDirectories, // latest vercel directory\n path.join(homedir(), \".now\"), // legacy config in user's home directory\n ...XDGAppPaths(\"now\").dataDirs(), // legacy XDG directory\n ];\n\n // The customPath flag is the preferred location,\n // followed by the vercel directory,\n // followed by the now directory.\n // If none of those exist, use the vercel directory.\n return (\n possibleConfigPaths.find((configPath) => isDirectory(configPath)) ||\n vercelDirectories[0]\n );\n};\n\nexport const getAuth = () => {\n try {\n const pathname = path.join(getGlobalPathConfig(), \"auth.json\");\n return StoredAuthFile.parse(fs.readFileSync(pathname, \"utf8\"));\n } catch {\n return null;\n }\n};\n\nexport function updateAuthConfig(config: AuthFile): void {\n const pathname = path.join(getGlobalPathConfig(), \"auth.json\");\n fs.mkdirSync(path.dirname(pathname), { recursive: true });\n const content = {\n token: config.token,\n expiresAt:\n config.expiresAt && Math.round(config.expiresAt.getTime() / 1000),\n refreshToken: config.refreshToken,\n } satisfies z.input<typeof AuthFile>;\n fs.writeFileSync(pathname, JSON.stringify(content) + \"\\n\");\n}\n"],"mappings":";;;;;;;;;;;;AAOA,MAAM,UAAUA,MAAE,QAAQ,CAAC,WAAW,4BAAY,IAAI,KAAK,UAAU,IAAK,CAAC;AAE3E,MAAM,WAAWA,MAAE,OAAO;CACxB,OAAOA,MAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,UAAU;CACnC,cAAcA,MAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,UAAU;CAC1C,WAAW,QAAQ,UAAU;CAC9B,CAAC;AAEF,MAAM,iBAAiBC,iBAAK,KAAK,SAAS;AAK1C,MAAM,eAAe,WAA0B;AAC7C,KAAI;AACF,SAAOC,gBAAG,UAAUC,OAAK,CAAC,aAAa;UAChC,GAAG;AAEV,SAAO;;;;;;;;;AAUX,MAAM,4BAAoC;AACxC,KAAI,QAAQ,IAAI,uBACd,QAAO,QAAQ,IAAI;CAGrB,MAAM,+CAAgC,iBAAiB,CAAC,UAAU;AAYlE,QAV4B;EAC1B,GAAG;EACHA,kBAAK,2BAAc,EAAE,OAAO;EAC5B,8BAAe,MAAM,CAAC,UAAU;EACjC,CAOqB,MAAM,eAAe,YAAY,WAAW,CAAC,IACjE,kBAAkB;;AAItB,MAAa,gBAAgB;AAC3B,KAAI;EACF,MAAM,WAAWA,kBAAK,KAAK,qBAAqB,EAAE,YAAY;AAC9D,SAAO,eAAe,MAAMD,gBAAG,aAAa,UAAU,OAAO,CAAC;SACxD;AACN,SAAO;;;AAIX,SAAgB,iBAAiB,QAAwB;CACvD,MAAM,WAAWC,kBAAK,KAAK,qBAAqB,EAAE,YAAY;AAC9D,iBAAG,UAAUA,kBAAK,QAAQ,SAAS,EAAE,EAAE,WAAW,MAAM,CAAC;CACzD,MAAM,UAAU;EACd,OAAO,OAAO;EACd,WACE,OAAO,aAAa,KAAK,MAAM,OAAO,UAAU,SAAS,GAAG,IAAK;EACnE,cAAc,OAAO;EACtB;AACD,iBAAG,cAAc,UAAU,KAAK,UAAU,QAAQ,GAAG,KAAK"}
@@ -0,0 +1,26 @@
1
+ import { z } from "zod";
2
+
3
+ //#region src/auth/file.d.ts
4
+ declare const AuthFile: z.ZodObject<{
5
+ token: z.ZodOptional<z.ZodString>;
6
+ refreshToken: z.ZodOptional<z.ZodString>;
7
+ expiresAt: z.ZodOptional<z.ZodEffects<z.ZodNumber, Date, number>>;
8
+ }, "strip", z.ZodTypeAny, {
9
+ token?: string | undefined;
10
+ refreshToken?: string | undefined;
11
+ expiresAt?: Date | undefined;
12
+ }, {
13
+ token?: string | undefined;
14
+ refreshToken?: string | undefined;
15
+ expiresAt?: number | undefined;
16
+ }>;
17
+ type AuthFile = z.infer<typeof AuthFile>;
18
+ declare const getAuth: () => {
19
+ token?: string | undefined;
20
+ refreshToken?: string | undefined;
21
+ expiresAt?: Date | undefined;
22
+ } | null;
23
+ declare function updateAuthConfig(config: AuthFile): void;
24
+ //#endregion
25
+ export { getAuth, updateAuthConfig };
26
+ //# sourceMappingURL=file.d.cts.map
@@ -1,22 +1,26 @@
1
1
  import { z } from "zod";
2
+
3
+ //#region src/auth/file.d.ts
2
4
  declare const AuthFile: z.ZodObject<{
3
- token: z.ZodOptional<z.ZodString>;
4
- refreshToken: z.ZodOptional<z.ZodString>;
5
- expiresAt: z.ZodOptional<z.ZodEffects<z.ZodNumber, Date, number>>;
5
+ token: z.ZodOptional<z.ZodString>;
6
+ refreshToken: z.ZodOptional<z.ZodString>;
7
+ expiresAt: z.ZodOptional<z.ZodEffects<z.ZodNumber, Date, number>>;
6
8
  }, "strip", z.ZodTypeAny, {
7
- expiresAt?: Date | undefined;
8
- token?: string | undefined;
9
- refreshToken?: string | undefined;
9
+ token?: string | undefined;
10
+ refreshToken?: string | undefined;
11
+ expiresAt?: Date | undefined;
10
12
  }, {
11
- expiresAt?: number | undefined;
12
- token?: string | undefined;
13
- refreshToken?: string | undefined;
13
+ token?: string | undefined;
14
+ refreshToken?: string | undefined;
15
+ expiresAt?: number | undefined;
14
16
  }>;
15
17
  type AuthFile = z.infer<typeof AuthFile>;
16
- export declare const getAuth: () => {
17
- expiresAt?: Date | undefined;
18
- token?: string | undefined;
19
- refreshToken?: string | undefined;
18
+ declare const getAuth: () => {
19
+ token?: string | undefined;
20
+ refreshToken?: string | undefined;
21
+ expiresAt?: Date | undefined;
20
22
  } | null;
21
- export declare function updateAuthConfig(config: AuthFile): void;
22
- export {};
23
+ declare function updateAuthConfig(config: AuthFile): void;
24
+ //#endregion
25
+ export { getAuth, updateAuthConfig };
26
+ //# sourceMappingURL=file.d.ts.map