@hed-hog/core 0.0.4
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/auth/auth.controller.d.ts +167 -0
- package/dist/auth/auth.controller.d.ts.map +1 -0
- package/dist/auth/auth.controller.js +236 -0
- package/dist/auth/auth.controller.js.map +1 -0
- package/dist/auth/auth.module.d.ts +5 -0
- package/dist/auth/auth.module.d.ts.map +1 -0
- package/dist/auth/auth.module.js +116 -0
- package/dist/auth/auth.module.js.map +1 -0
- package/dist/auth/auth.service.d.ts +215 -0
- package/dist/auth/auth.service.d.ts.map +1 -0
- package/dist/auth/auth.service.js +493 -0
- package/dist/auth/auth.service.js.map +1 -0
- package/dist/auth/consts/body.d.ts +2 -0
- package/dist/auth/consts/body.d.ts.map +1 -0
- package/dist/auth/consts/body.js +32 -0
- package/dist/auth/consts/body.js.map +1 -0
- package/dist/auth/dto/change.dto.d.ts +7 -0
- package/dist/auth/dto/change.dto.d.ts.map +1 -0
- package/dist/auth/dto/change.dto.js +51 -0
- package/dist/auth/dto/change.dto.js.map +1 -0
- package/dist/auth/dto/create-user.dto.d.ts +12 -0
- package/dist/auth/dto/create-user.dto.d.ts.map +1 -0
- package/dist/auth/dto/create-user.dto.js +60 -0
- package/dist/auth/dto/create-user.dto.js.map +1 -0
- package/dist/auth/dto/email.dto.d.ts +6 -0
- package/dist/auth/dto/email.dto.d.ts.map +1 -0
- package/dist/auth/dto/email.dto.js +33 -0
- package/dist/auth/dto/email.dto.js.map +1 -0
- package/dist/auth/dto/forget.dto.d.ts +6 -0
- package/dist/auth/dto/forget.dto.d.ts.map +1 -0
- package/dist/auth/dto/forget.dto.js +29 -0
- package/dist/auth/dto/forget.dto.js.map +1 -0
- package/dist/auth/dto/login-with-code.dto.d.ts +6 -0
- package/dist/auth/dto/login-with-code.dto.d.ts.map +1 -0
- package/dist/auth/dto/login-with-code.dto.js +31 -0
- package/dist/auth/dto/login-with-code.dto.js.map +1 -0
- package/dist/auth/dto/login-with-recovery-code.d.ts +5 -0
- package/dist/auth/dto/login-with-recovery-code.d.ts.map +1 -0
- package/dist/auth/dto/login-with-recovery-code.js +26 -0
- package/dist/auth/dto/login-with-recovery-code.js.map +1 -0
- package/dist/auth/dto/login.dto.d.ts +8 -0
- package/dist/auth/dto/login.dto.d.ts.map +1 -0
- package/dist/auth/dto/login.dto.js +51 -0
- package/dist/auth/dto/login.dto.js.map +1 -0
- package/dist/auth/dto/resend-mfa-code.dto.d.ts +4 -0
- package/dist/auth/dto/resend-mfa-code.dto.d.ts.map +1 -0
- package/dist/auth/dto/resend-mfa-code.dto.js +21 -0
- package/dist/auth/dto/resend-mfa-code.dto.js.map +1 -0
- package/dist/auth/dto/reset.dto.d.ts +5 -0
- package/dist/auth/dto/reset.dto.d.ts.map +1 -0
- package/dist/auth/dto/reset.dto.js +29 -0
- package/dist/auth/dto/reset.dto.js.map +1 -0
- package/dist/auth/enums/multifactor-type.enum.d.ts +5 -0
- package/dist/auth/enums/multifactor-type.enum.d.ts.map +1 -0
- package/dist/auth/enums/multifactor-type.enum.js +9 -0
- package/dist/auth/enums/multifactor-type.enum.js.map +1 -0
- package/dist/auth/guards/auth.guard.d.ts +11 -0
- package/dist/auth/guards/auth.guard.d.ts.map +1 -0
- package/dist/auth/guards/auth.guard.js +65 -0
- package/dist/auth/guards/auth.guard.js.map +1 -0
- package/dist/challenge/challenge.module.d.ts +3 -0
- package/dist/challenge/challenge.module.d.ts.map +1 -0
- package/dist/challenge/challenge.module.js +33 -0
- package/dist/challenge/challenge.module.js.map +1 -0
- package/dist/challenge/challenge.service.d.ts +84 -0
- package/dist/challenge/challenge.service.d.ts.map +1 -0
- package/dist/challenge/challenge.service.js +288 -0
- package/dist/challenge/challenge.service.js.map +1 -0
- package/dist/core/core.controller.d.ts +44 -0
- package/dist/core/core.controller.d.ts.map +1 -0
- package/dist/core/core.controller.js +38 -0
- package/dist/core/core.controller.js.map +1 -0
- package/dist/core/core.module.d.ts +3 -0
- package/dist/core/core.module.d.ts.map +1 -0
- package/dist/core/core.module.js +28 -0
- package/dist/core/core.module.js.map +1 -0
- package/dist/core/core.service.d.ts +56 -0
- package/dist/core/core.service.d.ts.map +1 -0
- package/dist/core/core.service.js +320 -0
- package/dist/core/core.service.js.map +1 -0
- package/dist/core/system.controller.d.ts +44 -0
- package/dist/core/system.controller.d.ts.map +1 -0
- package/dist/core/system.controller.js +38 -0
- package/dist/core/system.controller.js.map +1 -0
- package/dist/core/system.module.d.ts +3 -0
- package/dist/core/system.module.d.ts.map +1 -0
- package/dist/core/system.module.js +28 -0
- package/dist/core/system.module.js.map +1 -0
- package/dist/core/system.service.d.ts +56 -0
- package/dist/core/system.service.d.ts.map +1 -0
- package/dist/core/system.service.js +320 -0
- package/dist/core/system.service.js.map +1 -0
- package/dist/core.module.d.ts +5 -0
- package/dist/core.module.d.ts.map +1 -0
- package/dist/core.module.js +101 -0
- package/dist/core.module.js.map +1 -0
- package/dist/dashboard/dashboard/dashboard.controller.d.ts +24 -0
- package/dist/dashboard/dashboard/dashboard.controller.d.ts.map +1 -0
- package/dist/dashboard/dashboard/dashboard.controller.js +88 -0
- package/dist/dashboard/dashboard/dashboard.controller.js.map +1 -0
- package/dist/dashboard/dashboard/dashboard.module.d.ts +3 -0
- package/dist/dashboard/dashboard/dashboard.module.d.ts.map +1 -0
- package/dist/dashboard/dashboard/dashboard.module.js +26 -0
- package/dist/dashboard/dashboard/dashboard.module.js.map +1 -0
- package/dist/dashboard/dashboard/dashboard.service.d.ts +32 -0
- package/dist/dashboard/dashboard/dashboard.service.d.ts.map +1 -0
- package/dist/dashboard/dashboard/dashboard.service.js +61 -0
- package/dist/dashboard/dashboard/dashboard.service.js.map +1 -0
- package/dist/dashboard/dashboard/dto/create.dto.d.ts +5 -0
- package/dist/dashboard/dashboard/dto/create.dto.d.ts.map +1 -0
- package/dist/dashboard/dashboard/dto/create.dto.js +23 -0
- package/dist/dashboard/dashboard/dto/create.dto.js.map +1 -0
- package/dist/dashboard/dashboard/dto/update.dto.d.ts +6 -0
- package/dist/dashboard/dashboard/dto/update.dto.d.ts.map +1 -0
- package/dist/dashboard/dashboard/dto/update.dto.js +9 -0
- package/dist/dashboard/dashboard/dto/update.dto.js.map +1 -0
- package/dist/dashboard/dashboard-component/dashboard-component.controller.d.ts +24 -0
- package/dist/dashboard/dashboard-component/dashboard-component.controller.d.ts.map +1 -0
- package/dist/dashboard/dashboard-component/dashboard-component.controller.js +90 -0
- package/dist/dashboard/dashboard-component/dashboard-component.controller.js.map +1 -0
- package/dist/dashboard/dashboard-component/dashboard-component.module.d.ts +3 -0
- package/dist/dashboard/dashboard-component/dashboard-component.module.d.ts.map +1 -0
- package/dist/dashboard/dashboard-component/dashboard-component.module.js +26 -0
- package/dist/dashboard/dashboard-component/dashboard-component.module.js.map +1 -0
- package/dist/dashboard/dashboard-component/dashboard-component.service.d.ts +32 -0
- package/dist/dashboard/dashboard-component/dashboard-component.service.d.ts.map +1 -0
- package/dist/dashboard/dashboard-component/dashboard-component.service.js +59 -0
- package/dist/dashboard/dashboard-component/dashboard-component.service.js.map +1 -0
- package/dist/dashboard/dashboard-component/dto/create.dto.d.ts +13 -0
- package/dist/dashboard/dashboard-component/dto/create.dto.d.ts.map +1 -0
- package/dist/dashboard/dashboard-component/dto/create.dto.js +59 -0
- package/dist/dashboard/dashboard-component/dto/create.dto.js.map +1 -0
- package/dist/dashboard/dashboard-component/dto/update.dto.d.ts +6 -0
- package/dist/dashboard/dashboard-component/dto/update.dto.d.ts.map +1 -0
- package/dist/dashboard/dashboard-component/dto/update.dto.js +9 -0
- package/dist/dashboard/dashboard-component/dto/update.dto.js.map +1 -0
- package/dist/dashboard/dashboard-core/dashboard-core.controller.d.ts +52 -0
- package/dist/dashboard/dashboard-core/dashboard-core.controller.d.ts.map +1 -0
- package/dist/dashboard/dashboard-core/dashboard-core.controller.js +40 -0
- package/dist/dashboard/dashboard-core/dashboard-core.controller.js.map +1 -0
- package/dist/dashboard/dashboard-core/dashboard-core.module.d.ts +3 -0
- package/dist/dashboard/dashboard-core/dashboard-core.module.d.ts.map +1 -0
- package/dist/dashboard/dashboard-core/dashboard-core.module.js +26 -0
- package/dist/dashboard/dashboard-core/dashboard-core.module.js.map +1 -0
- package/dist/dashboard/dashboard-core/dashboard-core.service.d.ts +52 -0
- package/dist/dashboard/dashboard-core/dashboard-core.service.d.ts.map +1 -0
- package/dist/dashboard/dashboard-core/dashboard-core.service.js +44 -0
- package/dist/dashboard/dashboard-core/dashboard-core.service.js.map +1 -0
- package/dist/dashboard/dashboard-item/dashboard-item.controller.d.ts +54 -0
- package/dist/dashboard/dashboard-item/dashboard-item.controller.d.ts.map +1 -0
- package/dist/dashboard/dashboard-item/dashboard-item.controller.js +88 -0
- package/dist/dashboard/dashboard-item/dashboard-item.controller.js.map +1 -0
- package/dist/dashboard/dashboard-item/dashboard-item.module.d.ts +3 -0
- package/dist/dashboard/dashboard-item/dashboard-item.module.d.ts.map +1 -0
- package/dist/dashboard/dashboard-item/dashboard-item.module.js +26 -0
- package/dist/dashboard/dashboard-item/dashboard-item.module.js.map +1 -0
- package/dist/dashboard/dashboard-item/dashboard-item.service.d.ts +59 -0
- package/dist/dashboard/dashboard-item/dashboard-item.service.d.ts.map +1 -0
- package/dist/dashboard/dashboard-item/dashboard-item.service.js +77 -0
- package/dist/dashboard/dashboard-item/dashboard-item.service.js.map +1 -0
- package/dist/dashboard/dashboard-item/dto/create.dto.d.ts +9 -0
- package/dist/dashboard/dashboard-item/dto/create.dto.d.ts.map +1 -0
- package/dist/dashboard/dashboard-item/dto/create.dto.js +41 -0
- package/dist/dashboard/dashboard-item/dto/create.dto.js.map +1 -0
- package/dist/dashboard/dashboard-item/dto/update.dto.d.ts +6 -0
- package/dist/dashboard/dashboard-item/dto/update.dto.d.ts.map +1 -0
- package/dist/dashboard/dashboard-item/dto/update.dto.js +9 -0
- package/dist/dashboard/dashboard-item/dto/update.dto.js.map +1 -0
- package/dist/dashboard/dashboard-user/dashboard-user.controller.d.ts +54 -0
- package/dist/dashboard/dashboard-user/dashboard-user.controller.d.ts.map +1 -0
- package/dist/dashboard/dashboard-user/dashboard-user.controller.js +88 -0
- package/dist/dashboard/dashboard-user/dashboard-user.controller.js.map +1 -0
- package/dist/dashboard/dashboard-user/dashboard-user.module.d.ts +3 -0
- package/dist/dashboard/dashboard-user/dashboard-user.module.d.ts.map +1 -0
- package/dist/dashboard/dashboard-user/dashboard-user.module.js +26 -0
- package/dist/dashboard/dashboard-user/dashboard-user.module.js.map +1 -0
- package/dist/dashboard/dashboard-user/dashboard-user.service.d.ts +61 -0
- package/dist/dashboard/dashboard-user/dashboard-user.service.d.ts.map +1 -0
- package/dist/dashboard/dashboard-user/dashboard-user.service.js +83 -0
- package/dist/dashboard/dashboard-user/dashboard-user.service.js.map +1 -0
- package/dist/dashboard/dashboard-user/dto/create.dto.d.ts +10 -0
- package/dist/dashboard/dashboard-user/dto/create.dto.d.ts.map +1 -0
- package/dist/dashboard/dashboard-user/dto/create.dto.js +42 -0
- package/dist/dashboard/dashboard-user/dto/create.dto.js.map +1 -0
- package/dist/dashboard/dashboard-user/dto/update.dto.d.ts +6 -0
- package/dist/dashboard/dashboard-user/dto/update.dto.d.ts.map +1 -0
- package/dist/dashboard/dashboard-user/dto/update.dto.js +9 -0
- package/dist/dashboard/dashboard-user/dto/update.dto.js.map +1 -0
- package/dist/dashboard/dashboard.module.d.ts +3 -0
- package/dist/dashboard/dashboard.module.d.ts.map +1 -0
- package/dist/dashboard/dashboard.module.js +37 -0
- package/dist/dashboard/dashboard.module.js.map +1 -0
- package/dist/dashboard/index.d.ts +2 -0
- package/dist/dashboard/index.d.ts.map +1 -0
- package/dist/dashboard/index.js +18 -0
- package/dist/dashboard/index.js.map +1 -0
- package/dist/decorators/inject-locale.decorator.d.ts +2 -0
- package/dist/decorators/inject-locale.decorator.d.ts.map +1 -0
- package/dist/decorators/inject-locale.decorator.js +16 -0
- package/dist/decorators/inject-locale.decorator.js.map +1 -0
- package/dist/dto/delete.dto.d.ts +4 -0
- package/dist/dto/delete.dto.d.ts.map +1 -0
- package/dist/dto/delete.dto.js +23 -0
- package/dist/dto/delete.dto.js.map +1 -0
- package/dist/dto/update-ids.dto.d.ts +4 -0
- package/dist/dto/update-ids.dto.d.ts.map +1 -0
- package/dist/dto/update-ids.dto.js +27 -0
- package/dist/dto/update-ids.dto.js.map +1 -0
- package/dist/emails/index.d.ts +3 -0
- package/dist/emails/index.d.ts.map +1 -0
- package/dist/emails/index.js +19 -0
- package/dist/emails/index.js.map +1 -0
- package/dist/emails/lib.d.ts +8 -0
- package/dist/emails/lib.d.ts.map +1 -0
- package/dist/emails/lib.js +73 -0
- package/dist/emails/lib.js.map +1 -0
- package/dist/emails/templates.d.ts +17 -0
- package/dist/emails/templates.d.ts.map +1 -0
- package/dist/emails/templates.js +70 -0
- package/dist/emails/templates.js.map +1 -0
- package/dist/file/dto/delete.dto.d.ts +4 -0
- package/dist/file/dto/delete.dto.d.ts.map +1 -0
- package/dist/file/dto/delete.dto.js +23 -0
- package/dist/file/dto/delete.dto.js.map +1 -0
- package/dist/file/dto/upload.dto.d.ts +4 -0
- package/dist/file/dto/upload.dto.d.ts.map +1 -0
- package/dist/file/dto/upload.dto.js +22 -0
- package/dist/file/dto/upload.dto.js.map +1 -0
- package/dist/file/file.controller.d.ts +45 -0
- package/dist/file/file.controller.d.ts.map +1 -0
- package/dist/file/file.controller.js +112 -0
- package/dist/file/file.controller.js.map +1 -0
- package/dist/file/file.module.d.ts +3 -0
- package/dist/file/file.module.d.ts.map +1 -0
- package/dist/file/file.module.js +40 -0
- package/dist/file/file.module.js.map +1 -0
- package/dist/file/file.service.d.ts +92 -0
- package/dist/file/file.service.d.ts.map +1 -0
- package/dist/file/file.service.js +260 -0
- package/dist/file/file.service.js.map +1 -0
- package/dist/file/provider/abstract.provider.d.ts +25 -0
- package/dist/file/provider/abstract.provider.d.ts.map +1 -0
- package/dist/file/provider/abstract.provider.js +15 -0
- package/dist/file/provider/abstract.provider.js.map +1 -0
- package/dist/file/provider/azure.provider.d.ts +16 -0
- package/dist/file/provider/azure.provider.d.ts.map +1 -0
- package/dist/file/provider/azure.provider.js +102 -0
- package/dist/file/provider/azure.provider.js.map +1 -0
- package/dist/file/provider/gcs.provider.d.ts +17 -0
- package/dist/file/provider/gcs.provider.d.ts.map +1 -0
- package/dist/file/provider/gcs.provider.js +86 -0
- package/dist/file/provider/gcs.provider.js.map +1 -0
- package/dist/file/provider/local.provider.d.ts +16 -0
- package/dist/file/provider/local.provider.d.ts.map +1 -0
- package/dist/file/provider/local.provider.js +138 -0
- package/dist/file/provider/local.provider.js.map +1 -0
- package/dist/file/provider/provider.enum.d.ts +7 -0
- package/dist/file/provider/provider.enum.d.ts.map +1 -0
- package/dist/file/provider/provider.enum.js +11 -0
- package/dist/file/provider/provider.enum.js.map +1 -0
- package/dist/file/provider/provider.factory.d.ts +6 -0
- package/dist/file/provider/provider.factory.d.ts.map +1 -0
- package/dist/file/provider/provider.factory.js +21 -0
- package/dist/file/provider/provider.factory.js.map +1 -0
- package/dist/file/provider/s3.provider.d.ts +20 -0
- package/dist/file/provider/s3.provider.d.ts.map +1 -0
- package/dist/file/provider/s3.provider.js +183 -0
- package/dist/file/provider/s3.provider.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/install/dto/generate-migration.dto.d.ts +12 -0
- package/dist/install/dto/generate-migration.dto.d.ts.map +1 -0
- package/dist/install/dto/generate-migration.dto.js +51 -0
- package/dist/install/dto/generate-migration.dto.js.map +1 -0
- package/dist/install/dto/install.dto.d.ts +8 -0
- package/dist/install/dto/install.dto.d.ts.map +1 -0
- package/dist/install/dto/install.dto.js +46 -0
- package/dist/install/dto/install.dto.js.map +1 -0
- package/dist/install/install.controller.d.ts +19 -0
- package/dist/install/install.controller.d.ts.map +1 -0
- package/dist/install/install.controller.js +61 -0
- package/dist/install/install.controller.js.map +1 -0
- package/dist/install/install.module.d.ts +3 -0
- package/dist/install/install.module.d.ts.map +1 -0
- package/dist/install/install.module.js +32 -0
- package/dist/install/install.module.js.map +1 -0
- package/dist/install/install.service.d.ts +35 -0
- package/dist/install/install.service.d.ts.map +1 -0
- package/dist/install/install.service.js +332 -0
- package/dist/install/install.service.js.map +1 -0
- package/dist/mail/dto/create.dto.d.ts +15 -0
- package/dist/mail/dto/create.dto.d.ts.map +1 -0
- package/dist/mail/dto/create.dto.js +52 -0
- package/dist/mail/dto/create.dto.js.map +1 -0
- package/dist/mail/dto/send.dto.d.ts +6 -0
- package/dist/mail/dto/send.dto.d.ts.map +1 -0
- package/dist/mail/dto/send.dto.js +31 -0
- package/dist/mail/dto/send.dto.js.map +1 -0
- package/dist/mail/dto/test-mail.dto.d.ts +7 -0
- package/dist/mail/dto/test-mail.dto.d.ts.map +1 -0
- package/dist/mail/dto/test-mail.dto.js +37 -0
- package/dist/mail/dto/test-mail.dto.js.map +1 -0
- package/dist/mail/dto/update.dto.d.ts +6 -0
- package/dist/mail/dto/update.dto.d.ts.map +1 -0
- package/dist/mail/dto/update.dto.js +9 -0
- package/dist/mail/dto/update.dto.js.map +1 -0
- package/dist/mail/mail.controller.d.ts +89 -0
- package/dist/mail/mail.controller.d.ts.map +1 -0
- package/dist/mail/mail.controller.js +104 -0
- package/dist/mail/mail.controller.js.map +1 -0
- package/dist/mail/mail.module.d.ts +3 -0
- package/dist/mail/mail.module.d.ts.map +1 -0
- package/dist/mail/mail.module.js +113 -0
- package/dist/mail/mail.module.js.map +1 -0
- package/dist/mail/mail.service.d.ts +122 -0
- package/dist/mail/mail.service.d.ts.map +1 -0
- package/dist/mail/mail.service.js +356 -0
- package/dist/mail/mail.service.js.map +1 -0
- package/dist/mail-sent/dto/create.dto.d.ts +10 -0
- package/dist/mail-sent/dto/create.dto.d.ts.map +1 -0
- package/dist/mail-sent/dto/create.dto.js +70 -0
- package/dist/mail-sent/dto/create.dto.js.map +1 -0
- package/dist/mail-sent/dto/update.dto.d.ts +6 -0
- package/dist/mail-sent/dto/update.dto.d.ts.map +1 -0
- package/dist/mail-sent/dto/update.dto.js +9 -0
- package/dist/mail-sent/dto/update.dto.js.map +1 -0
- package/dist/mail-sent/mail-sent.controller.d.ts +57 -0
- package/dist/mail-sent/mail-sent.controller.d.ts.map +1 -0
- package/dist/mail-sent/mail-sent.controller.js +88 -0
- package/dist/mail-sent/mail-sent.controller.js.map +1 -0
- package/dist/mail-sent/mail-sent.module.d.ts +3 -0
- package/dist/mail-sent/mail-sent.module.d.ts.map +1 -0
- package/dist/mail-sent/mail-sent.module.js +26 -0
- package/dist/mail-sent/mail-sent.module.js.map +1 -0
- package/dist/mail-sent/mail-sent.service.d.ts +62 -0
- package/dist/mail-sent/mail-sent.service.d.ts.map +1 -0
- package/dist/mail-sent/mail-sent.service.js +93 -0
- package/dist/mail-sent/mail-sent.service.js.map +1 -0
- package/dist/mail-var/dto/create.dto.d.ts +5 -0
- package/dist/mail-var/dto/create.dto.d.ts.map +1 -0
- package/dist/mail-var/dto/create.dto.js +25 -0
- package/dist/mail-var/dto/create.dto.js.map +1 -0
- package/dist/mail-var/dto/update.dto.d.ts +6 -0
- package/dist/mail-var/dto/update.dto.d.ts.map +1 -0
- package/dist/mail-var/dto/update.dto.js +9 -0
- package/dist/mail-var/dto/update.dto.js.map +1 -0
- package/dist/mail-var/mail-var.controller.d.ts +42 -0
- package/dist/mail-var/mail-var.controller.d.ts.map +1 -0
- package/dist/mail-var/mail-var.controller.js +88 -0
- package/dist/mail-var/mail-var.controller.js.map +1 -0
- package/dist/mail-var/mail-var.module.d.ts +3 -0
- package/dist/mail-var/mail-var.module.d.ts.map +1 -0
- package/dist/mail-var/mail-var.module.js +26 -0
- package/dist/mail-var/mail-var.module.js.map +1 -0
- package/dist/mail-var/mail-var.service.d.ts +47 -0
- package/dist/mail-var/mail-var.service.d.ts.map +1 -0
- package/dist/mail-var/mail-var.service.js +73 -0
- package/dist/mail-var/mail-var.service.js.map +1 -0
- package/dist/menu/dto/create.dto.d.ts +8 -0
- package/dist/menu/dto/create.dto.d.ts.map +1 -0
- package/dist/menu/dto/create.dto.js +45 -0
- package/dist/menu/dto/create.dto.js.map +1 -0
- package/dist/menu/dto/order.dto.d.ts +4 -0
- package/dist/menu/dto/order.dto.d.ts.map +1 -0
- package/dist/menu/dto/order.dto.js +23 -0
- package/dist/menu/dto/order.dto.js.map +1 -0
- package/dist/menu/dto/update.dto.d.ts +7 -0
- package/dist/menu/dto/update.dto.d.ts.map +1 -0
- package/dist/menu/dto/update.dto.js +38 -0
- package/dist/menu/dto/update.dto.js.map +1 -0
- package/dist/menu/menu.controller.d.ts +81 -0
- package/dist/menu/menu.controller.d.ts.map +1 -0
- package/dist/menu/menu.controller.js +160 -0
- package/dist/menu/menu.controller.js.map +1 -0
- package/dist/menu/menu.module.d.ts +3 -0
- package/dist/menu/menu.module.d.ts.map +1 -0
- package/dist/menu/menu.module.js +31 -0
- package/dist/menu/menu.module.js.map +1 -0
- package/dist/menu/menu.service.d.ts +85 -0
- package/dist/menu/menu.service.d.ts.map +1 -0
- package/dist/menu/menu.service.js +223 -0
- package/dist/menu/menu.service.js.map +1 -0
- package/dist/menu/menu.service.spec.d.ts +1 -0
- package/dist/menu/menu.service.spec.d.ts.map +1 -0
- package/dist/menu/menu.service.spec.js +208 -0
- package/dist/menu/menu.service.spec.js.map +1 -0
- package/dist/middlewares/locale-injection.middleware.d.ts +6 -0
- package/dist/middlewares/locale-injection.middleware.d.ts.map +1 -0
- package/dist/middlewares/locale-injection.middleware.js +25 -0
- package/dist/middlewares/locale-injection.middleware.js.map +1 -0
- package/dist/oauth/interfaces/OAuthProvider.d.ts +6 -0
- package/dist/oauth/interfaces/OAuthProvider.d.ts.map +1 -0
- package/dist/oauth/interfaces/OAuthProvider.js +3 -0
- package/dist/oauth/interfaces/OAuthProvider.js.map +1 -0
- package/dist/oauth/oauth.controller.d.ts +27 -0
- package/dist/oauth/oauth.controller.d.ts.map +1 -0
- package/dist/oauth/oauth.controller.js +151 -0
- package/dist/oauth/oauth.controller.js.map +1 -0
- package/dist/oauth/oauth.module.d.ts +3 -0
- package/dist/oauth/oauth.module.d.ts.map +1 -0
- package/dist/oauth/oauth.module.js +49 -0
- package/dist/oauth/oauth.module.js.map +1 -0
- package/dist/oauth/oauth.service.d.ts +51 -0
- package/dist/oauth/oauth.service.d.ts.map +1 -0
- package/dist/oauth/oauth.service.js +294 -0
- package/dist/oauth/oauth.service.js.map +1 -0
- package/dist/oauth/providers/abstract.provider.d.ts +18 -0
- package/dist/oauth/providers/abstract.provider.d.ts.map +1 -0
- package/dist/oauth/providers/abstract.provider.js +30 -0
- package/dist/oauth/providers/abstract.provider.js.map +1 -0
- package/dist/oauth/providers/facebook.provider.d.ts +14 -0
- package/dist/oauth/providers/facebook.provider.d.ts.map +1 -0
- package/dist/oauth/providers/facebook.provider.js +73 -0
- package/dist/oauth/providers/facebook.provider.js.map +1 -0
- package/dist/oauth/providers/github.provider.d.ts +25 -0
- package/dist/oauth/providers/github.provider.d.ts.map +1 -0
- package/dist/oauth/providers/github.provider.js +105 -0
- package/dist/oauth/providers/github.provider.js.map +1 -0
- package/dist/oauth/providers/google.provider.d.ts +15 -0
- package/dist/oauth/providers/google.provider.d.ts.map +1 -0
- package/dist/oauth/providers/google.provider.js +94 -0
- package/dist/oauth/providers/google.provider.js.map +1 -0
- package/dist/oauth/providers/microsoft.provider.d.ts +14 -0
- package/dist/oauth/providers/microsoft.provider.d.ts.map +1 -0
- package/dist/oauth/providers/microsoft.provider.js +81 -0
- package/dist/oauth/providers/microsoft.provider.js.map +1 -0
- package/dist/profile/dto/change-password.dto.d.ts +5 -0
- package/dist/profile/dto/change-password.dto.d.ts.map +1 -0
- package/dist/profile/dto/change-password.dto.js +32 -0
- package/dist/profile/dto/change-password.dto.js.map +1 -0
- package/dist/profile/dto/email-verification-confirm.dto.d.ts +7 -0
- package/dist/profile/dto/email-verification-confirm.dto.d.ts.map +1 -0
- package/dist/profile/dto/email-verification-confirm.dto.js +36 -0
- package/dist/profile/dto/email-verification-confirm.dto.js.map +1 -0
- package/dist/profile/dto/generate-webauthn-registration-options.dto.d.ts +4 -0
- package/dist/profile/dto/generate-webauthn-registration-options.dto.d.ts.map +1 -0
- package/dist/profile/dto/generate-webauthn-registration-options.dto.js +22 -0
- package/dist/profile/dto/generate-webauthn-registration-options.dto.js.map +1 -0
- package/dist/profile/dto/regenerate-recovery-codes.dto.d.ts +7 -0
- package/dist/profile/dto/regenerate-recovery-codes.dto.d.ts.map +1 -0
- package/dist/profile/dto/regenerate-recovery-codes.dto.js +36 -0
- package/dist/profile/dto/regenerate-recovery-codes.dto.js.map +1 -0
- package/dist/profile/dto/remove-email-mfa.dto.d.ts +5 -0
- package/dist/profile/dto/remove-email-mfa.dto.d.ts.map +1 -0
- package/dist/profile/dto/remove-email-mfa.dto.js +27 -0
- package/dist/profile/dto/remove-email-mfa.dto.js.map +1 -0
- package/dist/profile/dto/remove-mfa-with-recovery-code.dto.d.ts +4 -0
- package/dist/profile/dto/remove-mfa-with-recovery-code.dto.d.ts.map +1 -0
- package/dist/profile/dto/remove-mfa-with-recovery-code.dto.js +22 -0
- package/dist/profile/dto/remove-mfa-with-recovery-code.dto.js.map +1 -0
- package/dist/profile/dto/remove-mfa.dto.d.ts +7 -0
- package/dist/profile/dto/remove-mfa.dto.d.ts.map +1 -0
- package/dist/profile/dto/remove-mfa.dto.js +36 -0
- package/dist/profile/dto/remove-mfa.dto.js.map +1 -0
- package/dist/profile/dto/remove-totp-mfa.dto.d.ts +4 -0
- package/dist/profile/dto/remove-totp-mfa.dto.d.ts.map +1 -0
- package/dist/profile/dto/remove-totp-mfa.dto.js +22 -0
- package/dist/profile/dto/remove-totp-mfa.dto.js.map +1 -0
- package/dist/profile/dto/send-email-verification.dto.d.ts +4 -0
- package/dist/profile/dto/send-email-verification.dto.d.ts.map +1 -0
- package/dist/profile/dto/send-email-verification.dto.js +24 -0
- package/dist/profile/dto/send-email-verification.dto.js.map +1 -0
- package/dist/profile/dto/set-preferences.dto.d.ts +5 -0
- package/dist/profile/dto/set-preferences.dto.d.ts.map +1 -0
- package/dist/profile/dto/set-preferences.dto.js +27 -0
- package/dist/profile/dto/set-preferences.dto.js.map +1 -0
- package/dist/profile/dto/update.dto.d.ts +4 -0
- package/dist/profile/dto/update.dto.d.ts.map +1 -0
- package/dist/profile/dto/update.dto.js +24 -0
- package/dist/profile/dto/update.dto.js.map +1 -0
- package/dist/profile/dto/verify-before-add-mfa.dto.d.ts +7 -0
- package/dist/profile/dto/verify-before-add-mfa.dto.d.ts.map +1 -0
- package/dist/profile/dto/verify-before-add-mfa.dto.js +34 -0
- package/dist/profile/dto/verify-before-add-mfa.dto.js.map +1 -0
- package/dist/profile/dto/verify-mfa-totp.dto.d.ts +6 -0
- package/dist/profile/dto/verify-mfa-totp.dto.d.ts.map +1 -0
- package/dist/profile/dto/verify-mfa-totp.dto.js +35 -0
- package/dist/profile/dto/verify-mfa-totp.dto.js.map +1 -0
- package/dist/profile/dto/verify-webauthn-registration.dto.d.ts +5 -0
- package/dist/profile/dto/verify-webauthn-registration.dto.d.ts.map +1 -0
- package/dist/profile/dto/verify-webauthn-registration.dto.js +27 -0
- package/dist/profile/dto/verify-webauthn-registration.dto.js.map +1 -0
- package/dist/profile/dto/verify-webauthn.dto.d.ts +4 -0
- package/dist/profile/dto/verify-webauthn.dto.d.ts.map +1 -0
- package/dist/profile/dto/verify-webauthn.dto.js +22 -0
- package/dist/profile/dto/verify-webauthn.dto.js.map +1 -0
- package/dist/profile/profile.controller.d.ts +264 -0
- package/dist/profile/profile.controller.d.ts.map +1 -0
- package/dist/profile/profile.controller.js +359 -0
- package/dist/profile/profile.controller.js.map +1 -0
- package/dist/profile/profile.module.d.ts +3 -0
- package/dist/profile/profile.module.d.ts.map +1 -0
- package/dist/profile/profile.module.js +34 -0
- package/dist/profile/profile.module.js.map +1 -0
- package/dist/profile/profile.service.d.ts +242 -0
- package/dist/profile/profile.service.d.ts.map +1 -0
- package/dist/profile/profile.service.js +1158 -0
- package/dist/profile/profile.service.js.map +1 -0
- package/dist/role/dto/create.dto.d.ts +5 -0
- package/dist/role/dto/create.dto.d.ts.map +1 -0
- package/dist/role/dto/create.dto.js +22 -0
- package/dist/role/dto/create.dto.js.map +1 -0
- package/dist/role/dto/update.dto.d.ts +6 -0
- package/dist/role/dto/update.dto.d.ts.map +1 -0
- package/dist/role/dto/update.dto.js +9 -0
- package/dist/role/dto/update.dto.js.map +1 -0
- package/dist/role/guards/role.guard.d.ts +11 -0
- package/dist/role/guards/role.guard.d.ts.map +1 -0
- package/dist/role/guards/role.guard.js +116 -0
- package/dist/role/guards/role.guard.js.map +1 -0
- package/dist/role/role.controller.d.ts +73 -0
- package/dist/role/role.controller.d.ts.map +1 -0
- package/dist/role/role.controller.js +183 -0
- package/dist/role/role.controller.js.map +1 -0
- package/dist/role/role.module.d.ts +3 -0
- package/dist/role/role.module.d.ts.map +1 -0
- package/dist/role/role.module.js +42 -0
- package/dist/role/role.module.js.map +1 -0
- package/dist/role/role.service.d.ts +80 -0
- package/dist/role/role.service.d.ts.map +1 -0
- package/dist/role/role.service.js +241 -0
- package/dist/role/role.service.js.map +1 -0
- package/dist/route/dto/create.dto.d.ts +6 -0
- package/dist/route/dto/create.dto.d.ts.map +1 -0
- package/dist/route/dto/create.dto.js +29 -0
- package/dist/route/dto/create.dto.js.map +1 -0
- package/dist/route/dto/update.dto.d.ts +6 -0
- package/dist/route/dto/update.dto.d.ts.map +1 -0
- package/dist/route/dto/update.dto.js +31 -0
- package/dist/route/dto/update.dto.js.map +1 -0
- package/dist/route/route.controller.d.ts +50 -0
- package/dist/route/route.controller.d.ts.map +1 -0
- package/dist/route/route.controller.js +134 -0
- package/dist/route/route.controller.js.map +1 -0
- package/dist/route/route.module.d.ts +3 -0
- package/dist/route/route.module.d.ts.map +1 -0
- package/dist/route/route.module.js +31 -0
- package/dist/route/route.module.js.map +1 -0
- package/dist/route/route.service.d.ts +54 -0
- package/dist/route/route.service.d.ts.map +1 -0
- package/dist/route/route.service.js +142 -0
- package/dist/route/route.service.js.map +1 -0
- package/dist/route/route.service.spec.d.ts +1 -0
- package/dist/route/route.service.spec.d.ts.map +1 -0
- package/dist/route/route.service.spec.js +262 -0
- package/dist/route/route.service.spec.js.map +1 -0
- package/dist/screen/dto/create.dto.d.ts +5 -0
- package/dist/screen/dto/create.dto.d.ts.map +1 -0
- package/dist/screen/dto/create.dto.js +28 -0
- package/dist/screen/dto/create.dto.js.map +1 -0
- package/dist/screen/dto/update.dto.d.ts +7 -0
- package/dist/screen/dto/update.dto.d.ts.map +1 -0
- package/dist/screen/dto/update.dto.js +38 -0
- package/dist/screen/dto/update.dto.js.map +1 -0
- package/dist/screen/screen.controller.d.ts +67 -0
- package/dist/screen/screen.controller.d.ts.map +1 -0
- package/dist/screen/screen.controller.js +137 -0
- package/dist/screen/screen.controller.js.map +1 -0
- package/dist/screen/screen.module.d.ts +3 -0
- package/dist/screen/screen.module.d.ts.map +1 -0
- package/dist/screen/screen.module.js +31 -0
- package/dist/screen/screen.module.js.map +1 -0
- package/dist/screen/screen.service.d.ts +72 -0
- package/dist/screen/screen.service.d.ts.map +1 -0
- package/dist/screen/screen.service.js +153 -0
- package/dist/screen/screen.service.js.map +1 -0
- package/dist/screen/screen.service.spec.d.ts +1 -0
- package/dist/screen/screen.service.spec.d.ts.map +1 -0
- package/dist/screen/screen.service.spec.js +259 -0
- package/dist/screen/screen.service.spec.js.map +1 -0
- package/dist/security/security.module.d.ts +3 -0
- package/dist/security/security.module.d.ts.map +1 -0
- package/dist/security/security.module.js +23 -0
- package/dist/security/security.module.js.map +1 -0
- package/dist/security/security.service.d.ts +18 -0
- package/dist/security/security.service.d.ts.map +1 -0
- package/dist/security/security.service.js +141 -0
- package/dist/security/security.service.js.map +1 -0
- package/dist/session/session.controller.d.ts +33 -0
- package/dist/session/session.controller.d.ts.map +1 -0
- package/dist/session/session.controller.js +72 -0
- package/dist/session/session.controller.js.map +1 -0
- package/dist/session/session.module.d.ts +3 -0
- package/dist/session/session.module.d.ts.map +1 -0
- package/dist/session/session.module.js +39 -0
- package/dist/session/session.module.js.map +1 -0
- package/dist/session/session.service.d.ts +72 -0
- package/dist/session/session.service.d.ts.map +1 -0
- package/dist/session/session.service.js +199 -0
- package/dist/session/session.service.js.map +1 -0
- package/dist/setting/dto/confirm-import.dto.d.ts +7 -0
- package/dist/setting/dto/confirm-import.dto.d.ts.map +1 -0
- package/dist/setting/dto/confirm-import.dto.js +22 -0
- package/dist/setting/dto/confirm-import.dto.js.map +1 -0
- package/dist/setting/dto/create.dto.d.ts +9 -0
- package/dist/setting/dto/create.dto.d.ts.map +1 -0
- package/dist/setting/dto/create.dto.js +40 -0
- package/dist/setting/dto/create.dto.js.map +1 -0
- package/dist/setting/dto/delete.dto.d.ts +4 -0
- package/dist/setting/dto/delete.dto.d.ts.map +1 -0
- package/dist/setting/dto/delete.dto.js +23 -0
- package/dist/setting/dto/delete.dto.js.map +1 -0
- package/dist/setting/dto/export.dto.d.ts +4 -0
- package/dist/setting/dto/export.dto.d.ts.map +1 -0
- package/dist/setting/dto/export.dto.js +24 -0
- package/dist/setting/dto/export.dto.js.map +1 -0
- package/dist/setting/dto/import-validation.dto.d.ts +7 -0
- package/dist/setting/dto/import-validation.dto.d.ts.map +1 -0
- package/dist/setting/dto/import-validation.dto.js +7 -0
- package/dist/setting/dto/import-validation.dto.js.map +1 -0
- package/dist/setting/dto/setting-user.dto.d.ts +4 -0
- package/dist/setting/dto/setting-user.dto.d.ts.map +1 -0
- package/dist/setting/dto/setting-user.dto.js +21 -0
- package/dist/setting/dto/setting-user.dto.js.map +1 -0
- package/dist/setting/dto/setting.dto.d.ts +9 -0
- package/dist/setting/dto/setting.dto.d.ts.map +1 -0
- package/dist/setting/dto/setting.dto.js +34 -0
- package/dist/setting/dto/setting.dto.js.map +1 -0
- package/dist/setting/dto/update.dto.d.ts +6 -0
- package/dist/setting/dto/update.dto.d.ts.map +1 -0
- package/dist/setting/dto/update.dto.js +9 -0
- package/dist/setting/dto/update.dto.js.map +1 -0
- package/dist/setting/setting.controller.d.ts +126 -0
- package/dist/setting/setting.controller.d.ts.map +1 -0
- package/dist/setting/setting.controller.js +206 -0
- package/dist/setting/setting.controller.js.map +1 -0
- package/dist/setting/setting.module.d.ts +3 -0
- package/dist/setting/setting.module.d.ts.map +1 -0
- package/dist/setting/setting.module.js +34 -0
- package/dist/setting/setting.module.js.map +1 -0
- package/dist/setting/setting.service.d.ts +134 -0
- package/dist/setting/setting.service.d.ts.map +1 -0
- package/dist/setting/setting.service.js +570 -0
- package/dist/setting/setting.service.js.map +1 -0
- package/dist/task/task.module.d.ts +3 -0
- package/dist/task/task.module.d.ts.map +1 -0
- package/dist/task/task.module.js +22 -0
- package/dist/task/task.module.js.map +1 -0
- package/dist/task/task.service.d.ts +8 -0
- package/dist/task/task.service.d.ts.map +1 -0
- package/dist/task/task.service.js +75 -0
- package/dist/task/task.service.js.map +1 -0
- package/dist/token/token.module.d.ts +3 -0
- package/dist/token/token.module.d.ts.map +1 -0
- package/dist/token/token.module.js +27 -0
- package/dist/token/token.module.js.map +1 -0
- package/dist/token/token.service.d.ts +31 -0
- package/dist/token/token.service.d.ts.map +1 -0
- package/dist/token/token.service.js +121 -0
- package/dist/token/token.service.js.map +1 -0
- package/dist/types/http-method.d.ts +2 -0
- package/dist/types/http-method.d.ts.map +1 -0
- package/dist/types/http-method.js +3 -0
- package/dist/types/http-method.js.map +1 -0
- package/dist/types/multer.d.ts +26 -0
- package/dist/types/multer.d.ts.map +1 -0
- package/dist/types/multer.js +3 -0
- package/dist/types/multer.js.map +1 -0
- package/dist/user/constants/user.constants.d.ts +2 -0
- package/dist/user/constants/user.constants.d.ts.map +1 -0
- package/dist/user/constants/user.constants.js +5 -0
- package/dist/user/constants/user.constants.js.map +1 -0
- package/dist/user/dto/create-with-email-and-password.dto.d.ts +8 -0
- package/dist/user/dto/create-with-email-and-password.dto.d.ts.map +1 -0
- package/dist/user/dto/create-with-email-and-password.dto.js +39 -0
- package/dist/user/dto/create-with-email-and-password.dto.js.map +1 -0
- package/dist/user/dto/update.dto.d.ts +4 -0
- package/dist/user/dto/update.dto.d.ts.map +1 -0
- package/dist/user/dto/update.dto.js +23 -0
- package/dist/user/dto/update.dto.js.map +1 -0
- package/dist/user/user.controller.d.ts +115 -0
- package/dist/user/user.controller.d.ts.map +1 -0
- package/dist/user/user.controller.js +123 -0
- package/dist/user/user.controller.js.map +1 -0
- package/dist/user/user.module.d.ts +3 -0
- package/dist/user/user.module.d.ts.map +1 -0
- package/dist/user/user.module.js +47 -0
- package/dist/user/user.module.js.map +1 -0
- package/dist/user/user.service.d.ts +191 -0
- package/dist/user/user.service.d.ts.map +1 -0
- package/dist/user/user.service.js +243 -0
- package/dist/user/user.service.js.map +1 -0
- package/dist/user/user.service.spec.d.ts +1 -0
- package/dist/user/user.service.spec.d.ts.map +1 -0
- package/dist/user/user.service.spec.js +261 -0
- package/dist/user/user.service.spec.js.map +1 -0
- package/dist/utils/locale-context.d.ts +8 -0
- package/dist/utils/locale-context.d.ts.map +1 -0
- package/dist/utils/locale-context.js +11 -0
- package/dist/utils/locale-context.js.map +1 -0
- package/dist/validators/is-email-with-settings.validator.d.ts +10 -0
- package/dist/validators/is-email-with-settings.validator.d.ts.map +1 -0
- package/dist/validators/is-email-with-settings.validator.js +80 -0
- package/dist/validators/is-email-with-settings.validator.js.map +1 -0
- package/dist/validators/is-pin-code-with-setting.validator.d.ts +11 -0
- package/dist/validators/is-pin-code-with-setting.validator.d.ts.map +1 -0
- package/dist/validators/is-pin-code-with-setting.validator.js +73 -0
- package/dist/validators/is-pin-code-with-setting.validator.js.map +1 -0
- package/dist/validators/is-strong-password-with-settings.validator.d.ts +12 -0
- package/dist/validators/is-strong-password-with-settings.validator.d.ts.map +1 -0
- package/dist/validators/is-strong-password-with-settings.validator.js +108 -0
- package/dist/validators/is-strong-password-with-settings.validator.js.map +1 -0
- package/hedhog/data/dashboard.yaml +1 -0
- package/hedhog/data/dashboard_component.yaml +28 -0
- package/hedhog/data/dashboard_item.yaml +40 -0
- package/hedhog/data/file_mimetype.yaml +27 -0
- package/hedhog/data/file_provider.yaml +12 -0
- package/hedhog/data/locale.yaml +6 -0
- package/hedhog/data/mail.yaml +192 -0
- package/hedhog/data/menu.yaml +41 -0
- package/hedhog/data/role.yaml +21 -0
- package/hedhog/data/route.yaml +802 -0
- package/hedhog/data/setting_group.yaml +996 -0
- package/hedhog/data/translation_namespace.yaml +33 -0
- package/hedhog/query/user_mfa_challenge_active_idx.sql +4 -0
- package/hedhog/query/user_mfa_validate_triggers.sql +56 -0
- package/hedhog/table/dashboard.yaml +11 -0
- package/hedhog/table/dashboard_component.yaml +39 -0
- package/hedhog/table/dashboard_item.yaml +24 -0
- package/hedhog/table/dashboard_user.yaml +24 -0
- package/hedhog/table/file.yaml +23 -0
- package/hedhog/table/file_mimetype.yaml +5 -0
- package/hedhog/table/file_provider.yaml +10 -0
- package/hedhog/table/locale.yaml +15 -0
- package/hedhog/table/mail.yaml +15 -0
- package/hedhog/table/mail_sent.yaml +21 -0
- package/hedhog/table/mail_var.yaml +12 -0
- package/hedhog/table/menu.yaml +25 -0
- package/hedhog/table/menu_screen.yaml +16 -0
- package/hedhog/table/role.yaml +18 -0
- package/hedhog/table/role_menu.yaml +18 -0
- package/hedhog/table/role_route.yaml +18 -0
- package/hedhog/table/role_screen.yaml +18 -0
- package/hedhog/table/role_user.yaml +18 -0
- package/hedhog/table/route.yaml +22 -0
- package/hedhog/table/route_screen.yaml +18 -0
- package/hedhog/table/screen.yaml +20 -0
- package/hedhog/table/setting.yaml +54 -0
- package/hedhog/table/setting_group.yaml +20 -0
- package/hedhog/table/setting_list.yaml +16 -0
- package/hedhog/table/setting_user.yaml +21 -0
- package/hedhog/table/translation.yaml +24 -0
- package/hedhog/table/translation_namespace.yaml +5 -0
- package/hedhog/table/user.yaml +23 -0
- package/hedhog/table/user_account.yaml +29 -0
- package/hedhog/table/user_activity.yaml +13 -0
- package/hedhog/table/user_credential.yaml +24 -0
- package/hedhog/table/user_identifier.yaml +23 -0
- package/hedhog/table/user_mfa.yaml +23 -0
- package/hedhog/table/user_mfa_challenge.yaml +19 -0
- package/hedhog/table/user_mfa_email.yaml +11 -0
- package/hedhog/table/user_mfa_phone.yaml +11 -0
- package/hedhog/table/user_mfa_totp.yaml +12 -0
- package/hedhog/table/user_mfa_webauthn.yaml +19 -0
- package/hedhog/table/user_recovery_code.yaml +16 -0
- package/hedhog/table/user_session.yaml +18 -0
- package/package.json +72 -0
- package/src/auth/auth.controller.ts +215 -0
- package/src/auth/auth.module.ts +106 -0
- package/src/auth/auth.service.ts +554 -0
- package/src/auth/consts/body.ts +27 -0
- package/src/auth/dto/change.dto.ts +36 -0
- package/src/auth/dto/create-user.dto.ts +37 -0
- package/src/auth/dto/email.dto.ts +16 -0
- package/src/auth/dto/forget.dto.ts +13 -0
- package/src/auth/dto/login-with-code.dto.ts +14 -0
- package/src/auth/dto/login-with-recovery-code.ts +10 -0
- package/src/auth/dto/login.dto.ts +33 -0
- package/src/auth/dto/resend-mfa-code.dto.ts +6 -0
- package/src/auth/dto/reset.dto.ts +13 -0
- package/src/auth/enums/multifactor-type.enum.ts +4 -0
- package/src/auth/guards/auth.guard.ts +59 -0
- package/src/challenge/challenge.module.ts +20 -0
- package/src/challenge/challenge.service.ts +327 -0
- package/src/core/system.controller.ts +15 -0
- package/src/core/system.module.ts +17 -0
- package/src/core/system.service.ts +296 -0
- package/src/core.module.ts +89 -0
- package/src/dashboard/dashboard/dashboard.controller.ts +49 -0
- package/src/dashboard/dashboard/dashboard.module.ts +13 -0
- package/src/dashboard/dashboard/dashboard.service.ts +71 -0
- package/src/dashboard/dashboard/dto/create.dto.ts +8 -0
- package/src/dashboard/dashboard/dto/update.dto.ts +4 -0
- package/src/dashboard/dashboard-component/dashboard-component.controller.ts +55 -0
- package/src/dashboard/dashboard-component/dashboard-component.module.ts +14 -0
- package/src/dashboard/dashboard-component/dashboard-component.service.ts +70 -0
- package/src/dashboard/dashboard-component/dto/create.dto.ts +36 -0
- package/src/dashboard/dashboard-component/dto/update.dto.ts +4 -0
- package/src/dashboard/dashboard-core/dashboard-core.controller.ts +13 -0
- package/src/dashboard/dashboard-core/dashboard-core.module.ts +14 -0
- package/src/dashboard/dashboard-core/dashboard-core.service.ts +27 -0
- package/src/dashboard/dashboard-item/dashboard-item.controller.ts +55 -0
- package/src/dashboard/dashboard-item/dashboard-item.module.ts +13 -0
- package/src/dashboard/dashboard-item/dashboard-item.service.ts +82 -0
- package/src/dashboard/dashboard-item/dto/create.dto.ts +22 -0
- package/src/dashboard/dashboard-item/dto/update.dto.ts +4 -0
- package/src/dashboard/dashboard-user/dashboard-user.controller.ts +55 -0
- package/src/dashboard/dashboard-user/dashboard-user.module.ts +13 -0
- package/src/dashboard/dashboard-user/dashboard-user.service.ts +89 -0
- package/src/dashboard/dashboard-user/dto/create.dto.ts +22 -0
- package/src/dashboard/dashboard-user/dto/update.dto.ts +4 -0
- package/src/dashboard/dashboard.module.ts +24 -0
- package/src/dashboard/index.ts +1 -0
- package/src/decorators/inject-locale.decorator.ts +17 -0
- package/src/dto/delete.dto.ts +8 -0
- package/src/dto/update-ids.dto.ts +12 -0
- package/src/emails/index.ts +2 -0
- package/src/emails/lib.ts +70 -0
- package/src/emails/templates.ts +73 -0
- package/src/file/dto/delete.dto.ts +8 -0
- package/src/file/dto/upload.dto.ts +7 -0
- package/src/file/file.controller.ts +78 -0
- package/src/file/file.module.ts +29 -0
- package/src/file/file.service.ts +339 -0
- package/src/file/provider/abstract.provider.ts +43 -0
- package/src/file/provider/azure.provider.ts +174 -0
- package/src/file/provider/gcs.provider.ts +108 -0
- package/src/file/provider/local.provider.ts +141 -0
- package/src/file/provider/provider.enum.ts +6 -0
- package/src/file/provider/provider.factory.ts +21 -0
- package/src/file/provider/s3.provider.ts +204 -0
- package/src/index.ts +26 -0
- package/src/install/dto/generate-migration.dto.ts +31 -0
- package/src/install/dto/install.dto.ts +27 -0
- package/src/install/install.controller.ts +26 -0
- package/src/install/install.module.ts +19 -0
- package/src/install/install.service.ts +345 -0
- package/src/language/en.json +112 -0
- package/src/language/pt.json +112 -0
- package/src/mail/dto/create.dto.ts +40 -0
- package/src/mail/dto/send.dto.ts +14 -0
- package/src/mail/dto/test-mail.dto.ts +19 -0
- package/src/mail/dto/update.dto.ts +4 -0
- package/src/mail/mail.controller.ts +67 -0
- package/src/mail/mail.module.ts +107 -0
- package/src/mail/mail.service.ts +371 -0
- package/src/mail-sent/dto/create.dto.ts +43 -0
- package/src/mail-sent/dto/update.dto.ts +4 -0
- package/src/mail-sent/mail-sent.controller.ts +55 -0
- package/src/mail-sent/mail-sent.module.ts +13 -0
- package/src/mail-sent/mail-sent.service.ts +103 -0
- package/src/mail-var/dto/create.dto.ts +9 -0
- package/src/mail-var/dto/update.dto.ts +4 -0
- package/src/mail-var/mail-var.controller.ts +55 -0
- package/src/mail-var/mail-var.module.ts +13 -0
- package/src/mail-var/mail-var.service.ts +78 -0
- package/src/menu/dto/create.dto.ts +26 -0
- package/src/menu/dto/order.dto.ts +8 -0
- package/src/menu/dto/update.dto.ts +20 -0
- package/src/menu/menu.controller.ts +105 -0
- package/src/menu/menu.module.ts +18 -0
- package/src/menu/menu.service.spec.ts +247 -0
- package/src/menu/menu.service.ts +264 -0
- package/src/middlewares/locale-injection.middleware.ts +15 -0
- package/src/oauth/interfaces/OAuthProvider.ts +5 -0
- package/src/oauth/oauth.controller.ts +116 -0
- package/src/oauth/oauth.module.ts +36 -0
- package/src/oauth/oauth.service.ts +364 -0
- package/src/oauth/providers/abstract.provider.ts +50 -0
- package/src/oauth/providers/facebook.provider.ts +69 -0
- package/src/oauth/providers/github.provider.ts +113 -0
- package/src/oauth/providers/google.provider.ts +108 -0
- package/src/oauth/providers/microsoft.provider.ts +76 -0
- package/src/profile/dto/change-password.dto.ts +16 -0
- package/src/profile/dto/email-verification-confirm.dto.ts +19 -0
- package/src/profile/dto/generate-webauthn-registration-options.dto.ts +7 -0
- package/src/profile/dto/regenerate-recovery-codes.dto.ts +18 -0
- package/src/profile/dto/remove-email-mfa.dto.ts +11 -0
- package/src/profile/dto/remove-mfa-with-recovery-code.dto.ts +7 -0
- package/src/profile/dto/remove-mfa.dto.ts +18 -0
- package/src/profile/dto/remove-totp-mfa.dto.ts +7 -0
- package/src/profile/dto/send-email-verification.dto.ts +9 -0
- package/src/profile/dto/set-preferences.dto.ts +11 -0
- package/src/profile/dto/update.dto.ts +10 -0
- package/src/profile/dto/verify-before-add-mfa.dto.ts +16 -0
- package/src/profile/dto/verify-mfa-totp.dto.ts +19 -0
- package/src/profile/dto/verify-webauthn-registration.dto.ts +11 -0
- package/src/profile/dto/verify-webauthn.dto.ts +7 -0
- package/src/profile/profile.controller.ts +201 -0
- package/src/profile/profile.module.ts +21 -0
- package/src/profile/profile.service.ts +1331 -0
- package/src/role/dto/create.dto.ts +7 -0
- package/src/role/dto/update.dto.ts +4 -0
- package/src/role/guards/role.guard.ts +121 -0
- package/src/role/role.controller.ts +126 -0
- package/src/role/role.module.ts +29 -0
- package/src/role/role.service.ts +289 -0
- package/src/route/dto/create.dto.ts +14 -0
- package/src/route/dto/update.dto.ts +16 -0
- package/src/route/route.controller.ts +91 -0
- package/src/route/route.module.ts +18 -0
- package/src/route/route.service.spec.ts +300 -0
- package/src/route/route.service.ts +164 -0
- package/src/screen/dto/create.dto.ts +12 -0
- package/src/screen/dto/update.dto.ts +20 -0
- package/src/screen/screen.controller.ts +93 -0
- package/src/screen/screen.module.ts +18 -0
- package/src/screen/screen.service.spec.ts +298 -0
- package/src/screen/screen.service.ts +179 -0
- package/src/security/security.module.ts +10 -0
- package/src/security/security.service.ts +103 -0
- package/src/session/session.controller.ts +35 -0
- package/src/session/session.module.ts +26 -0
- package/src/session/session.service.ts +207 -0
- package/src/setting/dto/confirm-import.dto.ts +7 -0
- package/src/setting/dto/create.dto.ts +21 -0
- package/src/setting/dto/delete.dto.ts +8 -0
- package/src/setting/dto/export.dto.ts +11 -0
- package/src/setting/dto/import-validation.dto.ts +6 -0
- package/src/setting/dto/setting-user.dto.ts +6 -0
- package/src/setting/dto/setting.dto.ts +17 -0
- package/src/setting/dto/update.dto.ts +4 -0
- package/src/setting/setting.controller.ts +136 -0
- package/src/setting/setting.module.ts +21 -0
- package/src/setting/setting.service.ts +673 -0
- package/src/task/task.module.ts +9 -0
- package/src/task/task.service.ts +55 -0
- package/src/token/token.module.ts +14 -0
- package/src/token/token.service.ts +110 -0
- package/src/types/http-method.ts +8 -0
- package/src/types/multer.d.ts +28 -0
- package/src/types/multer.ts +28 -0
- package/src/user/constants/user.constants.ts +1 -0
- package/src/user/dto/create-with-email-and-password.dto.ts +21 -0
- package/src/user/dto/update.dto.ts +11 -0
- package/src/user/user.controller.ts +87 -0
- package/src/user/user.module.ts +34 -0
- package/src/user/user.service.spec.ts +294 -0
- package/src/user/user.service.ts +269 -0
- package/src/utils/locale-context.ts +12 -0
- package/src/validators/is-email-with-settings.validator.ts +82 -0
- package/src/validators/is-pin-code-with-setting.validator.ts +81 -0
- package/src/validators/is-strong-password-with-settings.validator.ts +125 -0
|
@@ -0,0 +1,1158 @@
|
|
|
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
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
45
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.ProfileService = void 0;
|
|
49
|
+
const api_locale_1 = require("@hed-hog/api-locale");
|
|
50
|
+
const api_prisma_1 = require("@hed-hog/api-prisma");
|
|
51
|
+
const common_1 = require("@nestjs/common");
|
|
52
|
+
const jwt_1 = require("@nestjs/jwt");
|
|
53
|
+
const server_1 = require("@simplewebauthn/server");
|
|
54
|
+
const qrcode = __importStar(require("qrcode"));
|
|
55
|
+
const speakeasy = __importStar(require("speakeasy"));
|
|
56
|
+
const challenge_service_1 = require("../challenge/challenge.service");
|
|
57
|
+
const security_service_1 = require("../security/security.service");
|
|
58
|
+
const setting_service_1 = require("../setting/setting.service");
|
|
59
|
+
const token_service_1 = require("../token/token.service");
|
|
60
|
+
const user_service_1 = require("../user/user.service");
|
|
61
|
+
let ProfileService = class ProfileService {
|
|
62
|
+
constructor(prisma, user, jwt, setting, security, challenge, token) {
|
|
63
|
+
this.prisma = prisma;
|
|
64
|
+
this.user = user;
|
|
65
|
+
this.jwt = jwt;
|
|
66
|
+
this.setting = setting;
|
|
67
|
+
this.security = security;
|
|
68
|
+
this.challenge = challenge;
|
|
69
|
+
this.token = token;
|
|
70
|
+
this.settings = {};
|
|
71
|
+
}
|
|
72
|
+
async updatePreferences(locale, userId, { theme, language }) {
|
|
73
|
+
if (theme) {
|
|
74
|
+
await this.setting.setSettingUserValue(locale, userId, 'theme-mode', theme);
|
|
75
|
+
}
|
|
76
|
+
if (language) {
|
|
77
|
+
await this.setting.setSettingUserValue(locale, userId, 'language', language);
|
|
78
|
+
}
|
|
79
|
+
return { success: true };
|
|
80
|
+
}
|
|
81
|
+
async onModuleInit() {
|
|
82
|
+
this.settings = await this.setting.getSettingValues([
|
|
83
|
+
'mfa-issuer',
|
|
84
|
+
'mfa-window',
|
|
85
|
+
'mfa-setp',
|
|
86
|
+
'system-name',
|
|
87
|
+
'google_client_id',
|
|
88
|
+
'google_client_secret',
|
|
89
|
+
'google_scopes',
|
|
90
|
+
'url',
|
|
91
|
+
'mfa-challenge-expiration-minutes',
|
|
92
|
+
'access-token-expiration-minutes'
|
|
93
|
+
]);
|
|
94
|
+
}
|
|
95
|
+
async confirmEmailVerification(locale, userId, { pin, hash, name, email }) {
|
|
96
|
+
const challenge = await this.challenge.verifyCode(locale, userId, pin, hash, name, email);
|
|
97
|
+
const updatedUser = await this.prisma.user.findFirst({ where: { id: userId } });
|
|
98
|
+
const codes = await this.createMfaRecoveryCodes(updatedUser.id);
|
|
99
|
+
const newToken = await this.getToken(updatedUser);
|
|
100
|
+
return Object.assign(Object.assign({}, newToken), { challenge, codes });
|
|
101
|
+
}
|
|
102
|
+
async sendEmailVerification(locale, userId, { email }) {
|
|
103
|
+
const { codeHash } = await this.challenge.verifyEmail(locale, userId, email);
|
|
104
|
+
return { codeHash };
|
|
105
|
+
}
|
|
106
|
+
async sendCodeToRemove(locale, userId, email) {
|
|
107
|
+
return this.challenge.verifyEmail(locale, userId, email);
|
|
108
|
+
}
|
|
109
|
+
async getEmailIdentifier(userId) {
|
|
110
|
+
return this.prisma.user_identifier.findFirst({
|
|
111
|
+
where: { user_id: userId, type: 'email' },
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
async getProfile(userId) {
|
|
115
|
+
return this.prisma.user.findUnique({
|
|
116
|
+
where: { id: userId },
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
async getMFAMethods(userId) {
|
|
120
|
+
return this.prisma.user_mfa.findMany({
|
|
121
|
+
where: { user_id: userId },
|
|
122
|
+
include: {
|
|
123
|
+
user_mfa_email: true,
|
|
124
|
+
user_mfa_totp: true,
|
|
125
|
+
user_mfa_webauthn: true,
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
async updateMFA(userId, mfaId, { name }) {
|
|
130
|
+
return this.prisma.user_mfa.update({
|
|
131
|
+
where: { user_id: userId, id: mfaId },
|
|
132
|
+
data: { name }
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
async update(userid, { name }) {
|
|
136
|
+
return this.prisma.user.update({
|
|
137
|
+
where: { id: userid },
|
|
138
|
+
data: {
|
|
139
|
+
name,
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
async updateAvatar(userId, file) {
|
|
144
|
+
return this.user.changeAvatar(userId, file);
|
|
145
|
+
}
|
|
146
|
+
async changePassword(locale, userId, { currentPassword, newPassword }) {
|
|
147
|
+
const credential = await this.prisma.user_credential.findFirst({
|
|
148
|
+
where: { user_id: userId, type: 'password' },
|
|
149
|
+
});
|
|
150
|
+
if (!credential) {
|
|
151
|
+
throw new common_1.NotFoundException((0, api_locale_1.getLocaleText)('userNotFound', locale, 'User not found.'));
|
|
152
|
+
}
|
|
153
|
+
const isValidPassowrd = await this.security.validatePassword(locale, [credential], currentPassword);
|
|
154
|
+
if (!isValidPassowrd) {
|
|
155
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('accessDenied', locale, 'Access denied.'));
|
|
156
|
+
}
|
|
157
|
+
const passwordHash = await this.security.hashArgon2(newPassword);
|
|
158
|
+
await this.prisma.user_credential.update({
|
|
159
|
+
where: { id: credential.id },
|
|
160
|
+
data: { hash: passwordHash },
|
|
161
|
+
});
|
|
162
|
+
return { success: true };
|
|
163
|
+
}
|
|
164
|
+
generateRecoveryCodes(count = 10) {
|
|
165
|
+
const codes = Array.from({ length: count }, () => {
|
|
166
|
+
const array = new Uint8Array(4);
|
|
167
|
+
globalThis.crypto.getRandomValues(array);
|
|
168
|
+
return Array.from(array)
|
|
169
|
+
.map((b) => b.toString(16).padStart(2, '0'))
|
|
170
|
+
.join('');
|
|
171
|
+
});
|
|
172
|
+
return codes;
|
|
173
|
+
}
|
|
174
|
+
async createMfaRecoveryCodes(userId) {
|
|
175
|
+
const codes = this.generateRecoveryCodes();
|
|
176
|
+
await this.prisma.user_recovery_code.deleteMany({
|
|
177
|
+
where: {
|
|
178
|
+
user_id: userId,
|
|
179
|
+
},
|
|
180
|
+
});
|
|
181
|
+
const data = await Promise.all(codes.map(async (code) => ({
|
|
182
|
+
user_id: userId,
|
|
183
|
+
hash: await this.security.hashArgon2(code),
|
|
184
|
+
})));
|
|
185
|
+
await this.prisma.user_recovery_code.createMany({ data });
|
|
186
|
+
return codes;
|
|
187
|
+
}
|
|
188
|
+
async getToken(user) {
|
|
189
|
+
return { token: this.jwt.sign(user) };
|
|
190
|
+
}
|
|
191
|
+
async verifyMfaTotp(userId, token, secret, name) {
|
|
192
|
+
var _a, _b;
|
|
193
|
+
const window = (_a = this.settings['mfa-window']) !== null && _a !== void 0 ? _a : 0;
|
|
194
|
+
const step = (_b = this.settings['mfa-setp']) !== null && _b !== void 0 ? _b : 30;
|
|
195
|
+
const user = await this.prisma.user.findFirst({
|
|
196
|
+
where: { id: userId },
|
|
197
|
+
include: { user_mfa: { include: { user_mfa_totp: true } } }
|
|
198
|
+
});
|
|
199
|
+
if (!user) {
|
|
200
|
+
throw new common_1.NotFoundException((0, api_locale_1.getLocaleText)('userNotFound', 'en', 'User not found'));
|
|
201
|
+
}
|
|
202
|
+
const decodedSecret = Buffer.from(secret, 'base64').toString('utf-8');
|
|
203
|
+
const decryptedSecret = this.security.decrypt(decodedSecret);
|
|
204
|
+
const isValid = speakeasy.totp.verify({
|
|
205
|
+
secret: decryptedSecret,
|
|
206
|
+
encoding: 'base32',
|
|
207
|
+
token,
|
|
208
|
+
window,
|
|
209
|
+
step
|
|
210
|
+
});
|
|
211
|
+
if (!isValid) {
|
|
212
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('invalidCode', 'en', 'Invalid code'));
|
|
213
|
+
}
|
|
214
|
+
if (name) {
|
|
215
|
+
await this.prisma.user_mfa.create({
|
|
216
|
+
data: {
|
|
217
|
+
name,
|
|
218
|
+
user_id: userId,
|
|
219
|
+
type: 'totp',
|
|
220
|
+
verified_at: new Date(),
|
|
221
|
+
user_mfa_totp: {
|
|
222
|
+
create: {
|
|
223
|
+
secret: Buffer.from(decryptedSecret, 'utf-8'),
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
user_mfa_challenge: {
|
|
227
|
+
create: {
|
|
228
|
+
hash: await this.security.hashArgon2(decryptedSecret),
|
|
229
|
+
attempts: 1,
|
|
230
|
+
expires_at: new Date(),
|
|
231
|
+
verified_at: new Date()
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
const updatedUser = await this.prisma.user.findFirst({ where: { id: user.id } });
|
|
238
|
+
const codes = await this.createMfaRecoveryCodes(updatedUser.id);
|
|
239
|
+
const newToken = await this.getToken(updatedUser);
|
|
240
|
+
return Object.assign(Object.assign({}, newToken), { codes });
|
|
241
|
+
}
|
|
242
|
+
async generateMfaTotp(locale, userId) {
|
|
243
|
+
var _a, _b;
|
|
244
|
+
const user = await this.prisma.user.findFirst({
|
|
245
|
+
where: { id: userId },
|
|
246
|
+
select: {
|
|
247
|
+
user_mfa: true,
|
|
248
|
+
user_identifier: true
|
|
249
|
+
},
|
|
250
|
+
});
|
|
251
|
+
const issuer = (_a = this.settings['mfa-issuer']) !== null && _a !== void 0 ? _a : 'Hedhog';
|
|
252
|
+
const userEmail = user.user_identifier.find(ui => ui.type === 'email').value;
|
|
253
|
+
const appName = `${issuer} (${userEmail})`;
|
|
254
|
+
const secret = speakeasy.generateSecret({
|
|
255
|
+
length: 32,
|
|
256
|
+
name: appName,
|
|
257
|
+
otpauth: { label: appName, issuer },
|
|
258
|
+
encoding: 'base32',
|
|
259
|
+
});
|
|
260
|
+
const step = (_b = this.settings['mfa-setp']) !== null && _b !== void 0 ? _b : 30;
|
|
261
|
+
const otpauth = speakeasy.otpauthURL({
|
|
262
|
+
secret: secret.base32,
|
|
263
|
+
label: `${issuer}:${userEmail}`,
|
|
264
|
+
issuer,
|
|
265
|
+
period: step,
|
|
266
|
+
encoding: 'base32',
|
|
267
|
+
});
|
|
268
|
+
const qrCode = await qrcode.toDataURL(otpauth);
|
|
269
|
+
const encryptedSecret = this.security.encrypt(secret.base32);
|
|
270
|
+
const encodedSecret = Buffer.from(encryptedSecret, 'utf-8').toString('base64');
|
|
271
|
+
return { otpauthUrl: secret.otpauth_url, qrCode, secret: encodedSecret };
|
|
272
|
+
}
|
|
273
|
+
async removeMfaTotp(userId, mfaId, token) {
|
|
274
|
+
try {
|
|
275
|
+
const user = await this.prisma.user.findFirst({
|
|
276
|
+
where: { id: userId },
|
|
277
|
+
include: { user_identifier: true, user_mfa: { include: { user_mfa_totp: true } } }
|
|
278
|
+
});
|
|
279
|
+
const totpMfa = user.user_mfa.find((m) => m.type === 'totp' && m.user_mfa_totp);
|
|
280
|
+
if (!totpMfa || !totpMfa.user_mfa_totp) {
|
|
281
|
+
throw new common_1.NotFoundException((0, api_locale_1.getLocaleText)('totpNotFound', 'en', 'TOTP method not found'));
|
|
282
|
+
}
|
|
283
|
+
const secretBuffer = totpMfa.user_mfa_totp[0].secret;
|
|
284
|
+
const secretBase32 = secretBuffer instanceof Uint8Array
|
|
285
|
+
? Buffer.from(secretBuffer).toString('utf-8')
|
|
286
|
+
: String(secretBuffer);
|
|
287
|
+
const encryptedSecret = this.security.encrypt(secretBase32);
|
|
288
|
+
const encodedSecret = Buffer.from(encryptedSecret, 'utf-8').toString('base64');
|
|
289
|
+
await this.verifyMfaTotp(user.id, token, encodedSecret);
|
|
290
|
+
await this.prisma.$transaction(async (tx) => {
|
|
291
|
+
await tx.user_mfa.deleteMany({
|
|
292
|
+
where: {
|
|
293
|
+
id: mfaId,
|
|
294
|
+
user_id: userId,
|
|
295
|
+
type: 'totp',
|
|
296
|
+
},
|
|
297
|
+
});
|
|
298
|
+
await tx.user_recovery_code.deleteMany({
|
|
299
|
+
where: {
|
|
300
|
+
user_id: userId,
|
|
301
|
+
},
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
return this.getUserToken(userId);
|
|
305
|
+
}
|
|
306
|
+
catch (error) {
|
|
307
|
+
throw new common_1.BadRequestException(`Invalid code: ${error === null || error === void 0 ? void 0 : error.message}`);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
async removeMfaEmail(locale, userId, mfaId, token, providedHash) {
|
|
311
|
+
try {
|
|
312
|
+
await this.challenge.verifyCode(locale, userId, token, providedHash);
|
|
313
|
+
await this.prisma.user_mfa.deleteMany({
|
|
314
|
+
where: { id: mfaId, user_id: userId, type: 'email' },
|
|
315
|
+
});
|
|
316
|
+
return this.getUserToken(userId);
|
|
317
|
+
}
|
|
318
|
+
catch (error) {
|
|
319
|
+
throw new common_1.BadRequestException(`Invalid code: ${error === null || error === void 0 ? void 0 : error.message}`);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
async removeMfaWithRecoveryCode(locale, userId, mfaId, recoveryCode) {
|
|
323
|
+
try {
|
|
324
|
+
const user = await this.prisma.user.findUnique({
|
|
325
|
+
where: { id: userId },
|
|
326
|
+
include: {
|
|
327
|
+
user_recovery_code: true,
|
|
328
|
+
},
|
|
329
|
+
});
|
|
330
|
+
if (!user) {
|
|
331
|
+
throw new common_1.NotFoundException((0, api_locale_1.getLocaleText)('userNotFound', 'en', 'User not found'));
|
|
332
|
+
}
|
|
333
|
+
let isValid = false;
|
|
334
|
+
for (const code of user.user_recovery_code) {
|
|
335
|
+
if (await this.security.verifyArgon2(recoveryCode, code.hash)) {
|
|
336
|
+
isValid = true;
|
|
337
|
+
await this.prisma.user_recovery_code.delete({
|
|
338
|
+
where: { id: code.id },
|
|
339
|
+
});
|
|
340
|
+
break;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
if (!isValid) {
|
|
344
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('invalidRecoveryCode', locale, 'Invalid recovery code.'));
|
|
345
|
+
}
|
|
346
|
+
await this.prisma.user_mfa.deleteMany({
|
|
347
|
+
where: { id: mfaId, user_id: userId },
|
|
348
|
+
});
|
|
349
|
+
return this.getUserToken(userId);
|
|
350
|
+
}
|
|
351
|
+
catch (error) {
|
|
352
|
+
throw new common_1.BadRequestException(`Invalid code: ${error === null || error === void 0 ? void 0 : error.message}`);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
async removeMfa(locale, userId, mfaId, data) {
|
|
356
|
+
try {
|
|
357
|
+
const user = await this.prisma.user.findUnique({
|
|
358
|
+
where: { id: userId },
|
|
359
|
+
include: {
|
|
360
|
+
user_mfa: {
|
|
361
|
+
where: { id: mfaId, verified_at: { not: null } },
|
|
362
|
+
include: {
|
|
363
|
+
user_mfa_totp: true,
|
|
364
|
+
user_mfa_email: true,
|
|
365
|
+
user_mfa_webauthn: true
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
user_recovery_code: true
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
if (!user) {
|
|
372
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('userNotFound', locale, 'User not found.'));
|
|
373
|
+
}
|
|
374
|
+
const mfaToRemove = user.user_mfa.find(m => m.id === mfaId);
|
|
375
|
+
if (!mfaToRemove) {
|
|
376
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('mfaMethodNotFound', locale, 'MFA method not found.'));
|
|
377
|
+
}
|
|
378
|
+
if (data.verificationType !== 'webauthn' && !data.token) {
|
|
379
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('verificationCodeRequired', locale, 'Verification code is required.'));
|
|
380
|
+
}
|
|
381
|
+
if (data.verificationType === 'webauthn') {
|
|
382
|
+
if (!data.assertionResponse) {
|
|
383
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('assertionResponseRequired', locale, 'Assertion response is required for WebAuthn.'));
|
|
384
|
+
}
|
|
385
|
+
try {
|
|
386
|
+
await this.verifyWebAuthnAuthentication(userId, data.assertionResponse);
|
|
387
|
+
}
|
|
388
|
+
catch (error) {
|
|
389
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('invalidWebAuthn', locale, 'WebAuthn verification failed.'));
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
else if (data.verificationType === 'recovery') {
|
|
393
|
+
if (!data.token) {
|
|
394
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('verificationCodeRequired', locale, 'Verification code is required.'));
|
|
395
|
+
}
|
|
396
|
+
let isValid = false;
|
|
397
|
+
for (const recoveryCode of user.user_recovery_code) {
|
|
398
|
+
if (await this.security.verifyArgon2(data.token, recoveryCode.hash)) {
|
|
399
|
+
isValid = true;
|
|
400
|
+
await this.prisma.user_recovery_code.delete({
|
|
401
|
+
where: { id: recoveryCode.id }
|
|
402
|
+
});
|
|
403
|
+
break;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
if (!isValid) {
|
|
407
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('invalidRecoveryCode', locale, 'Invalid recovery code.'));
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
else if (data.verificationType === 'email' || mfaToRemove.type === 'email') {
|
|
411
|
+
if (!data.token) {
|
|
412
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('verificationCodeRequired', locale, 'Verification code is required.'));
|
|
413
|
+
}
|
|
414
|
+
try {
|
|
415
|
+
const isValid = await this.challenge.verifyMfaEmailCode(locale, userId, data.token);
|
|
416
|
+
if (!isValid) {
|
|
417
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('invalidVerificationCode', locale, 'Invalid verification code.'));
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
catch (error) {
|
|
421
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('invalidVerificationCode', locale, 'Invalid verification code.'));
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
else if (data.verificationType === 'totp' || mfaToRemove.type === 'totp') {
|
|
425
|
+
const totpMfa = user.user_mfa.find(m => m.type === 'totp' && m.user_mfa_totp);
|
|
426
|
+
if (!totpMfa || !totpMfa.user_mfa_totp || !totpMfa.user_mfa_totp[0]) {
|
|
427
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('totpMfaNotFound', locale, 'TOTP MFA not found.'));
|
|
428
|
+
}
|
|
429
|
+
const secretBuffer = totpMfa.user_mfa_totp[0].secret;
|
|
430
|
+
const secretBase32 = secretBuffer instanceof Uint8Array
|
|
431
|
+
? Buffer.from(secretBuffer).toString('utf-8')
|
|
432
|
+
: String(secretBuffer);
|
|
433
|
+
const encryptedSecret = this.security.encrypt(secretBase32);
|
|
434
|
+
const encodedSecret = Buffer.from(encryptedSecret, 'utf-8').toString('base64');
|
|
435
|
+
try {
|
|
436
|
+
await this.verifyMfaTotp(userId, data.token, encodedSecret);
|
|
437
|
+
}
|
|
438
|
+
catch (error) {
|
|
439
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('invalidVerificationCode', locale, 'Invalid verification code.'));
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
await this.prisma.user_mfa.deleteMany({
|
|
443
|
+
where: { id: mfaId, user_id: userId },
|
|
444
|
+
});
|
|
445
|
+
return this.getUserToken(userId);
|
|
446
|
+
}
|
|
447
|
+
catch (error) {
|
|
448
|
+
throw new common_1.BadRequestException(`Failed to remove MFA: ${error === null || error === void 0 ? void 0 : error.message}`);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
async checkMfaBeforeAdd(locale, userId) {
|
|
452
|
+
try {
|
|
453
|
+
const mfaMethods = await this.prisma.user_mfa.findMany({
|
|
454
|
+
where: {
|
|
455
|
+
user_id: userId,
|
|
456
|
+
verified_at: { not: null }
|
|
457
|
+
},
|
|
458
|
+
include: {
|
|
459
|
+
user_mfa_totp: true,
|
|
460
|
+
user_mfa_email: true,
|
|
461
|
+
user_mfa_webauthn: true
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
if (mfaMethods.length === 0) {
|
|
465
|
+
return { requiresVerification: false };
|
|
466
|
+
}
|
|
467
|
+
const totpMfa = mfaMethods.find(m => m.type === 'totp' && m.user_mfa_totp);
|
|
468
|
+
const emailMfas = mfaMethods.filter(m => m.type === 'email' && m.user_mfa_email && m.user_mfa_email.length > 0);
|
|
469
|
+
const webauthnMfa = mfaMethods.find(m => m.type === 'webauthn' && m.user_mfa_webauthn);
|
|
470
|
+
const availableMethods = [];
|
|
471
|
+
if (totpMfa) {
|
|
472
|
+
availableMethods.push('totp');
|
|
473
|
+
}
|
|
474
|
+
if (emailMfas.length > 0) {
|
|
475
|
+
const emails = emailMfas.map(mfa => mfa.user_mfa_email[0].email);
|
|
476
|
+
await this.challenge.sendMfaCodeToMultipleEmails(locale, userId, emails);
|
|
477
|
+
availableMethods.push('email');
|
|
478
|
+
}
|
|
479
|
+
if (availableMethods.length === 0 && !webauthnMfa) {
|
|
480
|
+
return { requiresVerification: false };
|
|
481
|
+
}
|
|
482
|
+
if (availableMethods.length === 0 && webauthnMfa) {
|
|
483
|
+
return {
|
|
484
|
+
requiresVerification: true,
|
|
485
|
+
availableMethods: [],
|
|
486
|
+
hasWebAuthn: true,
|
|
487
|
+
hasRecoveryCodes: true,
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
if (availableMethods.length === 2) {
|
|
491
|
+
return {
|
|
492
|
+
requiresVerification: true,
|
|
493
|
+
availableMethods,
|
|
494
|
+
hasWebAuthn: !!webauthnMfa,
|
|
495
|
+
hasRecoveryCodes: true,
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
return {
|
|
499
|
+
requiresVerification: true,
|
|
500
|
+
verificationType: availableMethods[0],
|
|
501
|
+
hasWebAuthn: !!webauthnMfa,
|
|
502
|
+
hasRecoveryCodes: true,
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
catch (error) {
|
|
506
|
+
throw new common_1.BadRequestException(`Failed to check MFA: ${error === null || error === void 0 ? void 0 : error.message}`);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
async checkMfaBeforeRemove(locale, userId) {
|
|
510
|
+
try {
|
|
511
|
+
const mfaMethods = await this.prisma.user_mfa.findMany({
|
|
512
|
+
where: {
|
|
513
|
+
user_id: userId,
|
|
514
|
+
verified_at: { not: null }
|
|
515
|
+
},
|
|
516
|
+
include: {
|
|
517
|
+
user_mfa_totp: true,
|
|
518
|
+
user_mfa_email: true,
|
|
519
|
+
user_mfa_webauthn: true
|
|
520
|
+
}
|
|
521
|
+
});
|
|
522
|
+
if (mfaMethods.length === 0) {
|
|
523
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('noMfaMethodsFound', locale, 'No MFA methods found.'));
|
|
524
|
+
}
|
|
525
|
+
const totpMfa = mfaMethods.find(m => m.type === 'totp' && m.user_mfa_totp);
|
|
526
|
+
const emailMfas = mfaMethods.filter(m => m.type === 'email' && m.user_mfa_email && m.user_mfa_email.length > 0);
|
|
527
|
+
const webauthnMfa = mfaMethods.find(m => m.type === 'webauthn' && m.user_mfa_webauthn);
|
|
528
|
+
const availableMethods = [];
|
|
529
|
+
if (totpMfa) {
|
|
530
|
+
availableMethods.push('totp');
|
|
531
|
+
}
|
|
532
|
+
if (emailMfas.length > 0) {
|
|
533
|
+
const emails = emailMfas.map(mfa => mfa.user_mfa_email[0].email);
|
|
534
|
+
await this.challenge.sendMfaCodeToMultipleEmails(locale, userId, emails);
|
|
535
|
+
availableMethods.push('email');
|
|
536
|
+
}
|
|
537
|
+
return {
|
|
538
|
+
requiresVerification: true,
|
|
539
|
+
availableMethods,
|
|
540
|
+
hasWebAuthn: !!webauthnMfa,
|
|
541
|
+
hasRecoveryCodes: mfaMethods.length > 0,
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
catch (error) {
|
|
545
|
+
throw new common_1.BadRequestException(`Failed to check MFA before remove: ${error === null || error === void 0 ? void 0 : error.message}`);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
async verifyBeforeAddMfa(locale, userId, data) {
|
|
549
|
+
try {
|
|
550
|
+
const user = await this.prisma.user.findUnique({
|
|
551
|
+
where: { id: userId },
|
|
552
|
+
include: {
|
|
553
|
+
user_mfa: {
|
|
554
|
+
where: { verified_at: { not: null } },
|
|
555
|
+
include: {
|
|
556
|
+
user_mfa_totp: true,
|
|
557
|
+
user_mfa_email: true,
|
|
558
|
+
user_mfa_webauthn: true
|
|
559
|
+
}
|
|
560
|
+
},
|
|
561
|
+
user_recovery_code: true
|
|
562
|
+
}
|
|
563
|
+
});
|
|
564
|
+
if (!user) {
|
|
565
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('userNotFound', locale, 'User not found.'));
|
|
566
|
+
}
|
|
567
|
+
if (user.user_mfa.length === 0) {
|
|
568
|
+
return { success: true };
|
|
569
|
+
}
|
|
570
|
+
if (data.verificationType === 'webauthn') {
|
|
571
|
+
if (!data.assertionResponse) {
|
|
572
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('assertionResponseRequired', locale, 'Assertion response is required for WebAuthn.'));
|
|
573
|
+
}
|
|
574
|
+
try {
|
|
575
|
+
await this.verifyWebAuthnAuthentication(userId, data.assertionResponse);
|
|
576
|
+
}
|
|
577
|
+
catch (error) {
|
|
578
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('invalidWebAuthn', locale, 'WebAuthn verification failed.'));
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
else if (data.verificationType === 'recovery') {
|
|
582
|
+
if (!data.verificationCode) {
|
|
583
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('verificationCodeRequired', locale, 'Verification code is required.'));
|
|
584
|
+
}
|
|
585
|
+
let isValid = false;
|
|
586
|
+
for (const recoveryCode of user.user_recovery_code) {
|
|
587
|
+
if (await this.security.verifyArgon2(data.verificationCode, recoveryCode.hash)) {
|
|
588
|
+
isValid = true;
|
|
589
|
+
await this.prisma.user_recovery_code.delete({
|
|
590
|
+
where: { id: recoveryCode.id }
|
|
591
|
+
});
|
|
592
|
+
break;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
if (!isValid) {
|
|
596
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('invalidRecoveryCode', locale, 'Invalid recovery code.'));
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
else if (data.verificationType === 'email') {
|
|
600
|
+
const emailMfa = user.user_mfa.find(m => m.type === 'email' && m.user_mfa_email);
|
|
601
|
+
if (!emailMfa) {
|
|
602
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('emailMfaNotFound', locale, 'Email MFA not found.'));
|
|
603
|
+
}
|
|
604
|
+
if (!data.verificationCode) {
|
|
605
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('verificationCodeRequired', locale, 'Verification code is required.'));
|
|
606
|
+
}
|
|
607
|
+
try {
|
|
608
|
+
const isValid = await this.challenge.verifyMfaEmailCode(locale, userId, data.verificationCode);
|
|
609
|
+
if (!isValid) {
|
|
610
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('invalidVerificationCode', locale, 'Invalid verification code.'));
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
catch (error) {
|
|
614
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('invalidVerificationCode', locale, 'Invalid verification code.'));
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
else {
|
|
618
|
+
const totpMfa = user.user_mfa.find(m => m.type === 'totp' && m.user_mfa_totp);
|
|
619
|
+
if (!totpMfa || !totpMfa.user_mfa_totp[0]) {
|
|
620
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('totpMfaNotFound', locale, 'TOTP MFA not found.'));
|
|
621
|
+
}
|
|
622
|
+
const secretBuffer = totpMfa.user_mfa_totp[0].secret;
|
|
623
|
+
const secretBase32 = secretBuffer instanceof Uint8Array
|
|
624
|
+
? Buffer.from(secretBuffer).toString('utf-8')
|
|
625
|
+
: String(secretBuffer);
|
|
626
|
+
const encryptedSecret = this.security.encrypt(secretBase32);
|
|
627
|
+
const encodedSecret = Buffer.from(encryptedSecret, 'utf-8').toString('base64');
|
|
628
|
+
try {
|
|
629
|
+
await this.verifyMfaTotp(userId, data.verificationCode, encodedSecret);
|
|
630
|
+
}
|
|
631
|
+
catch (error) {
|
|
632
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('invalidVerificationCode', locale, 'Invalid verification code.'));
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
return { success: true };
|
|
636
|
+
}
|
|
637
|
+
catch (error) {
|
|
638
|
+
throw new common_1.BadRequestException(`Failed to verify MFA: ${error === null || error === void 0 ? void 0 : error.message}`);
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
async sendRecoveryCodesVerification(locale, userId) {
|
|
642
|
+
try {
|
|
643
|
+
const mfaMethods = await this.prisma.user_mfa.findMany({
|
|
644
|
+
where: {
|
|
645
|
+
user_id: userId,
|
|
646
|
+
verified_at: { not: null }
|
|
647
|
+
},
|
|
648
|
+
include: {
|
|
649
|
+
user_mfa_totp: true,
|
|
650
|
+
user_mfa_email: true,
|
|
651
|
+
user_mfa_webauthn: true
|
|
652
|
+
}
|
|
653
|
+
});
|
|
654
|
+
if (mfaMethods.length === 0) {
|
|
655
|
+
return { requiresVerification: false };
|
|
656
|
+
}
|
|
657
|
+
const totpMfa = mfaMethods.find(m => m.type === 'totp' && m.user_mfa_totp);
|
|
658
|
+
const emailMfas = mfaMethods.filter(m => m.type === 'email' && m.user_mfa_email && m.user_mfa_email.length > 0);
|
|
659
|
+
const webauthnMfa = mfaMethods.find(m => m.type === 'webauthn' && m.user_mfa_webauthn);
|
|
660
|
+
const availableMethods = [];
|
|
661
|
+
if (totpMfa) {
|
|
662
|
+
availableMethods.push('totp');
|
|
663
|
+
}
|
|
664
|
+
if (emailMfas.length > 0) {
|
|
665
|
+
const emails = emailMfas.map(mfa => mfa.user_mfa_email[0].email);
|
|
666
|
+
await this.challenge.sendMfaCodeToMultipleEmails(locale, userId, emails);
|
|
667
|
+
availableMethods.push('email');
|
|
668
|
+
}
|
|
669
|
+
if (availableMethods.length === 0 && !webauthnMfa) {
|
|
670
|
+
return { requiresVerification: false };
|
|
671
|
+
}
|
|
672
|
+
if (availableMethods.length === 0 && webauthnMfa) {
|
|
673
|
+
return {
|
|
674
|
+
requiresVerification: true,
|
|
675
|
+
availableMethods: [],
|
|
676
|
+
hasWebAuthn: true,
|
|
677
|
+
hasRecoveryCodes: true,
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
if (availableMethods.length === 2) {
|
|
681
|
+
return {
|
|
682
|
+
requiresVerification: true,
|
|
683
|
+
availableMethods,
|
|
684
|
+
hasWebAuthn: !!webauthnMfa,
|
|
685
|
+
hasRecoveryCodes: true,
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
return {
|
|
689
|
+
requiresVerification: true,
|
|
690
|
+
verificationType: availableMethods[0],
|
|
691
|
+
hasWebAuthn: !!webauthnMfa,
|
|
692
|
+
hasRecoveryCodes: true,
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
catch (error) {
|
|
696
|
+
throw new common_1.BadRequestException(`Failed to send verification: ${error === null || error === void 0 ? void 0 : error.message}`);
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
async regenerateRecoveryCodes(locale, userId, data) {
|
|
700
|
+
try {
|
|
701
|
+
const user = await this.prisma.user.findUnique({
|
|
702
|
+
where: { id: userId },
|
|
703
|
+
include: {
|
|
704
|
+
user_mfa: {
|
|
705
|
+
where: { verified_at: { not: null } },
|
|
706
|
+
include: {
|
|
707
|
+
user_mfa_totp: true,
|
|
708
|
+
user_mfa_email: true,
|
|
709
|
+
user_mfa_webauthn: true
|
|
710
|
+
}
|
|
711
|
+
},
|
|
712
|
+
user_recovery_code: true
|
|
713
|
+
}
|
|
714
|
+
});
|
|
715
|
+
if (!user) {
|
|
716
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('userNotFound', locale, 'User not found.'));
|
|
717
|
+
}
|
|
718
|
+
if (user.user_mfa.length > 0) {
|
|
719
|
+
if (data.verificationType !== 'webauthn' && !data.verificationCode) {
|
|
720
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('verificationCodeRequired', locale, 'Verification code is required.'));
|
|
721
|
+
}
|
|
722
|
+
if (data.verificationType === 'webauthn') {
|
|
723
|
+
if (!data.assertionResponse) {
|
|
724
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('assertionResponseRequired', locale, 'Assertion response is required for WebAuthn.'));
|
|
725
|
+
}
|
|
726
|
+
try {
|
|
727
|
+
await this.verifyWebAuthnAuthentication(userId, data.assertionResponse);
|
|
728
|
+
}
|
|
729
|
+
catch (error) {
|
|
730
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('invalidWebAuthn', locale, 'WebAuthn verification failed.'));
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
else if (data.verificationType === 'recovery') {
|
|
734
|
+
if (!data.verificationCode) {
|
|
735
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('verificationCodeRequired', locale, 'Verification code is required.'));
|
|
736
|
+
}
|
|
737
|
+
let isValid = false;
|
|
738
|
+
for (const recoveryCode of user.user_recovery_code) {
|
|
739
|
+
if (await this.security.verifyArgon2(data.verificationCode, recoveryCode.hash)) {
|
|
740
|
+
isValid = true;
|
|
741
|
+
await this.prisma.user_recovery_code.delete({
|
|
742
|
+
where: { id: recoveryCode.id }
|
|
743
|
+
});
|
|
744
|
+
break;
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
if (!isValid) {
|
|
748
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('invalidRecoveryCode', locale, 'Invalid recovery code.'));
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
else if (data.verificationType === 'email') {
|
|
752
|
+
const emailMfa = user.user_mfa.find(m => m.type === 'email' && m.user_mfa_email);
|
|
753
|
+
if (!emailMfa) {
|
|
754
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('emailMfaNotFound', locale, 'Email MFA not found.'));
|
|
755
|
+
}
|
|
756
|
+
if (!data.verificationCode) {
|
|
757
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('verificationCodeRequired', locale, 'Verification code is required.'));
|
|
758
|
+
}
|
|
759
|
+
try {
|
|
760
|
+
const isValid = await this.challenge.verifyMfaEmailCode(locale, userId, data.verificationCode);
|
|
761
|
+
if (!isValid) {
|
|
762
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('invalidVerificationCode', locale, 'Invalid verification code.'));
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
catch (error) {
|
|
766
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('invalidVerificationCode', locale, 'Invalid verification code.'));
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
else {
|
|
770
|
+
const totpMfa = user.user_mfa.find(m => m.type === 'totp' && m.user_mfa_totp);
|
|
771
|
+
if (!totpMfa || !totpMfa.user_mfa_totp[0]) {
|
|
772
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('totpMfaNotFound', locale, 'TOTP MFA not found.'));
|
|
773
|
+
}
|
|
774
|
+
const secretBuffer = totpMfa.user_mfa_totp[0].secret;
|
|
775
|
+
const secretBase32 = secretBuffer instanceof Uint8Array
|
|
776
|
+
? Buffer.from(secretBuffer).toString('utf-8')
|
|
777
|
+
: String(secretBuffer);
|
|
778
|
+
const encryptedSecret = this.security.encrypt(secretBase32);
|
|
779
|
+
const encodedSecret = Buffer.from(encryptedSecret, 'utf-8').toString('base64');
|
|
780
|
+
try {
|
|
781
|
+
await this.verifyMfaTotp(userId, data.verificationCode, encodedSecret);
|
|
782
|
+
}
|
|
783
|
+
catch (error) {
|
|
784
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('invalidVerificationCode', locale, 'Invalid verification code.'));
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
const codes = await this.createMfaRecoveryCodes(userId);
|
|
789
|
+
return { codes };
|
|
790
|
+
}
|
|
791
|
+
catch (error) {
|
|
792
|
+
throw new common_1.BadRequestException(`Failed to regenerate recovery codes: ${error === null || error === void 0 ? void 0 : error.message}`);
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
async generateWebAuthnRegistrationOptions(locale, userId, name) {
|
|
796
|
+
var _a;
|
|
797
|
+
try {
|
|
798
|
+
const user = await this.prisma.user.findFirst({
|
|
799
|
+
where: { id: userId },
|
|
800
|
+
include: {
|
|
801
|
+
user_identifier: true,
|
|
802
|
+
user_mfa: {
|
|
803
|
+
where: { type: 'webauthn', verified_at: { not: null } },
|
|
804
|
+
include: { user_mfa_webauthn: true }
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
});
|
|
808
|
+
if (!user) {
|
|
809
|
+
throw new common_1.NotFoundException((0, api_locale_1.getLocaleText)('userNotFound', locale, 'User not found.'));
|
|
810
|
+
}
|
|
811
|
+
const rpName = this.settings['system-name'] || 'HedHog';
|
|
812
|
+
const rpID = new URL(process.env.FRONTEND_URL || 'http://localhost:3200').hostname;
|
|
813
|
+
const userEmail = ((_a = user.user_identifier.find(ui => ui.type === 'email')) === null || _a === void 0 ? void 0 : _a.value) || `user${userId}@example.com`;
|
|
814
|
+
const existingAuthenticators = user.user_mfa
|
|
815
|
+
.filter(mfa => mfa.user_mfa_webauthn && mfa.user_mfa_webauthn.length > 0)
|
|
816
|
+
.map(mfa => ({
|
|
817
|
+
credentialID: mfa.user_mfa_webauthn[0].credential_id,
|
|
818
|
+
credentialPublicKey: mfa.user_mfa_webauthn[0].public_key,
|
|
819
|
+
counter: mfa.user_mfa_webauthn[0].sign_count,
|
|
820
|
+
}));
|
|
821
|
+
const options = await (0, server_1.generateRegistrationOptions)({
|
|
822
|
+
rpName,
|
|
823
|
+
rpID,
|
|
824
|
+
userName: userEmail,
|
|
825
|
+
userDisplayName: user.name || userEmail,
|
|
826
|
+
attestationType: 'none',
|
|
827
|
+
excludeCredentials: existingAuthenticators.map(auth => ({
|
|
828
|
+
id: Buffer.from(auth.credentialID).toString('base64url'),
|
|
829
|
+
})),
|
|
830
|
+
authenticatorSelection: {
|
|
831
|
+
residentKey: 'preferred',
|
|
832
|
+
userVerification: 'preferred',
|
|
833
|
+
},
|
|
834
|
+
});
|
|
835
|
+
await this.prisma.user_mfa_challenge.create({
|
|
836
|
+
data: {
|
|
837
|
+
user_mfa: {
|
|
838
|
+
create: {
|
|
839
|
+
user_id: userId,
|
|
840
|
+
type: 'webauthn',
|
|
841
|
+
name: name || 'Security Key',
|
|
842
|
+
}
|
|
843
|
+
},
|
|
844
|
+
hash: options.challenge,
|
|
845
|
+
attempts: 0,
|
|
846
|
+
expires_at: new Date(Date.now() + 5 * 60 * 1000),
|
|
847
|
+
}
|
|
848
|
+
});
|
|
849
|
+
return options;
|
|
850
|
+
}
|
|
851
|
+
catch (error) {
|
|
852
|
+
throw new common_1.BadRequestException(`Failed to generate registration options: ${error === null || error === void 0 ? void 0 : error.message}`);
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
async verifyWebAuthnRegistration(locale, userId, name, attestationResponse) {
|
|
856
|
+
try {
|
|
857
|
+
const challengeRecord = await this.prisma.user_mfa_challenge.findFirst({
|
|
858
|
+
where: {
|
|
859
|
+
user_mfa: {
|
|
860
|
+
user_id: userId,
|
|
861
|
+
type: 'webauthn',
|
|
862
|
+
verified_at: null,
|
|
863
|
+
},
|
|
864
|
+
expires_at: { gt: new Date() }
|
|
865
|
+
},
|
|
866
|
+
include: { user_mfa: true },
|
|
867
|
+
orderBy: { created_at: 'desc' }
|
|
868
|
+
});
|
|
869
|
+
if (!challengeRecord) {
|
|
870
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('challengeNotFound', locale, 'Challenge not found or expired.'));
|
|
871
|
+
}
|
|
872
|
+
const rpID = new URL(process.env.FRONTEND_URL || 'http://localhost:3200').hostname;
|
|
873
|
+
const expectedOrigin = process.env.FRONTEND_URL || 'http://localhost:3200';
|
|
874
|
+
const verification = await (0, server_1.verifyRegistrationResponse)({
|
|
875
|
+
response: attestationResponse,
|
|
876
|
+
expectedChallenge: challengeRecord.hash,
|
|
877
|
+
expectedOrigin,
|
|
878
|
+
expectedRPID: rpID,
|
|
879
|
+
});
|
|
880
|
+
if (!verification.verified || !verification.registrationInfo) {
|
|
881
|
+
throw new common_1.BadRequestException((0, api_locale_1.getLocaleText)('verificationFailed', locale, 'Verification failed.'));
|
|
882
|
+
}
|
|
883
|
+
const { credential } = verification.registrationInfo;
|
|
884
|
+
await this.prisma.user_mfa.update({
|
|
885
|
+
where: { id: challengeRecord.user_mfa_id },
|
|
886
|
+
data: {
|
|
887
|
+
name,
|
|
888
|
+
verified_at: new Date(),
|
|
889
|
+
user_mfa_webauthn: {
|
|
890
|
+
create: {
|
|
891
|
+
credential_id: Buffer.from(credential.id, 'base64url'),
|
|
892
|
+
public_key: credential.publicKey,
|
|
893
|
+
sign_count: credential.counter,
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
});
|
|
898
|
+
await this.prisma.user_mfa_challenge.update({
|
|
899
|
+
where: { id: challengeRecord.id },
|
|
900
|
+
data: { verified_at: new Date() }
|
|
901
|
+
});
|
|
902
|
+
const codes = await this.createMfaRecoveryCodes(userId);
|
|
903
|
+
return { success: true, codes };
|
|
904
|
+
}
|
|
905
|
+
catch (error) {
|
|
906
|
+
throw new common_1.BadRequestException(`Failed to verify registration: ${error === null || error === void 0 ? void 0 : error.message}`);
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
async generateWebAuthnAuthenticationOptions(locale, userId) {
|
|
910
|
+
try {
|
|
911
|
+
const user = await this.prisma.user.findFirst({
|
|
912
|
+
where: { id: userId },
|
|
913
|
+
include: {
|
|
914
|
+
user_mfa: {
|
|
915
|
+
where: { type: 'webauthn', verified_at: { not: null } },
|
|
916
|
+
include: { user_mfa_webauthn: true }
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
});
|
|
920
|
+
if (!user || user.user_mfa.length === 0) {
|
|
921
|
+
throw new common_1.NotFoundException((0, api_locale_1.getLocaleText)('webauthnNotConfigured', locale, 'WebAuthn not configured.'));
|
|
922
|
+
}
|
|
923
|
+
const rpID = new URL(process.env.FRONTEND_URL || 'http://localhost:3200').hostname;
|
|
924
|
+
const allowCredentials = user.user_mfa
|
|
925
|
+
.filter(mfa => mfa.user_mfa_webauthn && mfa.user_mfa_webauthn.length > 0)
|
|
926
|
+
.map(mfa => ({
|
|
927
|
+
id: Buffer.from(mfa.user_mfa_webauthn[0].credential_id).toString('base64url'),
|
|
928
|
+
}));
|
|
929
|
+
const options = await (0, server_1.generateAuthenticationOptions)({
|
|
930
|
+
rpID,
|
|
931
|
+
allowCredentials,
|
|
932
|
+
userVerification: 'preferred',
|
|
933
|
+
});
|
|
934
|
+
await this.prisma.user_mfa_challenge.create({
|
|
935
|
+
data: {
|
|
936
|
+
user_mfa_id: user.user_mfa[0].id,
|
|
937
|
+
hash: options.challenge,
|
|
938
|
+
attempts: 0,
|
|
939
|
+
expires_at: new Date(Date.now() + 5 * 60 * 1000),
|
|
940
|
+
}
|
|
941
|
+
});
|
|
942
|
+
return options;
|
|
943
|
+
}
|
|
944
|
+
catch (error) {
|
|
945
|
+
throw new common_1.BadRequestException(`Failed to generate authentication options: ${error === null || error === void 0 ? void 0 : error.message}`);
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
async verifyWebAuthnAuthentication(userId, assertionResponse) {
|
|
949
|
+
try {
|
|
950
|
+
const challengeRecord = await this.prisma.user_mfa_challenge.findFirst({
|
|
951
|
+
where: {
|
|
952
|
+
user_mfa: {
|
|
953
|
+
user_id: userId,
|
|
954
|
+
type: 'webauthn',
|
|
955
|
+
verified_at: { not: null },
|
|
956
|
+
},
|
|
957
|
+
verified_at: null,
|
|
958
|
+
expires_at: { gt: new Date() }
|
|
959
|
+
},
|
|
960
|
+
include: {
|
|
961
|
+
user_mfa: {
|
|
962
|
+
include: { user_mfa_webauthn: true }
|
|
963
|
+
}
|
|
964
|
+
},
|
|
965
|
+
orderBy: { created_at: 'desc' }
|
|
966
|
+
});
|
|
967
|
+
if (!challengeRecord || !challengeRecord.user_mfa.user_mfa_webauthn[0]) {
|
|
968
|
+
throw new common_1.BadRequestException('Challenge not found or expired.');
|
|
969
|
+
}
|
|
970
|
+
const authenticator = challengeRecord.user_mfa.user_mfa_webauthn[0];
|
|
971
|
+
const rpID = new URL(process.env.FRONTEND_URL || 'http://localhost:3200').hostname;
|
|
972
|
+
const expectedOrigin = process.env.FRONTEND_URL || 'http://localhost:3200';
|
|
973
|
+
const verification = await (0, server_1.verifyAuthenticationResponse)({
|
|
974
|
+
response: assertionResponse,
|
|
975
|
+
expectedChallenge: challengeRecord.hash,
|
|
976
|
+
expectedOrigin,
|
|
977
|
+
expectedRPID: rpID,
|
|
978
|
+
credential: {
|
|
979
|
+
id: Buffer.from(authenticator.credential_id).toString('base64url'),
|
|
980
|
+
publicKey: authenticator.public_key,
|
|
981
|
+
counter: authenticator.sign_count,
|
|
982
|
+
},
|
|
983
|
+
});
|
|
984
|
+
if (!verification.verified) {
|
|
985
|
+
throw new common_1.BadRequestException('Verification failed.');
|
|
986
|
+
}
|
|
987
|
+
await this.prisma.user_mfa_webauthn.update({
|
|
988
|
+
where: { id: authenticator.id },
|
|
989
|
+
data: {
|
|
990
|
+
sign_count: verification.authenticationInfo.newCounter,
|
|
991
|
+
last_used_at: new Date(),
|
|
992
|
+
}
|
|
993
|
+
});
|
|
994
|
+
await this.prisma.user_mfa_challenge.update({
|
|
995
|
+
where: { id: challengeRecord.id },
|
|
996
|
+
data: { verified_at: new Date() }
|
|
997
|
+
});
|
|
998
|
+
return { success: true };
|
|
999
|
+
}
|
|
1000
|
+
catch (error) {
|
|
1001
|
+
throw new common_1.BadRequestException(`Failed to verify authentication: ${error === null || error === void 0 ? void 0 : error.message}`);
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
async removeWebAuthnMfa(locale, userId, mfaId) {
|
|
1005
|
+
try {
|
|
1006
|
+
const mfa = await this.prisma.user_mfa.findFirst({
|
|
1007
|
+
where: {
|
|
1008
|
+
id: mfaId,
|
|
1009
|
+
user_id: userId,
|
|
1010
|
+
type: 'webauthn',
|
|
1011
|
+
},
|
|
1012
|
+
});
|
|
1013
|
+
if (!mfa) {
|
|
1014
|
+
throw new common_1.NotFoundException((0, api_locale_1.getLocaleText)('mfaNotFound', locale, 'MFA method not found.'));
|
|
1015
|
+
}
|
|
1016
|
+
await this.prisma.user_mfa.delete({
|
|
1017
|
+
where: { id: mfaId },
|
|
1018
|
+
});
|
|
1019
|
+
return { success: true };
|
|
1020
|
+
}
|
|
1021
|
+
catch (error) {
|
|
1022
|
+
throw new common_1.BadRequestException(`Failed to remove WebAuthn: ${error === null || error === void 0 ? void 0 : error.message}`);
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
async generateWebAuthnAuthenticationOptionsForLogin(mfaToken) {
|
|
1026
|
+
try {
|
|
1027
|
+
const decoded = this.jwt.decode(mfaToken);
|
|
1028
|
+
if (!decoded || !decoded.userId) {
|
|
1029
|
+
throw new common_1.BadRequestException('Invalid MFA token');
|
|
1030
|
+
}
|
|
1031
|
+
const user = await this.prisma.user.findFirst({
|
|
1032
|
+
where: { id: decoded.userId },
|
|
1033
|
+
include: {
|
|
1034
|
+
user_mfa: {
|
|
1035
|
+
where: { type: 'webauthn', verified_at: { not: null } },
|
|
1036
|
+
include: { user_mfa_webauthn: true }
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
});
|
|
1040
|
+
if (!user || user.user_mfa.length === 0) {
|
|
1041
|
+
throw new common_1.NotFoundException((0, api_locale_1.getLocaleText)('webauthnNotConfigured', 'en', 'WebAuthn not configured.'));
|
|
1042
|
+
}
|
|
1043
|
+
const rpID = new URL(process.env.FRONTEND_URL || 'http://localhost:3200').hostname;
|
|
1044
|
+
const allowCredentials = user.user_mfa
|
|
1045
|
+
.filter(mfa => mfa.user_mfa_webauthn && mfa.user_mfa_webauthn.length > 0)
|
|
1046
|
+
.map(mfa => ({
|
|
1047
|
+
id: Buffer.from(mfa.user_mfa_webauthn[0].credential_id).toString('base64url'),
|
|
1048
|
+
}));
|
|
1049
|
+
const options = await (0, server_1.generateAuthenticationOptions)({
|
|
1050
|
+
rpID,
|
|
1051
|
+
allowCredentials,
|
|
1052
|
+
userVerification: 'preferred',
|
|
1053
|
+
});
|
|
1054
|
+
await this.prisma.user_mfa_challenge.create({
|
|
1055
|
+
data: {
|
|
1056
|
+
user_mfa_id: user.user_mfa[0].id,
|
|
1057
|
+
hash: options.challenge,
|
|
1058
|
+
attempts: 0,
|
|
1059
|
+
expires_at: new Date(Date.now() + 5 * 60 * 1000),
|
|
1060
|
+
}
|
|
1061
|
+
});
|
|
1062
|
+
return options;
|
|
1063
|
+
}
|
|
1064
|
+
catch (error) {
|
|
1065
|
+
throw new common_1.BadRequestException(`Failed to generate authentication options: ${error === null || error === void 0 ? void 0 : error.message}`);
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
async verifyWebAuthnAuthenticationForLogin(mfaToken, assertionResponse) {
|
|
1069
|
+
try {
|
|
1070
|
+
const decoded = this.jwt.decode(mfaToken);
|
|
1071
|
+
if (!decoded || !decoded.userId) {
|
|
1072
|
+
throw new common_1.BadRequestException('Invalid MFA token');
|
|
1073
|
+
}
|
|
1074
|
+
const userId = decoded.userId;
|
|
1075
|
+
const challengeRecord = await this.prisma.user_mfa_challenge.findFirst({
|
|
1076
|
+
where: {
|
|
1077
|
+
user_mfa: {
|
|
1078
|
+
user_id: userId,
|
|
1079
|
+
type: 'webauthn',
|
|
1080
|
+
verified_at: { not: null },
|
|
1081
|
+
},
|
|
1082
|
+
verified_at: null,
|
|
1083
|
+
expires_at: { gt: new Date() }
|
|
1084
|
+
},
|
|
1085
|
+
include: {
|
|
1086
|
+
user_mfa: {
|
|
1087
|
+
include: { user_mfa_webauthn: true }
|
|
1088
|
+
}
|
|
1089
|
+
},
|
|
1090
|
+
orderBy: { created_at: 'desc' }
|
|
1091
|
+
});
|
|
1092
|
+
if (!challengeRecord || !challengeRecord.user_mfa.user_mfa_webauthn[0]) {
|
|
1093
|
+
throw new common_1.BadRequestException('Challenge not found or expired.');
|
|
1094
|
+
}
|
|
1095
|
+
const authenticator = challengeRecord.user_mfa.user_mfa_webauthn[0];
|
|
1096
|
+
const rpID = new URL(process.env.FRONTEND_URL || 'http://localhost:3200').hostname;
|
|
1097
|
+
const expectedOrigin = process.env.FRONTEND_URL || 'http://localhost:3200';
|
|
1098
|
+
const verification = await (0, server_1.verifyAuthenticationResponse)({
|
|
1099
|
+
response: assertionResponse,
|
|
1100
|
+
expectedChallenge: challengeRecord.hash,
|
|
1101
|
+
expectedOrigin,
|
|
1102
|
+
expectedRPID: rpID,
|
|
1103
|
+
credential: {
|
|
1104
|
+
id: Buffer.from(authenticator.credential_id).toString('base64url'),
|
|
1105
|
+
publicKey: authenticator.public_key,
|
|
1106
|
+
counter: authenticator.sign_count,
|
|
1107
|
+
},
|
|
1108
|
+
});
|
|
1109
|
+
if (!verification.verified) {
|
|
1110
|
+
throw new common_1.BadRequestException('Verification failed.');
|
|
1111
|
+
}
|
|
1112
|
+
await this.prisma.user_mfa_webauthn.update({
|
|
1113
|
+
where: { id: authenticator.id },
|
|
1114
|
+
data: {
|
|
1115
|
+
sign_count: verification.authenticationInfo.newCounter,
|
|
1116
|
+
last_used_at: new Date(),
|
|
1117
|
+
}
|
|
1118
|
+
});
|
|
1119
|
+
await this.prisma.user_mfa_challenge.update({
|
|
1120
|
+
where: { id: challengeRecord.id },
|
|
1121
|
+
data: { verified_at: new Date() }
|
|
1122
|
+
});
|
|
1123
|
+
const user = await this.prisma.user.findFirst({ where: { id: userId } });
|
|
1124
|
+
if (!user) {
|
|
1125
|
+
throw new common_1.NotFoundException((0, api_locale_1.getLocaleText)('userNotFound', 'en', 'User not found'));
|
|
1126
|
+
}
|
|
1127
|
+
const payload = { sub: userId };
|
|
1128
|
+
const accessToken = await this.token.createAccessToken(payload);
|
|
1129
|
+
const refreshToken = this.jwt.sign({ userId, type: 'refresh' }, { expiresIn: '7d' });
|
|
1130
|
+
return {
|
|
1131
|
+
accessToken,
|
|
1132
|
+
refreshToken,
|
|
1133
|
+
};
|
|
1134
|
+
}
|
|
1135
|
+
catch (error) {
|
|
1136
|
+
throw new common_1.BadRequestException(`Failed to verify authentication: ${error === null || error === void 0 ? void 0 : error.message}`);
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
async getUserToken(userId) {
|
|
1140
|
+
const updatedUser = await this.prisma.user.findFirst({ where: { id: userId } });
|
|
1141
|
+
return this.getToken(updatedUser);
|
|
1142
|
+
}
|
|
1143
|
+
};
|
|
1144
|
+
exports.ProfileService = ProfileService;
|
|
1145
|
+
exports.ProfileService = ProfileService = __decorate([
|
|
1146
|
+
(0, common_1.Injectable)(),
|
|
1147
|
+
__param(2, (0, common_1.Inject)((0, common_1.forwardRef)(() => jwt_1.JwtService))),
|
|
1148
|
+
__param(3, (0, common_1.Inject)((0, common_1.forwardRef)(() => setting_service_1.SettingService))),
|
|
1149
|
+
__param(6, (0, common_1.Inject)((0, common_1.forwardRef)(() => token_service_1.TokenService))),
|
|
1150
|
+
__metadata("design:paramtypes", [api_prisma_1.PrismaService,
|
|
1151
|
+
user_service_1.UserService,
|
|
1152
|
+
jwt_1.JwtService,
|
|
1153
|
+
setting_service_1.SettingService,
|
|
1154
|
+
security_service_1.SecurityService,
|
|
1155
|
+
challenge_service_1.ChallengeService,
|
|
1156
|
+
token_service_1.TokenService])
|
|
1157
|
+
], ProfileService);
|
|
1158
|
+
//# sourceMappingURL=profile.service.js.map
|