@postman-cse/onboarding-bootstrap 2.8.0 → 2.9.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/dist/action.cjs CHANGED
@@ -264612,6 +264612,53 @@ var AccessTokenProvider = class {
264612
264612
  return token;
264613
264613
  }
264614
264614
  };
264615
+ async function describeMintFailure(mintError, apiKey, apiBaseUrl, fetchImpl) {
264616
+ const raw = mintError instanceof Error ? mintError.message : String(mintError);
264617
+ const rejected = /HTTP 40[13]|PMAK rejected/.test(raw);
264618
+ if (!rejected) {
264619
+ return raw;
264620
+ }
264621
+ try {
264622
+ const me = await fetchImpl(`${apiBaseUrl}/me`, { headers: { "x-api-key": apiKey } });
264623
+ if (me.ok) {
264624
+ const body2 = await me.json().catch(() => void 0);
264625
+ const user = body2?.user;
264626
+ const looksPersonal = Boolean(user && (user.username || user.email));
264627
+ if (looksPersonal) {
264628
+ return "Personal API key detected, cannot mint a service-account access token. POST /service-account-tokens only accepts a SERVICE-ACCOUNT API key; this postman-api-key belongs to a user account" + (user?.teamId ? ` (team ${user.teamId})` : "") + ". Create a service account in Team Settings and use its PMAK, or mint the token elsewhere and pass postman-access-token.";
264629
+ }
264630
+ return "The postman-api-key authenticates (GET /me OK) but was rejected by POST /service-account-tokens" + (user?.teamId ? ` (team ${user.teamId})` : "") + ". The service account likely lacks permission to mint access tokens, or service accounts are restricted for this team. Check the service account role in Team Settings, or pass a pre-minted postman-access-token.";
264631
+ }
264632
+ return "The postman-api-key is invalid, disabled, or expired (rejected by both POST /service-account-tokens and GET /me). Generate a fresh service-account PMAK in Team Settings and update the secret.";
264633
+ } catch {
264634
+ return raw;
264635
+ }
264636
+ }
264637
+ async function mintAccessTokenIfNeeded(inputs, log, setSecret2, fetchImpl = fetch) {
264638
+ if (inputs.postmanAccessToken || !inputs.postmanApiKey) {
264639
+ return;
264640
+ }
264641
+ const apiBaseUrl = String(
264642
+ inputs.postmanApiBase || POSTMAN_ENDPOINT_PROFILES.prod.apiBaseUrl
264643
+ ).replace(/\/+$/, "");
264644
+ const provider = new AccessTokenProvider({
264645
+ apiKey: inputs.postmanApiKey,
264646
+ apiBaseUrl,
264647
+ fetchImpl,
264648
+ onToken: (token) => setSecret2?.(token)
264649
+ });
264650
+ try {
264651
+ inputs.postmanAccessToken = await provider.refresh();
264652
+ log.info(
264653
+ "postman: no postman-access-token configured - minted a short-lived service-account access token from the postman-api-key."
264654
+ );
264655
+ } catch (error2) {
264656
+ const diagnosis = await describeMintFailure(error2, inputs.postmanApiKey, apiBaseUrl, fetchImpl);
264657
+ log.warning(
264658
+ "postman: could not mint an access token from the postman-api-key. " + diagnosis + " Continuing without an access token - access-token-only functionality will be unavailable unless postman-access-token is provided."
264659
+ );
264660
+ }
264661
+ }
264615
264662
 
264616
264663
  // src/lib/postman/workspace-selection.ts
264617
264664
  function chooseCanonicalWorkspace(args) {
@@ -307782,29 +307829,8 @@ function warnIfDeprecatedAccessToken(actionCore, inputs) {
307782
307829
  )
307783
307830
  );
307784
307831
  }
307785
- async function mintAccessTokenIfNeeded(inputs, log, setSecret2) {
307786
- if (inputs.postmanAccessToken || !inputs.postmanApiKey) {
307787
- return;
307788
- }
307789
- const provider = new AccessTokenProvider({
307790
- apiKey: inputs.postmanApiKey,
307791
- apiBaseUrl: inputs.postmanApiBase,
307792
- onToken: (token) => setSecret2?.(token)
307793
- });
307794
- try {
307795
- inputs.postmanAccessToken = await provider.refresh();
307796
- log.info(
307797
- "postman: no postman-access-token configured - minted a short-lived service-account access token from the postman-api-key."
307798
- );
307799
- } catch (error2) {
307800
- const mask = createSecretMasker([inputs.postmanApiKey]);
307801
- const message = error2 instanceof Error ? error2.message : String(error2);
307802
- log.warning(
307803
- mask(
307804
- "postman: could not mint an access token from the postman-api-key (" + message + "). Continuing with PMAK only - governance assignment and org-mode detection are disabled. Configure postman-access-token (postman-cs/postman-resolve-service-token-action) for full functionality."
307805
- )
307806
- );
307807
- }
307832
+ async function mintAccessTokenIfNeeded2(inputs, log, setSecret2) {
307833
+ await mintAccessTokenIfNeeded(inputs, log, setSecret2);
307808
307834
  }
307809
307835
  function isLegacyAccessTokenDeprecationWarning(message) {
307810
307836
  return message.includes("Postman CLI credential store populated by `postman login` is a legacy fallback");
@@ -309092,7 +309118,7 @@ async function runBootstrapInner(inputs, dependencies, telemetry) {
309092
309118
  }
309093
309119
  async function runAction(actionCore = core_exports, actionExec = exec_exports, actionIo = io_exports) {
309094
309120
  const inputs = readActionInputs(actionCore);
309095
- await mintAccessTokenIfNeeded(inputs, {
309121
+ await mintAccessTokenIfNeeded2(inputs, {
309096
309122
  info: (message) => actionCore.info(message),
309097
309123
  warning: (message) => actionCore.warning(message)
309098
309124
  }, (secret) => actionCore.setSecret(secret));
package/dist/cli.cjs CHANGED
@@ -262930,6 +262930,53 @@ var AccessTokenProvider = class {
262930
262930
  return token;
262931
262931
  }
262932
262932
  };
262933
+ async function describeMintFailure(mintError, apiKey, apiBaseUrl, fetchImpl) {
262934
+ const raw = mintError instanceof Error ? mintError.message : String(mintError);
262935
+ const rejected = /HTTP 40[13]|PMAK rejected/.test(raw);
262936
+ if (!rejected) {
262937
+ return raw;
262938
+ }
262939
+ try {
262940
+ const me = await fetchImpl(`${apiBaseUrl}/me`, { headers: { "x-api-key": apiKey } });
262941
+ if (me.ok) {
262942
+ const body2 = await me.json().catch(() => void 0);
262943
+ const user = body2?.user;
262944
+ const looksPersonal = Boolean(user && (user.username || user.email));
262945
+ if (looksPersonal) {
262946
+ return "Personal API key detected, cannot mint a service-account access token. POST /service-account-tokens only accepts a SERVICE-ACCOUNT API key; this postman-api-key belongs to a user account" + (user?.teamId ? ` (team ${user.teamId})` : "") + ". Create a service account in Team Settings and use its PMAK, or mint the token elsewhere and pass postman-access-token.";
262947
+ }
262948
+ return "The postman-api-key authenticates (GET /me OK) but was rejected by POST /service-account-tokens" + (user?.teamId ? ` (team ${user.teamId})` : "") + ". The service account likely lacks permission to mint access tokens, or service accounts are restricted for this team. Check the service account role in Team Settings, or pass a pre-minted postman-access-token.";
262949
+ }
262950
+ return "The postman-api-key is invalid, disabled, or expired (rejected by both POST /service-account-tokens and GET /me). Generate a fresh service-account PMAK in Team Settings and update the secret.";
262951
+ } catch {
262952
+ return raw;
262953
+ }
262954
+ }
262955
+ async function mintAccessTokenIfNeeded(inputs, log, setSecret2, fetchImpl = fetch) {
262956
+ if (inputs.postmanAccessToken || !inputs.postmanApiKey) {
262957
+ return;
262958
+ }
262959
+ const apiBaseUrl = String(
262960
+ inputs.postmanApiBase || POSTMAN_ENDPOINT_PROFILES.prod.apiBaseUrl
262961
+ ).replace(/\/+$/, "");
262962
+ const provider = new AccessTokenProvider({
262963
+ apiKey: inputs.postmanApiKey,
262964
+ apiBaseUrl,
262965
+ fetchImpl,
262966
+ onToken: (token) => setSecret2?.(token)
262967
+ });
262968
+ try {
262969
+ inputs.postmanAccessToken = await provider.refresh();
262970
+ log.info(
262971
+ "postman: no postman-access-token configured - minted a short-lived service-account access token from the postman-api-key."
262972
+ );
262973
+ } catch (error) {
262974
+ const diagnosis = await describeMintFailure(error, inputs.postmanApiKey, apiBaseUrl, fetchImpl);
262975
+ log.warning(
262976
+ "postman: could not mint an access token from the postman-api-key. " + diagnosis + " Continuing without an access token - access-token-only functionality will be unavailable unless postman-access-token is provided."
262977
+ );
262978
+ }
262979
+ }
262933
262980
 
262934
262981
  // src/lib/postman/workspace-selection.ts
262935
262982
  function chooseCanonicalWorkspace(args) {
@@ -306078,29 +306125,8 @@ function createPlannedOutputs(inputs) {
306078
306125
  })
306079
306126
  };
306080
306127
  }
306081
- async function mintAccessTokenIfNeeded(inputs, log, setSecret2) {
306082
- if (inputs.postmanAccessToken || !inputs.postmanApiKey) {
306083
- return;
306084
- }
306085
- const provider = new AccessTokenProvider({
306086
- apiKey: inputs.postmanApiKey,
306087
- apiBaseUrl: inputs.postmanApiBase,
306088
- onToken: (token) => setSecret2?.(token)
306089
- });
306090
- try {
306091
- inputs.postmanAccessToken = await provider.refresh();
306092
- log.info(
306093
- "postman: no postman-access-token configured - minted a short-lived service-account access token from the postman-api-key."
306094
- );
306095
- } catch (error) {
306096
- const mask = createSecretMasker([inputs.postmanApiKey]);
306097
- const message = error instanceof Error ? error.message : String(error);
306098
- log.warning(
306099
- mask(
306100
- "postman: could not mint an access token from the postman-api-key (" + message + "). Continuing with PMAK only - governance assignment and org-mode detection are disabled. Configure postman-access-token (postman-cs/postman-resolve-service-token-action) for full functionality."
306101
- )
306102
- );
306103
- }
306128
+ async function mintAccessTokenIfNeeded2(inputs, log, setSecret2) {
306129
+ await mintAccessTokenIfNeeded(inputs, log, setSecret2);
306104
306130
  }
306105
306131
  function createWorkspaceName(inputs) {
306106
306132
  return inputs.domainCode ? `[${inputs.domainCode}] ${inputs.projectName}` : inputs.projectName;
@@ -307718,7 +307744,7 @@ async function runCli(argv = process.argv.slice(2), runtime = {}) {
307718
307744
  assertOutputFileAllowed2(config.resultJsonPath);
307719
307745
  assertOutputFileAllowed2(config.dotenvPath);
307720
307746
  const mintReporter = new ConsoleReporter();
307721
- await mintAccessTokenIfNeeded(inputs, mintReporter);
307747
+ await mintAccessTokenIfNeeded2(inputs, mintReporter);
307722
307748
  const dependencies = createCliDependencies(inputs);
307723
307749
  await runCredentialPreflight({
307724
307750
  apiBaseUrl: inputs.postmanApiBase,
package/dist/index.cjs CHANGED
@@ -253786,7 +253786,7 @@ __export(index_exports, {
253786
253786
  ensurePostmanCli: () => ensurePostmanCli,
253787
253787
  getInput: () => getInput2,
253788
253788
  lintSpecViaCli: () => lintSpecViaCli,
253789
- mintAccessTokenIfNeeded: () => mintAccessTokenIfNeeded,
253789
+ mintAccessTokenIfNeeded: () => mintAccessTokenIfNeeded2,
253790
253790
  normalizeSpecDocument: () => normalizeSpecDocument,
253791
253791
  readActionInputs: () => readActionInputs,
253792
253792
  resolveInputs: () => resolveInputs,
@@ -264630,6 +264630,53 @@ var AccessTokenProvider = class {
264630
264630
  return token;
264631
264631
  }
264632
264632
  };
264633
+ async function describeMintFailure(mintError, apiKey, apiBaseUrl, fetchImpl) {
264634
+ const raw = mintError instanceof Error ? mintError.message : String(mintError);
264635
+ const rejected = /HTTP 40[13]|PMAK rejected/.test(raw);
264636
+ if (!rejected) {
264637
+ return raw;
264638
+ }
264639
+ try {
264640
+ const me = await fetchImpl(`${apiBaseUrl}/me`, { headers: { "x-api-key": apiKey } });
264641
+ if (me.ok) {
264642
+ const body2 = await me.json().catch(() => void 0);
264643
+ const user = body2?.user;
264644
+ const looksPersonal = Boolean(user && (user.username || user.email));
264645
+ if (looksPersonal) {
264646
+ return "Personal API key detected, cannot mint a service-account access token. POST /service-account-tokens only accepts a SERVICE-ACCOUNT API key; this postman-api-key belongs to a user account" + (user?.teamId ? ` (team ${user.teamId})` : "") + ". Create a service account in Team Settings and use its PMAK, or mint the token elsewhere and pass postman-access-token.";
264647
+ }
264648
+ return "The postman-api-key authenticates (GET /me OK) but was rejected by POST /service-account-tokens" + (user?.teamId ? ` (team ${user.teamId})` : "") + ". The service account likely lacks permission to mint access tokens, or service accounts are restricted for this team. Check the service account role in Team Settings, or pass a pre-minted postman-access-token.";
264649
+ }
264650
+ return "The postman-api-key is invalid, disabled, or expired (rejected by both POST /service-account-tokens and GET /me). Generate a fresh service-account PMAK in Team Settings and update the secret.";
264651
+ } catch {
264652
+ return raw;
264653
+ }
264654
+ }
264655
+ async function mintAccessTokenIfNeeded(inputs, log, setSecret2, fetchImpl = fetch) {
264656
+ if (inputs.postmanAccessToken || !inputs.postmanApiKey) {
264657
+ return;
264658
+ }
264659
+ const apiBaseUrl = String(
264660
+ inputs.postmanApiBase || POSTMAN_ENDPOINT_PROFILES.prod.apiBaseUrl
264661
+ ).replace(/\/+$/, "");
264662
+ const provider = new AccessTokenProvider({
264663
+ apiKey: inputs.postmanApiKey,
264664
+ apiBaseUrl,
264665
+ fetchImpl,
264666
+ onToken: (token) => setSecret2?.(token)
264667
+ });
264668
+ try {
264669
+ inputs.postmanAccessToken = await provider.refresh();
264670
+ log.info(
264671
+ "postman: no postman-access-token configured - minted a short-lived service-account access token from the postman-api-key."
264672
+ );
264673
+ } catch (error2) {
264674
+ const diagnosis = await describeMintFailure(error2, inputs.postmanApiKey, apiBaseUrl, fetchImpl);
264675
+ log.warning(
264676
+ "postman: could not mint an access token from the postman-api-key. " + diagnosis + " Continuing without an access token - access-token-only functionality will be unavailable unless postman-access-token is provided."
264677
+ );
264678
+ }
264679
+ }
264633
264680
 
264634
264681
  // src/lib/postman/workspace-selection.ts
264635
264682
  function chooseCanonicalWorkspace(args) {
@@ -307800,29 +307847,8 @@ function warnIfDeprecatedAccessToken(actionCore, inputs) {
307800
307847
  )
307801
307848
  );
307802
307849
  }
307803
- async function mintAccessTokenIfNeeded(inputs, log, setSecret2) {
307804
- if (inputs.postmanAccessToken || !inputs.postmanApiKey) {
307805
- return;
307806
- }
307807
- const provider = new AccessTokenProvider({
307808
- apiKey: inputs.postmanApiKey,
307809
- apiBaseUrl: inputs.postmanApiBase,
307810
- onToken: (token) => setSecret2?.(token)
307811
- });
307812
- try {
307813
- inputs.postmanAccessToken = await provider.refresh();
307814
- log.info(
307815
- "postman: no postman-access-token configured - minted a short-lived service-account access token from the postman-api-key."
307816
- );
307817
- } catch (error2) {
307818
- const mask = createSecretMasker([inputs.postmanApiKey]);
307819
- const message = error2 instanceof Error ? error2.message : String(error2);
307820
- log.warning(
307821
- mask(
307822
- "postman: could not mint an access token from the postman-api-key (" + message + "). Continuing with PMAK only - governance assignment and org-mode detection are disabled. Configure postman-access-token (postman-cs/postman-resolve-service-token-action) for full functionality."
307823
- )
307824
- );
307825
- }
307850
+ async function mintAccessTokenIfNeeded2(inputs, log, setSecret2) {
307851
+ await mintAccessTokenIfNeeded(inputs, log, setSecret2);
307826
307852
  }
307827
307853
  function isLegacyAccessTokenDeprecationWarning(message) {
307828
307854
  return message.includes("Postman CLI credential store populated by `postman login` is a legacy fallback");
@@ -309110,7 +309136,7 @@ async function runBootstrapInner(inputs, dependencies, telemetry) {
309110
309136
  }
309111
309137
  async function runAction(actionCore = core_exports, actionExec = exec_exports, actionIo = io_exports) {
309112
309138
  const inputs = readActionInputs(actionCore);
309113
- await mintAccessTokenIfNeeded(inputs, {
309139
+ await mintAccessTokenIfNeeded2(inputs, {
309114
309140
  info: (message) => actionCore.info(message),
309115
309141
  warning: (message) => actionCore.warning(message)
309116
309142
  }, (secret) => actionCore.setSecret(secret));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postman-cse/onboarding-bootstrap",
3
- "version": "2.8.0",
3
+ "version": "2.9.0",
4
4
  "description": "Bootstrap Postman workspaces, specs, and collections from OpenAPI.",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",