axiam-sdk 1.0.0-alpha40 → 1.0.0-alpha41

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.
@@ -738,6 +738,7 @@ async function login(client, email, password) {
738
738
  } catch (err) {
739
739
  const setup = mfaSetupRequired(err);
740
740
  if (setup) return setup;
741
+ if (err instanceof AxiamError) throw err;
741
742
  const status = extractAxiosStatus(err);
742
743
  if (status !== void 0) {
743
744
  throw mapHttpStatusToError(status, extractErrorMessage(extractAxiosData(err)) ?? "login failed", {
@@ -757,6 +758,7 @@ async function verifyMfa(client, mfaToken, code) {
757
758
  await client.session.onAuthenticated?.();
758
759
  return loginSuccessToResult(response.data);
759
760
  } catch (err) {
761
+ if (err instanceof AxiamError) throw err;
760
762
  const status = extractAxiosStatus(err);
761
763
  if (status !== void 0) {
762
764
  throw mapHttpStatusToError(status, extractErrorMessage(extractAxiosData(err)) ?? "verifyMfa failed", {
@@ -773,6 +775,7 @@ async function refresh(client) {
773
775
  await client.session.axios.post(REFRESH_PATH, client.session.buildRefreshBody());
774
776
  await client.session.onAuthenticated?.();
775
777
  } catch (err) {
778
+ if (err instanceof AxiamError) throw err;
776
779
  const status = extractAxiosStatus(err);
777
780
  if (status !== void 0) {
778
781
  throw mapHttpStatusToError(status, extractErrorMessage(extractAxiosData(err)) ?? "refresh failed", {
@@ -788,6 +791,7 @@ async function logout(client) {
788
791
  try {
789
792
  await client.session.axios.post(LOGOUT_PATH, {});
790
793
  } catch (err) {
794
+ if (err instanceof AxiamError) throw err;
791
795
  const status = extractAxiosStatus(err);
792
796
  if (status !== void 0) {
793
797
  throw mapHttpStatusToError(status, extractErrorMessage(extractAxiosData(err)) ?? "logout failed", {
@@ -953,6 +957,9 @@ async function loginOpaque(client, usernameOrEmail, password) {
953
957
  ke3 = exchange.finish(started.ke2, started);
954
958
  } catch (err) {
955
959
  if (err instanceof NetworkError) throw err;
960
+ if (started.mode === "optional") {
961
+ return await login(client, usernameOrEmail, password);
962
+ }
956
963
  throw mapHttpStatusToError(401, "invalid credentials", { cause: err });
957
964
  }
958
965
  let response;