@hed-hog/core 0.0.398 → 0.0.400
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/ai-agent.sort.d.ts +6 -0
- package/dist/ai/ai-agent.sort.d.ts.map +1 -0
- package/dist/ai/ai-agent.sort.js +21 -0
- package/dist/ai/ai-agent.sort.js.map +1 -0
- package/dist/ai/ai.controller.d.ts +4 -4
- package/dist/ai/ai.service.d.ts +35 -4
- package/dist/ai/ai.service.d.ts.map +1 -1
- package/dist/ai/ai.service.js +51 -137
- package/dist/ai/ai.service.js.map +1 -1
- package/dist/ai-instruction/ai-instruction.service.d.ts.map +1 -1
- package/dist/ai-instruction/ai-instruction.service.js +26 -23
- package/dist/ai-instruction/ai-instruction.service.js.map +1 -1
- package/dist/ai-instruction/ai-instruction.sort.d.ts +16 -0
- package/dist/ai-instruction/ai-instruction.sort.d.ts.map +1 -0
- package/dist/ai-instruction/ai-instruction.sort.js +32 -0
- package/dist/ai-instruction/ai-instruction.sort.js.map +1 -0
- package/dist/auth/auth.controller.d.ts +24 -8
- package/dist/auth/auth.controller.d.ts.map +1 -1
- package/dist/auth/auth.module.d.ts.map +1 -1
- package/dist/auth/auth.module.js +8 -1
- package/dist/auth/auth.module.js.map +1 -1
- package/dist/auth/auth.service.d.ts +72 -25
- package/dist/auth/auth.service.d.ts.map +1 -1
- package/dist/auth/auth.service.js +41 -4
- package/dist/auth/auth.service.js.map +1 -1
- package/dist/auth/guards/auth.guard.d.ts +3 -1
- package/dist/auth/guards/auth.guard.d.ts.map +1 -1
- package/dist/auth/guards/auth.guard.js +12 -3
- package/dist/auth/guards/auth.guard.js.map +1 -1
- package/dist/authorize/authorize.controller.d.ts +30 -6
- package/dist/authorize/authorize.controller.d.ts.map +1 -1
- package/dist/authorize/authorize.controller.js +120 -13
- package/dist/authorize/authorize.controller.js.map +1 -1
- package/dist/authorize/authorize.errors.d.ts +34 -0
- package/dist/authorize/authorize.errors.d.ts.map +1 -0
- package/dist/authorize/authorize.errors.js +37 -0
- package/dist/authorize/authorize.errors.js.map +1 -0
- package/dist/authorize/authorize.module.d.ts.map +1 -1
- package/dist/authorize/authorize.module.js +6 -1
- package/dist/authorize/authorize.module.js.map +1 -1
- package/dist/authorize/authorize.service.d.ts +78 -4
- package/dist/authorize/authorize.service.d.ts.map +1 -1
- package/dist/authorize/authorize.service.js +212 -21
- package/dist/authorize/authorize.service.js.map +1 -1
- package/dist/authorize/dto/authorize-info.dto.d.ts +10 -1
- package/dist/authorize/dto/authorize-info.dto.d.ts.map +1 -1
- package/dist/authorize/dto/authorize-info.dto.js +16 -1
- package/dist/authorize/dto/authorize-info.dto.js.map +1 -1
- package/dist/authorize/dto/consent.dto.d.ts +10 -1
- package/dist/authorize/dto/consent.dto.d.ts.map +1 -1
- package/dist/authorize/dto/consent.dto.js +16 -1
- package/dist/authorize/dto/consent.dto.js.map +1 -1
- package/dist/authorize/dto/token.dto.d.ts +12 -0
- package/dist/authorize/dto/token.dto.d.ts.map +1 -1
- package/dist/authorize/dto/token.dto.js +21 -1
- package/dist/authorize/dto/token.dto.js.map +1 -1
- package/dist/authorize/oauth-exception.filter.d.ts +17 -0
- package/dist/authorize/oauth-exception.filter.d.ts.map +1 -0
- package/dist/authorize/oauth-exception.filter.js +54 -0
- package/dist/authorize/oauth-exception.filter.js.map +1 -0
- package/dist/authorize/oauth-metadata.service.d.ts +39 -0
- package/dist/authorize/oauth-metadata.service.d.ts.map +1 -0
- package/dist/authorize/oauth-metadata.service.js +81 -0
- package/dist/authorize/oauth-metadata.service.js.map +1 -0
- package/dist/authorize/well-known.controller.d.ts +67 -0
- package/dist/authorize/well-known.controller.d.ts.map +1 -0
- package/dist/authorize/well-known.controller.js +126 -0
- package/dist/authorize/well-known.controller.js.map +1 -0
- package/dist/captcha/captcha.service.d.ts +32 -2
- package/dist/captcha/captcha.service.d.ts.map +1 -1
- package/dist/captcha/captcha.service.js +85 -12
- package/dist/captcha/captcha.service.js.map +1 -1
- package/dist/challenge/challenge.service.d.ts +2 -2
- package/dist/core.module.d.ts.map +1 -1
- package/dist/core.module.js +6 -0
- package/dist/core.module.js.map +1 -1
- package/dist/dashboard/dashboard/dashboard.controller.d.ts +9 -9
- package/dist/dashboard/dashboard/dashboard.service.d.ts +9 -9
- package/dist/dashboard/dashboard-component/dashboard-component.controller.d.ts +3 -3
- package/dist/dashboard/dashboard-component/dashboard-component.service.d.ts +3 -3
- package/dist/dashboard/dashboard-component-role/dashboard-component-role.controller.d.ts +3 -3
- package/dist/dashboard/dashboard-component-role/dashboard-component-role.service.d.ts +3 -3
- package/dist/dashboard/dashboard-component-role/dashboard-component-role.service.d.ts.map +1 -1
- package/dist/dashboard/dashboard-component-role/dashboard-component-role.service.js +2 -4
- package/dist/dashboard/dashboard-component-role/dashboard-component-role.service.js.map +1 -1
- package/dist/dashboard/dashboard-component-role/dashboard-component-role.sort.d.ts +8 -0
- package/dist/dashboard/dashboard-component-role/dashboard-component-role.sort.d.ts.map +1 -0
- package/dist/dashboard/dashboard-component-role/dashboard-component-role.sort.js +18 -0
- package/dist/dashboard/dashboard-component-role/dashboard-component-role.sort.js.map +1 -0
- package/dist/dashboard/dashboard-item/dashboard-item.service.d.ts.map +1 -1
- package/dist/dashboard/dashboard-item/dashboard-item.service.js +2 -4
- package/dist/dashboard/dashboard-item/dashboard-item.service.js.map +1 -1
- package/dist/dashboard/dashboard-item/dashboard-item.sort.d.ts +9 -0
- package/dist/dashboard/dashboard-item/dashboard-item.sort.d.ts.map +1 -0
- package/dist/dashboard/dashboard-item/dashboard-item.sort.js +19 -0
- package/dist/dashboard/dashboard-item/dashboard-item.sort.js.map +1 -0
- package/dist/dashboard/dashboard-role/dashboard-role.controller.d.ts +3 -3
- package/dist/dashboard/dashboard-role/dashboard-role.service.d.ts +3 -3
- package/dist/dashboard/dashboard-role/dashboard-role.service.d.ts.map +1 -1
- package/dist/dashboard/dashboard-role/dashboard-role.service.js +2 -4
- package/dist/dashboard/dashboard-role/dashboard-role.service.js.map +1 -1
- package/dist/dashboard/dashboard-role/dashboard-role.sort.d.ts +8 -0
- package/dist/dashboard/dashboard-role/dashboard-role.sort.d.ts.map +1 -0
- package/dist/dashboard/dashboard-role/dashboard-role.sort.js +16 -0
- package/dist/dashboard/dashboard-role/dashboard-role.sort.js.map +1 -0
- package/dist/file/file-upload-ticket.service.d.ts +160 -0
- package/dist/file/file-upload-ticket.service.d.ts.map +1 -0
- package/dist/file/file-upload-ticket.service.js +382 -0
- package/dist/file/file-upload-ticket.service.js.map +1 -0
- package/dist/file/file.controller.d.ts +24 -1
- package/dist/file/file.controller.d.ts.map +1 -1
- package/dist/file/file.controller.js +63 -2
- package/dist/file/file.controller.js.map +1 -1
- package/dist/file/file.module.d.ts.map +1 -1
- package/dist/file/file.module.js +14 -2
- package/dist/file/file.module.js.map +1 -1
- package/dist/file/file.service.d.ts +182 -6
- package/dist/file/file.service.d.ts.map +1 -1
- package/dist/file/file.service.js +385 -36
- package/dist/file/file.service.js.map +1 -1
- package/dist/file/filename-encoding.util.d.ts +24 -0
- package/dist/file/filename-encoding.util.d.ts.map +1 -0
- package/dist/file/filename-encoding.util.js +63 -0
- package/dist/file/filename-encoding.util.js.map +1 -0
- package/dist/file/image-optimization.service.d.ts +27 -0
- package/dist/file/image-optimization.service.d.ts.map +1 -1
- package/dist/file/image-optimization.service.js +63 -14
- package/dist/file/image-optimization.service.js.map +1 -1
- package/dist/file/mcp-file-source.schema.d.ts +33 -0
- package/dist/file/mcp-file-source.schema.d.ts.map +1 -0
- package/dist/file/mcp-file-source.schema.js +75 -0
- package/dist/file/mcp-file-source.schema.js.map +1 -0
- package/dist/file/mcp-file-source.service.d.ts +124 -0
- package/dist/file/mcp-file-source.service.d.ts.map +1 -0
- package/dist/file/mcp-file-source.service.js +262 -0
- package/dist/file/mcp-file-source.service.js.map +1 -0
- package/dist/file/mimetype-sniff.util.d.ts +62 -0
- package/dist/file/mimetype-sniff.util.d.ts.map +1 -0
- package/dist/file/mimetype-sniff.util.js +226 -0
- package/dist/file/mimetype-sniff.util.js.map +1 -0
- package/dist/file/remote-fetch.util.d.ts +35 -0
- package/dist/file/remote-fetch.util.d.ts.map +1 -0
- package/dist/file/remote-fetch.util.js +236 -0
- package/dist/file/remote-fetch.util.js.map +1 -0
- package/dist/impersonation/dto/start-impersonation.dto.d.ts +4 -1
- package/dist/impersonation/dto/start-impersonation.dto.d.ts.map +1 -1
- package/dist/impersonation/dto/start-impersonation.dto.js +1 -1
- package/dist/impersonation/dto/start-impersonation.dto.js.map +1 -1
- package/dist/impersonation/impersonation.service.d.ts +8 -3
- package/dist/impersonation/impersonation.service.d.ts.map +1 -1
- package/dist/impersonation/impersonation.service.js +14 -4
- package/dist/impersonation/impersonation.service.js.map +1 -1
- package/dist/incident/incident.controller.d.ts +2 -1
- package/dist/incident/incident.controller.d.ts.map +1 -1
- package/dist/incident/incident.controller.js +10 -6
- package/dist/incident/incident.controller.js.map +1 -1
- package/dist/incident/incident.service.d.ts +2 -0
- package/dist/incident/incident.service.d.ts.map +1 -1
- package/dist/incident/incident.service.js +4 -0
- package/dist/incident/incident.service.js.map +1 -1
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -1
- package/dist/integration-profile/integration-profile.secrets.d.ts.map +1 -1
- package/dist/integration-profile/integration-profile.secrets.js +7 -0
- package/dist/integration-profile/integration-profile.secrets.js.map +1 -1
- package/dist/integration-profile/integration-profile.service.d.ts +0 -13
- package/dist/integration-profile/integration-profile.service.d.ts.map +1 -1
- package/dist/integration-profile/integration-profile.service.js +5 -40
- package/dist/integration-profile/integration-profile.service.js.map +1 -1
- package/dist/integration-profile/integration-profile.utils.js +5 -5
- package/dist/integration-profile/integration-profile.utils.js.map +1 -1
- package/dist/integration-profile/testers/index.d.ts.map +1 -1
- package/dist/integration-profile/testers/index.js +2 -0
- package/dist/integration-profile/testers/index.js.map +1 -1
- package/dist/integration-profile/testers/shipping.testers.d.ts +3 -0
- package/dist/integration-profile/testers/shipping.testers.d.ts.map +1 -0
- package/dist/integration-profile/testers/shipping.testers.js +71 -0
- package/dist/integration-profile/testers/shipping.testers.js.map +1 -0
- package/dist/locale/locale.controller.d.ts +1 -1
- package/dist/locale/locale.service.d.ts +1 -1
- package/dist/mail/dto/send.dto.d.ts +6 -1
- package/dist/mail/dto/send.dto.d.ts.map +1 -1
- package/dist/mail/dto/send.dto.js.map +1 -1
- package/dist/mail/mail.service.d.ts +9 -0
- package/dist/mail/mail.service.d.ts.map +1 -1
- package/dist/mail/mail.service.js +34 -14
- package/dist/mail/mail.service.js.map +1 -1
- package/dist/mail-sent/mail-sent.controller.d.ts +1 -1
- package/dist/mail-sent/mail-sent.service.d.ts +1 -1
- package/dist/mail-sent/mail-sent.service.d.ts.map +1 -1
- package/dist/mail-sent/mail-sent.service.js +2 -1
- package/dist/mail-sent/mail-sent.service.js.map +1 -1
- package/dist/mail-sent/mail-sent.sort.d.ts +9 -0
- package/dist/mail-sent/mail-sent.sort.d.ts.map +1 -0
- package/dist/mail-sent/mail-sent.sort.js +19 -0
- package/dist/mail-sent/mail-sent.sort.js.map +1 -0
- package/dist/mcp/filters/mcp-challenge.filter.d.ts +20 -0
- package/dist/mcp/filters/mcp-challenge.filter.d.ts.map +1 -0
- package/dist/mcp/filters/mcp-challenge.filter.js +69 -0
- package/dist/mcp/filters/mcp-challenge.filter.js.map +1 -0
- package/dist/mcp/guards/mcp-auth.guard.d.ts +4 -1
- package/dist/mcp/guards/mcp-auth.guard.d.ts.map +1 -1
- package/dist/mcp/guards/mcp-auth.guard.js +19 -5
- package/dist/mcp/guards/mcp-auth.guard.js.map +1 -1
- package/dist/mcp/guards/mcp-permission.guard.d.ts +25 -3
- package/dist/mcp/guards/mcp-permission.guard.d.ts.map +1 -1
- package/dist/mcp/guards/mcp-permission.guard.js +46 -26
- package/dist/mcp/guards/mcp-permission.guard.js.map +1 -1
- package/dist/mcp/mcp-audit.service.d.ts +17 -0
- package/dist/mcp/mcp-audit.service.d.ts.map +1 -1
- package/dist/mcp/mcp-audit.service.js +32 -3
- package/dist/mcp/mcp-audit.service.js.map +1 -1
- package/dist/mcp/mcp-permission.service.d.ts +64 -0
- package/dist/mcp/mcp-permission.service.d.ts.map +1 -0
- package/dist/mcp/mcp-permission.service.js +178 -0
- package/dist/mcp/mcp-permission.service.js.map +1 -0
- package/dist/mcp/mcp-server.service.d.ts +3 -1
- package/dist/mcp/mcp-server.service.d.ts.map +1 -1
- package/dist/mcp/mcp-server.service.js +36 -15
- package/dist/mcp/mcp-server.service.js.map +1 -1
- package/dist/mcp/mcp.controller.d.ts.map +1 -1
- package/dist/mcp/mcp.controller.js +10 -2
- package/dist/mcp/mcp.controller.js.map +1 -1
- package/dist/mcp/mcp.module.d.ts.map +1 -1
- package/dist/mcp/mcp.module.js +5 -1
- package/dist/mcp/mcp.module.js.map +1 -1
- package/dist/mcp/tools/core-ai.mcp-tools.js +2 -9
- package/dist/mcp/tools/core-ai.mcp-tools.js.map +1 -1
- package/dist/mcp/tools/core-dashboard-items.mcp-tools.js +1 -1
- package/dist/mcp/tools/core-dashboard-items.mcp-tools.js.map +1 -1
- package/dist/mcp/tools/core-dashboard.mcp-tools.js +2 -9
- package/dist/mcp/tools/core-dashboard.mcp-tools.js.map +1 -1
- package/dist/mcp/tools/core-event-webhooks.mcp-tools.d.ts.map +1 -1
- package/dist/mcp/tools/core-event-webhooks.mcp-tools.js +2 -10
- package/dist/mcp/tools/core-event-webhooks.mcp-tools.js.map +1 -1
- package/dist/mcp/tools/core-files.mcp-tools.d.ts +17 -5
- package/dist/mcp/tools/core-files.mcp-tools.d.ts.map +1 -1
- package/dist/mcp/tools/core-files.mcp-tools.js +186 -24
- package/dist/mcp/tools/core-files.mcp-tools.js.map +1 -1
- package/dist/mcp/tools/core-integration-events.mcp-tools.js +2 -9
- package/dist/mcp/tools/core-integration-events.mcp-tools.js.map +1 -1
- package/dist/mcp/tools/core-mail-sent.mcp-tools.js +2 -14
- package/dist/mcp/tools/core-mail-sent.mcp-tools.js.map +1 -1
- package/dist/mcp/tools/core-mail.mcp-tools.js +2 -9
- package/dist/mcp/tools/core-mail.mcp-tools.js.map +1 -1
- package/dist/mcp/tools/core-menus.mcp-tools.d.ts.map +1 -1
- package/dist/mcp/tools/core-menus.mcp-tools.js +2 -10
- package/dist/mcp/tools/core-menus.mcp-tools.js.map +1 -1
- package/dist/mcp/tools/core-notifications.mcp-tools.d.ts.map +1 -1
- package/dist/mcp/tools/core-notifications.mcp-tools.js +0 -1
- package/dist/mcp/tools/core-notifications.mcp-tools.js.map +1 -1
- package/dist/mcp/tools/core-roles.mcp-tools.d.ts.map +1 -1
- package/dist/mcp/tools/core-roles.mcp-tools.js +2 -13
- package/dist/mcp/tools/core-roles.mcp-tools.js.map +1 -1
- package/dist/mcp/tools/core-routes.mcp-tools.d.ts.map +1 -1
- package/dist/mcp/tools/core-routes.mcp-tools.js +2 -11
- package/dist/mcp/tools/core-routes.mcp-tools.js.map +1 -1
- package/dist/mcp/tools/core-screens.mcp-tools.d.ts.map +1 -1
- package/dist/mcp/tools/core-screens.mcp-tools.js +2 -11
- package/dist/mcp/tools/core-screens.mcp-tools.js.map +1 -1
- package/dist/mcp/tools/core-sessions.mcp-tools.d.ts.map +1 -1
- package/dist/mcp/tools/core-sessions.mcp-tools.js +0 -2
- package/dist/mcp/tools/core-sessions.mcp-tools.js.map +1 -1
- package/dist/mcp/tools/core-settings.mcp-tools.d.ts.map +1 -1
- package/dist/mcp/tools/core-settings.mcp-tools.js +2 -10
- package/dist/mcp/tools/core-settings.mcp-tools.js.map +1 -1
- package/dist/mcp/tools/core-users.mcp-tools.js +2 -9
- package/dist/mcp/tools/core-users.mcp-tools.js.map +1 -1
- package/dist/mcp/tools/core-webhooks.mcp-tools.d.ts.map +1 -1
- package/dist/mcp/tools/core-webhooks.mcp-tools.js +2 -10
- package/dist/mcp/tools/core-webhooks.mcp-tools.js.map +1 -1
- package/dist/mcp/types/mcp-context.type.d.ts +9 -0
- package/dist/mcp/types/mcp-context.type.d.ts.map +1 -1
- package/dist/mcp-chat/mcp-chat.service.d.ts.map +1 -1
- package/dist/mcp-chat/mcp-chat.service.js +8 -0
- package/dist/mcp-chat/mcp-chat.service.js.map +1 -1
- package/dist/meeting/meeting-provider.registry.d.ts +115 -0
- package/dist/meeting/meeting-provider.registry.d.ts.map +1 -1
- package/dist/meeting/meeting-provider.registry.js.map +1 -1
- package/dist/meeting/meeting.constants.d.ts +70 -0
- package/dist/meeting/meeting.constants.d.ts.map +1 -1
- package/dist/meeting/meeting.constants.js +9 -1
- package/dist/meeting/meeting.constants.js.map +1 -1
- package/dist/menu/menu.service.d.ts.map +1 -1
- package/dist/menu/menu.service.js +29 -9
- package/dist/menu/menu.service.js.map +1 -1
- package/dist/message-template/dto/update-message-template.dto.d.ts +18 -0
- package/dist/message-template/dto/update-message-template.dto.d.ts.map +1 -0
- package/dist/message-template/dto/update-message-template.dto.js +38 -0
- package/dist/message-template/dto/update-message-template.dto.js.map +1 -0
- package/dist/message-template/message-template-admin.service.d.ts +70 -0
- package/dist/message-template/message-template-admin.service.d.ts.map +1 -0
- package/dist/message-template/message-template-admin.service.js +226 -0
- package/dist/message-template/message-template-admin.service.js.map +1 -0
- package/dist/message-template/message-template.controller.d.ts +29 -0
- package/dist/message-template/message-template.controller.d.ts.map +1 -0
- package/dist/message-template/message-template.controller.js +101 -0
- package/dist/message-template/message-template.controller.js.map +1 -0
- package/dist/message-template/message-template.module.d.ts +10 -0
- package/dist/message-template/message-template.module.d.ts.map +1 -0
- package/dist/message-template/message-template.module.js +33 -0
- package/dist/message-template/message-template.module.js.map +1 -0
- package/dist/message-template/message-template.registry.d.ts +55 -0
- package/dist/message-template/message-template.registry.d.ts.map +1 -0
- package/dist/message-template/message-template.registry.js +64 -0
- package/dist/message-template/message-template.registry.js.map +1 -0
- package/dist/message-template/message-template.service.d.ts +59 -0
- package/dist/message-template/message-template.service.d.ts.map +1 -0
- package/dist/message-template/message-template.service.js +166 -0
- package/dist/message-template/message-template.service.js.map +1 -0
- package/dist/notification/notification.constants.d.ts +11 -0
- package/dist/notification/notification.constants.d.ts.map +1 -0
- package/dist/notification/notification.constants.js +14 -0
- package/dist/notification/notification.constants.js.map +1 -0
- package/dist/notification/notification.controller.d.ts +20 -20
- package/dist/notification/notification.module.d.ts.map +1 -1
- package/dist/notification/notification.module.js +3 -0
- package/dist/notification/notification.module.js.map +1 -1
- package/dist/notification/notification.service.d.ts +33 -21
- package/dist/notification/notification.service.d.ts.map +1 -1
- package/dist/notification/notification.service.js +36 -2
- package/dist/notification/notification.service.js.map +1 -1
- package/dist/oauth/oauth.controller.d.ts +4 -6
- package/dist/oauth/oauth.controller.d.ts.map +1 -1
- package/dist/oauth/oauth.controller.js +0 -1
- package/dist/oauth/oauth.controller.js.map +1 -1
- package/dist/oauth/oauth.errors.d.ts +15 -1
- package/dist/oauth/oauth.errors.d.ts.map +1 -1
- package/dist/oauth/oauth.errors.js +9 -1
- package/dist/oauth/oauth.errors.js.map +1 -1
- package/dist/oauth/oauth.module.d.ts.map +1 -1
- package/dist/oauth/oauth.module.js +6 -1
- package/dist/oauth/oauth.module.js.map +1 -1
- package/dist/oauth/oauth.service.d.ts +25 -5
- package/dist/oauth/oauth.service.d.ts.map +1 -1
- package/dist/oauth/oauth.service.js +63 -27
- package/dist/oauth/oauth.service.js.map +1 -1
- package/dist/oauth/providers/abstract.provider.d.ts +10 -0
- package/dist/oauth/providers/abstract.provider.d.ts.map +1 -1
- package/dist/oauth/providers/abstract.provider.js +39 -12
- package/dist/oauth/providers/abstract.provider.js.map +1 -1
- package/dist/oauth/providers/github.provider.d.ts +1 -1
- package/dist/oauth/providers/github.provider.d.ts.map +1 -1
- package/dist/oauth/providers/github.provider.js +48 -22
- package/dist/oauth/providers/github.provider.js.map +1 -1
- package/dist/oauth/providers/microsoft-entra-id.provider.d.ts.map +1 -1
- package/dist/oauth/providers/microsoft-entra-id.provider.js +6 -0
- package/dist/oauth/providers/microsoft-entra-id.provider.js.map +1 -1
- package/dist/observability/monitored-cron.d.ts +29 -12
- package/dist/observability/monitored-cron.d.ts.map +1 -1
- package/dist/observability/monitored-cron.js +131 -46
- package/dist/observability/monitored-cron.js.map +1 -1
- package/dist/pairing/pairing.controller.d.ts +9 -9
- package/dist/pairing/pairing.service.d.ts +15 -11
- package/dist/pairing/pairing.service.d.ts.map +1 -1
- package/dist/profile/dto/change-password.dto.d.ts.map +1 -1
- package/dist/profile/dto/change-password.dto.js +4 -6
- package/dist/profile/dto/change-password.dto.js.map +1 -1
- package/dist/profile/profile.controller.d.ts +1 -1
- package/dist/profile/profile.service.d.ts +1 -1
- package/dist/profile/profile.service.d.ts.map +1 -1
- package/dist/profile/profile.service.js +9 -3
- package/dist/profile/profile.service.js.map +1 -1
- package/dist/realtime/realtime-tick.coalescer.d.ts +34 -0
- package/dist/realtime/realtime-tick.coalescer.d.ts.map +1 -0
- package/dist/realtime/realtime-tick.coalescer.js +60 -0
- package/dist/realtime/realtime-tick.coalescer.js.map +1 -0
- package/dist/realtime/realtime.service.d.ts +2 -0
- package/dist/realtime/realtime.service.d.ts.map +1 -1
- package/dist/realtime/realtime.service.js +22 -2
- package/dist/realtime/realtime.service.js.map +1 -1
- package/dist/redis/redis-kv.service.d.ts +90 -0
- package/dist/redis/redis-kv.service.d.ts.map +1 -0
- package/dist/redis/redis-kv.service.js +247 -0
- package/dist/redis/redis-kv.service.js.map +1 -0
- package/dist/redis/redis-master.d.ts +29 -0
- package/dist/redis/redis-master.d.ts.map +1 -0
- package/dist/redis/redis-master.js +81 -0
- package/dist/redis/redis-master.js.map +1 -0
- package/dist/redis/redis-pubsub.d.ts +12 -0
- package/dist/redis/redis-pubsub.d.ts.map +1 -1
- package/dist/redis/redis-pubsub.js +25 -2
- package/dist/redis/redis-pubsub.js.map +1 -1
- package/dist/redis/redis.module.d.ts +11 -0
- package/dist/redis/redis.module.d.ts.map +1 -0
- package/dist/redis/redis.module.js +30 -0
- package/dist/redis/redis.module.js.map +1 -0
- package/dist/session/session.controller.d.ts +6 -2
- package/dist/session/session.controller.d.ts.map +1 -1
- package/dist/session/session.service.d.ts +118 -15
- package/dist/session/session.service.d.ts.map +1 -1
- package/dist/session/session.service.js +251 -77
- package/dist/session/session.service.js.map +1 -1
- package/dist/setting/setting.controller.d.ts +5 -0
- package/dist/setting/setting.controller.d.ts.map +1 -1
- package/dist/setting/setting.service.d.ts +7 -0
- package/dist/setting/setting.service.d.ts.map +1 -1
- package/dist/setting/setting.service.js +38 -3
- package/dist/setting/setting.service.js.map +1 -1
- package/dist/task/task.service.d.ts +17 -0
- package/dist/task/task.service.d.ts.map +1 -1
- package/dist/task/task.service.js +48 -13
- package/dist/task/task.service.js.map +1 -1
- package/dist/token/token.service.d.ts +19 -1
- package/dist/token/token.service.d.ts.map +1 -1
- package/dist/token/token.service.js +39 -2
- package/dist/token/token.service.js.map +1 -1
- package/dist/user/user-credential.util.d.ts +10 -0
- package/dist/user/user-credential.util.d.ts.map +1 -1
- package/dist/user/user-credential.util.js +14 -1
- package/dist/user/user-credential.util.js.map +1 -1
- package/dist/user/user.service.d.ts +12 -4
- package/dist/user/user.service.d.ts.map +1 -1
- package/dist/user/user.service.js +2 -11
- package/dist/user/user.service.js.map +1 -1
- package/dist/user/user.sort.d.ts +16 -0
- package/dist/user/user.sort.d.ts.map +1 -0
- package/dist/user/user.sort.js +25 -0
- package/dist/user/user.sort.js.map +1 -0
- package/dist/utils/abbreviate-name.d.ts +13 -0
- package/dist/utils/abbreviate-name.d.ts.map +1 -0
- package/dist/utils/abbreviate-name.js +42 -0
- package/dist/utils/abbreviate-name.js.map +1 -0
- package/dist/utils/date-range-query.dto.d.ts +11 -0
- package/dist/utils/date-range-query.dto.d.ts.map +1 -0
- package/dist/utils/date-range-query.dto.js +63 -0
- package/dist/utils/date-range-query.dto.js.map +1 -0
- package/dist/utils/date-range.d.ts +96 -0
- package/dist/utils/date-range.d.ts.map +1 -0
- package/dist/utils/date-range.js +172 -0
- package/dist/utils/date-range.js.map +1 -0
- package/dist/webhook-integration/webhook-utils.d.ts.map +1 -1
- package/dist/webhook-integration/webhook-utils.js +24 -0
- package/dist/webhook-integration/webhook-utils.js.map +1 -1
- package/dist/whatsapp-sender/whatsapp-recipients.d.ts +49 -0
- package/dist/whatsapp-sender/whatsapp-recipients.d.ts.map +1 -0
- package/dist/whatsapp-sender/whatsapp-recipients.js +66 -0
- package/dist/whatsapp-sender/whatsapp-recipients.js.map +1 -0
- package/dist/whatsapp-sender/whatsapp-sender.service.d.ts +25 -0
- package/dist/whatsapp-sender/whatsapp-sender.service.d.ts.map +1 -1
- package/dist/whatsapp-sender/whatsapp-sender.service.js +46 -5
- package/dist/whatsapp-sender/whatsapp-sender.service.js.map +1 -1
- package/hedhog/data/integration_provider.yaml +9 -0
- package/hedhog/data/integration_type.yaml +6 -0
- package/hedhog/data/locale.yaml +0 -1
- package/hedhog/data/mail.yaml +2 -2
- package/hedhog/data/mail_layout.yaml +6 -3
- package/hedhog/data/menu.yaml +25 -5
- package/hedhog/data/route.yaml +140 -0
- package/hedhog/data/setting_group.yaml +137 -3
- package/hedhog/frontend/app/access-log/page.tsx.ejs +47 -53
- package/hedhog/frontend/app/account/components/active-sessions.tsx.ejs +33 -8
- package/hedhog/frontend/app/account/components/mcp-tokens.tsx.ejs +54 -13
- package/hedhog/frontend/app/account/components/mfa-method-card.tsx.ejs +7 -1
- package/hedhog/frontend/app/account/components/recovery-codes-dialog.tsx.ejs +1 -0
- package/hedhog/frontend/app/account/components/tokens.tsx.ejs +47 -17
- package/hedhog/frontend/app/ai_agent/page.tsx.ejs +46 -5
- package/hedhog/frontend/app/ai_instruction/_components/ai-instruction-form.tsx.ejs +101 -30
- package/hedhog/frontend/app/ai_instruction/_components/ai-instruction-versions.tsx.ejs +24 -8
- package/hedhog/frontend/app/ai_instruction/page.tsx.ejs +80 -15
- package/hedhog/frontend/app/configurations/[slug]/components/image-optimization-action.tsx.ejs +166 -0
- package/hedhog/frontend/app/configurations/[slug]/components/setting-field.test.tsx.ejs +145 -45
- package/hedhog/frontend/app/configurations/[slug]/components/setting-field.tsx.ejs +99 -219
- package/hedhog/frontend/app/configurations/[slug]/page.tsx.ejs +19 -1
- package/hedhog/frontend/app/configurations/layout.tsx.ejs +19 -5
- package/hedhog/frontend/app/dashboard/[slug]/widget-renderer.tsx.ejs +2 -8
- package/hedhog/frontend/app/dashboard/components/dynamic-widget.tsx.ejs +3 -0
- package/hedhog/frontend/app/dashboard/components/widget-wrapper.tsx.ejs +4 -0
- package/hedhog/frontend/app/dashboard/dashboard-home-tabs.tsx.ejs +43 -44
- package/hedhog/frontend/app/dashboard/management/tabs/component-roles-tab.tsx.ejs +41 -3
- package/hedhog/frontend/app/dashboard/management/tabs/components-tab.tsx.ejs +42 -2
- package/hedhog/frontend/app/dashboard/management/tabs/dashboard-roles-tab.tsx.ejs +41 -3
- package/hedhog/frontend/app/dashboard/management/tabs/dashboards-tab.tsx.ejs +39 -4
- package/hedhog/frontend/app/dashboard/management/tabs/items-tab.tsx.ejs +42 -3
- package/hedhog/frontend/app/incidents/page.tsx.ejs +60 -31
- package/hedhog/frontend/app/integration/profiles/page.tsx.ejs +45 -5
- package/hedhog/frontend/app/integrations-webhooks/page.tsx.ejs +92 -15
- package/hedhog/frontend/app/mail/log/page.tsx.ejs +109 -61
- package/hedhog/frontend/app/mail/template/page.tsx.ejs +125 -23
- package/hedhog/frontend/app/mcp_chat/chat-components.tsx.ejs +13 -15
- package/hedhog/frontend/app/mcp_chat/page.tsx.ejs +116 -110
- package/hedhog/frontend/app/message-templates/_components/message-template-sheet.tsx.ejs +245 -0
- package/hedhog/frontend/app/message-templates/_lib/types.ts.ejs +24 -0
- package/hedhog/frontend/app/message-templates/page.tsx.ejs +182 -0
- package/hedhog/frontend/app/pages/_components/page-wizard-sheet.tsx.ejs +1 -0
- package/hedhog/frontend/app/pages/page.tsx.ejs +94 -9
- package/hedhog/frontend/app/roles/menus.tsx.ejs +4 -4
- package/hedhog/frontend/app/roles/routes.tsx.ejs +4 -4
- package/hedhog/frontend/app/roles/users.tsx.ejs +4 -4
- package/hedhog/frontend/app/setting-list/page.tsx.ejs +71 -9
- package/hedhog/frontend/app/users/page.tsx.ejs +77 -67
- package/hedhog/frontend/messages/en.json +183 -36
- package/hedhog/frontend/messages/pt.json +183 -36
- package/hedhog/table/cron_lock.yaml +17 -0
- package/hedhog/table/file.yaml +13 -1
- package/hedhog/table/file_upload_chunk.yaml +23 -0
- package/hedhog/table/file_upload_ticket.yaml +67 -0
- package/hedhog/table/mcp_tool_call_log.yaml +30 -22
- package/hedhog/table/message_template.yaml +33 -0
- package/hedhog/table/setting.yaml +8 -0
- package/hedhog/table/user_session.yaml +36 -1
- package/package.json +8 -6
- package/src/ai/ai-agent.sort.ts +21 -0
- package/src/ai/ai.service.spec.ts +173 -1
- package/src/ai/ai.service.ts +64 -193
- package/src/ai-instruction/ai-instruction.service.ts +32 -28
- package/src/ai-instruction/ai-instruction.sort.ts +32 -0
- package/src/auth/auth.module.ts +8 -1
- package/src/auth/auth.service.spec.ts +108 -1
- package/src/auth/auth.service.ts +59 -5
- package/src/auth/guards/auth.guard.ts +9 -1
- package/src/authorize/authorize.controller.ts +126 -11
- package/src/authorize/authorize.errors.ts +55 -0
- package/src/authorize/authorize.module.ts +6 -1
- package/src/authorize/authorize.service.spec.ts +379 -7
- package/src/authorize/authorize.service.ts +309 -23
- package/src/authorize/dto/authorize-info.dto.ts +21 -3
- package/src/authorize/dto/consent.dto.ts +21 -3
- package/src/authorize/dto/token.dto.ts +24 -2
- package/src/authorize/oauth-exception.filter.ts +58 -0
- package/src/authorize/oauth-metadata.service.ts +67 -0
- package/src/authorize/well-known.controller.spec.ts +84 -0
- package/src/authorize/well-known.controller.ts +96 -0
- package/src/captcha/captcha.service.spec.ts +211 -4
- package/src/captcha/captcha.service.ts +127 -10
- package/src/core.module.ts +6 -0
- package/src/dashboard/dashboard-component-role/dashboard-component-role.service.ts +2 -3
- package/src/dashboard/dashboard-component-role/dashboard-component-role.sort.ts +18 -0
- package/src/dashboard/dashboard-item/dashboard-item.service.ts +2 -3
- package/src/dashboard/dashboard-item/dashboard-item.sort.ts +19 -0
- package/src/dashboard/dashboard-role/dashboard-role.service.ts +2 -3
- package/src/dashboard/dashboard-role/dashboard-role.sort.ts +16 -0
- package/src/file/file-upload-ticket.service.spec.ts +422 -0
- package/src/file/file-upload-ticket.service.ts +513 -0
- package/src/file/file.controller.ts +65 -0
- package/src/file/file.module.ts +14 -2
- package/src/file/file.service.spec.ts +94 -0
- package/src/file/file.service.ts +432 -30
- package/src/file/filename-encoding.util.spec.ts +54 -0
- package/src/file/filename-encoding.util.ts +67 -0
- package/src/file/image-optimization.service.spec.ts +156 -19
- package/src/file/image-optimization.service.ts +106 -21
- package/src/file/mcp-file-source.schema.ts +83 -0
- package/src/file/mcp-file-source.service.spec.ts +473 -0
- package/src/file/mcp-file-source.service.ts +445 -0
- package/src/file/mimetype-sniff.util.spec.ts +126 -0
- package/src/file/mimetype-sniff.util.ts +265 -0
- package/src/file/remote-fetch.util.spec.ts +117 -0
- package/src/file/remote-fetch.util.ts +330 -0
- package/src/impersonation/dto/start-impersonation.dto.ts +5 -2
- package/src/impersonation/impersonation.service.spec.ts +24 -1
- package/src/impersonation/impersonation.service.ts +14 -4
- package/src/incident/incident.controller.ts +9 -1
- package/src/incident/incident.service.ts +7 -0
- package/src/index.ts +17 -0
- package/src/integration-profile/integration-profile.secrets.ts +7 -0
- package/src/integration-profile/integration-profile.service.ts +7 -64
- package/src/integration-profile/integration-profile.utils.spec.ts +9 -0
- package/src/integration-profile/integration-profile.utils.ts +5 -5
- package/src/integration-profile/testers/index.ts +2 -0
- package/src/integration-profile/testers/remaining.testers.spec.ts +79 -0
- package/src/integration-profile/testers/shipping.testers.ts +94 -0
- package/src/mail/dto/send.dto.ts +6 -1
- package/src/mail/mail-template.spec.ts +58 -1
- package/src/mail/mail.service.spec.ts +112 -0
- package/src/mail/mail.service.ts +42 -4
- package/src/mail-sent/mail-sent.service.ts +3 -0
- package/src/mail-sent/mail-sent.sort.ts +19 -0
- package/src/mcp/filters/mcp-challenge.filter.spec.ts +76 -0
- package/src/mcp/filters/mcp-challenge.filter.ts +70 -0
- package/src/mcp/guards/mcp-auth.guard.spec.ts +51 -2
- package/src/mcp/guards/mcp-auth.guard.ts +24 -1
- package/src/mcp/guards/mcp-permission.guard.spec.ts +109 -15
- package/src/mcp/guards/mcp-permission.guard.ts +76 -51
- package/src/mcp/mcp-audit.service.spec.ts +107 -0
- package/src/mcp/mcp-audit.service.ts +37 -1
- package/src/mcp/mcp-permission.service.spec.ts +197 -0
- package/src/mcp/mcp-permission.service.ts +184 -0
- package/src/mcp/mcp-server.service.spec.ts +84 -2
- package/src/mcp/mcp-server.service.ts +111 -87
- package/src/mcp/mcp.controller.ts +8 -1
- package/src/mcp/mcp.module.ts +5 -1
- package/src/mcp/tools/core-ai.mcp-tools.ts +1 -1
- package/src/mcp/tools/core-dashboard-items.mcp-tools.ts +1 -1
- package/src/mcp/tools/core-dashboard.mcp-tools.ts +1 -1
- package/src/mcp/tools/core-event-webhooks.mcp-tools.ts +1 -2
- package/src/mcp/tools/core-files.mcp-tools.ts +202 -22
- package/src/mcp/tools/core-integration-events.mcp-tools.ts +1 -1
- package/src/mcp/tools/core-mail-sent.mcp-tools.ts +1 -1
- package/src/mcp/tools/core-mail.mcp-tools.ts +1 -1
- package/src/mcp/tools/core-menus.mcp-tools.ts +1 -2
- package/src/mcp/tools/core-notifications.mcp-tools.ts +0 -1
- package/src/mcp/tools/core-roles.mcp-tools.ts +1 -5
- package/src/mcp/tools/core-routes.mcp-tools.ts +1 -3
- package/src/mcp/tools/core-screens.mcp-tools.ts +1 -3
- package/src/mcp/tools/core-sessions.mcp-tools.ts +0 -2
- package/src/mcp/tools/core-settings.mcp-tools.ts +1 -2
- package/src/mcp/tools/core-users.mcp-tools.ts +1 -1
- package/src/mcp/tools/core-webhooks.mcp-tools.ts +1 -2
- package/src/mcp/types/mcp-context.type.ts +15 -6
- package/src/mcp-chat/mcp-chat.service.ts +8 -0
- package/src/meeting/meeting-provider.registry.ts +121 -0
- package/src/meeting/meeting.constants.ts +74 -0
- package/src/menu/menu.service.spec.ts +89 -0
- package/src/menu/menu.service.ts +29 -11
- package/src/message-template/dto/update-message-template.dto.ts +22 -0
- package/src/message-template/message-template-admin.service.spec.ts +163 -0
- package/src/message-template/message-template-admin.service.ts +239 -0
- package/src/message-template/message-template.controller.ts +52 -0
- package/src/message-template/message-template.module.ts +21 -0
- package/src/message-template/message-template.registry.spec.ts +62 -0
- package/src/message-template/message-template.registry.ts +125 -0
- package/src/message-template/message-template.service.spec.ts +149 -0
- package/src/message-template/message-template.service.ts +149 -0
- package/src/notification/notification.constants.ts +10 -0
- package/src/notification/notification.module.ts +3 -0
- package/src/notification/notification.service.spec.ts +75 -1
- package/src/notification/notification.service.ts +39 -1
- package/src/oauth/oauth.controller.ts +0 -1
- package/src/oauth/oauth.errors.ts +7 -0
- package/src/oauth/oauth.module.ts +6 -1
- package/src/oauth/oauth.service.spec.ts +58 -7
- package/src/oauth/oauth.service.ts +71 -32
- package/src/oauth/providers/abstract.provider.spec.ts +192 -0
- package/src/oauth/providers/abstract.provider.ts +46 -14
- package/src/oauth/providers/github.provider.ts +57 -34
- package/src/oauth/providers/microsoft-entra-id.provider.ts +8 -1
- package/src/observability/monitored-cron.spec.ts +164 -31
- package/src/observability/monitored-cron.ts +154 -62
- package/src/profile/dto/change-password.dto.ts +25 -7
- package/src/profile/profile.service.spec.ts +97 -0
- package/src/profile/profile.service.ts +9 -3
- package/src/realtime/realtime-tick.coalescer.spec.ts +92 -0
- package/src/realtime/realtime-tick.coalescer.ts +60 -0
- package/src/realtime/realtime.service.spec.ts +33 -0
- package/src/realtime/realtime.service.ts +28 -2
- package/src/redis/redis-kv.service.ts +261 -0
- package/src/redis/redis-master.spec.ts +111 -0
- package/src/redis/redis-master.ts +86 -0
- package/src/redis/redis-pubsub.ts +27 -3
- package/src/redis/redis.module.ts +17 -0
- package/src/session/session.service.spec.ts +121 -42
- package/src/session/session.service.ts +279 -82
- package/src/setting/setting.service.ts +44 -3
- package/src/task/task.service.spec.ts +41 -0
- package/src/task/task.service.ts +53 -13
- package/src/token/token.service.spec.ts +90 -0
- package/src/token/token.service.ts +48 -2
- package/src/user/user-credential.util.ts +14 -5
- package/src/user/user.service.ts +2 -12
- package/src/user/user.sort.ts +25 -0
- package/src/utils/abbreviate-name.spec.ts +50 -0
- package/src/utils/abbreviate-name.ts +44 -0
- package/src/utils/date-range-query.dto.ts +56 -0
- package/src/utils/date-range.spec.ts +175 -0
- package/src/utils/date-range.ts +246 -0
- package/src/webhook-integration/webhook-utils.spec.ts +67 -0
- package/src/webhook-integration/webhook-utils.ts +26 -0
- package/src/whatsapp-sender/whatsapp-recipients.spec.ts +89 -0
- package/src/whatsapp-sender/whatsapp-recipients.ts +83 -0
- package/src/whatsapp-sender/whatsapp-sender.service.spec.ts +112 -0
- package/src/whatsapp-sender/whatsapp-sender.service.ts +58 -5
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
import { PrismaService } from '@hed-hog/api-prisma';
|
|
2
|
+
import {
|
|
3
|
+
BadRequestException,
|
|
4
|
+
forwardRef,
|
|
5
|
+
Inject,
|
|
6
|
+
Injectable,
|
|
7
|
+
Logger,
|
|
8
|
+
} from '@nestjs/common';
|
|
9
|
+
import { createHash } from 'crypto';
|
|
10
|
+
import { SettingService } from '../setting/setting.service';
|
|
11
|
+
import { FileUploadTicketService } from './file-upload-ticket.service';
|
|
12
|
+
import { FileService } from './file.service';
|
|
13
|
+
import {
|
|
14
|
+
FILE_SOURCE_FIELDS,
|
|
15
|
+
FileSourceModality,
|
|
16
|
+
} from './mcp-file-source.schema';
|
|
17
|
+
import { findMimetypeConflict, MIMETYPE_SNIFF_BYTES } from './mimetype-sniff.util';
|
|
18
|
+
import { fetchRemoteFile } from './remote-fetch.util';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Normaliza as quatro origens de arquivo que uma tool MCP pode receber.
|
|
22
|
+
*
|
|
23
|
+
* Existe para que validação, sniffing de mimetype, auditoria e idempotência morem num
|
|
24
|
+
* ponto só. A alternativa — cada tool tratando as quatro origens por conta — garantiria
|
|
25
|
+
* que mais cedo ou mais tarde um caminho novo escapasse do `storage-accept-mimetype` ou
|
|
26
|
+
* da checagem de dono, e ninguém perceberia até virar incidente.
|
|
27
|
+
*
|
|
28
|
+
* Duas portas de saída, porque as tools consomem o arquivo de formas diferentes:
|
|
29
|
+
*
|
|
30
|
+
* - `resolveFileId` para quem persiste o anexo e só precisa do id;
|
|
31
|
+
* - `resolveMulterFile` para quem quer os bytes e não guarda nada (importar extrato,
|
|
32
|
+
* extrair dados de uma nota com IA).
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
export interface FileSourceArgs {
|
|
36
|
+
fileId?: number;
|
|
37
|
+
uploadId?: number;
|
|
38
|
+
fileUrl?: string;
|
|
39
|
+
fileBase64?: string;
|
|
40
|
+
fileName?: string;
|
|
41
|
+
mimeType?: string;
|
|
42
|
+
sha256?: string;
|
|
43
|
+
[key: string]: any;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface FileSourceContext {
|
|
47
|
+
userId: number;
|
|
48
|
+
toolName?: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface ResolveOptions {
|
|
52
|
+
/** Pasta no storage para as origens que ainda não têm arquivo gravado. */
|
|
53
|
+
destination: string;
|
|
54
|
+
isPrivate?: boolean;
|
|
55
|
+
/** `false` deixa a tool seguir sem arquivo (o extract-from-file aceita isso). */
|
|
56
|
+
required?: boolean;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface ResolvedFileSource {
|
|
60
|
+
fileId: number;
|
|
61
|
+
modality: FileSourceModality;
|
|
62
|
+
filename: string;
|
|
63
|
+
mimetype: string;
|
|
64
|
+
size: number;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface ResolvedFileContent {
|
|
68
|
+
file: MulterFile;
|
|
69
|
+
modality: FileSourceModality;
|
|
70
|
+
/** Preenchido quando a origem já era um arquivo armazenado. */
|
|
71
|
+
fileId?: number;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@Injectable()
|
|
75
|
+
export class McpFileSourceService {
|
|
76
|
+
private readonly logger = new Logger(McpFileSourceService.name);
|
|
77
|
+
|
|
78
|
+
constructor(
|
|
79
|
+
private readonly prismaService: PrismaService,
|
|
80
|
+
@Inject(forwardRef(() => FileService))
|
|
81
|
+
private readonly fileService: FileService,
|
|
82
|
+
@Inject(forwardRef(() => FileUploadTicketService))
|
|
83
|
+
private readonly uploadTickets: FileUploadTicketService,
|
|
84
|
+
@Inject(forwardRef(() => SettingService))
|
|
85
|
+
private readonly settingService: SettingService,
|
|
86
|
+
) {}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Qual origem veio, exigindo exatamente uma.
|
|
90
|
+
*
|
|
91
|
+
* Aceitar duas e escolher a "melhor" seria pior do que recusar: a chamada teria dois
|
|
92
|
+
* arquivos possíveis e o resultado dependeria de uma precedência que ninguém leu.
|
|
93
|
+
*/
|
|
94
|
+
detectModality(args: FileSourceArgs, required = true): FileSourceModality | null {
|
|
95
|
+
const present = FILE_SOURCE_FIELDS.filter((field) => {
|
|
96
|
+
const value = args?.[field];
|
|
97
|
+
return value !== undefined && value !== null && value !== '';
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
if (present.length > 1) {
|
|
101
|
+
throw new BadRequestException(
|
|
102
|
+
`Provide exactly one file source, got ${present.length}: ${present.join(', ')}`,
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (present.length === 0) {
|
|
107
|
+
if (required) {
|
|
108
|
+
throw new BadRequestException(
|
|
109
|
+
`A file source is required: one of ${FILE_SOURCE_FIELDS.join(', ')}`,
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return present[0];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
private async maxBytes(): Promise<number> {
|
|
120
|
+
const settings = await this.settingService.getSettingValues(['storage-max-size']);
|
|
121
|
+
return Number(settings['storage-max-size']) || 10485760;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
private async allowedUrlHosts(): Promise<string[]> {
|
|
125
|
+
const settings = await this.settingService.getSettingValues([
|
|
126
|
+
'mcp-file-url-allowed-hosts',
|
|
127
|
+
]);
|
|
128
|
+
const raw = settings['mcp-file-url-allowed-hosts'];
|
|
129
|
+
|
|
130
|
+
return String(raw ?? '')
|
|
131
|
+
.split(',')
|
|
132
|
+
.map((host) => host.trim())
|
|
133
|
+
.filter(Boolean);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Valida um buffer que ainda não está no storage: tamanho, tipo declarado, tipo real e
|
|
138
|
+
* sha256 quando informado.
|
|
139
|
+
*
|
|
140
|
+
* `acceptMimetypes` sozinho não basta — ele compara a string que o cliente mandou com a
|
|
141
|
+
* allowlist, então um executável declarado como `application/pdf` passaria. O sniff é o
|
|
142
|
+
* contraditório dessa declaração.
|
|
143
|
+
*/
|
|
144
|
+
private async assertBufferAcceptable(
|
|
145
|
+
buffer: Buffer,
|
|
146
|
+
mimetype: string,
|
|
147
|
+
expectedSha256?: string,
|
|
148
|
+
) {
|
|
149
|
+
const maxBytes = await this.maxBytes();
|
|
150
|
+
|
|
151
|
+
if (buffer.length === 0) {
|
|
152
|
+
throw new BadRequestException(`File content is empty`);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (buffer.length > maxBytes) {
|
|
156
|
+
throw new BadRequestException(
|
|
157
|
+
`File too large: ${buffer.length} bytes. The storage-max-size setting allows ${maxBytes}.`,
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (!(await this.fileService.acceptMimetypes(mimetype))) {
|
|
162
|
+
throw new BadRequestException(`Invalid file type: ${mimetype}`);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const conflict = findMimetypeConflict(mimetype, buffer);
|
|
166
|
+
|
|
167
|
+
if (conflict) {
|
|
168
|
+
throw new BadRequestException(
|
|
169
|
+
`Declared mimeType ${mimetype} but the content is ${conflict}`,
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (expectedSha256) {
|
|
174
|
+
const actual = createHash('sha256').update(buffer).digest('hex');
|
|
175
|
+
|
|
176
|
+
if (actual.toLowerCase() !== expectedSha256.toLowerCase()) {
|
|
177
|
+
throw new BadRequestException(
|
|
178
|
+
`sha256 mismatch: declared ${expectedSha256}, content hashes to ${actual}`,
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
private toMulterFile(
|
|
185
|
+
buffer: Buffer,
|
|
186
|
+
filename: string,
|
|
187
|
+
mimetype: string,
|
|
188
|
+
): MulterFile {
|
|
189
|
+
return {
|
|
190
|
+
fieldname: 'file',
|
|
191
|
+
originalname: filename,
|
|
192
|
+
encoding: '7bit',
|
|
193
|
+
mimetype,
|
|
194
|
+
size: buffer.length,
|
|
195
|
+
destination: '',
|
|
196
|
+
filename,
|
|
197
|
+
path: '',
|
|
198
|
+
buffer,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
private decodeBase64(args: FileSourceArgs): { buffer: Buffer; filename: string; mimetype: string } {
|
|
203
|
+
if (!args.fileName || !args.mimeType) {
|
|
204
|
+
throw new BadRequestException(
|
|
205
|
+
`fileBase64 requires fileName and mimeType`,
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const buffer = Buffer.from(String(args.fileBase64), 'base64');
|
|
210
|
+
|
|
211
|
+
// `Buffer.from(x, 'base64')` nunca reclama: entrada inválida vira bytes truncados em
|
|
212
|
+
// silêncio. Reencodar e comparar é o que separa um base64 verdadeiro de um texto
|
|
213
|
+
// qualquer que o modelo tenha emitido no lugar.
|
|
214
|
+
if (buffer.length === 0) {
|
|
215
|
+
throw new BadRequestException(`fileBase64 decoded to zero bytes`);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const normalized = String(args.fileBase64).replace(/\s/g, '');
|
|
219
|
+
|
|
220
|
+
if (buffer.toString('base64').replace(/=+$/, '') !== normalized.replace(/=+$/, '')) {
|
|
221
|
+
throw new BadRequestException(
|
|
222
|
+
`fileBase64 is not valid base64 (it may have been truncated in transit)`,
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return { buffer, filename: args.fileName, mimetype: args.mimeType };
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
private async fetchFromUrl(
|
|
230
|
+
args: FileSourceArgs,
|
|
231
|
+
): Promise<{ buffer: Buffer; filename: string; mimetype: string; host: string }> {
|
|
232
|
+
const result = await fetchRemoteFile(String(args.fileUrl), {
|
|
233
|
+
maxBytes: await this.maxBytes(),
|
|
234
|
+
allowedHosts: await this.allowedUrlHosts(),
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
// Nome e tipo declarados ganham do que o servidor remoto disse: quem chama sabe o que
|
|
238
|
+
// pediu, e o `Content-Type` de um link de compartilhamento costuma vir genérico. O
|
|
239
|
+
// conteúdo real ainda é conferido depois, contra o que tiver sobrado aqui.
|
|
240
|
+
const fallbackName =
|
|
241
|
+
decodeURIComponent(new URL(result.finalUrl).pathname.split('/').pop() || '') ||
|
|
242
|
+
'download';
|
|
243
|
+
|
|
244
|
+
return {
|
|
245
|
+
buffer: result.buffer,
|
|
246
|
+
filename: args.fileName || fallbackName,
|
|
247
|
+
mimetype: args.mimeType || result.contentType || 'application/octet-stream',
|
|
248
|
+
host: result.finalHost,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Normaliza qualquer origem para um `fileId`.
|
|
254
|
+
*
|
|
255
|
+
* `fileId` e `uploadId` não regravam nada — o arquivo já está lá. `fileUrl` e
|
|
256
|
+
* `fileBase64` gravam, com o dono registrado, e é por isso que o `fileId` devolvido
|
|
257
|
+
* pode ser reaproveitado numa chamada seguinte sem novo upload.
|
|
258
|
+
*/
|
|
259
|
+
// Sobrecargas para que o `| null` só apareça para quem pediu `required: false`. Sem
|
|
260
|
+
// isso todo chamador carregaria uma checagem de nulo que nunca acontece — e como o
|
|
261
|
+
// projeto não usa `strictNullChecks`, quem esquecesse a checagem não seria avisado.
|
|
262
|
+
async resolveFileId(
|
|
263
|
+
args: FileSourceArgs,
|
|
264
|
+
context: FileSourceContext,
|
|
265
|
+
options: ResolveOptions & { required?: true },
|
|
266
|
+
): Promise<ResolvedFileSource>;
|
|
267
|
+
async resolveFileId(
|
|
268
|
+
args: FileSourceArgs,
|
|
269
|
+
context: FileSourceContext,
|
|
270
|
+
options: ResolveOptions & { required: false },
|
|
271
|
+
): Promise<ResolvedFileSource | null>;
|
|
272
|
+
async resolveFileId(
|
|
273
|
+
args: FileSourceArgs,
|
|
274
|
+
context: FileSourceContext,
|
|
275
|
+
options: ResolveOptions,
|
|
276
|
+
): Promise<ResolvedFileSource | null> {
|
|
277
|
+
const modality = this.detectModality(args, options.required !== false);
|
|
278
|
+
|
|
279
|
+
if (!modality) {
|
|
280
|
+
return null;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
let file: any;
|
|
284
|
+
let sourceHost: string | undefined;
|
|
285
|
+
|
|
286
|
+
if (modality === 'fileId') {
|
|
287
|
+
file = await this.fileService.assertFileUsable(Number(args.fileId), context.userId);
|
|
288
|
+
} else if (modality === 'uploadId') {
|
|
289
|
+
file = await this.uploadTickets.complete(Number(args.uploadId), context.userId);
|
|
290
|
+
} else {
|
|
291
|
+
const fetched =
|
|
292
|
+
modality === 'fileUrl'
|
|
293
|
+
? await this.fetchFromUrl(args)
|
|
294
|
+
: this.decodeBase64(args);
|
|
295
|
+
|
|
296
|
+
sourceHost = (fetched as any).host;
|
|
297
|
+
|
|
298
|
+
await this.assertBufferAcceptable(fetched.buffer, fetched.mimetype, args.sha256);
|
|
299
|
+
|
|
300
|
+
file = await this.fileService.upload(
|
|
301
|
+
options.destination,
|
|
302
|
+
this.toMulterFile(fetched.buffer, fetched.filename, fetched.mimetype),
|
|
303
|
+
undefined,
|
|
304
|
+
{
|
|
305
|
+
isPrivate: options.isPrivate ?? false,
|
|
306
|
+
createdByUserId: context.userId,
|
|
307
|
+
},
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
const resolved: ResolvedFileSource = {
|
|
312
|
+
fileId: file.id,
|
|
313
|
+
modality,
|
|
314
|
+
filename: file.filename,
|
|
315
|
+
mimetype: await this.fileService.mimetypeNameById(file.mimetype_id),
|
|
316
|
+
size: file.size ?? 0,
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
await this.recordIngest(resolved, context, sourceHost);
|
|
320
|
+
|
|
321
|
+
return resolved;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Normaliza qualquer origem para os bytes, sem gravar quando não é preciso.
|
|
326
|
+
*
|
|
327
|
+
* `fileId`/`uploadId` leem do storage; `fileUrl`/`fileBase64` ficam em memória — a tool
|
|
328
|
+
* que só quer ler um extrato não deve encher o acervo de arquivos que ninguém mais vai
|
|
329
|
+
* abrir.
|
|
330
|
+
*/
|
|
331
|
+
async resolveMulterFile(
|
|
332
|
+
args: FileSourceArgs,
|
|
333
|
+
context: FileSourceContext,
|
|
334
|
+
options: Omit<ResolveOptions, 'destination'> & { destination?: string; required?: true },
|
|
335
|
+
): Promise<ResolvedFileContent>;
|
|
336
|
+
async resolveMulterFile(
|
|
337
|
+
args: FileSourceArgs,
|
|
338
|
+
context: FileSourceContext,
|
|
339
|
+
options: Omit<ResolveOptions, 'destination'> & { destination?: string; required: false },
|
|
340
|
+
): Promise<ResolvedFileContent | null>;
|
|
341
|
+
async resolveMulterFile(
|
|
342
|
+
args: FileSourceArgs,
|
|
343
|
+
context: FileSourceContext,
|
|
344
|
+
options: Omit<ResolveOptions, 'destination'> & { destination?: string },
|
|
345
|
+
): Promise<ResolvedFileContent | null> {
|
|
346
|
+
const modality = this.detectModality(args, options.required !== false);
|
|
347
|
+
|
|
348
|
+
if (!modality) {
|
|
349
|
+
return null;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
if (modality === 'fileId' || modality === 'uploadId') {
|
|
353
|
+
const stored =
|
|
354
|
+
modality === 'fileId'
|
|
355
|
+
? await this.fileService.assertFileUsable(Number(args.fileId), context.userId)
|
|
356
|
+
: await this.uploadTickets.complete(Number(args.uploadId), context.userId);
|
|
357
|
+
|
|
358
|
+
const buffer = await this.fileService.bufferById(stored.id, await this.maxBytes());
|
|
359
|
+
const mimetype = await this.fileService.mimetypeNameById(stored.mimetype_id);
|
|
360
|
+
|
|
361
|
+
await this.recordIngest(
|
|
362
|
+
{
|
|
363
|
+
fileId: stored.id,
|
|
364
|
+
modality,
|
|
365
|
+
filename: stored.filename,
|
|
366
|
+
mimetype,
|
|
367
|
+
size: buffer.length,
|
|
368
|
+
},
|
|
369
|
+
context,
|
|
370
|
+
);
|
|
371
|
+
|
|
372
|
+
return {
|
|
373
|
+
file: this.toMulterFile(buffer, stored.filename, mimetype),
|
|
374
|
+
modality,
|
|
375
|
+
fileId: stored.id,
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
const fetched =
|
|
380
|
+
modality === 'fileUrl' ? await this.fetchFromUrl(args) : this.decodeBase64(args);
|
|
381
|
+
|
|
382
|
+
await this.assertBufferAcceptable(fetched.buffer, fetched.mimetype, args.sha256);
|
|
383
|
+
|
|
384
|
+
await this.recordIngest(
|
|
385
|
+
{
|
|
386
|
+
fileId: 0,
|
|
387
|
+
modality,
|
|
388
|
+
filename: fetched.filename,
|
|
389
|
+
mimetype: fetched.mimetype,
|
|
390
|
+
size: fetched.buffer.length,
|
|
391
|
+
},
|
|
392
|
+
context,
|
|
393
|
+
(fetched as any).host,
|
|
394
|
+
);
|
|
395
|
+
|
|
396
|
+
return {
|
|
397
|
+
file: this.toMulterFile(fetched.buffer, fetched.filename, fetched.mimetype),
|
|
398
|
+
modality,
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Registra a ingestão em `audit_log`, com a modalidade usada.
|
|
404
|
+
*
|
|
405
|
+
* `audit_log` é tabela global (só o finance escrevia nela até aqui, mas ela não é do
|
|
406
|
+
* finance), e `finance.audit-logs.list` já a lê sem filtrar por library — então a
|
|
407
|
+
* trilha das quatro modalidades fica visível por um caminho que já existe.
|
|
408
|
+
*
|
|
409
|
+
* Nunca derruba a operação: auditoria que falha e leva o anexo junto troca um problema
|
|
410
|
+
* de observabilidade por um de funcionamento.
|
|
411
|
+
*/
|
|
412
|
+
private async recordIngest(
|
|
413
|
+
resolved: ResolvedFileSource,
|
|
414
|
+
context: FileSourceContext,
|
|
415
|
+
sourceHost?: string,
|
|
416
|
+
) {
|
|
417
|
+
try {
|
|
418
|
+
await this.prismaService.audit_log.create({
|
|
419
|
+
data: {
|
|
420
|
+
actor_user_id: context.userId || null,
|
|
421
|
+
action: 'MCP_FILE_INGEST',
|
|
422
|
+
entity_table: 'file',
|
|
423
|
+
entity_id: String(resolved.fileId || ''),
|
|
424
|
+
summary: `Ingested ${resolved.filename} via ${resolved.modality}${
|
|
425
|
+
context.toolName ? ` for ${context.toolName}` : ''
|
|
426
|
+
}`,
|
|
427
|
+
after_data: JSON.stringify({
|
|
428
|
+
modality: resolved.modality,
|
|
429
|
+
tool: context.toolName ?? null,
|
|
430
|
+
file_id: resolved.fileId || null,
|
|
431
|
+
filename: resolved.filename,
|
|
432
|
+
mimetype: resolved.mimetype,
|
|
433
|
+
bytes: resolved.size,
|
|
434
|
+
...(sourceHost ? { source_host: sourceHost } : {}),
|
|
435
|
+
}),
|
|
436
|
+
},
|
|
437
|
+
});
|
|
438
|
+
} catch (error: any) {
|
|
439
|
+
this.logger.warn(`Failed to record MCP file ingest: ${error.message}`);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/** Quanto do arquivo basta para reconhecer o tipo — reexportado para os testes. */
|
|
444
|
+
static readonly SNIFF_BYTES = MIMETYPE_SNIFF_BYTES;
|
|
445
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { describe, expect, it } from '@jest/globals';
|
|
2
|
+
import {
|
|
3
|
+
detectMimetypeFromBytes,
|
|
4
|
+
findMimetypeConflict,
|
|
5
|
+
} from './mimetype-sniff.util';
|
|
6
|
+
|
|
7
|
+
/** Cabeçalho mínimo de cada formato, com o resto preenchido para passar do tamanho. */
|
|
8
|
+
const sample = (...parts: Array<string | number[]>): Buffer => {
|
|
9
|
+
const chunks = parts.map((part) =>
|
|
10
|
+
typeof part === 'string' ? Buffer.from(part, 'latin1') : Buffer.from(part),
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
return Buffer.concat([...chunks, Buffer.alloc(64)]);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const PDF = sample('%PDF-1.7');
|
|
17
|
+
const JPEG = sample([0xff, 0xd8, 0xff, 0xe0]);
|
|
18
|
+
const PNG = sample([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
|
|
19
|
+
const GIF = sample('GIF89a');
|
|
20
|
+
const WEBP = sample('RIFF', [0, 0, 0, 0], 'WEBP');
|
|
21
|
+
const WAV = sample('RIFF', [0, 0, 0, 0], 'WAVE');
|
|
22
|
+
const MP3 = sample('ID3');
|
|
23
|
+
const FLAC = sample('fLaC');
|
|
24
|
+
const OGG = sample('OggS');
|
|
25
|
+
const MP4 = sample([0, 0, 0, 0x20], 'ftyp', 'isom');
|
|
26
|
+
const M4A = sample([0, 0, 0, 0x20], 'ftyp', 'M4A ');
|
|
27
|
+
const ZIP = sample([0x50, 0x4b, 0x03, 0x04]);
|
|
28
|
+
const DOCX = sample([0x50, 0x4b, 0x03, 0x04], '.....word/document.xml');
|
|
29
|
+
const XLSX = sample([0x50, 0x4b, 0x03, 0x04], '.....xl/workbook.xml');
|
|
30
|
+
const PPTX = sample([0x50, 0x4b, 0x03, 0x04], '.....ppt/presentation.xml');
|
|
31
|
+
/** Cabeçalho de executável do Windows — o caso que motiva o sniff existir. */
|
|
32
|
+
const EXE = sample('MZ', [0x90, 0x00, 0x03, 0x00]);
|
|
33
|
+
|
|
34
|
+
describe('detectMimetypeFromBytes', () => {
|
|
35
|
+
it.each([
|
|
36
|
+
['pdf', PDF, 'application/pdf'],
|
|
37
|
+
['jpeg', JPEG, 'image/jpeg'],
|
|
38
|
+
['png', PNG, 'image/png'],
|
|
39
|
+
['gif', GIF, 'image/gif'],
|
|
40
|
+
['webp', WEBP, 'image/webp'],
|
|
41
|
+
['wav', WAV, 'audio/wav'],
|
|
42
|
+
['mp3', MP3, 'audio/mpeg'],
|
|
43
|
+
['flac', FLAC, 'audio/flac'],
|
|
44
|
+
['ogg', OGG, 'audio/ogg'],
|
|
45
|
+
['mp4', MP4, 'video/mp4'],
|
|
46
|
+
['m4a', M4A, 'audio/mp4'],
|
|
47
|
+
['zip', ZIP, 'application/zip'],
|
|
48
|
+
])('reconhece %s', (_name, buffer, expected) => {
|
|
49
|
+
expect(detectMimetypeFromBytes(buffer)).toBe(expected);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('distingue os três OOXML pelo nome das entradas do zip', () => {
|
|
53
|
+
expect(detectMimetypeFromBytes(DOCX)).toBe(
|
|
54
|
+
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
55
|
+
);
|
|
56
|
+
expect(detectMimetypeFromBytes(XLSX)).toBe(
|
|
57
|
+
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
58
|
+
);
|
|
59
|
+
expect(detectMimetypeFromBytes(PPTX)).toBe(
|
|
60
|
+
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
|
61
|
+
);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('devolve null para formato que não conhece, em vez de chutar', () => {
|
|
65
|
+
// CSV e OFX entram por aqui, e é justamente por isso que desconhecido não é recusa:
|
|
66
|
+
// barrá-los quebraria o finance.statements.import.
|
|
67
|
+
expect(detectMimetypeFromBytes(Buffer.from('data,valor\n2026-01-01,10'))).toBeNull();
|
|
68
|
+
expect(detectMimetypeFromBytes(Buffer.alloc(2))).toBeNull();
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
describe('findMimetypeConflict', () => {
|
|
73
|
+
it('não acusa conflito quando o conteúdo confirma o declarado', () => {
|
|
74
|
+
expect(findMimetypeConflict('application/pdf', PDF)).toBeNull();
|
|
75
|
+
expect(findMimetypeConflict('image/png', PNG)).toBeNull();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('acusa um formato conhecido que contradiz o declarado', () => {
|
|
79
|
+
expect(findMimetypeConflict('application/pdf', PNG)).toBe('image/png');
|
|
80
|
+
expect(findMimetypeConflict('image/png', PDF)).toBe('application/pdf');
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('acusa o executável declarado como PDF', () => {
|
|
84
|
+
// O caso central: `storage-accept-mimetype` sozinho aprovaria, porque ele só olha a
|
|
85
|
+
// string que o cliente mandou. E um `.exe` não tem nenhuma assinatura que o sniffer
|
|
86
|
+
// reconheça, então tratar "desconhecido" como "sem objeção" deixaria ele entrar.
|
|
87
|
+
expect(findMimetypeConflict('application/pdf', EXE)).toBe('a Windows executable');
|
|
88
|
+
expect(
|
|
89
|
+
findMimetypeConflict('image/png', sample([0x7f, 0x45, 0x4c, 0x46])),
|
|
90
|
+
).toBe('an ELF executable');
|
|
91
|
+
expect(findMimetypeConflict('application/pdf', sample('#!/bin/sh\nrm -rf /'))).toBe(
|
|
92
|
+
'a script with a shebang',
|
|
93
|
+
);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('recusa conteúdo irreconhecível quando o tipo declarado é verificável', () => {
|
|
97
|
+
// Nem todo payload hostil traz assinatura de executável. Declarar um formato que TEM
|
|
98
|
+
// assinatura conhecida é assumir que ela vai estar lá.
|
|
99
|
+
expect(findMimetypeConflict('application/pdf', Buffer.from('nao sou um pdf'))).toBe(
|
|
100
|
+
'not recognizable as application/pdf',
|
|
101
|
+
);
|
|
102
|
+
expect(findMimetypeConflict('image/png', Buffer.from('nem uma imagem'))).toBe(
|
|
103
|
+
'not recognizable as image/png',
|
|
104
|
+
);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('aceita sinônimos do mesmo formato', () => {
|
|
108
|
+
expect(findMimetypeConflict('audio/mp3', MP3)).toBeNull();
|
|
109
|
+
expect(findMimetypeConflict('audio/x-wav', WAV)).toBeNull();
|
|
110
|
+
expect(findMimetypeConflict('image/jpg', JPEG)).toBeNull();
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('não briga dentro da família zip, já que um docx é literalmente um zip', () => {
|
|
114
|
+
expect(findMimetypeConflict('application/zip', DOCX)).toBeNull();
|
|
115
|
+
expect(
|
|
116
|
+
findMimetypeConflict(
|
|
117
|
+
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
118
|
+
ZIP,
|
|
119
|
+
),
|
|
120
|
+
).toBeNull();
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('não acusa nada quando a assinatura é desconhecida', () => {
|
|
124
|
+
expect(findMimetypeConflict('text/csv', Buffer.from('a,b,c'))).toBeNull();
|
|
125
|
+
});
|
|
126
|
+
});
|