@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
|
@@ -13,21 +13,17 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.GoogleAuthStrategy = void 0;
|
|
16
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
17
16
|
const common_1 = require("@nestjs/common");
|
|
18
|
-
const typeorm_1 = require("typeorm");
|
|
19
|
-
const typeorm_2 = require("@nestjs/typeorm");
|
|
20
17
|
const google_auth_library_1 = require("google-auth-library");
|
|
21
|
-
const
|
|
22
|
-
const oauth_provider_entity_1 = require("../../entities/oauth-provider.entity");
|
|
23
|
-
const auth_identify_entity_1 = require("../../entities/auth-identify.entity");
|
|
18
|
+
const identifier_type_enum_1 = require("../../enums/identifier-type.enum");
|
|
24
19
|
const auth_module_options_interface_1 = require("../../interfaces/auth-module-options.interface");
|
|
25
20
|
const crypto_1 = require("crypto");
|
|
26
21
|
const auth_type_enum_1 = require("../../enums/auth-type.enum");
|
|
22
|
+
const repository_tokens_1 = require("../../interfaces/repository-tokens");
|
|
27
23
|
let GoogleAuthStrategy = class GoogleAuthStrategy {
|
|
28
|
-
constructor(
|
|
29
|
-
this.dataSource = dataSource;
|
|
24
|
+
constructor(authRepo, identifierRepo, oauthProviderRepo, options) {
|
|
30
25
|
this.authRepo = authRepo;
|
|
26
|
+
this.identifierRepo = identifierRepo;
|
|
31
27
|
this.oauthProviderRepo = oauthProviderRepo;
|
|
32
28
|
this.options = options;
|
|
33
29
|
this.client = new google_auth_library_1.OAuth2Client(this.options.googleClientId);
|
|
@@ -55,80 +51,51 @@ let GoogleAuthStrategy = class GoogleAuthStrategy {
|
|
|
55
51
|
const payload = await this.verifyToken(dto.token);
|
|
56
52
|
const googleId = payload.sub;
|
|
57
53
|
const email = payload.email?.toLowerCase();
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
});
|
|
67
|
-
if (existingProvider) {
|
|
68
|
-
throw new common_1.BadRequestException('This Google account is already linked to a user');
|
|
69
|
-
}
|
|
70
|
-
// Check if email identifier is already taken
|
|
71
|
-
if (email) {
|
|
72
|
-
const existingIdentifier = await identifierRepo.findOne({
|
|
73
|
-
where: { value: email, type: auth_identify_entity_1.IdentifierType.EMAIL },
|
|
74
|
-
});
|
|
75
|
-
if (existingIdentifier) {
|
|
76
|
-
throw new common_1.BadRequestException('A user with this email already exists. Please login instead.');
|
|
77
|
-
}
|
|
54
|
+
const existingProvider = await this.oauthProviderRepo.findByProviderUserId(auth_type_enum_1.OAuthProviderType.GOOGLE, googleId);
|
|
55
|
+
if (existingProvider) {
|
|
56
|
+
throw new common_1.BadRequestException('This Google account is already linked to a user');
|
|
57
|
+
}
|
|
58
|
+
if (email) {
|
|
59
|
+
const existingIdentifier = await this.identifierRepo.findByValue(email);
|
|
60
|
+
if (existingIdentifier) {
|
|
61
|
+
throw new common_1.BadRequestException('A user with this email already exists. Please login instead.');
|
|
78
62
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
63
|
+
}
|
|
64
|
+
const identityUid = uid || (0, crypto_1.randomUUID)();
|
|
65
|
+
const newAuth = await this.authRepo.create({
|
|
66
|
+
uid: identityUid,
|
|
67
|
+
strategy: auth_type_enum_1.AuthStrategy.OAUTH,
|
|
68
|
+
isActive: true,
|
|
69
|
+
isVerified: this.options.forceVerificationOnGoogleSignup ? false : (payload.email_verified || false),
|
|
70
|
+
isPrimary: true,
|
|
71
|
+
createdAt: new Date(),
|
|
72
|
+
updatedAt: new Date(),
|
|
73
|
+
});
|
|
74
|
+
const identifiers = [];
|
|
75
|
+
if (email) {
|
|
76
|
+
identifiers.push(await this.identifierRepo.create({
|
|
77
|
+
auth: newAuth,
|
|
78
|
+
type: identifier_type_enum_1.IdentifierType.EMAIL,
|
|
79
|
+
value: email,
|
|
84
80
|
isVerified: this.options.forceVerificationOnGoogleSignup ? false : (payload.email_verified || false),
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
provider: auth_type_enum_1.OAuthProviderType.GOOGLE,
|
|
100
|
-
providerUserId: googleId,
|
|
101
|
-
rawProfile: payload,
|
|
102
|
-
displayName: payload.name,
|
|
103
|
-
avatarUrl: payload.picture,
|
|
104
|
-
emailVerified: payload.email_verified,
|
|
105
|
-
expiresAt: payload.exp ? new Date(payload.exp * 1000) : undefined,
|
|
106
|
-
});
|
|
107
|
-
newAuth.oauthProviders = [...(newAuth.oauthProviders || []), oauthProvider];
|
|
108
|
-
return { auth: await authRepo.save(newAuth), identifier: newAuth.identifiers?.[0] };
|
|
81
|
+
source: identifier_type_enum_1.IdentifierSource.GOOGLE,
|
|
82
|
+
verifiedBy: payload.email_verified ? 'PROVIDER' : undefined,
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
newAuth.identifiers = identifiers;
|
|
86
|
+
const oauthProvider = await this.oauthProviderRepo.create({
|
|
87
|
+
auth: newAuth,
|
|
88
|
+
provider: auth_type_enum_1.OAuthProviderType.GOOGLE,
|
|
89
|
+
providerUserId: googleId,
|
|
90
|
+
rawProfile: payload,
|
|
91
|
+
displayName: payload.name,
|
|
92
|
+
avatarUrl: payload.picture,
|
|
93
|
+
emailVerified: payload.email_verified,
|
|
94
|
+
expiresAt: payload.exp ? new Date(payload.exp * 1000) : undefined,
|
|
109
95
|
});
|
|
96
|
+
newAuth.oauthProviders = [oauthProvider];
|
|
97
|
+
return { auth: await this.authRepo.save(newAuth), identifier: newAuth.identifiers?.[0] };
|
|
110
98
|
}
|
|
111
|
-
// async login(dto: LoginDto): Promise<{ auth: Auth; identifier?: AuthIdentifier }> {
|
|
112
|
-
// if (!dto.token) {
|
|
113
|
-
// throw new BadRequestException('Google ID token is required');
|
|
114
|
-
// }
|
|
115
|
-
// const payload = await this.verifyToken(dto.token);
|
|
116
|
-
// const googleId = payload.sub;
|
|
117
|
-
// const oauthProvider = await this.oauthProviderRepo.findOne({
|
|
118
|
-
// where: { provider: OAuthProviderType.GOOGLE, providerUserId: googleId },
|
|
119
|
-
// relations: ['auth', 'auth.identifiers'],
|
|
120
|
-
// });
|
|
121
|
-
// if (!oauthProvider || !oauthProvider.auth) {
|
|
122
|
-
// throw new BadRequestException('No account found linked to this Google account. Please sign up.');
|
|
123
|
-
// }
|
|
124
|
-
// const auth = oauthProvider.auth;
|
|
125
|
-
// auth.lastUsedAt = new Date();
|
|
126
|
-
// await this.authRepo.save(auth);
|
|
127
|
-
// // Find the identifier that matches the email from Google
|
|
128
|
-
// const email = payload.email?.toLowerCase();
|
|
129
|
-
// const identifier = auth.identifiers?.find(id => id.value === email);
|
|
130
|
-
// return { auth, identifier };
|
|
131
|
-
// }
|
|
132
99
|
async login(dto) {
|
|
133
100
|
if (!dto.token) {
|
|
134
101
|
throw new common_1.BadRequestException('Google ID token is required');
|
|
@@ -136,92 +103,54 @@ let GoogleAuthStrategy = class GoogleAuthStrategy {
|
|
|
136
103
|
const payload = await this.verifyToken(dto.token);
|
|
137
104
|
const googleId = payload.sub;
|
|
138
105
|
const email = payload.email?.toLowerCase();
|
|
139
|
-
const result = await this.
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
oauthProvider.rawProfile = payload;
|
|
161
|
-
oauthProvider.displayName = payload.name ?? null;
|
|
162
|
-
oauthProvider.avatarUrl = payload.picture ?? null;
|
|
163
|
-
oauthProvider.emailVerified = payload.email_verified ?? false;
|
|
164
|
-
// -------------------------
|
|
165
|
-
// 3. Update Auth
|
|
166
|
-
// -------------------------
|
|
167
|
-
auth.lastUsedAt = new Date();
|
|
168
|
-
// -------------------------
|
|
169
|
-
// 4. Handle Identifier (EMAIL)
|
|
170
|
-
// -------------------------
|
|
171
|
-
let identifier = null;
|
|
172
|
-
if (email) {
|
|
173
|
-
identifier = await identifierRepo.findOne({
|
|
174
|
-
where: {
|
|
175
|
-
auth: { id: auth.id },
|
|
176
|
-
type: auth_identify_entity_1.IdentifierType.EMAIL,
|
|
177
|
-
},
|
|
106
|
+
const result = await this.oauthProviderRepo.findWithAuthByProviderUserId(auth_type_enum_1.OAuthProviderType.GOOGLE, googleId);
|
|
107
|
+
if (!result || !result.auth) {
|
|
108
|
+
throw new common_1.BadRequestException('No account found linked to this Google account. Please sign up.');
|
|
109
|
+
}
|
|
110
|
+
const oauthProvider = result.provider;
|
|
111
|
+
const auth = result.auth;
|
|
112
|
+
oauthProvider.rawProfile = payload;
|
|
113
|
+
oauthProvider.displayName = payload.name ?? null;
|
|
114
|
+
oauthProvider.avatarUrl = payload.picture ?? null;
|
|
115
|
+
oauthProvider.emailVerified = payload.email_verified ?? false;
|
|
116
|
+
auth.lastUsedAt = new Date();
|
|
117
|
+
let identifier = null;
|
|
118
|
+
if (email) {
|
|
119
|
+
const idResult = await this.identifierRepo.findWithAuthByValue(email);
|
|
120
|
+
identifier = idResult?.identifier || null;
|
|
121
|
+
if (!identifier || identifier.auth?.id !== auth.id) {
|
|
122
|
+
identifier = await this.identifierRepo.create({
|
|
123
|
+
auth,
|
|
124
|
+
type: identifier_type_enum_1.IdentifierType.EMAIL,
|
|
125
|
+
value: email,
|
|
126
|
+
isVerified: false,
|
|
178
127
|
});
|
|
179
|
-
if (!identifier) {
|
|
180
|
-
identifier = identifierRepo.create({
|
|
181
|
-
auth,
|
|
182
|
-
type: auth_identify_entity_1.IdentifierType.EMAIL,
|
|
183
|
-
value: email,
|
|
184
|
-
isVerified: false,
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
// always normalize + update
|
|
188
|
-
identifier.value = email;
|
|
189
|
-
if (!this.options.forceVerificationOnGoogleLogin) {
|
|
190
|
-
identifier.isVerified = payload.email_verified ?? false;
|
|
191
|
-
}
|
|
192
|
-
identifier.verifiedBy = payload.email_verified ? 'PROVIDER' : identifier.verifiedBy;
|
|
193
|
-
identifier.source = auth_identify_entity_1.IdentifierSource.GOOGLE;
|
|
194
|
-
await identifierRepo.save(identifier);
|
|
195
128
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
const updatedAuth = await this.authRepo.
|
|
207
|
-
|
|
208
|
-
relations: ['identifiers', 'oauthProviders'],
|
|
209
|
-
});
|
|
210
|
-
const identifier = updatedAuth?.identifiers?.find((i) => i.type === auth_identify_entity_1.IdentifierType.EMAIL && i.value === email);
|
|
129
|
+
identifier.value = email;
|
|
130
|
+
if (!this.options.forceVerificationOnGoogleLogin) {
|
|
131
|
+
identifier.isVerified = payload.email_verified ?? false;
|
|
132
|
+
}
|
|
133
|
+
identifier.verifiedBy = payload.email_verified ? 'PROVIDER' : identifier.verifiedBy;
|
|
134
|
+
identifier.source = identifier_type_enum_1.IdentifierSource.GOOGLE;
|
|
135
|
+
await this.identifierRepo.save(identifier);
|
|
136
|
+
}
|
|
137
|
+
await this.oauthProviderRepo.save(oauthProvider);
|
|
138
|
+
await this.authRepo.save(auth);
|
|
139
|
+
const updatedAuth = await this.authRepo.findWithIdentifiers(auth.id);
|
|
140
|
+
const updatedIdentifier = updatedAuth?.identifiers?.find((i) => i.type === identifier_type_enum_1.IdentifierType.EMAIL && i.value === email) || identifier;
|
|
211
141
|
return {
|
|
212
|
-
auth: updatedAuth,
|
|
213
|
-
identifier,
|
|
142
|
+
auth: updatedAuth || auth,
|
|
143
|
+
identifier: updatedIdentifier || undefined,
|
|
214
144
|
};
|
|
215
145
|
}
|
|
216
146
|
};
|
|
217
147
|
exports.GoogleAuthStrategy = GoogleAuthStrategy;
|
|
218
148
|
exports.GoogleAuthStrategy = GoogleAuthStrategy = __decorate([
|
|
219
149
|
(0, common_1.Injectable)(),
|
|
220
|
-
__param(
|
|
221
|
-
__param(
|
|
150
|
+
__param(0, (0, common_1.Inject)(repository_tokens_1.AUTH_REPOSITORY_TOKEN)),
|
|
151
|
+
__param(1, (0, common_1.Inject)(repository_tokens_1.AUTH_IDENTIFIER_REPOSITORY_TOKEN)),
|
|
152
|
+
__param(2, (0, common_1.Inject)(repository_tokens_1.OAUTH_PROVIDER_REPOSITORY_TOKEN)),
|
|
222
153
|
__param(3, (0, common_1.Inject)(auth_module_options_interface_1.AUTH_MODULE_OPTIONS)),
|
|
223
|
-
__metadata("design:paramtypes", [
|
|
224
|
-
typeorm_1.Repository,
|
|
225
|
-
typeorm_1.Repository, Object])
|
|
154
|
+
__metadata("design:paramtypes", [Object, Object, Object, Object])
|
|
226
155
|
], GoogleAuthStrategy);
|
|
227
156
|
//# sourceMappingURL=google.strategy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google.strategy.js","sourceRoot":"","sources":["../../../../src/auth/strategies/oauth/google.strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"google.strategy.js","sourceRoot":"","sources":["../../../../src/auth/strategies/oauth/google.strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAyE;AACzE,6DAAmD;AAEnD,2EAAoF;AACpF,kGAAwG;AAExG,mCAAoC;AAGpC,+DAA6E;AAC7E,0EAA8I;AAIvI,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAG7B,YACyC,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;QAE/D,IAAI,CAAC,MAAM,GAAG,IAAI,kCAAY,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IAC9D,CAAC;IAEO,KAAK,CAAC,WAAW,CAAC,KAAa;QACrC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;gBAC7C,OAAO,E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CAAC,CAAC;QAE/B,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACrE,MAAM,iBAAiB,GAAG,WAAW,EAAE,WAAW,EAAE,IAAI,CACtD,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,qCAAc,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,KAAK,KAAK,CAC5D,IAAI,UAAU,CAAC;QAEhB,OAAO;YACL,IAAI,EAAE,WAAW,IAAI,IAAI;YACzB,UAAU,EAAE,iBAAiB,IAAI,SAAS;SAC3C,CAAC;IACJ,CAAC;CACF,CAAA;AAlKY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;IAKR,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;;GAPnB,kBAAkB,CAkK9B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SignupDto } from '../../dto/requests/signup.dto';
|
|
2
2
|
import { LoginDto } from '../../dto/requests/login.dto';
|
|
3
|
-
import { Auth } from '../../
|
|
4
|
-
import { AuthIdentifier } from '../../
|
|
3
|
+
import { Auth } from '../../interfaces/models.interface';
|
|
4
|
+
import { AuthIdentifier } from '../../interfaces/models.interface';
|
|
5
5
|
import { GoogleAuthStrategy } from './google.strategy';
|
|
6
6
|
import { FacebookAuthStrategy } from './facebook.strategy';
|
|
7
7
|
import { AppleAuthStrategy } from './apple.strategy';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DynamicModule } from '@nestjs/common';
|
|
2
|
+
export interface PrismaAuthAdapterOptions {
|
|
3
|
+
/**
|
|
4
|
+
* The injection token for your Prisma Service.
|
|
5
|
+
* Default: 'PRISMA_SERVICE'
|
|
6
|
+
*/
|
|
7
|
+
prismaServiceToken?: string | symbol | any;
|
|
8
|
+
}
|
|
9
|
+
export declare class PrismaAuthAdapter {
|
|
10
|
+
static register(options?: PrismaAuthAdapterOptions): DynamicModule;
|
|
11
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var PrismaAuthAdapter_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.PrismaAuthAdapter = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const repository_tokens_1 = require("../../auth/interfaces/repository-tokens");
|
|
13
|
+
const repositories_1 = require("./repositories");
|
|
14
|
+
let PrismaAuthAdapter = PrismaAuthAdapter_1 = class PrismaAuthAdapter {
|
|
15
|
+
static register(options = {}) {
|
|
16
|
+
const prismaServiceToken = options.prismaServiceToken || 'PRISMA_SERVICE';
|
|
17
|
+
const aliasProvider = {
|
|
18
|
+
provide: 'PRISMA_SERVICE_TOKEN',
|
|
19
|
+
useExisting: prismaServiceToken,
|
|
20
|
+
};
|
|
21
|
+
const providers = [
|
|
22
|
+
aliasProvider,
|
|
23
|
+
{
|
|
24
|
+
provide: repository_tokens_1.AUTH_REPOSITORY_TOKEN,
|
|
25
|
+
useClass: repositories_1.PrismaAuthRepository,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
provide: repository_tokens_1.AUTH_IDENTIFIER_REPOSITORY_TOKEN,
|
|
29
|
+
useClass: repositories_1.PrismaAuthIdentifierRepository,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
provide: repository_tokens_1.SESSION_REPOSITORY_TOKEN,
|
|
33
|
+
useClass: repositories_1.PrismaSessionRepository,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
provide: repository_tokens_1.MFA_METHOD_REPOSITORY_TOKEN,
|
|
37
|
+
useClass: repositories_1.PrismaMfaMethodRepository,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
provide: repository_tokens_1.OAUTH_PROVIDER_REPOSITORY_TOKEN,
|
|
41
|
+
useClass: repositories_1.PrismaOAuthProviderRepository,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
provide: repository_tokens_1.SESSION_LOG_REPOSITORY_TOKEN,
|
|
45
|
+
useClass: repositories_1.PrismaSessionLogRepository,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
provide: repository_tokens_1.OTP_TOKEN_REPOSITORY_TOKEN,
|
|
49
|
+
useClass: repositories_1.PrismaOtpTokenRepository,
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
return {
|
|
53
|
+
module: PrismaAuthAdapter_1,
|
|
54
|
+
providers,
|
|
55
|
+
exports: providers.map(p => p.provide),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
exports.PrismaAuthAdapter = PrismaAuthAdapter;
|
|
60
|
+
exports.PrismaAuthAdapter = PrismaAuthAdapter = PrismaAuthAdapter_1 = __decorate([
|
|
61
|
+
(0, common_1.Global)(),
|
|
62
|
+
(0, common_1.Module)({})
|
|
63
|
+
], PrismaAuthAdapter);
|
|
64
|
+
//# sourceMappingURL=prisma-auth.adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prisma-auth.adapter.js","sourceRoot":"","sources":["../../../src/database/prisma/prisma-auth.adapter.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAyE;AACzE,+EAQiD;AAEjD,iDAQwB;AAYjB,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAC5B,MAAM,CAAC,QAAQ,CAAC,UAAoC,EAAE;QACpD,MAAM,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,IAAI,gBAAgB,CAAC;QAE1E,MAAM,aAAa,GAAa;YAC9B,OAAO,EAAE,sBAAsB;YAC/B,WAAW,EAAE,kBAAkB;SAChC,CAAC;QAEF,MAAM,SAAS,GAAe;YAC5B,aAAa;YACb;gBACE,OAAO,EAAE,yCAAqB;gBAC9B,QAAQ,EAAE,mCAAoB;aAC/B;YACD;gBACE,OAAO,EAAE,oDAAgC;gBACzC,QAAQ,EAAE,6CAA8B;aACzC;YACD;gBACE,OAAO,EAAE,4CAAwB;gBACjC,QAAQ,EAAE,sCAAuB;aAClC;YACD;gBACE,OAAO,EAAE,+CAA2B;gBACpC,QAAQ,EAAE,wCAAyB;aACpC;YACD;gBACE,OAAO,EAAE,mDAA+B;gBACxC,QAAQ,EAAE,4CAA6B;aACxC;YACD;gBACE,OAAO,EAAE,gDAA4B;gBACrC,QAAQ,EAAE,yCAA0B;aACrC;YACD;gBACE,OAAO,EAAE,8CAA0B;gBACnC,QAAQ,EAAE,uCAAwB;aACnC;SACF,CAAC;QAEF,OAAO;YACL,MAAM,EAAE,mBAAiB;YACzB,SAAS;YACT,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAE,CAAS,CAAC,OAAO,CAAC;SAChD,CAAC;IACJ,CAAC;CACF,CAAA;AA/CY,8CAAiB;4BAAjB,iBAAiB;IAF7B,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,iBAAiB,CA+C7B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AuthIdentifierRepository } from '../../../auth/interfaces/repositories.interface';
|
|
2
|
+
import { AuthIdentifier as CoreAuthIdentifier, Auth as CoreAuth } from '../../../auth/interfaces/models.interface';
|
|
3
|
+
export declare class PrismaAuthIdentifierRepository implements AuthIdentifierRepository {
|
|
4
|
+
private readonly prisma;
|
|
5
|
+
constructor(prisma: any);
|
|
6
|
+
create(data: Partial<CoreAuthIdentifier>): Promise<CoreAuthIdentifier>;
|
|
7
|
+
findByValue(value: string): Promise<CoreAuthIdentifier | null>;
|
|
8
|
+
findByAuthId(authId: string): Promise<CoreAuthIdentifier[]>;
|
|
9
|
+
findByUidAndTypes(uid: string, types: string[]): Promise<CoreAuthIdentifier | null>;
|
|
10
|
+
findWithAuthByValue(value: string): Promise<{
|
|
11
|
+
identifier: CoreAuthIdentifier;
|
|
12
|
+
auth: CoreAuth;
|
|
13
|
+
} | null>;
|
|
14
|
+
save(identifier: CoreAuthIdentifier): Promise<CoreAuthIdentifier>;
|
|
15
|
+
markVerifiedByAuthId(authId: string): Promise<void>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.PrismaAuthIdentifierRepository = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
let PrismaAuthIdentifierRepository = class PrismaAuthIdentifierRepository {
|
|
18
|
+
constructor(prisma) {
|
|
19
|
+
this.prisma = prisma;
|
|
20
|
+
}
|
|
21
|
+
async create(data) { return this.prisma.authIdentifier.create({ data: data }); }
|
|
22
|
+
async findByValue(value) { return this.prisma.authIdentifier.findUnique({ where: { value } }); }
|
|
23
|
+
async findByAuthId(authId) { return this.prisma.authIdentifier.findMany({ where: { authId } }); }
|
|
24
|
+
async findByUidAndTypes(uid, types) { return this.prisma.authIdentifier.findFirst({ where: { auth: { uid }, type: { in: types } } }); }
|
|
25
|
+
async findWithAuthByValue(value) {
|
|
26
|
+
const res = await this.prisma.authIdentifier.findUnique({ where: { value }, include: { auth: true } });
|
|
27
|
+
if (!res)
|
|
28
|
+
return null;
|
|
29
|
+
const { auth, ...identifier } = res;
|
|
30
|
+
return { identifier: identifier, auth: auth };
|
|
31
|
+
}
|
|
32
|
+
async save(identifier) { return this.prisma.authIdentifier.update({ where: { id: identifier.id }, data: identifier }); }
|
|
33
|
+
async markVerifiedByAuthId(authId) { await this.prisma.authIdentifier.updateMany({ where: { authId }, data: { isVerified: true } }); }
|
|
34
|
+
};
|
|
35
|
+
exports.PrismaAuthIdentifierRepository = PrismaAuthIdentifierRepository;
|
|
36
|
+
exports.PrismaAuthIdentifierRepository = PrismaAuthIdentifierRepository = __decorate([
|
|
37
|
+
(0, common_1.Injectable)(),
|
|
38
|
+
__param(0, (0, common_1.Inject)('PRISMA_SERVICE_TOKEN')),
|
|
39
|
+
__metadata("design:paramtypes", [Object])
|
|
40
|
+
], PrismaAuthIdentifierRepository);
|
|
41
|
+
//# sourceMappingURL=auth-identifier.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-identifier.repository.js","sourceRoot":"","sources":["../../../../src/database/prisma/repositories/auth-identifier.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoD;AAK7C,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IACzC,YAA6D,MAAW;QAAX,WAAM,GAAN,MAAM,CAAK;IAAG,CAAC;IAE5E,KAAK,CAAC,MAAM,CAAC,IAAiC,IAAiC,OAAO,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAW,EAAE,CAAC,CAAC,CAAC,CAAC;IACjJ,KAAK,CAAC,WAAW,CAAC,KAAa,IAAwC,OAAO,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IAC5I,KAAK,CAAC,YAAY,CAAC,MAAc,IAAmC,OAAO,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IACxI,KAAK,CAAC,iBAAiB,CAAC,GAAW,EAAE,KAAe,IAAwC,OAAO,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAC,CAAC,CAAC,CAAC,CAAC;IAE5L,KAAK,CAAC,mBAAmB,CAAC,KAAa;QACrC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;QACvG,IAAI,CAAC,GAAG;YAAE,OAAO,IAAI,CAAC;QACtB,MAAM,EAAE,IAAI,EAAE,GAAG,UAAU,EAAE,GAAG,GAAG,CAAC;QACpC,OAAO,EAAE,UAAU,EAAE,UAAiB,EAAE,IAAI,EAAE,IAAW,EAAE,CAAC;IAC9D,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,UAA8B,IAAiC,OAAO,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,UAAU,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,UAAiB,EAAE,CAAC,CAAC,CAAC,CAAC;IAChL,KAAK,CAAC,oBAAoB,CAAC,MAAc,IAAmB,MAAM,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;CAC9J,CAAA;AAjBY,wEAA8B;yCAA9B,8BAA8B;IAD1C,IAAA,mBAAU,GAAE;IAEE,WAAA,IAAA,eAAM,EAAC,sBAAsB,CAAC,CAAA;;GADhC,8BAA8B,CAiB1C"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AuthRepository } from '../../../auth/interfaces/repositories.interface';
|
|
2
|
+
import { Auth as CoreAuth } from '../../../auth/interfaces/models.interface';
|
|
3
|
+
import { AuthStrategy } from '../../../auth/enums/auth-type.enum';
|
|
4
|
+
export declare class PrismaAuthRepository implements AuthRepository {
|
|
5
|
+
private readonly prisma;
|
|
6
|
+
constructor(prisma: any);
|
|
7
|
+
create(data: Partial<CoreAuth>): Promise<CoreAuth>;
|
|
8
|
+
findById(id: string): Promise<CoreAuth | null>;
|
|
9
|
+
findByUid(uid: string): Promise<CoreAuth | null>;
|
|
10
|
+
findAllByUid(uid: string): Promise<CoreAuth[]>;
|
|
11
|
+
findAll(): Promise<CoreAuth[]>;
|
|
12
|
+
findByUidAndStrategy(uid: string, strategy: AuthStrategy): Promise<CoreAuth | null>;
|
|
13
|
+
findByUidAndStrategies(uid: string, strategies: AuthStrategy[]): Promise<CoreAuth | null>;
|
|
14
|
+
save(auth: CoreAuth): Promise<CoreAuth>;
|
|
15
|
+
update(id: string, data: Partial<CoreAuth>): Promise<void>;
|
|
16
|
+
delete(id: string): Promise<void>;
|
|
17
|
+
deleteByUid(uid: string): Promise<void>;
|
|
18
|
+
findWithIdentifiers(id: string): Promise<CoreAuth | null>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.PrismaAuthRepository = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
let PrismaAuthRepository = class PrismaAuthRepository {
|
|
18
|
+
constructor(prisma) {
|
|
19
|
+
this.prisma = prisma;
|
|
20
|
+
}
|
|
21
|
+
async create(data) {
|
|
22
|
+
const { identifiers, ...rest } = data;
|
|
23
|
+
return this.prisma.auth.create({
|
|
24
|
+
data: {
|
|
25
|
+
...rest,
|
|
26
|
+
identifiers: identifiers ? { create: identifiers } : undefined,
|
|
27
|
+
},
|
|
28
|
+
include: { identifiers: true }
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
async findById(id) { return this.prisma.auth.findUnique({ where: { id }, include: { identifiers: true } }); }
|
|
32
|
+
async findByUid(uid) { return this.prisma.auth.findUnique({ where: { uid }, include: { identifiers: true } }); }
|
|
33
|
+
async findAllByUid(uid) { return this.prisma.auth.findMany({ where: { uid } }); }
|
|
34
|
+
async findAll() { return this.prisma.auth.findMany(); }
|
|
35
|
+
async findByUidAndStrategy(uid, strategy) { return this.prisma.auth.findFirst({ where: { uid, strategy } }); }
|
|
36
|
+
async findByUidAndStrategies(uid, strategies) { return this.prisma.auth.findFirst({ where: { uid, strategy: { in: strategies } } }); }
|
|
37
|
+
async save(auth) { return this.prisma.auth.update({ where: { id: auth.id }, data: auth }); }
|
|
38
|
+
async update(id, data) { await this.prisma.auth.update({ where: { id }, data: data }); }
|
|
39
|
+
async delete(id) { await this.prisma.auth.delete({ where: { id } }); }
|
|
40
|
+
async deleteByUid(uid) { await this.prisma.auth.deleteMany({ where: { uid } }); }
|
|
41
|
+
async findWithIdentifiers(id) { return this.prisma.auth.findUnique({ where: { id }, include: { identifiers: true } }); }
|
|
42
|
+
};
|
|
43
|
+
exports.PrismaAuthRepository = PrismaAuthRepository;
|
|
44
|
+
exports.PrismaAuthRepository = PrismaAuthRepository = __decorate([
|
|
45
|
+
(0, common_1.Injectable)(),
|
|
46
|
+
__param(0, (0, common_1.Inject)('PRISMA_SERVICE_TOKEN')),
|
|
47
|
+
__metadata("design:paramtypes", [Object])
|
|
48
|
+
], PrismaAuthRepository);
|
|
49
|
+
//# sourceMappingURL=auth.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.repository.js","sourceRoot":"","sources":["../../../../src/database/prisma/repositories/auth.repository.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AAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;CAC3J,CAAA;AAzBY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;IAEE,WAAA,IAAA,eAAM,EAAC,sBAAsB,CAAC,CAAA;;GADhC,oBAAoB,CAyBhC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './auth.repository';
|
|
2
|
+
export * from './auth-identifier.repository';
|
|
3
|
+
export * from './session.repository';
|
|
4
|
+
export * from './session-log.repository';
|
|
5
|
+
export * from './mfa-method.repository';
|
|
6
|
+
export * from './oauth-provider.repository';
|
|
7
|
+
export * from './otp-token.repository';
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
__exportStar(require("./auth.repository"), exports);
|
|
18
|
+
__exportStar(require("./auth-identifier.repository"), exports);
|
|
19
|
+
__exportStar(require("./session.repository"), exports);
|
|
20
|
+
__exportStar(require("./session-log.repository"), exports);
|
|
21
|
+
__exportStar(require("./mfa-method.repository"), exports);
|
|
22
|
+
__exportStar(require("./oauth-provider.repository"), exports);
|
|
23
|
+
__exportStar(require("./otp-token.repository"), exports);
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/database/prisma/repositories/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,+DAA6C;AAC7C,uDAAqC;AACrC,2DAAyC;AACzC,0DAAwC;AACxC,8DAA4C;AAC5C,yDAAuC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MfaMethodRepository } from '../../../auth/interfaces/repositories.interface';
|
|
2
|
+
import { MfaMethod as CoreMfaMethod } from '../../../auth/interfaces/models.interface';
|
|
3
|
+
export declare class PrismaMfaMethodRepository implements MfaMethodRepository {
|
|
4
|
+
private readonly prisma;
|
|
5
|
+
constructor(prisma: any);
|
|
6
|
+
create(data: Partial<CoreMfaMethod>): Promise<CoreMfaMethod>;
|
|
7
|
+
findByUidAndType(uid: string, type: string): Promise<CoreMfaMethod | null>;
|
|
8
|
+
findByUidAndEnabled(uid: string): Promise<CoreMfaMethod | null>;
|
|
9
|
+
save(method: CoreMfaMethod): Promise<CoreMfaMethod>;
|
|
10
|
+
deleteByUid(uid: string): Promise<void>;
|
|
11
|
+
}
|