@eaccess/auth 0.1.9 → 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
@@ -575,6 +575,7 @@ interface AuthContext {
575
575
  accountId: number;
576
576
  email: string;
577
577
  }>;
578
+ userExistsByEmail: (email: string) => Promise<boolean>;
578
579
  forceLogoutForUserBy: (identifier: {
579
580
  accountId?: number;
580
581
  email?: string;
@@ -630,6 +631,7 @@ declare function confirmResetPassword(config: AuthConfig, token: string, passwor
630
631
  accountId: number;
631
632
  email: string;
632
633
  }>;
634
+ declare function userExistsByEmail(config: AuthConfig, email: string): Promise<boolean>;
633
635
  declare function forceLogoutForUserBy(config: AuthConfig, identifier: {
634
636
  accountId?: number;
635
637
  email?: string;
@@ -650,8 +652,9 @@ declare const authFunctions_register: typeof register;
650
652
  declare const authFunctions_removeRoleForUserBy: typeof removeRoleForUserBy;
651
653
  declare const authFunctions_resetPassword: typeof resetPassword;
652
654
  declare const authFunctions_setStatusForUserBy: typeof setStatusForUserBy;
655
+ declare const authFunctions_userExistsByEmail: typeof userExistsByEmail;
653
656
  declare namespace authFunctions {
654
- 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 };
655
658
  }
656
659
 
657
660
  type UserIdentifier = {
@@ -1170,4 +1173,4 @@ declare class AzureProvider extends BaseOAuthProvider {
1170
1173
  protected exchangeCodeForToken(code: string, tokenUrl: string): Promise<string>;
1171
1174
  }
1172
1175
 
1173
- 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
@@ -575,6 +575,7 @@ interface AuthContext {
575
575
  accountId: number;
576
576
  email: string;
577
577
  }>;
578
+ userExistsByEmail: (email: string) => Promise<boolean>;
578
579
  forceLogoutForUserBy: (identifier: {
579
580
  accountId?: number;
580
581
  email?: string;
@@ -630,6 +631,7 @@ declare function confirmResetPassword(config: AuthConfig, token: string, passwor
630
631
  accountId: number;
631
632
  email: string;
632
633
  }>;
634
+ declare function userExistsByEmail(config: AuthConfig, email: string): Promise<boolean>;
633
635
  declare function forceLogoutForUserBy(config: AuthConfig, identifier: {
634
636
  accountId?: number;
635
637
  email?: string;
@@ -650,8 +652,9 @@ declare const authFunctions_register: typeof register;
650
652
  declare const authFunctions_removeRoleForUserBy: typeof removeRoleForUserBy;
651
653
  declare const authFunctions_resetPassword: typeof resetPassword;
652
654
  declare const authFunctions_setStatusForUserBy: typeof setStatusForUserBy;
655
+ declare const authFunctions_userExistsByEmail: typeof userExistsByEmail;
653
656
  declare namespace authFunctions {
654
- 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 };
655
658
  }
656
659
 
657
660
  type UserIdentifier = {
@@ -1170,4 +1173,4 @@ declare class AzureProvider extends BaseOAuthProvider {
1170
1173
  protected exchangeCodeForToken(code: string, tokenUrl: string): Promise<string>;
1171
1174
  }
1172
1175
 
1173
- 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