@axiumine/koa-utils 5.7.0 → 5.7.2

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.
Files changed (192) hide show
  1. package/README.md +23 -4
  2. package/package.json +60 -18
  3. package/dist/dataSources/MariaDB.mjs.map +0 -1
  4. package/dist/dataSources/MongoDB.mjs.map +0 -1
  5. package/dist/dataSources/PostgreSQL.mjs.map +0 -1
  6. package/dist/dataSources/Redis.mjs.map +0 -1
  7. package/dist/email/SocketLabsLib.mjs.map +0 -1
  8. package/dist/files/IUploadTemp.mjs.map +0 -1
  9. package/dist/files/checkForNSFW.mjs.map +0 -1
  10. package/dist/files/fileConst.mjs.map +0 -1
  11. package/dist/files/moveFileStaticDomain.mjs.map +0 -1
  12. package/dist/files/moveImageFile.mjs.map +0 -1
  13. package/dist/files/moveTempFile.mjs.map +0 -1
  14. package/dist/files/reEncodeToJpeg.mjs.map +0 -1
  15. package/dist/files/reEncodeToPng.mjs.map +0 -1
  16. package/dist/files/reEncodeToWebp.mjs.map +0 -1
  17. package/dist/files/scanVirus.mjs.map +0 -1
  18. package/dist/files/storeUploadAsTemp.mjs.map +0 -1
  19. package/dist/files/uploadTempImage.mjs.map +0 -1
  20. package/dist/files/uploadTempPdf.mjs.map +0 -1
  21. package/dist/files/validateExtension.mjs.map +0 -1
  22. package/dist/files/validateJpgPngExtension.mjs.map +0 -1
  23. package/dist/files/validateMimeType.mjs.map +0 -1
  24. package/dist/files/validateMimeTypeImages.mjs.map +0 -1
  25. package/dist/files/validateMimeTypePdf.mjs.map +0 -1
  26. package/dist/files/validatePdfExtension.mjs.map +0 -1
  27. package/dist/graphQL/models/MongoDB/UserBase.mjs.map +0 -1
  28. package/dist/graphQL/models/MongoDB/log/DevStatsGraphQLCalls.mjs.map +0 -1
  29. package/dist/graphQL/models/MongoDB/log/LogGlobalError.mjs.map +0 -1
  30. package/dist/graphQL/models/MongoDB/log/LogStatsGraphql.mjs.map +0 -1
  31. package/dist/graphQL/models/MongoDB/log/LogThrow.mjs.map +0 -1
  32. package/dist/graphQL/schema/GraphQLInput/GraphQLInputLogin.mjs.map +0 -1
  33. package/dist/graphQL/schema/context/IContextAuthenticatedResource.mjs.map +0 -1
  34. package/dist/graphQL/schema/context/IContextKoaErrorHandler.mjs.map +0 -1
  35. package/dist/graphQL/schema/context/IContextLogin.mjs.map +0 -1
  36. package/dist/graphQL/schema/context/IContextLogout.mjs.map +0 -1
  37. package/dist/graphQL/schema/context/IContextRefresh.mjs.map +0 -1
  38. package/dist/graphQL/schema/context/TCommonHeaders.mjs.map +0 -1
  39. package/dist/graphQL/schema/interfaces/IFindAndUpdate.mjs.map +0 -1
  40. package/dist/graphQL/schema/mutations/emailChangeHashVerify.mjs.map +0 -1
  41. package/dist/graphQL/schema/mutations/login4Ever.mjs.map +0 -1
  42. package/dist/graphQL/schema/mutations/loginAdmin.mjs.map +0 -1
  43. package/dist/graphQL/schema/mutations/loginRememberme.mjs.map +0 -1
  44. package/dist/graphQL/schema/mutations/logout.mjs.map +0 -1
  45. package/dist/graphQL/schema/mutations/refresh.mjs.map +0 -1
  46. package/dist/graphQL/schema/mutations/resetPwd.mjs.map +0 -1
  47. package/dist/graphQL/schema/mutations/signUp.mjs.map +0 -1
  48. package/dist/graphQL/schema/mutations/updatePassword.mjs.map +0 -1
  49. package/dist/graphQL/schema/types/DeleteType.mjs.map +0 -1
  50. package/dist/graphQL/schema/types/DoneType.mjs.map +0 -1
  51. package/dist/graphQL/schema/types/FindOneAndUpdateType.mjs.map +0 -1
  52. package/dist/graphQL/schema/types/LoginAppType.mjs.map +0 -1
  53. package/dist/graphQL/schema/types/LoginType.mjs.map +0 -1
  54. package/dist/graphQL/schema/types/MidNameType.mjs.map +0 -1
  55. package/dist/graphQL/schema/types/OnlyIdType.mjs.map +0 -1
  56. package/dist/graphQL/schema/types/RefreshType.mjs.map +0 -1
  57. package/dist/graphQL/schema/types/RetStatusMexType.mjs.map +0 -1
  58. package/dist/graphQL/schema/types/RetStatusType.mjs.map +0 -1
  59. package/dist/graphQL/schema/types/SaveType.mjs.map +0 -1
  60. package/dist/graphQL/schema/types/SidNameType.mjs.map +0 -1
  61. package/dist/graphQL/schema/types/SidNomeType.mjs.map +0 -1
  62. package/dist/graphQL/schema/types/UpdateResultType.mjs.map +0 -1
  63. package/dist/graphQL/status.mjs.map +0 -1
  64. package/dist/graphQL/throw/throwAccessTokenExpiredOrDeleted.mjs.map +0 -1
  65. package/dist/graphQL/throw/throwAccessTokenRequired.mjs.map +0 -1
  66. package/dist/graphQL/throw/throwAlreadyDone.mjs.map +0 -1
  67. package/dist/graphQL/throw/throwAlreadyTakenError.mjs.map +0 -1
  68. package/dist/graphQL/throw/throwConflictError.mjs.map +0 -1
  69. package/dist/graphQL/throw/throwErrorWrongUserInput.mjs.map +0 -1
  70. package/dist/graphQL/throw/throwForbiddenError.mjs.map +0 -1
  71. package/dist/graphQL/throw/throwGoneError.mjs.map +0 -1
  72. package/dist/graphQL/throw/throwGraphQLError.mjs.map +0 -1
  73. package/dist/graphQL/throw/throwInternalError.mjs.map +0 -1
  74. package/dist/graphQL/throw/throwMethodNotAllowedError.mjs.map +0 -1
  75. package/dist/graphQL/throw/throwMissingMalformedInvalidToken.mjs.map +0 -1
  76. package/dist/graphQL/throw/throwNotAcceptableError.mjs.map +0 -1
  77. package/dist/graphQL/throw/throwNotFoundError.mjs.map +0 -1
  78. package/dist/graphQL/throw/throwNotImplementedError.mjs.map +0 -1
  79. package/dist/graphQL/throw/throwPaymentRequiredError.mjs.map +0 -1
  80. package/dist/graphQL/throw/throwPreconditionFailedNoAuthCookie.mjs.map +0 -1
  81. package/dist/graphQL/throw/throwPreconditionFailedNoAuthHeader.mjs.map +0 -1
  82. package/dist/graphQL/throw/throwRefreshTokenExpiredOrDeleted.mjs.map +0 -1
  83. package/dist/graphQL/throw/throwRefreshTokenRequired.mjs.map +0 -1
  84. package/dist/graphQL/throw/throwRefreshTokenSignatureRequired.mjs.map +0 -1
  85. package/dist/graphQL/throw/throwTooManyRequestsError.mjs.map +0 -1
  86. package/dist/graphQL/throw/throwUnauthorizedError.mjs.map +0 -1
  87. package/dist/graphQL/throw/throwUnprocessableContentError.mjs.map +0 -1
  88. package/dist/graphQL/throw/throwUnsupportedMediaTypeError.mjs.map +0 -1
  89. package/dist/koa/IFileUpload.mjs.map +0 -1
  90. package/dist/koa/IKoaError.mjs.map +0 -1
  91. package/dist/koa/customFormatErrorFn.mjs.map +0 -1
  92. package/dist/koa/logRequestToDb.mjs.map +0 -1
  93. package/dist/koa/middleware/authenticatedAuthorizationHandler/TCookieRefreshToken.mjs.map +0 -1
  94. package/dist/koa/middleware/authenticatedAuthorizationHandler/index.mjs.map +0 -1
  95. package/dist/koa/middleware/authenticatedAuthorizationHandler/verifySignedRefreshToken.mjs.map +0 -1
  96. package/dist/koa/middleware/authenticatedLogoutHandler/index.mjs.map +0 -1
  97. package/dist/koa/middleware/authenticatedResourceHandler/index.mjs.map +0 -1
  98. package/dist/koa/middleware/debug/index.mjs.map +0 -1
  99. package/dist/koa/router/verifyEmail.mjs.map +0 -1
  100. package/dist/koa/tdwKoaErrorHandler.mjs.map +0 -1
  101. package/dist/lib/ArrayLib.mjs.map +0 -1
  102. package/dist/lib/Constants.mjs.map +0 -1
  103. package/dist/lib/DateLib.mjs.map +0 -1
  104. package/dist/lib/IAuthorizationDisDel.mjs.map +0 -1
  105. package/dist/lib/ICookies.mjs.map +0 -1
  106. package/dist/lib/MariaDB/IMariaDBErr.mjs.map +0 -1
  107. package/dist/lib/MariaDB/MariaDBErrType.mjs.map +0 -1
  108. package/dist/lib/MariaDB/throwSqlErrors.mjs.map +0 -1
  109. package/dist/lib/MongoDB/IMongoDBError.mjs.map +0 -1
  110. package/dist/lib/MongoDB/IOnboarding.mjs.map +0 -1
  111. package/dist/lib/MongoDB/MongoDBErrType.mjs.map +0 -1
  112. package/dist/lib/MongoDB/throwIfMongoErr.mjs.map +0 -1
  113. package/dist/lib/MongoDB/throwMongoErrors.mjs.map +0 -1
  114. package/dist/lib/NumLib.mjs.map +0 -1
  115. package/dist/lib/PostgreSQL/IPostgresError.mjs.map +0 -1
  116. package/dist/lib/PostgreSQL/IPostgresErrorCodes.mjs.map +0 -1
  117. package/dist/lib/PostgreSQL/makePostgreSqlLogError.mjs.map +0 -1
  118. package/dist/lib/Redis/RedisBoolean.mjs.map +0 -1
  119. package/dist/lib/Redis/buildPrefixedRedisKey.mjs.map +0 -1
  120. package/dist/lib/Redis/fromRedisBooleanValue.mjs.map +0 -1
  121. package/dist/lib/Redis/toRedisBooleanValue.mjs.map +0 -1
  122. package/dist/lib/StringLib.mjs.map +0 -1
  123. package/dist/lib/access/accessPaths.mjs.map +0 -1
  124. package/dist/lib/access/createMailThrottle.mjs.map +0 -1
  125. package/dist/lib/access/createResetPwdFlow.mjs.map +0 -1
  126. package/dist/lib/access/createVerifyEmailFlow.mjs.map +0 -1
  127. package/dist/lib/access/verifyEmailMailer.mjs.map +0 -1
  128. package/dist/lib/checkEmailLen.mjs.map +0 -1
  129. package/dist/lib/checkPwdLen.mjs.map +0 -1
  130. package/dist/lib/db/log/hitStat.mjs.map +0 -1
  131. package/dist/lib/db/log/logGlobalError.mjs.map +0 -1
  132. package/dist/lib/db/log/logGraphql.mjs.map +0 -1
  133. package/dist/lib/db/log/logThrow.mjs.map +0 -1
  134. package/dist/lib/db/login/ILoginSet.mjs.map +0 -1
  135. package/dist/lib/db/login/ILoginUnset.mjs.map +0 -1
  136. package/dist/lib/db/registerNewUser.mjs.map +0 -1
  137. package/dist/lib/db/userExist.mjs.map +0 -1
  138. package/dist/lib/emailHash.mjs.map +0 -1
  139. package/dist/lib/encryptPassword.mjs.map +0 -1
  140. package/dist/lib/hash.mjs.map +0 -1
  141. package/dist/lib/isSafeRedirectTarget.mjs.map +0 -1
  142. package/dist/lib/isSessionBlocked.mjs.map +0 -1
  143. package/dist/lib/isValidUuidV4.mjs.map +0 -1
  144. package/dist/lib/makeOnboardingData.mjs.map +0 -1
  145. package/dist/lib/setLoginCookies.mjs.map +0 -1
  146. package/dist/lib/sleepMs.mjs.map +0 -1
  147. package/dist/lib/throwIfNotValidEnumValue.mjs.map +0 -1
  148. package/dist/lib/tokenOptions.mjs.map +0 -1
  149. package/dist/lib/tokens.mjs.map +0 -1
  150. package/dist/lib/tryCatchRethrow.mjs.map +0 -1
  151. package/dist/private/files/_validateMimeType.mjs.map +0 -1
  152. package/dist/private/files/assertNoTraversal.mjs.map +0 -1
  153. package/dist/private/files/reEncode.mjs.map +0 -1
  154. package/dist/private/graphQL/Consts.mjs.map +0 -1
  155. package/dist/private/graphQL/models/MongoDB/private/UserAdminKoaUtils.mjs.map +0 -1
  156. package/dist/private/graphQL/schema/context/IContextLog.mjs.map +0 -1
  157. package/dist/private/graphQL/schema/context/IContextVerifyEmail.mjs.map +0 -1
  158. package/dist/private/graphQL/schema/mutations/_buildLoginStatsUpdate.mjs.map +0 -1
  159. package/dist/private/graphQL/schema/mutations/_finalizeLoginCheck.mjs.map +0 -1
  160. package/dist/private/graphQL/schema/mutations/checkUserAdminLoginAuthorization.mjs.map +0 -1
  161. package/dist/private/graphQL/schema/mutations/checkUserLoginAuthorization.mjs.map +0 -1
  162. package/dist/private/graphQL/schema/mutations/infoUserAdminForLogin.mjs.map +0 -1
  163. package/dist/private/graphQL/schema/mutations/infoUserForLogin.mjs.map +0 -1
  164. package/dist/private/graphQL/schema/mutations/infoUserForLoginSQL.mjs.map +0 -1
  165. package/dist/private/graphQL/schema/mutations/setLastLoginSQL.mjs.map +0 -1
  166. package/dist/private/graphQL/schema/mutations/setRedisLoginSession.mjs.map +0 -1
  167. package/dist/private/graphQL/schema/mutations/updateAdminLoginStats.mjs.map +0 -1
  168. package/dist/private/graphQL/schema/mutations/updateLoginStats4ever.mjs.map +0 -1
  169. package/dist/private/graphQL/schema/mutations/updateLoginStatsRememberme.mjs.map +0 -1
  170. package/dist/private/lib/access/Constants.mjs.map +0 -1
  171. package/dist/private/lib/access/assertVerifyEmailAllowed.mjs.map +0 -1
  172. package/dist/private/lib/access/db/abandonUser.mjs.map +0 -1
  173. package/dist/private/lib/access/db/confirmNewEmail.mjs.map +0 -1
  174. package/dist/private/lib/access/db/deleteUserByEmail.mjs.map +0 -1
  175. package/dist/private/lib/access/db/enableEmailAccess.mjs.map +0 -1
  176. package/dist/private/lib/access/db/getResetPwd.mjs.map +0 -1
  177. package/dist/private/lib/access/db/incReqTimes.mjs.map +0 -1
  178. package/dist/private/lib/access/db/removeResetReq.mjs.map +0 -1
  179. package/dist/private/lib/access/db/saveResetReq.mjs.map +0 -1
  180. package/dist/private/lib/access/db/setEmailHash.mjs.map +0 -1
  181. package/dist/private/lib/access/db/updatePasswordDb.mjs.map +0 -1
  182. package/dist/private/lib/access/db/userData4VerifyEmail.mjs.map +0 -1
  183. package/dist/private/lib/access/handleBadDB.mjs.map +0 -1
  184. package/dist/private/lib/access/handleIfAccountDeleted.mjs.map +0 -1
  185. package/dist/private/lib/access/handleIfAccountDisabled.mjs.map +0 -1
  186. package/dist/private/lib/access/handleIfEmailAlreadyValid.mjs.map +0 -1
  187. package/dist/private/lib/access/handleIfHashBad.mjs.map +0 -1
  188. package/dist/private/lib/access/handleIfMoreThan3DaysPassed.mjs.map +0 -1
  189. package/dist/private/lib/access/handleIfTooMuchRequestsTimes.mjs.map +0 -1
  190. package/dist/private/lib/access/pathTools.mjs.map +0 -1
  191. package/dist/private/lib/makeBodyJson.mjs.map +0 -1
  192. package/dist/private/lib/verifyIntrospectionCode.mjs.map +0 -1
package/README.md CHANGED
@@ -16,14 +16,33 @@ yarn add @axiumine/koa-utils
16
16
  npm install @axiumine/koa-utils
17
17
  ```
18
18
 
19
- All runtime dependencies are declared as **peer dependencies**. Install the ones you use:
19
+ All runtime dependencies are declared as **peer dependencies** — the package ships zero `dependencies`, so the consuming project owns every installed version.
20
+
21
+ Seven are required. The auth core — sign-up, the login variants, refresh, logout, the middleware, the models and the error helpers — reaches all of them:
20
22
 
21
23
  ```bash
22
- yarn add @node-rs/bcrypt @sentry/node @socketlabs/email clamscan dotenv \
23
- file-type fs-extra graphql keygrip mongoose pg redis \
24
- reflect-metadata sequelize sequelize-typescript sharp uuid
24
+ yarn add @node-rs/bcrypt @sentry/node dotenv graphql mongoose redis uuid
25
25
  ```
26
26
 
27
+ The remaining twelve are declared **optional** in `peerDependenciesMeta`. There is no barrel export: each of these is reachable only through subpaths you opt into by importing them, so a project that never imports the subpath never loads the package, and npm/yarn will not warn about the missing peer. Install the row when you import the subpath:
28
+
29
+ | Optional peer | Required by |
30
+ |---|---|
31
+ | `@socketlabs/email` | `email/SocketLabsLib`, `lib/access/createResetPwdFlow`, `lib/access/createVerifyEmailFlow`, `lib/access/verifyEmailMailer`, `koa/router/verifyEmail`, and the `signUp` / `login*` / `resetPwd` / `updatePassword` / `emailChangeHashVerify` mutations |
32
+ | `clamscan` | `files/scanVirus`, `files/uploadTempImage`, `files/uploadTempPdf` |
33
+ | `file-type` | `files/validateMimeType`, `files/validateMimeTypeImages`, `files/validateJpgPngMimeType`, `files/uploadTempImage`, `files/uploadTempPdf` — loaded lazily, at first call |
34
+ | `fs-extra` | the `files/move*` and `files/validate*` helpers, `files/uploadTempImage`, `files/uploadTempPdf` |
35
+ | `keygrip` | `koa/middleware/authenticatedAuthorizationHandler`, `.../verifySignedRefreshToken`, `koa/middleware/authenticatedLogoutHandler` — types only; the `Keygrip` instance is yours to construct and pass in |
36
+ | `koa` | the `koa/middleware/*` handlers, `koa/tdwKoaErrorHandler`, `koa/logRequestToDb` — types only (`Next`) |
37
+ | `mariadb` | `dataSources/MariaDB` — Sequelize connects with `dialect: 'mariadb'` and loads the driver itself |
38
+ | `pg` | `dataSources/PostgreSQL` |
39
+ | `reflect-metadata` | `dataSources/MariaDB` — required by `sequelize-typescript`, never imported by this package |
40
+ | `sequelize` | `dataSources/MariaDB` — peer of `sequelize-typescript` |
41
+ | `sequelize-typescript` | `dataSources/MariaDB` |
42
+ | `sharp` | `files/reEncodeToJpeg`, `files/reEncodeToPng`, `files/reEncodeToWebp`, `files/uploadTempImage` |
43
+
44
+ Optionality is a promise about the load path, not a way to silence the warning: it holds only while the dependency stays behind a subpath the consumer opts into. Adding a root `"."` barrel, or importing one of these from a module that every subpath reaches, breaks it for every consumer at once.
45
+
27
46
  ## Usage
28
47
 
29
48
  No barrel — import each helper from its explicit subpath.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axiumine/koa-utils",
3
- "version": "5.7.0",
3
+ "version": "5.7.2",
4
4
  "description": "Koa Utils",
5
5
  "type": "module",
6
6
  "repository": {
@@ -646,27 +646,69 @@
646
646
  }
647
647
  },
648
648
  "files": [
649
- "dist"
649
+ "dist",
650
+ "!dist/**/*.mjs.map",
651
+ "!dist/**/*.js.map"
650
652
  ],
651
653
  "dependencies": {},
652
654
  "peerDependencies": {
653
- "@node-rs/bcrypt": "*",
654
- "@sentry/node": "*",
655
- "@socketlabs/email": "*",
656
- "clamscan": "*",
657
- "dotenv": "*",
658
- "file-type": "*",
659
- "fs-extra": "*",
660
- "graphql": "*",
655
+ "@node-rs/bcrypt": "<2",
656
+ "@sentry/node": "<11",
657
+ "@socketlabs/email": "<2",
658
+ "clamscan": "<3",
659
+ "dotenv": "<18",
660
+ "file-type": "<23",
661
+ "fs-extra": "<12",
662
+ "graphql": "<18",
661
663
  "keygrip": "^1.1.0",
662
- "mongoose": "*",
663
- "pg": "*",
664
- "redis": "*",
665
- "reflect-metadata": "*",
666
- "sequelize": "*",
667
- "sequelize-typescript": "*",
668
- "sharp": "*",
669
- "uuid": "*"
664
+ "koa": "<4",
665
+ "mariadb": "<4",
666
+ "mongoose": "<10",
667
+ "pg": "<9",
668
+ "redis": "<7",
669
+ "reflect-metadata": "<0.3",
670
+ "sequelize": "<7",
671
+ "sequelize-typescript": "<3",
672
+ "sharp": "<1",
673
+ "uuid": "<15"
674
+ },
675
+ "peerDependenciesMeta": {
676
+ "@socketlabs/email": {
677
+ "optional": true
678
+ },
679
+ "clamscan": {
680
+ "optional": true
681
+ },
682
+ "file-type": {
683
+ "optional": true
684
+ },
685
+ "fs-extra": {
686
+ "optional": true
687
+ },
688
+ "keygrip": {
689
+ "optional": true
690
+ },
691
+ "koa": {
692
+ "optional": true
693
+ },
694
+ "mariadb": {
695
+ "optional": true
696
+ },
697
+ "pg": {
698
+ "optional": true
699
+ },
700
+ "reflect-metadata": {
701
+ "optional": true
702
+ },
703
+ "sequelize": {
704
+ "optional": true
705
+ },
706
+ "sequelize-typescript": {
707
+ "optional": true
708
+ },
709
+ "sharp": {
710
+ "optional": true
711
+ }
670
712
  },
671
713
  "devDependencies": {
672
714
  "@axiumine/eslint-config-be": "^2.0.1",
@@ -1 +0,0 @@
1
- {"version":3,"file":"MariaDB.mjs","sourceRoot":"","sources":["../../src/dataSources/MariaDB.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AACtC,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAEhD,MAAM,CAAC,MAAM,EAAE,CAAA;AAEf,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,SAAS,CACrC,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,EAC/B,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,EAC7B,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,EAC5B;IACC,IAAI,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE;IACjC,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;IACpB,IAAI,EAAE;QACL,2BAA2B;QAC3B,GAAG,EAAE,EAAE;QACP,GAAG,EAAE,CAAC;QACN,IAAI,EAAE,KAAK;QACX,OAAO,EAAE,KAAK;KACd;IACD,KAAK,EAAE;QACN;;;;;aAKK;QACL,WAAW,EAAE,GAAG;QAChB,eAAe,EAAE,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gDAAgD,CAAC,CAAA;IAC9D,IAAI,CAAC;QACJ,MAAM,SAAS,CAAC,KAAK,EAAE,CAAA;QACvB,OAAO,CAAC,IAAI,CAAC,gEAAgE,CAAC,CAAA;IAC/E,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACZ,MAAM,QAAQ,GAAG,2DAA2D,CAAA;QAC5E,MAAM,CAAC,gBAAgB,CAAC,CAAC,EAAE;YAC1B,KAAK,EAAE,EAAE,MAAM,EAAE,qCAAqC,EAAE;SACxD,CAAC,CAAA;QACF,MAAM;YACL,OAAO,EAAE,QAAQ;YACjB,QAAQ,EAAE,IAAI;SACd,CAAA;IACF,CAAC;AACF,CAAC,CAAA","sourcesContent":["import * as Sentry from '@sentry/node'\nimport * as dotenv from 'dotenv'\nimport { Sequelize } from 'sequelize-typescript'\n\ndotenv.config()\n\nexport const sequelize = new Sequelize(\n\t`${process.env.MARIADB_DBNAME}`,\n\t`${process.env.MARIADB_USER}`,\n\t`${process.env.MARIADB_PWD}`,\n\t{\n\t\thost: `${process.env.MARIADB_IP}`,\n\t\tdialect: 'mariadb',\n\t\tquery: { raw: true },\n\t\tpool: {\n\t\t\t// handleDisconnects: true,\n\t\t\tmax: 13,\n\t\t\tmin: 1,\n\t\t\tidle: 10000,\n\t\t\tacquire: 20000\n\t\t},\n\t\tretry: {\n\t\t\t/* match: [\n\t\t\t\tSequelize.ConnectionError,\n\t\t\t\tSequelize.ConnectionTimedOutError,\n\t\t\t\tSequelize.TimeoutError,\n\t\t\t\t/Deadlock/i,\n\t\t\t], */\n\t\t\tbackoffBase: 100,\n\t\t\tbackoffExponent: 1.1,\n\t\t\ttimeout: 3000,\n\t\t\tbackoffJitter: 0.1, // Add this required property\n\t\t\tmax: parseInt(`${process.env.MARIADB_RETRY}`) || 5\n\t\t},\n\t\tdialectOptions: {\n\t\t\tuseUTC: true,\n\t\t\tskipSetTimezone: true,\n\t\t\tcompress: true,\n\t\t\trequestTimeout: parseInt(`${process.env.MARIADB_TIMEOUT}`) || 5000\n\t\t},\n\t\tport: parseInt(`${process.env.MARIADB_PORT}`, 10),\n\t\t/* c8 ignore next -- env-dependent boot config; covered only when MARIADB_LOGGING='false' */\n\t\tlogging: process.env.MARIADB_LOGGING === 'false' ? false : undefined // disable print queries in console\n\t}\n)\n\n// Setting up a connection\nexport const MariaDBConnect = async () => {\n\tconsole.info('[MariaDB] Try connect to database... ')\n\ttry {\n\t\tawait sequelize.authenticate()\n\t\tconsole.info('[MariaDB] OK: MariaDB connection has been established successfully.')\n\t} catch (e) {\n\t\tconst catchMex = '[MariaDB] FAIL: Unable to connect to the database'\n\t\tSentry.captureException(e, {\n\t\t\textra: { detail: catchMex }\n\t\t})\n\t\tthrow {\n\t\t\tmessage: catchMex,\n\t\t\tshutdown: true\n\t\t}\n\t}\n\treturn sequelize\n}\n\nexport const MariaDBDisconnect = async () => {\n\tconsole.info('[MariaDB] Try close connection to database... ')\n\ttry {\n\t\tawait sequelize.close()\n\t\tconsole.info('[MariaDB] OK: MariaDB connection has been closed successfully.')\n\t} catch (e) {\n\t\tconst catchMex = '[MariaDB] FAIL: Unable to close the database connection: '\n\t\tSentry.captureException(e, {\n\t\t\textra: { detail: 'Error during database disconnection' }\n\t\t})\n\t\tthrow {\n\t\t\tmessage: catchMex,\n\t\t\tshutdown: true\n\t\t}\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"MongoDB.mjs","sourceRoot":"","sources":["../../src/dataSources/MongoDB.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAChC,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAA;AAEpC,MAAM,CAAC,MAAM,EAAE,CAAA;AAEf,sFAAsF;AACtF,wCAAwC;AAExC,MAAM,CAAC,KAAK,UAAU,cAAc;IACnC,OAAO,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAA;IAErD,MAAM,OAAO,GAA4B;QACxC,qBAAqB;QACrB,wBAAwB;QACxB,yBAAyB;QACzB,MAAM,EAAE,CAAC,EAAE,OAAO;QAClB,2BAA2B;QAC3B,4BAA4B;QAC5B,wBAAwB,EAAE,IAAI;QAC9B,qBAAqB;QAErB,iBAAiB;QACjB,SAAS,EAAE,IAAI;QACf,wEAAwE;QACxE,8DAA8D;QAC9D,uBAAuB;QACvB,mBAAmB;QACnB,gCAAgC;KAChC,CAAA;IACD,QAAQ,CAAC,GAAG,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAA;IACpC,QAAQ,CAAC,GAAG,CAAC,aAAa,EAAE,KAAK,CAAC,CAAA,CAAC,4BAA4B;IAC/D,MAAM,QAAQ,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,OAAO,CAAC,CAAA;IAC7D,qFAAqF;IACrF,OAAO,CAAC,IAAI,CAAC,sEAAsE,CAAC,CAAA;AACrF,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB;IACtC,OAAO,CAAC,IAAI,CAAC,gDAAgD,CAAC,CAAA;IAC9D,MAAM,QAAQ,CAAC,UAAU,EAAE,CAAA;IAC3B,OAAO,CAAC,IAAI,CAAC,gEAAgE,CAAC,CAAA;AAC/E,CAAC","sourcesContent":["import * as dotenv from 'dotenv'\nimport * as mongoose from 'mongoose'\n\ndotenv.config()\n\n// DeprecationWarning: collection.ensureIndex is deprecated.Use createIndexes instead.\n// mongoose.set('useCreateIndex', true);\n\nexport async function MongoDBConnect() {\n\tconsole.info('[MongoDB] Try connect to database... ')\n\n\tconst options: mongoose.ConnectOptions = {\n\t\t// initial directives\n\t\t// useCreateIndex: true,\n\t\t// useNewUrlParser: true,\n\t\tfamily: 4, // ipv4\n\t\t// useFindAndModify: false,\n\t\t// useUnifiedTopology: true,\n\t\tserverSelectionTimeoutMS: 5000,\n\t\t// retryWrites: true,\n\n\t\t// new directives\n\t\tautoIndex: true\n\t\t// reconnectTries: Number.MAX_VALUE, // conflict with useUnifiedTopology\n\t\t// reconnectInterval: 500, // conflict with useUnifiedTopology\n\t\t// bufferMaxEntries: 0,\n\t\t// keepAlive: true,\n\t\t// keepAliveInitialDelay: 300000\n\t}\n\tmongoose.set('sanitizeFilter', true)\n\tmongoose.set('strictQuery', false) // will be done in mongose 7\n\tawait mongoose.connect(`${process.env.MONGODB_URI}`, options)\n\t/* c8 ignore next 2 -- success log + closing brace; covered only with live MongoDB */\n\tconsole.info('[MongoDB] OK: MongoDB connection has been established successfully. ')\n}\n\nexport async function MongoDBDisconnect() {\n\tconsole.info('[MongoDB] Try close connection to database... ')\n\tawait mongoose.disconnect()\n\tconsole.info('[MongoDB] OK: MongoDB connection has been closed successfully.')\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"PostgreSQL.mjs","sourceRoot":"","sources":["../../src/dataSources/PostgreSQL.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AACtC,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAChC,OAAO,EAAE,MAAM,IAAI,CAAA;AAEnB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,CAAA;AAE3B,MAAM,CAAC,MAAM,EAAE,CAAA;AAEf,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC;IAClC,IAAI,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE;IACtC,QAAQ,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE;IACzC,IAAI,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE;IACtC,IAAI,EAAE,QAAQ,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,EAAE,EAAE,CAAC;IACpD,QAAQ,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE;CAC5C,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC;IAC9B,IAAI,EAAE,GAAG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D,CAAC,CAAA;IACxE,IAAI,CAAC;QACJ,MAAM,QAAQ,CAAC,GAAG,EAAE,CAAA;QACpB,OAAO,CAAC,IAAI,CAAC,6EAA6E,CAAC,CAAA;IAC5F,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM;YACL,OAAO,EAAE,qEAAqE,GAAG,KAAK;YACtF,QAAQ,EAAE,IAAI;SACd,CAAA;IACF,CAAC;AACF,CAAC,CAAA;AAED;;;;;;;;GAQG;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,IAAI,EAAE;IAClD,OAAO,CAAC,GAAG,CAAC,wDAAwD,CAAC,CAAA;IACrE,IAAI,CAAC;QACJ,MAAM,MAAM,CAAC,GAAG,EAAE,CAAA;QAClB,OAAO,CAAC,IAAI,CAAC,2EAA2E,CAAC,CAAA;IAC1F,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM;YACL,OAAO,EAAE,mEAAmE,GAAG,KAAK;YACpF,QAAQ,EAAE,IAAI;SACd,CAAA;IACF,CAAC;AACF,CAAC,CAAA","sourcesContent":["import * as Sentry from '@sentry/node'\nimport * as dotenv from 'dotenv'\nimport pg from 'pg'\n\nconst { Client, Pool } = pg\n\ndotenv.config()\n\nexport const pgClient = new Client({\n\tuser: `${process.env.POSTGRESQL_USER}`,\n\tpassword: `${process.env.POSTGRESQL_PWD}`,\n\thost: `${process.env.POSTGRESQL_HOST}`,\n\tport: parseInt(`${process.env.POSTGRESQL_PORT}`, 10),\n\tdatabase: `${process.env.POSTGRESQL_DBNAME}`\n})\n\nexport const pgPool = new Pool({\n\tuser: `${process.env.POSTGRESQL_USER}`,\n\tpassword: `${process.env.POSTGRESQL_PWD}`,\n\thost: `${process.env.POSTGRESQL_HOST}`,\n\tport: parseInt(`${process.env.POSTGRESQL_PORT}`, 10),\n\tdatabase: `${process.env.POSTGRESQL_DBNAME}`,\n\tmax: parseInt(`${process.env.POSTGRESQL_POOL_MAX}`, 10),\n\tidleTimeoutMillis: parseInt(`${process.env.POSTGRESQL_IDLE_TIMEOUT}`, 10)\n})\n\n// the pool will emit an error on behalf of any idle clients\n// it contains if a backend error or network partition happens\n/* c8 ignore start -- idle-client error path: requires live pg backend partition, not unit-testable */\npgPool.on('error', (err) => {\n\tconsole.error('Unexpected error on idle client', err)\n\tprocess.exit(-1)\n})\n/* c8 ignore stop */\n\n/*************************\n * Client, for transaction and single connection\n */\n\n// Setting up a connection\nexport const PostgreSQLClientConnect = async () => {\n\tconsole.info('[PostgreSQL Client] Try connect to database... ')\n\n\ttry {\n\t\tawait pgClient.connect()\n\n\t\t// Attach an error listener only once\n\t\tif (!pgClient.listenerCount('error')) {\n\t\t\tpgClient.on('error', (e) => {\n\t\t\t\tconst catchMex = '[PostgreSQL Client] something bad has happened!'\n\t\t\t\tSentry.captureException(e, {\n\t\t\t\t\textra: { detail: catchMex }\n\t\t\t\t})\n\t\t\t\tconsole.error(catchMex)\n\t\t\t})\n\t\t}\n\t\tif (!pgClient.listenerCount('notification')) {\n\t\t\tpgClient.on('notification', (msg) => {\n\t\t\t\tconsole.info('[PostgreSQL Client]', msg.channel)\n\t\t\t\tconsole.info('[PostgreSQL Client]', msg.payload)\n\t\t\t\tSentry.captureMessage(`[PostgreSQL Client] notification: ${msg}`, {\n\t\t\t\t\tlevel: 'warning',\n\t\t\t\t\textra: {\n\t\t\t\t\t\tchannel: msg.channel,\n\t\t\t\t\t\tpayload: msg.payload\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t})\n\t\t}\n\t\t// https://www.postgresql.org/docs/9.6/static/plpgsql-errors-and-messages.html\n\t\tif (!pgClient.listenerCount('notice')) {\n\t\t\tpgClient.on('notice', (msg) => {\n\t\t\t\tSentry.captureMessage(`[PostgreSQL Client] notice: ${msg}`, 'warning')\n\t\t\t})\n\t\t}\n\t\tconsole.info('[PostgreSQL Client] OK: PostgreSQL connection has been established successfully.')\n\t} catch (error) {\n\t\tthrow {\n\t\t\tmessage: '[PostgreSQL Client] FAIL: Unable to connect to the database: ' + error,\n\t\t\tshutdown: true\n\t\t}\n\t}\n}\n\nexport const PostgreSQLClientDisconnect = async () => {\n\tconsole.info('[PostgreSQL Client] Try close connection to database... ')\n\ttry {\n\t\tawait pgClient.end()\n\t\tconsole.info('[PostgreSQL Client] OK: PostgreSQL connection has been closed successfully.')\n\t} catch (error) {\n\t\tthrow {\n\t\t\tmessage: '[PostgreSQL Client] FAIL: Unable to close the database connection: ' + error,\n\t\t\tshutdown: true\n\t\t}\n\t}\n}\n\n/*************************\n * Pool\n *\n * -- USE WITH --\n *\n * const pgPoolClient = await pgPool.connect()\n * your queries.. await client.query('YOUR_QUERY')\n * pgPoolClient.release()\n */\n\nexport const PostgreSQLPoolDisconnect = async () => {\n\tconsole.log('[PostgreSQL Pool] Try close connection to database... ')\n\ttry {\n\t\tawait pgPool.end()\n\t\tconsole.info('[PostgreSQL Pool] OK: PostgreSQL connection has been closed successfully.')\n\t} catch (error) {\n\t\tthrow {\n\t\t\tmessage: '[PostgreSQL Pool] FAIL: Unable to close the database connection: ' + error,\n\t\t\tshutdown: true\n\t\t}\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Redis.mjs","sourceRoot":"","sources":["../../src/dataSources/Redis.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AACtC,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAChC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAEnD,MAAM,CAAC,MAAM,EAAE,CAAA;AAEf,MAAM,CAAC,MAAM,WAAW,GACvB,OAAO,CAAC,GAAG,CAAC,gBAAgB,KAAK,GAAG;IACnC,CAAC,CAAC,qGAAqG;QACtG,aAAa,CAAC;YACb,SAAS,EAAE;gBACV,EAAE,GAAG,EAAE,WAAW,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,EAAE;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,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"]}
@@ -1 +0,0 @@
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,EAAE,cAAsB,EAAE,EAAE,aAAqB,EAAE;QACtF,IAAI,CAAC,MAAM,GAAG,IAAI,gBAAgB;QACjC,wFAAwF;QACxF,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,GAAG,CAAC,EACjD,GAAG,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,EACzC,EAAE,cAAc,EAAE,GAAG,EAAE,eAAe,EAAE,CAAC,EAAE,CAC3C,CAAA;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,SAAS,EAAE,CAAA;QAChC,IAAI,CAAC,YAAY,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,CAAA;QAClD,IAAI,CAAC,QAAQ,GAAG,GA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AAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,IAAI,CACzC,GAAG,EAAE;YACJ,4BAA4B;YAC5B,OAAO,IAAI,CAAA;QACZ,CAAC,EACD,CAAC,CAAQ,EAAE,EAAE;YACZ,MAAM,CAAC,gBAAgB,CAAC,CAAC,EAAE;gBAC1B,KAAK,EAAE,EAAE,MAAM,EAAE,4BAA4B,EAAE;aAC/C,CAAC,CAAA;YACF,OAAO,KAAK,CAAA;QACb,CAAC,CACD,CAAA;IACF,CAAC;IAED;;;OAGG;IACK,WAAW;QAClB,OAAO,CACN,2HAA2H;YAC3H,uDAAuD;YACvD,SAAS;YACT,yEAAyE;YACzE,WAAW,CACX,CAAA;IACF,CAAC;IAED;;;OAGG;IACK,WAAW;QAClB,OAAO,CACN,UAAU;YACV,2EAA2E;YAC3E,SAAS;YACT,SAAS;YACT,uCAAuC;YACvC,gFAAgF;YAChF,QAAQ;YACR,+IAA+I,CAC/I,CAAA;IACF,CAAC;IAEO,OAAO,CAAC,IAAY;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 IUserInfo {\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 sendResetPwdConfirmation(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 sendResetPwdConfirmationHash(email: string, name: string, hash: string): Promise<boolean> {\n\t\tconst encodedEmail = encodeURI(email)\n\t\tconst subject = `Password change confirmation for ${this.platformName}`\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\ttry {\n\t\t\treturn await this.sendTemplate(email, subject, textBody, htmlBody)\n\t\t} catch (e) {\n\t\t\tSentry.captureException(e)\n\t\t\treturn false\n\t\t}\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): Promise<boolean> {\n\t\tconst subject = `OTP code for ${this.platformName}`\n\t\tconst textBody = `To confirm your subscription on ${this.platformName}, enter the following OTP code: ${otp}`\n\t\tconst htmlBody = `<p>To confirm your subscription on ${this.platformName}, enter the following OTP code: ${otp}</p>`\n\n\t\ttry {\n\t\t\treturn await this.sendTemplate(emailTo, subject, textBody, htmlBody)\n\t\t} catch (e) {\n\t\t\tSentry.captureException(e)\n\t\t\treturn false\n\t\t}\n\t}\n\n\tasync sendEmailPostReported(userInfo: IUserInfo, 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\tuserInfo.personalData.name +\n\t\t\t' ' +\n\t\t\tuserInfo.personalData.surname +\n\t\t\t' (id: ' +\n\t\t\tuserInfo._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\tuserInfo.personalData.name +\n\t\t\t' ' +\n\t\t\tuserInfo.personalData.surname +\n\t\t\t' (id: ' +\n\t\t\tuserInfo._id +\n\t\t\t').' +\n\t\t\tthis.getHtmlFooter()\n\n\t\treturn await this.sendTemplate(`${process.env.DEV_TEAM_EMAIL}`, 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\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=\"en\" 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"]}
@@ -1 +0,0 @@
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"]}
@@ -1 +0,0 @@
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 // NSFW content detected in the image\n return false\n }\n\n // No NSFW content detected in the image\n return true\n } catch (err) {\n // Error during content moderation: err\n return false\n }\n}\n*/\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"fileConst.mjs","sourceRoot":"","sources":["../../src/files/fileConst.mts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAA;AAC/C,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,CAAC,CAAA","sourcesContent":["import path from 'path'\n\nexport const UPLOAD_TEMP_DIRECTORY_URL = '/tmp'\nexport const UPLOAD_IMG_DIRECTORY_URL = path.join(process.cwd(), 'upload/uimg')\n\nexport interface IStoreFile {\n\toriginalFilename: string\n\tfileName: string\n\tfilePath: string\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"moveFileStaticDomain.mjs","sourceRoot":"","sources":["../../src/files/moveFileStaticDomain.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,+CAA4C;AAExE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,cAAsB,EAAE,MAAc,EAAE,YAAoB,EAAE,YAAoB;IAC5H,8EAA8E;IAC9E,iBAAiB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IACnC,iBAAiB,CAAC,YAAY,EAAE,cAAc,CAAC,CAAA;IAE/C,MAAM,cAAc,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,MAAM,IAAI,YAAY,EAAE,CAAA;IAE/E,MAAM,YAAY,CAAC,cAAc,EAAE,YAAY,EAAE,cAAc,CAAC,CAAA;AACjE,CAAC","sourcesContent":["import { assertNoTraversal } from '@private/files/assertNoTraversal.mjs'\n\nimport { moveTempFile } from './moveTempFile.mjs'\n\n/**\n * read .env STATIC_FOLDER path\n * @param sourceFilePath\n * @param folder\n * @param secondFolder\n * @param destFilename\n */\nexport async function moveFileStaticDomain(sourceFilePath: string, folder: string, secondFolder: string, destFilename: string) {\n\t// folder/secondFolder are path segments: a `..` in them escapes STATIC_FOLDER\n\tassertNoTraversal(folder, 'folder')\n\tassertNoTraversal(secondFolder, 'secondFolder')\n\n\tconst destinationDir = `${process.env.STATIC_FOLDER}/${folder}/${secondFolder}`\n\n\tawait moveTempFile(sourceFilePath, destFilename, destinationDir)\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"moveImageFile.mjs","sourceRoot":"","sources":["../../src/files/moveImageFile.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,+CAA4C;AAExE,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,cAAsB,EAAE,MAAc,EAAE,YAAoB,EAAE,YAAoB;IACrH,yFAAyF;IACzF,iBAAiB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IACnC,iBAAiB,CAAC,YAAY,EAAE,cAAc,CAAC,CAAA;IAE/C,MAAM,cAAc,GAAG,GAAG,wBAAwB,IAAI,MAAM,IAAI,YAAY,EAAE,CAAA;IAE9E,MAAM,YAAY,CAAC,cAAc,EAAE,YAAY,EAAE,cAAc,CAAC,CAAA;AACjE,CAAC","sourcesContent":["import { assertNoTraversal } from '@private/files/assertNoTraversal.mjs'\n\nimport { UPLOAD_IMG_DIRECTORY_URL } from './fileConst.mjs'\nimport { moveTempFile } from './moveTempFile.mjs'\n\nexport async function moveImageFile(sourceFilePath: string, folder: string, secondFolder: string, destFilename: string) {\n\t// folder/secondFolder are path segments: a `..` in them escapes UPLOAD_IMG_DIRECTORY_URL\n\tassertNoTraversal(folder, 'folder')\n\tassertNoTraversal(secondFolder, 'secondFolder')\n\n\tconst destinationDir = `${UPLOAD_IMG_DIRECTORY_URL}/${folder}/${secondFolder}`\n\n\tawait moveTempFile(sourceFilePath, destFilename, destinationDir)\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"moveTempFile.mjs","sourceRoot":"","sources":["../../src/files/moveTempFile.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,+CAA4C;AACxE,OAAO,EAAE,MAAM,UAAU,CAAA;AACzB,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,cAAsB,EAAE,YAAoB,EAAE,cAAsB;IACtG,mGAAmG;IACnG,6FAA6F;IAC7F,oEAAoE;IACpE,iBAAiB,CAAC,YAAY,EAAE,cAAc,CAAC,CAAA;IAE/C,0CAA0C;IAC1C,MAAM,EAAE,CAAC,SAAS,CAAC,cAAc,CAAC,CAAA;IAElC,8BAA8B;IAC9B,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAA;IACxC,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,GAAG,YAAY,GAAG,GAAG,EAAE,CAAC,CAAA;IAE1E,gBAAgB;IAChB,MAAM,EAAE,CAAC,IAAI,CAAC,cAAc,EAAE,eAAe,CAAC,CAAA;AAC/C,CAAC","sourcesContent":["import { assertNoTraversal } from '@private/files/assertNoTraversal.mjs'\nimport fs from 'fs-extra'\nimport path from 'path'\n\n/**\n *\n * @param sourceFilePath\n * @param destFilename\n * @param destinationDir\n */\nexport async function moveTempFile(sourceFilePath: string, destFilename: string, destinationDir: string) {\n\t// destFilename is a filename, not a path: a `..` in it escapes destinationDir via path.join below.\n\t// sourceFilePath and destinationDir are genuine caller-owned paths and are intentionally NOT\n\t// checked here — validating those is the consumer's responsibility.\n\tassertNoTraversal(destFilename, 'destFilename')\n\n\t// Ensure the destination directory exists\n\tawait fs.ensureDir(destinationDir)\n\n\t// Define the destination path\n\tconst ext = path.extname(sourceFilePath)\n\tconst destinationPath = path.join(destinationDir, `${destFilename}${ext}`)\n\n\t// Move the file\n\tawait fs.move(sourceFilePath, destinationPath)\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"reEncodeToJpeg.mjs","sourceRoot":"","sources":["../../src/files/reEncodeToJpeg.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,sCAAmC;AAEtD,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,QAAgB,EAAE,OAAO,GAAG,GAAG;IACnE,OAAO,MAAM,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;AACjD,CAAC","sourcesContent":["import { reEncode } from '@private/files/reEncode.mjs'\n\nexport async function reEncodeToJpeg(filename: string, quality = 100) {\n\treturn await reEncode(filename, 'jpeg', quality)\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"reEncodeToPng.mjs","sourceRoot":"","sources":["../../src/files/reEncodeToPng.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,sCAAmC;AAEtD,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,QAAgB,EAAE,OAAO,GAAG,GAAG;IAClE,OAAO,MAAM,QAAQ,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAA;AAChD,CAAC","sourcesContent":["import { reEncode } from '@private/files/reEncode.mjs'\n\nexport async function reEncodeToPng(filename: string, quality = 100) {\n\treturn await reEncode(filename, 'png', quality)\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"reEncodeToWebp.mjs","sourceRoot":"","sources":["../../src/files/reEncodeToWebp.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,sCAAmC;AAEtD,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,QAAgB,EAAE,OAAO,GAAG,GAAG;IACnE,OAAO,MAAM,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;AACjD,CAAC","sourcesContent":["import { reEncode } from '@private/files/reEncode.mjs'\n\nexport async function reEncodeToWebp(filename: string, quality = 100) {\n\treturn await reEncode(filename, 'webp', quality)\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"scanVirus.mjs","sourceRoot":"","sources":["../../src/files/scanVirus.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AACtC,OAAO,QAAQ,MAAM,UAAU,CAAA;AAE/B,IAAI,gBAAgB,GAAoB,IAAI,CAAA;AAE5C;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAAmC;IACrE,MAAM,cAAc,GAAqB;QACxC,cAAc,EAAE,IAAI;QACpB,kBAAkB,EAAE,KAAK;QACzB,SAAS,EAAE;YACV,MAAM,EAAE,2BAA2B;YACnC,OAAO,EAAE,KAAK;YACd,SAAS,EAAE,IAAI;YACf,aAAa,EAAE,KAAK;SACpB;QACD,SAAS,EAAE,KAAK;KAChB,CAAA;IACD,OAAO,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAA;IAElC,IAAI,CAAC;QACJ,MAAM,aAAa,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,OAAO,EAAE,CAAA;QACvD,gBAAgB,GAAG,MAAM,IAAI,QAAQ,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;QAC3D,OAAO,CAAC,IAAI,CAAC,2DAA2D,CAAC,CAAA;QACzE,OAAO,gBAAgB,CAAA;IACxB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACZ,OAAO,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAA;QACjC,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAA;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'\nimport NodeClam from 'clamscan'\n\nlet clamScanInstance: NodeClam | null = null\n\n/**********\n * Call inside koa initialization\n */\nexport async function initClamScan(options?: Partial<NodeClam.Options>) {\n\tconst defaultOptions: NodeClam.Options = {\n\t\tremoveInfected: true,\n\t\tquarantineInfected: false,\n\t\tclamdscan: {\n\t\t\tsocket: '/var/run/clamav/clamd.ctl',\n\t\t\ttimeout: 60000,\n\t\t\tmultiscan: true,\n\t\t\tlocalFallback: false\n\t\t},\n\t\tdebugMode: false\n\t}\n\tconsole.info('[ClamScan] init...')\n\n\ttry {\n\t\tconst mergedOptions = { ...defaultOptions, ...options }\n\t\tclamScanInstance = await new NodeClam().init(mergedOptions)\n\t\tconsole.info('[ClamScan] OK: ClamScan has been initialized successfully')\n\t\treturn clamScanInstance\n\t} catch (e) {\n\t\tconsole.error('[ClamScan] Error')\n\t\tSentry.captureException(e)\n\t\tthrow e\n\t}\n}\n\n/**\n * Result of a virus scan.\n *\n * Returned rather than kept internal because the Sentry alert used to be the ONLY\n * effect of detecting an infected file: inverting `if (isInfected)` had no observable\n * consequence, so no test could pin it (@sentry/node is a sealed ES module namespace\n * and is never initialised in the suite, making captureMessage a silent no-op there).\n * `alerted` is set inside the branch precisely so the branch itself is observable.\n *\n * scanVirus still never throws on detection — blocking remains the caller's decision —\n * but the caller now has something to decide with. Note `scanned: false` means the scan\n * did not complete: treat it as unknown, not as clean.\n */\nexport interface IScanVirusResult {\n\t/** true when ClamAV reported the file as infected */\n\tisInfected: boolean\n\t/** virus names reported by ClamAV; empty when clean or when the scan failed */\n\tviruses: string[]\n\t/** true when the infected-file alert was raised */\n\talerted: boolean\n\t/** false when the scan itself errored — the result is unknown, NOT clean */\n\tscanned: boolean\n}\n\nexport async function scanVirus(filePath: string): Promise<IScanVirusResult> {\n\tif (!clamScanInstance) {\n\t\tthrow new Error('ClamScan has not been initialized. Call initClamScan first.')\n\t}\n\n\ttry {\n\t\tconst { isInfected, viruses } = await clamScanInstance.scanFile(filePath)\n\n\t\tlet alerted = false\n\t\tif (isInfected) {\n\t\t\talerted = true\n\t\t\tSentry.withScope((scope) => {\n\t\t\t\tscope.setTag('file', filePath)\n\t\t\t\tscope.setContext('viruses', { list: viruses, count: viruses.length })\n\t\t\t\tscope.setLevel('warning')\n\t\t\t\tSentry.captureMessage(`Infected file detected: ${filePath}`)\n\t\t\t})\n\t\t}\n\n\t\treturn { isInfected, viruses, alerted, scanned: true }\n\t} catch (e) {\n\t\tSentry.captureException(e, {\n\t\t\textra: { detail: `Error while scanning the file ${filePath}` }\n\t\t})\n\t\treturn { isInfected: false, viruses: [], alerted: false, scanned: false }\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"storeUploadAsTemp.mjs","sourceRoot":"","sources":["../../src/files/storeUploadAsTemp.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEnD,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAA;AAGnC,OAAO,EAAc,yBAAyB,EAAE,MAAM,iBAAiB,CAAA;AAEvE,2CAA2C;AAC3C,kCAAkC;AAClC,MAAM,aAAa,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAA,CAAC,iBAAiB;AAEvD,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,MAA4B,EAAE,cAAsB,aAAa;IACxG,MAAM,EAAE,gBAAgB,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAA;IACnD,MAAM,MAAM,GAAG,gBAAgB,EAAE,CAAA;IACjC,MAAM,cAAc,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAA;IACtE,MAAM,aAAa,GAAG,GAAG,yBAAyB,IAAI,cAAc,EAAE,CAAA;IACtE,IAAI,QAAQ,GAAG,CAAC,CAAA,CAAC,8BAA8B;I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,CAAC,CAAA;YACnB,CAAC;QACF,CAAC,CAAC,CAAA;QAEF,+EAA+E;QAC/E,8EAA8E;QAC9E,iFAAiF;QACjF,qBAAqB;QACrB,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,CAAQ,EAAE,EAAE;YACpC,YAAY,GAAG,CAAC,CAAA;QACjB,CAAC,CAAC,CAAA;QAEF,sLAAsL;QACtL,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAY,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA;QAEhE,yCAAyC;QACzC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IACzB,CAAC,CAAC,CAAA;IAEF,OAAO;QACN,gBAAgB,EAAE,QAAQ;QAC1B,QAAQ,EAAE,cAAc;QACxB,QAAQ,EAAE,aAAa;KACvB,CAAA;AACF,CAAC","sourcesContent":["import { createWriteStream, unlink } from 'node:fs'\n\nimport path from 'path'\nimport { v4 as uuidv4 } from 'uuid'\n\nimport { IFileUpload } from '../koa/IFileUpload.mjs'\nimport { IStoreFile, UPLOAD_TEMP_DIRECTORY_URL } from './fileConst.mjs'\n\n// Simulating __dirname using process.cwd()\n// const __dirname = process.cwd()\nconst MAX_FILE_SIZE = 5 * 1024 * 1024 // 5MB size limit\n\nexport async function storeUploadAsTemp(upload: Promise<IFileUpload>, maxFileSize: number = MAX_FILE_SIZE): Promise<IStoreFile> {\n\tconst { createReadStream, filename } = await upload\n\tconst stream = createReadStream()\n\tconst storedFileName = uuidv4() + path.extname(filename).toLowerCase()\n\tconst storedFileUrl = `${UPLOAD_TEMP_DIRECTORY_URL}/${storedFileName}`\n\tlet fileSize = 0 // Variable to track file size\n\tlet sizeExceeded = false // Set once the limit is passed; read by the 'close' handler\n\tlet writeFailure: Error | null = null // Set on a write/stream error; read by the 'close' handler\n\n\t// Store the file in the filesystem.\n\tawait new Promise((resolve, reject) => {\n\t\t// Create a stream to which the upload will be written.\n\t\tconst writeStream = createWriteStream(storedFileUrl)\n\n\t\t// Check file size during streaming.\n\t\t// Only flags and stops the stream — the rejection is issued from the 'close'\n\t\t// handler below. Rejecting from inside unlink's callback here would lose the\n\t\t// race: writeStream.destroy() emits 'close' synchronously ahead of the async\n\t\t// unlink, so 'close' resolved the promise first and the later reject() was a\n\t\t// no-op on an already-settled promise. An oversize upload therefore reported\n\t\t// SUCCESS while returning a path that had just been deleted.\n\t\tstream.on('data', (chunk: Buffer) => {\n\t\t\tfileSize += chunk.length\n\t\t\tif (!sizeExceeded && fileSize > maxFileSize) {\n\t\t\t\tsizeExceeded = true\n\t\t\t\twriteStream.destroy() // Stop the stream\n\t\t\t}\n\t\t})\n\n\t\t// Best-effort cleanup, then reject. Cleanup is fire-and-forget by design: the\n\t\t// upload has already failed, and an unlink error must not mask the real cause.\n\t\tconst removeThenReject = (reason: Error) => unlink(storedFileUrl, () => reject(reason))\n\n\t\t// 'close' is the single settle point. Every failure path below only RECORDS what\n\t\t// went wrong and stops the stream; nothing settles the Promise itself. Rejecting\n\t\t// from inside an unlink callback instead would lose the race — destroy() emits\n\t\t// 'close' ahead of the async unlink, so 'close' settled the Promise first and the\n\t\t// later reject() was a no-op. That is why an oversize upload used to report\n\t\t// SUCCESS with a filePath that had just been deleted, and why a write error did\n\t\t// the same.\n\t\twriteStream.on('close', () => {\n\t\t\tif (sizeExceeded) {\n\t\t\t\tremoveThenReject(new Error(`File size exceeds the limit of ${maxFileSize} bytes`))\n\t\t\t} else if (writeFailure !== null) {\n\t\t\t\tremoveThenReject(writeFailure)\n\t\t\t} else {\n\t\t\t\tresolve(undefined)\n\t\t\t}\n\t\t})\n\n\t\t// Record the write error; 'close' follows and does the rejecting. The previous\n\t\t// version rejected here with 'File size exceeds the limit.' regardless of the\n\t\t// actual cause, which was misleading for every non-size failure — the real error\n\t\t// is propagated now.\n\t\twriteStream.on('error', (e: Error) => {\n\t\t\twriteFailure = e\n\t\t})\n\n\t\t// In Node.js <= v13, errors are not automatically propagated between piped streams. If there is an error receiving the upload, destroy the write stream with the corresponding error.\n\t\tstream.on('error', (error: Error) => writeStream.destroy(error))\n\n\t\t// Pipe the upload into the write stream.\n\t\tstream.pipe(writeStream)\n\t})\n\n\treturn {\n\t\toriginalFilename: filename,\n\t\tfileName: storedFileName,\n\t\tfilePath: storedFileUrl\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"uploadTempImage.mjs","sourceRoot":"","sources":["../../src/files/uploadTempImage.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAA;AACvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAA;AAErE;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,GAAyB;IACzD,IAAI,cAAc,GAAG,EAAE,CAAA;IAEvB,IAAI,CAAC;QACJ,qBAAqB;QACrB,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,MAAM,iBAAiB,CAAC,GAAG,CAAC,CAAA;QAC3D,MAAM,uBAAuB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;QACjD,MAAM,sBAAsB,CAAC,QAAQ,CAAC,CAAA;QACtC,SAAS;QACT,MAAM,SAAS,CAAC,GAAG,QAAQ,EAAE,CAAC,CAAA;QAC9B,SAAS;QAET,cAAc,GAAG,MAAM,cAAc,CAAC,QAAQ,CAAC,CAAA;QAC/C,+BAA+B;QAC/B,+BAA+B;QAC/B,2BAA2B;QAC3B,cAAc;QACd,cAAc;QACd,cAAc;QACd,8CAA8C;QAC9C,iEAAiE;IAClE,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACZ,0BAA0B;QAC1B,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,CAAC,CAAC,CAAA;QACxC,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAA;IACvC,CAAC;IAED,OAAO;QACN,GAAG,EAAE,MAAM;QACX,QAAQ,EAAE,cAAc;KACxB,CAAA;AACF,CAAC","sourcesContent":["import { IFileUpload } from '../koa/IFileUpload.mjs'\nimport { IUploadTemp } from './IUploadTemp.mjs'\nimport { reEncodeToWebp } from './reEncodeToWebp.mjs'\nimport { scanVirus } from './scanVirus.mjs'\nimport { storeUploadAsTemp } from './storeUploadAsTemp.mjs'\nimport { validateJpgPngExtension } from './validateJpgPngExtension.mjs'\nimport { validateJpgPngMimeType } from './validateMimeTypeImages.mjs'\n\n/**\n * Validate file extension, Mime Type, scan with ClamAV, re encode to webp, rename final file\n * @todo log uploaded file\n * @param img\n */\nexport async function uploadTemp(img: Promise<IFileUpload>): Promise<IUploadTemp> {\n\tlet storedTempFile = ''\n\n\ttry {\n\t\t// Step 1 - Readme.md\n\t\tconst { fileName, filePath } = await storeUploadAsTemp(img)\n\t\tawait validateJpgPngExtension(fileName, filePath)\n\t\tawait validateJpgPngMimeType(filePath)\n\t\t// step 2\n\t\tawait scanVirus(`${filePath}`)\n\t\t// step 3\n\n\t\tstoredTempFile = await reEncodeToWebp(filePath)\n\t\t// await checkForNSFW(filePath)\n\t\t// step 4 - safe file name (ok)\n\t\t// step 5 - rate limit (ok)\n\t\t// step 6 - ok\n\t\t// step 7 - ok\n\t\t// step8 - log\n\t\t// user's IP address, filename, and timestamp,\n\t\t// @todo await logUpload('team', uId, originalFilename, fileName)\n\t} catch (e) {\n\t\t// error for file handling\n\t\tconsole.error('Error storing image:', e)\n\t\tthrow new Error('Error storing image')\n\t}\n\n\treturn {\n\t\text: 'webp',\n\t\ttempFile: storedTempFile\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"uploadTempPdf.mjs","sourceRoot":"","sources":["../../src/files/uploadTempPdf.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AAEjE;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,GAAyB;IAC5D,IAAI,cAAc,GAAG,EAAE,CAAA;IAEvB,IAAI,CAAC;QACJ,qBAAqB;QACrB,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,MAAM,iBAAiB,CAAC,GAAG,CAAC,CAAA;QAC3D,MAAM,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;QAC9C,MAAM,mBAAmB,CAAC,QAAQ,CAAC,CAAA;QACnC,SAAS;QACT,MAAM,SAAS,CAAC,GAAG,QAAQ,EAAE,CAAC,CAAA;QAC9B,SAAS;QAET,wFAAwF;QACxF,cAAc,GAAG,QAAQ,CAAA;QACzB,+BAA+B;QAC/B,+BAA+B;QAC/B,2BAA2B;QAC3B,cAAc;QACd,cAAc;QACd,cAAc;QACd,8CAA8C;QAC9C,iEAAiE;IAClE,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACZ,0BAA0B;QAC1B,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,CAAC,CAAC,CAAA;QACtC,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAA;IACrC,CAAC;IAED,OAAO;QACN,GAAG,EAAE,KAAK;QACV,QAAQ,EAAE,cAAc;KACxB,CAAA;AACF,CAAC","sourcesContent":["import { IFileUpload } from '../koa/IFileUpload.mjs'\nimport { IUploadTemp } from './IUploadTemp.mjs'\nimport { scanVirus } from './scanVirus.mjs'\nimport { storeUploadAsTemp } from './storeUploadAsTemp.mjs'\nimport { validateMimeTypePdf } from './validateMimeTypePdf.mjs'\nimport { validatePdfExtension } from './validatePdfExtension.mjs'\n\n/**\n * Validate file extension, Mime Type, scan with ClamAV, re encode to pdf, rename final file\n * @todo log uploaded file, reencode pdf\n * @param pdf\n */\nexport async function uploadTempPdf(pdf: Promise<IFileUpload>): Promise<IUploadTemp> {\n\tlet storedTempFile = ''\n\n\ttry {\n\t\t// Step 1 - Readme.md\n\t\tconst { fileName, filePath } = await storeUploadAsTemp(pdf)\n\t\tawait validatePdfExtension(fileName, filePath)\n\t\tawait validateMimeTypePdf(filePath)\n\t\t// step 2\n\t\tawait scanVirus(`${filePath}`)\n\t\t// step 3\n\n\t\t// @todo reencode with dangerzone https://github.com/freedomofpress/dangerzone/tree/main\n\t\tstoredTempFile = filePath\n\t\t// await checkForNSFW(filePath)\n\t\t// step 4 - safe file name (ok)\n\t\t// step 5 - rate limit (ok)\n\t\t// step 6 - ok\n\t\t// step 7 - ok\n\t\t// step8 - log\n\t\t// user's IP address, filename, and timestamp,\n\t\t// @todo await logUpload('team', uId, originalFilename, fileName)\n\t} catch (e) {\n\t\t// error for file handling\n\t\tconsole.error('Error storing pdf:', e)\n\t\tthrow new Error('Error storing pdf')\n\t}\n\n\treturn {\n\t\text: 'pdf',\n\t\ttempFile: storedTempFile\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"validateExtension.mjs","sourceRoot":"","sources":["../../src/files/validateExtension.mts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAAE,iBAA2B,EAAE,EAAE;IAClF,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAA;IAChD,OAAO,iBAAiB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;AACvC,CAAC,CAAA","sourcesContent":["import path from 'path'\n\n/**\n * Utility function to validate file extension\n * @param filename\n * @param allowedExtensions\n */\nexport const validateExtension = (filename: string, allowedExtensions: string[]) => {\n\tconst ext = path.extname(filename).toLowerCase()\n\treturn allowedExtensions.includes(ext)\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"validateJpgPngExtension.mjs","sourceRoot":"","sources":["../../src/files/validateJpgPngExtension.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAA;AAEzB,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAE3D,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,QAAgB,EAAE,QAAgB;IAC/E,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;QAC7D,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA,CAAC,oBAAoB;QAC9C,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAA;IAC1C,CAAC;AACF,CAAC","sourcesContent":["import fs from 'fs-extra'\n\nimport { validateExtension } from './validateExtension.mjs'\n\nexport async function validateJpgPngExtension(filename: string, filePath: string) {\n\tif (!validateExtension(filename, ['.jpg', '.jpeg', '.png'])) {\n\t\tawait fs.remove(filePath) // Clean up the file\n\t\tthrow new Error('Invalid file extension')\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"validateMimeType.mjs","sourceRoot":"","sources":["../../src/files/validateMimeType.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,+CAA4C;AACxE,OAAO,EAAE,MAAM,UAAU,CAAA;AAEzB;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,QAAgB,EAAE,gBAA0B;IAClF,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAA;IACpE,IAAI,QAAQ,KAAK,EAAE,EAAE,CAAC;QACrB,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA,CAAC,oBAAoB;QAC9C,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAA;IAC1C,CAAC;SAAM,CAAC;QACP,OAAO,QAAQ,CAAA;IAChB,CAAC;AACF,CAAC","sourcesContent":["import { _validateMimeType } from '@private/files/_validateMimeType.mjs'\nimport fs from 'fs-extra'\n\n/**\n * Validate MIME type based on file content (magic number validation)\n * @param filePath\n * @param allowedMimeTypes\n */\nexport async function validateMimeType(filePath: string, allowedMimeTypes: string[]): Promise<string> {\n\tconst mimeType = await _validateMimeType(filePath, allowedMimeTypes)\n\tif (mimeType === '') {\n\t\tawait fs.remove(filePath) // Clean up the file\n\t\tthrow new Error('Invalid file MIME type')\n\t} else {\n\t\treturn mimeType\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"validateMimeTypeImages.mjs","sourceRoot":"","sources":["../../src/files/validateMimeTypeImages.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAEzD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,QAAgB;IAC5D,OAAO,MAAM,gBAAgB,CAAC,QAAQ,EAAE,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC,CAAA;AACrE,CAAC","sourcesContent":["import { validateMimeType } from './validateMimeType.mjs'\n\n/**\n * Validate MIME type based on file content (magic number validation)\n * @param filePath\n */\nexport async function validateJpgPngMimeType(filePath: string): Promise<string> {\n\treturn await validateMimeType(filePath, ['image/jpeg', 'image/png'])\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"validateMimeTypePdf.mjs","sourceRoot":"","sources":["../../src/files/validateMimeTypePdf.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAEzD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,QAAgB;IACzD,OAAO,MAAM,gBAAgB,CAAC,QAAQ,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAA;AAC7D,CAAC","sourcesContent":["import { validateMimeType } from './validateMimeType.mjs'\n\n/**\n * Validate MIME type based on file content (magic number validation)\n * @param filePath\n */\nexport async function validateMimeTypePdf(filePath: string): Promise<string> {\n\treturn await validateMimeType(filePath, ['application/pdf'])\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"validatePdfExtension.mjs","sourceRoot":"","sources":["../../src/files/validatePdfExtension.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAA;AAEzB,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAE3D,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,QAAgB,EAAE,QAAgB;IAC5E,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;QAC5C,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA,CAAC,oBAAoB;QAC9C,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAA;IAC1C,CAAC;AACF,CAAC","sourcesContent":["import fs from 'fs-extra'\n\nimport { validateExtension } from './validateExtension.mjs'\n\nexport async function validatePdfExtension(filename: string, filePath: string) {\n\tif (!validateExtension(filename, ['.pdf'])) {\n\t\tawait fs.remove(filePath) // Clean up the file\n\t\tthrow new Error('Invalid file extension')\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"UserBase.mjs","sourceRoot":"","sources":["../../../../src/graphQL/models/MongoDB/UserBase.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAS,MAAM,UAAU,CAAA;AAgE/C,MAAM,cAAc,GAA4B,IAAI,MAAM,CACzD;IACC,KAAK,EAAE;QACN,IAAI,EAAE;YACL,GAAG,EAAE,KAAK;YACV,KAAK,EAAE;gBACN,IAAI,EAAE,MAAM;gBACZ,QAA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,YAAY,EAAE;gBACb,IAAI,EAAE,IAAI;gBACV,QAAQ,EAAE,KAAK;aACf;YACD,SAAS,EAAE;gBACV,IAAI,EAAE,MAAM;gBACZ,QAAQ,EAAE,KAAK;aACf;YACD,kFAAkF;YAClF,mFAAmF;YACnF,sFAAsF;YACtF,qFAAqF;YACrF,8EAA8E;YAC9E,mFAAmF;YACnF,uFAAuF;YACvF,yDAAyD;YACzD,QAAQ,EAAE;gBACT,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,KAAK;aACf;YACD,OAAO,EAAE;gBACR,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,KAAK;aACf;SACD;QACD,QAAQ,EAAE,IAAI;KACd;IACD,YAAY,EAAE;QACb,IAAI,EAAE;YACL,GAAG,EAAE,KAAK;YACV,IAAI,EAAE;gBACL,IAAI,EAAE,MAAM;gBACZ,QAAQ,EAAE,IAAI;aACd;SACD;QACD,QAAQ,EAAE,KAAK;KACf;IACD,GAAG,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,KAAK;KACf;CACD,EACD;IACC,UAAU,EAAE,MAAM;CAClB,CACD,CAAA;AAED,MAAM,QAAQ,GAAG,KAAK,CAAkB,UAAU,EAAE,cAAc,CAAC,CAAA;AACnE,OAAO,EAAE,QAAQ,EAAE,CAAA","sourcesContent":["import { model, Schema, Types } from 'mongoose'\n\nexport interface IInfoUserForLogin {\n\t_id: Types.ObjectId\n\tlogin: {\n\t\tpassword: string\n\t\tlastLogin?: Date\n\t}\n\taccount: {\n\t\temail: {\n\t\t\tvalid: boolean\n\t\t}\n\t\tonboardingStep?: string\n\t\tonboardingDone?: boolean\n\t\trememberMe?: boolean\n\t\tdisabled?: boolean\n\t\tdeleted?: boolean\n\t}\n}\n\nexport interface IUserBaseSchema {\n\t_id: Types.ObjectId\n\tlogin: {\n\t\t_id?: boolean\n\t\temail: string\n\t\tpassword: string\n\t\tfirstLogin?: Date\n\t\tlastLogin?: Date\n\t}\n\taccount: {\n\t\t_id?: boolean\n\t\temail: {\n\t\t\t_id?: boolean\n\t\t\tvalid: boolean\n\t\t\tdateLastReq?: Date\n\t\t\trequestTimes?: number\n\t\t\thash?: string\n\t\t\tnewEmailTmp?: string\n\t\t}\n\t\tonboardingStep?: string\n\t\tonboardingDone?: boolean\n\t\trememberMe?: boolean\n\t\tregistrationDate: Date\n\t\taccountValidDate?: Date\n\t\tnewsletter?: boolean\n\t\tresetDateReq?: Date\n\t\t/**\n\t\t * Password-reset token. Deliberately NOT `account.email.hash`: that slot belongs to the\n\t\t * email-verification and email-change flows, which have a different lifetime (3 days vs 60\n\t\t * minutes), a different throttle, and a different trust domain. While the two shared one\n\t\t * field, requesting a reset silently invalidated a pending activation link, and a hash\n\t\t * issued by either flow was accepted by the other.\n\t\t */\n\t\tresetHash?: string\n\t\tdisabled?: boolean\n\t\tdeleted?: boolean\n\t}\n\tpersonalData?: {\n\t\t_id: false\n\t\tname: string\n\t}\n\t__v?: number\n}\n\nconst UserBaseSchema: Schema<IUserBaseSchema> = new Schema(\n\t{\n\t\tlogin: {\n\t\t\ttype: {\n\t\t\t\t_id: false,\n\t\t\t\temail: {\n\t\t\t\t\ttype: String,\n\t\t\t\t\trequired: true\n\t\t\t\t},\n\t\t\t\tpassword: {\n\t\t\t\t\ttype: String,\n\t\t\t\t\trequired: true\n\t\t\t\t},\n\t\t\t\tfirstLogin: {\n\t\t\t\t\ttype: Date,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\tlastLogin: {\n\t\t\t\t\ttype: Date,\n\t\t\t\t\trequired: false\n\t\t\t\t}\n\t\t\t},\n\t\t\trequired: true\n\t\t},\n\t\taccount: {\n\t\t\ttype: {\n\t\t\t\t_id: false,\n\t\t\t\temail: {\n\t\t\t\t\ttype: {\n\t\t\t\t\t\t_id: false,\n\t\t\t\t\t\tvalid: {\n\t\t\t\t\t\t\ttype: Boolean,\n\t\t\t\t\t\t\trequired: true\n\t\t\t\t\t\t},\n\t\t\t\t\t\tdateLastReq: {\n\t\t\t\t\t\t\ttype: Date,\n\t\t\t\t\t\t\trequired: false\n\t\t\t\t\t\t},\n\t\t\t\t\t\trequestTimes: {\n\t\t\t\t\t\t\ttype: Number,\n\t\t\t\t\t\t\trequired: false\n\t\t\t\t\t\t},\n\t\t\t\t\t\thash: {\n\t\t\t\t\t\t\ttype: String,\n\t\t\t\t\t\t\trequired: false\n\t\t\t\t\t\t},\n\t\t\t\t\t\tnewEmailTmp: {\n\t\t\t\t\t\t\ttype: String,\n\t\t\t\t\t\t\trequired: false\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\trequired: true\n\t\t\t\t},\n\t\t\t\tonboardingStep: {\n\t\t\t\t\ttype: String,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\tonboardingDone: {\n\t\t\t\t\ttype: Boolean,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\trememberMe: {\n\t\t\t\t\ttype: Boolean,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\tregistrationDate: {\n\t\t\t\t\ttype: Date,\n\t\t\t\t\trequired: true\n\t\t\t\t},\n\t\t\t\taccountValidDate: {\n\t\t\t\t\ttype: Date,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\tnewsletter: {\n\t\t\t\t\ttype: Boolean,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\tresetDateReq: {\n\t\t\t\t\ttype: Date,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\tresetHash: {\n\t\t\t\t\ttype: String,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\t// Boolean, matching IUserBaseSchema. It was String, and that inverted the flag: a\n\t\t\t\t// hydrated read (infoUserForLogin uses .exec(), not .lean()) cast a stored `false`\n\t\t\t\t// to the string 'false', which is truthy, so every consumer's `if (account.disabled)`\n\t\t\t\t// locked out a user explicitly marked NOT disabled. Writing `false` through Mongoose\n\t\t\t\t// stored the string too. Existing rows holding 'true'/'false' strings must be\n\t\t\t\t// migrated — run scripts/migrate-account-disabled-to-boolean.mjs. Mongoose repairs\n\t\t\t\t// them on hydration, but .lean() readers (userData4VerifyEmail, emailChangeHashVerify)\n\t\t\t\t// see the raw value and would still block on the string.\n\t\t\t\tdisabled: {\n\t\t\t\t\ttype: Boolean,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\tdeleted: {\n\t\t\t\t\ttype: Boolean,\n\t\t\t\t\trequired: false\n\t\t\t\t}\n\t\t\t},\n\t\t\trequired: true\n\t\t},\n\t\tpersonalData: {\n\t\t\ttype: {\n\t\t\t\t_id: false,\n\t\t\t\tname: {\n\t\t\t\t\ttype: String,\n\t\t\t\t\trequired: true\n\t\t\t\t}\n\t\t\t},\n\t\t\trequired: false\n\t\t},\n\t\t__v: {\n\t\t\ttype: Number,\n\t\t\trequired: false\n\t\t}\n\t},\n\t{\n\t\tcollection: 'user'\n\t}\n)\n\nconst UserBase = model<IUserBaseSchema>('UserBase', UserBaseSchema)\nexport { UserBase }\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"DevStatsGraphQLCalls.mjs","sourceRoot":"","sources":["../../../../../src/graphQL/models/MongoDB/log/DevStatsGraphQLCalls.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAS,MAAM,UAAU,CAAA;AAoB/C,MAAM,0BAA0B,GAAG,IAAI,MAAM,CAC5C;IACC,IAAI,EAAE;QACL,IAAI,EAAE;YACL;gBACC,GAAG,EAAE;oBACJ,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,QAAQ;oBAC3B,QAAQ,EAAE,IAAI;iBACd;gBACD,IAAI,EAAE;oBACL,IAAI,EAAE,MAAM;oBACZ,QAAQ,EAAE,IAAI;iBACd;gBACD,GAAG,EAAE;oBACJ,IAAI,EAAE,OAAO;oBACb,QAAQ,EAAE,KAAK;iBACf;aACD;SACD;QACD,QAAQ,EAAE,IAAI;KACd;IACD,OAAO,EAAE;QACR,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,oDAAoD;KAC9E;IACD,GAAG,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,KAAK;KACf;CACD,EACD;IACC,UAAU,EAAE,sBAAsB;CAClC,CACD,CAAA;AAED,MAAM,oBAAoB,GAAG,KAAK,CAA8B,sBAAsB,EAAE,0BAA0B,CAAC,CAAA;AACnH,OAAO,EAAE,oBAAoB,EAAE,CAAA","sourcesContent":["import { model, Schema, Types } from 'mongoose'\n\nexport interface IDevStatsGraphQLCalls {\n\tname: string\n\thit?: boolean\n}\n\nexport interface IDevStatsGraphQLCallsSchema {\n\t_id: Types.ObjectId\n\tlist: [\n\t\t{\n\t\t\t_id?: Types.ObjectId\n\t\t\tname: string\n\t\t\thit?: boolean\n\t\t}\n\t]\n\tdataora: Date\n\t__v?: number\n}\n\nconst DevStatsGraphQLCallsSchema = new Schema<IDevStatsGraphQLCallsSchema>(\n\t{\n\t\tlist: {\n\t\t\ttype: [\n\t\t\t\t{\n\t\t\t\t\t_id: {\n\t\t\t\t\t\ttype: Schema.Types.ObjectId,\n\t\t\t\t\t\trequired: true\n\t\t\t\t\t},\n\t\t\t\t\tname: {\n\t\t\t\t\t\ttype: String,\n\t\t\t\t\t\trequired: true\n\t\t\t\t\t},\n\t\t\t\t\thit: {\n\t\t\t\t\t\ttype: Boolean,\n\t\t\t\t\t\trequired: false\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t],\n\t\t\trequired: true\n\t\t},\n\t\tdataora: {\n\t\t\ttype: Date,\n\t\t\trequired: false,\n\t\t\tdefault: () => new Date() // Ensure a new Date is generated for each document.\n\t\t},\n\t\t__v: {\n\t\t\ttype: Number,\n\t\t\trequired: false\n\t\t}\n\t},\n\t{\n\t\tcollection: 'devStatsGraphQLCalls'\n\t}\n)\n\nconst DevStatsGraphQLCalls = model<IDevStatsGraphQLCallsSchema>('DevStatsGraphQLCalls', DevStatsGraphQLCallsSchema)\nexport { DevStatsGraphQLCalls }\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"LogGlobalError.mjs","sourceRoot":"","sources":["../../../../../src/graphQL/models/MongoDB/log/LogGlobalError.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAS,MAAM,UAAU,CAAA;AAU/C,MAAM,wBAAwB,GAAG,IAAI,MAAM,CAC1C;IACC,CAAC,EAAE;QACF,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,CAAC,EAAE;QACF,IAAI,EAAE,CAAC,MAAM,CAAC;QACd,QAAQ,EAAE,IAAI;KACd;IACD,CAAC,EAAE;QACF,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,oDAAoD;KAC9E;IACD,GAAG,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,KAAK;KACf;CACD,EACD;IACC,UAAU,EAAE,gBAAgB;CAC5B,CACD,CAAA;AAED,MAAM,cAAc,GAAG,KAAK,CAA4B,gBAAgB,EAAE,wBAAwB,CAAC,CAAA;AACnG,OAAO,EAAE,cAAc,EAAE,CAAA","sourcesContent":["import { model, Schema, Types } from 'mongoose'\n\nexport interface IGlobalErrorGraphqlSchema {\n\t_id: Types.ObjectId\n\tm: string // message\n\ts: Array<string> // stack\n\ti: Date // inserted\n\t__v?: number\n}\n\nconst GlobalErrorGraphqlSchema = new Schema<IGlobalErrorGraphqlSchema>(\n\t{\n\t\tm: {\n\t\t\ttype: String,\n\t\t\trequired: true\n\t\t},\n\t\ts: {\n\t\t\ttype: [String],\n\t\t\trequired: true\n\t\t},\n\t\ti: {\n\t\t\ttype: Date,\n\t\t\trequired: false,\n\t\t\tdefault: () => new Date() // Ensure a new Date is generated for each document.\n\t\t},\n\t\t__v: {\n\t\t\ttype: Number,\n\t\t\trequired: false\n\t\t}\n\t},\n\t{\n\t\tcollection: 'logGlobalError'\n\t}\n)\n\nconst LogGlobalError = model<IGlobalErrorGraphqlSchema>('LogGlobalError', GlobalErrorGraphqlSchema)\nexport { LogGlobalError }\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"LogStatsGraphql.mjs","sourceRoot":"","sources":["../../../../../src/graphQL/models/MongoDB/log/LogStatsGraphql.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAS,MAAM,UAAU,CAAA;AAa/C,MAAM,kBAAkB,GAAG,IAAI,MAAM,CACpC;IACC,CAAC,EAAE;QACF,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,CAAC,EAAE;QACF,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,CAAC,EAAE;QACF,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,CAAC,EAAE;QACF,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,CAAC,EAAE;QACF,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,oDAAoD;KAC9E;IACD,GAAG,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,KAAK;KACf;CACD,EACD;IACC,UAAU,EAAE,iBAAiB;CAC7B,CACD,CAAA;AAED,MAAM,eAAe,GAAG,KAAK,CAAsB,iBAAiB,EAAE,kBAAkB,CAAC,CAAA;AACzF,OAAO,EAAE,eAAe,EAAE,CAAA","sourcesContent":["import { model, Schema, Types } from 'mongoose'\n\n/** Document shape of the `LogStatsGraphql` model. Exported so a consumer re-exporting the model can name its type. */\nexport interface IStatsGraphqlSchema {\n\t_id: Types.ObjectId\n\tu: number // user\n\tn: string // query name\n\ti: Date // inserted\n\ts: number // status\n\tm: number // msTot\n\t__v?: number\n}\n\nconst StatsGraphqlSchema = new Schema<IStatsGraphqlSchema>(\n\t{\n\t\tu: {\n\t\t\ttype: Number,\n\t\t\trequired: true\n\t\t},\n\t\tn: {\n\t\t\ttype: String,\n\t\t\trequired: true\n\t\t},\n\t\ts: {\n\t\t\ttype: Number,\n\t\t\trequired: true\n\t\t},\n\t\tm: {\n\t\t\ttype: Number,\n\t\t\trequired: true\n\t\t},\n\t\ti: {\n\t\t\ttype: Date,\n\t\t\trequired: false,\n\t\t\tdefault: () => new Date() // Ensure a new Date is generated for each document.\n\t\t},\n\t\t__v: {\n\t\t\ttype: Number,\n\t\t\trequired: false\n\t\t}\n\t},\n\t{\n\t\tcollection: 'logStatsGraphql'\n\t}\n)\n\nconst LogStatsGraphql = model<IStatsGraphqlSchema>('LogStatsGraphql', StatsGraphqlSchema)\nexport { LogStatsGraphql }\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"LogThrow.mjs","sourceRoot":"","sources":["../../../../../src/graphQL/models/MongoDB/log/LogThrow.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAS,MAAM,UAAU,CAAA;AAW/C,MAAM,qBAAqB,GAAG,IAAI,MAAM,CACvC;IACC,CAAC,EAAE;QACF,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,CAAC,EAAE;QACF,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,EAAE,EAAE;QACH,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,CAAC,EAAE;QACF,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,oDAAoD;KAC9E;IACD,GAAG,EAAE;QACJ,IAAI,EAAE,MAAM;KACZ;CACD,EACD;IACC,UAAU,EAAE,UAAU;CACtB,CACD,CAAA;AAED,MAAM,QAAQ,GAAG,KAAK,CAAyB,UAAU,EAAE,qBAAqB,CAAC,CAAA;AACjF,OAAO,EAAE,QAAQ,EAAE,CAAA","sourcesContent":["import { model, Schema, Types } from 'mongoose'\n\nexport interface ILogThrowGraphqlSchema {\n\t_id: Types.ObjectId\n\tu: number // user\n\tm: string // message\n\tel: number // error level\n\ti: Date // inserted\n\t__v?: number\n}\n\nconst LogThrowGraphqlSchema = new Schema<ILogThrowGraphqlSchema>(\n\t{\n\t\tu: {\n\t\t\ttype: Number,\n\t\t\trequired: true\n\t\t},\n\t\tm: {\n\t\t\ttype: String,\n\t\t\trequired: true\n\t\t},\n\t\tel: {\n\t\t\ttype: Number,\n\t\t\trequired: true\n\t\t},\n\t\ti: {\n\t\t\ttype: Date,\n\t\t\trequired: false,\n\t\t\tdefault: () => new Date() // Ensure a new Date is generated for each document.\n\t\t},\n\t\t__v: {\n\t\t\ttype: Number\n\t\t}\n\t},\n\t{\n\t\tcollection: 'logThrow'\n\t}\n)\n\nconst LogThrow = model<ILogThrowGraphqlSchema>('LogThrow', LogThrowGraphqlSchema)\nexport { LogThrow }\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"GraphQLInputLogin.mjs","sourceRoot":"","sources":["../../../../src/graphQL/schema/GraphQLInput/GraphQLInputLogin.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE/E,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,sBAAsB,CAAC;IAC3D,IAAI,EAAE,mBAAmB;IACzB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QACd,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,cAAc,CAAC,aAAa,CAAC,EAAE;QAClD,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,cAAc,CAAC,aAAa,CAAC,EAAE;KACrD,CAAC;CACF,CAAC,CAAA","sourcesContent":["import { GraphQLInputObjectType, GraphQLNonNull, GraphQLString } from 'graphql'\n\nexport const GraphQLInputLogin = new GraphQLInputObjectType({\n\tname: 'GraphQLInputLogin',\n\tfields: () => ({\n\t\temail: { type: new GraphQLNonNull(GraphQLString) },\n\t\tpassword: { type: new GraphQLNonNull(GraphQLString) }\n\t})\n})\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"IContextAuthenticatedResource.mjs","sourceRoot":"","sources":["../../../../src/graphQL/schema/context/IContextAuthenticatedResource.mts"],"names":[],"mappings":"","sourcesContent":["import { TCommonHeaders } from '@context/TCommonHeaders.mjs'\nimport { IncomingHttpHeaders } from 'http'\nimport { Types } from 'mongoose'\n\ninterface ISessionApi {\n\tid: Types.ObjectId\n\t// disabled?: boolean | 'true'; // no need to read this, user is blocked at resource handler level defined only if true or 'true'\n\t// deleted?: boolean | 'true'; // no need to read this, user is blocked at resource handler level defined only if true or 'true'\n}\n\ntype IStateApi = {\n\tuser: ISessionApi\n}\n\nexport type IContextAuthenticatedResource = {\n\tstate: IStateApi\n\trequest: {\n\t\theader?: TCommonHeaders & IncomingHttpHeaders\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"IContextKoaErrorHandler.mjs","sourceRoot":"","sources":["../../../../src/graphQL/schema/context/IContextKoaErrorHandler.mts"],"names":[],"mappings":"","sourcesContent":["import { IKoaError } from '../../../koa/IKoaError.mjs'\n\nexport interface IContextKoaErrorHandler {\n\tstatus: number\n\tbody: {\n\t\tdescription?: string\n\t\tmessage: string\n\t}\n\tapp: {\n\t\temit(event: string, err: IKoaError, ctx: IContextKoaErrorHandler): void\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"IContextLogin.mjs","sourceRoot":"","sources":["../../../../src/graphQL/schema/context/IContextLogin.mts"],"names":[],"mappings":"","sourcesContent":["import { ICookies } from '@lib/ICookies.mjs'\n\nexport type IContextLogin = {\n\tcookies: ICookies\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"IContextLogout.mjs","sourceRoot":"","sources":["../../../../src/graphQL/schema/context/IContextLogout.mts"],"names":[],"mappings":"","sourcesContent":["import { TCommonHeaders } from '@context/TCommonHeaders.mjs'\nimport { ICookies } from '@lib/ICookies.mjs'\nimport { IncomingHttpHeaders } from 'http'\n\ninterface ISessionApi {\n\trefreshToken: string // 90 days - cookie\n\taccessToken?: string // 90 min - headers\n}\n\ntype IStateApi = {\n\tuser: ISessionApi\n}\n\nexport type IContextLogout = {\n\tstate: IStateApi\n\tcookies: ICookies\n\trequest: {\n\t\theader?: TCommonHeaders & IncomingHttpHeaders\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"IContextRefresh.mjs","sourceRoot":"","sources":["../../../../src/graphQL/schema/context/IContextRefresh.mts"],"names":[],"mappings":"","sourcesContent":["import { TCommonHeaders } from '@context/TCommonHeaders.mjs'\nimport { ICookies } from '@lib/ICookies.mjs'\nimport { IncomingHttpHeaders } from 'http'\nimport { Types } from 'mongoose'\n\ninterface ISessionAuthenticated {\n\tid: Types.ObjectId\n\trefreshToken: string\n\t// disabled?: boolean | 'true'; // no need to read this, user is blocked at resource handler level defined only if true or 'true'\n\t// deleted?: boolean | 'true'; // no need to read this, user is blocked at resource handler level defined only if true or 'true'\n}\n\ntype IStateAuthenticated = {\n\tuser: ISessionAuthenticated\n}\n\nexport type IContextRefresh = {\n\tstate: IStateAuthenticated\n\tcookies: ICookies\n\trequest: {\n\t\theader?: TCommonHeaders & IncomingHttpHeaders\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"TCommonHeaders.mjs","sourceRoot":"","sources":["../../../../src/graphQL/schema/context/TCommonHeaders.mts"],"names":[],"mappings":"","sourcesContent":["export type TCommonHeaders = {\n\thost?: string\n\tauthorization?: string\n\t'user-agent'?: string\n\t'content-type'?: string\n\t'content-length'?: string\n\t'x-introspectioncode'?: string\n\taccept?: string\n\torigin?: string\n\treferer?: string\n\tcookie?: string\n\tconnection?: string\n\tdnt?: string\n\toperation?: string\n\t// Add other common headers as needed\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"IFindAndUpdate.mjs","sourceRoot":"","sources":["../../../../src/graphQL/schema/interfaces/IFindAndUpdate.mts"],"names":[],"mappings":"","sourcesContent":["import { Types } from 'mongoose'\n\n/**\n * Use like this:\n * const result = await Model.findByIdAndUpdate(...) as IFindAndUpdate<IImprenditoreModel>;\n * result.value; // IImprenditoreModel | null\n *\n * If you do not need the new or the old document, use updateOne() !\n */\nexport interface IFindAndUpdate<T = unknown> {\n\tvalue: T | null // The document\n\tlastErrorObject: {\n\t\tupdatedExisting: boolean // Indicates whether it updated an existing document (true) or created a new one via\n\t\t// \tupsert (false)\n\t\tupserted?: Types.ObjectId // Present only if an upsert occurred\n\t}\n\tok: 0 | 1 // indicates whether the MongoDB command succeeded (1) or had an error (0). If the\n\t// \tdocument was not found, ok is 1 because the command succeeded !! so\n\t// \tcheck if value is not null to verify the document was found\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"emailChangeHashVerify.mjs","sourceRoot":"","sources":["../../../../src/graphQL/schema/mutations/emailChangeHashVerify.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAmC,4CAAmC;AACzG,OAAO,EAAE,wBAAwB,EAAsB,kDAAyC;AAChG,OAAO,EAAE,SAAS,EAAE,mCAA0B;AAC9C,OAAO,EAAE,QAAQ,EAAE,0CAAoC;AACvD,OAAO,eAAqC,2DAAkD;AAC9F,OAAO,EAAE,WAAW,EAAgB,uDAA8C;AAClF,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,kDAAyC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,2CAAqC;AAClE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAkCvE;;;GAGG;AACH,KAAK,UAAU,kBAAkB,CAAC,GAAmB,EAAE,GAAmB,EAAE,YAAgC;IAC3G,cAAc;IAEd,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AAW,CAAC,EAAE,MAAM,EAAE,CAAC;iBACxC,MAAM,CAAC,eAAe,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;iBAC3G,IAAI,EAAE,CAAA;YAER,uEAAuE;YACvE,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;gBACnB,OAAO,KAAK,CAAA,CAAC,eAAe;YAC7B,CAAC;YAED,MAAM,GAAG,GAAmB,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAA;YAE1D,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAmB,CAAA;YACnD,MAAM,WAAW,GAAG,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,WAAW,CAAqB,CAAA;YAEzE,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC9C,OAAO,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,WAAW,CAAC,CAAA;YAC9C,CAAC;YACD,OAAO,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,YAAY,CAAuB,CAAC,CAAA;QAC9F,CAAC;KACD,CAAA;AACF,CAAC,CAAA;AAKD,uFAAuF;AACvF,MAAM,CAAC,MAAM,qBAAqB,GAAmC,mCAAmC,CAAC;IACxG,KAAK,EAAE,QAAQ;IACf,KAAK,EAAE,0BAA0B;IACjC,eAAe;IACf,WAAW;CACX,CAAC,CAAA","sourcesContent":["import { DEFAULT_VERIFY_EMAIL_PATHS, IVerifyEmailPaths, TAccessModel } from '@lib/access/accessPaths.mjs'\nimport { defaultVerifyEmailMailer, IVerifyEmailMailer } from '@lib/access/verifyEmailMailer.mjs'\nimport { StringLib } from '@lib/StringLib.mjs'\nimport { UserBase } from '@models/MongoDB/UserBase.mjs'\nimport confirmNewEmail, { TConfirmNewEmail } from '@private/lib/access/db/confirmNewEmail.mjs'\nimport { incReqTimes, TIncReqTimes } from '@private/lib/access/db/incReqTimes.mjs'\nimport { buildProjection, readPath } from '@private/lib/access/pathTools.mjs'\nimport { throwInternalError } from '@throw/throwInternalError.mjs'\nimport { GraphQLBoolean, GraphQLNonNull, GraphQLString } from 'graphql'\nimport { Types } from 'mongoose'\n\n/** Arguments accepted by the `emailChangeHashVerify` mutation. Exported so a consumer re-exporting the bound mutation can name its type. */\nexport interface IEmailChangeHashVerifyArgs {\n\temail: string\n\thash: string\n}\n\n/** Model, field map and writers the resolver needs, all bound together by the caller. */\nexport interface IEmailChangeHashVerifyDeps {\n\tmodel: TAccessModel\n\tpaths: IVerifyEmailPaths\n\tconfirmNewEmail: TConfirmNewEmail\n\tincReqTimes: TIncReqTimes\n\t/**\n\t * Who sends the three notifications this resolver can trigger. Optional, defaulting to the debounced\n\t * SocketLabs binding — the client used to be constructed in `resolve`, so no caller could exercise a\n\t * branch without a real send.\n\t */\n\tmailer?: IVerifyEmailMailer\n}\n\n/**\n * Everything the extracted branch handlers need, bundled so each stays within the max-params budget:\n * the bound deps, the lean document just read, the lowercased email and the resolved mailer.\n */\ninterface IVerifyContext {\n\tdeps: IEmailChangeHashVerifyDeps\n\tuser: unknown\n\tuEmail: string\n\tmailer: IVerifyEmailMailer\n}\n\n/**\n * The submitted hash does not match the stored one: count the attempt and warn the account owner.\n * Extracted from resolve() only to keep it inside the max-lines-per-function budget — behaviour unchanged.\n */\nasync function handleHashMismatch(ctx: IVerifyContext, uId: Types.ObjectId, requestTimes: number | undefined) {\n\t// hash failed\n\n\tif (typeof requestTimes === 'undefined') {\n\t\tthrow throwInternalError()\n\t}\n\n\tawait ctx.deps.incReqTimes(uId)\n\t// noinspection ES6MissingAwait\n\tctx.mailer.wrongHash(ctx.uEmail, requestTimes)\n\treturn false\n}\n\n/**\n * The submitted hash matches: enforce the freshness/account guards and, if the target email is still\n * free, accept it. Extracted from resolve() only to keep it inside the max-lines-per-function budget.\n */\nasync function handleValidHash(ctx: IVerifyContext, uId: Types.ObjectId, dateLastReq: Date | undefined) {\n\tconst { deps, user, uEmail, mailer } = ctx\n\tconst { paths } = deps\n\n\tif (typeof dateLastReq === 'undefined') {\n\t\t// @fixme sentry 'dateLastReq is undefined'\n\t\tthrow throwInternalError()\n\t}\n\n\t// if dateLastReq is older than 3 days, warn and stop\n\tconst StrLibObj = new StringLib()\n\tconst now = new Date()\n\tconst day3ago = new Date(now.setDate(now.getDate() - 3))\n\n\tif (StrLibObj.isoToTimestamp(day3ago) > StrLibObj.isoToTimestamp(dateLastReq)) {\n\t\t// dateLastReq too old then 3 days\n\n\t\t// noinspection ES6MissingAwait\n\t\tmailer.hashReqTooOld(uEmail)\n\t\treturn false\n\t}\n\n\t// account is deleted -> maybe by admin for any reason\n\t// Read raw: this is a .lean() query, so Mongoose casting never runs and these are real booleans\n\t// only on data that scripts/migrate-account-disabled-to-boolean.mjs has been through. A legacy\n\t// string 'false' is truthy and blocks here — migrate, don't coerce.\n\tif (readPath(user, paths.deleted)) {\n\t\treturn false\n\t}\n\t// if account is disabled, for any reason\n\tif (readPath(user, paths.disabled)) {\n\t\t// noinspection ES6MissingAwait\n\t\tmailer.accountDisabled(uEmail)\n\t\treturn false\n\t}\n\n\t// valid request. meanwhile, has some user registered with this email address ??\n\tconst qty = await deps.model.countDocuments({ [paths.email]: uEmail })\n\tif (qty > 0) {\n\t\treturn false\n\t}\n\n\t// accept new email\n\tawait deps.confirmNewEmail(uId, uEmail)\n\treturn true\n}\n\n/**\n * Change email - Verify match between email and hash\n *\n * The collection and every field path come from `deps`, so the same resolver serves any account model.\n * The projection is built from the same map the reads use, which is what keeps a read field from going\n * missing — the exact bug that made every wrong hash answer 500 through 5.1.0.\n */\nexport const createEmailChangeHashVerifyMutation = (deps: IEmailChangeHashVerifyDeps) => {\n\tconst mailer = deps.mailer ?? defaultVerifyEmailMailer\n\n\treturn {\n\t\tdescription: 'Change email - Verify match between email and hash',\n\t\ttype: new GraphQLNonNull(GraphQLBoolean),\n\t\targs: {\n\t\t\temail: { type: new GraphQLNonNull(GraphQLString) },\n\t\t\thash: { type: new GraphQLNonNull(GraphQLString) }\n\t\t},\n\t\tasync resolve(_: unknown, args: IEmailChangeHashVerifyArgs) {\n\t\t\tconst { paths } = deps\n\t\t\tconst uEmail = args.email.toLowerCase()\n\n\t\t\t// search if the email exists\n\t\t\t// Every field this resolver reads must be listed. account.email.requestTimes was missing, and\n\t\t\t// because this is a .lean() read the absent key made handleHashMismatch throw 500 on *every*\n\t\t\t// wrong hash: the strike counter never advanced and the owner never got the wrongHash warning.\n\t\t\tconst user = await deps.model\n\t\t\t\t.findOne({ [paths.newEmailTmp]: uEmail })\n\t\t\t\t.select(buildProjection([paths.hash, paths.dateLastReq, paths.requestTimes, paths.deleted, paths.disabled]))\n\t\t\t\t.lean()\n\n\t\t\t// if email not found, return (do not tell the user the real problem !)\n\t\t\tif (user === null) {\n\t\t\t\treturn false // @fixme throw\n\t\t\t}\n\n\t\t\tconst ctx: IVerifyContext = { deps, user, uEmail, mailer }\n\n\t\t\tconst uId = readPath(user, '_id') as Types.ObjectId\n\t\t\tconst dateLastReq = readPath(user, paths.dateLastReq) as Date | undefined\n\n\t\t\tif (args.hash === readPath(user, paths.hash)) {\n\t\t\t\treturn handleValidHash(ctx, uId, dateLastReq)\n\t\t\t}\n\t\t\treturn handleHashMismatch(ctx, uId, readPath(user, paths.requestTimes) as number | undefined)\n\t\t}\n\t}\n}\n\n/** Shape of the bound mutation, for the modules that take it as a dependency. */\nexport type TEmailChangeHashVerifyMutation = ReturnType<typeof createEmailChangeHashVerifyMutation>\n\n/** `UserBase`-bound default — the mutation every existing consumer already imports. */\nexport const emailChangeHashVerify: TEmailChangeHashVerifyMutation = createEmailChangeHashVerifyMutation({\n\tmodel: UserBase,\n\tpaths: DEFAULT_VERIFY_E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,CAAA;QAErB,IAAI,WAAW,GAAG,EAAE,CAAA;QAEpB,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,YAAY,EAAE,CAAA;QAC7C,IAAI,CAAC;YACJ,MAAM,OAAO,CAAC,eAAe,CAAC,KAAK,IAAI,EAAE;gBACxC,6BAA6B;gBAC7B,MAAM,IAAI,GAAG,MAAM,2BAA2B,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;gBAEzE,YAAY;gBACZ,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAA;gBACvB,MAAM,qBAAqB,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;gBAEzD,WAAW,GAAG,mBAAmB,EAAE,CAAA;gBACnC,MAAM,YAAY,GAAG,oBAAoB,EAAE,CAAA;gBAC3C,MAAM,WAAW,GAAG,iBAAiB,EAAE,CAAA;gBAEvC,MAAM,oBAAoB,CAAC,GAAG,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,CAAC,CAAA;gBACvE,eAAe,CAAC,GAAG,EAAE,YAAY,CAAC,CAAA;YACnC,CAAC,CAAC,CAAA;QACH,CAAC;QAAC,OAAO,CAAU,EAAE,CAAC;YACrB,WAAW,GAAG,EAAE,CAAA;YAChB,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAA;YAC1B,eAAe,CAAC,CAAyB,CAAC,CAAA;QAC3C,CAAC;gBAAS,CAAC;YACV,MAAM,OAAO,CAAC,UAAU,EAAE,CAAA;QAC3B,CAAC;QACD,OAAO,EAAE,WAAW,EAAE,CAAA;IACvB,CAAC;CACD,CAAA","sourcesContent":["import { IContextLogin } from '@context/IContextLogin.mjs'\nimport { checkEmailLen } from '@lib/checkEmailLen.mjs'\nimport { checkPwdLen } from '@lib/checkPwdLen.mjs'\nimport { setLoginCookies } from '@lib/setLoginCookies.mjs'\nimport { accessTokenExpiry, generateAccessToken, generateRefreshToken } from '@lib/tokens.mjs'\nimport { tryCatchRethrow } from '@lib/tryCatchRethrow.mjs'\nimport { checkUserLoginAuthorization } from '@private/graphQL/schema/mutations/checkUserLoginAuthorization.mjs'\nimport { setRedisLoginSession } from '@private/graphQL/schema/mutations/setRedisLoginSession.mjs'\nimport { updateLoginStats4ever } from '@private/graphQL/schema/mutations/updateLoginStats4ever.mjs'\nimport * as Sentry from '@sentry/node'\nimport { LoginType } from '@stypes/LoginType.mjs'\nimport { GraphQLError, GraphQLNonNull, GraphQLString } from 'graphql'\nimport mongoose from 'mongoose'\n\n/** Arguments accepted by the `login4Ever` mutation. Exported so a consumer re-exporting the bound mutation can name its type. */\nexport interface ILogin4EverArgs {\n\temail: string\n\tpassword: string\n}\n\nexport const login4Ever = {\n\tdescription: 'login in platform WITHOUT remember me flag',\n\ttype: new GraphQLNonNull(LoginType),\n\targs: {\n\t\temail: { type: new GraphQLNonNull(GraphQLString) },\n\t\tpassword: { type: new GraphQLNonNull(GraphQLString) }\n\t},\n\tasync resolve(_: unknown, args: ILogin4EverArgs, ctx: IContextLogin) {\n\t\tconst { email, password } = args\n\n\t\tconst uEmail = email.toLowerCase().trim()\n\t\tcheckEmailLen(uEmail)\n\t\tcheckPwdLen(password)\n\n\t\tlet accessToken = ''\n\n\t\tconst session = await mongoose.startSession()\n\t\ttry {\n\t\t\tawait session.withTransaction(async () => {\n\t\t\t\t// search if the email exists\n\t\t\t\tconst user = await checkUserLoginAuthorization(uEmail, password, session)\n\n\t\t\t\t// pwd valid\n\t\t\t\tconst uId = user.userId\n\t\t\t\tawait updateLoginStats4ever(uId, user.lastLogin, session)\n\n\t\t\t\taccessToken = generateAccessToken()\n\t\t\t\tconst refreshToken = generateRefreshToken()\n\t\t\t\tconst accTokenExp = accessTokenExpiry()\n\n\t\t\t\tawait setRedisLoginSession(uId, accessToken, accTokenExp, refreshToken)\n\t\t\t\tsetLoginCookies(ctx, refreshToken)\n\t\t\t})\n\t\t} catch (e: unknown) {\n\t\t\taccessToken = ''\n\t\t\tSentry.captureException(e)\n\t\t\ttryCatchRethrow(e as GraphQLError | Error)\n\t\t} finally {\n\t\t\tawait session.endSession()\n\t\t}\n\t\treturn { accessToken }\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"loginAdmin.mjs","sourceRoot":"","sources":["../../../../src/graphQL/schema/mutations/loginAdmin.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,uCAA8B;AACtD,OAAO,EAAE,WAAW,EAAE,qCAA4B;AAClD,OAAO,EAAE,eAAe,EAAE,yCAAgC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,gCAAuB;AAC9F,OAAO,EAAE,eAAe,EAAE,yCAAgC;AAC1D,OAAO,EAAE,gCAAgC,EAAE,uFAA8E;AACzH,OAAO,EAAE,oBAAoB,EAAE,2EAAkE;AACjG,OAAO,EAAE,qBAAqB,EAAE,4EAAmE;AACnG,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,+BAA6B;AACjD,OAAO,EAAE,cAAc,EAAgB,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACrF,OAAO,QAAQ,MAAM,UAAU,CAAA;AAS/B;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACzB,WAAW,EAAE,yBAAyB;IACtC,IAAI,EAAE,IAAI,cAAc,CAAC,SAAS,CAAC;IACnC,IAAI,EAAE;QACL,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,cAAc,CAAC,aAAa,CAAC,EAAE;QAClD,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,cAAc,CAAC,aAAa,CAAC,EAAE;QACrD,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,cAAc,CAAC,cAAc,CAAC,EAAE;KACxD;IACD,KAAK,CAAC,OAAO,CAAC,CAAU,EAAE,IAAqB,EAAE,GAAkB;QAClE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE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mjs'\nimport { checkEmailLen } from '@lib/checkEmailLen.mjs'\nimport { checkPwdLen } from '@lib/checkPwdLen.mjs'\nimport { setLoginCookies } from '@lib/setLoginCookies.mjs'\nimport { accessTokenExpiry, generateAccessToken, generateRefreshToken } from '@lib/tokens.mjs'\nimport { tryCatchRethrow } from '@lib/tryCatchRethrow.mjs'\nimport { checkUserAdminLoginAuthorization } from '@private/graphQL/schema/mutations/checkUserAdminLoginAuthorization.mjs'\nimport { setRedisLoginSession } from '@private/graphQL/schema/mutations/setRedisLoginSession.mjs'\nimport { updateAdminLoginStats } from '@private/graphQL/schema/mutations/updateAdminLoginStats.mjs'\nimport * as Sentry from '@sentry/node'\nimport { LoginType } from '@stypes/LoginType.mjs'\nimport { GraphQLBoolean, GraphQLError, GraphQLNonNull, GraphQLString } from 'graphql'\nimport mongoose from 'mongoose'\n\n/** Arguments accepted by the `loginAdmin` mutation. Exported so a consumer re-exporting the bound mutation can name its type. */\nexport interface ILoginAdminArgs {\n\temail: string\n\tpassword: string\n\trememberMe: boolean\n}\n\n/**\n *\n */\nexport const loginAdmin = {\n\tdescription: 'login admin in platform',\n\ttype: new GraphQLNonNull(LoginType),\n\targs: {\n\t\temail: { type: new GraphQLNonNull(GraphQLString) },\n\t\tpassword: { type: new GraphQLNonNull(GraphQLString) },\n\t\trememberMe: { type: new GraphQLNonNull(GraphQLBoolean) }\n\t},\n\tasync resolve(_: unknown, args: ILoginAdminArgs, ctx: IContextLogin) {\n\t\tconst { email, password, rememberMe } = args\n\n\t\tconst uEmail = email.toLowerCase().trim()\n\t\tcheckEmailLen(uEmail)\n\t\tcheckPwdLen(password)\n\n\t\tlet accessToken = ''\n\n\t\tconst session = await mongoose.startSession()\n\t\ttry {\n\t\t\tawait session.withTransaction(async () => {\n\t\t\t\t// search if the email exists\n\t\t\t\tconst user = await checkUserAdminLoginAuthorization(uEmail, password, session)\n\t\t\t\t// pwd valid\n\t\t\t\tconst uId = user.userId\n\t\t\t\tawait updateAdminLoginStats(uId, user.lastLogin, rememberMe, session)\n\n\t\t\t\taccessToken = generateAccessToken()\n\t\t\t\tconst refreshToken = generateRefreshToken()\n\t\t\t\tconst accTokenExp = accessTokenExpiry()\n\n\t\t\t\tawait setRedisLoginSession(uId, accessToken, accTokenExp, refreshToken)\n\t\t\t\tsetLoginCookies(ctx, refreshToken)\n\t\t\t})\n\t\t} catch (e: unknown) {\n\t\t\taccessToken = ''\n\t\t\tSentry.captureException(e)\n\t\t\ttryCatchRethrow(e as GraphQLError | Error)\n\t\t} finally {\n\t\t\tawait session.endSession()\n\t\t}\n\n\t\treturn {\n\t\t\taccessToken\n\t\t}\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"loginRememberme.mjs","sourceRoot":"","sources":["../../../../src/graphQL/schema/mutations/loginRememberme.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,uCAA8B;AACtD,OAAO,EAAE,WAAW,EAAE,qCAA4B;AAClD,OAAO,EAAE,eAAe,EAAE,yCAAgC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,gCAAuB;AAC9F,OAAO,EAAE,eAAe,EAAE,yCAAgC;AAC1D,OAAO,EAAE,2BAA2B,EAAE,kFAAyE;AAC/G,OAAO,EAAE,oBAAoB,EAAE,2EAAkE;AACjG,OAAO,EAAE,0BAA0B,EAAE,iFAAwE;AAC7G,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,+BAA6B;AACjD,OAAO,EAAE,cAAc,EAAgB,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACrF,OAAO,QAAQ,MAAM,UAAU,CAAA;AAS/B,MAAM,CAAC,MAAM,eAAe,GAAG;IAC9B,WAAW,EAAE,yCAAyC;IACtD,IAAI,EAAE,IAAI,cAAc,CAAC,SAAS,CAAC;IACnC,IAAI,EAAE;QACL,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,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B,WAAW,GAAG,EAAE,CAAA;YAChB,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAA;YAC1B,eAAe,CAAC,CAAyB,CAAC,CAAA;QAC3C,CAAC;gBAAS,CAAC;YACV,MAAM,OAAO,CAAC,UAAU,EAAE,CAAA;QAC3B,CAAC;QAED,OAAO,EAAE,WAAW,EAAE,CAAA;IACvB,CAAC;CACD,CAAA","sourcesContent":["import { IContextLogin } from '@context/IContextLogin.mjs'\nimport { checkEmailLen } from '@lib/checkEmailLen.mjs'\nimport { checkPwdLen } from '@lib/checkPwdLen.mjs'\nimport { setLoginCookies } from '@lib/setLoginCookies.mjs'\nimport { accessTokenExpiry, generateAccessToken, generateRefreshToken } from '@lib/tokens.mjs'\nimport { tryCatchRethrow } from '@lib/tryCatchRethrow.mjs'\nimport { checkUserLoginAuthorization } from '@private/graphQL/schema/mutations/checkUserLoginAuthorization.mjs'\nimport { setRedisLoginSession } from '@private/graphQL/schema/mutations/setRedisLoginSession.mjs'\nimport { updateLoginStatsRememberme } from '@private/graphQL/schema/mutations/updateLoginStatsRememberme.mjs'\nimport * as Sentry from '@sentry/node'\nimport { LoginType } from '@stypes/LoginType.mjs'\nimport { GraphQLBoolean, GraphQLError, GraphQLNonNull, GraphQLString } from 'graphql'\nimport mongoose from 'mongoose'\n\n/** Arguments accepted by the `loginRememberme` mutation. Exported so a consumer re-exporting the bound mutation can name its type. */\nexport interface ILoginRemembermeArgs {\n\temail: string\n\tpassword: string\n\trememberMe: boolean\n}\n\nexport const loginRememberme = {\n\tdescription: 'login in platform with remember me flag',\n\ttype: new GraphQLNonNull(LoginType),\n\targs: {\n\t\temail: { type: new GraphQLNonNull(GraphQLString) },\n\t\tpassword: { type: new GraphQLNonNull(GraphQLString) },\n\t\trememberMe: { type: new GraphQLNonNull(GraphQLBoolean) }\n\t},\n\tasync resolve(_: unknown, args: ILoginRemembermeArgs, ctx: IContextLogin) {\n\t\tconst { email, password, rememberMe } = args\n\n\t\tconst uEmail = email.toLowerCase().trim()\n\t\tcheckEmailLen(uEmail)\n\t\tcheckPwdLen(password)\n\n\t\tlet accessToken = ''\n\n\t\tconst session = await mongoose.startSession()\n\t\ttry {\n\t\t\tawait session.withTransaction(async () => {\n\t\t\t\t// search if the email exists\n\t\t\t\tconst user = await checkUserLoginAuthorization(uEmail, password, session)\n\t\t\t\t// pwd valid\n\t\t\t\tconst uId = user.userId\n\t\t\t\tawait updateLoginStatsRememberme(uId, user.lastLogin, rememberMe, session)\n\n\t\t\t\taccessToken = generateAccessToken()\n\t\t\t\tconst refreshToken = generateRefreshToken()\n\t\t\t\tconst accTokenExp = accessTokenExpiry()\n\n\t\t\t\tawait setRedisLoginSession(uId, accessToken, accTokenExp, refreshToken)\n\t\t\t\tsetLoginCookies(ctx, refreshToken)\n\t\t\t})\n\t\t} catch (e: unknown) {\n\t\t\taccessToken = ''\n\t\t\tSentry.captureException(e)\n\t\t\ttryCatchRethrow(e as GraphQLError | Error)\n\t\t} finally {\n\t\t\tawait session.endSession()\n\t\t}\n\n\t\treturn { accessToken }\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"logout.mjs","sourceRoot":"","sources":["../../../../src/graphQL/schema/mutations/logout.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,uCAA8B;AACpD,OAAO,EAAE,qBAAqB,EAAE,qDAA4C;AAC5E,OAAO,EAAE,mBAAmB,EAAE,sCAA6B;AAC3D,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AACtC,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAChC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAExD,MAAM,CAAC,MAAM,EAAE,CAAA;AAEf,MAAM,CAAC,MAAM,MAAM,GAAG;IACrB,WAAW,EAAE,QAAQ;IACrB,IAAI,EAAE,IAAI,cAAc,CAAC,cAAc,CAAC;IACxC,KAAK,CAAC,OAAO,CAAC,CAAU,EAAE,EAAE,EAAE,GAAmB;QAChD,IAAI,CAAC;YACJ,iDAAiD;YACjD,iDAAiD;YACjD,2FAA2F;YAC3F,mFAAmF;YACnF,wFAAwF;YAExF,MAAM,WAAW,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,GAAG,qBAAqB,CAAC,UAAU,EAAE,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,CAAA;YAElH,MAAM,WAAW,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,WAAW,IAAI,EAAE,CAAA;YACrD,IAAI,WAAW,KAAK,EAAE,EAAE,CAAC;gBACxB,MAAM,WAAW,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,GAAG,qBAAqB,CAAC,SAAS,EAAE,WAAW,CAAC,EAAE,CAAC,CAAA;YAClG,CAAC;YAED,iBAAiB;YACjB,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,EAAE,EAAE,mBAAmB,CAAC,CAAA;QAC1D,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACZ,gBAAgB;YAChB,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAA;QAC3B,CAAC;QAED,OAAO,IAAI,CAAA;IACZ,CAAC;CACD,CAAA","sourcesContent":["import { IContextLogout } from '@context/IContextLogout.mjs'\nimport { redisClient } from '@dataSources/Redis.mjs'\nimport { buildPrefixedRedisKey } from '@lib/Redis/buildPrefixedRedisKey.mjs'\nimport { refreshTokenOptions } from '@lib/tokenOptions.mjs'\nimport * as Sentry from '@sentry/node'\nimport * as dotenv from 'dotenv'\nimport { GraphQLBoolean, GraphQLNonNull } from 'graphql'\n\ndotenv.config()\n\nexport const logout = {\n\tdescription: 'logout',\n\ttype: new GraphQLNonNull(GraphQLBoolean),\n\tasync resolve(_: unknown, {}, ctx: IContextLogout) {\n\t\ttry {\n\t\t\t// delete the access token used to make this call\n\t\t\t// and, if it still exists, the refresh token too\n\t\t\t// buildPrefixedRedisKey is idempotent: the tokens are already prefixed when ctx.state.user\n\t\t\t// comes from authenticatedLogoutHandler, so re-adding the prefix here would delete\n\t\t\t// 'refresh:refresh:<uuid>' — a key that was never written — and leave the session alive\n\n\t\t\tawait redisClient.del(`${process.env.REDIS_KEY}${buildPrefixedRedisKey('refresh:', ctx.state.user.refreshToken)}`)\n\n\t\t\tconst accessToken = ctx.state.user?.accessToken || ''\n\t\t\tif (accessToken !== '') {\n\t\t\t\tawait redisClient.del(`${process.env.REDIS_KEY}${buildPrefixedRedisKey('access:', accessToken)}`)\n\t\t\t}\n\n\t\t\t// delete cookies\n\t\t\tctx.cookies.set('refresh_token', '', refreshTokenOptions)\n\t\t} catch (e) {\n\t\t\t// ignore errors\n\t\t\tSentry.captureException(e)\n\t\t}\n\n\t\treturn true\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"refresh.mjs","sourceRoot":"","sources":["../../../../src/graphQL/schema/mutations/refresh.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,uCAA8B;AACpD,OAAO,EAAE,eAAe,EAAE,yCAAgC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,gCAAuB;AACpH,OAAO,EAAE,eAAe,EAAE,yCAAgC;AAC1D,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,iCAA+B;AACrD,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAChC,OAAO,EAAgB,cAAc,EAAE,MAAM,SAAS,CAAA;AAEtD,MAAM,CAAC,MAAM,EAAE,CAAA;AAEf,MAAM,CAAC,MAAM,OAAO,GAAG;IACtB,WAAW,EAAE,eAAe;IAC5B,IAAI,EAAE,IAAI,cAAc,CAAC,WAAW,CAAC;IACrC,KAAK,CAAC,OAAO,CAAC,CAAU,EAAE,EAAE,EAAE,GAAoB;QACjD,IA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CAAC,SAAS,GAAG,UAAU,EAAE,CAAC,CAAA;YAE9D,MAAM,GAAG,IAAI,CAAA;QACd,CAAC;QAAC,OAAO,CAAU,EAAE,CAAC;YACrB,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAA;YAC1B,cAAc;YACd,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;YAC5E,WAAW,GAAG,EAAE,CAAA;YAChB,eAAe,CAAC,CAAyB,CAAC,CAAA;QAC3C,CAAC;QAED,OAAO;YACN,MAAM;YACN,WAAW;SACX,CAAA;IACF,CAAC;CACD,CAAA","sourcesContent":["import { IContextRefresh } from '@context/IContextRefresh.mjs'\nimport { redisClient } from '@dataSources/Redis.mjs'\nimport { setLoginCookies } from '@lib/setLoginCookies.mjs'\nimport { accessTokenExpiry, generateAccessToken, generateRefreshToken, REFRESH_TOKEN_EXPIRY } from '@lib/tokens.mjs'\nimport { tryCatchRethrow } from '@lib/tryCatchRethrow.mjs'\nimport * as Sentry from '@sentry/node'\nimport { RefreshType } from '@stypes/RefreshType.mjs'\nimport * as dotenv from 'dotenv'\nimport { GraphQLError, GraphQLNonNull } from 'graphql'\n\ndotenv.config()\n\nexport const refresh = {\n\tdescription: 'refresh token',\n\ttype: new GraphQLNonNull(RefreshType),\n\tasync resolve(_: unknown, {}, ctx: IContextRefresh) {\n\t\tlet status = false // default\n\n\t\t// has the refresh token, access token already expired\n\n\t\t// gets the user id already copied into ctx\n\t\tconst userId = ctx.state.user.id.toString()\n\n\t\t// generates the 2 new tokens\n\t\tlet accessToken = generateAccessToken()\n\t\tlet refreshToken = generateRefreshToken()\n\t\tconst keyAccess = `${process.env.REDIS_KEY}access:${accessToken}`\n\t\tconst keyRefresh = `${process.env.REDIS_KEY}refresh:${refreshToken}`\n\n\t\tlet accessTokenData = ctx.state.user\n\t\tconst oldRefresh = ctx.state.user.refreshToken\n\t\t// @ts-expect-error delete refresh\n\t\tdelete accessTokenData.refreshToken\n\n\t\tconst refreshTokenData = { id: userId }\n\n\t\ttry {\n\t\t\t// Store session in Redis\n\t\t\tawait Promise.all([\n\t\t\t\tredisClient.hSet(keyAccess, accessTokenData as unknown as Record<string, string>),\n\t\t\t\tredisClient.hSet(keyRefresh, refreshTokenData as unknown as Record<string, string>)\n\t\t\t])\n\n\t\t\t// set expiry\n\t\t\tconst accTokenExp = accessTokenExpiry()\n\t\t\tawait Promise.all([redisClient.expire(keyAccess, accTokenExp), redisClient.expire(keyRefresh, REFRESH_TOKEN_EXPIRY)])\n\n\t\t\tsetLoginCookies(ctx, refreshToken)\n\n\t\t\t// deletes the refresh token used to make this call\n\t\t\tawait redisClient.del(`${process.env.REDIS_KEY}${oldRefresh}`)\n\n\t\t\tstatus = true\n\t\t} catch (e: unknown) {\n\t\t\tSentry.captureException(e)\n\t\t\t// delete keys\n\t\t\tawait Promise.all([redisClient.del(keyAccess), redisClient.del(keyRefresh)])\n\t\t\taccessToken = ''\n\t\t\ttryCatchRethrow(e as GraphQLError | Error)\n\t\t}\n\n\t\treturn {\n\t\t\tstatus,\n\t\t\taccessToken\n\t\t}\n\t}\n}\n"]}