@axiumine/koa-utils 5.7.0 → 5.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"createVerifyEmailFlow.mjs","sourceRoot":"","sources":["../../../src/lib/access/createVerifyEmailFlow.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAA6B,8DAAwD;AAC5H,OAAO,EAAE,iBAAiB,EAAE,oDAA8C;AAC1E,OAAO,EAAE,qBAAqB,EAAoB,wDAAkD;AAEpG,OAAO,EAAE,uBAAuB,EAAsB,0DAAoD;AAC1G,OAAO,EAAE,iBAAiB,EAAgB,oDAA8C;AACxF,OAAO,EAAE,kBAAkB,EAAiB,qDAA+C;AAC3F,OAAO,EAAE,0BAA0B,EAAyB,6DAAuD;AACnH,OAAO,EAAE,4BAA4B,EAAE,4DAAsD;AAC7F,OAAO,EAAE,6BAA6B,EAAE,6DAAuD;AAC/F,OAAO,EAAE,+BAA+B,EAAE,+DAAyD;AACnG,OAAO,EAAE,qBAAqB,EAAE,qDAA+C;AAC/E,OAAO,EAAE,iCAAiC,EAAE,iEAA2D;AACvG,OAAO,EAAE,kCAAkC,EAAE,kEAA4D;AAEzG,OAAO,EACN,mCAAmC,EAEnC,MAAM,0DAA0D,CAAA;AACjE,OAAO,EAAE,uBAAuB,EAAsB,MAAM,kCAAkC,CAAA;AAC9F,OAAO,EAAqB,uBAAuB,EAA4B,MAAM,mBAAmB,CAAA;AACxG,OAAO,EAAE,kBAAkB,EAAiB,MAAM,0BAA0B,CAAA;AAC5E,OAAO,EAAsB,2BAA2B,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAwCzG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,EACrC,KAAK,EACL,KAAK,EACL,SAAS,GAAG,QAAQ,EACpB,YAAY,EACZ,iBAAiB,EACjB,MAAM,EACN,YAAY,EACgB,EAAoB,EAAE;IAClD,MAAM,QAAQ,GAAG,uBAAuB,CAAC,KAAK,CAAC,CAAA;IAC/C,MAAM,cAAc,GAAG,MAAM,IAAI,cAAc,CAAC,2BAA2B,EAAE,YAAY,IAAI,kBAAkB,EAAE,CAAC,CAAA;IAElH,MAAM,oBAAoB,GAAG,0BAA0B,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;IACxE,MAAM,iBAAiB,GAAG,uBAAuB,CAAC,KAAK,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAA;IAClF,MAAM,eAAe,GAAG,qBAAqB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;IAC9D,uGAAuG;IACvG,MAAM,WAAW,GAAG,iBAAiB,IAAI,iBAAiB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC,CAAA;IACrH,MAAM,WAAW,GAAG,iBAAiB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;IAEtD,MAAM,wBAAwB,GAAG,8BAA8B,CAAC;QAC/D,KAAK,EAAE,QAAQ;QACf,yBAAyB,EAAE,+BAA+B,CAAC,cAAc,CAAC;QAC1E,eAAe,EAAE,qBAAqB,CAAC,WAAW,EAAE,cAAc,CAAC;QACnE,2BAA2B,EAAE,iCAAiC,CAAC,WAAW,EAAE,cAAc,CAAC;QAC3F,4BAA4B,EAAE,kCAAkC,CAAC,WAAW,EAAE,cAAc,CAAC;QAC7F,sBAAsB,EAAE,4BAA4B,CAAC,cAAc,CAAC;QACpE,uBAAuB,EAAE,6BAA6B,CAAC,cAAc,CAAC;KACtE,CAAC,CAAA;IAEF,OAAO;QACN,oBAAoB;QACpB,YAAY,EAAE,kBAAkB,CAAC,KAAK,EAAE,QAAQ,CAAC;QACjD,iBAAiB;QACjB,eAAe;QACf,iBAAiB,EAAE,WAAW;QAC9B,WAAW;QACX,wBAAwB;QACxB,qBAAqB,EAAE,mCAAmC,CAAC;YAC1D,KAAK;YACL,KAAK,EAAE,QAAQ;YACf,eAAe;YACf,WAAW;YACX,MAAM,EAAE,cAAc;SACtB,CAAC;QACF,iBAAiB,EAAE,uBAAuB,CAAC;YAC1C,oBAAoB;YACpB,wBAAwB;YACxB,iBAAiB;SACjB,CAAC;KACF,CAAA;AACF,CAAC,CAAA","sourcesContent":["import { createAssertVerifyEmailAllowed, TAssertVerifyEmailAllowed } from '@private/lib/access/assertVerifyEmailAllowed.mjs'\nimport { createAbandonUser } from '@private/lib/access/db/abandonUser.mjs'\nimport { createConfirmNewEmail, TConfirmNewEmail } from '@private/lib/access/db/confirmNewEmail.mjs'\nimport { TDeleteUserByEmail } from '@private/lib/access/db/deleteUserByEmail.mjs'\nimport { createEnableEmailAccess, TEnableEmailAccess } from '@private/lib/access/db/enableEmailAccess.mjs'\nimport { createIncReqTimes, TIncReqTimes } from '@private/lib/access/db/incReqTimes.mjs'\nimport { createSetEmailHash, TSetEmailHash } from '@private/lib/access/db/setEmailHash.mjs'\nimport { createUserData4VerifyEmail, TUserData4VerifyEmail } from '@private/lib/access/db/userData4VerifyEmail.mjs'\nimport { createHandleIfAccountDeleted } from '@private/lib/access/handleIfAccountDeleted.mjs'\nimport { createHandleIfAccountDisabled } from '@private/lib/access/handleIfAccountDisabled.mjs'\nimport { createHandleIfEmailAlreadyValid } from '@private/lib/access/handleIfEmailAlreadyValid.mjs'\nimport { createHandleIfHashBad } from '@private/lib/access/handleIfHashBad.mjs'\nimport { createHandleIfMoreThan3DaysPassed } from '@private/lib/access/handleIfMoreThan3DaysPassed.mjs'\nimport { createHandleIfTooMuchRequestsTimes } from '@private/lib/access/handleIfTooMuchRequestsTimes.mjs'\n\nimport {\n\tcreateEmailChangeHashVerifyMutation,\n\tTEmailChangeHashVerifyMutation\n} from '../../graphQL/schema/mutations/emailChangeHashVerify.mjs'\nimport { createVerifyEmailRouter, TVerifyEmailRouter } from '../../koa/router/verifyEmail.mjs'\nimport { IVerifyEmailPaths, resolveVerifyEmailPaths, TAccessModel, TOnAbandon } from './accessPaths.mjs'\nimport { createMailThrottle, TMailThrottle } from './createMailThrottle.mjs'\nimport { IVerifyEmailMailer, socketLabsVerifyEmailMailer, throttleMailer } from './verifyEmailMailer.mjs'\n\n/** What the factory needs: the account model, plus any path or policy that differs from the default. */\nexport interface ICreateVerifyEmailFlowArgs {\n\tmodel: TAccessModel\n\tpaths?: Partial<IVerifyEmailPaths>\n\t/** How an abandoned/expired registration is disposed of. Default `'delete'` — current behaviour. */\n\tonAbandon?: TOnAbandon\n\t/**\n\t * Value `'soft-delete'` writes to `paths.deleted`. A function is called once per write, so a layout\n\t * storing a timestamp passes `() => new Date()`. Default `true`, matching `UserBase`. Ignored by the\n\t * other two modes.\n\t */\n\tdeletedValue?: unknown\n\t/** Full override of the disposal writer; wins over `onAbandon` and `deletedValue`. */\n\tdeleteUserByEmail?: TDeleteUserByEmail\n\t/** Who sends the verify-email notifications. Default: SocketLabs, debounced by `mailThrottle`. */\n\tmailer?: IVerifyEmailMailer\n\t/**\n\t * Debounce applied to every notification an unauthenticated request can trigger. Default: a 15 minute\n\t * per-address, per-template window. Pass `ALWAYS_MAIL` for the send-every-time behaviour of 5.6.1 and earlier, or a\n\t * Redis-backed one to share the window across instances. Ignored when `mailer` is supplied — wrap it\n\t * yourself with `throttleMailer` if you want both.\n\t */\n\tmailThrottle?: TMailThrottle\n}\n\n/** Everything the verify-email chain exposes, bound to the model and paths passed in. */\nexport interface IVerifyEmailFlow {\n\tuserData4VerifyEmail: TUserData4VerifyEmail\n\tsetEmailHash: TSetEmailHash\n\tenableEmailAccess: TEnableEmailAccess\n\tconfirmNewEmail: TConfirmNewEmail\n\tdeleteUserByEmail: TDeleteUserByEmail\n\tincReqTimes: TIncReqTimes\n\tassertVerifyEmailAllowed: TAssertVerifyEmailAllowed\n\temailChangeHashVerify: TEmailChangeHashVerifyMutation\n\trouterVerifyEmail: TVerifyEmailRouter\n}\n\n/**\n * Build the whole email-verification chain against any mongoose model.\n *\n * The package's own exports (`userData4VerifyEmail`, `setEmailHash`, `enableEmailAccess`,\n * `confirmNewEmail`, `emailChangeHashVerify`, `routerVerifyEmail`) are this factory applied to\n * `UserBase` with `DEFAULT_VERIFY_EMAIL_PATHS`, so switching to it changes nothing until a path is\n * overridden.\n *\n * The two `*Clear` keys are lists of paths to `$unset`, and neither is derived from the leaf paths the\n * flow reads: a schema storing the verification state as one required-members subdocument is left\n * invalid by unsetting a single member. Pass the container path in that case. See `IVerifyEmailPaths`.\n *\n * Two guards dispose of an abandoned registration — the fifth wrong hash and a link older than 3 days.\n * Through 5.6.1 that always meant `deleteOne`, which is wrong for any row other rows depend on: the\n * package has no idea what a delete costs in a schema it was handed, and a mongo collection has no\n * cascade to lean on. `onAbandon` picks the policy; `deleteUserByEmail` replaces the writer outright.\n * Whatever it does, both guards still throw — disposal never decides whether the link is honoured.\n *\n * Replacing `flow.deleteUserByEmail` on the returned object does nothing, by design: the guards close\n * over the writer at construction time. The value returned is the same one they hold, so it reports the\n * policy rather than setting it.\n *\n * ```ts\n * const flow = createVerifyEmailFlow({\n * model: Account,\n * paths: { email: 'mail', valid: 'verified', verifyClear: ['verification'] },\n * onAbandon: 'soft-delete',\n * deletedValue: () => new Date()\n * })\n * router.get('/check/verify-email/:email/:hash', flow.routerVerifyEmail())\n * ```\n */\nexport const createVerifyEmailFlow = ({\n\tmodel,\n\tpaths,\n\tonAbandon = 'delete',\n\tdeletedValue,\n\tdeleteUserByEmail,\n\tmailer,\n\tmailThrottle\n}: ICreateVerifyEmailFlowArgs): IVerifyEmailFlow => {\n\tconst resolved = resolveVerifyEmailPaths(paths)\n\tconst resolvedMailer = mailer ?? throttleMailer(socketLabsVerifyEmailMailer, mailThrottle ?? createMailThrottle())\n\n\tconst userData4VerifyEmail = createUserData4VerifyEmail(model, resolved)\n\tconst enableEmailAccess = createEnableEmailAccess(model, resolved, resolvedMailer)\n\tconst confirmNewEmail = createConfirmNewEmail(model, resolved)\n\t// One writer, used by the guards and handed back — the returned member cannot disagree with what runs.\n\tconst abandonUser = deleteUserByEmail ?? createAbandonUser({ model, paths: resolved, mode: onAbandon, deletedValue })\n\tconst incReqTimes = createIncReqTimes(model, resolved)\n\n\tconst assertVerifyEmailAllowed = createAssertVerifyEmailAllowed({\n\t\tpaths: resolved,\n\t\thandleIfEmailAlreadyValid: createHandleIfEmailAlreadyValid(resolvedMailer),\n\t\thandleIfHashBad: createHandleIfHashBad(incReqTimes, resolvedMailer),\n\t\thandleIfMoreThan3DaysPassed: createHandleIfMoreThan3DaysPassed(abandonUser, resolvedMailer),\n\t\thandleIfTooMuchRequestsTimes: createHandleIfTooMuchRequestsTimes(abandonUser, resolvedMailer),\n\t\thandleIfAccountDeleted: createHandleIfAccountDeleted(resolvedMailer),\n\t\thandleIfAccountDisabled: createHandleIfAccountDisabled(resolvedMailer)\n\t})\n\n\treturn {\n\t\tuserData4VerifyEmail,\n\t\tsetEmailHash: createSetEmailHash(model, resolved),\n\t\tenableEmailAccess,\n\t\tconfirmNewEmail,\n\t\tdeleteUserByEmail: abandonUser,\n\t\tincReqTimes,\n\t\tassertVerifyEmailAllowed,\n\t\temailChangeHashVerify: createEmailChangeHashVerifyMutation({\n\t\t\tmodel,\n\t\t\tpaths: resolved,\n\t\t\tconfirmNewEmail,\n\t\t\tincReqTimes,\n\t\t\tmailer: resolvedMailer\n\t\t}),\n\t\trouterVerifyEmail: createVerifyEmailRouter({\n\t\t\tuserData4VerifyEmail,\n\t\t\tassertVerifyEmailAllowed,\n\t\t\tenableEmailAccess\n\t\t})\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"verifyEmailMailer.mjs","sourceRoot":"","sources":["../../../src/lib/access/verifyEmailMailer.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,sCAAgC;AAExD,OAAO,EAAE,kBAAkB,EAAiB,MAAM,0BAA0B,CAAA;AA4B5E;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAuB;IAC9D,iBAAiB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,aAAa,EAAE,CAAC,iBAAiB,CAAC,KAAK,CAAC;IAC1E,SAAS,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,aAAa,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC;IACxE,qBAAqB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,aAAa,EAAE,CAAC,qBAAqB,CAAC,KAAK,CAAC;IAClF,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,aAAa,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC;IAClE,eAAe,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,aAAa,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC;IACtE,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,aAAa,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC;CAC9D,CAAA;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAA0B,EAAE,QAAuB,EAAsB,EAAE;IACzG,MAAM,KAAK,GAAG,KAAK,EAAE,IAAY,EAAE,KAAa,EAAE,OAA+B,EAAoB,EAAE,CACtG,CAAC,MAAM,QAAQ,CAAC,GAAG,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;IAE7D,OAAO;QACN,iBAAiB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,mBAAmB,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;QACtG,SAAS,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC5F,qBAAqB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,uBAAuB,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;QAClH,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,eAAe,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC1F,eAAe,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,iBAAiB,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QAChG,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC;KACjD,CAAA;AACF,CAAC,CAAA;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAuB,cAAc,CAAC,2BAA2B,EAAE,kBAAkB,EAAE,CAAC,CAAA","sourcesContent":["import { SocketLabsLib } from '@email/SocketLabsLib.mjs'\n\nimport { createMailThrottle, TMailThrottle } from './createMailThrottle.mjs'\n\n/**\n * Every notification the email-verification chain sends.\n *\n * Each guard used to construct its own `SocketLabsLib` inline, which made no branch of the chain drivable\n * from an integration suite: with real credentials in `.env` the only two paths reachable without mailing\n * a real person were \"address not found\" and the bad-DB guard. Everything else was unit-tests-with-mocks\n * only — including the success path, since `enableEmailAccess` sent the welcome mail itself.\n *\n * Structural, not nominal: any object carrying these six methods satisfies it, `SocketLabsLib` included.\n * `sendWelcome` is the only one not reachable unauthenticated, and the only one the debounce leaves alone.\n */\nexport interface IVerifyEmailMailer {\n\t/** The address is already verified. No counter guards this branch — see {@link createMailThrottle}. */\n\temailAlreadyValid(email: string): Promise<unknown>\n\t/** The hash in the link does not match the stored one. `times` is the strike this attempt makes. */\n\twrongHash(email: string, times: number): Promise<unknown>\n\t/** The strike counter reached 5. */\n\ttooMuchVerifyRequests(email: string): Promise<unknown>\n\t/** The link is older than the 3-day window. */\n\thashReqTooOld(email: string): Promise<unknown>\n\t/** The account is disabled — or deleted: there is no `accountDeleted` template, so both guards send this one. */\n\taccountDisabled(email: string): Promise<unknown>\n\t/** The account has just been activated. Success path only, so never debounced. */\n\tsendWelcome(email: string): Promise<unknown>\n}\n\n/**\n * SocketLabs, constructed per call exactly as the guards did inline.\n *\n * Per call rather than once at module load because the constructor reads `process.env` (server id, API key,\n * platform name, domain, sender) and builds a client from it — hoisting that to import time would pin\n * whatever the environment held when the module was first resolved.\n */\nexport const socketLabsVerifyEmailMailer: IVerifyEmailMailer = {\n\temailAlreadyValid: (email) => new SocketLabsLib().emailAlreadyValid(email),\n\twrongHash: (email, times) => new SocketLabsLib().wrongHash(email, times),\n\ttooMuchVerifyRequests: (email) => new SocketLabsLib().tooMuchVerifyRequests(email),\n\thashReqTooOld: (email) => new SocketLabsLib().hashReqTooOld(email),\n\taccountDisabled: (email) => new SocketLabsLib().accountDisabled(email),\n\tsendWelcome: (email) => new SocketLabsLib().sendWelcome(email)\n}\n\n/**\n * Wrap a mailer so each guard notification is asked of `throttle` first, keyed `<method>:<address>`.\n *\n * A dropped send resolves `undefined` and is invisible to the caller: the guard still throws, so the\n * request still gets the same redirect it always did. Only the mail is suppressed.\n *\n * `sendWelcome` passes straight through. It fires once, on the success path, at the moment the account is\n * activated — debouncing it could silently swallow the welcome mail of an address that re-registered\n * inside the window, and no unauthenticated caller can trigger it twice anyway (the second request meets\n * `handleIfEmailAlreadyValid`).\n */\nexport const throttleMailer = (mailer: IVerifyEmailMailer, throttle: TMailThrottle): IVerifyEmailMailer => {\n\tconst gated = async (kind: string, email: string, deliver: () => Promise<unknown>): Promise<unknown> =>\n\t\t(await throttle(`${kind}:${email}`)) ? deliver() : undefined\n\n\treturn {\n\t\temailAlreadyValid: (email) => gated('emailAlreadyValid', email, () => mailer.emailAlreadyValid(email)),\n\t\twrongHash: (email, times) => gated('wrongHash', email, () => mailer.wrongHash(email, times)),\n\t\ttooMuchVerifyRequests: (email) => gated('tooMuchVerifyRequests', email, () => mailer.tooMuchVerifyRequests(email)),\n\t\thashReqTooOld: (email) => gated('hashReqTooOld', email, () => mailer.hashReqTooOld(email)),\n\t\taccountDisabled: (email) => gated('accountDisabled', email, () => mailer.accountDisabled(email)),\n\t\tsendWelcome: (email) => mailer.sendWelcome(email)\n\t}\n}\n\n/**\n * What the `UserBase`-bound guard exports mail through: SocketLabs, debounced on the default window.\n *\n * One shared throttle for the whole process, because these bindings are one shared chain — the\n * `routerVerifyEmail` export every existing consumer imports. `createVerifyEmailFlow` does not use this\n * value; it builds its own mailer and its own throttle per flow.\n */\nexport const defaultVerifyEmailMailer: IVerifyEmailMailer = throttleMailer(socketLabsVerifyEmailMailer, createMailThrottle())\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"checkEmailLen.mjs","sourceRoot":"","sources":["../../src/lib/checkEmailLen.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,wBAA0B;AAClD,OAAO,EAAE,wBAAwB,EAAE,sDAA2C;AAE9E,MAAM,UAAU,aAAa,CAAC,KAAa;IAC1C,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;QAClB,MAAM,wBAAwB,CAAC,uBAAuB,CAAC,CAAA;IACxD,CAAC;SAAM,IAAI,KAAK,CAAC,MAAM,GAAG,aAAa,EAAE,CAAC;QACzC,MAAM,wBAAwB,CAAC,uBAAuB,aAAa,aAAa,CAAC,CAAA;IAClF,CAAC;AACF,CAAC","sourcesContent":["import { EMAIL_MAX_LEN } from '@lib/Constants.mjs'\nimport { throwErrorWrongUserInput } from '@throw/throwErrorWrongUserInput.mjs'\n\nexport function checkEmailLen(email: string) {\n\tif (email === '') {\n\t\tthrow throwErrorWrongUserInput('Email cannot be empty')\n\t} else if (email.length > EMAIL_MAX_LEN) {\n\t\tthrow throwErrorWrongUserInput(`Email cannot exceed ${EMAIL_MAX_LEN} characters`)\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"checkPwdLen.mjs","sourceRoot":"","sources":["../../src/lib/checkPwdLen.mts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,0GAA0G;AAE1G,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,wBAA0B;AACnE,OAAO,EAAE,wBAAwB,EAAE,sDAA2C;AAE9E,MAAM,UAAU,WAAW,CAAC,QAAgB;IAC3C,IAAI,QAAQ,CAAC,MAAM,GAAG,cAAc,EAAE,CAAC;QACtC,MAAM,wBAAwB,CAAC,uBAAuB,CAAC,CAAA;IACxD,CAAC;SAAM,IAAI,QAAQ,CAAC,MAAM,GAAG,cAAc,EAAE,CAAC;QAC7C,MAAM,wBAAwB,CAAC,sBAAsB,CAAC,CAAA;IACvD,CAAC;AACF,CAAC","sourcesContent":["// OWASP max len 72 chr for bcrypt\n// https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html#input-limits-of-bcrypt\n\nimport { MAX_PWD_LENGTH, MIN_PWD_LENGTH } from '@lib/Constants.mjs'\nimport { throwErrorWrongUserInput } from '@throw/throwErrorWrongUserInput.mjs'\n\nexport function checkPwdLen(password: string) {\n\tif (password.length < MIN_PWD_LENGTH) {\n\t\tthrow throwErrorWrongUserInput('Password is too short')\n\t} else if (password.length > MAX_PWD_LENGTH) {\n\t\tthrow throwErrorWrongUserInput('Password is too long')\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"hitStat.mjs","sourceRoot":"","sources":["../../../../src/lib/db/log/hitStat.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,qEAAoD;AAEnF,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,WAAW,IAAY;IAClD,6BAA6B;IAC7B,MAAM,GAAG,GAAG,MAAM,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;IACnG,MAAM,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAA;IAElB,yBAAyB;IACzB,OAAO,oBAAoB,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;AAC5H,CAAC,CAAA","sourcesContent":["import { DevStatsGraphQLCalls } from '@models/MongoDB/log/DevStatsGraphQLCalls.mjs'\n\nexport const hitStat = async function (call: string) {\n\t// get last document of stats\n\tconst ret = await DevStatsGraphQLCalls.find({}).select('_id').sort({ dataora: -1 }).limit(1).lean()\n\tconst doc = ret[0]\n\n\t// set true for this call\n\treturn DevStatsGraphQLCalls.updateOne({ _id: doc._id, 'list.name': call }, { 'list.$.hit': true }, { runValidators: true })\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"logGlobalError.mjs","sourceRoot":"","sources":["../../../../src/lib/db/log/logGlobalError.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,+DAA8C;AAQvE,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,GAAiB;IACxD,IAAI,GAAG,CAAC,OAAO,KAAK,EAAE,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAM;IAE3D,MAAM,cAAc,GAAG,IAAI,cAAc,CAAC,EAAE,CAAC,CAAA;IAC7C,IAAI,GAAG,CAAC,OAAO,KAAK,EAAE;QAAE,cAAc,CAAC,CAAC,GAAG,GAAG,CAAC,OAAO,CAAA;IACtD,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,cAAc,CAAC,CAAC,GAAG,GAAG,CAAC,QAAQ,CAAA;IAE9D,+BAA+B;AAChC,CAAC,CAAA","sourcesContent":["import { LogGlobalError } from '@models/MongoDB/log/LogGlobalError.mjs'\n\n/** Payload accepted by `logGlobalError`. Exported so a consumer re-exporting the helper can name its type. */\nexport interface IGlobalError {\n\tmessage: string\n\tstackArr: Array<string>\n}\n\nexport const logGlobalError = function (log: IGlobalError) {\n\tif (log.message === '' && log.stackArr.length === 0) return\n\n\tconst newGlobalError = new LogGlobalError({})\n\tif (log.message !== '') newGlobalError.m = log.message\n\tif (log.stackArr.length !== 0) newGlobalError.s = log.stackArr\n\n\t// return newGlobalError.save()\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"logGraphql.mjs","sourceRoot":"","sources":["../../../../src/lib/db/log/logGraphql.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gEAA+C;AAGzE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,KAAqB,EAAE,IAAY,EAAE,MAAc,EAAE,KAAa;IACrG,IAAI,eAAe,CAAC;QACnB,KAAK;QACL,IAAI;QACJ,MAAM;QACN,KAAK;KACL,CAAC,CAAA;IACF;;;;;;;;;OASM;AACP,CAAC,CAAA","sourcesContent":["import { LogStatsGraphql } from '@models/MongoDB/log/LogStatsGraphql.mjs'\nimport { Types } from 'mongoose'\n\n/**\n * Logs operations performed by users\n * @param owner\n * @param nome\n * @param status\n * @param msTot\n */\nexport const logGraphql = function (owner: Types.ObjectId, nome: string, status: number, msTot: number) {\n\tnew LogStatsGraphql({\n\t\towner,\n\t\tnome,\n\t\tstatus,\n\t\tmsTot\n\t})\n\t/*\n return new Promise((resolve, reject) => {\n newStatsGraphql.save((err: any, res: any) => {\n if (err) {\n reject('Log error.' + err)\n } else {\n resolve(res)\n }\n })\n }) */\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"logThrow.mjs","sourceRoot":"","sources":["../../../../src/lib/db/log/logThrow.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,yDAAwC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAEhC,oCAAoC;AAEpC,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,GAAW,EAAE,QAAgB;IAC9D,IAAI,QAAQ,CAAC;QACZ,GAAG,EAAE,IAAI,KAAK,CAAC,QAAQ,EAAE;QACzB,OAAO,EAAE,GAAG;QACZ,QAAQ;QACR,QAAQ,EAAE,IAAI,IAAI,EAAE;KACpB,CAAC,CAAA;IAEF,+LAA+L;IAC/L,mGAAmG;IAEnG,8BAA8B;AAC/B,CAAC,CAAA","sourcesContent":["import { LogThrow } from '@models/MongoDB/log/LogThrow.mjs'\nimport { Types } from 'mongoose'\n\n// const lastSendEmail = new Date();\n\nexport const logThrow = function (log: string, errLevel: number) {\n\tnew LogThrow({\n\t\t_id: new Types.ObjectId(),\n\t\tmessage: log,\n\t\terrLevel,\n\t\tinserted: new Date()\n\t})\n\n\t// send email, check last send email to avoid flooding (check last send email in collection with TTL / create a variable that stays available on every call to this function (lastSendEmail ?))\n\t// check db with config, e.g.: admin sets block on sending email because they're fixing the problem\n\n\t// return newThrowError.save()\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ILoginSet.mjs","sourceRoot":"","sources":["../../../../src/lib/db/login/ILoginSet.mts"],"names":[],"mappings":"","sourcesContent":["export interface ILoginSet {\n\tlogin?: {\n\t\tfirstLogin?: Date\n\t\tlastLogin?: Date\n\t\trememberMe?: boolean\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ILoginUnset.mjs","sourceRoot":"","sources":["../../../../src/lib/db/login/ILoginUnset.mts"],"names":[],"mappings":"","sourcesContent":["export interface ILoginUnset {\n\tlogin?: {\n\t\trememberMe: number\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"registerNewUser.mjs","sourceRoot":"","sources":["../../../src/lib/db/registerNewUser.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,yBAA0B;AAC9C,OAAO,EAAE,eAAe,EAAE,+BAAgC;AAC1D,OAAO,EAAE,QAAQ,EAAE,kDAAoC;AACvD,OAAO,EAAiB,KAAK,EAAE,MAAM,UAAU,CAAA;AAE/C,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,MAAc,EAAE,QAAgB,EAAE,OAAsB;IAC7F,MAAM,MAAM,GAAG,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAA;IACnC,MAAM,KAAK,GAAG,IAAI,IAAI,EAAE,CAAA;IACxB,MAAM,gBAAgB,GAAG,SAAS,EAAE,CAAA;IACpC,MAAM,GAAG,GAAG,MAAM,eAAe,CAAC,QAAQ,CAAC,CAAA;IAE3C,MAAM,QAAQ,GAAG;QAChB;YACC,GAAG,EAAE,MAAM;YACX,KAAK,EAAE;gBACN,KAAK,EAAE,MAAM;gBACb,QAAQ,EAAE,GAAG;aACb;YACD,OAAO,EAAE;gBACR,KAAK,EAAE;oBACN,KAAK,EAAE,KAAK;oBACZ,WAAW,EAAE,KAAK;oBAClB,YAAY,EAAE,CAAC;oBACf,IAAI,EAAE,gBAAgB;iBACtB;gBACD,gBAAgB,EAAE,KAAK;aACvB;SACD;KACD,CAAA;IAED,MAAM,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,CAAC,CAAA;IAC5C,OAAO,gBAAgB,CAAA;AACxB,CAAC","sourcesContent":["import { emailHash } from '@lib/emailHash.mjs'\nimport { encryptPassword } from '@lib/encryptPassword.mjs'\nimport { UserBase } from '@models/MongoDB/UserBase.mjs'\nimport { ClientSession, Types } from 'mongoose'\n\nexport async function registerNewUser(uEmail: string, password: string, session: ClientSession) {\n\tconst userId = new Types.ObjectId()\n\tconst nowDt = new Date()\n\tconst hashConfirmEmail = emailHash()\n\tconst pwd = await encryptPassword(password)\n\n\tconst newUsers = [\n\t\t{\n\t\t\t_id: userId,\n\t\t\tlogin: {\n\t\t\t\temail: uEmail,\n\t\t\t\tpassword: pwd\n\t\t\t},\n\t\t\taccount: {\n\t\t\t\temail: {\n\t\t\t\t\tvalid: false,\n\t\t\t\t\tdateLastReq: nowDt,\n\t\t\t\t\trequestTimes: 1,\n\t\t\t\t\thash: hashConfirmEmail\n\t\t\t\t},\n\t\t\t\tregistrationDate: nowDt\n\t\t\t}\n\t\t}\n\t]\n\n\tawait UserBase.create(newUsers, { session })\n\treturn hashConfirmEmail\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"userExist.mjs","sourceRoot":"","sources":["../../../src/lib/db/userExist.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,kDAAoC;AAGvD,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,MAAc,EAAE,OAAsB;IACrE,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAA;IAE7F,OAAO,IAAI,KAAK,IAAI,CAAA;AACrB,CAAC","sourcesContent":["import { UserBase } from '@models/MongoDB/UserBase.mjs'\nimport { ClientSession } from 'mongoose'\n\nexport async function userExist(uEmail: string, session: ClientSession) {\n\tconst user = await UserBase.findOne({ 'login.email': uEmail }, '_id').session(session).lean()\n\n\treturn user !== null\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"emailHash.mjs","sourceRoot":"","sources":["../../src/lib/emailHash.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,wBAA0B;AACnD,OAAO,EAAE,SAAS,EAAE,wBAA0B;AAE9C,MAAM,UAAU,SAAS;IACxB,MAAM,MAAM,GAAG,IAAI,SAAS,EAAE,CAAA;IAC9B,OAAO,MAAM,CAAC,YAAY,CAAC,cAAc,CAAC,CAAA;AAC3C,CAAC","sourcesContent":["import { EMAIL_HASH_LEN } from '@lib/Constants.mjs'\nimport { StringLib } from '@lib/StringLib.mjs'\n\nexport function emailHash() {\n\tconst StrObj = new StringLib()\n\treturn StrObj.randomString(EMAIL_HASH_LEN)\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"encryptPassword.mjs","sourceRoot":"","sources":["../../src/lib/encryptPassword.mts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,iBAAiB,CAAA;AACpC,OAAO,EAAE,WAAW,EAAE,4CAAyC;AAE/D,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,GAAW;IAChD,OAAO,MAAM,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAA;AAC3C,CAAC","sourcesContent":["import bcrypt from '@node-rs/bcrypt'\nimport { SALT_ROUNDS } from '@private/lib/access/Constants.mjs'\n\nexport async function encryptPassword(pwd: string): Promise<string> {\n\treturn await bcrypt.hash(pwd, SALT_ROUNDS)\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"hash.mjs","sourceRoot":"","sources":["../../src/lib/hash.mts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,iBAAiB,CAAA;AAEpC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,KAAa,EAAE,IAAY;IACjE,IAAI,CAAC;QACJ,OAAO,MAAM,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IACzC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACd,MAAM,GAAG,CAAA;IACV,CAAC;AACF,CAAC","sourcesContent":["import bcrypt from '@node-rs/bcrypt'\n\n/**\n *\n * @param clear plaintext password\n * @param hash password hash\n */\nexport async function compareHashAsync(clear: string, hash: string) {\n\ttry {\n\t\treturn await bcrypt.compare(clear, hash)\n\t} catch (err) {\n\t\tthrow err\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"isSafeRedirectTarget.mjs","sourceRoot":"","sources":["../../src/lib/isSafeRedirectTarget.mts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,4EAA4E;AAC5E,+EAA+E;AAC/E,MAAM,0BAA0B,GAAG,2BAA2B,CAAA;AAE9D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAa;IACjD,OAAO,0BAA0B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AAC9C,CAAC","sourcesContent":["// Anchored allowlist: an absolute path under /x/ and nothing else. The leading `/x/` is\n// literal, so a protocol-relative target ('//evil.com') and an absolute URL\n// ('https://evil.com') both fail before the character class is ever consulted.\nconst ALLOW_ENCODED_URLS_AFTER_X = /^\\/x\\/[a-zA-Z0-9._\\-%/]+$/\n\n/**\n * Is this value safe to hand to `ctx.redirect()`?\n *\n * Exists as a named, tested function rather than an inline regex test because guard\n * *strength* is invisible to static analysis: Semgrep accepts any `if (re.test(x))` or\n * `if (x.startsWith(p))` as a sanitizer without evaluating what the pattern actually\n * admits. Replacing this call with `link.startsWith('/')` was verified to pass both the\n * semgrep scan and the full test suite while accepting '//evil.com' — a real open\n * redirect. The regex therefore lives here, behind tests that pin the attack strings it\n * must reject, and koa-utils.open-redirect.unvalidated recognises only this function as\n * a sanitizer so an ad-hoc replacement is reported instead of silently trusted.\n *\n * Deliberately strict: same-origin absolute paths under the /x/ prefix only. Percent\n * encoding is allowed (the prefix is still literal, so an encoded separator cannot\n * escape the path into an authority), but scheme-relative and absolute URLs are not.\n *\n * @param value the candidate redirect target, typically attacker-influenced\n */\nexport function isSafeRedirectTarget(value: string): boolean {\n\treturn ALLOW_ENCODED_URLS_AFTER_X.test(value)\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"isSessionBlocked.mjs","sourceRoot":"","sources":["../../src/lib/isSessionBlocked.mts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAA+B;IAC/D,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,QAAQ,IAAI,OAAO,EAAE,OAAO,CAAC,CAAA;AACjD,CAAC","sourcesContent":["/**\n * Is the user reported as blocked within the session?\n * Redis stores hash values as strings, so this flag is truthy for both the strings\n * 'true' and 'false' alike — any non-empty value blocks.\n * Use this instead of deleting the token to block user access; set the flag from the control panel.\n */\nexport function isSessionBlocked(redData: Record<string, string>): boolean {\n\treturn !!(redData?.disabled || redData?.deleted)\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"isValidUuidV4.mjs","sourceRoot":"","sources":["../../src/lib/isValidUuidV4.mts"],"names":[],"mappings":"AAAA,MAAM,UAAU,GAAG,wEAAwE,CAAA;AAE3F;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,KAAa;IAC1C,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AAC9B,CAAC","sourcesContent":["const UUID_V4_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i\n\n/**\n * Is this a syntactically valid v4 UUID — the shape generateAccessToken/generateRefreshToken\n * (src/lib/tokens.mts) always produce?\n * Used at the trust boundary to reject a client-supplied token suffix before it is used to build\n * a Redis key: checking the 'access:' prefix alone still leaves the rest of the key client-controlled.\n */\nexport function isValidUuidV4(value: string): boolean {\n\treturn UUID_V4_RE.test(value)\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"makeOnboardingData.mjs","sourceRoot":"","sources":["../../src/lib/makeOnboardingData.mts"],"names":[],"mappings":"AAEA,MAAM,UAAU,kBAAkB,CAAC,IAAiB;IACnD,OAAO,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AAChE,CAAC","sourcesContent":["import { IOnboarding } from '@lib/MongoDB/IOnboarding.mjs'\n\nexport function makeOnboardingData(data: IOnboarding): string | null {\n\treturn data.onboardingDone ? (data.onboardingStep ?? '') : null\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"setLoginCookies.mjs","sourceRoot":"","sources":["../../src/lib/setLoginCookies.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,2BAA6B;AAC3D,OAAO,EAAE,oBAAoB,EAAE,qBAAuB;AAEtD,MAAM,UAAU,eAAe,CAAC,GAAkB,EAAE,YAAoB;IACvE,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,YAAY,EAAE;QAC9C,GAAG,mBAAmB;QACtB,MAAM,EAAE,oBAAoB,GAAG,IAAI,CAAC,4BAA4B;KAChE,CAAC,CAAA;IACF,6BAA6B;AAC9B,CAAC","sourcesContent":["import { IContextLogin } from '@context/IContextLogin.mjs'\nimport { refreshTokenOptions } from '@lib/tokenOptions.mjs'\nimport { REFRESH_TOKEN_EXPIRY } from '@lib/tokens.mjs'\n\nexport function setLoginCookies(ctx: IContextLogin, refreshToken: string) {\n\tctx.cookies.set('refresh_token', refreshToken, {\n\t\t...refreshTokenOptions,\n\t\tmaxAge: REFRESH_TOKEN_EXPIRY * 1000 // maxAge is in milliseconds\n\t})\n\t// if remember me, generate ?\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"sleepMs.mjs","sourceRoot":"","sources":["../../src/lib/sleepMs.mts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA","sourcesContent":["export const sleepMs = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"throwIfNotValidEnumValue.mjs","sourceRoot":"","sources":["../../src/lib/throwIfNotValidEnumValue.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,sDAA2C;AAE9E,MAAM,UAAU,wBAAwB,CACvC,OAAU,EACV,KAAgC;IAEhC,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,KAAwB,CAAC,CAAA;IACrE,IAAI,CAAC,GAAG,EAAE,CAAC;QACV,MAAM,wBAAwB,CAAC,kBAAkB,CAAC,CAAA;IACnD,CAAC;AACF,CAAC","sourcesContent":["import { throwErrorWrongUserInput } from '@throw/throwErrorWrongUserInput.mjs'\n\nexport function throwIfNotValidEnumValue<T extends Record<string, string | number>>(\n\tenumObj: T,\n\tvalue: string | number | boolean\n): void {\n\tconst ret = Object.values(enumObj).includes(value as string | number)\n\tif (!ret) {\n\t\tthrow throwErrorWrongUserInput('Wrong enum value')\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"tokenOptions.mjs","sourceRoot":"","sources":["../../src/lib/tokenOptions.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAEhC,MAAM,CAAC,MAAM,EAAE,CAAA;AAEf,MAAM,WAAW,GAAG;IACnB,QAAQ,EAAE,IAAI;IACd,QAAQ,EAAE,QAAQ;IAClB,MAAM,EAAE,KAAK,EAAE,4BAA4B;IAC3C,cAAc,EAAE,CAAC;CACjB,CAAA;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG;IACjC,GAAG,WAAW;IACd,0BAA0B;CAC1B,CAAA;AACD,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAClC,GAAG,WAAW;IACd,+BAA+B;CAC/B,CAAA,CAAC,oBAAoB","sourcesContent":["import * as dotenv from 'dotenv'\n\ndotenv.config()\n\nconst baseOptions = {\n\thttpOnly: true,\n\tsameSite: 'Strict',\n\tsecure: false, // rewrite a true in Nginx !\n\texpirationDate: 0\n}\n\nexport const accessTokenOptions = {\n\t...baseOptions\n\t// path: '/resource-api',\n}\nexport const refreshTokenOptions = {\n\t...baseOptions\n\t// path: '/authorization-api',\n} /* c8 ignore next */\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"tokens.mjs","sourceRoot":"","sources":["../../src/lib/tokens.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAA;AAEnC,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAA,CAAC,UAAU;AAEhE,SAAS,aAAa;IACrB,OAAO,MAAM,EAAE,CAAA;AAChB,CAAC;AAED,MAAM,UAAU,mBAAmB;IAClC,OAAO,aAAa,EAAE,CAAA;AACvB,CAAC;AAED,MAAM,UAAU,oBAAoB;IACnC,OAAO,aAAa,EAAE,CAAA;AACvB,CAAC;AAED,MAAM,UAAU,iBAAiB;IAChC,mEAAmE;IACnE,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAA;IAC5B,2CAA2C;IAC3C,MAAM,YAAY,GAAG,MAAM,GAAG,EAAE,CAAA,CAAC,cAAc;IAC/C,kDAAkD;IAClD,MAAM,aAAa,GAAG,CAAC,YAAY,GAAG,EAAE,CAAC,GAAG,EAAE,CAAA;IAC9C,kDAAkD;IAClD,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;AACjC,CAAC","sourcesContent":["import { v4 as uuidv4 } from 'uuid'\n\nexport const REFRESH_TOKEN_EXPIRY = 90 * 24 * 60 * 60 // 90 days\n\nfunction generateToken() {\n\treturn uuidv4()\n}\n\nexport function generateAccessToken() {\n\treturn generateToken()\n}\n\nexport function generateRefreshToken() {\n\treturn generateToken()\n}\n\nexport function accessTokenExpiry() {\n\t// Generate a random number between 0 (inclusive) and 1 (exclusive)\n\tconst random = Math.random()\n\t// Scale it to the desired range (30 to 90)\n\tconst scaledRandom = random * 61 // 90 - 30 + 1\n\t// Shift it to start from 30 and switch to minutes\n\tconst shiftedRandom = (scaledRandom + 30) * 60\n\t// Floor the value to get an integer and return it\n\treturn Math.floor(shiftedRandom)\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"tryCatchRethrow.mjs","sourceRoot":"","sources":["../../src/lib/tryCatchRethrow.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,iBAAiB,EAAE,+CAAoC;AAChE,OAAO,EAAE,kBAAkB,EAAE,gDAAqC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAEtC,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAE/D,MAAM,UAAU,eAAe,CAAC,CAAuB;IACtD,eAAe,CAAC,CAAC,CAAC,CAAA;IAElB,kBAAkB;IAClB,IAAI,CAAC,YAAY,YAAY,EAAE,CAAC;QAC/B,uCAAuC;QACvC,MAAM,MAAM,GAAG,CAAC,CAAC,UAAU,EAAE,IAAI,EAAE,MAAM,IAAI,GAAG,CAAA;QAChD,MAAM,IAAI,GAAI,CAAC,CAAC,UAAU,EAAE,WAAsB,IAAI,EAAE,CAAA;QACxD,MAAM,iBAAiB,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;IACjD,CAAC;SAAM,CAAC;QACP,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAA;QAC1B,MAAM,kBAAkB,EAAE,CAAA;IAC3B,CAAC;AACF,CAAC","sourcesContent":["import * as Sentry from '@sentry/node'\nimport { throwGraphQLError } from '@throw/throwGraphQLError.mjs'\nimport { throwInternalError } from '@throw/throwInternalError.mjs'\nimport { GraphQLError } from 'graphql'\n\nimport { throwIfMongoErr } from './MongoDB/throwIfMongoErr.mjs'\n\nexport function tryCatchRethrow(e: GraphQLError | Error) {\n\tthrowIfMongoErr(e)\n\n\t// else throw here\n\tif (e instanceof GraphQLError) {\n\t\t// @ts-expect-error status do not exist\n\t\tconst status = e.extensions?.http?.status || 500\n\t\tconst desc = (e.extensions?.description as string) || ''\n\t\tthrow throwGraphQLError(status, e.message, desc)\n\t} else {\n\t\tSentry.captureException(e)\n\t\tthrow throwInternalError()\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"_validateMimeType.mjs","sourceRoot":"","sources":["../../../src/private/files/_validateMimeType.mts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EAAE,QAAgB,EAAE,gBAA0B,EAAmB,EAAE;IACxG,0CAA0C;IAC1C,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,CAAA;IAEtD,MAAM,QAAQ,GAAG,MAAM,gBAAgB,CAAC,QAAQ,CAAC,CAAA,CAAC,kCAAkC;IACpF,IAAI,CAAC,QAAQ;QAAE,OAAO,EAAE,CAAA,CAAC,6BAA6B;IACtD,8EAA8E;IAC9E,IAAI,gBAAgB,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9C,OAAO,QAAQ,CAAC,GAAG,CAAA;IACpB,CAAC;SAAM,CAAC;QACP,OAAO,EAAE,CAAA;IACV,CAAC;AACF,CAAC,CAAA","sourcesContent":["/**\n * Utility function to validate MIME type via magic number\n * @param filePath\n * @param allowedMimeTypes\n */\nexport const _validateMimeType = async (filePath: string, allowedMimeTypes: string[]): Promise<string> => {\n\t// Dynamically import the file-type module\n\tconst { fileTypeFromFile } = await import('file-type')\n\n\tconst fileType = await fileTypeFromFile(filePath) // Get the file type from the file\n\tif (!fileType) return '' // Could not detect file type\n\t// Check if the detected MIME type is allowed and is so, return file extension\n\tif (allowedMimeTypes.includes(fileType.mime)) {\n\t\treturn fileType.ext\n\t} else {\n\t\treturn ''\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"assertNoTraversal.mjs","sourceRoot":"","sources":["../../../src/private/files/assertNoTraversal.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAa,EAAE,IAAY;IAC5D,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,WAAW,IAAI,kBAAkB,CAAC,CAAA;IACnD,CAAC;AACF,CAAC","sourcesContent":["/**\n * Reject a path traversal attempt in a value that is interpolated into a filesystem path.\n *\n * Deliberately narrow: it rejects only a literal `..` path component, and still allows\n * separators, so a legitimate multi-segment value such as `2026/07` keeps working. A\n * stricter `path.basename()` would close more, but it silently rewrites `2026/07` to `07`\n * and would break published consumers — see the rule notes in .semgrep/koa-utils.yml.\n *\n * @param value the caller-supplied value\n * @param name parameter name, used in the error message\n */\nexport function assertNoTraversal(value: string, name: string) {\n\tif (value.split(/[\\\\/]/).includes('..')) {\n\t\tthrow new Error(`Invalid ${name}: path traversal`)\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"reEncode.mjs","sourceRoot":"","sources":["../../../src/private/files/reEncode.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,kBAAkB,EAAE,mDAAqC;AAClE,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAA;AACnC,OAAO,KAAqB,MAAM,OAAO,CAAA;AAIzC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,QAAgB,EAAE,GAA0C,EAAE,OAAO,GAAG,GAAG;IACzG,MAAM,aAAa,GAAG,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,GAAG,EAAE,CAAC,CAAA;IAE7D,IAAI,CAAC;QACJ,4FAA4F;QAC5F,6EAA6E;QAC7E,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;QAEzC,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;YACpB,MAAM,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA;QAC5G,CAAC;aAAM,IAAI,GAAG,KAAK,KAAK,EAAE,CAAC;YAC1B,MAAM,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA;QAC3G,CAAC;aAAM,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;YAC3B,MAAM,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA;QACzG,CAAC;aAAM,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;YAC3B,MAAM,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA;QACzG,CAAC;IACF,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACd,MAAM,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAA;QAC5B,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;IAC9C,CAAC;IAED,4FAA4F;IAC5F,wFAAwF;IACxF,IAAI,aAAa,KAAK,QAAQ,EAAE,CAAC;QAChC,IAAI,CAAC;YACJ,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;QAC1B,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACZ,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAA;YAC1B,MAAM,kBAAkB,EAAE,CAAA;QAC3B,CAAC;IACF,CAAC;IAED,OAAO,aAAa,CAAA;AACrB,CAAC","sourcesContent":["import * as Sentry from '@sentry/node'\nimport { throwInternalError } from '@throw/throwInternalError.mjs'\nimport { promises as fs } from 'fs'\nimport sharp, { FormatEnum } from 'sharp'\n\ntype AvailableFormatInf = 'jpeg' | 'png' | 'webp' | 'avif'\n\n/**\n * Re-encode the image to a specific format and remove all metadata (EXIF, etc.)\n * @param filePath\n * @param ext\n * @param quality\n */\nexport async function reEncode(filePath: string, ext: keyof FormatEnum | AvailableFormatInf, quality = 100) {\n\tconst finalFilepath = filePath.replace(/\\.[^.]+$/, `.${ext}`)\n\n\ttry {\n\t\t// Read the bytes up front: sharp refuses to use one file as both input and output, which is\n\t\t// exactly what happens when the source already carries the target extension.\n\t\tconst input = await fs.readFile(filePath)\n\n\t\tif (ext === 'jpeg') {\n\t\t\tawait sharp(input).jpeg({ quality, progressive: true }).withMetadata({}).withExif({}).toFile(finalFilepath)\n\t\t} else if (ext === 'png') {\n\t\t\tawait sharp(input).png({ quality, progressive: true }).withMetadata({}).withExif({}).toFile(finalFilepath)\n\t\t} else if (ext === 'webp') {\n\t\t\tawait sharp(input).webp({ quality, lossless: true }).withMetadata({}).withExif({}).toFile(finalFilepath)\n\t\t} else if (ext === 'avif') {\n\t\t\tawait sharp(input).avif({ quality, lossless: true }).withMetadata({}).withExif({}).toFile(finalFilepath)\n\t\t}\n\t} catch (err) {\n\t\tSentry.captureException(err)\n\t\tthrow new Error('Error processing the image')\n\t}\n\n\t// unlink the original only when the re-encoded image landed on a different path — comparing\n\t// extensions instead would delete the file just written whenever the two paths coincide\n\tif (finalFilepath !== filePath) {\n\t\ttry {\n\t\t\tawait fs.unlink(filePath)\n\t\t} catch (e) {\n\t\t\tSentry.captureException(e)\n\t\t\tthrow throwInternalError()\n\t\t}\n\t}\n\n\treturn finalFilepath\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Consts.mjs","sourceRoot":"","sources":["../../../src/private/graphQL/Consts.mts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAC7B,8GAA8G,CAAA;AAC/G,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAA","sourcesContent":["export const ERR_MISCONFIGURED =\n\t'We have misconfigured some services. Our technicians are already fixing the problem. Please try again later.'\nexport const ERR_OOPS = 'Oops'\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"UserAdminKoaUtils.mjs","sourceRoot":"","sources":["../../../../../../src/private/graphQL/models/MongoDB/private/UserAdminKoaUtils.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAS,MAAM,UAAU,CAAA;AAqD/C,MAAM,uBAAuB,GAAqC,IAAI,MAAM,CAC3E;IACC,KAAK,EAAE;QACN,IAAI,EAAE;YACL,GAAG,EAAE,KAAK;YACV,KAAK,EAAE;gBACN,IAAI,EAAE,MAAM;gBACZ,QAAQ,EAAE,IAAI;aACd;YACD,QAAQ,EAAE;gBACT,IAAI,EAAE,MAAM;gBACZ,QAAQ,EAAE,IAAI;aACd;YACD,UAAU,EAAE;gBACX,IAAI,EAAE,IAAI;gBACV,QAAQ,EAAE,KAAK;aACf;YACD,SAAS,EAAE;gBACV,IAAI,EAAE,IAAI;gBACV,QAAQ,EAAE,KAAK;aACf;SACD;QACD,QAAQ,EAAE,IAAI;KACd;IACD,OAAO,EAAE;QACR,IAAI,EAAE;YACL,GAAG,EAAE,KAAK;YACV,KAAK,EAAE;gBACN,IAAI,EAAE;oBACL,GAAG,EAAE,KAAK;oBACV,KAAK,EAAE;wBACN,IAAI,EAAE,OAAO;wBACb,QAAQ,EAAE,IAAI;qBACd;oBACD,WAAW,EAAE;wBACZ,IAAI,EAAE,IAAI;wBACV,QAAQ,EAAE,KAAK;qBACf;oBACD,YAAY,EAAE;wBACb,IAAI,EAAE,MAAM;wBACZ,QAAQ,EAAE,KAAK;qBACf;oBACD,IAAI,EAAE;wBACL,IAAI,EAAE,MAAM;wBACZ,QAAQ,EAAE,KAAK;qBACf;oBACD,WAAW,EAAE;wBACZ,IAAI,EAAE,MAAM;wBACZ,QAAQ,EAAE,KAAK;qBACf;iBACD;gBACD,QAAQ,EAAE,IAAI;aACd;YACD,UAAU,EAAE;gBACX,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,KAAK;aACf;YACD,gBAAgB,EAAE;gBACjB,IAAI,EAAE,IAAI;gBACV,QAAQ,EAAE,IAAI;aACd;YACD,gBAAgB,EAAE;gBACjB,IAAI,EAAE,IAAI;gBACV,QAAQ,EAAE,KAAK;aACf;YACD,UAAU,EAAE;gBACX,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,KAAK;aACf;YACD,YAAY,EAAE;gBACb,IAAI,EAAE,IAAI;gBACV,QAAQ,EAAE,KAAK;aACf;YACD,kFAAkF;YAClF,iFAAiF;YACjF,yEAAyE;YACzE,qFAAqF;YACrF,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;YACD,OAAO,EAAE;gBACR,IAAI,EAAE,MAAM;gBACZ,QAAQ,EAAE,IAAI;aACd;SACD;QACD,QAAQ,EAAE,IAAI;KACd;IACD,GAAG,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,KAAK;KACf;CACD,EACD;IACC,UAAU,EAAE,WAAW;CACvB,CACD,CAAA;AAED,eAAe,KAAK,CAA2B,mBAAmB,EAAE,uBAAuB,CAAC,CAAA","sourcesContent":["import { model, Schema, Types } from 'mongoose'\n\nexport interface IInfoUserAdminForLogin {\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\trememberMe?: boolean\n\t\tdisabled?: boolean\n\t\tdeleted?: boolean\n\t}\n}\n\nexport interface IUserAdminKoaUtilsSchema {\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\trememberMe?: boolean\n\t\tregistrationDate: Date\n\t\taccountValidDate?: Date\n\t\tnewsletter?: boolean\n\t\tresetDateReq?: Date\n\t\tdisabled?: boolean\n\t\tdeleted?: boolean\n\t}\n\tpersonalData: {\n\t\t_id: false\n\t\tname: string\n\t\tsurname: string\n\t}\n\t__v?: number\n}\n\nconst UserAdminKoaUtilsSchema: Schema<IUserAdminKoaUtilsSchema> = 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\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\t// Boolean, matching IUserAdminKoaUtilsSchema — same fix as UserBase. As String, a\n\t\t\t\t// stored `false` hydrated to the truthy string 'false' and infoUserAdminForLogin\n\t\t\t\t// locked out admins who were explicitly not disabled. Existing rows need\n\t\t\t\t// scripts/migrate-account-disabled-to-boolean.mjs, which covers this collection too.\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\tsurname: {\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: true\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: 'userAdmin'\n\t}\n)\n\nexport default model<IUserAdminKoaUtilsSchema>('UserAdminKoaUtils', UserAdminKoaUtilsSchema)\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"IContextLog.mjs","sourceRoot":"","sources":["../../../../../src/private/graphQL/schema/context/IContextLog.mts"],"names":[],"mappings":"","sourcesContent":["export interface IContextLog {\n\tmethod: string\n\turl: string\n\tstate: {\n\t\tuser: {\n\t\t\tid: string\n\t\t}\n\t}\n\trequest: {\n\t\tbody?: {\n\t\t\toperationName: string\n\t\t}\n\t}\n\tstatus: number\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"IContextVerifyEmail.mjs","sourceRoot":"","sources":["../../../../../src/private/graphQL/schema/context/IContextVerifyEmail.mts"],"names":[],"mappings":"","sourcesContent":["export interface IContextVerifyEmail {\n\tparams: {\n\t\temail: string\n\t\thash: string\n\t}\n\n\tredirect(value: string): void\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"_buildLoginStatsUpdate.mjs","sourceRoot":"","sources":["../../../../../src/private/graphQL/schema/mutations/_buildLoginStatsUpdate.mts"],"names":[],"mappings":"AAgBA,MAAM,UAAU,sBAAsB,CAAC,SAAsB,EAAE,UAAmB;IACjF,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAA;IAEtB,oBAAoB;IACpB,MAAM,KAAK,GAAS,EAAE,CAAA;IACtB,MAAM,OAAO,GAAW,EAAE,CAAA;IAE1B,6BAA6B;IAC7B,KAAK,CAAC,iBAAiB,CAAC,GAAG,GAAG,CAAA;IAE9B,6CAA6C;IAC7C,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;QACxB,6BAA6B;QAC7B,KAAK,CAAC,kBAAkB,CAAC,GAAG,GAAG,CAAA;IAChC,CAAC;SAAM,CAAC;QACP,sBAAsB;IACvB,CAAC;IAED,IAAI,UAAU,EAAE,CAAC;QAChB,6BAA6B;QAC7B,KAAK,CAAC,oBAAoB,CAAC,GAAG,IAAI,CAAA;IACnC,CAAC;SAAM,CAAC;QACP,6BAA6B;QAC7B,OAAO,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAA;IAClC,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAA;AAC1B,CAAC","sourcesContent":["interface ISet {\n\tlogin?: {\n\t\tfirstLogin?: Date\n\t\tlastLogin?: Date\n\t}\n\taccount?: {\n\t\trememberMe: boolean\n\t}\n}\n\ninterface IUnset {\n\taccount?: {\n\t\trememberMe: number\n\t}\n}\n\nexport function _buildLoginStatsUpdate(lastLogin: null | Date, rememberMe: boolean) {\n\tconst now = new Date()\n\n\t// update last login\n\tconst dbSet: ISet = {}\n\tconst dbUnset: IUnset = {}\n\n\t// @ts-expect-error avoid any\n\tdbSet['login.lastLogin'] = now\n\n\t// set firstLogin if this is the first login.\n\tif (lastLogin === null) {\n\t\t// @ts-expect-error avoid any\n\t\tdbSet['login.firstLogin'] = now\n\t} else {\n\t\t// not the first login\n\t}\n\n\tif (rememberMe) {\n\t\t// @ts-expect-error avoid any\n\t\tdbSet['account.rememberMe'] = true\n\t} else {\n\t\t// @ts-expect-error avoid any\n\t\tdbUnset['account.rememberMe'] = 1\n\t}\n\n\treturn { dbSet, dbUnset }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"_finalizeLoginCheck.mjs","sourceRoot":"","sources":["../../../../../src/private/graphQL/schema/mutations/_finalizeLoginCheck.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,4CAAgC;AACxD,OAAO,EAAE,gBAAgB,EAAE,iCAAqB;AAChD,OAAO,EAAE,mBAAmB,EAAE,0DAAsC;AASpE,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,IAAqB,EAAE,MAAc,EAAE,QAAgB;IAChG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QAC/B,MAAM,mBAAmB,EAAE,CAAA;IAC5B,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;IAEjE,IAAI,CAAC,GAAG,EAAE,CAAC;QACV,MAAM,mBAAmB,EAAE,CAAA;IAC5B,CAAC;IAED,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QAC1B,MAAM,mBAAmB,EAAE,CAAA;IAC5B,CAAC;IAED,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;QAC3B,MAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAA;QACzC,MAAM,aAAa,CAAC,eAAe,CAAC,MAAM,CAAC,CAAA;QAC3C,MAAM,mBAAmB,EAAE,CAAA;IAC5B,CAAC;IAED,OAAO;QACN,MAAM,EAAE,IAAI,CAAC,GAAG;QAChB,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,IAAI,IAAI;KACvC,CAAA;AACF,CAAC","sourcesContent":["import { SocketLabsLib } from '@email/SocketLabsLib.mjs'\nimport { compareHashAsync } from '@lib/hash.mjs'\nimport { throwForbiddenError } from '@throw/throwForbiddenError.mjs'\nimport { Types } from 'mongoose'\n\nexport interface ILoginUserShape {\n\t_id: Types.ObjectId\n\tlogin: { password: string; lastLogin?: Date }\n\taccount: { email: { valid: boolean }; disabled?: boolean; deleted?: boolean }\n}\n\nexport async function _finalizeLoginCheck(user: ILoginUserShape, uEmail: string, password: string) {\n\tif (!user.account.email.valid) {\n\t\tthrow throwForbiddenError()\n\t}\n\n\tconst ret = await compareHashAsync(password, user.login.password)\n\n\tif (!ret) {\n\t\tthrow throwForbiddenError()\n\t}\n\n\tif (user.account.deleted) {\n\t\tthrow throwForbiddenError()\n\t}\n\n\tif (user.account.disabled) {\n\t\tconst SocketLabsObj = new SocketLabsLib()\n\t\tawait SocketLabsObj.accountDisabled(uEmail)\n\t\tthrow throwForbiddenError()\n\t}\n\n\treturn {\n\t\tuserId: user._id,\n\t\tlastLogin: user.login.lastLogin ?? null\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"checkUserAdminLoginAuthorization.mjs","sourceRoot":"","sources":["../../../../../src/private/graphQL/schema/mutations/checkUserAdminLoginAuthorization.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,oCAAmE;AAGnG,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAE/D,MAAM,CAAC,KAAK,UAAU,gCAAgC,CAAC,MAAc,EAAE,QAAgB,EAAE,OAAsB;IAC9G,MAAM,IAAI,GAAG,MAAM,qBAAqB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAEzD,OAAO,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAA;AACnD,CAAC","sourcesContent":["import { infoUserAdminForLogin } from '@private/graphQL/schema/mutations/infoUserAdminForLogin.mjs'\nimport { ClientSession } from 'mongoose'\n\nimport { _finalizeLoginCheck } from './_finalizeLoginCheck.mjs'\n\nexport async function checkUserAdminLoginAuthorization(uEmail: string, password: string, session: ClientSession) {\n\tconst user = await infoUserAdminForLogin(uEmail, session)\n\n\treturn _finalizeLoginCheck(user, uEmail, password)\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"checkUserLoginAuthorization.mjs","sourceRoot":"","sources":["../../../../../src/private/graphQL/schema/mutations/checkUserLoginAuthorization.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAEzD,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,MAAc,EAAE,QAAgB,EAAE,OAAsB;IACzG,MAAM,IAAI,GAAG,MAAM,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAEpD,OAAO,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAA;AACnD,CAAC","sourcesContent":["import { ClientSession } from 'mongoose'\n\nimport { _finalizeLoginCheck } from './_finalizeLoginCheck.mjs'\nimport { infoUserForLogin } from './infoUserForLogin.mjs'\n\nexport async function checkUserLoginAuthorization(uEmail: string, password: string, session: ClientSession) {\n\tconst user = await infoUserForLogin(uEmail, session)\n\n\treturn _finalizeLoginCheck(user, uEmail, password)\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"infoUserAdminForLogin.mjs","sourceRoot":"","sources":["../../../../../src/private/graphQL/schema/mutations/infoUserAdminForLogin.mts"],"names":[],"mappings":"AAAA,OAAO,iBAA6C,2DAAqE;AACzH,OAAO,EAAE,sBAAsB,EAAE,6DAAyC;AAG1E,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,KAAa,EAAE,OAAsB;IAChF,MAAM,GAAG,GAAG,MAAM,iBAAiB,CAAC,OAAO,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;SACnE,MAAM,CAAC,yEAAyE,GAAG,kBAAkB,CAAC;SACtG,OAAO,CAAC,OAAO,CAAC;SAChB,IAAI,EAAE,CAAA;IAER,IAAI,GAAG,KAAK,IAAI;QAAE,MAAM,sBAAsB,EAAE,CAAA;IAEhD,OAAO,GAAG,CAAA;AACX,CAAC","sourcesContent":["import UserAdminKoaUtils, { IInfoUserAdminForLogin } from '@private/graphQL/models/MongoDB/private/UserAdminKoaUtils.mjs'\nimport { throwUnauthorizedError } from '@throw/throwUnauthorizedError.mjs'\nimport { ClientSession } from 'mongoose'\n\nexport async function infoUserAdminForLogin(email: string, session: ClientSession): Promise<IInfoUserAdminForLogin> {\n\tconst ret = await UserAdminKoaUtils.findOne({ 'login.email': email })\n\t\t.select('_id login.password login.lastLogin account.email.valid account.deleted ' + 'account.disabled')\n\t\t.session(session)\n\t\t.exec()\n\n\tif (ret === null) throw throwUnauthorizedError()\n\n\treturn ret\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"infoUserForLogin.mjs","sourceRoot":"","sources":["../../../../../src/private/graphQL/schema/mutations/infoUserForLogin.mts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,QAAQ,EAAE,wDAAoC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,6DAAyC;AAG1E,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,KAAa,EAAE,OAAsB;IAC3E,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;SAC1D,MAAM,CAAC,yEAAyE,GAAG,kBAAkB,CAAC;SACtG,OAAO,CAAC,OAAO,CAAC;SAChB,IAAI,EAAE,CAAA;IAER,IAAI,GAAG,KAAK,IAAI;QAAE,MAAM,sBAAsB,EAAE,CAAA;IAEhD,OAAO,GAAG,CAAA;AACX,CAAC","sourcesContent":["import { IInfoUserForLogin, UserBase } from '@models/MongoDB/UserBase.mjs'\nimport { throwUnauthorizedError } from '@throw/throwUnauthorizedError.mjs'\nimport { ClientSession } from 'mongoose'\n\nexport async function infoUserForLogin(email: string, session: ClientSession): Promise<IInfoUserForLogin> {\n\tconst ret = await UserBase.findOne({ 'login.email': email })\n\t\t.select('_id login.password login.lastLogin account.email.valid account.deleted ' + 'account.disabled')\n\t\t.session(session)\n\t\t.exec()\n\n\tif (ret === null) throw throwUnauthorizedError()\n\n\treturn ret\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"infoUserForLoginSQL.mjs","sourceRoot":"","sources":["../../../../../src/private/graphQL/schema/mutations/infoUserForLoginSQL.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,4CAAgC;AACpD,OAAO,EAAE,wBAAwB,EAAE,+DAA2C;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAUtC,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,KAAa;IACtD,MAAM,GAAG,GAAG,4EAA4E,CAAA;IAExF,IAAI,GAAG,GAA0B,CAAC,MAAM,SAAS,CAAC,KAAK,CAAC,GAAG,EAAE;QAC5D,IAAI,EAAE,UAAU,CAAC,MAAM;QACvB,YAAY,EAAE;YACb,KAAK,EAAE,KAAK;SACZ;KACD,CAAC,CAA0B,CAAA;IAE5B,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,wBAAwB,CAAC,qBAAqB,CAAC,CAAA;IAE3E,OAAO,GAAG,CAAC,CAAC,CAAC,CAAA;AACd,CAAC","sourcesContent":["import { sequelize } from '@dataSources/MariaDB.mjs'\nimport { throwErrorWrongUserInput } from '@throw/throwErrorWrongUserInput.mjs'\nimport { QueryTypes } from 'sequelize'\n\nexport type InfoUserForLoginSQL = {\n\tid: number\n\tpassword: string\n\tvalid: boolean\n\tdeleted: boolean\n\tdisabled: boolean\n}\n\nexport async function infoUserForLoginSQL(email: string): Promise<InfoUserForLoginSQL> {\n\tconst sql = 'SELECT id, password, valid, deleted, disabled FROM user WHERE email=:email'\n\n\tlet ret: InfoUserForLoginSQL[] = (await sequelize.query(sql, {\n\t\ttype: QueryTypes.SELECT,\n\t\treplacements: {\n\t\t\temail: email\n\t\t}\n\t})) as InfoUserForLoginSQL[]\n\n\tif (ret.length === 0) throw throwErrorWrongUserInput('User does not exist')\n\n\treturn ret[0]\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"setLastLoginSQL.mjs","sourceRoot":"","sources":["../../../../../src/private/graphQL/schema/mutations/setLastLoginSQL.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,4CAAgC;AACpD,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAEtC,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,EAAU;IAC/C,4DAA4D;IAC5D,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;IACtB,8BAA8B;IAC9B,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,CAAA;IAC1B,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IAEnE,IAAI,GAAG,GAAG,KAAK,CAAA;IACf,IAAI,CAAC;QACJ,MAAM,GAAG,GAAG,uDAAuD,CAAA;QAEnE,MAAM,SAAS,CAAC,KAAK,CAAC,GAAG,EAAE;YAC1B,IAAI,EAAE,UAAU,CAAC,MAAM;YACvB,YAAY,EAAE;gBACb,SAAS,EAAE,SAAS;gBACpB,EAAE,EAAE,EAAE;aACN;SACD,CAAC,CAAA;QAEF,GAAG,GAAG,IAAI,CAAA;IACX,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACZ,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAA;IAC3B,CAAC;IAED,OAAO,GAAG,CAAA;AACX,CAAC","sourcesContent":["import { sequelize } from '@dataSources/MariaDB.mjs'\nimport * as Sentry from '@sentry/node'\nimport { QueryTypes } from 'sequelize'\n\nexport async function setLastLoginSQL(id: number): Promise<boolean> {\n\t// Get the current time in milliseconds since the Unix Epoch\n\tconst now = Date.now()\n\t// Convert it to a Date object\n\tconst date = new Date(now)\n\tconst timestamp = date.toISOString().slice(0, 19).replace('T', ' ')\n\n\tlet ret = false\n\ttry {\n\t\tconst sql = 'UPDATE user SET lastlogin = :timestamp WHERE id = :id'\n\n\t\tawait sequelize.query(sql, {\n\t\t\ttype: QueryTypes.UPDATE,\n\t\t\treplacements: {\n\t\t\t\ttimestamp: timestamp,\n\t\t\t\tid: id\n\t\t\t}\n\t\t})\n\n\t\tret = true\n\t} catch (e) {\n\t\tSentry.captureException(e)\n\t}\n\n\treturn ret\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"setRedisLoginSession.mjs","sourceRoot":"","sources":["../../../../../src/private/graphQL/schema/mutations/setRedisLoginSession.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,0CAA8B;AACpD,OAAO,EAAE,oBAAoB,EAAE,mCAAuB;AACtD,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,kBAAkB,EAAE,yDAAqC;AAClE,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAGhC,MAAM,CAAC,MAAM,EAAE,CAAA;AAEf,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,EAAkB,EAAE,WAAmB,EAAE,WAAmB,EAAE,YAAoB;IAC5H,MAAM,aAAa,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAA;IAC3C,MAAM,cAAc,GAAG,EAAE,GAAG,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,CAAA;IAEhE,MAAM,SAAS,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,UAAU,WAAW,EAAE,CAAA;IACjE,MAAM,UAAU,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,WAAW,YAAY,EAAE,CAAA;IAEpE,IAAI,CAAC;QACJ,yBAAyB;QACzB,MAAM,OAAO,CAAC,GAAG,CAAC;YACjB,WAAW,CAAC,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC;YAC1C,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC,UAAU;SACvD,CAAC,CAAA;QAEF,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,UAAU,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAA;IACtH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACZ,cAAc;QACd,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;QAC5E,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAA;QAC1B,MAAM,kBAAkB,EAAE,CAAA;IAC3B,CAAC;AACF,CAAC","sourcesContent":["import { redisClient } from '@dataSources/Redis.mjs'\nimport { REFRESH_TOKEN_EXPIRY } from '@lib/tokens.mjs'\nimport * as Sentry from '@sentry/node'\nimport { throwInternalError } from '@throw/throwInternalError.mjs'\nimport * as dotenv from 'dotenv'\nimport { Types } from 'mongoose'\n\ndotenv.config()\n\nexport async function setRedisLoginSession(id: Types.ObjectId, accessToken: string, accTokenExp: number, refreshToken: string) {\n\tconst keyDataAccess = { id: id.toString() }\n\tconst keyDataRefresh = { ...keyDataAccess, access: accessToken }\n\n\tconst keyAccess = `${process.env.REDIS_KEY}access:${accessToken}`\n\tconst keyRefresh = `${process.env.REDIS_KEY}refresh:${refreshToken}`\n\n\ttry {\n\t\t// Store session in Redis\n\t\tawait Promise.all([\n\t\t\tredisClient.hSet(keyAccess, keyDataAccess),\n\t\t\tredisClient.hSet(keyRefresh, keyDataRefresh) // 90 days\n\t\t])\n\n\t\tawait Promise.all([redisClient.expire(keyAccess, accTokenExp), redisClient.expire(keyRefresh, REFRESH_TOKEN_EXPIRY)])\n\t} catch (e) {\n\t\t// delete keys\n\t\tawait Promise.all([redisClient.del(keyAccess), redisClient.del(keyRefresh)])\n\t\tSentry.captureException(e)\n\t\tthrow throwInternalError()\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"updateAdminLoginStats.mjs","sourceRoot":"","sources":["../../../../../src/private/graphQL/schema/mutations/updateAdminLoginStats.mts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,2DAAqE;AAG7F,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAA;AAErE,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAC1C,EAAkB,EAClB,SAAsB,EACtB,UAAmB,EACnB,OAAsB;IAEtB,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,sBAAsB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;IAExE,MAAM,iBAAiB,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;AACnH,CAAC","sourcesContent":["import UserAdminKoaUtils from '@private/graphQL/models/MongoDB/private/UserAdminKoaUtils.mjs'\nimport { ClientSession, Types } from 'mongoose'\n\nimport { _buildLoginStatsUpdate } from './_buildLoginStatsUpdate.mjs'\n\nexport async function updateAdminLoginStats(\n\tid: Types.ObjectId,\n\tlastLogin: null | Date,\n\trememberMe: boolean,\n\tsession: ClientSession\n) {\n\tconst { dbSet, dbUnset } = _buildLoginStatsUpdate(lastLogin, rememberMe)\n\n\tawait UserAdminKoaUtils.updateOne({ _id: id }, { $set: dbSet, $unset: dbUnset }, { session, runValidators: true })\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"updateLoginStats4ever.mjs","sourceRoot":"","sources":["../../../../../src/private/graphQL/schema/mutations/updateLoginStats4ever.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,wDAAoC;AAUvD,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,EAAkB,EAAE,SAAsB,EAAE,OAAsB;IAC7G,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAA;IAEtB,oBAAoB;IACpB,MAAM,KAAK,GAAS,EAAE,CAAA;IAEtB,6BAA6B;IAC7B,KAAK,CAAC,iBAAiB,CAAC,GAAG,GAAG,CAAA;IAE9B,6CAA6C;IAC7C,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;QACxB,6BAA6B;QAC7B,KAAK,CAAC,kBAAkB,CAAC,GAAG,GAAG,CAAA;IAChC,CAAC;SAAM,CAAC;QACP,sBAAsB;IACvB,CAAC;IAED,MAAM,QAAQ,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;AACzF,CAAC","sourcesContent":["import { UserBase } from '@models/MongoDB/UserBase.mjs'\nimport { ClientSession, Types } from 'mongoose'\n\ninterface ISet {\n\tlogin?: {\n\t\tfirstLogin?: Date\n\t\tlastLogin?: Date\n\t}\n}\n\nexport async function updateLoginStats4ever(id: Types.ObjectId, lastLogin: null | Date, session: ClientSession) {\n\tconst now = new Date()\n\n\t// update last login\n\tconst dbSet: ISet = {}\n\n\t// @ts-expect-error avoid any\n\tdbSet['login.lastLogin'] = now\n\n\t// set firstLogin if this is the first login.\n\tif (lastLogin === null) {\n\t\t// @ts-expect-error avoid any\n\t\tdbSet['login.firstLogin'] = now\n\t} else {\n\t\t// not the first login\n\t}\n\n\tawait UserBase.updateOne({ _id: id }, { $set: dbSet }, { session, runValidators: true })\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"updateLoginStatsRememberme.mjs","sourceRoot":"","sources":["../../../../../src/private/graphQL/schema/mutations/updateLoginStatsRememberme.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,wDAAoC;AAGvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAA;AAErE,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC/C,EAAkB,EAClB,SAAsB,EACtB,UAAmB,EACnB,OAAsB;IAEtB,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,sBAAsB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;IAExE,MAAM,QAAQ,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;AAC1G,CAAC","sourcesContent":["import { UserBase } from '@models/MongoDB/UserBase.mjs'\nimport { ClientSession, Types } from 'mongoose'\n\nimport { _buildLoginStatsUpdate } from './_buildLoginStatsUpdate.mjs'\n\nexport async function updateLoginStatsRememberme(\n\tid: Types.ObjectId,\n\tlastLogin: null | Date,\n\trememberMe: boolean,\n\tsession: ClientSession\n) {\n\tconst { dbSet, dbUnset } = _buildLoginStatsUpdate(lastLogin, rememberMe)\n\n\tawait UserBase.updateOne({ _id: id }, { $set: dbSet, $unset: dbUnset }, { session, runValidators: true })\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Constants.mjs","sourceRoot":"","sources":["../../../../src/private/lib/access/Constants.mts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,CAAA;AAE7B,QAAQ;AACR,MAAM,CAAC,MAAM,gBAAgB,GAAG,gBAAgB,CAAA","sourcesContent":["export const SALT_ROUNDS = 14\n\n// links\nexport const EMAIL_CHECK_LINK = '/x/email-check'\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"assertVerifyEmailAllowed.mjs","sourceRoot":"","sources":["../../../../src/private/lib/access/assertVerifyEmailAllowed.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAqB,4CAAmC;AAG3F,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,sBAAsB,EAA2B,MAAM,8BAA8B,CAAA;AAC9F,OAAO,EAAE,uBAAuB,EAA4B,MAAM,+BAA+B,CAAA;AACjG,OAAO,EAAE,yBAAyB,EAA8B,MAAM,iCAAiC,CAAA;AACvG,OAAO,EAAE,eAAe,EAAoB,MAAM,uBAAuB,CAAA;AACzE,OAAO,EAAE,2BAA2B,EAAgC,MAAM,mCAAmC,CAAA;AAC7G,OAAO,EAAE,4BAA4B,EAAiC,MAAM,oCAAoC,CAAA;AAChH,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAkC1C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,IAAmC,EAAE,EAAE,CACrF,KAAK,UAAU,wBAAwB,CAAC,IAAa,EAAE,KAAa,EAAE,IAAY;IACjF,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAA;IACtB,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAmB,CAAA;IACnD,MAAM,YAAY,GAAG,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,YAAY,CAAuB,CAAA;IAC7E,MAAM,WAAW,GAAG,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,WAAW,CAAqB,CAAA;IACzE,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,CAAwB,CAAA;IACpE,MAAM,QAAQ,GAAG,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAwB,CAAA;IAEtE,MAAM,IAAI,CAAC,yBAAyB,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAY,CAAC,CAAA;IACnF,WAAW,CAAC,YAAY,EAAE,WAAW,CAAC,CAAA;IACtC,MAAM,IAAI,CAAC,4BAA4B,CAAC,KAAK,EAAE,YAAY,CAAC,CAAA;IAC5D,kFAAkF;IAClF,MAAM,IAAI,CAAC,eAAe,CAAC;QAC1B,GAAG;QACH,MAAM,EAAE,KAAK;QACb,IAAI;QACJ,YAAY;QACZ,MAAM,EAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAuB;KACxD,CAAC,CAAA;IAEF,MAAM,IAAI,CAAC,2BAA2B,CAAC,KAAK,EAAE,WAAW,CAAC,CAAA;IAC1D,+FAA+F;IAC/F,kFAAkF;IAClF,gGAAgG;IAChG,4FAA4F;IAC5F,MAAM,IAAI,CAAC,sBAAsB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;IACjD,MAAM,IAAI,CAAC,uBAAuB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;IAEnD,OAAO,GAAG,CAAA;AACX,CAAC,CAAA;AAKF,wFAAwF;AACxF,MAAM,CAAC,MAAM,wBAAwB,GAA8B,8BAA8B,CAAC;IACjG,KAAK,EAAE,0BAA0B;IACjC,yBAAyB;IACzB,eAAe;IACf,2BAA2B;IAC3B,4BAA4B;IAC5B,sBAAsB;IACtB,uBAAuB;CACvB,CAAC,CAAA","sourcesContent":["import { DEFAULT_VERIFY_EMAIL_PATHS, IVerifyEmailPaths } from '@lib/access/accessPaths.mjs'\nimport { Types } from 'mongoose'\n\nimport { handleBadDB } from './handleBadDB.mjs'\nimport { handleIfAccountDeleted, THandleIfAccountDeleted } from './handleIfAccountDeleted.mjs'\nimport { handleIfAccountDisabled, THandleIfAccountDisabled } from './handleIfAccountDisabled.mjs'\nimport { handleIfEmailAlreadyValid, THandleIfEmailAlreadyValid } from './handleIfEmailAlreadyValid.mjs'\nimport { handleIfHashBad, THandleIfHashBad } from './handleIfHashBad.mjs'\nimport { handleIfMoreThan3DaysPassed, THandleIfMoreThan3DaysPassed } from './handleIfMoreThan3DaysPassed.mjs'\nimport { handleIfTooMuchRequestsTimes, THandleIfTooMuchRequestsTimes } from './handleIfTooMuchRequestsTimes.mjs'\nimport { readPath } from './pathTools.mjs'\n\n/** The projection userData4VerifyEmail selects under the default paths, as the guard chain needs it. */\nexport interface IVerifyEmailUser {\n\t_id: Types.ObjectId\n\taccount: {\n\t\temail: {\n\t\t\thash?: string\n\t\t\tvalid: boolean\n\t\t\tdateLastReq?: Date\n\t\t\trequestTimes?: number\n\t\t}\n\t\tdeleted?: boolean\n\t\tdisabled?: boolean\n\t}\n}\n\n/**\n * Collaborators the chain needs, all bound to the same model + paths by the caller.\n *\n * The three mail-only guards are here for the same reason the writer-backed ones are: hard-importing them\n * meant the mailer they use was fixed at module load, so no caller could reach these branches without a real\n * SocketLabs send. `handleBadDB` stays a direct import — it writes nothing and mails nobody.\n */\nexport interface IAssertVerifyEmailAllowedDeps {\n\tpaths: IVerifyEmailPaths\n\thandleIfEmailAlreadyValid: THandleIfEmailAlreadyValid\n\thandleIfHashBad: THandleIfHashBad\n\thandleIfMoreThan3DaysPassed: THandleIfMoreThan3DaysPassed\n\thandleIfTooMuchRequestsTimes: THandleIfTooMuchRequestsTimes\n\thandleIfAccountDeleted: THandleIfAccountDeleted\n\thandleIfAccountDisabled: THandleIfAccountDisabled\n}\n\n/**\n * Run every guard that must pass before an email-verification link is honoured, in order.\n *\n * Extracted from routerVerifyEmail so the sequence is reachable by tests. Inside the\n * router it was not: the handler's only entry point performs a DB read, which cannot be\n * stubbed under the tsx loader (ESM live bindings), so in the suite it always rejected\n * and the whole try-body was dead code — sitting under a `c8 ignore` besides. Mutation\n * testing confirmed the cost: deleting the disabled-account guard, negating the deleted\n * flag, comparing the URL hash against ITSELF instead of the stored one, hard-coding\n * requestTimes to 0, and dropping the `await` on the hash check ALL left the suite green.\n * Each guard had thorough unit tests of its own; nothing tested that the router called\n * them, with the right values, in the right order.\n *\n * Throws (via the handleIf* guards) when the link must not be honoured. Returns the user\n * id to enable when every guard passes.\n *\n * Enabling the account is deliberately NOT done here. The caller performs it on the\n * returned id, so the irreversible side effect cannot be reordered ahead of a guard —\n * a mutation that did exactly that also survived.\n *\n * The document is read through `paths` rather than by fixed property access, so the same\n * chain serves any account layout. Nothing else about the sequence changes.\n */\nexport const createAssertVerifyEmailAllowed = (deps: IAssertVerifyEmailAllowedDeps) =>\n\tasync function assertVerifyEmailAllowed(user: unknown, email: string, hash: string): Promise<Types.ObjectId> {\n\t\tconst { paths } = deps\n\t\tconst uId = readPath(user, '_id') as Types.ObjectId\n\t\tconst requestTimes = readPath(user, paths.requestTimes) as number | undefined\n\t\tconst dateLastReq = readPath(user, paths.dateLastReq) as Date | undefined\n\t\tconst deleted = readPath(user, paths.deleted) as boolean | undefined\n\t\tconst disabled = readPath(user, paths.disabled) as boolean | undefined\n\n\t\tawait deps.handleIfEmailAlreadyValid(email, readPath(user, paths.valid) as boolean)\n\t\thandleBadDB(requestTimes, dateLastReq)\n\t\tawait deps.handleIfTooMuchRequestsTimes(email, requestTimes)\n\t\t// dbHash is the value STORED for this account — never the one supplied in the URL\n\t\tawait deps.handleIfHashBad({\n\t\t\tuId,\n\t\t\tuEmail: email,\n\t\t\thash,\n\t\t\trequestTimes,\n\t\t\tdbHash: readPath(user, paths.hash) as string | undefined\n\t\t})\n\n\t\tawait deps.handleIfMoreThan3DaysPassed(email, dateLastReq)\n\t\t// The flags are passed raw. userData4VerifyEmail reads .lean(), so Mongoose casting never runs\n\t\t// and these are exactly what the driver found — which is only ever a boolean once\n\t\t// scripts/migrate-account-disabled-to-boolean.mjs has run. On un-migrated data a stored 'false'\n\t\t// is a truthy string and blocks the account; the fix is the migration, not a coercion here.\n\t\tawait deps.handleIfAccountDeleted(email, deleted)\n\t\tawait deps.handleIfAccountDisabled(email, disabled)\n\n\t\treturn uId\n\t}\n\n/** Signature of the bound chain, for the modules that take it as a dependency. */\nexport type TAssertVerifyEmailAllowed = ReturnType<typeof createAssertVerifyEmailAllowed>\n\n/** `UserBase`-bound default — the behaviour every existing consumer already imports. */\nexport const assertVerifyEmailAllowed: TAssertVerifyEmailAllowed = createAssertVerifyEmailAllowed({\n\tpaths: DEFAULT_VERIFY_EMAIL_PATHS,\n\thandleIfEmailAlreadyValid,\n\thandleIfHashBad,\n\thandleIfMoreThan3DaysPassed,\n\thandleIfTooMuchRequestsTimes,\n\thandleIfAccountDeleted,\n\thandleIfAccountDisabled\n})\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"abandonUser.mjs","sourceRoot":"","sources":["../../../../../src/private/lib/access/db/abandonUser.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAsB,MAAM,yBAAyB,CAAA;AAkBrF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI,EAA0B,EAAsB,EAAE;IAC5H,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QACrB,OAAO,KAAK,UAAU,QAAQ;YAC7B,4EAA4E;YAC5E,OAAO,SAAS,CAAA;QACjB,CAAC,CAAA;IACF,CAAC;IAED,IAAI,IAAI,KAAK,aAAa,EAAE,CAAC;QAC5B,OAAO,KAAK,UAAU,qBAAqB,CAAC,KAAa;YACxD,MAAM,KAAK,GAAG,OAAO,YAAY,KAAK,UAAU,CAAC,CAAC,CAAE,YAA8B,EAAE,CAAC,CAAC,CAAC,YAAY,CAAA;YAEnG,iGAAiG;YACjG,qGAAqG;YACrG,MAAM,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;QAC/G,CAAC,CAAA;IACF,CAAC;IAED,OAAO,uBAAuB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;AAC7C,CAAC,CAAA","sourcesContent":["import { IVerifyEmailPaths, TAccessModel, TOnAbandon } from '@lib/access/accessPaths.mjs'\n\nimport { createDeleteUserByEmail, TDeleteUserByEmail } from './deleteUserByEmail.mjs'\n\n/** Model, field map and disposal policy for {@link createAbandonUser}. */\nexport interface ICreateAbandonUserArgs {\n\tmodel: TAccessModel\n\tpaths: IVerifyEmailPaths\n\t/** See {@link TOnAbandon}. */\n\tmode: TOnAbandon\n\t/**\n\t * Value `'soft-delete'` writes to `paths.deleted`. A function is called once per write, so a layout\n\t * storing a timestamp passes `() => new Date()`.\n\t *\n\t * Default `true`, matching `UserBase`, where `account.deleted` is `type: Boolean`. Not hard-coded: the\n\t * guards only test the flag for truthiness, so what belongs in the slot is the schema's business.\n\t */\n\tdeletedValue?: unknown\n}\n\n/**\n * Build the writer the two abandonment guards call — `handleIfMoreThan3DaysPassed` (link older than 3 days)\n * and `handleIfTooMuchRequestsTimes` (fifth wrong hash).\n *\n * All three modes share one signature, so the guards stay unaware of which policy they are running under.\n * They throw either way: the mode decides what happens to the row, never whether the link is honoured.\n */\nexport const createAbandonUser = ({ model, paths, mode, deletedValue = true }: ICreateAbandonUserArgs): TDeleteUserByEmail => {\n\tif (mode === 'keep') {\n\t\treturn async function keepUser(): Promise<void> {\n\t\t\t// Nothing to do: the caller disposes of abandoned registrations themselves.\n\t\t\treturn undefined\n\t\t}\n\t}\n\n\tif (mode === 'soft-delete') {\n\t\treturn async function softDeleteUserByEmail(email: string) {\n\t\t\tconst value = typeof deletedValue === 'function' ? (deletedValue as () => unknown)() : deletedValue\n\n\t\t\t// Only the tombstone is written. The verification fields are left as they are — the flag is what\n\t\t\t// every guard reads, and unsetting members of a strict subdocument is what `verifyClear` exists for.\n\t\t\tawait model.updateOne({ [paths.email]: email }, { $set: { [paths.deleted]: value } }, { runValidators: true })\n\t\t}\n\t}\n\n\treturn createDeleteUserByEmail(model, paths)\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"confirmNewEmail.mjs","sourceRoot":"","sources":["../../../../../src/private/lib/access/db/confirmNewEmail.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAmC,+CAAmC;AACzG,OAAO,EAAE,QAAQ,EAAE,wDAAoC;AACvD,OAAO,EAAE,UAAU,EAAE,yBAAyC;AAG9D,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,KAAmB,EAAE,KAAwB,EAAE,EAAE,CACtF,KAAK,UAAU,eAAe,CAAC,GAA4B,EAAE,KAAa;IACzE,OAAO,MAAM,KAAK;SAChB,SAAS,CACT,EAAE,GAAG,EAAE,EACP;QACC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE;QAC9B,MAAM,EAAE,UAAU,CAAC,KAAK,CAAC,gBAAgB,CAAC;KAC1C,CACD;SACA,IAAI,EAAE,CAAA;AACT,CAAC,CAAA;AAKF,wFAAwF;AACxF,eAAe,qBAAqB,CAAC,QAAQ,EAAE,0BAA0B,CAAC,CAAA","sourcesContent":["import { DEFAULT_VERIFY_EMAIL_PATHS, IVerifyEmailPaths, TAccessModel } from '@lib/access/accessPaths.mjs'\nimport { UserBase } from '@models/MongoDB/UserBase.mjs'\nimport { buildUnset } from '@private/lib/access/pathTools.mjs'\nimport mongoose from 'mongoose'\n\nexport const createConfirmNewEmail = (model: TAccessModel, paths: IVerifyEmailPaths) =>\n\tasync function confirmNewEmail(_id: mongoose.Types.ObjectId, email: string) {\n\t\treturn await model\n\t\t\t.updateOne(\n\t\t\t\t{ _id },\n\t\t\t\t{\n\t\t\t\t\t$set: { [paths.email]: email },\n\t\t\t\t\t$unset: buildUnset(paths.emailChangeClear)\n\t\t\t\t}\n\t\t\t)\n\t\t\t.exec()\n\t}\n\n/** Signature of the bound writer, for the modules that take it as a dependency. */\nexport type TConfirmNewEmail = ReturnType<typeof createConfirmNewEmail>\n\n/** `UserBase`-bound default — the behaviour every existing consumer already imports. */\nexport default createConfirmNewEmail(UserBase, DEFAULT_VERIFY_EMAIL_PATHS)\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"deleteUserByEmail.mjs","sourceRoot":"","sources":["../../../../../src/private/lib/access/db/deleteUserByEmail.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAmC,+CAAmC;AACzG,OAAO,EAAE,QAAQ,EAAE,wDAAoC;AACvD,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AAEtC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,KAAmB,EAAE,KAAwB,EAAE,EAAE,CACxF,KAAK,UAAU,iBAAiB,CAAC,KAAa;IAC7C,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;IAE3D,IAAI,GAAG,CAAC,YAAY,KAAK,CAAC,EAAE,CAAC;QAC5B,qGAAqG;QACrG,sGAAsG;QACtG,uGAAuG;QACvG,MAAM,CAAC,cAAc,CAAC,2CAA2C,KAAK,CAAC,KAAK,MAAM,KAAK,EAAE,EAAE,SAAS,CAAC,CAAA;IACtG,CAAC;AACF,CAAC,CAAA;AAKF,wFAAwF;AACxF,eAAe,uBAAuB,CAAC,QAAQ,EAAE,0BAA0B,CAAC,CAAA","sourcesContent":["import { DEFAULT_VERIFY_EMAIL_PATHS, IVerifyEmailPaths, TAccessModel } from '@lib/access/accessPaths.mjs'\nimport { UserBase } from '@models/MongoDB/UserBase.mjs'\nimport * as Sentry from '@sentry/node'\n\n/**\n * Hard delete of an abandoned pending registration, keyed by the login-email path.\n *\n * Reached through `createAbandonUser`, which is what decides whether abandonment means this, a tombstone\n * flag or nothing at all — the package cannot know what deleting a row costs in a model it was handed.\n * See `TOnAbandon`.\n */\nexport const createDeleteUserByEmail = (model: TAccessModel, paths: IVerifyEmailPaths) =>\n\tasync function deleteUserByEmail(email: string) {\n\t\tconst ret = await model.deleteOne({ [paths.email]: email })\n\n\t\tif (ret.deletedCount === 0) {\n\t\t\t// The caller read this account moments ago and its guards decided the registration was abandoned, so\n\t\t\t// nothing matching means the address moved, the path map is wrong, or another writer got there first.\n\t\t\t// Reporting nothing is what left a delete that matched nothing indistinguishable from one that worked.\n\t\t\tSentry.captureMessage(`[deleteUserByEmail] no document matched ${paths.email} = ${email}`, 'warning')\n\t\t}\n\t}\n\n/** Signature of the bound writer, for the modules that take it as a dependency. */\nexport type TDeleteUserByEmail = ReturnType<typeof createDeleteUserByEmail>\n\n/** `UserBase`-bound default — the behaviour every existing consumer already imports. */\nexport default createDeleteUserByEmail(UserBase, DEFAULT_VERIFY_EMAIL_PATHS)\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"enableEmailAccess.mjs","sourceRoot":"","sources":["../../../../../src/private/lib/access/db/enableEmailAccess.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAmC,+CAAmC;AACzG,OAAO,EAAE,wBAAwB,EAAsB,qDAAyC;AAChG,OAAO,EAAE,QAAQ,EAAE,wDAAoC;AACvD,OAAO,EAAE,UAAU,EAAE,yBAAyC;AAG9D;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,KAAmB,EAAE,KAAwB,EAAE,MAA0B,EAAE,EAAE,CACpH,KAAK,UAAU,iBAAiB,CAAC,GAA4B,EAAE,KAAa;IAC3E,MAAM,KAAK,CAAC,SAAS,CACpB,EAAE,GAAG,EAAE,EACP;QACC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE;QAC7B,MAAM,EAAE,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC;KACrC,EACD;QACC,aAAa,EAAE,IAAI;KACnB,CACD,CAAA;IAED,MAAM,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;AAChC,CAAC,CAAA;AAKF,wFAAwF;AACxF,MAAM,CAAC,MAAM,iBAAiB,GAAuB,uBAAuB,CAC3E,QAAQ,EACR,0BAA0B,EAC1B,wBAAwB,CACxB,CAAA","sourcesContent":["import { DEFAULT_VERIFY_EMAIL_PATHS, IVerifyEmailPaths, TAccessModel } from '@lib/access/accessPaths.mjs'\nimport { defaultVerifyEmailMailer, IVerifyEmailMailer } from '@lib/access/verifyEmailMailer.mjs'\nimport { UserBase } from '@models/MongoDB/UserBase.mjs'\nimport { buildUnset } from '@private/lib/access/pathTools.mjs'\nimport mongoose from 'mongoose'\n\n/**\n * Mark the address verified, clear the pending-verification fields, welcome the user.\n *\n * The welcome mail goes through an injected mailer so the success path is drivable from an integration suite\n * without a real send. It is never debounced: it fires once per account, on the one path that already required\n * a valid hash. See `throttleMailer`.\n */\nexport const createEnableEmailAccess = (model: TAccessModel, paths: IVerifyEmailPaths, mailer: IVerifyEmailMailer) =>\n\tasync function enableEmailAccess(_id: mongoose.Types.ObjectId, email: string) {\n\t\tawait model.updateOne(\n\t\t\t{ _id },\n\t\t\t{\n\t\t\t\t$set: { [paths.valid]: true },\n\t\t\t\t$unset: buildUnset(paths.verifyClear)\n\t\t\t},\n\t\t\t{\n\t\t\t\trunValidators: true\n\t\t\t}\n\t\t)\n\n\t\tawait mailer.sendWelcome(email)\n\t}\n\n/** Signature of the bound writer, for the modules that take it as a dependency. */\nexport type TEnableEmailAccess = ReturnType<typeof createEnableEmailAccess>\n\n/** `UserBase`-bound default — the behaviour every existing consumer already imports. */\nexport const enableEmailAccess: TEnableEmailAccess = createEnableEmailAccess(\n\tUserBase,\n\tDEFAULT_VERIFY_EMAIL_PATHS,\n\tdefaultVerifyEmailMailer\n)\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"getResetPwd.mjs","sourceRoot":"","sources":["../../../../../src/private/lib/access/db/getResetPwd.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAgC,+CAAmC;AACnG,OAAO,EAAE,QAAQ,EAAE,wDAAoC;AACvD,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,yBAAyC;AAW7E,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAmB,EAAE,KAAqB,EAAE,EAAE,CAC/E,KAAK,UAAU,WAAW,CAAC,OAAsB,EAAE,KAAa;IAC/D,IAAI,GAAG,GAA2B,IAAI,CAAA;IAEtC,MAAM,QAAQ,GAAG,MAAM,KAAK;SAC1B,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC;SACjC,MAAM,CAAC,eAAe,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;SACzG,OAAO,CAAC,OAAO,CAAC;SAChB,IAAI,EAAE,CAAA;IAER,8BAA8B;IAC9B,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACvB,4FAA4F;QAC5F,4FAA4F;QAC5F,6FAA6F;QAC7F,qFAAqF;QACrF,gFAAgF;QAChF,EAAE;QACF,4FAA4F;QAC5F,2FAA2F;QAC3F,wFAAwF;QACxF,4FAA4F;QAC5F,QAAQ;QACR,IAAI,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC7E,OAAO,IAAI,CAAA;QACZ,CAAC;QAED,MAAM,YAAY,GAAG,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAqB,CAAA;QAC/E,IAAI,SAAS,GAAkB,IAAI,CAAA;QAEnC,IAAI,OAAO,YAAY,KAAK,WAAW,EAAE,CAAC;YACzC,MAAM,UAAU,GAAG,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,CAAA;YAEtD,2FAA2F;YAC3F,2FAA2F;YAC3F,2FAA2F;YAC3F,wFAAwF;YACxF,0FAA0F;YAC1F,uFAAuF;YACvF,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE,CAAC;gBACpC,SAAS,GAAG,UAAU,CAAA;YACvB,CAAC;QACF,CAAC;QAED,GAAG,GAAG;YACL,GAAG,EAAE,QAAQ,CAAC,GAAqB;YACnC,YAAY;YACZ,SAAS;YACT,IAAI,EAAG,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAwB,IAAI,EAAE;SAClE,CAAA;IACF,CAAC;IACD,OAAO,GAAG,CAAA;AACX,CAAC,CAAA;AAKF,wFAAwF;AACxF,MAAM,CAAC,MAAM,WAAW,GAAiB,iBAAiB,CAAC,QAAQ,EAAE,uBAAuB,CAAC,CAAA","sourcesContent":["import { DEFAULT_RESET_PWD_PATHS, IResetPwdPaths, TAccessModel } from '@lib/access/accessPaths.mjs'\nimport { UserBase } from '@models/MongoDB/UserBase.mjs'\nimport { buildProjection, readPath } from '@private/lib/access/pathTools.mjs'\nimport { ClientSession, Types } from 'mongoose'\n\n/** What the reset flow needs about an account, flattened out of whatever layout `paths` describes. */\nexport interface IResetPwdRecord {\n\t_id: Types.ObjectId\n\tresetDateReq: Date | undefined\n\tresetHash: string | null\n\tname: string\n}\n\nexport const createGetResetPwd = (model: TAccessModel, paths: IResetPwdPaths) =>\n\tasync function getResetPwd(session: ClientSession, email: string): Promise<IResetPwdRecord | null> {\n\t\tlet ret: IResetPwdRecord | null = null\n\n\t\tconst queryRet = await model\n\t\t\t.findOne({ [paths.email]: email })\n\t\t\t.select(buildProjection([paths.name, paths.resetDateReq, paths.resetHash, paths.deleted, paths.disabled]))\n\t\t\t.session(session)\n\t\t\t.lean()\n\n\t\t// if a reset request is found\n\t\tif (queryRet !== null) {\n\t\t\t// A tombstoned or locked-out account is not a reset target: without this, resetPwd mailed a\n\t\t\t// live link to a deleted address and updatePassword overwrote the bcrypt hash of a disabled\n\t\t\t// one, so re-enabling the account handed it back with an attacker-chosen password. `null` is\n\t\t\t// the same answer an unknown address gets — resetPwd returns true and sends nothing,\n\t\t\t// updatePassword answers the same 403 — so no new enumeration oracle is opened.\n\t\t\t//\n\t\t\t// The flags are read raw, exactly as assertVerifyEmailAllowed reads them. This is a .lean()\n\t\t\t// read, so Mongoose casting never runs and these are what the driver found: a boolean once\n\t\t\t// scripts/migrate-account-disabled-to-boolean.mjs has run. On un-migrated data a stored\n\t\t\t// 'false' is a truthy string and blocks the reset; the fix is the migration, not a coercion\n\t\t\t// here.\n\t\t\tif (readPath(queryRet, paths.deleted) || readPath(queryRet, paths.disabled)) {\n\t\t\t\treturn null\n\t\t\t}\n\n\t\t\tconst resetDateReq = readPath(queryRet, paths.resetDateReq) as Date | undefined\n\t\t\tlet resetHash: string | null = null\n\n\t\t\tif (typeof resetDateReq !== 'undefined') {\n\t\t\t\tconst storedHash = readPath(queryRet, paths.resetHash)\n\n\t\t\t\t// Never stringify, and never fall back to the email-verification hash slot. '' + undefined\n\t\t\t\t// yields the literal string \"undefined\", which passed updatePassword's null check and then\n\t\t\t\t// matched a caller sending that same literal as the hash argument — a reset with no secret\n\t\t\t\t// at all. The two fields must also stay disjoint: reading the verification slot here is\n\t\t\t\t// what let a hash issued by one flow authenticate the other. Anything but a stored string\n\t\t\t\t// => null, which updatePassword rejects with the same 403 it gives an unknown address.\n\t\t\t\tif (typeof storedHash === 'string') {\n\t\t\t\t\tresetHash = storedHash\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tret = {\n\t\t\t\t_id: queryRet._id as Types.ObjectId,\n\t\t\t\tresetDateReq,\n\t\t\t\tresetHash,\n\t\t\t\tname: (readPath(queryRet, paths.name) as string | undefined) || ''\n\t\t\t}\n\t\t}\n\t\treturn ret\n\t}\n\n/** Signature of the bound reader, for the modules that take it as a dependency. */\nexport type TGetResetPwd = ReturnType<typeof createGetResetPwd>\n\n/** `UserBase`-bound default — the behaviour every existing consumer already imports. */\nexport const getResetPwd: TGetResetPwd = createGetResetPwd(UserBase, DEFAULT_RESET_PWD_PATHS)\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"incReqTimes.mjs","sourceRoot":"","sources":["../../../../../src/private/lib/access/db/incReqTimes.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAmC,+CAAmC;AACzG,OAAO,EAAE,QAAQ,EAAE,wDAAoC;AAGvD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAmB,EAAE,KAAwB,EAAE,EAAE,CAClF,KAAK,UAAU,WAAW,CAAC,GAA4B;IACtD,OAAO,KAAK,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;AAChG,CAAC,CAAA;AAKF,wFAAwF;AACxF,MAAM,CAAC,MAAM,WAAW,GAAiB,iBAAiB,CAAC,QAAQ,EAAE,0BAA0B,CAAC,CAAA","sourcesContent":["import { DEFAULT_VERIFY_EMAIL_PATHS, IVerifyEmailPaths, TAccessModel } from '@lib/access/accessPaths.mjs'\nimport { UserBase } from '@models/MongoDB/UserBase.mjs'\nimport mongoose from 'mongoose'\n\nexport const createIncReqTimes = (model: TAccessModel, paths: IVerifyEmailPaths) =>\n\tasync function incReqTimes(_id: mongoose.Types.ObjectId) {\n\t\treturn model.updateOne({ _id }, { $inc: { [paths.requestTimes]: 1 } }, { runValidators: true })\n\t}\n\n/** Signature of the bound writer, for the modules that take it as a dependency. */\nexport type TIncReqTimes = ReturnType<typeof createIncReqTimes>\n\n/** `UserBase`-bound default — the behaviour every existing consumer already imports. */\nexport const incReqTimes: TIncReqTimes = createIncReqTimes(UserBase, DEFAULT_VERIFY_EMAIL_PATHS)\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"removeResetReq.mjs","sourceRoot":"","sources":["../../../../../src/private/lib/access/db/removeResetReq.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAgC,+CAAmC;AACnG,OAAO,EAAE,QAAQ,EAAE,wDAAoC;AACvD,OAAO,EAAE,UAAU,EAAE,yBAAyC;AAG9D,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAmB,EAAE,KAAqB,EAAE,EAAE,CAClF,KAAK,UAAU,cAAc,CAAC,OAAsB,EAAE,KAAa;IAClE,iGAAiG;IACjG,gGAAgG;IAChG,uFAAuF;IACvF,kGAAkG;IAClG,+BAA+B;IAC/B,EAAE;IACF,gGAAgG;IAChG,kGAAkG;IAClG,2FAA2F;IAC3F,OAAO,KAAK;SACV,SAAS,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC;SAC7E,OAAO,CAAC,OAAO,CAAC;SAChB,IAAI,EAAE,CAAA;AACT,CAAC,CAAA;AAKF,wFAAwF;AACxF,eAAe,oBAAoB,CAAC,QAAQ,EAAE,uBAAuB,CAAC,CAAA","sourcesContent":["import { DEFAULT_RESET_PWD_PATHS, IResetPwdPaths, TAccessModel } from '@lib/access/accessPaths.mjs'\nimport { UserBase } from '@models/MongoDB/UserBase.mjs'\nimport { buildUnset } from '@private/lib/access/pathTools.mjs'\nimport { ClientSession } from 'mongoose'\n\nexport const createRemoveResetReq = (model: TAccessModel, paths: IResetPwdPaths) =>\n\tasync function removeResetReq(session: ClientSession, email: string) {\n\t\t// No { upsert: true }. An upsert on a clearing operation is backwards: when the email matched no\n\t\t// document MongoDB did not no-op, it inserted one keyed by the login-email path — and updateOne\n\t\t// skips validators, so that row bypassed every required field in the schema (password,\n\t\t// email.valid, registrationDate). A no-op is the only correct answer to \"clear the reset state of\n\t\t// a user that does not exist\".\n\t\t//\n\t\t// The unset list comes from paths.resetClear, NOT from the fields saveResetReq writes. A layout\n\t\t// holding the request in one required subdocument can only be cleared by unsetting the container;\n\t\t// unsetting its members leaves a document that fails validation and the write is rejected.\n\t\treturn model\n\t\t\t.updateOne({ [paths.email]: email }, { $unset: buildUnset(paths.resetClear) })\n\t\t\t.session(session)\n\t\t\t.exec()\n\t}\n\n/** Signature of the bound writer, for the modules that take it as a dependency. */\nexport type TRemoveResetReq = ReturnType<typeof createRemoveResetReq>\n\n/** `UserBase`-bound default — the behaviour every existing consumer already imports. */\nexport default createRemoveResetReq(UserBase, DEFAULT_RESET_PWD_PATHS)\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"saveResetReq.mjs","sourceRoot":"","sources":["../../../../../src/private/lib/access/db/saveResetReq.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAgC,+CAAmC;AAEnG,OAAO,EAAE,kBAAkB,EAAE,qDAAyC;AACtE,OAAO,EAAE,QAAQ,EAAE,wDAAoC;AAGvD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAmB,EAAE,KAAqB,EAAE,EAAE,CAChF,KAAK,UAAU,YAAY,CAAC,OAAsB,EAAE,GAAmB,EAAE,GAAS,EAAE,IAAY;IAC/F,IAAI,CAAC;QACJ,MAAM,KAAK,CAAC,SAAS,CACpB,EAAE,GAAG,EAAE,EACP;YACC,IAAI,EAAE;gBACL,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,GAAG;gBACzB,kFAAkF;gBAClF,gFAAgF;gBAChF,wDAAwD;gBACxD,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,IAAI;aACvB;SACD,EACD,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,CAChC,CAAA;IACF,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACZ,MAAM,kBAAkB,CAAC,CAAkB,CAAC,CAAA;IAC7C,CAAC;AACF,CAAC,CAAA;AAKF,wFAAwF;AACxF,MAAM,CAAC,MAAM,YAAY,GAAkB,kBAAkB,CAAC,QAAQ,EAAE,uBAAuB,CAAC,CAAA","sourcesContent":["import { DEFAULT_RESET_PWD_PATHS, IResetPwdPaths, TAccessModel } from '@lib/access/accessPaths.mjs'\nimport { IMongoDBError } from '@lib/MongoDB/IMongoDBError.mjs'\nimport { throwMongoDBErrors } from '@lib/MongoDB/throwMongoErrors.mjs'\nimport { UserBase } from '@models/MongoDB/UserBase.mjs'\nimport { ClientSession, Types } from 'mongoose'\n\nexport const createSaveResetReq = (model: TAccessModel, paths: IResetPwdPaths) =>\n\tasync function saveResetReq(session: ClientSession, _id: Types.ObjectId, now: Date, hash: string) {\n\t\ttry {\n\t\t\tawait model.updateOne(\n\t\t\t\t{ _id },\n\t\t\t\t{\n\t\t\t\t\t$set: {\n\t\t\t\t\t\t[paths.resetDateReq]: now,\n\t\t\t\t\t\t// the reset slot, never the email-verification one: writing the verification slot\n\t\t\t\t\t\t// here invalidated any pending activation or email-change link, and left a live\n\t\t\t\t\t\t// reset token in the field those flows compare against.\n\t\t\t\t\t\t[paths.resetHash]: hash\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{ session, runValidators: true }\n\t\t\t)\n\t\t} catch (e) {\n\t\t\tthrow throwMongoDBErrors(e as IMongoDBError)\n\t\t}\n\t}\n\n/** Signature of the bound writer, for the modules that take it as a dependency. */\nexport type TSaveResetReq = ReturnType<typeof createSaveResetReq>\n\n/** `UserBase`-bound default — the behaviour every existing consumer already imports. */\nexport const saveResetReq: TSaveResetReq = createSaveResetReq(UserBase, DEFAULT_RESET_PWD_PATHS)\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"setEmailHash.mjs","sourceRoot":"","sources":["../../../../../src/private/lib/access/db/setEmailHash.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAmC,+CAAmC;AACzG,OAAO,EAAE,SAAS,EAAE,sCAA0B;AAC9C,OAAO,EAAE,QAAQ,EAAE,wDAAoC;AAGvD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAmB,EAAE,KAAwB,EAAE,EAAE,CACnF,KAAK,UAAU,YAAY,CAAC,OAAsB,EAAE,MAAsB;IACzE,MAAM,IAAI,GAAG,SAAS,EAAE,CAAA;IAExB,yBAAyB;IACzB,MAAM,KAAK,GAAG,IAAI,IAAI,EAAE,CAAA;IAExB,MAAM,KAAK,CAAC,SAAS,CACpB,EAAE,GAAG,EAAE,MAAM,EAAE,EACf;QACC,IAAI,EAAE;YACL,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI;YAClB,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,CAAC,EAAE,KAAK;YAC9B,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,KAAK;SAC1B;KACD,EACD,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,CAChC,CAAA;IAED,OAAO,IAAI,CAAA,CAAC,2CAA2C;AACxD,CAAC,CAAA;AAKF,wFAAwF;AACxF,MAAM,CAAC,MAAM,YAAY,GAAkB,kBAAkB,CAAC,QAAQ,EAAE,0BAA0B,CAAC,CAAA","sourcesContent":["import { DEFAULT_VERIFY_EMAIL_PATHS, IVerifyEmailPaths, TAccessModel } from '@lib/access/accessPaths.mjs'\nimport { emailHash } from '@lib/emailHash.mjs'\nimport { UserBase } from '@models/MongoDB/UserBase.mjs'\nimport { ClientSession, Types } from 'mongoose'\n\nexport const createSetEmailHash = (model: TAccessModel, paths: IVerifyEmailPaths) =>\n\tasync function setEmailHash(session: ClientSession, userId: Types.ObjectId) {\n\t\tconst hash = emailHash()\n\n\t\t//calculate password hash\n\t\tconst dtNow = new Date()\n\n\t\tawait model.updateOne(\n\t\t\t{ _id: userId },\n\t\t\t{\n\t\t\t\t$set: {\n\t\t\t\t\t[paths.hash]: hash,\n\t\t\t\t\t[paths.requestTimes]: 1, // ok\n\t\t\t\t\t[paths.dateLastReq]: dtNow\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ session, runValidators: true }\n\t\t)\n\n\t\treturn hash // else it goes into exception @fixme check\n\t}\n\n/** Signature of the bound writer, for the modules that take it as a dependency. */\nexport type TSetEmailHash = ReturnType<typeof createSetEmailHash>\n\n/** `UserBase`-bound default — the behaviour every existing consumer already imports. */\nexport const setEmailHash: TSetEmailHash = createSetEmailHash(UserBase, DEFAULT_VERIFY_EMAIL_PATHS)\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"updatePasswordDb.mjs","sourceRoot":"","sources":["../../../../../src/private/lib/access/db/updatePasswordDb.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAgC,+CAAmC;AACnG,OAAO,EAAE,QAAQ,EAAE,wDAAoC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,yBAAyC;AAG/D,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAmB,EAAE,KAAqB,EAAE,EAAE,CACpF,KAAK,UAAU,cAAc,CAAC,OAAsB,EAAE,GAA4B,EAAE,QAAgB;IACnG,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAA;IAEjD,OAAO,KAAK,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;AAC3G,CAAC,CAAA;AAKF,wFAAwF;AACxF,eAAe,sBAAsB,CAAC,QAAQ,EAAE,uBAAuB,CAAC,CAAA","sourcesContent":["import { DEFAULT_RESET_PWD_PATHS, IResetPwdPaths, TAccessModel } from '@lib/access/accessPaths.mjs'\nimport { UserBase } from '@models/MongoDB/UserBase.mjs'\nimport { hash } from '@node-rs/bcrypt'\nimport { SALT_ROUNDS } from '@private/lib/access/Constants.mjs'\nimport mongoose, { ClientSession } from 'mongoose'\n\nexport const createUpdatePasswordDb = (model: TAccessModel, paths: IResetPwdPaths) =>\n\tasync function updatePassword(session: ClientSession, _id: mongoose.Types.ObjectId, password: string) {\n\t\tconst hashVal = await hash(password, SALT_ROUNDS)\n\n\t\treturn model.updateOne({ _id }, { $set: { [paths.password]: hashVal } }, { session, runValidators: true })\n\t}\n\n/** Signature of the bound writer, for the modules that take it as a dependency. */\nexport type TUpdatePasswordDb = ReturnType<typeof createUpdatePasswordDb>\n\n/** `UserBase`-bound default — the behaviour every existing consumer already imports. */\nexport default createUpdatePasswordDb(UserBase, DEFAULT_RESET_PWD_PATHS)\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"userData4VerifyEmail.mjs","sourceRoot":"","sources":["../../../../../src/private/lib/access/db/userData4VerifyEmail.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAmC,+CAAmC;AACzG,OAAO,EAAE,QAAQ,EAAE,wDAAoC;AACvD,OAAO,EAAE,gBAAgB,EAAE,yBAAyC;AACpE,OAAO,EAAE,eAAe,EAAE,yBAAyC;AACnE,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AAEtC,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,KAAmB,EAAE,KAAwB,EAAE,EAAE,CAC3F,KAAK,UAAU,oBAAoB,CAAC,MAAc;IACjD,gGAAgG;IAChG,4FAA4F;IAC5F,+FAA+F;IAC/F,MAAM,IAAI,GAAG,MAAM,KAAK;SACtB,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;SAClC,MAAM,CAAC,eAAe,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;SACxH,IAAI,EAAE,CAAA;IAER,gDAAgD;IAChD,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QACnB,MAAM,CAAC,cAAc,CAAC,QAAQ,MAAM,YAAY,CAAC,CAAA;QAEjD,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAA;IAClC,CAAC;IACD,OAAO,IAAI,CAAA;AACZ,CAAC,CAAA;AAKF,wFAAwF;AACxF,MAAM,CAAC,MAAM,oBAAoB,GAA0B,0BAA0B,CAAC,QAAQ,EAAE,0BAA0B,CAAC,CAAA","sourcesContent":["import { DEFAULT_VERIFY_EMAIL_PATHS, IVerifyEmailPaths, TAccessModel } from '@lib/access/accessPaths.mjs'\nimport { UserBase } from '@models/MongoDB/UserBase.mjs'\nimport { EMAIL_CHECK_LINK } from '@private/lib/access/Constants.mjs'\nimport { buildProjection } from '@private/lib/access/pathTools.mjs'\nimport * as Sentry from '@sentry/node'\n\nexport const createUserData4VerifyEmail = (model: TAccessModel, paths: IVerifyEmailPaths) =>\n\tasync function userData4VerifyEmail(uEmail: string) {\n\t\t// Every field the guard chain reads must be listed. This is a .lean() read, so a field left out\n\t\t// of the projection is simply absent on the returned object, with no error — which is how a\n\t\t// missing requestTimes turned every wrong-hash attempt into a 500 under a green coverage gate.\n\t\tconst user = await model\n\t\t\t.findOne({ [paths.email]: uEmail })\n\t\t\t.select(buildProjection([paths.hash, paths.valid, paths.dateLastReq, paths.requestTimes, paths.deleted, paths.disabled]))\n\t\t\t.lean()\n\n\t\t// if email not found, return stNotFoundNotMatch\n\t\tif (user === null) {\n\t\t\tSentry.captureMessage(`User ${uEmail} not exist`)\n\n\t\t\tthrow new Error(EMAIL_CHECK_LINK)\n\t\t}\n\t\treturn user\n\t}\n\n/** Signature of the bound reader, for the modules that take it as a dependency. */\nexport type TUserData4VerifyEmail = ReturnType<typeof createUserData4VerifyEmail>\n\n/** `UserBase`-bound default — the behaviour every existing consumer already imports. */\nexport const userData4VerifyEmail: TUserData4VerifyEmail = createUserData4VerifyEmail(UserBase, DEFAULT_VERIFY_EMAIL_PATHS)\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"handleBadDB.mjs","sourceRoot":"","sources":["../../../../src/private/lib/access/handleBadDB.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AAEtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAElD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW,CAAC,YAAqB,EAAE,WAAkB;IACpE,IAAI,OAAO,YAAY,KAAK,WAAW,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QACtE,MAAM,CAAC,cAAc,CAAC,wBAAwB,EAAE,OAAO,CAAC,CAAA;QAExD,wEAAwE;QACxE,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAA;IAClC,CAAC;AACF,CAAC","sourcesContent":["import * as Sentry from '@sentry/node'\n\nimport { EMAIL_CHECK_LINK } from './Constants.mjs'\n\n/**\n * A stored hash without its bookkeeping fields is our bug, not the caller's.\n *\n * It redirects exactly where a hash mismatch, an expired link and an unknown address redirect — that is the\n * point. Through 5.6.1 this branch threw `/x/error` while an unknown address threw `EMAIL_CHECK_LINK`, so two\n * distinguishable responses answered an unauthenticated GET and the pair told anybody who asked whether an\n * address had an account. Worse on data predating the verification fields, where every real account answered\n * `/x/error` and every unknown one answered the other: a clean enumeration oracle.\n *\n * The distinction is kept where it belongs — Sentry, which is who needs to know.\n */\nexport function handleBadDB(requestTimes?: number, dateLastReq?: Date) {\n\tif (typeof requestTimes === 'undefined' || dateLastReq === undefined) {\n\t\tSentry.captureMessage('[handleBadDB] DB ERROR', 'error')\n\n\t\t// it's an our error !! cannot be present the hash without requestTimes!\n\t\tthrow new Error(EMAIL_CHECK_LINK)\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"handleIfAccountDeleted.mjs","sourceRoot":"","sources":["../../../../src/private/lib/access/handleIfAccountDeleted.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAsB,kDAAyC;AAEhG,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAElD;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,MAA0B,EAAE,EAAE,CAC1E,KAAK,UAAU,sBAAsB,CAAC,KAAa,EAAE,UAAmB,KAAK;IAC5E,IAAI,OAAO,EAAE,CAAC;QACb,MAAM,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAA;QACnC,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAA;IAClC,CAAC;AACF,CAAC,CAAA;AAKF,uGAAuG;AACvG,MAAM,CAAC,MAAM,sBAAsB,GAA4B,4BAA4B,CAAC,wBAAwB,CAAC,CAAA","sourcesContent":["import { defaultVerifyEmailMailer, IVerifyEmailMailer } from '@lib/access/verifyEmailMailer.mjs'\n\nimport { EMAIL_CHECK_LINK } from './Constants.mjs'\n\n/**\n * The account carries the tombstone flag.\n *\n * Sends `accountDisabled`, not an `accountDeleted` of its own: `SocketLabsLib` has no such template, so a\n * deleted account is told it is disabled. That is the shipped copy, left as it is here on purpose — this is\n * the guard, not the place to invent a message.\n *\n * Like every other counter-less branch it mails on each request, which is why the mailer is injected and the\n * default one is debounced. See `createMailThrottle`.\n */\nexport const createHandleIfAccountDeleted = (mailer: IVerifyEmailMailer) =>\n\tasync function handleIfAccountDeleted(email: string, deleted: boolean = false) {\n\t\tif (deleted) {\n\t\t\tawait mailer.accountDisabled(email)\n\t\t\tthrow new Error(EMAIL_CHECK_LINK)\n\t\t}\n\t}\n\n/** Signature of the bound guard, for the modules that take it as a dependency. */\nexport type THandleIfAccountDeleted = ReturnType<typeof createHandleIfAccountDeleted>\n\n/** `UserBase`-bound default — the behaviour every existing consumer already imports, now debounced. */\nexport const handleIfAccountDeleted: THandleIfAccountDeleted = createHandleIfAccountDeleted(defaultVerifyEmailMailer)\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"handleIfAccountDisabled.mjs","sourceRoot":"","sources":["../../../../src/private/lib/access/handleIfAccountDisabled.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAsB,kDAAyC;AAEhG,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAElD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,MAA0B,EAAE,EAAE,CAC3E,KAAK,UAAU,uBAAuB,CAAC,KAAa,EAAE,WAAoB,KAAK;IAC9E,IAAI,QAAQ,EAAE,CAAC;QACd,MAAM,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAA;QACnC,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAA;IAClC,CAAC;AACF,CAAC,CAAA;AAKF,uGAAuG;AACvG,MAAM,CAAC,MAAM,uBAAuB,GAA6B,6BAA6B,CAAC,wBAAwB,CAAC,CAAA","sourcesContent":["import { defaultVerifyEmailMailer, IVerifyEmailMailer } from '@lib/access/verifyEmailMailer.mjs'\n\nimport { EMAIL_CHECK_LINK } from './Constants.mjs'\n\n/**\n * The account carries the lockout flag.\n *\n * Byte-identical to `handleIfAccountDeleted` apart from the flag it reads, because there is only one\n * template for both states. Kept as two guards so the chain reads as the two distinct conditions it checks.\n *\n * Counter-less like the rest, so the mailer is injected and the default one is debounced. See\n * `createMailThrottle`.\n */\nexport const createHandleIfAccountDisabled = (mailer: IVerifyEmailMailer) =>\n\tasync function handleIfAccountDisabled(email: string, disabled: boolean = false) {\n\t\tif (disabled) {\n\t\t\tawait mailer.accountDisabled(email)\n\t\t\tthrow new Error(EMAIL_CHECK_LINK)\n\t\t}\n\t}\n\n/** Signature of the bound guard, for the modules that take it as a dependency. */\nexport type THandleIfAccountDisabled = ReturnType<typeof createHandleIfAccountDisabled>\n\n/** `UserBase`-bound default — the behaviour every existing consumer already imports, now debounced. */\nexport const handleIfAccountDisabled: THandleIfAccountDisabled = createHandleIfAccountDisabled(defaultVerifyEmailMailer)\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"handleIfEmailAlreadyValid.mjs","sourceRoot":"","sources":["../../../../src/private/lib/access/handleIfEmailAlreadyValid.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAsB,kDAAyC;AAEhG,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAElD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAC,MAA0B,EAAE,EAAE,CAC7E,KAAK,UAAU,yBAAyB,CAAC,MAAc,EAAE,KAAc;IACtE,IAAI,KAAK,EAAE,CAAC;QACX,MAAM,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAA;QACtC,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAA;IAClC,CAAC;AACF,CAAC,CAAA;AAKF,uGAAuG;AACvG,MAAM,CAAC,MAAM,yBAAyB,GAA+B,+BAA+B,CAAC,wBAAwB,CAAC,CAAA","sourcesContent":["import { defaultVerifyEmailMailer, IVerifyEmailMailer } from '@lib/access/verifyEmailMailer.mjs'\n\nimport { EMAIL_CHECK_LINK } from './Constants.mjs'\n\n/**\n * The address in the link is already verified.\n *\n * The notification goes through an injected mailer, which buys two things. The branch becomes drivable from\n * an integration suite without a real send — the SocketLabs client used to be constructed right here, so\n * reaching this path with real credentials mailed a real person. And the debounce gets somewhere to live:\n * this guard has no counter behind it, so through 5.6.1 an unauthenticated GET mailed the address once per\n * request, for as many requests as the caller cared to make. `defaultVerifyEmailMailer` is throttled — see\n * `createMailThrottle`.\n *\n * A suppressed mail changes nothing the caller can observe: the throw, and so the redirect, is unconditional.\n */\nexport const createHandleIfEmailAlreadyValid = (mailer: IVerifyEmailMailer) =>\n\tasync function handleIfEmailAlreadyValid(uEmail: string, valid: boolean) {\n\t\tif (valid) {\n\t\t\tawait mailer.emailAlreadyValid(uEmail)\n\t\t\tthrow new Error(EMAIL_CHECK_LINK)\n\t\t}\n\t}\n\n/** Signature of the bound guard, for the modules that take it as a dependency. */\nexport type THandleIfEmailAlreadyValid = ReturnType<typeof createHandleIfEmailAlreadyValid>\n\n/** `UserBase`-bound default — the behaviour every existing consumer already imports, now debounced. */\nexport const handleIfEmailAlreadyValid: THandleIfEmailAlreadyValid = createHandleIfEmailAlreadyValid(defaultVerifyEmailMailer)\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"handleIfHashBad.mjs","sourceRoot":"","sources":["../../../../src/private/lib/access/handleIfHashBad.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAsB,kDAAyC;AAGhG,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,WAAW,EAAgB,MAAM,sBAAsB,CAAA;AAUhE;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,aAA2B,EAAE,MAA0B,EAAE,EAAE,CAChG,KAAK,UAAU,eAAe,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,CAAC,EAAE,MAAM,EAAwB;IACnG,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QACrB,cAAc;QACd,MAAM,aAAa,CAAC,GAAG,CAAC,CAAA;QAExB,MAAM,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,CAAC,CAAC,CAAA;QAChD,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAA;IAClC,CAAC;AACF,CAAC,CAAA;AAKF,wFAAwF;AACxF,MAAM,CAAC,MAAM,eAAe,GAAqB,qBAAqB,CAAC,WAAW,EAAE,wBAAwB,CAAC,CAAA","sourcesContent":["import { defaultVerifyEmailMailer, IVerifyEmailMailer } from '@lib/access/verifyEmailMailer.mjs'\nimport mongoose from 'mongoose'\n\nimport { EMAIL_CHECK_LINK } from './Constants.mjs'\nimport { incReqTimes, TIncReqTimes } from './db/incReqTimes.mjs'\n\ninterface IHandleIfHashBadArgs {\n\tuId: mongoose.Types.ObjectId\n\tuEmail: string\n\thash: string\n\trequestTimes?: number // but the check is already performed\n\tdbHash?: string\n}\n\n/**\n * The hash in the activation url is wrong.\n *\n * The strike counter is bumped through an injected writer so the guard can serve a model other than\n * `UserBase`: the counter path itself lives in the verify-email `paths` map the writer was built with.\n *\n * The warning mail goes through an injected mailer for the same reason plus one more — a constructed-in-place\n * SocketLabs client made this branch unreachable from an integration suite without sending for real.\n */\nexport const createHandleIfHashBad = (incReqTimesFn: TIncReqTimes, mailer: IVerifyEmailMailer) =>\n\tasync function handleIfHashBad({ uId, uEmail, hash, requestTimes = 0, dbHash }: IHandleIfHashBadArgs) {\n\t\tif (hash !== dbHash) {\n\t\t\t// hash failed\n\t\t\tawait incReqTimesFn(uId)\n\n\t\t\tawait mailer.wrongHash(uEmail, requestTimes + 1)\n\t\t\tthrow new Error(EMAIL_CHECK_LINK)\n\t\t}\n\t}\n\n/** Signature of the bound guard, for the modules that take it as a dependency. */\nexport type THandleIfHashBad = ReturnType<typeof createHandleIfHashBad>\n\n/** `UserBase`-bound default — the behaviour every existing consumer already imports. */\nexport const handleIfHashBad: THandleIfHashBad = createHandleIfHashBad(incReqTimes, defaultVerifyEmailMailer)\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"handleIfMoreThan3DaysPassed.mjs","sourceRoot":"","sources":["../../../../src/private/lib/access/handleIfMoreThan3DaysPassed.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAsB,kDAAyC;AAChG,OAAO,EAAE,SAAS,EAAE,mCAA0B;AAE9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,iBAAyC,MAAM,4BAA4B,CAAA;AAElF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC,mBAAuC,EAAE,MAA0B,EAAE,EAAE,CACxH,KAAK,UAAU,2BAA2B,CACzC,MAAc,EACd,cAAoB,IAAI,IAAI,EAAE,CAAC,4BAA4B;;IAE3D;;OAEG;IAEH,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAA;IACtB,MAAM,OAAO,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,CAAA;IACxD,MAAM,SAAS,GAAG,IAAI,SAAS,EAAE,CAAA;IACjC,MAAM,KAAK,GAAG,SAAS,CAAC,cAAc,CAAC,WAAW,CAAC,CAAA;IACnD,MAAM,SAAS,GAAG,SAAS,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;IAEnD,IAAI,SAAS,GAAG,KAAK,EAAE,CAAC;QACvB,kCAAkC;QAClC,MAAM,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA;QAElC,MAAM,mBAAmB,CAAC,MAAM,CAAC,CAAA;QAEjC,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAA;IAClC,CAAC;AACF,CAAC,CAAA;AAKF,wFAAwF;AACxF,MAAM,CAAC,MAAM,2BAA2B,GAAiC,iCAAiC,CACzG,iBAAiB,EACjB,wBAAwB,CACxB,CAAA","sourcesContent":["import { defaultVerifyEmailMailer, IVerifyEmailMailer } from '@lib/access/verifyEmailMailer.mjs'\nimport { StringLib } from '@lib/StringLib.mjs'\n\nimport { EMAIL_CHECK_LINK } from './Constants.mjs'\nimport deleteUserByEmail, { TDeleteUserByEmail } from './db/deleteUserByEmail.mjs'\n\n/**\n * A verification link older than 3 days disposes of the pending account.\n *\n * Disposal runs through an injected writer so the guard can serve a model other than `UserBase`, and so the\n * *policy* is the caller's: hard delete, tombstone flag or nothing. See `createAbandonUser`. The guard throws\n * either way — what happens to the row never changes whether the link is honoured.\n *\n * The mail goes through an injected mailer, which also carries the debounce on the default binding.\n */\nexport const createHandleIfMoreThan3DaysPassed = (deleteUserByEmailFn: TDeleteUserByEmail, mailer: IVerifyEmailMailer) =>\n\tasync function handleIfMoreThan3DaysPassed(\n\t\tuEmail: string,\n\t\tdateLastReq: Date = new Date() // but it is already handled\n\t) {\n\t\t/****************************************************\n\t\t * if dateLastReq too old then 3 days send email\n\t\t */\n\n\t\tconst now = new Date()\n\t\tconst day3ago = new Date(now.setDate(now.getDate() - 3))\n\t\tconst StrLibObj = new StringLib()\n\t\tconst tsReq = StrLibObj.isoToTimestamp(dateLastReq)\n\t\tconst ts3DayAgo = StrLibObj.isoToTimestamp(day3ago)\n\n\t\tif (ts3DayAgo > tsReq) {\n\t\t\t// dateLastReq too old then 3 days\n\t\t\tawait mailer.hashReqTooOld(uEmail)\n\n\t\t\tawait deleteUserByEmailFn(uEmail)\n\n\t\t\tthrow new Error(EMAIL_CHECK_LINK)\n\t\t}\n\t}\n\n/** Signature of the bound guard, for the modules that take it as a dependency. */\nexport type THandleIfMoreThan3DaysPassed = ReturnType<typeof createHandleIfMoreThan3DaysPassed>\n\n/** `UserBase`-bound default — the behaviour every existing consumer already imports. */\nexport const handleIfMoreThan3DaysPassed: THandleIfMoreThan3DaysPassed = createHandleIfMoreThan3DaysPassed(\n\tdeleteUserByEmail,\n\tdefaultVerifyEmailMailer\n)\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"handleIfTooMuchRequestsTimes.mjs","sourceRoot":"","sources":["../../../../src/private/lib/access/handleIfTooMuchRequestsTimes.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAsB,kDAAyC;AAEhG,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,iBAAyC,MAAM,4BAA4B,CAAA;AAElF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,mBAAuC,EAAE,MAA0B,EAAE,EAAE,CACzH,KAAK,UAAU,4BAA4B,CAC1C,MAAc,EACd,eAAuB,EAAE,CAAC,4BAA4B;;IAEtD,IAAI,YAAY,IAAI,CAAC,EAAE,CAAC;QACvB,MAAM,MAAM,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAA;QAE1C,MAAM,mBAAmB,CAAC,MAAM,CAAC,CAAA;QAEjC,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAA;IAClC,CAAC;AACF,CAAC,CAAA;AAKF,wFAAwF;AACxF,MAAM,CAAC,MAAM,4BAA4B,GAAkC,kCAAkC,CAC5G,iBAAiB,EACjB,wBAAwB,CACxB,CAAA","sourcesContent":["import { defaultVerifyEmailMailer, IVerifyEmailMailer } from '@lib/access/verifyEmailMailer.mjs'\n\nimport { EMAIL_CHECK_LINK } from './Constants.mjs'\nimport deleteUserByEmail, { TDeleteUserByEmail } from './db/deleteUserByEmail.mjs'\n\n/**\n * Five wrong-hash attempts dispose of the pending account.\n *\n * Disposal runs through an injected writer so the guard can serve a model other than `UserBase`, and so the\n * *policy* is the caller's: hard delete, tombstone flag or nothing. See `createAbandonUser`. Under `'keep'`\n * the strike count keeps climbing past 5, so this branch repeats — which is the other reason the mail is\n * injected and the default binding is debounced.\n */\nexport const createHandleIfTooMuchRequestsTimes = (deleteUserByEmailFn: TDeleteUserByEmail, mailer: IVerifyEmailMailer) =>\n\tasync function handleIfTooMuchRequestsTimes(\n\t\tuEmail: string,\n\t\trequestTimes: number = 99 // but it is already handled\n\t) {\n\t\tif (requestTimes >= 5) {\n\t\t\tawait mailer.tooMuchVerifyRequests(uEmail)\n\n\t\t\tawait deleteUserByEmailFn(uEmail)\n\n\t\t\tthrow new Error(EMAIL_CHECK_LINK)\n\t\t}\n\t}\n\n/** Signature of the bound guard, for the modules that take it as a dependency. */\nexport type THandleIfTooMuchRequestsTimes = ReturnType<typeof createHandleIfTooMuchRequestsTimes>\n\n/** `UserBase`-bound default — the behaviour every existing consumer already imports. */\nexport const handleIfTooMuchRequestsTimes: THandleIfTooMuchRequestsTimes = createHandleIfTooMuchRequestsTimes(\n\tdeleteUserByEmail,\n\tdefaultVerifyEmailMailer\n)\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"pathTools.mjs","sourceRoot":"","sources":["../../../../src/private/lib/access/pathTools.mts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAAC,MAAe,EAAE,IAAY;IACrD,IAAI,OAAO,GAAY,MAAM,CAAA;IAE7B,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACnC,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YACrD,OAAO,SAAS,CAAA;QACjB,CAAC;QACD,OAAO,GAAI,OAAmC,CAAC,GAAG,CAAC,CAAA;IACpD,CAAC;IAED,OAAO,OAAO,CAAA;AACf,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,KAAwB;IAClD,MAAM,KAAK,GAAuB,EAAE,CAAA;IAEpC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC1B,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAA;IACjB,CAAC;IAED,OAAO,KAAK,CAAA;AACb,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,KAAwB;IACvD,OAAO,CAAC,KAAK,EAAE,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACnC,CAAC","sourcesContent":["/**\n * Read a dotted mongo path out of a lean document.\n *\n * `.lean()` hands back a plain object, so a configured path such as `account.email.hash` has to be\n * walked by hand. Any missing or non-object link yields `undefined` rather than throwing: a path\n * pointing at a field the document does not carry must read as \"absent\", exactly like a projection\n * that left the field out, so the callers' existing `typeof x === 'undefined'` guards keep working.\n */\nexport function readPath(source: unknown, path: string): unknown {\n\tlet current: unknown = source\n\n\tfor (const key of path.split('.')) {\n\t\tif (current === null || typeof current !== 'object') {\n\t\t\treturn undefined\n\t\t}\n\t\tcurrent = (current as Record<string, unknown>)[key]\n\t}\n\n\treturn current\n}\n\n/**\n * Build a mongo `$unset` payload from a list of paths.\n *\n * The list is supplied by the caller, never derived from the fields that were written: a layout\n * storing the reset request as one required subdocument can only be cleared by unsetting the\n * container, not its members. See `IResetPwdPaths.resetClear`.\n */\nexport function buildUnset(paths: readonly string[]): Record<string, ''> {\n\tconst unset: Record<string, ''> = {}\n\n\tfor (const path of paths) {\n\t\tunset[path] = ''\n\t}\n\n\treturn unset\n}\n\n/**\n * Build a `.select()` projection string, always including `_id`.\n *\n * Every field a resolver reads must be listed here. A `.lean()` read of a field left out of the\n * projection is simply absent, with no error — that is how a missing `account.email.requestTimes`\n * turned every wrong-hash attempt into a 500 while the coverage gate stayed green.\n */\nexport function buildProjection(paths: readonly string[]): string {\n\treturn ['_id', ...paths].join(' ')\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"makeBodyJson.mjs","sourceRoot":"","sources":["../../../src/private/lib/makeBodyJson.mts"],"names":[],"mappings":"AAAA,MAAM,UAAU,YAAY,CAAC,OAAe,EAAE,WAAmB;IAChE,OAAO,IAAI,CAAC,SAAS,CAAC;QACrB,OAAO;QACP,WAAW;KACX,CAAC,CAAA;AACH,CAAC","sourcesContent":["export function makeBodyJson(message: string, description: string) {\n\treturn JSON.stringify({\n\t\tmessage,\n\t\tdescription\n\t})\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"verifyIntrospectionCode.mjs","sourceRoot":"","sources":["../../../src/private/lib/verifyIntrospectionCode.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE7C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,WAA+B,EAAW,EAAE;IACnF,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAA;IAC3C,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnD,OAAO,KAAK,CAAA;IACb,CAAC;IACD,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;QACrC,OAAO,KAAK,CAAA;IACb,CAAC;IACD,6FAA6F;IAC7F,8FAA8F;IAC9F,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IAC7C,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACpC,IAAI,YAAY,CAAC,MAAM,KAAK,UAAU,CAAC,MAAM,EAAE,CAAC;QAC/C,OAAO,KAAK,CAAA;IACb,CAAC;IACD,OAAO,eAAe,CAAC,YAAY,EAAE,UAAU,CAAC,CAAA;AACjD,CAAC,CAAA","sourcesContent":["import { Buffer } from 'node:buffer'\nimport { timingSafeEqual } from 'node:crypto'\n\n/**\n * Constant-time check of the `x-introspectioncode` header against INTROSPECTION_CODE.\n *\n * Fails closed: an unset or empty INTROSPECTION_CODE never matches, whatever the caller sends.\n * The call sites previously compared against `${process.env.INTROSPECTION_CODE}`, which coerces\n * an unset variable to the literal string 'undefined' — a client sending that exact header value\n * satisfied the check with no secret at all.\n */\nexport const verifyIntrospectionCode = (headerValue: string | undefined): boolean => {\n\tconst code = process.env.INTROSPECTION_CODE\n\tif (typeof code !== 'string' || code.length === 0) {\n\t\treturn false\n\t}\n\tif (typeof headerValue !== 'string') {\n\t\treturn false\n\t}\n\t// byte length, not character length: timingSafeEqual throws on unequal-length buffers, and a\n\t// multi-byte header value can match code.length while encoding to a different number of bytes\n\tconst headerBuffer = Buffer.from(headerValue)\n\tconst codeBuffer = Buffer.from(code)\n\tif (headerBuffer.length !== codeBuffer.length) {\n\t\treturn false\n\t}\n\treturn timingSafeEqual(headerBuffer, codeBuffer)\n}\n"]}