@hed-hog/core 0.0.390 → 0.0.394
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -0
- package/dist/access-log/access-log.controller.d.ts.map +1 -1
- package/dist/access-log/access-log.controller.js +1 -1
- package/dist/access-log/access-log.controller.js.map +1 -1
- package/dist/access-log/access-log.interceptor.d.ts.map +1 -1
- package/dist/access-log/access-log.interceptor.js +8 -5
- package/dist/access-log/access-log.interceptor.js.map +1 -1
- package/dist/access-log/access-log.service.d.ts +4 -0
- package/dist/access-log/access-log.service.d.ts.map +1 -1
- package/dist/access-log/access-log.service.js +31 -4
- package/dist/access-log/access-log.service.js.map +1 -1
- package/dist/access-log/dto/query-access-log.dto.d.ts +2 -0
- package/dist/access-log/dto/query-access-log.dto.d.ts.map +1 -1
- package/dist/access-log/dto/query-access-log.dto.js +5 -0
- package/dist/access-log/dto/query-access-log.dto.js.map +1 -1
- package/dist/ai/ai.controller.d.ts +12 -8
- package/dist/ai/ai.controller.d.ts.map +1 -1
- package/dist/ai/ai.controller.js +17 -2
- package/dist/ai/ai.controller.js.map +1 -1
- package/dist/ai/ai.module.d.ts.map +1 -1
- package/dist/ai/ai.module.js +3 -2
- package/dist/ai/ai.module.js.map +1 -1
- package/dist/ai/ai.service.d.ts +30 -1
- package/dist/ai/ai.service.d.ts.map +1 -1
- package/dist/ai/ai.service.js +97 -3
- package/dist/ai/ai.service.js.map +1 -1
- package/dist/ai/dto/richtext-edit-html.dto.d.ts +5 -0
- package/dist/ai/dto/richtext-edit-html.dto.d.ts.map +1 -0
- package/dist/ai/dto/richtext-edit-html.dto.js +27 -0
- package/dist/ai/dto/richtext-edit-html.dto.js.map +1 -0
- package/dist/ai/richtext-ai.prompts.d.ts +5 -0
- package/dist/ai/richtext-ai.prompts.d.ts.map +1 -0
- package/dist/ai/richtext-ai.prompts.js +57 -0
- package/dist/ai/richtext-ai.prompts.js.map +1 -0
- package/dist/ai/richtext-ai.service.d.ts +34 -0
- package/dist/ai/richtext-ai.service.d.ts.map +1 -0
- package/dist/ai/richtext-ai.service.js +95 -0
- package/dist/ai/richtext-ai.service.js.map +1 -0
- package/dist/ai-instruction/ai-instruction.controller.d.ts +5 -5
- package/dist/auth/auth.controller.d.ts +66 -7
- package/dist/auth/auth.controller.d.ts.map +1 -1
- package/dist/auth/auth.controller.js +67 -23
- package/dist/auth/auth.controller.js.map +1 -1
- package/dist/auth/auth.module.d.ts.map +1 -1
- package/dist/auth/auth.module.js +2 -0
- package/dist/auth/auth.module.js.map +1 -1
- package/dist/auth/auth.service.d.ts +136 -4
- package/dist/auth/auth.service.d.ts.map +1 -1
- package/dist/auth/auth.service.js +246 -48
- package/dist/auth/auth.service.js.map +1 -1
- package/dist/auth/dto/confirm-email.dto.d.ts +4 -0
- package/dist/auth/dto/confirm-email.dto.d.ts.map +1 -0
- package/dist/auth/dto/confirm-email.dto.js +22 -0
- package/dist/auth/dto/confirm-email.dto.js.map +1 -0
- package/dist/auth/dto/resend-confirmation.dto.d.ts +8 -0
- package/dist/auth/dto/resend-confirmation.dto.d.ts.map +1 -0
- package/dist/auth/dto/resend-confirmation.dto.js +36 -0
- package/dist/auth/dto/resend-confirmation.dto.js.map +1 -0
- package/dist/authorize/authorize.controller.d.ts +1 -1
- package/dist/authorize/authorize.controller.d.ts.map +1 -1
- package/dist/authorize/authorize.controller.js +4 -2
- package/dist/authorize/authorize.controller.js.map +1 -1
- package/dist/authorize/authorize.service.d.ts +7 -0
- package/dist/authorize/authorize.service.d.ts.map +1 -1
- package/dist/authorize/authorize.service.js +1 -1
- package/dist/authorize/authorize.service.js.map +1 -1
- package/dist/challenge/challenge.service.d.ts +18 -5
- package/dist/challenge/challenge.service.d.ts.map +1 -1
- package/dist/challenge/challenge.service.js +50 -3
- package/dist/challenge/challenge.service.js.map +1 -1
- package/dist/core.module.d.ts.map +1 -1
- package/dist/core.module.js +17 -0
- package/dist/core.module.js.map +1 -1
- package/dist/dashboard/dashboard/dashboard.controller.d.ts +6 -6
- package/dist/dashboard/dashboard/dashboard.service.d.ts +6 -6
- package/dist/dashboard/dashboard-component/dashboard-component.controller.d.ts +4 -4
- package/dist/dashboard/dashboard-component/dashboard-component.service.d.ts +4 -4
- package/dist/dashboard/dashboard-component-role/dashboard-component-role.controller.d.ts +1 -1
- package/dist/dashboard/dashboard-component-role/dashboard-component-role.service.d.ts +1 -1
- package/dist/dashboard/dashboard-core/dashboard-core.controller.d.ts +2 -2
- package/dist/dashboard/dashboard-core/dashboard-core.service.d.ts +2 -2
- package/dist/dashboard/dashboard-item/dashboard-item.controller.d.ts +2 -2
- package/dist/dashboard/dashboard-item/dashboard-item.service.d.ts +2 -2
- package/dist/file/file.controller.d.ts +8 -1
- package/dist/file/file.controller.d.ts.map +1 -1
- package/dist/file/file.controller.js +45 -7
- package/dist/file/file.controller.js.map +1 -1
- package/dist/file/file.service.d.ts +128 -1
- package/dist/file/file.service.d.ts.map +1 -1
- package/dist/file/file.service.js +319 -8
- package/dist/file/file.service.js.map +1 -1
- package/dist/file/image-optimization.service.d.ts +43 -0
- package/dist/file/image-optimization.service.d.ts.map +1 -1
- package/dist/file/image-optimization.service.js +154 -0
- package/dist/file/image-optimization.service.js.map +1 -1
- package/dist/file/provider/abstract.provider.d.ts +16 -0
- package/dist/file/provider/abstract.provider.d.ts.map +1 -1
- package/dist/file/provider/abstract.provider.js +4 -0
- package/dist/file/provider/abstract.provider.js.map +1 -1
- package/dist/file/provider/gcs.provider.d.ts +2 -0
- package/dist/file/provider/gcs.provider.d.ts.map +1 -1
- package/dist/file/provider/gcs.provider.js +10 -0
- package/dist/file/provider/gcs.provider.js.map +1 -1
- package/dist/file/provider/local.provider.d.ts +1 -0
- package/dist/file/provider/local.provider.d.ts.map +1 -1
- package/dist/file/provider/local.provider.js +13 -0
- package/dist/file/provider/local.provider.js.map +1 -1
- package/dist/file/provider/s3.provider.d.ts +5 -0
- package/dist/file/provider/s3.provider.d.ts.map +1 -1
- package/dist/file/provider/s3.provider.js +15 -0
- package/dist/file/provider/s3.provider.js.map +1 -1
- package/dist/file/provider/spaces.provider.d.ts +5 -0
- package/dist/file/provider/spaces.provider.d.ts.map +1 -1
- package/dist/file/provider/spaces.provider.js +16 -0
- package/dist/file/provider/spaces.provider.js.map +1 -1
- package/dist/impersonation/dto/redeem-impersonation.dto.d.ts +4 -0
- package/dist/impersonation/dto/redeem-impersonation.dto.d.ts.map +1 -0
- package/dist/impersonation/dto/redeem-impersonation.dto.js +23 -0
- package/dist/impersonation/dto/redeem-impersonation.dto.js.map +1 -0
- package/dist/impersonation/dto/start-impersonation.dto.d.ts +7 -0
- package/dist/impersonation/dto/start-impersonation.dto.d.ts.map +1 -0
- package/dist/impersonation/dto/start-impersonation.dto.js +27 -0
- package/dist/impersonation/dto/start-impersonation.dto.js.map +1 -0
- package/dist/impersonation/impersonation-restrictions.d.ts +26 -0
- package/dist/impersonation/impersonation-restrictions.d.ts.map +1 -0
- package/dist/impersonation/impersonation-restrictions.js +76 -0
- package/dist/impersonation/impersonation-restrictions.js.map +1 -0
- package/dist/impersonation/impersonation.controller.d.ts +90 -0
- package/dist/impersonation/impersonation.controller.d.ts.map +1 -0
- package/dist/impersonation/impersonation.controller.js +135 -0
- package/dist/impersonation/impersonation.controller.js.map +1 -0
- package/dist/impersonation/impersonation.module.d.ts +8 -0
- package/dist/impersonation/impersonation.module.d.ts.map +1 -0
- package/dist/impersonation/impersonation.module.js +44 -0
- package/dist/impersonation/impersonation.module.js.map +1 -0
- package/dist/impersonation/impersonation.service.d.ts +164 -0
- package/dist/impersonation/impersonation.service.d.ts.map +1 -0
- package/dist/impersonation/impersonation.service.js +408 -0
- package/dist/impersonation/impersonation.service.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -1
- package/dist/integration/services/outbox-polling.coordinator.d.ts +2 -0
- package/dist/integration/services/outbox-polling.coordinator.d.ts.map +1 -1
- package/dist/integration/services/outbox-polling.coordinator.js +50 -30
- package/dist/integration/services/outbox-polling.coordinator.js.map +1 -1
- package/dist/integration/services/outbox.service.d.ts.map +1 -1
- package/dist/integration/services/outbox.service.js +5 -1
- package/dist/integration/services/outbox.service.js.map +1 -1
- package/dist/integration-profile/integration-profile.secrets.d.ts.map +1 -1
- package/dist/integration-profile/integration-profile.secrets.js +3 -0
- package/dist/integration-profile/integration-profile.secrets.js.map +1 -1
- package/dist/integration-profile/integration-profile.utils.d.ts +14 -0
- package/dist/integration-profile/integration-profile.utils.d.ts.map +1 -1
- package/dist/integration-profile/integration-profile.utils.js +26 -0
- package/dist/integration-profile/integration-profile.utils.js.map +1 -1
- package/dist/integration-profile/testers/email.testers.d.ts.map +1 -1
- package/dist/integration-profile/testers/email.testers.js +28 -0
- package/dist/integration-profile/testers/email.testers.js.map +1 -1
- package/dist/language/en.json +11 -0
- package/dist/language/pt.json +11 -0
- package/dist/mail/dto/send.dto.d.ts +38 -1
- package/dist/mail/dto/send.dto.d.ts.map +1 -1
- package/dist/mail/dto/send.dto.js +10 -0
- package/dist/mail/dto/send.dto.js.map +1 -1
- package/dist/mail/mail.controller.d.ts +1 -0
- package/dist/mail/mail.controller.d.ts.map +1 -1
- package/dist/mail/mail.module.d.ts.map +1 -1
- package/dist/mail/mail.module.js +2 -0
- package/dist/mail/mail.module.js.map +1 -1
- package/dist/mail/mail.service.d.ts +48 -4
- package/dist/mail/mail.service.d.ts.map +1 -1
- package/dist/mail/mail.service.js +187 -35
- package/dist/mail/mail.service.js.map +1 -1
- package/dist/mail-delivery/mail-delivery-provision.service.d.ts +21 -0
- package/dist/mail-delivery/mail-delivery-provision.service.d.ts.map +1 -0
- package/dist/mail-delivery/mail-delivery-provision.service.js +64 -0
- package/dist/mail-delivery/mail-delivery-provision.service.js.map +1 -0
- package/dist/mail-delivery/mail-delivery.constants.d.ts +17 -0
- package/dist/mail-delivery/mail-delivery.constants.d.ts.map +1 -0
- package/dist/mail-delivery/mail-delivery.constants.js +31 -0
- package/dist/mail-delivery/mail-delivery.constants.js.map +1 -0
- package/dist/mail-delivery/mail-delivery.controller.d.ts +19 -0
- package/dist/mail-delivery/mail-delivery.controller.d.ts.map +1 -0
- package/dist/mail-delivery/mail-delivery.controller.js +53 -0
- package/dist/mail-delivery/mail-delivery.controller.js.map +1 -0
- package/dist/mail-delivery/mail-delivery.module.d.ts +7 -0
- package/dist/mail-delivery/mail-delivery.module.d.ts.map +1 -0
- package/dist/mail-delivery/mail-delivery.module.js +36 -0
- package/dist/mail-delivery/mail-delivery.module.js.map +1 -0
- package/dist/mail-delivery/mail-delivery.service.d.ts +38 -0
- package/dist/mail-delivery/mail-delivery.service.d.ts.map +1 -0
- package/dist/mail-delivery/mail-delivery.service.js +140 -0
- package/dist/mail-delivery/mail-delivery.service.js.map +1 -0
- package/dist/mail-delivery/ses-event.parser.d.ts +27 -0
- package/dist/mail-delivery/ses-event.parser.d.ts.map +1 -0
- package/dist/mail-delivery/ses-event.parser.js +131 -0
- package/dist/mail-delivery/ses-event.parser.js.map +1 -0
- package/dist/mail-delivery/ses-webhook.service.d.ts +58 -0
- package/dist/mail-delivery/ses-webhook.service.d.ts.map +1 -0
- package/dist/mail-delivery/ses-webhook.service.js +214 -0
- package/dist/mail-delivery/ses-webhook.service.js.map +1 -0
- package/dist/mail-delivery/sns-message.util.d.ts +38 -0
- package/dist/mail-delivery/sns-message.util.d.ts.map +1 -0
- package/dist/mail-delivery/sns-message.util.js +109 -0
- package/dist/mail-delivery/sns-message.util.js.map +1 -0
- package/dist/mail-sent/dto/query-mail-sent-list.dto.d.ts +5 -0
- package/dist/mail-sent/dto/query-mail-sent-list.dto.d.ts.map +1 -1
- package/dist/mail-sent/dto/query-mail-sent-list.dto.js +6 -0
- package/dist/mail-sent/dto/query-mail-sent-list.dto.js.map +1 -1
- package/dist/mail-sent/mail-sent.controller.d.ts +39 -0
- package/dist/mail-sent/mail-sent.controller.d.ts.map +1 -1
- package/dist/mail-sent/mail-sent.service.d.ts +39 -0
- package/dist/mail-sent/mail-sent.service.d.ts.map +1 -1
- package/dist/mail-sent/mail-sent.service.js +45 -4
- package/dist/mail-sent/mail-sent.service.js.map +1 -1
- package/dist/mailbox/mailbox-fetcher.registry.d.ts +100 -0
- package/dist/mailbox/mailbox-fetcher.registry.d.ts.map +1 -0
- package/dist/mailbox/mailbox-fetcher.registry.js +59 -0
- package/dist/mailbox/mailbox-fetcher.registry.js.map +1 -0
- package/dist/mailbox/mailbox.module.d.ts +8 -0
- package/dist/mailbox/mailbox.module.d.ts.map +1 -0
- package/dist/mailbox/mailbox.module.js +27 -0
- package/dist/mailbox/mailbox.module.js.map +1 -0
- package/dist/meeting/meeting-provider.registry.d.ts +155 -0
- package/dist/meeting/meeting-provider.registry.d.ts.map +1 -0
- package/dist/meeting/meeting-provider.registry.js +53 -0
- package/dist/meeting/meeting-provider.registry.js.map +1 -0
- package/dist/meeting/meeting.constants.d.ts +47 -0
- package/dist/meeting/meeting.constants.d.ts.map +1 -0
- package/dist/meeting/meeting.constants.js +21 -0
- package/dist/meeting/meeting.constants.js.map +1 -0
- package/dist/meeting/meeting.module.d.ts +7 -0
- package/dist/meeting/meeting.module.d.ts.map +1 -0
- package/dist/meeting/meeting.module.js +26 -0
- package/dist/meeting/meeting.module.js.map +1 -0
- package/dist/middlewares/locale-injection.middleware.d.ts +12 -0
- package/dist/middlewares/locale-injection.middleware.d.ts.map +1 -1
- package/dist/middlewares/locale-injection.middleware.js +20 -4
- package/dist/middlewares/locale-injection.middleware.js.map +1 -1
- package/dist/oauth/providers/google.provider.d.ts +7 -0
- package/dist/oauth/providers/google.provider.d.ts.map +1 -1
- package/dist/oauth/providers/google.provider.js +43 -13
- package/dist/oauth/providers/google.provider.js.map +1 -1
- package/dist/observability/monitored-cron.d.ts +34 -0
- package/dist/observability/monitored-cron.d.ts.map +1 -0
- package/dist/observability/monitored-cron.js +118 -0
- package/dist/observability/monitored-cron.js.map +1 -0
- package/dist/pairing/dto/approve-reverse-pairing.dto.d.ts +12 -0
- package/dist/pairing/dto/approve-reverse-pairing.dto.d.ts.map +1 -0
- package/dist/pairing/dto/approve-reverse-pairing.dto.js +30 -0
- package/dist/pairing/dto/approve-reverse-pairing.dto.js.map +1 -0
- package/dist/pairing/dto/claim-pairing.dto.d.ts +11 -0
- package/dist/pairing/dto/claim-pairing.dto.d.ts.map +1 -0
- package/dist/pairing/dto/claim-pairing.dto.js +35 -0
- package/dist/pairing/dto/claim-pairing.dto.js.map +1 -0
- package/dist/pairing/dto/confirm-pairing.dto.d.ts +10 -0
- package/dist/pairing/dto/confirm-pairing.dto.d.ts.map +1 -0
- package/dist/pairing/dto/confirm-pairing.dto.js +24 -0
- package/dist/pairing/dto/confirm-pairing.dto.js.map +1 -0
- package/dist/pairing/dto/poll-reverse-pairing.dto.d.ts +5 -0
- package/dist/pairing/dto/poll-reverse-pairing.dto.d.ts.map +1 -0
- package/dist/pairing/dto/poll-reverse-pairing.dto.js +24 -0
- package/dist/pairing/dto/poll-reverse-pairing.dto.js.map +1 -0
- package/dist/pairing/dto/start-pairing.dto.d.ts +11 -0
- package/dist/pairing/dto/start-pairing.dto.d.ts.map +1 -0
- package/dist/pairing/dto/start-pairing.dto.js +30 -0
- package/dist/pairing/dto/start-pairing.dto.js.map +1 -0
- package/dist/pairing/dto/start-reverse-pairing.dto.d.ts +24 -0
- package/dist/pairing/dto/start-reverse-pairing.dto.d.ts.map +1 -0
- package/dist/pairing/dto/start-reverse-pairing.dto.js +47 -0
- package/dist/pairing/dto/start-reverse-pairing.dto.js.map +1 -0
- package/dist/pairing/pairing.controller.d.ts +118 -0
- package/dist/pairing/pairing.controller.d.ts.map +1 -0
- package/dist/pairing/pairing.controller.js +296 -0
- package/dist/pairing/pairing.controller.js.map +1 -0
- package/dist/pairing/pairing.module.d.ts +10 -0
- package/dist/pairing/pairing.module.d.ts.map +1 -0
- package/dist/pairing/pairing.module.js +40 -0
- package/dist/pairing/pairing.module.js.map +1 -0
- package/dist/pairing/pairing.service.d.ts +238 -0
- package/dist/pairing/pairing.service.d.ts.map +1 -0
- package/dist/pairing/pairing.service.js +495 -0
- package/dist/pairing/pairing.service.js.map +1 -0
- package/dist/pdf/pdf.service.d.ts +3 -6
- package/dist/pdf/pdf.service.d.ts.map +1 -1
- package/dist/pdf/pdf.service.js +8 -20
- package/dist/pdf/pdf.service.js.map +1 -1
- package/dist/profile/profile.controller.d.ts +11 -0
- package/dist/profile/profile.controller.d.ts.map +1 -1
- package/dist/profile/profile.service.d.ts +11 -0
- package/dist/profile/profile.service.d.ts.map +1 -1
- package/dist/profile/profile.service.js +20 -11
- package/dist/profile/profile.service.js.map +1 -1
- package/dist/redis/redis-pubsub.d.ts.map +1 -1
- package/dist/redis/redis-pubsub.js +44 -0
- package/dist/redis/redis-pubsub.js.map +1 -1
- package/dist/role/guards/role.guard.d.ts +5 -0
- package/dist/role/guards/role.guard.d.ts.map +1 -1
- package/dist/role/guards/role.guard.js +41 -39
- package/dist/role/guards/role.guard.js.map +1 -1
- package/dist/session/session.controller.d.ts +2 -0
- package/dist/session/session.controller.d.ts.map +1 -1
- package/dist/session/session.service.d.ts +39 -0
- package/dist/session/session.service.d.ts.map +1 -1
- package/dist/session/session.service.js +91 -8
- package/dist/session/session.service.js.map +1 -1
- package/dist/setting/brand-asset.service.d.ts +48 -0
- package/dist/setting/brand-asset.service.d.ts.map +1 -0
- package/dist/setting/brand-asset.service.js +130 -0
- package/dist/setting/brand-asset.service.js.map +1 -0
- package/dist/setting/setting.module.d.ts.map +1 -1
- package/dist/setting/setting.module.js +3 -2
- package/dist/setting/setting.module.js.map +1 -1
- package/dist/setting/setting.service.d.ts +33 -0
- package/dist/setting/setting.service.d.ts.map +1 -1
- package/dist/setting/setting.service.js +88 -0
- package/dist/setting/setting.service.js.map +1 -1
- package/dist/token/token.service.d.ts +23 -2
- package/dist/token/token.service.d.ts.map +1 -1
- package/dist/token/token.service.js +39 -4
- package/dist/token/token.service.js.map +1 -1
- package/dist/user/user.controller.d.ts +8 -22
- package/dist/user/user.controller.d.ts.map +1 -1
- package/dist/user/user.service.d.ts +44 -24
- package/dist/user/user.service.d.ts.map +1 -1
- package/dist/user/user.service.js +89 -6
- package/dist/user/user.service.js.map +1 -1
- package/dist/user-device/user-device.controller.d.ts +54 -0
- package/dist/user-device/user-device.controller.d.ts.map +1 -0
- package/dist/user-device/user-device.controller.js +103 -0
- package/dist/user-device/user-device.controller.js.map +1 -0
- package/dist/user-device/user-device.module.d.ts +3 -0
- package/dist/user-device/user-device.module.d.ts.map +1 -0
- package/dist/user-device/user-device.module.js +26 -0
- package/dist/user-device/user-device.module.js.map +1 -0
- package/dist/user-device/user-device.service.d.ts +71 -0
- package/dist/user-device/user-device.service.d.ts.map +1 -0
- package/dist/user-device/user-device.service.js +158 -0
- package/dist/user-device/user-device.service.js.map +1 -0
- package/dist/utils/device-key.d.ts +23 -0
- package/dist/utils/device-key.d.ts.map +1 -0
- package/dist/utils/device-key.js +31 -0
- package/dist/utils/device-key.js.map +1 -0
- package/dist/utils/geo-ip.d.ts +38 -0
- package/dist/utils/geo-ip.d.ts.map +1 -0
- package/dist/utils/geo-ip.js +122 -0
- package/dist/utils/geo-ip.js.map +1 -0
- package/dist/utils/locale-context.d.ts +10 -7
- package/dist/utils/locale-context.d.ts.map +1 -1
- package/dist/utils/locale-context.js +14 -8
- package/dist/utils/locale-context.js.map +1 -1
- package/dist/utils/security-event-vars.d.ts +56 -0
- package/dist/utils/security-event-vars.d.ts.map +1 -0
- package/dist/utils/security-event-vars.js +109 -0
- package/dist/utils/security-event-vars.js.map +1 -0
- package/dist/utils/user-agent.d.ts +19 -0
- package/dist/utils/user-agent.d.ts.map +1 -0
- package/dist/utils/user-agent.js +36 -0
- package/dist/utils/user-agent.js.map +1 -0
- package/dist/webhook-integration/webhook-integration.service.d.ts +5 -0
- package/dist/webhook-integration/webhook-integration.service.d.ts.map +1 -1
- package/dist/webhook-integration/webhook-integration.service.js +50 -4
- package/dist/webhook-integration/webhook-integration.service.js.map +1 -1
- package/dist/webhook-integration/webhook-protocol.registry.d.ts +6 -0
- package/dist/webhook-integration/webhook-protocol.registry.d.ts.map +1 -1
- package/dist/webhook-integration/webhook-protocol.registry.js.map +1 -1
- package/hedhog/data/integration_provider.yaml +9 -0
- package/hedhog/data/mail.yaml +198 -62
- package/hedhog/data/mail_layout.yaml +43 -33
- package/hedhog/data/menu.yaml +2 -0
- package/hedhog/data/role.yaml +16 -0
- package/hedhog/data/route.yaml +172 -3
- package/hedhog/data/setting_group.yaml +178 -2
- package/hedhog/data/setting_subgroup.yaml +8 -0
- package/hedhog/frontend/app/_lib/hooks/use-core-access.test.tsx.ejs +125 -0
- package/hedhog/frontend/app/_lib/hooks/use-core-access.ts.ejs +29 -0
- package/hedhog/frontend/app/_lib/hooks/use-impersonation-access.test.ts.ejs +71 -0
- package/hedhog/frontend/app/_lib/hooks/use-impersonation-access.ts.ejs +32 -0
- package/hedhog/frontend/app/access-log/page.tsx.ejs +96 -22
- package/hedhog/frontend/app/account/components/active-sessions.tsx.ejs +17 -1
- package/hedhog/frontend/app/account/components/known-devices.tsx.ejs +89 -0
- package/hedhog/frontend/app/account/components/profile-form.tsx.ejs +2 -1
- package/hedhog/frontend/app/account/components/user-devices-list.tsx.ejs +186 -0
- package/hedhog/frontend/app/account/devices/page.tsx.ejs +5 -0
- package/hedhog/frontend/app/account/layout.tsx.ejs +2 -0
- package/hedhog/frontend/app/configurations/[slug]/components/setting-field.test.tsx.ejs +298 -0
- package/hedhog/frontend/app/configurations/[slug]/components/setting-field.tsx.ejs +376 -1236
- package/hedhog/frontend/app/mail/log/page.tsx.ejs +210 -3
- package/hedhog/frontend/app/mail/template/page.tsx.ejs +190 -132
- package/hedhog/frontend/app/users/active-session.tsx.ejs +58 -11
- package/hedhog/frontend/app/users/page.tsx.ejs +69 -10
- package/hedhog/frontend/app/users/simulate-access-dialog.test.tsx.ejs +202 -0
- package/hedhog/frontend/app/users/simulate-access-dialog.tsx.ejs +170 -0
- package/hedhog/frontend/app/users/user-activity-timeline.tsx.ejs +19 -0
- package/hedhog/frontend/app/users/user-devices.tsx.ejs +89 -0
- package/hedhog/frontend/app/users/user-logs.tsx.ejs +13 -1
- package/hedhog/frontend/app/users/user-sheet.tsx.ejs +46 -24
- package/hedhog/frontend/messages/en.json +146 -48
- package/hedhog/frontend/messages/pt.json +146 -48
- package/hedhog/table/access_log.yaml +7 -0
- package/hedhog/table/file.yaml +8 -0
- package/hedhog/table/mail_delivery_event.yaml +76 -0
- package/hedhog/table/mail_sent.yaml +23 -0
- package/hedhog/table/user_activity.yaml +9 -0
- package/hedhog/table/user_device.yaml +52 -0
- package/hedhog/table/user_session.yaml +20 -1
- package/package.json +6 -5
- package/src/access-log/access-log.controller.ts +1 -0
- package/src/access-log/access-log.interceptor.ts +5 -1
- package/src/access-log/access-log.service.spec.ts +33 -2
- package/src/access-log/access-log.service.ts +38 -0
- package/src/access-log/dto/query-access-log.dto.ts +5 -0
- package/src/ai/ai.controller.ts +9 -0
- package/src/ai/ai.module.ts +3 -2
- package/src/ai/ai.service.ts +150 -13
- package/src/ai/dto/richtext-edit-html.dto.ts +11 -0
- package/src/ai/richtext-ai.prompts.ts +57 -0
- package/src/ai/richtext-ai.service.ts +109 -0
- package/src/auth/auth.controller.ts +47 -8
- package/src/auth/auth.module.ts +2 -0
- package/src/auth/auth.service.spec.ts +383 -6
- package/src/auth/auth.service.ts +345 -56
- package/src/auth/dto/confirm-email.dto.ts +7 -0
- package/src/auth/dto/resend-confirmation.dto.ts +20 -0
- package/src/authorize/authorize.controller.ts +2 -0
- package/src/authorize/authorize.service.spec.ts +23 -0
- package/src/authorize/authorize.service.ts +8 -0
- package/src/challenge/challenge.service.spec.ts +73 -0
- package/src/challenge/challenge.service.ts +62 -3
- package/src/core.module.ts +19 -0
- package/src/file/file.controller.ts +54 -4
- package/src/file/file.service.spec.ts +275 -105
- package/src/file/file.service.ts +409 -14
- package/src/file/image-optimization.service.spec.ts +92 -0
- package/src/file/image-optimization.service.ts +202 -0
- package/src/file/provider/abstract.provider.ts +23 -0
- package/src/file/provider/gcs.provider.ts +17 -0
- package/src/file/provider/local.provider.ts +21 -0
- package/src/file/provider/s3.provider.ts +25 -0
- package/src/file/provider/spaces.provider.ts +26 -0
- package/src/impersonation/dto/redeem-impersonation.dto.ts +8 -0
- package/src/impersonation/dto/start-impersonation.dto.ts +13 -0
- package/src/impersonation/impersonation-restrictions.ts +84 -0
- package/src/impersonation/impersonation.controller.ts +109 -0
- package/src/impersonation/impersonation.module.ts +31 -0
- package/src/impersonation/impersonation.service.spec.ts +427 -0
- package/src/impersonation/impersonation.service.ts +577 -0
- package/src/index.ts +21 -0
- package/src/integration/services/outbox-polling.coordinator.spec.ts +90 -0
- package/src/integration/services/outbox-polling.coordinator.ts +62 -40
- package/src/integration/services/outbox.service.spec.ts +8 -0
- package/src/integration/services/outbox.service.ts +19 -13
- package/src/integration-profile/integration-profile.secrets.ts +3 -0
- package/src/integration-profile/integration-profile.utils.ts +38 -0
- package/src/integration-profile/testers/email.testers.ts +34 -1
- package/src/language/en.json +11 -0
- package/src/language/pt.json +11 -0
- package/src/mail/dto/send.dto.ts +46 -2
- package/src/mail/mail-template.spec.ts +79 -2
- package/src/mail/mail.module.ts +2 -0
- package/src/mail/mail.service.spec.ts +307 -6
- package/src/mail/mail.service.ts +227 -30
- package/src/mail-delivery/mail-delivery-provision.service.ts +66 -0
- package/src/mail-delivery/mail-delivery.constants.ts +31 -0
- package/src/mail-delivery/mail-delivery.controller.ts +38 -0
- package/src/mail-delivery/mail-delivery.module.ts +23 -0
- package/src/mail-delivery/mail-delivery.service.spec.ts +136 -0
- package/src/mail-delivery/mail-delivery.service.ts +152 -0
- package/src/mail-delivery/ses-event.parser.spec.ts +140 -0
- package/src/mail-delivery/ses-event.parser.ts +191 -0
- package/src/mail-delivery/ses-webhook.service.spec.ts +170 -0
- package/src/mail-delivery/ses-webhook.service.ts +240 -0
- package/src/mail-delivery/sns-message.util.spec.ts +163 -0
- package/src/mail-delivery/sns-message.util.ts +125 -0
- package/src/mail-sent/dto/query-mail-sent-list.dto.ts +15 -0
- package/src/mail-sent/mail-sent.service.ts +46 -2
- package/src/mailbox/mailbox-fetcher.registry.ts +132 -0
- package/src/mailbox/mailbox.module.ts +14 -0
- package/src/meeting/meeting-provider.registry.ts +193 -0
- package/src/meeting/meeting.constants.ts +53 -0
- package/src/meeting/meeting.module.ts +13 -0
- package/src/middlewares/locale-injection.middleware.ts +25 -6
- package/src/oauth/providers/google.provider.ts +49 -15
- package/src/observability/monitored-cron.spec.ts +102 -0
- package/src/observability/monitored-cron.ts +110 -0
- package/src/pairing/dto/approve-reverse-pairing.dto.ts +20 -0
- package/src/pairing/dto/claim-pairing.dto.ts +19 -0
- package/src/pairing/dto/confirm-pairing.dto.ts +14 -0
- package/src/pairing/dto/poll-reverse-pairing.dto.ts +9 -0
- package/src/pairing/dto/start-pairing.dto.ts +19 -0
- package/src/pairing/dto/start-reverse-pairing.dto.ts +45 -0
- package/src/pairing/pairing.controller.ts +246 -0
- package/src/pairing/pairing.module.ts +27 -0
- package/src/pairing/pairing.service.spec.ts +462 -0
- package/src/pairing/pairing.service.ts +614 -0
- package/src/pdf/pdf.service.ts +6 -24
- package/src/profile/profile.service.ts +26 -8
- package/src/redis/redis-pubsub.ts +11 -0
- package/src/role/guards/role.guard.spec.ts +75 -0
- package/src/role/guards/role.guard.ts +64 -46
- package/src/session/session.service.spec.ts +81 -0
- package/src/session/session.service.ts +93 -6
- package/src/setting/brand-asset.service.ts +137 -0
- package/src/setting/setting.module.ts +3 -2
- package/src/setting/setting.service.spec.ts +79 -1
- package/src/setting/setting.service.ts +109 -1
- package/src/token/token.service.spec.ts +62 -0
- package/src/token/token.service.ts +57 -3
- package/src/user/user.service.spec.ts +33 -2
- package/src/user/user.service.ts +108 -6
- package/src/user-device/user-device.controller.ts +77 -0
- package/src/user-device/user-device.module.ts +13 -0
- package/src/user-device/user-device.service.spec.ts +234 -0
- package/src/user-device/user-device.service.ts +168 -0
- package/src/utils/device-key.spec.ts +57 -0
- package/src/utils/device-key.ts +32 -0
- package/src/utils/geo-ip.spec.ts +134 -0
- package/src/utils/geo-ip.ts +93 -0
- package/src/utils/locale-context.spec.ts +27 -1
- package/src/utils/locale-context.ts +15 -12
- package/src/utils/security-event-vars.spec.ts +161 -0
- package/src/utils/security-event-vars.ts +153 -0
- package/src/utils/user-agent.spec.ts +37 -0
- package/src/utils/user-agent.ts +46 -0
- package/src/webhook-integration/webhook-integration.service.ts +57 -3
- package/src/webhook-integration/webhook-protocol.registry.ts +6 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NoRole, Public, User, UserOptional } from '@hed-hog/api';
|
|
1
|
+
import { Impersonation, ImpersonationContext, NoRole, Public, Session, User, UserOptional } from '@hed-hog/api';
|
|
2
2
|
import { Locale } from '@hed-hog/api-locale';
|
|
3
3
|
import {
|
|
4
4
|
Body,
|
|
@@ -19,14 +19,15 @@ import { Throttle, ThrottlerGuard } from '@nestjs/throttler';
|
|
|
19
19
|
import type { PublicKeyCredentialRequestOptionsJSON } from '@simplewebauthn/server';
|
|
20
20
|
import { TokenService } from '../token/token.service';
|
|
21
21
|
import { CreateWithEmailAndPasswordDTO } from '../user/dto/create-with-email-and-password.dto';
|
|
22
|
-
import { UserService } from '../user/user.service';
|
|
23
22
|
import { AuthService } from './auth.service';
|
|
23
|
+
import { ConfirmEmailDTO } from './dto/confirm-email.dto';
|
|
24
24
|
import { ForgetDTO } from './dto/forget.dto';
|
|
25
25
|
import { LoginEmailVerificationResendDTO } from './dto/login-email-verification-resend.dto';
|
|
26
26
|
import { LoginEmailVerificationDTO } from './dto/login-email-verification.dto';
|
|
27
27
|
import { LoginWithCodeDTO } from './dto/login-with-code.dto';
|
|
28
28
|
import { LoginWithRecoveryCodeDTO } from './dto/login-with-recovery-code';
|
|
29
29
|
import { LoginDTO } from './dto/login.dto';
|
|
30
|
+
import { ResendConfirmationDTO } from './dto/resend-confirmation.dto';
|
|
30
31
|
import { ResendMfaCodeDTO } from './dto/resend-mfa-code.dto';
|
|
31
32
|
import { ResetDTO } from './dto/reset.dto';
|
|
32
33
|
import { CompleteAccountDTO, VerifyAccountInviteDTO } from './dto/complete-account.dto';
|
|
@@ -40,25 +41,24 @@ export class AuthController {
|
|
|
40
41
|
private readonly service: AuthService,
|
|
41
42
|
@Inject(forwardRef(() => TokenService))
|
|
42
43
|
private readonly token: TokenService,
|
|
43
|
-
@Inject(forwardRef(() => UserService))
|
|
44
|
-
private readonly user: UserService,
|
|
45
44
|
) { }
|
|
46
45
|
|
|
47
46
|
@NoRole()
|
|
48
47
|
@Get('verify')
|
|
49
|
-
async verify(@User() { id }, @Locale() locale: string) {
|
|
50
|
-
return this.service.verifyUser(locale, id);
|
|
48
|
+
async verify(@User() { id }, @Session() sessionId: number, @Locale() locale: string) {
|
|
49
|
+
return this.service.verifyUser(locale, id, sessionId);
|
|
51
50
|
}
|
|
52
51
|
|
|
53
52
|
@NoRole()
|
|
54
53
|
@Get('desktop-token')
|
|
55
54
|
async desktopToken(
|
|
56
55
|
@User() { id },
|
|
56
|
+
@Impersonation() impersonation: ImpersonationContext,
|
|
57
57
|
@Locale() locale: string,
|
|
58
58
|
@Ip() ipAddress: string,
|
|
59
59
|
@Headers('user-agent') userAgent: string,
|
|
60
60
|
) {
|
|
61
|
-
return this.service.issueDesktopToken(locale, id, ipAddress, userAgent);
|
|
61
|
+
return this.service.issueDesktopToken(locale, id, ipAddress, userAgent, impersonation.active);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
@NoRole()
|
|
@@ -137,13 +137,50 @@ export class AuthController {
|
|
|
137
137
|
return this.service.emailVerificationLoginResend(locale, token, origin);
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
+
// Confirma o e-mail pelo link do cadastro. Não autentica: só marca o
|
|
141
|
+
// identificador como verificado, e repetir o clique é inofensivo.
|
|
140
142
|
@Public()
|
|
143
|
+
@UseGuards(ThrottlerGuard)
|
|
144
|
+
@Throttle({ default: { limit: 10, ttl: 60_000 } })
|
|
145
|
+
@Post('confirm-email')
|
|
146
|
+
async confirmEmail(
|
|
147
|
+
@Locale() locale: string,
|
|
148
|
+
@Body() { token }: ConfirmEmailDTO,
|
|
149
|
+
) {
|
|
150
|
+
return this.service.confirmEmail(locale, token);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Mesmo rate-limit do login: sem ele a rota criava contas sem qualquer
|
|
154
|
+
// limite por IP. Recebe os dados de sessão porque, quando a confirmação de
|
|
155
|
+
// e-mail não é exigida, o cadastro já sai autenticado.
|
|
156
|
+
@Public()
|
|
157
|
+
@UseGuards(ThrottlerGuard)
|
|
158
|
+
@Throttle({ default: { limit: 10, ttl: 60_000 } })
|
|
141
159
|
@Post('signup')
|
|
142
160
|
async registerWithEmailAndPassword(
|
|
143
161
|
@Locale() locale: string,
|
|
144
162
|
@Body() data: CreateWithEmailAndPasswordDTO,
|
|
163
|
+
@Ip() ipAddress: string,
|
|
164
|
+
@Headers('user-agent') userAgent: string,
|
|
165
|
+
@Headers('x-browser-id') browserId: string,
|
|
166
|
+
@Headers('origin') origin: string,
|
|
167
|
+
@Res({ passthrough: true }) res,
|
|
145
168
|
) {
|
|
146
|
-
return this.
|
|
169
|
+
return this.service.signupWithEmailAndPassword(res, locale, ipAddress, userAgent, data, browserId || null, origin);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Reenvia o link de confirmação do cadastro. Limite mais apertado que o das
|
|
173
|
+
// demais rotas públicas porque cada chamada dispara um e-mail.
|
|
174
|
+
@Public()
|
|
175
|
+
@UseGuards(ThrottlerGuard)
|
|
176
|
+
@Throttle({ default: { limit: 3, ttl: 60_000 } })
|
|
177
|
+
@Post('resend-confirmation')
|
|
178
|
+
async resendConfirmation(
|
|
179
|
+
@Locale() locale: string,
|
|
180
|
+
@Body() { email, app }: ResendConfirmationDTO,
|
|
181
|
+
@Headers('origin') origin: string,
|
|
182
|
+
) {
|
|
183
|
+
return this.service.resendEmailConfirmation(locale, email, app, origin);
|
|
147
184
|
}
|
|
148
185
|
|
|
149
186
|
@Public()
|
|
@@ -184,6 +221,7 @@ export class AuthController {
|
|
|
184
221
|
@Ip() ipAddress: string,
|
|
185
222
|
@Headers('user-agent') userAgent: string,
|
|
186
223
|
@Headers('x-browser-id') browserId: string,
|
|
224
|
+
@Headers('origin') origin: string,
|
|
187
225
|
@Res({ passthrough: true }) res,
|
|
188
226
|
) {
|
|
189
227
|
const { accessToken, refreshToken, session, requiresPasswordReset } = await this.service.verifyMfaRecoveryCode(
|
|
@@ -193,6 +231,7 @@ export class AuthController {
|
|
|
193
231
|
ipAddress,
|
|
194
232
|
userAgent,
|
|
195
233
|
browserId || null,
|
|
234
|
+
origin,
|
|
196
235
|
);
|
|
197
236
|
|
|
198
237
|
await this.token.setRefreshTokenCookie(locale, res, refreshToken, session.expires_at);
|
package/src/auth/auth.module.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { SessionModule } from '../session/session.module';
|
|
|
15
15
|
import { SettingModule } from '../setting/setting.module';
|
|
16
16
|
import { TokenModule } from '../token/token.module';
|
|
17
17
|
import { TokenService } from '../token/token.service';
|
|
18
|
+
import { UserDeviceModule } from '../user-device/user-device.module';
|
|
18
19
|
import { UserModule } from '../user/user.module';
|
|
19
20
|
import { AuthController } from './auth.controller';
|
|
20
21
|
import { AuthService } from './auth.service';
|
|
@@ -77,6 +78,7 @@ import { AuthGuard } from './guards/auth.guard';
|
|
|
77
78
|
forwardRef(() => TokenModule),
|
|
78
79
|
forwardRef(() => ChallengeModule),
|
|
79
80
|
forwardRef(() => SessionModule),
|
|
81
|
+
forwardRef(() => UserDeviceModule),
|
|
80
82
|
ConfigModule,
|
|
81
83
|
HttpModule,
|
|
82
84
|
],
|
|
@@ -10,13 +10,19 @@ jest.mock('speakeasy', () => ({
|
|
|
10
10
|
totp: { verify: (...args: any[]) => speakeasyVerify(...args) },
|
|
11
11
|
}));
|
|
12
12
|
|
|
13
|
+
import { localeStorage } from '@hed-hog/api-locale';
|
|
13
14
|
import { AuthService } from './auth.service';
|
|
14
15
|
|
|
15
16
|
const makeDeps = () => {
|
|
16
17
|
const prisma = {
|
|
17
18
|
user: { update: jest.fn(), findUnique: jest.fn(), findFirst: jest.fn() },
|
|
18
19
|
user_credential: { findFirst: jest.fn(), updateMany: jest.fn() },
|
|
19
|
-
user_identifier: {
|
|
20
|
+
user_identifier: {
|
|
21
|
+
findFirst: jest.fn(),
|
|
22
|
+
findMany: jest.fn(),
|
|
23
|
+
findUnique: jest.fn(),
|
|
24
|
+
update: jest.fn(),
|
|
25
|
+
},
|
|
20
26
|
user_identifier_challenge: {
|
|
21
27
|
create: jest.fn(),
|
|
22
28
|
findUnique: jest.fn(),
|
|
@@ -29,8 +35,17 @@ const makeDeps = () => {
|
|
|
29
35
|
role: { findMany: jest.fn() },
|
|
30
36
|
$transaction: jest.fn(),
|
|
31
37
|
};
|
|
32
|
-
const mail = {
|
|
33
|
-
|
|
38
|
+
const mail = {
|
|
39
|
+
sendTemplatedMail: jest.fn().mockResolvedValue(undefined),
|
|
40
|
+
// Idempotente por contrato: sem preferencia gravada, devolve o que veio.
|
|
41
|
+
resolveRecipientLocale: jest.fn(async (_email: string, locale?: string) => locale ?? 'en'),
|
|
42
|
+
};
|
|
43
|
+
const setting = {
|
|
44
|
+
getSettingValues: jest.fn(),
|
|
45
|
+
getUserSettingValue: jest.fn(async () => null),
|
|
46
|
+
getSettingListValues: jest.fn(async () => ['en', 'pt']),
|
|
47
|
+
setSettingUserValue: jest.fn(async () => ({})),
|
|
48
|
+
};
|
|
34
49
|
const security = {
|
|
35
50
|
generateCode: jest.fn(),
|
|
36
51
|
hashWithPepper: jest.fn(),
|
|
@@ -44,6 +59,7 @@ const makeDeps = () => {
|
|
|
44
59
|
decodeExpiredToken: jest.fn(),
|
|
45
60
|
createMfaChallengeToken: jest.fn(),
|
|
46
61
|
verifyMfaChallengeToken: jest.fn(),
|
|
62
|
+
verifyEmailConfirmationToken: jest.fn(),
|
|
47
63
|
setRefreshTokenCookie: jest.fn(),
|
|
48
64
|
};
|
|
49
65
|
const session = {
|
|
@@ -55,6 +71,7 @@ const makeDeps = () => {
|
|
|
55
71
|
findUserByEmail: jest.fn(),
|
|
56
72
|
findUserById: jest.fn(),
|
|
57
73
|
registerUserActivity: jest.fn(),
|
|
74
|
+
createWithEmailAndPassword: jest.fn(),
|
|
58
75
|
};
|
|
59
76
|
const challenge = {
|
|
60
77
|
sendMfaCodeToMultipleEmails: jest.fn(),
|
|
@@ -63,8 +80,15 @@ const makeDeps = () => {
|
|
|
63
80
|
verifyCodePassword: jest.fn(),
|
|
64
81
|
verifyMfaEmailCode: jest.fn(),
|
|
65
82
|
resolveAppKeyFromOrigin: jest.fn().mockResolvedValue(undefined),
|
|
83
|
+
sendEmailConfirmationLink: jest.fn(),
|
|
66
84
|
};
|
|
67
|
-
|
|
85
|
+
const userDevice = {
|
|
86
|
+
// Default false: dispositivo conhecido, nenhum alerta — o cenario esperado
|
|
87
|
+
// pela maioria dos casos, que so verificam o retorno do login.
|
|
88
|
+
isNewDevice: jest.fn().mockResolvedValue(false),
|
|
89
|
+
remember: jest.fn().mockResolvedValue(undefined),
|
|
90
|
+
};
|
|
91
|
+
return { prisma, mail, setting, security, token, session, user, challenge, userDevice };
|
|
68
92
|
};
|
|
69
93
|
|
|
70
94
|
const makeService = (deps = makeDeps()) => ({
|
|
@@ -77,6 +101,7 @@ const makeService = (deps = makeDeps()) => ({
|
|
|
77
101
|
deps.session as any,
|
|
78
102
|
deps.user as any,
|
|
79
103
|
deps.challenge as any,
|
|
104
|
+
deps.userDevice as any,
|
|
80
105
|
),
|
|
81
106
|
deps,
|
|
82
107
|
});
|
|
@@ -330,6 +355,284 @@ describe('AuthService', () => {
|
|
|
330
355
|
});
|
|
331
356
|
});
|
|
332
357
|
|
|
358
|
+
describe('signupWithEmailAndPassword', () => {
|
|
359
|
+
const createdUser = { id: 9, name: 'Aluno Novo' };
|
|
360
|
+
|
|
361
|
+
it('com require-email-verification ligada, não emite sessão nem seta cookie', async () => {
|
|
362
|
+
const { service, deps } = makeService();
|
|
363
|
+
deps.user.createWithEmailAndPassword.mockResolvedValue({ user: createdUser });
|
|
364
|
+
deps.setting.getSettingValues.mockResolvedValue({
|
|
365
|
+
'require-email-verification': true,
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
const result = await service.signupWithEmailAndPassword(
|
|
369
|
+
{},
|
|
370
|
+
'pt-BR',
|
|
371
|
+
'1.1.1.1',
|
|
372
|
+
'UA',
|
|
373
|
+
{ email: 'aluno@example.com', name: 'Aluno Novo', password: 'Sup3r$ecret' } as any,
|
|
374
|
+
);
|
|
375
|
+
|
|
376
|
+
expect(result).toEqual({ user: createdUser, hasChallenge: true });
|
|
377
|
+
expect(deps.token.setRefreshTokenCookie).not.toHaveBeenCalled();
|
|
378
|
+
expect(deps.token.createAccessToken).not.toHaveBeenCalled();
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
it('com require-email-verification desligada, cadastra já autenticado', async () => {
|
|
382
|
+
const { service, deps } = makeService();
|
|
383
|
+
deps.user.createWithEmailAndPassword.mockResolvedValue({ user: createdUser });
|
|
384
|
+
deps.setting.getSettingValues.mockResolvedValue({
|
|
385
|
+
'require-email-verification': false,
|
|
386
|
+
});
|
|
387
|
+
deps.prisma.user_identifier.findMany.mockResolvedValue([
|
|
388
|
+
{ value: 'aluno@example.com' },
|
|
389
|
+
]);
|
|
390
|
+
deps.session.create.mockResolvedValue({
|
|
391
|
+
token: 'refresh-9',
|
|
392
|
+
session: { id: 9, expires_at: new Date('2026-01-02') },
|
|
393
|
+
});
|
|
394
|
+
deps.token.createAccessToken.mockResolvedValue('access-9');
|
|
395
|
+
|
|
396
|
+
const result = await service.signupWithEmailAndPassword(
|
|
397
|
+
{},
|
|
398
|
+
'pt-BR',
|
|
399
|
+
'1.1.1.1',
|
|
400
|
+
'UA',
|
|
401
|
+
{ email: 'aluno@example.com', name: 'Aluno Novo', password: 'Sup3r$ecret' } as any,
|
|
402
|
+
);
|
|
403
|
+
|
|
404
|
+
expect(deps.token.setRefreshTokenCookie).toHaveBeenCalled();
|
|
405
|
+
expect(result).toEqual({
|
|
406
|
+
user: createdUser,
|
|
407
|
+
hasChallenge: false,
|
|
408
|
+
accessToken: 'access-9',
|
|
409
|
+
refreshToken: 'refresh-9',
|
|
410
|
+
requiresPasswordReset: false,
|
|
411
|
+
});
|
|
412
|
+
});
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
describe('resendEmailConfirmation', () => {
|
|
416
|
+
it('reenvia o link quando encontra o usuário pelo e-mail', async () => {
|
|
417
|
+
const { service, deps } = makeService();
|
|
418
|
+
deps.user.findUserByEmail.mockResolvedValue({ id: 4 });
|
|
419
|
+
|
|
420
|
+
const result = await service.resendEmailConfirmation(
|
|
421
|
+
'pt-BR',
|
|
422
|
+
'aluno@example.com',
|
|
423
|
+
'class',
|
|
424
|
+
'https://class.hcode.com.br',
|
|
425
|
+
);
|
|
426
|
+
|
|
427
|
+
expect(deps.challenge.sendEmailConfirmationLink).toHaveBeenCalledWith(
|
|
428
|
+
'pt-BR',
|
|
429
|
+
4,
|
|
430
|
+
'aluno@example.com',
|
|
431
|
+
'class',
|
|
432
|
+
'https://class.hcode.com.br',
|
|
433
|
+
);
|
|
434
|
+
expect(result).toEqual({ sent: true });
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
it('responde sent:true mesmo sem encontrar o e-mail (evita enumeração)', async () => {
|
|
438
|
+
const { service, deps } = makeService();
|
|
439
|
+
deps.user.findUserByEmail.mockResolvedValue(null);
|
|
440
|
+
|
|
441
|
+
const result = await service.resendEmailConfirmation('pt-BR', 'inexistente@example.com');
|
|
442
|
+
|
|
443
|
+
expect(deps.challenge.sendEmailConfirmationLink).not.toHaveBeenCalled();
|
|
444
|
+
expect(result).toEqual({ sent: true });
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
it('responde sent:true mesmo quando o envio falha (ex.: e-mail já verificado)', async () => {
|
|
448
|
+
const { service, deps } = makeService();
|
|
449
|
+
deps.user.findUserByEmail.mockResolvedValue({ id: 4 });
|
|
450
|
+
deps.challenge.sendEmailConfirmationLink.mockRejectedValue(
|
|
451
|
+
new NotFoundException('already verified'),
|
|
452
|
+
);
|
|
453
|
+
|
|
454
|
+
const result = await service.resendEmailConfirmation('pt-BR', 'aluno@example.com');
|
|
455
|
+
|
|
456
|
+
expect(result).toEqual({ sent: true });
|
|
457
|
+
});
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
describe('alerta de dispositivo novo', () => {
|
|
461
|
+
// Login simples, sem MFA nem verificação de e-mail: o caminho que chega em
|
|
462
|
+
// login() e decide se manda o alerta.
|
|
463
|
+
const arrangeLogin = (deps: any, identifiers = [{ value: 'a@b.com' }]) => {
|
|
464
|
+
deps.user.findUserByEmail.mockResolvedValue({
|
|
465
|
+
id: 1,
|
|
466
|
+
name: 'John',
|
|
467
|
+
user_credential: [{ type: 'password' }],
|
|
468
|
+
user_identifier: [{ type: 'email', value: 'a@b.com', verified_at: new Date() }],
|
|
469
|
+
});
|
|
470
|
+
deps.security.validatePassword.mockResolvedValue(true);
|
|
471
|
+
deps.prisma.user_mfa.findMany.mockResolvedValue([]);
|
|
472
|
+
deps.setting.getSettingValues.mockResolvedValue({
|
|
473
|
+
'require-mfa': false,
|
|
474
|
+
'require-email-verification': false,
|
|
475
|
+
});
|
|
476
|
+
deps.prisma.user_identifier.findMany.mockResolvedValue(identifiers);
|
|
477
|
+
deps.session.create.mockResolvedValue({
|
|
478
|
+
token: 'refresh-1',
|
|
479
|
+
session: { id: 1, expires_at: new Date('2026-01-02') },
|
|
480
|
+
});
|
|
481
|
+
deps.token.createAccessToken.mockResolvedValue('access-1');
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
const doLogin = (service: any) =>
|
|
485
|
+
service.loginWithEmailAndPassword({}, 'pt', '8.8.8.8', 'UA', {
|
|
486
|
+
email: 'a@b.com',
|
|
487
|
+
password: 'right',
|
|
488
|
+
} as any);
|
|
489
|
+
|
|
490
|
+
it('não avisa quando o dispositivo já é conhecido', async () => {
|
|
491
|
+
const { service, deps } = makeService();
|
|
492
|
+
arrangeLogin(deps);
|
|
493
|
+
deps.userDevice.isNewDevice.mockResolvedValue(false);
|
|
494
|
+
|
|
495
|
+
await doLogin(service);
|
|
496
|
+
|
|
497
|
+
expect(deps.mail.sendTemplatedMail).not.toHaveBeenCalled();
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
it('avisa quando o dispositivo é desconhecido', async () => {
|
|
501
|
+
const { service, deps } = makeService();
|
|
502
|
+
arrangeLogin(deps);
|
|
503
|
+
deps.userDevice.isNewDevice.mockResolvedValue(true);
|
|
504
|
+
|
|
505
|
+
await doLogin(service);
|
|
506
|
+
|
|
507
|
+
expect(deps.userDevice.isNewDevice).toHaveBeenCalledWith(1, 'UA', undefined);
|
|
508
|
+
expect(deps.mail.sendTemplatedMail).toHaveBeenCalledTimes(1);
|
|
509
|
+
const [locale, payload] = deps.mail.sendTemplatedMail.mock.calls[0] as any[];
|
|
510
|
+
expect(locale).toBe('pt');
|
|
511
|
+
expect(payload.slug).toBe('auth-login-new-device');
|
|
512
|
+
expect(payload.email).toBe('a@b.com');
|
|
513
|
+
// Enriquecimento: nada de "Unknown" literal, e o UA cru vira browser/os.
|
|
514
|
+
expect(payload.variables).toMatchObject({ name: 'John', ipAddress: '8.8.8.8' });
|
|
515
|
+
expect(payload.variables.datetime).toEqual(expect.any(String));
|
|
516
|
+
expect(payload.variables.location).not.toBe('Unknown');
|
|
517
|
+
});
|
|
518
|
+
|
|
519
|
+
it('avisa só o e-mail usado no login, não todos os identificadores', async () => {
|
|
520
|
+
const { service, deps } = makeService();
|
|
521
|
+
arrangeLogin(deps, [{ value: 'secundario@b.com' }, { value: 'a@b.com' }]);
|
|
522
|
+
deps.userDevice.isNewDevice.mockResolvedValue(true);
|
|
523
|
+
|
|
524
|
+
await doLogin(service);
|
|
525
|
+
|
|
526
|
+
expect(deps.mail.sendTemplatedMail).toHaveBeenCalledTimes(1);
|
|
527
|
+
expect((deps.mail.sendTemplatedMail.mock.calls[0] as any[])[1].email).toBe('a@b.com');
|
|
528
|
+
});
|
|
529
|
+
|
|
530
|
+
// O idioma e aprendido no mesmo funil do dispositivo. Write-once: um login
|
|
531
|
+
// de aparelho emprestado nao pode apagar a escolha feita nas preferencias.
|
|
532
|
+
describe('preferencia de idioma detectada', () => {
|
|
533
|
+
// `detected` so e verdadeiro quando o cliente mandou um idioma suportado.
|
|
534
|
+
const loginWithDetectedLocale = (service: any, detected: boolean) =>
|
|
535
|
+
localeStorage.run({ locale: 'pt', detected }, () =>
|
|
536
|
+
service.loginWithEmailAndPassword({}, 'pt', '8.8.8.8', 'UA', {
|
|
537
|
+
email: 'a@b.com',
|
|
538
|
+
password: 'right',
|
|
539
|
+
} as any),
|
|
540
|
+
);
|
|
541
|
+
|
|
542
|
+
it('grava o idioma do cliente quando o usuario ainda nao tem preferencia', async () => {
|
|
543
|
+
const { service, deps } = makeService();
|
|
544
|
+
arrangeLogin(deps);
|
|
545
|
+
deps.userDevice.isNewDevice.mockResolvedValue(false);
|
|
546
|
+
|
|
547
|
+
await loginWithDetectedLocale(service, true);
|
|
548
|
+
|
|
549
|
+
expect(deps.setting.setSettingUserValue).toHaveBeenCalledWith(
|
|
550
|
+
'pt', 1, 'language', 'pt',
|
|
551
|
+
);
|
|
552
|
+
});
|
|
553
|
+
|
|
554
|
+
it('nao sobrescreve a preferencia ja escolhida pelo usuario', async () => {
|
|
555
|
+
const { service, deps } = makeService();
|
|
556
|
+
arrangeLogin(deps);
|
|
557
|
+
deps.userDevice.isNewDevice.mockResolvedValue(false);
|
|
558
|
+
deps.setting.getUserSettingValue.mockResolvedValue('en');
|
|
559
|
+
|
|
560
|
+
await loginWithDetectedLocale(service, true);
|
|
561
|
+
|
|
562
|
+
expect(deps.setting.setSettingUserValue).not.toHaveBeenCalled();
|
|
563
|
+
});
|
|
564
|
+
|
|
565
|
+
// Sem esta guarda, todo cliente que nao manda `Accept-Language` (o app
|
|
566
|
+
// mobile, cron, curl) congelaria o default `en` como preferencia.
|
|
567
|
+
it('nao grava quando o cliente nao declarou idioma', async () => {
|
|
568
|
+
const { service, deps } = makeService();
|
|
569
|
+
arrangeLogin(deps);
|
|
570
|
+
deps.userDevice.isNewDevice.mockResolvedValue(false);
|
|
571
|
+
|
|
572
|
+
await loginWithDetectedLocale(service, false);
|
|
573
|
+
|
|
574
|
+
expect(deps.setting.setSettingUserValue).not.toHaveBeenCalled();
|
|
575
|
+
});
|
|
576
|
+
|
|
577
|
+
// `setSettingUserValue` valida override, nao o valor: sem esta checagem
|
|
578
|
+
// um navegador em `de-DE` gravaria um idioma sem template nenhum.
|
|
579
|
+
it('nao grava idioma fora das opcoes da setting', async () => {
|
|
580
|
+
const { service, deps } = makeService();
|
|
581
|
+
arrangeLogin(deps);
|
|
582
|
+
deps.userDevice.isNewDevice.mockResolvedValue(false);
|
|
583
|
+
|
|
584
|
+
await localeStorage.run({ locale: 'de', detected: true }, () =>
|
|
585
|
+
service.loginWithEmailAndPassword({}, 'de', '8.8.8.8', 'UA', {
|
|
586
|
+
email: 'a@b.com',
|
|
587
|
+
password: 'right',
|
|
588
|
+
} as any),
|
|
589
|
+
);
|
|
590
|
+
|
|
591
|
+
expect(deps.setting.setSettingUserValue).not.toHaveBeenCalled();
|
|
592
|
+
});
|
|
593
|
+
|
|
594
|
+
it('nao derruba o login quando a gravacao falha', async () => {
|
|
595
|
+
const { service, deps } = makeService();
|
|
596
|
+
arrangeLogin(deps);
|
|
597
|
+
deps.userDevice.isNewDevice.mockResolvedValue(false);
|
|
598
|
+
deps.setting.setSettingUserValue.mockRejectedValue(new Error('db down'));
|
|
599
|
+
|
|
600
|
+
await expect(loginWithDetectedLocale(service, true)).resolves.toEqual(
|
|
601
|
+
expect.objectContaining({ accessToken: 'access-1' }),
|
|
602
|
+
);
|
|
603
|
+
});
|
|
604
|
+
});
|
|
605
|
+
|
|
606
|
+
it('checa o dispositivo antes de registrá-lo', async () => {
|
|
607
|
+
const { service, deps } = makeService();
|
|
608
|
+
arrangeLogin(deps);
|
|
609
|
+
|
|
610
|
+
await doLogin(service);
|
|
611
|
+
|
|
612
|
+
// Invertido, o registro do login atual faria todo login parecer conhecido.
|
|
613
|
+
expect(deps.userDevice.isNewDevice.mock.invocationCallOrder[0]).toBeLessThan(
|
|
614
|
+
deps.userDevice.remember.mock.invocationCallOrder[0],
|
|
615
|
+
);
|
|
616
|
+
});
|
|
617
|
+
|
|
618
|
+
it('registra o dispositivo em getAuthenticationPayload, valendo para todo caminho de login', async () => {
|
|
619
|
+
const { service, deps } = makeService();
|
|
620
|
+
deps.session.create.mockResolvedValue({
|
|
621
|
+
token: 'refresh-1',
|
|
622
|
+
session: { id: 1, expires_at: new Date('2026-01-02') },
|
|
623
|
+
});
|
|
624
|
+
deps.token.createAccessToken.mockResolvedValue('access-1');
|
|
625
|
+
|
|
626
|
+
await service.getAuthenticationPayload('pt', 7, '8.8.8.8', 'UA', 'browser-9');
|
|
627
|
+
|
|
628
|
+
expect(deps.userDevice.remember).toHaveBeenCalledWith(7, {
|
|
629
|
+
userAgent: 'UA',
|
|
630
|
+
browserId: 'browser-9',
|
|
631
|
+
ipAddress: '8.8.8.8',
|
|
632
|
+
});
|
|
633
|
+
});
|
|
634
|
+
});
|
|
635
|
+
|
|
333
636
|
describe('verifyRoles / verifyUser', () => {
|
|
334
637
|
it('verifyRoles delega para prisma.role.findMany', async () => {
|
|
335
638
|
const { service, deps } = makeService();
|
|
@@ -830,7 +1133,7 @@ describe('AuthService', () => {
|
|
|
830
1133
|
deps.prisma.user_identifier_challenge.findUnique.mockResolvedValue({
|
|
831
1134
|
hash: 'matching-hash',
|
|
832
1135
|
user_identifier_id: 2,
|
|
833
|
-
user_identifier: { user_id: 9 },
|
|
1136
|
+
user_identifier: { user_id: 9, value: 'a@b.com' },
|
|
834
1137
|
});
|
|
835
1138
|
deps.security.hashWithPepper.mockReturnValue('matching-hash');
|
|
836
1139
|
deps.prisma.$transaction.mockImplementation(async (cb: any) =>
|
|
@@ -886,8 +1189,82 @@ describe('AuthService', () => {
|
|
|
886
1189
|
where: { type: 'password', user_id: 1 },
|
|
887
1190
|
data: { hash: 'new-hash', requires_reset: false },
|
|
888
1191
|
});
|
|
889
|
-
|
|
1192
|
+
// user_id (1), não o id do identificador (2): a atividade é do usuário.
|
|
1193
|
+
expect(deps.user.registerUserActivity).toHaveBeenCalledWith(1, 'resetPassword');
|
|
890
1194
|
expect(result.accessToken).toBe('access-8');
|
|
891
1195
|
});
|
|
892
1196
|
});
|
|
1197
|
+
|
|
1198
|
+
describe('confirmEmail', () => {
|
|
1199
|
+
const identifier = {
|
|
1200
|
+
id: 42,
|
|
1201
|
+
user_id: 7,
|
|
1202
|
+
value: 'a@b.com',
|
|
1203
|
+
verified_at: null,
|
|
1204
|
+
user: { id: 7, name: 'Bob' },
|
|
1205
|
+
};
|
|
1206
|
+
|
|
1207
|
+
it('marca o e-mail como verificado e não cria sessão', async () => {
|
|
1208
|
+
const { service, deps } = makeService();
|
|
1209
|
+
deps.token.verifyEmailConfirmationToken.mockResolvedValue({
|
|
1210
|
+
userIdentifierId: 42,
|
|
1211
|
+
});
|
|
1212
|
+
deps.prisma.user_identifier.findUnique.mockResolvedValue(identifier);
|
|
1213
|
+
|
|
1214
|
+
const result = await service.confirmEmail('pt-BR', 'tok');
|
|
1215
|
+
|
|
1216
|
+
expect(deps.prisma.user_identifier.update).toHaveBeenCalledWith({
|
|
1217
|
+
where: { id: 42 },
|
|
1218
|
+
data: { verified_at: expect.any(Date), enabled: true },
|
|
1219
|
+
});
|
|
1220
|
+
expect(deps.user.registerUserActivity).toHaveBeenCalledWith(7, 'confirmEmail');
|
|
1221
|
+
expect(deps.session.create).not.toHaveBeenCalled();
|
|
1222
|
+
expect(result).toEqual({
|
|
1223
|
+
confirmed: true,
|
|
1224
|
+
alreadyConfirmed: false,
|
|
1225
|
+
email: 'a@b.com',
|
|
1226
|
+
name: 'Bob',
|
|
1227
|
+
});
|
|
1228
|
+
});
|
|
1229
|
+
|
|
1230
|
+
it('segundo clique no link responde "já confirmado" em vez de erro', async () => {
|
|
1231
|
+
const { service, deps } = makeService();
|
|
1232
|
+
deps.token.verifyEmailConfirmationToken.mockResolvedValue({
|
|
1233
|
+
userIdentifierId: 42,
|
|
1234
|
+
});
|
|
1235
|
+
deps.prisma.user_identifier.findUnique.mockResolvedValue({
|
|
1236
|
+
...identifier,
|
|
1237
|
+
verified_at: new Date('2026-01-01T00:00:00Z'),
|
|
1238
|
+
});
|
|
1239
|
+
|
|
1240
|
+
const result = await service.confirmEmail('pt-BR', 'tok');
|
|
1241
|
+
|
|
1242
|
+
expect(result.alreadyConfirmed).toBe(true);
|
|
1243
|
+
expect(deps.prisma.user_identifier.update).not.toHaveBeenCalled();
|
|
1244
|
+
});
|
|
1245
|
+
|
|
1246
|
+
it('propaga a recusa de token inválido, expirado ou de outro propósito', async () => {
|
|
1247
|
+
const { service, deps } = makeService();
|
|
1248
|
+
deps.token.verifyEmailConfirmationToken.mockRejectedValue(
|
|
1249
|
+
new BadRequestException('invalid'),
|
|
1250
|
+
);
|
|
1251
|
+
|
|
1252
|
+
await expect(service.confirmEmail('pt-BR', 'tok')).rejects.toThrow(
|
|
1253
|
+
BadRequestException,
|
|
1254
|
+
);
|
|
1255
|
+
expect(deps.prisma.user_identifier.update).not.toHaveBeenCalled();
|
|
1256
|
+
});
|
|
1257
|
+
|
|
1258
|
+
it('lança BadRequest quando o identificador do token não existe mais', async () => {
|
|
1259
|
+
const { service, deps } = makeService();
|
|
1260
|
+
deps.token.verifyEmailConfirmationToken.mockResolvedValue({
|
|
1261
|
+
userIdentifierId: 42,
|
|
1262
|
+
});
|
|
1263
|
+
deps.prisma.user_identifier.findUnique.mockResolvedValue(null);
|
|
1264
|
+
|
|
1265
|
+
await expect(service.confirmEmail('pt-BR', 'tok')).rejects.toThrow(
|
|
1266
|
+
BadRequestException,
|
|
1267
|
+
);
|
|
1268
|
+
});
|
|
1269
|
+
});
|
|
893
1270
|
});
|