neon 9.8.0 → 9.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.
Files changed (39) hide show
  1. package/dist/_chunks/{auth-DY5Bm7Ym.js → auth-CEb642X3.js} +20 -9
  2. package/dist/_chunks/{auth_selection-CwGLN9Qz.js → auth_selection-D81EvEz9.js} +1 -1
  3. package/dist/_chunks/{checkout-DZa--fO4.js → checkout-9zUY4N8W.js} +2 -2
  4. package/dist/_chunks/{claim-Dv5wARrN.js → claim-D7fATGLw.js} +1 -1
  5. package/dist/_chunks/{config-DFj1Btk-.js → config-CUWOp44_.js} +1 -1
  6. package/dist/_chunks/{credential_io-DbeSh3Pl.js → credential_io-BHwacMdt.js} +1 -1
  7. package/dist/_chunks/{deploy-CVJIahZE.js → deploy-BUkXtacE.js} +1 -1
  8. package/dist/_chunks/{dev-CtIzg7vq.js → dev-Dp6LuAe2.js} +1 -1
  9. package/dist/_chunks/{git-ax3xtNoz.js → git-BISnX9MB.js} +2 -2
  10. package/dist/_chunks/{link-Z2_mLhVn.js → link-CfbTC-or.js} +1 -1
  11. package/dist/_chunks/{profile-Qoyql0AR.js → profile-BVkmMwHO.js} +68 -28
  12. package/dist/_chunks/{profiles-DTazQtjK.js → profiles-kpRUx7gU.js} +32 -2
  13. package/dist/_chunks/{status-DRWS1u6H.js → status-BM42rYe1.js} +1 -1
  14. package/dist/analytics.js +1 -1
  15. package/dist/auth_recovery.js +2 -2
  16. package/dist/commands/auth.js +1 -1
  17. package/dist/commands/checkout.js +1 -1
  18. package/dist/commands/claim.js +1 -1
  19. package/dist/commands/config.js +1 -1
  20. package/dist/commands/deploy.js +1 -1
  21. package/dist/commands/dev.js +1 -1
  22. package/dist/commands/functions_new.js +1 -1
  23. package/dist/commands/git.js +1 -1
  24. package/dist/commands/index.js +10 -10
  25. package/dist/commands/link.js +1 -1
  26. package/dist/commands/profile.js +1 -1
  27. package/dist/commands/status.js +1 -1
  28. package/dist/credential_io.js +1 -1
  29. package/dist/hosts.js +130 -0
  30. package/dist/index.js +8 -6
  31. package/dist/init/auth.js +1 -1
  32. package/dist/init/deploy.js +2 -2
  33. package/dist/init/detect.js +3 -3
  34. package/dist/init/link.js +2 -2
  35. package/dist/init/run.js +3 -3
  36. package/dist/retire_credential.js +1 -1
  37. package/dist/utils/middlewares.js +1 -1
  38. package/dist/utils/staging.js +6 -16
  39. package/package.json +5 -5
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.js";
2
- import { a as OAUTH, i as API_KEY, l as interpretCredentials, s as credentialLabel, t as storeFor } from "./credential_io-DbeSh3Pl.js";
2
+ import { a as OAUTH, i as API_KEY, l as interpretCredentials, s as credentialLabel, t as storeFor } from "./credential_io-BHwacMdt.js";
3
3
  import { hasTerminal, isCi } from "../env.js";
4
4
  import { log } from "../log.js";
5
5
  import { withExclusiveLock } from "../refresh_lock.js";
@@ -7,12 +7,13 @@ import { getApiClient, isNeonApiError } from "../api.js";
7
7
  import { setAuthContext } from "../auth_context.js";
8
8
  import { a as isOwnedCredentialPath } from "./paths-B55ZfOg1.js";
9
9
  import { currentContextFile, isAskCommand, isClaimCommand, isConfigAdd, isConfigInit, isCurrentBranchProbe, isDocsCommand, isFeedbackCommand, isFunctionsTemplateCommand, isGitLocalCommand, isIncidentsCommand, isInspectDbUrl, isMcpCommand, isMcpOauth, isPluginsCommand, isProfileCommand, isSkillsCommand, isUnfollowedGitHookSync, readContextFile } from "../context.js";
10
- import { _ as upsertProfile, d as newProfileLocation, g as selectProfileName, h as resolveProfile, i as assertValidProfileName, l as locationForName, m as readProfiles, n as KEYRING_CREDENTIALS, p as profilesUsingPath, r as assertProfilesUsable, s as isKeyringPointer, t as DEFAULT_PROFILE, u as locationOf } from "./profiles-DTazQtjK.js";
10
+ import { _ as readProfiles, b as upsertProfile, f as locationForName, g as profilesUsingPath, i as assertValidProfileName, m as newProfileLocation, n as KEYRING_CREDENTIALS, p as locationOf, r as assertProfilesUsable, t as DEFAULT_PROFILE, u as isKeyringPointer, v as resolveProfile, y as selectProfileName } from "./profiles-kpRUx7gU.js";
11
11
  import { extendTokenSet } from "../utils/auth.js";
12
12
  import { AuthRefreshError, auth, classifyRefreshFailure, refreshToken } from "../auth.js";
13
- import { i as selectCredential, n as displacedProfileWarning, t as credentialInputs } from "./auth_selection-CwGLN9Qz.js";
13
+ import { i as selectCredential, n as displacedProfileWarning, t as credentialInputs } from "./auth_selection-D81EvEz9.js";
14
14
  import { ClaimableClient, ClaimableServiceError } from "../claimable/api.js";
15
15
  import { assertionHasExpired, claimableCredentialsExist, claimableCredentialsPath, readLinkedClaimableCredentials, shouldUseClaimableCredentials } from "../claimable/state.js";
16
+ import { hostUpdateFor, hostsForProfile, issuingHosts } from "../hosts.js";
16
17
  import { readOutgoingCredential, retirePreviousCredential } from "../retire_credential.js";
17
18
  import { getCliName } from "../utils/cli_name.js";
18
19
  import { helpEpilogue, helpWidth, wrapHelpText } from "../utils/help_text.js";
@@ -59,9 +60,14 @@ const builder = (yargs) => yargs.option("context-file", { hidden: true }).option
59
60
  type: "boolean"
60
61
  }).example("$0 login", "Sign in with a browser").example("$0 login --profile work", "Save a browser session in profile work").example("$0 projects list --api-key \"$KEY\"", "Use an existing API key for this command").example("NEON_API_KEY=\"$KEY\" $0 projects list", "Use an existing API key from the environment").example("$0 profile create agent --api-key \"$KEY\"", "Store an existing API key").example("echo \"$KEY\" | $0 profile create agent --api-key -", "Store a key read from stdin").example("$0 profile create ci --mint", "Sign in once in a browser and store a new API key").epilogue(authHelpEpilogue());
61
62
  const handler = async (args) => {
62
- await authFlow(args);
63
+ const target = selectProfileName(args.profile);
64
+ await authFlow({
65
+ ...args,
66
+ ...hostsForProfile(args.configDir, target),
67
+ hosts: hostUpdateFor(target)
68
+ });
63
69
  };
64
- const authFlow = async ({ configDir, oauthHost, clientId, apiHost, forceAuth, "force-auth": forceAuthKebab, allowUnsafeTls, profile, keyring }) => {
70
+ const authFlow = async ({ configDir, oauthHost, clientId, apiHost, forceAuth, "force-auth": forceAuthKebab, allowUnsafeTls, profile, keyring, hosts }) => {
65
71
  const profileName = selectProfileName(profile);
66
72
  const isNamed = profileName !== DEFAULT_PROFILE;
67
73
  if (isNamed) assertValidProfileName(profileName);
@@ -75,6 +81,10 @@ const authFlow = async ({ configDir, oauthHost, clientId, apiHost, forceAuth, "f
75
81
  let previousFile;
76
82
  let previousWasKeyring = false;
77
83
  let previousOutgoing = null;
84
+ const previousHosts = issuingHosts(configDir, profileName, {
85
+ apiHost,
86
+ oauthHost
87
+ });
78
88
  try {
79
89
  const previous = resolveProfile(configDir, profileName);
80
90
  previousWasKeyring = previous.storage === "keyring";
@@ -103,7 +113,8 @@ const authFlow = async ({ configDir, oauthHost, clientId, apiHost, forceAuth, "f
103
113
  upsertProfile(configDir, profileName, {
104
114
  credentials: at.storage === "keyring" ? KEYRING_CREDENTIALS : at.path,
105
115
  ...identity.email ? { label: identity.email } : {},
106
- ...identity.id ? { userId: identity.id } : {}
116
+ ...identity.id ? { userId: identity.id } : {},
117
+ ...hosts
107
118
  });
108
119
  } catch (err) {
109
120
  if (at.storage === "keyring" && !previousWasKeyring) {
@@ -113,8 +124,7 @@ const authFlow = async ({ configDir, oauthHost, clientId, apiHost, forceAuth, "f
113
124
  throw err instanceof Error ? err : new Error(String(err));
114
125
  }
115
126
  if (at.storage === "keyring") await retirePreviousCredential({
116
- apiHost,
117
- oauthHost,
127
+ ...previousHosts,
118
128
  clientId,
119
129
  ...allowUnsafeTls ? { allowUnsafeTls } : {}
120
130
  }, profileName, previousOutgoing);
@@ -493,7 +503,8 @@ const ensureAuth = async (props) => {
493
503
  if (!(props.forceAuth ?? props["force-auth"]) && !isCi() && !hasTerminal()) throw new Error(`Not signed in: profile "${selection.profile}" ${state}, and this shell has no terminal to start a browser sign-in from. ${signInHint}`);
494
504
  const apiKey = await authFlow({
495
505
  ...props,
496
- profile: selection.profile
506
+ profile: selection.profile,
507
+ hosts: hostUpdateFor(selection.profile)
497
508
  });
498
509
  props.apiKey = apiKey;
499
510
  props.apiClient = getApiClient({
@@ -1,4 +1,4 @@
1
- import "./profiles-DTazQtjK.js";
1
+ import "./profiles-kpRUx7gU.js";
2
2
  // ../../internals/cli-core/dist/auth_selection.js
3
3
  /**
4
4
  * # Which credential an invocation authenticates with
@@ -12,8 +12,8 @@ import { fillSingleProject, listAllProjectBranches } from "../utils/enrichers.js
12
12
  import { buildCheckoutEvent, readGitContext } from "../utils/git.js";
13
13
  import { buildHookBranch, loadHookConfig, resolveHookEnv, runCheckoutAfterHook, runCheckoutBeforeHook, runCreateAfterHook, runCreateBeforeHook } from "../utils/hooks.js";
14
14
  import { n as autoPullEnvAfterPin } from "./env-DxcO3oJk.js";
15
- import { a as applyPolicyOnCreate, f as envFlag, l as createBranchFromPolicyOnCheckout } from "./config-DFj1Btk-.js";
16
- import { i as handler$1 } from "./link-Z2_mLhVn.js";
15
+ import { a as applyPolicyOnCreate, f as envFlag, l as createBranchFromPolicyOnCheckout } from "./config-CUWOp44_.js";
16
+ import { i as handler$1 } from "./link-CfbTC-or.js";
17
17
  import chalk from "chalk";
18
18
  import prompts from "prompts";
19
19
  // src/commands/checkout.ts
@@ -3,7 +3,7 @@ import { isCi } from "../env.js";
3
3
  import { log } from "../log.js";
4
4
  import { getApiClient } from "../api.js";
5
5
  import { applyContext, contextBranch, readContextFile } from "../context.js";
6
- import { t as credentialInputs } from "./auth_selection-CwGLN9Qz.js";
6
+ import { t as credentialInputs } from "./auth_selection-D81EvEz9.js";
7
7
  import { ClaimableClient, ClaimableServiceError } from "../claimable/api.js";
8
8
  import { assertionHasExpired, listClaimableCredentials, readClaimableCredentials, readLinkedClaimableCredentials, removeClaimableCredentials, writeClaimableCredentials } from "../claimable/state.js";
9
9
  import { NEON_SERVICES, deprecatedServiceMessage, parseServices, servicesFlagValue, servicesOption } from "../neon_services.js";
@@ -7,7 +7,7 @@ import "../config.js";
7
7
  import { contextBranch, ensureDirectoryGitignored, readContextFile } from "../context.js";
8
8
  import { DetailedError } from "../errors.js";
9
9
  import { getCliName } from "../utils/cli_name.js";
10
- import { l as existingApiClient } from "./auth-DY5Bm7Ym.js";
10
+ import { l as existingApiClient } from "./auth-CEb642X3.js";
11
11
  import { NEON_SERVICES, NEON_SERVICE_LABELS, deprecatedServiceMessage, servicesFlagValue, servicesOption } from "../neon_services.js";
12
12
  import { FUNCTION_FILENAME, FUNCTION_SLUG, FUNCTION_TEMPLATE, REQUIRED_PACKAGES, dataApiChoiceFromView, parseConfigInitServices, renderFunctionSource, renderNeonConfig, renderNeonConfigFromView } from "../config_template.js";
13
13
  import { TYPESCRIPT_EXTENSION, asRelativeModulePath, editNeonConfig } from "../config_edit.js";
@@ -1,6 +1,6 @@
1
1
  import { t as writeSecretFile } from "./secure_file-Caskdohg.js";
2
2
  import { a as isOwnedCredentialPath } from "./paths-B55ZfOg1.js";
3
- import { f as profilesFilePath, v as CRED_STORAGE_FILE, y as CRED_STORAGE_KEYRING } from "./profiles-DTazQtjK.js";
3
+ import { S as CRED_STORAGE_KEYRING, h as profilesFilePath, x as CRED_STORAGE_FILE } from "./profiles-kpRUx7gU.js";
4
4
  import { tryLoadKeyring } from "../keyring.js";
5
5
  import { existsSync, readFileSync, rmSync } from "node:fs";
6
6
  import { dirname } from "node:path";
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.js";
2
2
  import { fillSingleProject } from "../utils/enrichers.js";
3
- import { f as envFlag, i as applyFlags, p as envPullFlag, r as applyCmd } from "./config-DFj1Btk-.js";
3
+ import { f as envFlag, i as applyFlags, p as envPullFlag, r as applyCmd } from "./config-CUWOp44_.js";
4
4
  import { DEPLOY_COMMANDS_EPILOGUE } from "../commands/deploy_help.js";
5
5
  // src/commands/deploy.ts
6
6
  var deploy_exports = /* @__PURE__ */ __exportAll({
@@ -7,7 +7,7 @@ import { t as NEON_DEV_FUNCTION_PORTS } from "./env-EJU-0InB.js";
7
7
  import { branchIdResolve } from "../utils/enrichers.js";
8
8
  import { bundleEntry } from "../utils/esbuild.js";
9
9
  import { a as resolveDevEnv } from "./env-CFBmcKyo.js";
10
- import { f as envFlag } from "./config-DFj1Btk-.js";
10
+ import { f as envFlag } from "./config-CUWOp44_.js";
11
11
  import { findConfigFunctionBySource, resolveFunctionsFromConfig } from "../dev/functions.js";
12
12
  import { resolveWatchInputs } from "../dev/inputs.js";
13
13
  import { existsSync, mkdirSync, rmSync, statSync, writeFileSync } from "node:fs";
@@ -5,8 +5,8 @@ import { CONTEXT_FILE, contextBranch, gitBranchMap, gitBranchMapping, isUnfollow
5
5
  import { writer } from "../writer.js";
6
6
  import { neonSafeBranchName } from "../utils/branch_name.js";
7
7
  import { currentGitBranch, gitPull, gitRepoRoot, hasUpstream, installPostCheckoutHook, isGitRepo, isManagedHook, localGitBranches, postCheckoutHookPath, readGitContext, removePostCheckoutHook } from "../utils/git.js";
8
- import { o as quoteFlagValue } from "./link-Z2_mLhVn.js";
9
- import { o as handler$1 } from "./checkout-DZa--fO4.js";
8
+ import { o as quoteFlagValue } from "./link-CfbTC-or.js";
9
+ import { o as handler$1 } from "./checkout-9zUY4N8W.js";
10
10
  import { existsSync } from "node:fs";
11
11
  import { join } from "node:path";
12
12
  import chalk from "chalk";
@@ -14,7 +14,7 @@ import { createBranch, pickBranchInteractively } from "../utils/branch_picker.js
14
14
  import { looksLikeBranchId } from "../utils/formats.js";
15
15
  import { listAllProjectBranches } from "../utils/enrichers.js";
16
16
  import { n as autoPullEnvAfterPin } from "./env-DxcO3oJk.js";
17
- import { h as initCmd } from "./config-DFj1Btk-.js";
17
+ import { h as initCmd } from "./config-CUWOp44_.js";
18
18
  import { formatLinkSummary } from "../commands/link_output.js";
19
19
  import { r as REGIONS } from "./projects-a3X4OFEJ.js";
20
20
  import prompts from "prompts";
@@ -1,16 +1,17 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.js";
2
2
  import { t as writeSecretFile } from "./secure_file-Caskdohg.js";
3
- import { c as describeScope, d as scopeOf, l as interpretCredentials, n as KEYRING_SERVICE, o as apiKeyCredentials, r as keyringAccount, s as credentialLabel, t as storeFor } from "./credential_io-DbeSh3Pl.js";
3
+ import { c as describeScope, d as scopeOf, l as interpretCredentials, n as KEYRING_SERVICE, o as apiKeyCredentials, r as keyringAccount, s as credentialLabel, t as storeFor } from "./credential_io-BHwacMdt.js";
4
4
  import { isCi } from "../env.js";
5
5
  import { log } from "../log.js";
6
6
  import { getApiClient, isNeonApiError } from "../api.js";
7
7
  import { setAuthContext } from "../auth_context.js";
8
8
  import { a as isOwnedCredentialPath, n as credentialsPath } from "./paths-B55ZfOg1.js";
9
- import { _ as upsertProfile, a as canDropProfilesFile, c as listProfiles, d as newProfileLocation, f as profilesFilePath, g as selectProfileName, h as resolveProfile, i as assertValidProfileName, l as locationForName, m as readProfiles, n as KEYRING_CREDENTIALS, o as credentialsDisplay, p as profilesUsingPath, r as assertProfilesUsable, s as isKeyringPointer, u as locationOf, v as CRED_STORAGE_FILE, y as CRED_STORAGE_KEYRING } from "./profiles-DTazQtjK.js";
9
+ import { S as CRED_STORAGE_KEYRING, _ as readProfiles, a as canDropProfilesFile, b as upsertProfile, d as listProfiles, f as locationForName, g as profilesUsingPath, h as profilesFilePath, i as assertValidProfileName, m as newProfileLocation, n as KEYRING_CREDENTIALS, o as credentialsDisplay, p as locationOf, r as assertProfilesUsable, s as hostsOf, u as isKeyringPointer, v as resolveProfile, x as CRED_STORAGE_FILE, y as selectProfileName } from "./profiles-kpRUx7gU.js";
10
10
  import { auth, revokeToken } from "../auth.js";
11
- import { t as credentialInputs } from "./auth_selection-CwGLN9Qz.js";
11
+ import { t as credentialInputs } from "./auth_selection-D81EvEz9.js";
12
+ import { hostUpdateFor, hostsForProfile, issuingHosts } from "../hosts.js";
12
13
  import { readOutgoingCredential, retirePreviousCredential, revokeTokenSet, withdrawKey } from "../retire_credential.js";
13
- import { m as usableCredential, n as authFlow } from "./auth-DY5Bm7Ym.js";
14
+ import { m as usableCredential, n as authFlow } from "./auth-CEb642X3.js";
14
15
  import { identityFromAuthDetails, isApiKeyMethod, mintedKeyName, notAnApiKeyMessage } from "../profile_keys.js";
15
16
  import { writer } from "../writer.js";
16
17
  import { noPassthrough, single } from "../utils/flags.js";
@@ -70,11 +71,11 @@ const builder = (argv) => argv.usage("$0 profile <sub-command> [options]").comma
70
71
  throw new Error(`--force is no longer a flag. \`neon profile create ${name}\` always replaces an existing profile and revokes the credential it held. Drop --force.`);
71
72
  }
72
73
  return true;
73
- }).example("$0 profile create work", "Sign in with the browser, like `neon login --profile work`").example("$0 profile create work --api-key \"$KEY\"", "Store a key you already have").example("echo \"$KEY\" | $0 profile create work --api-key -", "Or pipe it, so it never reaches the process arguments").example("$0 profile create ci --mint --org-id org-abc-123", "One browser sign-in, then an org-scoped key and no session left behind").example("$0 profile create work --keyring", "Store the credential in the OS keyring instead of a file"), async (args) => await create(args)).command("rotate-key <name>", "Mint a fresh API key for a profile, at the same scope, and revoke the one it replaces", (y) => y.positional("name", {
74
+ }).example("$0 profile create work", "Sign in with the browser, like `neon login --profile work`").example("$0 profile create work --api-key \"$KEY\"", "Store a key you already have").example("echo \"$KEY\" | $0 profile create work --api-key -", "Or pipe it, so it never reaches the process arguments").example("$0 profile create ci --mint --org-id org-abc-123", "One browser sign-in, then an org-scoped key and no session left behind").example("$0 profile create work --keyring", "Store the credential in the OS keyring instead of a file"), async (args) => await create(withProfileHosts(args))).command("rotate-key <name>", "Mint a fresh API key for a profile, at the same scope, and revoke the one it replaces", (y) => y.positional("name", {
74
75
  describe: "Profile to rotate",
75
76
  type: "string",
76
77
  demandOption: true
77
- }).strict().check(noPassthrough("profile rotate-key")), async (args) => await rotateKey(args)).command("remove <name>", "Revoke a profile's credential where possible, and remove it", (y) => y.positional("name", {
78
+ }).strict().check(noPassthrough("profile rotate-key")), async (args) => await rotateKey(withProfileHosts(args))).command("remove <name>", "Revoke a profile's credential where possible, and remove it", (y) => y.positional("name", {
78
79
  describe: "Profile to remove",
79
80
  type: "string",
80
81
  demandOption: true
@@ -83,9 +84,17 @@ const builder = (argv) => argv.usage("$0 profile <sub-command> [options]").comma
83
84
  describe: "Skip the confirmation prompt",
84
85
  type: "boolean",
85
86
  default: false
86
- }).strict().check(noPassthrough("profile remove")), async (args) => await remove(args));
87
+ }).strict().check(noPassthrough("profile remove")), async (args) => await remove(withProfileHosts(args)));
87
88
  const handler = (_args) => {};
88
89
  /**
90
+ * These subcommands act on the profile they name, which credential selection never picked, so
91
+ * the hosts the middleware resolved may belong to another profile.
92
+ */
93
+ const withProfileHosts = (props) => ({
94
+ ...props,
95
+ ...hostsForProfile(props.configDir, props.name)
96
+ });
97
+ /**
89
98
  * Refuse a global credential flag that a `profile` subcommand cannot honour.
90
99
  *
91
100
  * These commands name their target as a positional and authenticate as that profile, so both
@@ -172,6 +181,8 @@ const list = async (props) => {
172
181
  return {
173
182
  active: p.name === active ? "*" : "",
174
183
  name: p.name,
184
+ ...p.apiHost !== void 0 ? { apiHost: p.apiHost } : {},
185
+ ...p.oauthHost !== void 0 ? { oauthHost: p.oauthHost } : {},
175
186
  account: p.label ?? p.userId ?? storedUserId ?? "-",
176
187
  auth,
177
188
  scope: auth === "oauth" ? describeScope({}) : stored !== null && auth === "api key" ? describeScope(scopeOf(stored)) : "-",
@@ -180,16 +191,27 @@ const list = async (props) => {
180
191
  credentials: props.output === "table" ? credentialsListValue(p, props.configDir) : credentialsDisplay(p)
181
192
  };
182
193
  });
183
- writer(props).end(rows, {
194
+ const fields = [
195
+ "active",
196
+ "name",
197
+ "account",
198
+ "auth",
199
+ "credentials",
200
+ "scope"
201
+ ];
202
+ if (props.output !== "table") {
203
+ writer(props).end(rows, {
204
+ title: "Profiles",
205
+ fields
206
+ });
207
+ return;
208
+ }
209
+ writer(props).end(rows.map(({ apiHost, ...row }) => ({
210
+ ...row,
211
+ api_host: apiHost
212
+ })), {
184
213
  title: "Profiles",
185
- fields: [
186
- "active",
187
- "name",
188
- "account",
189
- "auth",
190
- "credentials",
191
- "scope"
192
- ]
214
+ fields: [...fields, "api_host"]
193
215
  });
194
216
  };
195
217
  const credentialsListValue = (profile, configDir) => {
@@ -297,11 +319,13 @@ const create = async (props) => {
297
319
  rejectProfileFlag(props, "create");
298
320
  assertValidProfileName(name);
299
321
  assertProfilesUsable(props.configDir, name);
322
+ const hosts = hostUpdateFor(name);
323
+ const previousHosts = issuingHosts(props.configDir, name, props);
300
324
  if (props.keyring === true) storeFor(props.configDir).assertKeyringWritable(existingLocation(props.configDir, name)?.storage === "keyring" ? name : void 0);
301
325
  const suppliedKey = credentialInputs().apiKeyFlag.trim() !== "";
302
326
  if (props.mint) {
303
327
  if (suppliedKey) throw new Error("--mint creates a new key, so it cannot be combined with --api-key. Drop one.");
304
- await createByMinting(props);
328
+ await createByMinting(props, hosts, previousHosts);
305
329
  return;
306
330
  }
307
331
  if ((props.orgId ?? props.projectId) !== void 0) throw new Error("--org-id and --project-id only apply with --mint: they choose what a key we mint can reach, and a key you supply already has a scope.");
@@ -314,9 +338,13 @@ const create = async (props) => {
314
338
  ...props,
315
339
  _: ["auth"],
316
340
  profile: name,
317
- keyring: props.keyring
341
+ keyring: props.keyring,
342
+ hosts
318
343
  }) === "") throw new Error(`Could not save credentials for profile "${name}".`);
319
- if (at.storage !== "keyring") await retirePreviousCredential(props, name, previous);
344
+ if (at.storage !== "keyring") await retirePreviousCredential({
345
+ ...props,
346
+ ...previousHosts
347
+ }, name, previous);
320
348
  const signedIn = readProfiles(props.configDir, log.warning)?.profiles[name];
321
349
  report(props, {
322
350
  name,
@@ -340,12 +368,15 @@ const create = async (props) => {
340
368
  ...identity.orgId !== void 0 ? { scope: { orgId: identity.orgId } } : {}
341
369
  }));
342
370
  try {
343
- recordProfile(props, name, at, identity);
371
+ recordProfile(props, name, at, identity, hosts);
344
372
  } catch (err) {
345
373
  if (at.storage === "keyring" && existing?.storage !== "keyring") warnIfKeyringRollbackUnconfirmed(storeFor(props.configDir).delete(at, { required: false }), name);
346
374
  throw err instanceof Error ? err : new Error(String(err));
347
375
  }
348
- await retirePreviousCredential(props, name, previous, apiKey);
376
+ await retirePreviousCredential({
377
+ ...props,
378
+ ...previousHosts
379
+ }, name, previous, apiKey);
349
380
  if (at.storage === "keyring" && existing?.storage === "file") deleteLeftoverOwnedFile(props.configDir, existing.path, name);
350
381
  report(props, {
351
382
  name,
@@ -382,11 +413,16 @@ const warnAboutReach = (scope) => {
382
413
  */
383
414
  const report = (props, record) => {
384
415
  const out = writer(props);
416
+ const entry = readProfiles(props.configDir)?.profiles[record.name];
417
+ const hosts = entry === void 0 ? {} : hostsOf(entry);
385
418
  if (props.output === "table") {
386
- log.info("Profile \"%s\" now holds %s for %s (%s), in %s", record.name, record.auth, record.account, record.scope, record.credentials);
419
+ log.info("Profile \"%s\" now holds %s for %s (%s), in %s%s", record.name, record.auth, record.account, record.scope, record.credentials, hosts.apiHost !== void 0 ? `, for ${hosts.apiHost}` : "");
387
420
  return;
388
421
  }
389
- out.end(record, {
422
+ out.end({
423
+ ...record,
424
+ ...hosts
425
+ }, {
390
426
  fields: [
391
427
  "name",
392
428
  "account",
@@ -399,11 +435,12 @@ const report = (props, record) => {
399
435
  title: "Profile"
400
436
  });
401
437
  };
402
- const recordProfile = (props, name, at, identity) => {
438
+ const recordProfile = (props, name, at, identity, hosts) => {
403
439
  upsertProfile(props.configDir, name, {
404
440
  credentials: at.storage === "keyring" ? KEYRING_CREDENTIALS : at.path,
405
441
  ...identity.label ? { label: identity.label } : {},
406
- ...identity.userId ? { userId: identity.userId } : {}
442
+ ...identity.userId ? { userId: identity.userId } : {},
443
+ ...hosts
407
444
  });
408
445
  };
409
446
  /**
@@ -414,7 +451,7 @@ const recordProfile = (props, name, at, identity) => {
414
451
  * it, so no half-forgotten login is left behind — which also means the file holds exactly one
415
452
  * credential, for exactly one account.
416
453
  */
417
- const createByMinting = async (props) => {
454
+ const createByMinting = async (props, hosts, previousHosts) => {
418
455
  const { name } = props;
419
456
  if (isCi() && props.forceAuth !== true) throw new Error(`--mint needs a browser sign-in, which cannot happen in CI. Mint the key with \`neon api-keys create --name ${name}\` and pipe it in: echo "$KEY" | neon profile create ${name} --api-key -`);
420
457
  if (locationForCreate(props.configDir, name, props.keyring).storage === "keyring") storeFor(props.configDir).assertKeyringWritable(existingLocation(props.configDir, name)?.storage === "keyring" ? name : void 0);
@@ -446,13 +483,16 @@ const createByMinting = async (props) => {
446
483
  scope
447
484
  }));
448
485
  try {
449
- recordProfile(props, name, at, identity);
486
+ recordProfile(props, name, at, identity, hosts);
450
487
  } catch (err) {
451
488
  if (at.storage === "keyring" && existing?.storage !== "keyring") warnIfKeyringRollbackUnconfirmed(storeFor(props.configDir).delete(at, { required: false }), name);
452
489
  else keyIsReachable = true;
453
490
  throw err instanceof Error ? err : new Error(String(err));
454
491
  }
455
- await retirePreviousCredential(props, name, previous, minted.key);
492
+ await retirePreviousCredential({
493
+ ...props,
494
+ ...previousHosts
495
+ }, name, previous, minted.key);
456
496
  if (at.storage === "keyring" && existing?.storage === "file") deleteLeftoverOwnedFile(props.configDir, existing.path, name);
457
497
  keyIsReachable = true;
458
498
  report(props, {
@@ -17,6 +17,16 @@ const isKeyringPointer = (credentials) => credentials === KEYRING_CREDENTIALS;
17
17
  const DEFAULT_PROFILE = "DEFAULT";
18
18
  /** Profile names become part of a filename, so keep them boring. */
19
19
  const NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
20
+ const HOST_FIELDS = ["apiHost", "oauthHost"];
21
+ const isHttpUrl = (value) => {
22
+ if (!URL.canParse(value)) return false;
23
+ const { protocol } = new URL(value);
24
+ return protocol === "https:" || protocol === "http:";
25
+ };
26
+ const hostsOf = (entry) => ({
27
+ ...entry.apiHost !== void 0 ? { apiHost: entry.apiHost } : {},
28
+ ...entry.oauthHost !== void 0 ? { oauthHost: entry.oauthHost } : {}
29
+ });
20
30
  const locationOf = (profile) => profile.storage === "keyring" ? {
21
31
  profile: profile.name,
22
32
  storage: CRED_STORAGE_KEYRING
@@ -67,6 +77,12 @@ const inspectProfiles = (dir) => {
67
77
  for (const [name, entry] of Object.entries(profiles)) {
68
78
  if (!NAME_PATTERN.test(name)) return broken(`"${name}" is not a valid profile name`);
69
79
  if (entry === null || typeof entry !== "object" || typeof entry.credentials !== "string" || entry.credentials.trim() === "") return broken(`profile "${name}" has no \`credentials\` pointer`);
80
+ for (const field of HOST_FIELDS) {
81
+ const value = entry[field];
82
+ if (value === void 0) continue;
83
+ if (name === "DEFAULT") return broken(`profile "${DEFAULT_PROFILE}" sets \`${field}\`, which only a named profile can. DEFAULT follows --api-host / --oauth-host and NEON_API_HOST / NEON_OAUTH_HOST`);
84
+ if (typeof value !== "string" || !isHttpUrl(value)) return broken(`profile "${name}" has an invalid \`${field}\`: expected an http or https URL`);
85
+ }
70
86
  }
71
87
  return {
72
88
  kind: "ok",
@@ -119,6 +135,7 @@ const resolveProfile = (dir, name) => {
119
135
  storage: CRED_STORAGE_KEYRING,
120
136
  ...entry.label ? { label: entry.label } : {},
121
137
  ...entry.userId ? { userId: entry.userId } : {},
138
+ ...hostsOf(entry),
122
139
  declared: true
123
140
  };
124
141
  return {
@@ -127,6 +144,7 @@ const resolveProfile = (dir, name) => {
127
144
  credentialsPath: resolveEntryPath(dir, entry.credentials),
128
145
  ...entry.label ? { label: entry.label } : {},
129
146
  ...entry.userId ? { userId: entry.userId } : {},
147
+ ...hostsOf(entry),
130
148
  declared: true
131
149
  };
132
150
  }
@@ -152,6 +170,11 @@ const newProfileCredentialsPath = (dir, name) => resolve(dir, `credentials.${nam
152
170
  */
153
171
  const upsertProfile = (dir, name, entry) => {
154
172
  assertValidProfileName(name);
173
+ if (name === "DEFAULT" && HOST_FIELDS.some((field) => typeof entry[field] === "string")) throw new Error(`Profile "${DEFAULT_PROFILE}" cannot record an API or OAuth host. Create a named profile for another Neon environment.`);
174
+ for (const field of HOST_FIELDS) {
175
+ const value = entry[field];
176
+ if (typeof value === "string" && !isHttpUrl(value)) throw new Error(`Cannot record "${value}" as profile "${name}"'s ${field}: expected an http or https URL.`);
177
+ }
155
178
  const path = profilesFilePath(dir);
156
179
  const read = inspectProfiles(dir);
157
180
  if (read.kind === "unusable") throw new Error(`${read.reason}. Refusing to rewrite it, because doing so would discard the profiles it defines. Fix or delete the file, then re-run.`);
@@ -159,10 +182,17 @@ const upsertProfile = (dir, name, entry) => {
159
182
  version: 1,
160
183
  profiles: { [DEFAULT_PROFILE]: { credentials: storedPointer(path, credentialsPath(dir)) } }
161
184
  };
185
+ const previous = file.profiles[name];
186
+ const host = (field) => {
187
+ const value = entry[field] === void 0 ? previous?.[field] : entry[field];
188
+ return typeof value === "string" ? { [field]: value } : {};
189
+ };
162
190
  file.profiles[name] = {
163
191
  credentials: storedPointer(path, entry.credentials),
164
192
  ...entry.label ? { label: entry.label } : {},
165
- ...entry.userId ? { userId: entry.userId } : {}
193
+ ...entry.userId ? { userId: entry.userId } : {},
194
+ ...host("apiHost"),
195
+ ...host("oauthHost")
166
196
  };
167
197
  writeProfiles(path, file);
168
198
  };
@@ -217,4 +247,4 @@ function nonEmpty(value) {
217
247
  const trimmed = value.trim();
218
248
  return trimmed === "" ? void 0 : trimmed;
219
249
  }
220
- export { upsertProfile as _, canDropProfilesFile as a, listProfiles as c, newProfileLocation as d, profilesFilePath as f, selectProfileName as g, resolveProfile as h, assertValidProfileName as i, locationForName as l, readProfiles as m, KEYRING_CREDENTIALS as n, credentialsDisplay as o, profilesUsingPath as p, assertProfilesUsable as r, isKeyringPointer as s, DEFAULT_PROFILE as t, locationOf as u, CRED_STORAGE_FILE as v, CRED_STORAGE_KEYRING as y };
250
+ export { CRED_STORAGE_KEYRING as S, readProfiles as _, canDropProfilesFile as a, upsertProfile as b, inspectProfiles as c, listProfiles as d, locationForName as f, profilesUsingPath as g, profilesFilePath as h, assertValidProfileName as i, isHttpUrl as l, newProfileLocation as m, KEYRING_CREDENTIALS as n, credentialsDisplay as o, locationOf as p, assertProfilesUsable as r, hostsOf as s, DEFAULT_PROFILE as t, isKeyringPointer as u, resolveProfile as v, CRED_STORAGE_FILE as x, selectProfileName as y };
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.js";
2
2
  import { fillSingleProject } from "../utils/enrichers.js";
3
- import { y as status } from "./config-DFj1Btk-.js";
3
+ import { y as status } from "./config-CUWOp44_.js";
4
4
  // src/commands/status.ts
5
5
  var status_exports = /* @__PURE__ */ __exportAll({
6
6
  builder: () => builder,
package/dist/analytics.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as OAUTH, t as storeFor } from "./_chunks/credential_io-DbeSh3Pl.js";
1
+ import { a as OAUTH, t as storeFor } from "./_chunks/credential_io-BHwacMdt.js";
2
2
  import { getCliAgent, getGithubEnvVars, getTty, isCi } from "./env.js";
3
3
  import { log } from "./log.js";
4
4
  import { getOrCreateAnonymousId } from "./anonymous_id.js";
@@ -1,8 +1,8 @@
1
- import { t as storeFor } from "./_chunks/credential_io-DbeSh3Pl.js";
1
+ import { t as storeFor } from "./_chunks/credential_io-BHwacMdt.js";
2
2
  import { log } from "./log.js";
3
3
  import { authFailureMessage, getAuthContext, locationFromContext } from "./auth_context.js";
4
4
  import { AuthRefreshError } from "./auth.js";
5
- import { d as isAccessTokenUsable, p as refreshStoredCredentials } from "./_chunks/auth-DY5Bm7Ym.js";
5
+ import { d as isAccessTokenUsable, p as refreshStoredCredentials } from "./_chunks/auth-CEb642X3.js";
6
6
  // src/auth_recovery.ts
7
7
  const supersededOnDisk = (rejectedToken) => {
8
8
  if (rejectedToken === void 0) return false;
@@ -1 +1 @@
1
- export { t as aliases, n as authFlow, i as builder, a as command, o as deleteCredentialsAt, s as describe, c as ensureAuth, l as existingApiClient, u as handler, d as isAccessTokenUsable, f as locationForAuth, p as refreshStoredCredentials, m as usableCredential } from "../_chunks/auth-DY5Bm7Ym.js";
1
+ export { t as aliases, n as authFlow, i as builder, a as command, o as deleteCredentialsAt, s as describe, c as ensureAuth, l as existingApiClient, u as handler, d as isAccessTokenUsable, f as locationForAuth, p as refreshStoredCredentials, m as usableCredential } from "../_chunks/auth-CEb642X3.js";
@@ -1 +1 @@
1
- export { t as builder, r as command, i as describe, a as formatCheckoutPolicyFailure, o as handler } from "../_chunks/checkout-DZa--fO4.js";
1
+ export { t as builder, r as command, i as describe, a as formatCheckoutPolicyFailure, o as handler } from "../_chunks/checkout-9zUY4N8W.js";
@@ -1 +1 @@
1
- export { t as CLAIM_CREATE_FIELDS, n as CLAIM_LIST_FIELDS, r as aliases, i as builder, a as claimCreateFields, s as claimableCapabilities, c as command, l as create, u as describe, d as handler } from "../_chunks/claim-Dv5wARrN.js";
1
+ export { t as CLAIM_CREATE_FIELDS, n as CLAIM_LIST_FIELDS, r as aliases, i as builder, a as claimCreateFields, s as claimableCapabilities, c as command, l as create, u as describe, d as handler } from "../_chunks/claim-D7fATGLw.js";
@@ -1 +1 @@
1
- export { t as ConfigInstallFailed, n as addCmd, r as applyCmd, i as applyFlags, a as applyPolicyOnCreate, o as builder, s as command, l as createBranchFromPolicyOnCheckout, u as describe, d as ensureConfigPackages, f as envFlag, p as envPullFlag, m as handler, h as initCmd, g as installCommandFrom, _ as missingDependencies, v as planCmd, y as status } from "../_chunks/config-DFj1Btk-.js";
1
+ export { t as ConfigInstallFailed, n as addCmd, r as applyCmd, i as applyFlags, a as applyPolicyOnCreate, o as builder, s as command, l as createBranchFromPolicyOnCheckout, u as describe, d as ensureConfigPackages, f as envFlag, p as envPullFlag, m as handler, h as initCmd, g as installCommandFrom, _ as missingDependencies, v as planCmd, y as status } from "../_chunks/config-CUWOp44_.js";
@@ -1 +1 @@
1
- export { t as builder, n as command, i as describe, a as handler } from "../_chunks/deploy-CVJIahZE.js";
1
+ export { t as builder, n as command, i as describe, a as handler } from "../_chunks/deploy-BUkXtacE.js";
@@ -1 +1 @@
1
- export { t as builder, n as captureShellEnv, r as command, i as describe, a as devBundleDir, o as devEnvContext, c as diffUnits, l as formatEnvFiles, u as formatEnvSummary, d as handler, f as loadDevEnvFiles, p as localFunctionPortsEnv, m as planFunctionsToUnits, h as reportDevCredential, g as sourceFunctionUrlOverlay } from "../_chunks/dev-CtIzg7vq.js";
1
+ export { t as builder, n as captureShellEnv, r as command, i as describe, a as devBundleDir, o as devEnvContext, c as diffUnits, l as formatEnvFiles, u as formatEnvSummary, d as handler, f as loadDevEnvFiles, p as localFunctionPortsEnv, m as planFunctionsToUnits, h as reportDevCredential, g as sourceFunctionUrlOverlay } from "../_chunks/dev-Dp6LuAe2.js";
@@ -9,7 +9,7 @@ import { writer } from "../writer.js";
9
9
  import { formatInitDone, printInitDone } from "../init/chrome.js";
10
10
  import { FUNCTION_SLUG_PATTERN, deriveFunctionSlug } from "../utils/function_slug.js";
11
11
  import { displayPath } from "./env_output.js";
12
- import { _ as missingDependencies, d as ensureConfigPackages, g as installCommandFrom } from "../_chunks/config-DFj1Btk-.js";
12
+ import { _ as missingDependencies, d as ensureConfigPackages, g as installCommandFrom } from "../_chunks/config-CUWOp44_.js";
13
13
  import { recommendedOperations } from "../functions/registry.js";
14
14
  import { collidingFiles, operationsFromFlags, planConfigRegistration, planEnvExample, planScaffold, writeScaffold } from "../functions/scaffold.js";
15
15
  import { describeRegistrySources, openRegistry } from "../functions/source.js";
@@ -1 +1 @@
1
- export { t as aliases, n as builder, r as cleanup, i as command, a as describe, s as handler, c as install, l as partitionBranchesToPrune, u as status, d as sync, f as uninstall } from "../_chunks/git-ax3xtNoz.js";
1
+ export { t as aliases, n as builder, r as cleanup, i as command, a as describe, s as handler, c as install, l as partitionBranchesToPrune, u as status, d as sync, f as uninstall } from "../_chunks/git-BISnX9MB.js";
@@ -1,30 +1,30 @@
1
- import { r as auth_exports } from "../_chunks/auth-DY5Bm7Ym.js";
1
+ import { r as auth_exports } from "../_chunks/auth-CEb642X3.js";
2
2
  import { t as api_exports } from "../_chunks/api-1MKsfpY3.js";
3
3
  import { n as api_keys_exports } from "../_chunks/api_keys-CTFHd5m_.js";
4
4
  import { n as ask_exports } from "../_chunks/ask-Xlek1Pxh.js";
5
5
  import { o as env_exports } from "../_chunks/env-DxcO3oJk.js";
6
- import { c as config_exports } from "../_chunks/config-DFj1Btk-.js";
6
+ import { c as config_exports } from "../_chunks/config-CUWOp44_.js";
7
7
  import { u as projects_exports } from "../_chunks/projects-a3X4OFEJ.js";
8
- import { a as link_exports } from "../_chunks/link-Z2_mLhVn.js";
8
+ import { a as link_exports } from "../_chunks/link-CfbTC-or.js";
9
9
  import { o as mcp_exports } from "../_chunks/mcp-SvqWzHnT.js";
10
10
  import { c as plugins_exports } from "../_chunks/plugins-BwUZQ6Ic.js";
11
11
  import { l as skills_exports } from "../_chunks/skills-Bv8oKKwE.js";
12
12
  import { t as bootstrap_exports } from "../_chunks/bootstrap-B73qVB39.js";
13
13
  import { r as branches_exports } from "../_chunks/branches-Bp-5z1lM.js";
14
14
  import { n as bucket_exports } from "../_chunks/bucket-D06bvDSa.js";
15
- import { n as checkout_exports } from "../_chunks/checkout-DZa--fO4.js";
16
- import { o as claim_exports } from "../_chunks/claim-Dv5wARrN.js";
15
+ import { n as checkout_exports } from "../_chunks/checkout-9zUY4N8W.js";
16
+ import { o as claim_exports } from "../_chunks/claim-D7fATGLw.js";
17
17
  import { o as connection_string_exports } from "../_chunks/connection_string-6WhV4WFx.js";
18
18
  import { a as credentials_exports } from "../_chunks/credentials-KV1jlK-n.js";
19
19
  import { r as data_api_exports } from "../_chunks/data_api-BpSGbdZf.js";
20
20
  import { s as databases_exports } from "../_chunks/databases-B-qY303S.js";
21
- import { r as deploy_exports } from "../_chunks/deploy-CVJIahZE.js";
22
- import { s as dev_exports } from "../_chunks/dev-CtIzg7vq.js";
21
+ import { r as deploy_exports } from "../_chunks/deploy-BUkXtacE.js";
22
+ import { s as dev_exports } from "../_chunks/dev-Dp6LuAe2.js";
23
23
  import { i as diff_exports } from "../_chunks/diff-dnxneH0u.js";
24
24
  import { c as docs_exports } from "../_chunks/docs-DjYRHjGY.js";
25
25
  import { o as feedback_exports } from "../_chunks/feedback-mQmdTRFn.js";
26
26
  import { o as functions_exports } from "../_chunks/functions-PHaU-kRb.js";
27
- import { o as git_exports } from "../_chunks/git-ax3xtNoz.js";
27
+ import { o as git_exports } from "../_chunks/git-BISnX9MB.js";
28
28
  import { o as incidents_exports } from "../_chunks/incidents-BSFkUu1P.js";
29
29
  import { a as init_exports } from "../_chunks/init-BSwLzxjX.js";
30
30
  import { o as inspect_exports } from "../_chunks/inspect-yFAb61qo.js";
@@ -37,11 +37,11 @@ import { o as orgs_exports } from "../_chunks/orgs-BrvAWM8Z.js";
37
37
  import { o as psql_exports } from "../_chunks/psql-BcxiPR4W.js";
38
38
  import { f as roles_exports } from "../_chunks/roles-BELJqjTy.js";
39
39
  import { o as postgres_exports } from "../_chunks/postgres-BhR1vUFM.js";
40
- import { o as profile_exports } from "../_chunks/profile-Qoyql0AR.js";
40
+ import { o as profile_exports } from "../_chunks/profile-BVkmMwHO.js";
41
41
  import { s as realtime_exports } from "../_chunks/realtime-cV7-c2-O.js";
42
42
  import { a as set_context_exports } from "../_chunks/set_context-ompB6d2D.js";
43
43
  import { s as snapshots_exports } from "../_chunks/snapshots-DxNhjcco.js";
44
- import { a as status_exports } from "../_chunks/status-DRWS1u6H.js";
44
+ import { a as status_exports } from "../_chunks/status-BM42rYe1.js";
45
45
  import { d as triggers_exports } from "../_chunks/triggers-m3IBjiph.js";
46
46
  import { s as user_exports } from "../_chunks/user-C1pTJS9O.js";
47
47
  import { i as vpc_endpoints_exports } from "../_chunks/vpc_endpoints-C-Y4WK2M.js";
@@ -1 +1 @@
1
- export { t as builder, n as command, r as describe, i as handler, o as quoteFlagValue, s as runLink, c as shouldOfferConfigInit } from "../_chunks/link-Z2_mLhVn.js";
1
+ export { t as builder, n as command, r as describe, i as handler, o as quoteFlagValue, s as runLink, c as shouldOfferConfigInit } from "../_chunks/link-CfbTC-or.js";
@@ -1 +1 @@
1
- export { t as aliases, n as builder, r as command, i as describe, a as handler } from "../_chunks/profile-Qoyql0AR.js";
1
+ export { t as aliases, n as builder, r as command, i as describe, a as handler } from "../_chunks/profile-BVkmMwHO.js";
@@ -1 +1 @@
1
- export { t as builder, n as command, r as describe, i as handler } from "../_chunks/status-DRWS1u6H.js";
1
+ export { t as builder, n as command, r as describe, i as handler } from "../_chunks/status-BM42rYe1.js";
@@ -1 +1 @@
1
- export { t as storeFor } from "./_chunks/credential_io-DbeSh3Pl.js";
1
+ export { t as storeFor } from "./_chunks/credential_io-BHwacMdt.js";
package/dist/hosts.js ADDED
@@ -0,0 +1,130 @@
1
+ import { DEFAULT_API_HOST } from "./api.js";
2
+ import { r as defaultDir } from "./_chunks/paths-B55ZfOg1.js";
3
+ import { c as inspectProfiles, l as isHttpUrl, s as hostsOf } from "./_chunks/profiles-kpRUx7gU.js";
4
+ import { i as selectCredential } from "./_chunks/auth_selection-D81EvEz9.js";
5
+ import { Parser, hideBin } from "yargs/helpers";
6
+ // src/hosts.ts
7
+ /**
8
+ * # Which Neon API and OAuth hosts an invocation talks to
9
+ *
10
+ * Per host, each entry winning over the next:
11
+ *
12
+ * 1. `--api-host` / `--oauth-host`.
13
+ * 2. The host recorded on the named profile whose credential this invocation uses.
14
+ * 3. `NEON_API_HOST` / `NEON_OAUTH_HOST`.
15
+ * 4. Production.
16
+ *
17
+ * A recorded host outranks the environment variable for the reason `--profile` outranks
18
+ * `NEON_API_KEY`: the profile's credential is valid only on the environment that issued it, so an
19
+ * exported host must not send it somewhere else. Only a flag typed for this one command does.
20
+ *
21
+ * Hosts are recorded only from those flags, on `neon login --profile <name>` and `neon profile
22
+ * create <name>`. The environment variables are never written down, so exporting one keeps
23
+ * meaning "this shell", as it did before profiles could hold hosts.
24
+ *
25
+ * The arguments are read before yargs runs, because the staging gate decides which commands to
26
+ * register from the host, and the result becomes the yargs default so every handler receives it.
27
+ */
28
+ const DEFAULT_OAUTH_HOST = "https://oauth2.neon.tech";
29
+ const lastString = (value) => {
30
+ const last = Array.isArray(value) ? value.at(-1) : value;
31
+ return typeof last === "string" ? last : void 0;
32
+ };
33
+ const parseInvocation = (args, env) => {
34
+ const { argv } = Parser.detailed([...args], {
35
+ string: [
36
+ "api-host",
37
+ "oauth-host",
38
+ "profile",
39
+ "api-key",
40
+ "config-dir"
41
+ ],
42
+ alias: {
43
+ "api-host": ["apiHost"],
44
+ "oauth-host": ["oauthHost"],
45
+ "api-key": ["apiKey"],
46
+ "config-dir": ["configDir"]
47
+ },
48
+ narg: { "api-key": 1 },
49
+ configuration: {
50
+ "populate--": true,
51
+ "parse-positional-numbers": false
52
+ }
53
+ });
54
+ const apiHost = lastString(argv["api-host"]);
55
+ const oauthHost = lastString(argv["oauth-host"]);
56
+ return {
57
+ flags: {
58
+ ...apiHost !== void 0 ? { apiHost } : {},
59
+ ...oauthHost !== void 0 ? { oauthHost } : {}
60
+ },
61
+ configDir: lastString(argv["config-dir"]) ?? defaultDir,
62
+ profile: credentialProfile({
63
+ apiKeyFlag: lastString(argv["api-key"]) ?? "",
64
+ profileFlag: lastString(argv.profile) ?? "",
65
+ apiKeyEnv: env.NEON_API_KEY ?? "",
66
+ profileEnv: env.NEON_PROFILE ?? ""
67
+ })
68
+ };
69
+ };
70
+ const credentialProfile = (inputs) => {
71
+ try {
72
+ const selection = selectCredential(inputs);
73
+ return selection.source === "profile" ? selection.profile : void 0;
74
+ } catch {
75
+ return;
76
+ }
77
+ };
78
+ const resolveHosts = (flags, recorded, env = process.env) => ({
79
+ apiHost: flags.apiHost ?? recorded.apiHost ?? env.NEON_API_HOST ?? "https://console.neon.tech/api/v2",
80
+ oauthHost: flags.oauthHost ?? recorded.oauthHost ?? env.NEON_OAUTH_HOST ?? "https://oauth2.neon.tech"
81
+ });
82
+ /**
83
+ * The hosts recorded on a named profile. A missing or unreadable `profiles.json` yields none:
84
+ * every command that goes on to use the profile's credential fails on that file with its own
85
+ * message, and one that never touches the credential has no use for the hosts.
86
+ */
87
+ const recordedHosts = (configDir, profile) => {
88
+ if (profile === void 0 || profile === "DEFAULT") return {};
89
+ const read = inspectProfiles(configDir);
90
+ if (read.kind !== "ok") return {};
91
+ const entry = read.file.profiles[profile];
92
+ return entry === void 0 ? {} : hostsOf(entry);
93
+ };
94
+ /** The hosts this invocation uses, for the profile credential selection picks. */
95
+ const invocationHosts = (args = hideBin(process.argv), env = process.env) => {
96
+ const { flags, configDir, profile } = parseInvocation(args, env);
97
+ return resolveHosts(flags, recordedHosts(configDir, profile), env);
98
+ };
99
+ /** The hosts for a command that names its profile itself: `login --profile`, `profile <sub> <name>`. */
100
+ const hostsForProfile = (configDir, profile, args = hideBin(process.argv)) => resolveHosts(parseInvocation(args, process.env).flags, recordedHosts(configDir, profile));
101
+ /**
102
+ * Where a profile's stored credential was issued, for revoking it when it is replaced: its
103
+ * recorded hosts, else the ones this invocation uses.
104
+ */
105
+ const issuingHosts = (configDir, profile, current) => {
106
+ const recorded = recordedHosts(configDir, profile);
107
+ return {
108
+ apiHost: recorded.apiHost ?? current.apiHost,
109
+ oauthHost: recorded.oauthHost ?? current.oauthHost
110
+ };
111
+ };
112
+ /**
113
+ * What a sign-in or `profile create` writes to the profile's hosts: each typed flag, with the
114
+ * production URL removing the recorded host. DEFAULT records none. Call it before any request,
115
+ * so a mistyped URL fails having changed nothing.
116
+ */
117
+ const hostUpdateFor = (profile, args = hideBin(process.argv)) => {
118
+ if (profile === "DEFAULT") return {};
119
+ const { flags } = parseInvocation(args, process.env);
120
+ return {
121
+ ...hostUpdate("api-host", flags.apiHost, DEFAULT_API_HOST, "apiHost"),
122
+ ...hostUpdate("oauth-host", flags.oauthHost, DEFAULT_OAUTH_HOST, "oauthHost")
123
+ };
124
+ };
125
+ const hostUpdate = (flag, value, production, field) => {
126
+ if (value === void 0) return {};
127
+ if (!isHttpUrl(value)) throw new Error(`--${flag} must be an http or https URL, such as ${production}.`);
128
+ return { [field]: value.replace(/\/+$/, "") === production ? null : value };
129
+ };
130
+ export { DEFAULT_OAUTH_HOST, hostUpdateFor, hostsForProfile, invocationHosts, issuingHosts, resolveHosts };
package/dist/index.js CHANGED
@@ -8,8 +8,9 @@ import { currentContextFile, enrichFromContext } from "./context.js";
8
8
  import { NETWORK_ERROR_MESSAGE, isNetworkError, matchErrorCode } from "./errors.js";
9
9
  import { analyticsMiddleware, closeAnalytics, initAnalyticsClientMiddleware, isAnalyticsActive, recordCommandSuccessExtras, sendError, takeCommandSuccessExtras, trackCommandSuccess } from "./analytics.js";
10
10
  import { AuthRefreshError, defaultClientID } from "./auth.js";
11
+ import { invocationHosts } from "./hosts.js";
11
12
  import { getCliName } from "./utils/cli_name.js";
12
- import { c as ensureAuth } from "./_chunks/auth-DY5Bm7Ym.js";
13
+ import { c as ensureAuth } from "./_chunks/auth-CEb642X3.js";
13
14
  import { recoverFrom401 } from "./auth_recovery.js";
14
15
  import { UsageError, failOnUsageError, isBareParentCommand, showHelp, showUsageErrorHelp } from "./help.js";
15
16
  import { lazyCommands, preloadCommand } from "./commands/manifest.js";
@@ -18,9 +19,9 @@ import { recoverFromSSO } from "./sso_recovery.js";
18
19
  import { notifyIfUpdateAvailable, shouldRunSkillsNotifier } from "./update_notifier.js";
19
20
  import { fillInArgs, resolveApiKeyFromEnv } from "./utils/middlewares.js";
20
21
  import { collapseRepeatedFlags, declaredOptions } from "./utils/repeated_flags.js";
21
- import { stagingFeaturesEnabledForArgv } from "./utils/staging.js";
22
- import yargs from "yargs";
22
+ import { isStagingApiHost } from "./utils/staging.js";
23
23
  import { hideBin } from "yargs/helpers";
24
+ import yargs from "yargs";
24
25
  // src/index.ts
25
26
  const NO_SUBCOMMANDS_VERBS = [
26
27
  "api",
@@ -50,6 +51,7 @@ const NO_SUBCOMMANDS_VERBS = [
50
51
  "bootstrap",
51
52
  "status"
52
53
  ];
54
+ const hosts = invocationHosts(hideBin(process.argv));
53
55
  let builder = yargs(hideBin(process.argv));
54
56
  builder = builder.scriptName(pkg_default.name).locale("en").usage("$0 <command> [options]").parserConfiguration({
55
57
  "populate--": true,
@@ -69,7 +71,7 @@ builder = builder.scriptName(pkg_default.name).locale("en").usage("$0 <command>
69
71
  }).option("api-host", {
70
72
  describe: "The API host",
71
73
  hidden: true,
72
- default: process.env.NEON_API_HOST ?? "https://console.neon.tech/api/v2"
74
+ default: hosts.apiHost
73
75
  }).option("config-dir", {
74
76
  describe: "Path to config directory",
75
77
  group: "Global options:",
@@ -88,7 +90,7 @@ builder = builder.scriptName(pkg_default.name).locale("en").usage("$0 <command>
88
90
  "oauth-host": {
89
91
  description: "URL to Neon OAuth host",
90
92
  hidden: true,
91
- default: process.env.NEON_OAUTH_HOST ?? "https://oauth2.neon.tech"
93
+ default: hosts.oauthHost
92
94
  },
93
95
  "client-id": {
94
96
  description: "OAuth client id",
@@ -139,7 +141,7 @@ builder = builder.scriptName(pkg_default.name).locale("en").usage("$0 <command>
139
141
  if (args.help) await showHelp(builder);
140
142
  }, true).middleware(async (args) => {
141
143
  if (args._.length === 1 && !NO_SUBCOMMANDS_VERBS.includes(args._[0]) || args._.length > 1 && isBareParentCommand(builder, args._)) await showHelp(builder);
142
- }).middleware(ensureAuth).middleware(enrichFromContext).middleware(analyticsMiddleware).command(lazyCommands({ staging: stagingFeaturesEnabledForArgv(hideBin(process.argv)) })).strictCommands().version(pkg_default.version).group("version", "Global options:").alias("version", "v").completion().scriptName(getCliName()).epilog("For more information, visit https://neon.com/docs/reference/neon-cli").wrap(null).fail(failOnUsageError);
144
+ }).middleware(ensureAuth).middleware(enrichFromContext).middleware(analyticsMiddleware).command(lazyCommands({ staging: isStagingApiHost(hosts.apiHost) })).strictCommands().version(pkg_default.version).group("version", "Global options:").alias("version", "v").completion().scriptName(getCliName()).epilog("For more information, visit https://neon.com/docs/reference/neon-cli").wrap(null).fail(failOnUsageError);
143
145
  async function handleError(msg, err, canRetry) {
144
146
  if (process.argv.some((arg) => arg === "--help" || arg === "-h")) {
145
147
  await showHelp(builder);
package/dist/init/auth.js CHANGED
@@ -2,7 +2,7 @@ import { isNeonApiError } from "../api.js";
2
2
  import { r as defaultDir } from "../_chunks/paths-B55ZfOg1.js";
3
3
  import "../config.js";
4
4
  import "../auth.js";
5
- import { c as ensureAuth, l as existingApiClient } from "../_chunks/auth-DY5Bm7Ym.js";
5
+ import { c as ensureAuth, l as existingApiClient } from "../_chunks/auth-CEb642X3.js";
6
6
  import { recoverFrom401 } from "../auth_recovery.js";
7
7
  import { c as pull } from "../_chunks/env-DxcO3oJk.js";
8
8
  import { c as setupNeonMcp } from "../_chunks/mcp-SvqWzHnT.js";
@@ -1,10 +1,10 @@
1
1
  import { isNeonApiError } from "../api.js";
2
2
  import { contextBranch, readContextFile } from "../context.js";
3
- import { c as ensureAuth } from "../_chunks/auth-DY5Bm7Ym.js";
3
+ import { c as ensureAuth } from "../_chunks/auth-CEb642X3.js";
4
4
  import { recoverFrom401 } from "../auth_recovery.js";
5
5
  import { loadProjectConfig } from "../project.js";
6
6
  import { loadEnvFileIntoProcess } from "../env_file.js";
7
- import { r as applyCmd } from "../_chunks/config-DFj1Btk-.js";
7
+ import { r as applyCmd } from "../_chunks/config-CUWOp44_.js";
8
8
  import { authContext } from "./auth.js";
9
9
  import { existsSync } from "node:fs";
10
10
  import { missingFunctionEnv } from "@neon/config";
@@ -1,7 +1,7 @@
1
- import { t as storeFor } from "../_chunks/credential_io-DbeSh3Pl.js";
1
+ import { t as storeFor } from "../_chunks/credential_io-BHwacMdt.js";
2
2
  import { isCi } from "../env.js";
3
- import { h as resolveProfile, u as locationOf } from "../_chunks/profiles-DTazQtjK.js";
4
- import { i as selectCredential, t as credentialInputs } from "../_chunks/auth_selection-CwGLN9Qz.js";
3
+ import { p as locationOf, v as resolveProfile } from "../_chunks/profiles-kpRUx7gU.js";
4
+ import { i as selectCredential, t as credentialInputs } from "../_chunks/auth_selection-D81EvEz9.js";
5
5
  import { detectInstalledAgents, detectProjectAgents, uniqueAgentIds } from "../mcp/agents.js";
6
6
  import "./agents.js";
7
7
  import { directoryIsEmpty } from "./plan.js";
package/dist/init/link.js CHANGED
@@ -2,9 +2,9 @@ import { isNeonApiError } from "../api.js";
2
2
  import { r as defaultDir } from "../_chunks/paths-B55ZfOg1.js";
3
3
  import "../config.js";
4
4
  import "../auth.js";
5
- import { c as ensureAuth } from "../_chunks/auth-DY5Bm7Ym.js";
5
+ import { c as ensureAuth } from "../_chunks/auth-CEb642X3.js";
6
6
  import { recoverFrom401 } from "../auth_recovery.js";
7
- import { s as runLink } from "../_chunks/link-Z2_mLhVn.js";
7
+ import { s as runLink } from "../_chunks/link-CfbTC-or.js";
8
8
  // src/init/link.ts
9
9
  const isUnauthorized = (error) => isNeonApiError(error) && error.status === 401;
10
10
  const authenticationFailed = () => /* @__PURE__ */ new Error("Authentication failed.");
package/dist/init/run.js CHANGED
@@ -14,8 +14,8 @@ import { getAgentDisplayName } from "../mcp/agents.js";
14
14
  import { missingPluginsCommands, pluginsCommandProblemText, pluginsInstallableAgents, unusablePluginsCommands } from "../plugins/targets.js";
15
15
  import { AGENTS_NOT_INSTALLED, CANCELLED_BODY, CLAIMABLE_ACCOUNT_FLAGS, CLAIMABLE_ALREADY_LINKED, CLAIMABLE_MCP_API_KEY, CLAIMABLE_NO_LINK, MCP_API_KEY_NEEDS_AUTH, MCP_SCOPED_NEEDS_PROJECT, NON_TTY_LINK_NEEDS_AUTH, NO_AGENTS_FALLBACK_STATUS, PROGRESS, PROJECT_PINNED_OFFLINE, claimableNext, claimableThenServicesNext, configInitNext, envPullFailedNext, existingConfigNext, installFailedNext, mcpAfterLinkNext, mcpConfigLocationSkipped, mcpConfigLocationUnavailable, mcpKeyFailedNext, namedAgentsUnavailable, newConfigNext, offlinePinNext, skippedLinkNext, toolingFailedNext, unattendedUnauthedNext } from "./copy.js";
16
16
  import { agentsRowValue, configRowValue, formatInitDone, headingForKind, printInitBanner, printInitDone, printInitProgress, projectRowValue, shouldPrintInitBanner } from "./chrome.js";
17
- import { h as initCmd, t as ConfigInstallFailed } from "../_chunks/config-DFj1Btk-.js";
18
- import { o as quoteFlagValue, s as runLink } from "../_chunks/link-Z2_mLhVn.js";
17
+ import { h as initCmd, t as ConfigInstallFailed } from "../_chunks/config-CUWOp44_.js";
18
+ import { o as quoteFlagValue, s as runLink } from "../_chunks/link-CfbTC-or.js";
19
19
  import { runAuthenticatedLink } from "./link.js";
20
20
  import { mcpInstallableAgents } from "../mcp/targets.js";
21
21
  import { skillsInstallableAgents } from "../skills/targets.js";
@@ -25,7 +25,7 @@ import { pullInitEnv, resolveInitConfigApi } from "./auth.js";
25
25
  import { InitCancelled, raceSigint, restoreCursor } from "./cancelled.js";
26
26
  import { pickAgentSetupInteractively, pickInitAgentsInteractively, pickInitConfigInteractively, pickInitMcpAuthInteractively, pickInitMcpConfigLocationInteractively, pickInitModeInteractively, pickInitPackageManagerInteractively, pickInitProjectSetupInteractively, pickInitServicesInteractively, pickInitSkillsInteractively } from "./wizard.js";
27
27
  import { runToolingSteps, toolingStepCommandText } from "./tooling.js";
28
- import { l as create } from "../_chunks/claim-Dv5wARrN.js";
28
+ import { l as create } from "../_chunks/claim-D7fATGLw.js";
29
29
  import { INIT_CONFIG_SERVICES_CONFLICT, configPlanFromResolution, initEnvPullAfterConfig, resolveInitConfigChoice } from "./choices.js";
30
30
  import { detectInitEnvironment } from "./detect.js";
31
31
  import { createInitFunnel, emitInitStart, finishInitFunnel, initStartProperties, recordInitError, recordInitExit } from "./funnel.js";
@@ -1,4 +1,4 @@
1
- import { a as OAUTH, d as scopeOf, i as API_KEY, l as interpretCredentials, t as storeFor, u as isSameCredential } from "./_chunks/credential_io-DbeSh3Pl.js";
1
+ import { a as OAUTH, d as scopeOf, i as API_KEY, l as interpretCredentials, t as storeFor, u as isSameCredential } from "./_chunks/credential_io-BHwacMdt.js";
2
2
  import { log } from "./log.js";
3
3
  import { getApiClient } from "./api.js";
4
4
  import { revokeToken } from "./auth.js";
@@ -1,4 +1,4 @@
1
- import { r as recordCredentialInputs } from "../_chunks/auth_selection-CwGLN9Qz.js";
1
+ import { r as recordCredentialInputs } from "../_chunks/auth_selection-D81EvEz9.js";
2
2
  // src/utils/middlewares.ts
3
3
  /**
4
4
  * Forwarding Yargs's default would turn ambient configuration into an explicit child override.
@@ -1,28 +1,18 @@
1
- import { Parser, hideBin } from "yargs/helpers";
1
+ import { invocationHosts } from "../hosts.js";
2
+ import { hideBin } from "yargs/helpers";
2
3
  // src/utils/staging.ts
3
4
  /**
4
5
  * Staging-only features ship in a release before their API reaches production. The CLI
5
- * exposes them only when the API host it sends requests to (`--api-host`, else
6
- * `NEON_API_HOST`) is Neon's staging console; with production or no host set, they are
7
- * hidden from help and fail with a "coming soon" message.
6
+ * exposes them only when the API host it sends requests to (`--api-host`, else the selected
7
+ * profile's recorded host, else `NEON_API_HOST`) is Neon's staging console; with production or
8
+ * no host set, they are hidden from help and fail with a "coming soon" message.
8
9
  */
9
10
  const STAGING_API_HOST = "https://console-stage.neon.build/api/v2";
10
11
  /** `NEON_STAGING_API_HOST` lets the CLI's tests treat their local mock API as staging. */
11
12
  const stagingHostname = () => new URL(process.env.NEON_STAGING_API_HOST ?? "https://console-stage.neon.build/api/v2").hostname;
12
13
  const isStagingApiHost = (apiHost) => apiHost !== void 0 && URL.canParse(apiHost) && new URL(apiHost).hostname === stagingHostname();
13
14
  /** The API host this process was invoked with, read before or without yargs. */
14
- const stagingFeaturesEnabledForArgv = (args = hideBin(process.argv)) => {
15
- const { argv } = Parser.detailed([...args], {
16
- string: ["api-host"],
17
- alias: { "api-host": ["apiHost"] },
18
- configuration: {
19
- "populate--": true,
20
- "parse-positional-numbers": false
21
- }
22
- });
23
- const flag = argv["api-host"];
24
- return isStagingApiHost(typeof flag === "string" ? flag : process.env.NEON_API_HOST);
25
- };
15
+ const stagingFeaturesEnabledForArgv = (args = hideBin(process.argv)) => isStagingApiHost(invocationHosts(args).apiHost);
26
16
  /** `apiHost` is a command's resolved host; without one, the host this process was invoked with. */
27
17
  const stagingFeaturesEnabled = (apiHost) => apiHost === void 0 ? stagingFeaturesEnabledForArgv() : isStagingApiHost(apiHost);
28
18
  /** A hard stop: callers that degrade other failures to warnings let this one through. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neon",
3
- "version": "9.8.0",
3
+ "version": "9.9.0",
4
4
  "description": "CLI tool for Neon, the cloud backend primitives built around Lakebase Postgres",
5
5
  "keywords": [
6
6
  "neon",
@@ -73,10 +73,10 @@
73
73
  "yaml": "^2.9.0",
74
74
  "yargs": "17.7.2",
75
75
  "yoctocolors": "^2.1.2",
76
- "@neon/config-runtime": "1.12.8",
77
- "@neon/realtime": "0.2.1",
78
76
  "@neon/sdk": "7.14.3",
79
- "@neon/config": "1.14.5"
77
+ "@neon/config": "1.14.5",
78
+ "@neon/config-runtime": "1.12.8",
79
+ "@neon/realtime": "0.2.1"
80
80
  },
81
81
  "optionalDependencies": {
82
82
  "@napi-rs/keyring": "1.3.0",
@@ -113,8 +113,8 @@
113
113
  "typescript": "^5.9.0",
114
114
  "vitest": "^3.0.9",
115
115
  "@neon-internals/cli-core": "0.0.0",
116
- "@neon/e2e-harness": "0.0.0",
117
116
  "@neon-internals/env-core": "0.0.56",
117
+ "@neon/e2e-harness": "0.0.0",
118
118
  "@neon/env": "2.1.8",
119
119
  "@neon/functions": "0.11.0"
120
120
  },