@youkno/edge-cli 1.21.342 → 1.21.344

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.
@@ -14,7 +14,7 @@ function registerLogin(program) {
14
14
  const opts = (parent?.opts() ?? {});
15
15
  const cfg = await (0, config_1.resolveEffectiveConfig)(opts);
16
16
  // --client selects the company to sign in as, here and only here: the explicit login.
17
- const email = await (0, auth_1.login)({ ...cfg, exchangeClientId: opts.clientId?.trim() || undefined });
17
+ const email = await (0, auth_1.login)({ ...cfg, exchangeClientId: (opts.client ?? opts.clientId)?.trim() || undefined });
18
18
  process.stdout.write(`Successfully authenticated as ${email}\n`);
19
19
  if (this.opts().shell) {
20
20
  await (0, shell_1.repl)(cfg, {});
package/dist/lib/auth.js CHANGED
@@ -242,11 +242,12 @@ function asShellAuthMethodError(err, hint) {
242
242
  }
243
243
  /**
244
244
  * The server's `errorCode`s for an exchange whose subject cannot be selected. Mirror
245
- * `ApiErrorCode.NOT_A_MEMBER`, `VULGUS_NOT_SELECTABLE` and `VIRTUAL_CREDENTIAL_REFUSED`.
245
+ * `ApiErrorCode.NOT_A_MEMBER`, `VULGUS_NOT_SELECTABLE`, `VIRTUAL_CREDENTIAL_REFUSED` and `COMPANY_REQUIRED`.
246
246
  */
247
247
  const ERROR_CODE_NOT_A_MEMBER = 403012;
248
248
  const ERROR_CODE_VULGUS_NOT_SELECTABLE = 400006;
249
249
  const ERROR_CODE_VIRTUAL_CREDENTIAL_REFUSED = 400007;
250
+ const ERROR_CODE_COMPANY_REQUIRED = 400008;
250
251
  /**
251
252
  * A `--client` refusal as an error that says what to do, or undefined when this failure is
252
253
  * something else. Matched on errorCode, never on the prose.
@@ -262,6 +263,9 @@ function asCompanySelectionError(err, cfg) {
262
263
  case ERROR_CODE_VULGUS_NOT_SELECTABLE:
263
264
  return new Error(`Login failed: --client ${cfg.exchangeClientId} is the Vulgus company, ` +
264
265
  `which is your own account. Omit --client.`, { cause: err });
266
+ case ERROR_CODE_COMPANY_REQUIRED:
267
+ return new Error("Login failed: this account works for more than one company, so one has to be " +
268
+ "chosen. Sign in with --client=<company id or pin>.", { cause: err });
265
269
  case ERROR_CODE_VIRTUAL_CREDENTIAL_REFUSED:
266
270
  return new Error("Login failed: the console handed over a company session's Firebase token. " +
267
271
  "It must hand over the person's own Firebase token, not the company session's; " +
@@ -195,7 +195,7 @@ async function resolveEffectiveConfig(options) {
195
195
  env,
196
196
  baseUrl,
197
197
  consoleBaseUrl: resolveConsoleBaseUrl(product, env, productsConfig),
198
- clientId: options.clientId ?? merged.CLIENT_ID,
198
+ clientId: options.client ?? options.clientId ?? merged.CLIENT_ID,
199
199
  configFiles: usedFiles
200
200
  };
201
201
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@youkno/edge-cli",
3
- "version": "1.21.342",
3
+ "version": "1.21.344",
4
4
  "description": "Cross-platform Edge CLI",
5
5
  "bin": "dist/index.js",
6
6
  "publishConfig": {
@@ -15,7 +15,7 @@ export function registerLogin(program: Command): void {
15
15
  const opts = (parent?.opts() ?? {}) as CliOptions;
16
16
  const cfg = await resolveEffectiveConfig(opts);
17
17
  // --client selects the company to sign in as, here and only here: the explicit login.
18
- const email = await login({ ...cfg, exchangeClientId: opts.clientId?.trim() || undefined });
18
+ const email = await login({ ...cfg, exchangeClientId: (opts.client ?? opts.clientId)?.trim() || undefined });
19
19
  process.stdout.write(`Successfully authenticated as ${email}\n`);
20
20
  if (this.opts<{ shell?: boolean }>().shell) {
21
21
  await repl(cfg, {});
package/src/lib/auth.ts CHANGED
@@ -295,11 +295,12 @@ function asShellAuthMethodError(err: unknown, hint: string): ShellAuthMethodErro
295
295
 
296
296
  /**
297
297
  * The server's `errorCode`s for an exchange whose subject cannot be selected. Mirror
298
- * `ApiErrorCode.NOT_A_MEMBER`, `VULGUS_NOT_SELECTABLE` and `VIRTUAL_CREDENTIAL_REFUSED`.
298
+ * `ApiErrorCode.NOT_A_MEMBER`, `VULGUS_NOT_SELECTABLE`, `VIRTUAL_CREDENTIAL_REFUSED` and `COMPANY_REQUIRED`.
299
299
  */
300
300
  const ERROR_CODE_NOT_A_MEMBER = 403012;
301
301
  const ERROR_CODE_VULGUS_NOT_SELECTABLE = 400006;
302
302
  const ERROR_CODE_VIRTUAL_CREDENTIAL_REFUSED = 400007;
303
+ const ERROR_CODE_COMPANY_REQUIRED = 400008;
303
304
 
304
305
  /**
305
306
  * A `--client` refusal as an error that says what to do, or undefined when this failure is
@@ -316,6 +317,9 @@ function asCompanySelectionError(err: unknown, cfg: EffectiveConfig): Error | un
316
317
  case ERROR_CODE_VULGUS_NOT_SELECTABLE:
317
318
  return new Error(`Login failed: --client ${cfg.exchangeClientId} is the Vulgus company, ` +
318
319
  `which is your own account. Omit --client.`, { cause: err });
320
+ case ERROR_CODE_COMPANY_REQUIRED:
321
+ return new Error("Login failed: this account works for more than one company, so one has to be " +
322
+ "chosen. Sign in with --client=<company id or pin>.", { cause: err });
319
323
  case ERROR_CODE_VIRTUAL_CREDENTIAL_REFUSED:
320
324
  return new Error("Login failed: the console handed over a company session's Firebase token. " +
321
325
  "It must hand over the person's own Firebase token, not the company session's; " +
package/src/lib/config.ts CHANGED
@@ -228,7 +228,7 @@ export async function resolveEffectiveConfig(options: CliOptions): Promise<Effec
228
228
  env,
229
229
  baseUrl,
230
230
  consoleBaseUrl: resolveConsoleBaseUrl(product, env, productsConfig),
231
- clientId: options.clientId ?? merged.CLIENT_ID,
231
+ clientId: options.client ?? options.clientId ?? merged.CLIENT_ID,
232
232
  configFiles: usedFiles
233
233
  };
234
234
  }
package/src/lib/types.ts CHANGED
@@ -4,6 +4,12 @@ export type CliOptions = {
4
4
  product?: string;
5
5
  env?: CliEnv;
6
6
  baseUrl?: string;
7
+ /**
8
+ * `--client`. Commander stores a flag under the flag's own name, whatever the placeholder says
9
+ * (`--client <clientId>` -> `client`), so this is read as `client`; `clientId` stays for callers
10
+ * that build options by hand.
11
+ */
12
+ client?: string;
7
13
  clientId?: string;
8
14
  configPath?: string;
9
15
  };