@agentdocumentformat/cli 0.7.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.
- package/LICENSE +21 -0
- package/README.md +45 -0
- package/dist/adf.mjs +162 -0
- package/dist/chunks/APEv2Parser-2CNNHMXV.mjs +22 -0
- package/dist/chunks/AiffParser-7BR4RL6G.mjs +162 -0
- package/dist/chunks/App-L5L37JI5.mjs +16747 -0
- package/dist/chunks/AsfParser-VVRSLFOM.mjs +538 -0
- package/dist/chunks/DsdiffParser-CMD4AX7A.mjs +156 -0
- package/dist/chunks/DsfParser-UOGZDS2M.mjs +94 -0
- package/dist/chunks/FlacParser-HB3T3CD4.mjs +23 -0
- package/dist/chunks/MP4Parser-66HBRUSX.mjs +973 -0
- package/dist/chunks/MatroskaParser-J3HUIMEW.mjs +579 -0
- package/dist/chunks/MpegParser-YW6LIUEW.mjs +442 -0
- package/dist/chunks/MusepackParser-PAUSXP7D.mjs +252 -0
- package/dist/chunks/OggParser-NUBV3GWC.mjs +359 -0
- package/dist/chunks/WavPackParser-WQAGT7TC.mjs +171 -0
- package/dist/chunks/WaveParser-EWLQVDX4.mjs +238 -0
- package/dist/chunks/adf-schema-JRU2BTOG.mjs +62 -0
- package/dist/chunks/build-QF5W473T.mjs +60 -0
- package/dist/chunks/chatgpt-subscription-BQGWYZXE.mjs +23 -0
- package/dist/chunks/chunk-2DIECGFL.mjs +6 -0
- package/dist/chunks/chunk-2NAP2ZF7.mjs +60 -0
- package/dist/chunks/chunk-3AT7IIP7.mjs +25696 -0
- package/dist/chunks/chunk-3GNIDM53.mjs +35 -0
- package/dist/chunks/chunk-3M4ZPOA3.mjs +1477 -0
- package/dist/chunks/chunk-4MQPTCXY.mjs +510 -0
- package/dist/chunks/chunk-5PO5PKRV.mjs +366 -0
- package/dist/chunks/chunk-5QU5VY7N.mjs +52 -0
- package/dist/chunks/chunk-5W7KES6P.mjs +436 -0
- package/dist/chunks/chunk-62NE4LG4.mjs +61 -0
- package/dist/chunks/chunk-64OKE4X3.mjs +45 -0
- package/dist/chunks/chunk-6GJ4QHRI.mjs +1278 -0
- package/dist/chunks/chunk-6VQEXLE2.mjs +144 -0
- package/dist/chunks/chunk-6XUV6EK6.mjs +41 -0
- package/dist/chunks/chunk-776TSXEP.mjs +43 -0
- package/dist/chunks/chunk-7CV2SA3H.mjs +285 -0
- package/dist/chunks/chunk-7MTRVW2U.mjs +3103 -0
- package/dist/chunks/chunk-7N2R2VCG.mjs +1434 -0
- package/dist/chunks/chunk-7T2YMTWL.mjs +374 -0
- package/dist/chunks/chunk-7XYNI52E.mjs +149 -0
- package/dist/chunks/chunk-APHX6HSV.mjs +7731 -0
- package/dist/chunks/chunk-APRU6PHC.mjs +40 -0
- package/dist/chunks/chunk-AUYKRQPJ.mjs +499 -0
- package/dist/chunks/chunk-DXWDD5XJ.mjs +136 -0
- package/dist/chunks/chunk-EWL5FG4I.mjs +39 -0
- package/dist/chunks/chunk-EYX2YLJW.mjs +117 -0
- package/dist/chunks/chunk-F5ELW46V.mjs +27 -0
- package/dist/chunks/chunk-G426FACA.mjs +49 -0
- package/dist/chunks/chunk-GEKSJHIV.mjs +2472 -0
- package/dist/chunks/chunk-HBUENVQL.mjs +570 -0
- package/dist/chunks/chunk-HPVFJYXR.mjs +112 -0
- package/dist/chunks/chunk-HWLWPXQ7.mjs +721 -0
- package/dist/chunks/chunk-I2HJYHFT.mjs +665 -0
- package/dist/chunks/chunk-I3UYSITV.mjs +68 -0
- package/dist/chunks/chunk-IC4JDZCI.mjs +3864 -0
- package/dist/chunks/chunk-IHDDCZBS.mjs +112 -0
- package/dist/chunks/chunk-IIGMZHQQ.mjs +10416 -0
- package/dist/chunks/chunk-KWFOS5WC.mjs +41 -0
- package/dist/chunks/chunk-LAZIXV2F.mjs +5290 -0
- package/dist/chunks/chunk-LFMB4PAA.mjs +10814 -0
- package/dist/chunks/chunk-M2RX3S2T.mjs +49 -0
- package/dist/chunks/chunk-M3WPIJYM.mjs +65 -0
- package/dist/chunks/chunk-NBTUWMGP.mjs +263 -0
- package/dist/chunks/chunk-NGK6PVSF.mjs +2676 -0
- package/dist/chunks/chunk-NZ7JTHEO.mjs +85 -0
- package/dist/chunks/chunk-OQN33RGQ.mjs +52 -0
- package/dist/chunks/chunk-RIX34QHC.mjs +2935 -0
- package/dist/chunks/chunk-SGUTYISF.mjs +16 -0
- package/dist/chunks/chunk-SLJ5L7PY.mjs +1473 -0
- package/dist/chunks/chunk-SLUKGXKH.mjs +68 -0
- package/dist/chunks/chunk-TMT32MXT.mjs +419 -0
- package/dist/chunks/chunk-UYY5M2PB.mjs +151 -0
- package/dist/chunks/chunk-VAUOM3IN.mjs +298 -0
- package/dist/chunks/chunk-VMHTYDH4.mjs +172 -0
- package/dist/chunks/chunk-VZS54AA5.mjs +200 -0
- package/dist/chunks/chunk-WFQUVXML.mjs +295 -0
- package/dist/chunks/chunk-X34PDRUH.mjs +809 -0
- package/dist/chunks/chunk-XNPZBLYL.mjs +33 -0
- package/dist/chunks/chunk-XX7OSWTO.mjs +157 -0
- package/dist/chunks/chunk-XYTWGHFS.mjs +600 -0
- package/dist/chunks/chunk-XYV3VCIX.mjs +336 -0
- package/dist/chunks/chunk-Y5ZLKFLE.mjs +1469 -0
- package/dist/chunks/chunk-ZJKXHM4Q.mjs +230 -0
- package/dist/chunks/cli-TCMBNZF6.mjs +1030 -0
- package/dist/chunks/commands-DTEKM4ZL.mjs +20 -0
- package/dist/chunks/daemon-ZC3FZ2P4.mjs +112449 -0
- package/dist/chunks/daemon-control-WDX7PMTC.mjs +300 -0
- package/dist/chunks/daemon-token-WRSULP7G.mjs +23 -0
- package/dist/chunks/devtools-H7CI2ZVG.mjs +85 -0
- package/dist/chunks/discord-IWDQJA7A.mjs +70588 -0
- package/dist/chunks/dist-C57KYFS2.mjs +4952 -0
- package/dist/chunks/dist-I3XBAGDL.mjs +11 -0
- package/dist/chunks/email-V4Q4VJON.mjs +58679 -0
- package/dist/chunks/environment-NX277MQG.mjs +15 -0
- package/dist/chunks/grok-subscription-4PYX7TBF.mjs +19 -0
- package/dist/chunks/layout-EPJQNFAI.mjs +22 -0
- package/dist/chunks/lib-N7FCZWKH.mjs +4038 -0
- package/dist/chunks/open-OTQDGDH5.mjs +36 -0
- package/dist/chunks/parser-JVY2PWSM.mjs +19 -0
- package/dist/chunks/pipeline-executor-BHBSJX2K.mjs +19 -0
- package/dist/chunks/react-IUIDQ5LX.mjs +11 -0
- package/dist/chunks/screen-54BUTYCW.mjs +27 -0
- package/dist/chunks/slack-3L5QTDZX.mjs +8113 -0
- package/dist/chunks/store-WR7TZJZS.mjs +32 -0
- package/dist/chunks/telegram-5ISVFBV3.mjs +14918 -0
- package/dist/chunks/terminal-O5WO7C5U.mjs +48 -0
- package/dist/chunks/theme-NORU4J74.mjs +20 -0
- package/dist/chunks/themes-F2FKU7CP.mjs +23 -0
- package/dist/chunks/token-6G3HCMNX.mjs +54 -0
- package/dist/chunks/token-util-UXYSDQIW.mjs +12 -0
- package/dist/chunks/tui-ODVYUIMT.mjs +197 -0
- package/dist/chunks/welcome-XHXFV7SH.mjs +32 -0
- package/dist/chunks/whatsapp-XSAMNGPJ.mjs +85412 -0
- package/dist/chunks/xterm-headless-YF53XWXE.mjs +3353 -0
- package/package.json +53 -0
- package/resources/wasm/coreutils.LICENSE +18 -0
- package/resources/wasm/coreutils.wasm +0 -0
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import { createRequire as __adfCreateRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __adfFileURLToPath } from 'node:url';
|
|
3
|
+
import { dirname as __adfDirname } from 'node:path';
|
|
4
|
+
const require = __adfCreateRequire(import.meta.url);
|
|
5
|
+
const __filename = __adfFileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = __adfDirname(__filename);
|
|
7
|
+
import {
|
|
8
|
+
require_token_error
|
|
9
|
+
} from "./chunk-KWFOS5WC.mjs";
|
|
10
|
+
import {
|
|
11
|
+
__commonJS,
|
|
12
|
+
__require
|
|
13
|
+
} from "./chunk-M2RX3S2T.mjs";
|
|
14
|
+
|
|
15
|
+
// node_modules/@vercel/oidc/dist/token-io.js
|
|
16
|
+
var require_token_io = __commonJS({
|
|
17
|
+
"node_modules/@vercel/oidc/dist/token-io.js"(exports, module) {
|
|
18
|
+
"use strict";
|
|
19
|
+
var __create = Object.create, __defProp = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __getOwnPropNames = Object.getOwnPropertyNames, __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty, __export = (target, all) => {
|
|
20
|
+
for (var name in all)
|
|
21
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
22
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
23
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
24
|
+
for (let key of __getOwnPropNames(from))
|
|
25
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
26
|
+
return to;
|
|
27
|
+
}, __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
28
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
29
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
30
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
31
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
32
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
33
|
+
mod
|
|
34
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod), token_io_exports = {};
|
|
35
|
+
__export(token_io_exports, {
|
|
36
|
+
findRootDir: () => findRootDir,
|
|
37
|
+
getUserDataDir: () => getUserDataDir
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(token_io_exports);
|
|
40
|
+
var import_path = __toESM(__require("path")), import_fs = __toESM(__require("fs")), import_os = __toESM(__require("os")), import_token_error = require_token_error();
|
|
41
|
+
function findRootDir() {
|
|
42
|
+
try {
|
|
43
|
+
let dir = process.cwd();
|
|
44
|
+
for (; dir !== import_path.default.dirname(dir); ) {
|
|
45
|
+
let pkgPath = import_path.default.join(dir, ".vercel");
|
|
46
|
+
if (import_fs.default.existsSync(pkgPath))
|
|
47
|
+
return dir;
|
|
48
|
+
dir = import_path.default.dirname(dir);
|
|
49
|
+
}
|
|
50
|
+
} catch {
|
|
51
|
+
throw new import_token_error.VercelOidcTokenError(
|
|
52
|
+
"Token refresh only supported in node server environments"
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
function getUserDataDir() {
|
|
58
|
+
if (process.env.XDG_DATA_HOME)
|
|
59
|
+
return process.env.XDG_DATA_HOME;
|
|
60
|
+
switch (import_os.default.platform()) {
|
|
61
|
+
case "darwin":
|
|
62
|
+
return import_path.default.join(import_os.default.homedir(), "Library/Application Support");
|
|
63
|
+
case "linux":
|
|
64
|
+
return import_path.default.join(import_os.default.homedir(), ".local/share");
|
|
65
|
+
case "win32":
|
|
66
|
+
return process.env.LOCALAPPDATA ? process.env.LOCALAPPDATA : null;
|
|
67
|
+
default:
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// node_modules/@vercel/oidc/dist/auth-config.js
|
|
75
|
+
var require_auth_config = __commonJS({
|
|
76
|
+
"node_modules/@vercel/oidc/dist/auth-config.js"(exports, module) {
|
|
77
|
+
"use strict";
|
|
78
|
+
var __create = Object.create, __defProp = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __getOwnPropNames = Object.getOwnPropertyNames, __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty, __export = (target, all) => {
|
|
79
|
+
for (var name in all)
|
|
80
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
81
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
82
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
83
|
+
for (let key of __getOwnPropNames(from))
|
|
84
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
85
|
+
return to;
|
|
86
|
+
}, __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
87
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
88
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
89
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
90
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
91
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
92
|
+
mod
|
|
93
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod), auth_config_exports = {};
|
|
94
|
+
__export(auth_config_exports, {
|
|
95
|
+
isValidAccessToken: () => isValidAccessToken,
|
|
96
|
+
readAuthConfig: () => readAuthConfig,
|
|
97
|
+
writeAuthConfig: () => writeAuthConfig
|
|
98
|
+
});
|
|
99
|
+
module.exports = __toCommonJS(auth_config_exports);
|
|
100
|
+
var fs = __toESM(__require("fs")), path = __toESM(__require("path")), import_token_util = require_token_util();
|
|
101
|
+
function getAuthConfigPath() {
|
|
102
|
+
let dataDir = (0, import_token_util.getVercelDataDir)();
|
|
103
|
+
if (!dataDir)
|
|
104
|
+
throw new Error(
|
|
105
|
+
`Unable to find Vercel CLI data directory. Your platform: ${process.platform}. Supported: darwin, linux, win32.`
|
|
106
|
+
);
|
|
107
|
+
return path.join(dataDir, "auth.json");
|
|
108
|
+
}
|
|
109
|
+
function readAuthConfig() {
|
|
110
|
+
try {
|
|
111
|
+
let authPath = getAuthConfigPath();
|
|
112
|
+
if (!fs.existsSync(authPath))
|
|
113
|
+
return null;
|
|
114
|
+
let content = fs.readFileSync(authPath, "utf8");
|
|
115
|
+
return content ? JSON.parse(content) : null;
|
|
116
|
+
} catch {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function writeAuthConfig(config) {
|
|
121
|
+
let authPath = getAuthConfigPath(), authDir = path.dirname(authPath);
|
|
122
|
+
fs.existsSync(authDir) || fs.mkdirSync(authDir, { mode: 504, recursive: !0 }), fs.writeFileSync(authPath, JSON.stringify(config, null, 2), { mode: 384 });
|
|
123
|
+
}
|
|
124
|
+
function isValidAccessToken(authConfig) {
|
|
125
|
+
if (!authConfig.token)
|
|
126
|
+
return !1;
|
|
127
|
+
if (typeof authConfig.expiresAt != "number")
|
|
128
|
+
return !0;
|
|
129
|
+
let nowInSeconds = Math.floor(Date.now() / 1e3);
|
|
130
|
+
return authConfig.expiresAt >= nowInSeconds;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
// node_modules/@vercel/oidc/dist/oauth.js
|
|
136
|
+
var require_oauth = __commonJS({
|
|
137
|
+
"node_modules/@vercel/oidc/dist/oauth.js"(exports, module) {
|
|
138
|
+
"use strict";
|
|
139
|
+
var __defProp = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __getOwnPropNames = Object.getOwnPropertyNames, __hasOwnProp = Object.prototype.hasOwnProperty, __export = (target, all) => {
|
|
140
|
+
for (var name in all)
|
|
141
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
142
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
143
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
144
|
+
for (let key of __getOwnPropNames(from))
|
|
145
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
146
|
+
return to;
|
|
147
|
+
}, __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod), oauth_exports = {};
|
|
148
|
+
__export(oauth_exports, {
|
|
149
|
+
processTokenResponse: () => processTokenResponse,
|
|
150
|
+
refreshTokenRequest: () => refreshTokenRequest
|
|
151
|
+
});
|
|
152
|
+
module.exports = __toCommonJS(oauth_exports);
|
|
153
|
+
var import_os = __require("os"), VERCEL_ISSUER = "https://vercel.com", VERCEL_CLI_CLIENT_ID = "cl_HYyOPBNtFMfHhaUn9L4QPfTZz6TP47bp", userAgent = `@vercel/oidc node-${process.version} ${(0, import_os.platform)()} (${(0, import_os.arch)()}) ${(0, import_os.hostname)()}`, _tokenEndpoint = null;
|
|
154
|
+
async function getTokenEndpoint() {
|
|
155
|
+
if (_tokenEndpoint)
|
|
156
|
+
return _tokenEndpoint;
|
|
157
|
+
let discoveryUrl = `${VERCEL_ISSUER}/.well-known/openid-configuration`, response = await fetch(discoveryUrl, {
|
|
158
|
+
headers: { "user-agent": userAgent }
|
|
159
|
+
});
|
|
160
|
+
if (!response.ok)
|
|
161
|
+
throw new Error("Failed to discover OAuth endpoints");
|
|
162
|
+
let metadata = await response.json();
|
|
163
|
+
if (!metadata || typeof metadata.token_endpoint != "string")
|
|
164
|
+
throw new Error("Invalid OAuth discovery response");
|
|
165
|
+
let endpoint = metadata.token_endpoint;
|
|
166
|
+
return _tokenEndpoint = endpoint, endpoint;
|
|
167
|
+
}
|
|
168
|
+
async function refreshTokenRequest(options) {
|
|
169
|
+
let tokenEndpoint = await getTokenEndpoint();
|
|
170
|
+
return await fetch(tokenEndpoint, {
|
|
171
|
+
method: "POST",
|
|
172
|
+
headers: {
|
|
173
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
174
|
+
"user-agent": userAgent
|
|
175
|
+
},
|
|
176
|
+
body: new URLSearchParams({
|
|
177
|
+
client_id: VERCEL_CLI_CLIENT_ID,
|
|
178
|
+
grant_type: "refresh_token",
|
|
179
|
+
...options
|
|
180
|
+
})
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
async function processTokenResponse(response) {
|
|
184
|
+
let json = await response.json();
|
|
185
|
+
if (!response.ok) {
|
|
186
|
+
let errorMsg = typeof json == "object" && json && "error" in json ? String(json.error) : "Token refresh failed";
|
|
187
|
+
return [new Error(errorMsg)];
|
|
188
|
+
}
|
|
189
|
+
return typeof json != "object" || json === null ? [new Error("Invalid token response")] : typeof json.access_token != "string" ? [new Error("Missing access_token in response")] : json.token_type !== "Bearer" ? [new Error("Invalid token_type in response")] : typeof json.expires_in != "number" ? [new Error("Missing expires_in in response")] : [null, json];
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
// node_modules/@vercel/oidc/dist/token-util.js
|
|
195
|
+
var require_token_util = __commonJS({
|
|
196
|
+
"node_modules/@vercel/oidc/dist/token-util.js"(exports, module) {
|
|
197
|
+
var __create = Object.create, __defProp = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __getOwnPropNames = Object.getOwnPropertyNames, __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty, __export = (target, all) => {
|
|
198
|
+
for (var name in all)
|
|
199
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
200
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
201
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
202
|
+
for (let key of __getOwnPropNames(from))
|
|
203
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
204
|
+
return to;
|
|
205
|
+
}, __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
206
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
207
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
208
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
209
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
210
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
211
|
+
mod
|
|
212
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod), token_util_exports = {};
|
|
213
|
+
__export(token_util_exports, {
|
|
214
|
+
assertVercelOidcTokenResponse: () => assertVercelOidcTokenResponse,
|
|
215
|
+
findProjectInfo: () => findProjectInfo,
|
|
216
|
+
getTokenPayload: () => getTokenPayload,
|
|
217
|
+
getVercelCliToken: () => getVercelCliToken,
|
|
218
|
+
getVercelDataDir: () => getVercelDataDir,
|
|
219
|
+
getVercelOidcToken: () => getVercelOidcToken,
|
|
220
|
+
isExpired: () => isExpired,
|
|
221
|
+
loadToken: () => loadToken,
|
|
222
|
+
saveToken: () => saveToken
|
|
223
|
+
});
|
|
224
|
+
module.exports = __toCommonJS(token_util_exports);
|
|
225
|
+
var path = __toESM(__require("path")), fs = __toESM(__require("fs")), import_token_error = require_token_error(), import_token_io = require_token_io(), import_auth_config = require_auth_config(), import_oauth = require_oauth();
|
|
226
|
+
function getVercelDataDir() {
|
|
227
|
+
let vercelFolder = "com.vercel.cli", dataDir = (0, import_token_io.getUserDataDir)();
|
|
228
|
+
return dataDir ? path.join(dataDir, vercelFolder) : null;
|
|
229
|
+
}
|
|
230
|
+
async function getVercelCliToken() {
|
|
231
|
+
let authConfig = (0, import_auth_config.readAuthConfig)();
|
|
232
|
+
if (!authConfig)
|
|
233
|
+
return null;
|
|
234
|
+
if ((0, import_auth_config.isValidAccessToken)(authConfig))
|
|
235
|
+
return authConfig.token || null;
|
|
236
|
+
if (!authConfig.refreshToken)
|
|
237
|
+
return (0, import_auth_config.writeAuthConfig)({}), null;
|
|
238
|
+
try {
|
|
239
|
+
let tokenResponse = await (0, import_oauth.refreshTokenRequest)({
|
|
240
|
+
refresh_token: authConfig.refreshToken
|
|
241
|
+
}), [tokensError, tokens] = await (0, import_oauth.processTokenResponse)(tokenResponse);
|
|
242
|
+
if (tokensError || !tokens)
|
|
243
|
+
return (0, import_auth_config.writeAuthConfig)({}), null;
|
|
244
|
+
let updatedConfig = {
|
|
245
|
+
token: tokens.access_token,
|
|
246
|
+
expiresAt: Math.floor(Date.now() / 1e3) + tokens.expires_in
|
|
247
|
+
};
|
|
248
|
+
return tokens.refresh_token && (updatedConfig.refreshToken = tokens.refresh_token), (0, import_auth_config.writeAuthConfig)(updatedConfig), updatedConfig.token ?? null;
|
|
249
|
+
} catch {
|
|
250
|
+
return (0, import_auth_config.writeAuthConfig)({}), null;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
async function getVercelOidcToken(authToken, projectId, teamId) {
|
|
254
|
+
let url = `https://api.vercel.com/v1/projects/${projectId}/token?source=vercel-oidc-refresh${teamId ? `&teamId=${teamId}` : ""}`, res = await fetch(url, {
|
|
255
|
+
method: "POST",
|
|
256
|
+
headers: {
|
|
257
|
+
Authorization: `Bearer ${authToken}`
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
if (!res.ok)
|
|
261
|
+
throw new import_token_error.VercelOidcTokenError(
|
|
262
|
+
`Failed to refresh OIDC token: ${res.statusText}`
|
|
263
|
+
);
|
|
264
|
+
let tokenRes = await res.json();
|
|
265
|
+
return assertVercelOidcTokenResponse(tokenRes), tokenRes;
|
|
266
|
+
}
|
|
267
|
+
function assertVercelOidcTokenResponse(res) {
|
|
268
|
+
if (!res || typeof res != "object")
|
|
269
|
+
throw new TypeError(
|
|
270
|
+
"Vercel OIDC token is malformed. Expected an object. Please run `vc env pull` and try again"
|
|
271
|
+
);
|
|
272
|
+
if (!("token" in res) || typeof res.token != "string")
|
|
273
|
+
throw new TypeError(
|
|
274
|
+
"Vercel OIDC token is malformed. Expected a string-valued token property. Please run `vc env pull` and try again"
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
function findProjectInfo() {
|
|
278
|
+
let dir = (0, import_token_io.findRootDir)();
|
|
279
|
+
if (!dir)
|
|
280
|
+
throw new import_token_error.VercelOidcTokenError(
|
|
281
|
+
"Unable to find project root directory. Have you linked your project with `vc link?`"
|
|
282
|
+
);
|
|
283
|
+
let prjPath = path.join(dir, ".vercel", "project.json");
|
|
284
|
+
if (!fs.existsSync(prjPath))
|
|
285
|
+
throw new import_token_error.VercelOidcTokenError(
|
|
286
|
+
"project.json not found, have you linked your project with `vc link?`"
|
|
287
|
+
);
|
|
288
|
+
let prj = JSON.parse(fs.readFileSync(prjPath, "utf8"));
|
|
289
|
+
if (typeof prj.projectId != "string" && typeof prj.orgId != "string")
|
|
290
|
+
throw new TypeError(
|
|
291
|
+
"Expected a string-valued projectId property. Try running `vc link` to re-link your project."
|
|
292
|
+
);
|
|
293
|
+
return { projectId: prj.projectId, teamId: prj.orgId };
|
|
294
|
+
}
|
|
295
|
+
function saveToken(token, projectId) {
|
|
296
|
+
let dir = (0, import_token_io.getUserDataDir)();
|
|
297
|
+
if (!dir)
|
|
298
|
+
throw new import_token_error.VercelOidcTokenError(
|
|
299
|
+
"Unable to find user data directory. Please reach out to Vercel support."
|
|
300
|
+
);
|
|
301
|
+
let tokenPath = path.join(dir, "com.vercel.token", `${projectId}.json`), tokenJson = JSON.stringify(token);
|
|
302
|
+
fs.mkdirSync(path.dirname(tokenPath), { mode: 504, recursive: !0 }), fs.writeFileSync(tokenPath, tokenJson), fs.chmodSync(tokenPath, 432);
|
|
303
|
+
}
|
|
304
|
+
function loadToken(projectId) {
|
|
305
|
+
let dir = (0, import_token_io.getUserDataDir)();
|
|
306
|
+
if (!dir)
|
|
307
|
+
throw new import_token_error.VercelOidcTokenError(
|
|
308
|
+
"Unable to find user data directory. Please reach out to Vercel support."
|
|
309
|
+
);
|
|
310
|
+
let tokenPath = path.join(dir, "com.vercel.token", `${projectId}.json`);
|
|
311
|
+
if (!fs.existsSync(tokenPath))
|
|
312
|
+
return null;
|
|
313
|
+
let token = JSON.parse(fs.readFileSync(tokenPath, "utf8"));
|
|
314
|
+
return assertVercelOidcTokenResponse(token), token;
|
|
315
|
+
}
|
|
316
|
+
function getTokenPayload(token) {
|
|
317
|
+
let tokenParts = token.split(".");
|
|
318
|
+
if (tokenParts.length !== 3)
|
|
319
|
+
throw new import_token_error.VercelOidcTokenError(
|
|
320
|
+
"Invalid token. Please run `vc env pull` and try again"
|
|
321
|
+
);
|
|
322
|
+
let base64 = tokenParts[1].replace(/-/g, "+").replace(/_/g, "/"), padded = base64.padEnd(
|
|
323
|
+
base64.length + (4 - base64.length % 4) % 4,
|
|
324
|
+
"="
|
|
325
|
+
);
|
|
326
|
+
return JSON.parse(Buffer.from(padded, "base64").toString("utf8"));
|
|
327
|
+
}
|
|
328
|
+
function isExpired(token) {
|
|
329
|
+
return token.exp * 1e3 < Date.now();
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
export {
|
|
335
|
+
require_token_util
|
|
336
|
+
};
|