@axiumine/koa-utils 4.0.1
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/LICENSE +236 -0
- package/README.md +183 -0
- package/dist/dataSources/MariaDB.d.mts +4 -0
- package/dist/dataSources/MariaDB.mjs +75 -0
- package/dist/dataSources/MariaDB.mjs.map +1 -0
- package/dist/dataSources/MongoDB.d.mts +2 -0
- package/dist/dataSources/MongoDB.mjs +36 -0
- package/dist/dataSources/MongoDB.mjs.map +1 -0
- package/dist/dataSources/PostgreSQL.d.mts +17 -0
- package/dist/dataSources/PostgreSQL.mjs +111 -0
- package/dist/dataSources/PostgreSQL.mjs.map +1 -0
- package/dist/dataSources/Redis.d.mts +4629 -0
- package/dist/dataSources/Redis.mjs +46 -0
- package/dist/dataSources/Redis.mjs.map +1 -0
- package/dist/email/SocketLabsLib.d.mts +110 -0
- package/dist/email/SocketLabsLib.mjs +379 -0
- package/dist/email/SocketLabsLib.mjs.map +1 -0
- package/dist/files/IUploadTemp.d.mts +4 -0
- package/dist/files/IUploadTemp.mjs +2 -0
- package/dist/files/IUploadTemp.mjs.map +1 -0
- package/dist/files/checkForNSFW.d.mts +1 -0
- package/dist/files/checkForNSFW.mjs +22 -0
- package/dist/files/checkForNSFW.mjs.map +1 -0
- package/dist/files/fileConst.d.mts +7 -0
- package/dist/files/fileConst.mjs +4 -0
- package/dist/files/fileConst.mjs.map +1 -0
- package/dist/files/moveFileStaticDomain.d.mts +8 -0
- package/dist/files/moveFileStaticDomain.mjs +17 -0
- package/dist/files/moveFileStaticDomain.mjs.map +1 -0
- package/dist/files/moveImageFile.d.mts +1 -0
- package/dist/files/moveImageFile.mjs +11 -0
- package/dist/files/moveImageFile.mjs.map +1 -0
- package/dist/files/moveTempFile.d.mts +7 -0
- package/dist/files/moveTempFile.mjs +23 -0
- package/dist/files/moveTempFile.mjs.map +1 -0
- package/dist/files/reEncodeToJpeg.d.mts +1 -0
- package/dist/files/reEncodeToJpeg.mjs +5 -0
- package/dist/files/reEncodeToJpeg.mjs.map +1 -0
- package/dist/files/reEncodeToPng.d.mts +1 -0
- package/dist/files/reEncodeToPng.mjs +5 -0
- package/dist/files/reEncodeToPng.mjs.map +1 -0
- package/dist/files/reEncodeToWebp.d.mts +1 -0
- package/dist/files/reEncodeToWebp.mjs +5 -0
- package/dist/files/reEncodeToWebp.mjs.map +1 -0
- package/dist/files/scanVirus.d.mts +29 -0
- package/dist/files/scanVirus.mjs +60 -0
- package/dist/files/scanVirus.mjs.map +1 -0
- package/dist/files/storeUploadAsTemp.d.mts +3 -0
- package/dist/files/storeUploadAsTemp.mjs +74 -0
- package/dist/files/storeUploadAsTemp.mjs.map +1 -0
- package/dist/files/uploadTempImage.d.mts +8 -0
- package/dist/files/uploadTempImage.mjs +42 -0
- package/dist/files/uploadTempImage.mjs.map +1 -0
- package/dist/files/uploadTempPdf.d.mts +8 -0
- package/dist/files/uploadTempPdf.mjs +42 -0
- package/dist/files/uploadTempPdf.mjs.map +1 -0
- package/dist/files/validateExtension.d.mts +6 -0
- package/dist/files/validateExtension.mjs +11 -0
- package/dist/files/validateExtension.mjs.map +1 -0
- package/dist/files/validateJpgPngExtension.d.mts +1 -0
- package/dist/files/validateJpgPngExtension.mjs +9 -0
- package/dist/files/validateJpgPngExtension.mjs.map +1 -0
- package/dist/files/validateMimeType.d.mts +6 -0
- package/dist/files/validateMimeType.mjs +18 -0
- package/dist/files/validateMimeType.mjs.map +1 -0
- package/dist/files/validateMimeTypeImages.d.mts +5 -0
- package/dist/files/validateMimeTypeImages.mjs +9 -0
- package/dist/files/validateMimeTypeImages.mjs.map +1 -0
- package/dist/files/validateMimeTypePdf.d.mts +5 -0
- package/dist/files/validateMimeTypePdf.mjs +9 -0
- package/dist/files/validateMimeTypePdf.mjs.map +1 -0
- package/dist/files/validatePdfExtension.d.mts +1 -0
- package/dist/files/validatePdfExtension.mjs +9 -0
- package/dist/files/validatePdfExtension.mjs.map +1 -0
- package/dist/graphQL/models/MongoDB/UserBase.d.mts +61 -0
- package/dist/graphQL/models/MongoDB/UserBase.mjs +112 -0
- package/dist/graphQL/models/MongoDB/UserBase.mjs.map +1 -0
- package/dist/graphQL/models/MongoDB/log/DevStatsGraphQLCalls.d.mts +25 -0
- package/dist/graphQL/models/MongoDB/log/DevStatsGraphQLCalls.mjs +36 -0
- package/dist/graphQL/models/MongoDB/log/DevStatsGraphQLCalls.mjs.map +1 -0
- package/dist/graphQL/models/MongoDB/log/LogGlobalError.d.mts +16 -0
- package/dist/graphQL/models/MongoDB/log/LogGlobalError.mjs +25 -0
- package/dist/graphQL/models/MongoDB/log/LogGlobalError.mjs.map +1 -0
- package/dist/graphQL/models/MongoDB/log/LogStatsGraphql.d.mts +18 -0
- package/dist/graphQL/models/MongoDB/log/LogStatsGraphql.mjs +33 -0
- package/dist/graphQL/models/MongoDB/log/LogStatsGraphql.mjs.map +1 -0
- package/dist/graphQL/models/MongoDB/log/LogThrow.d.mts +17 -0
- package/dist/graphQL/models/MongoDB/log/LogThrow.mjs +28 -0
- package/dist/graphQL/models/MongoDB/log/LogThrow.mjs.map +1 -0
- package/dist/graphQL/schema/GraphQLInput/GraphQLInputLogin.d.mts +2 -0
- package/dist/graphQL/schema/GraphQLInput/GraphQLInputLogin.mjs +9 -0
- package/dist/graphQL/schema/GraphQLInput/GraphQLInputLogin.mjs.map +1 -0
- package/dist/graphQL/schema/context/IContextAuthenticatedResource.d.mts +16 -0
- package/dist/graphQL/schema/context/IContextAuthenticatedResource.mjs +2 -0
- package/dist/graphQL/schema/context/IContextAuthenticatedResource.mjs.map +1 -0
- package/dist/graphQL/schema/context/IContextKoaErrorHandler.d.mts +11 -0
- package/dist/graphQL/schema/context/IContextKoaErrorHandler.mjs +2 -0
- package/dist/graphQL/schema/context/IContextKoaErrorHandler.mjs.map +1 -0
- package/dist/graphQL/schema/context/IContextLogin.d.mts +4 -0
- package/dist/graphQL/schema/context/IContextLogin.mjs +2 -0
- package/dist/graphQL/schema/context/IContextLogin.mjs.map +1 -0
- package/dist/graphQL/schema/context/IContextLogout.d.mts +18 -0
- package/dist/graphQL/schema/context/IContextLogout.mjs +2 -0
- package/dist/graphQL/schema/context/IContextLogout.mjs.map +1 -0
- package/dist/graphQL/schema/context/IContextRefresh.d.mts +19 -0
- package/dist/graphQL/schema/context/IContextRefresh.mjs +2 -0
- package/dist/graphQL/schema/context/IContextRefresh.mjs.map +1 -0
- package/dist/graphQL/schema/context/TCommonHeaders.d.mts +15 -0
- package/dist/graphQL/schema/context/TCommonHeaders.mjs +2 -0
- package/dist/graphQL/schema/context/TCommonHeaders.mjs.map +1 -0
- package/dist/graphQL/schema/interfaces/IFindAndUpdate.d.mts +16 -0
- package/dist/graphQL/schema/interfaces/IFindAndUpdate.mjs +2 -0
- package/dist/graphQL/schema/interfaces/IFindAndUpdate.mjs.map +1 -0
- package/dist/graphQL/schema/mutations/emailChangeHashVerify.d.mts +22 -0
- package/dist/graphQL/schema/mutations/emailChangeHashVerify.mjs +100 -0
- package/dist/graphQL/schema/mutations/emailChangeHashVerify.mjs.map +1 -0
- package/dist/graphQL/schema/mutations/login4Ever.d.mts +22 -0
- package/dist/graphQL/schema/mutations/login4Ever.mjs +60 -0
- package/dist/graphQL/schema/mutations/login4Ever.mjs.map +1 -0
- package/dist/graphQL/schema/mutations/loginAdmin.d.mts +29 -0
- package/dist/graphQL/schema/mutations/loginAdmin.mjs +59 -0
- package/dist/graphQL/schema/mutations/loginAdmin.mjs.map +1 -0
- package/dist/graphQL/schema/mutations/loginRememberme.d.mts +26 -0
- package/dist/graphQL/schema/mutations/loginRememberme.mjs +54 -0
- package/dist/graphQL/schema/mutations/loginRememberme.mjs.map +1 -0
- package/dist/graphQL/schema/mutations/logout.d.mts +7 -0
- package/dist/graphQL/schema/mutations/logout.mjs +33 -0
- package/dist/graphQL/schema/mutations/logout.mjs.map +1 -0
- package/dist/graphQL/schema/mutations/refresh.d.mts +10 -0
- package/dist/graphQL/schema/mutations/refresh.mjs +56 -0
- package/dist/graphQL/schema/mutations/refresh.mjs.map +1 -0
- package/dist/graphQL/schema/mutations/resetPwd.d.mts +19 -0
- package/dist/graphQL/schema/mutations/resetPwd.mjs +90 -0
- package/dist/graphQL/schema/mutations/resetPwd.mjs.map +1 -0
- package/dist/graphQL/schema/mutations/signUp.d.mts +19 -0
- package/dist/graphQL/schema/mutations/signUp.mjs +55 -0
- package/dist/graphQL/schema/mutations/signUp.mjs.map +1 -0
- package/dist/graphQL/schema/mutations/updatePassword.d.mts +23 -0
- package/dist/graphQL/schema/mutations/updatePassword.mjs +71 -0
- package/dist/graphQL/schema/mutations/updatePassword.mjs.map +1 -0
- package/dist/graphQL/schema/types/DeleteType.d.mts +6 -0
- package/dist/graphQL/schema/types/DeleteType.mjs +13 -0
- package/dist/graphQL/schema/types/DeleteType.mjs.map +1 -0
- package/dist/graphQL/schema/types/DoneType.d.mts +2 -0
- package/dist/graphQL/schema/types/DoneType.mjs +10 -0
- package/dist/graphQL/schema/types/DoneType.mjs.map +1 -0
- package/dist/graphQL/schema/types/FindOneAndUpdateType.d.mts +2 -0
- package/dist/graphQL/schema/types/FindOneAndUpdateType.mjs +15 -0
- package/dist/graphQL/schema/types/FindOneAndUpdateType.mjs.map +1 -0
- package/dist/graphQL/schema/types/LoginAppType.d.mts +2 -0
- package/dist/graphQL/schema/types/LoginAppType.mjs +11 -0
- package/dist/graphQL/schema/types/LoginAppType.mjs.map +1 -0
- package/dist/graphQL/schema/types/LoginType.d.mts +2 -0
- package/dist/graphQL/schema/types/LoginType.mjs +9 -0
- package/dist/graphQL/schema/types/LoginType.mjs.map +1 -0
- package/dist/graphQL/schema/types/MidNameType.d.mts +5 -0
- package/dist/graphQL/schema/types/MidNameType.mjs +12 -0
- package/dist/graphQL/schema/types/MidNameType.mjs.map +1 -0
- package/dist/graphQL/schema/types/OnlyIdType.d.mts +2 -0
- package/dist/graphQL/schema/types/OnlyIdType.mjs +8 -0
- package/dist/graphQL/schema/types/OnlyIdType.mjs.map +1 -0
- package/dist/graphQL/schema/types/RefreshType.d.mts +2 -0
- package/dist/graphQL/schema/types/RefreshType.mjs +10 -0
- package/dist/graphQL/schema/types/RefreshType.mjs.map +1 -0
- package/dist/graphQL/schema/types/RetStatusMexType.d.mts +2 -0
- package/dist/graphQL/schema/types/RetStatusMexType.mjs +9 -0
- package/dist/graphQL/schema/types/RetStatusMexType.mjs.map +1 -0
- package/dist/graphQL/schema/types/RetStatusType.d.mts +2 -0
- package/dist/graphQL/schema/types/RetStatusType.mjs +8 -0
- package/dist/graphQL/schema/types/RetStatusType.mjs.map +1 -0
- package/dist/graphQL/schema/types/SaveType.d.mts +2 -0
- package/dist/graphQL/schema/types/SaveType.mjs +9 -0
- package/dist/graphQL/schema/types/SaveType.mjs.map +1 -0
- package/dist/graphQL/schema/types/SidNameType.d.mts +5 -0
- package/dist/graphQL/schema/types/SidNameType.mjs +12 -0
- package/dist/graphQL/schema/types/SidNameType.mjs.map +1 -0
- package/dist/graphQL/schema/types/SidNomeType.d.mts +5 -0
- package/dist/graphQL/schema/types/SidNomeType.mjs +12 -0
- package/dist/graphQL/schema/types/SidNomeType.mjs.map +1 -0
- package/dist/graphQL/schema/types/UpdateResultType.d.mts +2 -0
- package/dist/graphQL/schema/types/UpdateResultType.mjs +9 -0
- package/dist/graphQL/schema/types/UpdateResultType.mjs.map +1 -0
- package/dist/graphQL/status.d.mts +7 -0
- package/dist/graphQL/status.mjs +8 -0
- package/dist/graphQL/status.mjs.map +1 -0
- package/dist/graphQL/throw/throwAccessTokenExpiredOrDeleted.d.mts +1 -0
- package/dist/graphQL/throw/throwAccessTokenExpiredOrDeleted.mjs +5 -0
- package/dist/graphQL/throw/throwAccessTokenExpiredOrDeleted.mjs.map +1 -0
- package/dist/graphQL/throw/throwAccessTokenRequired.d.mts +1 -0
- package/dist/graphQL/throw/throwAccessTokenRequired.mjs +5 -0
- package/dist/graphQL/throw/throwAccessTokenRequired.mjs.map +1 -0
- package/dist/graphQL/throw/throwAlreadyDone.d.mts +4 -0
- package/dist/graphQL/throw/throwAlreadyDone.mjs +8 -0
- package/dist/graphQL/throw/throwAlreadyDone.mjs.map +1 -0
- package/dist/graphQL/throw/throwAlreadyTakenError.d.mts +1 -0
- package/dist/graphQL/throw/throwAlreadyTakenError.mjs +6 -0
- package/dist/graphQL/throw/throwAlreadyTakenError.mjs.map +1 -0
- package/dist/graphQL/throw/throwConflictError.d.mts +1 -0
- package/dist/graphQL/throw/throwConflictError.mjs +6 -0
- package/dist/graphQL/throw/throwConflictError.mjs.map +1 -0
- package/dist/graphQL/throw/throwErrorWrongUserInput.d.mts +1 -0
- package/dist/graphQL/throw/throwErrorWrongUserInput.mjs +5 -0
- package/dist/graphQL/throw/throwErrorWrongUserInput.mjs.map +1 -0
- package/dist/graphQL/throw/throwForbiddenError.d.mts +1 -0
- package/dist/graphQL/throw/throwForbiddenError.mjs +5 -0
- package/dist/graphQL/throw/throwForbiddenError.mjs.map +1 -0
- package/dist/graphQL/throw/throwGoneError.d.mts +1 -0
- package/dist/graphQL/throw/throwGoneError.mjs +6 -0
- package/dist/graphQL/throw/throwGoneError.mjs.map +1 -0
- package/dist/graphQL/throw/throwGraphQLError.d.mts +1 -0
- package/dist/graphQL/throw/throwGraphQLError.mjs +5 -0
- package/dist/graphQL/throw/throwGraphQLError.mjs.map +1 -0
- package/dist/graphQL/throw/throwInternalError.d.mts +1 -0
- package/dist/graphQL/throw/throwInternalError.mjs +5 -0
- package/dist/graphQL/throw/throwInternalError.mjs.map +1 -0
- package/dist/graphQL/throw/throwMethodNotAllowedError.d.mts +1 -0
- package/dist/graphQL/throw/throwMethodNotAllowedError.mjs +6 -0
- package/dist/graphQL/throw/throwMethodNotAllowedError.mjs.map +1 -0
- package/dist/graphQL/throw/throwMissingMalformedInvalidToken.d.mts +1 -0
- package/dist/graphQL/throw/throwMissingMalformedInvalidToken.mjs +5 -0
- package/dist/graphQL/throw/throwMissingMalformedInvalidToken.mjs.map +1 -0
- package/dist/graphQL/throw/throwNotAcceptableError.d.mts +1 -0
- package/dist/graphQL/throw/throwNotAcceptableError.mjs +6 -0
- package/dist/graphQL/throw/throwNotAcceptableError.mjs.map +1 -0
- package/dist/graphQL/throw/throwNotFoundError.d.mts +1 -0
- package/dist/graphQL/throw/throwNotFoundError.mjs +6 -0
- package/dist/graphQL/throw/throwNotFoundError.mjs.map +1 -0
- package/dist/graphQL/throw/throwNotImplementedError.d.mts +1 -0
- package/dist/graphQL/throw/throwNotImplementedError.mjs +6 -0
- package/dist/graphQL/throw/throwNotImplementedError.mjs.map +1 -0
- package/dist/graphQL/throw/throwPaymentRequiredError.d.mts +1 -0
- package/dist/graphQL/throw/throwPaymentRequiredError.mjs +5 -0
- package/dist/graphQL/throw/throwPaymentRequiredError.mjs.map +1 -0
- package/dist/graphQL/throw/throwPreconditionFailedNoAuthCookie.d.mts +1 -0
- package/dist/graphQL/throw/throwPreconditionFailedNoAuthCookie.mjs +5 -0
- package/dist/graphQL/throw/throwPreconditionFailedNoAuthCookie.mjs.map +1 -0
- package/dist/graphQL/throw/throwPreconditionFailedNoAuthHeader.d.mts +1 -0
- package/dist/graphQL/throw/throwPreconditionFailedNoAuthHeader.mjs +5 -0
- package/dist/graphQL/throw/throwPreconditionFailedNoAuthHeader.mjs.map +1 -0
- package/dist/graphQL/throw/throwRefreshTokenExpiredOrDeleted.d.mts +1 -0
- package/dist/graphQL/throw/throwRefreshTokenExpiredOrDeleted.mjs +5 -0
- package/dist/graphQL/throw/throwRefreshTokenExpiredOrDeleted.mjs.map +1 -0
- package/dist/graphQL/throw/throwRefreshTokenRequired.d.mts +1 -0
- package/dist/graphQL/throw/throwRefreshTokenRequired.mjs +5 -0
- package/dist/graphQL/throw/throwRefreshTokenRequired.mjs.map +1 -0
- package/dist/graphQL/throw/throwRefreshTokenSignatureRequired.d.mts +1 -0
- package/dist/graphQL/throw/throwRefreshTokenSignatureRequired.mjs +5 -0
- package/dist/graphQL/throw/throwRefreshTokenSignatureRequired.mjs.map +1 -0
- package/dist/graphQL/throw/throwTooManyRequestsError.d.mts +1 -0
- package/dist/graphQL/throw/throwTooManyRequestsError.mjs +5 -0
- package/dist/graphQL/throw/throwTooManyRequestsError.mjs.map +1 -0
- package/dist/graphQL/throw/throwUnauthorizedError.d.mts +1 -0
- package/dist/graphQL/throw/throwUnauthorizedError.mjs +5 -0
- package/dist/graphQL/throw/throwUnauthorizedError.mjs.map +1 -0
- package/dist/graphQL/throw/throwUnprocessableContentError.d.mts +1 -0
- package/dist/graphQL/throw/throwUnprocessableContentError.mjs +5 -0
- package/dist/graphQL/throw/throwUnprocessableContentError.mjs.map +1 -0
- package/dist/graphQL/throw/throwUnsupportedMediaTypeError.d.mts +1 -0
- package/dist/graphQL/throw/throwUnsupportedMediaTypeError.mjs +5 -0
- package/dist/graphQL/throw/throwUnsupportedMediaTypeError.mjs.map +1 -0
- package/dist/koa/IFileUpload.d.mts +6 -0
- package/dist/koa/IFileUpload.mjs +2 -0
- package/dist/koa/IFileUpload.mjs.map +1 -0
- package/dist/koa/IKoaError.d.mts +15 -0
- package/dist/koa/IKoaError.mjs +2 -0
- package/dist/koa/IKoaError.mjs.map +1 -0
- package/dist/koa/customFormatErrorFn.d.mts +2 -0
- package/dist/koa/customFormatErrorFn.mjs +10 -0
- package/dist/koa/customFormatErrorFn.mjs.map +1 -0
- package/dist/koa/logRequestToDb.d.mts +3 -0
- package/dist/koa/logRequestToDb.mjs +16 -0
- package/dist/koa/logRequestToDb.mjs.map +1 -0
- package/dist/koa/middleware/authenticatedAuthorizationHandler/TCookieRefreshToken.d.mts +4 -0
- package/dist/koa/middleware/authenticatedAuthorizationHandler/TCookieRefreshToken.mjs +2 -0
- package/dist/koa/middleware/authenticatedAuthorizationHandler/TCookieRefreshToken.mjs.map +1 -0
- package/dist/koa/middleware/authenticatedAuthorizationHandler/index.d.mts +4 -0
- package/dist/koa/middleware/authenticatedAuthorizationHandler/index.mjs +36 -0
- package/dist/koa/middleware/authenticatedAuthorizationHandler/index.mjs.map +1 -0
- package/dist/koa/middleware/authenticatedAuthorizationHandler/verifySignedRefreshToken.d.mts +3 -0
- package/dist/koa/middleware/authenticatedAuthorizationHandler/verifySignedRefreshToken.mjs +41 -0
- package/dist/koa/middleware/authenticatedAuthorizationHandler/verifySignedRefreshToken.mjs.map +1 -0
- package/dist/koa/middleware/authenticatedLogoutHandler/index.d.mts +4 -0
- package/dist/koa/middleware/authenticatedLogoutHandler/index.mjs +69 -0
- package/dist/koa/middleware/authenticatedLogoutHandler/index.mjs.map +1 -0
- package/dist/koa/middleware/authenticatedResourceHandler/index.d.mts +6 -0
- package/dist/koa/middleware/authenticatedResourceHandler/index.mjs +54 -0
- package/dist/koa/middleware/authenticatedResourceHandler/index.mjs.map +1 -0
- package/dist/koa/middleware/debug/index.d.mts +3 -0
- package/dist/koa/middleware/debug/index.mjs +9 -0
- package/dist/koa/middleware/debug/index.mjs.map +1 -0
- package/dist/koa/router/verifyEmail.d.mts +2 -0
- package/dist/koa/router/verifyEmail.mjs +33 -0
- package/dist/koa/router/verifyEmail.mjs.map +1 -0
- package/dist/koa/tdwKoaErrorHandler.d.mts +3 -0
- package/dist/koa/tdwKoaErrorHandler.mjs +52 -0
- package/dist/koa/tdwKoaErrorHandler.mjs.map +1 -0
- package/dist/lib/ArrayLib.d.mts +4 -0
- package/dist/lib/ArrayLib.mjs +9 -0
- package/dist/lib/ArrayLib.mjs.map +1 -0
- package/dist/lib/Constants.d.mts +7 -0
- package/dist/lib/Constants.mjs +8 -0
- package/dist/lib/Constants.mjs.map +1 -0
- package/dist/lib/DateLib.d.mts +9 -0
- package/dist/lib/DateLib.mjs +35 -0
- package/dist/lib/DateLib.mjs.map +1 -0
- package/dist/lib/IAuthorizationDisDel.d.mts +4 -0
- package/dist/lib/IAuthorizationDisDel.mjs +2 -0
- package/dist/lib/IAuthorizationDisDel.mjs.map +1 -0
- package/dist/lib/ICookies.d.mts +13 -0
- package/dist/lib/ICookies.mjs +2 -0
- package/dist/lib/ICookies.mjs.map +1 -0
- package/dist/lib/MariaDB/IMariaDBErr.d.mts +6 -0
- package/dist/lib/MariaDB/IMariaDBErr.mjs +2 -0
- package/dist/lib/MariaDB/IMariaDBErr.mjs.map +1 -0
- package/dist/lib/MariaDB/MariaDBErrType.d.mts +3 -0
- package/dist/lib/MariaDB/MariaDBErrType.mjs +6 -0
- package/dist/lib/MariaDB/MariaDBErrType.mjs.map +1 -0
- package/dist/lib/MariaDB/throwSqlErrors.d.mts +2 -0
- package/dist/lib/MariaDB/throwSqlErrors.mjs +20 -0
- package/dist/lib/MariaDB/throwSqlErrors.mjs.map +1 -0
- package/dist/lib/MongoDB/IMongoDBError.d.mts +12 -0
- package/dist/lib/MongoDB/IMongoDBError.mjs +2 -0
- package/dist/lib/MongoDB/IMongoDBError.mjs.map +1 -0
- package/dist/lib/MongoDB/IOnboarding.d.mts +4 -0
- package/dist/lib/MongoDB/IOnboarding.mjs +2 -0
- package/dist/lib/MongoDB/IOnboarding.mjs.map +1 -0
- package/dist/lib/MongoDB/MongoDBErrType.d.mts +3 -0
- package/dist/lib/MongoDB/MongoDBErrType.mjs +5 -0
- package/dist/lib/MongoDB/MongoDBErrType.mjs.map +1 -0
- package/dist/lib/MongoDB/throwIfMongoErr.d.mts +2 -0
- package/dist/lib/MongoDB/throwIfMongoErr.mjs +13 -0
- package/dist/lib/MongoDB/throwIfMongoErr.mjs.map +1 -0
- package/dist/lib/MongoDB/throwMongoErrors.d.mts +2 -0
- package/dist/lib/MongoDB/throwMongoErrors.mjs +10 -0
- package/dist/lib/MongoDB/throwMongoErrors.mjs.map +1 -0
- package/dist/lib/NumLib.d.mts +10 -0
- package/dist/lib/NumLib.mjs +13 -0
- package/dist/lib/NumLib.mjs.map +1 -0
- package/dist/lib/PostgreSQL/IPostgresError.d.mts +6 -0
- package/dist/lib/PostgreSQL/IPostgresError.mjs +2 -0
- package/dist/lib/PostgreSQL/IPostgresError.mjs.map +1 -0
- package/dist/lib/PostgreSQL/IPostgresErrorCodes.d.mts +3 -0
- package/dist/lib/PostgreSQL/IPostgresErrorCodes.mjs +5 -0
- package/dist/lib/PostgreSQL/IPostgresErrorCodes.mjs.map +1 -0
- package/dist/lib/PostgreSQL/makePostgreSqlLogError.d.mts +2 -0
- package/dist/lib/PostgreSQL/makePostgreSqlLogError.mjs +4 -0
- package/dist/lib/PostgreSQL/makePostgreSqlLogError.mjs.map +1 -0
- package/dist/lib/Redis/RedisBoolean.d.mts +4 -0
- package/dist/lib/Redis/RedisBoolean.mjs +6 -0
- package/dist/lib/Redis/RedisBoolean.mjs.map +1 -0
- package/dist/lib/Redis/buildPrefixedRedisKey.d.mts +9 -0
- package/dist/lib/Redis/buildPrefixedRedisKey.mjs +12 -0
- package/dist/lib/Redis/buildPrefixedRedisKey.mjs.map +1 -0
- package/dist/lib/Redis/fromRedisBooleanValue.d.mts +2 -0
- package/dist/lib/Redis/fromRedisBooleanValue.mjs +5 -0
- package/dist/lib/Redis/fromRedisBooleanValue.mjs.map +1 -0
- package/dist/lib/Redis/toRedisBooleanValue.d.mts +2 -0
- package/dist/lib/Redis/toRedisBooleanValue.mjs +5 -0
- package/dist/lib/Redis/toRedisBooleanValue.mjs.map +1 -0
- package/dist/lib/StringLib.d.mts +46 -0
- package/dist/lib/StringLib.mjs +95 -0
- package/dist/lib/StringLib.mjs.map +1 -0
- package/dist/lib/checkEmailLen.d.mts +1 -0
- package/dist/lib/checkEmailLen.mjs +11 -0
- package/dist/lib/checkEmailLen.mjs.map +1 -0
- package/dist/lib/checkPwdLen.d.mts +1 -0
- package/dist/lib/checkPwdLen.mjs +13 -0
- package/dist/lib/checkPwdLen.mjs.map +1 -0
- package/dist/lib/db/log/hitStat.d.mts +1 -0
- package/dist/lib/db/log/hitStat.mjs +9 -0
- package/dist/lib/db/log/hitStat.mjs.map +1 -0
- package/dist/lib/db/log/logGlobalError.d.mts +6 -0
- package/dist/lib/db/log/logGlobalError.mjs +12 -0
- package/dist/lib/db/log/logGlobalError.mjs.map +1 -0
- package/dist/lib/db/log/logGraphql.d.mts +9 -0
- package/dist/lib/db/log/logGraphql.mjs +27 -0
- package/dist/lib/db/log/logGraphql.mjs.map +1 -0
- package/dist/lib/db/log/logThrow.d.mts +1 -0
- package/dist/lib/db/log/logThrow.mjs +15 -0
- package/dist/lib/db/log/logThrow.mjs.map +1 -0
- package/dist/lib/db/login/ILoginSet.d.mts +7 -0
- package/dist/lib/db/login/ILoginSet.mjs +2 -0
- package/dist/lib/db/login/ILoginSet.mjs.map +1 -0
- package/dist/lib/db/login/ILoginUnset.d.mts +5 -0
- package/dist/lib/db/login/ILoginUnset.mjs +2 -0
- package/dist/lib/db/login/ILoginUnset.mjs.map +1 -0
- package/dist/lib/db/registerNewUser.d.mts +2 -0
- package/dist/lib/db/registerNewUser.mjs +33 -0
- package/dist/lib/db/registerNewUser.mjs.map +1 -0
- package/dist/lib/db/userExist.d.mts +2 -0
- package/dist/lib/db/userExist.mjs +6 -0
- package/dist/lib/db/userExist.mjs.map +1 -0
- package/dist/lib/emailHash.d.mts +1 -0
- package/dist/lib/emailHash.mjs +7 -0
- package/dist/lib/emailHash.mjs.map +1 -0
- package/dist/lib/encryptPassword.d.mts +1 -0
- package/dist/lib/encryptPassword.mjs +6 -0
- package/dist/lib/encryptPassword.mjs.map +1 -0
- package/dist/lib/hash.d.mts +6 -0
- package/dist/lib/hash.mjs +15 -0
- package/dist/lib/hash.mjs.map +1 -0
- package/dist/lib/isSafeRedirectTarget.d.mts +19 -0
- package/dist/lib/isSafeRedirectTarget.mjs +26 -0
- package/dist/lib/isSafeRedirectTarget.mjs.map +1 -0
- package/dist/lib/isSessionBlocked.d.mts +7 -0
- package/dist/lib/isSessionBlocked.mjs +10 -0
- package/dist/lib/isSessionBlocked.mjs.map +1 -0
- package/dist/lib/isValidUuidV4.d.mts +7 -0
- package/dist/lib/isValidUuidV4.mjs +11 -0
- package/dist/lib/isValidUuidV4.mjs.map +1 -0
- package/dist/lib/makeOnboardingData.d.mts +2 -0
- package/dist/lib/makeOnboardingData.mjs +4 -0
- package/dist/lib/makeOnboardingData.mjs.map +1 -0
- package/dist/lib/setLoginCookies.d.mts +2 -0
- package/dist/lib/setLoginCookies.mjs +10 -0
- package/dist/lib/setLoginCookies.mjs.map +1 -0
- package/dist/lib/sleepMs.d.mts +1 -0
- package/dist/lib/sleepMs.mjs +2 -0
- package/dist/lib/sleepMs.mjs.map +1 -0
- package/dist/lib/throwIfNotValidEnumValue.d.mts +1 -0
- package/dist/lib/throwIfNotValidEnumValue.mjs +8 -0
- package/dist/lib/throwIfNotValidEnumValue.mjs.map +1 -0
- package/dist/lib/tokenOptions.d.mts +12 -0
- package/dist/lib/tokenOptions.mjs +17 -0
- package/dist/lib/tokenOptions.mjs.map +1 -0
- package/dist/lib/tokens.d.mts +4 -0
- package/dist/lib/tokens.mjs +22 -0
- package/dist/lib/tokens.mjs.map +1 -0
- package/dist/lib/tryCatchRethrow.d.mts +2 -0
- package/dist/lib/tryCatchRethrow.mjs +20 -0
- package/dist/lib/tryCatchRethrow.mjs.map +1 -0
- package/dist/private/files/_validateMimeType.d.mts +6 -0
- package/dist/private/files/_validateMimeType.mjs +21 -0
- package/dist/private/files/_validateMimeType.mjs.map +1 -0
- package/dist/private/files/assertNoTraversal.d.mts +12 -0
- package/dist/private/files/assertNoTraversal.mjs +17 -0
- package/dist/private/files/assertNoTraversal.mjs.map +1 -0
- package/dist/private/files/reEncode.d.mts +10 -0
- package/dist/private/files/reEncode.mjs +47 -0
- package/dist/private/files/reEncode.mjs.map +1 -0
- package/dist/private/graphQL/Consts.d.mts +2 -0
- package/dist/private/graphQL/Consts.mjs +3 -0
- package/dist/private/graphQL/Consts.mjs.map +1 -0
- package/dist/private/graphQL/models/MongoDB/private/UserAdminKoaUtils.d.mts +58 -0
- package/dist/private/graphQL/models/MongoDB/private/UserAdminKoaUtils.mjs +107 -0
- package/dist/private/graphQL/models/MongoDB/private/UserAdminKoaUtils.mjs.map +1 -0
- package/dist/private/graphQL/schema/context/IContextLog.d.mts +15 -0
- package/dist/private/graphQL/schema/context/IContextLog.mjs +2 -0
- package/dist/private/graphQL/schema/context/IContextLog.mjs.map +1 -0
- package/dist/private/graphQL/schema/context/IContextVerifyEmail.d.mts +7 -0
- package/dist/private/graphQL/schema/context/IContextVerifyEmail.mjs +2 -0
- package/dist/private/graphQL/schema/context/IContextVerifyEmail.mjs.map +1 -0
- package/dist/private/graphQL/schema/mutations/_buildLoginStatsUpdate.d.mts +19 -0
- package/dist/private/graphQL/schema/mutations/_buildLoginStatsUpdate.mjs +26 -0
- package/dist/private/graphQL/schema/mutations/_buildLoginStatsUpdate.mjs.map +1 -0
- package/dist/private/graphQL/schema/mutations/_finalizeLoginCheck.d.mts +19 -0
- package/dist/private/graphQL/schema/mutations/_finalizeLoginCheck.mjs +28 -0
- package/dist/private/graphQL/schema/mutations/_finalizeLoginCheck.mjs.map +1 -0
- package/dist/private/graphQL/schema/mutations/checkUserAdminLoginAuthorization.d.mts +5 -0
- package/dist/private/graphQL/schema/mutations/checkUserAdminLoginAuthorization.mjs +7 -0
- package/dist/private/graphQL/schema/mutations/checkUserAdminLoginAuthorization.mjs.map +1 -0
- package/dist/private/graphQL/schema/mutations/checkUserLoginAuthorization.d.mts +5 -0
- package/dist/private/graphQL/schema/mutations/checkUserLoginAuthorization.mjs +8 -0
- package/dist/private/graphQL/schema/mutations/checkUserLoginAuthorization.mjs.map +1 -0
- package/dist/private/graphQL/schema/mutations/infoUserAdminForLogin.d.mts +3 -0
- package/dist/private/graphQL/schema/mutations/infoUserAdminForLogin.mjs +13 -0
- package/dist/private/graphQL/schema/mutations/infoUserAdminForLogin.mjs.map +1 -0
- package/dist/private/graphQL/schema/mutations/infoUserForLogin.d.mts +3 -0
- package/dist/private/graphQL/schema/mutations/infoUserForLogin.mjs +13 -0
- package/dist/private/graphQL/schema/mutations/infoUserForLogin.mjs.map +1 -0
- package/dist/private/graphQL/schema/mutations/infoUserForLoginSQL.d.mts +8 -0
- package/dist/private/graphQL/schema/mutations/infoUserForLoginSQL.mjs +16 -0
- package/dist/private/graphQL/schema/mutations/infoUserForLoginSQL.mjs.map +1 -0
- package/dist/private/graphQL/schema/mutations/setLastLoginSQL.d.mts +1 -0
- package/dist/private/graphQL/schema/mutations/setLastLoginSQL.mjs +27 -0
- package/dist/private/graphQL/schema/mutations/setLastLoginSQL.mjs.map +1 -0
- package/dist/private/graphQL/schema/mutations/setRedisLoginSession.d.mts +2 -0
- package/dist/private/graphQL/schema/mutations/setRedisLoginSession.mjs +27 -0
- package/dist/private/graphQL/schema/mutations/setRedisLoginSession.mjs.map +1 -0
- package/dist/private/graphQL/schema/mutations/updateAdminLoginStats.d.mts +2 -0
- package/dist/private/graphQL/schema/mutations/updateAdminLoginStats.mjs +7 -0
- package/dist/private/graphQL/schema/mutations/updateAdminLoginStats.mjs.map +1 -0
- package/dist/private/graphQL/schema/mutations/updateLoginStats4ever.d.mts +2 -0
- package/dist/private/graphQL/schema/mutations/updateLoginStats4ever.mjs +18 -0
- package/dist/private/graphQL/schema/mutations/updateLoginStats4ever.mjs.map +1 -0
- package/dist/private/graphQL/schema/mutations/updateLoginStatsRememberme.d.mts +2 -0
- package/dist/private/graphQL/schema/mutations/updateLoginStatsRememberme.mjs +7 -0
- package/dist/private/graphQL/schema/mutations/updateLoginStatsRememberme.mjs.map +1 -0
- package/dist/private/lib/access/Constants.d.mts +2 -0
- package/dist/private/lib/access/Constants.mjs +4 -0
- package/dist/private/lib/access/Constants.mjs.map +1 -0
- package/dist/private/lib/access/assertVerifyEmailAllowed.d.mts +36 -0
- package/dist/private/lib/access/assertVerifyEmailAllowed.mjs +45 -0
- package/dist/private/lib/access/assertVerifyEmailAllowed.mjs.map +1 -0
- package/dist/private/lib/access/db/confirmNewEmail.d.mts +2 -0
- package/dist/private/lib/access/db/confirmNewEmail.mjs +13 -0
- package/dist/private/lib/access/db/confirmNewEmail.mjs.map +1 -0
- package/dist/private/lib/access/db/deleteUserByEmail.d.mts +1 -0
- package/dist/private/lib/access/db/deleteUserByEmail.mjs +8 -0
- package/dist/private/lib/access/db/deleteUserByEmail.mjs.map +1 -0
- package/dist/private/lib/access/db/enableEmailAccess.d.mts +2 -0
- package/dist/private/lib/access/db/enableEmailAccess.mjs +17 -0
- package/dist/private/lib/access/db/enableEmailAccess.mjs.map +1 -0
- package/dist/private/lib/access/db/getResetPwd.d.mts +7 -0
- package/dist/private/lib/access/db/getResetPwd.mjs +24 -0
- package/dist/private/lib/access/db/getResetPwd.mjs.map +1 -0
- package/dist/private/lib/access/db/incReqTimes.d.mts +2 -0
- package/dist/private/lib/access/db/incReqTimes.mjs +5 -0
- package/dist/private/lib/access/db/incReqTimes.mjs.map +1 -0
- package/dist/private/lib/access/db/removeResetReq.d.mts +2 -0
- package/dist/private/lib/access/db/removeResetReq.mjs +7 -0
- package/dist/private/lib/access/db/removeResetReq.mjs.map +1 -0
- package/dist/private/lib/access/db/saveResetReq.d.mts +2 -0
- package/dist/private/lib/access/db/saveResetReq.mjs +17 -0
- package/dist/private/lib/access/db/saveResetReq.mjs.map +1 -0
- package/dist/private/lib/access/db/setEmailHash.d.mts +2 -0
- package/dist/private/lib/access/db/setEmailHash.mjs +16 -0
- package/dist/private/lib/access/db/setEmailHash.mjs.map +1 -0
- package/dist/private/lib/access/db/updatePasswordDb.d.mts +2 -0
- package/dist/private/lib/access/db/updatePasswordDb.mjs +8 -0
- package/dist/private/lib/access/db/updatePasswordDb.mjs.map +1 -0
- package/dist/private/lib/access/db/userData4VerifyEmail.d.mts +3 -0
- package/dist/private/lib/access/db/userData4VerifyEmail.mjs +16 -0
- package/dist/private/lib/access/db/userData4VerifyEmail.mjs.map +1 -0
- package/dist/private/lib/access/handleBadDB.d.mts +1 -0
- package/dist/private/lib/access/handleBadDB.mjs +9 -0
- package/dist/private/lib/access/handleBadDB.mjs.map +1 -0
- package/dist/private/lib/access/handleIfAccountDeleted.d.mts +1 -0
- package/dist/private/lib/access/handleIfAccountDeleted.mjs +10 -0
- package/dist/private/lib/access/handleIfAccountDeleted.mjs.map +1 -0
- package/dist/private/lib/access/handleIfAccountDisabled.d.mts +1 -0
- package/dist/private/lib/access/handleIfAccountDisabled.mjs +10 -0
- package/dist/private/lib/access/handleIfAccountDisabled.mjs.map +1 -0
- package/dist/private/lib/access/handleIfEmailAlreadyValid.d.mts +1 -0
- package/dist/private/lib/access/handleIfEmailAlreadyValid.mjs +10 -0
- package/dist/private/lib/access/handleIfEmailAlreadyValid.mjs.map +1 -0
- package/dist/private/lib/access/handleIfHashBad.d.mts +14 -0
- package/dist/private/lib/access/handleIfHashBad.mjs +17 -0
- package/dist/private/lib/access/handleIfHashBad.mjs.map +1 -0
- package/dist/private/lib/access/handleIfMoreThan3DaysPassed.d.mts +1 -0
- package/dist/private/lib/access/handleIfMoreThan3DaysPassed.mjs +23 -0
- package/dist/private/lib/access/handleIfMoreThan3DaysPassed.mjs.map +1 -0
- package/dist/private/lib/access/handleIfTooMuchRequestsTimes.d.mts +1 -0
- package/dist/private/lib/access/handleIfTooMuchRequestsTimes.mjs +13 -0
- package/dist/private/lib/access/handleIfTooMuchRequestsTimes.mjs.map +1 -0
- package/dist/private/lib/makeBodyJson.d.mts +1 -0
- package/dist/private/lib/makeBodyJson.mjs +7 -0
- package/dist/private/lib/makeBodyJson.mjs.map +1 -0
- package/dist/private/lib/verifyIntrospectionCode.d.mts +9 -0
- package/dist/private/lib/verifyIntrospectionCode.mjs +28 -0
- package/dist/private/lib/verifyIntrospectionCode.mjs.map +1 -0
- package/package.json +709 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as Sentry from '@sentry/node';
|
|
2
|
+
import * as dotenv from 'dotenv';
|
|
3
|
+
import { createClient, createCluster } from 'redis';
|
|
4
|
+
dotenv.config();
|
|
5
|
+
export const redisClient = process.env.REDIS_IS_CLUSTER === '1'
|
|
6
|
+
? /* c8 ignore start -- cluster branch: requires REDIS_IS_CLUSTER=1 + 3 redis nodes, not in unit env */
|
|
7
|
+
createCluster({
|
|
8
|
+
rootNodes: [
|
|
9
|
+
{ url: `redis://${process.env.REDIS_DB1_HOST}:${process.env.REDIS_DB1_PORT}` },
|
|
10
|
+
{ url: `redis://${process.env.REDIS_DB2_HOST}:${process.env.REDIS_DB2_PORT}` },
|
|
11
|
+
{ url: `redis://${process.env.REDIS_DB3_HOST}:${process.env.REDIS_DB3_PORT}` }
|
|
12
|
+
],
|
|
13
|
+
defaults: {
|
|
14
|
+
username: process.env.REDIS_USERNAME,
|
|
15
|
+
password: process.env.REDIS_PASSWORD
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
: /* c8 ignore stop */
|
|
19
|
+
createClient({ url: process.env.REDIS_URL });
|
|
20
|
+
export const RedisConnect = async () => {
|
|
21
|
+
console.info('[Redis] Try connect to database... ');
|
|
22
|
+
redisClient.on('error', (e) => {
|
|
23
|
+
console.error('Redis Client Error');
|
|
24
|
+
Sentry.captureException(e);
|
|
25
|
+
});
|
|
26
|
+
await redisClient.connect();
|
|
27
|
+
console.info('[Redis] OK: Redis connection has been established successfully. ');
|
|
28
|
+
};
|
|
29
|
+
export async function RedisDisconnect() {
|
|
30
|
+
console.info('[Redis] Try close connection to database... ');
|
|
31
|
+
try {
|
|
32
|
+
await redisClient.close(); // Gracefully close a client's connection to Redis
|
|
33
|
+
console.info('[Redis] OK: Redis connection has been closed successfully.');
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
if (e instanceof Error && e.message === 'The client is closed') {
|
|
37
|
+
console.info('[Redis] Client was already closed');
|
|
38
|
+
return; // Continue execution if client is already closed
|
|
39
|
+
}
|
|
40
|
+
// For any other errors, log and re-throw
|
|
41
|
+
console.error('[Redis] Error during disconnection');
|
|
42
|
+
Sentry.captureException(e);
|
|
43
|
+
throw e;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=Redis.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Redis.mjs","sourceRoot":"","sources":["../../src/dataSources/Redis.mts"],"names":[],"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AC,OAAO,EAAE,CAAA;IAC3B,OAAO,CAAC,IAAI,CAAC,kEAAkE,CAAC,CAAA;AACjF,CAAC,CAAA;AAED,MAAM,CAAC,KAAK,UAAU,eAAe;IACpC,OAAO,CAAC,IAAI,CAAC,8CAA8C,CAAC,CAAA;IAC5D,IAAI,CAAC;QACJ,MAAM,WAAW,CAAC,KAAK,EAAE,CAAA,CAAC,kDAAkD;QAC5E,OAAO,CAAC,IAAI,CAAC,4DAA4D,CAAC,CAAA;IAC3E,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACZ,IAAI,CAAC,YAAY,KAAK,IAAI,CAAC,CAAC,OAAO,KAAK,sBAAsB,EAAE,CAAC;YAChE,OAAO,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAA;YACjD,OAAM,CAAC,iDAAiD;QACzD,CAAC;QACD,yCAAyC;QACzC,OAAO,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAA;QACnD,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAA;QAC1B,MAAM,CAAC,CAAA;IACR,CAAC;AACF,CAAC","sourcesContent":["import * as Sentry from '@sentry/node'\nimport * as dotenv from 'dotenv'\nimport { createClient, createCluster } from 'redis'\n\ndotenv.config()\n\nexport const redisClient =\n\tprocess.env.REDIS_IS_CLUSTER === '1'\n\t\t? /* c8 ignore start -- cluster branch: requires REDIS_IS_CLUSTER=1 + 3 redis nodes, not in unit env */\n\t\t\tcreateCluster({\n\t\t\t\trootNodes: [\n\t\t\t\t\t{ url: `redis://${process.env.REDIS_DB1_HOST}:${process.env.REDIS_DB1_PORT}` },\n\t\t\t\t\t{ url: `redis://${process.env.REDIS_DB2_HOST}:${process.env.REDIS_DB2_PORT}` },\n\t\t\t\t\t{ url: `redis://${process.env.REDIS_DB3_HOST}:${process.env.REDIS_DB3_PORT}` }\n\t\t\t\t],\n\t\t\t\tdefaults: {\n\t\t\t\t\tusername: process.env.REDIS_USERNAME,\n\t\t\t\t\tpassword: process.env.REDIS_PASSWORD\n\t\t\t\t}\n\t\t\t})\n\t\t: /* c8 ignore stop */\n\t\t\tcreateClient({ url: process.env.REDIS_URL })\n\nexport const RedisConnect = async () => {\n\tconsole.info('[Redis] Try connect to database... ')\n\n\tredisClient.on('error', (e) => {\n\t\tconsole.error('Redis Client Error')\n\t\tSentry.captureException(e)\n\t})\n\tawait redisClient.connect()\n\tconsole.info('[Redis] OK: Redis connection has been established successfully. ')\n}\n\nexport async function RedisDisconnect() {\n\tconsole.info('[Redis] Try close connection to database... ')\n\ttry {\n\t\tawait redisClient.close() // Gracefully close a client's connection to Redis\n\t\tconsole.info('[Redis] OK: Redis connection has been closed successfully.')\n\t} catch (e) {\n\t\tif (e instanceof Error && e.message === 'The client is closed') {\n\t\t\tconsole.info('[Redis] Client was already closed')\n\t\t\treturn // Continue execution if client is already closed\n\t\t}\n\t\t// For any other errors, log and re-throw\n\t\tconsole.error('[Redis] Error during disconnection')\n\t\tSentry.captureException(e)\n\t\tthrow e\n\t}\n}\n"]}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
interface IInfoUtente {
|
|
2
|
+
_id: string;
|
|
3
|
+
personalData: {
|
|
4
|
+
name: string;
|
|
5
|
+
surname: string;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export declare class SocketLabsLib {
|
|
9
|
+
private StringObj;
|
|
10
|
+
private readonly platformName;
|
|
11
|
+
private readonly linkBase;
|
|
12
|
+
private readonly emailFrom;
|
|
13
|
+
private client;
|
|
14
|
+
private readonly emailHtmlHeader1;
|
|
15
|
+
private readonly emailHtmlHeader2;
|
|
16
|
+
private readonly emailHtmlFooter;
|
|
17
|
+
constructor(htmlHeader1?: string, htmlHeader2?: string, htmlFooter?: string);
|
|
18
|
+
sendEmailVerify(emailTo: string, hash: string, name?: string): Promise<boolean>;
|
|
19
|
+
/**
|
|
20
|
+
* @fixme handle retry
|
|
21
|
+
*
|
|
22
|
+
statusCode: ECONNABORTED
|
|
23
|
+
Error in sending the email
|
|
24
|
+
SendResponse {
|
|
25
|
+
transactionReceipt: null,
|
|
26
|
+
addressResults: null,
|
|
27
|
+
result: {
|
|
28
|
+
name: 'Timeout',
|
|
29
|
+
value: 1,
|
|
30
|
+
message: 'A timeout occurred sending the message'
|
|
31
|
+
},
|
|
32
|
+
responseMessage: 'A timeout occurred sending the message'
|
|
33
|
+
}
|
|
34
|
+
*/
|
|
35
|
+
sendEmailChangeVerify(emailTo: string, hash: string, name?: string): Promise<boolean>;
|
|
36
|
+
sendWelcome(emailTo: string): Promise<boolean>;
|
|
37
|
+
/**
|
|
38
|
+
* Send account disabled notification
|
|
39
|
+
* @param emailTo
|
|
40
|
+
*/
|
|
41
|
+
accountDisabled(emailTo: string): Promise<boolean>;
|
|
42
|
+
/**
|
|
43
|
+
* Send account disabled notification
|
|
44
|
+
* @param emailTo
|
|
45
|
+
*/
|
|
46
|
+
accountBanned(emailTo: string): Promise<boolean>;
|
|
47
|
+
/**
|
|
48
|
+
* alertDevTeam
|
|
49
|
+
* @param err
|
|
50
|
+
*/
|
|
51
|
+
alertDevTeam(err: string): Promise<boolean>;
|
|
52
|
+
/**
|
|
53
|
+
*
|
|
54
|
+
* @param emailTo
|
|
55
|
+
* @param times
|
|
56
|
+
*/
|
|
57
|
+
wrongHash(emailTo: string, times: number): Promise<boolean>;
|
|
58
|
+
/*****************
|
|
59
|
+
* Too much verify requests
|
|
60
|
+
* @param emailTo
|
|
61
|
+
* @returns {Promise<string|null>}
|
|
62
|
+
*/
|
|
63
|
+
tooMuchVerifyRequests(emailTo: string): Promise<boolean>;
|
|
64
|
+
/*****************
|
|
65
|
+
* @param emailTo
|
|
66
|
+
* @returns {Promise<string|null>}
|
|
67
|
+
*/
|
|
68
|
+
hashReqTooOld(emailTo: string): Promise<boolean>;
|
|
69
|
+
/*****************
|
|
70
|
+
* @param emailTo
|
|
71
|
+
* @returns {Promise<string|null>}
|
|
72
|
+
*/
|
|
73
|
+
emailAlreadyValid(emailTo: string): Promise<boolean>;
|
|
74
|
+
/**
|
|
75
|
+
* Send subscription email
|
|
76
|
+
* @param emailTo
|
|
77
|
+
* @param otp
|
|
78
|
+
*/
|
|
79
|
+
sendSubscriptionEmail(emailTo: string, otp: string): Promise<boolean>;
|
|
80
|
+
sendConfermaResetPwd(emailTo: string, name?: string): Promise<boolean>;
|
|
81
|
+
sendConfermaResetPwdHash(email: string, name: string, hash: string): Promise<true | null>;
|
|
82
|
+
sendEmailReset(emailTo: string, hash: string, name?: string): Promise<boolean>;
|
|
83
|
+
/**
|
|
84
|
+
* fallback footer
|
|
85
|
+
*/
|
|
86
|
+
htmlFooter(): string;
|
|
87
|
+
/**
|
|
88
|
+
* send OTP
|
|
89
|
+
* @param emailTo
|
|
90
|
+
* @param otp
|
|
91
|
+
*/
|
|
92
|
+
sendOTP(emailTo: string, otp: string): Promise<null>;
|
|
93
|
+
sendEmailPostSegnalato(infoUtente: IInfoUtente, idPost: number | string): Promise<boolean>;
|
|
94
|
+
getHtmlHeader(title: string): string;
|
|
95
|
+
getHtmlFooter(): string;
|
|
96
|
+
private sendTemplate;
|
|
97
|
+
private sendEmail;
|
|
98
|
+
/**
|
|
99
|
+
* fallback header
|
|
100
|
+
* @private
|
|
101
|
+
*/
|
|
102
|
+
private htmlHeader1;
|
|
103
|
+
/**
|
|
104
|
+
* fallback header
|
|
105
|
+
* @private
|
|
106
|
+
*/
|
|
107
|
+
private htmlHeader2;
|
|
108
|
+
private fixName;
|
|
109
|
+
}
|
|
110
|
+
export {};
|
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
import { StringLib } from "../lib/StringLib.mjs";
|
|
2
|
+
import * as Sentry from '@sentry/node';
|
|
3
|
+
import { BasicMessage, SocketLabsClient } from '@socketlabs/email';
|
|
4
|
+
import { throwInternalError } from "../graphQL/throw/throwInternalError.mjs";
|
|
5
|
+
import * as dotenv from 'dotenv';
|
|
6
|
+
dotenv.config();
|
|
7
|
+
export class SocketLabsLib {
|
|
8
|
+
StringObj;
|
|
9
|
+
platformName;
|
|
10
|
+
linkBase;
|
|
11
|
+
emailFrom;
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
+
client;
|
|
14
|
+
emailHtmlHeader1;
|
|
15
|
+
emailHtmlHeader2;
|
|
16
|
+
emailHtmlFooter;
|
|
17
|
+
constructor(htmlHeader1 = '', htmlHeader2 = '', htmlFooter = '') {
|
|
18
|
+
this.client = new SocketLabsClient(
|
|
19
|
+
/* c8 ignore next -- env fallback '0' covered only when SOCKETLABS_SERVER_ID is unset */
|
|
20
|
+
parseInt(process.env.SOCKETLABS_SERVER_ID || '0'), `${process.env.SOCKETLABS_SERVER_APIKEY}`, { requestTimeout: 120, numberOfRetries: 3 });
|
|
21
|
+
this.StringObj = new StringLib();
|
|
22
|
+
this.platformName = `${process.env.PLATFORM_NAME}`;
|
|
23
|
+
this.linkBase = `${process.env.APP_DOMAIN}`;
|
|
24
|
+
this.emailFrom = `${process.env.EMAIL_FROM}`;
|
|
25
|
+
this.emailHtmlHeader1 = htmlHeader1 === '' ? this.htmlHeader1() : htmlHeader1;
|
|
26
|
+
this.emailHtmlHeader2 = htmlHeader2 === '' ? this.htmlHeader2() : htmlHeader2;
|
|
27
|
+
this.emailHtmlFooter = htmlFooter === '' ? this.htmlFooter() : htmlFooter;
|
|
28
|
+
}
|
|
29
|
+
async sendEmailVerify(emailTo, hash, name = '') {
|
|
30
|
+
const subject = `Confirm your email for ${this.platformName}`;
|
|
31
|
+
const encodedEmail = encodeURI(emailTo);
|
|
32
|
+
const nameFixed = this.fixName(name);
|
|
33
|
+
const link = `${this.linkBase}/check/verify-email/${encodedEmail}/${hash}`;
|
|
34
|
+
const linkHtml = this.StringObj.makeLink(link);
|
|
35
|
+
const messageTxt = `Hi${nameFixed}, you or someone else is registering you on ${this.platformName}.
|
|
36
|
+
You can confirm the registration by copying this link ${link} into your browser. The Team`;
|
|
37
|
+
const messageHtml = `Hi${nameFixed},<br>you or someone else is registering you on ${this.platformName}.<br><br>
|
|
38
|
+
You can confirm the registration by visiting this link ${linkHtml}<br><br>
|
|
39
|
+
<br><br>The Team`;
|
|
40
|
+
return await this.sendTemplate(emailTo, subject, messageTxt, messageHtml);
|
|
41
|
+
}
|
|
42
|
+
/*
|
|
43
|
+
async sendEmailPostReported(userInfo, idPost) {
|
|
44
|
+
const subject = 'Post ' + idPost + ' reported'
|
|
45
|
+
|
|
46
|
+
const messageTxt =
|
|
47
|
+
'Hello, post ' +
|
|
48
|
+
idPost +
|
|
49
|
+
' has been reported by ' +
|
|
50
|
+
userInfo.personalData.name +
|
|
51
|
+
' ' +
|
|
52
|
+
userInfo.personalData.surname +
|
|
53
|
+
' (id: ' +
|
|
54
|
+
userInfo._id +
|
|
55
|
+
').'
|
|
56
|
+
|
|
57
|
+
const messageHtml =
|
|
58
|
+
this.getHtmlHeader(subject) +
|
|
59
|
+
'Hello, post ' +
|
|
60
|
+
idPost +
|
|
61
|
+
' has been reported by ' +
|
|
62
|
+
userInfo.personalData.name +
|
|
63
|
+
' ' +
|
|
64
|
+
userInfo.personalData.surname +
|
|
65
|
+
' (id: ' +
|
|
66
|
+
userInfo._id +
|
|
67
|
+
').' +
|
|
68
|
+
this.getHtmlFooter()
|
|
69
|
+
|
|
70
|
+
const message = {
|
|
71
|
+
emailFrom: this.emailFrom,
|
|
72
|
+
emailFromName: this.platformName,
|
|
73
|
+
emailTo: 'dummy@example.com',
|
|
74
|
+
subject,
|
|
75
|
+
textBody: messageTxt,
|
|
76
|
+
htmlBody: messageHtml
|
|
77
|
+
}
|
|
78
|
+
return await this.sendEmail(message)
|
|
79
|
+
}
|
|
80
|
+
*/
|
|
81
|
+
/**
|
|
82
|
+
* @fixme handle retry
|
|
83
|
+
*
|
|
84
|
+
statusCode: ECONNABORTED
|
|
85
|
+
Error in sending the email
|
|
86
|
+
SendResponse {
|
|
87
|
+
transactionReceipt: null,
|
|
88
|
+
addressResults: null,
|
|
89
|
+
result: {
|
|
90
|
+
name: 'Timeout',
|
|
91
|
+
value: 1,
|
|
92
|
+
message: 'A timeout occurred sending the message'
|
|
93
|
+
},
|
|
94
|
+
responseMessage: 'A timeout occurred sending the message'
|
|
95
|
+
}
|
|
96
|
+
*/
|
|
97
|
+
async sendEmailChangeVerify(emailTo, hash, name = '') {
|
|
98
|
+
const encodedEmail = encodeURI(emailTo);
|
|
99
|
+
const subject = `Confirm your email for ${this.platformName}`;
|
|
100
|
+
const nameFixed = this.fixName(name);
|
|
101
|
+
const link = `${this.linkBase}/check/verify-change-email/${encodedEmail}/${hash}`;
|
|
102
|
+
const linkHtml = this.StringObj.makeLink(link);
|
|
103
|
+
const messageTxt = `Hi${nameFixed}, you or someone else has changed the email you sign in with.
|
|
104
|
+
You can confirm by copying this link ${link} into your browser. The Team.`;
|
|
105
|
+
const messageHtml = `Hi${nameFixed},<br>you or someone else has changed the email you sign in with.<br><br>" +
|
|
106
|
+
'You can confirm the registration by visiting this link ${linkHtml}
|
|
107
|
+
<br><br>The Team.`;
|
|
108
|
+
return await this.sendTemplate(emailTo, subject, messageTxt, messageHtml);
|
|
109
|
+
}
|
|
110
|
+
async sendWelcome(emailTo) {
|
|
111
|
+
const subject = `Welcome to ${this.platformName}`;
|
|
112
|
+
const linkHtml = this.StringObj.makeLink(this.linkBase, this.platformName);
|
|
113
|
+
const messageTxt = `Welcome to ${this.platformName}`;
|
|
114
|
+
const messageHtml = `Welcome to ${linkHtml}`;
|
|
115
|
+
return await this.sendTemplate(emailTo, subject, messageTxt, messageHtml);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Send account disabled notification
|
|
119
|
+
* @param emailTo
|
|
120
|
+
*/
|
|
121
|
+
async accountDisabled(emailTo) {
|
|
122
|
+
const subject = 'Your account has been disabled';
|
|
123
|
+
const textBody = 'Hi, we are sorry but your account has been disabled. Contact us for more information.';
|
|
124
|
+
const htmlBody = `<p>${textBody}</p>`;
|
|
125
|
+
return await this.sendTemplate(emailTo, subject, textBody, htmlBody);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Send account disabled notification
|
|
129
|
+
* @param emailTo
|
|
130
|
+
*/
|
|
131
|
+
async accountBanned(emailTo) {
|
|
132
|
+
const subject = 'Your account has been banned';
|
|
133
|
+
const textBody = 'Hi, we are sorry but your account has been banned. Contact us for more information.';
|
|
134
|
+
const htmlBody = `<p>${textBody}</p>`;
|
|
135
|
+
return await this.sendTemplate(emailTo, subject, textBody, htmlBody);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* alertDevTeam
|
|
139
|
+
* @param err
|
|
140
|
+
*/
|
|
141
|
+
async alertDevTeam(err) {
|
|
142
|
+
const textBody = 'error 500 ' + err;
|
|
143
|
+
const htmlBody = '<p>error 500 <br><br>' + err + '</p>';
|
|
144
|
+
return await this.sendTemplate(`${process.env.DEV_TEAM_EMAIL}`, `${this.platformName} error 500`, textBody, htmlBody);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
*
|
|
148
|
+
* @param emailTo
|
|
149
|
+
* @param times
|
|
150
|
+
*/
|
|
151
|
+
async wrongHash(emailTo, times) {
|
|
152
|
+
if (times > 5)
|
|
153
|
+
throwInternalError();
|
|
154
|
+
const remainingTimes = 5 - times;
|
|
155
|
+
const subject = 'Wrong activation link';
|
|
156
|
+
const textBody = `Hi, you or someone else is trying to verify your email with a wrong link. You have ${remainingTimes} attempts remaining.`;
|
|
157
|
+
const htmlBody = `<p>${textBody}</p>`;
|
|
158
|
+
return await this.sendTemplate(emailTo, subject, textBody, htmlBody);
|
|
159
|
+
}
|
|
160
|
+
/*****************
|
|
161
|
+
* Too much verify requests
|
|
162
|
+
* @param emailTo
|
|
163
|
+
* @returns {Promise<string|null>}
|
|
164
|
+
*/
|
|
165
|
+
async tooMuchVerifyRequests(emailTo) {
|
|
166
|
+
const subject = 'Too many attempts to verify your email';
|
|
167
|
+
const textBody = 'Hi, you have made more than 5 attempts to verify your email. You need to repeat the registration request.';
|
|
168
|
+
const htmlBody = '<p>Hi, you have made 5 or more attempts to verify your email. You need to repeat the registration request.</p>';
|
|
169
|
+
return await this.sendTemplate(emailTo, subject, textBody, htmlBody);
|
|
170
|
+
}
|
|
171
|
+
/*****************
|
|
172
|
+
* @param emailTo
|
|
173
|
+
* @returns {Promise<string|null>}
|
|
174
|
+
*/
|
|
175
|
+
async hashReqTooOld(emailTo) {
|
|
176
|
+
const subject = 'Activation link expired';
|
|
177
|
+
const textBody = 'Hi, the activation link you are trying to use is older than 3 days and has expired. You need to repeat the registration request.';
|
|
178
|
+
const htmlBody = '<p>Hi, the activation link you are trying to use is older than 3 days and has expired. You need to repeat the registration request.</p>';
|
|
179
|
+
return await this.sendTemplate(emailTo, subject, textBody, htmlBody);
|
|
180
|
+
}
|
|
181
|
+
/*****************
|
|
182
|
+
* @param emailTo
|
|
183
|
+
* @returns {Promise<string|null>}
|
|
184
|
+
*/
|
|
185
|
+
async emailAlreadyValid(emailTo) {
|
|
186
|
+
const subject = 'Account already valid';
|
|
187
|
+
const textBody = 'Hi, your account is already valid, you can log in.';
|
|
188
|
+
const htmlBody = `<p>${textBody}</p>`;
|
|
189
|
+
return await this.sendTemplate(emailTo, subject, textBody, htmlBody);
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Send subscription email
|
|
193
|
+
* @param emailTo
|
|
194
|
+
* @param otp
|
|
195
|
+
*/
|
|
196
|
+
async sendSubscriptionEmail(emailTo, otp) {
|
|
197
|
+
const subject = `Activate your ${this.platformName} account}`;
|
|
198
|
+
const url = `${this.linkBase}'/x/emailVerify`;
|
|
199
|
+
const urlHtml = this.StringObj.makeLink(url);
|
|
200
|
+
const linkHomeHtml = this.StringObj.makeLink(this.linkBase, this.platformName);
|
|
201
|
+
const textBody = `To confirm your subscription on ${this.platformName}, open the following link in your browser
|
|
202
|
+
${url} and enter the following activation code: ${otp}`;
|
|
203
|
+
const htmlBody = `<p>To confirm your subscription on ${linkHomeHtml}, open the following link in your browser
|
|
204
|
+
${urlHtml} and enter the following activation code: ${otp}</p>`;
|
|
205
|
+
return await this.sendTemplate(emailTo, subject, textBody, htmlBody);
|
|
206
|
+
}
|
|
207
|
+
async sendConfermaResetPwd(emailTo, name = '') {
|
|
208
|
+
const subject = `Password reset for ${this.platformName}`;
|
|
209
|
+
const link = this.linkBase;
|
|
210
|
+
const linkHtml = this.StringObj.makeLink(link, this.platformName);
|
|
211
|
+
const nameFixed = this.fixName(name);
|
|
212
|
+
const textBody = `Hi${nameFixed}, you have confirmed your new password. You can now log in at: ${link}. The Team.`;
|
|
213
|
+
const htmlBody = `Hi${nameFixed},<br>you have confirmed your new password.<br><br>You can now log in at:<br>${linkHtml}<br><br>The Team.`;
|
|
214
|
+
return await this.sendTemplate(emailTo, subject, textBody, htmlBody);
|
|
215
|
+
}
|
|
216
|
+
async sendConfermaResetPwdHash(email, name, hash) {
|
|
217
|
+
const encodedEmail = encodeURI(email);
|
|
218
|
+
const subject = 'Password reset for YourCompany';
|
|
219
|
+
const linkReset = this.linkBase + '/index.php?q=reset&hash=' + hash + '&email=' + encodedEmail;
|
|
220
|
+
const textBody = 'Hi ' + name + ', you have confirmed your new password. You can now log in at: ' + this.linkBase + ' . ';
|
|
221
|
+
const htmlBody = this.getHtmlHeader(subject) +
|
|
222
|
+
'Hi ' +
|
|
223
|
+
name +
|
|
224
|
+
',<br>you have confirmed your new password.<br><br>You can now log in at:<br> ' +
|
|
225
|
+
this.StringObj.makeLink(linkReset) +
|
|
226
|
+
'<br><br>The Team' +
|
|
227
|
+
this.getHtmlFooter();
|
|
228
|
+
let ret;
|
|
229
|
+
try {
|
|
230
|
+
ret = await this.sendTemplate(email, 'Password change confirmation for YourCompany', textBody, htmlBody);
|
|
231
|
+
}
|
|
232
|
+
catch (e) {
|
|
233
|
+
Sentry.captureException(e);
|
|
234
|
+
ret = null;
|
|
235
|
+
}
|
|
236
|
+
return ret ? ret : null; // if the send succeeds, returns the hash, otherwise null
|
|
237
|
+
}
|
|
238
|
+
async sendEmailReset(emailTo, hash, name = '') {
|
|
239
|
+
const subject = `Password reset for ${this.platformName}`;
|
|
240
|
+
const encodedEmail = encodeURI(emailTo);
|
|
241
|
+
const link = `${this.linkBase}/x/reset/${encodedEmail}/${hash}`;
|
|
242
|
+
const linkHtml = this.StringObj.makeLink(link);
|
|
243
|
+
const nameFixed = this.fixName(name);
|
|
244
|
+
const textBody = `Hi${nameFixed}, you or someone else has requested a password reset. You can change your login password
|
|
245
|
+
by copying this link ${link} into your browser. The Team.`;
|
|
246
|
+
const htmlBody = `Hi${nameFixed},<br>you or someone else has requested a password reset.<br><br>
|
|
247
|
+
You can change your password by clicking the link:<br>${linkHtml}
|
|
248
|
+
<br><br>The Team.`;
|
|
249
|
+
return await this.sendTemplate(emailTo, subject, textBody, htmlBody);
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* fallback footer
|
|
253
|
+
*/
|
|
254
|
+
htmlFooter() {
|
|
255
|
+
return '</p></td>' + ' </tr>' + ' </table>' + '</body>';
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* send OTP
|
|
259
|
+
* @param emailTo
|
|
260
|
+
* @param otp
|
|
261
|
+
*/
|
|
262
|
+
async sendOTP(emailTo, otp) {
|
|
263
|
+
let textBody = 'To confirm your subscription on YourCompany, enter the following OTP code: ' + otp;
|
|
264
|
+
let htmlBody = '<p>To confirm your subscription on YourCompany, enter the following OTP code: ' + otp + '</p>';
|
|
265
|
+
let ret;
|
|
266
|
+
try {
|
|
267
|
+
await this.sendTemplate(emailTo, 'OTP code for YourCompany', textBody, htmlBody);
|
|
268
|
+
ret = null;
|
|
269
|
+
}
|
|
270
|
+
catch (e) {
|
|
271
|
+
Sentry.captureException(e);
|
|
272
|
+
ret = null;
|
|
273
|
+
}
|
|
274
|
+
/* c8 ignore next -- ret is always null in this function */
|
|
275
|
+
return ret ? ret : null; // if the send succeeds, returns the hash, otherwise null
|
|
276
|
+
}
|
|
277
|
+
async sendEmailPostSegnalato(infoUtente, idPost) {
|
|
278
|
+
const subject = 'Post ' + idPost + ' reported';
|
|
279
|
+
const messageTxt = 'Hi, post ' +
|
|
280
|
+
idPost +
|
|
281
|
+
' has been reported by ' +
|
|
282
|
+
infoUtente.personalData.name +
|
|
283
|
+
' ' +
|
|
284
|
+
infoUtente.personalData.surname +
|
|
285
|
+
' (id: ' +
|
|
286
|
+
infoUtente._id +
|
|
287
|
+
').';
|
|
288
|
+
const messageHtml = this.getHtmlHeader(subject) +
|
|
289
|
+
'Hi, post ' +
|
|
290
|
+
idPost +
|
|
291
|
+
' has been reported by ' +
|
|
292
|
+
infoUtente.personalData.name +
|
|
293
|
+
' ' +
|
|
294
|
+
infoUtente.personalData.surname +
|
|
295
|
+
' (id: ' +
|
|
296
|
+
infoUtente._id +
|
|
297
|
+
').' +
|
|
298
|
+
this.getHtmlFooter();
|
|
299
|
+
return await this.sendTemplate('dummy@example.com', subject, messageTxt, messageHtml);
|
|
300
|
+
}
|
|
301
|
+
getHtmlHeader(title) {
|
|
302
|
+
return ('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' +
|
|
303
|
+
'<html xmlns="http://www.w3.org/1999/xhtml">' +
|
|
304
|
+
' <head>' +
|
|
305
|
+
' <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />' +
|
|
306
|
+
' <title>' +
|
|
307
|
+
title +
|
|
308
|
+
'</title>' +
|
|
309
|
+
' <meta name="viewport" content="width=device-width, initial-scale=1.0"/>' +
|
|
310
|
+
'</head>' +
|
|
311
|
+
'</html>' +
|
|
312
|
+
'<body style="margin: 0; padding: 0;">' +
|
|
313
|
+
' <table align="center" border="0" cellpadding="0" cellspacing="0" width="600">' +
|
|
314
|
+
' <tr>' +
|
|
315
|
+
' <td bgcolor="#ffffff" style="padding: 40px 30px 40px 30px;"><p style="color: #000000; font-family: Verdana, sans-serif; font-size: 12pt;">');
|
|
316
|
+
}
|
|
317
|
+
getHtmlFooter() {
|
|
318
|
+
return '</p></td>' + ' </tr>' + ' </table>' + '</body>';
|
|
319
|
+
}
|
|
320
|
+
async sendTemplate(emailTo, subject, textBody, htmlBody) {
|
|
321
|
+
return await this.sendEmail({
|
|
322
|
+
emailFrom: this.emailFrom,
|
|
323
|
+
emailFromName: this.platformName,
|
|
324
|
+
emailTo,
|
|
325
|
+
subject,
|
|
326
|
+
textBody,
|
|
327
|
+
htmlBody
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
async sendEmail(args) {
|
|
331
|
+
const { emailFrom, emailFromName, emailTo, subject, textBody, htmlBody } = args;
|
|
332
|
+
const basicMessage = new BasicMessage();
|
|
333
|
+
basicMessage.setFromAddress(emailFrom, emailFromName);
|
|
334
|
+
basicMessage.setSubject(subject);
|
|
335
|
+
basicMessage.setTextBody(textBody);
|
|
336
|
+
basicMessage.setHtmlBody(this.emailHtmlHeader1 + subject + this.emailHtmlHeader2 + htmlBody + this.emailHtmlFooter);
|
|
337
|
+
basicMessage.setTo(emailTo);
|
|
338
|
+
return this.client.send(basicMessage).then(() => {
|
|
339
|
+
//Handle successful API call
|
|
340
|
+
// console.debug('[sendEmail] Email sent correctly')
|
|
341
|
+
//console. // console.debug('[sendEmail] Email sent correctly')(res);
|
|
342
|
+
return true;
|
|
343
|
+
}, (e) => {
|
|
344
|
+
Sentry.captureException(e, {
|
|
345
|
+
extra: { detail: 'Error in sending the email' }
|
|
346
|
+
});
|
|
347
|
+
return false;
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* fallback header
|
|
352
|
+
* @private
|
|
353
|
+
*/
|
|
354
|
+
htmlHeader1() {
|
|
355
|
+
return ('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' +
|
|
356
|
+
'<html lang="it" xmlns="http://www.w3.org/1999/xhtml">' +
|
|
357
|
+
' <head>' +
|
|
358
|
+
' <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />' +
|
|
359
|
+
' <title>');
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* fallback header
|
|
363
|
+
* @private
|
|
364
|
+
*/
|
|
365
|
+
htmlHeader2() {
|
|
366
|
+
return ('</title>' +
|
|
367
|
+
' <meta name="viewport" content="width=device-width, initial-scale=1.0"/>' +
|
|
368
|
+
'</head>' +
|
|
369
|
+
'</html>' +
|
|
370
|
+
'<body style="margin: 0; padding: 0;">' +
|
|
371
|
+
' <table align="center" border="0" cellpadding="0" cellspacing="0" width="600">' +
|
|
372
|
+
' <tr>' +
|
|
373
|
+
' <td bgcolor="#ffffff" style="padding: 40px 30px 40px 30px;"><p style="color: #000000; font-family: Verdana, sans-serif; font-size: 12pt;">');
|
|
374
|
+
}
|
|
375
|
+
fixName(name) {
|
|
376
|
+
return name !== '' ? ` ${name}` : '';
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
//# sourceMappingURL=SocketLabsLib.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SocketLabsLib.mjs","sourceRoot":"","sources":["../../src/email/SocketLabsLib.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,6BAA0B;AAC9C,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,kBAAkB,EAAE,gDAAqC;AAClE,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAEhC,MAAM,CAAC,MAAM,EAAE,CAAA;AAmBf,MAAM,OAAO,aAAa;IACjB,SAAS,CAAW;IACX,YAAY,CAAQ;IACpB,QAAQ,CAAQ;IAChB,SAAS,CAAQ;IAClC,8DAA8D;IACtD,MAAM,CAAK;IACF,gBAAgB,CAAQ;IACxB,gBAAgB,CAAQ;IACxB,eAAe,CAAQ;IAExC,YAAY,cAAsB,EAAE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Y;QAC3B,OAAO,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;IACrC,CAAC;CACD","sourcesContent":["import { StringLib } from '@lib/StringLib.mjs'\nimport * as Sentry from '@sentry/node'\nimport { BasicMessage, SocketLabsClient } from '@socketlabs/email'\nimport { throwInternalError } from '@throw/throwInternalError.mjs'\nimport * as dotenv from 'dotenv'\n\ndotenv.config()\n\ninterface ISendEmail {\n\temailFrom: string\n\temailFromName: string\n\temailTo: string\n\tsubject: string\n\ttextBody: string\n\thtmlBody: string\n}\n\ninterface IInfoUtente {\n\t_id: string\n\tpersonalData: {\n\t\tname: string\n\t\tsurname: string\n\t}\n}\n\nexport class SocketLabsLib {\n\tprivate StringObj: StringLib\n\tprivate readonly platformName: string\n\tprivate readonly linkBase: string\n\tprivate readonly emailFrom: string\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tprivate client: any\n\tprivate readonly emailHtmlHeader1: string\n\tprivate readonly emailHtmlHeader2: string\n\tprivate readonly emailHtmlFooter: string\n\n\tconstructor(htmlHeader1: string = '', htmlHeader2: string = '', htmlFooter: string = '') {\n\t\tthis.client = new SocketLabsClient(\n\t\t\t/* c8 ignore next -- env fallback '0' covered only when SOCKETLABS_SERVER_ID is unset */\n\t\t\tparseInt(process.env.SOCKETLABS_SERVER_ID || '0'),\n\t\t\t`${process.env.SOCKETLABS_SERVER_APIKEY}`,\n\t\t\t{ requestTimeout: 120, numberOfRetries: 3 }\n\t\t)\n\t\tthis.StringObj = new StringLib()\n\t\tthis.platformName = `${process.env.PLATFORM_NAME}`\n\t\tthis.linkBase = `${process.env.APP_DOMAIN}`\n\t\tthis.emailFrom = `${process.env.EMAIL_FROM}`\n\n\t\tthis.emailHtmlHeader1 = htmlHeader1 === '' ? this.htmlHeader1() : htmlHeader1\n\t\tthis.emailHtmlHeader2 = htmlHeader2 === '' ? this.htmlHeader2() : htmlHeader2\n\t\tthis.emailHtmlFooter = htmlFooter === '' ? this.htmlFooter() : htmlFooter\n\t}\n\n\tasync sendEmailVerify(emailTo: string, hash: string, name: string = '') {\n\t\tconst subject = `Confirm your email for ${this.platformName}`\n\t\tconst encodedEmail = encodeURI(emailTo)\n\t\tconst nameFixed = this.fixName(name)\n\t\tconst link = `${this.linkBase}/check/verify-email/${encodedEmail}/${hash}`\n\t\tconst linkHtml = this.StringObj.makeLink(link)\n\n\t\tconst messageTxt = `Hi${nameFixed}, you or someone else is registering you on ${this.platformName}.\n You can confirm the registration by copying this link ${link} into your browser. The Team`\n\t\tconst messageHtml = `Hi${nameFixed},<br>you or someone else is registering you on ${this.platformName}.<br><br>\n You can confirm the registration by visiting this link ${linkHtml}<br><br>\n <br><br>The Team`\n\n\t\treturn await this.sendTemplate(emailTo, subject, messageTxt, messageHtml)\n\t}\n\n\t/*\n async sendEmailPostReported(userInfo, idPost) {\n const subject = 'Post ' + idPost + ' reported'\n\n const messageTxt =\n 'Hello, post ' +\n idPost +\n ' has been reported by ' +\n userInfo.personalData.name +\n ' ' +\n userInfo.personalData.surname +\n ' (id: ' +\n userInfo._id +\n ').'\n\n const messageHtml =\n this.getHtmlHeader(subject) +\n 'Hello, post ' +\n idPost +\n ' has been reported by ' +\n userInfo.personalData.name +\n ' ' +\n userInfo.personalData.surname +\n ' (id: ' +\n userInfo._id +\n ').' +\n this.getHtmlFooter()\n\n const message = {\n emailFrom: this.emailFrom,\n emailFromName: this.platformName,\n emailTo: 'dummy@example.com',\n subject,\n textBody: messageTxt,\n htmlBody: messageHtml\n }\n return await this.sendEmail(message)\n }\n*/\n\t/**\n\t * @fixme handle retry\n\t *\nstatusCode: ECONNABORTED\nError in sending the email\nSendResponse {\n transactionReceipt: null,\n addressResults: null,\n result: {\n name: 'Timeout',\n value: 1,\n message: 'A timeout occurred sending the message'\n },\n responseMessage: 'A timeout occurred sending the message'\n}\n\t */\n\n\tasync sendEmailChangeVerify(emailTo: string, hash: string, name: string = '') {\n\t\tconst encodedEmail = encodeURI(emailTo)\n\t\tconst subject = `Confirm your email for ${this.platformName}`\n\t\tconst nameFixed = this.fixName(name)\n\t\tconst link = `${this.linkBase}/check/verify-change-email/${encodedEmail}/${hash}`\n\t\tconst linkHtml = this.StringObj.makeLink(link)\n\n\t\tconst messageTxt = `Hi${nameFixed}, you or someone else has changed the email you sign in with.\n You can confirm by copying this link ${link} into your browser. The Team.`\n\n\t\tconst messageHtml = `Hi${nameFixed},<br>you or someone else has changed the email you sign in with.<br><br>\" +\n 'You can confirm the registration by visiting this link ${linkHtml}\n <br><br>The Team.`\n\n\t\treturn await this.sendTemplate(emailTo, subject, messageTxt, messageHtml)\n\t}\n\n\tasync sendWelcome(emailTo: string) {\n\t\tconst subject = `Welcome to ${this.platformName}`\n\t\tconst linkHtml = this.StringObj.makeLink(this.linkBase, this.platformName)\n\t\tconst messageTxt = `Welcome to ${this.platformName}`\n\t\tconst messageHtml = `Welcome to ${linkHtml}`\n\n\t\treturn await this.sendTemplate(emailTo, subject, messageTxt, messageHtml)\n\t}\n\n\t/**\n\t * Send account disabled notification\n\t * @param emailTo\n\t */\n\tasync accountDisabled(emailTo: string) {\n\t\tconst subject = 'Your account has been disabled'\n\t\tconst textBody = 'Hi, we are sorry but your account has been disabled. Contact us for more information.'\n\t\tconst htmlBody = `<p>${textBody}</p>`\n\n\t\treturn await this.sendTemplate(emailTo, subject, textBody, htmlBody)\n\t}\n\n\t/**\n\t * Send account disabled notification\n\t * @param emailTo\n\t */\n\tasync accountBanned(emailTo: string) {\n\t\tconst subject = 'Your account has been banned'\n\t\tconst textBody = 'Hi, we are sorry but your account has been banned. Contact us for more information.'\n\t\tconst htmlBody = `<p>${textBody}</p>`\n\n\t\treturn await this.sendTemplate(emailTo, subject, textBody, htmlBody)\n\t}\n\n\t/**\n\t * alertDevTeam\n\t * @param err\n\t */\n\tasync alertDevTeam(err: string) {\n\t\tconst textBody = 'error 500 ' + err\n\t\tconst htmlBody = '<p>error 500 <br><br>' + err + '</p>'\n\n\t\treturn await this.sendTemplate(`${process.env.DEV_TEAM_EMAIL}`, `${this.platformName} error 500`, textBody, htmlBody)\n\t}\n\n\t/**\n\t *\n\t * @param emailTo\n\t * @param times\n\t */\n\tasync wrongHash(emailTo: string, times: number) {\n\t\tif (times > 5) throwInternalError()\n\t\tconst remainingTimes = 5 - times\n\n\t\tconst subject = 'Wrong activation link'\n\t\tconst textBody = `Hi, you or someone else is trying to verify your email with a wrong link. You have ${remainingTimes} attempts remaining.`\n\t\tconst htmlBody = `<p>${textBody}</p>`\n\n\t\treturn await this.sendTemplate(emailTo, subject, textBody, htmlBody)\n\t}\n\n\t/*****************\n\t * Too much verify requests\n\t * @param emailTo\n\t * @returns {Promise<string|null>}\n\t */\n\tasync tooMuchVerifyRequests(emailTo: string) {\n\t\tconst subject = 'Too many attempts to verify your email'\n\t\tconst textBody = 'Hi, you have made more than 5 attempts to verify your email. You need to repeat the registration request.'\n\t\tconst htmlBody =\n\t\t\t'<p>Hi, you have made 5 or more attempts to verify your email. You need to repeat the registration request.</p>'\n\n\t\treturn await this.sendTemplate(emailTo, subject, textBody, htmlBody)\n\t}\n\n\t/*****************\n\t * @param emailTo\n\t * @returns {Promise<string|null>}\n\t */\n\tasync hashReqTooOld(emailTo: string) {\n\t\tconst subject = 'Activation link expired'\n\t\tconst textBody =\n\t\t\t'Hi, the activation link you are trying to use is older than 3 days and has expired. You need to repeat the registration request.'\n\t\tconst htmlBody =\n\t\t\t'<p>Hi, the activation link you are trying to use is older than 3 days and has expired. You need to repeat the registration request.</p>'\n\n\t\treturn await this.sendTemplate(emailTo, subject, textBody, htmlBody)\n\t}\n\n\t/*****************\n\t * @param emailTo\n\t * @returns {Promise<string|null>}\n\t */\n\tasync emailAlreadyValid(emailTo: string) {\n\t\tconst subject = 'Account already valid'\n\t\tconst textBody = 'Hi, your account is already valid, you can log in.'\n\t\tconst htmlBody = `<p>${textBody}</p>`\n\n\t\treturn await this.sendTemplate(emailTo, subject, textBody, htmlBody)\n\t}\n\n\t/**\n\t * Send subscription email\n\t * @param emailTo\n\t * @param otp\n\t */\n\tasync sendSubscriptionEmail(emailTo: string, otp: string) {\n\t\tconst subject = `Activate your ${this.platformName} account}`\n\t\tconst url = `${this.linkBase}'/x/emailVerify`\n\t\tconst urlHtml = this.StringObj.makeLink(url)\n\t\tconst linkHomeHtml = this.StringObj.makeLink(this.linkBase, this.platformName)\n\n\t\tconst textBody = `To confirm your subscription on ${this.platformName}, open the following link in your browser\n ${url} and enter the following activation code: ${otp}`\n\n\t\tconst htmlBody = `<p>To confirm your subscription on ${linkHomeHtml}, open the following link in your browser\n ${urlHtml} and enter the following activation code: ${otp}</p>`\n\n\t\treturn await this.sendTemplate(emailTo, subject, textBody, htmlBody)\n\t}\n\n\tasync sendConfermaResetPwd(emailTo: string, name: string = '') {\n\t\tconst subject = `Password reset for ${this.platformName}`\n\t\tconst link = this.linkBase\n\t\tconst linkHtml = this.StringObj.makeLink(link, this.platformName)\n\t\tconst nameFixed = this.fixName(name)\n\n\t\tconst textBody = `Hi${nameFixed}, you have confirmed your new password. You can now log in at: ${link}. The Team.`\n\t\tconst htmlBody = `Hi${nameFixed},<br>you have confirmed your new password.<br><br>You can now log in at:<br>${linkHtml}<br><br>The Team.`\n\n\t\treturn await this.sendTemplate(emailTo, subject, textBody, htmlBody)\n\t}\n\n\tasync sendConfermaResetPwdHash(email: string, name: string, hash: string) {\n\t\tconst encodedEmail = encodeURI(email)\n\t\tconst subject = 'Password reset for YourCompany'\n\t\tconst linkReset = this.linkBase + '/index.php?q=reset&hash=' + hash + '&email=' + encodedEmail\n\n\t\tconst textBody = 'Hi ' + name + ', you have confirmed your new password. You can now log in at: ' + this.linkBase + ' . '\n\t\tconst htmlBody =\n\t\t\tthis.getHtmlHeader(subject) +\n\t\t\t'Hi ' +\n\t\t\tname +\n\t\t\t',<br>you have confirmed your new password.<br><br>You can now log in at:<br> ' +\n\t\t\tthis.StringObj.makeLink(linkReset) +\n\t\t\t'<br><br>The Team' +\n\t\t\tthis.getHtmlFooter()\n\n\t\tlet ret: boolean | null\n\t\ttry {\n\t\t\tret = await this.sendTemplate(email, 'Password change confirmation for YourCompany', textBody, htmlBody)\n\t\t} catch (e) {\n\t\t\tSentry.captureException(e)\n\t\t\tret = null\n\t\t}\n\t\treturn ret ? ret : null // if the send succeeds, returns the hash, otherwise null\n\t}\n\n\tasync sendEmailReset(emailTo: string, hash: string, name: string = '') {\n\t\tconst subject = `Password reset for ${this.platformName}`\n\t\tconst encodedEmail = encodeURI(emailTo)\n\t\tconst link = `${this.linkBase}/x/reset/${encodedEmail}/${hash}`\n\t\tconst linkHtml = this.StringObj.makeLink(link)\n\t\tconst nameFixed = this.fixName(name)\n\n\t\tconst textBody = `Hi${nameFixed}, you or someone else has requested a password reset. You can change your login password\n by copying this link ${link} into your browser. The Team.`\n\t\tconst htmlBody = `Hi${nameFixed},<br>you or someone else has requested a password reset.<br><br>\n You can change your password by clicking the link:<br>${linkHtml}\n <br><br>The Team.`\n\n\t\treturn await this.sendTemplate(emailTo, subject, textBody, htmlBody)\n\t}\n\n\t/**\n\t * fallback footer\n\t */\n\thtmlFooter() {\n\t\treturn '</p></td>' + ' </tr>' + ' </table>' + '</body>'\n\t}\n\n\t/**\n\t * send OTP\n\t * @param emailTo\n\t * @param otp\n\t */\n\tasync sendOTP(emailTo: string, otp: string) {\n\t\tlet textBody = 'To confirm your subscription on YourCompany, enter the following OTP code: ' + otp\n\t\tlet htmlBody = '<p>To confirm your subscription on YourCompany, enter the following OTP code: ' + otp + '</p>'\n\n\t\tlet ret: string | null\n\t\ttry {\n\t\t\tawait this.sendTemplate(emailTo, 'OTP code for YourCompany', textBody, htmlBody)\n\t\t\tret = null\n\t\t} catch (e) {\n\t\t\tSentry.captureException(e)\n\t\t\tret = null\n\t\t}\n\t\t/* c8 ignore next -- ret is always null in this function */\n\t\treturn ret ? ret : null // if the send succeeds, returns the hash, otherwise null\n\t}\n\n\tasync sendEmailPostSegnalato(infoUtente: IInfoUtente, idPost: number | string) {\n\t\tconst subject = 'Post ' + idPost + ' reported'\n\n\t\tconst messageTxt =\n\t\t\t'Hi, post ' +\n\t\t\tidPost +\n\t\t\t' has been reported by ' +\n\t\t\tinfoUtente.personalData.name +\n\t\t\t' ' +\n\t\t\tinfoUtente.personalData.surname +\n\t\t\t' (id: ' +\n\t\t\tinfoUtente._id +\n\t\t\t').'\n\n\t\tconst messageHtml =\n\t\t\tthis.getHtmlHeader(subject) +\n\t\t\t'Hi, post ' +\n\t\t\tidPost +\n\t\t\t' has been reported by ' +\n\t\t\tinfoUtente.personalData.name +\n\t\t\t' ' +\n\t\t\tinfoUtente.personalData.surname +\n\t\t\t' (id: ' +\n\t\t\tinfoUtente._id +\n\t\t\t').' +\n\t\t\tthis.getHtmlFooter()\n\n\t\treturn await this.sendTemplate('dummy@example.com', subject, messageTxt, messageHtml)\n\t}\n\n\tgetHtmlHeader(title: string) {\n\t\treturn (\n\t\t\t'<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">' +\n\t\t\t'<html xmlns=\"http://www.w3.org/1999/xhtml\">' +\n\t\t\t' <head>' +\n\t\t\t' <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />' +\n\t\t\t' <title>' +\n\t\t\ttitle +\n\t\t\t'</title>' +\n\t\t\t' <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"/>' +\n\t\t\t'</head>' +\n\t\t\t'</html>' +\n\t\t\t'<body style=\"margin: 0; padding: 0;\">' +\n\t\t\t' <table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"600\">' +\n\t\t\t' <tr>' +\n\t\t\t' <td bgcolor=\"#ffffff\" style=\"padding: 40px 30px 40px 30px;\"><p style=\"color: #000000; font-family: Verdana, sans-serif; font-size: 12pt;\">'\n\t\t)\n\t}\n\n\tgetHtmlFooter() {\n\t\treturn '</p></td>' + ' </tr>' + ' </table>' + '</body>'\n\t}\n\n\tprivate async sendTemplate(emailTo: string, subject: string, textBody: string, htmlBody: string): Promise<boolean> {\n\t\treturn await this.sendEmail({\n\t\t\temailFrom: this.emailFrom,\n\t\t\temailFromName: this.platformName,\n\t\t\temailTo,\n\t\t\tsubject,\n\t\t\ttextBody,\n\t\t\thtmlBody\n\t\t})\n\t}\n\n\tprivate async sendEmail(args: ISendEmail): Promise<boolean> {\n\t\tconst { emailFrom, emailFromName, emailTo, subject, textBody, htmlBody } = args\n\t\tconst basicMessage = new BasicMessage()\n\t\tbasicMessage.setFromAddress(emailFrom, emailFromName)\n\t\tbasicMessage.setSubject(subject)\n\t\tbasicMessage.setTextBody(textBody)\n\t\tbasicMessage.setHtmlBody(this.emailHtmlHeader1 + subject + this.emailHtmlHeader2 + htmlBody + this.emailHtmlFooter)\n\t\tbasicMessage.setTo(emailTo)\n\n\t\treturn this.client.send(basicMessage).then(\n\t\t\t() => {\n\t\t\t\t//Handle successful API call\n\t\t\t\t// console.debug('[sendEmail] Email sent correctly')\n\t\t\t\t//console.\t\t\t\t// console.debug('[sendEmail] Email sent correctly')(res);\n\t\t\t\treturn true\n\t\t\t},\n\t\t\t(e: Error) => {\n\t\t\t\tSentry.captureException(e, {\n\t\t\t\t\textra: { detail: 'Error in sending the email' }\n\t\t\t\t})\n\t\t\t\treturn false\n\t\t\t}\n\t\t)\n\t}\n\n\t/**\n\t * fallback header\n\t * @private\n\t */\n\tprivate htmlHeader1() {\n\t\treturn (\n\t\t\t'<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">' +\n\t\t\t'<html lang=\"it\" xmlns=\"http://www.w3.org/1999/xhtml\">' +\n\t\t\t' <head>' +\n\t\t\t' <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />' +\n\t\t\t' <title>'\n\t\t)\n\t}\n\n\t/**\n\t * fallback header\n\t * @private\n\t */\n\tprivate htmlHeader2() {\n\t\treturn (\n\t\t\t'</title>' +\n\t\t\t' <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"/>' +\n\t\t\t'</head>' +\n\t\t\t'</html>' +\n\t\t\t'<body style=\"margin: 0; padding: 0;\">' +\n\t\t\t' <table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"600\">' +\n\t\t\t' <tr>' +\n\t\t\t' <td bgcolor=\"#ffffff\" style=\"padding: 40px 30px 40px 30px;\"><p style=\"color: #000000; font-family: Verdana, sans-serif; font-size: 12pt;\">'\n\t\t)\n\t}\n\n\tprivate fixName(name: string) {\n\t\treturn name !== '' ? ` ${name}` : ''\n\t}\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IUploadTemp.mjs","sourceRoot":"","sources":["../../src/files/IUploadTemp.mts"],"names":[],"mappings":"","sourcesContent":["export interface IUploadTemp {\n\ttempFile: string\n\text: string\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// const Sightengine = require('sightengine')('your-api-user', 'your-api-secret');
|
|
2
|
+
export {};
|
|
3
|
+
/*
|
|
4
|
+
// https://sightengine.com/ but there are other services too
|
|
5
|
+
export async function checkForNSFW(imageUrl: string) {
|
|
6
|
+
try {
|
|
7
|
+
const result = await Sightengine.check(['nudity', 'wad']).set_url(imageUrl)
|
|
8
|
+
|
|
9
|
+
if (result.nudity.safe < 0.9) {
|
|
10
|
+
console.debug('NSFW content detected in the image')
|
|
11
|
+
return false
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
console.debug('No NSFW content detected in the image')
|
|
15
|
+
return true
|
|
16
|
+
} catch (err) {
|
|
17
|
+
console.error('Error during content moderation:', err)
|
|
18
|
+
return false
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
*/
|
|
22
|
+
//# sourceMappingURL=checkForNSFW.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkForNSFW.mjs","sourceRoot":"","sources":["../../src/files/checkForNSFW.mts"],"names":[],"mappings":"AAAA,kFAAkF;;AAElF;;;;;;;;;;;;;;;;;;EAkBE","sourcesContent":["// const Sightengine = require('sightengine')('your-api-user', 'your-api-secret');\n\n/*\n// https://sightengine.com/ but there are other services too\nexport async function checkForNSFW(imageUrl: string) {\n\ttry {\n const result = await Sightengine.check(['nudity', 'wad']).set_url(imageUrl)\n\n if (result.nudity.safe < 0.9) {\n console.debug('NSFW content detected in the image')\n return false\n }\n\n console.debug('No NSFW content detected in the image')\n return true\n } catch (err) {\n console.error('Error during content moderation:', err)\n return false\n }\n}\n*/\n"]}
|