@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
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, jest } from '@jest/globals';
|
|
2
|
+
import { BadRequestException } from '@nestjs/common';
|
|
3
|
+
import { createHash, randomBytes } from 'crypto';
|
|
4
|
+
|
|
5
|
+
// Mocka o MESMO módulo de onde o service importa (@hed-hog/api-prisma). Mockar
|
|
6
|
+
// '@prisma/client' aqui deixaria o teste verde com um import que quebra em
|
|
7
|
+
// runtime — a mesma armadilha documentada no spec do AuthorizeService.
|
|
8
|
+
jest.mock('@hed-hog/api-prisma', () => ({
|
|
9
|
+
PrismaService: class {},
|
|
10
|
+
Prisma: {
|
|
11
|
+
sql: (strings: TemplateStringsArray, ...values: unknown[]) => ({
|
|
12
|
+
strings: [...strings],
|
|
13
|
+
values,
|
|
14
|
+
}),
|
|
15
|
+
},
|
|
16
|
+
}));
|
|
17
|
+
|
|
18
|
+
// eslint-disable-next-line import/first
|
|
19
|
+
import { PairingService } from './pairing.service';
|
|
20
|
+
|
|
21
|
+
const CLIENT_ID = 'hedhog-vaults';
|
|
22
|
+
const USER_ID = 7;
|
|
23
|
+
|
|
24
|
+
const sha256b64url = (value: string) =>
|
|
25
|
+
createHash('sha256').update(value).digest('base64url');
|
|
26
|
+
|
|
27
|
+
const makeToken = () => randomBytes(32).toString('base64url');
|
|
28
|
+
|
|
29
|
+
const future = () => new Date(Date.now() + 60_000);
|
|
30
|
+
const past = () => new Date(Date.now() - 1);
|
|
31
|
+
|
|
32
|
+
type Row = {
|
|
33
|
+
id: bigint;
|
|
34
|
+
direction: string;
|
|
35
|
+
user_id: number | null;
|
|
36
|
+
eph_public_key: string | null;
|
|
37
|
+
want_session: boolean;
|
|
38
|
+
payload_enc: string | null;
|
|
39
|
+
issued_ip: string | null;
|
|
40
|
+
issued_user_agent: string | null;
|
|
41
|
+
claimed_at: Date | null;
|
|
42
|
+
claim_ip: string | null;
|
|
43
|
+
claim_user_agent: string | null;
|
|
44
|
+
confirmed_at: Date | null;
|
|
45
|
+
cancelled_at: Date | null;
|
|
46
|
+
consumed_at: Date | null;
|
|
47
|
+
expires_at: Date;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const makeRow = (overrides: Partial<Row> = {}): Row => ({
|
|
51
|
+
id: 1n,
|
|
52
|
+
direction: 'browser-to-device',
|
|
53
|
+
user_id: USER_ID,
|
|
54
|
+
eph_public_key: null,
|
|
55
|
+
want_session: true,
|
|
56
|
+
payload_enc: null,
|
|
57
|
+
issued_ip: '10.0.0.1',
|
|
58
|
+
issued_user_agent: 'Chrome',
|
|
59
|
+
claimed_at: null,
|
|
60
|
+
claim_ip: null,
|
|
61
|
+
claim_user_agent: null,
|
|
62
|
+
confirmed_at: null,
|
|
63
|
+
cancelled_at: null,
|
|
64
|
+
consumed_at: null,
|
|
65
|
+
expires_at: future(),
|
|
66
|
+
...overrides,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const makeDeps = () => {
|
|
70
|
+
const prisma = {
|
|
71
|
+
oauth_app_client: {
|
|
72
|
+
findUnique: jest.fn(async () => ({ client_id: CLIENT_ID, enabled: true })),
|
|
73
|
+
},
|
|
74
|
+
device_pairing_request: {
|
|
75
|
+
create: jest.fn(async () => ({ id: 1n })),
|
|
76
|
+
findFirst: jest.fn(async () => null),
|
|
77
|
+
updateMany: jest.fn(async () => ({ count: 1 })),
|
|
78
|
+
deleteMany: jest.fn(async () => ({ count: 0 })),
|
|
79
|
+
},
|
|
80
|
+
user_activity: { create: jest.fn(async () => ({})) },
|
|
81
|
+
$queryRaw: jest.fn(async () => [] as unknown[]),
|
|
82
|
+
};
|
|
83
|
+
// Cripto real: o hash é o contrato com o cliente, então não pode ser mockado.
|
|
84
|
+
const security = { hashSha256: (value: string) => sha256b64url(value) };
|
|
85
|
+
const auth = {
|
|
86
|
+
getAuthenticationPayload: jest.fn(async () => ({
|
|
87
|
+
accessToken: 'ACCESS',
|
|
88
|
+
refreshToken: 'REFRESH',
|
|
89
|
+
session: { id: 1, expires_at: future() },
|
|
90
|
+
})),
|
|
91
|
+
};
|
|
92
|
+
return { prisma, security, auth };
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const makeService = (deps: ReturnType<typeof makeDeps>) =>
|
|
96
|
+
new PairingService(
|
|
97
|
+
deps.prisma as never,
|
|
98
|
+
deps.security as never,
|
|
99
|
+
deps.auth as never,
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
/** Valores interpolados no `Prisma.sql` da última chamada. */
|
|
103
|
+
const lastSqlValues = (deps: ReturnType<typeof makeDeps>): unknown[] => {
|
|
104
|
+
const calls = deps.prisma.$queryRaw.mock.calls;
|
|
105
|
+
return (calls[calls.length - 1]?.[0] as { values: unknown[] }).values;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
let deps: ReturnType<typeof makeDeps>;
|
|
109
|
+
let service: PairingService;
|
|
110
|
+
|
|
111
|
+
beforeEach(() => {
|
|
112
|
+
deps = makeDeps();
|
|
113
|
+
service = makeService(deps);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
describe('direção A: abertura', () => {
|
|
117
|
+
it('persiste apenas o hash — o token cru nunca chega ao banco', async () => {
|
|
118
|
+
const token = makeToken();
|
|
119
|
+
|
|
120
|
+
await service.start({
|
|
121
|
+
userId: USER_ID,
|
|
122
|
+
authTokenHash: sha256b64url(token),
|
|
123
|
+
clientId: CLIENT_ID,
|
|
124
|
+
ipAddress: '10.0.0.1',
|
|
125
|
+
userAgent: 'Chrome',
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
const args = deps.prisma.device_pairing_request.create.mock
|
|
129
|
+
.calls[0][0] as { data: Record<string, unknown> };
|
|
130
|
+
expect(args.data.auth_hash).toBe(sha256b64url(token));
|
|
131
|
+
expect(JSON.stringify(args.data)).not.toContain(token);
|
|
132
|
+
// Um pareamento recém-aberto não guarda material de chave nenhum.
|
|
133
|
+
expect(args.data.payload_enc).toBeUndefined();
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it('recusa cliente desconhecido ou desabilitado', async () => {
|
|
137
|
+
deps.prisma.oauth_app_client.findUnique.mockResolvedValueOnce(null as never);
|
|
138
|
+
|
|
139
|
+
await expect(
|
|
140
|
+
service.start({
|
|
141
|
+
userId: USER_ID,
|
|
142
|
+
authTokenHash: 'h',
|
|
143
|
+
clientId: 'quem-sou-eu',
|
|
144
|
+
ipAddress: '',
|
|
145
|
+
userAgent: '',
|
|
146
|
+
}),
|
|
147
|
+
).rejects.toThrow(BadRequestException);
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
describe('direção A: claim', () => {
|
|
152
|
+
it('reivindica uma vez e registra quem foi', async () => {
|
|
153
|
+
const token = makeToken();
|
|
154
|
+
deps.prisma.$queryRaw.mockResolvedValueOnce([
|
|
155
|
+
{ id: 1n, user_id: USER_ID, expires_at: future() },
|
|
156
|
+
] as never);
|
|
157
|
+
|
|
158
|
+
const result = await service.claim({
|
|
159
|
+
authToken: token,
|
|
160
|
+
clientId: CLIENT_ID,
|
|
161
|
+
ipAddress: '192.168.0.9',
|
|
162
|
+
userAgent: 'HedHogVaults/1.0',
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
expect(result.status).toBe('claimed');
|
|
166
|
+
const values = lastSqlValues(deps);
|
|
167
|
+
expect(values).toContain('192.168.0.9');
|
|
168
|
+
expect(values).toContain(sha256b64url(token));
|
|
169
|
+
expect(values).not.toContain(token);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it('o segundo leitor do mesmo QR perde a corrida', async () => {
|
|
173
|
+
// O UPDATE ... WHERE claimed_at IS NULL não devolve linha na segunda vez.
|
|
174
|
+
deps.prisma.$queryRaw.mockResolvedValueOnce([] as never);
|
|
175
|
+
|
|
176
|
+
await expect(
|
|
177
|
+
service.claim({
|
|
178
|
+
authToken: makeToken(),
|
|
179
|
+
clientId: CLIENT_ID,
|
|
180
|
+
ipAddress: '',
|
|
181
|
+
userAgent: '',
|
|
182
|
+
}),
|
|
183
|
+
).rejects.toThrow(BadRequestException);
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
describe('direção A: confirm', () => {
|
|
188
|
+
it('grava o blob e marca confirmado', async () => {
|
|
189
|
+
deps.prisma.$queryRaw.mockResolvedValueOnce([{ id: 1n }] as never);
|
|
190
|
+
|
|
191
|
+
await service.confirm({ userId: USER_ID, id: '1', payloadEnc: 'BLOB' });
|
|
192
|
+
|
|
193
|
+
expect(lastSqlValues(deps)).toContain('BLOB');
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
it('a consulta é sempre filtrada pelo dono', async () => {
|
|
197
|
+
deps.prisma.$queryRaw.mockResolvedValueOnce([{ id: 1n }] as never);
|
|
198
|
+
|
|
199
|
+
await service.confirm({ userId: USER_ID, id: '1', payloadEnc: 'BLOB' });
|
|
200
|
+
|
|
201
|
+
expect(lastSqlValues(deps)).toContain(USER_ID);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
it('recusa quando o registro não está no estado esperado', async () => {
|
|
205
|
+
// Cobre "de outro usuário", "antes do claim", "já confirmado" e "expirado":
|
|
206
|
+
// todos falham pelo mesmo WHERE, que não devolve linha.
|
|
207
|
+
deps.prisma.$queryRaw.mockResolvedValueOnce([] as never);
|
|
208
|
+
|
|
209
|
+
await expect(
|
|
210
|
+
service.confirm({ userId: 999, id: '1', payloadEnc: 'BLOB' }),
|
|
211
|
+
).rejects.toThrow(BadRequestException);
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it('recusa id que não é número', async () => {
|
|
215
|
+
await expect(
|
|
216
|
+
service.confirm({ userId: USER_ID, id: 'abc', payloadEnc: 'BLOB' }),
|
|
217
|
+
).rejects.toThrow(BadRequestException);
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
describe('direção A: redeem', () => {
|
|
222
|
+
const params = {
|
|
223
|
+
authToken: 'TOKEN',
|
|
224
|
+
clientId: CLIENT_ID,
|
|
225
|
+
locale: 'en',
|
|
226
|
+
ipAddress: '192.168.0.9',
|
|
227
|
+
userAgent: 'HedHogVaults/1.0',
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
it('antes do confirm devolve pending e NÃO consome', async () => {
|
|
231
|
+
deps.prisma.device_pairing_request.findFirst.mockResolvedValueOnce(
|
|
232
|
+
makeRow({ claimed_at: new Date() }) as never,
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
expect(await service.redeem(params)).toEqual({ status: 'pending' });
|
|
236
|
+
// O poll não pode queimar o registro: a aprovação ainda vai chegar.
|
|
237
|
+
expect(deps.prisma.$queryRaw).not.toHaveBeenCalled();
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it('depois do confirm devolve tokens e o blob intacto', async () => {
|
|
241
|
+
deps.prisma.device_pairing_request.findFirst.mockResolvedValueOnce(
|
|
242
|
+
makeRow({ claimed_at: new Date(), confirmed_at: new Date() }) as never,
|
|
243
|
+
);
|
|
244
|
+
deps.prisma.$queryRaw.mockResolvedValueOnce([
|
|
245
|
+
{ user_id: USER_ID, payload_enc: 'BLOB-OPACO' },
|
|
246
|
+
] as never);
|
|
247
|
+
|
|
248
|
+
const result = await service.redeem(params);
|
|
249
|
+
|
|
250
|
+
expect(result).toMatchObject({
|
|
251
|
+
status: 'confirmed',
|
|
252
|
+
accessToken: 'ACCESS',
|
|
253
|
+
refreshToken: 'REFRESH',
|
|
254
|
+
payload: 'BLOB-OPACO',
|
|
255
|
+
});
|
|
256
|
+
expect(deps.auth.getAuthenticationPayload).toHaveBeenCalledWith(
|
|
257
|
+
'en',
|
|
258
|
+
USER_ID,
|
|
259
|
+
'192.168.0.9',
|
|
260
|
+
'HedHogVaults/1.0',
|
|
261
|
+
);
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
it('o segundo redeem falha (consumo é único)', async () => {
|
|
265
|
+
deps.prisma.device_pairing_request.findFirst.mockResolvedValueOnce(
|
|
266
|
+
makeRow({ confirmed_at: new Date() }) as never,
|
|
267
|
+
);
|
|
268
|
+
deps.prisma.$queryRaw.mockResolvedValueOnce([] as never);
|
|
269
|
+
|
|
270
|
+
await expect(service.redeem(params)).rejects.toThrow(BadRequestException);
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
it('recusa registro expirado, cancelado ou já consumido', async () => {
|
|
274
|
+
for (const row of [
|
|
275
|
+
makeRow({ expires_at: past() }),
|
|
276
|
+
makeRow({ cancelled_at: new Date() }),
|
|
277
|
+
makeRow({ consumed_at: new Date() }),
|
|
278
|
+
]) {
|
|
279
|
+
deps.prisma.device_pairing_request.findFirst.mockResolvedValueOnce(
|
|
280
|
+
row as never,
|
|
281
|
+
);
|
|
282
|
+
await expect(service.redeem(params)).rejects.toThrow(BadRequestException);
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
it('a mensagem de erro não distingue os casos', async () => {
|
|
287
|
+
const messages: string[] = [];
|
|
288
|
+
for (const row of [null, makeRow({ expires_at: past() })]) {
|
|
289
|
+
deps.prisma.device_pairing_request.findFirst.mockResolvedValueOnce(
|
|
290
|
+
row as never,
|
|
291
|
+
);
|
|
292
|
+
await service.redeem(params).catch((e: Error) => messages.push(e.message));
|
|
293
|
+
}
|
|
294
|
+
expect(messages[0]).toBe(messages[1]);
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
describe('direção B', () => {
|
|
299
|
+
const EPH = 'BFakePublicKeyBase64==';
|
|
300
|
+
|
|
301
|
+
it('abre sem dono: o navegador que pede ainda não é ninguém', async () => {
|
|
302
|
+
await service.startReverse({
|
|
303
|
+
pollHash: 'HASH',
|
|
304
|
+
ephPublicKey: EPH,
|
|
305
|
+
wantSession: true,
|
|
306
|
+
clientId: CLIENT_ID,
|
|
307
|
+
ipAddress: '10.0.0.1',
|
|
308
|
+
userAgent: 'Chrome',
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
const args = deps.prisma.device_pairing_request.create.mock
|
|
312
|
+
.calls[0][0] as { data: Record<string, unknown> };
|
|
313
|
+
expect(args.data.user_id).toBeUndefined();
|
|
314
|
+
expect(args.data.eph_public_key).toBe(EPH);
|
|
315
|
+
expect(args.data.direction).toBe('device-to-browser');
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
it('a inspeção exige a pública efêmera do QR (barra enumeração de id)', async () => {
|
|
319
|
+
deps.prisma.device_pairing_request.findFirst.mockResolvedValue(
|
|
320
|
+
makeRow({ direction: 'device-to-browser', eph_public_key: EPH }) as never,
|
|
321
|
+
);
|
|
322
|
+
|
|
323
|
+
await expect(service.getReverseRequest('1', 'chave-errada')).rejects.toThrow(
|
|
324
|
+
BadRequestException,
|
|
325
|
+
);
|
|
326
|
+
await expect(service.getReverseRequest('1', EPH)).resolves.toMatchObject({
|
|
327
|
+
issuedIp: '10.0.0.1',
|
|
328
|
+
issuedUserAgent: 'Chrome',
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
it('aprovar amarra o registro a quem aprovou', async () => {
|
|
333
|
+
deps.prisma.$queryRaw.mockResolvedValueOnce([{ id: 1n }] as never);
|
|
334
|
+
|
|
335
|
+
await service.approveReverse({
|
|
336
|
+
userId: USER_ID,
|
|
337
|
+
id: '1',
|
|
338
|
+
ephPublicKey: EPH,
|
|
339
|
+
payloadEnc: 'BLOB',
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
const values = lastSqlValues(deps);
|
|
343
|
+
expect(values).toContain(USER_ID);
|
|
344
|
+
expect(values).toContain(EPH);
|
|
345
|
+
expect(values).toContain('BLOB');
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
it('aprovar com a efêmera errada é recusado', async () => {
|
|
349
|
+
deps.prisma.$queryRaw.mockResolvedValueOnce([] as never);
|
|
350
|
+
|
|
351
|
+
await expect(
|
|
352
|
+
service.approveReverse({
|
|
353
|
+
userId: USER_ID,
|
|
354
|
+
id: '1',
|
|
355
|
+
ephPublicKey: 'outra',
|
|
356
|
+
payloadEnc: 'BLOB',
|
|
357
|
+
}),
|
|
358
|
+
).rejects.toThrow(BadRequestException);
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
it('o poll antes da aprovação não consome', async () => {
|
|
362
|
+
deps.prisma.device_pairing_request.findFirst.mockResolvedValueOnce(
|
|
363
|
+
makeRow({ direction: 'device-to-browser' }) as never,
|
|
364
|
+
);
|
|
365
|
+
|
|
366
|
+
expect(await service.pollReverse({ pollToken: 'T', locale: 'en' })).toEqual({
|
|
367
|
+
status: 'pending',
|
|
368
|
+
claimed: false,
|
|
369
|
+
});
|
|
370
|
+
expect(deps.prisma.$queryRaw).not.toHaveBeenCalled();
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
it('com want_session, a sessão nasce com o IP do NAVEGADOR, não do celular', async () => {
|
|
374
|
+
deps.prisma.device_pairing_request.findFirst.mockResolvedValueOnce(
|
|
375
|
+
makeRow({
|
|
376
|
+
direction: 'device-to-browser',
|
|
377
|
+
confirmed_at: new Date(),
|
|
378
|
+
}) as never,
|
|
379
|
+
);
|
|
380
|
+
deps.prisma.$queryRaw.mockResolvedValueOnce([
|
|
381
|
+
{
|
|
382
|
+
user_id: USER_ID,
|
|
383
|
+
payload_enc: 'BLOB',
|
|
384
|
+
want_session: true,
|
|
385
|
+
issued_ip: '10.0.0.1',
|
|
386
|
+
issued_user_agent: 'Chrome',
|
|
387
|
+
},
|
|
388
|
+
] as never);
|
|
389
|
+
|
|
390
|
+
const result = await service.pollReverse({ pollToken: 'T', locale: 'en' });
|
|
391
|
+
|
|
392
|
+
expect(result).toMatchObject({ status: 'confirmed', payload: 'BLOB' });
|
|
393
|
+
expect(deps.auth.getAuthenticationPayload).toHaveBeenCalledWith(
|
|
394
|
+
'en',
|
|
395
|
+
USER_ID,
|
|
396
|
+
'10.0.0.1',
|
|
397
|
+
'Chrome',
|
|
398
|
+
);
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
it('sem want_session não emite sessão nenhuma', async () => {
|
|
402
|
+
deps.prisma.device_pairing_request.findFirst.mockResolvedValueOnce(
|
|
403
|
+
makeRow({
|
|
404
|
+
direction: 'device-to-browser',
|
|
405
|
+
confirmed_at: new Date(),
|
|
406
|
+
}) as never,
|
|
407
|
+
);
|
|
408
|
+
deps.prisma.$queryRaw.mockResolvedValueOnce([
|
|
409
|
+
{
|
|
410
|
+
user_id: USER_ID,
|
|
411
|
+
payload_enc: 'BLOB',
|
|
412
|
+
want_session: false,
|
|
413
|
+
issued_ip: null,
|
|
414
|
+
issued_user_agent: null,
|
|
415
|
+
},
|
|
416
|
+
] as never);
|
|
417
|
+
|
|
418
|
+
const result = await service.pollReverse({ pollToken: 'T', locale: 'en' });
|
|
419
|
+
|
|
420
|
+
expect(result).toEqual({ status: 'confirmed', payload: 'BLOB' });
|
|
421
|
+
expect(deps.auth.getAuthenticationPayload).not.toHaveBeenCalled();
|
|
422
|
+
});
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
describe('zero-knowledge', () => {
|
|
426
|
+
it('o serviço não tem como decifrar o payload', () => {
|
|
427
|
+
// O SecurityService injetado expõe só o hash. Se alguém adicionar
|
|
428
|
+
// `security.decrypt(payload_enc)` mais tarde, este teste quebra na hora —
|
|
429
|
+
// e é o único guarda-corpo automático da promessa de zero-knowledge.
|
|
430
|
+
expect(Object.keys(deps.security)).toEqual(['hashSha256']);
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
it('o blob volta byte a byte como entrou', async () => {
|
|
434
|
+
const blob = JSON.stringify({ v: 1, c: 'ciphertext', i: 'iv' });
|
|
435
|
+
deps.prisma.device_pairing_request.findFirst.mockResolvedValueOnce(
|
|
436
|
+
makeRow({ confirmed_at: new Date() }) as never,
|
|
437
|
+
);
|
|
438
|
+
deps.prisma.$queryRaw.mockResolvedValueOnce([
|
|
439
|
+
{ user_id: USER_ID, payload_enc: blob },
|
|
440
|
+
] as never);
|
|
441
|
+
|
|
442
|
+
const result = await service.redeem({
|
|
443
|
+
authToken: 'T',
|
|
444
|
+
clientId: CLIENT_ID,
|
|
445
|
+
locale: 'en',
|
|
446
|
+
ipAddress: '',
|
|
447
|
+
userAgent: '',
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
expect((result as { payload: string }).payload).toBe(blob);
|
|
451
|
+
});
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
describe('limpeza', () => {
|
|
455
|
+
it('apaga o que expirou há mais de um dia', async () => {
|
|
456
|
+
await service.purgeExpired();
|
|
457
|
+
|
|
458
|
+
const where = deps.prisma.device_pairing_request.deleteMany.mock
|
|
459
|
+
.calls[0][0] as { where: { expires_at: { lt: Date } } };
|
|
460
|
+
expect(where.where.expires_at.lt.getTime()).toBeLessThan(Date.now());
|
|
461
|
+
});
|
|
462
|
+
});
|