axiam-sdk 1.0.0-alpha40 → 1.0.0-alpha43

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.
@@ -991,6 +991,7 @@ async function login(client, email, password) {
991
991
  } catch (err) {
992
992
  const setup = mfaSetupRequired(err);
993
993
  if (setup) return setup;
994
+ if (err instanceof AxiamError) throw err;
994
995
  const status = extractAxiosStatus(err);
995
996
  if (status !== void 0) {
996
997
  throw mapHttpStatusToError(status, extractErrorMessage(extractAxiosData(err)) ?? "login failed", {
@@ -1010,6 +1011,7 @@ async function verifyMfa(client, mfaToken, code) {
1010
1011
  await client.session.onAuthenticated?.();
1011
1012
  return loginSuccessToResult(response.data);
1012
1013
  } catch (err) {
1014
+ if (err instanceof AxiamError) throw err;
1013
1015
  const status = extractAxiosStatus(err);
1014
1016
  if (status !== void 0) {
1015
1017
  throw mapHttpStatusToError(status, extractErrorMessage(extractAxiosData(err)) ?? "verifyMfa failed", {
@@ -1026,6 +1028,7 @@ async function refresh(client) {
1026
1028
  await client.session.axios.post(REFRESH_PATH, client.session.buildRefreshBody());
1027
1029
  await client.session.onAuthenticated?.();
1028
1030
  } catch (err) {
1031
+ if (err instanceof AxiamError) throw err;
1029
1032
  const status = extractAxiosStatus(err);
1030
1033
  if (status !== void 0) {
1031
1034
  throw mapHttpStatusToError(status, extractErrorMessage(extractAxiosData(err)) ?? "refresh failed", {
@@ -1041,6 +1044,7 @@ async function logout(client) {
1041
1044
  try {
1042
1045
  await client.session.axios.post(LOGOUT_PATH, {});
1043
1046
  } catch (err) {
1047
+ if (err instanceof AxiamError) throw err;
1044
1048
  const status = extractAxiosStatus(err);
1045
1049
  if (status !== void 0) {
1046
1050
  throw mapHttpStatusToError(status, extractErrorMessage(extractAxiosData(err)) ?? "logout failed", {
@@ -1206,6 +1210,9 @@ async function loginOpaque(client, usernameOrEmail, password) {
1206
1210
  ke3 = exchange.finish(started.ke2, started);
1207
1211
  } catch (err) {
1208
1212
  if (err instanceof NetworkError) throw err;
1213
+ if (started.mode === "optional") {
1214
+ return await login(client, usernameOrEmail, password);
1215
+ }
1209
1216
  throw mapHttpStatusToError(401, "invalid credentials", { cause: err });
1210
1217
  }
1211
1218
  let response;