@sentry/craft 3.11.2 → 3.12.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 (2) hide show
  1. package/dist/craft +154 -50
  2. package/package.json +1 -1
package/dist/craft CHANGED
@@ -124838,6 +124838,42 @@ var init_dotnetWorkspaces = __esm({
124838
124838
  }
124839
124839
  });
124840
124840
 
124841
+ // src/utils/githubOidc.ts
124842
+ function getGitHubOidcRequest() {
124843
+ const url3 = process.env.ACTIONS_ID_TOKEN_REQUEST_URL;
124844
+ const token = process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN;
124845
+ return url3 && token ? { url: url3, token } : void 0;
124846
+ }
124847
+ async function getGitHubOidcToken(request3, audience) {
124848
+ const url3 = new URL(request3.url);
124849
+ url3.searchParams.set("audience", audience);
124850
+ const response = await fetch(url3, {
124851
+ headers: {
124852
+ Accept: "application/json",
124853
+ Authorization: `Bearer ${request3.token}`
124854
+ },
124855
+ signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
124856
+ });
124857
+ if (!response.ok) {
124858
+ throw new Error(
124859
+ `GitHub OIDC token request failed: HTTP ${response.status}`
124860
+ );
124861
+ }
124862
+ const { value } = await response.json();
124863
+ if (!value) {
124864
+ throw new Error("GitHub OIDC token response has no token");
124865
+ }
124866
+ return value;
124867
+ }
124868
+ var REQUEST_TIMEOUT_MS;
124869
+ var init_githubOidc = __esm({
124870
+ "src/utils/githubOidc.ts"() {
124871
+ "use strict";
124872
+ init_import_meta_url();
124873
+ REQUEST_TIMEOUT_MS = 3e4;
124874
+ }
124875
+ });
124876
+
124841
124877
  // src/utils/nugetRegistry.ts
124842
124878
  function normalizeNugetVersion(version2) {
124843
124879
  const withoutMetadata = version2.split("+")[0];
@@ -125021,7 +125057,7 @@ var init_nugetRegistry = __esm({
125021
125057
  function readXmlTag(content, tag2) {
125022
125058
  return new RegExp(`<${tag2}>([^<]+)</${tag2}>`).exec(content)?.[1].trim();
125023
125059
  }
125024
- var import_fs18, import_path15, import_crypto6, NUGET_DOTNET_BIN, DEFAULT_NUGET_SERVER_URL, DEFAULT_NUGET_REGEX, SYMBOLS_NUGET_REGEX, DOTNET_SPAWN_OPTIONS, NugetTarget;
125060
+ var import_fs18, import_path15, import_crypto6, NUGET_DOTNET_BIN, DEFAULT_NUGET_SERVER_URL, NUGET_USER_ENV_VAR, NUGET_TOKEN_SERVICE_URL, NUGET_OIDC_AUDIENCE, TEMPORARY_API_KEY_MAX_AGE_MS, REQUEST_TIMEOUT_MS2, DEFAULT_NUGET_REGEX, SYMBOLS_NUGET_REGEX, DOTNET_SPAWN_OPTIONS, NugetTarget;
125025
125061
  var init_nuget = __esm({
125026
125062
  "src/targets/nuget.ts"() {
125027
125063
  "use strict";
@@ -125035,17 +125071,25 @@ var init_nuget = __esm({
125035
125071
  init_base5();
125036
125072
  init_dotnetWorkspaces();
125037
125073
  init_workspaces();
125074
+ init_githubOidc();
125038
125075
  init_nugetRegistry();
125039
125076
  init_logger2();
125040
125077
  init_versionPatterns();
125041
125078
  NUGET_DOTNET_BIN = process.env.NUGET_DOTNET_BIN || "dotnet";
125042
125079
  DEFAULT_NUGET_SERVER_URL = "https://api.nuget.org/v3/index.json";
125080
+ NUGET_USER_ENV_VAR = "NUGET_USER";
125081
+ NUGET_TOKEN_SERVICE_URL = "https://www.nuget.org/api/v2/token";
125082
+ NUGET_OIDC_AUDIENCE = "https://www.nuget.org";
125083
+ TEMPORARY_API_KEY_MAX_AGE_MS = 45 * 60 * 1e3;
125084
+ REQUEST_TIMEOUT_MS2 = 3e4;
125043
125085
  DEFAULT_NUGET_REGEX = /^.*\d\.\d.*\.nupkg$/;
125044
125086
  SYMBOLS_NUGET_REGEX = /^.*\d\.\d.*\.snupkg$/;
125045
125087
  DOTNET_SPAWN_OPTIONS = { cwd: "/" };
125046
125088
  NugetTarget = class _NugetTarget extends BaseTarget {
125047
125089
  name = "nuget";
125048
125090
  nugetConfig;
125091
+ /** Temporary API key from trusted publishing, shared by parallel pushes */
125092
+ temporaryApiKey;
125049
125093
  /**
125050
125094
  * Expand a nuget target config into multiple targets if workspaces is enabled.
125051
125095
  *
@@ -125121,6 +125165,9 @@ var init_nuget = __esm({
125121
125165
  if (config.serverUrl) {
125122
125166
  expandedTarget.serverUrl = config.serverUrl;
125123
125167
  }
125168
+ if (config.trustedPublishingUser) {
125169
+ expandedTarget.trustedPublishingUser = config.trustedPublishingUser;
125170
+ }
125124
125171
  return expandedTarget;
125125
125172
  });
125126
125173
  }
@@ -125240,41 +125287,123 @@ var init_nuget = __esm({
125240
125287
  * Extracts Nuget target options from the raw configuration
125241
125288
  */
125242
125289
  getNugetConfig() {
125290
+ const config = this.config;
125291
+ const serverUrl = config.serverUrl || DEFAULT_NUGET_SERVER_URL;
125292
+ const trustedPublishingUser = config.trustedPublishingUser || process.env[NUGET_USER_ENV_VAR];
125293
+ if (trustedPublishingUser) {
125294
+ if (!getGitHubOidcRequest()) {
125295
+ throw new ConfigurationError(
125296
+ `Cannot perform Nuget release: trusted publishing is enabled ("trustedPublishingUser" or ${NUGET_USER_ENV_VAR}), but GitHub Actions OIDC is not available. Run in GitHub Actions with the "id-token: write" permission.`
125297
+ );
125298
+ }
125299
+ if (serverUrl !== DEFAULT_NUGET_SERVER_URL) {
125300
+ throw new ConfigurationError(
125301
+ `Cannot perform Nuget release: trusted publishing only works with ${DEFAULT_NUGET_SERVER_URL}, but serverUrl is ${serverUrl}.`
125302
+ );
125303
+ }
125304
+ return { trustedPublishingUser, serverUrl };
125305
+ }
125243
125306
  if (!process.env.NUGET_API_TOKEN) {
125244
125307
  throw new ConfigurationError(
125245
125308
  `Cannot perform Nuget release: missing credentials.
125246
- Please use NUGET_API_TOKEN environment variable.`
125309
+ Please set "trustedPublishingUser" or ${NUGET_USER_ENV_VAR} (trusted publishing), or NUGET_API_TOKEN.`
125247
125310
  );
125248
125311
  }
125249
- const config = this.config;
125250
- return {
125251
- apiToken: process.env.NUGET_API_TOKEN,
125252
- serverUrl: config.serverUrl || DEFAULT_NUGET_SERVER_URL
125253
- };
125312
+ return { apiToken: process.env.NUGET_API_TOKEN, serverUrl };
125313
+ }
125314
+ /**
125315
+ * Returns the API key to push with: NUGET_API_TOKEN, or with trusted
125316
+ * publishing, a temporary key that is renewed before it expires.
125317
+ */
125318
+ getApiKey() {
125319
+ const { apiToken, trustedPublishingUser } = this.nugetConfig;
125320
+ if (!trustedPublishingUser) {
125321
+ return Promise.resolve(apiToken ?? "");
125322
+ }
125323
+ if (!this.temporaryApiKey || Date.now() >= this.temporaryApiKey.expiresAt) {
125324
+ this.temporaryApiKey = {
125325
+ value: this.requestTemporaryApiKey(trustedPublishingUser),
125326
+ expiresAt: Date.now() + TEMPORARY_API_KEY_MAX_AGE_MS
125327
+ };
125328
+ }
125329
+ return this.temporaryApiKey.value;
125330
+ }
125331
+ /**
125332
+ * Exchanges a GitHub Actions OIDC token for a temporary nuget.org API key,
125333
+ * as described in https://learn.microsoft.com/nuget/nuget-org/trusted-publishing
125334
+ */
125335
+ async requestTemporaryApiKey(user) {
125336
+ const oidcRequest = getGitHubOidcRequest();
125337
+ if (!oidcRequest) {
125338
+ throw new Error("GitHub Actions OIDC is no longer available");
125339
+ }
125340
+ const oidcToken = await getGitHubOidcToken(
125341
+ oidcRequest,
125342
+ NUGET_OIDC_AUDIENCE
125343
+ );
125344
+ this.logger.info(
125345
+ `Requesting a temporary NuGet API key for "${user}" with trusted publishing`
125346
+ );
125347
+ const response = await fetch(NUGET_TOKEN_SERVICE_URL, {
125348
+ method: "POST",
125349
+ headers: {
125350
+ Authorization: `Bearer ${oidcToken}`,
125351
+ "Content-Type": "application/json",
125352
+ "User-Agent": "getsentry/craft"
125353
+ },
125354
+ body: JSON.stringify({ username: user, tokenType: "ApiKey" }),
125355
+ signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS2)
125356
+ });
125357
+ if (!response.ok) {
125358
+ const details = (await response.text().catch(() => "")).slice(0, 500);
125359
+ throw new Error(
125360
+ `NuGet trusted publishing token exchange failed: HTTP ${response.status}` + (details ? `: ${details}` : "") + `
125361
+
125362
+ Check that a trusted publishing policy on nuget.org matches this repository, workflow file and environment, and that "${user}" is the nuget.org user who created the policy, not the organization that owns it.`
125363
+ );
125364
+ }
125365
+ const { apiKey } = await response.json();
125366
+ if (!apiKey) {
125367
+ throw new Error(
125368
+ "NuGet trusted publishing token exchange returned no API key"
125369
+ );
125370
+ }
125371
+ if (process.env.GITHUB_ACTIONS === "true") {
125372
+ process.stdout.write(`::add-mask::${apiKey}
125373
+ `);
125374
+ }
125375
+ return apiKey;
125254
125376
  }
125255
125377
  /**
125256
125378
  * Uploads an archive to Nuget using "dotnet nuget"
125379
+ *
125380
+ * The key is passed as a `${...}` placeholder that spawnProcess fills in,
125381
+ * so it never shows up in the logged command line.
125257
125382
  */
125258
- async uploadAsset(path22) {
125383
+ async uploadAsset(path22, apiKey) {
125259
125384
  const args = [
125260
125385
  "nuget",
125261
125386
  "push",
125262
125387
  path22,
125263
125388
  "--api-key",
125264
- "${NUGET_API_TOKEN}",
125389
+ "${NUGET_API_KEY}",
125265
125390
  "--source",
125266
125391
  this.nugetConfig.serverUrl,
125267
125392
  "--timeout",
125268
125393
  "1800"
125269
125394
  ];
125270
- return spawnProcess(NUGET_DOTNET_BIN, args, DOTNET_SPAWN_OPTIONS);
125395
+ return spawnProcess(NUGET_DOTNET_BIN, args, {
125396
+ ...DOTNET_SPAWN_OPTIONS,
125397
+ env: { ...process.env, NUGET_API_KEY: apiKey }
125398
+ });
125271
125399
  }
125272
125400
  /**
125273
125401
  * Pushes a file, adding a hint when NuGet rejects it as a duplicate.
125274
125402
  */
125275
125403
  async push(path22) {
125404
+ const apiKey = await this.getApiKey();
125276
125405
  try {
125277
- await this.uploadAsset(path22);
125406
+ await this.uploadAsset(path22, apiKey);
125278
125407
  } catch (error3) {
125279
125408
  const message = error3 instanceof Error ? error3.message : String(error3);
125280
125409
  if (/\b409\b|already (contains|exists)/i.test(message)) {
@@ -158332,7 +158461,7 @@ function withoutSchema(server) {
158332
158461
  function errorMessage(err) {
158333
158462
  return err instanceof Error ? err.message : String(err);
158334
158463
  }
158335
- var import_fs23, import_path19, import_util23, DEFAULT_REGISTRY_URL, DEFAULT_MANIFEST, DEFAULT_NPM_REGISTRY_URL, GITHUB_TOKEN_ENV_VAR, OFFICIAL_META_KEY, REQUEST_TIMEOUT_MS, NPM_ATTEMPTS, NPM_RETRY_DELAY_MS, LISTING_ATTEMPTS, LISTING_RETRY_DELAY_MS, McpRegistryTarget;
158464
+ var import_fs23, import_path19, import_util23, DEFAULT_REGISTRY_URL, DEFAULT_MANIFEST, DEFAULT_NPM_REGISTRY_URL, GITHUB_TOKEN_ENV_VAR, OFFICIAL_META_KEY, REQUEST_TIMEOUT_MS3, NPM_ATTEMPTS, NPM_RETRY_DELAY_MS, LISTING_ATTEMPTS, LISTING_RETRY_DELAY_MS, McpRegistryTarget;
158336
158465
  var init_mcpRegistry = __esm({
158337
158466
  "src/targets/mcpRegistry.ts"() {
158338
158467
  "use strict";
@@ -158344,6 +158473,7 @@ var init_mcpRegistry = __esm({
158344
158473
  init_async();
158345
158474
  init_dryRun();
158346
158475
  init_errors2();
158476
+ init_githubOidc();
158347
158477
  init_helpers();
158348
158478
  init_base5();
158349
158479
  DEFAULT_REGISTRY_URL = "https://registry.modelcontextprotocol.io";
@@ -158351,7 +158481,7 @@ var init_mcpRegistry = __esm({
158351
158481
  DEFAULT_NPM_REGISTRY_URL = "https://registry.npmjs.org";
158352
158482
  GITHUB_TOKEN_ENV_VAR = "MCP_GITHUB_TOKEN";
158353
158483
  OFFICIAL_META_KEY = "io.modelcontextprotocol.registry/official";
158354
- REQUEST_TIMEOUT_MS = 3e4;
158484
+ REQUEST_TIMEOUT_MS3 = 3e4;
158355
158485
  NPM_ATTEMPTS = 30;
158356
158486
  NPM_RETRY_DELAY_MS = 1e4;
158357
158487
  LISTING_ATTEMPTS = 6;
@@ -158491,7 +158621,7 @@ var init_mcpRegistry = __esm({
158491
158621
  async getListing(name, version2) {
158492
158622
  const response = await fetch(this.listingUrl(name, version2), {
158493
158623
  headers: { Accept: "application/json" },
158494
- signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
158624
+ signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS3)
158495
158625
  });
158496
158626
  if (response.status === 404) {
158497
158627
  return void 0;
@@ -158547,7 +158677,7 @@ var init_mcpRegistry = __esm({
158547
158677
  try {
158548
158678
  response = await fetch(url3, {
158549
158679
  headers: { Accept: "application/json" },
158550
- signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
158680
+ signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS3)
158551
158681
  });
158552
158682
  reason = `HTTP ${response.status}`;
158553
158683
  } catch (err) {
@@ -158573,11 +158703,13 @@ var init_mcpRegistry = __esm({
158573
158703
  * `id-token: write`, otherwise exchanges `MCP_GITHUB_TOKEN`.
158574
158704
  */
158575
158705
  async getRegistryToken() {
158576
- const requestUrl = process.env.ACTIONS_ID_TOKEN_REQUEST_URL;
158577
- const requestToken = process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN;
158578
- if (requestUrl && requestToken) {
158706
+ const oidcRequest = getGitHubOidcRequest();
158707
+ if (oidcRequest) {
158579
158708
  this.logger.debug("Authenticating with GitHub Actions OIDC");
158580
- const oidcToken = await this.getGitHubOidcToken(requestUrl, requestToken);
158709
+ const oidcToken = await getGitHubOidcToken(
158710
+ oidcRequest,
158711
+ new URL(this.mcpRegistryConfig.registryUrl).origin
158712
+ );
158581
158713
  return this.exchangeToken("github-oidc", { oidc_token: oidcToken });
158582
158714
  }
158583
158715
  const githubToken = process.env[GITHUB_TOKEN_ENV_VAR];
@@ -158589,34 +158721,6 @@ var init_mcpRegistry = __esm({
158589
158721
  `[mcp-registry] No credentials: run in GitHub Actions with "id-token: write" permission, or set ${GITHUB_TOKEN_ENV_VAR}`
158590
158722
  );
158591
158723
  }
158592
- /**
158593
- * Requests a GitHub Actions OIDC token. Its audience is the registry origin,
158594
- * which the registry checks (same as `mcp-publisher login github-oidc`).
158595
- */
158596
- async getGitHubOidcToken(requestUrl, requestToken) {
158597
- const url3 = new URL(requestUrl);
158598
- url3.searchParams.set(
158599
- "audience",
158600
- new URL(this.mcpRegistryConfig.registryUrl).origin
158601
- );
158602
- const response = await fetch(url3, {
158603
- headers: {
158604
- Accept: "application/json",
158605
- Authorization: `Bearer ${requestToken}`
158606
- },
158607
- signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
158608
- });
158609
- if (!response.ok) {
158610
- throw new Error(
158611
- `GitHub OIDC token request failed: HTTP ${response.status}`
158612
- );
158613
- }
158614
- const { value } = await response.json();
158615
- if (!value) {
158616
- throw new Error("GitHub OIDC token response has no token");
158617
- }
158618
- return value;
158619
- }
158620
158724
  /** Exchanges a GitHub credential for a short-lived registry token */
158621
158725
  async exchangeToken(method, body) {
158622
158726
  const response = await this.postJson(
@@ -158647,7 +158751,7 @@ var init_mcpRegistry = __esm({
158647
158751
  ...token ? { Authorization: `Bearer ${token}` } : {}
158648
158752
  },
158649
158753
  body: JSON.stringify(body),
158650
- signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
158754
+ signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS3)
158651
158755
  }
158652
158756
  );
158653
158757
  if (!response.ok) {
@@ -230922,7 +231026,7 @@ var require_package7 = __commonJS({
230922
231026
  "package.json"(exports2, module2) {
230923
231027
  module2.exports = {
230924
231028
  name: "@sentry/craft",
230925
- version: "3.11.2",
231029
+ version: "3.12.0",
230926
231030
  description: "The universal sentry workflow CLI",
230927
231031
  main: "dist/craft",
230928
231032
  repository: "https://github.com/getsentry/craft",
@@ -231130,7 +231234,7 @@ function getPackage() {
231130
231234
  }
231131
231235
  function getPackageVersion3() {
231132
231236
  const { version: version2 } = getPackage();
231133
- const buildInfo = "9567926a606072678ef367b02445c4f99f374795";
231237
+ const buildInfo = "0da9309228741a4c300d3c87ed7dcafa8f703525";
231134
231238
  return buildInfo ? `${version2} (${buildInfo})` : version2;
231135
231239
  }
231136
231240
  function semVerToString(s8) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/craft",
3
- "version": "3.11.2",
3
+ "version": "3.12.0",
4
4
  "description": "The universal sentry workflow CLI",
5
5
  "main": "dist/craft",
6
6
  "repository": "https://github.com/getsentry/craft",