@vynelix/nestjs-multi-auth 0.3.2 → 1.0.1
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 +14 -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
|
@@ -0,0 +1,33 @@
|
|
|
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.PrismaMfaMethodRepository = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
let PrismaMfaMethodRepository = class PrismaMfaMethodRepository {
|
|
18
|
+
constructor(prisma) {
|
|
19
|
+
this.prisma = prisma;
|
|
20
|
+
}
|
|
21
|
+
async create(data) { return this.prisma.mfaMethod.create({ data: data }); }
|
|
22
|
+
async findByUidAndType(uid, type) { return this.prisma.mfaMethod.findFirst({ where: { auth: { uid }, type } }); }
|
|
23
|
+
async findByUidAndEnabled(uid) { return this.prisma.mfaMethod.findFirst({ where: { auth: { uid }, isEnabled: true } }); }
|
|
24
|
+
async save(method) { return this.prisma.mfaMethod.update({ where: { id: method.id }, data: method }); }
|
|
25
|
+
async deleteByUid(uid) { await this.prisma.mfaMethod.deleteMany({ where: { auth: { uid } } }); }
|
|
26
|
+
};
|
|
27
|
+
exports.PrismaMfaMethodRepository = PrismaMfaMethodRepository;
|
|
28
|
+
exports.PrismaMfaMethodRepository = PrismaMfaMethodRepository = __decorate([
|
|
29
|
+
(0, common_1.Injectable)(),
|
|
30
|
+
__param(0, (0, common_1.Inject)('PRISMA_SERVICE_TOKEN')),
|
|
31
|
+
__metadata("design:paramtypes", [Object])
|
|
32
|
+
], PrismaMfaMethodRepository);
|
|
33
|
+
//# sourceMappingURL=mfa-method.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mfa-method.repository.js","sourceRoot":"","sources":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AAE;IAEE,WAAA,IAAA,eAAM,EAAC,sBAAsB,CAAC,CAAA;;GADhC,yBAAyB,CAQrC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { OAuthProviderRepository } from '../../../auth/interfaces/repositories.interface';
|
|
2
|
+
import { OAuthProvider as CoreOAuthProvider, Auth as CoreAuth } from '../../../auth/interfaces/models.interface';
|
|
3
|
+
export declare class PrismaOAuthProviderRepository implements OAuthProviderRepository {
|
|
4
|
+
private readonly prisma;
|
|
5
|
+
constructor(prisma: any);
|
|
6
|
+
create(data: Partial<CoreOAuthProvider>): Promise<CoreOAuthProvider>;
|
|
7
|
+
findByProviderUserId(provider: string, providerUserId: string): Promise<CoreOAuthProvider | null>;
|
|
8
|
+
findWithAuthByProviderUserId(provider: string, providerUserId: string): Promise<{
|
|
9
|
+
provider: CoreOAuthProvider;
|
|
10
|
+
auth: CoreAuth;
|
|
11
|
+
} | null>;
|
|
12
|
+
save(provider: CoreOAuthProvider): Promise<CoreOAuthProvider>;
|
|
13
|
+
update(id: string, data: Partial<CoreOAuthProvider>): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
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.PrismaOAuthProviderRepository = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
let PrismaOAuthProviderRepository = class PrismaOAuthProviderRepository {
|
|
18
|
+
constructor(prisma) {
|
|
19
|
+
this.prisma = prisma;
|
|
20
|
+
}
|
|
21
|
+
async create(data) { return this.prisma.oAuthProvider.create({ data: data }); }
|
|
22
|
+
async findByProviderUserId(provider, providerUserId) { return this.prisma.oAuthProvider.findUnique({ where: { providerUserId } }); }
|
|
23
|
+
async findWithAuthByProviderUserId(provider, providerUserId) {
|
|
24
|
+
const res = await this.prisma.oAuthProvider.findUnique({ where: { providerUserId }, include: { auth: true } });
|
|
25
|
+
if (!res)
|
|
26
|
+
return null;
|
|
27
|
+
const { auth, ...prov } = res;
|
|
28
|
+
return { provider: prov, auth: auth };
|
|
29
|
+
}
|
|
30
|
+
async save(provider) { return this.prisma.oAuthProvider.update({ where: { id: provider.id }, data: provider }); }
|
|
31
|
+
async update(id, data) { await this.prisma.oAuthProvider.update({ where: { id }, data: data }); }
|
|
32
|
+
};
|
|
33
|
+
exports.PrismaOAuthProviderRepository = PrismaOAuthProviderRepository;
|
|
34
|
+
exports.PrismaOAuthProviderRepository = PrismaOAuthProviderRepository = __decorate([
|
|
35
|
+
(0, common_1.Injectable)(),
|
|
36
|
+
__param(0, (0, common_1.Inject)('PRISMA_SERVICE_TOKEN')),
|
|
37
|
+
__metadata("design:paramtypes", [Object])
|
|
38
|
+
], PrismaOAuthProviderRepository);
|
|
39
|
+
//# sourceMappingURL=oauth-provider.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth-provider.repository.js","sourceRoot":"","sources":["../../../../src/database/prisma/repositories/oauth-provider.repository.ts"],"names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AAM,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,IAAW,EAAE,CAAC,CAAC,CAAC,CAAC;CAC5J,CAAA;AAfY,sEAA6B;wCAA7B,6BAA6B;IADzC,IAAA,mBAAU,GAAE;IAEE,WAAA,IAAA,eAAM,EAAC,sBAAsB,CAAC,CAAA;;GADhC,6BAA6B,CAezC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { OtpTokenRepository } from '../../../auth/interfaces/repositories.interface';
|
|
2
|
+
import { OtpToken as CoreOtpToken } from '../../../auth/interfaces/models.interface';
|
|
3
|
+
export declare class PrismaOtpTokenRepository implements OtpTokenRepository {
|
|
4
|
+
private readonly prisma;
|
|
5
|
+
constructor(prisma: any);
|
|
6
|
+
create(data: Partial<CoreOtpToken>): Promise<CoreOtpToken>;
|
|
7
|
+
save(data: CoreOtpToken): Promise<CoreOtpToken>;
|
|
8
|
+
delete(id: string): Promise<void>;
|
|
9
|
+
deleteByUid(uid: string): Promise<void>;
|
|
10
|
+
transaction<T>(callback: (repo: any) => Promise<T>): Promise<T>;
|
|
11
|
+
findLatestUnused(uid: string): Promise<CoreOtpToken | null>;
|
|
12
|
+
findLatestUnusedByPurpose(uid: string, purpose: string): Promise<CoreOtpToken | null>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
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.PrismaOtpTokenRepository = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
let PrismaOtpTokenRepository = class PrismaOtpTokenRepository {
|
|
18
|
+
constructor(prisma) {
|
|
19
|
+
this.prisma = prisma;
|
|
20
|
+
}
|
|
21
|
+
async create(data) {
|
|
22
|
+
return this.prisma.otpToken.create({ data: data });
|
|
23
|
+
}
|
|
24
|
+
async save(data) {
|
|
25
|
+
return this.prisma.otpToken.update({
|
|
26
|
+
where: { id: data.id },
|
|
27
|
+
data: data,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
async delete(id) { await this.prisma.otpToken.delete({ where: { id } }); }
|
|
31
|
+
async deleteByUid(uid) { await this.prisma.otpToken.deleteMany({ where: { uid } }); }
|
|
32
|
+
async transaction(callback) { return callback(this); }
|
|
33
|
+
async findLatestUnused(uid) {
|
|
34
|
+
return this.prisma.otpToken.findFirst({
|
|
35
|
+
where: { uid, isUsed: false },
|
|
36
|
+
orderBy: { createdAt: 'desc' },
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
async findLatestUnusedByPurpose(uid, purpose) {
|
|
40
|
+
return this.prisma.otpToken.findFirst({
|
|
41
|
+
where: { uid, purpose, isUsed: false },
|
|
42
|
+
orderBy: { createdAt: 'desc' },
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
exports.PrismaOtpTokenRepository = PrismaOtpTokenRepository;
|
|
47
|
+
exports.PrismaOtpTokenRepository = PrismaOtpTokenRepository = __decorate([
|
|
48
|
+
(0, common_1.Injectable)(),
|
|
49
|
+
__param(0, (0, common_1.Inject)('PRISMA_SERVICE_TOKEN')),
|
|
50
|
+
__metadata("design:paramtypes", [Object])
|
|
51
|
+
], PrismaOtpTokenRepository);
|
|
52
|
+
//# sourceMappingURL=otp-token.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otp-token.repository.js","sourceRoot":"","sources":["../../../../src/database/prisma/repositories/otp-token.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoD;AAK7C,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IACnC,YAA6D,MAAW;QAAX,WAAM,GAAN,MAAM,CAAK;IAAG,CAAC;IAE5E,KAAK,CAAC,MAAM,CAAC,IAA2B;QACtC,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAW,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,IAAkB;QAC3B,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;YACjC,KAAK,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE;YACtB,IAAI,EAAE,IAAW;SAClB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAU,IAAmB,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IACjG,KAAK,CAAC,WAAW,CAAC,GAAW,IAAmB,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IAC5G,KAAK,CAAC,WAAW,CAAI,QAAmC,IAAgB,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAChG,KAAK,CAAC,gBAAgB,CAAC,GAAW;QAChC,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC;YACpC,KAAK,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE;YAC7B,OAAO,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE;SAC/B,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,yBAAyB,CAAC,GAAW,EAAE,OAAe;QAC1D,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC;YACpC,KAAK,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE;YACtC,OAAO,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE;SAC/B,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AA9BY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,mBAAU,GAAE;IAEE,WAAA,IAAA,eAAM,EAAC,sBAAsB,CAAC,CAAA;;GADhC,wBAAwB,CA8BpC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SessionLogRepository } from '../../../auth/interfaces/repositories.interface';
|
|
2
|
+
import { SessionLog as CoreSessionLog } from '../../../auth/interfaces/models.interface';
|
|
3
|
+
export declare class PrismaSessionLogRepository implements SessionLogRepository {
|
|
4
|
+
private readonly prisma;
|
|
5
|
+
constructor(prisma: any);
|
|
6
|
+
save(data: CoreSessionLog): Promise<CoreSessionLog>;
|
|
7
|
+
saveMany(data: CoreSessionLog[]): Promise<CoreSessionLog[]>;
|
|
8
|
+
create(data: Partial<CoreSessionLog>): Promise<CoreSessionLog>;
|
|
9
|
+
findByUid(uid: string): Promise<CoreSessionLog[]>;
|
|
10
|
+
transaction<T>(callback: (repo: any) => Promise<T>): Promise<T>;
|
|
11
|
+
findByUidAndNamespace(uid: string, namespace: string): Promise<CoreSessionLog[]>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
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.PrismaSessionLogRepository = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
let PrismaSessionLogRepository = class PrismaSessionLogRepository {
|
|
18
|
+
constructor(prisma) {
|
|
19
|
+
this.prisma = prisma;
|
|
20
|
+
}
|
|
21
|
+
async save(data) { return this.prisma.sessionLog.update({ where: { id: data.id }, data: data }); }
|
|
22
|
+
async saveMany(data) { return Promise.all(data.map(d => this.save(d))); }
|
|
23
|
+
async create(data) {
|
|
24
|
+
return this.prisma.sessionLog.create({ data: data });
|
|
25
|
+
}
|
|
26
|
+
async findByUid(uid) { return this.prisma.sessionLog.findMany({ where: { uid } }); }
|
|
27
|
+
async transaction(callback) { return callback(this); }
|
|
28
|
+
async findByUidAndNamespace(uid, namespace) {
|
|
29
|
+
return this.prisma.sessionLog.findMany({
|
|
30
|
+
where: { uid, namespace },
|
|
31
|
+
orderBy: { createdAt: 'desc' },
|
|
32
|
+
take: 50,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
exports.PrismaSessionLogRepository = PrismaSessionLogRepository;
|
|
37
|
+
exports.PrismaSessionLogRepository = PrismaSessionLogRepository = __decorate([
|
|
38
|
+
(0, common_1.Injectable)(),
|
|
39
|
+
__param(0, (0, common_1.Inject)('PRISMA_SERVICE_TOKEN')),
|
|
40
|
+
__metadata("design:paramtypes", [Object])
|
|
41
|
+
], PrismaSessionLogRepository);
|
|
42
|
+
//# sourceMappingURL=session-log.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-log.repository.js","sourceRoot":"","sources":["../../../../src/database/prisma/repositories/session-log.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoD;AAK7C,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IACrC,YAA6D,MAAW;QAAX,WAAM,GAAN,MAAM,CAAK;IAAG,CAAC;IAE5E,KAAK,CAAC,IAAI,CAAC,IAAoB,IAA6B,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAW,EAAE,CAAC,CAAC,CAAC,CAAC;IAClJ,KAAK,CAAC,QAAQ,CAAC,IAAsB,IAA+B,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACtH,KAAK,CAAC,MAAM,CAAC,IAA6B;QACxC,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAW,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,GAAW,IAA+B,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IACvH,KAAK,CAAC,WAAW,CAAI,QAAmC,IAAgB,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAChG,KAAK,CAAC,qBAAqB,CAAC,GAAW,EAAE,SAAiB;QACxD,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC;YACrC,KAAK,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE;YACzB,OAAO,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE;YAC9B,IAAI,EAAE,EAAE;SACT,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAlBY,gEAA0B;qCAA1B,0BAA0B;IADtC,IAAA,mBAAU,GAAE;IAEE,WAAA,IAAA,eAAM,EAAC,sBAAsB,CAAC,CAAA;;GADhC,0BAA0B,CAkBtC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SessionRepository } from '../../../auth/interfaces/repositories.interface';
|
|
2
|
+
import { Session as CoreSession } from '../../../auth/interfaces/models.interface';
|
|
3
|
+
export declare class PrismaSessionRepository implements SessionRepository {
|
|
4
|
+
private readonly prisma;
|
|
5
|
+
constructor(prisma: any);
|
|
6
|
+
create(data: Partial<CoreSession>): Promise<CoreSession>;
|
|
7
|
+
findById(id: string): Promise<CoreSession | null>;
|
|
8
|
+
findDeviceSession(uid: string, namespace: string | undefined, deviceFingerprint: string): Promise<CoreSession | null>;
|
|
9
|
+
findByUid(uid: string): Promise<CoreSession[]>;
|
|
10
|
+
findByIdWithDetails(id: string, namespace?: string): Promise<CoreSession | null>;
|
|
11
|
+
save(session: CoreSession): Promise<CoreSession>;
|
|
12
|
+
update(id: string, data: Partial<CoreSession>): Promise<void>;
|
|
13
|
+
delete(id: string): Promise<void>;
|
|
14
|
+
deleteByUid(uid: string): Promise<void>;
|
|
15
|
+
transaction(runInTransaction: (repo: SessionRepository) => Promise<void>): 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.PrismaSessionRepository = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
let PrismaSessionRepository = class PrismaSessionRepository {
|
|
18
|
+
constructor(prisma) {
|
|
19
|
+
this.prisma = prisma;
|
|
20
|
+
}
|
|
21
|
+
async create(data) { return this.prisma.session.create({ data: data }); }
|
|
22
|
+
async findById(id) { return this.prisma.session.findUnique({ where: { id } }); }
|
|
23
|
+
async findDeviceSession(uid, namespace, deviceFingerprint) {
|
|
24
|
+
// simplified lookup since Prisma cannot easily query inside Json without raw queries across different DBs.
|
|
25
|
+
return this.prisma.session.findFirst({ where: { uid } });
|
|
26
|
+
}
|
|
27
|
+
async findByUid(uid) { return this.prisma.session.findMany({ where: { uid } }); }
|
|
28
|
+
async findByIdWithDetails(id, namespace) { return this.prisma.session.findUnique({ where: { id } }); }
|
|
29
|
+
async save(session) { return this.prisma.session.update({ where: { id: session.id }, data: session }); }
|
|
30
|
+
async update(id, data) { await this.prisma.session.update({ where: { id }, data: data }); }
|
|
31
|
+
async delete(id) { await this.prisma.session.delete({ where: { id } }); }
|
|
32
|
+
async deleteByUid(uid) { await this.prisma.session.deleteMany({ where: { uid } }); }
|
|
33
|
+
async transaction(runInTransaction) { await runInTransaction(this); }
|
|
34
|
+
};
|
|
35
|
+
exports.PrismaSessionRepository = PrismaSessionRepository;
|
|
36
|
+
exports.PrismaSessionRepository = PrismaSessionRepository = __decorate([
|
|
37
|
+
(0, common_1.Injectable)(),
|
|
38
|
+
__param(0, (0, common_1.Inject)('PRISMA_SERVICE_TOKEN')),
|
|
39
|
+
__metadata("design:paramtypes", [Object])
|
|
40
|
+
], PrismaSessionRepository);
|
|
41
|
+
//# sourceMappingURL=session.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.repository.js","sourceRoot":"","sources":["../../../../src/database/prisma/repositories/session.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoD;AAK7C,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAClC,YAA6D,MAAW;QAAX,WAAM,GAAN,MAAM,CAAK;IAAG,CAAC;IAE5E,KAAK,CAAC,MAAM,CAAC,IAA0B,IAA0B,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAW,EAAE,CAAC,CAAC,CAAC,CAAC;IAC5H,KAAK,CAAC,QAAQ,CAAC,EAAU,IAAiC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IACrH,KAAK,CAAC,iBAAiB,CAAC,GAAW,EAAE,SAA6B,EAAE,iBAAyB;QAC3F,2GAA2G;QAC3G,OAAO,IAA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BAA4D,IAAmB,MAAM,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;CACjI,CAAA;AAhBY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,mBAAU,GAAE;IAEE,WAAA,IAAA,eAAM,EAAC,sBAAsB,CAAC,CAAA;;GADhC,uBAAuB,CAgBnC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Auth } from './auth.entity';
|
|
2
|
+
import { BaseEntity } from './base.entity';
|
|
3
|
+
import { IdentifierType, IdentifierSource } from '../../../auth/enums/identifier-type.enum';
|
|
4
|
+
export declare class AuthIdentifier extends BaseEntity {
|
|
5
|
+
auth: Auth;
|
|
6
|
+
type: IdentifierType;
|
|
7
|
+
value: string;
|
|
8
|
+
isVerified: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Who issued this identifier
|
|
11
|
+
*/
|
|
12
|
+
source: IdentifierSource;
|
|
13
|
+
/**
|
|
14
|
+
* Optional: how it was verified
|
|
15
|
+
*/
|
|
16
|
+
verifiedBy?: 'OTP' | 'PROVIDER' | 'ADMIN';
|
|
17
|
+
toMap(): {
|
|
18
|
+
id: string;
|
|
19
|
+
type: IdentifierType;
|
|
20
|
+
value: string;
|
|
21
|
+
isVerified: boolean;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AuthIdentifier = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const auth_entity_1 = require("./auth.entity");
|
|
15
|
+
const base_entity_1 = require("./base.entity");
|
|
16
|
+
const identifier_type_enum_1 = require("../../../auth/enums/identifier-type.enum");
|
|
17
|
+
let AuthIdentifier = class AuthIdentifier extends base_entity_1.BaseEntity {
|
|
18
|
+
toMap() {
|
|
19
|
+
return {
|
|
20
|
+
id: this.id,
|
|
21
|
+
type: this.type,
|
|
22
|
+
value: this.value,
|
|
23
|
+
isVerified: this.isVerified,
|
|
24
|
+
// auth: this.auth.toMap(),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
exports.AuthIdentifier = AuthIdentifier;
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, typeorm_1.ManyToOne)(() => auth_entity_1.Auth, (auth) => auth.identifiers, { onDelete: 'CASCADE' }),
|
|
31
|
+
__metadata("design:type", auth_entity_1.Auth)
|
|
32
|
+
], AuthIdentifier.prototype, "auth", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, typeorm_1.Column)({ type: 'enum', enum: identifier_type_enum_1.IdentifierType }),
|
|
35
|
+
__metadata("design:type", String)
|
|
36
|
+
], AuthIdentifier.prototype, "type", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, typeorm_1.Index)({ unique: true }),
|
|
39
|
+
(0, typeorm_1.Column)(),
|
|
40
|
+
__metadata("design:type", String)
|
|
41
|
+
], AuthIdentifier.prototype, "value", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, typeorm_1.Column)({ default: false }),
|
|
44
|
+
__metadata("design:type", Boolean)
|
|
45
|
+
], AuthIdentifier.prototype, "isVerified", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, typeorm_1.Column)({
|
|
48
|
+
type: 'enum',
|
|
49
|
+
enum: identifier_type_enum_1.IdentifierSource,
|
|
50
|
+
default: identifier_type_enum_1.IdentifierSource.LOCAL,
|
|
51
|
+
}),
|
|
52
|
+
__metadata("design:type", String)
|
|
53
|
+
], AuthIdentifier.prototype, "source", void 0);
|
|
54
|
+
__decorate([
|
|
55
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
56
|
+
__metadata("design:type", String)
|
|
57
|
+
], AuthIdentifier.prototype, "verifiedBy", void 0);
|
|
58
|
+
exports.AuthIdentifier = AuthIdentifier = __decorate([
|
|
59
|
+
(0, typeorm_1.Entity)('auth_identifiers')
|
|
60
|
+
], AuthIdentifier);
|
|
61
|
+
//# sourceMappingURL=auth-identify.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-identify.entity.js","sourceRoot":"","sources":["../../../../src/database/typeorm/entities/auth-identify.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAKiB;AACjB,+CAAqC;AACrC,+CAA2C;AAG3C,mFAA4F;AAGrF,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,wBAAU;IAiC5C,KAAK;QACH,OAAO;YACL,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,2BAA2B;SAC5B,CAAC;IACJ,CAAC;CACF,CAAA;AA1CY,wCAAc;AAGzB;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,kBAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;8BACrE,kBAAI;4CAAC;AAGX;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,qCAAc,EAAE,CAAC;;4CAC1B;AAMrB;IAFC,IAAA,eAAK,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IACvB,IAAA,gBAAM,GAAE;;6CACK;AAGd;IADC,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;kDACP;AAUpB;IALC,IAAA,gBAAM,EAAC;QACN,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,uCAAgB;QACtB,OAAO,EAAE,uCAAgB,CAAC,KAAK;KAChC,CAAC;;8CACuB;AAMzB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;kDACe;yBA/B/B,cAAc;IAD1B,IAAA,gBAAM,EAAC,kBAAkB,CAAC;GACd,cAAc,CA0C1B"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { BaseEntity } from './base.entity';
|
|
2
|
+
import { AuthIdentifier } from './auth-identify.entity';
|
|
3
|
+
import { OAuthProvider } from './oauth-provider.entity';
|
|
4
|
+
import { AuthStrategy } from '../../../auth/enums/auth-type.enum';
|
|
5
|
+
export declare class Auth extends BaseEntity {
|
|
6
|
+
uid: string;
|
|
7
|
+
strategy: AuthStrategy;
|
|
8
|
+
identifiers: AuthIdentifier[];
|
|
9
|
+
secretHash?: string;
|
|
10
|
+
isPrimary: boolean;
|
|
11
|
+
isVerified: boolean;
|
|
12
|
+
isActive: boolean;
|
|
13
|
+
meta?: Record<string, any>;
|
|
14
|
+
lastUsedAt?: Date;
|
|
15
|
+
oauthProviders?: OAuthProvider[];
|
|
16
|
+
toMap(): {
|
|
17
|
+
id: string;
|
|
18
|
+
strategy: AuthStrategy;
|
|
19
|
+
isActive: boolean;
|
|
20
|
+
isVerified: boolean;
|
|
21
|
+
isPrimary: boolean;
|
|
22
|
+
meta: Record<string, any>;
|
|
23
|
+
lastUsedAt: Date;
|
|
24
|
+
identifiers: {
|
|
25
|
+
id: string;
|
|
26
|
+
type: import("../../../auth/enums/identifier-type.enum").IdentifierType;
|
|
27
|
+
value: string;
|
|
28
|
+
isVerified: boolean;
|
|
29
|
+
}[];
|
|
30
|
+
oauthProviders: {
|
|
31
|
+
id: string;
|
|
32
|
+
provider: import("../../../auth/enums/auth-type.enum").OAuthProviderType;
|
|
33
|
+
providerUserId: string;
|
|
34
|
+
accessToken: string;
|
|
35
|
+
refreshToken: string;
|
|
36
|
+
expiresAt: Date;
|
|
37
|
+
createdAt: Date;
|
|
38
|
+
updatedAt: Date;
|
|
39
|
+
deletedAt: Date;
|
|
40
|
+
}[];
|
|
41
|
+
createdAt: Date;
|
|
42
|
+
updatedAt: Date;
|
|
43
|
+
deletedAt: Date;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Auth = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
15
|
+
const base_entity_1 = require("./base.entity");
|
|
16
|
+
const auth_identify_entity_1 = require("./auth-identify.entity");
|
|
17
|
+
const oauth_provider_entity_1 = require("./oauth-provider.entity");
|
|
18
|
+
const auth_type_enum_1 = require("../../../auth/enums/auth-type.enum");
|
|
19
|
+
let Auth = class Auth extends base_entity_1.BaseEntity {
|
|
20
|
+
toMap() {
|
|
21
|
+
return {
|
|
22
|
+
id: this.id,
|
|
23
|
+
strategy: this.strategy,
|
|
24
|
+
isActive: this.isActive,
|
|
25
|
+
isVerified: this.isVerified,
|
|
26
|
+
isPrimary: this.isPrimary,
|
|
27
|
+
meta: this.meta,
|
|
28
|
+
lastUsedAt: this.lastUsedAt,
|
|
29
|
+
// user: this.user.toMap(),
|
|
30
|
+
identifiers: this.identifiers?.map((id) => id?.toMap()),
|
|
31
|
+
oauthProviders: this.oauthProviders?.map((provider) => provider?.toMap()),
|
|
32
|
+
createdAt: this.createdAt,
|
|
33
|
+
updatedAt: this.updatedAt,
|
|
34
|
+
deletedAt: this.deletedAt,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
exports.Auth = Auth;
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, swagger_1.ApiProperty)({
|
|
41
|
+
description: 'Unique identity ID (UID) of this account. Multiple auth methods can share the same UID.',
|
|
42
|
+
type: 'string',
|
|
43
|
+
example: 'uuid-string',
|
|
44
|
+
}),
|
|
45
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
46
|
+
(0, typeorm_1.Index)(),
|
|
47
|
+
__metadata("design:type", String)
|
|
48
|
+
], Auth.prototype, "uid", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, typeorm_1.Column)({ type: 'enum', enum: auth_type_enum_1.AuthStrategy }),
|
|
51
|
+
__metadata("design:type", String)
|
|
52
|
+
], Auth.prototype, "strategy", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
(0, typeorm_1.OneToMany)(() => auth_identify_entity_1.AuthIdentifier, (identifier) => identifier.auth, {
|
|
55
|
+
cascade: true,
|
|
56
|
+
}),
|
|
57
|
+
__metadata("design:type", Array)
|
|
58
|
+
], Auth.prototype, "identifiers", void 0);
|
|
59
|
+
__decorate([
|
|
60
|
+
(0, swagger_1.ApiProperty)({
|
|
61
|
+
example: '$2b$10$hashedpassword...',
|
|
62
|
+
description: 'Hashed secret (password, TOTP secret). Null for OAuth',
|
|
63
|
+
nullable: true,
|
|
64
|
+
}),
|
|
65
|
+
(0, typeorm_1.Column)({ nullable: true, select: false }),
|
|
66
|
+
__metadata("design:type", String)
|
|
67
|
+
], Auth.prototype, "secretHash", void 0);
|
|
68
|
+
__decorate([
|
|
69
|
+
(0, swagger_1.ApiProperty)({
|
|
70
|
+
example: true,
|
|
71
|
+
description: 'Primary login method for the user',
|
|
72
|
+
}),
|
|
73
|
+
(0, typeorm_1.Column)({ default: false }),
|
|
74
|
+
__metadata("design:type", Boolean)
|
|
75
|
+
], Auth.prototype, "isPrimary", void 0);
|
|
76
|
+
__decorate([
|
|
77
|
+
(0, swagger_1.ApiProperty)({
|
|
78
|
+
example: true,
|
|
79
|
+
description: 'Whether the identifier is verified',
|
|
80
|
+
}),
|
|
81
|
+
(0, typeorm_1.Column)({ default: false }),
|
|
82
|
+
__metadata("design:type", Boolean)
|
|
83
|
+
], Auth.prototype, "isVerified", void 0);
|
|
84
|
+
__decorate([
|
|
85
|
+
(0, swagger_1.ApiProperty)({
|
|
86
|
+
example: true,
|
|
87
|
+
description: 'Whether this auth method is enabled',
|
|
88
|
+
}),
|
|
89
|
+
(0, typeorm_1.Column)({ default: true }),
|
|
90
|
+
__metadata("design:type", Boolean)
|
|
91
|
+
], Auth.prototype, "isActive", void 0);
|
|
92
|
+
__decorate([
|
|
93
|
+
(0, swagger_1.ApiProperty)({
|
|
94
|
+
example: { device: 'iPhone', ip: '192.168.1.1' },
|
|
95
|
+
description: 'Additional metadata (JSON)',
|
|
96
|
+
}),
|
|
97
|
+
(0, typeorm_1.Column)({ type: 'jsonb', nullable: true }),
|
|
98
|
+
__metadata("design:type", Object)
|
|
99
|
+
], Auth.prototype, "meta", void 0);
|
|
100
|
+
__decorate([
|
|
101
|
+
(0, swagger_1.ApiProperty)({
|
|
102
|
+
example: '2025-09-30T12:00:00Z',
|
|
103
|
+
description: 'Last successful usage timestamp',
|
|
104
|
+
}),
|
|
105
|
+
(0, typeorm_1.Column)({ type: 'timestamp', nullable: true }),
|
|
106
|
+
__metadata("design:type", Date)
|
|
107
|
+
], Auth.prototype, "lastUsedAt", void 0);
|
|
108
|
+
__decorate([
|
|
109
|
+
(0, swagger_1.ApiProperty)({
|
|
110
|
+
type: () => oauth_provider_entity_1.OAuthProvider,
|
|
111
|
+
description: 'OAuth provider details (only for OAUTH method)',
|
|
112
|
+
required: false,
|
|
113
|
+
}),
|
|
114
|
+
(0, typeorm_1.OneToMany)(() => oauth_provider_entity_1.OAuthProvider, (provider) => provider.auth, {
|
|
115
|
+
cascade: true,
|
|
116
|
+
nullable: true,
|
|
117
|
+
}),
|
|
118
|
+
__metadata("design:type", Array)
|
|
119
|
+
], Auth.prototype, "oauthProviders", void 0);
|
|
120
|
+
exports.Auth = Auth = __decorate([
|
|
121
|
+
(0, typeorm_1.Entity)('auth'),
|
|
122
|
+
(0, typeorm_1.Index)('IDX_user_primary_auth', ['uid'], {
|
|
123
|
+
unique: true,
|
|
124
|
+
where: `"isPrimary" = true`,
|
|
125
|
+
}),
|
|
126
|
+
(0, typeorm_1.Index)(['strategy']),
|
|
127
|
+
(0, typeorm_1.Index)(['isActive'])
|
|
128
|
+
], Auth);
|
|
129
|
+
//# sourceMappingURL=auth.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.entity.js","sourceRoot":"","sources":["../../../../src/database/typeorm/entities/auth.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAgF;AAChF,6CAA8C;AAC9C,+CAA2C;AAC3C,iEAAwD;AACxD,mEAAwD;AACxD,uEAAkE;AAS3D,IAAM,IAAI,GAAV,MAAM,IAAK,SAAQ,wBAAU;I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,qCAAa,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE;QAC3D,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;KACf,CAAC;;4CAC+B;eAlGtB,IAAI;IAPhB,IAAA,gBAAM,EAAC,MAAM,CAAC;IACd,IAAA,eAAK,EAAC,uBAAuB,EAAE,CAAC,KAAK,CAAC,EAAE;QACvC,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE,oBAAoB;KAC5B,CAAC;IACD,IAAA,eAAK,EAAC,CAAC,UAAU,CAAC,CAAC;IACnB,IAAA,eAAK,EAAC,CAAC,UAAU,CAAC,CAAC;GACP,IAAI,CAqHhB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.BaseEntity = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
15
|
+
class BaseEntity {
|
|
16
|
+
toMap() {
|
|
17
|
+
return { ...this };
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.BaseEntity = BaseEntity;
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, swagger_1.ApiProperty)({
|
|
23
|
+
example: 'uuid-string',
|
|
24
|
+
description: 'Unique identifier',
|
|
25
|
+
}),
|
|
26
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
27
|
+
__metadata("design:type", String)
|
|
28
|
+
], BaseEntity.prototype, "id", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, swagger_1.ApiProperty)({ description: 'Creation date' }),
|
|
31
|
+
(0, typeorm_1.CreateDateColumn)({ type: 'timestamp' }),
|
|
32
|
+
__metadata("design:type", Date)
|
|
33
|
+
], BaseEntity.prototype, "createdAt", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, swagger_1.ApiProperty)({ description: 'Last update date' }),
|
|
36
|
+
(0, typeorm_1.UpdateDateColumn)({ type: 'timestamp' }),
|
|
37
|
+
__metadata("design:type", Date)
|
|
38
|
+
], BaseEntity.prototype, "updatedAt", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, swagger_1.ApiProperty)({ description: 'Deletion date (soft delete)' }),
|
|
41
|
+
(0, typeorm_1.DeleteDateColumn)({ type: 'timestamp', nullable: true }),
|
|
42
|
+
__metadata("design:type", Date)
|
|
43
|
+
], BaseEntity.prototype, "deletedAt", void 0);
|
|
44
|
+
//# sourceMappingURL=base.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.entity.js","sourceRoot":"","sources":["../../../../src/database/typeorm/entities/base.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAKiB;AACjB,6CAA8C;AAE9C,MAAsB,UAAU;IAoB5B,KAAK;QACD,OAAO,EAAE,GAAG,IAAI,EAAE,CAAC;IACvB,CAAC;CACJ;AAvBD,gCAuBC;AAjBG;IALC,IAAA,qBAAW,EAAC;QACT,OAAO,EAAE,aAAa;QACtB,WAAW,EAAE,mBAAmB;KACnC,CAAC;IACD,IAAA,gCAAsB,EAAC,MAAM,CAAC;;sCACpB;AAIX;IAFC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,eAAe,EAAE,CAAC;IAC7C,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;8BAC7B,IAAI;6CAAC;AAIhB;IAFC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,kBAAkB,EAAE,CAAC;IAChD,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;8BAC7B,IAAI;6CAAC;AAIhB;IAFC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,6BAA6B,EAAE,CAAC;IAC3D,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;8BAC7C,IAAI;6CAAC"}
|