@vynelix/nestjs-multi-auth 0.3.1 → 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 +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 +53 -26
- package/dist/auth/auth.service.js +239 -328
- 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,7 @@
|
|
|
1
|
+
import { Auth } from "./auth.entity";
|
|
2
|
+
import { AuthIdentifier } from "./auth-identify.entity";
|
|
3
|
+
import { OAuthProvider } from "./oauth-provider.entity";
|
|
4
|
+
import { OtpToken } from "./otp-token.entity";
|
|
5
|
+
import { MfaMethod } from "./mfa-method.entity";
|
|
6
|
+
import { Session } from "./session.entity";
|
|
7
|
+
export declare const AuthEntities: (typeof AuthIdentifier | typeof Auth | typeof OAuthProvider | typeof OtpToken | typeof Session | typeof MfaMethod)[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthEntities = void 0;
|
|
4
|
+
const auth_entity_1 = require("./auth.entity");
|
|
5
|
+
const auth_identify_entity_1 = require("./auth-identify.entity");
|
|
6
|
+
const oauth_provider_entity_1 = require("./oauth-provider.entity");
|
|
7
|
+
const otp_token_entity_1 = require("./otp-token.entity");
|
|
8
|
+
const mfa_method_entity_1 = require("./mfa-method.entity");
|
|
9
|
+
const session_entity_1 = require("./session.entity");
|
|
10
|
+
exports.AuthEntities = [
|
|
11
|
+
auth_entity_1.Auth,
|
|
12
|
+
auth_identify_entity_1.AuthIdentifier,
|
|
13
|
+
oauth_provider_entity_1.OAuthProvider,
|
|
14
|
+
otp_token_entity_1.OtpToken,
|
|
15
|
+
session_entity_1.Session,
|
|
16
|
+
mfa_method_entity_1.MfaMethod
|
|
17
|
+
];
|
|
18
|
+
//# sourceMappingURL=entities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entities.js","sourceRoot":"","sources":["../../../../src/database/typeorm/entities/entities.ts"],"names":[],"mappings":";;;AAAA,+CAAqC;AACrC,iEAAwD;AACxD,mEAAwD;AACxD,yDAA8C;AAE9C,2DAAgD;AAChD,qDAA2C;AAE9B,QAAA,YAAY,GAAG;IACxB,kBAAI;IACJ,qCAAc;IACd,qCAAa;IACb,2BAAQ;IACR,wBAAO;IACP,6BAAS;CACZ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseEntity } from './base.entity';
|
|
2
|
+
import { MfaType } from '../../../auth/enums/mfa-type.enum';
|
|
3
|
+
export declare class MfaMethod extends BaseEntity {
|
|
4
|
+
uid: string;
|
|
5
|
+
type: MfaType;
|
|
6
|
+
secret: string;
|
|
7
|
+
isEnabled: boolean;
|
|
8
|
+
isDefault: boolean;
|
|
9
|
+
lastUsedAt: Date;
|
|
10
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
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.MfaMethod = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const base_entity_1 = require("./base.entity");
|
|
15
|
+
const mfa_type_enum_1 = require("../../../auth/enums/mfa-type.enum");
|
|
16
|
+
let MfaMethod = class MfaMethod extends base_entity_1.BaseEntity {
|
|
17
|
+
};
|
|
18
|
+
exports.MfaMethod = MfaMethod;
|
|
19
|
+
__decorate([
|
|
20
|
+
(0, typeorm_1.Column)(),
|
|
21
|
+
(0, typeorm_1.Index)(),
|
|
22
|
+
__metadata("design:type", String)
|
|
23
|
+
], MfaMethod.prototype, "uid", void 0);
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, typeorm_1.Column)({ type: 'enum', enum: mfa_type_enum_1.MfaType }),
|
|
26
|
+
__metadata("design:type", String)
|
|
27
|
+
], MfaMethod.prototype, "type", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, typeorm_1.Column)({ select: false }),
|
|
30
|
+
__metadata("design:type", String)
|
|
31
|
+
], MfaMethod.prototype, "secret", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, typeorm_1.Column)({ default: false }),
|
|
34
|
+
__metadata("design:type", Boolean)
|
|
35
|
+
], MfaMethod.prototype, "isEnabled", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
(0, typeorm_1.Column)({ default: false }),
|
|
38
|
+
__metadata("design:type", Boolean)
|
|
39
|
+
], MfaMethod.prototype, "isDefault", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
42
|
+
__metadata("design:type", Date)
|
|
43
|
+
], MfaMethod.prototype, "lastUsedAt", void 0);
|
|
44
|
+
exports.MfaMethod = MfaMethod = __decorate([
|
|
45
|
+
(0, typeorm_1.Entity)('auth_mfa_methods')
|
|
46
|
+
], MfaMethod);
|
|
47
|
+
//# sourceMappingURL=mfa-method.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mfa-method.entity.js","sourceRoot":"","sources":["../../../../src/database/typeorm/entities/mfa-method.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAIiB;AAEjB,+CAA2C;AAC3C,qEAA4D;AAGrD,IAAM,SAAS,GAAf,MAAM,SAAU,SAAQ,wBAAU;CAsBxC,CAAA;AAtBY,8BAAS;AAGpB;IAFC,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,GAAE;;sCACI;AAGZ;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,uBAAO,EAAE,CAAC;;uCAC1B;AAKd;IADC,IAAA,gBAAM,EAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;;yCACX;AAGf;IADC,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;4CACR;AAGnB;IADC,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;4CACR;AAGnB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;8BACf,IAAI;6CAAC;oBApBN,SAAS;IADrB,IAAA,gBAAM,EAAC,kBAAkB,CAAC;GACd,SAAS,CAsBrB"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { BaseEntity } from './base.entity';
|
|
2
|
+
import { Auth } from './auth.entity';
|
|
3
|
+
import { OAuthProviderType } from '../../../auth/enums/auth-type.enum';
|
|
4
|
+
export declare class OAuthProvider extends BaseEntity {
|
|
5
|
+
auth: Auth;
|
|
6
|
+
provider: OAuthProviderType;
|
|
7
|
+
providerUserId: string;
|
|
8
|
+
accessToken?: string;
|
|
9
|
+
refreshToken?: string;
|
|
10
|
+
expiresAt?: Date;
|
|
11
|
+
/**
|
|
12
|
+
* Display name from provider (e.g. "John Doe")
|
|
13
|
+
*/
|
|
14
|
+
displayName?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Avatar/profile picture URL
|
|
17
|
+
*/
|
|
18
|
+
avatarUrl?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Whether provider verified the email
|
|
21
|
+
*/
|
|
22
|
+
emailVerified?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Raw provider response (for debugging/future-proofing)
|
|
25
|
+
*/
|
|
26
|
+
rawProfile?: Record<string, any>;
|
|
27
|
+
toMap(): {
|
|
28
|
+
id: string;
|
|
29
|
+
provider: OAuthProviderType;
|
|
30
|
+
providerUserId: string;
|
|
31
|
+
accessToken: string;
|
|
32
|
+
refreshToken: string;
|
|
33
|
+
expiresAt: Date;
|
|
34
|
+
createdAt: Date;
|
|
35
|
+
updatedAt: Date;
|
|
36
|
+
deletedAt: Date;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
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.OAuthProvider = 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_entity_1 = require("./auth.entity");
|
|
17
|
+
const auth_type_enum_1 = require("../../../auth/enums/auth-type.enum");
|
|
18
|
+
let OAuthProvider = class OAuthProvider extends base_entity_1.BaseEntity {
|
|
19
|
+
toMap() {
|
|
20
|
+
return {
|
|
21
|
+
id: this.id,
|
|
22
|
+
provider: this.provider,
|
|
23
|
+
providerUserId: this.providerUserId,
|
|
24
|
+
accessToken: this.accessToken,
|
|
25
|
+
refreshToken: this.refreshToken,
|
|
26
|
+
expiresAt: this.expiresAt,
|
|
27
|
+
createdAt: this.createdAt,
|
|
28
|
+
updatedAt: this.updatedAt,
|
|
29
|
+
deletedAt: this.deletedAt,
|
|
30
|
+
// auth: this.auth.toMap(),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
exports.OAuthProvider = OAuthProvider;
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, typeorm_1.ManyToOne)(() => auth_entity_1.Auth, (auth) => auth.oauthProviders, { onDelete: 'CASCADE' }),
|
|
37
|
+
(0, typeorm_1.JoinColumn)({ name: 'authId' }),
|
|
38
|
+
__metadata("design:type", auth_entity_1.Auth)
|
|
39
|
+
], OAuthProvider.prototype, "auth", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
(0, swagger_1.ApiProperty)({ enum: auth_type_enum_1.OAuthProviderType, example: auth_type_enum_1.OAuthProviderType.GOOGLE }),
|
|
42
|
+
(0, typeorm_1.Column)({ type: 'enum', enum: auth_type_enum_1.OAuthProviderType }),
|
|
43
|
+
__metadata("design:type", String)
|
|
44
|
+
], OAuthProvider.prototype, "provider", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, swagger_1.ApiProperty)({ example: '1234567890' }),
|
|
47
|
+
(0, typeorm_1.Column)(),
|
|
48
|
+
__metadata("design:type", String)
|
|
49
|
+
], OAuthProvider.prototype, "providerUserId", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, swagger_1.ApiProperty)({ example: 'ya29.a0ARrdaM...' }),
|
|
52
|
+
(0, typeorm_1.Column)({ nullable: true, select: false }),
|
|
53
|
+
__metadata("design:type", String)
|
|
54
|
+
], OAuthProvider.prototype, "accessToken", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
(0, swagger_1.ApiProperty)({ example: '1//0gdf1234...' }),
|
|
57
|
+
(0, typeorm_1.Column)({ nullable: true, select: false }),
|
|
58
|
+
__metadata("design:type", String)
|
|
59
|
+
], OAuthProvider.prototype, "refreshToken", void 0);
|
|
60
|
+
__decorate([
|
|
61
|
+
(0, swagger_1.ApiProperty)({ example: '2025-10-01T12:00:00Z' }),
|
|
62
|
+
(0, typeorm_1.Column)({ type: 'timestamp', nullable: true }),
|
|
63
|
+
__metadata("design:type", Date)
|
|
64
|
+
], OAuthProvider.prototype, "expiresAt", void 0);
|
|
65
|
+
__decorate([
|
|
66
|
+
(0, swagger_1.ApiProperty)({ example: 'John Doe', required: false }),
|
|
67
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
68
|
+
__metadata("design:type", String)
|
|
69
|
+
], OAuthProvider.prototype, "displayName", void 0);
|
|
70
|
+
__decorate([
|
|
71
|
+
(0, swagger_1.ApiProperty)({ example: 'https://lh3.googleusercontent.com/...', required: false }),
|
|
72
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
73
|
+
__metadata("design:type", String)
|
|
74
|
+
], OAuthProvider.prototype, "avatarUrl", void 0);
|
|
75
|
+
__decorate([
|
|
76
|
+
(0, swagger_1.ApiProperty)({ example: true, required: false }),
|
|
77
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
78
|
+
__metadata("design:type", Boolean)
|
|
79
|
+
], OAuthProvider.prototype, "emailVerified", void 0);
|
|
80
|
+
__decorate([
|
|
81
|
+
(0, swagger_1.ApiProperty)({ required: false }),
|
|
82
|
+
(0, typeorm_1.Column)({ type: 'jsonb', nullable: true }),
|
|
83
|
+
__metadata("design:type", Object)
|
|
84
|
+
], OAuthProvider.prototype, "rawProfile", void 0);
|
|
85
|
+
exports.OAuthProvider = OAuthProvider = __decorate([
|
|
86
|
+
(0, typeorm_1.Entity)('oauth_providers')
|
|
87
|
+
], OAuthProvider);
|
|
88
|
+
//# sourceMappingURL=oauth-provider.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth-provider.entity.js","sourceRoot":"","sources":["../../../../src/database/typeorm/entities/oauth-provider.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAgE;AAChE,6CAA8C;AAC9C,+CAA2C;AAC3C,+CAAqC;AACrC,uEAAuE;AAGhE,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,wBAAU;IA0D3C,KAAK;QACH,OAAO;YACL,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,2BAA2B;SAC5B,CAAC;IACJ,CAAC;CACF,CAAA;AAxEY,sCAAa;AAGxB;IAFC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,kBAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IAC7E,IAAA,oBAAU,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;8BACzB,kBAAI;2CAAC;AAIX;IAFC,IAAA,qBAAW,EAAC,EAAE,IAAI,EAAE,kCAAiB,EAAE,OAAO,EAAE,kCAAiB,CAAC,MAAM,EAAE,CAAC;IAC3E,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,kCAAiB,EAAE,CAAC;;+CACtB;AAK5B;IAFC,IAAA,qBAAW,EAAC,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;IACtC,IAAA,gBAAM,GAAE;;qDACc;AAIvB;IAFC,IAAA,qBAAW,EAAC,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC;IAC5C,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;;kDACrB;AAIrB;IAFC,IAAA,qBAAW,EAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC1C,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;;mDACpB;AAItB;IAFC,IAAA,qBAAW,EAAC,EAAE,OAAO,EAAE,sBAAsB,EAAE,CAAC;IAChD,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;8BAClC,IAAI;gDAAC;AAWjB;IAFC,IAAA,qBAAW,EAAC,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IACrD,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;kDACN;AAOrB;IAFC,IAAA,qBAAW,EAAC,EAAE,OAAO,EAAE,uCAAuC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IAClF,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDACR;AAOnB;IAFC,IAAA,qBAAW,EAAC,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IAC/C,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;oDACH;AAOxB;IAFC,IAAA,qBAAW,EAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IAChC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iDACT;wBAxDtB,aAAa;IADzB,IAAA,gBAAM,EAAC,iBAAiB,CAAC;GACb,aAAa,CAwEzB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseEntity } from './base.entity';
|
|
2
|
+
import { OtpPurpose } from '../../../auth/enums/otp-purpose.enum';
|
|
3
|
+
export declare class OtpToken extends BaseEntity {
|
|
4
|
+
identifier: string;
|
|
5
|
+
purpose: OtpPurpose;
|
|
6
|
+
codeHash: string;
|
|
7
|
+
expiresAt: Date;
|
|
8
|
+
isUsed: boolean;
|
|
9
|
+
requestUserId?: string;
|
|
10
|
+
/**
|
|
11
|
+
* The ID of the primary Auth record that triggered this verification.
|
|
12
|
+
* This is used to mark the specific Auth method as verified upon success.
|
|
13
|
+
*/
|
|
14
|
+
requestAuthId?: string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
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.OtpToken = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const base_entity_1 = require("./base.entity");
|
|
15
|
+
const otp_purpose_enum_1 = require("../../../auth/enums/otp-purpose.enum");
|
|
16
|
+
let OtpToken = class OtpToken extends base_entity_1.BaseEntity {
|
|
17
|
+
};
|
|
18
|
+
exports.OtpToken = OtpToken;
|
|
19
|
+
__decorate([
|
|
20
|
+
(0, typeorm_1.Column)(),
|
|
21
|
+
__metadata("design:type", String)
|
|
22
|
+
], OtpToken.prototype, "identifier", void 0);
|
|
23
|
+
__decorate([
|
|
24
|
+
(0, typeorm_1.Column)({ type: 'enum', enum: otp_purpose_enum_1.OtpPurpose }),
|
|
25
|
+
__metadata("design:type", String)
|
|
26
|
+
], OtpToken.prototype, "purpose", void 0);
|
|
27
|
+
__decorate([
|
|
28
|
+
(0, typeorm_1.Column)(),
|
|
29
|
+
__metadata("design:type", String)
|
|
30
|
+
], OtpToken.prototype, "codeHash", void 0);
|
|
31
|
+
__decorate([
|
|
32
|
+
(0, typeorm_1.Column)({ type: 'timestamp' }),
|
|
33
|
+
__metadata("design:type", Date)
|
|
34
|
+
], OtpToken.prototype, "expiresAt", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, typeorm_1.Column)({ default: false }),
|
|
37
|
+
__metadata("design:type", Boolean)
|
|
38
|
+
], OtpToken.prototype, "isUsed", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
41
|
+
__metadata("design:type", String)
|
|
42
|
+
], OtpToken.prototype, "requestUserId", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
45
|
+
__metadata("design:type", String)
|
|
46
|
+
], OtpToken.prototype, "requestAuthId", void 0);
|
|
47
|
+
exports.OtpToken = OtpToken = __decorate([
|
|
48
|
+
(0, typeorm_1.Entity)('otp_tokens')
|
|
49
|
+
// Index makes lookup fast: "Find latest unused OTP for john@gmail.com"
|
|
50
|
+
,
|
|
51
|
+
(0, typeorm_1.Index)(['identifier', 'purpose', 'isUsed'])
|
|
52
|
+
], OtpToken);
|
|
53
|
+
//# sourceMappingURL=otp-token.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otp-token.entity.js","sourceRoot":"","sources":["../../../../src/database/typeorm/entities/otp-token.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAgD;AAChD,+CAA2C;AAE3C,2EAAkE;AAK3D,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,wBAAU;CAgCvC,CAAA;AAhCY,4BAAQ;AAInB;IADC,IAAA,gBAAM,GAAE;;4CACU;AAInB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,6BAAU,EAAE,CAAC;;yCACvB;AAKpB;IADC,IAAA,gBAAM,GAAE;;0CACQ;AAGjB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;8BACnB,IAAI;2CAAC;AAGhB;IADC,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;wCACX;AAKhB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;+CACJ;AAOvB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;+CACJ;mBA/BZ,QAAQ;IAHpB,IAAA,gBAAM,EAAC,YAAY,CAAC;IACrB,uEAAuE;;IACtE,IAAA,eAAK,EAAC,CAAC,YAAY,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;GAC9B,QAAQ,CAgCpB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare class Session {
|
|
2
|
+
id: string;
|
|
3
|
+
uid: string;
|
|
4
|
+
namespace: string;
|
|
5
|
+
refreshTokenHash: string;
|
|
6
|
+
userAgent: string;
|
|
7
|
+
deviceFingerprint: string;
|
|
8
|
+
ipAddress: string;
|
|
9
|
+
expiresAt: Date;
|
|
10
|
+
createdAt: Date;
|
|
11
|
+
toMap(): {
|
|
12
|
+
id: string;
|
|
13
|
+
uid: string;
|
|
14
|
+
userAgent: string;
|
|
15
|
+
deviceFingerprint: string;
|
|
16
|
+
ipAddress: string;
|
|
17
|
+
expiresAt: Date;
|
|
18
|
+
createdAt: Date;
|
|
19
|
+
namespace: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
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.Session = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
let Session = class Session {
|
|
15
|
+
toMap() {
|
|
16
|
+
return {
|
|
17
|
+
id: this.id,
|
|
18
|
+
uid: this.uid,
|
|
19
|
+
userAgent: this.userAgent,
|
|
20
|
+
deviceFingerprint: this.deviceFingerprint,
|
|
21
|
+
ipAddress: this.ipAddress,
|
|
22
|
+
expiresAt: this.expiresAt,
|
|
23
|
+
createdAt: this.createdAt,
|
|
24
|
+
namespace: this.namespace,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
exports.Session = Session;
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], Session.prototype, "id", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, typeorm_1.Column)(),
|
|
35
|
+
(0, typeorm_1.Index)(),
|
|
36
|
+
__metadata("design:type", String)
|
|
37
|
+
], Session.prototype, "uid", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
40
|
+
(0, typeorm_1.Index)(),
|
|
41
|
+
__metadata("design:type", String)
|
|
42
|
+
], Session.prototype, "namespace", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, typeorm_1.Column)({ select: false }) // Do not return in standard queries
|
|
45
|
+
,
|
|
46
|
+
__metadata("design:type", String)
|
|
47
|
+
], Session.prototype, "refreshTokenHash", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
50
|
+
__metadata("design:type", String)
|
|
51
|
+
], Session.prototype, "userAgent", void 0);
|
|
52
|
+
__decorate([
|
|
53
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
54
|
+
__metadata("design:type", String)
|
|
55
|
+
], Session.prototype, "deviceFingerprint", void 0);
|
|
56
|
+
__decorate([
|
|
57
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
58
|
+
__metadata("design:type", String)
|
|
59
|
+
], Session.prototype, "ipAddress", void 0);
|
|
60
|
+
__decorate([
|
|
61
|
+
(0, typeorm_1.Column)(),
|
|
62
|
+
__metadata("design:type", Date)
|
|
63
|
+
], Session.prototype, "expiresAt", void 0);
|
|
64
|
+
__decorate([
|
|
65
|
+
(0, typeorm_1.CreateDateColumn)(),
|
|
66
|
+
__metadata("design:type", Date)
|
|
67
|
+
], Session.prototype, "createdAt", void 0);
|
|
68
|
+
exports.Session = Session = __decorate([
|
|
69
|
+
(0, typeorm_1.Entity)('sessions')
|
|
70
|
+
], Session);
|
|
71
|
+
//# sourceMappingURL=session.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.entity.js","sourceRoot":"","sources":["../../../../src/database/typeorm/entities/session.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAMiB;AAGV,IAAM,OAAO,GAAb,MAAM,OAAO;IAmClB,KAAK;QACH,OAAO;YACL,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC;IACJ,CAAC;CACF,CAAA;AA/CY,0BAAO;AAElB;IADC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;mCACpB;AAKX;IAFC,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,GAAE;;oCACI;AAIZ;IAFC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC1B,IAAA,eAAK,GAAE;;0CACU;AAKlB;IADC,IAAA,gBAAM,EAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,oCAAoC;;;iDACtC;AAIzB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;0CACT;AAIlB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;kDACD;AAG1B;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;0CACT;AAGlB;IADC,IAAA,gBAAM,GAAE;8BACE,IAAI;0CAAC;AAGhB;IADC,IAAA,0BAAgB,GAAE;8BACR,IAAI;0CAAC;kBAjCL,OAAO;IADnB,IAAA,gBAAM,EAAC,UAAU,CAAC;GACN,OAAO,CA+CnB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SessionEvent } from '../../../auth/enums/session-event.enum';
|
|
2
|
+
export declare class SessionLog {
|
|
3
|
+
id: string;
|
|
4
|
+
sessionId: string;
|
|
5
|
+
uid: string;
|
|
6
|
+
namespace: string;
|
|
7
|
+
event: SessionEvent;
|
|
8
|
+
userAgent: string;
|
|
9
|
+
deviceFingerprint: string;
|
|
10
|
+
ipAddress: string;
|
|
11
|
+
timestamp: Date;
|
|
12
|
+
reason?: string;
|
|
13
|
+
toMap(): {
|
|
14
|
+
id: string;
|
|
15
|
+
uid: string;
|
|
16
|
+
sessionId: string;
|
|
17
|
+
event: SessionEvent;
|
|
18
|
+
userAgent: string;
|
|
19
|
+
deviceFingerprint: string;
|
|
20
|
+
ipAddress: string;
|
|
21
|
+
timestamp: Date;
|
|
22
|
+
reason: string;
|
|
23
|
+
namespace: string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
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.SessionLog = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const session_event_enum_1 = require("../../../auth/enums/session-event.enum");
|
|
15
|
+
let SessionLog = class SessionLog {
|
|
16
|
+
toMap() {
|
|
17
|
+
return {
|
|
18
|
+
id: this.id,
|
|
19
|
+
uid: this.uid,
|
|
20
|
+
sessionId: this.sessionId,
|
|
21
|
+
event: this.event,
|
|
22
|
+
userAgent: this.userAgent,
|
|
23
|
+
deviceFingerprint: this.deviceFingerprint,
|
|
24
|
+
ipAddress: this.ipAddress,
|
|
25
|
+
timestamp: this.timestamp,
|
|
26
|
+
reason: this.reason,
|
|
27
|
+
namespace: this.namespace,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
exports.SessionLog = SessionLog;
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
34
|
+
__metadata("design:type", String)
|
|
35
|
+
], SessionLog.prototype, "id", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
(0, typeorm_1.Column)('uuid'),
|
|
38
|
+
(0, typeorm_1.Index)(),
|
|
39
|
+
__metadata("design:type", String)
|
|
40
|
+
], SessionLog.prototype, "sessionId", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, typeorm_1.Column)('uuid'),
|
|
43
|
+
(0, typeorm_1.Index)(),
|
|
44
|
+
__metadata("design:type", String)
|
|
45
|
+
], SessionLog.prototype, "uid", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
48
|
+
(0, typeorm_1.Index)(),
|
|
49
|
+
__metadata("design:type", String)
|
|
50
|
+
], SessionLog.prototype, "namespace", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
(0, typeorm_1.Column)(),
|
|
53
|
+
__metadata("design:type", Number)
|
|
54
|
+
], SessionLog.prototype, "event", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
57
|
+
__metadata("design:type", String)
|
|
58
|
+
], SessionLog.prototype, "userAgent", void 0);
|
|
59
|
+
__decorate([
|
|
60
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
61
|
+
__metadata("design:type", String)
|
|
62
|
+
], SessionLog.prototype, "deviceFingerprint", void 0);
|
|
63
|
+
__decorate([
|
|
64
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
65
|
+
__metadata("design:type", String)
|
|
66
|
+
], SessionLog.prototype, "ipAddress", void 0);
|
|
67
|
+
__decorate([
|
|
68
|
+
(0, typeorm_1.CreateDateColumn)(),
|
|
69
|
+
__metadata("design:type", Date)
|
|
70
|
+
], SessionLog.prototype, "timestamp", void 0);
|
|
71
|
+
__decorate([
|
|
72
|
+
(0, typeorm_1.Column)(),
|
|
73
|
+
__metadata("design:type", String)
|
|
74
|
+
], SessionLog.prototype, "reason", void 0);
|
|
75
|
+
exports.SessionLog = SessionLog = __decorate([
|
|
76
|
+
(0, typeorm_1.Entity)('session_logs')
|
|
77
|
+
], SessionLog);
|
|
78
|
+
//# sourceMappingURL=session_log.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session_log.entity.js","sourceRoot":"","sources":["../../../../src/database/typeorm/entities/session_log.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAMiB;AAEjB,+EAAsE;AAG/D,IAAM,UAAU,GAAhB,MAAM,UAAU;IAqCrB,KAAK;QACH,OAAO;YACL,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC;IACJ,CAAC;CACF,CAAA;AAnDY,gCAAU;AAErB;IADC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;sCACpB;AAIX;IAFC,IAAA,gBAAM,EAAC,MAAM,CAAC;IACd,IAAA,eAAK,GAAE;;6CACU;AAKlB;IAFC,IAAA,gBAAM,EAAC,MAAM,CAAC;IACd,IAAA,eAAK,GAAE;;uCACI;AAIZ;IAFC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC1B,IAAA,eAAK,GAAE;;6CACU;AAGlB;IADC,IAAA,gBAAM,GAAE;;yCACW;AAIpB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACT;AAIlB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qDACD;AAG1B;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACT;AAGlB;IADC,IAAA,0BAAgB,GAAE;8BACR,IAAI;6CAAC;AAGhB;IADC,IAAA,gBAAM,GAAE;;0CACO;qBAnCL,UAAU;IADtB,IAAA,gBAAM,EAAC,cAAc,CAAC;GACV,UAAU,CAmDtB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Auth } from '../entities/auth.entity';
|
|
2
|
+
import { AuthIdentifier } from '../entities/auth-identify.entity';
|
|
3
|
+
import { OAuthProvider } from '../entities/oauth-provider.entity';
|
|
4
|
+
import { MfaMethod } from '../entities/mfa-method.entity';
|
|
5
|
+
import { OtpToken } from '../entities/otp-token.entity';
|
|
6
|
+
import { Session } from '../entities/session.entity';
|
|
7
|
+
export declare const AuthEntities: (typeof AuthIdentifier | typeof Auth | typeof OAuthProvider | typeof OtpToken | typeof Session | typeof MfaMethod)[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthEntities = void 0;
|
|
4
|
+
const auth_entity_1 = require("../entities/auth.entity");
|
|
5
|
+
const auth_identify_entity_1 = require("../entities/auth-identify.entity");
|
|
6
|
+
const oauth_provider_entity_1 = require("../entities/oauth-provider.entity");
|
|
7
|
+
const mfa_method_entity_1 = require("../entities/mfa-method.entity");
|
|
8
|
+
const otp_token_entity_1 = require("../entities/otp-token.entity");
|
|
9
|
+
const session_entity_1 = require("../entities/session.entity");
|
|
10
|
+
exports.AuthEntities = [
|
|
11
|
+
auth_entity_1.Auth,
|
|
12
|
+
auth_identify_entity_1.AuthIdentifier,
|
|
13
|
+
oauth_provider_entity_1.OAuthProvider,
|
|
14
|
+
mfa_method_entity_1.MfaMethod,
|
|
15
|
+
otp_token_entity_1.OtpToken,
|
|
16
|
+
session_entity_1.Session,
|
|
17
|
+
];
|
|
18
|
+
//# sourceMappingURL=auth-entities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-entities.js","sourceRoot":"","sources":["../../../../src/database/typeorm/migrations/auth-entities.ts"],"names":[],"mappings":";;;AAAA,yDAA+C;AAC/C,2EAAkE;AAClE,6EAAkE;AAClE,qEAA0D;AAC1D,mEAAwD;AACxD,+DAAqD;AAExC,QAAA,YAAY,GAAG;IAC1B,kBAAI;IACJ,qCAAc;IACd,qCAAa;IACb,6BAAS;IACT,2BAAQ;IACR,wBAAO;CACR,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { OnModuleInit } from "@nestjs/common";
|
|
2
|
+
import { AuthMigrationService } from "./migration.service";
|
|
3
|
+
import { AuthModuleOptions } from '../../../auth/interfaces/auth-module-options.interface';
|
|
4
|
+
export declare class AuthSchemaInitializer implements OnModuleInit {
|
|
5
|
+
private migrationService;
|
|
6
|
+
private options;
|
|
7
|
+
constructor(migrationService: AuthMigrationService, options: AuthModuleOptions);
|
|
8
|
+
onModuleInit(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
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.AuthSchemaInitializer = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const migration_service_1 = require("./migration.service");
|
|
18
|
+
const auth_module_options_interface_1 = require("../../../auth/interfaces/auth-module-options.interface");
|
|
19
|
+
let AuthSchemaInitializer = class AuthSchemaInitializer {
|
|
20
|
+
constructor(migrationService, options) {
|
|
21
|
+
this.migrationService = migrationService;
|
|
22
|
+
this.options = options;
|
|
23
|
+
}
|
|
24
|
+
async onModuleInit() {
|
|
25
|
+
if (this.options.autoMigrate) {
|
|
26
|
+
await this.migrationService.runMigrations();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
exports.AuthSchemaInitializer = AuthSchemaInitializer;
|
|
31
|
+
exports.AuthSchemaInitializer = AuthSchemaInitializer = __decorate([
|
|
32
|
+
(0, common_1.Injectable)(),
|
|
33
|
+
__param(1, (0, common_1.Inject)(auth_module_options_interface_1.AUTH_MODULE_OPTIONS)),
|
|
34
|
+
__metadata("design:paramtypes", [migration_service_1.AuthMigrationService, Object])
|
|
35
|
+
], AuthSchemaInitializer);
|
|
36
|
+
//# sourceMappingURL=auth-schema.initializer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-schema.initializer.js","sourceRoot":"","sources":["../../../../src/database/typeorm/migrations/auth-schema.initializer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAkE;AAClE,2DAA2D;AAC3D,0GAAgH;AAGzG,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAC9B,YACY,gBAAsC,EACT,OAA0B;QADvD,qBAAgB,GAAhB,gBAAgB,CAAsB;QACT,YAAO,GAAP,OAAO,CAAmB;IAC/D,CAAC;IAEL,KAAK,CAAC,YAAY;QACd,IAAI,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;YAC3B,MAAM,IAAI,CAAC,gBAAgB,CAAC,aAAa,EAAE,CAAC;QAChD,CAAC;IACL,CAAC;CACJ,CAAA;AAXY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;IAIJ,WAAA,IAAA,eAAM,EAAC,mDAAmB,CAAC,CAAA;qCADF,wCAAoB;GAFzC,qBAAqB,CAWjC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { QueryRunner } from 'typeorm';
|
|
2
|
+
export interface AuthMigration {
|
|
3
|
+
version: number;
|
|
4
|
+
up(queryRunner: QueryRunner): Promise<void>;
|
|
5
|
+
down(queryRunner: QueryRunner): Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
export declare class AuthMigrationV1 implements AuthMigration {
|
|
8
|
+
down(queryRunner: QueryRunner): Promise<void>;
|
|
9
|
+
static version: number;
|
|
10
|
+
get version(): number;
|
|
11
|
+
up(queryRunner: QueryRunner): Promise<void>;
|
|
12
|
+
}
|