@nauth-toolkit/social-google 0.1.3
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/LICENSE +90 -0
- package/README.md +30 -0
- package/dist/nestjs/google-social-auth.module.d.ts +10 -0
- package/dist/nestjs/google-social-auth.module.d.ts.map +1 -0
- package/dist/nestjs/google-social-auth.module.js +72 -0
- package/dist/nestjs/google-social-auth.module.js.map +1 -0
- package/dist/nestjs/index.d.ts +7 -0
- package/dist/nestjs/index.d.ts.map +1 -0
- package/dist/nestjs/index.js +25 -0
- package/dist/nestjs/index.js.map +1 -0
- package/dist/src/dto/social-login.dto.d.ts +47 -0
- package/dist/src/dto/social-login.dto.d.ts.map +1 -0
- package/dist/src/dto/social-login.dto.js +131 -0
- package/dist/src/dto/social-login.dto.js.map +1 -0
- package/dist/src/google-oauth.client.d.ts +15 -0
- package/dist/src/google-oauth.client.d.ts.map +1 -0
- package/dist/src/google-oauth.client.js +95 -0
- package/dist/src/google-oauth.client.js.map +1 -0
- package/dist/src/google-social-auth.service.d.ts +16 -0
- package/dist/src/google-social-auth.service.d.ts.map +1 -0
- package/dist/src/google-social-auth.service.js +78 -0
- package/dist/src/google-social-auth.service.js.map +1 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +25 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/token-verifier.service.d.ts +9 -0
- package/dist/src/token-verifier.service.d.ts.map +1 -0
- package/dist/src/token-verifier.service.js +61 -0
- package/dist/src/token-verifier.service.js.map +1 -0
- package/dist/src/verified-token-profile.interface.d.ts +9 -0
- package/dist/src/verified-token-profile.interface.d.ts.map +1 -0
- package/dist/src/verified-token-profile.interface.js +3 -0
- package/dist/src/verified-token-profile.interface.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +68 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GoogleSocialAuthService = void 0;
|
|
4
|
+
const core_1 = require("@nauth-toolkit/core");
|
|
5
|
+
const internal_1 = require("@nauth-toolkit/core/internal");
|
|
6
|
+
const google_oauth_client_1 = require("./google-oauth.client");
|
|
7
|
+
const token_verifier_service_1 = require("./token-verifier.service");
|
|
8
|
+
class GoogleSocialAuthService extends internal_1.BaseSocialAuthProviderService {
|
|
9
|
+
providerName = 'google';
|
|
10
|
+
oauthClient;
|
|
11
|
+
tokenVerifier;
|
|
12
|
+
constructor(config, logger, authService, socialAuthService, jwtService, sessionService, challengeHelper, clientInfoService, stateStore, userRepository, phoneVerificationService, auditService, trustedDeviceService, tokenVerifier) {
|
|
13
|
+
super(config, logger, authService, socialAuthService, jwtService, sessionService, challengeHelper, clientInfoService, stateStore, userRepository, phoneVerificationService, auditService, trustedDeviceService);
|
|
14
|
+
const providerConfig = this.getProviderConfig();
|
|
15
|
+
if (!providerConfig || !providerConfig.enabled) {
|
|
16
|
+
this.oauthClient = null;
|
|
17
|
+
this.tokenVerifier = null;
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const webClientId = Array.isArray(providerConfig.clientId) ? providerConfig.clientId[0] : providerConfig.clientId;
|
|
21
|
+
if (!webClientId || !providerConfig.clientSecret) {
|
|
22
|
+
throw new core_1.NAuthException(core_1.AuthErrorCode.SOCIAL_CONFIG_MISSING, 'Google OAuth clientId and clientSecret are required when enabled');
|
|
23
|
+
}
|
|
24
|
+
this.oauthClient = new google_oauth_client_1.GoogleOAuthClient({
|
|
25
|
+
clientId: webClientId,
|
|
26
|
+
clientSecret: providerConfig.clientSecret,
|
|
27
|
+
redirectUri: providerConfig.callbackUrl || '',
|
|
28
|
+
scopes: providerConfig.scopes || ['openid', 'email', 'profile'],
|
|
29
|
+
});
|
|
30
|
+
this.tokenVerifier = tokenVerifier || new token_verifier_service_1.TokenVerifierService(config);
|
|
31
|
+
this.logger?.debug?.('GoogleSocialAuthService initialized');
|
|
32
|
+
}
|
|
33
|
+
async getAuthUrl(state) {
|
|
34
|
+
if (!this.oauthClient) {
|
|
35
|
+
throw new core_1.NAuthException(core_1.AuthErrorCode.SOCIAL_CONFIG_MISSING, 'Google OAuth is not enabled');
|
|
36
|
+
}
|
|
37
|
+
const finalState = state || this.generateState();
|
|
38
|
+
return this.oauthClient.getAuthorizationUrl(finalState);
|
|
39
|
+
}
|
|
40
|
+
async getOAuthProfile(code, _state) {
|
|
41
|
+
if (!this.oauthClient) {
|
|
42
|
+
throw new core_1.NAuthException(core_1.AuthErrorCode.SOCIAL_CONFIG_MISSING, 'Google OAuth is not enabled');
|
|
43
|
+
}
|
|
44
|
+
const providerConfig = this.getProviderConfig();
|
|
45
|
+
if (!providerConfig || !providerConfig.callbackUrl) {
|
|
46
|
+
throw new core_1.NAuthException(core_1.AuthErrorCode.SOCIAL_CONFIG_MISSING, 'Google OAuth callback URL is not configured');
|
|
47
|
+
}
|
|
48
|
+
const tokens = await this.oauthClient.exchangeCodeForToken(code, providerConfig.callbackUrl);
|
|
49
|
+
return await this.oauthClient.getUserProfile(tokens.accessToken);
|
|
50
|
+
}
|
|
51
|
+
async verifyNativeToken(idToken, _accessToken, profileData) {
|
|
52
|
+
const providerConfig = this.getProviderConfig();
|
|
53
|
+
if (!providerConfig) {
|
|
54
|
+
throw new core_1.NAuthException(core_1.AuthErrorCode.SOCIAL_CONFIG_MISSING, 'Google OAuth is not configured');
|
|
55
|
+
}
|
|
56
|
+
const clientIds = providerConfig.clientId || '';
|
|
57
|
+
if (!this.tokenVerifier?.verifyGoogleToken) {
|
|
58
|
+
throw new core_1.NAuthException(core_1.AuthErrorCode.SOCIAL_CONFIG_MISSING, 'Google token verifier is not available');
|
|
59
|
+
}
|
|
60
|
+
const verified = (await this.tokenVerifier.verifyGoogleToken(idToken, clientIds));
|
|
61
|
+
this.logger?.debug?.(`Verified Google token for: ${verified.email}`);
|
|
62
|
+
if (!verified.email || !verified.email_verified) {
|
|
63
|
+
throw new core_1.NAuthException(core_1.AuthErrorCode.SOCIAL_EMAIL_REQUIRED, 'Email is required and must be verified by Google.');
|
|
64
|
+
}
|
|
65
|
+
const profileDataTyped = profileData;
|
|
66
|
+
return {
|
|
67
|
+
id: verified.sub,
|
|
68
|
+
email: verified.email,
|
|
69
|
+
firstName: verified.given_name || profileDataTyped?.givenName || null,
|
|
70
|
+
lastName: verified.family_name || profileDataTyped?.familyName || null,
|
|
71
|
+
picture: verified.picture || profileDataTyped?.imageUrl || null,
|
|
72
|
+
verified: verified.email_verified,
|
|
73
|
+
raw: verified,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.GoogleSocialAuthService = GoogleSocialAuthService;
|
|
78
|
+
//# sourceMappingURL=google-social-auth.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-social-auth.service.js","sourceRoot":"","sources":["../../src/google-social-auth.service.ts"],"names":[],"mappings":";;;AACA,8CAa6B;AAE7B,2DAOsC;AAEtC,+DAA0D;AAC1D,qEAA8F;AAiC9F,MAAa,uBAAwB,SAAQ,wCAA6B;IAC/D,YAAY,GAAG,QAAQ,CAAC;IAChB,WAAW,CAA2B;IACtC,aAAa,CAA+B;IAE7D,YACE,MAAmB,EACnB,MAAmB,EACnB,WAAwB,EACxB,iBAAoC,EACpC,UAAsB,EACtB,cAA8B,EAC9B,eAA2C,EAC3C,iBAAoC,EAEpC,UAAgE,EAChE,cAAoC,EAEpC,wBAAmD,EAEnD,YAA+B,EAE/B,oBAA2C,EAE3C,aAAqC;QAErC,KAAK,CACH,MAAM,EACN,MAAM,EACN,WAAW,EACX,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,wBAAwB,EACxB,YAAY,EACZ,oBAAoB,CACrB,CAAC;QAGF,MAAM,cAAc,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAChD,IA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EAAE,KAAK,EAAE,CAAC,8BAA8B,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;QAGrE,IAAI,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAC;YAChD,MAAM,IAAI,qBAAc,CACtB,oBAAa,CAAC,qBAAqB,EACnC,mDAAmD,CACpD,CAAC;QACJ,CAAC;QAED,MAAM,gBAAgB,GAAG,WAAyF,CAAC;QACnH,OAAO;YACL,EAAE,EAAE,QAAQ,CAAC,GAAG;YAChB,KAAK,EAAE,QAAQ,CAAC,KAAK;YACrB,SAAS,EAAE,QAAQ,CAAC,UAAU,IAAI,gBAAgB,EAAE,SAAS,IAAI,IAAI;YACrE,QAAQ,EAAE,QAAQ,CAAC,WAAW,IAAI,gBAAgB,EAAE,UAAU,IAAI,IAAI;YACtE,OAAO,EAAE,QAAQ,CAAC,OAAO,IAAI,gBAAgB,EAAE,QAAQ,IAAI,IAAI;YAC/D,QAAQ,EAAE,QAAQ,CAAC,cAAc;YACjC,GAAG,EAAE,QAA8C;SACpD,CAAC;IACJ,CAAC;CACF;AAtJD,0DAsJC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { GoogleOAuthClient } from './google-oauth.client';
|
|
2
|
+
export { TokenVerifierService } from './token-verifier.service';
|
|
3
|
+
export { GoogleSocialAuthService } from './google-social-auth.service';
|
|
4
|
+
export { VerifiedGoogleTokenProfile } from './verified-token-profile.interface';
|
|
5
|
+
export * from './dto/social-login.dto';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAChF,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.GoogleSocialAuthService = exports.TokenVerifierService = exports.GoogleOAuthClient = void 0;
|
|
18
|
+
var google_oauth_client_1 = require("./google-oauth.client");
|
|
19
|
+
Object.defineProperty(exports, "GoogleOAuthClient", { enumerable: true, get: function () { return google_oauth_client_1.GoogleOAuthClient; } });
|
|
20
|
+
var token_verifier_service_1 = require("./token-verifier.service");
|
|
21
|
+
Object.defineProperty(exports, "TokenVerifierService", { enumerable: true, get: function () { return token_verifier_service_1.TokenVerifierService; } });
|
|
22
|
+
var google_social_auth_service_1 = require("./google-social-auth.service");
|
|
23
|
+
Object.defineProperty(exports, "GoogleSocialAuthService", { enumerable: true, get: function () { return google_social_auth_service_1.GoogleSocialAuthService; } });
|
|
24
|
+
__exportStar(require("./dto/social-login.dto"), exports);
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAOA,6DAA0D;AAAjD,wHAAA,iBAAiB,OAAA;AAC1B,mEAAgE;AAAvD,8HAAA,oBAAoB,OAAA;AAC7B,2EAAuE;AAA9D,qIAAA,uBAAuB,OAAA;AAEhC,yDAAuC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { NAuthConfig, ITokenVerifierService } from '@nauth-toolkit/core';
|
|
2
|
+
import { VerifiedGoogleTokenProfile } from './verified-token-profile.interface';
|
|
3
|
+
export declare class TokenVerifierService implements ITokenVerifierService {
|
|
4
|
+
private googleJWKS;
|
|
5
|
+
private readonly logger;
|
|
6
|
+
constructor(config: NAuthConfig);
|
|
7
|
+
verifyGoogleToken(idToken: string, clientId: string | string[]): Promise<VerifiedGoogleTokenProfile>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=token-verifier.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-verifier.service.d.ts","sourceRoot":"","sources":["../../src/token-verifier.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAA8C,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AACrH,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAoBhF,qBAAa,oBAAqB,YAAW,qBAAqB;IAChE,OAAO,CAAC,UAAU,CAAwC;IAC1D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;gBAEzB,MAAM,EAAE,WAAW;IA2BzB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,0BAA0B,CAAC;CA+D3G"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TokenVerifierService = void 0;
|
|
4
|
+
const jose_1 = require("jose");
|
|
5
|
+
const core_1 = require("@nauth-toolkit/core");
|
|
6
|
+
class TokenVerifierService {
|
|
7
|
+
googleJWKS;
|
|
8
|
+
logger;
|
|
9
|
+
constructor(config) {
|
|
10
|
+
this.logger = config.logger;
|
|
11
|
+
this.googleJWKS = (0, jose_1.createRemoteJWKSet)(new URL('https://www.googleapis.com/oauth2/v3/certs'));
|
|
12
|
+
}
|
|
13
|
+
async verifyGoogleToken(idToken, clientId) {
|
|
14
|
+
try {
|
|
15
|
+
const clientIds = Array.isArray(clientId) ? clientId : [clientId];
|
|
16
|
+
this.logger?.debug?.(`[TokenVerifier] Verifying Google token with ${clientIds.length} accepted client ID(s)`);
|
|
17
|
+
let verified;
|
|
18
|
+
let lastError;
|
|
19
|
+
for (const aud of clientIds) {
|
|
20
|
+
try {
|
|
21
|
+
verified = await (0, jose_1.jwtVerify)(idToken, this.googleJWKS, {
|
|
22
|
+
issuer: 'https://accounts.google.com',
|
|
23
|
+
audience: aud,
|
|
24
|
+
clockTolerance: 300,
|
|
25
|
+
});
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
lastError = err;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (!verified) {
|
|
33
|
+
const msg = lastError instanceof Error ? lastError.message : 'Unknown error';
|
|
34
|
+
throw new core_1.NAuthException(core_1.AuthErrorCode.SOCIAL_TOKEN_INVALID, `JWT verification failed: ${msg}`);
|
|
35
|
+
}
|
|
36
|
+
const payload = verified.payload;
|
|
37
|
+
if (!payload.email_verified) {
|
|
38
|
+
throw new core_1.NAuthException(core_1.AuthErrorCode.SOCIAL_EMAIL_REQUIRED, 'Google email not verified');
|
|
39
|
+
}
|
|
40
|
+
if (!payload.sub || !payload.email) {
|
|
41
|
+
throw new core_1.NAuthException(core_1.AuthErrorCode.SOCIAL_TOKEN_INVALID, 'Missing required fields in Google token (sub or email)');
|
|
42
|
+
}
|
|
43
|
+
this.logger?.log?.(`[TokenVerifier] Google token verified (secure): ${payload.email}`);
|
|
44
|
+
return {
|
|
45
|
+
sub: payload.sub,
|
|
46
|
+
email: payload.email,
|
|
47
|
+
email_verified: payload.email_verified,
|
|
48
|
+
given_name: payload.given_name,
|
|
49
|
+
family_name: payload.family_name,
|
|
50
|
+
picture: payload.picture,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
55
|
+
this.logger?.error?.(`[TokenVerifier] Google token verification FAILED: ${errorMessage}`);
|
|
56
|
+
throw new core_1.NAuthException(core_1.AuthErrorCode.SOCIAL_TOKEN_INVALID, `Google token verification failed: ${errorMessage}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.TokenVerifierService = TokenVerifierService;
|
|
61
|
+
//# sourceMappingURL=token-verifier.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-verifier.service.js","sourceRoot":"","sources":["../../src/token-verifier.service.ts"],"names":[],"mappings":";;;AAAA,+BAAiE;AACjE,8CAAqH;AAqBrH,MAAa,oBAAoB;IACvB,UAAU,CAAwC;IACzC,MAAM,CAAc;IAErC,YAAY,MAAmB;QAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAqB,CAAC;QAE3C,IAAI,CAAC,UAAU,GAAG,IAAA,yBAAkB,EAAC,IAAI,GAAG,CAAC,4CAA4C,CAAC,CAAC,CAAC;IAC9F,CAAC;IAuBD,KAAK,CAAC,iBAAiB,CAAC,OAAe,EAAE,QAA2B;QAClE,IAAI,CAAC;YAEH,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;YAClE,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC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AAO,CAAC,KAAe;gBAC9B,cAAc,EAAE,OAAO,CAAC,cAAyB;gBACjD,UAAU,EAAE,OAAO,CAAC,UAAU;gBAC9B,WAAW,EAAE,OAAO,CAAC,WAAW;gBAChC,OAAO,EAAE,OAAO,CAAC,OAAO;aACzB,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;YAC9E,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,qDAAqD,YAAY,EAAE,CAAC,CAAC;YAC1F,MAAM,IAAI,qBAAc,CAAC,oBAAa,CAAC,oBAAoB,EAAE,qCAAqC,YAAY,EAAE,CAAC,CAAC;QACpH,CAAC;IACH,CAAC;CACF;AA9FD,oDA8FC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verified-token-profile.interface.d.ts","sourceRoot":"","sources":["../../src/verified-token-profile.interface.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,0BAA0B;IAIzC,GAAG,EAAE,MAAM,CAAC;IAKZ,KAAK,EAAE,MAAM,CAAC;IAKd,cAAc,EAAE,OAAO,CAAC;IAKxB,UAAU,CAAC,EAAE,MAAM,CAAC;IAKpB,WAAW,CAAC,EAAE,MAAM,CAAC;IAKrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verified-token-profile.interface.js","sourceRoot":"","sources":["../../src/verified-token-profile.interface.ts"],"names":[],"mappings":""}
|