@ofeklabs/horizon-auth 0.2.1 → 0.4.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/README.md +544 -175
- package/dist/account/account.module.d.ts +2 -0
- package/dist/account/account.module.js +23 -0
- package/dist/account/account.module.js.map +1 -0
- package/dist/account/account.service.d.ts +10 -0
- package/dist/account/account.service.js +69 -0
- package/dist/account/account.service.js.map +1 -0
- package/dist/account/dto/deactivate-account.dto.d.ts +3 -0
- package/dist/account/dto/deactivate-account.dto.js +22 -0
- package/dist/account/dto/deactivate-account.dto.js.map +1 -0
- package/dist/account/dto/index.d.ts +1 -0
- package/dist/account/dto/index.js +18 -0
- package/dist/account/dto/index.js.map +1 -0
- package/dist/auth/auth.controller.d.ts +81 -2
- package/dist/auth/auth.controller.js +304 -6
- package/dist/auth/auth.controller.js.map +1 -1
- package/dist/auth/auth.module.d.ts +2 -1
- package/dist/auth/auth.module.js +36 -14
- package/dist/auth/auth.module.js.map +1 -1
- package/dist/auth/auth.service.d.ts +19 -2
- package/dist/auth/auth.service.js +85 -3
- package/dist/auth/auth.service.js.map +1 -1
- package/dist/common/exceptions/account-deactivated.exception.d.ts +4 -0
- package/dist/common/exceptions/account-deactivated.exception.js +13 -0
- package/dist/common/exceptions/account-deactivated.exception.js.map +1 -0
- package/dist/common/exceptions/backup-code-already-used.exception.d.ts +4 -0
- package/dist/common/exceptions/backup-code-already-used.exception.js +11 -0
- package/dist/common/exceptions/backup-code-already-used.exception.js.map +1 -0
- package/dist/common/exceptions/feature-disabled.exception.d.ts +4 -0
- package/dist/common/exceptions/feature-disabled.exception.js +11 -0
- package/dist/common/exceptions/feature-disabled.exception.js.map +1 -0
- package/dist/common/exceptions/index.d.ts +6 -0
- package/dist/common/exceptions/index.js +23 -0
- package/dist/common/exceptions/index.js.map +1 -0
- package/dist/common/exceptions/invalid-two-factor-code.exception.d.ts +4 -0
- package/dist/common/exceptions/invalid-two-factor-code.exception.js +11 -0
- package/dist/common/exceptions/invalid-two-factor-code.exception.js.map +1 -0
- package/dist/common/exceptions/social-account-already-linked.exception.d.ts +4 -0
- package/dist/common/exceptions/social-account-already-linked.exception.js +11 -0
- package/dist/common/exceptions/social-account-already-linked.exception.js.map +1 -0
- package/dist/common/exceptions/two-factor-required.exception.d.ts +5 -0
- package/dist/common/exceptions/two-factor-required.exception.js +12 -0
- package/dist/common/exceptions/two-factor-required.exception.js.map +1 -0
- package/dist/devices/device.module.d.ts +2 -0
- package/dist/devices/device.module.js +24 -0
- package/dist/devices/device.module.js.map +1 -0
- package/dist/devices/device.service.d.ts +48 -0
- package/dist/devices/device.service.js +149 -0
- package/dist/devices/device.service.js.map +1 -0
- package/dist/devices/dto/device-info.dto.d.ts +3 -0
- package/dist/devices/dto/device-info.dto.js +22 -0
- package/dist/devices/dto/device-info.dto.js.map +1 -0
- package/dist/devices/dto/device-response.dto.d.ts +9 -0
- package/dist/devices/dto/device-response.dto.js +7 -0
- package/dist/devices/dto/device-response.dto.js.map +1 -0
- package/dist/devices/dto/index.d.ts +2 -0
- package/dist/devices/dto/index.js +19 -0
- package/dist/devices/dto/index.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/horizon-auth-config.interface.d.ts +29 -0
- package/dist/lib/horizon-auth-env.config.d.ts +3 -0
- package/dist/lib/horizon-auth-env.config.js +173 -0
- package/dist/lib/horizon-auth-env.config.js.map +1 -0
- package/dist/lib/horizon-auth.module.d.ts +1 -1
- package/dist/lib/horizon-auth.module.js +10 -8
- package/dist/lib/horizon-auth.module.js.map +1 -1
- package/dist/push-tokens/dto/index.d.ts +1 -0
- package/dist/push-tokens/dto/index.js +18 -0
- package/dist/push-tokens/dto/index.js.map +1 -0
- package/dist/push-tokens/dto/register-push-token.dto.d.ts +5 -0
- package/dist/push-tokens/dto/register-push-token.dto.js +30 -0
- package/dist/push-tokens/dto/register-push-token.dto.js.map +1 -0
- package/dist/push-tokens/push-token.module.d.ts +2 -0
- package/dist/push-tokens/push-token.module.js +24 -0
- package/dist/push-tokens/push-token.module.js.map +1 -0
- package/dist/push-tokens/push-token.service.d.ts +52 -0
- package/dist/push-tokens/push-token.service.js +129 -0
- package/dist/push-tokens/push-token.service.js.map +1 -0
- package/dist/social-auth/dto/facebook-callback.dto.d.ts +3 -0
- package/dist/social-auth/dto/facebook-callback.dto.js +22 -0
- package/dist/social-auth/dto/facebook-callback.dto.js.map +1 -0
- package/dist/social-auth/dto/google-callback.dto.d.ts +3 -0
- package/dist/social-auth/dto/google-callback.dto.js +22 -0
- package/dist/social-auth/dto/google-callback.dto.js.map +1 -0
- package/dist/social-auth/dto/index.d.ts +2 -0
- package/dist/social-auth/dto/index.js +19 -0
- package/dist/social-auth/dto/index.js.map +1 -0
- package/dist/social-auth/social-auth.module.d.ts +2 -0
- package/dist/social-auth/social-auth.module.js +25 -0
- package/dist/social-auth/social-auth.module.js.map +1 -0
- package/dist/social-auth/social-auth.service.d.ts +43 -0
- package/dist/social-auth/social-auth.service.js +130 -0
- package/dist/social-auth/social-auth.service.js.map +1 -0
- package/dist/social-auth/strategies/facebook.strategy.d.ts +9 -0
- package/dist/social-auth/strategies/facebook.strategy.js +51 -0
- package/dist/social-auth/strategies/facebook.strategy.js.map +1 -0
- package/dist/social-auth/strategies/google.strategy.d.ts +9 -0
- package/dist/social-auth/strategies/google.strategy.js +49 -0
- package/dist/social-auth/strategies/google.strategy.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/two-factor/dto/enable-two-factor.dto.d.ts +2 -0
- package/dist/two-factor/dto/enable-two-factor.dto.js +7 -0
- package/dist/two-factor/dto/enable-two-factor.dto.js.map +1 -0
- package/dist/two-factor/dto/index.d.ts +2 -0
- package/dist/two-factor/dto/index.js +19 -0
- package/dist/two-factor/dto/index.js.map +1 -0
- package/dist/two-factor/dto/two-factor-enabled-response.dto.d.ts +3 -0
- package/dist/two-factor/dto/two-factor-enabled-response.dto.js +7 -0
- package/dist/two-factor/dto/two-factor-enabled-response.dto.js.map +1 -0
- package/dist/two-factor/dto/two-factor-setup-response.dto.d.ts +4 -0
- package/dist/two-factor/dto/two-factor-setup-response.dto.js +7 -0
- package/dist/two-factor/dto/two-factor-setup-response.dto.js.map +1 -0
- package/dist/two-factor/dto/verify-two-factor-login.dto.d.ts +3 -0
- package/dist/two-factor/dto/verify-two-factor-login.dto.js +22 -0
- package/dist/two-factor/dto/verify-two-factor-login.dto.js.map +1 -0
- package/dist/two-factor/dto/verify-two-factor-setup.dto.d.ts +3 -0
- package/dist/two-factor/dto/verify-two-factor-setup.dto.js +22 -0
- package/dist/two-factor/dto/verify-two-factor-setup.dto.js.map +1 -0
- package/dist/two-factor/two-factor.module.d.ts +2 -0
- package/dist/two-factor/two-factor.module.js +23 -0
- package/dist/two-factor/two-factor.module.js.map +1 -0
- package/dist/two-factor/two-factor.service.d.ts +19 -0
- package/dist/two-factor/two-factor.service.js +215 -0
- package/dist/two-factor/two-factor.service.js.map +1 -0
- package/dist/users/users.service.d.ts +1 -1
- package/dist/users/users.service.js.map +1 -1
- package/package.json +26 -4
- package/prisma/migrations/20260218105110_add_enhanced_auth_features/migration.sql +192 -0
- package/prisma/migrations/migration_lock.toml +3 -0
- package/prisma/schema.prisma +106 -13
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enable-two-factor.dto.js","sourceRoot":"","sources":["../../../src/two-factor/dto/enable-two-factor.dto.ts"],"names":[],"mappings":";;;AACA,MAAa,kBAAkB;CAAG;AAAlC,gDAAkC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./verify-two-factor-setup.dto"), exports);
|
|
18
|
+
__exportStar(require("./verify-two-factor-login.dto"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/two-factor/dto/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gEAA8C;AAC9C,gEAA8C"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TwoFactorEnabledResponseDto = void 0;
|
|
4
|
+
class TwoFactorEnabledResponseDto {
|
|
5
|
+
}
|
|
6
|
+
exports.TwoFactorEnabledResponseDto = TwoFactorEnabledResponseDto;
|
|
7
|
+
//# sourceMappingURL=two-factor-enabled-response.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"two-factor-enabled-response.dto.js","sourceRoot":"","sources":["../../../src/two-factor/dto/two-factor-enabled-response.dto.ts"],"names":[],"mappings":";;;AAAA,MAAa,2BAA2B;CAEvC;AAFD,kEAEC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TwoFactorSetupResponseDto = void 0;
|
|
4
|
+
class TwoFactorSetupResponseDto {
|
|
5
|
+
}
|
|
6
|
+
exports.TwoFactorSetupResponseDto = TwoFactorSetupResponseDto;
|
|
7
|
+
//# sourceMappingURL=two-factor-setup-response.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"two-factor-setup-response.dto.js","sourceRoot":"","sources":["../../../src/two-factor/dto/two-factor-setup-response.dto.ts"],"names":[],"mappings":";;;AAAA,MAAa,yBAAyB;CAGrC;AAHD,8DAGC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
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.VerifyTwoFactorLoginDto = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
class VerifyTwoFactorLoginDto {
|
|
15
|
+
}
|
|
16
|
+
exports.VerifyTwoFactorLoginDto = VerifyTwoFactorLoginDto;
|
|
17
|
+
__decorate([
|
|
18
|
+
(0, class_validator_1.IsString)(),
|
|
19
|
+
(0, class_validator_1.Length)(6, 9),
|
|
20
|
+
__metadata("design:type", String)
|
|
21
|
+
], VerifyTwoFactorLoginDto.prototype, "code", void 0);
|
|
22
|
+
//# sourceMappingURL=verify-two-factor-login.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-two-factor-login.dto.js","sourceRoot":"","sources":["../../../src/two-factor/dto/verify-two-factor-login.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAmD;AAEnD,MAAa,uBAAuB;CAInC;AAJD,0DAIC;AADC;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,wBAAM,EAAC,CAAC,EAAE,CAAC,CAAC;;qDACA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
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.VerifyTwoFactorSetupDto = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
class VerifyTwoFactorSetupDto {
|
|
15
|
+
}
|
|
16
|
+
exports.VerifyTwoFactorSetupDto = VerifyTwoFactorSetupDto;
|
|
17
|
+
__decorate([
|
|
18
|
+
(0, class_validator_1.IsString)(),
|
|
19
|
+
(0, class_validator_1.Length)(6, 6),
|
|
20
|
+
__metadata("design:type", String)
|
|
21
|
+
], VerifyTwoFactorSetupDto.prototype, "code", void 0);
|
|
22
|
+
//# sourceMappingURL=verify-two-factor-setup.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-two-factor-setup.dto.js","sourceRoot":"","sources":["../../../src/two-factor/dto/verify-two-factor-setup.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAmD;AAEnD,MAAa,uBAAuB;CAInC;AAJD,0DAIC;AADC;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,wBAAM,EAAC,CAAC,EAAE,CAAC,CAAC;;qDACA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.TwoFactorModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const two_factor_service_1 = require("./two-factor.service");
|
|
12
|
+
const prisma_module_1 = require("../prisma/prisma.module");
|
|
13
|
+
let TwoFactorModule = class TwoFactorModule {
|
|
14
|
+
};
|
|
15
|
+
exports.TwoFactorModule = TwoFactorModule;
|
|
16
|
+
exports.TwoFactorModule = TwoFactorModule = __decorate([
|
|
17
|
+
(0, common_1.Module)({
|
|
18
|
+
imports: [prisma_module_1.PrismaModule],
|
|
19
|
+
providers: [two_factor_service_1.TwoFactorService],
|
|
20
|
+
exports: [two_factor_service_1.TwoFactorService],
|
|
21
|
+
})
|
|
22
|
+
], TwoFactorModule);
|
|
23
|
+
//# sourceMappingURL=two-factor.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"two-factor.module.js","sourceRoot":"","sources":["../../src/two-factor/two-factor.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6DAAwD;AACxD,2DAAuD;AAOhD,IAAM,eAAe,GAArB,MAAM,eAAe;CAAG,CAAA;AAAlB,0CAAe;0BAAf,eAAe;IAL3B,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,4BAAY,CAAC;QACvB,SAAS,EAAE,CAAC,qCAAgB,CAAC;QAC7B,OAAO,EAAE,CAAC,qCAAgB,CAAC;KAC5B,CAAC;GACW,eAAe,CAAG"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { PrismaService } from '../prisma/prisma.service';
|
|
2
|
+
export declare class TwoFactorService {
|
|
3
|
+
private readonly prisma;
|
|
4
|
+
constructor(prisma: PrismaService);
|
|
5
|
+
generateTotpSecret(userId: string, issuer?: string): Promise<{
|
|
6
|
+
secret: string;
|
|
7
|
+
qrCode: string;
|
|
8
|
+
}>;
|
|
9
|
+
verifyTotpSetup(userId: string, code: string): Promise<boolean>;
|
|
10
|
+
enableTwoFactor(userId: string): Promise<{
|
|
11
|
+
backupCodes: string[];
|
|
12
|
+
}>;
|
|
13
|
+
disableTwoFactor(userId: string): Promise<void>;
|
|
14
|
+
verifyTotpCode(userId: string, code: string): Promise<boolean>;
|
|
15
|
+
verifyBackupCode(userId: string, code: string): Promise<boolean>;
|
|
16
|
+
regenerateBackupCodes(userId: string): Promise<string[]>;
|
|
17
|
+
isTwoFactorEnabled(userId: string): Promise<boolean>;
|
|
18
|
+
private generateBackupCodes;
|
|
19
|
+
}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
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;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.TwoFactorService = void 0;
|
|
46
|
+
const common_1 = require("@nestjs/common");
|
|
47
|
+
const prisma_service_1 = require("../prisma/prisma.service");
|
|
48
|
+
const otplib_1 = require("otplib");
|
|
49
|
+
const QRCode = __importStar(require("qrcode"));
|
|
50
|
+
const crypto = __importStar(require("crypto"));
|
|
51
|
+
const bcrypt = __importStar(require("bcrypt"));
|
|
52
|
+
let TwoFactorService = class TwoFactorService {
|
|
53
|
+
constructor(prisma) {
|
|
54
|
+
this.prisma = prisma;
|
|
55
|
+
}
|
|
56
|
+
async generateTotpSecret(userId, issuer = 'HorizonAuth') {
|
|
57
|
+
const user = await this.prisma.user.findUnique({
|
|
58
|
+
where: { id: userId },
|
|
59
|
+
select: { email: true },
|
|
60
|
+
});
|
|
61
|
+
if (!user) {
|
|
62
|
+
throw new Error('User not found');
|
|
63
|
+
}
|
|
64
|
+
const secret = await (0, otplib_1.generateSecret)();
|
|
65
|
+
const otpauthUrl = (0, otplib_1.generateURI)({
|
|
66
|
+
issuer,
|
|
67
|
+
label: user.email,
|
|
68
|
+
secret,
|
|
69
|
+
});
|
|
70
|
+
const qrCode = await QRCode.toDataURL(otpauthUrl);
|
|
71
|
+
await this.prisma.twoFactorAuth.upsert({
|
|
72
|
+
where: { userId },
|
|
73
|
+
create: {
|
|
74
|
+
userId,
|
|
75
|
+
totpSecret: secret,
|
|
76
|
+
enabled: false,
|
|
77
|
+
},
|
|
78
|
+
update: {
|
|
79
|
+
totpSecret: secret,
|
|
80
|
+
enabled: false,
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
return { secret, qrCode };
|
|
84
|
+
}
|
|
85
|
+
async verifyTotpSetup(userId, code) {
|
|
86
|
+
const twoFactorAuth = await this.prisma.twoFactorAuth.findUnique({
|
|
87
|
+
where: { userId },
|
|
88
|
+
});
|
|
89
|
+
if (!twoFactorAuth) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
const result = await (0, otplib_1.verify)({
|
|
93
|
+
token: code,
|
|
94
|
+
secret: twoFactorAuth.totpSecret,
|
|
95
|
+
});
|
|
96
|
+
return result.valid;
|
|
97
|
+
}
|
|
98
|
+
async enableTwoFactor(userId) {
|
|
99
|
+
const twoFactorAuth = await this.prisma.twoFactorAuth.findUnique({
|
|
100
|
+
where: { userId },
|
|
101
|
+
});
|
|
102
|
+
if (!twoFactorAuth) {
|
|
103
|
+
throw new Error('2FA setup not initiated');
|
|
104
|
+
}
|
|
105
|
+
const backupCodes = this.generateBackupCodes();
|
|
106
|
+
const hashedCodes = await Promise.all(backupCodes.map(async (code) => ({
|
|
107
|
+
userId,
|
|
108
|
+
codeHash: await bcrypt.hash(code, 10),
|
|
109
|
+
used: false,
|
|
110
|
+
})));
|
|
111
|
+
await this.prisma.$transaction([
|
|
112
|
+
this.prisma.twoFactorAuth.update({
|
|
113
|
+
where: { userId },
|
|
114
|
+
data: {
|
|
115
|
+
enabled: true,
|
|
116
|
+
enabledAt: new Date(),
|
|
117
|
+
},
|
|
118
|
+
}),
|
|
119
|
+
this.prisma.backupCode.createMany({
|
|
120
|
+
data: hashedCodes,
|
|
121
|
+
}),
|
|
122
|
+
]);
|
|
123
|
+
return { backupCodes };
|
|
124
|
+
}
|
|
125
|
+
async disableTwoFactor(userId) {
|
|
126
|
+
await this.prisma.$transaction([
|
|
127
|
+
this.prisma.twoFactorAuth.delete({
|
|
128
|
+
where: { userId },
|
|
129
|
+
}),
|
|
130
|
+
this.prisma.backupCode.deleteMany({
|
|
131
|
+
where: { userId },
|
|
132
|
+
}),
|
|
133
|
+
]);
|
|
134
|
+
}
|
|
135
|
+
async verifyTotpCode(userId, code) {
|
|
136
|
+
const twoFactorAuth = await this.prisma.twoFactorAuth.findUnique({
|
|
137
|
+
where: { userId, enabled: true },
|
|
138
|
+
});
|
|
139
|
+
if (!twoFactorAuth) {
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
const result = await (0, otplib_1.verify)({
|
|
143
|
+
token: code,
|
|
144
|
+
secret: twoFactorAuth.totpSecret,
|
|
145
|
+
});
|
|
146
|
+
return result.valid;
|
|
147
|
+
}
|
|
148
|
+
async verifyBackupCode(userId, code) {
|
|
149
|
+
const backupCodes = await this.prisma.backupCode.findMany({
|
|
150
|
+
where: { userId, used: false },
|
|
151
|
+
});
|
|
152
|
+
for (const backupCode of backupCodes) {
|
|
153
|
+
const isValid = await bcrypt.compare(code, backupCode.codeHash);
|
|
154
|
+
if (isValid) {
|
|
155
|
+
await this.prisma.backupCode.update({
|
|
156
|
+
where: { id: backupCode.id },
|
|
157
|
+
data: {
|
|
158
|
+
used: true,
|
|
159
|
+
usedAt: new Date(),
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
async regenerateBackupCodes(userId) {
|
|
168
|
+
const twoFactorAuth = await this.prisma.twoFactorAuth.findUnique({
|
|
169
|
+
where: { userId, enabled: true },
|
|
170
|
+
});
|
|
171
|
+
if (!twoFactorAuth) {
|
|
172
|
+
throw new Error('2FA not enabled');
|
|
173
|
+
}
|
|
174
|
+
const backupCodes = this.generateBackupCodes();
|
|
175
|
+
const hashedCodes = await Promise.all(backupCodes.map(async (code) => ({
|
|
176
|
+
userId,
|
|
177
|
+
codeHash: await bcrypt.hash(code, 10),
|
|
178
|
+
used: false,
|
|
179
|
+
})));
|
|
180
|
+
await this.prisma.$transaction([
|
|
181
|
+
this.prisma.backupCode.deleteMany({
|
|
182
|
+
where: { userId },
|
|
183
|
+
}),
|
|
184
|
+
this.prisma.backupCode.createMany({
|
|
185
|
+
data: hashedCodes,
|
|
186
|
+
}),
|
|
187
|
+
]);
|
|
188
|
+
return backupCodes;
|
|
189
|
+
}
|
|
190
|
+
async isTwoFactorEnabled(userId) {
|
|
191
|
+
const twoFactorAuth = await this.prisma.twoFactorAuth.findUnique({
|
|
192
|
+
where: { userId, enabled: true },
|
|
193
|
+
});
|
|
194
|
+
return !!twoFactorAuth;
|
|
195
|
+
}
|
|
196
|
+
generateBackupCodes() {
|
|
197
|
+
const codes = [];
|
|
198
|
+
const chars = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789';
|
|
199
|
+
for (let i = 0; i < 10; i++) {
|
|
200
|
+
let code = '';
|
|
201
|
+
const bytes = crypto.randomBytes(8);
|
|
202
|
+
for (let j = 0; j < 8; j++) {
|
|
203
|
+
code += chars[bytes[j] % chars.length];
|
|
204
|
+
}
|
|
205
|
+
codes.push(`${code.slice(0, 4)}-${code.slice(4)}`);
|
|
206
|
+
}
|
|
207
|
+
return codes;
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
exports.TwoFactorService = TwoFactorService;
|
|
211
|
+
exports.TwoFactorService = TwoFactorService = __decorate([
|
|
212
|
+
(0, common_1.Injectable)(),
|
|
213
|
+
__metadata("design:paramtypes", [prisma_service_1.PrismaService])
|
|
214
|
+
], TwoFactorService);
|
|
215
|
+
//# sourceMappingURL=two-factor.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"two-factor.service.js","sourceRoot":"","sources":["../../src/two-factor/two-factor.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,6DAAyD;AACzD,mCAA6D;AAC7D,+CAAiC;AACjC,+CAAiC;AACjC,+CAAiC;AAG1B,IAAM,gBAAgB,GAAtB,MAAM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AE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;QAEH,OAAO,CAAC,CAAC,aAAa,CAAC;IACzB,CAAC;IAKO,mBAAmB;QACzB,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,MAAM,KAAK,GAAG,kCAAkC,CAAC;QAEjD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;YAC5B,IAAI,IAAI,GAAG,EAAE,CAAC;YACd,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YAEpC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC3B,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;YACzC,CAAC;YAGD,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACrD,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAA;AA/OY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;qCAE0B,8BAAa;GADvC,gBAAgB,CA+O5B"}
|
|
@@ -6,7 +6,7 @@ export declare class UsersService {
|
|
|
6
6
|
constructor(prisma: PrismaService);
|
|
7
7
|
findByEmail(email: string): Promise<User | null>;
|
|
8
8
|
findById(id: string): Promise<User | null>;
|
|
9
|
-
create(email: string, passwordHash: string, tenantId?: string): Promise<User>;
|
|
9
|
+
create(email: string, passwordHash: string | null, tenantId?: string): Promise<User>;
|
|
10
10
|
update(id: string, data: Partial<User>): Promise<User>;
|
|
11
11
|
verifyEmail(token: string): Promise<User>;
|
|
12
12
|
generateResetToken(email: string): Promise<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"users.service.js","sourceRoot":"","sources":["../../src/users/users.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAkF;AAClF,6DAAyD;AAEzD,mCAAoC;AAK7B,IAAM,YAAY,GAAlB,MAAM,YAAY;IACvB,YAA6B,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAG,CAAC;IAOtD,KAAK,CAAC,WAAW,CAAC,KAAa;QAC7B,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;YACjC,KAAK,EAAE,EAAE,KAAK,EAAE;YAChB,OAAO,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAOD,KAAK,CAAC,QAAQ,CAAC,EAAU;QACvB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;YACjC,KAAK,EAAE,EAAE,EAAE,EAAE;YACb,OAAO,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IASD,KAAK,CAAC,MAAM,CACV,KAAa,EACb,
|
|
1
|
+
{"version":3,"file":"users.service.js","sourceRoot":"","sources":["../../src/users/users.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAkF;AAClF,6DAAyD;AAEzD,mCAAoC;AAK7B,IAAM,YAAY,GAAlB,MAAM,YAAY;IACvB,YAA6B,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAG,CAAC;IAOtD,KAAK,CAAC,WAAW,CAAC,KAAa;QAC7B,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;YACjC,KAAK,EAAE,EAAE,KAAK,EAAE;YAChB,OAAO,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAOD,KAAK,CAAC,QAAQ,CAAC,EAAU;QACvB,OAAO,IAAI,CAAC,MAAM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,EAAE,eAAe;gBAC7B,UAAU,EAAE,IAAI;gBAChB,gBAAgB,EAAE,IAAI;aACvB;SACF,CAAC,CAAC;IACL,CAAC;IAOD,UAAU,CAAC,IAAU;QACnB,MAAM,EAAE,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,gBAAgB,EAAE,GAAG,QAAQ,EAAE,GAAG,IAAI,CAAC;QAC3F,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF,CAAA;AAxJY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAU,GAAE;qCAE0B,8BAAa;GADvC,YAAY,CAwJxB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ofeklabs/horizon-auth",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Production-ready NestJS authentication module with
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Production-ready NestJS authentication module with ENV-based configuration, 2FA, device management, and SSO support",
|
|
5
5
|
"author": "Ofek Itzhaki",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "dist/index.js",
|
|
@@ -38,11 +38,18 @@
|
|
|
38
38
|
"@nestjs/jwt": "^10.2.0",
|
|
39
39
|
"@nestjs/throttler": "^5.1.0",
|
|
40
40
|
"@node-rs/argon2": "^1.8.0",
|
|
41
|
+
"@types/bcrypt": "^6.0.0",
|
|
42
|
+
"bcrypt": "^6.0.0",
|
|
41
43
|
"class-transformer": "^0.5.1",
|
|
42
44
|
"class-validator": "^0.14.1",
|
|
43
45
|
"dotenv": "^17.3.1",
|
|
44
46
|
"ioredis": "^5.3.2",
|
|
45
|
-
"
|
|
47
|
+
"otplib": "^13.3.0",
|
|
48
|
+
"passport-facebook": "^3.0.0",
|
|
49
|
+
"passport-google-oauth20": "^2.0.0",
|
|
50
|
+
"pg": "^8.18.0",
|
|
51
|
+
"qrcode": "^1.5.4",
|
|
52
|
+
"ua-parser-js": "^2.0.9"
|
|
46
53
|
},
|
|
47
54
|
"devDependencies": {
|
|
48
55
|
"@nestjs/cli": "^10.3.0",
|
|
@@ -50,7 +57,11 @@
|
|
|
50
57
|
"@nestjs/testing": "^10.3.0",
|
|
51
58
|
"@types/jest": "^29.5.11",
|
|
52
59
|
"@types/node": "^20.11.0",
|
|
60
|
+
"@types/passport-facebook": "^3.0.4",
|
|
61
|
+
"@types/passport-google-oauth20": "^2.0.17",
|
|
53
62
|
"@types/passport-jwt": "^4.0.0",
|
|
63
|
+
"@types/qrcode": "^1.5.6",
|
|
64
|
+
"@types/ua-parser-js": "^0.7.39",
|
|
54
65
|
"@typescript-eslint/eslint-plugin": "^6.19.0",
|
|
55
66
|
"@typescript-eslint/parser": "^6.19.0",
|
|
56
67
|
"eslint": "^8.56.0",
|
|
@@ -69,7 +80,18 @@
|
|
|
69
80
|
"refresh-token",
|
|
70
81
|
"redis",
|
|
71
82
|
"multi-tenant",
|
|
72
|
-
"security"
|
|
83
|
+
"security",
|
|
84
|
+
"2fa",
|
|
85
|
+
"totp",
|
|
86
|
+
"two-factor",
|
|
87
|
+
"device-management",
|
|
88
|
+
"push-notifications",
|
|
89
|
+
"account-management",
|
|
90
|
+
"social-login",
|
|
91
|
+
"oauth",
|
|
92
|
+
"sso",
|
|
93
|
+
"env-config",
|
|
94
|
+
"zero-config"
|
|
73
95
|
],
|
|
74
96
|
"repository": {
|
|
75
97
|
"type": "git",
|