@bagelink/auth 1.5.17 → 1.5.20

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.cjs CHANGED
@@ -47,7 +47,7 @@ class EventEmitter {
47
47
  }
48
48
  }
49
49
  function queryParams() {
50
- if (typeof window === "undefined" || !window.location?.search) {
50
+ if ("undefined" === typeof window || !window.location?.search) {
51
51
  return {};
52
52
  }
53
53
  const params = new URLSearchParams(window.location.search);
@@ -68,7 +68,7 @@ class AuthApi {
68
68
  this.api.interceptors.request.use((config) => {
69
69
  const urlParams = new URLSearchParams(window.location.search);
70
70
  const resetToken = urlParams.get("token");
71
- if (resetToken !== null && config.headers) {
71
+ if (null !== resetToken && config.headers) {
72
72
  config.headers["X-Reset-Token"] = resetToken;
73
73
  }
74
74
  return config;
@@ -350,9 +350,13 @@ function waitForPopupCallback(popup, provider, timeoutMs = 9e4) {
350
350
  }, timeoutMs);
351
351
  function onMessage(ev) {
352
352
  try {
353
- if (ev.origin !== window.location.origin) return;
353
+ if (ev.origin !== window.location.origin) {
354
+ return;
355
+ }
354
356
  const data = ev.data || {};
355
- if (data.type !== "auth:complete" || data.provider !== provider) return;
357
+ if ("auth:complete" !== data.type || data.provider !== provider) {
358
+ return;
359
+ }
356
360
  cleanup();
357
361
  if (data.error) {
358
362
  reject(new SSOError(data.error, "OAUTH_ERROR"));
@@ -406,7 +410,7 @@ function waitForPopupCallback(popup, provider, timeoutMs = 9e4) {
406
410
  }
407
411
  function createSSOProvider(config) {
408
412
  const getDefaultRedirectUri = () => {
409
- if (typeof window !== "undefined") {
413
+ if ("undefined" !== typeof window) {
410
414
  return `${window.location.origin}/auth/callback`;
411
415
  }
412
416
  return `/auth/callback`;
@@ -418,7 +422,7 @@ function createSSOProvider(config) {
418
422
  const auth = getAuthApi();
419
423
  const redirectUri = options.redirectUri ?? getDefaultRedirectUri();
420
424
  const state = options.state ?? generateState();
421
- if (typeof sessionStorage !== "undefined") {
425
+ if ("undefined" !== typeof sessionStorage) {
422
426
  sessionStorage.setItem(getStateKey(), state);
423
427
  sessionStorage.setItem(`oauth_provider:${state}`, config.id);
424
428
  }
@@ -436,7 +440,7 @@ function createSSOProvider(config) {
436
440
  const redirectUri = options.redirectUri ?? getDefaultRedirectUri();
437
441
  const state = options.state ?? generateState();
438
442
  const timeout = options.popupTimeout ?? 9e4;
439
- if (typeof sessionStorage !== "undefined") {
443
+ if ("undefined" !== typeof sessionStorage) {
440
444
  sessionStorage.setItem(getStateKey(), state);
441
445
  sessionStorage.setItem(`oauth_provider:${state}`, config.id);
442
446
  }
@@ -461,7 +465,7 @@ function createSSOProvider(config) {
461
465
  },
462
466
  async callback(code, state) {
463
467
  const auth = getAuthApi();
464
- if (typeof sessionStorage !== "undefined" && state) {
468
+ if ("undefined" !== typeof sessionStorage && state) {
465
469
  const storedState = sessionStorage.getItem(getStateKey());
466
470
  sessionStorage.removeItem(getStateKey());
467
471
  sessionStorage.removeItem(`oauth_provider:${state}`);
@@ -477,7 +481,7 @@ function createSSOProvider(config) {
477
481
  },
478
482
  async link(code, state) {
479
483
  const auth = getAuthApi();
480
- if (typeof sessionStorage !== "undefined" && state) {
484
+ if ("undefined" !== typeof sessionStorage && state) {
481
485
  const storedState = sessionStorage.getItem(getStateKey());
482
486
  sessionStorage.removeItem(getStateKey());
483
487
  sessionStorage.removeItem(`oauth_provider:${state}`);
@@ -679,7 +683,9 @@ var AuthState = /* @__PURE__ */ ((AuthState2) => {
679
683
  return AuthState2;
680
684
  })(AuthState || {});
681
685
  function accountToUser(account) {
682
- if (account === null) return null;
686
+ if (null === account) {
687
+ return null;
688
+ }
683
689
  if (account.person !== void 0) {
684
690
  return {
685
691
  id: account.person.id,
@@ -708,7 +714,7 @@ function accountToUser(account) {
708
714
  };
709
715
  }
710
716
  const emailMethod = account.authentication_methods.find(
711
- (m) => m.type === "password" || m.type === "email_token"
717
+ (m) => "password" === m.type || "email_token" === m.type
712
718
  );
713
719
  return {
714
720
  id: account.id,
@@ -728,10 +734,10 @@ const accountInfo = vue.ref(null);
728
734
  function initAuth({
729
735
  baseURL
730
736
  }) {
731
- if (authApi === null) {
737
+ if (null === authApi) {
732
738
  authApi = new AuthApi(baseURL);
733
739
  }
734
- if (eventEmitter === null) {
740
+ if (null === eventEmitter) {
735
741
  eventEmitter = new EventEmitter();
736
742
  }
737
743
  return {
@@ -757,10 +763,10 @@ function initAuth({
757
763
  };
758
764
  }
759
765
  function useAuth() {
760
- if (authApi === null) {
766
+ if (null === authApi) {
761
767
  throw new Error("Auth not initialized. Call initAuth first.");
762
768
  }
763
- if (eventEmitter === null) {
769
+ if (null === eventEmitter) {
764
770
  throw new Error("Event emitter not initialized. Call initAuth first.");
765
771
  }
766
772
  const api = authApi;
@@ -772,7 +778,7 @@ function useAuth() {
772
778
  },
773
779
  loginWithSSO: async (params) => {
774
780
  const { data } = await api.ssoCallback(params);
775
- if (data.success === true && data.requires_verification !== true) {
781
+ if (true === data.success && true !== data.requires_verification) {
776
782
  await checkAuth();
777
783
  }
778
784
  emitter.emit(AuthState.LOGIN);
@@ -793,7 +799,7 @@ function useAuth() {
793
799
  return user.value?.name ?? "";
794
800
  };
795
801
  const getIsLoggedIn = () => {
796
- return user.value !== null;
802
+ return null !== user.value;
797
803
  };
798
804
  const getEmail = () => {
799
805
  return user.value?.email ?? "";
@@ -805,10 +811,10 @@ function useAuth() {
805
811
  return user.value?.type ?? "person";
806
812
  };
807
813
  const isPersonAccount = () => {
808
- return user.value?.type === "person";
814
+ return "person" === user.value?.type;
809
815
  };
810
816
  const isEntityAccount = () => {
811
- return user.value?.type === "entity";
817
+ return "entity" === user.value?.type;
812
818
  };
813
819
  async function logout() {
814
820
  const logoutPromise = api.logout();
@@ -822,7 +828,7 @@ function useAuth() {
822
828
  credentials.email.toLowerCase(),
823
829
  credentials.password
824
830
  );
825
- if (data.success === true && data.requires_verification !== true) {
831
+ if (true === data.success && true !== data.requires_verification) {
826
832
  await checkAuth();
827
833
  }
828
834
  emitter.emit(AuthState.LOGIN);
@@ -842,7 +848,7 @@ function useAuth() {
842
848
  }
843
849
  }
844
850
  async function signup(newUser) {
845
- const hasPassword = newUser.password !== void 0 && newUser.password.length > 0;
851
+ const hasPassword = newUser.password !== void 0 && 0 < newUser.password.length;
846
852
  if (hasPassword && newUser.password !== newUser.confirmPassword) {
847
853
  throw new Error("Passwords do not match");
848
854
  }
@@ -853,7 +859,7 @@ function useAuth() {
853
859
  phone_number: newUser.phone_number,
854
860
  password: newUser.password
855
861
  });
856
- if (data.success === true && data.requires_verification !== true) {
862
+ if (true === data.success && true !== data.requires_verification) {
857
863
  await checkAuth();
858
864
  }
859
865
  emitter.emit(AuthState.SIGNUP);
@@ -911,7 +917,7 @@ function useAuth() {
911
917
  }
912
918
  async function getSessions(accountId) {
913
919
  const id = accountId ?? user.value?.accountId;
914
- if (id === void 0 || id === "") {
920
+ if (id === void 0 || "" === id) {
915
921
  throw new Error("No account ID available");
916
922
  }
917
923
  return api.getSessions(id);
@@ -921,7 +927,7 @@ function useAuth() {
921
927
  }
922
928
  async function revokeAllSessions(accountId) {
923
929
  const id = accountId ?? user.value?.accountId;
924
- if (id === void 0 || id === "") {
930
+ if (id === void 0 || "" === id) {
925
931
  throw new Error("No account ID available");
926
932
  }
927
933
  await api.revokeAllSessions(id);
@@ -932,7 +938,7 @@ function useAuth() {
932
938
  }
933
939
  async function loginWithSSO(params) {
934
940
  const { data } = await api.ssoCallback(params);
935
- if (data.success === true && data.requires_verification !== true) {
941
+ if (true === data.success && true !== data.requires_verification) {
936
942
  await checkAuth();
937
943
  }
938
944
  emitter.emit(AuthState.LOGIN);
package/dist/index.mjs CHANGED
@@ -41,7 +41,7 @@ class EventEmitter {
41
41
  }
42
42
  }
43
43
  function queryParams() {
44
- if (typeof window === "undefined" || !window.location?.search) {
44
+ if ("undefined" === typeof window || !window.location?.search) {
45
45
  return {};
46
46
  }
47
47
  const params = new URLSearchParams(window.location.search);
@@ -62,7 +62,7 @@ class AuthApi {
62
62
  this.api.interceptors.request.use((config) => {
63
63
  const urlParams = new URLSearchParams(window.location.search);
64
64
  const resetToken = urlParams.get("token");
65
- if (resetToken !== null && config.headers) {
65
+ if (null !== resetToken && config.headers) {
66
66
  config.headers["X-Reset-Token"] = resetToken;
67
67
  }
68
68
  return config;
@@ -344,9 +344,13 @@ function waitForPopupCallback(popup, provider, timeoutMs = 9e4) {
344
344
  }, timeoutMs);
345
345
  function onMessage(ev) {
346
346
  try {
347
- if (ev.origin !== window.location.origin) return;
347
+ if (ev.origin !== window.location.origin) {
348
+ return;
349
+ }
348
350
  const data = ev.data || {};
349
- if (data.type !== "auth:complete" || data.provider !== provider) return;
351
+ if ("auth:complete" !== data.type || data.provider !== provider) {
352
+ return;
353
+ }
350
354
  cleanup();
351
355
  if (data.error) {
352
356
  reject(new SSOError(data.error, "OAUTH_ERROR"));
@@ -400,7 +404,7 @@ function waitForPopupCallback(popup, provider, timeoutMs = 9e4) {
400
404
  }
401
405
  function createSSOProvider(config) {
402
406
  const getDefaultRedirectUri = () => {
403
- if (typeof window !== "undefined") {
407
+ if ("undefined" !== typeof window) {
404
408
  return `${window.location.origin}/auth/callback`;
405
409
  }
406
410
  return `/auth/callback`;
@@ -412,7 +416,7 @@ function createSSOProvider(config) {
412
416
  const auth = getAuthApi();
413
417
  const redirectUri = options.redirectUri ?? getDefaultRedirectUri();
414
418
  const state = options.state ?? generateState();
415
- if (typeof sessionStorage !== "undefined") {
419
+ if ("undefined" !== typeof sessionStorage) {
416
420
  sessionStorage.setItem(getStateKey(), state);
417
421
  sessionStorage.setItem(`oauth_provider:${state}`, config.id);
418
422
  }
@@ -430,7 +434,7 @@ function createSSOProvider(config) {
430
434
  const redirectUri = options.redirectUri ?? getDefaultRedirectUri();
431
435
  const state = options.state ?? generateState();
432
436
  const timeout = options.popupTimeout ?? 9e4;
433
- if (typeof sessionStorage !== "undefined") {
437
+ if ("undefined" !== typeof sessionStorage) {
434
438
  sessionStorage.setItem(getStateKey(), state);
435
439
  sessionStorage.setItem(`oauth_provider:${state}`, config.id);
436
440
  }
@@ -455,7 +459,7 @@ function createSSOProvider(config) {
455
459
  },
456
460
  async callback(code, state) {
457
461
  const auth = getAuthApi();
458
- if (typeof sessionStorage !== "undefined" && state) {
462
+ if ("undefined" !== typeof sessionStorage && state) {
459
463
  const storedState = sessionStorage.getItem(getStateKey());
460
464
  sessionStorage.removeItem(getStateKey());
461
465
  sessionStorage.removeItem(`oauth_provider:${state}`);
@@ -471,7 +475,7 @@ function createSSOProvider(config) {
471
475
  },
472
476
  async link(code, state) {
473
477
  const auth = getAuthApi();
474
- if (typeof sessionStorage !== "undefined" && state) {
478
+ if ("undefined" !== typeof sessionStorage && state) {
475
479
  const storedState = sessionStorage.getItem(getStateKey());
476
480
  sessionStorage.removeItem(getStateKey());
477
481
  sessionStorage.removeItem(`oauth_provider:${state}`);
@@ -673,7 +677,9 @@ var AuthState = /* @__PURE__ */ ((AuthState2) => {
673
677
  return AuthState2;
674
678
  })(AuthState || {});
675
679
  function accountToUser(account) {
676
- if (account === null) return null;
680
+ if (null === account) {
681
+ return null;
682
+ }
677
683
  if (account.person !== void 0) {
678
684
  return {
679
685
  id: account.person.id,
@@ -702,7 +708,7 @@ function accountToUser(account) {
702
708
  };
703
709
  }
704
710
  const emailMethod = account.authentication_methods.find(
705
- (m) => m.type === "password" || m.type === "email_token"
711
+ (m) => "password" === m.type || "email_token" === m.type
706
712
  );
707
713
  return {
708
714
  id: account.id,
@@ -722,10 +728,10 @@ const accountInfo = ref(null);
722
728
  function initAuth({
723
729
  baseURL
724
730
  }) {
725
- if (authApi === null) {
731
+ if (null === authApi) {
726
732
  authApi = new AuthApi(baseURL);
727
733
  }
728
- if (eventEmitter === null) {
734
+ if (null === eventEmitter) {
729
735
  eventEmitter = new EventEmitter();
730
736
  }
731
737
  return {
@@ -751,10 +757,10 @@ function initAuth({
751
757
  };
752
758
  }
753
759
  function useAuth() {
754
- if (authApi === null) {
760
+ if (null === authApi) {
755
761
  throw new Error("Auth not initialized. Call initAuth first.");
756
762
  }
757
- if (eventEmitter === null) {
763
+ if (null === eventEmitter) {
758
764
  throw new Error("Event emitter not initialized. Call initAuth first.");
759
765
  }
760
766
  const api = authApi;
@@ -766,7 +772,7 @@ function useAuth() {
766
772
  },
767
773
  loginWithSSO: async (params) => {
768
774
  const { data } = await api.ssoCallback(params);
769
- if (data.success === true && data.requires_verification !== true) {
775
+ if (true === data.success && true !== data.requires_verification) {
770
776
  await checkAuth();
771
777
  }
772
778
  emitter.emit(AuthState.LOGIN);
@@ -787,7 +793,7 @@ function useAuth() {
787
793
  return user.value?.name ?? "";
788
794
  };
789
795
  const getIsLoggedIn = () => {
790
- return user.value !== null;
796
+ return null !== user.value;
791
797
  };
792
798
  const getEmail = () => {
793
799
  return user.value?.email ?? "";
@@ -799,10 +805,10 @@ function useAuth() {
799
805
  return user.value?.type ?? "person";
800
806
  };
801
807
  const isPersonAccount = () => {
802
- return user.value?.type === "person";
808
+ return "person" === user.value?.type;
803
809
  };
804
810
  const isEntityAccount = () => {
805
- return user.value?.type === "entity";
811
+ return "entity" === user.value?.type;
806
812
  };
807
813
  async function logout() {
808
814
  const logoutPromise = api.logout();
@@ -816,7 +822,7 @@ function useAuth() {
816
822
  credentials.email.toLowerCase(),
817
823
  credentials.password
818
824
  );
819
- if (data.success === true && data.requires_verification !== true) {
825
+ if (true === data.success && true !== data.requires_verification) {
820
826
  await checkAuth();
821
827
  }
822
828
  emitter.emit(AuthState.LOGIN);
@@ -836,7 +842,7 @@ function useAuth() {
836
842
  }
837
843
  }
838
844
  async function signup(newUser) {
839
- const hasPassword = newUser.password !== void 0 && newUser.password.length > 0;
845
+ const hasPassword = newUser.password !== void 0 && 0 < newUser.password.length;
840
846
  if (hasPassword && newUser.password !== newUser.confirmPassword) {
841
847
  throw new Error("Passwords do not match");
842
848
  }
@@ -847,7 +853,7 @@ function useAuth() {
847
853
  phone_number: newUser.phone_number,
848
854
  password: newUser.password
849
855
  });
850
- if (data.success === true && data.requires_verification !== true) {
856
+ if (true === data.success && true !== data.requires_verification) {
851
857
  await checkAuth();
852
858
  }
853
859
  emitter.emit(AuthState.SIGNUP);
@@ -905,7 +911,7 @@ function useAuth() {
905
911
  }
906
912
  async function getSessions(accountId) {
907
913
  const id = accountId ?? user.value?.accountId;
908
- if (id === void 0 || id === "") {
914
+ if (id === void 0 || "" === id) {
909
915
  throw new Error("No account ID available");
910
916
  }
911
917
  return api.getSessions(id);
@@ -915,7 +921,7 @@ function useAuth() {
915
921
  }
916
922
  async function revokeAllSessions(accountId) {
917
923
  const id = accountId ?? user.value?.accountId;
918
- if (id === void 0 || id === "") {
924
+ if (id === void 0 || "" === id) {
919
925
  throw new Error("No account ID available");
920
926
  }
921
927
  await api.revokeAllSessions(id);
@@ -926,7 +932,7 @@ function useAuth() {
926
932
  }
927
933
  async function loginWithSSO(params) {
928
934
  const { data } = await api.ssoCallback(params);
929
- if (data.success === true && data.requires_verification !== true) {
935
+ if (true === data.success && true !== data.requires_verification) {
930
936
  await checkAuth();
931
937
  }
932
938
  emitter.emit(AuthState.LOGIN);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/auth",
3
3
  "type": "module",
4
- "version": "1.5.17",
4
+ "version": "1.5.20",
5
5
  "description": "Bagelink auth package",
6
6
  "author": {
7
7
  "name": "Bagel Studio",
package/src/api.ts CHANGED
@@ -53,7 +53,7 @@ export class AuthApi {
53
53
  // Handle password reset token from URL
54
54
  const urlParams = new URLSearchParams(window.location.search)
55
55
  const resetToken = urlParams.get('token')
56
- if (resetToken !== null && config.headers) {
56
+ if (null !== resetToken && config.headers) {
57
57
  config.headers['X-Reset-Token'] = resetToken
58
58
  }
59
59
  return config
package/src/sso.ts CHANGED
@@ -220,10 +220,10 @@ function waitForPopupCallback(popup: Window, provider: string, timeoutMs = 90000
220
220
  function onMessage(ev: MessageEvent) {
221
221
  try {
222
222
  // Strict origin check
223
- if (ev.origin !== window.location.origin) return
223
+ if (ev.origin !== window.location.origin) {return}
224
224
 
225
225
  const data = ev.data || {}
226
- if (data.type !== 'auth:complete' || data.provider !== provider) return
226
+ if ('auth:complete' !== data.type || data.provider !== provider) {return}
227
227
 
228
228
  cleanup()
229
229
  if (data.error) {
@@ -295,7 +295,7 @@ function waitForPopupCallback(popup: Window, provider: string, timeoutMs = 90000
295
295
  */
296
296
  function createSSOProvider(config: SSOProviderConfig): SSOProviderInstance {
297
297
  const getDefaultRedirectUri = () => {
298
- if (typeof window !== 'undefined') {
298
+ if ('undefined' !== typeof window) {
299
299
  return `${window.location.origin}/auth/callback`
300
300
  }
301
301
  return `/auth/callback`
@@ -315,7 +315,7 @@ function createSSOProvider(config: SSOProviderConfig): SSOProviderInstance {
315
315
  const state = options.state ?? generateState()
316
316
 
317
317
  // Store state AND provider in sessionStorage for verification
318
- if (typeof sessionStorage !== 'undefined') {
318
+ if ('undefined' !== typeof sessionStorage) {
319
319
  sessionStorage.setItem(getStateKey(), state)
320
320
  // Map state -> provider so we can identify which provider on callback
321
321
  sessionStorage.setItem(`oauth_provider:${state}`, config.id)
@@ -339,7 +339,7 @@ function createSSOProvider(config: SSOProviderConfig): SSOProviderInstance {
339
339
  const timeout = options.popupTimeout ?? 90000
340
340
 
341
341
  // Store state AND provider in sessionStorage for verification
342
- if (typeof sessionStorage !== 'undefined') {
342
+ if ('undefined' !== typeof sessionStorage) {
343
343
  sessionStorage.setItem(getStateKey(), state)
344
344
  // Map state -> provider so we can identify which provider on callback
345
345
  sessionStorage.setItem(`oauth_provider:${state}`, config.id)
@@ -373,7 +373,7 @@ function createSSOProvider(config: SSOProviderConfig): SSOProviderInstance {
373
373
  const auth = getAuthApi()
374
374
 
375
375
  // Verify state if it was stored (per-provider key)
376
- if (typeof sessionStorage !== 'undefined' && state) {
376
+ if ('undefined' !== typeof sessionStorage && state) {
377
377
  const storedState = sessionStorage.getItem(getStateKey())
378
378
  sessionStorage.removeItem(getStateKey())
379
379
  // Clean up provider mapping
@@ -395,7 +395,7 @@ function createSSOProvider(config: SSOProviderConfig): SSOProviderInstance {
395
395
  const auth = getAuthApi()
396
396
 
397
397
  // Verify state if it was stored (per-provider key)
398
- if (typeof sessionStorage !== 'undefined' && state) {
398
+ if ('undefined' !== typeof sessionStorage && state) {
399
399
  const storedState = sessionStorage.getItem(getStateKey())
400
400
  sessionStorage.removeItem(getStateKey())
401
401
  // Clean up provider mapping
package/src/types.ts CHANGED
@@ -311,7 +311,7 @@ export type SSOUnlinkResponse = AxiosResponse<MessageResponse>
311
311
  * Extract unified user from account info
312
312
  */
313
313
  export function accountToUser(account: AccountInfo | null): User | null {
314
- if (account === null) return null
314
+ if (null === account) {return null}
315
315
 
316
316
  // Person account - most common case
317
317
  if (account.person !== undefined) {
@@ -347,7 +347,7 @@ export function accountToUser(account: AccountInfo | null): User | null {
347
347
  // Fallback - use account info directly
348
348
  // Extract email from authentication methods
349
349
  const emailMethod = account.authentication_methods.find(
350
- m => m.type === 'password' || m.type === 'email_token',
350
+ m => 'password' === m.type || 'email_token' === m.type,
351
351
  )
352
352
 
353
353
  return {
package/src/useAuth.ts CHANGED
@@ -28,11 +28,11 @@ export function initAuth({
28
28
  }: {
29
29
  baseURL: string
30
30
  }) {
31
- if (authApi === null) {
31
+ if (null === authApi) {
32
32
  authApi = new AuthApi(baseURL)
33
33
  }
34
34
 
35
- if (eventEmitter === null) {
35
+ if (null === eventEmitter) {
36
36
  eventEmitter = new EventEmitter()
37
37
  }
38
38
 
@@ -65,11 +65,11 @@ export function initAuth({
65
65
 
66
66
  // Composable
67
67
  export function useAuth() {
68
- if (authApi === null) {
68
+ if (null === authApi) {
69
69
  throw new Error('Auth not initialized. Call initAuth first.')
70
70
  }
71
71
 
72
- if (eventEmitter === null) {
72
+ if (null === eventEmitter) {
73
73
  throw new Error('Event emitter not initialized. Call initAuth first.')
74
74
  }
75
75
 
@@ -84,7 +84,7 @@ export function useAuth() {
84
84
  },
85
85
  loginWithSSO: async (params: SSOCallbackRequest) => {
86
86
  const { data } = await api.ssoCallback(params)
87
- if (data.success === true && data.requires_verification !== true) {
87
+ if (true === data.success && true !== data.requires_verification) {
88
88
  await checkAuth()
89
89
  }
90
90
  emitter.emit(AuthState.LOGIN)
@@ -110,7 +110,7 @@ export function useAuth() {
110
110
  }
111
111
 
112
112
  const getIsLoggedIn = () => {
113
- return user.value !== null
113
+ return null !== user.value
114
114
  }
115
115
 
116
116
  const getEmail = () => {
@@ -126,11 +126,11 @@ export function useAuth() {
126
126
  }
127
127
 
128
128
  const isPersonAccount = () => {
129
- return user.value?.type === 'person'
129
+ return 'person' === user.value?.type
130
130
  }
131
131
 
132
132
  const isEntityAccount = () => {
133
- return user.value?.type === 'entity'
133
+ return 'entity' === user.value?.type
134
134
  }
135
135
 
136
136
  // Actions
@@ -153,7 +153,7 @@ export function useAuth() {
153
153
  )
154
154
 
155
155
  // If successful and not requiring verification, fetch user data
156
- if (data.success === true && data.requires_verification !== true) {
156
+ if (true === data.success && true !== data.requires_verification) {
157
157
  await checkAuth()
158
158
  }
159
159
 
@@ -177,7 +177,7 @@ export function useAuth() {
177
177
 
178
178
  async function signup(newUser: NewUser) {
179
179
  // Check password match if password is provided
180
- const hasPassword = newUser.password !== undefined && newUser.password.length > 0
180
+ const hasPassword = newUser.password !== undefined && 0 < newUser.password.length
181
181
  if (hasPassword && newUser.password !== newUser.confirmPassword) {
182
182
  throw new Error('Passwords do not match')
183
183
  }
@@ -191,7 +191,7 @@ export function useAuth() {
191
191
  })
192
192
 
193
193
  // If successful and not requiring verification, fetch user data
194
- if (data.success === true && data.requires_verification !== true) {
194
+ if (true === data.success && true !== data.requires_verification) {
195
195
  await checkAuth()
196
196
  }
197
197
 
@@ -264,7 +264,7 @@ export function useAuth() {
264
264
 
265
265
  async function getSessions(accountId?: string) {
266
266
  const id = accountId ?? user.value?.accountId
267
- if (id === undefined || id === '') {
267
+ if (id === undefined || '' === id) {
268
268
  throw new Error('No account ID available')
269
269
  }
270
270
  return api.getSessions(id)
@@ -276,7 +276,7 @@ export function useAuth() {
276
276
 
277
277
  async function revokeAllSessions(accountId?: string) {
278
278
  const id = accountId ?? user.value?.accountId
279
- if (id === undefined || id === '') {
279
+ if (id === undefined || '' === id) {
280
280
  throw new Error('No account ID available')
281
281
  }
282
282
  await api.revokeAllSessions(id)
@@ -302,7 +302,7 @@ export function useAuth() {
302
302
  const { data } = await api.ssoCallback(params)
303
303
 
304
304
  // If successful and not requiring verification, fetch user data
305
- if (data.success === true && data.requires_verification !== true) {
305
+ if (true === data.success && true !== data.requires_verification) {
306
306
  await checkAuth()
307
307
  }
308
308
 
package/src/utils.ts CHANGED
@@ -46,7 +46,7 @@ export class EventEmitter {
46
46
  }
47
47
 
48
48
  export function queryParams(): Record<string, string> {
49
- if (typeof window === 'undefined' || !window.location?.search) {
49
+ if ('undefined' === typeof window || !window.location?.search) {
50
50
  return {}
51
51
  }
52
52
  const params = new URLSearchParams(window.location.search)