@hed-hog/core 0.0.390 → 0.0.393
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,577 @@
|
|
|
1
|
+
// `Prisma` vem de @hed-hog/api-prisma, nao de '@prisma/client': o tsconfig do
|
|
2
|
+
// monorepo mapeia '@prisma/client' para o client gerado, que nao expoe
|
|
3
|
+
// `Prisma.sql`. E a convencao do repo inteiro.
|
|
4
|
+
import { Prisma, PrismaService } from '@hed-hog/api-prisma';
|
|
5
|
+
import { getLocaleText } from '@hed-hog/api-locale';
|
|
6
|
+
import { PaginationDTO, PaginationService } from '@hed-hog/api-pagination';
|
|
7
|
+
import {
|
|
8
|
+
BadRequestException,
|
|
9
|
+
ForbiddenException,
|
|
10
|
+
Inject,
|
|
11
|
+
Injectable,
|
|
12
|
+
Logger,
|
|
13
|
+
NotFoundException,
|
|
14
|
+
forwardRef,
|
|
15
|
+
} from '@nestjs/common';
|
|
16
|
+
import { Cron, CronExpression } from '@nestjs/schedule';
|
|
17
|
+
import { SecurityService } from '../security/security.service';
|
|
18
|
+
import { SessionService } from '../session/session.service';
|
|
19
|
+
import { SettingService } from '../setting/setting.service';
|
|
20
|
+
import { TokenService } from '../token/token.service';
|
|
21
|
+
import { UserService } from '../user/user.service';
|
|
22
|
+
|
|
23
|
+
type StartParams = {
|
|
24
|
+
locale: string;
|
|
25
|
+
operatorUserId: number;
|
|
26
|
+
targetUserId: number;
|
|
27
|
+
app: string;
|
|
28
|
+
reason?: string | null;
|
|
29
|
+
isImpersonating: boolean;
|
|
30
|
+
ipAddress: string;
|
|
31
|
+
userAgent: string;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
type RedeemParams = {
|
|
35
|
+
locale: string;
|
|
36
|
+
code: string;
|
|
37
|
+
ipAddress: string;
|
|
38
|
+
userAgent: string;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
type GrantRow = {
|
|
42
|
+
id: number;
|
|
43
|
+
impersonator_user_id: number;
|
|
44
|
+
target_user_id: number;
|
|
45
|
+
app: string;
|
|
46
|
+
reason: string | null;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Simulacao de acesso: um operador ve o sistema como outro usuario, por uma
|
|
51
|
+
* janela curta, com tudo marcado como simulado.
|
|
52
|
+
*
|
|
53
|
+
* DESENHO EM DUAS ETAPAS. `start` nao devolve token nenhum — devolve um codigo
|
|
54
|
+
* de uso unico com TTL de 60s, que viaja no FRAGMENT da URL da aba nova
|
|
55
|
+
* (fragment nao chega ao servidor, entao nao entra em log de acesso nem em
|
|
56
|
+
* Referer). Quem cria a sessao e o `redeem`, na aba de destino. Assim a sessao
|
|
57
|
+
* do operador nunca e tocada: nenhum cookie `rt` e emitido, nenhum
|
|
58
|
+
* `localStorage` compartilhado e sobrescrito.
|
|
59
|
+
*
|
|
60
|
+
* A SESSAO E NAO RENOVAVEL POR CONSTRUCAO. `SessionService.createImpersonation`
|
|
61
|
+
* gera o token opaco e o descarta, entao nao existe refresh token para ela em
|
|
62
|
+
* lugar nenhum — e nao apenas "e proibido renovar".
|
|
63
|
+
*/
|
|
64
|
+
@Injectable()
|
|
65
|
+
export class ImpersonationService {
|
|
66
|
+
private readonly logger = new Logger(ImpersonationService.name);
|
|
67
|
+
|
|
68
|
+
/** Curto: o codigo so precisa sobreviver ao carregamento da aba nova. */
|
|
69
|
+
private readonly codeTtlMs = 60_000;
|
|
70
|
+
|
|
71
|
+
/** Caminho da tela de resgate, igual nos tres apps. */
|
|
72
|
+
static readonly REDEEM_PATH = '/simulacao';
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Simular quem ja e administrador nao ajuda em nada no suporte e transformaria
|
|
76
|
+
* o papel `admin-impersonation` num atalho para virar `admin`.
|
|
77
|
+
*/
|
|
78
|
+
private static readonly BLOCKED_TARGET_ROLES = ['admin', 'admin-impersonation'];
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Apps com tela de resgate. `training` tem autenticacao propria e nao usa o
|
|
82
|
+
* @hed-hog/next-app-provider, entao ficou fora desta fase.
|
|
83
|
+
*/
|
|
84
|
+
private static readonly REDEEMABLE_APPS = ['admin', 'class', 'partners'];
|
|
85
|
+
|
|
86
|
+
constructor(
|
|
87
|
+
@Inject(forwardRef(() => PrismaService))
|
|
88
|
+
private readonly prisma: PrismaService,
|
|
89
|
+
@Inject(forwardRef(() => SecurityService))
|
|
90
|
+
private readonly security: SecurityService,
|
|
91
|
+
@Inject(forwardRef(() => SettingService))
|
|
92
|
+
private readonly setting: SettingService,
|
|
93
|
+
@Inject(forwardRef(() => TokenService))
|
|
94
|
+
private readonly token: TokenService,
|
|
95
|
+
@Inject(forwardRef(() => SessionService))
|
|
96
|
+
private readonly session: SessionService,
|
|
97
|
+
@Inject(forwardRef(() => UserService))
|
|
98
|
+
private readonly user: UserService,
|
|
99
|
+
@Inject(forwardRef(() => PaginationService))
|
|
100
|
+
private readonly pagination: PaginationService,
|
|
101
|
+
) {}
|
|
102
|
+
|
|
103
|
+
// ==========================================
|
|
104
|
+
// Etapa 1 — emissao do codigo
|
|
105
|
+
// ==========================================
|
|
106
|
+
|
|
107
|
+
async start(params: StartParams) {
|
|
108
|
+
const { locale, operatorUserId, targetUserId } = params;
|
|
109
|
+
|
|
110
|
+
if (params.isImpersonating) {
|
|
111
|
+
throw new ForbiddenException(
|
|
112
|
+
getLocaleText(
|
|
113
|
+
'impersonation.nested',
|
|
114
|
+
locale,
|
|
115
|
+
'You cannot start an access simulation from inside another one.',
|
|
116
|
+
),
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (operatorUserId === targetUserId) {
|
|
121
|
+
throw new BadRequestException(
|
|
122
|
+
getLocaleText(
|
|
123
|
+
'impersonation.self',
|
|
124
|
+
locale,
|
|
125
|
+
'You cannot simulate your own access.',
|
|
126
|
+
),
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
await this.assertTargetIsEligible(locale, targetUserId);
|
|
131
|
+
|
|
132
|
+
const origin = await this.resolveAppOrigin(locale, params.app);
|
|
133
|
+
|
|
134
|
+
const code = this.security.randomOpaque(32);
|
|
135
|
+
const codeHash = this.security.hashSha256(code);
|
|
136
|
+
const reason = params.reason?.trim() ? params.reason.trim().slice(0, 255) : null;
|
|
137
|
+
const expiresAt = new Date(Date.now() + this.codeTtlMs);
|
|
138
|
+
|
|
139
|
+
const grant = await this.prisma.impersonation_grant.create({
|
|
140
|
+
data: {
|
|
141
|
+
code_hash: codeHash,
|
|
142
|
+
impersonator_user_id: operatorUserId,
|
|
143
|
+
target_user_id: targetUserId,
|
|
144
|
+
app: params.app,
|
|
145
|
+
reason,
|
|
146
|
+
issued_ip: params.ipAddress || null,
|
|
147
|
+
issued_user_agent: params.userAgent || null,
|
|
148
|
+
expires_at: expiresAt,
|
|
149
|
+
},
|
|
150
|
+
select: { id: true },
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// A TENTATIVA ja vira auditoria, mesmo que o codigo nunca seja resgatado —
|
|
154
|
+
// pedir acesso a conta de alguem e o evento relevante, nao so consumi-lo.
|
|
155
|
+
await this.user.recordUserChange({
|
|
156
|
+
targetUserId,
|
|
157
|
+
actorUserId: operatorUserId,
|
|
158
|
+
action: 'impersonation_requested',
|
|
159
|
+
summary: `app=${params.app} grant=#${grant.id}${reason ? ` reason=${reason}` : ''}`,
|
|
160
|
+
ipAddress: params.ipAddress || null,
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
this.logger.log(
|
|
164
|
+
`[Impersonation] grant=#${grant.id} operator=${operatorUserId} target=${targetUserId} app=${params.app} ip=${params.ipAddress}`,
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
return {
|
|
168
|
+
// O codigo vai no fragment: nunca chega ao servidor de destino, nao entra
|
|
169
|
+
// em access_log nem em Referer, e a tela de resgate o apaga com
|
|
170
|
+
// history.replaceState logo apos ler.
|
|
171
|
+
url: `${origin}${ImpersonationService.REDEEM_PATH}#code=${code}`,
|
|
172
|
+
expiresAt: expiresAt.toISOString(),
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// ==========================================
|
|
177
|
+
// Etapa 2 — resgate na aba de destino
|
|
178
|
+
// ==========================================
|
|
179
|
+
|
|
180
|
+
async redeem(params: RedeemParams) {
|
|
181
|
+
const { locale } = params;
|
|
182
|
+
const codeHash = this.security.hashSha256(params.code ?? '');
|
|
183
|
+
|
|
184
|
+
// Consumo atomico: dois requests com o mesmo codigo — o caso de replay — so
|
|
185
|
+
// podem ter um vencedor, decidido pelo banco.
|
|
186
|
+
const rows = await this.prisma.$queryRaw<GrantRow[]>(
|
|
187
|
+
Prisma.sql`
|
|
188
|
+
UPDATE impersonation_grant
|
|
189
|
+
SET consumed_at = NOW(),
|
|
190
|
+
redeemed_ip = ${params.ipAddress || null},
|
|
191
|
+
redeemed_user_agent = ${params.userAgent || null}
|
|
192
|
+
WHERE code_hash = ${codeHash}
|
|
193
|
+
AND expires_at > NOW()
|
|
194
|
+
AND consumed_at IS NULL
|
|
195
|
+
RETURNING id, impersonator_user_id, target_user_id, app, reason
|
|
196
|
+
`,
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
const grant = rows[0];
|
|
200
|
+
if (!grant) {
|
|
201
|
+
// Uma mensagem so para todos os modos de falha (inexistente, expirado, ja
|
|
202
|
+
// usado): distingui-los entregaria um oraculo a quem tem so o codigo.
|
|
203
|
+
throw new BadRequestException(
|
|
204
|
+
getLocaleText(
|
|
205
|
+
'impersonation.invalidCode',
|
|
206
|
+
locale,
|
|
207
|
+
'Invalid, expired or already used simulation code.',
|
|
208
|
+
),
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Revalida: o alvo pode ter virado admin ou sido desativado dentro dos 60s.
|
|
213
|
+
await this.assertTargetIsEligible(locale, grant.target_user_id);
|
|
214
|
+
|
|
215
|
+
const settings = await this.setting.getSettingValues(['impersonation-session-minutes']);
|
|
216
|
+
const minutes = Number(settings['impersonation-session-minutes']) || 30;
|
|
217
|
+
|
|
218
|
+
const session = await this.session.createImpersonation(
|
|
219
|
+
locale,
|
|
220
|
+
grant.target_user_id,
|
|
221
|
+
grant.impersonator_user_id,
|
|
222
|
+
params.ipAddress,
|
|
223
|
+
params.userAgent,
|
|
224
|
+
minutes,
|
|
225
|
+
grant.reason,
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
// `expiresIn` por chamada: o token precisa morrer junto com a sessao, nao
|
|
229
|
+
// aos 15 minutos globais do JwtModule (e nao ha refresh para renova-lo).
|
|
230
|
+
const accessToken = await this.token.createAccessToken(
|
|
231
|
+
{
|
|
232
|
+
sub: grant.target_user_id,
|
|
233
|
+
sessionId: session.id,
|
|
234
|
+
act: grant.impersonator_user_id,
|
|
235
|
+
imp: true,
|
|
236
|
+
},
|
|
237
|
+
{ expiresIn: minutes * 60 },
|
|
238
|
+
);
|
|
239
|
+
|
|
240
|
+
await this.prisma.impersonation_grant.update({
|
|
241
|
+
where: { id: grant.id },
|
|
242
|
+
data: { session_id: session.id },
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
const [operator, target] = await this.getUserPair(
|
|
246
|
+
grant.impersonator_user_id,
|
|
247
|
+
grant.target_user_id,
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
await Promise.all([
|
|
251
|
+
this.user.registerUserActivity(
|
|
252
|
+
grant.target_user_id,
|
|
253
|
+
'impersonationStarted',
|
|
254
|
+
grant.impersonator_user_id,
|
|
255
|
+
),
|
|
256
|
+
this.user.registerUserActivity(
|
|
257
|
+
grant.impersonator_user_id,
|
|
258
|
+
'impersonationPerformed',
|
|
259
|
+
grant.target_user_id,
|
|
260
|
+
),
|
|
261
|
+
this.user.recordUserChange({
|
|
262
|
+
targetUserId: grant.target_user_id,
|
|
263
|
+
actorUserId: grant.impersonator_user_id,
|
|
264
|
+
action: 'impersonation_started',
|
|
265
|
+
summary: `app=${grant.app} session=#${session.id} expires=${session.expires_at.toISOString()}${grant.reason ? ` reason=${grant.reason}` : ''}`,
|
|
266
|
+
ipAddress: params.ipAddress || null,
|
|
267
|
+
}),
|
|
268
|
+
]);
|
|
269
|
+
|
|
270
|
+
this.logger.log(
|
|
271
|
+
`[Impersonation] redeemed grant=#${grant.id} session=#${session.id} operator=${grant.impersonator_user_id} target=${grant.target_user_id} minutes=${minutes}`,
|
|
272
|
+
);
|
|
273
|
+
|
|
274
|
+
return {
|
|
275
|
+
accessToken,
|
|
276
|
+
expiresAt: session.expires_at.toISOString(),
|
|
277
|
+
sessionId: session.id,
|
|
278
|
+
app: grant.app,
|
|
279
|
+
operator,
|
|
280
|
+
target,
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// ==========================================
|
|
285
|
+
// Encerrar
|
|
286
|
+
// ==========================================
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Chamado pela propria sessao simulada, entao todos os identificadores vem do
|
|
290
|
+
* `request.auth` — nao ha parametro que permita encerrar sessao alheia.
|
|
291
|
+
*/
|
|
292
|
+
async stop(params: {
|
|
293
|
+
sessionId: number | null;
|
|
294
|
+
targetUserId: number;
|
|
295
|
+
operatorUserId: number | null;
|
|
296
|
+
ipAddress?: string;
|
|
297
|
+
}) {
|
|
298
|
+
if (!params.sessionId || !params.operatorUserId) {
|
|
299
|
+
return { ended: false };
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
const revoked = await this.prisma.user_session.updateMany({
|
|
303
|
+
where: {
|
|
304
|
+
id: params.sessionId,
|
|
305
|
+
revoked_at: null,
|
|
306
|
+
impersonator_user_id: { not: null },
|
|
307
|
+
},
|
|
308
|
+
data: { revoked_at: new Date() },
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
await this.prisma.impersonation_grant.updateMany({
|
|
312
|
+
where: { session_id: params.sessionId, ended_at: null },
|
|
313
|
+
data: { ended_at: new Date() },
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
if (revoked.count > 0) {
|
|
317
|
+
await Promise.all([
|
|
318
|
+
this.user.registerUserActivity(
|
|
319
|
+
params.targetUserId,
|
|
320
|
+
'impersonationEnded',
|
|
321
|
+
params.operatorUserId,
|
|
322
|
+
),
|
|
323
|
+
this.user.registerUserActivity(
|
|
324
|
+
params.operatorUserId,
|
|
325
|
+
'impersonationPerformedEnded',
|
|
326
|
+
params.targetUserId,
|
|
327
|
+
),
|
|
328
|
+
this.user.recordUserChange({
|
|
329
|
+
targetUserId: params.targetUserId,
|
|
330
|
+
actorUserId: params.operatorUserId,
|
|
331
|
+
action: 'impersonation_ended',
|
|
332
|
+
summary: `session=#${params.sessionId}`,
|
|
333
|
+
ipAddress: params.ipAddress || null,
|
|
334
|
+
}),
|
|
335
|
+
]);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
this.logger.log(
|
|
339
|
+
`[Impersonation] stopped session=#${params.sessionId} operator=${params.operatorUserId} target=${params.targetUserId} revoked=${revoked.count}`,
|
|
340
|
+
);
|
|
341
|
+
|
|
342
|
+
return { ended: revoked.count > 0 };
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// ==========================================
|
|
346
|
+
// Leitura
|
|
347
|
+
// ==========================================
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Fonte de verdade do banner. A `sessionStorage` do cliente e so cache — e
|
|
351
|
+
* gravavel pelo proprio navegador, entao nao serve para decidir nada.
|
|
352
|
+
*/
|
|
353
|
+
async currentSession(sessionId: number | null) {
|
|
354
|
+
if (!sessionId) {
|
|
355
|
+
return { active: false as const };
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
const session = await this.prisma.user_session.findUnique({
|
|
359
|
+
where: { id: sessionId },
|
|
360
|
+
select: {
|
|
361
|
+
user_id: true,
|
|
362
|
+
impersonator_user_id: true,
|
|
363
|
+
impersonation_reason: true,
|
|
364
|
+
expires_at: true,
|
|
365
|
+
revoked_at: true,
|
|
366
|
+
},
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
if (!session?.impersonator_user_id || session.revoked_at) {
|
|
370
|
+
return { active: false as const };
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
const [operator, target] = await this.getUserPair(
|
|
374
|
+
session.impersonator_user_id,
|
|
375
|
+
session.user_id,
|
|
376
|
+
);
|
|
377
|
+
|
|
378
|
+
return {
|
|
379
|
+
active: true as const,
|
|
380
|
+
operator,
|
|
381
|
+
target,
|
|
382
|
+
reason: session.impersonation_reason,
|
|
383
|
+
expiresAt: session.expires_at.toISOString(),
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/** Apps que o operador pode escolher como destino. */
|
|
388
|
+
async listRedeemableApps() {
|
|
389
|
+
const settings = await this.setting.getSettingValues(['app-urls']);
|
|
390
|
+
const entries = this.parseAppUrls(settings['app-urls']);
|
|
391
|
+
|
|
392
|
+
return ImpersonationService.REDEEMABLE_APPS.filter((key) => entries.has(key)).map(
|
|
393
|
+
(key) => ({ key, url: entries.get(key)! }),
|
|
394
|
+
);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
async history(paginationParams: PaginationDTO, filters: { targetUserId?: number }) {
|
|
398
|
+
const where: any = {};
|
|
399
|
+
if (filters.targetUserId) {
|
|
400
|
+
where.target_user_id = filters.targetUserId;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
const paginated = await this.pagination.paginatePrismaModel(
|
|
404
|
+
this.prisma.impersonation_grant,
|
|
405
|
+
{
|
|
406
|
+
...paginationParams,
|
|
407
|
+
sortField: (paginationParams as any)?.sortField || 'created_at',
|
|
408
|
+
sortOrder: (paginationParams as any)?.sortOrder || 'desc',
|
|
409
|
+
validSortFields: ['id', 'created_at', 'consumed_at', 'ended_at'],
|
|
410
|
+
where,
|
|
411
|
+
},
|
|
412
|
+
);
|
|
413
|
+
|
|
414
|
+
const rows = (paginated.data || []) as any[];
|
|
415
|
+
const ids = [
|
|
416
|
+
...new Set(
|
|
417
|
+
rows.flatMap((row) => [row.impersonator_user_id, row.target_user_id]),
|
|
418
|
+
),
|
|
419
|
+
].filter((id): id is number => typeof id === 'number');
|
|
420
|
+
|
|
421
|
+
const users = ids.length
|
|
422
|
+
? await this.prisma.user.findMany({
|
|
423
|
+
where: { id: { in: ids } },
|
|
424
|
+
select: { id: true, name: true },
|
|
425
|
+
})
|
|
426
|
+
: [];
|
|
427
|
+
const byId = new Map(users.map((user) => [user.id, user]));
|
|
428
|
+
|
|
429
|
+
return {
|
|
430
|
+
...paginated,
|
|
431
|
+
data: rows.map((row) => ({
|
|
432
|
+
// `code_hash` nunca sai daqui.
|
|
433
|
+
id: row.id,
|
|
434
|
+
app: row.app,
|
|
435
|
+
reason: row.reason,
|
|
436
|
+
sessionId: row.session_id,
|
|
437
|
+
operator: byId.get(row.impersonator_user_id) ?? null,
|
|
438
|
+
target: byId.get(row.target_user_id) ?? null,
|
|
439
|
+
issuedIp: row.issued_ip,
|
|
440
|
+
redeemedIp: row.redeemed_ip,
|
|
441
|
+
consumedAt: row.consumed_at?.toISOString?.() ?? null,
|
|
442
|
+
endedAt: row.ended_at?.toISOString?.() ?? null,
|
|
443
|
+
expiresAt: row.expires_at?.toISOString?.() ?? null,
|
|
444
|
+
createdAt: row.created_at?.toISOString?.() ?? null,
|
|
445
|
+
})),
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
// ==========================================
|
|
450
|
+
// Manutencao
|
|
451
|
+
// ==========================================
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* Concessoes nao resgatadas viram lixo em 60s. As consumidas ficam: sao a
|
|
455
|
+
* trilha de auditoria.
|
|
456
|
+
*/
|
|
457
|
+
@Cron(CronExpression.EVERY_DAY_AT_4AM)
|
|
458
|
+
async purgeExpired() {
|
|
459
|
+
const { count } = await this.prisma.impersonation_grant.deleteMany({
|
|
460
|
+
where: {
|
|
461
|
+
consumed_at: null,
|
|
462
|
+
expires_at: { lt: new Date(Date.now() - 24 * 60 * 60 * 1000) },
|
|
463
|
+
},
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
if (count > 0) {
|
|
467
|
+
this.logger.log(`[Impersonation] purged ${count} unredeemed grant(s)`);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
// ==========================================
|
|
472
|
+
// Helpers
|
|
473
|
+
// ==========================================
|
|
474
|
+
|
|
475
|
+
private async assertTargetIsEligible(locale: string, targetUserId: number) {
|
|
476
|
+
const target = await this.prisma.user.findUnique({
|
|
477
|
+
where: { id: targetUserId },
|
|
478
|
+
select: {
|
|
479
|
+
id: true,
|
|
480
|
+
deactivated_at: true,
|
|
481
|
+
role_user: { select: { role: { select: { slug: true } } } },
|
|
482
|
+
},
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
if (!target) {
|
|
486
|
+
throw new NotFoundException(
|
|
487
|
+
getLocaleText('userNotFound', locale, 'User not found'),
|
|
488
|
+
);
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
// Conta excluida pelo proprio usuario: os identificadores ja foram
|
|
492
|
+
// anonimizados, entao nao ha o que simular.
|
|
493
|
+
if (target.deactivated_at) {
|
|
494
|
+
throw new BadRequestException(
|
|
495
|
+
getLocaleText(
|
|
496
|
+
'impersonation.deactivatedTarget',
|
|
497
|
+
locale,
|
|
498
|
+
'This account has been deactivated and cannot be simulated.',
|
|
499
|
+
),
|
|
500
|
+
);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// Conta suspensa CONTINUA simulavel de proposito: "o usuario nao consegue
|
|
504
|
+
// entrar" e justamente o chamado de suporte mais comum.
|
|
505
|
+
|
|
506
|
+
const slugs = target.role_user.map((link) => link.role?.slug).filter(Boolean);
|
|
507
|
+
if (slugs.some((slug) => ImpersonationService.BLOCKED_TARGET_ROLES.includes(slug!))) {
|
|
508
|
+
throw new ForbiddenException(
|
|
509
|
+
getLocaleText(
|
|
510
|
+
'impersonation.privilegedTarget',
|
|
511
|
+
locale,
|
|
512
|
+
'Administrators cannot be simulated.',
|
|
513
|
+
),
|
|
514
|
+
);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
private async resolveAppOrigin(locale: string, app: string) {
|
|
519
|
+
if (!ImpersonationService.REDEEMABLE_APPS.includes(app)) {
|
|
520
|
+
throw new BadRequestException(
|
|
521
|
+
getLocaleText(
|
|
522
|
+
'impersonation.unknownApp',
|
|
523
|
+
locale,
|
|
524
|
+
'This application does not support access simulation.',
|
|
525
|
+
),
|
|
526
|
+
);
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
const settings = await this.setting.getSettingValues(['app-urls']);
|
|
530
|
+
const origin = this.parseAppUrls(settings['app-urls']).get(app);
|
|
531
|
+
|
|
532
|
+
if (!origin) {
|
|
533
|
+
throw new BadRequestException(
|
|
534
|
+
getLocaleText(
|
|
535
|
+
'impersonation.appNotConfigured',
|
|
536
|
+
locale,
|
|
537
|
+
'This application has no URL configured in the app-urls setting.',
|
|
538
|
+
),
|
|
539
|
+
);
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
return origin;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* `app-urls` e uma lista de `chave=url`. Mesmo formato lido por
|
|
547
|
+
* `ChallengeService.resolveAppKeyFromOrigin` e `OAuthService`.
|
|
548
|
+
*/
|
|
549
|
+
private parseAppUrls(value: unknown): Map<string, string> {
|
|
550
|
+
const entries = new Map<string, string>();
|
|
551
|
+
const list: string[] = Array.isArray(value) ? value : [];
|
|
552
|
+
|
|
553
|
+
for (const entry of list) {
|
|
554
|
+
const separatorIndex = entry.indexOf('=');
|
|
555
|
+
if (separatorIndex === -1) continue;
|
|
556
|
+
|
|
557
|
+
const key = entry.slice(0, separatorIndex).trim();
|
|
558
|
+
const url = entry.slice(separatorIndex + 1).trim().replace(/\/+$/, '');
|
|
559
|
+
if (key && url) entries.set(key, url);
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
return entries;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
private async getUserPair(operatorId: number, targetId: number) {
|
|
566
|
+
const users = await this.prisma.user.findMany({
|
|
567
|
+
where: { id: { in: [operatorId, targetId] } },
|
|
568
|
+
select: { id: true, name: true },
|
|
569
|
+
});
|
|
570
|
+
const byId = new Map(users.map((user) => [user.id, user]));
|
|
571
|
+
|
|
572
|
+
return [
|
|
573
|
+
byId.get(operatorId) ?? { id: operatorId, name: '' },
|
|
574
|
+
byId.get(targetId) ?? { id: targetId, name: '' },
|
|
575
|
+
];
|
|
576
|
+
}
|
|
577
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -49,6 +49,7 @@ export * from './file/file.service';
|
|
|
49
49
|
|
|
50
50
|
export * from './pdf/pdf.module';
|
|
51
51
|
export * from './pdf/pdf.service';
|
|
52
|
+
export * from './setting/brand-asset.service';
|
|
52
53
|
export * from './setting/setting.module';
|
|
53
54
|
export * from './setting/setting.service';
|
|
54
55
|
|
|
@@ -65,12 +66,26 @@ export * from './ai-instruction/types/ai-instruction.types';
|
|
|
65
66
|
|
|
66
67
|
export * from './app-command/app-command.module';
|
|
67
68
|
export * from './app-command/app-command.registry';
|
|
69
|
+
export * from './mail-delivery/mail-delivery.constants';
|
|
70
|
+
export * from './mail-delivery/mail-delivery-provision.service';
|
|
71
|
+
export * from './mail-delivery/mail-delivery.module';
|
|
72
|
+
export * from './mail-delivery/mail-delivery.service';
|
|
73
|
+
export * from './mail-delivery/ses-event.parser';
|
|
74
|
+
export * from './mail-delivery/ses-webhook.service';
|
|
75
|
+
export * from './mail-delivery/sns-message.util';
|
|
68
76
|
export * from './webhook-integration/event-webhook.service';
|
|
69
77
|
export * from './webhook-integration/integration-event-catalog.service';
|
|
70
78
|
export * from './webhook-integration/webhook-integration.module';
|
|
71
79
|
export * from './webhook-integration/webhook-integration.service';
|
|
72
80
|
export * from './webhook-integration/webhook-protocol.registry';
|
|
73
81
|
|
|
82
|
+
// Meeting Module (porta genérica de reuniões online)
|
|
83
|
+
export * from './mailbox/mailbox.module';
|
|
84
|
+
export * from './mailbox/mailbox-fetcher.registry';
|
|
85
|
+
export * from './meeting/meeting.constants';
|
|
86
|
+
export * from './meeting/meeting.module';
|
|
87
|
+
export * from './meeting/meeting-provider.registry';
|
|
88
|
+
|
|
74
89
|
// Integration Module
|
|
75
90
|
export * from './integration/integration.module';
|
|
76
91
|
export * from './integration/services/domain-event.publisher';
|
|
@@ -104,6 +119,9 @@ export * from './oauth/oauth-token-broker.service';
|
|
|
104
119
|
|
|
105
120
|
// Utilities
|
|
106
121
|
export * from './utils/locale-context';
|
|
122
|
+
export * from './utils/geo-ip';
|
|
123
|
+
export * from './utils/user-agent';
|
|
124
|
+
export * from './utils/security-event-vars';
|
|
107
125
|
|
|
108
126
|
|
|
109
127
|
// Notification Module
|
|
@@ -120,3 +138,6 @@ export * from './realtime/realtime.gateway';
|
|
|
120
138
|
export * from './presence/presence.module';
|
|
121
139
|
export * from './presence/presence.service';
|
|
122
140
|
|
|
141
|
+
// Observability
|
|
142
|
+
export * from './observability/monitored-cron';
|
|
143
|
+
|