@carlonicora/nestjs-neo4jsonapi 1.39.0 → 1.40.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/dist/config/base.config.d.ts.map +1 -1
- package/dist/config/base.config.js +9 -0
- package/dist/config/base.config.js.map +1 -1
- package/dist/config/interfaces/base.config.interface.d.ts +2 -0
- package/dist/config/interfaces/base.config.interface.d.ts.map +1 -1
- package/dist/config/interfaces/config.two.factor.interface.d.ts +27 -0
- package/dist/config/interfaces/config.two.factor.interface.d.ts.map +1 -0
- package/dist/config/interfaces/config.two.factor.interface.js +3 -0
- package/dist/config/interfaces/config.two.factor.interface.js.map +1 -0
- package/dist/config/interfaces/index.d.ts +1 -0
- package/dist/config/interfaces/index.d.ts.map +1 -1
- package/dist/config/interfaces/index.js +1 -0
- package/dist/config/interfaces/index.js.map +1 -1
- package/dist/core/jsonapi/services/jsonapi.service.d.ts.map +1 -1
- package/dist/core/jsonapi/services/jsonapi.service.js +3 -1
- package/dist/core/jsonapi/services/jsonapi.service.js.map +1 -1
- package/dist/core/llm/services/vision.llm.service.d.ts.map +1 -1
- package/dist/core/llm/services/vision.llm.service.js +0 -1
- package/dist/core/llm/services/vision.llm.service.js.map +1 -1
- package/dist/core/security/services/security.service.d.ts +27 -0
- package/dist/core/security/services/security.service.d.ts.map +1 -1
- package/dist/core/security/services/security.service.js +37 -0
- package/dist/core/security/services/security.service.js.map +1 -1
- package/dist/foundations/auth/auth.module.d.ts.map +1 -1
- package/dist/foundations/auth/auth.module.js +6 -0
- package/dist/foundations/auth/auth.module.js.map +1 -1
- package/dist/foundations/auth/entities/pending-auth.entity.d.ts +16 -0
- package/dist/foundations/auth/entities/pending-auth.entity.d.ts.map +1 -0
- package/dist/foundations/auth/entities/pending-auth.entity.js +3 -0
- package/dist/foundations/auth/entities/pending-auth.entity.js.map +1 -0
- package/dist/foundations/auth/entities/pending-auth.map.d.ts +6 -0
- package/dist/foundations/auth/entities/pending-auth.map.d.ts.map +1 -0
- package/dist/foundations/auth/entities/pending-auth.map.js +20 -0
- package/dist/foundations/auth/entities/pending-auth.map.js.map +1 -0
- package/dist/foundations/auth/entities/pending-auth.meta.d.ts +3 -0
- package/dist/foundations/auth/entities/pending-auth.meta.d.ts.map +1 -0
- package/dist/foundations/auth/entities/pending-auth.meta.js +10 -0
- package/dist/foundations/auth/entities/pending-auth.meta.js.map +1 -0
- package/dist/foundations/auth/entities/pending-auth.model.d.ts +9 -0
- package/dist/foundations/auth/entities/pending-auth.model.d.ts.map +1 -0
- package/dist/foundations/auth/entities/pending-auth.model.js +19 -0
- package/dist/foundations/auth/entities/pending-auth.model.js.map +1 -0
- package/dist/foundations/auth/serialisers/pending-auth.serialiser.d.ts +18 -0
- package/dist/foundations/auth/serialisers/pending-auth.serialiser.d.ts.map +1 -0
- package/dist/foundations/auth/serialisers/pending-auth.serialiser.js +49 -0
- package/dist/foundations/auth/serialisers/pending-auth.serialiser.js.map +1 -0
- package/dist/foundations/auth/services/auth.service.d.ts +12 -1
- package/dist/foundations/auth/services/auth.service.d.ts.map +1 -1
- package/dist/foundations/auth/services/auth.service.js +60 -6
- package/dist/foundations/auth/services/auth.service.js.map +1 -1
- package/dist/foundations/foundations.modules.d.ts.map +1 -1
- package/dist/foundations/foundations.modules.js +2 -0
- package/dist/foundations/foundations.modules.js.map +1 -1
- package/dist/foundations/index.d.ts +1 -0
- package/dist/foundations/index.d.ts.map +1 -1
- package/dist/foundations/index.js +1 -0
- package/dist/foundations/index.js.map +1 -1
- package/dist/foundations/stripe/services/billing.service.d.ts +3 -4
- package/dist/foundations/stripe/services/billing.service.d.ts.map +1 -1
- package/dist/foundations/stripe/services/billing.service.js +1 -1
- package/dist/foundations/stripe/services/billing.service.js.map +1 -1
- package/dist/foundations/stripe-invoice/services/stripe-invoice-admin.service.d.ts +1 -1
- package/dist/foundations/stripe-invoice/services/stripe-invoice-admin.service.js +1 -1
- package/dist/foundations/stripe-invoice/services/stripe-invoice-api.service.d.ts +1 -1
- package/dist/foundations/stripe-invoice/services/stripe-invoice-api.service.d.ts.map +1 -1
- package/dist/foundations/stripe-invoice/services/stripe-invoice-api.service.js +2 -2
- package/dist/foundations/stripe-invoice/services/stripe-invoice-api.service.js.map +1 -1
- package/dist/foundations/stripe-subscription/controllers/stripe-subscription.controller.d.ts.map +1 -1
- package/dist/foundations/stripe-subscription/controllers/stripe-subscription.controller.js +0 -3
- package/dist/foundations/stripe-subscription/controllers/stripe-subscription.controller.js.map +1 -1
- package/dist/foundations/stripe-subscription/services/stripe-subscription-admin.service.d.ts +1 -1
- package/dist/foundations/stripe-subscription/services/stripe-subscription-admin.service.d.ts.map +1 -1
- package/dist/foundations/stripe-subscription/services/stripe-subscription-admin.service.js +1 -3
- package/dist/foundations/stripe-subscription/services/stripe-subscription-admin.service.js.map +1 -1
- package/dist/foundations/stripe-subscription/services/stripe-subscription-api.service.d.ts +1 -1
- package/dist/foundations/stripe-subscription/services/stripe-subscription-api.service.d.ts.map +1 -1
- package/dist/foundations/stripe-subscription/services/stripe-subscription-api.service.js +1 -5
- package/dist/foundations/stripe-subscription/services/stripe-subscription-api.service.js.map +1 -1
- package/dist/foundations/two-factor/controllers/passkey.controller.d.ts +52 -0
- package/dist/foundations/two-factor/controllers/passkey.controller.d.ts.map +1 -0
- package/dist/foundations/two-factor/controllers/passkey.controller.js +155 -0
- package/dist/foundations/two-factor/controllers/passkey.controller.js.map +1 -0
- package/dist/foundations/two-factor/controllers/totp.controller.d.ts +47 -0
- package/dist/foundations/two-factor/controllers/totp.controller.d.ts.map +1 -0
- package/dist/foundations/two-factor/controllers/totp.controller.js +132 -0
- package/dist/foundations/two-factor/controllers/totp.controller.js.map +1 -0
- package/dist/foundations/two-factor/controllers/two-factor.controller.d.ts +124 -0
- package/dist/foundations/two-factor/controllers/two-factor.controller.d.ts.map +1 -0
- package/dist/foundations/two-factor/controllers/two-factor.controller.js +352 -0
- package/dist/foundations/two-factor/controllers/two-factor.controller.js.map +1 -0
- package/dist/foundations/two-factor/dtos/passkey-options.dto.d.ts +42 -0
- package/dist/foundations/two-factor/dtos/passkey-options.dto.d.ts.map +1 -0
- package/dist/foundations/two-factor/dtos/passkey-options.dto.js +77 -0
- package/dist/foundations/two-factor/dtos/passkey-options.dto.js.map +1 -0
- package/dist/foundations/two-factor/dtos/passkey-verify.dto.d.ts +120 -0
- package/dist/foundations/two-factor/dtos/passkey-verify.dto.d.ts.map +1 -0
- package/dist/foundations/two-factor/dtos/passkey-verify.dto.js +226 -0
- package/dist/foundations/two-factor/dtos/passkey-verify.dto.js.map +1 -0
- package/dist/foundations/two-factor/dtos/totp-setup.dto.d.ts +32 -0
- package/dist/foundations/two-factor/dtos/totp-setup.dto.d.ts.map +1 -0
- package/dist/foundations/two-factor/dtos/totp-setup.dto.js +67 -0
- package/dist/foundations/two-factor/dtos/totp-setup.dto.js.map +1 -0
- package/dist/foundations/two-factor/dtos/totp-verify.dto.d.ts +62 -0
- package/dist/foundations/two-factor/dtos/totp-verify.dto.d.ts.map +1 -0
- package/dist/foundations/two-factor/dtos/totp-verify.dto.js +118 -0
- package/dist/foundations/two-factor/dtos/totp-verify.dto.js.map +1 -0
- package/dist/foundations/two-factor/dtos/two-factor-verify.dto.d.ts +83 -0
- package/dist/foundations/two-factor/dtos/two-factor-verify.dto.d.ts.map +1 -0
- package/dist/foundations/two-factor/dtos/two-factor-verify.dto.js +161 -0
- package/dist/foundations/two-factor/dtos/two-factor-verify.dto.js.map +1 -0
- package/dist/foundations/two-factor/entities/backup-code.d.ts +22 -0
- package/dist/foundations/two-factor/entities/backup-code.d.ts.map +1 -0
- package/dist/foundations/two-factor/entities/backup-code.js +25 -0
- package/dist/foundations/two-factor/entities/backup-code.js.map +1 -0
- package/dist/foundations/two-factor/entities/backup-code.meta.d.ts +3 -0
- package/dist/foundations/two-factor/entities/backup-code.meta.d.ts.map +1 -0
- package/dist/foundations/two-factor/entities/backup-code.meta.js +10 -0
- package/dist/foundations/two-factor/entities/backup-code.meta.js.map +1 -0
- package/dist/foundations/two-factor/entities/backup-codes-count.d.ts +18 -0
- package/dist/foundations/two-factor/entities/backup-codes-count.d.ts.map +1 -0
- package/dist/foundations/two-factor/entities/backup-codes-count.js +19 -0
- package/dist/foundations/two-factor/entities/backup-codes-count.js.map +1 -0
- package/dist/foundations/two-factor/entities/backup-codes-count.meta.d.ts +3 -0
- package/dist/foundations/two-factor/entities/backup-codes-count.meta.d.ts.map +1 -0
- package/dist/foundations/two-factor/entities/backup-codes-count.meta.js +10 -0
- package/dist/foundations/two-factor/entities/backup-codes-count.meta.js.map +1 -0
- package/dist/foundations/two-factor/entities/backup-codes-generation.d.ts +19 -0
- package/dist/foundations/two-factor/entities/backup-codes-generation.d.ts.map +1 -0
- package/dist/foundations/two-factor/entities/backup-codes-generation.js +20 -0
- package/dist/foundations/two-factor/entities/backup-codes-generation.js.map +1 -0
- package/dist/foundations/two-factor/entities/backup-codes-generation.meta.d.ts +3 -0
- package/dist/foundations/two-factor/entities/backup-codes-generation.meta.d.ts.map +1 -0
- package/dist/foundations/two-factor/entities/backup-codes-generation.meta.js +10 -0
- package/dist/foundations/two-factor/entities/backup-codes-generation.meta.js.map +1 -0
- package/dist/foundations/two-factor/entities/passkey-authentication-options.d.ts +19 -0
- package/dist/foundations/two-factor/entities/passkey-authentication-options.d.ts.map +1 -0
- package/dist/foundations/two-factor/entities/passkey-authentication-options.js +20 -0
- package/dist/foundations/two-factor/entities/passkey-authentication-options.js.map +1 -0
- package/dist/foundations/two-factor/entities/passkey-authentication-options.meta.d.ts +3 -0
- package/dist/foundations/two-factor/entities/passkey-authentication-options.meta.d.ts.map +1 -0
- package/dist/foundations/two-factor/entities/passkey-authentication-options.meta.js +10 -0
- package/dist/foundations/two-factor/entities/passkey-authentication-options.meta.js.map +1 -0
- package/dist/foundations/two-factor/entities/passkey-registration-options.d.ts +19 -0
- package/dist/foundations/two-factor/entities/passkey-registration-options.d.ts.map +1 -0
- package/dist/foundations/two-factor/entities/passkey-registration-options.js +20 -0
- package/dist/foundations/two-factor/entities/passkey-registration-options.js.map +1 -0
- package/dist/foundations/two-factor/entities/passkey-registration-options.meta.d.ts +3 -0
- package/dist/foundations/two-factor/entities/passkey-registration-options.meta.d.ts.map +1 -0
- package/dist/foundations/two-factor/entities/passkey-registration-options.meta.js +10 -0
- package/dist/foundations/two-factor/entities/passkey-registration-options.meta.js.map +1 -0
- package/dist/foundations/two-factor/entities/passkey.d.ts +27 -0
- package/dist/foundations/two-factor/entities/passkey.d.ts.map +1 -0
- package/dist/foundations/two-factor/entities/passkey.js +30 -0
- package/dist/foundations/two-factor/entities/passkey.js.map +1 -0
- package/dist/foundations/two-factor/entities/passkey.meta.d.ts +3 -0
- package/dist/foundations/two-factor/entities/passkey.meta.d.ts.map +1 -0
- package/dist/foundations/two-factor/entities/passkey.meta.js +10 -0
- package/dist/foundations/two-factor/entities/passkey.meta.js.map +1 -0
- package/dist/foundations/two-factor/entities/pending-two-factor.d.ts +24 -0
- package/dist/foundations/two-factor/entities/pending-two-factor.d.ts.map +1 -0
- package/dist/foundations/two-factor/entities/pending-two-factor.js +27 -0
- package/dist/foundations/two-factor/entities/pending-two-factor.js.map +1 -0
- package/dist/foundations/two-factor/entities/pending-two-factor.meta.d.ts +3 -0
- package/dist/foundations/two-factor/entities/pending-two-factor.meta.d.ts.map +1 -0
- package/dist/foundations/two-factor/entities/pending-two-factor.meta.js +10 -0
- package/dist/foundations/two-factor/entities/pending-two-factor.meta.js.map +1 -0
- package/dist/foundations/two-factor/entities/totp-authenticator.d.ts +24 -0
- package/dist/foundations/two-factor/entities/totp-authenticator.d.ts.map +1 -0
- package/dist/foundations/two-factor/entities/totp-authenticator.js +27 -0
- package/dist/foundations/two-factor/entities/totp-authenticator.js.map +1 -0
- package/dist/foundations/two-factor/entities/totp-authenticator.meta.d.ts +3 -0
- package/dist/foundations/two-factor/entities/totp-authenticator.meta.d.ts.map +1 -0
- package/dist/foundations/two-factor/entities/totp-authenticator.meta.js +10 -0
- package/dist/foundations/two-factor/entities/totp-authenticator.meta.js.map +1 -0
- package/dist/foundations/two-factor/entities/totp-setup.d.ts +20 -0
- package/dist/foundations/two-factor/entities/totp-setup.d.ts.map +1 -0
- package/dist/foundations/two-factor/entities/totp-setup.js +21 -0
- package/dist/foundations/two-factor/entities/totp-setup.js.map +1 -0
- package/dist/foundations/two-factor/entities/totp-setup.meta.d.ts +3 -0
- package/dist/foundations/two-factor/entities/totp-setup.meta.d.ts.map +1 -0
- package/dist/foundations/two-factor/entities/totp-setup.meta.js +10 -0
- package/dist/foundations/two-factor/entities/totp-setup.meta.js.map +1 -0
- package/dist/foundations/two-factor/entities/two-factor-challenge.d.ts +21 -0
- package/dist/foundations/two-factor/entities/two-factor-challenge.d.ts.map +1 -0
- package/dist/foundations/two-factor/entities/two-factor-challenge.js +22 -0
- package/dist/foundations/two-factor/entities/two-factor-challenge.js.map +1 -0
- package/dist/foundations/two-factor/entities/two-factor-challenge.meta.d.ts +3 -0
- package/dist/foundations/two-factor/entities/two-factor-challenge.meta.d.ts.map +1 -0
- package/dist/foundations/two-factor/entities/two-factor-challenge.meta.js +10 -0
- package/dist/foundations/two-factor/entities/two-factor-challenge.meta.js.map +1 -0
- package/dist/foundations/two-factor/entities/two-factor-config.d.ts +21 -0
- package/dist/foundations/two-factor/entities/two-factor-config.d.ts.map +1 -0
- package/dist/foundations/two-factor/entities/two-factor-config.js +23 -0
- package/dist/foundations/two-factor/entities/two-factor-config.js.map +1 -0
- package/dist/foundations/two-factor/entities/two-factor-config.meta.d.ts +3 -0
- package/dist/foundations/two-factor/entities/two-factor-config.meta.d.ts.map +1 -0
- package/dist/foundations/two-factor/entities/two-factor-config.meta.js +10 -0
- package/dist/foundations/two-factor/entities/two-factor-config.meta.js.map +1 -0
- package/dist/foundations/two-factor/entities/two-factor-status.d.ts +25 -0
- package/dist/foundations/two-factor/entities/two-factor-status.d.ts.map +1 -0
- package/dist/foundations/two-factor/entities/two-factor-status.js +22 -0
- package/dist/foundations/two-factor/entities/two-factor-status.js.map +1 -0
- package/dist/foundations/two-factor/entities/two-factor-status.meta.d.ts +3 -0
- package/dist/foundations/two-factor/entities/two-factor-status.meta.d.ts.map +1 -0
- package/dist/foundations/two-factor/entities/two-factor-status.meta.js +10 -0
- package/dist/foundations/two-factor/entities/two-factor-status.meta.js.map +1 -0
- package/dist/foundations/two-factor/entities/two-factor-verification.d.ts +19 -0
- package/dist/foundations/two-factor/entities/two-factor-verification.d.ts.map +1 -0
- package/dist/foundations/two-factor/entities/two-factor-verification.js +20 -0
- package/dist/foundations/two-factor/entities/two-factor-verification.js.map +1 -0
- package/dist/foundations/two-factor/entities/two-factor-verification.meta.d.ts +3 -0
- package/dist/foundations/two-factor/entities/two-factor-verification.meta.d.ts.map +1 -0
- package/dist/foundations/two-factor/entities/two-factor-verification.meta.js +10 -0
- package/dist/foundations/two-factor/entities/two-factor-verification.meta.js.map +1 -0
- package/dist/foundations/two-factor/guards/pending-auth.guard.d.ts +35 -0
- package/dist/foundations/two-factor/guards/pending-auth.guard.d.ts.map +1 -0
- package/dist/foundations/two-factor/guards/pending-auth.guard.js +70 -0
- package/dist/foundations/two-factor/guards/pending-auth.guard.js.map +1 -0
- package/dist/foundations/two-factor/index.d.ts +47 -0
- package/dist/foundations/two-factor/index.d.ts.map +1 -0
- package/dist/foundations/two-factor/index.js +134 -0
- package/dist/foundations/two-factor/index.js.map +1 -0
- package/dist/foundations/two-factor/repositories/backup-code.repository.d.ts +34 -0
- package/dist/foundations/two-factor/repositories/backup-code.repository.d.ts.map +1 -0
- package/dist/foundations/two-factor/repositories/backup-code.repository.js +107 -0
- package/dist/foundations/two-factor/repositories/backup-code.repository.js.map +1 -0
- package/dist/foundations/two-factor/repositories/passkey.repository.d.ts +51 -0
- package/dist/foundations/two-factor/repositories/passkey.repository.d.ts.map +1 -0
- package/dist/foundations/two-factor/repositories/passkey.repository.js +159 -0
- package/dist/foundations/two-factor/repositories/passkey.repository.js.map +1 -0
- package/dist/foundations/two-factor/repositories/pending-two-factor.repository.d.ts +47 -0
- package/dist/foundations/two-factor/repositories/pending-two-factor.repository.d.ts.map +1 -0
- package/dist/foundations/two-factor/repositories/pending-two-factor.repository.js +159 -0
- package/dist/foundations/two-factor/repositories/pending-two-factor.repository.js.map +1 -0
- package/dist/foundations/two-factor/repositories/totp-authenticator.repository.d.ts +51 -0
- package/dist/foundations/two-factor/repositories/totp-authenticator.repository.d.ts.map +1 -0
- package/dist/foundations/two-factor/repositories/totp-authenticator.repository.js +156 -0
- package/dist/foundations/two-factor/repositories/totp-authenticator.repository.js.map +1 -0
- package/dist/foundations/two-factor/repositories/two-factor-config.repository.d.ts +32 -0
- package/dist/foundations/two-factor/repositories/two-factor-config.repository.d.ts.map +1 -0
- package/dist/foundations/two-factor/repositories/two-factor-config.repository.js +105 -0
- package/dist/foundations/two-factor/repositories/two-factor-config.repository.js.map +1 -0
- package/dist/foundations/two-factor/services/backup-code.service.d.ts +95 -0
- package/dist/foundations/two-factor/services/backup-code.service.d.ts.map +1 -0
- package/dist/foundations/two-factor/services/backup-code.service.js +216 -0
- package/dist/foundations/two-factor/services/backup-code.service.js.map +1 -0
- package/dist/foundations/two-factor/services/index.d.ts +6 -0
- package/dist/foundations/two-factor/services/index.d.ts.map +1 -0
- package/dist/foundations/two-factor/services/index.js +14 -0
- package/dist/foundations/two-factor/services/index.js.map +1 -0
- package/dist/foundations/two-factor/services/passkey.service.d.ts +132 -0
- package/dist/foundations/two-factor/services/passkey.service.d.ts.map +1 -0
- package/dist/foundations/two-factor/services/passkey.service.js +400 -0
- package/dist/foundations/two-factor/services/passkey.service.js.map +1 -0
- package/dist/foundations/two-factor/services/totp-encryption.service.d.ts +42 -0
- package/dist/foundations/two-factor/services/totp-encryption.service.d.ts.map +1 -0
- package/dist/foundations/two-factor/services/totp-encryption.service.js +136 -0
- package/dist/foundations/two-factor/services/totp-encryption.service.js.map +1 -0
- package/dist/foundations/two-factor/services/totp.service.d.ts +132 -0
- package/dist/foundations/two-factor/services/totp.service.d.ts.map +1 -0
- package/dist/foundations/two-factor/services/totp.service.js +324 -0
- package/dist/foundations/two-factor/services/totp.service.js.map +1 -0
- package/dist/foundations/two-factor/services/two-factor.service.d.ts +165 -0
- package/dist/foundations/two-factor/services/two-factor.service.d.ts.map +1 -0
- package/dist/foundations/two-factor/services/two-factor.service.js +468 -0
- package/dist/foundations/two-factor/services/two-factor.service.js.map +1 -0
- package/dist/foundations/two-factor/two-factor.module.d.ts +23 -0
- package/dist/foundations/two-factor/two-factor.module.d.ts.map +1 -0
- package/dist/foundations/two-factor/two-factor.module.js +132 -0
- package/dist/foundations/two-factor/two-factor.module.js.map +1 -0
- package/dist/foundations/user/repositories/user.repository.d.ts +8 -0
- package/dist/foundations/user/repositories/user.repository.d.ts.map +1 -1
- package/dist/foundations/user/repositories/user.repository.js +28 -1
- package/dist/foundations/user/repositories/user.repository.js.map +1 -1
- package/dist/foundations/waitlist/controllers/waitlist.controller.d.ts.map +1 -1
- package/dist/foundations/waitlist/controllers/waitlist.controller.js +0 -4
- package/dist/foundations/waitlist/controllers/waitlist.controller.js.map +1 -1
- package/dist/foundations/waitlist/repositories/waitlist.repository.d.ts.map +1 -1
- package/dist/foundations/waitlist/repositories/waitlist.repository.js +0 -2
- package/dist/foundations/waitlist/repositories/waitlist.repository.js.map +1 -1
- package/dist/foundations/waitlist/services/waitlist.service.d.ts +1 -0
- package/dist/foundations/waitlist/services/waitlist.service.d.ts.map +1 -1
- package/dist/foundations/waitlist/services/waitlist.service.js +6 -7
- package/dist/foundations/waitlist/services/waitlist.service.js.map +1 -1
- package/dist/scripts/generate-module/generator.js +13 -13
- package/dist/scripts/generate-module/generator.js.map +1 -1
- package/dist/scripts/generate-module/index.js +6 -6
- package/dist/scripts/generate-module/index.js.map +1 -1
- package/dist/scripts/generate-module/utils/file-writer.js +2 -2
- package/dist/scripts/generate-module/utils/file-writer.js.map +1 -1
- package/dist/scripts/generate-module/utils/module-registrar.js +7 -7
- package/dist/scripts/generate-module/utils/module-registrar.js.map +1 -1
- package/dist/tools/migrate-entity/index.js +3 -3
- package/dist/tools/migrate-entity/lib/descriptor-generator.js +6 -6
- package/dist/tools/migrate-entity/lib/entity-migrator.js +13 -13
- package/package.json +5 -1
|
@@ -0,0 +1,468 @@
|
|
|
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 crypto = __importStar(require("crypto"));
|
|
48
|
+
const base_config_1 = require("../../../config/base.config");
|
|
49
|
+
const jsonapi_service_1 = require("../../../core/jsonapi/services/jsonapi.service");
|
|
50
|
+
const two_factor_config_1 = require("../entities/two-factor-config");
|
|
51
|
+
const two_factor_status_1 = require("../entities/two-factor-status");
|
|
52
|
+
const two_factor_verification_1 = require("../entities/two-factor-verification");
|
|
53
|
+
const pending_two_factor_repository_1 = require("../repositories/pending-two-factor.repository");
|
|
54
|
+
const two_factor_config_repository_1 = require("../repositories/two-factor-config.repository");
|
|
55
|
+
const backup_code_service_1 = require("./backup-code.service");
|
|
56
|
+
const passkey_service_1 = require("./passkey.service");
|
|
57
|
+
const totp_service_1 = require("./totp.service");
|
|
58
|
+
/**
|
|
59
|
+
* Two-Factor Orchestration Service
|
|
60
|
+
*
|
|
61
|
+
* Coordinates all 2FA functionality including status management, method verification,
|
|
62
|
+
* and pending session handling. This service is the main entry point for 2FA operations
|
|
63
|
+
* and delegates to specialized services (TOTP, Passkey, BackupCode) for specific tasks.
|
|
64
|
+
*/
|
|
65
|
+
let TwoFactorService = class TwoFactorService {
|
|
66
|
+
constructor(jsonApiService, twoFactorConfigRepository, pendingTwoFactorRepository, totpService, passkeyService, backupCodeService) {
|
|
67
|
+
this.jsonApiService = jsonApiService;
|
|
68
|
+
this.twoFactorConfigRepository = twoFactorConfigRepository;
|
|
69
|
+
this.pendingTwoFactorRepository = pendingTwoFactorRepository;
|
|
70
|
+
this.totpService = totpService;
|
|
71
|
+
this.passkeyService = passkeyService;
|
|
72
|
+
this.backupCodeService = backupCodeService;
|
|
73
|
+
this.maxTotpAttempts = 5;
|
|
74
|
+
this.maxPasskeyAttempts = 3;
|
|
75
|
+
this.maxBackupAttempts = 3;
|
|
76
|
+
this.pendingTtlSeconds = base_config_1.baseConfig.twoFactor?.pendingTtl ?? 300; // 5 minutes default
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get the 2FA configuration for a user.
|
|
80
|
+
*
|
|
81
|
+
* @param userId - The user's ID
|
|
82
|
+
* @returns The user's TwoFactorConfig, or null if not configured
|
|
83
|
+
*/
|
|
84
|
+
async getConfig(userId) {
|
|
85
|
+
const config = await this.twoFactorConfigRepository.findByUserId({ userId });
|
|
86
|
+
return config;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Get the full 2FA status for a user including available methods.
|
|
90
|
+
*
|
|
91
|
+
* @param userId - The user's ID
|
|
92
|
+
* @returns JSON:API response with 2FA status
|
|
93
|
+
*/
|
|
94
|
+
async getStatus(userId) {
|
|
95
|
+
const config = await this.twoFactorConfigRepository.findByUserId({ userId });
|
|
96
|
+
// Check method availability in parallel
|
|
97
|
+
const [hasTotp, hasPasskey, backupCodesCount] = await Promise.all([
|
|
98
|
+
this.totpService.hasVerifiedAuthenticator({ userId }),
|
|
99
|
+
this.passkeyService.hasPasskeys({ userId }),
|
|
100
|
+
this.backupCodeService.getRawUnusedCount({ userId }),
|
|
101
|
+
]);
|
|
102
|
+
const hasBackup = backupCodesCount > 0;
|
|
103
|
+
return this.jsonApiService.buildSingle(two_factor_status_1.TwoFactorStatusDescriptor.model, {
|
|
104
|
+
id: userId,
|
|
105
|
+
isEnabled: config?.isEnabled ?? false,
|
|
106
|
+
preferredMethod: config?.preferredMethod ?? "totp",
|
|
107
|
+
methods: {
|
|
108
|
+
totp: hasTotp,
|
|
109
|
+
passkey: hasPasskey,
|
|
110
|
+
backup: hasBackup,
|
|
111
|
+
},
|
|
112
|
+
backupCodesCount,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Enable 2FA for a user.
|
|
117
|
+
* Requires at least one 2FA method to be configured.
|
|
118
|
+
*
|
|
119
|
+
* @param userId - The user's ID
|
|
120
|
+
* @param preferredMethod - The preferred 2FA method (default: 'totp')
|
|
121
|
+
* @throws BadRequestException if no 2FA methods are configured
|
|
122
|
+
* @returns JSON:API response with the 2FA config
|
|
123
|
+
*/
|
|
124
|
+
async enable(userId, preferredMethod = "totp") {
|
|
125
|
+
// Check that at least one method is available
|
|
126
|
+
const [hasTotp, hasPasskey] = await Promise.all([
|
|
127
|
+
this.totpService.hasVerifiedAuthenticator({ userId }),
|
|
128
|
+
this.passkeyService.hasPasskeys({ userId }),
|
|
129
|
+
]);
|
|
130
|
+
if (!hasTotp && !hasPasskey) {
|
|
131
|
+
throw new common_1.BadRequestException("Cannot enable 2FA without at least one configured method (TOTP or Passkey)");
|
|
132
|
+
}
|
|
133
|
+
// Validate preferred method is available
|
|
134
|
+
if (preferredMethod === "totp" && !hasTotp) {
|
|
135
|
+
preferredMethod = "passkey";
|
|
136
|
+
}
|
|
137
|
+
else if (preferredMethod === "passkey" && !hasPasskey) {
|
|
138
|
+
preferredMethod = "totp";
|
|
139
|
+
}
|
|
140
|
+
// Get or create config
|
|
141
|
+
const existingConfig = await this.twoFactorConfigRepository.findByUserId({ userId });
|
|
142
|
+
let config;
|
|
143
|
+
if (existingConfig) {
|
|
144
|
+
config = await this.twoFactorConfigRepository.updateByUserId({
|
|
145
|
+
userId,
|
|
146
|
+
isEnabled: true,
|
|
147
|
+
preferredMethod,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
config = await this.twoFactorConfigRepository.createForUser({
|
|
152
|
+
configId: crypto.randomUUID(),
|
|
153
|
+
userId,
|
|
154
|
+
isEnabled: true,
|
|
155
|
+
preferredMethod,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
return this.jsonApiService.buildSingle(two_factor_config_1.TwoFactorConfigDescriptor.model, config);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Disable 2FA for a user.
|
|
162
|
+
*
|
|
163
|
+
* @param userId - The user's ID
|
|
164
|
+
*/
|
|
165
|
+
async disable(userId) {
|
|
166
|
+
const config = await this.twoFactorConfigRepository.findByUserId({ userId });
|
|
167
|
+
if (!config) {
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
return this.twoFactorConfigRepository.updateByUserId({
|
|
171
|
+
userId,
|
|
172
|
+
isEnabled: false,
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Set the preferred 2FA method for a user.
|
|
177
|
+
*
|
|
178
|
+
* @param userId - The user's ID
|
|
179
|
+
* @param method - The preferred method
|
|
180
|
+
* @throws BadRequestException if the method is not available
|
|
181
|
+
*/
|
|
182
|
+
async setPreferredMethod(userId, method) {
|
|
183
|
+
// Validate the method is available
|
|
184
|
+
let isAvailable = false;
|
|
185
|
+
switch (method) {
|
|
186
|
+
case "totp":
|
|
187
|
+
isAvailable = await this.totpService.hasVerifiedAuthenticator({ userId });
|
|
188
|
+
break;
|
|
189
|
+
case "passkey":
|
|
190
|
+
isAvailable = await this.passkeyService.hasPasskeys({ userId });
|
|
191
|
+
break;
|
|
192
|
+
case "backup":
|
|
193
|
+
throw new common_1.BadRequestException("Backup codes cannot be set as preferred method");
|
|
194
|
+
}
|
|
195
|
+
if (!isAvailable) {
|
|
196
|
+
throw new common_1.BadRequestException(`Cannot set ${method} as preferred - method not configured`);
|
|
197
|
+
}
|
|
198
|
+
const config = await this.twoFactorConfigRepository.findByUserId({ userId });
|
|
199
|
+
if (!config) {
|
|
200
|
+
throw new common_1.NotFoundException("Two-factor configuration not found");
|
|
201
|
+
}
|
|
202
|
+
return this.twoFactorConfigRepository.updateByUserId({
|
|
203
|
+
userId,
|
|
204
|
+
preferredMethod: method,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Create a pending 2FA session after successful password validation.
|
|
209
|
+
* This is called by the auth service when a user with 2FA enabled logs in.
|
|
210
|
+
*
|
|
211
|
+
* @param userId - The user's ID
|
|
212
|
+
* @returns The pending session info
|
|
213
|
+
*/
|
|
214
|
+
async createPendingSession(userId) {
|
|
215
|
+
const pendingId = crypto.randomUUID();
|
|
216
|
+
const expiration = new Date(Date.now() + this.pendingTtlSeconds * 1000);
|
|
217
|
+
// Create the pending session with a simple challenge
|
|
218
|
+
// The challenge is just a random string for session identification
|
|
219
|
+
const challenge = crypto.randomBytes(32).toString("base64url");
|
|
220
|
+
await this.pendingTwoFactorRepository.createForUser({
|
|
221
|
+
pendingId,
|
|
222
|
+
userId,
|
|
223
|
+
challenge,
|
|
224
|
+
challengeType: "login",
|
|
225
|
+
expiration,
|
|
226
|
+
});
|
|
227
|
+
return {
|
|
228
|
+
pendingId,
|
|
229
|
+
expiration,
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Get available 2FA methods for a user during login.
|
|
234
|
+
*
|
|
235
|
+
* @param userId - The user's ID
|
|
236
|
+
* @returns Array of available method names
|
|
237
|
+
*/
|
|
238
|
+
async getAvailableMethods(userId) {
|
|
239
|
+
const [hasTotp, hasPasskey, backupCodesCount] = await Promise.all([
|
|
240
|
+
this.totpService.hasVerifiedAuthenticator({ userId }),
|
|
241
|
+
this.passkeyService.hasPasskeys({ userId }),
|
|
242
|
+
this.backupCodeService.getRawUnusedCount({ userId }),
|
|
243
|
+
]);
|
|
244
|
+
const methods = [];
|
|
245
|
+
if (hasTotp)
|
|
246
|
+
methods.push("totp");
|
|
247
|
+
if (hasPasskey)
|
|
248
|
+
methods.push("passkey");
|
|
249
|
+
if (backupCodesCount > 0)
|
|
250
|
+
methods.push("backup");
|
|
251
|
+
return methods;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Verify a TOTP code for 2FA login.
|
|
255
|
+
*
|
|
256
|
+
* @param pendingId - The pending session ID from createPendingSession
|
|
257
|
+
* @param code - The 6-digit TOTP code
|
|
258
|
+
* @returns JSON:API response with verification result
|
|
259
|
+
*/
|
|
260
|
+
async verifyTotp(pendingId, code) {
|
|
261
|
+
const pendingData = await this.validateAndGetPending(pendingId, "login");
|
|
262
|
+
// Check attempt count
|
|
263
|
+
const attemptCount = await this.pendingTwoFactorRepository.incrementAttemptCount({ pendingId });
|
|
264
|
+
if (attemptCount > this.maxTotpAttempts) {
|
|
265
|
+
await this.pendingTwoFactorRepository.deletePending({ pendingId });
|
|
266
|
+
throw new common_1.BadRequestException("Maximum TOTP attempts exceeded");
|
|
267
|
+
}
|
|
268
|
+
// Verify the code
|
|
269
|
+
const authenticatorId = await this.totpService.verifyCodeForUser({
|
|
270
|
+
userId: pendingData.userId,
|
|
271
|
+
code,
|
|
272
|
+
});
|
|
273
|
+
if (!authenticatorId) {
|
|
274
|
+
return this.jsonApiService.buildSingle(two_factor_verification_1.TwoFactorVerificationDescriptor.model, {
|
|
275
|
+
id: pendingId,
|
|
276
|
+
success: false,
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
// Clean up the pending session
|
|
280
|
+
await this.pendingTwoFactorRepository.deletePending({ pendingId });
|
|
281
|
+
return this.jsonApiService.buildSingle(two_factor_verification_1.TwoFactorVerificationDescriptor.model, {
|
|
282
|
+
id: pendingId,
|
|
283
|
+
success: true,
|
|
284
|
+
userId: pendingData.userId,
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Verify a passkey for 2FA login.
|
|
289
|
+
*
|
|
290
|
+
* @param pendingId - The pending session ID
|
|
291
|
+
* @param response - The WebAuthn authentication response
|
|
292
|
+
* @returns JSON:API response with verification result
|
|
293
|
+
*/
|
|
294
|
+
async verifyPasskey(pendingId, response) {
|
|
295
|
+
const pendingData = await this.validateAndGetPending(pendingId, "login");
|
|
296
|
+
// Check attempt count
|
|
297
|
+
const attemptCount = await this.pendingTwoFactorRepository.incrementAttemptCount({ pendingId });
|
|
298
|
+
if (attemptCount > this.maxPasskeyAttempts) {
|
|
299
|
+
await this.pendingTwoFactorRepository.deletePending({ pendingId });
|
|
300
|
+
throw new common_1.BadRequestException("Maximum passkey attempts exceeded");
|
|
301
|
+
}
|
|
302
|
+
// For passkey verification during login, we need to use the existing passkey challenge
|
|
303
|
+
// But since this is a 2FA flow after password, we're verifying differently
|
|
304
|
+
// We need to generate auth options first if not already done
|
|
305
|
+
try {
|
|
306
|
+
// First, generate authentication options
|
|
307
|
+
const authOptions = await this.passkeyService.generateAuthenticationOptions({
|
|
308
|
+
userId: pendingData.userId,
|
|
309
|
+
});
|
|
310
|
+
// Note: In a real implementation, the client would need to perform the WebAuthn
|
|
311
|
+
// ceremony with these options. For the 2FA flow, we're doing a simplified verification.
|
|
312
|
+
// The actual passkey verification happens via the passkey.service.verifyAuthentication
|
|
313
|
+
const passkeyId = await this.passkeyService.verifyAuthentication({
|
|
314
|
+
pendingId: authOptions.data.attributes.pendingId,
|
|
315
|
+
response,
|
|
316
|
+
});
|
|
317
|
+
if (!passkeyId) {
|
|
318
|
+
return this.jsonApiService.buildSingle(two_factor_verification_1.TwoFactorVerificationDescriptor.model, {
|
|
319
|
+
id: pendingId,
|
|
320
|
+
success: false,
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
// Clean up the login pending session
|
|
324
|
+
await this.pendingTwoFactorRepository.deletePending({ pendingId });
|
|
325
|
+
return this.jsonApiService.buildSingle(two_factor_verification_1.TwoFactorVerificationDescriptor.model, {
|
|
326
|
+
id: pendingId,
|
|
327
|
+
success: true,
|
|
328
|
+
userId: pendingData.userId,
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
catch {
|
|
332
|
+
return this.jsonApiService.buildSingle(two_factor_verification_1.TwoFactorVerificationDescriptor.model, {
|
|
333
|
+
id: pendingId,
|
|
334
|
+
success: false,
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Verify a backup code for 2FA login.
|
|
340
|
+
*
|
|
341
|
+
* @param pendingId - The pending session ID
|
|
342
|
+
* @param code - The backup code
|
|
343
|
+
* @returns JSON:API response with verification result
|
|
344
|
+
*/
|
|
345
|
+
async verifyBackupCode(pendingId, code) {
|
|
346
|
+
const pendingData = await this.validateAndGetPending(pendingId, "login");
|
|
347
|
+
// Check attempt count
|
|
348
|
+
const attemptCount = await this.pendingTwoFactorRepository.incrementAttemptCount({ pendingId });
|
|
349
|
+
if (attemptCount > this.maxBackupAttempts) {
|
|
350
|
+
await this.pendingTwoFactorRepository.deletePending({ pendingId });
|
|
351
|
+
throw new common_1.BadRequestException("Maximum backup code attempts exceeded");
|
|
352
|
+
}
|
|
353
|
+
// Verify the backup code
|
|
354
|
+
const isValid = await this.backupCodeService.validateCode({
|
|
355
|
+
userId: pendingData.userId,
|
|
356
|
+
code,
|
|
357
|
+
});
|
|
358
|
+
if (!isValid) {
|
|
359
|
+
return this.jsonApiService.buildSingle(two_factor_verification_1.TwoFactorVerificationDescriptor.model, {
|
|
360
|
+
id: pendingId,
|
|
361
|
+
success: false,
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
// Update backup codes count in config
|
|
365
|
+
const unusedCount = await this.backupCodeService.getRawUnusedCount({ userId: pendingData.userId });
|
|
366
|
+
await this.twoFactorConfigRepository.updateByUserId({
|
|
367
|
+
userId: pendingData.userId,
|
|
368
|
+
backupCodesCount: unusedCount,
|
|
369
|
+
});
|
|
370
|
+
// Clean up the pending session
|
|
371
|
+
await this.pendingTwoFactorRepository.deletePending({ pendingId });
|
|
372
|
+
return this.jsonApiService.buildSingle(two_factor_verification_1.TwoFactorVerificationDescriptor.model, {
|
|
373
|
+
id: pendingId,
|
|
374
|
+
success: true,
|
|
375
|
+
userId: pendingData.userId,
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Get pending session info by ID.
|
|
380
|
+
*
|
|
381
|
+
* @param pendingId - The pending session ID
|
|
382
|
+
* @returns The pending session data if found
|
|
383
|
+
*/
|
|
384
|
+
async getPendingSession(pendingId) {
|
|
385
|
+
return this.pendingTwoFactorRepository.findByIdWithUser({ pendingId });
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Delete a pending session.
|
|
389
|
+
*
|
|
390
|
+
* @param pendingId - The pending session ID
|
|
391
|
+
*/
|
|
392
|
+
async deletePendingSession(pendingId) {
|
|
393
|
+
await this.pendingTwoFactorRepository.deletePending({ pendingId });
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Update backup codes count in the config.
|
|
397
|
+
* Called after generating or using backup codes.
|
|
398
|
+
*
|
|
399
|
+
* @param userId - The user's ID
|
|
400
|
+
*/
|
|
401
|
+
async updateBackupCodesCount(userId) {
|
|
402
|
+
const unusedCount = await this.backupCodeService.getRawUnusedCount({ userId });
|
|
403
|
+
const config = await this.twoFactorConfigRepository.findByUserId({ userId });
|
|
404
|
+
if (config) {
|
|
405
|
+
await this.twoFactorConfigRepository.updateByUserId({
|
|
406
|
+
userId,
|
|
407
|
+
backupCodesCount: unusedCount,
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Check if 2FA should be automatically disabled due to no methods remaining.
|
|
413
|
+
* Called when removing the last TOTP authenticator or passkey.
|
|
414
|
+
*
|
|
415
|
+
* @param userId - The user's ID
|
|
416
|
+
* @returns true if 2FA was disabled
|
|
417
|
+
*/
|
|
418
|
+
async checkAndDisableIfNoMethods(userId) {
|
|
419
|
+
const [hasTotp, hasPasskey] = await Promise.all([
|
|
420
|
+
this.totpService.hasVerifiedAuthenticator({ userId }),
|
|
421
|
+
this.passkeyService.hasPasskeys({ userId }),
|
|
422
|
+
]);
|
|
423
|
+
if (!hasTotp && !hasPasskey) {
|
|
424
|
+
const config = await this.twoFactorConfigRepository.findByUserId({ userId });
|
|
425
|
+
if (config?.isEnabled) {
|
|
426
|
+
await this.disable(userId);
|
|
427
|
+
return true;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
return false;
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Validate a pending session and return its data.
|
|
434
|
+
*
|
|
435
|
+
* @param pendingId - The pending session ID
|
|
436
|
+
* @param expectedType - The expected challenge type
|
|
437
|
+
* @throws NotFoundException if session not found
|
|
438
|
+
* @throws BadRequestException if session expired or wrong type
|
|
439
|
+
*/
|
|
440
|
+
async validateAndGetPending(pendingId, expectedType) {
|
|
441
|
+
const pendingData = await this.pendingTwoFactorRepository.findByIdWithUser({ pendingId });
|
|
442
|
+
if (!pendingData) {
|
|
443
|
+
throw new common_1.NotFoundException("Pending 2FA session not found");
|
|
444
|
+
}
|
|
445
|
+
const { pending } = pendingData;
|
|
446
|
+
// Check challenge type
|
|
447
|
+
if (pending.challengeType !== expectedType) {
|
|
448
|
+
throw new common_1.BadRequestException(`Invalid challenge type: expected ${expectedType}`);
|
|
449
|
+
}
|
|
450
|
+
// Check expiration
|
|
451
|
+
if (new Date() > pending.expiration) {
|
|
452
|
+
await this.pendingTwoFactorRepository.deletePending({ pendingId });
|
|
453
|
+
throw new common_1.BadRequestException("2FA session has expired");
|
|
454
|
+
}
|
|
455
|
+
return pendingData;
|
|
456
|
+
}
|
|
457
|
+
};
|
|
458
|
+
exports.TwoFactorService = TwoFactorService;
|
|
459
|
+
exports.TwoFactorService = TwoFactorService = __decorate([
|
|
460
|
+
(0, common_1.Injectable)(),
|
|
461
|
+
__metadata("design:paramtypes", [jsonapi_service_1.JsonApiService,
|
|
462
|
+
two_factor_config_repository_1.TwoFactorConfigRepository,
|
|
463
|
+
pending_two_factor_repository_1.PendingTwoFactorRepository,
|
|
464
|
+
totp_service_1.TotpService,
|
|
465
|
+
passkey_service_1.PasskeyService,
|
|
466
|
+
backup_code_service_1.BackupCodeService])
|
|
467
|
+
], TwoFactorService);
|
|
468
|
+
//# sourceMappingURL=two-factor.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"two-factor.service.js","sourceRoot":"","sources":["../../../../src/foundations/two-factor/services/two-factor.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAoF;AACpF,+CAAiC;AACjC,6DAAyD;AACzD,oFAAgF;AAEhF,qEAA2F;AAC3F,qEAA0E;AAC1E,iFAAsF;AACtF,iGAA2F;AAC3F,+FAAyF;AACzF,+DAA0D;AAC1D,uDAAmD;AACnD,iDAA6C;AAyB7C;;;;;;GAMG;AAEI,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAM3B,YACmB,cAA8B,EAC9B,yBAAoD,EACpD,0BAAsD,EACtD,WAAwB,EACxB,cAA8B,EAC9B,iBAAoC;QALpC,mBAAc,GAAd,cAAc,CAAgB;QAC9B,8BAAyB,GAAzB,yBAAyB,CAA2B;QACpD,+BAA0B,GAA1B,0BAA0B,CAA4B;QACtD,gBAAW,GAAX,WAAW,CAAa;QACxB,mBAAc,GAAd,cAAc,CAAgB;QAC9B,sBAAiB,GAAjB,iBAAiB,CAAmB;QAVtC,oBAAe,GAAG,CAAC,CAAC;QACpB,uBAAkB,GAAG,CAAC,CAAC;QACvB,sBAAiB,GAAG,CAAC,CAAC;QAUrC,IAAI,CAAC,iBAAiB,GAAG,wBAAU,CAAC,SAAS,EAAE,UAAU,IAAI,GAAG,C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|
+
import { OnModuleInit } from "@nestjs/common";
|
|
2
|
+
/**
|
|
3
|
+
* TwoFactorModule - Two-Factor Authentication Module
|
|
4
|
+
*
|
|
5
|
+
* Provides comprehensive 2FA functionality including:
|
|
6
|
+
* - TOTP (Time-based One-Time Password) authentication
|
|
7
|
+
* - Passkey/WebAuthn authentication
|
|
8
|
+
* - Backup codes for account recovery
|
|
9
|
+
* - Pending session management for 2FA login flow
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* // Import in AuthModule
|
|
14
|
+
* @Module({
|
|
15
|
+
* imports: [TwoFactorModule],
|
|
16
|
+
* })
|
|
17
|
+
* export class AuthModule {}
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare class TwoFactorModule implements OnModuleInit {
|
|
21
|
+
onModuleInit(): void;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=two-factor.module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"two-factor.module.d.ts","sourceRoot":"","sources":["../../../src/foundations/two-factor/two-factor.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,YAAY,EAAE,MAAM,gBAAgB,CAAC;AA2ClE;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAkDa,eAAgB,YAAW,YAAY;IAClD,YAAY;CAgBb"}
|
|
@@ -0,0 +1,132 @@
|
|
|
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 registry_1 = require("../../common/registries/registry");
|
|
12
|
+
const jsonapi_module_1 = require("../../core/jsonapi/jsonapi.module");
|
|
13
|
+
const auth_module_1 = require("../auth/auth.module");
|
|
14
|
+
const user_module_1 = require("../user/user.module");
|
|
15
|
+
// Controllers
|
|
16
|
+
const passkey_controller_1 = require("./controllers/passkey.controller");
|
|
17
|
+
const totp_controller_1 = require("./controllers/totp.controller");
|
|
18
|
+
const two_factor_controller_1 = require("./controllers/two-factor.controller");
|
|
19
|
+
// Entity Descriptors (models for registration)
|
|
20
|
+
const backup_code_1 = require("./entities/backup-code");
|
|
21
|
+
const backup_codes_count_1 = require("./entities/backup-codes-count");
|
|
22
|
+
const backup_codes_generation_1 = require("./entities/backup-codes-generation");
|
|
23
|
+
const passkey_1 = require("./entities/passkey");
|
|
24
|
+
const passkey_authentication_options_1 = require("./entities/passkey-authentication-options");
|
|
25
|
+
const passkey_registration_options_1 = require("./entities/passkey-registration-options");
|
|
26
|
+
const pending_two_factor_1 = require("./entities/pending-two-factor");
|
|
27
|
+
const totp_authenticator_1 = require("./entities/totp-authenticator");
|
|
28
|
+
const totp_setup_1 = require("./entities/totp-setup");
|
|
29
|
+
const two_factor_challenge_1 = require("./entities/two-factor-challenge");
|
|
30
|
+
const two_factor_config_1 = require("./entities/two-factor-config");
|
|
31
|
+
const two_factor_status_1 = require("./entities/two-factor-status");
|
|
32
|
+
const two_factor_verification_1 = require("./entities/two-factor-verification");
|
|
33
|
+
// Repositories
|
|
34
|
+
const backup_code_repository_1 = require("./repositories/backup-code.repository");
|
|
35
|
+
const passkey_repository_1 = require("./repositories/passkey.repository");
|
|
36
|
+
const pending_two_factor_repository_1 = require("./repositories/pending-two-factor.repository");
|
|
37
|
+
const totp_authenticator_repository_1 = require("./repositories/totp-authenticator.repository");
|
|
38
|
+
const two_factor_config_repository_1 = require("./repositories/two-factor-config.repository");
|
|
39
|
+
// Services
|
|
40
|
+
const backup_code_service_1 = require("./services/backup-code.service");
|
|
41
|
+
const passkey_service_1 = require("./services/passkey.service");
|
|
42
|
+
const totp_encryption_service_1 = require("./services/totp-encryption.service");
|
|
43
|
+
const totp_service_1 = require("./services/totp.service");
|
|
44
|
+
const two_factor_service_1 = require("./services/two-factor.service");
|
|
45
|
+
// Guards
|
|
46
|
+
const pending_auth_guard_1 = require("./guards/pending-auth.guard");
|
|
47
|
+
/**
|
|
48
|
+
* TwoFactorModule - Two-Factor Authentication Module
|
|
49
|
+
*
|
|
50
|
+
* Provides comprehensive 2FA functionality including:
|
|
51
|
+
* - TOTP (Time-based One-Time Password) authentication
|
|
52
|
+
* - Passkey/WebAuthn authentication
|
|
53
|
+
* - Backup codes for account recovery
|
|
54
|
+
* - Pending session management for 2FA login flow
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* // Import in AuthModule
|
|
59
|
+
* @Module({
|
|
60
|
+
* imports: [TwoFactorModule],
|
|
61
|
+
* })
|
|
62
|
+
* export class AuthModule {}
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
let TwoFactorModule = class TwoFactorModule {
|
|
66
|
+
onModuleInit() {
|
|
67
|
+
// Register all 2FA models with the global model registry
|
|
68
|
+
registry_1.modelRegistry.register(backup_code_1.BackupCodeDescriptor.model);
|
|
69
|
+
registry_1.modelRegistry.register(backup_codes_count_1.BackupCodesCountDescriptor.model);
|
|
70
|
+
registry_1.modelRegistry.register(backup_codes_generation_1.BackupCodesGenerationDescriptor.model);
|
|
71
|
+
registry_1.modelRegistry.register(passkey_1.PasskeyDescriptor.model);
|
|
72
|
+
registry_1.modelRegistry.register(passkey_authentication_options_1.PasskeyAuthenticationOptionsDescriptor.model);
|
|
73
|
+
registry_1.modelRegistry.register(passkey_registration_options_1.PasskeyRegistrationOptionsDescriptor.model);
|
|
74
|
+
registry_1.modelRegistry.register(pending_two_factor_1.PendingTwoFactorDescriptor.model);
|
|
75
|
+
registry_1.modelRegistry.register(totp_authenticator_1.TotpAuthenticatorDescriptor.model);
|
|
76
|
+
registry_1.modelRegistry.register(totp_setup_1.TotpSetupDescriptor.model);
|
|
77
|
+
registry_1.modelRegistry.register(two_factor_challenge_1.TwoFactorChallengeDescriptor.model);
|
|
78
|
+
registry_1.modelRegistry.register(two_factor_config_1.TwoFactorConfigDescriptor.model);
|
|
79
|
+
registry_1.modelRegistry.register(two_factor_status_1.TwoFactorStatusDescriptor.model);
|
|
80
|
+
registry_1.modelRegistry.register(two_factor_verification_1.TwoFactorVerificationDescriptor.model);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
exports.TwoFactorModule = TwoFactorModule;
|
|
84
|
+
exports.TwoFactorModule = TwoFactorModule = __decorate([
|
|
85
|
+
(0, common_1.Module)({
|
|
86
|
+
imports: [jsonapi_module_1.JsonApiModule, user_module_1.UserModule, (0, common_1.forwardRef)(() => auth_module_1.AuthModule)],
|
|
87
|
+
controllers: [passkey_controller_1.PasskeyController, totp_controller_1.TotpController, two_factor_controller_1.TwoFactorController],
|
|
88
|
+
providers: [
|
|
89
|
+
// Serializers from descriptors
|
|
90
|
+
backup_code_1.BackupCodeDescriptor.model.serialiser,
|
|
91
|
+
backup_codes_count_1.BackupCodesCountDescriptor.model.serialiser,
|
|
92
|
+
backup_codes_generation_1.BackupCodesGenerationDescriptor.model.serialiser,
|
|
93
|
+
passkey_1.PasskeyDescriptor.model.serialiser,
|
|
94
|
+
passkey_authentication_options_1.PasskeyAuthenticationOptionsDescriptor.model.serialiser,
|
|
95
|
+
passkey_registration_options_1.PasskeyRegistrationOptionsDescriptor.model.serialiser,
|
|
96
|
+
pending_two_factor_1.PendingTwoFactorDescriptor.model.serialiser,
|
|
97
|
+
totp_authenticator_1.TotpAuthenticatorDescriptor.model.serialiser,
|
|
98
|
+
totp_setup_1.TotpSetupDescriptor.model.serialiser,
|
|
99
|
+
two_factor_challenge_1.TwoFactorChallengeDescriptor.model.serialiser,
|
|
100
|
+
two_factor_config_1.TwoFactorConfigDescriptor.model.serialiser,
|
|
101
|
+
two_factor_status_1.TwoFactorStatusDescriptor.model.serialiser,
|
|
102
|
+
two_factor_verification_1.TwoFactorVerificationDescriptor.model.serialiser,
|
|
103
|
+
// Repositories
|
|
104
|
+
backup_code_repository_1.BackupCodeRepository,
|
|
105
|
+
passkey_repository_1.PasskeyRepository,
|
|
106
|
+
pending_two_factor_repository_1.PendingTwoFactorRepository,
|
|
107
|
+
totp_authenticator_repository_1.TotpAuthenticatorRepository,
|
|
108
|
+
two_factor_config_repository_1.TwoFactorConfigRepository,
|
|
109
|
+
// Services
|
|
110
|
+
backup_code_service_1.BackupCodeService,
|
|
111
|
+
passkey_service_1.PasskeyService,
|
|
112
|
+
totp_encryption_service_1.TotpEncryptionService,
|
|
113
|
+
totp_service_1.TotpService,
|
|
114
|
+
two_factor_service_1.TwoFactorService,
|
|
115
|
+
// Guards
|
|
116
|
+
pending_auth_guard_1.PendingAuthGuard,
|
|
117
|
+
],
|
|
118
|
+
exports: [
|
|
119
|
+
// Export services for use by other modules (e.g., AuthModule)
|
|
120
|
+
two_factor_service_1.TwoFactorService,
|
|
121
|
+
totp_service_1.TotpService,
|
|
122
|
+
passkey_service_1.PasskeyService,
|
|
123
|
+
backup_code_service_1.BackupCodeService,
|
|
124
|
+
totp_encryption_service_1.TotpEncryptionService,
|
|
125
|
+
pending_auth_guard_1.PendingAuthGuard,
|
|
126
|
+
// Export repositories for advanced use cases
|
|
127
|
+
two_factor_config_repository_1.TwoFactorConfigRepository,
|
|
128
|
+
pending_two_factor_repository_1.PendingTwoFactorRepository,
|
|
129
|
+
],
|
|
130
|
+
})
|
|
131
|
+
], TwoFactorModule);
|
|
132
|
+
//# sourceMappingURL=two-factor.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"two-factor.module.js","sourceRoot":"","sources":["../../../src/foundations/two-factor/two-factor.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAkE;AAClE,+DAAiE;AACjE,sEAAkE;AAClE,qDAAiD;AACjD,qDAAiD;AAEjD,cAAc;AACd,yEAAqE;AACrE,mEAA+D;AAC/D,+EAA0E;AAE1E,+CAA+C;AAC/C,wDAA8D;AAC9D,sEAA2E;AAC3E,gFAAqF;AACrF,gDAAuD;AACvD,8FAAmG;AACnG,0FAA+F;AAC/F,sEAA2E;AAC3E,sEAA4E;AAC5E,sDAA4D;AAC5D,0EAA+E;AAC/E,oEAAyE;AACzE,oEAAyE;AACzE,gFAAqF;AAErF,eAAe;AACf,kFAA6E;AAC7E,0EAAsE;AACtE,gGAA0F;AAC1F,gGAA2F;AAC3F,8FAAwF;AAExF,WAAW;AACX,wEAAmE;AACnE,gEAA4D;AAC5D,gFAA2E;AAC3E,0DAAsD;AACtD,sEAAiE;AAEjE,SAAS;AACT,oEAA+D;AAE/D;;;;;;;;;;;;;;;;;GAiBG;AAmDI,IAAM,eAAe,GAArB,MAAM,eAAe;IAC1B,YAAY;QACV,yDAAyD;QACzD,wBAAa,CAAC,QAAQ,CAAC,kCAAoB,CAAC,KAAK,CAAC,CAAC;QACnD,wBAAa,CAAC,QAAQ,CAAC,+CAA0B,CAAC,KAAK,CAAC,CAAC;QACzD,wBAAa,CAAC,QAAQ,CAAC,yDAA+B,CAAC,KAAK,CAAC,CAAC;QAC9D,wBAAa,CAAC,QAAQ,CAAC,2BAAiB,CAAC,KAAK,CAAC,CAAC;QAChD,wBAAa,CAAC,QAAQ,CAAC,uEAAsC,CAAC,KAAK,CAAC,CAAC;QACrE,wBAAa,CAAC,QAAQ,CAAC,mEAAoC,CAAC,KAAK,CAAC,CAAC;QACnE,wBAAa,CAAC,QAAQ,CAAC,+CAA0B,CAAC,KAAK,CAAC,CAAC;QACzD,wBAAa,CAAC,QAAQ,CAAC,gDAA2B,CAAC,KA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YACX,uCAAiB;YACjB,gCAAc;YACd,+CAAqB;YACrB,0BAAW;YACX,qCAAgB;YAEhB,SAAS;YACT,qCAAgB;SACjB;QACD,OAAO,EAAE;YACP,8DAA8D;YAC9D,qCAAgB;YAChB,0BAAW;YACX,gCAAc;YACd,uCAAiB;YACjB,+CAAqB;YACrB,qCAAgB;YAEhB,6CAA6C;YAC7C,wDAAyB;YACzB,0DAA0B;SAC3B;KACF,CAAC;GACW,eAAe,CAiB3B"}
|
|
@@ -16,6 +16,14 @@ export declare class UserRepository implements OnModuleInit {
|
|
|
16
16
|
findOneForAdmin(params: {
|
|
17
17
|
userId: string;
|
|
18
18
|
}): Promise<User>;
|
|
19
|
+
/**
|
|
20
|
+
* Find user for 2FA login completion.
|
|
21
|
+
* Does NOT require companyId in CLS - finds company through user relationship.
|
|
22
|
+
* Returns user with roles, company, and features needed for token creation.
|
|
23
|
+
*/
|
|
24
|
+
findForTwoFactorLogin(params: {
|
|
25
|
+
userId: string;
|
|
26
|
+
}): Promise<User>;
|
|
19
27
|
findFullUser(params: {
|
|
20
28
|
userId: string;
|
|
21
29
|
}): Promise<User>;
|