@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.
Files changed (162) hide show
  1. package/README.md +54 -0
  2. package/dist/sentry-mcp.cjs +3436 -0
  3. package/package.json +22 -40
  4. package/LICENSE.md +0 -105
  5. package/dist/auth/constants.cjs +0 -9
  6. package/dist/auth/constants.d.cts +0 -31
  7. package/dist/auth/constants.d.cts.map +0 -1
  8. package/dist/auth/constants.d.ts +0 -31
  9. package/dist/auth/constants.d.ts.map +0 -1
  10. package/dist/auth/constants.js +0 -3
  11. package/dist/auth/device-code-flow.cjs +0 -10
  12. package/dist/auth/device-code-flow.d.cts +0 -34
  13. package/dist/auth/device-code-flow.d.cts.map +0 -1
  14. package/dist/auth/device-code-flow.d.ts +0 -34
  15. package/dist/auth/device-code-flow.d.ts.map +0 -1
  16. package/dist/auth/device-code-flow.js +0 -6
  17. package/dist/auth/resolve-token.cjs +0 -8
  18. package/dist/auth/resolve-token.d.cts +0 -17
  19. package/dist/auth/resolve-token.d.cts.map +0 -1
  20. package/dist/auth/resolve-token.d.ts +0 -17
  21. package/dist/auth/resolve-token.d.ts.map +0 -1
  22. package/dist/auth/resolve-token.js +0 -8
  23. package/dist/auth/token-cache.cjs +0 -5
  24. package/dist/auth/token-cache.d.cts +0 -11
  25. package/dist/auth/token-cache.d.cts.map +0 -1
  26. package/dist/auth/token-cache.d.ts +0 -11
  27. package/dist/auth/token-cache.d.ts.map +0 -1
  28. package/dist/auth/token-cache.js +0 -3
  29. package/dist/auth/types.cjs +0 -7
  30. package/dist/auth/types.d.cts +0 -2
  31. package/dist/auth/types.d.ts +0 -2
  32. package/dist/auth/types.js +0 -3
  33. package/dist/auth-CYOpb-jm.cjs +0 -90
  34. package/dist/auth-CYOpb-jm.cjs.map +0 -1
  35. package/dist/auth-YZqLxyqD.js +0 -79
  36. package/dist/auth-YZqLxyqD.js.map +0 -1
  37. package/dist/blob-utils-B0ae0K-m-BF8kTomr.cjs +0 -4724
  38. package/dist/blob-utils-B0ae0K-m-BF8kTomr.cjs.map +0 -1
  39. package/dist/blob-utils-B0ae0K-m-BhC2W04C.js +0 -4701
  40. package/dist/blob-utils-B0ae0K-m-BhC2W04C.js.map +0 -1
  41. package/dist/blob-utils-BM8EcgEO.js +0 -3
  42. package/dist/blob-utils-DBvCs9nw.cjs +0 -3
  43. package/dist/chunk-CunrlGP7.js +0 -37
  44. package/dist/chunk-Cv9WC9bY.cjs +0 -58
  45. package/dist/cli/commands/auth.cjs +0 -11
  46. package/dist/cli/commands/auth.d.cts +0 -8
  47. package/dist/cli/commands/auth.d.cts.map +0 -1
  48. package/dist/cli/commands/auth.d.ts +0 -8
  49. package/dist/cli/commands/auth.d.ts.map +0 -1
  50. package/dist/cli/commands/auth.js +0 -10
  51. package/dist/cli/output.cjs +0 -3
  52. package/dist/cli/output.d.cts +0 -7
  53. package/dist/cli/output.d.cts.map +0 -1
  54. package/dist/cli/output.d.ts +0 -7
  55. package/dist/cli/output.d.ts.map +0 -1
  56. package/dist/cli/output.js +0 -3
  57. package/dist/cli/parse.cjs +0 -5
  58. package/dist/cli/parse.d.cts +0 -11
  59. package/dist/cli/parse.d.cts.map +0 -1
  60. package/dist/cli/parse.d.ts +0 -11
  61. package/dist/cli/parse.d.ts.map +0 -1
  62. package/dist/cli/parse.js +0 -3
  63. package/dist/cli/resolve.cjs +0 -6
  64. package/dist/cli/resolve.d.cts +0 -16
  65. package/dist/cli/resolve.d.cts.map +0 -1
  66. package/dist/cli/resolve.d.ts +0 -16
  67. package/dist/cli/resolve.d.ts.map +0 -1
  68. package/dist/cli/resolve.js +0 -4
  69. package/dist/cli/types.cjs +0 -0
  70. package/dist/cli/types.d.cts +0 -2
  71. package/dist/cli/types.d.ts +0 -2
  72. package/dist/cli/types.js +0 -0
  73. package/dist/cli/usage.cjs +0 -3
  74. package/dist/cli/usage.d.cts +0 -9
  75. package/dist/cli/usage.d.cts.map +0 -1
  76. package/dist/cli/usage.d.ts +0 -9
  77. package/dist/cli/usage.d.ts.map +0 -1
  78. package/dist/cli/usage.js +0 -3
  79. package/dist/config-40SaJWzQ-Bxau3bPR.cjs +0 -928
  80. package/dist/config-40SaJWzQ-Bxau3bPR.cjs.map +0 -1
  81. package/dist/config-40SaJWzQ-Dz27jdMQ.js +0 -886
  82. package/dist/config-40SaJWzQ-Dz27jdMQ.js.map +0 -1
  83. package/dist/config-DeGbV11k.cjs +0 -7
  84. package/dist/config-NGx6OsOU.js +0 -3
  85. package/dist/constants-BqO-QSHl.cjs +0 -636
  86. package/dist/constants-BqO-QSHl.cjs.map +0 -1
  87. package/dist/constants-Da7VwSRQ.js +0 -450
  88. package/dist/constants-Da7VwSRQ.js.map +0 -1
  89. package/dist/device-code-flow-Bk6L232R.js +0 -124
  90. package/dist/device-code-flow-Bk6L232R.js.map +0 -1
  91. package/dist/device-code-flow-Dv-auCiV.cjs +0 -154
  92. package/dist/device-code-flow-Dv-auCiV.cjs.map +0 -1
  93. package/dist/index.cjs +0 -61541
  94. package/dist/index.cjs.map +0 -1
  95. package/dist/index.d.cts +0 -1
  96. package/dist/index.d.ts +0 -1
  97. package/dist/index.js +0 -61542
  98. package/dist/index.js.map +0 -1
  99. package/dist/output-A_-7o7gV.js +0 -8
  100. package/dist/output-A_-7o7gV.js.map +0 -1
  101. package/dist/output-DEoNyYz7.cjs +0 -14
  102. package/dist/output-DEoNyYz7.cjs.map +0 -1
  103. package/dist/parse-CPY7-_2_.cjs +0 -130
  104. package/dist/parse-CPY7-_2_.cjs.map +0 -1
  105. package/dist/parse-Dd3OOgIq.js +0 -112
  106. package/dist/parse-Dd3OOgIq.js.map +0 -1
  107. package/dist/resolve-CZUghJrC.cjs +0 -179
  108. package/dist/resolve-CZUghJrC.cjs.map +0 -1
  109. package/dist/resolve-CkkdMFiR.js +0 -144
  110. package/dist/resolve-CkkdMFiR.js.map +0 -1
  111. package/dist/resolve-token-4RkU7UPe.js +0 -47
  112. package/dist/resolve-token-4RkU7UPe.js.map +0 -1
  113. package/dist/resolve-token-Daqu57f-.cjs +0 -52
  114. package/dist/resolve-token-Daqu57f-.cjs.map +0 -1
  115. package/dist/stdio-4lgW_97D.cjs +0 -65
  116. package/dist/stdio-4lgW_97D.cjs.map +0 -1
  117. package/dist/stdio-C0wKX460.js +0 -59
  118. package/dist/stdio-C0wKX460.js.map +0 -1
  119. package/dist/token-3xpHVxQo.js +0 -51
  120. package/dist/token-3xpHVxQo.js.map +0 -1
  121. package/dist/token-C7MavkKX.cjs +0 -55
  122. package/dist/token-C7MavkKX.cjs.map +0 -1
  123. package/dist/token-cache-ATUcs1cg.cjs +0 -84
  124. package/dist/token-cache-ATUcs1cg.cjs.map +0 -1
  125. package/dist/token-cache-DbZp4rvg.js +0 -66
  126. package/dist/token-cache-DbZp4rvg.js.map +0 -1
  127. package/dist/token-error-CBmJNKLY.js +0 -43
  128. package/dist/token-error-CBmJNKLY.js.map +0 -1
  129. package/dist/token-error-x_miDBP3.cjs +0 -48
  130. package/dist/token-error-x_miDBP3.cjs.map +0 -1
  131. package/dist/token-util-4bIYDTMS.js +0 -4
  132. package/dist/token-util-BRoQwIG6.cjs +0 -363
  133. package/dist/token-util-BRoQwIG6.cjs.map +0 -1
  134. package/dist/token-util-DurDL44i.cjs +0 -9
  135. package/dist/token-util-batRsXGA.js +0 -358
  136. package/dist/token-util-batRsXGA.js.map +0 -1
  137. package/dist/transports/stdio.cjs +0 -4
  138. package/dist/transports/stdio.d.cts +0 -40
  139. package/dist/transports/stdio.d.cts.map +0 -1
  140. package/dist/transports/stdio.d.ts +0 -40
  141. package/dist/transports/stdio.d.ts.map +0 -1
  142. package/dist/transports/stdio.js +0 -4
  143. package/dist/types-BCSxlxZI.js +0 -57
  144. package/dist/types-BCSxlxZI.js.map +0 -1
  145. package/dist/types-BGyk9F4G.d.ts +0 -61
  146. package/dist/types-BGyk9F4G.d.ts.map +0 -1
  147. package/dist/types-C9HgNyIE.d.cts +0 -61
  148. package/dist/types-C9HgNyIE.d.cts.map +0 -1
  149. package/dist/types-D-BIcaY4.d.ts +0 -91
  150. package/dist/types-D-BIcaY4.d.ts.map +0 -1
  151. package/dist/types-Dyacb-A8.d.cts +0 -91
  152. package/dist/types-Dyacb-A8.d.cts.map +0 -1
  153. package/dist/types-dghCRFW4.cjs +0 -87
  154. package/dist/types-dghCRFW4.cjs.map +0 -1
  155. package/dist/usage-DZ4QDygT.cjs +0 -74
  156. package/dist/usage-DZ4QDygT.cjs.map +0 -1
  157. package/dist/usage-Hi-6-LDr.js +0 -68
  158. package/dist/usage-Hi-6-LDr.js.map +0 -1
  159. package/dist/version-B-XjWQrQ.cjs +0 -19
  160. package/dist/version-B-XjWQrQ.cjs.map +0 -1
  161. package/dist/version-CWKzsUXy.js +0 -7
  162. package/dist/version-CWKzsUXy.js.map +0 -1
@@ -1,124 +0,0 @@
1
- import { DEVICE_CODE_ENDPOINT, DEVICE_CODE_SCOPES, SLOW_DOWN_INCREMENT_SEC, TOKEN_ENDPOINT } from "./constants-Da7VwSRQ.js";
2
- import { LIB_VERSION } from "./version-CWKzsUXy.js";
3
- import { DeviceCodeErrorSchema, DeviceCodeResponseSchema, TokenResponseSchema, getTokenUserLabel } from "./types-BCSxlxZI.js";
4
- import { exec } from "node:child_process";
5
- import * as fs from "node:fs";
6
-
7
- //#region src/auth/device-code-flow.ts
8
- const USER_AGENT = `sentry-mcp-server/${LIB_VERSION}`;
9
- var DeviceCodeError = class extends Error {
10
- constructor(message, code) {
11
- super(message);
12
- this.code = code;
13
- this.name = "DeviceCodeError";
14
- }
15
- };
16
- async function requestDeviceCode(clientId, host, scopes = DEVICE_CODE_SCOPES) {
17
- const url = `https://${host}${DEVICE_CODE_ENDPOINT}`;
18
- const resp = await fetch(url, {
19
- method: "POST",
20
- headers: {
21
- "Content-Type": "application/x-www-form-urlencoded",
22
- "User-Agent": USER_AGENT
23
- },
24
- body: new URLSearchParams({
25
- client_id: clientId,
26
- scope: scopes
27
- })
28
- });
29
- if (!resp.ok) {
30
- const text = await resp.text();
31
- throw new DeviceCodeError(`Failed to request device code (HTTP ${resp.status}): ${text}`);
32
- }
33
- const body = await resp.json();
34
- return DeviceCodeResponseSchema.parse(body);
35
- }
36
- function sleep(ms) {
37
- return new Promise((resolve) => setTimeout(resolve, ms));
38
- }
39
- async function pollForToken({ deviceCode, clientId, host, interval, expiresIn }) {
40
- const url = `https://${host}${TOKEN_ENDPOINT}`;
41
- const deadline = Date.now() + expiresIn * 1e3;
42
- let pollInterval = interval;
43
- while (Date.now() < deadline) {
44
- await sleep(pollInterval * 1e3);
45
- const resp = await fetch(url, {
46
- method: "POST",
47
- headers: {
48
- "Content-Type": "application/x-www-form-urlencoded",
49
- "User-Agent": USER_AGENT
50
- },
51
- body: new URLSearchParams({
52
- grant_type: "urn:ietf:params:oauth:grant-type:device_code",
53
- device_code: deviceCode,
54
- client_id: clientId
55
- })
56
- });
57
- if (resp.ok) {
58
- const body = await resp.json();
59
- return TokenResponseSchema.parse(body);
60
- }
61
- const errorBody = await resp.json().catch(() => null);
62
- const parsed = DeviceCodeErrorSchema.safeParse(errorBody);
63
- const errorCode = parsed.success ? parsed.data.error : void 0;
64
- switch (errorCode) {
65
- case "authorization_pending": continue;
66
- case "slow_down":
67
- pollInterval += SLOW_DOWN_INCREMENT_SEC;
68
- continue;
69
- case "access_denied": throw new DeviceCodeError("Authorization was denied. Please try again or provide --access-token.", errorCode);
70
- case "expired_token": throw new DeviceCodeError("Device code expired before authorization was completed.", errorCode);
71
- default: throw new DeviceCodeError(`Unexpected error during device code polling: ${errorCode ?? resp.statusText}`, errorCode);
72
- }
73
- }
74
- throw new DeviceCodeError("Device code expired before authorization was completed.", "expired_token");
75
- }
76
- /**
77
- * Write directly to stderr, bypassing console.warn which may be
78
- * intercepted by the MCP transport layer.
79
- */
80
- function stderr(msg) {
81
- process.stderr.write(`${msg}\n`);
82
- }
83
- function isWSL() {
84
- try {
85
- return fs.readFileSync("/proc/version", "utf-8").toLowerCase().includes("microsoft");
86
- } catch {
87
- return false;
88
- }
89
- }
90
- function openBrowser(url) {
91
- try {
92
- const { platform } = process;
93
- if (platform === "darwin") exec(`open ${JSON.stringify(url)}`);
94
- else if (platform === "win32") exec(`start "" ${JSON.stringify(url)}`);
95
- else if (isWSL()) exec(`cmd.exe /c start "" ${JSON.stringify(url)}`);
96
- else exec(`xdg-open ${JSON.stringify(url)}`);
97
- } catch {}
98
- }
99
- function displayDeviceCode(response) {
100
- stderr("");
101
- stderr(`To authorize, visit: ${response.verification_uri_complete}`);
102
- stderr(` and enter code: ${response.user_code}`);
103
- stderr("");
104
- stderr("Waiting for authorization...");
105
- openBrowser(response.verification_uri_complete);
106
- }
107
- async function authenticate({ clientId, host }) {
108
- stderr("No access token provided. Starting device authorization...");
109
- const deviceCodeResponse = await requestDeviceCode(clientId, host);
110
- displayDeviceCode(deviceCodeResponse);
111
- const tokenResponse = await pollForToken({
112
- deviceCode: deviceCodeResponse.device_code,
113
- clientId,
114
- host,
115
- interval: deviceCodeResponse.interval,
116
- expiresIn: deviceCodeResponse.expires_in
117
- });
118
- stderr(`Successfully authenticated as ${getTokenUserLabel(tokenResponse)}`);
119
- return tokenResponse;
120
- }
121
-
122
- //#endregion
123
- export { DeviceCodeError, authenticate, displayDeviceCode, pollForToken, requestDeviceCode };
124
- //# sourceMappingURL=device-code-flow-Bk6L232R.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"device-code-flow-Bk6L232R.js","names":["message: string","code?: string","clientId: string","host: string","scopes: string","ms: number","msg: string","url: string","response: DeviceCodeResponse"],"sources":["../src/auth/device-code-flow.ts"],"sourcesContent":["import { exec } from \"node:child_process\";\nimport * as fs from \"node:fs\";\nimport { LIB_VERSION } from \"@sentry/mcp-core/version\";\nimport {\n DEVICE_CODE_ENDPOINT,\n DEVICE_CODE_SCOPES,\n SLOW_DOWN_INCREMENT_SEC,\n TOKEN_ENDPOINT,\n} from \"./constants\";\nimport {\n DeviceCodeResponseSchema,\n DeviceCodeErrorSchema,\n TokenResponseSchema,\n getTokenUserLabel,\n type DeviceCodeResponse,\n type TokenResponse,\n} from \"./types\";\n\nconst USER_AGENT = `sentry-mcp-server/${LIB_VERSION}`;\n\nexport class DeviceCodeError extends Error {\n constructor(\n message: string,\n public readonly code?: string,\n ) {\n super(message);\n this.name = \"DeviceCodeError\";\n }\n}\n\nexport async function requestDeviceCode(\n clientId: string,\n host: string,\n scopes: string = DEVICE_CODE_SCOPES,\n): Promise<DeviceCodeResponse> {\n const url = `https://${host}${DEVICE_CODE_ENDPOINT}`;\n const resp = await fetch(url, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n \"User-Agent\": USER_AGENT,\n },\n body: new URLSearchParams({\n client_id: clientId,\n scope: scopes,\n }),\n });\n\n if (!resp.ok) {\n const text = await resp.text();\n throw new DeviceCodeError(\n `Failed to request device code (HTTP ${resp.status}): ${text}`,\n );\n }\n\n const body = await resp.json();\n return DeviceCodeResponseSchema.parse(body);\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nexport async function pollForToken({\n deviceCode,\n clientId,\n host,\n interval,\n expiresIn,\n}: {\n deviceCode: string;\n clientId: string;\n host: string;\n interval: number;\n expiresIn: number;\n}): Promise<TokenResponse> {\n const url = `https://${host}${TOKEN_ENDPOINT}`;\n const deadline = Date.now() + expiresIn * 1000;\n let pollInterval = interval;\n\n while (Date.now() < deadline) {\n await sleep(pollInterval * 1000);\n\n const resp = await fetch(url, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n \"User-Agent\": USER_AGENT,\n },\n body: new URLSearchParams({\n grant_type: \"urn:ietf:params:oauth:grant-type:device_code\",\n device_code: deviceCode,\n client_id: clientId,\n }),\n });\n\n if (resp.ok) {\n const body = await resp.json();\n return TokenResponseSchema.parse(body);\n }\n\n const errorBody = await resp.json().catch(() => null);\n const parsed = DeviceCodeErrorSchema.safeParse(errorBody);\n const errorCode = parsed.success ? parsed.data.error : undefined;\n\n switch (errorCode) {\n case \"authorization_pending\":\n // Keep polling at current interval\n continue;\n case \"slow_down\":\n pollInterval += SLOW_DOWN_INCREMENT_SEC;\n continue;\n case \"access_denied\":\n throw new DeviceCodeError(\n \"Authorization was denied. Please try again or provide --access-token.\",\n errorCode,\n );\n case \"expired_token\":\n throw new DeviceCodeError(\n \"Device code expired before authorization was completed.\",\n errorCode,\n );\n default:\n throw new DeviceCodeError(\n `Unexpected error during device code polling: ${errorCode ?? resp.statusText}`,\n errorCode,\n );\n }\n }\n\n throw new DeviceCodeError(\n \"Device code expired before authorization was completed.\",\n \"expired_token\",\n );\n}\n\n/**\n * Write directly to stderr, bypassing console.warn which may be\n * intercepted by the MCP transport layer.\n */\nfunction stderr(msg: string): void {\n process.stderr.write(`${msg}\\n`);\n}\n\nfunction isWSL(): boolean {\n try {\n return fs\n .readFileSync(\"/proc/version\", \"utf-8\")\n .toLowerCase()\n .includes(\"microsoft\");\n } catch {\n return false;\n }\n}\n\nfunction openBrowser(url: string): void {\n try {\n const { platform } = process;\n if (platform === \"darwin\") {\n exec(`open ${JSON.stringify(url)}`);\n } else if (platform === \"win32\") {\n exec(`start \"\" ${JSON.stringify(url)}`);\n } else if (isWSL()) {\n // WSL: invoke cmd.exe to open the default browser.\n exec(`cmd.exe /c start \"\" ${JSON.stringify(url)}`);\n } else {\n exec(`xdg-open ${JSON.stringify(url)}`);\n }\n } catch {\n // Best-effort — ignore errors (headless, etc.)\n }\n}\n\nexport function displayDeviceCode(response: DeviceCodeResponse): void {\n stderr(\"\");\n stderr(`To authorize, visit: ${response.verification_uri_complete}`);\n stderr(` and enter code: ${response.user_code}`);\n stderr(\"\");\n stderr(\"Waiting for authorization...\");\n\n openBrowser(response.verification_uri_complete);\n}\n\nexport async function authenticate({\n clientId,\n host,\n}: {\n clientId: string;\n host: string;\n}): Promise<TokenResponse> {\n stderr(\"No access token provided. Starting device authorization...\");\n\n const deviceCodeResponse = await requestDeviceCode(clientId, host);\n displayDeviceCode(deviceCodeResponse);\n\n const tokenResponse = await pollForToken({\n deviceCode: deviceCodeResponse.device_code,\n clientId,\n host,\n interval: deviceCodeResponse.interval,\n expiresIn: deviceCodeResponse.expires_in,\n });\n\n stderr(`Successfully authenticated as ${getTokenUserLabel(tokenResponse)}`);\n return tokenResponse;\n}\n"],"mappings":";;;;;;;AAkBA,MAAM,cAAc,oBAAoB;AAExC,IAAa,kBAAb,cAAqC,MAAM;CACzC,YACEA,SACgBC,MAChB;AACA,QAAM,QAAQ;EAFE;AAGhB,OAAK,OAAO;CACb;AACF;AAED,eAAsB,kBACpBC,UACAC,MACAC,SAAiB,oBACY;CAC7B,MAAM,OAAO,UAAU,OAAO;CAC9B,MAAM,OAAO,MAAM,MAAM,KAAK;EAC5B,QAAQ;EACR,SAAS;GACP,gBAAgB;GAChB,cAAc;EACf;EACD,MAAM,IAAI,gBAAgB;GACxB,WAAW;GACX,OAAO;EACR;CACF,EAAC;AAEF,MAAK,KAAK,IAAI;EACZ,MAAM,OAAO,MAAM,KAAK,MAAM;AAC9B,QAAM,IAAI,iBACP,sCAAsC,KAAK,OAAO,KAAK;CAE3D;CAED,MAAM,OAAO,MAAM,KAAK,MAAM;AAC9B,QAAO,yBAAyB,MAAM,KAAK;AAC5C;AAED,SAAS,MAAMC,IAA2B;AACxC,QAAO,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,GAAG;AACxD;AAED,eAAsB,aAAa,EACjC,YACA,UACA,MACA,UACA,WAOD,EAA0B;CACzB,MAAM,OAAO,UAAU,OAAO;CAC9B,MAAM,WAAW,KAAK,KAAK,GAAG,YAAY;CAC1C,IAAI,eAAe;AAEnB,QAAO,KAAK,KAAK,GAAG,UAAU;AAC5B,QAAM,MAAM,eAAe,IAAK;EAEhC,MAAM,OAAO,MAAM,MAAM,KAAK;GAC5B,QAAQ;GACR,SAAS;IACP,gBAAgB;IAChB,cAAc;GACf;GACD,MAAM,IAAI,gBAAg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AA0B;AAChD;AAED,eAAsB,aAAa,EACjC,UACA,MAID,EAA0B;AACzB,QAAO,6DAA6D;CAEpE,MAAM,qBAAqB,MAAM,kBAAkB,UAAU,KAAK;AAClE,mBAAkB,mBAAmB;CAErC,MAAM,gBAAgB,MAAM,aAAa;EACvC,YAAY,mBAAmB;EAC/B;EACA;EACA,UAAU,mBAAmB;EAC7B,WAAW,mBAAmB;CAC/B,EAAC;AAEF,SAAQ,gCAAgC,kBAAkB,cAAc,GAAG;AAC3E,QAAO;AACR"}
@@ -1,154 +0,0 @@
1
- const require_chunk = require('./chunk-Cv9WC9bY.cjs');
2
- const require_constants = require('./constants-BqO-QSHl.cjs');
3
- const require_version = require('./version-B-XjWQrQ.cjs');
4
- const require_types = require('./types-dghCRFW4.cjs');
5
- const node_child_process = require_chunk.__toESM(require("node:child_process"));
6
- const node_fs = require_chunk.__toESM(require("node:fs"));
7
-
8
- //#region src/auth/device-code-flow.ts
9
- const USER_AGENT = `sentry-mcp-server/${require_version.LIB_VERSION}`;
10
- var DeviceCodeError = class extends Error {
11
- constructor(message, code) {
12
- super(message);
13
- this.code = code;
14
- this.name = "DeviceCodeError";
15
- }
16
- };
17
- async function requestDeviceCode(clientId, host, scopes = require_constants.DEVICE_CODE_SCOPES) {
18
- const url = `https://${host}${require_constants.DEVICE_CODE_ENDPOINT}`;
19
- const resp = await fetch(url, {
20
- method: "POST",
21
- headers: {
22
- "Content-Type": "application/x-www-form-urlencoded",
23
- "User-Agent": USER_AGENT
24
- },
25
- body: new URLSearchParams({
26
- client_id: clientId,
27
- scope: scopes
28
- })
29
- });
30
- if (!resp.ok) {
31
- const text = await resp.text();
32
- throw new DeviceCodeError(`Failed to request device code (HTTP ${resp.status}): ${text}`);
33
- }
34
- const body = await resp.json();
35
- return require_types.DeviceCodeResponseSchema.parse(body);
36
- }
37
- function sleep(ms) {
38
- return new Promise((resolve) => setTimeout(resolve, ms));
39
- }
40
- async function pollForToken({ deviceCode, clientId, host, interval, expiresIn }) {
41
- const url = `https://${host}${require_constants.TOKEN_ENDPOINT}`;
42
- const deadline = Date.now() + expiresIn * 1e3;
43
- let pollInterval = interval;
44
- while (Date.now() < deadline) {
45
- await sleep(pollInterval * 1e3);
46
- const resp = await fetch(url, {
47
- method: "POST",
48
- headers: {
49
- "Content-Type": "application/x-www-form-urlencoded",
50
- "User-Agent": USER_AGENT
51
- },
52
- body: new URLSearchParams({
53
- grant_type: "urn:ietf:params:oauth:grant-type:device_code",
54
- device_code: deviceCode,
55
- client_id: clientId
56
- })
57
- });
58
- if (resp.ok) {
59
- const body = await resp.json();
60
- return require_types.TokenResponseSchema.parse(body);
61
- }
62
- const errorBody = await resp.json().catch(() => null);
63
- const parsed = require_types.DeviceCodeErrorSchema.safeParse(errorBody);
64
- const errorCode = parsed.success ? parsed.data.error : void 0;
65
- switch (errorCode) {
66
- case "authorization_pending": continue;
67
- case "slow_down":
68
- pollInterval += require_constants.SLOW_DOWN_INCREMENT_SEC;
69
- continue;
70
- case "access_denied": throw new DeviceCodeError("Authorization was denied. Please try again or provide --access-token.", errorCode);
71
- case "expired_token": throw new DeviceCodeError("Device code expired before authorization was completed.", errorCode);
72
- default: throw new DeviceCodeError(`Unexpected error during device code polling: ${errorCode ?? resp.statusText}`, errorCode);
73
- }
74
- }
75
- throw new DeviceCodeError("Device code expired before authorization was completed.", "expired_token");
76
- }
77
- /**
78
- * Write directly to stderr, bypassing console.warn which may be
79
- * intercepted by the MCP transport layer.
80
- */
81
- function stderr(msg) {
82
- process.stderr.write(`${msg}\n`);
83
- }
84
- function isWSL() {
85
- try {
86
- return node_fs.readFileSync("/proc/version", "utf-8").toLowerCase().includes("microsoft");
87
- } catch {
88
- return false;
89
- }
90
- }
91
- function openBrowser(url) {
92
- try {
93
- const { platform } = process;
94
- if (platform === "darwin") (0, node_child_process.exec)(`open ${JSON.stringify(url)}`);
95
- else if (platform === "win32") (0, node_child_process.exec)(`start "" ${JSON.stringify(url)}`);
96
- else if (isWSL()) (0, node_child_process.exec)(`cmd.exe /c start "" ${JSON.stringify(url)}`);
97
- else (0, node_child_process.exec)(`xdg-open ${JSON.stringify(url)}`);
98
- } catch {}
99
- }
100
- function displayDeviceCode(response) {
101
- stderr("");
102
- stderr(`To authorize, visit: ${response.verification_uri_complete}`);
103
- stderr(` and enter code: ${response.user_code}`);
104
- stderr("");
105
- stderr("Waiting for authorization...");
106
- openBrowser(response.verification_uri_complete);
107
- }
108
- async function authenticate({ clientId, host }) {
109
- stderr("No access token provided. Starting device authorization...");
110
- const deviceCodeResponse = await requestDeviceCode(clientId, host);
111
- displayDeviceCode(deviceCodeResponse);
112
- const tokenResponse = await pollForToken({
113
- deviceCode: deviceCodeResponse.device_code,
114
- clientId,
115
- host,
116
- interval: deviceCodeResponse.interval,
117
- expiresIn: deviceCodeResponse.expires_in
118
- });
119
- stderr(`Successfully authenticated as ${require_types.getTokenUserLabel(tokenResponse)}`);
120
- return tokenResponse;
121
- }
122
-
123
- //#endregion
124
- Object.defineProperty(exports, 'DeviceCodeError', {
125
- enumerable: true,
126
- get: function () {
127
- return DeviceCodeError;
128
- }
129
- });
130
- Object.defineProperty(exports, 'authenticate', {
131
- enumerable: true,
132
- get: function () {
133
- return authenticate;
134
- }
135
- });
136
- Object.defineProperty(exports, 'displayDeviceCode', {
137
- enumerable: true,
138
- get: function () {
139
- return displayDeviceCode;
140
- }
141
- });
142
- Object.defineProperty(exports, 'pollForToken', {
143
- enumerable: true,
144
- get: function () {
145
- return pollForToken;
146
- }
147
- });
148
- Object.defineProperty(exports, 'requestDeviceCode', {
149
- enumerable: true,
150
- get: function () {
151
- return requestDeviceCode;
152
- }
153
- });
154
- //# sourceMappingURL=device-code-flow-Dv-auCiV.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"device-code-flow-Dv-auCiV.cjs","names":["LIB_VERSION","message: string","code?: string","clientId: string","host: string","scopes: string","DEVICE_CODE_SCOPES","DEVICE_CODE_ENDPOINT","ms: number","TOKEN_ENDPOINT","SLOW_DOWN_INCREMENT_SEC","msg: string","url: string","response: DeviceCodeResponse"],"sources":["../src/auth/device-code-flow.ts"],"sourcesContent":["import { exec } from \"node:child_process\";\nimport * as fs from \"node:fs\";\nimport { LIB_VERSION } from \"@sentry/mcp-core/version\";\nimport {\n DEVICE_CODE_ENDPOINT,\n DEVICE_CODE_SCOPES,\n SLOW_DOWN_INCREMENT_SEC,\n TOKEN_ENDPOINT,\n} from \"./constants\";\nimport {\n DeviceCodeResponseSchema,\n DeviceCodeErrorSchema,\n TokenResponseSchema,\n getTokenUserLabel,\n type DeviceCodeResponse,\n type TokenResponse,\n} from \"./types\";\n\nconst USER_AGENT = `sentry-mcp-server/${LIB_VERSION}`;\n\nexport class DeviceCodeError extends Error {\n constructor(\n message: string,\n public readonly code?: string,\n ) {\n super(message);\n this.name = \"DeviceCodeError\";\n }\n}\n\nexport async function requestDeviceCode(\n clientId: string,\n host: string,\n scopes: string = DEVICE_CODE_SCOPES,\n): Promise<DeviceCodeResponse> {\n const url = `https://${host}${DEVICE_CODE_ENDPOINT}`;\n const resp = await fetch(url, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n \"User-Agent\": USER_AGENT,\n },\n body: new URLSearchParams({\n client_id: clientId,\n scope: scopes,\n }),\n });\n\n if (!resp.ok) {\n const text = await resp.text();\n throw new DeviceCodeError(\n `Failed to request device code (HTTP ${resp.status}): ${text}`,\n );\n }\n\n const body = await resp.json();\n return DeviceCodeResponseSchema.parse(body);\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nexport async function pollForToken({\n deviceCode,\n clientId,\n host,\n interval,\n expiresIn,\n}: {\n deviceCode: string;\n clientId: string;\n host: string;\n interval: number;\n expiresIn: number;\n}): Promise<TokenResponse> {\n const url = `https://${host}${TOKEN_ENDPOINT}`;\n const deadline = Date.now() + expiresIn * 1000;\n let pollInterval = interval;\n\n while (Date.now() < deadline) {\n await sleep(pollInterval * 1000);\n\n const resp = await fetch(url, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n \"User-Agent\": USER_AGENT,\n },\n body: new URLSearchParams({\n grant_type: \"urn:ietf:params:oauth:grant-type:device_code\",\n device_code: deviceCode,\n client_id: clientId,\n }),\n });\n\n if (resp.ok) {\n const body = await resp.json();\n return TokenResponseSchema.parse(body);\n }\n\n const errorBody = await resp.json().catch(() => null);\n const parsed = DeviceCodeErrorSchema.safeParse(errorBody);\n const errorCode = parsed.success ? parsed.data.error : undefined;\n\n switch (errorCode) {\n case \"authorization_pending\":\n // Keep polling at current interval\n continue;\n case \"slow_down\":\n pollInterval += SLOW_DOWN_INCREMENT_SEC;\n continue;\n case \"access_denied\":\n throw new DeviceCodeError(\n \"Authorization was denied. Please try again or provide --access-token.\",\n errorCode,\n );\n case \"expired_token\":\n throw new DeviceCodeError(\n \"Device code expired before authorization was completed.\",\n errorCode,\n );\n default:\n throw new DeviceCodeError(\n `Unexpected error during device code polling: ${errorCode ?? resp.statusText}`,\n errorCode,\n );\n }\n }\n\n throw new DeviceCodeError(\n \"Device code expired before authorization was completed.\",\n \"expired_token\",\n );\n}\n\n/**\n * Write directly to stderr, bypassing console.warn which may be\n * intercepted by the MCP transport layer.\n */\nfunction stderr(msg: string): void {\n process.stderr.write(`${msg}\\n`);\n}\n\nfunction isWSL(): boolean {\n try {\n return fs\n .readFileSync(\"/proc/version\", \"utf-8\")\n .toLowerCase()\n .includes(\"microsoft\");\n } catch {\n return false;\n }\n}\n\nfunction openBrowser(url: string): void {\n try {\n const { platform } = process;\n if (platform === \"darwin\") {\n exec(`open ${JSON.stringify(url)}`);\n } else if (platform === \"win32\") {\n exec(`start \"\" ${JSON.stringify(url)}`);\n } else if (isWSL()) {\n // WSL: invoke cmd.exe to open the default browser.\n exec(`cmd.exe /c start \"\" ${JSON.stringify(url)}`);\n } else {\n exec(`xdg-open ${JSON.stringify(url)}`);\n }\n } catch {\n // Best-effort — ignore errors (headless, etc.)\n }\n}\n\nexport function displayDeviceCode(response: DeviceCodeResponse): void {\n stderr(\"\");\n stderr(`To authorize, visit: ${response.verification_uri_complete}`);\n stderr(` and enter code: ${response.user_code}`);\n stderr(\"\");\n stderr(\"Waiting for authorization...\");\n\n openBrowser(response.verification_uri_complete);\n}\n\nexport async function authenticate({\n clientId,\n host,\n}: {\n clientId: string;\n host: string;\n}): Promise<TokenResponse> {\n stderr(\"No access token provided. Starting device authorization...\");\n\n const deviceCodeResponse = await requestDeviceCode(clientId, host);\n displayDeviceCode(deviceCodeResponse);\n\n const tokenResponse = await pollForToken({\n deviceCode: deviceCodeResponse.device_code,\n clientId,\n host,\n interval: deviceCodeResponse.interval,\n expiresIn: deviceCodeResponse.expires_in,\n });\n\n stderr(`Successfully authenticated as ${getTokenUserLabel(tokenResponse)}`);\n return tokenResponse;\n}\n"],"mappings":";;;;;;;;AAkBA,MAAM,cAAc,oBAAoBA;AAExC,IAAa,kBAAb,cAAqC,MAAM;CACzC,YACEC,SACgBC,MAChB;AACA,QAAM,QAAQ;EAFE;AAGhB,OAAK,OAAO;CACb;AACF;AAED,eAAsB,kBACpBC,UACAC,MACAC,SAAiBC,sCACY;CAC7B,MAAM,OAAO,UAAU,OAAOC;CAC9B,MAAM,OAAO,MAAM,MAAM,KAAK;EAC5B,QAAQ;EACR,SAAS;GACP,gBAAgB;GAChB,cAAc;EACf;EACD,MAAM,IAAI,gBAAgB;GACxB,WAAW;GACX,OAAO;EACR;CACF,EAAC;AAEF,MAAK,KAAK,IAAI;EACZ,MAAM,OAAO,MAAM,KAAK,MAAM;AAC9B,QAAM,IAAI,iBACP,sCAAsC,KAAK,OAAO,KAAK;CAE3D;CAED,MAAM,OAAO,MAAM,KAAK,MAAM;AAC9B,QAAO,uCAAyB,MAAM,KAAK;AAC5C;AAED,SAAS,MAAMC,IAA2B;AACxC,QAAO,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,GAAG;AACxD;AAED,eAAsB,aAAa,EACjC,YAC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