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.
package/dist/index.mjs CHANGED
@@ -723,6 +723,7 @@ async function login(client, email, password) {
723
723
  } catch (err) {
724
724
  const setup = mfaSetupRequired(err);
725
725
  if (setup) return setup;
726
+ if (err instanceof AxiamError) throw err;
726
727
  const status = extractAxiosStatus(err);
727
728
  if (status !== void 0) {
728
729
  throw mapHttpStatusToError(status, extractErrorMessage(extractAxiosData(err)) ?? "login failed", {
@@ -742,6 +743,7 @@ async function verifyMfa(client, mfaToken, code) {
742
743
  await client.session.onAuthenticated?.();
743
744
  return loginSuccessToResult(response.data);
744
745
  } catch (err) {
746
+ if (err instanceof AxiamError) throw err;
745
747
  const status = extractAxiosStatus(err);
746
748
  if (status !== void 0) {
747
749
  throw mapHttpStatusToError(status, extractErrorMessage(extractAxiosData(err)) ?? "verifyMfa failed", {
@@ -758,6 +760,7 @@ async function refresh(client) {
758
760
  await client.session.axios.post(REFRESH_PATH, client.session.buildRefreshBody());
759
761
  await client.session.onAuthenticated?.();
760
762
  } catch (err) {
763
+ if (err instanceof AxiamError) throw err;
761
764
  const status = extractAxiosStatus(err);
762
765
  if (status !== void 0) {
763
766
  throw mapHttpStatusToError(status, extractErrorMessage(extractAxiosData(err)) ?? "refresh failed", {
@@ -773,6 +776,7 @@ async function logout(client) {
773
776
  try {
774
777
  await client.session.axios.post(LOGOUT_PATH, {});
775
778
  } catch (err) {
779
+ if (err instanceof AxiamError) throw err;
776
780
  const status = extractAxiosStatus(err);
777
781
  if (status !== void 0) {
778
782
  throw mapHttpStatusToError(status, extractErrorMessage(extractAxiosData(err)) ?? "logout failed", {
@@ -938,6 +942,9 @@ async function loginOpaque(client, usernameOrEmail, password) {
938
942
  ke3 = exchange.finish(started.ke2, started);
939
943
  } catch (err) {
940
944
  if (err instanceof NetworkError) throw err;
945
+ if (started.mode === "optional") {
946
+ return await login(client, usernameOrEmail, password);
947
+ }
941
948
  throw mapHttpStatusToError(401, "invalid credentials", { cause: err });
942
949
  }
943
950
  let response;