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.js CHANGED
@@ -729,6 +729,7 @@ async function login(client, email, password) {
729
729
  } catch (err) {
730
730
  const setup = mfaSetupRequired(err);
731
731
  if (setup) return setup;
732
+ if (err instanceof AxiamError) throw err;
732
733
  const status = extractAxiosStatus(err);
733
734
  if (status !== void 0) {
734
735
  throw mapHttpStatusToError(status, extractErrorMessage(extractAxiosData(err)) ?? "login failed", {
@@ -748,6 +749,7 @@ async function verifyMfa(client, mfaToken, code) {
748
749
  await client.session.onAuthenticated?.();
749
750
  return loginSuccessToResult(response.data);
750
751
  } catch (err) {
752
+ if (err instanceof AxiamError) throw err;
751
753
  const status = extractAxiosStatus(err);
752
754
  if (status !== void 0) {
753
755
  throw mapHttpStatusToError(status, extractErrorMessage(extractAxiosData(err)) ?? "verifyMfa failed", {
@@ -764,6 +766,7 @@ async function refresh(client) {
764
766
  await client.session.axios.post(REFRESH_PATH, client.session.buildRefreshBody());
765
767
  await client.session.onAuthenticated?.();
766
768
  } catch (err) {
769
+ if (err instanceof AxiamError) throw err;
767
770
  const status = extractAxiosStatus(err);
768
771
  if (status !== void 0) {
769
772
  throw mapHttpStatusToError(status, extractErrorMessage(extractAxiosData(err)) ?? "refresh failed", {
@@ -779,6 +782,7 @@ async function logout(client) {
779
782
  try {
780
783
  await client.session.axios.post(LOGOUT_PATH, {});
781
784
  } catch (err) {
785
+ if (err instanceof AxiamError) throw err;
782
786
  const status = extractAxiosStatus(err);
783
787
  if (status !== void 0) {
784
788
  throw mapHttpStatusToError(status, extractErrorMessage(extractAxiosData(err)) ?? "logout failed", {
@@ -944,6 +948,9 @@ async function loginOpaque(client, usernameOrEmail, password) {
944
948
  ke3 = exchange.finish(started.ke2, started);
945
949
  } catch (err) {
946
950
  if (err instanceof NetworkError) throw err;
951
+ if (started.mode === "optional") {
952
+ return await login(client, usernameOrEmail, password);
953
+ }
947
954
  throw mapHttpStatusToError(401, "invalid credentials", { cause: err });
948
955
  }
949
956
  let response;