@sentry/mcp-server 0.41.0 → 0.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -0
- package/dist/sentry-mcp.cjs +3436 -0
- package/package.json +22 -40
- package/LICENSE.md +0 -105
- package/dist/auth/constants.cjs +0 -9
- package/dist/auth/constants.d.cts +0 -31
- package/dist/auth/constants.d.cts.map +0 -1
- package/dist/auth/constants.d.ts +0 -31
- package/dist/auth/constants.d.ts.map +0 -1
- package/dist/auth/constants.js +0 -3
- package/dist/auth/device-code-flow.cjs +0 -10
- package/dist/auth/device-code-flow.d.cts +0 -34
- package/dist/auth/device-code-flow.d.cts.map +0 -1
- package/dist/auth/device-code-flow.d.ts +0 -34
- package/dist/auth/device-code-flow.d.ts.map +0 -1
- package/dist/auth/device-code-flow.js +0 -6
- package/dist/auth/resolve-token.cjs +0 -8
- package/dist/auth/resolve-token.d.cts +0 -17
- package/dist/auth/resolve-token.d.cts.map +0 -1
- package/dist/auth/resolve-token.d.ts +0 -17
- package/dist/auth/resolve-token.d.ts.map +0 -1
- package/dist/auth/resolve-token.js +0 -8
- package/dist/auth/token-cache.cjs +0 -5
- package/dist/auth/token-cache.d.cts +0 -11
- package/dist/auth/token-cache.d.cts.map +0 -1
- package/dist/auth/token-cache.d.ts +0 -11
- package/dist/auth/token-cache.d.ts.map +0 -1
- package/dist/auth/token-cache.js +0 -3
- package/dist/auth/types.cjs +0 -7
- package/dist/auth/types.d.cts +0 -2
- package/dist/auth/types.d.ts +0 -2
- package/dist/auth/types.js +0 -3
- package/dist/auth-CYOpb-jm.cjs +0 -90
- package/dist/auth-CYOpb-jm.cjs.map +0 -1
- package/dist/auth-YZqLxyqD.js +0 -79
- package/dist/auth-YZqLxyqD.js.map +0 -1
- package/dist/blob-utils-B0ae0K-m-BF8kTomr.cjs +0 -4724
- package/dist/blob-utils-B0ae0K-m-BF8kTomr.cjs.map +0 -1
- package/dist/blob-utils-B0ae0K-m-BhC2W04C.js +0 -4701
- package/dist/blob-utils-B0ae0K-m-BhC2W04C.js.map +0 -1
- package/dist/blob-utils-BM8EcgEO.js +0 -3
- package/dist/blob-utils-DBvCs9nw.cjs +0 -3
- package/dist/chunk-CunrlGP7.js +0 -37
- package/dist/chunk-Cv9WC9bY.cjs +0 -58
- package/dist/cli/commands/auth.cjs +0 -11
- package/dist/cli/commands/auth.d.cts +0 -8
- package/dist/cli/commands/auth.d.cts.map +0 -1
- package/dist/cli/commands/auth.d.ts +0 -8
- package/dist/cli/commands/auth.d.ts.map +0 -1
- package/dist/cli/commands/auth.js +0 -10
- package/dist/cli/output.cjs +0 -3
- package/dist/cli/output.d.cts +0 -7
- package/dist/cli/output.d.cts.map +0 -1
- package/dist/cli/output.d.ts +0 -7
- package/dist/cli/output.d.ts.map +0 -1
- package/dist/cli/output.js +0 -3
- package/dist/cli/parse.cjs +0 -5
- package/dist/cli/parse.d.cts +0 -11
- package/dist/cli/parse.d.cts.map +0 -1
- package/dist/cli/parse.d.ts +0 -11
- package/dist/cli/parse.d.ts.map +0 -1
- package/dist/cli/parse.js +0 -3
- package/dist/cli/resolve.cjs +0 -6
- package/dist/cli/resolve.d.cts +0 -16
- package/dist/cli/resolve.d.cts.map +0 -1
- package/dist/cli/resolve.d.ts +0 -16
- package/dist/cli/resolve.d.ts.map +0 -1
- package/dist/cli/resolve.js +0 -4
- package/dist/cli/types.cjs +0 -0
- package/dist/cli/types.d.cts +0 -2
- package/dist/cli/types.d.ts +0 -2
- package/dist/cli/types.js +0 -0
- package/dist/cli/usage.cjs +0 -3
- package/dist/cli/usage.d.cts +0 -9
- package/dist/cli/usage.d.cts.map +0 -1
- package/dist/cli/usage.d.ts +0 -9
- package/dist/cli/usage.d.ts.map +0 -1
- package/dist/cli/usage.js +0 -3
- package/dist/config-40SaJWzQ-Bxau3bPR.cjs +0 -928
- package/dist/config-40SaJWzQ-Bxau3bPR.cjs.map +0 -1
- package/dist/config-40SaJWzQ-Dz27jdMQ.js +0 -886
- package/dist/config-40SaJWzQ-Dz27jdMQ.js.map +0 -1
- package/dist/config-DeGbV11k.cjs +0 -7
- package/dist/config-NGx6OsOU.js +0 -3
- package/dist/constants-BqO-QSHl.cjs +0 -636
- package/dist/constants-BqO-QSHl.cjs.map +0 -1
- package/dist/constants-Da7VwSRQ.js +0 -450
- package/dist/constants-Da7VwSRQ.js.map +0 -1
- package/dist/device-code-flow-Bk6L232R.js +0 -124
- package/dist/device-code-flow-Bk6L232R.js.map +0 -1
- package/dist/device-code-flow-Dv-auCiV.cjs +0 -154
- package/dist/device-code-flow-Dv-auCiV.cjs.map +0 -1
- package/dist/index.cjs +0 -61541
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -61542
- package/dist/index.js.map +0 -1
- package/dist/output-A_-7o7gV.js +0 -8
- package/dist/output-A_-7o7gV.js.map +0 -1
- package/dist/output-DEoNyYz7.cjs +0 -14
- package/dist/output-DEoNyYz7.cjs.map +0 -1
- package/dist/parse-CPY7-_2_.cjs +0 -130
- package/dist/parse-CPY7-_2_.cjs.map +0 -1
- package/dist/parse-Dd3OOgIq.js +0 -112
- package/dist/parse-Dd3OOgIq.js.map +0 -1
- package/dist/resolve-CZUghJrC.cjs +0 -179
- package/dist/resolve-CZUghJrC.cjs.map +0 -1
- package/dist/resolve-CkkdMFiR.js +0 -144
- package/dist/resolve-CkkdMFiR.js.map +0 -1
- package/dist/resolve-token-4RkU7UPe.js +0 -47
- package/dist/resolve-token-4RkU7UPe.js.map +0 -1
- package/dist/resolve-token-Daqu57f-.cjs +0 -52
- package/dist/resolve-token-Daqu57f-.cjs.map +0 -1
- package/dist/stdio-4lgW_97D.cjs +0 -65
- package/dist/stdio-4lgW_97D.cjs.map +0 -1
- package/dist/stdio-C0wKX460.js +0 -59
- package/dist/stdio-C0wKX460.js.map +0 -1
- package/dist/token-3xpHVxQo.js +0 -51
- package/dist/token-3xpHVxQo.js.map +0 -1
- package/dist/token-C7MavkKX.cjs +0 -55
- package/dist/token-C7MavkKX.cjs.map +0 -1
- package/dist/token-cache-ATUcs1cg.cjs +0 -84
- package/dist/token-cache-ATUcs1cg.cjs.map +0 -1
- package/dist/token-cache-DbZp4rvg.js +0 -66
- package/dist/token-cache-DbZp4rvg.js.map +0 -1
- package/dist/token-error-CBmJNKLY.js +0 -43
- package/dist/token-error-CBmJNKLY.js.map +0 -1
- package/dist/token-error-x_miDBP3.cjs +0 -48
- package/dist/token-error-x_miDBP3.cjs.map +0 -1
- package/dist/token-util-4bIYDTMS.js +0 -4
- package/dist/token-util-BRoQwIG6.cjs +0 -363
- package/dist/token-util-BRoQwIG6.cjs.map +0 -1
- package/dist/token-util-DurDL44i.cjs +0 -9
- package/dist/token-util-batRsXGA.js +0 -358
- package/dist/token-util-batRsXGA.js.map +0 -1
- package/dist/transports/stdio.cjs +0 -4
- package/dist/transports/stdio.d.cts +0 -40
- package/dist/transports/stdio.d.cts.map +0 -1
- package/dist/transports/stdio.d.ts +0 -40
- package/dist/transports/stdio.d.ts.map +0 -1
- package/dist/transports/stdio.js +0 -4
- package/dist/types-BCSxlxZI.js +0 -57
- package/dist/types-BCSxlxZI.js.map +0 -1
- package/dist/types-BGyk9F4G.d.ts +0 -61
- package/dist/types-BGyk9F4G.d.ts.map +0 -1
- package/dist/types-C9HgNyIE.d.cts +0 -61
- package/dist/types-C9HgNyIE.d.cts.map +0 -1
- package/dist/types-D-BIcaY4.d.ts +0 -91
- package/dist/types-D-BIcaY4.d.ts.map +0 -1
- package/dist/types-Dyacb-A8.d.cts +0 -91
- package/dist/types-Dyacb-A8.d.cts.map +0 -1
- package/dist/types-dghCRFW4.cjs +0 -87
- package/dist/types-dghCRFW4.cjs.map +0 -1
- package/dist/usage-DZ4QDygT.cjs +0 -74
- package/dist/usage-DZ4QDygT.cjs.map +0 -1
- package/dist/usage-Hi-6-LDr.js +0 -68
- package/dist/usage-Hi-6-LDr.js.map +0 -1
- package/dist/version-B-XjWQrQ.cjs +0 -19
- package/dist/version-B-XjWQrQ.cjs.map +0 -1
- package/dist/version-CWKzsUXy.js +0 -7
- package/dist/version-CWKzsUXy.js.map +0 -1
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
const require_chunk = require('./chunk-Cv9WC9bY.cjs');
|
|
2
|
-
const node_fs_promises = require_chunk.__toESM(require("node:fs/promises"));
|
|
3
|
-
const node_path = require_chunk.__toESM(require("node:path"));
|
|
4
|
-
const node_os = require_chunk.__toESM(require("node:os"));
|
|
5
|
-
|
|
6
|
-
//#region src/auth/token-cache.ts
|
|
7
|
-
/** Safety window: treat tokens as expired 5 minutes before actual expiry. */
|
|
8
|
-
const EXPIRY_SAFETY_MS = 5 * 60 * 1e3;
|
|
9
|
-
function getCacheFilePath() {
|
|
10
|
-
if (process.env.SENTRY_MCP_AUTH_CACHE) return process.env.SENTRY_MCP_AUTH_CACHE;
|
|
11
|
-
return node_path.join(node_os.homedir(), ".sentry", "mcp.json");
|
|
12
|
-
}
|
|
13
|
-
function cacheKey(host, clientId) {
|
|
14
|
-
return `${host}:${clientId}`;
|
|
15
|
-
}
|
|
16
|
-
async function readCacheFile() {
|
|
17
|
-
try {
|
|
18
|
-
const raw = await node_fs_promises.readFile(getCacheFilePath(), "utf-8");
|
|
19
|
-
return JSON.parse(raw);
|
|
20
|
-
} catch {
|
|
21
|
-
return {};
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
async function writeCacheFile(data) {
|
|
25
|
-
const filePath = getCacheFilePath();
|
|
26
|
-
const dir = node_path.dirname(filePath);
|
|
27
|
-
await node_fs_promises.mkdir(dir, {
|
|
28
|
-
recursive: true,
|
|
29
|
-
mode: 448
|
|
30
|
-
});
|
|
31
|
-
const tmpPath = `${filePath}.tmp.${process.pid}`;
|
|
32
|
-
await node_fs_promises.writeFile(tmpPath, JSON.stringify(data, null, 2), {
|
|
33
|
-
encoding: "utf-8",
|
|
34
|
-
mode: 384
|
|
35
|
-
});
|
|
36
|
-
await node_fs_promises.rename(tmpPath, filePath);
|
|
37
|
-
}
|
|
38
|
-
async function readCachedToken(host, clientId) {
|
|
39
|
-
const data = await readCacheFile();
|
|
40
|
-
const key = cacheKey(host, clientId);
|
|
41
|
-
const entry = data[key];
|
|
42
|
-
if (!entry) return null;
|
|
43
|
-
const expiresAt = new Date(entry.expires_at).getTime();
|
|
44
|
-
if (!Number.isFinite(expiresAt) || expiresAt - Date.now() <= EXPIRY_SAFETY_MS) {
|
|
45
|
-
delete data[key];
|
|
46
|
-
await writeCacheFile(data);
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
return entry;
|
|
50
|
-
}
|
|
51
|
-
async function writeCachedToken(token) {
|
|
52
|
-
const data = await readCacheFile();
|
|
53
|
-
data[cacheKey(token.sentry_host, token.client_id)] = token;
|
|
54
|
-
await writeCacheFile(data);
|
|
55
|
-
}
|
|
56
|
-
async function clearCachedToken(host, clientId) {
|
|
57
|
-
const data = await readCacheFile();
|
|
58
|
-
const key = cacheKey(host, clientId);
|
|
59
|
-
if (key in data) {
|
|
60
|
-
delete data[key];
|
|
61
|
-
await writeCacheFile(data);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
//#endregion
|
|
66
|
-
Object.defineProperty(exports, 'clearCachedToken', {
|
|
67
|
-
enumerable: true,
|
|
68
|
-
get: function () {
|
|
69
|
-
return clearCachedToken;
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
Object.defineProperty(exports, 'readCachedToken', {
|
|
73
|
-
enumerable: true,
|
|
74
|
-
get: function () {
|
|
75
|
-
return readCachedToken;
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
Object.defineProperty(exports, 'writeCachedToken', {
|
|
79
|
-
enumerable: true,
|
|
80
|
-
get: function () {
|
|
81
|
-
return writeCachedToken;
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
//# sourceMappingURL=token-cache-ATUcs1cg.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"token-cache-ATUcs1cg.cjs","names":["host: string","clientId: string","data: CacheFile","token: CachedToken"],"sources":["../src/auth/token-cache.ts"],"sourcesContent":["/**\n * Persistent token cache for device code auth.\n * Tokens are stored at ~/.sentry/mcp.json, keyed by {host}:{clientId}.\n * See docs/operations/stdio-auth.md for cache format and security details.\n */\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport * as os from \"node:os\";\nimport type { CachedToken } from \"./types\";\n\n/** Safety window: treat tokens as expired 5 minutes before actual expiry. */\nconst EXPIRY_SAFETY_MS = 5 * 60 * 1000;\n\nfunction getCacheFilePath(): string {\n if (process.env.SENTRY_MCP_AUTH_CACHE) {\n return process.env.SENTRY_MCP_AUTH_CACHE;\n }\n return path.join(os.homedir(), \".sentry\", \"mcp.json\");\n}\n\nfunction cacheKey(host: string, clientId: string): string {\n return `${host}:${clientId}`;\n}\n\ntype CacheFile = Record<string, CachedToken>;\n\nasync function readCacheFile(): Promise<CacheFile> {\n try {\n const raw = await fs.readFile(getCacheFilePath(), \"utf-8\");\n return JSON.parse(raw) as CacheFile;\n } catch {\n return {};\n }\n}\n\nasync function writeCacheFile(data: CacheFile): Promise<void> {\n const filePath = getCacheFilePath();\n const dir = path.dirname(filePath);\n\n await fs.mkdir(dir, { recursive: true, mode: 0o700 });\n\n // Atomic write: write to temp file then rename\n const tmpPath = `${filePath}.tmp.${process.pid}`;\n await fs.writeFile(tmpPath, JSON.stringify(data, null, 2), {\n encoding: \"utf-8\",\n mode: 0o600,\n });\n await fs.rename(tmpPath, filePath);\n}\n\nexport async function readCachedToken(\n host: string,\n clientId: string,\n): Promise<CachedToken | null> {\n const data = await readCacheFile();\n const key = cacheKey(host, clientId);\n const entry = data[key];\n if (!entry) return null;\n\n const expiresAt = new Date(entry.expires_at).getTime();\n if (\n !Number.isFinite(expiresAt) ||\n expiresAt - Date.now() <= EXPIRY_SAFETY_MS\n ) {\n delete data[key];\n await writeCacheFile(data);\n return null;\n }\n\n return entry;\n}\n\nexport async function writeCachedToken(token: CachedToken): Promise<void> {\n const data = await readCacheFile();\n data[cacheKey(token.sentry_host, token.client_id)] = token;\n await writeCacheFile(data);\n}\n\nexport async function clearCachedToken(\n host: string,\n clientId: string,\n): Promise<void> {\n const data = await readCacheFile();\n const key = cacheKey(host, clientId);\n if (key in data) {\n delete data[key];\n await writeCacheFile(data);\n }\n}\n"],"mappings":";;;;;;;AAWA,MAAM,mBAAmB,IAAI,KAAK;AAElC,SAAS,mBAA2B;AAClC,KAAI,QAAQ,IAAI,sBACd,QAAO,QAAQ,IAAI;AAErB,QAAO,UAAK,KAAK,QAAG,SAAS,EAAE,WAAW,WAAW;AACtD;AAED,SAAS,SAASA,MAAcC,UAA0B;AACxD,WAAU,KAAK,GAAG;AACnB;AAID,eAAe,gBAAoC;AACjD,KAAI;EACF,MAAM,MAAM,MAAM,iBAAG,SAAS,kBAAkB,EAAE,QAAQ;AAC1D,SAAO,KAAK,MAAM,IAAI;CACvB,QAAO;AACN,SAAO,CAAE;CACV;AACF;AAED,eAAe,eAAeC,MAAgC;CAC5D,MAAM,WAAW,kBAAkB;CACnC,MAAM,MAAM,UAAK,QAAQ,SAAS;AAElC,OAAM,iBAAG,MAAM,KAAK;EAAE,WAAW;EAAM,MAAM;CAAO,EAAC;CAGrD,MAAM,aAAa,SAAS,OAAO,QAAQ;AAC3C,OAAM,iBAAG,UAAU,SAAS,KAAK,UAAU,MAAM,MAAM,EAAE,EAAE;EACzD,UAAU;EACV,MAAM;CACP,EAAC;AACF,OAAM,iBAAG,OAAO,SAAS,SAAS;AACnC;AAED,eAAsB,gBACpBF,MACAC,UAC6B;CAC7B,MAAM,OAAO,MAAM,eAAe;CAClC,MAAM,MAAM,SAAS,MAAM,SAAS;CACpC,MAAM,QAAQ,KAAK;AACnB,MAAK,MAAO,QAAO;CAEnB,MAAM,YAAY,IAAI,KAAK,MAAM,YAAY,SAAS;AACtD,MACG,OAAO,SAAS,UAAU,IAC3B,YAAY,KAAK,KAAK,IAAI,kBAC1B;AACA,SAAO,KAAK;AACZ,QAAM,eAAe,KAAK;AAC1B,SAAO;CACR;AAED,QAAO;AACR;AAED,eAAsB,iBAAiBE,OAAmC;CACxE,MAAM,OAAO,MAAM,eAAe;AAClC,MAAK,SAAS,MAAM,aAAa,MAAM,UAAU,IAAI;AACrD,OAAM,eAAe,KAAK;AAC3B;AAED,eAAsB,iBACpBH,MACAC,UACe;CACf,MAAM,OAAO,MAAM,eAAe;CAClC,MAAM,MAAM,SAAS,MAAM,SAAS;AACpC,KAAI,OAAO,MAAM;AACf,SAAO,KAAK;AACZ,QAAM,eAAe,KAAK;CAC3B;AACF"}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import * as fs from "node:fs/promises";
|
|
2
|
-
import * as path from "node:path";
|
|
3
|
-
import * as os from "node:os";
|
|
4
|
-
|
|
5
|
-
//#region src/auth/token-cache.ts
|
|
6
|
-
/** Safety window: treat tokens as expired 5 minutes before actual expiry. */
|
|
7
|
-
const EXPIRY_SAFETY_MS = 5 * 60 * 1e3;
|
|
8
|
-
function getCacheFilePath() {
|
|
9
|
-
if (process.env.SENTRY_MCP_AUTH_CACHE) return process.env.SENTRY_MCP_AUTH_CACHE;
|
|
10
|
-
return path.join(os.homedir(), ".sentry", "mcp.json");
|
|
11
|
-
}
|
|
12
|
-
function cacheKey(host, clientId) {
|
|
13
|
-
return `${host}:${clientId}`;
|
|
14
|
-
}
|
|
15
|
-
async function readCacheFile() {
|
|
16
|
-
try {
|
|
17
|
-
const raw = await fs.readFile(getCacheFilePath(), "utf-8");
|
|
18
|
-
return JSON.parse(raw);
|
|
19
|
-
} catch {
|
|
20
|
-
return {};
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
async function writeCacheFile(data) {
|
|
24
|
-
const filePath = getCacheFilePath();
|
|
25
|
-
const dir = path.dirname(filePath);
|
|
26
|
-
await fs.mkdir(dir, {
|
|
27
|
-
recursive: true,
|
|
28
|
-
mode: 448
|
|
29
|
-
});
|
|
30
|
-
const tmpPath = `${filePath}.tmp.${process.pid}`;
|
|
31
|
-
await fs.writeFile(tmpPath, JSON.stringify(data, null, 2), {
|
|
32
|
-
encoding: "utf-8",
|
|
33
|
-
mode: 384
|
|
34
|
-
});
|
|
35
|
-
await fs.rename(tmpPath, filePath);
|
|
36
|
-
}
|
|
37
|
-
async function readCachedToken(host, clientId) {
|
|
38
|
-
const data = await readCacheFile();
|
|
39
|
-
const key = cacheKey(host, clientId);
|
|
40
|
-
const entry = data[key];
|
|
41
|
-
if (!entry) return null;
|
|
42
|
-
const expiresAt = new Date(entry.expires_at).getTime();
|
|
43
|
-
if (!Number.isFinite(expiresAt) || expiresAt - Date.now() <= EXPIRY_SAFETY_MS) {
|
|
44
|
-
delete data[key];
|
|
45
|
-
await writeCacheFile(data);
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
return entry;
|
|
49
|
-
}
|
|
50
|
-
async function writeCachedToken(token) {
|
|
51
|
-
const data = await readCacheFile();
|
|
52
|
-
data[cacheKey(token.sentry_host, token.client_id)] = token;
|
|
53
|
-
await writeCacheFile(data);
|
|
54
|
-
}
|
|
55
|
-
async function clearCachedToken(host, clientId) {
|
|
56
|
-
const data = await readCacheFile();
|
|
57
|
-
const key = cacheKey(host, clientId);
|
|
58
|
-
if (key in data) {
|
|
59
|
-
delete data[key];
|
|
60
|
-
await writeCacheFile(data);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
//#endregion
|
|
65
|
-
export { clearCachedToken, readCachedToken, writeCachedToken };
|
|
66
|
-
//# sourceMappingURL=token-cache-DbZp4rvg.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"token-cache-DbZp4rvg.js","names":["host: string","clientId: string","data: CacheFile","token: CachedToken"],"sources":["../src/auth/token-cache.ts"],"sourcesContent":["/**\n * Persistent token cache for device code auth.\n * Tokens are stored at ~/.sentry/mcp.json, keyed by {host}:{clientId}.\n * See docs/operations/stdio-auth.md for cache format and security details.\n */\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport * as os from \"node:os\";\nimport type { CachedToken } from \"./types\";\n\n/** Safety window: treat tokens as expired 5 minutes before actual expiry. */\nconst EXPIRY_SAFETY_MS = 5 * 60 * 1000;\n\nfunction getCacheFilePath(): string {\n if (process.env.SENTRY_MCP_AUTH_CACHE) {\n return process.env.SENTRY_MCP_AUTH_CACHE;\n }\n return path.join(os.homedir(), \".sentry\", \"mcp.json\");\n}\n\nfunction cacheKey(host: string, clientId: string): string {\n return `${host}:${clientId}`;\n}\n\ntype CacheFile = Record<string, CachedToken>;\n\nasync function readCacheFile(): Promise<CacheFile> {\n try {\n const raw = await fs.readFile(getCacheFilePath(), \"utf-8\");\n return JSON.parse(raw) as CacheFile;\n } catch {\n return {};\n }\n}\n\nasync function writeCacheFile(data: CacheFile): Promise<void> {\n const filePath = getCacheFilePath();\n const dir = path.dirname(filePath);\n\n await fs.mkdir(dir, { recursive: true, mode: 0o700 });\n\n // Atomic write: write to temp file then rename\n const tmpPath = `${filePath}.tmp.${process.pid}`;\n await fs.writeFile(tmpPath, JSON.stringify(data, null, 2), {\n encoding: \"utf-8\",\n mode: 0o600,\n });\n await fs.rename(tmpPath, filePath);\n}\n\nexport async function readCachedToken(\n host: string,\n clientId: string,\n): Promise<CachedToken | null> {\n const data = await readCacheFile();\n const key = cacheKey(host, clientId);\n const entry = data[key];\n if (!entry) return null;\n\n const expiresAt = new Date(entry.expires_at).getTime();\n if (\n !Number.isFinite(expiresAt) ||\n expiresAt - Date.now() <= EXPIRY_SAFETY_MS\n ) {\n delete data[key];\n await writeCacheFile(data);\n return null;\n }\n\n return entry;\n}\n\nexport async function writeCachedToken(token: CachedToken): Promise<void> {\n const data = await readCacheFile();\n data[cacheKey(token.sentry_host, token.client_id)] = token;\n await writeCacheFile(data);\n}\n\nexport async function clearCachedToken(\n host: string,\n clientId: string,\n): Promise<void> {\n const data = await readCacheFile();\n const key = cacheKey(host, clientId);\n if (key in data) {\n delete data[key];\n await writeCacheFile(data);\n }\n}\n"],"mappings":";;;;;;AAWA,MAAM,mBAAmB,IAAI,KAAK;AAElC,SAAS,mBAA2B;AAClC,KAAI,QAAQ,IAAI,sBACd,QAAO,QAAQ,IAAI;AAErB,QAAO,KAAK,KAAK,GAAG,SAAS,EAAE,WAAW,WAAW;AACtD;AAED,SAAS,SAASA,MAAcC,UAA0B;AACxD,WAAU,KAAK,GAAG;AACnB;AAID,eAAe,gBAAoC;AACjD,KAAI;EACF,MAAM,MAAM,MAAM,GAAG,SAAS,kBAAkB,EAAE,QAAQ;AAC1D,SAAO,KAAK,MAAM,IAAI;CACvB,QAAO;AACN,SAAO,CAAE;CACV;AACF;AAED,eAAe,eAAeC,MAAgC;CAC5D,MAAM,WAAW,kBAAkB;CACnC,MAAM,MAAM,KAAK,QAAQ,SAAS;AAElC,OAAM,GAAG,MAAM,KAAK;EAAE,WAAW;EAAM,MAAM;CAAO,EAAC;CAGrD,MAAM,aAAa,SAAS,OAAO,QAAQ;AAC3C,OAAM,GAAG,UAAU,SAAS,KAAK,UAAU,MAAM,MAAM,EAAE,EAAE;EACzD,UAAU;EACV,MAAM;CACP,EAAC;AACF,OAAM,GAAG,OAAO,SAAS,SAAS;AACnC;AAED,eAAsB,gBACpBF,MACAC,UAC6B;CAC7B,MAAM,OAAO,MAAM,eAAe;CAClC,MAAM,MAAM,SAAS,MAAM,SAAS;CACpC,MAAM,QAAQ,KAAK;AACnB,MAAK,MAAO,QAAO;CAEnB,MAAM,YAAY,IAAI,KAAK,MAAM,YAAY,SAAS;AACtD,MACG,OAAO,SAAS,UAAU,IAC3B,YAAY,KAAK,KAAK,IAAI,kBAC1B;AACA,SAAO,KAAK;AACZ,QAAM,eAAe,KAAK;AAC1B,SAAO;CACR;AAED,QAAO;AACR;AAED,eAAsB,iBAAiBE,OAAmC;CACxE,MAAM,OAAO,MAAM,eAAe;AAClC,MAAK,SAAS,MAAM,aAAa,MAAM,UAAU,IAAI;AACrD,OAAM,eAAe,KAAK;AAC3B;AAED,eAAsB,iBACpBH,MACAC,UACe;CACf,MAAM,OAAO,MAAM,eAAe;CAClC,MAAM,MAAM,SAAS,MAAM,SAAS;AACpC,KAAI,OAAO,MAAM;AACf,SAAO,KAAK;AACZ,QAAM,eAAe,KAAK;CAC3B;AACF"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { __commonJS } from "./chunk-CunrlGP7.js";
|
|
2
|
-
|
|
3
|
-
//#region ../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/token-error.js
|
|
4
|
-
var require_token_error = __commonJS({ "../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/token-error.js"(exports, module) {
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __export = (target, all) => {
|
|
10
|
-
for (var name in all) __defProp(target, name, {
|
|
11
|
-
get: all[name],
|
|
12
|
-
enumerable: true
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
var __copyProps = (to, from, except, desc) => {
|
|
16
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
-
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
18
|
-
get: () => from[key],
|
|
19
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
return to;
|
|
23
|
-
};
|
|
24
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
-
var token_error_exports = {};
|
|
26
|
-
__export(token_error_exports, { VercelOidcTokenError: () => VercelOidcTokenError });
|
|
27
|
-
module.exports = __toCommonJS(token_error_exports);
|
|
28
|
-
var VercelOidcTokenError = class extends Error {
|
|
29
|
-
constructor(message, cause) {
|
|
30
|
-
super(message);
|
|
31
|
-
this.name = "VercelOidcTokenError";
|
|
32
|
-
this.cause = cause;
|
|
33
|
-
}
|
|
34
|
-
toString() {
|
|
35
|
-
if (this.cause) return `${this.name}: ${this.message}: ${this.cause}`;
|
|
36
|
-
return `${this.name}: ${this.message}`;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
} });
|
|
40
|
-
|
|
41
|
-
//#endregion
|
|
42
|
-
export { require_token_error };
|
|
43
|
-
//# sourceMappingURL=token-error-CBmJNKLY.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"token-error-CBmJNKLY.js","names":[],"sources":["../../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/token-error.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar token_error_exports = {};\n__export(token_error_exports, {\n VercelOidcTokenError: () => VercelOidcTokenError\n});\nmodule.exports = __toCommonJS(token_error_exports);\nclass VercelOidcTokenError extends Error {\n constructor(message, cause) {\n super(message);\n this.name = \"VercelOidcTokenError\";\n this.cause = cause;\n }\n toString() {\n if (this.cause) {\n return `${this.name}: ${this.message}: ${this.cause}`;\n }\n return `${this.name}: ${this.message}`;\n }\n}\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n VercelOidcTokenError\n});\n"],"x_google_ignoreList":[0],"mappings":";;;;CACA,IAAI,YAAY,OAAO;CACvB,IAAI,mBAAmB,OAAO;CAC9B,IAAI,oBAAoB,OAAO;CAC/B,IAAI,eAAe,OAAO,UAAU;CACpC,IAAI,WAAW,CAAC,QAAQ,QAAQ;AAC9B,OAAK,IAAI,QAAQ,IACf,WAAU,QAAQ,MAAM;GAAE,KAAK,IAAI;GAAO,YAAY;EAAM,EAAC;CAChE;CACD,IAAI,cAAc,CAAC,IAAI,MAAM,QAAQ,SAAS;AAC5C,MAAI,eAAe,SAAS,mBAAmB,SAAS,YACtD;QAAK,IAAI,OAAO,kBAAkB,KAAK,CACrC,MAAK,aAAa,KAAK,IAAI,IAAI,IAAI,QAAQ,OACzC,WAAU,IAAI,KAAK;IAAE,KAAK,MAAM,KAAK;IAAM,cAAc,OAAO,iBAAiB,MAAM,IAAI,KAAK,KAAK;GAAY,EAAC;EAAC;AAEzH,SAAO;CACR;CACD,IAAI,eAAe,CAAC,QAAQ,YAAY,UAAU,CAAE,GAAE,cAAc,EAAE,OAAO,KAAM,EAAC,EAAE,IAAI;CAC1F,IAAI,sBAAsB,CAAE;AAC5B,UAAS,qBAAqB,EAC5B,sBAAsB,MAAM,qBAC7B,EAAC;AACF,QAAO,UAAU,aAAa,oBAAoB;CAClD,IAAM,uBAAN,cAAmC,MAAM;EACvC,YAAY,SAAS,OAAO;AAC1B,SAAM,QAAQ;AACd,QAAK,OAAO;AACZ,QAAK,QAAQ;EACd;EACD,WAAW;AACT,OAAI,KAAK,MACP,WAAU,KAAK,KAAK,IAAI,KAAK,QAAQ,IAAI,KAAK;AAEhD,aAAU,KAAK,KAAK,IAAI,KAAK;EAC9B;CACF"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
const require_chunk = require('./chunk-Cv9WC9bY.cjs');
|
|
2
|
-
|
|
3
|
-
//#region ../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/token-error.js
|
|
4
|
-
var require_token_error = require_chunk.__commonJS({ "../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/token-error.js"(exports, module) {
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __export = (target, all) => {
|
|
10
|
-
for (var name in all) __defProp(target, name, {
|
|
11
|
-
get: all[name],
|
|
12
|
-
enumerable: true
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
var __copyProps = (to, from, except, desc) => {
|
|
16
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
-
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
18
|
-
get: () => from[key],
|
|
19
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
return to;
|
|
23
|
-
};
|
|
24
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
-
var token_error_exports = {};
|
|
26
|
-
__export(token_error_exports, { VercelOidcTokenError: () => VercelOidcTokenError });
|
|
27
|
-
module.exports = __toCommonJS(token_error_exports);
|
|
28
|
-
var VercelOidcTokenError = class extends Error {
|
|
29
|
-
constructor(message, cause) {
|
|
30
|
-
super(message);
|
|
31
|
-
this.name = "VercelOidcTokenError";
|
|
32
|
-
this.cause = cause;
|
|
33
|
-
}
|
|
34
|
-
toString() {
|
|
35
|
-
if (this.cause) return `${this.name}: ${this.message}: ${this.cause}`;
|
|
36
|
-
return `${this.name}: ${this.message}`;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
} });
|
|
40
|
-
|
|
41
|
-
//#endregion
|
|
42
|
-
Object.defineProperty(exports, 'require_token_error', {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
get: function () {
|
|
45
|
-
return require_token_error;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
//# sourceMappingURL=token-error-x_miDBP3.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"token-error-x_miDBP3.cjs","names":[],"sources":["../../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/token-error.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar token_error_exports = {};\n__export(token_error_exports, {\n VercelOidcTokenError: () => VercelOidcTokenError\n});\nmodule.exports = __toCommonJS(token_error_exports);\nclass VercelOidcTokenError extends Error {\n constructor(message, cause) {\n super(message);\n this.name = \"VercelOidcTokenError\";\n this.cause = cause;\n }\n toString() {\n if (this.cause) {\n return `${this.name}: ${this.message}: ${this.cause}`;\n }\n return `${this.name}: ${this.message}`;\n }\n}\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n VercelOidcTokenError\n});\n"],"x_google_ignoreList":[0],"mappings":";;;;CACA,IAAI,YAAY,OAAO;CACvB,IAAI,mBAAmB,OAAO;CAC9B,IAAI,oBAAoB,OAAO;CAC/B,IAAI,eAAe,OAAO,UAAU;CACpC,IAAI,WAAW,CAAC,QAAQ,QAAQ;AAC9B,OAAK,IAAI,QAAQ,IACf,WAAU,QAAQ,MAAM;GAAE,KAAK,IAAI;GAAO,YAAY;EAAM,EAAC;CAChE;CACD,IAAI,cAAc,CAAC,IAAI,MAAM,QAAQ,SAAS;AAC5C,MAAI,eAAe,SAAS,mBAAmB,SAAS,YACtD;QAAK,IAAI,OAAO,kBAAkB,KAAK,CACrC,MAAK,aAAa,KAAK,IAAI,IAAI,IAAI,QAAQ,OACzC,WAAU,IAAI,KAAK;IAAE,KAAK,MAAM,KAAK;IAAM,cAAc,OAAO,iBAAiB,MAAM,IAAI,KAAK,KAAK;GAAY,EAAC;EAAC;AAEzH,SAAO;CACR;CACD,IAAI,eAAe,CAAC,QAAQ,YAAY,UAAU,CAAE,GAAE,cAAc,EAAE,OAAO,KAAM,EAAC,EAAE,IAAI;CAC1F,IAAI,sBAAsB,CAAE;AAC5B,UAAS,qBAAqB,EAC5B,sBAAsB,MAAM,qBAC7B,EAAC;AACF,QAAO,UAAU,aAAa,oBAAoB;CAClD,IAAM,uBAAN,cAAmC,MAAM;EACvC,YAAY,SAAS,OAAO;AAC1B,SAAM,QAAQ;AACd,QAAK,OAAO;AACZ,QAAK,QAAQ;EACd;EACD,WAAW;AACT,OAAI,KAAK,MACP,WAAU,KAAK,KAAK,IAAI,KAAK,QAAQ,IAAI,KAAK;AAEhD,aAAU,KAAK,KAAK,IAAI,KAAK;EAC9B;CACF"}
|
|
@@ -1,363 +0,0 @@
|
|
|
1
|
-
const require_chunk = require('./chunk-Cv9WC9bY.cjs');
|
|
2
|
-
const require_token_error$1 = require('./token-error-x_miDBP3.cjs');
|
|
3
|
-
|
|
4
|
-
//#region ../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/token-io.js
|
|
5
|
-
var require_token_io = require_chunk.__commonJS({ "../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/token-io.js"(exports, module) {
|
|
6
|
-
var __create$2 = Object.create;
|
|
7
|
-
var __defProp$3 = Object.defineProperty;
|
|
8
|
-
var __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor;
|
|
9
|
-
var __getOwnPropNames$3 = Object.getOwnPropertyNames;
|
|
10
|
-
var __getProtoOf$2 = Object.getPrototypeOf;
|
|
11
|
-
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
12
|
-
var __export$3 = (target, all) => {
|
|
13
|
-
for (var name in all) __defProp$3(target, name, {
|
|
14
|
-
get: all[name],
|
|
15
|
-
enumerable: true
|
|
16
|
-
});
|
|
17
|
-
};
|
|
18
|
-
var __copyProps$3 = (to, from, except, desc) => {
|
|
19
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
-
for (let key of __getOwnPropNames$3(from)) if (!__hasOwnProp$3.call(to, key) && key !== except) __defProp$3(to, key, {
|
|
21
|
-
get: () => from[key],
|
|
22
|
-
enumerable: !(desc = __getOwnPropDesc$3(from, key)) || desc.enumerable
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
return to;
|
|
26
|
-
};
|
|
27
|
-
var __toESM$2 = (mod, isNodeMode, target) => (target = mod != null ? __create$2(__getProtoOf$2(mod)) : {}, __copyProps$3(isNodeMode || !mod || !mod.__esModule ? __defProp$3(target, "default", {
|
|
28
|
-
value: mod,
|
|
29
|
-
enumerable: true
|
|
30
|
-
}) : target, mod));
|
|
31
|
-
var __toCommonJS$3 = (mod) => __copyProps$3(__defProp$3({}, "__esModule", { value: true }), mod);
|
|
32
|
-
var token_io_exports = {};
|
|
33
|
-
__export$3(token_io_exports, {
|
|
34
|
-
findRootDir: () => findRootDir,
|
|
35
|
-
getUserDataDir: () => getUserDataDir
|
|
36
|
-
});
|
|
37
|
-
module.exports = __toCommonJS$3(token_io_exports);
|
|
38
|
-
var import_path = __toESM$2(require("path"));
|
|
39
|
-
var import_fs = __toESM$2(require("fs"));
|
|
40
|
-
var import_os$1 = __toESM$2(require("os"));
|
|
41
|
-
var import_token_error$1 = require_token_error$1.require_token_error();
|
|
42
|
-
function findRootDir() {
|
|
43
|
-
try {
|
|
44
|
-
let dir = process.cwd();
|
|
45
|
-
while (dir !== import_path.default.dirname(dir)) {
|
|
46
|
-
const pkgPath = import_path.default.join(dir, ".vercel");
|
|
47
|
-
if (import_fs.default.existsSync(pkgPath)) return dir;
|
|
48
|
-
dir = import_path.default.dirname(dir);
|
|
49
|
-
}
|
|
50
|
-
} catch (e) {
|
|
51
|
-
throw new import_token_error$1.VercelOidcTokenError("Token refresh only supported in node server environments");
|
|
52
|
-
}
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
function getUserDataDir() {
|
|
56
|
-
if (process.env.XDG_DATA_HOME) return process.env.XDG_DATA_HOME;
|
|
57
|
-
switch (import_os$1.default.platform()) {
|
|
58
|
-
case "darwin": return import_path.default.join(import_os$1.default.homedir(), "Library/Application Support");
|
|
59
|
-
case "linux": return import_path.default.join(import_os$1.default.homedir(), ".local/share");
|
|
60
|
-
case "win32":
|
|
61
|
-
if (process.env.LOCALAPPDATA) return process.env.LOCALAPPDATA;
|
|
62
|
-
return null;
|
|
63
|
-
default: return null;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
} });
|
|
67
|
-
|
|
68
|
-
//#endregion
|
|
69
|
-
//#region ../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/auth-config.js
|
|
70
|
-
var require_auth_config = require_chunk.__commonJS({ "../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/auth-config.js"(exports, module) {
|
|
71
|
-
var __create$1 = Object.create;
|
|
72
|
-
var __defProp$2 = Object.defineProperty;
|
|
73
|
-
var __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor;
|
|
74
|
-
var __getOwnPropNames$2 = Object.getOwnPropertyNames;
|
|
75
|
-
var __getProtoOf$1 = Object.getPrototypeOf;
|
|
76
|
-
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
77
|
-
var __export$2 = (target, all) => {
|
|
78
|
-
for (var name in all) __defProp$2(target, name, {
|
|
79
|
-
get: all[name],
|
|
80
|
-
enumerable: true
|
|
81
|
-
});
|
|
82
|
-
};
|
|
83
|
-
var __copyProps$2 = (to, from, except, desc) => {
|
|
84
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
85
|
-
for (let key of __getOwnPropNames$2(from)) if (!__hasOwnProp$2.call(to, key) && key !== except) __defProp$2(to, key, {
|
|
86
|
-
get: () => from[key],
|
|
87
|
-
enumerable: !(desc = __getOwnPropDesc$2(from, key)) || desc.enumerable
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
return to;
|
|
91
|
-
};
|
|
92
|
-
var __toESM$1 = (mod, isNodeMode, target) => (target = mod != null ? __create$1(__getProtoOf$1(mod)) : {}, __copyProps$2(isNodeMode || !mod || !mod.__esModule ? __defProp$2(target, "default", {
|
|
93
|
-
value: mod,
|
|
94
|
-
enumerable: true
|
|
95
|
-
}) : target, mod));
|
|
96
|
-
var __toCommonJS$2 = (mod) => __copyProps$2(__defProp$2({}, "__esModule", { value: true }), mod);
|
|
97
|
-
var auth_config_exports = {};
|
|
98
|
-
__export$2(auth_config_exports, {
|
|
99
|
-
isValidAccessToken: () => isValidAccessToken,
|
|
100
|
-
readAuthConfig: () => readAuthConfig,
|
|
101
|
-
writeAuthConfig: () => writeAuthConfig
|
|
102
|
-
});
|
|
103
|
-
module.exports = __toCommonJS$2(auth_config_exports);
|
|
104
|
-
var fs$1 = __toESM$1(require("fs"));
|
|
105
|
-
var path$1 = __toESM$1(require("path"));
|
|
106
|
-
var import_token_util = require_token_util();
|
|
107
|
-
function getAuthConfigPath() {
|
|
108
|
-
const dataDir = (0, import_token_util.getVercelDataDir)();
|
|
109
|
-
if (!dataDir) throw new Error(`Unable to find Vercel CLI data directory. Your platform: ${process.platform}. Supported: darwin, linux, win32.`);
|
|
110
|
-
return path$1.join(dataDir, "auth.json");
|
|
111
|
-
}
|
|
112
|
-
function readAuthConfig() {
|
|
113
|
-
try {
|
|
114
|
-
const authPath = getAuthConfigPath();
|
|
115
|
-
if (!fs$1.existsSync(authPath)) return null;
|
|
116
|
-
const content = fs$1.readFileSync(authPath, "utf8");
|
|
117
|
-
if (!content) return null;
|
|
118
|
-
return JSON.parse(content);
|
|
119
|
-
} catch (error) {
|
|
120
|
-
return null;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
function writeAuthConfig(config) {
|
|
124
|
-
const authPath = getAuthConfigPath();
|
|
125
|
-
const authDir = path$1.dirname(authPath);
|
|
126
|
-
if (!fs$1.existsSync(authDir)) fs$1.mkdirSync(authDir, {
|
|
127
|
-
mode: 504,
|
|
128
|
-
recursive: true
|
|
129
|
-
});
|
|
130
|
-
fs$1.writeFileSync(authPath, JSON.stringify(config, null, 2), { mode: 384 });
|
|
131
|
-
}
|
|
132
|
-
function isValidAccessToken(authConfig) {
|
|
133
|
-
if (!authConfig.token) return false;
|
|
134
|
-
if (typeof authConfig.expiresAt !== "number") return true;
|
|
135
|
-
const nowInSeconds = Math.floor(Date.now() / 1e3);
|
|
136
|
-
return authConfig.expiresAt >= nowInSeconds;
|
|
137
|
-
}
|
|
138
|
-
} });
|
|
139
|
-
|
|
140
|
-
//#endregion
|
|
141
|
-
//#region ../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/oauth.js
|
|
142
|
-
var require_oauth = require_chunk.__commonJS({ "../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/oauth.js"(exports, module) {
|
|
143
|
-
var __defProp$1 = Object.defineProperty;
|
|
144
|
-
var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
|
|
145
|
-
var __getOwnPropNames$1 = Object.getOwnPropertyNames;
|
|
146
|
-
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
147
|
-
var __export$1 = (target, all) => {
|
|
148
|
-
for (var name in all) __defProp$1(target, name, {
|
|
149
|
-
get: all[name],
|
|
150
|
-
enumerable: true
|
|
151
|
-
});
|
|
152
|
-
};
|
|
153
|
-
var __copyProps$1 = (to, from, except, desc) => {
|
|
154
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
155
|
-
for (let key of __getOwnPropNames$1(from)) if (!__hasOwnProp$1.call(to, key) && key !== except) __defProp$1(to, key, {
|
|
156
|
-
get: () => from[key],
|
|
157
|
-
enumerable: !(desc = __getOwnPropDesc$1(from, key)) || desc.enumerable
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
return to;
|
|
161
|
-
};
|
|
162
|
-
var __toCommonJS$1 = (mod) => __copyProps$1(__defProp$1({}, "__esModule", { value: true }), mod);
|
|
163
|
-
var oauth_exports = {};
|
|
164
|
-
__export$1(oauth_exports, {
|
|
165
|
-
processTokenResponse: () => processTokenResponse,
|
|
166
|
-
refreshTokenRequest: () => refreshTokenRequest
|
|
167
|
-
});
|
|
168
|
-
module.exports = __toCommonJS$1(oauth_exports);
|
|
169
|
-
var import_os = require("os");
|
|
170
|
-
const VERCEL_ISSUER = "https://vercel.com";
|
|
171
|
-
const VERCEL_CLI_CLIENT_ID = "cl_HYyOPBNtFMfHhaUn9L4QPfTZz6TP47bp";
|
|
172
|
-
const userAgent = `@vercel/oidc node-${process.version} ${(0, import_os.platform)()} (${(0, import_os.arch)()}) ${(0, import_os.hostname)()}`;
|
|
173
|
-
let _tokenEndpoint = null;
|
|
174
|
-
async function getTokenEndpoint() {
|
|
175
|
-
if (_tokenEndpoint) return _tokenEndpoint;
|
|
176
|
-
const discoveryUrl = `${VERCEL_ISSUER}/.well-known/openid-configuration`;
|
|
177
|
-
const response = await fetch(discoveryUrl, { headers: { "user-agent": userAgent } });
|
|
178
|
-
if (!response.ok) throw new Error("Failed to discover OAuth endpoints");
|
|
179
|
-
const metadata = await response.json();
|
|
180
|
-
if (!metadata || typeof metadata.token_endpoint !== "string") throw new Error("Invalid OAuth discovery response");
|
|
181
|
-
const endpoint = metadata.token_endpoint;
|
|
182
|
-
_tokenEndpoint = endpoint;
|
|
183
|
-
return endpoint;
|
|
184
|
-
}
|
|
185
|
-
async function refreshTokenRequest(options) {
|
|
186
|
-
const tokenEndpoint = await getTokenEndpoint();
|
|
187
|
-
return await fetch(tokenEndpoint, {
|
|
188
|
-
method: "POST",
|
|
189
|
-
headers: {
|
|
190
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
191
|
-
"user-agent": userAgent
|
|
192
|
-
},
|
|
193
|
-
body: new URLSearchParams({
|
|
194
|
-
client_id: VERCEL_CLI_CLIENT_ID,
|
|
195
|
-
grant_type: "refresh_token",
|
|
196
|
-
...options
|
|
197
|
-
})
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
async function processTokenResponse(response) {
|
|
201
|
-
const json = await response.json();
|
|
202
|
-
if (!response.ok) {
|
|
203
|
-
const errorMsg = typeof json === "object" && json && "error" in json ? String(json.error) : "Token refresh failed";
|
|
204
|
-
return [new Error(errorMsg)];
|
|
205
|
-
}
|
|
206
|
-
if (typeof json !== "object" || json === null) return [/* @__PURE__ */ new Error("Invalid token response")];
|
|
207
|
-
if (typeof json.access_token !== "string") return [/* @__PURE__ */ new Error("Missing access_token in response")];
|
|
208
|
-
if (json.token_type !== "Bearer") return [/* @__PURE__ */ new Error("Invalid token_type in response")];
|
|
209
|
-
if (typeof json.expires_in !== "number") return [/* @__PURE__ */ new Error("Missing expires_in in response")];
|
|
210
|
-
return [null, json];
|
|
211
|
-
}
|
|
212
|
-
} });
|
|
213
|
-
|
|
214
|
-
//#endregion
|
|
215
|
-
//#region ../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/token-util.js
|
|
216
|
-
var require_token_util = require_chunk.__commonJS({ "../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/token-util.js"(exports, module) {
|
|
217
|
-
var __create = Object.create;
|
|
218
|
-
var __defProp = Object.defineProperty;
|
|
219
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
220
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
221
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
222
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
223
|
-
var __export = (target, all) => {
|
|
224
|
-
for (var name in all) __defProp(target, name, {
|
|
225
|
-
get: all[name],
|
|
226
|
-
enumerable: true
|
|
227
|
-
});
|
|
228
|
-
};
|
|
229
|
-
var __copyProps = (to, from, except, desc) => {
|
|
230
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
231
|
-
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
232
|
-
get: () => from[key],
|
|
233
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
return to;
|
|
237
|
-
};
|
|
238
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
239
|
-
value: mod,
|
|
240
|
-
enumerable: true
|
|
241
|
-
}) : target, mod));
|
|
242
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
243
|
-
var token_util_exports = {};
|
|
244
|
-
__export(token_util_exports, {
|
|
245
|
-
assertVercelOidcTokenResponse: () => assertVercelOidcTokenResponse,
|
|
246
|
-
findProjectInfo: () => findProjectInfo,
|
|
247
|
-
getTokenPayload: () => getTokenPayload,
|
|
248
|
-
getVercelCliToken: () => getVercelCliToken,
|
|
249
|
-
getVercelDataDir: () => getVercelDataDir,
|
|
250
|
-
getVercelOidcToken: () => getVercelOidcToken,
|
|
251
|
-
isExpired: () => isExpired,
|
|
252
|
-
loadToken: () => loadToken,
|
|
253
|
-
saveToken: () => saveToken
|
|
254
|
-
});
|
|
255
|
-
module.exports = __toCommonJS(token_util_exports);
|
|
256
|
-
var path = __toESM(require("path"));
|
|
257
|
-
var fs = __toESM(require("fs"));
|
|
258
|
-
var import_token_error = require_token_error$1.require_token_error();
|
|
259
|
-
var import_token_io = require_token_io();
|
|
260
|
-
var import_auth_config = require_auth_config();
|
|
261
|
-
var import_oauth = require_oauth();
|
|
262
|
-
function getVercelDataDir() {
|
|
263
|
-
const vercelFolder = "com.vercel.cli";
|
|
264
|
-
const dataDir = (0, import_token_io.getUserDataDir)();
|
|
265
|
-
if (!dataDir) return null;
|
|
266
|
-
return path.join(dataDir, vercelFolder);
|
|
267
|
-
}
|
|
268
|
-
async function getVercelCliToken() {
|
|
269
|
-
const authConfig = (0, import_auth_config.readAuthConfig)();
|
|
270
|
-
if (!authConfig) return null;
|
|
271
|
-
if ((0, import_auth_config.isValidAccessToken)(authConfig)) return authConfig.token || null;
|
|
272
|
-
if (!authConfig.refreshToken) {
|
|
273
|
-
(0, import_auth_config.writeAuthConfig)({});
|
|
274
|
-
return null;
|
|
275
|
-
}
|
|
276
|
-
try {
|
|
277
|
-
const tokenResponse = await (0, import_oauth.refreshTokenRequest)({ refresh_token: authConfig.refreshToken });
|
|
278
|
-
const [tokensError, tokens] = await (0, import_oauth.processTokenResponse)(tokenResponse);
|
|
279
|
-
if (tokensError || !tokens) {
|
|
280
|
-
(0, import_auth_config.writeAuthConfig)({});
|
|
281
|
-
return null;
|
|
282
|
-
}
|
|
283
|
-
const updatedConfig = {
|
|
284
|
-
token: tokens.access_token,
|
|
285
|
-
expiresAt: Math.floor(Date.now() / 1e3) + tokens.expires_in
|
|
286
|
-
};
|
|
287
|
-
if (tokens.refresh_token) updatedConfig.refreshToken = tokens.refresh_token;
|
|
288
|
-
(0, import_auth_config.writeAuthConfig)(updatedConfig);
|
|
289
|
-
return updatedConfig.token ?? null;
|
|
290
|
-
} catch (error) {
|
|
291
|
-
(0, import_auth_config.writeAuthConfig)({});
|
|
292
|
-
return null;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
async function getVercelOidcToken(authToken, projectId, teamId) {
|
|
296
|
-
const url = `https://api.vercel.com/v1/projects/${projectId}/token?source=vercel-oidc-refresh${teamId ? `&teamId=${teamId}` : ""}`;
|
|
297
|
-
const res = await fetch(url, {
|
|
298
|
-
method: "POST",
|
|
299
|
-
headers: { Authorization: `Bearer ${authToken}` }
|
|
300
|
-
});
|
|
301
|
-
if (!res.ok) throw new import_token_error.VercelOidcTokenError(`Failed to refresh OIDC token: ${res.statusText}`);
|
|
302
|
-
const tokenRes = await res.json();
|
|
303
|
-
assertVercelOidcTokenResponse(tokenRes);
|
|
304
|
-
return tokenRes;
|
|
305
|
-
}
|
|
306
|
-
function assertVercelOidcTokenResponse(res) {
|
|
307
|
-
if (!res || typeof res !== "object") throw new TypeError("Vercel OIDC token is malformed. Expected an object. Please run `vc env pull` and try again");
|
|
308
|
-
if (!("token" in res) || typeof res.token !== "string") throw new TypeError("Vercel OIDC token is malformed. Expected a string-valued token property. Please run `vc env pull` and try again");
|
|
309
|
-
}
|
|
310
|
-
function findProjectInfo() {
|
|
311
|
-
const dir = (0, import_token_io.findRootDir)();
|
|
312
|
-
if (!dir) throw new import_token_error.VercelOidcTokenError("Unable to find project root directory. Have you linked your project with `vc link?`");
|
|
313
|
-
const prjPath = path.join(dir, ".vercel", "project.json");
|
|
314
|
-
if (!fs.existsSync(prjPath)) throw new import_token_error.VercelOidcTokenError("project.json not found, have you linked your project with `vc link?`");
|
|
315
|
-
const prj = JSON.parse(fs.readFileSync(prjPath, "utf8"));
|
|
316
|
-
if (typeof prj.projectId !== "string" && typeof prj.orgId !== "string") throw new TypeError("Expected a string-valued projectId property. Try running `vc link` to re-link your project.");
|
|
317
|
-
return {
|
|
318
|
-
projectId: prj.projectId,
|
|
319
|
-
teamId: prj.orgId
|
|
320
|
-
};
|
|
321
|
-
}
|
|
322
|
-
function saveToken(token, projectId) {
|
|
323
|
-
const dir = (0, import_token_io.getUserDataDir)();
|
|
324
|
-
if (!dir) throw new import_token_error.VercelOidcTokenError("Unable to find user data directory. Please reach out to Vercel support.");
|
|
325
|
-
const tokenPath = path.join(dir, "com.vercel.token", `${projectId}.json`);
|
|
326
|
-
const tokenJson = JSON.stringify(token);
|
|
327
|
-
fs.mkdirSync(path.dirname(tokenPath), {
|
|
328
|
-
mode: 504,
|
|
329
|
-
recursive: true
|
|
330
|
-
});
|
|
331
|
-
fs.writeFileSync(tokenPath, tokenJson);
|
|
332
|
-
fs.chmodSync(tokenPath, 432);
|
|
333
|
-
return;
|
|
334
|
-
}
|
|
335
|
-
function loadToken(projectId) {
|
|
336
|
-
const dir = (0, import_token_io.getUserDataDir)();
|
|
337
|
-
if (!dir) throw new import_token_error.VercelOidcTokenError("Unable to find user data directory. Please reach out to Vercel support.");
|
|
338
|
-
const tokenPath = path.join(dir, "com.vercel.token", `${projectId}.json`);
|
|
339
|
-
if (!fs.existsSync(tokenPath)) return null;
|
|
340
|
-
const token = JSON.parse(fs.readFileSync(tokenPath, "utf8"));
|
|
341
|
-
assertVercelOidcTokenResponse(token);
|
|
342
|
-
return token;
|
|
343
|
-
}
|
|
344
|
-
function getTokenPayload(token) {
|
|
345
|
-
const tokenParts = token.split(".");
|
|
346
|
-
if (tokenParts.length !== 3) throw new import_token_error.VercelOidcTokenError("Invalid token. Please run `vc env pull` and try again");
|
|
347
|
-
const base64 = tokenParts[1].replace(/-/g, "+").replace(/_/g, "/");
|
|
348
|
-
const padded = base64.padEnd(base64.length + (4 - base64.length % 4) % 4, "=");
|
|
349
|
-
return JSON.parse(Buffer.from(padded, "base64").toString("utf8"));
|
|
350
|
-
}
|
|
351
|
-
function isExpired(token) {
|
|
352
|
-
return token.exp * 1e3 < Date.now();
|
|
353
|
-
}
|
|
354
|
-
} });
|
|
355
|
-
|
|
356
|
-
//#endregion
|
|
357
|
-
Object.defineProperty(exports, 'require_token_util', {
|
|
358
|
-
enumerable: true,
|
|
359
|
-
get: function () {
|
|
360
|
-
return require_token_util;
|
|
361
|
-
}
|
|
362
|
-
});
|
|
363
|
-
//# sourceMappingURL=token-util-BRoQwIG6.cjs.map
|