@fluid-app/fluid-cli 0.1.413 → 0.1.414

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.
@@ -190,9 +190,9 @@ const FLUID_API_ERROR = {
190
190
  code: "API_UNREACHABLE",
191
191
  message: "Could not reach the Fluid API"
192
192
  },
193
- UUID_NOT_FOUND: {
194
- code: "UUID_NOT_FOUND",
195
- message: "Verification session not found"
193
+ SIGN_IN_UNFINISHED: {
194
+ code: "SIGN_IN_UNFINISHED",
195
+ message: "This sign-in can't be finished. Check the shop and the address, then request a new code"
196
196
  },
197
197
  CODE_EXPIRED: {
198
198
  code: "CODE_EXPIRED",
@@ -204,7 +204,11 @@ const FLUID_API_ERROR = {
204
204
  },
205
205
  INVALID_CODE: {
206
206
  code: "INVALID_CODE",
207
- message: "Invalid verification code"
207
+ message: "Verification code is invalid, expired, already used, or locked after too many attempts"
208
+ },
209
+ CONTACT_MISSING: {
210
+ code: "CONTACT_MISSING",
211
+ message: "The code is right, but the email or phone it was sent to is no longer on this account. Ask the company's admin to restore it"
208
212
  },
209
213
  COMPANY_NOT_FOUND: {
210
214
  code: "COMPANY_NOT_FOUND",
@@ -330,10 +334,10 @@ async function confirmMfa(uuid, code, options = {}) {
330
334
  signInPath: data.sign_in_path === "identity" ? "identity" : "legacy"
331
335
  });
332
336
  }
333
- if (response.status === 404) return failure(createApiError(FLUID_API_ERROR.UUID_NOT_FOUND));
337
+ if (response.status === 404) return failure(createApiError(FLUID_API_ERROR.SIGN_IN_UNFINISHED));
334
338
  if (response.status === 410) return failure(createApiError(FLUID_API_ERROR.CODE_EXPIRED));
335
- if (response.status === 422) return failure(createApiError(FLUID_API_ERROR.INVALID_CODE));
336
339
  const body = await response.text();
340
+ if (response.status === 422) return failure(createApiError(namesVerificationChannel(body) ? FLUID_API_ERROR.CONTACT_MISSING : FLUID_API_ERROR.INVALID_CODE));
337
341
  if (response.status === 429) return failure(createApiError(FLUID_API_ERROR.RATE_LIMITED, `HTTP 429: ${body}`));
338
342
  return failure(createApiError(FLUID_API_ERROR.API_UNREACHABLE, `HTTP ${response.status}: ${body}`));
339
343
  } catch (err) {
@@ -480,6 +484,15 @@ function signupError(template, extra = {}) {
480
484
  function asRecord(value) {
481
485
  return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
482
486
  }
487
+ /** Whether a confirm 422 body names the verification channel. */
488
+ function namesVerificationChannel(body) {
489
+ try {
490
+ const errors = asRecord(asRecord(JSON.parse(body))?.errors);
491
+ return errors !== void 0 && fieldMessages(errors, "multi_factor_authentication", "verification_channel").length > 0;
492
+ } catch {
493
+ return false;
494
+ }
495
+ }
483
496
  function fieldMessages(errors, record, field) {
484
497
  const messages = asRecord(errors[record])?.[field];
485
498
  return Array.isArray(messages) ? messages.filter((m) => typeof m === "string") : [];
@@ -3787,4 +3800,4 @@ function exitOnInputsError(error, io = processIo) {
3787
3800
  //#endregion
3788
3801
  export { isNodeError as $, primeIdentityProfile as A, SIGNUP_ERROR as B, updateConfig as C, getConfigFilePath as D, getConfigDir as E, resolveIdentityUrl as F, sendMfa as G, fetchUserCompanies as H, createFetchClient as I, validateToken as J, signup as K, createDefaultConfig as L, sessionFacts as M, signInWithBrowser as N, describeIdentityError as O, signOutIdentity as P, isFailure as Q, isIdentityProfile as R, readConfig as S, isStrictConfig as T, getFluidApiBase as U, confirmMfa as V, redeemIdentityLink as W, getErrorMessage$1 as X, failure as Y, isError as Z, getAuthToken as _, INPUTS_UNDECLARED_CODE as a, tryCatchAsync as at, resolveCredentialSource as b, inputsModeActive as c, filterCatalog as ct, setActiveSnapshot as d, visibleSubcommands as dt, isSuccess as et, inInternalRead as f, walkCommands as ft, getActiveProfile as g, declareInputs as h, INPUTS_MODE_ENV as i, tryCatch as it, profileAccessToken as j, identityToken as k, registerInputsHook as l, rootCommand as lt, withInternalReadsAsync as m, INPUTS_MISMATCH_CODE as n, mapResult as nt, INPUTS_UNDECLARED_EXIT as o, unwrap as ot, withInternalReads as p, describeCommand as pt, switchCompany as q, INPUTS_MISMATCH_EXIT as r, success as rt, exitOnInputsError as s, unwrapOr as st, INPUTS_EXPECT_ENV as t, mapError as tt, createInputsReader as u, visibleOptions as ut, getAuthTokenAsync as v, writeConfig as w, findProjectConfig as x, listProfileNames as y, FLUID_API_ERROR as z };
3789
3802
 
3790
- //# sourceMappingURL=hook-jDkZbqMt.mjs.map
3803
+ //# sourceMappingURL=hook-Cpk6jCiV.mjs.map