@nauth-toolkit/mfa-totp 0.1.3
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/LICENSE +90 -0
- package/README.md +30 -0
- package/dist/nestjs/index.d.ts +5 -0
- package/dist/nestjs/index.d.ts.map +1 -0
- package/dist/nestjs/index.js +23 -0
- package/dist/nestjs/index.js.map +1 -0
- package/dist/nestjs/totp-mfa.module.d.ts +10 -0
- package/dist/nestjs/totp-mfa.module.d.ts.map +1 -0
- package/dist/nestjs/totp-mfa.module.js +67 -0
- package/dist/nestjs/totp-mfa.module.js.map +1 -0
- package/dist/src/dto/mfa.dto.d.ts +143 -0
- package/dist/src/dto/mfa.dto.d.ts.map +1 -0
- package/dist/src/dto/mfa.dto.js +3 -0
- package/dist/src/dto/mfa.dto.js.map +1 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +23 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/totp-mfa-provider.service.d.ts +14 -0
- package/dist/src/totp-mfa-provider.service.d.ts.map +1 -0
- package/dist/src/totp-mfa-provider.service.js +71 -0
- package/dist/src/totp-mfa-provider.service.js.map +1 -0
- package/dist/src/totp.service.d.ts +22 -0
- package/dist/src/totp.service.d.ts.map +1 -0
- package/dist/src/totp.service.js +163 -0
- package/dist/src/totp.service.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +61 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
NAUTH TOOLKIT EARLY ACCESS LICENSE
|
|
2
|
+
Version 1.0 (December 2025)
|
|
3
|
+
|
|
4
|
+
================================================================================
|
|
5
|
+
FUTURE OPEN SOURCE NOTICE
|
|
6
|
+
================================================================================
|
|
7
|
+
NAuth Toolkit will transition to an open-source license (MIT or Apache 2.0) for
|
|
8
|
+
core authentication features once the project reaches production readiness.
|
|
9
|
+
|
|
10
|
+
This Early Access License is temporary and designed to:
|
|
11
|
+
• Allow developers to build with nauth-toolkit during preview/beta
|
|
12
|
+
• Provide clear expectations during the pre-release phase
|
|
13
|
+
• Enable feedback and real-world testing before GA
|
|
14
|
+
|
|
15
|
+
We're committed to keeping core auth free and open source. Premium features
|
|
16
|
+
(enterprise SSO, advanced compliance, hosted options) will be offered separately
|
|
17
|
+
under fair commercial terms.
|
|
18
|
+
|
|
19
|
+
================================================================================
|
|
20
|
+
EARLY ACCESS LICENSE TERMS
|
|
21
|
+
================================================================================
|
|
22
|
+
|
|
23
|
+
1. Grant of Use
|
|
24
|
+
You are granted a free, non-exclusive, non-transferable license to:
|
|
25
|
+
- Install and use nauth-toolkit packages in development, testing, staging,
|
|
26
|
+
and production environments
|
|
27
|
+
- Modify the code for your own internal use
|
|
28
|
+
- Deploy applications using nauth-toolkit to serve your users
|
|
29
|
+
|
|
30
|
+
You may NOT:
|
|
31
|
+
- Redistribute NAuth Toolkit as a standalone product or service
|
|
32
|
+
- Sell, sublicense, or offer NAuth Toolkit as part of a competing auth
|
|
33
|
+
platform or toolkit
|
|
34
|
+
- Remove or alter copyright notices
|
|
35
|
+
|
|
36
|
+
2. No Fees During Early Access
|
|
37
|
+
There are no license fees, subscription costs, or usage charges during the
|
|
38
|
+
Early Access period. You may use nauth-toolkit freely for commercial and
|
|
39
|
+
non-commercial purposes within the terms of this license.
|
|
40
|
+
|
|
41
|
+
3. Production Use
|
|
42
|
+
Production use is permitted but comes with standard early-access caveats:
|
|
43
|
+
- Features and APIs may change between preview releases
|
|
44
|
+
- Support is community-based (GitHub issues/discussions)
|
|
45
|
+
- No SLA or guaranteed uptime (you run it on your infrastructure)
|
|
46
|
+
|
|
47
|
+
We recommend thorough testing and having rollback plans for critical systems.
|
|
48
|
+
|
|
49
|
+
4. Future Transition
|
|
50
|
+
When nauth-toolkit releases v1.0 GA:
|
|
51
|
+
- Core packages will adopt an open-source license (MIT or Apache 2.0)
|
|
52
|
+
- Your existing deployments will continue to work
|
|
53
|
+
- Premium features (if any) will be clearly documented with separate licensing
|
|
54
|
+
- No forced upgrades or surprise fees
|
|
55
|
+
|
|
56
|
+
5. Ownership
|
|
57
|
+
NAuth Toolkit is developed and maintained by Noorix Digital Solutions.
|
|
58
|
+
You retain full ownership of your applications and data.
|
|
59
|
+
|
|
60
|
+
6. Data and Privacy
|
|
61
|
+
NAuth Toolkit runs in YOUR infrastructure and database. You control all data.
|
|
62
|
+
You are responsible for compliance with applicable data protection laws.
|
|
63
|
+
|
|
64
|
+
7. Disclaimer of Warranty
|
|
65
|
+
THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
66
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
67
|
+
FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
|
68
|
+
|
|
69
|
+
8. Limitation of Liability
|
|
70
|
+
IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY INDIRECT, INCIDENTAL,
|
|
71
|
+
SPECIAL, CONSEQUENTIAL, OR EXEMPLARY DAMAGES, INCLUDING BUT NOT LIMITED TO LOSS
|
|
72
|
+
OF PROFITS, REVENUE, DATA, OR USE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
|
73
|
+
DAMAGES.
|
|
74
|
+
|
|
75
|
+
9. Termination
|
|
76
|
+
This license remains in effect until:
|
|
77
|
+
- You stop using nauth-toolkit, or
|
|
78
|
+
- The project transitions to open source (at which point the new license applies)
|
|
79
|
+
|
|
80
|
+
If you breach these terms, your license terminates and you must stop using the
|
|
81
|
+
software.
|
|
82
|
+
|
|
83
|
+
10. Contact and Support
|
|
84
|
+
- Documentation: https://nauth.dev
|
|
85
|
+
- Issues/Discussions: GitHub (when public repository launches)
|
|
86
|
+
- Commercial inquiries: Contact admin@noorix.com
|
|
87
|
+
|
|
88
|
+
================================================================================
|
|
89
|
+
Thank you for being an early adopter. Your feedback shapes the future of NAuth.
|
|
90
|
+
================================================================================
|
package/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# @nauth-toolkit/mfa-totp
|
|
2
|
+
|
|
3
|
+
TOTP/Authenticator MFA provider for nauth-toolkit
|
|
4
|
+
|
|
5
|
+
## ⚠️ Preview Release Notice
|
|
6
|
+
|
|
7
|
+
**This is a preview release for internal testing. Do not use in production yet.**
|
|
8
|
+
|
|
9
|
+
This package is part of nauth-toolkit and is currently in early access/preview. Features and APIs may change between releases. For production use, please wait for the stable v1.0 release.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @nauth-toolkit/mfa-totp@preview
|
|
15
|
+
# or
|
|
16
|
+
yarn add @nauth-toolkit/mfa-totp@preview
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## License
|
|
20
|
+
|
|
21
|
+
See LICENSE file in the package root for full license terms.
|
|
22
|
+
|
|
23
|
+
## Documentation
|
|
24
|
+
|
|
25
|
+
Full documentation: https://nauth.dev
|
|
26
|
+
|
|
27
|
+
## Support
|
|
28
|
+
|
|
29
|
+
- Issues/Discussions: GitHub (when repository is public)
|
|
30
|
+
- Documentation: https://nauth.dev
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../nestjs/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD,cAAc,qBAAqB,CAAC;AACpC,cAAc,kCAAkC,CAAC;AACjD,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
exports.TOTPMFAModule = void 0;
|
|
18
|
+
var totp_mfa_module_1 = require("./totp-mfa.module");
|
|
19
|
+
Object.defineProperty(exports, "TOTPMFAModule", { enumerable: true, get: function () { return totp_mfa_module_1.TOTPMFAModule; } });
|
|
20
|
+
__exportStar(require("../src/totp.service"), exports);
|
|
21
|
+
__exportStar(require("../src/totp-mfa-provider.service"), exports);
|
|
22
|
+
__exportStar(require("../src/dto/mfa.dto"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../nestjs/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAMA,qDAAkD;AAAzC,gHAAA,aAAa,OAAA;AAGtB,sDAAoC;AACpC,mEAAiD;AACjD,qDAAmC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { OnModuleInit } from '@nestjs/common';
|
|
2
|
+
import { TOTPMFAProviderService } from '../src/totp-mfa-provider.service';
|
|
3
|
+
import { MFAService } from '@nauth-toolkit/core';
|
|
4
|
+
export declare class TOTPMFAModule implements OnModuleInit {
|
|
5
|
+
private readonly totpMFAProvider;
|
|
6
|
+
private readonly mfaService;
|
|
7
|
+
constructor(totpMFAProvider: TOTPMFAProviderService, mfaService: MFAService);
|
|
8
|
+
onModuleInit(): void;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=totp-mfa.module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"totp-mfa.module.d.ts","sourceRoot":"","sources":["../../nestjs/totp-mfa.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAG1E,OAAO,EAAE,UAAU,EAA4B,MAAM,qBAAqB,CAAC;AAwB3E,qBAmDa,aAAc,YAAW,YAAY;IAE9C,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,UAAU;gBADV,eAAe,EAAE,sBAAsB,EACvC,UAAU,EAAE,UAAU;IAMzC,YAAY,IAAI,IAAI;CAMrB"}
|
|
@@ -0,0 +1,67 @@
|
|
|
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.TOTPMFAModule = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const totp_mfa_provider_service_1 = require("../src/totp-mfa-provider.service");
|
|
15
|
+
const totp_service_1 = require("../src/totp.service");
|
|
16
|
+
const core_1 = require("@nauth-toolkit/core");
|
|
17
|
+
const internal_1 = require("@nauth-toolkit/core/internal");
|
|
18
|
+
const core_2 = require("@nauth-toolkit/core");
|
|
19
|
+
let TOTPMFAModule = class TOTPMFAModule {
|
|
20
|
+
totpMFAProvider;
|
|
21
|
+
mfaService;
|
|
22
|
+
constructor(totpMFAProvider, mfaService) {
|
|
23
|
+
this.totpMFAProvider = totpMFAProvider;
|
|
24
|
+
this.mfaService = mfaService;
|
|
25
|
+
}
|
|
26
|
+
onModuleInit() {
|
|
27
|
+
if (!this.mfaService) {
|
|
28
|
+
throw new Error('MFAService is not available. Ensure AuthModule.forRoot() is imported before TOTPMFAModule.');
|
|
29
|
+
}
|
|
30
|
+
this.mfaService.registerProvider(this.totpMFAProvider);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
exports.TOTPMFAModule = TOTPMFAModule;
|
|
34
|
+
exports.TOTPMFAModule = TOTPMFAModule = __decorate([
|
|
35
|
+
(0, common_1.Module)({
|
|
36
|
+
providers: [
|
|
37
|
+
{
|
|
38
|
+
provide: totp_service_1.TOTPService,
|
|
39
|
+
useFactory: (config, logger) => {
|
|
40
|
+
return new totp_service_1.TOTPService(config, logger);
|
|
41
|
+
},
|
|
42
|
+
inject: ['NAUTH_CONFIG', 'NAUTH_LOGGER'],
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
provide: totp_mfa_provider_service_1.TOTPMFAProviderService,
|
|
46
|
+
useFactory: (mfaDeviceRepository, userRepository, config, logger, passwordService, totpService, challengeService, auditService, clientInfoService) => {
|
|
47
|
+
return new totp_mfa_provider_service_1.TOTPMFAProviderService(mfaDeviceRepository, userRepository, config, logger, passwordService, totpService, challengeService, auditService, clientInfoService);
|
|
48
|
+
},
|
|
49
|
+
inject: [
|
|
50
|
+
'MFADeviceRepository',
|
|
51
|
+
'UserRepository',
|
|
52
|
+
'NAUTH_CONFIG',
|
|
53
|
+
'NAUTH_LOGGER',
|
|
54
|
+
{ token: internal_1.PasswordService, optional: true },
|
|
55
|
+
totp_service_1.TOTPService,
|
|
56
|
+
{ token: 'ChallengeService', optional: true },
|
|
57
|
+
{ token: internal_1.AuthAuditService, optional: true },
|
|
58
|
+
{ token: core_2.ClientInfoService, optional: true },
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
exports: [totp_service_1.TOTPService, totp_mfa_provider_service_1.TOTPMFAProviderService],
|
|
63
|
+
}),
|
|
64
|
+
__metadata("design:paramtypes", [totp_mfa_provider_service_1.TOTPMFAProviderService,
|
|
65
|
+
core_1.MFAService])
|
|
66
|
+
], TOTPMFAModule);
|
|
67
|
+
//# sourceMappingURL=totp-mfa.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"totp-mfa.module.js","sourceRoot":"","sources":["../../nestjs/totp-mfa.module.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAsD;AACtD,gFAA0E;AAC1E,sDAAkD;AAElD,8CAA2E;AAE3E,2DAA6G;AAC7G,8CAAwD;AAwEjD,IAAM,aAAa,GAAnB,MAAM,aAAa;IAEL;IACA;IAFnB,YACmB,eAAuC,EACvC,UAAsB;QADtB,oBAAe,GAAf,eAAe,CAAwB;QACvC,eAAU,GAAV,UAAU,CAAY;IACtC,CAAC;IAKJ,YAAY;QACV,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,4FAA4F,CAAC,CAAC;QAChH,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IACzD,CAAC;CACF,CAAA;AAfY,sCAAa;wBAAb,aAAa;IAnDzB,IAAA,eAAM,EAAC;QACN,SAAS,EAAE;YAET;gBACE,OAAO,EAAE,0BAAW;gBACpB,UAAU,EAAE,CAAC,MAAmB,EAAE,MAAmB,EAAE,EAAE;oBACvD,OAAO,IAAI,0BAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBACzC,CAAC;gBACD,MAAM,EAAE,CAAC,cAAc,EAAE,cAAc,CAAC;aACzC;YAED;gBACE,OAAO,EAAE,kDAAsB;gBAC/B,UAAU,EAAE,CACV,mBAA8C,EAC9C,cAAoC,EACpC,MAAmB,EACnB,MAAmB,EACnB,eAAgC,EAChC,WAAwB,EACxB,gBAAqB,EACrB,YAAiB,EACjB,iBAAsB,EACtB,EAAE;oBACF,OAAO,IAAI,kDAAsB,CAC/B,mBAAmB,EACnB,cAAc,EACd,MAAM,EACN,MAAM,EACN,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,CAClB,CAAC;gBACJ,CAAC;gBACD,MAAM,EAAE;oBACN,qBAAqB;oBACrB,gBAAgB;oBAChB,cAAc;oBACd,cAAc;oBACd,EAAE,KAAK,EAAE,0BAAe,EAAE,QAAQ,EAAE,IAAI,EAAE;oBAC1C,0BAAW;oBACX,EAAE,KAAK,EAAE,kBAAkB,EAAE,QAAQ,EAAE,IAAI,EAAE;oBAC7C,EAAE,KAAK,EAAE,2BAAwB,EAAE,QAAQ,EAAE,IAAI,EAAE;oBACnD,EAAE,KAAK,EAAE,wBAAiB,EAAE,QAAQ,EAAE,IAAI,EAAE;iBAC7C;aACF;SACF;QACD,OAAO,EAAE,CAAC,0BAAW,EAAE,kDAAsB,CAAC;KAC/C,CAAC;qCAGoC,kDAAsB;QAC3B,iBAAU;GAH9B,aAAa,CAezB"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
export interface MFAChallengeResponseDTO {
|
|
2
|
+
challengeName: 'MFA_REQUIRED';
|
|
3
|
+
session: string;
|
|
4
|
+
challengeParameters: {
|
|
5
|
+
availableMethods: Array<'totp' | 'sms' | 'passkey' | 'backup'>;
|
|
6
|
+
preferredMethod?: 'totp' | 'sms' | 'passkey';
|
|
7
|
+
maskedPhone?: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export interface VerifyMFACodeDTO {
|
|
11
|
+
session: string;
|
|
12
|
+
method: 'totp' | 'sms' | 'backup';
|
|
13
|
+
code: string;
|
|
14
|
+
trustDevice?: boolean;
|
|
15
|
+
deviceId?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface VerifyPasskeyDTO {
|
|
18
|
+
session: string;
|
|
19
|
+
credential: {
|
|
20
|
+
id: string;
|
|
21
|
+
rawId: string;
|
|
22
|
+
response: {
|
|
23
|
+
clientDataJSON: string;
|
|
24
|
+
authenticatorData: string;
|
|
25
|
+
signature: string;
|
|
26
|
+
userHandle?: string;
|
|
27
|
+
};
|
|
28
|
+
type: 'public-key';
|
|
29
|
+
};
|
|
30
|
+
trustDevice?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface SetupTOTPResponseDTO {
|
|
33
|
+
secret: string;
|
|
34
|
+
qrCode: string;
|
|
35
|
+
manualEntryKey: string;
|
|
36
|
+
issuer: string;
|
|
37
|
+
accountName: string;
|
|
38
|
+
}
|
|
39
|
+
export interface VerifyTOTPSetupDTO {
|
|
40
|
+
secret: string;
|
|
41
|
+
code: string;
|
|
42
|
+
deviceName?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface SetupSMSMFADTO {
|
|
45
|
+
phoneNumber: string;
|
|
46
|
+
deviceName?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface VerifySMSMFASetupDTO {
|
|
49
|
+
phoneNumber: string;
|
|
50
|
+
code: string;
|
|
51
|
+
}
|
|
52
|
+
export interface SendSMSMFACodeDTO {
|
|
53
|
+
session: string;
|
|
54
|
+
}
|
|
55
|
+
export interface SetupPasskeyResponseDTO {
|
|
56
|
+
options: {
|
|
57
|
+
challenge: string;
|
|
58
|
+
rp: {
|
|
59
|
+
name: string;
|
|
60
|
+
id: string;
|
|
61
|
+
};
|
|
62
|
+
user: {
|
|
63
|
+
id: string;
|
|
64
|
+
name: string;
|
|
65
|
+
displayName: string;
|
|
66
|
+
};
|
|
67
|
+
pubKeyCredParams: Array<{
|
|
68
|
+
type: 'public-key';
|
|
69
|
+
alg: number;
|
|
70
|
+
}>;
|
|
71
|
+
timeout: number;
|
|
72
|
+
attestation: 'none' | 'indirect' | 'direct';
|
|
73
|
+
authenticatorSelection?: {
|
|
74
|
+
authenticatorAttachment?: 'platform' | 'cross-platform';
|
|
75
|
+
requireResidentKey?: boolean;
|
|
76
|
+
userVerification?: 'required' | 'preferred' | 'discouraged';
|
|
77
|
+
};
|
|
78
|
+
excludeCredentials?: Array<{
|
|
79
|
+
id: string;
|
|
80
|
+
type: 'public-key';
|
|
81
|
+
transports?: string[];
|
|
82
|
+
}>;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
export interface VerifyPasskeySetupDTO {
|
|
86
|
+
credential: {
|
|
87
|
+
id: string;
|
|
88
|
+
rawId: string;
|
|
89
|
+
response: {
|
|
90
|
+
clientDataJSON: string;
|
|
91
|
+
attestationObject: string;
|
|
92
|
+
};
|
|
93
|
+
type: 'public-key';
|
|
94
|
+
};
|
|
95
|
+
deviceName?: string;
|
|
96
|
+
}
|
|
97
|
+
export interface GetPasskeyChallengeResponseDTO {
|
|
98
|
+
options: {
|
|
99
|
+
challenge: string;
|
|
100
|
+
timeout: number;
|
|
101
|
+
rpId: string;
|
|
102
|
+
allowCredentials: Array<{
|
|
103
|
+
id: string;
|
|
104
|
+
type: 'public-key';
|
|
105
|
+
transports?: string[];
|
|
106
|
+
}>;
|
|
107
|
+
userVerification: 'required' | 'preferred' | 'discouraged';
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
export interface GenerateBackupCodesResponseDTO {
|
|
111
|
+
codes: string[];
|
|
112
|
+
generated: string;
|
|
113
|
+
}
|
|
114
|
+
export interface MFADeviceDTO {
|
|
115
|
+
id: number;
|
|
116
|
+
type: 'totp' | 'sms' | 'passkey';
|
|
117
|
+
name: string;
|
|
118
|
+
isActive: boolean;
|
|
119
|
+
isPrimary: boolean;
|
|
120
|
+
lastUsedAt?: string;
|
|
121
|
+
createdAt: string;
|
|
122
|
+
maskedPhone?: string;
|
|
123
|
+
}
|
|
124
|
+
export interface ListMFADevicesResponseDTO {
|
|
125
|
+
devices: MFADeviceDTO[];
|
|
126
|
+
hasBackupCodes: boolean;
|
|
127
|
+
}
|
|
128
|
+
export interface UpdateMFADeviceDTO {
|
|
129
|
+
name?: string;
|
|
130
|
+
isPrimary?: boolean;
|
|
131
|
+
}
|
|
132
|
+
export interface DisableMFADeviceDTO {
|
|
133
|
+
password: string;
|
|
134
|
+
}
|
|
135
|
+
export interface MFAStatusResponseDTO {
|
|
136
|
+
enabled: boolean;
|
|
137
|
+
required: boolean;
|
|
138
|
+
gracePeriodEnds?: string;
|
|
139
|
+
configuredMethods: Array<'totp' | 'sms' | 'passkey'>;
|
|
140
|
+
preferredMethod?: 'totp' | 'sms' | 'passkey';
|
|
141
|
+
hasBackupCodes: boolean;
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=mfa.dto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mfa.dto.d.ts","sourceRoot":"","sources":["../../../src/dto/mfa.dto.ts"],"names":[],"mappings":"AAiCA,MAAM,WAAW,uBAAuB;IAItC,aAAa,EAAE,cAAc,CAAC;IAM9B,OAAO,EAAE,MAAM,CAAC;IAKhB,mBAAmB,EAAE;QAInB,gBAAgB,EAAE,KAAK,CAAC,MAAM,GAAG,KAAK,GAAG,SAAS,GAAG,QAAQ,CAAC,CAAC;QAK/D,eAAe,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,CAAC;QAM7C,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;CACH;AA6BD,MAAM,WAAW,gBAAgB;IAI/B,OAAO,EAAE,MAAM,CAAC;IAKhB,MAAM,EAAE,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAC;IAKlC,IAAI,EAAE,MAAM,CAAC;IAQb,WAAW,C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names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
exports.TOTPMFAProviderService = exports.TOTPService = void 0;
|
|
18
|
+
var totp_service_1 = require("./totp.service");
|
|
19
|
+
Object.defineProperty(exports, "TOTPService", { enumerable: true, get: function () { return totp_service_1.TOTPService; } });
|
|
20
|
+
var totp_mfa_provider_service_1 = require("./totp-mfa-provider.service");
|
|
21
|
+
Object.defineProperty(exports, "TOTPMFAProviderService", { enumerable: true, get: function () { return totp_mfa_provider_service_1.TOTPMFAProviderService; } });
|
|
22
|
+
__exportStar(require("./dto/mfa.dto"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAOA,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AACpB,yEAAqE;AAA5D,mIAAA,sBAAsB,OAAA;AAC/B,gDAA8B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Repository } from 'typeorm';
|
|
2
|
+
import { BaseMFADevice, BaseUser, IUser, NAuthConfig, NAuthLogger, MFAMethod } from '@nauth-toolkit/core';
|
|
3
|
+
import { BaseMFAProviderService } from '@nauth-toolkit/core/internal';
|
|
4
|
+
import { TOTPService } from './totp.service';
|
|
5
|
+
import { SetupTOTPResponseDTO } from './dto/mfa.dto';
|
|
6
|
+
export declare class TOTPMFAProviderService extends BaseMFAProviderService {
|
|
7
|
+
private readonly totpService;
|
|
8
|
+
readonly methodName = MFAMethod.TOTP;
|
|
9
|
+
constructor(mfaDeviceRepository: Repository<BaseMFADevice>, userRepository: Repository<BaseUser>, config: NAuthConfig, logger: NAuthLogger, passwordService: unknown, totpService: TOTPService, challengeService?: unknown, auditService?: unknown, clientInfoService?: unknown);
|
|
10
|
+
setup(user: IUser, _setupData?: unknown): Promise<SetupTOTPResponseDTO>;
|
|
11
|
+
verifySetup(user: IUser, verificationData: unknown, deviceName?: string): Promise<number>;
|
|
12
|
+
verify(user: IUser, code: unknown, deviceId?: number): Promise<boolean>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=totp-mfa-provider.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"totp-mfa-provider.service.d.ts","sourceRoot":"","sources":["../../src/totp-mfa-provider.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EACL,aAAa,EACb,QAAQ,EACR,KAAK,EACL,WAAW,EACX,WAAW,EAGX,SAAS,EACV,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAsB,MAAM,eAAe,CAAC;AAsBzE,qBAAa,sBAAuB,SAAQ,sBAAsB;IAS9D,OAAO,CAAC,QAAQ,CAAC,WAAW;IAR9B,QAAQ,CAAC,UAAU,kBAAkB;gBAGnC,mBAAmB,EAAE,UAAU,CAAC,aAAa,CAAC,EAC9C,cAAc,EAAE,UAAU,CAAC,QAAQ,CAAC,EACpC,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,WAAW,EACnB,eAAe,EAAE,OAAO,EACP,WAAW,EAAE,WAAW,EACzC,gBAAgB,CAAC,EAAE,OAAO,EAC1B,YAAY,CAAC,EAAE,OAAO,EACtB,iBAAiB,CAAC,EAAE,OAAO;IA+BvB,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,UAAU,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,oBAAoB,CAAC;IA0CvE,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA0DzF,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAoC9E"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TOTPMFAProviderService = void 0;
|
|
4
|
+
const core_1 = require("@nauth-toolkit/core");
|
|
5
|
+
const internal_1 = require("@nauth-toolkit/core/internal");
|
|
6
|
+
class TOTPMFAProviderService extends internal_1.BaseMFAProviderService {
|
|
7
|
+
totpService;
|
|
8
|
+
methodName = core_1.MFAMethod.TOTP;
|
|
9
|
+
constructor(mfaDeviceRepository, userRepository, config, logger, passwordService, totpService, challengeService, auditService, clientInfoService) {
|
|
10
|
+
super(mfaDeviceRepository, userRepository, config, logger, passwordService, challengeService, auditService, clientInfoService);
|
|
11
|
+
this.totpService = totpService;
|
|
12
|
+
}
|
|
13
|
+
async setup(user, _setupData) {
|
|
14
|
+
this.logger?.log?.(`Setting up TOTP for user: ${user.sub}`);
|
|
15
|
+
if (!this.isMethodAllowed()) {
|
|
16
|
+
throw new core_1.NAuthException(core_1.AuthErrorCode.VALIDATION_FAILED, 'TOTP is not enabled', { feature: 'totp' });
|
|
17
|
+
}
|
|
18
|
+
const setup = await this.totpService.generateSecret(user.email);
|
|
19
|
+
this.logger?.log?.(`TOTP setup initiated for user: ${user.sub}`);
|
|
20
|
+
return setup;
|
|
21
|
+
}
|
|
22
|
+
async verifySetup(user, verificationData, deviceName) {
|
|
23
|
+
this.logger?.log?.(`Verifying TOTP setup for user: ${user.sub}`);
|
|
24
|
+
const dto = verificationData;
|
|
25
|
+
if (!this.totpService.isValidSecret(dto.secret)) {
|
|
26
|
+
throw new core_1.NAuthException(core_1.AuthErrorCode.VALIDATION_FAILED, 'Invalid TOTP secret', { field: 'secret' });
|
|
27
|
+
}
|
|
28
|
+
const result = this.totpService.verifyCodeWithDetails(dto.secret, dto.code);
|
|
29
|
+
if (!result.valid) {
|
|
30
|
+
throw new core_1.NAuthException(core_1.AuthErrorCode.VERIFICATION_CODE_INVALID, result.error || 'Invalid TOTP code');
|
|
31
|
+
}
|
|
32
|
+
const userEntity = user;
|
|
33
|
+
const userId = userEntity.id;
|
|
34
|
+
const userMfaEnabled = userEntity.mfaEnabled || false;
|
|
35
|
+
const device = await this.createDevice(userId, {
|
|
36
|
+
name: deviceName || dto.deviceName || 'Authenticator App',
|
|
37
|
+
secret: dto.secret,
|
|
38
|
+
isActive: true,
|
|
39
|
+
isPrimary: !userMfaEnabled,
|
|
40
|
+
});
|
|
41
|
+
await this.enableMFAForUser(user);
|
|
42
|
+
this.logger?.log?.(`TOTP setup completed for user: ${user.sub}`);
|
|
43
|
+
return device.id;
|
|
44
|
+
}
|
|
45
|
+
async verify(user, code, deviceId) {
|
|
46
|
+
this.logger?.log?.(`Verifying TOTP code for user: ${user.sub}`);
|
|
47
|
+
const totpCode = code;
|
|
48
|
+
if (!totpCode || typeof totpCode !== 'string') {
|
|
49
|
+
this.logger?.warn?.('Invalid TOTP code format');
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
const userEntity = user;
|
|
53
|
+
const userId = userEntity.id;
|
|
54
|
+
const device = await this.findDevice(userId, deviceId);
|
|
55
|
+
if (!device || !device.secret) {
|
|
56
|
+
this.logger?.warn?.(`No active TOTP device found for user: ${user.sub}`);
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
const isValid = this.totpService.verifyCode(device.secret, totpCode);
|
|
60
|
+
if (isValid) {
|
|
61
|
+
await this.updateDeviceUsage(device.id);
|
|
62
|
+
this.logger?.log?.(`TOTP code verified successfully for user: ${user.sub}`);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
this.logger?.warn?.(`TOTP code verification failed for user: ${user.sub}`);
|
|
66
|
+
}
|
|
67
|
+
return isValid;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.TOTPMFAProviderService = TOTPMFAProviderService;
|
|
71
|
+
//# sourceMappingURL=totp-mfa-provider.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"totp-mfa-provider.service.js","sourceRoot":"","sources":["../../src/totp-mfa-provider.service.ts"],"names":[],"mappings":";;;AAEA,8CAS6B;AAE7B,2DAAsE;AAwBtE,MAAa,sBAAuB,SAAQ,iCAAsB;IAS7C;IARV,UAAU,GAAG,gBAAS,CAAC,IAAI,CAAC;IAErC,YACE,mBAA8C,EAC9C,cAAoC,EACpC,MAAmB,EACnB,MAAmB,EACnB,eAAwB,EACP,WAAwB,EACzC,gBAA0B,EAC1B,YAAsB,EACtB,iBAA2B;QAE3B,KAAK,CACH,mBAAmB,EACnB,cAAc,EACd,MAAM,EACN,MAAM,EACN,eAAe,EACf,gBAAu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AAC;QACvD,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YAC9B,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,yCAAyC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;YACzE,OAAO,KAAK,CAAC;QACf,CAAC;QAGD,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAErE,IAAI,OAAO,EAAE,CAAC;YAEZ,MAAM,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YACxC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,6CAA6C,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;QAC9E,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,2CAA2C,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;QAC7E,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CAIF;AAnLD,wDAmLC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { NAuthConfig, NAuthLogger } from '@nauth-toolkit/core';
|
|
2
|
+
import { SetupTOTPResponseDTO } from './dto/mfa.dto';
|
|
3
|
+
export declare class TOTPService {
|
|
4
|
+
private readonly config;
|
|
5
|
+
private readonly logger;
|
|
6
|
+
private readonly defaultConfig;
|
|
7
|
+
constructor(config: NAuthConfig, logger: NAuthLogger);
|
|
8
|
+
private configureAuthenticator;
|
|
9
|
+
private getTOTPConfig;
|
|
10
|
+
private getIssuer;
|
|
11
|
+
generateSecret(accountName: string): Promise<SetupTOTPResponseDTO>;
|
|
12
|
+
private formatSecretForManualEntry;
|
|
13
|
+
verifyCode(secret: string, code: string): boolean;
|
|
14
|
+
verifyCodeWithDetails(secret: string, code: string): {
|
|
15
|
+
valid: boolean;
|
|
16
|
+
error?: string;
|
|
17
|
+
};
|
|
18
|
+
generateCode(secret: string): string;
|
|
19
|
+
isValidSecret(secret: string): boolean;
|
|
20
|
+
getTimeRemaining(): number;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=totp.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"totp.service.d.ts","sourceRoot":"","sources":["../../src/totp.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAc,WAAW,EAAiC,MAAM,qBAAqB,CAAC;AAC1G,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAyBrD,qBAAa,WAAW;IASpB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IATzB,OAAO,CAAC,QAAQ,CAAC,aAAa,CAK5B;gBAGiB,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,WAAW;IAkBtC,OAAO,CAAC,sBAAsB;IAqB9B,OAAO,CAAC,aAAa;IAarB,OAAO,CAAC,SAAS;IAyBX,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAkDxE,OAAO,CAAC,0BAA0B;IA8BlC,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO;IA8CjD,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE;IA+CvF,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAmBpC,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAgCtC,gBAAgB,IAAI,MAAM;CAM3B"}
|