esim-cli 2026.1202.214 → 2026.1202.215

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -41,9 +41,9 @@ esim market buy --schema
41
41
 
42
42
  Root help lists top-level commands by group. Run `esim help <group>` for one-line summaries, and `esim <noun> --help` for the available verbs. A bare noun such as `battle` or `market` opens its default view. Command help and schema describe parameters, defaults, fields, write behavior and the relevant wiki page.
43
43
 
44
- Run `esim login` and approve the link in your browser after checking that the verification code matches the terminal. Use `esim login --no-browser` to open the printed link yourself. The CLI saves the credential under `${XDG_CONFIG_HOME:-~/.config}/esim/credentials.json` and uses it when the API URL matches. `esim logout` deletes the local file. To revoke the API token, open **API token** on the web account page (`/account`).
44
+ Run `esim login` and approve the link in your browser after checking that the verification code matches the terminal. Use `esim login --no-browser` to open the printed link yourself. The CLI saves the credential under `${XDG_CONFIG_HOME:-~/.config}/esim/credentials.json` and uses it when the API origin (scheme, host and port) matches. `esim logout` deletes the local file. To revoke the API token, open **API token** on the web account page (`/account`).
45
45
 
46
- The executable reads `ESIM_API_URL` and defaults to `https://esim.350124.xyz`. For local development, set `ESIM_API_URL=http://127.0.0.1:8766`. `ESIM_API_TOKEN` overrides both the saved credential and `ESIM_SESSION_COOKIE`. `ESIM_SESSION_COOKIE` accepts a development cookie in the form `citizen=…` and overrides the saved credential.
46
+ The executable reads `ESIM_API_URL` and defaults to `https://esim.350124.xyz`. For local development, set `ESIM_API_URL=http://127.0.0.1:8766`. For player commands, `ESIM_API_TOKEN` overrides both the saved credential and `ESIM_SESSION_COOKIE`. `ESIM_SESSION_COOKIE` accepts a development cookie in the form `citizen=…` and overrides the saved credential.
47
47
 
48
48
  Text is the default output. Use `--json` to get the full structured output. `--fields a,b.c` projects keys before rendering either format, including keys inside arrays. Lists default to 20 entries. Use `--cursor` for the next page or `--all --max N` to bound the result. Errors go to stderr in the selected format. Exit codes are 0 for success, 2 for usage, 3 for business or authentication rejection, and 4 for transport or API failure.
49
49
 
@@ -61,7 +61,7 @@ Use `claim <task>` or `claim --chest` to collect one reward. Bare `claim` exits
61
61
 
62
62
  ## Administration
63
63
 
64
- `esim admin --help` lists the commands available in the installed CLI. Supply the administrator's current `citizen=…` cookie through `ESIM_SESSION_COOKIE` using a private environment. The API checks the account's administrator role. Admin uses HTTPS, with HTTP allowed on loopback for local development. API requests reject redirects.
64
+ Run `esim login` and approve the device code in your browser with an administrator account on the target server. The installed CLI uses that saved device credential for `esim admin`. The API checks your current administrator role on every request. If you signed in before the server supported CLI administration, run `esim login` again. Admin uses HTTPS, with HTTP allowed on loopback for local development. API requests reject redirects. Run `esim admin --help` to see the available commands.
65
65
 
66
66
  ```sh
67
67
  esim admin feedback list --status open --kind bug
package/dist/esim.js CHANGED
@@ -38396,9 +38396,49 @@ var adminOperations = [
38396
38396
  { operationId: "ResolveAdminFeedback", name: "resolve-admin-feedback", method: "POST", path: "/api/admin/feedback/{id}/resolve", spec: "feedback.yaml", write: true, retry: "unsafe", description: "Requires an administrator session and a same-origin JSON request. Closes an open report and records the review in the audit log.", parameters: [{ name: "id", in: "path", required: true, schema: { type: "integer", format: "int64", minimum: 1 } }], body: { required: true, schema: { type: "object", additionalProperties: false, required: ["status", "reply"], properties: { status: { type: "string", enum: ["accepted", "rejected", "duplicate"], "x-enum-varnames": ["ResolveAccepted", "ResolveRejected", "ResolveDuplicate"], description: "Use accepted after verifying that the fix is available to players." }, reply: { type: "string", minLength: 1, maxLength: 2000 }, duplicateOf: { type: "integer", format: "int64", minimum: 1, description: "Required only for duplicate." } } } }, requiresCredentials: true, responses: { "204": { kind: "empty" } }, responseFields: [] }
38397
38397
  ];
38398
38398
 
38399
+ // login-credentials.ts
38400
+ var tokenSchema = string2().regex(/^esim_[A-Za-z0-9_-]+$/);
38401
+ var credentialSchema = object({ apiUrl: string2(), token: tokenSchema });
38402
+ function httpApiUrl(apiUrl) {
38403
+ const url = URL.canParse(apiUrl) ? new URL(apiUrl) : undefined;
38404
+ if (url && ["http:", "https:"].includes(url.protocol) && !url.username && !url.password)
38405
+ return url;
38406
+ }
38407
+ async function resolveCredentials(env, apiUrl, store) {
38408
+ if (env.ESIM_API_TOKEN)
38409
+ return { token: env.ESIM_API_TOKEN };
38410
+ if (env.ESIM_SESSION_COOKIE)
38411
+ return { cookie: env.ESIM_SESSION_COOKIE };
38412
+ return readSavedCredential(apiUrl, store);
38413
+ }
38414
+ async function readSavedCredential(apiUrl, store) {
38415
+ const origin = httpApiUrl(apiUrl)?.origin;
38416
+ if (!origin)
38417
+ return;
38418
+ const text = await store.read().catch(() => {
38419
+ throw new CommandError(4, "credentials_file_error", "Could not access the local CLI credentials file.", "Check access to the credentials file and run esim login again.");
38420
+ });
38421
+ if (text === undefined)
38422
+ return;
38423
+ let stored;
38424
+ try {
38425
+ stored = JSON.parse(text);
38426
+ } catch {
38427
+ return;
38428
+ }
38429
+ const credentials = credentialSchema.safeParse(stored);
38430
+ if (credentials.success && httpApiUrl(credentials.data.apiUrl)?.origin === origin)
38431
+ return { token: credentials.data.token };
38432
+ }
38433
+ function saveCredentials(store, credentials) {
38434
+ return store.write(JSON.stringify(credentials) + `
38435
+ `);
38436
+ }
38437
+
38399
38438
  // admin.ts
38400
38439
  var commands3 = [...coreAdminCommands, ...moderationCommands];
38401
38440
  var operations2 = new Map(adminOperations.map((operation) => [operation.operationId, operation]));
38441
+ var loginHint = "Run esim login for this server using an administrator account.";
38402
38442
  function commandUsage(command) {
38403
38443
  return `${command.usage}${command.write ? " (--dry-run | --yes)" : ""} [--json]`;
38404
38444
  }
@@ -38411,7 +38451,7 @@ function groupHelp2(path, matches) {
38411
38451
  ...matches.map((command) => ` ${commandUsage(command)}
38412
38452
  ${command.summary}`),
38413
38453
  "",
38414
- "Set ESIM_SESSION_COOKIE to a current administrator session before running a command."
38454
+ loginHint
38415
38455
  ].join(`
38416
38456
  `);
38417
38457
  }
@@ -38459,9 +38499,9 @@ function parse4(command, argv) {
38459
38499
  return { positionals, values: Object.fromEntries(values), dryRun, confirmed };
38460
38500
  }
38461
38501
  function adminOrigin(baseUrl) {
38462
- const url = URL.canParse(baseUrl) ? new URL(baseUrl) : undefined;
38502
+ const url = httpApiUrl(baseUrl);
38463
38503
  const loopback = url && ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname);
38464
- if (!url || url.username || url.password || !(url.protocol === "https:" || url.protocol === "http:" && loopback)) {
38504
+ if (!url || !(url.protocol === "https:" || url.protocol === "http:" && loopback)) {
38465
38505
  throw new CommandError(2, "invalid_api_url", "Admin requires HTTPS or a loopback HTTP address.", "Check ESIM_API_URL.");
38466
38506
  }
38467
38507
  return url.origin;
@@ -38478,8 +38518,11 @@ function failureFor(error, operationId, input) {
38478
38518
  if (conflict && operationId === "ResolveAdminFeedback") {
38479
38519
  throw new CommandError(3, "feedback_already_closed", "This feedback report is already closed.", readFeedback);
38480
38520
  }
38521
+ if (error.error === "session_required" || error.error === "not_allowed_for_token") {
38522
+ throw new CommandError(3, error.error, "A current CLI device login is required for this administrator request.", loginHint);
38523
+ }
38481
38524
  if (error.error === "forbidden" || error.error === "http_403") {
38482
- throw new CommandError(3, "forbidden", "The API refused this administrator request.", "Check that ESIM_SESSION_COOKIE belongs to an administrator on this server.");
38525
+ throw new CommandError(3, "forbidden", "The API refused this administrator request.", "Check that the signed-in account has administrator access on this server. Run esim login again if needed.");
38483
38526
  }
38484
38527
  if (error.exitCode === 4 && (operationId === "UpdateWorldSpeed" || operationId === "ResolveAdminFeedback")) {
38485
38528
  throw new CommandError(4, error.error, error.message, operationId === "UpdateWorldSpeed" ? "Run esim admin config show to check whether the speed change was applied." : readFeedback);
@@ -38498,12 +38541,12 @@ function redact(value, secret) {
38498
38541
  }
38499
38542
  return value;
38500
38543
  }
38501
- async function runAdmin(argv, options, cookie) {
38544
+ async function runAdmin(argv, options, store) {
38502
38545
  const json = jsonRequested(argv);
38503
38546
  const help = flagRequested(argv, "--help");
38504
38547
  const words = help ? argv.filter((word) => word !== "--help" && word !== "--json") : argv;
38505
38548
  const command = commands3.find((entry) => entry.path.every((part, index) => part === words[index]));
38506
- const secret = cookie?.slice("citizen=".length) ?? "";
38549
+ let secret = "";
38507
38550
  try {
38508
38551
  if (!command) {
38509
38552
  const matches = commands3.filter((entry) => words.every((word, index) => entry.path[index] === word));
@@ -38521,17 +38564,20 @@ ${command.summary}
38521
38564
  return 0;
38522
38565
  }
38523
38566
  const args = parse4(command, argv.slice(command.path.length));
38524
- if (!cookie) {
38525
- throw new CommandError(3, "session_required", "A current administrator session is required.", "Set ESIM_SESSION_COOKIE to your citizen session cookie.");
38567
+ const baseUrl = adminOrigin(options.env.baseUrl);
38568
+ const credentials = await readSavedCredential(baseUrl, store);
38569
+ if (!credentials) {
38570
+ throw new CommandError(3, "session_required", "A current CLI device login is required.", loginHint);
38526
38571
  }
38572
+ secret = credentials.token;
38527
38573
  const { fetch: fetch2, stdout, stderr, columns } = options;
38528
38574
  const transport = {
38529
38575
  fetch: fetch2,
38530
38576
  stdout,
38531
38577
  stderr,
38532
38578
  columns,
38533
- credentials: { cookie },
38534
- env: { baseUrl: adminOrigin(options.env.baseUrl), signal: options.env.signal },
38579
+ credentials,
38580
+ env: { baseUrl, signal: options.env.signal },
38535
38581
  apiUrlEnvVar: "ESIM_API_URL"
38536
38582
  };
38537
38583
  const result = await command.run({
@@ -38572,34 +38618,8 @@ ${command.summary}
38572
38618
  }
38573
38619
  }
38574
38620
 
38575
- // login-credentials.ts
38576
- var tokenSchema = string2().regex(/^esim_[A-Za-z0-9_-]+$/);
38577
- var credentialSchema = object({ apiUrl: string2(), token: tokenSchema });
38578
- async function resolveCredentials(env, apiUrl, store) {
38579
- if (env.ESIM_API_TOKEN)
38580
- return { token: env.ESIM_API_TOKEN };
38581
- if (env.ESIM_SESSION_COOKIE)
38582
- return { cookie: env.ESIM_SESSION_COOKIE };
38583
- const text = await store.read();
38584
- if (text === undefined)
38585
- return;
38586
- let stored;
38587
- try {
38588
- stored = JSON.parse(text);
38589
- } catch {
38590
- return;
38591
- }
38592
- const credentials = credentialSchema.safeParse(stored);
38593
- if (credentials.success && credentials.data.apiUrl === apiUrl)
38594
- return { token: credentials.data.token };
38595
- }
38596
- function saveCredentials(store, credentials) {
38597
- return store.write(JSON.stringify(credentials) + `
38598
- `);
38599
- }
38600
-
38601
38621
  // version.ts
38602
- var version2 = "2026.1202.214";
38622
+ var version2 = "2026.1202.215";
38603
38623
  var installKind = version2 === "dev" ? "source" : typeof ESIM_CLI_EXECUTABLE === "boolean" && ESIM_CLI_EXECUTABLE ? "executable" : "npm";
38604
38624
  var npmLatestUrl = "https://registry.npmjs.org/esim-cli/latest";
38605
38625
  var releaseUrl = (release) => `https://github.com/CorrectRoadH/open-esim/releases/download/cli-v${release}`;
@@ -38663,8 +38683,8 @@ var identity = object({ citizen: object({ pid: string2().regex(/^[1-9][0-9]*$/),
38663
38683
  var noticeTimeout = 3000;
38664
38684
  var sleep = (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds));
38665
38685
  function apiOrigin(apiUrl) {
38666
- const url2 = URL.canParse(apiUrl) ? new URL(apiUrl) : undefined;
38667
- if (!url2 || !["http:", "https:"].includes(url2.protocol) || url2.username || url2.password) {
38686
+ const url2 = httpApiUrl(apiUrl);
38687
+ if (!url2) {
38668
38688
  throw new CommandError(2, "invalid_api_url", "Set ESIM_API_URL to an HTTP or HTTPS URL.", "");
38669
38689
  }
38670
38690
  return url2.origin;
@@ -38732,7 +38752,7 @@ Verification code: ${userCode}
38732
38752
  if (poll.data.status === "pending")
38733
38753
  continue;
38734
38754
  const { token } = poll.data;
38735
- await saveCredentials(executable.credentials, { apiUrl: options.env.baseUrl, token });
38755
+ await saveCredentials(executable.credentials, { apiUrl: apiOrigin(options.env.baseUrl), token });
38736
38756
  const operation = operations.get("me");
38737
38757
  if (!operation)
38738
38758
  invalidResponse();
@@ -38843,7 +38863,7 @@ async function runCommandLine(input, executable) {
38843
38863
  apiUrlEnvVar: "ESIM_API_URL"
38844
38864
  };
38845
38865
  if (isAdminInvocation(argv)) {
38846
- return runAdmin(name === "admin" ? args : ["--help", ...args.slice(1)], options, executable.env.ESIM_SESSION_COOKIE);
38866
+ return runAdmin(name === "admin" ? args : ["--help", ...args.slice(1)], options, executable.credentials);
38847
38867
  }
38848
38868
  try {
38849
38869
  if (name === "--version" && !args.filter((arg) => arg !== "--json").length) {
package/dist/index.js CHANGED
@@ -38402,9 +38402,49 @@ var adminOperations = [
38402
38402
  { operationId: "ResolveAdminFeedback", name: "resolve-admin-feedback", method: "POST", path: "/api/admin/feedback/{id}/resolve", spec: "feedback.yaml", write: true, retry: "unsafe", description: "Requires an administrator session and a same-origin JSON request. Closes an open report and records the review in the audit log.", parameters: [{ name: "id", in: "path", required: true, schema: { type: "integer", format: "int64", minimum: 1 } }], body: { required: true, schema: { type: "object", additionalProperties: false, required: ["status", "reply"], properties: { status: { type: "string", enum: ["accepted", "rejected", "duplicate"], "x-enum-varnames": ["ResolveAccepted", "ResolveRejected", "ResolveDuplicate"], description: "Use accepted after verifying that the fix is available to players." }, reply: { type: "string", minLength: 1, maxLength: 2000 }, duplicateOf: { type: "integer", format: "int64", minimum: 1, description: "Required only for duplicate." } } } }, requiresCredentials: true, responses: { "204": { kind: "empty" } }, responseFields: [] }
38403
38403
  ];
38404
38404
 
38405
+ // login-credentials.ts
38406
+ var tokenSchema = string2().regex(/^esim_[A-Za-z0-9_-]+$/);
38407
+ var credentialSchema = object({ apiUrl: string2(), token: tokenSchema });
38408
+ function httpApiUrl(apiUrl) {
38409
+ const url = URL.canParse(apiUrl) ? new URL(apiUrl) : undefined;
38410
+ if (url && ["http:", "https:"].includes(url.protocol) && !url.username && !url.password)
38411
+ return url;
38412
+ }
38413
+ async function resolveCredentials(env, apiUrl, store) {
38414
+ if (env.ESIM_API_TOKEN)
38415
+ return { token: env.ESIM_API_TOKEN };
38416
+ if (env.ESIM_SESSION_COOKIE)
38417
+ return { cookie: env.ESIM_SESSION_COOKIE };
38418
+ return readSavedCredential(apiUrl, store);
38419
+ }
38420
+ async function readSavedCredential(apiUrl, store) {
38421
+ const origin = httpApiUrl(apiUrl)?.origin;
38422
+ if (!origin)
38423
+ return;
38424
+ const text = await store.read().catch(() => {
38425
+ throw new CommandError(4, "credentials_file_error", "Could not access the local CLI credentials file.", "Check access to the credentials file and run esim login again.");
38426
+ });
38427
+ if (text === undefined)
38428
+ return;
38429
+ let stored;
38430
+ try {
38431
+ stored = JSON.parse(text);
38432
+ } catch {
38433
+ return;
38434
+ }
38435
+ const credentials = credentialSchema.safeParse(stored);
38436
+ if (credentials.success && httpApiUrl(credentials.data.apiUrl)?.origin === origin)
38437
+ return { token: credentials.data.token };
38438
+ }
38439
+ function saveCredentials(store, credentials) {
38440
+ return store.write(JSON.stringify(credentials) + `
38441
+ `);
38442
+ }
38443
+
38405
38444
  // admin.ts
38406
38445
  var commands3 = [...coreAdminCommands, ...moderationCommands];
38407
38446
  var operations2 = new Map(adminOperations.map((operation) => [operation.operationId, operation]));
38447
+ var loginHint = "Run esim login for this server using an administrator account.";
38408
38448
  function commandUsage(command) {
38409
38449
  return `${command.usage}${command.write ? " (--dry-run | --yes)" : ""} [--json]`;
38410
38450
  }
@@ -38417,7 +38457,7 @@ function groupHelp2(path, matches) {
38417
38457
  ...matches.map((command) => ` ${commandUsage(command)}
38418
38458
  ${command.summary}`),
38419
38459
  "",
38420
- "Set ESIM_SESSION_COOKIE to a current administrator session before running a command."
38460
+ loginHint
38421
38461
  ].join(`
38422
38462
  `);
38423
38463
  }
@@ -38465,9 +38505,9 @@ function parse4(command, argv) {
38465
38505
  return { positionals, values: Object.fromEntries(values), dryRun, confirmed };
38466
38506
  }
38467
38507
  function adminOrigin(baseUrl) {
38468
- const url = URL.canParse(baseUrl) ? new URL(baseUrl) : undefined;
38508
+ const url = httpApiUrl(baseUrl);
38469
38509
  const loopback = url && ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname);
38470
- if (!url || url.username || url.password || !(url.protocol === "https:" || url.protocol === "http:" && loopback)) {
38510
+ if (!url || !(url.protocol === "https:" || url.protocol === "http:" && loopback)) {
38471
38511
  throw new CommandError(2, "invalid_api_url", "Admin requires HTTPS or a loopback HTTP address.", "Check ESIM_API_URL.");
38472
38512
  }
38473
38513
  return url.origin;
@@ -38484,8 +38524,11 @@ function failureFor(error, operationId, input) {
38484
38524
  if (conflict && operationId === "ResolveAdminFeedback") {
38485
38525
  throw new CommandError(3, "feedback_already_closed", "This feedback report is already closed.", readFeedback);
38486
38526
  }
38527
+ if (error.error === "session_required" || error.error === "not_allowed_for_token") {
38528
+ throw new CommandError(3, error.error, "A current CLI device login is required for this administrator request.", loginHint);
38529
+ }
38487
38530
  if (error.error === "forbidden" || error.error === "http_403") {
38488
- throw new CommandError(3, "forbidden", "The API refused this administrator request.", "Check that ESIM_SESSION_COOKIE belongs to an administrator on this server.");
38531
+ throw new CommandError(3, "forbidden", "The API refused this administrator request.", "Check that the signed-in account has administrator access on this server. Run esim login again if needed.");
38489
38532
  }
38490
38533
  if (error.exitCode === 4 && (operationId === "UpdateWorldSpeed" || operationId === "ResolveAdminFeedback")) {
38491
38534
  throw new CommandError(4, error.error, error.message, operationId === "UpdateWorldSpeed" ? "Run esim admin config show to check whether the speed change was applied." : readFeedback);
@@ -38504,12 +38547,12 @@ function redact(value, secret) {
38504
38547
  }
38505
38548
  return value;
38506
38549
  }
38507
- async function runAdmin(argv, options, cookie) {
38550
+ async function runAdmin(argv, options, store) {
38508
38551
  const json = jsonRequested(argv);
38509
38552
  const help = flagRequested(argv, "--help");
38510
38553
  const words = help ? argv.filter((word) => word !== "--help" && word !== "--json") : argv;
38511
38554
  const command = commands3.find((entry) => entry.path.every((part, index) => part === words[index]));
38512
- const secret = cookie?.slice("citizen=".length) ?? "";
38555
+ let secret = "";
38513
38556
  try {
38514
38557
  if (!command) {
38515
38558
  const matches = commands3.filter((entry) => words.every((word, index) => entry.path[index] === word));
@@ -38527,17 +38570,20 @@ ${command.summary}
38527
38570
  return 0;
38528
38571
  }
38529
38572
  const args = parse4(command, argv.slice(command.path.length));
38530
- if (!cookie) {
38531
- throw new CommandError(3, "session_required", "A current administrator session is required.", "Set ESIM_SESSION_COOKIE to your citizen session cookie.");
38573
+ const baseUrl = adminOrigin(options.env.baseUrl);
38574
+ const credentials = await readSavedCredential(baseUrl, store);
38575
+ if (!credentials) {
38576
+ throw new CommandError(3, "session_required", "A current CLI device login is required.", loginHint);
38532
38577
  }
38578
+ secret = credentials.token;
38533
38579
  const { fetch: fetch2, stdout, stderr, columns } = options;
38534
38580
  const transport = {
38535
38581
  fetch: fetch2,
38536
38582
  stdout,
38537
38583
  stderr,
38538
38584
  columns,
38539
- credentials: { cookie },
38540
- env: { baseUrl: adminOrigin(options.env.baseUrl), signal: options.env.signal },
38585
+ credentials,
38586
+ env: { baseUrl, signal: options.env.signal },
38541
38587
  apiUrlEnvVar: "ESIM_API_URL"
38542
38588
  };
38543
38589
  const result = await command.run({
@@ -38578,34 +38624,8 @@ ${command.summary}
38578
38624
  }
38579
38625
  }
38580
38626
 
38581
- // login-credentials.ts
38582
- var tokenSchema = string2().regex(/^esim_[A-Za-z0-9_-]+$/);
38583
- var credentialSchema = object({ apiUrl: string2(), token: tokenSchema });
38584
- async function resolveCredentials(env, apiUrl, store) {
38585
- if (env.ESIM_API_TOKEN)
38586
- return { token: env.ESIM_API_TOKEN };
38587
- if (env.ESIM_SESSION_COOKIE)
38588
- return { cookie: env.ESIM_SESSION_COOKIE };
38589
- const text = await store.read();
38590
- if (text === undefined)
38591
- return;
38592
- let stored;
38593
- try {
38594
- stored = JSON.parse(text);
38595
- } catch {
38596
- return;
38597
- }
38598
- const credentials = credentialSchema.safeParse(stored);
38599
- if (credentials.success && credentials.data.apiUrl === apiUrl)
38600
- return { token: credentials.data.token };
38601
- }
38602
- function saveCredentials(store, credentials) {
38603
- return store.write(JSON.stringify(credentials) + `
38604
- `);
38605
- }
38606
-
38607
38627
  // version.ts
38608
- var version2 = "2026.1202.214";
38628
+ var version2 = "2026.1202.215";
38609
38629
  var installKind = version2 === "dev" ? "source" : typeof ESIM_CLI_EXECUTABLE === "boolean" && ESIM_CLI_EXECUTABLE ? "executable" : "npm";
38610
38630
  var npmLatestUrl = "https://registry.npmjs.org/esim-cli/latest";
38611
38631
  var releaseVersion = /^\d+\.\d+\.\d+$/;
@@ -38668,8 +38688,8 @@ var identity = object({ citizen: object({ pid: string2().regex(/^[1-9][0-9]*$/),
38668
38688
  var noticeTimeout = 3000;
38669
38689
  var sleep = (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds));
38670
38690
  function apiOrigin(apiUrl) {
38671
- const url2 = URL.canParse(apiUrl) ? new URL(apiUrl) : undefined;
38672
- if (!url2 || !["http:", "https:"].includes(url2.protocol) || url2.username || url2.password) {
38691
+ const url2 = httpApiUrl(apiUrl);
38692
+ if (!url2) {
38673
38693
  throw new CommandError(2, "invalid_api_url", "Set ESIM_API_URL to an HTTP or HTTPS URL.", "");
38674
38694
  }
38675
38695
  return url2.origin;
@@ -38737,7 +38757,7 @@ Verification code: ${userCode}
38737
38757
  if (poll.data.status === "pending")
38738
38758
  continue;
38739
38759
  const { token } = poll.data;
38740
- await saveCredentials(executable.credentials, { apiUrl: options.env.baseUrl, token });
38760
+ await saveCredentials(executable.credentials, { apiUrl: apiOrigin(options.env.baseUrl), token });
38741
38761
  const operation = operations.get("me");
38742
38762
  if (!operation)
38743
38763
  invalidResponse();
@@ -38848,7 +38868,7 @@ async function runCommandLine(input, executable) {
38848
38868
  apiUrlEnvVar: "ESIM_API_URL"
38849
38869
  };
38850
38870
  if (isAdminInvocation(argv)) {
38851
- return runAdmin(name === "admin" ? args : ["--help", ...args.slice(1)], options, executable.env.ESIM_SESSION_COOKIE);
38871
+ return runAdmin(name === "admin" ? args : ["--help", ...args.slice(1)], options, executable.credentials);
38852
38872
  }
38853
38873
  try {
38854
38874
  if (name === "--version" && !args.filter((arg) => arg !== "--json").length) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esim-cli",
3
- "version": "2026.1202.214",
3
+ "version": "2026.1202.215",
4
4
  "description": "Command-line client and agent project for Open E-Sim",
5
5
  "type": "module",
6
6
  "license": "MIT",