@stokr/components-library 3.0.43 → 3.0.45

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.
@@ -1,6 +1,7 @@
1
1
  import Cookies from "js-cookie";
2
2
  import axios from "axios";
3
3
  import axiosInstance from "../model/axios.js";
4
+ import axiosInstance$1 from "../model/axiosPublic.js";
4
5
  import getCookieDomain from "../utils/get-cookie-domain.js";
5
6
  import { getLastFirebaseConfig } from "../config.js";
6
7
  import { initFirebase, getFirebaseAuth } from "../firebase-config.js";
@@ -134,6 +135,15 @@ class Auth {
134
135
  });
135
136
  });
136
137
  }
138
+ static reportFailedLoginAttempt(email) {
139
+ return new Promise((resolve, reject) => {
140
+ axiosInstance$1.post(`auth/failed-login-attempt`, { email }).then((response) => {
141
+ resolve(response.data);
142
+ }).catch((err) => {
143
+ reject(err);
144
+ });
145
+ });
146
+ }
137
147
  static resendActivationEmail(email) {
138
148
  return new Promise((resolve, reject) => {
139
149
  axiosInstance.post(`auth/resend-activation-email`, {
@@ -124,11 +124,13 @@ class AuthProviderClass extends Component {
124
124
  if (!expiresAt) return;
125
125
  const delay = expiresAt - Date.now();
126
126
  if (delay <= 0) {
127
+ Auth.logout();
127
128
  this.setState({ sessionExpiryPendingReason: "cookie" });
128
129
  return;
129
130
  }
130
131
  this.cookieExpiryTimerRef = setTimeout(() => {
131
132
  this.cookieExpiryTimerRef = null;
133
+ Auth.logout();
132
134
  this.setState({ sessionExpiryPendingReason: "cookie" });
133
135
  }, delay);
134
136
  };
@@ -176,6 +178,7 @@ class AuthProviderClass extends Component {
176
178
  const delay = this.getInactivityTimeMs();
177
179
  this.inactivityTimerRef = setTimeout(() => {
178
180
  this.inactivityTimerRef = null;
181
+ Auth.logout();
179
182
  this.setState({ sessionExpiryPendingReason: "inactivity" });
180
183
  }, delay);
181
184
  }
@@ -222,8 +225,18 @@ class AuthProviderClass extends Component {
222
225
  break;
223
226
  case "auth/invalid-login-credentials":
224
227
  case "auth/invalid-credential":
228
+ if (email) {
229
+ Auth.reportFailedLoginAttempt(email).catch(() => {
230
+ });
231
+ }
225
232
  error.message = "The credentials are not correct. Try again?";
226
233
  throw error;
234
+ case "auth/user-disabled":
235
+ error.message = "Your account has been locked due to too many failed login attempts. Please contact support at support.stokr.io to reactivate.";
236
+ throw error;
237
+ case "auth/too-many-requests":
238
+ error.message = "Too many sign-in attempts. Please wait a few minutes before trying again.";
239
+ throw error;
227
240
  case "auth/invalid-custom-token":
228
241
  case "auth/argument-error":
229
242
  error.message = "This sign-in link is invalid, expired, or was already used. Please sign in again or request a new link.";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stokr/components-library",
3
- "version": "3.0.43",
3
+ "version": "3.0.45",
4
4
  "description": "STOKR - Components Library",
5
5
  "author": "Bilal Hodzic <bilal@stokr.io>",
6
6
  "license": "MIT",