@vynelix/nestjs-multi-auth 0.3.2 → 1.0.0
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/CHANGELOG.md +10 -0
- package/README.md +309 -18
- package/dist/auth/auth.controller.d.ts +3 -2
- package/dist/auth/auth.controller.js +32 -5
- package/dist/auth/auth.controller.js.map +1 -1
- package/dist/auth/auth.module.js +116 -68
- package/dist/auth/auth.module.js.map +1 -1
- package/dist/auth/auth.service.d.ts +52 -25
- package/dist/auth/auth.service.js +238 -327
- package/dist/auth/auth.service.js.map +1 -1
- package/dist/auth/core/auth-mapper.d.ts +1 -1
- package/dist/auth/core/database-otp.provider.d.ts +12 -0
- package/dist/auth/core/database-otp.provider.js +122 -0
- package/dist/auth/core/database-otp.provider.js.map +1 -0
- package/dist/auth/dto/requests/magic-link.dto.d.ts +1 -0
- package/dist/auth/dto/requests/magic-link.dto.js +6 -0
- package/dist/auth/dto/requests/magic-link.dto.js.map +1 -1
- package/dist/auth/dto/requests/mfa.dto.d.ts +5 -1
- package/dist/auth/dto/requests/mfa.dto.js +29 -8
- package/dist/auth/dto/requests/mfa.dto.js.map +1 -1
- package/dist/auth/enums/identifier-type.enum.d.ts +11 -0
- package/dist/auth/enums/identifier-type.enum.js +17 -0
- package/dist/auth/enums/identifier-type.enum.js.map +1 -0
- package/dist/auth/enums/mfa-type.enum.d.ts +5 -0
- package/dist/auth/enums/mfa-type.enum.js +10 -0
- package/dist/auth/enums/mfa-type.enum.js.map +1 -0
- package/dist/auth/enums/otp-purpose.enum.d.ts +8 -0
- package/dist/auth/enums/otp-purpose.enum.js +13 -0
- package/dist/auth/enums/otp-purpose.enum.js.map +1 -0
- package/dist/auth/enums/session-event.enum.d.ts +7 -0
- package/dist/auth/enums/session-event.enum.js +12 -0
- package/dist/auth/enums/session-event.enum.js.map +1 -0
- package/dist/auth/interfaces/auth-module-options.interface.d.ts +36 -1
- package/dist/auth/interfaces/auth-notification-provider.interface.d.ts +7 -1
- package/dist/auth/interfaces/auth-otp-provider.interface.d.ts +60 -0
- package/dist/auth/interfaces/auth-otp-provider.interface.js +7 -0
- package/dist/auth/interfaces/auth-otp-provider.interface.js.map +1 -0
- package/dist/auth/interfaces/models.interface.d.ts +91 -0
- package/dist/auth/interfaces/models.interface.js +3 -0
- package/dist/auth/interfaces/models.interface.js.map +1 -0
- package/dist/auth/interfaces/oauth-strategy.interface.d.ts +2 -2
- package/dist/auth/interfaces/repositories.interface.d.ts +70 -0
- package/dist/auth/interfaces/repositories.interface.js +3 -0
- package/dist/auth/interfaces/repositories.interface.js.map +1 -0
- package/dist/auth/interfaces/repository-tokens.d.ts +7 -0
- package/dist/auth/interfaces/repository-tokens.js +11 -0
- package/dist/auth/interfaces/repository-tokens.js.map +1 -0
- package/dist/auth/interfaces/signup-event-body.interface.d.ts +1 -1
- package/dist/auth/strategies/local-auth.strategy.d.ts +3 -5
- package/dist/auth/strategies/local-auth.strategy.js +64 -99
- package/dist/auth/strategies/local-auth.strategy.js.map +1 -1
- package/dist/auth/strategies/oauth/apple.strategy.d.ts +4 -6
- package/dist/auth/strategies/oauth/apple.strategy.js +57 -70
- package/dist/auth/strategies/oauth/apple.strategy.js.map +1 -1
- package/dist/auth/strategies/oauth/facebook.strategy.d.ts +4 -6
- package/dist/auth/strategies/oauth/facebook.strategy.js +58 -71
- package/dist/auth/strategies/oauth/facebook.strategy.js.map +1 -1
- package/dist/auth/strategies/oauth/google.strategy.d.ts +4 -6
- package/dist/auth/strategies/oauth/google.strategy.js +84 -155
- package/dist/auth/strategies/oauth/google.strategy.js.map +1 -1
- package/dist/auth/strategies/oauth/oauth.strategy.d.ts +2 -2
- package/dist/database/prisma/prisma-auth.adapter.d.ts +11 -0
- package/dist/database/prisma/prisma-auth.adapter.js +64 -0
- package/dist/database/prisma/prisma-auth.adapter.js.map +1 -0
- package/dist/database/prisma/repositories/auth-identifier.repository.d.ts +16 -0
- package/dist/database/prisma/repositories/auth-identifier.repository.js +41 -0
- package/dist/database/prisma/repositories/auth-identifier.repository.js.map +1 -0
- package/dist/database/prisma/repositories/auth.repository.d.ts +19 -0
- package/dist/database/prisma/repositories/auth.repository.js +49 -0
- package/dist/database/prisma/repositories/auth.repository.js.map +1 -0
- package/dist/database/prisma/repositories/index.d.ts +7 -0
- package/dist/database/prisma/repositories/index.js +24 -0
- package/dist/database/prisma/repositories/index.js.map +1 -0
- package/dist/database/prisma/repositories/mfa-method.repository.d.ts +11 -0
- package/dist/database/prisma/repositories/mfa-method.repository.js +33 -0
- package/dist/database/prisma/repositories/mfa-method.repository.js.map +1 -0
- package/dist/database/prisma/repositories/oauth-provider.repository.d.ts +14 -0
- package/dist/database/prisma/repositories/oauth-provider.repository.js +39 -0
- package/dist/database/prisma/repositories/oauth-provider.repository.js.map +1 -0
- package/dist/database/prisma/repositories/otp-token.repository.d.ts +13 -0
- package/dist/database/prisma/repositories/otp-token.repository.js +52 -0
- package/dist/database/prisma/repositories/otp-token.repository.js.map +1 -0
- package/dist/database/prisma/repositories/session-log.repository.d.ts +12 -0
- package/dist/database/prisma/repositories/session-log.repository.js +42 -0
- package/dist/database/prisma/repositories/session-log.repository.js.map +1 -0
- package/dist/database/prisma/repositories/session.repository.d.ts +16 -0
- package/dist/database/prisma/repositories/session.repository.js +41 -0
- package/dist/database/prisma/repositories/session.repository.js.map +1 -0
- package/dist/database/typeorm/entities/auth-identify.entity.d.ts +23 -0
- package/dist/database/typeorm/entities/auth-identify.entity.js +61 -0
- package/dist/database/typeorm/entities/auth-identify.entity.js.map +1 -0
- package/dist/database/typeorm/entities/auth.entity.d.ts +45 -0
- package/dist/database/typeorm/entities/auth.entity.js +129 -0
- package/dist/database/typeorm/entities/auth.entity.js.map +1 -0
- package/dist/database/typeorm/entities/base.entity.d.ts +7 -0
- package/dist/database/typeorm/entities/base.entity.js +44 -0
- package/dist/database/typeorm/entities/base.entity.js.map +1 -0
- package/dist/database/typeorm/entities/entities.d.ts +7 -0
- package/dist/database/typeorm/entities/entities.js +18 -0
- package/dist/database/typeorm/entities/entities.js.map +1 -0
- package/dist/database/typeorm/entities/mfa-method.entity.d.ts +10 -0
- package/dist/database/typeorm/entities/mfa-method.entity.js +47 -0
- package/dist/database/typeorm/entities/mfa-method.entity.js.map +1 -0
- package/dist/database/typeorm/entities/oauth-provider.entity.d.ts +38 -0
- package/dist/database/typeorm/entities/oauth-provider.entity.js +88 -0
- package/dist/database/typeorm/entities/oauth-provider.entity.js.map +1 -0
- package/dist/database/typeorm/entities/otp-token.entity.d.ts +15 -0
- package/dist/database/typeorm/entities/otp-token.entity.js +53 -0
- package/dist/database/typeorm/entities/otp-token.entity.js.map +1 -0
- package/dist/database/typeorm/entities/session.entity.d.ts +21 -0
- package/dist/database/typeorm/entities/session.entity.js +71 -0
- package/dist/database/typeorm/entities/session.entity.js.map +1 -0
- package/dist/database/typeorm/entities/session_log.entity.d.ts +25 -0
- package/dist/database/typeorm/entities/session_log.entity.js +78 -0
- package/dist/database/typeorm/entities/session_log.entity.js.map +1 -0
- package/dist/database/typeorm/migrations/auth-entities.d.ts +7 -0
- package/dist/database/typeorm/migrations/auth-entities.js +18 -0
- package/dist/database/typeorm/migrations/auth-entities.js.map +1 -0
- package/dist/database/typeorm/migrations/auth-schema.initializer.d.ts +9 -0
- package/dist/database/typeorm/migrations/auth-schema.initializer.js +36 -0
- package/dist/database/typeorm/migrations/auth-schema.initializer.js.map +1 -0
- package/dist/database/typeorm/migrations/auth.migration.v1.d.ts +12 -0
- package/dist/database/typeorm/migrations/auth.migration.v1.js +157 -0
- package/dist/database/typeorm/migrations/auth.migration.v1.js.map +1 -0
- package/dist/database/typeorm/migrations/auth.migration.v2.d.ts +8 -0
- package/dist/database/typeorm/migrations/auth.migration.v2.js +23 -0
- package/dist/database/typeorm/migrations/auth.migration.v2.js.map +1 -0
- package/dist/database/typeorm/migrations/auth.migrations.d.ts +2 -0
- package/dist/database/typeorm/migrations/auth.migrations.js +10 -0
- package/dist/database/typeorm/migrations/auth.migrations.js.map +1 -0
- package/dist/database/typeorm/migrations/migration.service.d.ts +9 -0
- package/dist/database/typeorm/migrations/migration.service.js +75 -0
- package/dist/database/typeorm/migrations/migration.service.js.map +1 -0
- package/dist/database/typeorm/repositories/auth-identifier.repository.d.ts +18 -0
- package/dist/database/typeorm/repositories/auth-identifier.repository.js +64 -0
- package/dist/database/typeorm/repositories/auth-identifier.repository.js.map +1 -0
- package/dist/database/typeorm/repositories/auth.repository.d.ts +21 -0
- package/dist/database/typeorm/repositories/auth.repository.js +71 -0
- package/dist/database/typeorm/repositories/auth.repository.js.map +1 -0
- package/dist/database/typeorm/repositories/index.d.ts +7 -0
- package/dist/database/typeorm/repositories/index.js +24 -0
- package/dist/database/typeorm/repositories/index.js.map +1 -0
- package/dist/database/typeorm/repositories/mfa-method.repository.d.ts +13 -0
- package/dist/database/typeorm/repositories/mfa-method.repository.js +46 -0
- package/dist/database/typeorm/repositories/mfa-method.repository.js.map +1 -0
- package/dist/database/typeorm/repositories/oauth-provider.repository.d.ts +16 -0
- package/dist/database/typeorm/repositories/oauth-provider.repository.js +52 -0
- package/dist/database/typeorm/repositories/oauth-provider.repository.js.map +1 -0
- package/dist/database/typeorm/repositories/otp-token.repository.d.ts +13 -0
- package/dist/database/typeorm/repositories/otp-token.repository.js +52 -0
- package/dist/database/typeorm/repositories/otp-token.repository.js.map +1 -0
- package/dist/database/typeorm/repositories/session-log.repository.d.ts +12 -0
- package/dist/database/typeorm/repositories/session-log.repository.js +47 -0
- package/dist/database/typeorm/repositories/session-log.repository.js.map +1 -0
- package/dist/database/typeorm/repositories/session.repository.d.ts +18 -0
- package/dist/database/typeorm/repositories/session.repository.js +84 -0
- package/dist/database/typeorm/repositories/session.repository.js.map +1 -0
- package/dist/database/typeorm/typeorm-auth.adapter.d.ts +2 -0
- package/dist/database/typeorm/typeorm-auth.adapter.js +50 -0
- package/dist/database/typeorm/typeorm-auth.adapter.js.map +1 -0
- package/dist/index.d.ts +11 -9
- package/dist/index.js +18 -10
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/fix-imports.js +46 -0
- package/fix-syntax.js +66 -0
- package/package.json +22 -20
- package/patch-local-specs.js +52 -0
- package/patch-oauth-specs.js +41 -0
- package/patch-specs.js +36 -0
- package/prompts/database_adapter.md +157 -0
- package/prompts/otp_provider.md +292 -0
- package/scratch/create-prisma-repos-final.js +139 -0
- package/scratch/create-prisma-repos.js +280 -0
- package/scratch/fix-events-spec.js +12 -0
- package/scratch/fix-imports.js +53 -0
- package/scratch/fix-prisma-interfaces.js +41 -0
- package/scratch/fix-prisma-interfaces2.js +36 -0
- package/scratch/fix-prisma-interfaces3.js +26 -0
- package/scratch/fix-prisma.js +28 -0
- package/scratch/fix-test-imports.js +51 -0
- package/scratch/fix-tests-advanced.js +68 -0
- package/scratch/fix-tests-advanced2.js +23 -0
- package/scratch/fix-tests-concrete.js +40 -0
- package/scratch/fix-tests-final.js +35 -0
- package/scratch/fix-tests-final2.js +28 -0
- package/scratch/fix-tests-final3.js +26 -0
- package/scratch/fix-tests-methods.js +40 -0
- package/scratch/fix-tests-proxy.js +67 -0
- package/scratch/fix-tests-types.js +24 -0
- package/scratch/rewrite-tests.js +110 -0
- package/tsc_errors.txt +60 -0
- package/tsc_errors2.txt +93 -0
- package/tmp-cv-test/package-lock.json +0 -250
- package/tmp-cv-test/package.json +0 -17
- package/tmp-cv-test/test.ts +0 -11
|
@@ -14,19 +14,16 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.AppleAuthStrategy = void 0;
|
|
16
16
|
const common_1 = require("@nestjs/common");
|
|
17
|
-
const
|
|
18
|
-
const typeorm_2 = require("@nestjs/typeorm");
|
|
19
|
-
const auth_entity_1 = require("../../entities/auth.entity");
|
|
20
|
-
const oauth_provider_entity_1 = require("../../entities/oauth-provider.entity");
|
|
21
|
-
const auth_identify_entity_1 = require("../../entities/auth-identify.entity");
|
|
17
|
+
const identifier_type_enum_1 = require("../../enums/identifier-type.enum");
|
|
22
18
|
const auth_type_enum_1 = require("../../enums/auth-type.enum");
|
|
23
19
|
const auth_module_options_interface_1 = require("../../interfaces/auth-module-options.interface");
|
|
24
20
|
const crypto_1 = require("crypto");
|
|
25
21
|
const jwt = require("jsonwebtoken");
|
|
22
|
+
const repository_tokens_1 = require("../../interfaces/repository-tokens");
|
|
26
23
|
let AppleAuthStrategy = class AppleAuthStrategy {
|
|
27
|
-
constructor(
|
|
28
|
-
this.dataSource = dataSource;
|
|
24
|
+
constructor(authRepo, identifierRepo, oauthProviderRepo, options) {
|
|
29
25
|
this.authRepo = authRepo;
|
|
26
|
+
this.identifierRepo = identifierRepo;
|
|
30
27
|
this.oauthProviderRepo = oauthProviderRepo;
|
|
31
28
|
this.options = options;
|
|
32
29
|
this.applePublicKeys = [];
|
|
@@ -88,59 +85,51 @@ let AppleAuthStrategy = class AppleAuthStrategy {
|
|
|
88
85
|
const payload = await this.verifyToken(dto.token);
|
|
89
86
|
const appleId = payload.sub;
|
|
90
87
|
const email = payload.email?.toLowerCase();
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
});
|
|
100
|
-
if (existingProvider) {
|
|
101
|
-
throw new common_1.BadRequestException('This Apple account is already linked to a user');
|
|
102
|
-
}
|
|
103
|
-
// Check if email identifier is already taken
|
|
104
|
-
if (email) {
|
|
105
|
-
const existingIdentifier = await identifierRepo.findOne({
|
|
106
|
-
where: { value: email, type: auth_identify_entity_1.IdentifierType.EMAIL },
|
|
107
|
-
});
|
|
108
|
-
if (existingIdentifier) {
|
|
109
|
-
throw new common_1.BadRequestException('A user with this email already exists');
|
|
110
|
-
}
|
|
88
|
+
const existingProvider = await this.oauthProviderRepo.findByProviderUserId(auth_type_enum_1.OAuthProviderType.APPLE, appleId);
|
|
89
|
+
if (existingProvider) {
|
|
90
|
+
throw new common_1.BadRequestException('This Apple account is already linked to a user');
|
|
91
|
+
}
|
|
92
|
+
if (email) {
|
|
93
|
+
const existingIdentifier = await this.identifierRepo.findByValue(email);
|
|
94
|
+
if (existingIdentifier) {
|
|
95
|
+
throw new common_1.BadRequestException('A user with this email already exists');
|
|
111
96
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
97
|
+
}
|
|
98
|
+
const identityUid = uid || (0, crypto_1.randomUUID)();
|
|
99
|
+
const newAuth = await this.authRepo.create({
|
|
100
|
+
uid: identityUid,
|
|
101
|
+
strategy: auth_type_enum_1.AuthStrategy.OAUTH,
|
|
102
|
+
isActive: true,
|
|
103
|
+
isVerified: payload.email_verified === 'true' || payload.email_verified === true,
|
|
104
|
+
isPrimary: true,
|
|
105
|
+
createdAt: new Date(),
|
|
106
|
+
updatedAt: new Date(),
|
|
107
|
+
});
|
|
108
|
+
const identifiers = [];
|
|
109
|
+
if (email) {
|
|
110
|
+
identifiers.push(await this.identifierRepo.create({
|
|
111
|
+
auth: newAuth,
|
|
112
|
+
type: identifier_type_enum_1.IdentifierType.EMAIL,
|
|
113
|
+
value: email,
|
|
117
114
|
isVerified: payload.email_verified === 'true' || payload.email_verified === true,
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
provider: auth_type_enum_1.OAuthProviderType.APPLE,
|
|
133
|
-
providerUserId: appleId,
|
|
134
|
-
expiresAt: payload.exp ? new Date(payload.exp * 1000) : undefined,
|
|
135
|
-
rawProfile: payload,
|
|
136
|
-
emailVerified: payload.email_verified === 'true' || payload.email_verified === true,
|
|
137
|
-
displayName: payload.name?.displayName,
|
|
138
|
-
avatarUrl: payload.picture,
|
|
139
|
-
});
|
|
140
|
-
newAuth.oauthProviders = [...(newAuth.oauthProviders || []), oauthProvider];
|
|
141
|
-
const savedAuth = await authRepo.save(newAuth);
|
|
142
|
-
return { auth: savedAuth, identifier: savedAuth.identifiers?.[0] };
|
|
115
|
+
source: identifier_type_enum_1.IdentifierSource.APPLE,
|
|
116
|
+
verifiedBy: payload.email_verified ? 'PROVIDER' : undefined,
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
119
|
+
newAuth.identifiers = identifiers;
|
|
120
|
+
const oauthProvider = await this.oauthProviderRepo.create({
|
|
121
|
+
auth: newAuth,
|
|
122
|
+
provider: auth_type_enum_1.OAuthProviderType.APPLE,
|
|
123
|
+
providerUserId: appleId,
|
|
124
|
+
expiresAt: payload.exp ? new Date(payload.exp * 1000) : undefined,
|
|
125
|
+
rawProfile: payload,
|
|
126
|
+
emailVerified: payload.email_verified === 'true' || payload.email_verified === true,
|
|
127
|
+
displayName: payload.name?.displayName,
|
|
128
|
+
avatarUrl: payload.picture,
|
|
143
129
|
});
|
|
130
|
+
newAuth.oauthProviders = [oauthProvider];
|
|
131
|
+
const savedAuth = await this.authRepo.save(newAuth);
|
|
132
|
+
return { auth: savedAuth, identifier: savedAuth.identifiers?.[0] };
|
|
144
133
|
}
|
|
145
134
|
async login(dto) {
|
|
146
135
|
if (!dto.token) {
|
|
@@ -148,29 +137,27 @@ let AppleAuthStrategy = class AppleAuthStrategy {
|
|
|
148
137
|
}
|
|
149
138
|
const payload = await this.verifyToken(dto.token);
|
|
150
139
|
const appleId = payload.sub;
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
relations: ['auth', 'auth.identifiers'],
|
|
154
|
-
});
|
|
155
|
-
if (!oauthProvider || !oauthProvider.auth) {
|
|
140
|
+
const result = await this.oauthProviderRepo.findWithAuthByProviderUserId(auth_type_enum_1.OAuthProviderType.APPLE, appleId);
|
|
141
|
+
if (!result || !result.auth) {
|
|
156
142
|
throw new common_1.BadRequestException('No account found linked to this Apple account');
|
|
157
143
|
}
|
|
158
|
-
const
|
|
144
|
+
const oauthProvider = result.provider;
|
|
145
|
+
const auth = result.auth;
|
|
159
146
|
auth.lastUsedAt = new Date();
|
|
160
147
|
await this.authRepo.save(auth);
|
|
161
148
|
const email = payload.email?.toLowerCase();
|
|
162
|
-
const
|
|
163
|
-
|
|
149
|
+
const updatedAuth = await this.authRepo.findWithIdentifiers(auth.id);
|
|
150
|
+
const identifier = updatedAuth?.identifiers?.find(id => id.value === email);
|
|
151
|
+
return { auth: updatedAuth || auth, identifier: identifier || undefined };
|
|
164
152
|
}
|
|
165
153
|
};
|
|
166
154
|
exports.AppleAuthStrategy = AppleAuthStrategy;
|
|
167
155
|
exports.AppleAuthStrategy = AppleAuthStrategy = __decorate([
|
|
168
156
|
(0, common_1.Injectable)(),
|
|
169
|
-
__param(
|
|
170
|
-
__param(
|
|
157
|
+
__param(0, (0, common_1.Inject)(repository_tokens_1.AUTH_REPOSITORY_TOKEN)),
|
|
158
|
+
__param(1, (0, common_1.Inject)(repository_tokens_1.AUTH_IDENTIFIER_REPOSITORY_TOKEN)),
|
|
159
|
+
__param(2, (0, common_1.Inject)(repository_tokens_1.OAUTH_PROVIDER_REPOSITORY_TOKEN)),
|
|
171
160
|
__param(3, (0, common_1.Inject)(auth_module_options_interface_1.AUTH_MODULE_OPTIONS)),
|
|
172
|
-
__metadata("design:paramtypes", [
|
|
173
|
-
typeorm_1.Repository,
|
|
174
|
-
typeorm_1.Repository, Object])
|
|
161
|
+
__metadata("design:paramtypes", [Object, Object, Object, Object])
|
|
175
162
|
], AppleAuthStrategy);
|
|
176
163
|
//# sourceMappingURL=apple.strategy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apple.strategy.js","sourceRoot":"","sources":["../../../../src/auth/strategies/oauth/apple.strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAyE;
|
|
1
|
+
{"version":3,"file":"apple.strategy.js","sourceRoot":"","sources":["../../../../src/auth/strategies/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BAAiB;IAD7B,IAAA,mBAAU,GAAE;IAMJ,WAAA,IAAA,eAAM,EAAC,yCAAqB,CAAC,CAAA;IAC7B,WAAA,IAAA,eAAM,EAAC,oDAAgC,CAAC,CAAA;IACxC,WAAA,IAAA,eAAM,EAAC,mDAA+B,CAAC,CAAA;IACvC,WAAA,IAAA,eAAM,EAAC,mDAAmB,CAAC,CAAA;;GARvB,iBAAiB,CAgK7B"}
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import { DataSource, Repository } from 'typeorm';
|
|
2
1
|
import { LoginDto } from '../../dto/requests/login.dto';
|
|
3
2
|
import { SignupDto } from '../../dto/requests/signup.dto';
|
|
4
|
-
import { Auth } from '../../
|
|
5
|
-
import { OAuthProvider } from '../../entities/oauth-provider.entity';
|
|
6
|
-
import { AuthIdentifier } from '../../entities/auth-identify.entity';
|
|
3
|
+
import { Auth, AuthIdentifier } from '../../interfaces/models.interface';
|
|
7
4
|
import { AuthModuleOptions } from '../../interfaces/auth-module-options.interface';
|
|
8
5
|
import { IOAuthStrategy } from '../../interfaces/oauth-strategy.interface';
|
|
6
|
+
import { AuthRepository, AuthIdentifierRepository, OAuthProviderRepository } from '../../interfaces/repositories.interface';
|
|
9
7
|
export declare class FacebookAuthStrategy implements IOAuthStrategy {
|
|
10
|
-
private readonly dataSource;
|
|
11
8
|
private authRepo;
|
|
9
|
+
private identifierRepo;
|
|
12
10
|
private oauthProviderRepo;
|
|
13
11
|
private options;
|
|
14
|
-
constructor(
|
|
12
|
+
constructor(authRepo: AuthRepository, identifierRepo: AuthIdentifierRepository, oauthProviderRepo: OAuthProviderRepository, options: AuthModuleOptions);
|
|
15
13
|
private verifyToken;
|
|
16
14
|
registerCredentials(dto: SignupDto, uid?: string): Promise<{
|
|
17
15
|
auth: Auth;
|
|
@@ -14,18 +14,15 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.FacebookAuthStrategy = void 0;
|
|
16
16
|
const common_1 = require("@nestjs/common");
|
|
17
|
-
const
|
|
18
|
-
const typeorm_2 = require("@nestjs/typeorm");
|
|
19
|
-
const auth_entity_1 = require("../../entities/auth.entity");
|
|
20
|
-
const oauth_provider_entity_1 = require("../../entities/oauth-provider.entity");
|
|
21
|
-
const auth_identify_entity_1 = require("../../entities/auth-identify.entity");
|
|
17
|
+
const identifier_type_enum_1 = require("../../enums/identifier-type.enum");
|
|
22
18
|
const auth_type_enum_1 = require("../../enums/auth-type.enum");
|
|
23
19
|
const auth_module_options_interface_1 = require("../../interfaces/auth-module-options.interface");
|
|
24
20
|
const crypto_1 = require("crypto");
|
|
21
|
+
const repository_tokens_1 = require("../../interfaces/repository-tokens");
|
|
25
22
|
let FacebookAuthStrategy = class FacebookAuthStrategy {
|
|
26
|
-
constructor(
|
|
27
|
-
this.dataSource = dataSource;
|
|
23
|
+
constructor(authRepo, identifierRepo, oauthProviderRepo, options) {
|
|
28
24
|
this.authRepo = authRepo;
|
|
25
|
+
this.identifierRepo = identifierRepo;
|
|
29
26
|
this.oauthProviderRepo = oauthProviderRepo;
|
|
30
27
|
this.options = options;
|
|
31
28
|
}
|
|
@@ -62,59 +59,51 @@ let FacebookAuthStrategy = class FacebookAuthStrategy {
|
|
|
62
59
|
const payload = await this.verifyToken(dto.token);
|
|
63
60
|
const facebookId = payload.id;
|
|
64
61
|
const email = payload.email?.toLowerCase();
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
});
|
|
74
|
-
if (existingProvider) {
|
|
75
|
-
throw new common_1.BadRequestException('This Facebook account is already linked to a user');
|
|
76
|
-
}
|
|
77
|
-
// Check if email identifier is already taken
|
|
78
|
-
if (email) {
|
|
79
|
-
const existingIdentifier = await identifierRepo.findOne({
|
|
80
|
-
where: { value: email, type: auth_identify_entity_1.IdentifierType.EMAIL },
|
|
81
|
-
});
|
|
82
|
-
if (existingIdentifier) {
|
|
83
|
-
throw new common_1.BadRequestException('A user with this email already exists');
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
const identityUid = uid || (0, crypto_1.randomUUID)();
|
|
87
|
-
const newAuth = authRepo.create({
|
|
88
|
-
uid: identityUid,
|
|
89
|
-
strategy: auth_type_enum_1.AuthStrategy.OAUTH,
|
|
90
|
-
isActive: true,
|
|
91
|
-
isVerified: true, // Facebook verifies emails
|
|
92
|
-
isPrimary: true,
|
|
93
|
-
});
|
|
94
|
-
const identifiers = [];
|
|
95
|
-
if (email) {
|
|
96
|
-
identifiers.push(identifierRepo.create({
|
|
97
|
-
type: auth_identify_entity_1.IdentifierType.EMAIL,
|
|
98
|
-
value: email,
|
|
99
|
-
isVerified: true,
|
|
100
|
-
source: auth_identify_entity_1.IdentifierSource.FACEBOOK,
|
|
101
|
-
verifiedBy: 'PROVIDER',
|
|
102
|
-
}));
|
|
62
|
+
const existingProvider = await this.oauthProviderRepo.findByProviderUserId(auth_type_enum_1.OAuthProviderType.FACEBOOK, facebookId);
|
|
63
|
+
if (existingProvider) {
|
|
64
|
+
throw new common_1.BadRequestException('This Facebook account is already linked to a user');
|
|
65
|
+
}
|
|
66
|
+
if (email) {
|
|
67
|
+
const existingIdentifier = await this.identifierRepo.findByValue(email);
|
|
68
|
+
if (existingIdentifier) {
|
|
69
|
+
throw new common_1.BadRequestException('A user with this email already exists');
|
|
103
70
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
newAuth.oauthProviders = [...(newAuth.oauthProviders || []), oauthProvider];
|
|
115
|
-
const savedAuth = await authRepo.save(newAuth);
|
|
116
|
-
return { auth: savedAuth, identifier: savedAuth.identifiers?.[0] };
|
|
71
|
+
}
|
|
72
|
+
const identityUid = uid || (0, crypto_1.randomUUID)();
|
|
73
|
+
const newAuth = await this.authRepo.create({
|
|
74
|
+
uid: identityUid,
|
|
75
|
+
strategy: auth_type_enum_1.AuthStrategy.OAUTH,
|
|
76
|
+
isActive: true,
|
|
77
|
+
isVerified: true, // Facebook verifies emails
|
|
78
|
+
isPrimary: true,
|
|
79
|
+
createdAt: new Date(),
|
|
80
|
+
updatedAt: new Date(),
|
|
117
81
|
});
|
|
82
|
+
const identifiers = [];
|
|
83
|
+
if (email) {
|
|
84
|
+
identifiers.push(await this.identifierRepo.create({
|
|
85
|
+
auth: newAuth,
|
|
86
|
+
type: identifier_type_enum_1.IdentifierType.EMAIL,
|
|
87
|
+
value: email,
|
|
88
|
+
isVerified: true,
|
|
89
|
+
source: identifier_type_enum_1.IdentifierSource.FACEBOOK,
|
|
90
|
+
verifiedBy: 'PROVIDER',
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
newAuth.identifiers = identifiers;
|
|
94
|
+
const oauthProvider = await this.oauthProviderRepo.create({
|
|
95
|
+
auth: newAuth,
|
|
96
|
+
provider: auth_type_enum_1.OAuthProviderType.FACEBOOK,
|
|
97
|
+
providerUserId: facebookId,
|
|
98
|
+
expiresAt: payload.exp ? new Date(payload.exp * 1000) : undefined,
|
|
99
|
+
rawProfile: payload,
|
|
100
|
+
emailVerified: payload.email_verified === 'true' || payload.email_verified === true,
|
|
101
|
+
displayName: payload.name,
|
|
102
|
+
avatarUrl: payload.picture,
|
|
103
|
+
});
|
|
104
|
+
newAuth.oauthProviders = [oauthProvider];
|
|
105
|
+
const savedAuth = await this.authRepo.save(newAuth);
|
|
106
|
+
return { auth: savedAuth, identifier: savedAuth.identifiers?.[0] };
|
|
118
107
|
}
|
|
119
108
|
async login(dto) {
|
|
120
109
|
if (!dto.token) {
|
|
@@ -122,29 +111,27 @@ let FacebookAuthStrategy = class FacebookAuthStrategy {
|
|
|
122
111
|
}
|
|
123
112
|
const payload = await this.verifyToken(dto.token);
|
|
124
113
|
const facebookId = payload.id;
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
relations: ['auth', 'auth.identifiers'],
|
|
128
|
-
});
|
|
129
|
-
if (!oauthProvider || !oauthProvider.auth) {
|
|
114
|
+
const result = await this.oauthProviderRepo.findWithAuthByProviderUserId(auth_type_enum_1.OAuthProviderType.FACEBOOK, facebookId);
|
|
115
|
+
if (!result || !result.auth) {
|
|
130
116
|
throw new common_1.BadRequestException('No account found linked to this Facebook account');
|
|
131
117
|
}
|
|
132
|
-
const
|
|
118
|
+
const oauthProvider = result.provider;
|
|
119
|
+
const auth = result.auth;
|
|
133
120
|
auth.lastUsedAt = new Date();
|
|
134
121
|
await this.authRepo.save(auth);
|
|
135
122
|
const email = payload.email?.toLowerCase();
|
|
136
|
-
const
|
|
137
|
-
|
|
123
|
+
const updatedAuth = await this.authRepo.findWithIdentifiers(auth.id);
|
|
124
|
+
const identifier = updatedAuth?.identifiers?.find(id => id.value === email);
|
|
125
|
+
return { auth: updatedAuth || auth, identifier: identifier || undefined };
|
|
138
126
|
}
|
|
139
127
|
};
|
|
140
128
|
exports.FacebookAuthStrategy = FacebookAuthStrategy;
|
|
141
129
|
exports.FacebookAuthStrategy = FacebookAuthStrategy = __decorate([
|
|
142
130
|
(0, common_1.Injectable)(),
|
|
143
|
-
__param(
|
|
144
|
-
__param(
|
|
131
|
+
__param(0, (0, common_1.Inject)(repository_tokens_1.AUTH_REPOSITORY_TOKEN)),
|
|
132
|
+
__param(1, (0, common_1.Inject)(repository_tokens_1.AUTH_IDENTIFIER_REPOSITORY_TOKEN)),
|
|
133
|
+
__param(2, (0, common_1.Inject)(repository_tokens_1.OAUTH_PROVIDER_REPOSITORY_TOKEN)),
|
|
145
134
|
__param(3, (0, common_1.Inject)(auth_module_options_interface_1.AUTH_MODULE_OPTIONS)),
|
|
146
|
-
__metadata("design:paramtypes", [
|
|
147
|
-
typeorm_1.Repository,
|
|
148
|
-
typeorm_1.Repository, Object])
|
|
135
|
+
__metadata("design:paramtypes", [Object, Object, Object, Object])
|
|
149
136
|
], FacebookAuthStrategy);
|
|
150
137
|
//# sourceMappingURL=facebook.strategy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"facebook.strategy.js","sourceRoot":"","sources":["../../../../src/auth/strategies/oauth/facebook.strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAyE;
|
|
1
|
+
{"version":3,"file":"facebook.strategy.js","sourceRoot":"","sources":["../../../../src/auth/strategies/oauth/facebook.strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAyE;AAIzE,2EAAoF;AACpF,+DAA6E;AAC7E,kGAAwG;AAExG,mCAAgD;AAChD,0EAA8I;AAIvI,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAC7B,YAC2C,QAAwB,EACb,cAAwC,EACzC,iBAA0C,EACtD,OAA0B;QAHxB,aAAQ,GAAR,QAAQ,CAAgB;QACb,mBAAc,GAAd,cAAc,CAA0B;QACzC,sBAAiB,GAAjB,iBAAiB,CAAyB;QACtD,YAAO,GAAP,OAAO,CAAmB;IAC/D,CAAC;IAEG,KAAK,CAAC,WAAW,CAAC,KAAa;QACnC,IAAI,CAAC;YACD,6DAA6D;YAC7D,IAAI,cAAc,GAAG,EAAE,CAAC;YACxB,IAAI,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC;gBACjC,cAAc,GAAG,IAAA,mBAAU,EAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC;qBAChE,MAAM,CAAC,KAAK,CAAC;qBACb,MAAM,CAAC,KAAK,CAAC,CAAC;YACvB,CAAC;YAED,MAAM,GAAG,GAAG,mFAAmF,KAAK,GAAG,cAAc,CAAC,CAAC,CAAC,oBAAoB,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;YAEpK,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;YAClC,MAAM,IAAI,GAAG,MAAM,QAA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AC,EAAE,CAAC,CAAC;QACrE,MAAM,UAAU,GAAG,WAAW,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;QAE5E,OAAO,EAAE,IAAI,EAAE,WAAW,IAAI,IAAI,EAAE,UAAU,EAAE,UAAU,IAAI,SAAS,EAAE,CAAC;IAC9E,CAAC;CACJ,CAAA;AApIY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;IAGJ,WAAA,IAAA,eAAM,EAAC,yCAAqB,CAAC,CAAA;IAC7B,WAAA,IAAA,eAAM,EAAC,oDAAgC,CAAC,CAAA;IACxC,WAAA,IAAA,eAAM,EAAC,mDAA+B,CAAC,CAAA;IACvC,WAAA,IAAA,eAAM,EAAC,mDAAmB,CAAC,CAAA;;GALvB,oBAAoB,CAoIhC"}
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Auth } from '../../entities/auth.entity';
|
|
3
|
-
import { OAuthProvider } from '../../entities/oauth-provider.entity';
|
|
4
|
-
import { AuthIdentifier } from '../../entities/auth-identify.entity';
|
|
1
|
+
import { Auth, AuthIdentifier } from '../../interfaces/models.interface';
|
|
5
2
|
import { AuthModuleOptions } from '../../interfaces/auth-module-options.interface';
|
|
6
3
|
import { IOAuthStrategy } from '../../interfaces/oauth-strategy.interface';
|
|
7
4
|
import { LoginDto } from '../../dto/requests/login.dto';
|
|
8
5
|
import { SignupDto } from '../../dto/requests/signup.dto';
|
|
6
|
+
import { AuthRepository, AuthIdentifierRepository, OAuthProviderRepository } from '../../interfaces/repositories.interface';
|
|
9
7
|
export declare class GoogleAuthStrategy implements IOAuthStrategy {
|
|
10
|
-
private readonly dataSource;
|
|
11
8
|
private authRepo;
|
|
9
|
+
private identifierRepo;
|
|
12
10
|
private oauthProviderRepo;
|
|
13
11
|
private options;
|
|
14
12
|
private client;
|
|
15
|
-
constructor(
|
|
13
|
+
constructor(authRepo: AuthRepository, identifierRepo: AuthIdentifierRepository, oauthProviderRepo: OAuthProviderRepository, options: AuthModuleOptions);
|
|
16
14
|
private verifyToken;
|
|
17
15
|
registerCredentials(dto: SignupDto, uid?: string): Promise<{
|
|
18
16
|
auth: Auth;
|