@eaccess/auth 0.1.8 → 0.1.10

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.d.cts CHANGED
@@ -351,6 +351,7 @@ interface TwoFactorManager$1 {
351
351
  emailEnabled(): Promise<boolean>;
352
352
  smsEnabled(): Promise<boolean>;
353
353
  getEnabledMethods(): Promise<TwoFactorMechanism[]>;
354
+ getTotpUri(): Promise<string | null>;
354
355
  setup: {
355
356
  /**
356
357
  * Setup TOTP authentication using an authenticator app.
@@ -574,6 +575,7 @@ interface AuthContext {
574
575
  accountId: number;
575
576
  email: string;
576
577
  }>;
578
+ userExistsByEmail: (email: string) => Promise<boolean>;
577
579
  forceLogoutForUserBy: (identifier: {
578
580
  accountId?: number;
579
581
  email?: string;
@@ -629,6 +631,7 @@ declare function confirmResetPassword(config: AuthConfig, token: string, passwor
629
631
  accountId: number;
630
632
  email: string;
631
633
  }>;
634
+ declare function userExistsByEmail(config: AuthConfig, email: string): Promise<boolean>;
632
635
  declare function forceLogoutForUserBy(config: AuthConfig, identifier: {
633
636
  accountId?: number;
634
637
  email?: string;
@@ -649,8 +652,9 @@ declare const authFunctions_register: typeof register;
649
652
  declare const authFunctions_removeRoleForUserBy: typeof removeRoleForUserBy;
650
653
  declare const authFunctions_resetPassword: typeof resetPassword;
651
654
  declare const authFunctions_setStatusForUserBy: typeof setStatusForUserBy;
655
+ declare const authFunctions_userExistsByEmail: typeof userExistsByEmail;
652
656
  declare namespace authFunctions {
653
- export { authFunctions_addRoleForUserBy as addRoleForUserBy, authFunctions_changePasswordForUserBy as changePasswordForUserBy, authFunctions_confirmResetPassword as confirmResetPassword, authFunctions_createUser as createUser, authFunctions_deleteUserBy as deleteUserBy, authFunctions_forceLogoutForUserBy as forceLogoutForUserBy, authFunctions_hasRoleForUserBy as hasRoleForUserBy, authFunctions_initiatePasswordResetForUserBy as initiatePasswordResetForUserBy, authFunctions_register as register, authFunctions_removeRoleForUserBy as removeRoleForUserBy, authFunctions_resetPassword as resetPassword, authFunctions_setStatusForUserBy as setStatusForUserBy };
657
+ export { authFunctions_addRoleForUserBy as addRoleForUserBy, authFunctions_changePasswordForUserBy as changePasswordForUserBy, authFunctions_confirmResetPassword as confirmResetPassword, authFunctions_createUser as createUser, authFunctions_deleteUserBy as deleteUserBy, authFunctions_forceLogoutForUserBy as forceLogoutForUserBy, authFunctions_hasRoleForUserBy as hasRoleForUserBy, authFunctions_initiatePasswordResetForUserBy as initiatePasswordResetForUserBy, authFunctions_register as register, authFunctions_removeRoleForUserBy as removeRoleForUserBy, authFunctions_resetPassword as resetPassword, authFunctions_setStatusForUserBy as setStatusForUserBy, authFunctions_userExistsByEmail as userExistsByEmail };
654
658
  }
655
659
 
656
660
  type UserIdentifier = {
@@ -1169,4 +1173,4 @@ declare class AzureProvider extends BaseOAuthProvider {
1169
1173
  protected exchangeCodeForToken(code: string, tokenUrl: string): Promise<string>;
1170
1174
  }
1171
1175
 
1172
- export { ActivityLogger, type AuthAccount, type AuthActivity, AuthActivityAction, type AuthActivityActionType, type AuthConfig, type AuthConfirmation, type AuthContext, AuthError, type AuthManager$1 as AuthManager, type AuthProvider, type AuthRemember, type AuthReset, AuthRole, type AuthSession, AuthStatus, AzureProvider, type AzureProviderConfig, BaseOAuthProvider, ConfirmationExpiredError, ConfirmationNotFoundError, EmailNotVerifiedError, EmailTakenError, GitHubProvider, type GitHubProviderConfig, GoogleProvider, type GoogleProviderConfig, InvalidBackupCodeError, InvalidEmailError, InvalidPasswordError, InvalidTokenError, InvalidTwoFactorCodeError, type OAuthProvider, type OAuthProviderConfig, type OAuthUserData, OtpProvider, ResetDisabledError, ResetExpiredError, ResetNotFoundError, SecondFactorRequiredError, type TokenCallback, TooManyResetsError, TotpProvider, TwoFactorAlreadyEnabledError, type TwoFactorChallenge, TwoFactorExpiredError, TwoFactorManager, TwoFactorMechanism, type TwoFactorMethod, TwoFactorNotSetupError, TwoFactorSetupIncompleteError, type TwoFactorSetupResult, type TwoFactorToken, type UserIdentifier, UserInactiveError, UserNotFoundError, UserNotLoggedInError, addRoleForUserBy, addRoleToUser, authFunctions, changePasswordForUserBy, cleanupExpiredTokens, confirmResetPassword, createAuthContext, createAuthMiddleware, createAuthTables, createUser, deleteUserBy, dropAuthTables, forceLogoutForUserBy, getAuthTableStats, getUserRoles, hasRoleForUserBy, initiatePasswordResetForUserBy, isValidEmail, register, removeRoleForUserBy, removeRoleFromUser, resetPassword, setStatusForUserBy, setUserRoles, validateEmail };
1176
+ export { ActivityLogger, type AuthAccount, type AuthActivity, AuthActivityAction, type AuthActivityActionType, type AuthConfig, type AuthConfirmation, type AuthContext, AuthError, type AuthManager$1 as AuthManager, type AuthProvider, type AuthRemember, type AuthReset, AuthRole, type AuthSession, AuthStatus, AzureProvider, type AzureProviderConfig, BaseOAuthProvider, ConfirmationExpiredError, ConfirmationNotFoundError, EmailNotVerifiedError, EmailTakenError, GitHubProvider, type GitHubProviderConfig, GoogleProvider, type GoogleProviderConfig, InvalidBackupCodeError, InvalidEmailError, InvalidPasswordError, InvalidTokenError, InvalidTwoFactorCodeError, type OAuthProvider, type OAuthProviderConfig, type OAuthUserData, OtpProvider, ResetDisabledError, ResetExpiredError, ResetNotFoundError, SecondFactorRequiredError, type TokenCallback, TooManyResetsError, TotpProvider, TwoFactorAlreadyEnabledError, type TwoFactorChallenge, TwoFactorExpiredError, TwoFactorManager, TwoFactorMechanism, type TwoFactorMethod, TwoFactorNotSetupError, TwoFactorSetupIncompleteError, type TwoFactorSetupResult, type TwoFactorToken, type UserIdentifier, UserInactiveError, UserNotFoundError, UserNotLoggedInError, addRoleForUserBy, addRoleToUser, authFunctions, changePasswordForUserBy, cleanupExpiredTokens, confirmResetPassword, createAuthContext, createAuthMiddleware, createAuthTables, createUser, deleteUserBy, dropAuthTables, forceLogoutForUserBy, getAuthTableStats, getUserRoles, hasRoleForUserBy, initiatePasswordResetForUserBy, isValidEmail, register, removeRoleForUserBy, removeRoleFromUser, resetPassword, setStatusForUserBy, setUserRoles, userExistsByEmail, validateEmail };
package/dist/index.d.ts CHANGED
@@ -351,6 +351,7 @@ interface TwoFactorManager$1 {
351
351
  emailEnabled(): Promise<boolean>;
352
352
  smsEnabled(): Promise<boolean>;
353
353
  getEnabledMethods(): Promise<TwoFactorMechanism[]>;
354
+ getTotpUri(): Promise<string | null>;
354
355
  setup: {
355
356
  /**
356
357
  * Setup TOTP authentication using an authenticator app.
@@ -574,6 +575,7 @@ interface AuthContext {
574
575
  accountId: number;
575
576
  email: string;
576
577
  }>;
578
+ userExistsByEmail: (email: string) => Promise<boolean>;
577
579
  forceLogoutForUserBy: (identifier: {
578
580
  accountId?: number;
579
581
  email?: string;
@@ -629,6 +631,7 @@ declare function confirmResetPassword(config: AuthConfig, token: string, passwor
629
631
  accountId: number;
630
632
  email: string;
631
633
  }>;
634
+ declare function userExistsByEmail(config: AuthConfig, email: string): Promise<boolean>;
632
635
  declare function forceLogoutForUserBy(config: AuthConfig, identifier: {
633
636
  accountId?: number;
634
637
  email?: string;
@@ -649,8 +652,9 @@ declare const authFunctions_register: typeof register;
649
652
  declare const authFunctions_removeRoleForUserBy: typeof removeRoleForUserBy;
650
653
  declare const authFunctions_resetPassword: typeof resetPassword;
651
654
  declare const authFunctions_setStatusForUserBy: typeof setStatusForUserBy;
655
+ declare const authFunctions_userExistsByEmail: typeof userExistsByEmail;
652
656
  declare namespace authFunctions {
653
- export { authFunctions_addRoleForUserBy as addRoleForUserBy, authFunctions_changePasswordForUserBy as changePasswordForUserBy, authFunctions_confirmResetPassword as confirmResetPassword, authFunctions_createUser as createUser, authFunctions_deleteUserBy as deleteUserBy, authFunctions_forceLogoutForUserBy as forceLogoutForUserBy, authFunctions_hasRoleForUserBy as hasRoleForUserBy, authFunctions_initiatePasswordResetForUserBy as initiatePasswordResetForUserBy, authFunctions_register as register, authFunctions_removeRoleForUserBy as removeRoleForUserBy, authFunctions_resetPassword as resetPassword, authFunctions_setStatusForUserBy as setStatusForUserBy };
657
+ export { authFunctions_addRoleForUserBy as addRoleForUserBy, authFunctions_changePasswordForUserBy as changePasswordForUserBy, authFunctions_confirmResetPassword as confirmResetPassword, authFunctions_createUser as createUser, authFunctions_deleteUserBy as deleteUserBy, authFunctions_forceLogoutForUserBy as forceLogoutForUserBy, authFunctions_hasRoleForUserBy as hasRoleForUserBy, authFunctions_initiatePasswordResetForUserBy as initiatePasswordResetForUserBy, authFunctions_register as register, authFunctions_removeRoleForUserBy as removeRoleForUserBy, authFunctions_resetPassword as resetPassword, authFunctions_setStatusForUserBy as setStatusForUserBy, authFunctions_userExistsByEmail as userExistsByEmail };
654
658
  }
655
659
 
656
660
  type UserIdentifier = {
@@ -1169,4 +1173,4 @@ declare class AzureProvider extends BaseOAuthProvider {
1169
1173
  protected exchangeCodeForToken(code: string, tokenUrl: string): Promise<string>;
1170
1174
  }
1171
1175
 
1172
- export { ActivityLogger, type AuthAccount, type AuthActivity, AuthActivityAction, type AuthActivityActionType, type AuthConfig, type AuthConfirmation, type AuthContext, AuthError, type AuthManager$1 as AuthManager, type AuthProvider, type AuthRemember, type AuthReset, AuthRole, type AuthSession, AuthStatus, AzureProvider, type AzureProviderConfig, BaseOAuthProvider, ConfirmationExpiredError, ConfirmationNotFoundError, EmailNotVerifiedError, EmailTakenError, GitHubProvider, type GitHubProviderConfig, GoogleProvider, type GoogleProviderConfig, InvalidBackupCodeError, InvalidEmailError, InvalidPasswordError, InvalidTokenError, InvalidTwoFactorCodeError, type OAuthProvider, type OAuthProviderConfig, type OAuthUserData, OtpProvider, ResetDisabledError, ResetExpiredError, ResetNotFoundError, SecondFactorRequiredError, type TokenCallback, TooManyResetsError, TotpProvider, TwoFactorAlreadyEnabledError, type TwoFactorChallenge, TwoFactorExpiredError, TwoFactorManager, TwoFactorMechanism, type TwoFactorMethod, TwoFactorNotSetupError, TwoFactorSetupIncompleteError, type TwoFactorSetupResult, type TwoFactorToken, type UserIdentifier, UserInactiveError, UserNotFoundError, UserNotLoggedInError, addRoleForUserBy, addRoleToUser, authFunctions, changePasswordForUserBy, cleanupExpiredTokens, confirmResetPassword, createAuthContext, createAuthMiddleware, createAuthTables, createUser, deleteUserBy, dropAuthTables, forceLogoutForUserBy, getAuthTableStats, getUserRoles, hasRoleForUserBy, initiatePasswordResetForUserBy, isValidEmail, register, removeRoleForUserBy, removeRoleFromUser, resetPassword, setStatusForUserBy, setUserRoles, validateEmail };
1176
+ export { ActivityLogger, type AuthAccount, type AuthActivity, AuthActivityAction, type AuthActivityActionType, type AuthConfig, type AuthConfirmation, type AuthContext, AuthError, type AuthManager$1 as AuthManager, type AuthProvider, type AuthRemember, type AuthReset, AuthRole, type AuthSession, AuthStatus, AzureProvider, type AzureProviderConfig, BaseOAuthProvider, ConfirmationExpiredError, ConfirmationNotFoundError, EmailNotVerifiedError, EmailTakenError, GitHubProvider, type GitHubProviderConfig, GoogleProvider, type GoogleProviderConfig, InvalidBackupCodeError, InvalidEmailError, InvalidPasswordError, InvalidTokenError, InvalidTwoFactorCodeError, type OAuthProvider, type OAuthProviderConfig, type OAuthUserData, OtpProvider, ResetDisabledError, ResetExpiredError, ResetNotFoundError, SecondFactorRequiredError, type TokenCallback, TooManyResetsError, TotpProvider, TwoFactorAlreadyEnabledError, type TwoFactorChallenge, TwoFactorExpiredError, TwoFactorManager, TwoFactorMechanism, type TwoFactorMethod, TwoFactorNotSetupError, TwoFactorSetupIncompleteError, type TwoFactorSetupResult, type TwoFactorToken, type UserIdentifier, UserInactiveError, UserNotFoundError, UserNotLoggedInError, addRoleForUserBy, addRoleToUser, authFunctions, changePasswordForUserBy, cleanupExpiredTokens, confirmResetPassword, createAuthContext, createAuthMiddleware, createAuthTables, createUser, deleteUserBy, dropAuthTables, forceLogoutForUserBy, getAuthTableStats, getUserRoles, hasRoleForUserBy, initiatePasswordResetForUserBy, isValidEmail, register, removeRoleForUserBy, removeRoleFromUser, resetPassword, setStatusForUserBy, setUserRoles, userExistsByEmail, validateEmail };
package/dist/index.js CHANGED
@@ -1380,7 +1380,8 @@ __export(auth_functions_exports, {
1380
1380
  register: () => register,
1381
1381
  removeRoleForUserBy: () => removeRoleForUserBy,
1382
1382
  resetPassword: () => resetPassword,
1383
- setStatusForUserBy: () => setStatusForUserBy
1383
+ setStatusForUserBy: () => setStatusForUserBy,
1384
+ userExistsByEmail: () => userExistsByEmail
1384
1385
  });
1385
1386
  import { hash as hash3 } from "@prsm/hash";
1386
1387
  import ms2 from "@prsm/ms";
@@ -1598,6 +1599,12 @@ async function confirmResetPassword(config, token, password) {
1598
1599
  await queries.deleteResetToken(token);
1599
1600
  return { accountId: account.id, email: account.email };
1600
1601
  }
1602
+ async function userExistsByEmail(config, email) {
1603
+ validateEmail(email);
1604
+ const queries = new AuthQueries(config);
1605
+ const account = await queries.findAccountByEmail(email);
1606
+ return account !== null;
1607
+ }
1601
1608
  async function forceLogoutForUserBy(config, identifier) {
1602
1609
  const queries = new AuthQueries(config);
1603
1610
  const account = await findAccountByIdentifier(queries, identifier);
@@ -2594,6 +2601,7 @@ function createAuthContext(config) {
2594
2601
  initiatePasswordResetForUserBy: (identifier, expiresAfter, callback) => initiatePasswordResetForUserBy(config, identifier, expiresAfter, callback),
2595
2602
  resetPassword: (email, expiresAfter, maxOpenRequests, callback) => resetPassword(config, email, expiresAfter, maxOpenRequests, callback),
2596
2603
  confirmResetPassword: (token, password) => confirmResetPassword(config, token, password),
2604
+ userExistsByEmail: (email) => userExistsByEmail(config, email),
2597
2605
  forceLogoutForUserBy: (identifier) => forceLogoutForUserBy(config, identifier)
2598
2606
  };
2599
2607
  }
@@ -2694,6 +2702,7 @@ export {
2694
2702
  resetPassword,
2695
2703
  setStatusForUserBy,
2696
2704
  setUserRoles,
2705
+ userExistsByEmail,
2697
2706
  validateEmail
2698
2707
  };
2699
2708
  //# sourceMappingURL=index.js.map