@eaccess/auth 0.1.13 → 0.1.14
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 +3 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -4
- package/dist/index.d.ts +7 -4
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -92,9 +92,12 @@ interface OAuthUserData {
|
|
|
92
92
|
name?: string;
|
|
93
93
|
avatar?: string;
|
|
94
94
|
}
|
|
95
|
+
interface OAuthCallbackResult {
|
|
96
|
+
isNewUser: boolean;
|
|
97
|
+
}
|
|
95
98
|
interface OAuthProvider {
|
|
96
99
|
getAuthUrl(state?: string, scopes?: string[]): string;
|
|
97
|
-
handleCallback(req: Request): Promise<
|
|
100
|
+
handleCallback(req: Request): Promise<OAuthCallbackResult>;
|
|
98
101
|
getUserData(req: Request): Promise<OAuthUserData>;
|
|
99
102
|
}
|
|
100
103
|
interface AuthConfirmation {
|
|
@@ -1146,8 +1149,8 @@ declare abstract class BaseOAuthProvider implements OAuthProvider {
|
|
|
1146
1149
|
constructor(config: OAuthProviderConfig, authConfig: AuthConfig, authManager: AuthManager);
|
|
1147
1150
|
abstract getAuthUrl(state?: string, scopes?: string[]): string;
|
|
1148
1151
|
abstract getUserData(req: Request): Promise<OAuthUserData>;
|
|
1149
|
-
handleCallback(req: Request): Promise<
|
|
1150
|
-
protected processOAuthLogin(userData: OAuthUserData, req: Request): Promise<
|
|
1152
|
+
handleCallback(req: Request): Promise<OAuthCallbackResult>;
|
|
1153
|
+
protected processOAuthLogin(userData: OAuthUserData, req: Request): Promise<OAuthCallbackResult>;
|
|
1151
1154
|
protected abstract getProviderName(): string;
|
|
1152
1155
|
protected exchangeCodeForToken(code: string, tokenUrl: string): Promise<string>;
|
|
1153
1156
|
protected fetchUserFromAPI(accessToken: string, apiUrl: string): Promise<any>;
|
|
@@ -1175,4 +1178,4 @@ declare class AzureProvider extends BaseOAuthProvider {
|
|
|
1175
1178
|
protected exchangeCodeForToken(code: string, tokenUrl: string): Promise<string>;
|
|
1176
1179
|
}
|
|
1177
1180
|
|
|
1178
|
-
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 };
|
|
1181
|
+
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 OAuthCallbackResult, 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
|
@@ -92,9 +92,12 @@ interface OAuthUserData {
|
|
|
92
92
|
name?: string;
|
|
93
93
|
avatar?: string;
|
|
94
94
|
}
|
|
95
|
+
interface OAuthCallbackResult {
|
|
96
|
+
isNewUser: boolean;
|
|
97
|
+
}
|
|
95
98
|
interface OAuthProvider {
|
|
96
99
|
getAuthUrl(state?: string, scopes?: string[]): string;
|
|
97
|
-
handleCallback(req: Request): Promise<
|
|
100
|
+
handleCallback(req: Request): Promise<OAuthCallbackResult>;
|
|
98
101
|
getUserData(req: Request): Promise<OAuthUserData>;
|
|
99
102
|
}
|
|
100
103
|
interface AuthConfirmation {
|
|
@@ -1146,8 +1149,8 @@ declare abstract class BaseOAuthProvider implements OAuthProvider {
|
|
|
1146
1149
|
constructor(config: OAuthProviderConfig, authConfig: AuthConfig, authManager: AuthManager);
|
|
1147
1150
|
abstract getAuthUrl(state?: string, scopes?: string[]): string;
|
|
1148
1151
|
abstract getUserData(req: Request): Promise<OAuthUserData>;
|
|
1149
|
-
handleCallback(req: Request): Promise<
|
|
1150
|
-
protected processOAuthLogin(userData: OAuthUserData, req: Request): Promise<
|
|
1152
|
+
handleCallback(req: Request): Promise<OAuthCallbackResult>;
|
|
1153
|
+
protected processOAuthLogin(userData: OAuthUserData, req: Request): Promise<OAuthCallbackResult>;
|
|
1151
1154
|
protected abstract getProviderName(): string;
|
|
1152
1155
|
protected exchangeCodeForToken(code: string, tokenUrl: string): Promise<string>;
|
|
1153
1156
|
protected fetchUserFromAPI(accessToken: string, apiUrl: string): Promise<any>;
|
|
@@ -1175,4 +1178,4 @@ declare class AzureProvider extends BaseOAuthProvider {
|
|
|
1175
1178
|
protected exchangeCodeForToken(code: string, tokenUrl: string): Promise<string>;
|
|
1176
1179
|
}
|
|
1177
1180
|
|
|
1178
|
-
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 };
|
|
1181
|
+
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 OAuthCallbackResult, 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
|
@@ -625,7 +625,7 @@ var BaseOAuthProvider = class {
|
|
|
625
625
|
}
|
|
626
626
|
async handleCallback(req) {
|
|
627
627
|
const userData = await this.getUserData(req);
|
|
628
|
-
|
|
628
|
+
return this.processOAuthLogin(userData, req);
|
|
629
629
|
}
|
|
630
630
|
async processOAuthLogin(userData, req) {
|
|
631
631
|
const { queries } = this.authManager;
|
|
@@ -635,7 +635,7 @@ var BaseOAuthProvider = class {
|
|
|
635
635
|
const account2 = await queries.findAccountById(existingProvider.account_id);
|
|
636
636
|
if (account2) {
|
|
637
637
|
await this.authManager.onLoginSuccessful(account2, false);
|
|
638
|
-
return;
|
|
638
|
+
return { isNewUser: false };
|
|
639
639
|
}
|
|
640
640
|
}
|
|
641
641
|
if (userData.email) {
|
|
@@ -670,6 +670,7 @@ var BaseOAuthProvider = class {
|
|
|
670
670
|
providerAvatar: userData.avatar || null
|
|
671
671
|
});
|
|
672
672
|
await this.authManager.onLoginSuccessful(account, false);
|
|
673
|
+
return { isNewUser: true };
|
|
673
674
|
}
|
|
674
675
|
async exchangeCodeForToken(code, tokenUrl) {
|
|
675
676
|
const response = await fetch(tokenUrl, {
|