@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.
- package/README.md +23 -4
- package/package.json +60 -18
- package/dist/dataSources/MariaDB.mjs.map +0 -1
- package/dist/dataSources/MongoDB.mjs.map +0 -1
- package/dist/dataSources/PostgreSQL.mjs.map +0 -1
- package/dist/dataSources/Redis.mjs.map +0 -1
- package/dist/email/SocketLabsLib.mjs.map +0 -1
- package/dist/files/IUploadTemp.mjs.map +0 -1
- package/dist/files/checkForNSFW.mjs.map +0 -1
- package/dist/files/fileConst.mjs.map +0 -1
- package/dist/files/moveFileStaticDomain.mjs.map +0 -1
- package/dist/files/moveImageFile.mjs.map +0 -1
- package/dist/files/moveTempFile.mjs.map +0 -1
- package/dist/files/reEncodeToJpeg.mjs.map +0 -1
- package/dist/files/reEncodeToPng.mjs.map +0 -1
- package/dist/files/reEncodeToWebp.mjs.map +0 -1
- package/dist/files/scanVirus.mjs.map +0 -1
- package/dist/files/storeUploadAsTemp.mjs.map +0 -1
- package/dist/files/uploadTempImage.mjs.map +0 -1
- package/dist/files/uploadTempPdf.mjs.map +0 -1
- package/dist/files/validateExtension.mjs.map +0 -1
- package/dist/files/validateJpgPngExtension.mjs.map +0 -1
- package/dist/files/validateMimeType.mjs.map +0 -1
- package/dist/files/validateMimeTypeImages.mjs.map +0 -1
- package/dist/files/validateMimeTypePdf.mjs.map +0 -1
- package/dist/files/validatePdfExtension.mjs.map +0 -1
- package/dist/graphQL/models/MongoDB/UserBase.mjs.map +0 -1
- package/dist/graphQL/models/MongoDB/log/DevStatsGraphQLCalls.mjs.map +0 -1
- package/dist/graphQL/models/MongoDB/log/LogGlobalError.mjs.map +0 -1
- package/dist/graphQL/models/MongoDB/log/LogStatsGraphql.mjs.map +0 -1
- package/dist/graphQL/models/MongoDB/log/LogThrow.mjs.map +0 -1
- package/dist/graphQL/schema/GraphQLInput/GraphQLInputLogin.mjs.map +0 -1
- package/dist/graphQL/schema/context/IContextAuthenticatedResource.mjs.map +0 -1
- package/dist/graphQL/schema/context/IContextKoaErrorHandler.mjs.map +0 -1
- package/dist/graphQL/schema/context/IContextLogin.mjs.map +0 -1
- package/dist/graphQL/schema/context/IContextLogout.mjs.map +0 -1
- package/dist/graphQL/schema/context/IContextRefresh.mjs.map +0 -1
- package/dist/graphQL/schema/context/TCommonHeaders.mjs.map +0 -1
- package/dist/graphQL/schema/interfaces/IFindAndUpdate.mjs.map +0 -1
- package/dist/graphQL/schema/mutations/emailChangeHashVerify.mjs.map +0 -1
- package/dist/graphQL/schema/mutations/login4Ever.mjs.map +0 -1
- package/dist/graphQL/schema/mutations/loginAdmin.mjs.map +0 -1
- package/dist/graphQL/schema/mutations/loginRememberme.mjs.map +0 -1
- package/dist/graphQL/schema/mutations/logout.mjs.map +0 -1
- package/dist/graphQL/schema/mutations/refresh.mjs.map +0 -1
- package/dist/graphQL/schema/mutations/resetPwd.mjs.map +0 -1
- package/dist/graphQL/schema/mutations/signUp.mjs.map +0 -1
- package/dist/graphQL/schema/mutations/updatePassword.mjs.map +0 -1
- package/dist/graphQL/schema/types/DeleteType.mjs.map +0 -1
- package/dist/graphQL/schema/types/DoneType.mjs.map +0 -1
- package/dist/graphQL/schema/types/FindOneAndUpdateType.mjs.map +0 -1
- package/dist/graphQL/schema/types/LoginAppType.mjs.map +0 -1
- package/dist/graphQL/schema/types/LoginType.mjs.map +0 -1
- package/dist/graphQL/schema/types/MidNameType.mjs.map +0 -1
- package/dist/graphQL/schema/types/OnlyIdType.mjs.map +0 -1
- package/dist/graphQL/schema/types/RefreshType.mjs.map +0 -1
- package/dist/graphQL/schema/types/RetStatusMexType.mjs.map +0 -1
- package/dist/graphQL/schema/types/RetStatusType.mjs.map +0 -1
- package/dist/graphQL/schema/types/SaveType.mjs.map +0 -1
- package/dist/graphQL/schema/types/SidNameType.mjs.map +0 -1
- package/dist/graphQL/schema/types/SidNomeType.mjs.map +0 -1
- package/dist/graphQL/schema/types/UpdateResultType.mjs.map +0 -1
- package/dist/graphQL/status.mjs.map +0 -1
- package/dist/graphQL/throw/throwAccessTokenExpiredOrDeleted.mjs.map +0 -1
- package/dist/graphQL/throw/throwAccessTokenRequired.mjs.map +0 -1
- package/dist/graphQL/throw/throwAlreadyDone.mjs.map +0 -1
- package/dist/graphQL/throw/throwAlreadyTakenError.mjs.map +0 -1
- package/dist/graphQL/throw/throwConflictError.mjs.map +0 -1
- package/dist/graphQL/throw/throwErrorWrongUserInput.mjs.map +0 -1
- package/dist/graphQL/throw/throwForbiddenError.mjs.map +0 -1
- package/dist/graphQL/throw/throwGoneError.mjs.map +0 -1
- package/dist/graphQL/throw/throwGraphQLError.mjs.map +0 -1
- package/dist/graphQL/throw/throwInternalError.mjs.map +0 -1
- package/dist/graphQL/throw/throwMethodNotAllowedError.mjs.map +0 -1
- package/dist/graphQL/throw/throwMissingMalformedInvalidToken.mjs.map +0 -1
- package/dist/graphQL/throw/throwNotAcceptableError.mjs.map +0 -1
- package/dist/graphQL/throw/throwNotFoundError.mjs.map +0 -1
- package/dist/graphQL/throw/throwNotImplementedError.mjs.map +0 -1
- package/dist/graphQL/throw/throwPaymentRequiredError.mjs.map +0 -1
- package/dist/graphQL/throw/throwPreconditionFailedNoAuthCookie.mjs.map +0 -1
- package/dist/graphQL/throw/throwPreconditionFailedNoAuthHeader.mjs.map +0 -1
- package/dist/graphQL/throw/throwRefreshTokenExpiredOrDeleted.mjs.map +0 -1
- package/dist/graphQL/throw/throwRefreshTokenRequired.mjs.map +0 -1
- package/dist/graphQL/throw/throwRefreshTokenSignatureRequired.mjs.map +0 -1
- package/dist/graphQL/throw/throwTooManyRequestsError.mjs.map +0 -1
- package/dist/graphQL/throw/throwUnauthorizedError.mjs.map +0 -1
- package/dist/graphQL/throw/throwUnprocessableContentError.mjs.map +0 -1
- package/dist/graphQL/throw/throwUnsupportedMediaTypeError.mjs.map +0 -1
- package/dist/koa/IFileUpload.mjs.map +0 -1
- package/dist/koa/IKoaError.mjs.map +0 -1
- package/dist/koa/customFormatErrorFn.mjs.map +0 -1
- package/dist/koa/logRequestToDb.mjs.map +0 -1
- package/dist/koa/middleware/authenticatedAuthorizationHandler/TCookieRefreshToken.mjs.map +0 -1
- package/dist/koa/middleware/authenticatedAuthorizationHandler/index.mjs.map +0 -1
- package/dist/koa/middleware/authenticatedAuthorizationHandler/verifySignedRefreshToken.mjs.map +0 -1
- package/dist/koa/middleware/authenticatedLogoutHandler/index.mjs.map +0 -1
- package/dist/koa/middleware/authenticatedResourceHandler/index.mjs.map +0 -1
- package/dist/koa/middleware/debug/index.mjs.map +0 -1
- package/dist/koa/router/verifyEmail.mjs.map +0 -1
- package/dist/koa/tdwKoaErrorHandler.mjs.map +0 -1
- package/dist/lib/ArrayLib.mjs.map +0 -1
- package/dist/lib/Constants.mjs.map +0 -1
- package/dist/lib/DateLib.mjs.map +0 -1
- package/dist/lib/IAuthorizationDisDel.mjs.map +0 -1
- package/dist/lib/ICookies.mjs.map +0 -1
- package/dist/lib/MariaDB/IMariaDBErr.mjs.map +0 -1
- package/dist/lib/MariaDB/MariaDBErrType.mjs.map +0 -1
- package/dist/lib/MariaDB/throwSqlErrors.mjs.map +0 -1
- package/dist/lib/MongoDB/IMongoDBError.mjs.map +0 -1
- package/dist/lib/MongoDB/IOnboarding.mjs.map +0 -1
- package/dist/lib/MongoDB/MongoDBErrType.mjs.map +0 -1
- package/dist/lib/MongoDB/throwIfMongoErr.mjs.map +0 -1
- package/dist/lib/MongoDB/throwMongoErrors.mjs.map +0 -1
- package/dist/lib/NumLib.mjs.map +0 -1
- package/dist/lib/PostgreSQL/IPostgresError.mjs.map +0 -1
- package/dist/lib/PostgreSQL/IPostgresErrorCodes.mjs.map +0 -1
- package/dist/lib/PostgreSQL/makePostgreSqlLogError.mjs.map +0 -1
- package/dist/lib/Redis/RedisBoolean.mjs.map +0 -1
- package/dist/lib/Redis/buildPrefixedRedisKey.mjs.map +0 -1
- package/dist/lib/Redis/fromRedisBooleanValue.mjs.map +0 -1
- package/dist/lib/Redis/toRedisBooleanValue.mjs.map +0 -1
- package/dist/lib/StringLib.mjs.map +0 -1
- package/dist/lib/access/accessPaths.mjs.map +0 -1
- package/dist/lib/access/createMailThrottle.mjs.map +0 -1
- package/dist/lib/access/createResetPwdFlow.mjs.map +0 -1
- package/dist/lib/access/createVerifyEmailFlow.mjs.map +0 -1
- package/dist/lib/access/verifyEmailMailer.mjs.map +0 -1
- package/dist/lib/checkEmailLen.mjs.map +0 -1
- package/dist/lib/checkPwdLen.mjs.map +0 -1
- package/dist/lib/db/log/hitStat.mjs.map +0 -1
- package/dist/lib/db/log/logGlobalError.mjs.map +0 -1
- package/dist/lib/db/log/logGraphql.mjs.map +0 -1
- package/dist/lib/db/log/logThrow.mjs.map +0 -1
- package/dist/lib/db/login/ILoginSet.mjs.map +0 -1
- package/dist/lib/db/login/ILoginUnset.mjs.map +0 -1
- package/dist/lib/db/registerNewUser.mjs.map +0 -1
- package/dist/lib/db/userExist.mjs.map +0 -1
- package/dist/lib/emailHash.mjs.map +0 -1
- package/dist/lib/encryptPassword.mjs.map +0 -1
- package/dist/lib/hash.mjs.map +0 -1
- package/dist/lib/isSafeRedirectTarget.mjs.map +0 -1
- package/dist/lib/isSessionBlocked.mjs.map +0 -1
- package/dist/lib/isValidUuidV4.mjs.map +0 -1
- package/dist/lib/makeOnboardingData.mjs.map +0 -1
- package/dist/lib/setLoginCookies.mjs.map +0 -1
- package/dist/lib/sleepMs.mjs.map +0 -1
- package/dist/lib/throwIfNotValidEnumValue.mjs.map +0 -1
- package/dist/lib/tokenOptions.mjs.map +0 -1
- package/dist/lib/tokens.mjs.map +0 -1
- package/dist/lib/tryCatchRethrow.mjs.map +0 -1
- package/dist/private/files/_validateMimeType.mjs.map +0 -1
- package/dist/private/files/assertNoTraversal.mjs.map +0 -1
- package/dist/private/files/reEncode.mjs.map +0 -1
- package/dist/private/graphQL/Consts.mjs.map +0 -1
- package/dist/private/graphQL/models/MongoDB/private/UserAdminKoaUtils.mjs.map +0 -1
- package/dist/private/graphQL/schema/context/IContextLog.mjs.map +0 -1
- package/dist/private/graphQL/schema/context/IContextVerifyEmail.mjs.map +0 -1
- package/dist/private/graphQL/schema/mutations/_buildLoginStatsUpdate.mjs.map +0 -1
- package/dist/private/graphQL/schema/mutations/_finalizeLoginCheck.mjs.map +0 -1
- package/dist/private/graphQL/schema/mutations/checkUserAdminLoginAuthorization.mjs.map +0 -1
- package/dist/private/graphQL/schema/mutations/checkUserLoginAuthorization.mjs.map +0 -1
- package/dist/private/graphQL/schema/mutations/infoUserAdminForLogin.mjs.map +0 -1
- package/dist/private/graphQL/schema/mutations/infoUserForLogin.mjs.map +0 -1
- package/dist/private/graphQL/schema/mutations/infoUserForLoginSQL.mjs.map +0 -1
- package/dist/private/graphQL/schema/mutations/setLastLoginSQL.mjs.map +0 -1
- package/dist/private/graphQL/schema/mutations/setRedisLoginSession.mjs.map +0 -1
- package/dist/private/graphQL/schema/mutations/updateAdminLoginStats.mjs.map +0 -1
- package/dist/private/graphQL/schema/mutations/updateLoginStats4ever.mjs.map +0 -1
- package/dist/private/graphQL/schema/mutations/updateLoginStatsRememberme.mjs.map +0 -1
- package/dist/private/lib/access/Constants.mjs.map +0 -1
- package/dist/private/lib/access/assertVerifyEmailAllowed.mjs.map +0 -1
- package/dist/private/lib/access/db/abandonUser.mjs.map +0 -1
- package/dist/private/lib/access/db/confirmNewEmail.mjs.map +0 -1
- package/dist/private/lib/access/db/deleteUserByEmail.mjs.map +0 -1
- package/dist/private/lib/access/db/enableEmailAccess.mjs.map +0 -1
- package/dist/private/lib/access/db/getResetPwd.mjs.map +0 -1
- package/dist/private/lib/access/db/incReqTimes.mjs.map +0 -1
- package/dist/private/lib/access/db/removeResetReq.mjs.map +0 -1
- package/dist/private/lib/access/db/saveResetReq.mjs.map +0 -1
- package/dist/private/lib/access/db/setEmailHash.mjs.map +0 -1
- package/dist/private/lib/access/db/updatePasswordDb.mjs.map +0 -1
- package/dist/private/lib/access/db/userData4VerifyEmail.mjs.map +0 -1
- package/dist/private/lib/access/handleBadDB.mjs.map +0 -1
- package/dist/private/lib/access/handleIfAccountDeleted.mjs.map +0 -1
- package/dist/private/lib/access/handleIfAccountDisabled.mjs.map +0 -1
- package/dist/private/lib/access/handleIfEmailAlreadyValid.mjs.map +0 -1
- package/dist/private/lib/access/handleIfHashBad.mjs.map +0 -1
- package/dist/private/lib/access/handleIfMoreThan3DaysPassed.mjs.map +0 -1
- package/dist/private/lib/access/handleIfTooMuchRequestsTimes.mjs.map +0 -1
- package/dist/private/lib/access/pathTools.mjs.map +0 -1
- package/dist/private/lib/makeBodyJson.mjs.map +0 -1
- package/dist/private/lib/verifyIntrospectionCode.mjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resetPwd.mjs","sourceRoot":"","sources":["../../../../src/graphQL/schema/mutations/resetPwd.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,yCAAgC;AACxD,OAAO,EAAE,aAAa,EAAE,uCAA8B;AACtD,OAAO,EAAE,cAAc,EAAE,mCAA0B;AACnD,OAAO,EAAE,OAAO,EAAE,iCAAwB;AAC1C,OAAO,EAAE,SAAS,EAAE,mCAA0B;AAC9C,OAAO,EAAE,eAAe,EAAE,yCAAgC;AAC1D,OAAO,EAAE,WAAW,EAAgB,uDAA8C;AAClF,OAAO,EAAE,YAAY,EAAiB,wDAA+C;AACrF,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,cAAc,EAAgB,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACrF,OAAO,QAAQ,MAAM,UAAU,CAAA;AAmB/B;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,IAAmB,EAAE,EAAE,CAAC,CAAC;IAC/D,WAAW,EAAE,0BAA0B;IACvC,IAAI,EAAE,IAAI,cAAc,CAAC,cAAc,CAAC;IACxC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oEAAoE;gBACpE,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAA;YAC3B,CAAC;QACF,CAAC;QAED,OAAO,IAAI,CAAA;IACZ,CAAC;CACD,CAAC,CAAA;AAKF,uFAAuF;AACvF,MAAM,CAAC,MAAM,QAAQ,GAAsB,sBAAsB,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC,CAAA","sourcesContent":["import { SocketLabsLib } from '@email/SocketLabsLib.mjs'\nimport { checkEmailLen } from '@lib/checkEmailLen.mjs'\nimport { EMAIL_HASH_LEN } from '@lib/Constants.mjs'\nimport { DateLib } from '@lib/DateLib.mjs'\nimport { StringLib } from '@lib/StringLib.mjs'\nimport { tryCatchRethrow } from '@lib/tryCatchRethrow.mjs'\nimport { getResetPwd, TGetResetPwd } from '@private/lib/access/db/getResetPwd.mjs'\nimport { saveResetReq, TSaveResetReq } from '@private/lib/access/db/saveResetReq.mjs'\nimport * as Sentry from '@sentry/node'\nimport { GraphQLBoolean, GraphQLError, GraphQLNonNull, GraphQLString } from 'graphql'\nimport mongoose from 'mongoose'\n\n/** Arguments accepted by the `resetPwd` mutation. Exported so a consumer re-exporting the bound mutation can name its type. */\nexport interface IResetPwdArgs {\n\temail: string\n}\n\n/** What the committed transaction leaves behind for the post-commit send. */\ninterface IPendingMail {\n\thash: string\n\tname: string\n}\n\n/** Readers and writers the resolver needs, all bound to the same model + paths by the caller. */\nexport interface IResetPwdDeps {\n\tgetResetPwd: TGetResetPwd\n\tsaveResetReq: TSaveResetReq\n}\n\n/**\n * Take the user email and send an email with a link for change the password.\n * for privacy, true is returned whatever happens: unknown address, first request, or a request\n * throttled because the previous one is less than 10 minutes old. The caller can never tell them apart,\n * and the mail is queued after the commit without being awaited so the response time does not tell\n * them apart either.\n *\n * The collection and field layout live entirely in the injected reader/writer, so the same resolver\n * serves any account model. Nothing about the flow itself changes.\n */\nexport const createResetPwdMutation = (deps: IResetPwdDeps) => ({\n\tdescription: 'send reset password link',\n\ttype: new GraphQLNonNull(GraphQLBoolean),\n\targs: {\n\t\temail: { type: new GraphQLNonNull(GraphQLString) }\n\t},\n\tasync resolve(_: unknown, args: IResetPwdArgs) {\n\t\tconst { email } = args\n\n\t\tconst uEmail = email.toLowerCase().trim()\n\t\tcheckEmailLen(uEmail)\n\n\t\t// Set only when the transaction actually persisted a fresh reset request. The mail itself goes\n\t\t// out after the commit, and is not awaited — see the block below the transaction.\n\t\tlet pendingMail: IPendingMail | null = null\n\n\t\tconst session = await mongoose.startSession()\n\t\ttry {\n\t\t\tawait session.withTransaction(async () => {\n\t\t\t\t// email exists? -> retrieve whether there have already been reset requests -> return 4xx ??\n\t\t\t\tconst resetPwdVal = await deps.getResetPwd(session, uEmail)\n\n\t\t\t\t// don't reveal that the email doesn't exist, for privacy\n\t\t\t\tif (resetPwdVal === null) return\n\n\t\t\t\t// ok, email exists\n\n\t\t\t\t// -> wait 10 minutes from the last password reset request\n\n\t\t\t\t// if a password request already exists, read the date in seconds.\n\t\t\t\tconst lastReq = typeof resetPwdVal.resetDateReq !== 'undefined' ? new Date('' + resetPwdVal.resetDateReq) : null\n\n\t\t\t\t// request already made previously?\n\t\t\t\t// send a new email with the recovery link only if the last one is at least 10 minutes old\n\t\t\t\tconst nowDt = new Date()\n\n\t\t\t\t// The throttle is enforced silently. Throwing 429 here answered \"this address is\n\t\t\t\t// registered and has a reset pending\" to an unauthenticated caller, while an unknown\n\t\t\t\t// address returned true — an enumeration oracle for any address that had been through\n\t\t\t\t// this flow. Both cases now return true and send nothing.\n\t\t\t\tlet calculateHash = true\n\t\t\t\tif (lastReq !== null) {\n\t\t\t\t\tcalculateHash = DateLib.minElapsed(lastReq) >= 10\n\t\t\t\t}\n\n\t\t\t\tif (calculateHash) {\n\t\t\t\t\t// generate hash for password reset\n\t\t\t\t\tconst StrObj = new StringLib()\n\t\t\t\t\tconst hash = StrObj.randomString(EMAIL_HASH_LEN)\n\n\t\t\t\t\t// set hash and current reset date\n\t\t\t\t\tawait deps.saveResetReq(session, resetPwdVal._id, nowDt, hash)\n\n\t\t\t\t\t// the mail is queued after the commit, not here\n\t\t\t\t\tpendingMail = { hash, name: resetPwdVal.name }\n\t\t\t\t} // calculateHash\n\t\t\t})\n\t\t} catch (e: unknown) {\n\t\t\ttryCatchRethrow(e as GraphQLError | Error)\n\t\t} finally {\n\t\t\tawait session.endSession()\n\t\t}\n\n\t\t// Reached only on a committed transaction: tryCatchRethrow above always throws.\n\t\t//\n\t\t// Three reasons this send sits here and is deliberately not awaited:\n\t\t// 1. Timing. Awaiting a network round-trip to SocketLabs made the response measurably slower\n\t\t// exactly when the address was registered and not throttled — the same fact the removed 429\n\t\t// used to state outright. What is left is one extra updateOne, ~a millisecond against\n\t\t// internet jitter, and the 10-minute throttle caps an attacker at one sample per address,\n\t\t// so there is nothing to average out.\n\t\t// 2. Retries. session.withTransaction re-runs its callback on a transient error. With the send\n\t\t// inside, a retried commit mailed the user a second link and invalidated the first.\n\t\t// 3. Failure disclosure. A SocketLabs outage used to surface as a 500, which only an address\n\t\t// that actually exists could ever receive.\n\t\t// The cost is that a delivery failure is now visible in Sentry only, mail in flight is lost if\n\t\t// the process is killed before the request settles, and — the one a user feels — the hash is\n\t\t// already committed when the send fails, so the 10-minute throttle is armed for a link that\n\t\t// never arrived. Clearing resetHash/resetDateReq from the catch below to undo that was\n\t\t// considered and rejected: a rejected promise does not prove non-delivery, and a timeout after\n\t\t// SocketLabs accepted the message would kill a link already sitting in the user's inbox.\n\t\tconst mail = pendingMail as IPendingMail | null\n\t\tif (mail !== null) {\n\t\t\ttry {\n\t\t\t\tconst SocketLabsObj = new SocketLabsLib()\n\t\t\t\tvoid SocketLabsObj.sendEmailReset(uEmail, mail.hash, mail.name).catch((e: unknown) => {\n\t\t\t\t\tSentry.captureException(e)\n\t\t\t\t})\n\t\t\t} catch (e: unknown) {\n\t\t\t\t// the constructor, or a synchronous throw before the promise exists\n\t\t\t\tSentry.captureException(e)\n\t\t\t}\n\t\t}\n\n\t\treturn true\n\t}\n})\n\n/** Shape of the bound mutation, for the modules that take it as a dependency. */\nexport type TResetPwdMutation = ReturnType<typeof createResetPwdMutation>\n\n/** `UserBase`-bound default — the mutation every existing consumer already imports. */\nexport const resetPwd: TResetPwdMutation = createResetPwdMutation({ getResetPwd, saveResetReq })\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signUp.mjs","sourceRoot":"","sources":["../../../../src/graphQL/schema/mutations/signUp.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,yCAAgC;AACxD,OAAO,EAAE,aAAa,EAAE,uCAA8B;AACtD,OAAO,EAAE,WAAW,EAAE,qCAA4B;AAClD,OAAO,EAAE,eAAe,EAAE,4CAAmC;AAC7D,OAAO,EAAE,SAAS,EAAE,sCAA6B;AACjD,OAAO,EAAE,eAAe,EAAE,yCAAgC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,2CAAqC;AAClE,OAAO,EAAE,cAAc,EAAgB,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACrF,OAAO,QAAQ,MAAM,UAAU,CAAA;AAQ/B,MAAM,CAAC,MAAM,MAAM,GAAG;IACrB,WAAW,EAAE,SAAS;IACtB,IAAI,EAAE,IAAI,cAAc,CAAC,cAAc,CAAC;IACxC,IAAI,EAAE;QACL,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,cAAc,CAAC,aAAa,CAAC,EAAE;QAClD,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,cAAc,CAAC,aAAa,CAAC,EAAE;KACrD;IACD,KAAK,CAAC,OAAO,CAAC,CAAU,EAAE,IAAiB;QAC1C,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAA;QAEhC,MAAM,MAAM,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAA;QACzC,aAAa,CAAC,MAAM,CAAC,CAAA;QACrB,WAAW,CAAC,QAAQ,CAAC,CAAA;QAErB,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,YAAY,EAAE,CAAA;QAC7C,IAAI,MAAM,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC;YACJ,MAAM,OAAO,CAAC,eAAe,CAAC,KAAK,IAAI,EAAE;gBACxC;;mBAEG;gBACH,MAAM,GAAG,MAAM,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;gBACzC,IAAI,MAAM,EAAE,CAAC;oBACZ,MAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAA;oBACzC,MAAM,aAAa,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAA;oBAC7C,MAAM,kBAAkB,EAAE,CAAA;gBAC3B,CAAC;gBAED;;mBAEG;gBACH,MAAM,gBAAgB,GAAG,MAAM,eAAe,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;gBAEzE;;mBAEG;gBACH,MAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAA;gBACzC,MAAM,aAAa,CAAC,eAAe,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;YAC9D,CAAC,CAAC,CAAA;QACH,CAAC;QAAC,OAAO,CAAU,EAAE,CAAC;YACrB,eAAe,CAAC,CAAyB,CAAC,CAAA;QAC3C,CAAC;gBAAS,CAAC;YACV,MAAM,OAAO,CAAC,UAAU,EAAE,CAAA;QAC3B,CAAC;QAED,OAAO,IAAI,CAAA;IACZ,CAAC;CACD,CAAA","sourcesContent":["import { SocketLabsLib } from '@email/SocketLabsLib.mjs'\nimport { checkEmailLen } from '@lib/checkEmailLen.mjs'\nimport { checkPwdLen } from '@lib/checkPwdLen.mjs'\nimport { registerNewUser } from '@lib/db/registerNewUser.mjs'\nimport { userExist } from '@lib/db/userExist.mjs'\nimport { tryCatchRethrow } from '@lib/tryCatchRethrow.mjs'\nimport { throwConflictError } from '@throw/throwConflictError.mjs'\nimport { GraphQLBoolean, GraphQLError, GraphQLNonNull, GraphQLString } from 'graphql'\nimport mongoose from 'mongoose'\n\n/** Arguments accepted by the `signUp` mutation. Exported so a consumer re-exporting the bound mutation can name its type. */\nexport interface ISignUpArgs {\n\temail: string\n\tpassword: string\n}\n\nexport const signUp = {\n\tdescription: 'Sign Up',\n\ttype: new GraphQLNonNull(GraphQLBoolean),\n\targs: {\n\t\temail: { type: new GraphQLNonNull(GraphQLString) },\n\t\tpassword: { type: new GraphQLNonNull(GraphQLString) }\n\t},\n\tasync resolve(_: unknown, args: ISignUpArgs) {\n\t\tconst { email, password } = args\n\n\t\tconst uEmail = email.toLowerCase().trim()\n\t\tcheckEmailLen(uEmail)\n\t\tcheckPwdLen(password)\n\n\t\tconst session = await mongoose.startSession()\n\t\tlet uExist = false\n\t\ttry {\n\t\t\tawait session.withTransaction(async () => {\n\t\t\t\t/********************************************\n\t\t\t\t * First, search if the user does not exist\n\t\t\t\t */\n\t\t\t\tuExist = await userExist(uEmail, session)\n\t\t\t\tif (uExist) {\n\t\t\t\t\tconst SocketLabsObj = new SocketLabsLib()\n\t\t\t\t\tawait SocketLabsObj.emailAlreadyValid(uEmail)\n\t\t\t\t\tthrow throwConflictError()\n\t\t\t\t}\n\n\t\t\t\t/*********************************************\n\t\t\t\t * ok, new user. create user obj for DB. generate hash password\n\t\t\t\t */\n\t\t\t\tconst hashConfirmEmail = await registerNewUser(uEmail, password, session)\n\n\t\t\t\t/************************************\n\t\t\t\t * send email\n\t\t\t\t */\n\t\t\t\tconst SocketLabsObj = new SocketLabsLib()\n\t\t\t\tawait SocketLabsObj.sendEmailVerify(uEmail, hashConfirmEmail)\n\t\t\t})\n\t\t} catch (e: unknown) {\n\t\t\ttryCatchRethrow(e as GraphQLError | Error)\n\t\t} finally {\n\t\t\tawait session.endSession()\n\t\t}\n\n\t\treturn true\n\t}\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"updatePassword.mjs","sourceRoot":"","sources":["../../../../src/graphQL/schema/mutations/updatePassword.mts"],"names":[],"mappings":"AAAA,OAA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C;YAAC,OAAO,CAAU,EAAE,CAAC;gBACrB,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAA;YAC3B,CAAC;QACF,CAAC;QAED,OAAO,IAAI,CAAA;IACZ,CAAC;CACD,CAAC,CAAA;AAKF,uFAAuF;AACvF,MAAM,CAAC,MAAM,cAAc,GAA4B,4BAA4B,CAAC;IACnF,WAAW;IACX,gBAAgB;IAChB,cAAc;CACd,CAAC,CAAA","sourcesContent":["import { SocketLabsLib } from '@email/SocketLabsLib.mjs'\nimport { checkEmailLen } from '@lib/checkEmailLen.mjs'\nimport { checkPwdLen } from '@lib/checkPwdLen.mjs'\nimport { DateLib } from '@lib/DateLib.mjs'\nimport { tryCatchRethrow } from '@lib/tryCatchRethrow.mjs'\nimport { getResetPwd, TGetResetPwd } from '@private/lib/access/db/getResetPwd.mjs'\nimport removeResetReq, { TRemoveResetReq } from '@private/lib/access/db/removeResetReq.mjs'\nimport updatePasswordDb, { TUpdatePasswordDb } from '@private/lib/access/db/updatePasswordDb.mjs'\nimport * as Sentry from '@sentry/node'\nimport { throwForbiddenError } from '@throw/throwForbiddenError.mjs'\nimport { throwInternalError } from '@throw/throwInternalError.mjs'\nimport { GraphQLBoolean, GraphQLError, GraphQLNonNull, GraphQLString } from 'graphql'\nimport mongoose, { ClientSession } from 'mongoose'\n\n/** Arguments accepted by the `updatePassword` mutation. Exported so a consumer re-exporting the bound mutation can name its type. */\nexport interface IUpdatePasswordArgs {\n\temail: string\n\thash: string\n\tpassword: string\n}\n\n/** Readers and writers the resolver needs, all bound to the same model + paths by the caller. */\nexport interface IUpdatePasswordDeps {\n\tgetResetPwd: TGetResetPwd\n\tupdatePasswordDb: TUpdatePasswordDb\n\tremoveResetReq: TRemoveResetReq\n}\n\n/** Normalised inputs the transaction body works on, bundled to keep it within the max-params budget. */\ninterface IUpdatePasswordInput {\n\tuEmail: string\n\thash: string\n\tpassword: string\n}\n\n/**\n * The transactional core: validate the reset hash, apply the new password and clear the request.\n * Extracted from resolve() only to keep it inside the max-lines-per-function budget — behaviour\n * unchanged. Returns the account holder's name so the caller can mail the post-commit confirmation.\n */\nasync function applyPasswordReset(\n\tdeps: IUpdatePasswordDeps,\n\tsession: ClientSession,\n\tinput: IUpdatePasswordInput\n): Promise<string> {\n\tconst { uEmail, hash, password } = input\n\tconst resetPwd = await deps.getResetPwd(session, uEmail)\n\n\t// check if email is present in db\n\tif (resetPwd === null) {\n\t\tthrow throwForbiddenError() // don't reveal whether the email is present, for privacy\n\t}\n\n\t// No usable reset state. This is NOT an internal error as far as the caller is concerned:\n\t// answering 500 here while an unknown address answers 403 turns this mutation into an\n\t// account-enumeration oracle, because every registered account that has never requested a\n\t// reset lands on this branch (getResetPwd yields resetHash === null whenever\n\t// account.resetDateReq is undefined). Same 403 as the unknown-address path; the orphan\n\t// state is reported to Sentry instead of to the caller.\n\tif (resetPwd.resetHash === null) {\n\t\tSentry.captureMessage(`[updatePassword] no usable resetHash for ${uEmail}`)\n\t\tthrow throwForbiddenError()\n\t}\n\t/* c8 ignore next 4 -- defensive guard, resetDateReq cannot be null when resetHash is set */\n\tif (resetPwd.resetDateReq === null) {\n\t\tSentry.captureMessage(`[updatePassword] resetHash set but resetDateReq missing for ${uEmail}`)\n\t\tthrow throwForbiddenError()\n\t}\n\n\t// check if hash is missing or invalid\n\tif (resetPwd.resetHash !== hash) {\n\t\tthrow throwForbiddenError() // don't reveal whether the email is present, for privacy\n\t}\n\n\t// check if the request was made within 1 hour\n\tconst dt1 = new Date('' + resetPwd.resetDateReq)\n\tif (DateLib.minElapsed(dt1) > 60) {\n\t\tthrow throwForbiddenError() // The link is no longer valid\n\t}\n\n\tconst update = await deps.updatePasswordDb(session, resetPwd._id, password)\n\tif (!update) {\n\t\tthrow throwInternalError() // \"System error while updating the password.\"\n\t}\n\n\t// delete password reset request data from db\n\tawait deps.removeResetReq(session, uEmail)\n\n\t// the confirmation email is sent after the commit, not here\n\treturn resetPwd.name\n}\n\n/**\n * Change the password of an account holding a valid, unexpired reset hash.\n *\n * The collection and field layout live entirely in the injected reader/writers, so the same resolver\n * serves any account model. In particular the cleanup unsets whatever `resetClear` names, which is not\n * necessarily the two leaf paths this resolver reads — see `removeResetReq`.\n */\nexport const createUpdatePasswordMutation = (deps: IUpdatePasswordDeps) => ({\n\tdescription: \"changes the user's password\",\n\ttype: new GraphQLNonNull(GraphQLBoolean),\n\targs: {\n\t\temail: { type: new GraphQLNonNull(GraphQLString) },\n\t\thash: { type: new GraphQLNonNull(GraphQLString) },\n\t\tpassword: { type: new GraphQLNonNull(GraphQLString) }\n\t},\n\tasync resolve(_: unknown, args: IUpdatePasswordArgs) {\n\t\tconst { email, hash, password } = args\n\n\t\tconst uEmail = email.trim().toLowerCase()\n\t\tcheckEmailLen(uEmail)\n\t\tcheckPwdLen(password)\n\n\t\t// Set only once the transaction has actually persisted the new password. Carries the user's\n\t\t// name to the post-commit confirmation email.\n\t\tlet confirmTo: string | null = null\n\n\t\tconst session = await mongoose.startSession()\n\n\t\ttry {\n\t\t\tawait session.withTransaction(async () => {\n\t\t\t\tconfirmTo = await applyPasswordReset(deps, session, { uEmail, hash, password })\n\t\t\t})\n\t\t} catch (e: unknown) {\n\t\t\ttryCatchRethrow(e as GraphQLError | Error)\n\t\t} finally {\n\t\t\tawait session.endSession()\n\t\t}\n\n\t\t// Reached only on a committed transaction: tryCatchRethrow above always throws.\n\t\t//\n\t\t// The send sits here rather than inside the callback because session.withTransaction re-runs\n\t\t// its callback on a transient error, and a retried commit therefore mailed the user a second\n\t\t// \"your password was changed\" notice. It is still awaited — unlike resetPwd there is no timing\n\t\t// oracle to close here, since reaching this point at all requires a valid reset hash.\n\t\t//\n\t\t// A delivery failure no longer fails the request. It used to abort the transaction and answer\n\t\t// 500, rolling back the password change with it — consistent, but it made the mail provider a\n\t\t// hard dependency: with SocketLabs down, nobody could complete a reset at all. The password is\n\t\t// committed by the time we get here, so the failure goes to Sentry and the caller still gets\n\t\t// true. The confirmation is a notice, not part of the operation.\n\t\t//\n\t\t// Don't \"restore\" the abort: there is no transaction left to abort at this point. Rethrowing\n\t\t// would report 500 for a password that is already live, and compensating would mean writing\n\t\t// back the old bcrypt hash, which this flow never reads. Moving the send back inside the\n\t\t// callback brings back the duplicate notice AND lets a mail go out for a commit that then\n\t\t// fails — an email cannot be recalled.\n\t\tconst name = confirmTo as string | null\n\t\tif (name !== null) {\n\t\t\ttry {\n\t\t\t\tconst SocketLabsObj = new SocketLabsLib()\n\t\t\t\tawait SocketLabsObj.sendResetPwdConfirmation(uEmail, name)\n\t\t\t} catch (e: unknown) {\n\t\t\t\tSentry.captureException(e)\n\t\t\t}\n\t\t}\n\n\t\treturn true\n\t}\n})\n\n/** Shape of the bound mutation, for the modules that take it as a dependency. */\nexport type TUpdatePasswordMutation = ReturnType<typeof createUpdatePasswordMutation>\n\n/** `UserBase`-bound default — the mutation every existing consumer already imports. */\nexport const updatePassword: TUpdatePasswordMutation = createUpdatePasswordMutation({\n\tgetResetPwd,\n\tupdatePasswordDb,\n\tremoveResetReq\n})\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DeleteType.mjs","sourceRoot":"","sources":["../../../../src/graphQL/schema/types/DeleteType.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEvE,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,iBAAiB,CAAC;IAC/C,IAAI,EAAE,YAAY;IAClB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QACd,YAAY,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE;QACtC,YAAY,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE;KAClC,CAAC;CACF,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC/B,YAAY,EAAE,KAAK;IACnB,YAAY,EAAE,CAAC;CACf,CAAA","sourcesContent":["import { GraphQLBoolean, GraphQLInt, GraphQLObjectType } from 'graphql'\n\nexport const DeleteType = new GraphQLObjectType({\n\tname: 'DeleteType',\n\tfields: () => ({\n\t\tacknowledged: { type: GraphQLBoolean },\n\t\tdeletedCount: { type: GraphQLInt }\n\t})\n})\n\nexport const RET_DEL_ROLLBACK = {\n\tacknowledged: false,\n\tdeletedCount: 0\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DoneType.mjs","sourceRoot":"","sources":["../../../../src/graphQL/schema/types/DoneType.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,cAAc,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAErG,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,iBAAiB,CAAC;IAC7C,IAAI,EAAE,UAAU;IAChB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QACd,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,cAAc,CAAC,cAAc,CAAC,EAAE;QAClD,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,cAAc,CAAC,aAAa,CAAC,EAAE;QACpD,GAAG,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;KACxB,CAAC;CACF,CAAC,CAAA","sourcesContent":["import { GraphQLBoolean, GraphQLID, GraphQLNonNull, GraphQLObjectType, GraphQLString } from 'graphql'\n\nexport const DoneType = new GraphQLObjectType({\n\tname: 'DoneType',\n\tfields: () => ({\n\t\tdone: { type: new GraphQLNonNull(GraphQLBoolean) },\n\t\tmessage: { type: new GraphQLNonNull(GraphQLString) },\n\t\t_id: { type: GraphQLID }\n\t})\n})\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FindOneAndUpdateType.mjs","sourceRoot":"","sources":["../../../../src/graphQL/schema/types/FindOneAndUpdateType.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAE3E,MAAM,0BAA0B,GAAG,IAAI,iBAAiB,CAAC;IACxD,IAAI,EAAE,4BAA4B;IAClC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QACd,eAAe,EAAE,EAAE,IAAI,EAAE,IAAI,cAAc,CAAC,cAAc,CAAC,EAAE;KAC7D,CAAC;CACF,CAAC,CAAA;AAEF,0BAA0B;AAC1B,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,iBAAiB,CAAC;IACzD,IAAI,EAAE,sBAAsB;IAC5B,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QACd,eAAe,EAAE,EAAE,IAAI,EAAE,IAAI,cAAc,CAAC,0BAA0B,CAAC,EAAE;KACzE,CAAC;CACF,CAAC,CAAA","sourcesContent":["import { GraphQLBoolean, GraphQLNonNull, GraphQLObjectType } from 'graphql'\n\nconst FindOneAndUpdateDetailType = new GraphQLObjectType({\n\tname: 'FindOneAndUpdateDetailType',\n\tfields: () => ({\n\t\tupdatedExisting: { type: new GraphQLNonNull(GraphQLBoolean) }\n\t})\n})\n\n// I ignore the other data\nexport const FindOneAndUpdateType = new GraphQLObjectType({\n\tname: 'FindOneAndUpdateType',\n\tfields: () => ({\n\t\tlastErrorObject: { type: new GraphQLNonNull(FindOneAndUpdateDetailType) }\n\t})\n})\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LoginAppType.mjs","sourceRoot":"","sources":["../../../../src/graphQL/schema/types/LoginAppType.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE1F,sCAAsC;AACtC,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,iBAAiB,CAAC;IACjD,IAAI,EAAE,cAAc;IACpB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QACd,WAAW,EAAE,EAAE,IAAI,EAAE,IAAI,cAAc,CAAC,aAAa,CAAC,EAAE;QACxD,cAAc,EAAE,EAAE,IAAI,EAAE,IAAI,cAAc,CAAC,aAAa,CAAC,EAAE;QAC3D,cAAc,EAAE,EAAE,IAAI,EAAE,IAAI,cAAc,CAAC,cAAc,CAAC,EAAE;KAC5D,CAAC;CACF,CAAC,CAAA","sourcesContent":["import { GraphQLBoolean, GraphQLNonNull, GraphQLObjectType, GraphQLString } from 'graphql'\n\n// returns null id if it fails to save\nexport const LoginAppType = new GraphQLObjectType({\n\tname: 'LoginAppType',\n\tfields: () => ({\n\t\taccessToken: { type: new GraphQLNonNull(GraphQLString) },\n\t\tonboardingStep: { type: new GraphQLNonNull(GraphQLString) },\n\t\tonboardingDone: { type: new GraphQLNonNull(GraphQLBoolean) }\n\t})\n})\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LoginType.mjs","sourceRoot":"","sources":["../../../../src/graphQL/schema/types/LoginType.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE1E,sCAAsC;AACtC,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,iBAAiB,CAAC;IAC9C,IAAI,EAAE,WAAW;IACjB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QACd,WAAW,EAAE,EAAE,IAAI,EAAE,IAAI,cAAc,CAAC,aAAa,CAAC,EAAE;KACxD,CAAC;CACF,CAAC,CAAA","sourcesContent":["import { GraphQLNonNull, GraphQLObjectType, GraphQLString } from 'graphql'\n\n// returns null id if it fails to save\nexport const LoginType = new GraphQLObjectType({\n\tname: 'LoginType',\n\tfields: () => ({\n\t\taccessToken: { type: new GraphQLNonNull(GraphQLString) }\n\t})\n})\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MidNameType.mjs","sourceRoot":"","sources":["../../../../src/graphQL/schema/types/MidNameType.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAErF;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,iBAAiB,CAAC;IAChD,IAAI,EAAE,aAAa;IACnB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QACd,GAAG,EAAE,EAAE,IAAI,EAAE,IAAI,cAAc,CAAC,SAAS,CAAC,EAAE;QAC5C,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,cAAc,CAAC,aAAa,CAAC,EAAE;KACjD,CAAC;CACF,CAAC,CAAA","sourcesContent":["import { GraphQLID, GraphQLNonNull, GraphQLObjectType, GraphQLString } from 'graphql'\n\n/**\n * MongoDB _id & name\n */\nexport const MidNameType = new GraphQLObjectType({\n\tname: 'MidNameType',\n\tfields: () => ({\n\t\t_id: { type: new GraphQLNonNull(GraphQLID) },\n\t\tname: { type: new GraphQLNonNull(GraphQLString) }\n\t})\n})\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OnlyIdType.mjs","sourceRoot":"","sources":["../../../../src/graphQL/schema/types/OnlyIdType.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEtE,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,iBAAiB,CAAC;IAC/C,IAAI,EAAE,YAAY;IAClB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QACd,GAAG,EAAE,EAAE,IAAI,EAAE,IAAI,cAAc,CAAC,SAAS,CAAC,EAAE;KAC5C,CAAC;CACF,CAAC,CAAA","sourcesContent":["import { GraphQLID, GraphQLNonNull, GraphQLObjectType } from 'graphql'\n\nexport const OnlyIdType = new GraphQLObjectType({\n\tname: 'OnlyIdType',\n\tfields: () => ({\n\t\t_id: { type: new GraphQLNonNull(GraphQLID) }\n\t})\n})\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RefreshType.mjs","sourceRoot":"","sources":["../../../../src/graphQL/schema/types/RefreshType.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE1F,sCAAsC;AACtC,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,iBAAiB,CAAC;IAChD,IAAI,EAAE,aAAa;IACnB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QACd,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,cAAc,CAAC,cAAc,CAAC,EAAE;QACpD,WAAW,EAAE,EAAE,IAAI,EAAE,IAAI,cAAc,CAAC,aAAa,CAAC,EAAE;KACxD,CAAC;CACF,CAAC,CAAA","sourcesContent":["import { GraphQLBoolean, GraphQLNonNull, GraphQLObjectType, GraphQLString } from 'graphql'\n\n// returns null id if it fails to save\nexport const RefreshType = new GraphQLObjectType({\n\tname: 'RefreshType',\n\tfields: () => ({\n\t\tstatus: { type: new GraphQLNonNull(GraphQLBoolean) },\n\t\taccessToken: { type: new GraphQLNonNull(GraphQLString) }\n\t})\n})\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RetStatusMexType.mjs","sourceRoot":"","sources":["../../../../src/graphQL/schema/types/RetStatusMexType.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE1E,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,iBAAiB,CAAC;IACrD,IAAI,EAAE,kBAAkB;IACxB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QACd,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,cAAc,CAAC,aAAa,CAAC,EAAE;QACnD,GAAG,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE;KAC5B,CAAC;CACF,CAAC,CAAA","sourcesContent":["import { GraphQLNonNull, GraphQLObjectType, GraphQLString } from 'graphql'\n\nexport const RetStatusMexType = new GraphQLObjectType({\n\tname: 'RetStatusMexType',\n\tfields: () => ({\n\t\tstatus: { type: new GraphQLNonNull(GraphQLString) },\n\t\tmex: { type: GraphQLString }\n\t})\n})\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RetStatusType.mjs","sourceRoot":"","sources":["../../../../src/graphQL/schema/types/RetStatusType.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE1E,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,iBAAiB,CAAC;IAClD,IAAI,EAAE,eAAe;IACrB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QACd,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,cAAc,CAAC,aAAa,CAAC,EAAE;KACnD,CAAC;CACF,CAAC,CAAA","sourcesContent":["import { GraphQLNonNull, GraphQLObjectType, GraphQLString } from 'graphql'\n\nexport const RetStatusType = new GraphQLObjectType({\n\tname: 'RetStatusType',\n\tfields: () => ({\n\t\tstatus: { type: new GraphQLNonNull(GraphQLString) }\n\t})\n})\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SaveType.mjs","sourceRoot":"","sources":["../../../../src/graphQL/schema/types/SaveType.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEtD,sCAAsC;AACtC,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,iBAAiB,CAAC;IAC7C,IAAI,EAAE,UAAU;IAChB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QACd,GAAG,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;KACxB,CAAC;CACF,CAAC,CAAA","sourcesContent":["import { GraphQLID, GraphQLObjectType } from 'graphql'\n\n// returns null id if it fails to save\nexport const SaveType = new GraphQLObjectType({\n\tname: 'SaveType',\n\tfields: () => ({\n\t\t_id: { type: GraphQLID }\n\t})\n})\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SidNameType.mjs","sourceRoot":"","sources":["../../../../src/graphQL/schema/types/SidNameType.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEtF;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,iBAAiB,CAAC;IAChD,IAAI,EAAE,aAAa;IACnB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QACd,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,cAAc,CAAC,UAAU,CAAC,EAAE;QAC5C,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,cAAc,CAAC,aAAa,CAAC,EAAE;KACjD,CAAC;CACF,CAAC,CAAA","sourcesContent":["import { GraphQLInt, GraphQLNonNull, GraphQLObjectType, GraphQLString } from 'graphql'\n\n/**\n * MariaDB id & name\n */\nexport const SidNameType = new GraphQLObjectType({\n\tname: 'SidNameType',\n\tfields: () => ({\n\t\tid: { type: new GraphQLNonNull(GraphQLInt) },\n\t\tname: { type: new GraphQLNonNull(GraphQLString) }\n\t})\n})\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SidNomeType.mjs","sourceRoot":"","sources":["../../../../src/graphQL/schema/types/SidNomeType.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEtF;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,iBAAiB,CAAC;IAChD,IAAI,EAAE,aAAa;IACnB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QACd,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,cAAc,CAAC,UAAU,CAAC,EAAE;QAC5C,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,cAAc,CAAC,aAAa,CAAC,EAAE;KACjD,CAAC;CACF,CAAC,CAAA","sourcesContent":["import { GraphQLInt, GraphQLNonNull, GraphQLObjectType, GraphQLString } from 'graphql'\n\n/**\n * MariaDB id & nome\n */\nexport const SidNomeType = new GraphQLObjectType({\n\tname: 'SidNomeType',\n\tfields: () => ({\n\t\tid: { type: new GraphQLNonNull(GraphQLInt) },\n\t\tnome: { type: new GraphQLNonNull(GraphQLString) }\n\t})\n})\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UpdateResultType.mjs","sourceRoot":"","sources":["../../../../src/graphQL/schema/types/UpdateResultType.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA,CAAC,sCAAsC;AAE9G,sCAAsC;AACtC,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,iBAAiB,CAAC;IACrD,IAAI,EAAE,kBAAkB;IACxB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QACd,aAAa,EAAE,EAAE,IAAI,EAAE,IAAI,cAAc,CAAC,UAAU,CAAC,EAAE;KACvD,CAAC;CACF,CAAC,CAAA","sourcesContent":["import { GraphQLInt, GraphQLNonNull, GraphQLObjectType } from 'graphql' // returns null id if it fails to save\n\n// returns null id if it fails to save\nexport const UpdateResultType = new GraphQLObjectType({\n\tname: 'UpdateResultType',\n\tfields: () => ({\n\t\tmodifiedCount: { type: new GraphQLNonNull(GraphQLInt) }\n\t})\n})\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"status.mjs","sourceRoot":"","sources":["../../src/graphQL/status.mts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,CAAA;AACxB,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAA;AAC9B,MAAM,CAAC,MAAM,iBAAiB,GAAG,iBAAiB,CAAA;AAClD,MAAM,CAAC,MAAM,kBAAkB,GAAG,kBAAkB,CAAA;AACpD,MAAM,CAAC,MAAM,YAAY,GAAG,YAAY,CAAA;AACxC,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAA;AAC5B,MAAM,CAAC,MAAM,SAAS,GAAG,SAAS,CAAA","sourcesContent":["export const stOk = 'ok'\nexport const stExist = 'exist'\nexport const stFailToSendEmail = 'failToSendEmail'\nexport const stNotFoundNotMatch = 'notFoundNotMatch'\nexport const stErrBackend = 'errBackend'\nexport const stWait = 'wait'\nexport const stExpired = 'expired'\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throwAccessTokenExpiredOrDeleted.mjs","sourceRoot":"","sources":["../../../src/graphQL/throw/throwAccessTokenExpiredOrDeleted.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,gCAAoC;AAEhE,MAAM,CAAC,MAAM,gCAAgC,GAAG,GAAG,EAAE;IACpD,MAAM,iBAAiB,CAAC,GAAG,EAAE,eAAe,EAAE,8CAA8C,CAAC,CAAA;AAC9F,CAAC,CAAA","sourcesContent":["import { throwGraphQLError } from '@throw/throwGraphQLError.mjs'\n\nexport const throwAccessTokenExpiredOrDeleted = () => {\n\tthrow throwGraphQLError(498, 'Invalid Token', 'Access Token is expired or deleted by Admin.')\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throwAccessTokenRequired.mjs","sourceRoot":"","sources":["../../../src/graphQL/throw/throwAccessTokenRequired.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,gCAAoC;AAEhE,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,EAAE;IAC5C,MAAM,iBAAiB,CAAC,GAAG,EAAE,gBAAgB,EAAE,wBAAwB,CAAC,CAAA;AACzE,CAAC,CAAA","sourcesContent":["import { throwGraphQLError } from '@throw/throwGraphQLError.mjs'\n\nexport const throwAccessTokenRequired = () => {\n\tthrow throwGraphQLError(499, 'Token Required', 'Access Token Required.')\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throwAlreadyDone.mjs","sourceRoot":"","sources":["../../../src/graphQL/throw/throwAlreadyDone.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,gCAAoC;AAEhE;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACpC,MAAM,iBAAiB,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;AACrC,CAAC,CAAA","sourcesContent":["import { throwGraphQLError } from '@throw/throwGraphQLError.mjs'\n\n/**\n * this status code do not allow body content\n */\nexport const throwAlreadyDone = () => {\n\tthrow throwGraphQLError(204, '', '')\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throwAlreadyTakenError.mjs","sourceRoot":"","sources":["../../../src/graphQL/throw/throwAlreadyTakenError.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,gCAAoC;AAEhE,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,OAAe,6BAA6B,EAAE,EAAE;IACtF,2DAA2D;IAC3D,MAAM,iBAAiB,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,CAAC,CAAA;AAC/C,CAAC,CAAA","sourcesContent":["import { throwGraphQLError } from '@throw/throwGraphQLError.mjs'\n\nexport const throwAlreadyTakenError = (desc: string = 'You have already done this.') => {\n\t// e.g. sending an email to someone who already received it\n\tthrow throwGraphQLError(409, 'Conflict', desc)\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throwConflictError.mjs","sourceRoot":"","sources":["../../../src/graphQL/throw/throwConflictError.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,qCAAyC;AAE1E,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAAe,6BAA6B,EAAE,EAAE;IAClF,+DAA+D;IAC/D,MAAM,sBAAsB,CAAC,IAAI,CAAC,CAAA;AACnC,CAAC,CAAA","sourcesContent":["import { throwAlreadyTakenError } from '@throw/throwAlreadyTakenError.mjs'\n\nexport const throwConflictError = (desc: string = 'You have already done this.') => {\n\t// e.g. sending an email to someone who has already received it\n\tthrow throwAlreadyTakenError(desc)\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throwErrorWrongUserInput.mjs","sourceRoot":"","sources":["../../../src/graphQL/throw/throwErrorWrongUserInput.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,gCAAoC;AAEhE,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,OAAe,EAAE,EAAE;IAC3D,MAAM,iBAAiB,CAAC,GAAG,EAAE,aAAa,EAAE,OAAO,CAAC,CAAA;AACrD,CAAC,CAAA","sourcesContent":["import { throwGraphQLError } from '@throw/throwGraphQLError.mjs'\n\nexport const throwErrorWrongUserInput = (message: string) => {\n\tthrow throwGraphQLError(400, 'Bad Request', message)\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throwForbiddenError.mjs","sourceRoot":"","sources":["../../../src/graphQL/throw/throwForbiddenError.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,gCAAoC;AAEhE,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACvC,MAAM,iBAAiB,CAAC,GAAG,EAAE,WAAW,EAAE,YAAY,CAAC,CAAA;AACxD,CAAC,CAAA","sourcesContent":["import { throwGraphQLError } from '@throw/throwGraphQLError.mjs'\n\nexport const throwForbiddenError = () => {\n\tthrow throwGraphQLError(403, 'Forbidden', 'Forbidden.')\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throwGoneError.mjs","sourceRoot":"","sources":["../../../src/graphQL/throw/throwGoneError.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,yCAAmC;AACzE,OAAO,EAAE,iBAAiB,EAAE,gCAAoC;AAEhE,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,OAAe,iBAAiB,EAAE,EAAE;IAClE,MAAM,iBAAiB,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAA;AAC7C,CAAC,CAAA","sourcesContent":["import { ERR_MISCONFIGURED, ERR_OOPS } from '@private/graphQL/Consts.mjs'\nimport { throwGraphQLError } from '@throw/throwGraphQLError.mjs'\n\nexport const throwGoneError = (desc: string = ERR_MISCONFIGURED) => {\n\tthrow throwGraphQLError(410, ERR_OOPS, desc)\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throwGraphQLError.mjs","sourceRoot":"","sources":["../../../src/graphQL/throw/throwGraphQLError.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAEtC,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAAE,KAAa,EAAE,cAAsB,EAAE,EAAE,EAAE;IAC5F,MAAM,IAAI,YAAY,CAAC,KAAK,EAAE,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,EAAE,CAAC,CAAA;AACjF,CAAC,CAAA","sourcesContent":["import { GraphQLError } from 'graphql'\n\nexport const throwGraphQLError = (status: number, title: string, description: string = '') => {\n\tthrow new GraphQLError(title, { extensions: { http: { status }, description } })\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throwInternalError.mjs","sourceRoot":"","sources":["../../../src/graphQL/throw/throwInternalError.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,gCAAoC;AAEhE,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAAe,EAAE,EAAE,EAAE;IACvD,MAAM,iBAAiB,CAAC,GAAG,EAAE,uBAAuB,EAAE,8BAA8B,IAAI,EAAE,CAAC,CAAA;AAC5F,CAAC,CAAA","sourcesContent":["import { throwGraphQLError } from '@throw/throwGraphQLError.mjs'\n\nexport const throwInternalError = (desc: string = '') => {\n\tthrow throwGraphQLError(500, 'Internal Server Error', `Error reported to Dev Team.${desc}`)\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throwMethodNotAllowedError.mjs","sourceRoot":"","sources":["../../../src/graphQL/throw/throwMethodNotAllowedError.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,yCAAmC;AACzE,OAAO,EAAE,iBAAiB,EAAE,gCAAoC;AAEhE,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,EAAE;IAC9C,MAAM,iBAAiB,CAAC,GAAG,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAA;AAC1D,CAAC,CAAA","sourcesContent":["import { ERR_MISCONFIGURED, ERR_OOPS } from '@private/graphQL/Consts.mjs'\nimport { throwGraphQLError } from '@throw/throwGraphQLError.mjs'\n\nexport const throwMethodNotAllowedError = () => {\n\tthrow throwGraphQLError(405, ERR_OOPS, ERR_MISCONFIGURED)\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throwMissingMalformedInvalidToken.mjs","sourceRoot":"","sources":["../../../src/graphQL/throw/throwMissingMalformedInvalidToken.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,gCAAoC;AAEhE,MAAM,CAAC,MAAM,iCAAiC,GAAG,GAAG,EAAE;IACrD,MAAM,iBAAiB,CAAC,GAAG,EAAE,gBAAgB,EAAE,kCAAkC,CAAC,CAAA;AACnF,CAAC,CAAA","sourcesContent":["import { throwGraphQLError } from '@throw/throwGraphQLError.mjs'\n\nexport const throwMissingMalformedInvalidToken = () => {\n\tthrow throwGraphQLError(499, 'Token Required', 'Missing/malformed/invalid token.')\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throwNotAcceptableError.mjs","sourceRoot":"","sources":["../../../src/graphQL/throw/throwNotAcceptableError.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,yCAAmC;AACzE,OAAO,EAAE,iBAAiB,EAAE,gCAAoC;AAEhE,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,EAAE;IAC3C,MAAM,iBAAiB,CAAC,GAAG,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAA;AAC1D,CAAC,CAAA","sourcesContent":["import { ERR_MISCONFIGURED, ERR_OOPS } from '@private/graphQL/Consts.mjs'\nimport { throwGraphQLError } from '@throw/throwGraphQLError.mjs'\n\nexport const throwNotAcceptableError = () => {\n\tthrow throwGraphQLError(406, ERR_OOPS, ERR_MISCONFIGURED)\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throwNotFoundError.mjs","sourceRoot":"","sources":["../../../src/graphQL/throw/throwNotFoundError.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,yCAAmC;AACzE,OAAO,EAAE,iBAAiB,EAAE,gCAAoC;AAEhE,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAAe,iBAAiB,EAAE,EAAE;IACtE,MAAM,iBAAiB,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAA;AAC7C,CAAC,CAAA","sourcesContent":["import { ERR_MISCONFIGURED, ERR_OOPS } from '@private/graphQL/Consts.mjs'\nimport { throwGraphQLError } from '@throw/throwGraphQLError.mjs'\n\nexport const throwNotFoundError = (desc: string = ERR_MISCONFIGURED) => {\n\tthrow throwGraphQLError(404, ERR_OOPS, desc)\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throwNotImplementedError.mjs","sourceRoot":"","sources":["../../../src/graphQL/throw/throwNotImplementedError.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,yCAAmC;AACzE,OAAO,EAAE,iBAAiB,EAAE,gCAAoC;AAEhE,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,EAAE;IAC5C,MAAM,iBAAiB,CAAC,GAAG,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAA;AAC1D,CAAC,CAAA","sourcesContent":["import { ERR_MISCONFIGURED, ERR_OOPS } from '@private/graphQL/Consts.mjs'\nimport { throwGraphQLError } from '@throw/throwGraphQLError.mjs'\n\nexport const throwNotImplementedError = () => {\n\tthrow throwGraphQLError(501, ERR_OOPS, ERR_MISCONFIGURED)\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throwPaymentRequiredError.mjs","sourceRoot":"","sources":["../../../src/graphQL/throw/throwPaymentRequiredError.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,gCAAoC;AAEhE,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAG,EAAE;IAC7C,MAAM,iBAAiB,CAAC,GAAG,EAAE,kBAAkB,EAAE,mDAAmD,CAAC,CAAA;AACtG,CAAC,CAAA","sourcesContent":["import { throwGraphQLError } from '@throw/throwGraphQLError.mjs'\n\nexport const throwPaymentRequiredError = () => {\n\tthrow throwGraphQLError(402, 'Payment Required', 'You must have a subscription to use this feature.')\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throwPreconditionFailedNoAuthCookie.mjs","sourceRoot":"","sources":["../../../src/graphQL/throw/throwPreconditionFailedNoAuthCookie.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAE3D,MAAM,CAAC,MAAM,mCAAmC,GAAG,GAAG,EAAE;IACvD,MAAM,iBAAiB,CAAC,GAAG,EAAE,qBAAqB,EAAE,0BAA0B,CAAC,CAAA;AAChF,CAAC,CAAA","sourcesContent":["import { throwGraphQLError } from './throwGraphQLError.mjs'\n\nexport const throwPreconditionFailedNoAuthCookie = () => {\n\tthrow throwGraphQLError(412, 'Precondition Failed', 'No authorization cookie.')\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throwPreconditionFailedNoAuthHeader.mjs","sourceRoot":"","sources":["../../../src/graphQL/throw/throwPreconditionFailedNoAuthHeader.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAE3D,MAAM,CAAC,MAAM,mCAAmC,GAAG,GAAG,EAAE;IACvD,MAAM,iBAAiB,CAAC,GAAG,EAAE,qBAAqB,EAAE,0BAA0B,CAAC,CAAA;AAChF,CAAC,CAAA","sourcesContent":["import { throwGraphQLError } from './throwGraphQLError.mjs'\n\nexport const throwPreconditionFailedNoAuthHeader = () => {\n\tthrow throwGraphQLError(412, 'Precondition Failed', 'No authorization header.')\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throwRefreshTokenExpiredOrDeleted.mjs","sourceRoot":"","sources":["../../../src/graphQL/throw/throwRefreshTokenExpiredOrDeleted.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,gCAAoC;AAEhE,MAAM,CAAC,MAAM,iCAAiC,GAAG,GAAG,EAAE;IACrD,MAAM,iBAAiB,CAAC,GAAG,EAAE,eAAe,EAAE,+CAA+C,CAAC,CAAA;AAC/F,CAAC,CAAA","sourcesContent":["import { throwGraphQLError } from '@throw/throwGraphQLError.mjs'\n\nexport const throwRefreshTokenExpiredOrDeleted = () => {\n\tthrow throwGraphQLError(498, 'Invalid Token', 'Refresh Token is expired or deleted by Admin.')\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throwRefreshTokenRequired.mjs","sourceRoot":"","sources":["../../../src/graphQL/throw/throwRefreshTokenRequired.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,gCAAoC;AAEhE,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAG,EAAE;IAC7C,MAAM,iBAAiB,CAAC,GAAG,EAAE,gBAAgB,EAAE,yBAAyB,CAAC,CAAA;AAC1E,CAAC,CAAA","sourcesContent":["import { throwGraphQLError } from '@throw/throwGraphQLError.mjs'\n\nexport const throwRefreshTokenRequired = () => {\n\tthrow throwGraphQLError(499, 'Token Required', 'Refresh Token Required.')\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throwRefreshTokenSignatureRequired.mjs","sourceRoot":"","sources":["../../../src/graphQL/throw/throwRefreshTokenSignatureRequired.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,gCAAoC;AAEhE,MAAM,CAAC,MAAM,kCAAkC,GAAG,GAAG,EAAE;IACtD,MAAM,iBAAiB,CAAC,GAAG,EAAE,gBAAgB,EAAE,mCAAmC,CAAC,CAAA;AACpF,CAAC,CAAA","sourcesContent":["import { throwGraphQLError } from '@throw/throwGraphQLError.mjs'\n\nexport const throwRefreshTokenSignatureRequired = () => {\n\tthrow throwGraphQLError(499, 'Token Required', 'Refresh Token Signature Required.')\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throwTooManyRequestsError.mjs","sourceRoot":"","sources":["../../../src/graphQL/throw/throwTooManyRequestsError.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,gCAAoC;AAEhE,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,OAAe,EAAE,EAAE,EAAE;IAC9D,MAAM,iBAAiB,CAAC,GAAG,EAAE,mBAAmB,EAAE,IAAI,CAAC,CAAA;AACxD,CAAC,CAAA","sourcesContent":["import { throwGraphQLError } from '@throw/throwGraphQLError.mjs'\n\nexport const throwTooManyRequestsError = (desc: string = '') => {\n\tthrow throwGraphQLError(429, 'Too Many Requests', desc)\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throwUnauthorizedError.mjs","sourceRoot":"","sources":["../../../src/graphQL/throw/throwUnauthorizedError.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,gCAAoC;AAEhE,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,OAAe,uBAAuB,EAAE,EAAE;IAChF,MAAM,iBAAiB,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,CAAC,CAAA;AACnD,CAAC,CAAA","sourcesContent":["import { throwGraphQLError } from '@throw/throwGraphQLError.mjs'\n\nexport const throwUnauthorizedError = (text: string = 'You are unauthorized.') => {\n\tthrow throwGraphQLError(401, 'Unauthorized', text)\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throwUnprocessableContentError.mjs","sourceRoot":"","sources":["../../../src/graphQL/throw/throwUnprocessableContentError.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,gCAAoC;AAEhE,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAC7C,MAAc,qEAAqE,EAClF,EAAE;IACH,MAAM,iBAAiB,CAAC,GAAG,EAAE,uBAAuB,EAAE,GAAG,CAAC,CAAA;AAC3D,CAAC,CAAA","sourcesContent":["import { throwGraphQLError } from '@throw/throwGraphQLError.mjs'\n\nexport const throwUnprocessableContentError = (\n\ttxt: string = 'We are unable to process the instructions contained in the request.'\n) => {\n\tthrow throwGraphQLError(422, 'Unprocessable Content', txt)\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throwUnsupportedMediaTypeError.mjs","sourceRoot":"","sources":["../../../src/graphQL/throw/throwUnsupportedMediaTypeError.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,gCAAoC;AAEhE,MAAM,CAAC,MAAM,8BAA8B,GAAG,GAAG,EAAE;IAClD,MAAM,iBAAiB,CAAC,GAAG,EAAE,wBAAwB,EAAE,uEAAuE,CAAC,CAAA;AAChI,CAAC,CAAA","sourcesContent":["import { throwGraphQLError } from '@throw/throwGraphQLError.mjs'\n\nexport const throwUnsupportedMediaTypeError = () => {\n\tthrow throwGraphQLError(415, 'Unsupported Media Type', 'The chosen media type is not supported. Please change the media type.')\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IFileUpload.mjs","sourceRoot":"","sources":["../../src/koa/IFileUpload.mts"],"names":[],"mappings":"","sourcesContent":["export interface IFileUpload {\n\tcreateReadStream: () => NodeJS.ReadableStream\n\tfilename: string\n\tmimetype: string\n\tencoding: string\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IKoaError.mjs","sourceRoot":"","sources":["../../src/koa/IKoaError.mts"],"names":[],"mappings":"","sourcesContent":["export interface IKoaError {\n\textensions?: {\n\t\thttp?: {\n\t\t\tstatus: number\n\t\t}\n\t\tdescription: string\n\t}\n\tstatus?: number\n\tbody: {\n\t\tdescription: string\n\t}\n\tmessage: string\n\tpath: string\n\tstack: string\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"customFormatErrorFn.mjs","sourceRoot":"","sources":["../../src/koa/customFormatErrorFn.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAEtC,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,GAAyB,EAAE,EAAE;IAChE,IAAI,GAAG,YAAY,YAAY,EAAE,CAAC;QACjC,MAAM,IAAI,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE;YACnC,UAAU,EAAE,GAAG,CAAC,UAAU;SAC1B,CAAC,CAAA;IACH,CAAC;IAED,OAAO,GAAG,CAAA;AACX,CAAC,CAAA","sourcesContent":["import { GraphQLError } from 'graphql'\n\nexport const customFormatErrorFn = (err: GraphQLError | Error) => {\n\tif (err instanceof GraphQLError) {\n\t\tthrow new GraphQLError(err.message, {\n\t\t\textensions: err.extensions\n\t\t})\n\t}\n\n\treturn err\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logRequestToDb.mjs","sourceRoot":"","sources":["../../src/koa/logRequestToDb.mts"],"names":[],"mappings":"AAGA,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,GAAgB,EAAE,IAAU;IAChE,MAAM,IAAI,EAAE,CAAA;IAEZ,iDAAiD;AAClD,CAAC","sourcesContent":["import { IContextLog } from '@private/graphQL/schema/context/IContextLog.mjs'\nimport { Next } from 'koa'\n\nexport async function logRequestToDb(ctx: IContextLog, next: Next) {\n\tawait next()\n\n\t// logGraphql(user, operationName, status, msTot)\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TCookieRefreshToken.mjs","sourceRoot":"","sources":["../../../../src/koa/middleware/authenticatedAuthorizationHandler/TCookieRefreshToken.mts"],"names":[],"mappings":"","sourcesContent":["export type TCookieRefreshToken = {\n\trefresh_token?: string\n\t'refresh_token.sig'?: string\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../../src/koa/middleware/authenticatedAuthorizationHandler/index.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,uCAA8B;AACpD,OAAO,EAAE,gBAAgB,EAAE,0CAAiC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,yDAAgD;AAClF,OAAO,EAAE,mBAAmB,EAAE,uDAAsC;AACpE,OAAO,EAAE,iCAAiC,EAAE,qEAAoD;AAChG,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAGhC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAEhC,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAA;AAEzE,MAAM,CAAC,MAAM,EAAE,CAAA;AAEf,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC,IAAa,EAAE,EAAE,CAAC,KAAK,EAAE,GAAoB,EAAE,IAAU,EAAE,EAAE;IAC9G;;;OAGG;IAEH,8CAA8C;IAC9C,MAAM,iBAAiB,GAAG,wBAAwB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IAC7D,MAAM,UAAU,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,GAAG,iBAAiB,EAAE,CAAC,CAAA;IAC5F,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1C,MAAM,OAAO,GAAG,EAAE,GAAG,UAAU,EAAE,CAAA,CAAC,mGAAmG;QAErI,6EAA6E;QAC7E,IAAI,gBAAgB,CAAC,OAAO,CAAC,EAAE,CAAC;YAC/B,MAAM,mBAAmB,EAAE,CAAA;QAC5B,CAAC;QACD,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG;YAChB,GAAG,OAAO;YACV,EAAE,EAAE,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YAClC,YAAY,EAAE,iBAAiB;SAC/B,CAAA;IACF,CAAC;SAAM,IAAI,CAAC,uBAAuB,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,qBAAqB,CAAC,CAAC,EAAE,CAAC;QAClF,MAAM,iCAAiC,EAAE,CAAA;IAC1C,CAAC,CAAC,qBAAqB;IAEvB,OAAO,IAAI,EAAE,CAAA;AACd,CAAC,CAAA","sourcesContent":["import { IContextRefresh } from '@context/IContextRefresh.mjs'\nimport { redisClient } from '@dataSources/Redis.mjs'\nimport { isSessionBlocked } from '@lib/isSessionBlocked.mjs'\nimport { verifyIntrospectionCode } from '@private/lib/verifyIntrospectionCode.mjs'\nimport { throwForbiddenError } from '@throw/throwForbiddenError.mjs'\nimport { throwRefreshTokenExpiredOrDeleted } from '@throw/throwRefreshTokenExpiredOrDeleted.mjs'\nimport * as dotenv from 'dotenv'\nimport Keygrip from 'keygrip'\nimport { Next } from 'koa'\nimport { Types } from 'mongoose'\n\nimport { verifySignedRefreshToken } from './verifySignedRefreshToken.mjs'\n\ndotenv.config()\n\nexport const authenticatedAuthorizationHandler = (keys: Keygrip) => async (ctx: IContextRefresh, next: Next) => {\n\t/***************************\n\t * CLIENT:\n\t * - sends opaque token as cookie\n\t */\n\n\t// does the key exist in redis? ok, read redis\n\tconst refreshTokenRedis = verifySignedRefreshToken(ctx, keys)\n\tconst redSession = await redisClient.hGetAll(`${process.env.REDIS_KEY}${refreshTokenRedis}`)\n\tif (Object.keys(redSession).length !== 0) {\n\t\tconst redData = { ...redSession } // For safety, Redis return an object without the default Object.prototype in its prototype chain.\n\n\t\t// is the user reported as blocked within the session? (see isSessionBlocked)\n\t\tif (isSessionBlocked(redData)) {\n\t\t\tthrow throwForbiddenError()\n\t\t}\n\t\tctx.state.user = {\n\t\t\t...redData,\n\t\t\tid: new Types.ObjectId(redData.id),\n\t\t\trefreshToken: refreshTokenRedis\n\t\t}\n\t} else if (!verifyIntrospectionCode(ctx.request.header?.['x-introspectioncode'])) {\n\t\tthrow throwRefreshTokenExpiredOrDeleted()\n\t} // else return next()\n\n\treturn next()\n}\n"]}
|
package/dist/koa/middleware/authenticatedAuthorizationHandler/verifySignedRefreshToken.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"verifySignedRefreshToken.mjs","sourceRoot":"","sources":["../../../../src/koa/middleware/authenticatedAuthorizationHandler/verifySignedRefreshToken.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,mCAAmC,EAAE,uEAAsD;AACpG,OAAO,EAAE,yBAAyB,EAAE,6DAA4C;AAChF,OAAO,EAAE,kCAAkC,EAAE,sEAAqD;AAClG,OAAO,EAAE,sBAAsB,EAAE,0DAAyC;AAK1E,MAAM,UAAU,wBAAwB,CAAC,GAAoB,EAAE,IAAa;IAC3E,oGAAoG;IAEpG,MAAM,YAAY,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAA;IAE/C,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAChC,MAAM,mCAAmC,EAAE,CAAA;IAC5C,CAAC;IAED,MAAM,OAAO,GAAwB,EAAE,CAAA;IACvC,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;QAC1C,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAC7C,qCAAqC;QACrC,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;IACrB,CAAC,CAAC,CAAA;IACF;;OAEG;IACH,MAAM,YAAY,GAAG,OAAO,EAAE,aAAa,CAAA;IAC3C,IAAI,CAAC,YAAY,EAAE,CAAC;QACnB,MAAM,yBAAyB,EAAE,CAAA;IAClC,CAAC;IACD,MAAM,SAAS,GAAG,OAAO,EAAE,CAAC,mBAAmB,CAAC,CAAA;IAChD,IAAI,CAAC,SAAS,EAAE,CAAC;QAChB,MAAM,kCAAkC,EAAE,CAAA;IAC3C,CAAC;IAED,mBAAmB;IACnB,gCAAgC;IAChC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,YAAY,EAAE,EAAE,SAAS,CAAC,CAAA;IAEpE,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;QAClB,oBAAoB;QACpB,MAAM,sBAAsB,CAAC,kCAAkC,CAAC,CAAA;IACjE,CAAC;IAED,OAAO,WAAW,YAAY,EAAE,CAAA;AACjC,CAAC","sourcesContent":["import { IContextRefresh } from '@context/IContextRefresh.mjs'\nimport { throwPreconditionFailedNoAuthCookie } from '@throw/throwPreconditionFailedNoAuthCookie.mjs'\nimport { throwRefreshTokenRequired } from '@throw/throwRefreshTokenRequired.mjs'\nimport { throwRefreshTokenSignatureRequired } from '@throw/throwRefreshTokenSignatureRequired.mjs'\nimport { throwUnauthorizedError } from '@throw/throwUnauthorizedError.mjs'\nimport Keygrip from 'keygrip'\n\nimport { TCookieRefreshToken } from './TCookieRefreshToken.mjs'\n\nexport function verifySignedRefreshToken(ctx: IContextRefresh, keys: Keygrip): string {\n\t// @todo must check the cookie or the header or both, and what to do if one of the two is missing ??\n\n\tconst cookieHeader = ctx.request.header?.cookie\n\n\tif (cookieHeader === undefined) {\n\t\tthrow throwPreconditionFailedNoAuthCookie()\n\t}\n\n\tconst cookies: TCookieRefreshToken = {}\n\tcookieHeader.split(';').forEach((cookie) => {\n\t\tconst [key, value] = cookie.trim().split('=')\n\t\t// @ts-expect-error ignore wrong keys\n\t\tcookies[key] = value\n\t})\n\t/**\n\t * 'refresh_token=27119032-9043-4a9f-bd4c-9d06fd576290; refresh_token.sig=P1gZO6-49xVEMkiMqkOjJ2Cxaf3mQb18GaflDsjibuv4fFWYIOzcW26didnVJ1aridyY40CFzDtufzI6zI8jkQ'\n\t */\n\tconst refreshToken = cookies?.refresh_token\n\tif (!refreshToken) {\n\t\tthrow throwRefreshTokenRequired()\n\t}\n\tconst signature = cookies?.['refresh_token.sig']\n\tif (!signature) {\n\t\tthrow throwRefreshTokenSignatureRequired()\n\t}\n\n\t// Verify signature\n\t// Verify signature with Keygrip\n\tconst index = keys.index(`refresh_token=${refreshToken}`, signature)\n\n\tif (index === -1) {\n\t\t// Signature invalid\n\t\tthrow throwUnauthorizedError('Invalid Refresh Cookie signature')\n\t}\n\n\treturn `refresh:${refreshToken}`\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../../src/koa/middleware/authenticatedLogoutHandler/index.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,uCAA8B;AACpD,OAAO,EAAE,aAAa,EAAE,uCAA8B;AACtD,OAAO,EAAE,uBA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} from '@context/IContextLogout.mjs'\nimport { IContextRefresh } from '@context/IContextRefresh.mjs'\nimport { redisClient } from '@dataSources/Redis.mjs'\nimport { isValidUuidV4 } from '@lib/isValidUuidV4.mjs'\nimport { verifyIntrospectionCode } from '@private/lib/verifyIntrospectionCode.mjs'\nimport { throwAlreadyDone } from '@throw/throwAlreadyDone.mjs'\nimport { throwPreconditionFailedNoAuthCookie } from '@throw/throwPreconditionFailedNoAuthCookie.mjs'\nimport { throwPreconditionFailedNoAuthHeader } from '@throw/throwPreconditionFailedNoAuthHeader.mjs'\nimport * as dotenv from 'dotenv'\nimport Keygrip from 'keygrip'\nimport { Next } from 'koa'\n\nimport { verifySignedRefreshToken } from '../authenticatedAuthorizationHandler/verifySignedRefreshToken.mjs'\n\ndotenv.config()\n\nconst requireIntrospectionOrThrow = (header: IContextLogout['request']['header'], throwOnFail: () => never): true => {\n\tif (typeof header !== 'undefined' && verifyIntrospectionCode(header['x-introspectioncode'])) {\n\t\treturn true\n\t}\n\tthrow throwOnFail()\n}\n\nconst extractBearerAccessToken = (authorization: string | undefined): string =>\n\tauthorization?.startsWith('Bearer access:') && isValidUuidV4(authorization.slice('Bearer access:'.length))\n\t\t? authorization.replace('Bearer ', '')\n\t\t: ''\n\nexport const authenticatedLogoutHandler = (keys: Keygrip) => async (ctx: IContextLogout, next: Next) => {\n\t/***************************\n\t * CLIENT:\n\t * - in authorization: ctx.request.header.authorization = Bearer ACCESS_TOKEN_HERE\n\t * - in cookie: ctx.request.header.cookie = refresh_cookie=TOKEN_HERE\n\t */\n\tlet introspection = false\n\n\t// refresh\n\tconst cookie = ctx.request.header?.cookie // refresh\n\tif (typeof cookie === 'undefined') {\n\t\tintrospection = requireIntrospectionOrThrow(ctx.request.header, throwPreconditionFailedNoAuthCookie)\n\t}\n\n\tconst authorization = ctx.request.header?.authorization // access\n\tif (typeof authorization === 'undefined') {\n\t\tintrospection = requireIntrospectionOrThrow(ctx.request.header, throwPreconditionFailedNoAuthHeader)\n\t}\n\n\tif (!introspection) {\n\t\tconst refreshToken = verifySignedRefreshToken(ctx as unknown as IContextRefresh, keys)\n\t\tconst redRefreshSession = await redisClient.hGet(`${process.env.REDIS_KEY}${refreshToken}`, 'id')\n\t\tif (redRefreshSession != null) {\n\t\t\tctx.state = {\n\t\t\t\tuser: {\n\t\t\t\t\trefreshToken: refreshToken\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthrow throwAlreadyDone()\n\t\t}\n\n\t\t// Access Token, optional\n\t\t// The 'Bearer access:' prefix must be checked before building the Redis key:\n\t\t// without this check the client controls the entire key and could reach refresh: entries.\n\t\t// The suffix is checked too: the prefix alone still leaves the rest of the key client-controlled.\n\t\t// Tokens with the wrong prefix, or a suffix that is not a v4 uuid, are ignored rather than\n\t\t// rejected: the access token remains optional here.\n\t\tconst accessToken = extractBearerAccessToken(authorization)\n\t\tif (accessToken !== '') {\n\t\t\tconst redAccessSession = await redisClient.hGet(`${process.env.REDIS_KEY}${accessToken}`, 'id') // 'access:' already present\n\t\t\tif (redAccessSession != null) {\n\t\t\t\tctx.state.user.accessToken = accessToken\n\t\t\t} // else no problem, session could be expired\n\t\t}\n\t} // else introspection\n\treturn next()\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../../src/koa/middleware/authenticatedResourceHandler/index.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,uCAA8B;AACpD,OAAO,EAAE,gBAAgB,EAAE,0CAAiC;AAC5D,OAAO,EAAE,aAAa,EAAE,uCAA8B;AACtD,OAAO,EAAE,uBAAuB,EAAE,yDAAgD;AAClF,OAAO,EAAE,gCAAgC,EAAE,oEAAmD;AAC9F,OAAO,EAAE,wBAAwB,EAAE,4DAA2C;AAC9E,OAAO,EAAE,mBAAmB,EAAE,uDAAsC;AACpE,OAAO,EAAE,iCAAiC,EAAE,qEAAoD;AAChG,OAAO,EAAE,mCAAmC,EAAE,uE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C,KAAK,CAAC,IAAI,GAAG;YAChB,GAAG,OAAO;YACV,EAAE,EAAE,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,qBAAqB;SACxD,CAAA;IACF,CAAC;SAAM,IAAI,CAAC,uBAAuB,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,qBAAqB,CAAC,CAAC,EAAE,CAAC;QAClF,MAAM,gCAAgC,EAAE,CAAA;IACzC,CAAC,CAAC,mBAAmB;IAErB,OAAO,IAAI,EAAE,CAAA;AACd,CAAC,CAAA","sourcesContent":["import { IContextAuthenticatedResource } from '@context/IContextAuthenticatedResource.mjs'\nimport { redisClient } from '@dataSources/Redis.mjs'\nimport { isSessionBlocked } from '@lib/isSessionBlocked.mjs'\nimport { isValidUuidV4 } from '@lib/isValidUuidV4.mjs'\nimport { verifyIntrospectionCode } from '@private/lib/verifyIntrospectionCode.mjs'\nimport { throwAccessTokenExpiredOrDeleted } from '@throw/throwAccessTokenExpiredOrDeleted.mjs'\nimport { throwAccessTokenRequired } from '@throw/throwAccessTokenRequired.mjs'\nimport { throwForbiddenError } from '@throw/throwForbiddenError.mjs'\nimport { throwMissingMalformedInvalidToken } from '@throw/throwMissingMalformedInvalidToken.mjs'\nimport { throwPreconditionFailedNoAuthHeader } from '@throw/throwPreconditionFailedNoAuthHeader.mjs'\nimport * as dotenv from 'dotenv'\nimport { Next } from 'koa'\nimport { Types } from 'mongoose'\n\ndotenv.config()\n\n/**\n * Find out access token in Bearer header\n */\nexport const authenticatedResourceHandler = () => async (ctx: IContextAuthenticatedResource, next: Next) => {\n\t/***************************\n\t * CLIENT:\n\t * - in authorization: ctx.request.header.authorization = 'Bearer ACCESS_TOKEN\n\t */\n\n\tconst authorization = ctx.request.header?.authorization\n\n\t// more detailed errors code instead of generic 401 unauthorized (tampering)\n\tif (authorization === undefined) {\n\t\tthrow throwPreconditionFailedNoAuthHeader()\n\t}\n\tif (!authorization.startsWith('Bearer access:')) {\n\t\tthrow throwAccessTokenRequired()\n\t}\n\n\tconst key = authorization.replace('Bearer ', '')\n\n\t// the prefix check above leaves the rest of the key client-controlled: the suffix must be a\n\t// real v4 uuid — the only shape generateAccessToken produces — before it reaches Redis\n\tif (!isValidUuidV4(key.slice('access:'.length))) {\n\t\tthrow throwMissingMalformedInvalidToken()\n\t}\n\n\t// does the key access:xxx exist in Redis ? read Redis...\n\tconst redSession = await redisClient.hGetAll(\n\t\t`${process.env.REDIS_KEY}${key}` // 'access:' present inside key\n\t)\n\tif (Object.keys(redSession).length !== 0) {\n\t\tconst redData = { ...redSession } // For safety, Redis return an object without the default Object.prototype in its prototype chain.\n\t\t// is the user reported as blocked within the session ? (see isSessionBlocked)\n\t\tif (isSessionBlocked(redData)) {\n\t\t\tthrow throwForbiddenError()\n\t\t}\n\n\t\tctx.state.user = {\n\t\t\t...redData,\n\t\t\tid: new Types.ObjectId(redData.id) // fix id as ObjectId\n\t\t}\n\t} else if (!verifyIntrospectionCode(ctx.request.header?.['x-introspectioncode'])) {\n\t\tthrow throwAccessTokenExpiredOrDeleted()\n\t} // else return next\n\n\treturn next()\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../../src/koa/middleware/debug/index.mts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,EAAE,CAAC,KAAK,EAAE,GAAoB,EAAE,IAAU,EAAE,EAAE;IAC5E,OAAO,IAAI,EAAE,CAAA;AACd,CAAC,CAAA","sourcesContent":["import { IContextRefresh } from '@context/IContextRefresh.mjs'\nimport { Next } from 'koa'\n\nexport const debugHandler = () => async (ctx: IContextRefresh, next: Next) => {\n\treturn next()\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"verifyEmail.mjs","sourceRoot":"","sources":["../../../src/koa/router/verifyEmail.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAA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A","sourcesContent":["import { isSafeRedirectTarget } from '@lib/isSafeRedirectTarget.mjs'\nimport { IContextVerifyEmail } from '@private/graphQL/schema/context/IContextVerifyEmail.mjs'\nimport { assertVerifyEmailAllowed, TAssertVerifyEmailAllowed } from '@private/lib/access/assertVerifyEmailAllowed.mjs'\nimport { enableEmailAccess, TEnableEmailAccess } from '@private/lib/access/db/enableEmailAccess.mjs'\nimport { TUserData4VerifyEmail, userData4VerifyEmail } from '@private/lib/access/db/userData4VerifyEmail.mjs'\n\n/** Reader, guard chain and writer the handler needs, all bound to the same model + paths by the caller. */\nexport interface IVerifyEmailRouterDeps {\n\tuserData4VerifyEmail: TUserData4VerifyEmail\n\tassertVerifyEmailAllowed: TAssertVerifyEmailAllowed\n\tenableEmailAccess: TEnableEmailAccess\n}\n\n/**\n * Koa handler for the email-activation link.\n *\n * Taking the collaborators as arguments is what makes the handler testable at all: the DB read used to\n * be an ESM live binding that the tsx loader refuses to let sinon replace, so the whole try-body was\n * dead code in the suite and sat under a `c8 ignore`. It is now injected, the ignore is gone, and every\n * path is exercised directly.\n */\nexport const createVerifyEmailRouter = (deps: IVerifyEmailRouterDeps) => () => async (ctx: IContextVerifyEmail) => {\n\tconst { email, hash } = ctx.params\n\n\tconst uEmail = email.toLowerCase()\n\n\ttry {\n\t\t// search if the email exists\n\t\tconst user = await deps.userData4VerifyEmail(uEmail)\n\n\t\t// Every access guard lives in assertVerifyEmailAllowed, which is unit-tested.\n\t\tconst uId = await deps.assertVerifyEmailAllowed(user, email, hash)\n\n\t\t// ok enable email — only ever reached once every guard above has passed\n\t\tawait deps.enableEmailAccess(uId, email)\n\t\tctx.redirect('/x/registration-done') // url without prefix\n\t\t// ctx.redirect('https://google.it') // external url\n\t} catch (err: unknown) {\n\t\tconst link = (err as Error).message as string\n\t\tif (isSafeRedirectTarget(link)) {\n\t\t\tctx.redirect(link)\n\t\t} else {\n\t\t\tctx.redirect('/x/error')\n\t\t}\n\t}\n}\n\n/** Shape of the bound router, for the modules that take it as a dependency. */\nexport type TVerifyEmailRouter = ReturnType<typeof createVerifyEmailRouter>\n\n/** `UserBase`-bound default — the router every existing consumer already imports. */\nexport const routerVerifyEmail: TVerifyEmailRouter = createVerifyEmailRouter({\n\tuserData4VerifyEmail,\n\tassertVerifyEmailAllowed,\n\tenableEmailAccess\n})\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tdwKoaErrorHandler.mjs","sourceRoot":"","sources":["../../src/koa/tdwKoaErrorHandler.mts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AACtC,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAKtC,MAAM,CAAC,MAAM,EAAE,CAAA;AAEf,eAAe;AACf,SAAS,kBAAkB,CAAC,MAAiB,EAAE,cAAuB;IACrE,IAAI,cAAc,EAAE,CAAC;QACpB,OAAO,MAAM,CAAC,UAAU,EAAE,IAAI,EAAE,MAAM,IAAI,GAAG,CAAA;IAC9C,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,IAAI,GAAG,CAAA;AAC5B,CAAC;AAED;;GAEG;AACH,SAAS,cAAc,CACtB,MAAiB,EACjB,cAAuB,EACvB,MAAc;IAEd,MAAM,SAAS,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;IAElE,IAAI,CAAC,SAAS,EAAE,CAAC;QAChB,OAAO,SAAS,CAAA;IACjB,CAAC;IAED,MAAM,IAAI,GAAoC;QAC7C,OAAO,EAAE,MAAM,CAAC,OAAO;KACvB,CAAA;IACD,IAAI,cAAc,EAAE,CAAC;QACpB,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,UAAU,EAAE,WAAW,IAAI,EAAE,CAAA;IACxD,CAAC;IACD,OAAO,IAAI,CAAA;AACZ,CAAC;AAED,oBAAoB;AACpB,SAAS,uBAAuB,CAAC,MAAiB,EAAE,cAAuB;IAC1E,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EAAE,CAAC;QAC5C,IAAI,CAAC,cAAc,EAAE,CAAC;YACrB,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAA;QAChC,CAAC;IACF,CAAC;AACF,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,GAA4B,EAAE,IAAU;IAChF,IAAI,CAAC;QACJ,MAAM,IAAI,EAAE,CAAA;IACb,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACvB,MAAM,MAAM,GAAG,GAAgB,CAAA;QAC/B,MAAM,cAAc,GAAG,GAAG,YAAY,YAAY,CAAA;QAElD,GAAG,CAAC,MAAM,GAAG,kBAAkB,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;QAEvD,MAAM,IAAI,GAAG,cAAc,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;QAC/D,IAAI,IAAI,EAAE,CAAC;YACV,GAAG,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,CAAC;QAED,uBAAuB,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;QAE/C,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,CAAA;IACnC,CAAC;AACF,CAAC","sourcesContent":["import { IContextKoaErrorHandler } from '@context/IContextKoaErrorHandler.mjs'\nimport * as Sentry from '@sentry/node'\nimport * as dotenv from 'dotenv'\nimport { GraphQLError } from 'graphql'\nimport { Next } from 'koa'\n\nimport { IKoaError } from './IKoaError.mjs'\n\ndotenv.config()\n\n// check status\nfunction resolveErrorStatus(errKoa: IKoaError, isIstanceOfGQL: boolean): number {\n\tif (isIstanceOfGQL) {\n\t\treturn errKoa.extensions?.http?.status || 500\n\t}\n\treturn errKoa.status || 500\n}\n\n/**\n * do not set body for status codes that do not allow it\n */\nfunction buildErrorBody(\n\terrKoa: IKoaError,\n\tisIstanceOfGQL: boolean,\n\tstatus: number\n): IContextKoaErrorHandler['body'] | undefined {\n\tconst allowBody = ![100, 101, 102, 204, 205, 304].includes(status)\n\n\tif (!allowBody) {\n\t\treturn undefined\n\t}\n\n\tconst body: IContextKoaErrorHandler['body'] = {\n\t\tmessage: errKoa.message\n\t}\n\tif (isIstanceOfGQL) {\n\t\tbody.description = errKoa.extensions?.description || ''\n\t}\n\treturn body\n}\n\n// more debug data ?\nfunction maybeCaptureSentryError(errKoa: IKoaError, isIstanceOfGQL: boolean): void {\n\tif (process.env.NODE_ENV === 'development') {\n\t\tif (!isIstanceOfGQL) {\n\t\t\tSentry.captureException(errKoa)\n\t\t}\n\t}\n}\n\nexport async function tdwKoaErrorHandler(ctx: IContextKoaErrorHandler, next: Next) {\n\ttry {\n\t\tawait next()\n\t} catch (err: unknown) {\n\t\tconst errKoa = err as IKoaError\n\t\tconst isIstanceOfGQL = err instanceof GraphQLError\n\n\t\tctx.status = resolveErrorStatus(errKoa, isIstanceOfGQL)\n\n\t\tconst body = buildErrorBody(errKoa, isIstanceOfGQL, ctx.status)\n\t\tif (body) {\n\t\t\tctx.body = body\n\t\t}\n\n\t\tmaybeCaptureSentryError(errKoa, isIstanceOfGQL)\n\n\t\tctx.app.emit('error', errKoa, ctx)\n\t}\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ArrayLib.mjs","sourceRoot":"","sources":["../../src/lib/ArrayLib.mts"],"names":[],"mappings":"AAAA,MAAM,OAAO,QAAQ;IACpB,gBAAe,CAAC;IAEhB,OAAO,CAAC,IAAc,EAAE,IAAc;QACrC,MAAM,MAAM,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAA;QAC/D,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;QAEnC,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IACjD,CAAC;CACD,CAAC,oBAAoB","sourcesContent":["export class ArrayLib {\n\tconstructor() {}\n\n\tarrDiff(arr1: string[], arr2: string[]) {\n\t\tconst arrays = [arr1, arr2].sort((a, b) => a.length - b.length)\n\t\tconst smallSet = new Set(arrays[0])\n\n\t\treturn arrays[1].filter((x) => !smallSet.has(x))\n\t}\n} /* c8 ignore next */\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Constants.mjs","sourceRoot":"","sources":["../../src/lib/Constants.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAEhC,MAAM,CAAC,MAAM,cAAc,GAAG,0BAA0B,CAAA;AACxD,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAA;AAChE,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAA;AAEhC,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAA;AAChC,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAA;AAEhC,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAA","sourcesContent":["import { Types } from 'mongoose'\n\nexport const OBJECTID_0_STR = '000000000000000000000000'\nexport const OBJECTID_0_OBJ = new Types.ObjectId(OBJECTID_0_STR)\nexport const EMAIL_MAX_LEN = 255\n\nexport const MIN_PWD_LENGTH = 10\nexport const MAX_PWD_LENGTH = 72\n\nexport const EMAIL_HASH_LEN = 50\n"]}
|
package/dist/lib/DateLib.mjs.map
DELETED
|
@@ -1 +0,0 @@
|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AG,EAAE,CAAC,OAAO,EAAE,CAAA;QAC5B,8CAA8C;QAE9C,OAAO,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IACzC,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,OAAe,EAAE,GAAW;QAC9C,MAAM,UAAU,GAAG,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,OAAO,CAAA;QAChE,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,CAAA;IAC5C,CAAC;CACD,CAAA,CAAC,oBAAoB","sourcesContent":["export const DateLib = class DateLib {\n\tconstructor() {}\n\n\tstatic getDate(dateNum: Date) {\n\t\tconst dateStr = dateNum.toString()\n\t\tconst year = parseInt(dateStr.substring(0, 4))\n\t\tconst month = parseInt(dateStr.substring(4, 6))\n\t\tconst day = parseInt(dateStr.substring(6, 8))\n\t\tconst hours = parseInt(dateStr.substring(8, 10))\n\t\tconst min = parseInt(dateStr.substring(10, 12))\n\t\tconst sec = parseInt(dateStr.substring(12, 14))\n\n\t\tconst date = new Date(Date.UTC(year, month - 1, day, hours, min, sec))\n\n\t\treturn {\n\t\t\tyear,\n\t\t\tdate\n\t\t}\n\t}\n\n\tstatic minElapsed(dt: Date): number {\n\t\t// read elapsed minutes\n\t\tconst nowDt = new Date()\n\t\tconst now = nowDt.getTime()\n\n\t\tconst lastReq = dt.getTime()\n\t\t// const lastReq = new Date('' + dt).getTime()\n\n\t\treturn DateLib.timeDiffMin(lastReq, now)\n\t}\n\n\tstatic timeDiffMin(lastReq: number, now: number): number {\n\t\tconst difference = lastReq > now ? lastReq - now : now - lastReq\n\t\treturn Math.floor(difference / (1000 * 60))\n\t}\n} /* c8 ignore next */\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IAuthorizationDisDel.mjs","sourceRoot":"","sources":["../../src/lib/IAuthorizationDisDel.mts"],"names":[],"mappings":"","sourcesContent":["export interface IAuthorizationDisDel {\n\tdisabled?: boolean\n\tdeleted?: Date\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ICookies.mjs","sourceRoot":"","sources":["../../src/lib/ICookies.mts"],"names":[],"mappings":"","sourcesContent":["export type ICookies = {\n\tset(key: 'access_token' | 'refresh_token', value: string, options: Options): void\n\tget(key: 'access_token' | 'refresh_token'): string | undefined\n}\ntype Options = {\n\thttpOnly?: boolean\n\tsameSite?: string\n\tsecure?: boolean\n\tpath?: string\n\texpirationDate?: number\n\tmaxAge?: number\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IMariaDBErr.mjs","sourceRoot":"","sources":["../../../src/lib/MariaDB/IMariaDBErr.mts"],"names":[],"mappings":"","sourcesContent":["export interface IMariaDbErr {\n\tparent?: {\n\t\tsqlMessage?: string\n\t\tcode: string\n\t}\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MariaDBErrType.mjs","sourceRoot":"","sources":["../../../src/lib/MariaDB/MariaDBErrType.mts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,MAAM,CAAN,IAAY,cAEX;AAFD,WAAY,cAAc;IACzB,uDAAqC,CAAA;AACtC,CAAC,EAFW,cAAc,KAAd,cAAc,QAEzB","sourcesContent":["// https://mariadb.com/kb/en/mariadb-error-code-reference/\nexport enum MariaDBErrType {\n\tER_DATA_TOO_LONG = 'ER_DATA_TOO_LONG'\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throwSqlErrors.mjs","sourceRoot":"","sources":["../../../src/lib/MariaDB/throwSqlErrors.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,yDAA2C;AAC9E,OAAO,EAAE,kBAAkB,EAAE,mDAAqC;AAElE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAErD,MAAM,UAAU,cAAc,CAAC,CAAc;IAC5C,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC,UAAU,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,cAAc,CAAC,gBAAgB,EAAE,CAAC;QAC1F,MAAM,GAAG,GAAG,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAA;QAEtD,6DAA6D;QAC7D,MAAM,eAAe,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QACxC,8GAA8G;QAC9G,MAAM,gBAAgB,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,eAAe,GAAG,CAAC,CAAC,CAAA;QAC9D,2FAA2F;QAC3F,MAAM,YAAY,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,gBAAgB,GAAG,CAAC,CAAC,CAAA;QAE3D,MAAM,wBAAwB,CAAC,YAAY,CAAC,CAAA;IAC7C,CAAC;SAAM,CAAC;QACP,yBAAyB;QACzB,MAAM,kBAAkB,EAAE,CAAA;IAC3B,CAAC;AACF,CAAC","sourcesContent":["import { IMariaDbErr } from '@lib/MariaDB/IMariaDBErr.mjs'\nimport { throwErrorWrongUserInput } from '@throw/throwErrorWrongUserInput.mjs'\nimport { throwInternalError } from '@throw/throwInternalError.mjs'\n\nimport { MariaDBErrType } from './MariaDBErrType.mjs'\n\nexport function throwSqlErrors(e: IMariaDbErr) {\n\tif (e.parent && e.parent.sqlMessage && e.parent.code === MariaDBErrType.ER_DATA_TOO_LONG) {\n\t\tconst err = e.parent.sqlMessage.replace(' column', '')\n\n\t\t// Find the index of the first occurrence of the single quote\n\t\tconst firstQuoteIndex = err.indexOf(\"'\")\n\t\t// Find the index of the second occurrence of the single quote, starting the search just after the first quote\n\t\tconst secondQuoteIndex = err.indexOf(\"'\", firstQuoteIndex + 1)\n\t\t// Extract the substring from the start of the string to just after the second single quote\n\t\tconst errorMessage = err.substring(0, secondQuoteIndex + 1)\n\n\t\tthrow throwErrorWrongUserInput(errorMessage)\n\t} else {\n\t\t// @todo report to Sentry\n\t\tthrow throwInternalError()\n\t}\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IMongoDBError.mjs","sourceRoot":"","sources":["../../../src/lib/MongoDB/IMongoDBError.mts"],"names":[],"mappings":"","sourcesContent":["import { MongoDBErrType } from '@lib/MongoDB/MongoDBErrType.mjs'\n\nexport interface IMongoDBError {\n\terrorResponse?: {\n\t\tcode: MongoDBErrType\n\t}\n\tparent?: {\n\t\terrorResponse?: {\n\t\t\tcode: MongoDBErrType\n\t\t}\n\t}\n\tmessage: string\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IOnboarding.mjs","sourceRoot":"","sources":["../../../src/lib/MongoDB/IOnboarding.mts"],"names":[],"mappings":"","sourcesContent":["export interface IOnboarding {\n\tonboardingStep?: string\n\tonboardingDone?: boolean\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MongoDBErrType.mjs","sourceRoot":"","sources":["../../../src/lib/MongoDB/MongoDBErrType.mts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,cAEX;AAFD,WAAY,cAAc;IACzB,iFAAyB,CAAA;AAC1B,CAAC,EAFW,cAAc,KAAd,cAAc,QAEzB","sourcesContent":["export enum MongoDBErrType {\n\tDuplicateKeyError = 11000\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throwIfMongoErr.mjs","sourceRoot":"","sources":["../../../src/lib/MongoDB/throwIfMongoErr.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,6BAAuC;AAChE,OAAO,EAAE,kBAAkB,EAAE,mDAAqC;AAClE,OAAO,EAAE,wBAAwB,EAAE,yDAA2C;AAE9E,MAAM,UAAU,eAAe,CAAC,CAAgB;IAC/C,IACC,CAAC,CAAC,CAAC,aAAa,IAAI,CAAC,CAAC,aAAa,CAAC,IAAI,KAAK,cAAc,CAAC,iBAAiB,CAAC;QAC9E,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC,aAAa,IAAI,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,KAAK,cAAc,CAAC,iBAAiB,CAAC,EACvG,CAAC;QACF,MAAM,kBAAkB,EAAE,CAAA;IAC3B,CAAC;SAAM,IAAI,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;QAChD,MAAM,wBAAwB,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAA;IAC5E,CAAC;AACF,CAAC","sourcesContent":["import { IMongoDBError } from '@lib/MongoDB/IMongoDBError.mjs'\nimport { MongoDBErrType } from '@lib/MongoDB/MongoDBErrType.mjs'\nimport { throwConflictError } from '@throw/throwConflictError.mjs'\nimport { throwErrorWrongUserInput } from '@throw/throwErrorWrongUserInput.mjs'\n\nexport function throwIfMongoErr(e: IMongoDBError) {\n\tif (\n\t\t(e.errorResponse && e.errorResponse.code === MongoDBErrType.DuplicateKeyError) ||\n\t\t(e.parent && e.parent.errorResponse && e.parent.errorResponse.code === MongoDBErrType.DuplicateKeyError)\n\t) {\n\t\tthrow throwConflictError()\n\t} else if (e.message.startsWith('[Validator]')) {\n\t\tthrow throwErrorWrongUserInput(e.message.replace('[Validator]', '').trim())\n\t}\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throwMongoErrors.mjs","sourceRoot":"","sources":["../../../src/lib/MongoDB/throwMongoErrors.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,8BAAwC;AAClE,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,kBAAkB,EAAE,mDAAqC;AAElE,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAgB,EAAS,EAAE;IAC7D,eAAe,CAAC,CAAC,CAAC,CAAA;IAClB,kBAAkB;IAElB,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAA;IAC1B,MAAM,kBAAkB,EAAE,CAAA;AAC3B,CAAC,CAAA","sourcesContent":["import { IMongoDBError } from '@lib/MongoDB/IMongoDBError.mjs'\nimport { throwIfMongoErr } from '@lib/MongoDB/throwIfMongoErr.mjs'\nimport * as Sentry from '@sentry/node'\nimport { throwInternalError } from '@throw/throwInternalError.mjs'\n\nexport const throwMongoDBErrors = (e: IMongoDBError): never => {\n\tthrowIfMongoErr(e)\n\t// else throw here\n\n\tSentry.captureException(e)\n\tthrow throwInternalError()\n}\n"]}
|
package/dist/lib/NumLib.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NumLib.mjs","sourceRoot":"","sources":["../../src/lib/NumLib.mts"],"names":[],"mappings":"AAAA,MAAM,OAAO,MAAM;IAClB,gBAAe,CAAC;IAEhB;;;;;OAKG;IACH,MAAM,CAAC,eAAe,CAAC,GAAW;QACjC,OAAO,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAA;IAC1C,CAAC;CACD,CAAC,oBAAoB","sourcesContent":["export class NumLib {\n\tconstructor() {}\n\n\t/************\n\t * parseFloat wants '.' as the decimal separator !!\n\t *\n\t * @param val\n\t * @returns {number}\n\t */\n\tstatic parseFloatFixed(val: string): number {\n\t\treturn parseFloat(val.replace(/,/g, '.'))\n\t}\n} /* c8 ignore next */\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IPostgresError.mjs","sourceRoot":"","sources":["../../../src/lib/PostgreSQL/IPostgresError.mts"],"names":[],"mappings":"","sourcesContent":["export interface IPostgresError extends Error {\n\tcode?: string\n\tdetail?: string\n\tconstraint?: string\n\thint?: string\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IPostgresErrorCodes.mjs","sourceRoot":"","sources":["../../../src/lib/PostgreSQL/IPostgresErrorCodes.mts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,mBAEX;AAFD,WAAY,mBAAmB;IAC9B,kDAA2B,CAAA;AAC5B,CAAC,EAFW,mBAAmB,KAAnB,mBAAmB,QAE9B","sourcesContent":["export enum IPostgresErrorCodes {\n\tduplicateKeyValue = '23505'\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"makePostgreSqlLogError.mjs","sourceRoot":"","sources":["../../../src/lib/PostgreSQL/makePostgreSqlLogError.mts"],"names":[],"mappings":"AAEA,MAAM,UAAU,sBAAsB,CAAC,OAAuB;IAC7D,OAAO,GAAG,OAAO,CAAC,IAAI,MAAM,OAAO,CAAC,IAAI,MAAM,OAAO,CAAC,MAAM,MAAM,OAAO,CAAC,UAAU,EAAE,CAAA;AACvF,CAAC","sourcesContent":["import { IPostgresError } from '@lib/PostgreSQL/IPostgresError.mjs'\n\nexport function makePostgreSqlLogError(pgError: IPostgresError): string {\n\treturn `${pgError.code} | ${pgError.hint} | ${pgError.detail} | ${pgError.constraint}`\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RedisBoolean.mjs","sourceRoot":"","sources":["../../../src/lib/Redis/RedisBoolean.mts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACvB,0BAAU,CAAA;IACV,2BAAW,CAAA;AACZ,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB","sourcesContent":["export enum RedisBoolean {\n\ttrue = '1',\n\tfalse = '0'\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"buildPrefixedRedisKey.mjs","sourceRoot":"","sources":["../../../src/lib/Redis/buildPrefixedRedisKey.mts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAA8B,EAAE,KAAa;IAClF,OAAO,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,KAAK,EAAE,CAAA;AAC9D,CAAC","sourcesContent":["/**\n * Builds a Redis session key by adding its namespace prefix ('access:' or 'refresh:') — unless the\n * token already carries it, in which case it is returned unchanged.\n * ctx.state.user.refreshToken/accessToken arrive already prefixed from this package's own\n * authenticatedLogoutHandler / authenticatedAuthorizationHandler, but a consumer wiring\n * ctx.state.user by hand may pass a bare uuid: accept both shapes so the caller never builds\n * 'refresh:refresh:<uuid>' and deletes a key that was never written.\n */\nexport function buildPrefixedRedisKey(prefix: 'access:' | 'refresh:', token: string): string {\n\treturn token.startsWith(prefix) ? token : `${prefix}${token}`\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fromRedisBooleanValue.mjs","sourceRoot":"","sources":["../../../src/lib/Redis/fromRedisBooleanValue.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,MAAM,UAAU,qBAAqB,CAAC,IAAkB;IACvD,OAAO,IAAI,KAAK,YAAY,CAAC,IAAI,CAAA;AAClC,CAAC","sourcesContent":["import { RedisBoolean } from './RedisBoolean.mjs'\n\nexport function fromRedisBooleanValue(data: RedisBoolean) {\n\treturn data === RedisBoolean.true\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"toRedisBooleanValue.mjs","sourceRoot":"","sources":["../../../src/lib/Redis/toRedisBooleanValue.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,MAAM,UAAU,mBAAmB,CAAC,KAAc;IACjD,OAAO,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAA;AACtD,CAAC","sourcesContent":["import { RedisBoolean } from './RedisBoolean.mjs'\n\nexport function toRedisBooleanValue(value: boolean) {\n\treturn value ? RedisBoolean.true : RedisBoolean.false\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StringLib.mjs","sourceRoot":"","sources":["../../src/lib/StringLib.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEpD,mFAAmF;AACnF,MAAM,eAAe,GAAG,kCAAkC,CAAA;AAE1D,MAAM,OAAO,SAAS;IACrB,wBAAwB;IACxB,gBAAe,CAAC;IAEhB,SAAS,CAAC,GAAW;QACpB,OAAO,GAAG,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAA;IACxC,CAAC;IAED,kBAAkB,CAAC,GAAuB;QACzC,OAAO,OAAO,GAAG,KAAK,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAA;IAC3E,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,YAAY,CAAC,MAAc;QAC1B,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAA;QAC9C,IAAI,CAAC,GAAG,EAAE,CAAA;QACV,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;YACvB,CAAC,IAAI,eAAe,CAAC,CAAC,GAAG,eAAe,CAAC,MAAM,CAAC,CAAA;QACjD,CAAC;QAED,OAAO,CAAC,CAAA;IACT,CAAC;IAED;;;OAGG;IACH,YAAY;QACX,OAAO,EAAE,GAAG,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACpD,CAAC;IAED;;;;;;;;;;;OAWG;IACH,kBAAkB,CA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AC,CAAC,CAAC,EAAE,CAAC;YAChC,CAAC,CAAC,UAAU,EAAE,CACd,CAAA;IACF,CAAC;IAED,QAAQ,CAAC,IAAY,EAAE,WAAmB,EAAE;QAC3C,OAAO,4BAA4B,IAAI,KAAK,QAAQ,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,MAAM,CAAA;IACpF,CAAC;CACD,CAAC,oBAAoB","sourcesContent":["import { randomBytes, randomInt } from 'node:crypto'\n\n// 32 chars, a subset of base36. 256 % 32 === 0 so a byte maps uniformly with % 32.\nconst RANDOM_ALPHABET = '0123456789abcdefghijklmnopqrstuv'\n\nexport class StringLib {\n\t// implements IStringLib\n\tconstructor() {}\n\n\tcleanHtml(str: string): string {\n\t\treturn str.replace(/(<([^>]+)>)/gi, '')\n\t}\n\n\tcleanHtmlUndefined(str: string | undefined): string | undefined {\n\t\treturn typeof str === 'undefined' ? str : str.replace(/(<([^>]+)>)/gi, '')\n\t}\n\n\t/**\n\t * Cryptographically random string of `length` characters.\n\t *\n\t * This is the generator behind every password-reset hash and email-confirmation\n\t * hash in the package (emailHash -> registerNewUser / setEmailHash, and resetPwd\n\t * directly). It previously used Math.random(), which is NOT a CSPRNG: V8 implements\n\t * it as xorshift128+, whose internal state is recoverable from a modest number of\n\t * observed outputs, after which every future value is predictable. An attacker could\n\t * request a reset for an account they control, read their own hash from the email,\n\t * recover the generator state, and predict the hash issued next — then trigger a\n\t * reset for a victim and use the predicted token. The 50-character length gave no\n\t * protection: entropy is bounded by the generator, not by the output length.\n\t *\n\t * The alphabet is 32 characters, a subset of the base36 output this has always\n\t * produced, so callers matching /^[0-9a-z]+$/ are unaffected. 256 % 32 === 0, so\n\t * mapping a byte with % 32 is uniform — no modulo bias, and no rejection branch.\n\t * 5 bits per character: a 50-character hash carries 250 bits.\n\t */\n\trandomString(length: number): string {\n\t\tconst bytes = randomBytes(Math.max(0, length))\n\t\tlet s = ''\n\t\tfor (const b of bytes) {\n\t\t\ts += RANDOM_ALPHABET[b % RANDOM_ALPHABET.length]\n\t\t}\n\n\t\treturn s\n\t}\n\n\t/**\n\t * return OTP as string\n\t * @returns {string}\n\t */\n\tgetRandomOTP(): string {\n\t\treturn '' + this.getRandomArbitrary(100000, 999999)\n\t}\n\n\t/**\n\t * Cryptographically random integer in [min, max).\n\t *\n\t * Also moved off Math.random(): this backs getRandomOTP(), and a predictable\n\t * one-time password defeats the point of one.\n\t *\n\t * Uses crypto.randomInt rather than a hand-rolled modulo, which would over-represent\n\t * the low end of the range. Hand-rolling the usual rejection loop was the first\n\t * attempt, but its retry branch is statistically unreachable (~1 in 4 billion), so it\n\t * could never be covered by a test — and an uncoverable branch is exactly what the\n\t * coverage gate exists to refuse. randomInt does the same rejection inside Node.\n\t */\n\tgetRandomArbitrary(min: number, max: number) {\n\t\tconst lo = Math.trunc(min)\n\t\tconst range = Math.max(0, Math.trunc(max) - lo)\n\t\tif (range === 0) {\n\t\t\treturn lo\n\t\t}\n\n\t\treturn randomInt(lo, lo + range)\n\t}\n\n\tisoToTimestamp(isoStr: Date): number {\n\t\t// const date = new Date(isoStr)\n\t\t// return date.getTime()\n\t\treturn isoStr.getTime()\n\t}\n\n\tisoFormatDMY(data: string): string {\n\t\tconst d = new Date(data)\n\t\treturn d.getUTCDate() + '/' + (d.getUTCMonth() + +1) + '/' + d.getUTCFullYear()\n\t}\n\n\tisoFormatDateTime(data: string): string {\n\t\tconst d = new Date(data)\n\t\treturn (\n\t\t\td.getUTCDate() +\n\t\t\t'/' +\n\t\t\t(d.getUTCMonth() + +1) +\n\t\t\t'/' +\n\t\t\td.getUTCFullYear() +\n\t\t\t' ' +\n\t\t\td.getHours() +\n\t\t\t':' +\n\t\t\t(d.getMinutes() < 10 ? '0' : '') +\n\t\t\td.getMinutes() +\n\t\t\t':' +\n\t\t\t(d.getSeconds() < 10 ? '0' : '') +\n\t\t\td.getSeconds()\n\t\t)\n\t}\n\n\tmakeLink(link: string, linkText: string = ''): string {\n\t\treturn `<a target='_blank' href='${link}'>${linkText === '' ? link : linkText}</a>`\n\t}\n} /* c8 ignore next */\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"accessPaths.mjs","sourceRoot":"","sources":["../../../src/lib/access/accessPaths.mts"],"names":[],"mappings":"AAmDA,8FAA8F;AAC9F,MAAM,CAAC,MAAM,uBAAuB,GAAmB,MAAM,CAAC,MAAM,CAAC;IACpE,KAAK,EAAE,aAAa;IACpB,QAAQ,EAAE,gBAAgB;IAC1B,IAAI,EAAE,mBAAmB;IACzB,YAAY,EAAE,sBAAsB;IACpC,SAAS,EAAE,mBAAmB;IAC9B,OAAO,EAAE,iBAAiB;IAC1B,QAAQ,EAAE,kBAAkB;IAC5B,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,sBAAsB,EAAE,mBAAmB,CAAC,CAAC;CACxE,CAAC,CAAA;AAEF;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAA+B;IACnE,OAAO,EAAE,GAAG,uBAAuB,EAAE,GAAG,KAAK,EAAE,CAAA;AAChD,CAAC;AAkCD,8FAA8F;AAC9F,MAAM,CAAC,MAAM,0BAA0B,GAAsB,MAAM,CAAC,MAAM,CAAC;IAC1E,KAAK,EAAE,aAAa;IACpB,KAAK,EAAE,qBAAqB;IAC5B,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,2BAA2B;IACxC,YAAY,EAAE,4BAA4B;IAC1C,WAAW,EAAE,2BAA2B;IACxC,OAAO,EAAE,iBAAiB;IAC1B,QAAQ,EAAE,kBAAkB;IAC5B,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,oBAAoB,EAAE,2BAA2B,EAAE,4BAA4B,CAAC,CAAC;IAC7G,gBAAgB,EAAE,MAAM,CAAC,MAAM,CAAC;QAC/B,oBAAoB;QACpB,2BAA2B;QAC3B,4BAA4B;QAC5B,2BAA2B;KAC3B,CAAC;CACF,CAAC,CAAA;AAEF;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAAkC;IACzE,OAAO,EAAE,GAAG,0BAA0B,EAAE,GAAG,KAAK,EAAE,CAAA;AACnD,CAAC","sourcesContent":["import { Model } from 'mongoose'\n\n/**\n * Any mongoose model an access flow can be pointed at.\n *\n * Deliberately `Model<any>`: the flows only ever call `findOne`, `updateOne`, `countDocuments` and\n * `deleteOne` with computed field paths, so nothing here can be typed against a concrete document\n * shape without forcing every consumer to describe theirs. The `paths` map below is what pins the\n * contract instead — a wrong path is a runtime no-op, which is why the defaults are exported and the\n * flows are tested against them.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type TAccessModel = Model<any>\n\n/**\n * Field paths the password-reset flow reads and writes.\n *\n * Every value is a dotted mongo path into the account document. They are supplied as data rather\n * than hard-coded because `UserBase` is only one possible layout: a consumer whose accounts live in\n * another collection, or under another field tree, could not use `resetPwd` / `updatePassword` at\n * all while the paths were baked in.\n */\nexport interface IResetPwdPaths {\n\t/** Login address. Used as the lookup filter by `getResetPwd` and `removeResetReq`. */\n\temail: string\n\t/** Bcrypt hash slot `updatePassword` overwrites. */\n\tpassword: string\n\t/** Display name passed to the reset / confirmation emails. Missing value ⇒ empty string. */\n\tname: string\n\t/** When the pending reset was requested. Drives the 10-minute throttle and the 60-minute expiry. */\n\tresetDateReq: string\n\t/** Password-reset token. Must stay disjoint from the email-verification hash slot. */\n\tresetHash: string\n\t/** Account tombstone flag. A set value makes `getResetPwd` answer `null`, as for an unknown address. */\n\tdeleted: string\n\t/** Account lockout flag. A set value makes `getResetPwd` answer `null`, as for an unknown address. */\n\tdisabled: string\n\t/**\n\t * Paths `removeResetReq` `$unset`s once a reset has been consumed.\n\t *\n\t * Kept separate from `resetDateReq` / `resetHash` on purpose — it is NOT always the same list.\n\t * A layout that stores the request as one all-or-nothing subdocument, e.g.\n\t * `resetPwd: { resetDateReq, resetHash }` under `validationLevel: 'strict'` +\n\t * `validationAction: 'error'`, rejects a write that unsets a single member: the leftover document\n\t * fails validation. The only legal cleanup there is `$unset: { resetPwd: '' }` — one container\n\t * path, not two leaf paths. Deriving this list from the leaves would make that layout impossible\n\t * to express, and the flat default hides the problem completely.\n\t */\n\tresetClear: readonly string[]\n}\n\n/** The layout of `UserBase` — i.e. the behaviour of the flow before it took a `paths` map. */\nexport const DEFAULT_RESET_PWD_PATHS: IResetPwdPaths = Object.freeze({\n\temail: 'login.email',\n\tpassword: 'login.password',\n\tname: 'personalData.name',\n\tresetDateReq: 'account.resetDateReq',\n\tresetHash: 'account.resetHash',\n\tdeleted: 'account.deleted',\n\tdisabled: 'account.disabled',\n\tresetClear: Object.freeze(['account.resetDateReq', 'account.resetHash'])\n})\n\n/**\n * Merge a partial override over {@link DEFAULT_RESET_PWD_PATHS}.\n *\n * Plain spread: a key present with an explicit `undefined` value overrides the default with\n * `undefined`, so pass only the keys being changed.\n */\nexport function resolveResetPwdPaths(paths?: Partial<IResetPwdPaths>): IResetPwdPaths {\n\treturn { ...DEFAULT_RESET_PWD_PATHS, ...paths }\n}\n\n/**\n * Field paths the email-verification and email-change flows read and write.\n *\n * Same rationale as {@link IResetPwdPaths}. Note that `hash` here is the inbox-proof token\n * (activation and email change, 3-day life, `requestTimes` throttle) and must never be pointed at\n * the same field as `IResetPwdPaths.resetHash`: while the two shared one slot, a hash issued by\n * either flow authenticated the other, and an unauthenticated reset request killed pending\n * activation links.\n */\nexport interface IVerifyEmailPaths {\n\t/** Live login address — lookup filter, and the field `confirmNewEmail` writes on an email change. */\n\temail: string\n\t/** Boolean flag `enableEmailAccess` flips once a verification link is honoured. */\n\tvalid: string\n\t/** Verification / email-change token. Never the password-reset slot. */\n\thash: string\n\t/** When the current token was issued. Drives the 3-day link window. */\n\tdateLastReq: string\n\t/** Strike counter. Five wrong hashes delete the account. */\n\trequestTimes: string\n\t/** Address awaiting confirmation during an email change. */\n\tnewEmailTmp: string\n\t/** Account tombstone flag. */\n\tdeleted: string\n\t/** Account lockout flag. */\n\tdisabled: string\n\t/** Paths `enableEmailAccess` `$unset`s once a verification link is honoured. */\n\tverifyClear: readonly string[]\n\t/** Paths `confirmNewEmail` `$unset`s once a new address is accepted. */\n\temailChangeClear: readonly string[]\n}\n\n/** The layout of `UserBase` — i.e. the behaviour of the flow before it took a `paths` map. */\nexport const DEFAULT_VERIFY_EMAIL_PATHS: IVerifyEmailPaths = Object.freeze({\n\temail: 'login.email',\n\tvalid: 'account.email.valid',\n\thash: 'account.email.hash',\n\tdateLastReq: 'account.email.dateLastReq',\n\trequestTimes: 'account.email.requestTimes',\n\tnewEmailTmp: 'account.email.newEmailTmp',\n\tdeleted: 'account.deleted',\n\tdisabled: 'account.disabled',\n\tverifyClear: Object.freeze(['account.email.hash', 'account.email.dateLastReq', 'account.email.requestTimes']),\n\temailChangeClear: Object.freeze([\n\t\t'account.email.hash',\n\t\t'account.email.dateLastReq',\n\t\t'account.email.requestTimes',\n\t\t'account.email.newEmailTmp'\n\t])\n})\n\n/**\n * Merge a partial override over {@link DEFAULT_VERIFY_EMAIL_PATHS}.\n *\n * Plain spread: a key present with an explicit `undefined` value overrides the default with\n * `undefined`, so pass only the keys being changed.\n */\nexport function resolveVerifyEmailPaths(paths?: Partial<IVerifyEmailPaths>): IVerifyEmailPaths {\n\treturn { ...DEFAULT_VERIFY_EMAIL_PATHS, ...paths }\n}\n\n/**\n * What the verify-email guards do with an abandoned pending registration — a link older than 3 days, or a\n * fifth wrong hash.\n *\n * `'delete'` removes the row. It is the behaviour through 5.6.1, the only one the chain had, and it is safe\n * for `UserBase`, whose rows own nothing. It is not safe for a model at the head of a hierarchy the package\n * cannot see: once the factory accepts an arbitrary model, the package no longer knows what deleting a row\n * costs, and with no foreign keys and no cascade in Mongo it takes the children with it in effect while\n * leaving them behind in fact.\n *\n * `'soft-delete'` writes `paths.deleted` instead — the one tombstone convention {@link IVerifyEmailPaths}\n * already declares and the chain otherwise only ever read. The guards test it for truthiness, so the value\n * written is the caller's (`deletedValue`), boolean or timestamp alike.\n *\n * `'keep'` leaves the document alone. The guard still throws, so the link is still refused; only the row\n * survives, and disposing of it becomes the caller's job.\n */\nexport type TOnAbandon = 'delete' | 'soft-delete' | 'keep'\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createMailThrottle.mjs","sourceRoot":"","sources":["../../../src/lib/access/createMailThrottle.mts"],"names":[],"mappings":"AAuBA;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,EAClC,QAAQ,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,EACzB,OAAO,GAAG,IAAI,KACc,EAAE,EAAiB,EAAE;IACjD,6GAA6G;IAC7G,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAA;IAExC,OAAO,SAAS,OAAO,CAAC,GAAW;QAClC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QACtB,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAEhC,IAAI,QAAQ,KAAK,SAAS,IAAI,GAAG,GAAG,QAAQ,GAAG,QAAQ,EAAE,CAAC;YACzD,OAAO,KAAK,CAAA;QACb,CAAC;QAED,mFAAmF;QACnF,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QAElB,IAAI,MAAM,CAAC,IAAI,IAAI,OAAO,EAAE,CAAC;YAC5B,KAAK,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,MAAM,EAAE,CAAC;gBACpC,IAAI,GAAG,GAAG,EAAE,IAAI,QAAQ,EAAE,CAAC;oBAC1B,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;gBACvB,CAAC;YACF,CAAC;QACF,CAAC;QAED,IAAI,MAAM,CAAC,IAAI,IAAI,OAAO,EAAE,CAAC;YAC5B,6FAA6F;YAC7F,8FAA8F;YAC9F,4FAA4F;YAC5F,uCAAuC;YACvC,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAA;YAEnC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;gBAClB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;YAC5B,CAAC;QACF,CAAC;QAED,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;QACpB,OAAO,IAAI,CAAA;IACZ,CAAC,CAAA;AACF,CAAC,CAAA;AAED,0GAA0G;AAC1G,MAAM,CAAC,MAAM,WAAW,GAAkB,GAAG,EAAE,CAAC,IAAI,CAAA","sourcesContent":["/**\n * Answers \"may this notification be sent?\" for a key. `true` sends, `false` drops silently.\n *\n * Every `handleIf*` guard in the verify-email chain is reachable from an unauthenticated\n * `GET /check/verify-email/:email/:hash`, and three of them have no counter to lean on:\n * `handleIfEmailAlreadyValid`, `handleIfAccountDeleted` and `handleIfAccountDisabled` mailed the address\n * on *every* request through 5.6.1. Anyone who knew a registered address could make the platform's own\n * SocketLabs account mail its owner once per request — a mail bomb aimed at a third party, plus a\n * sending-reputation problem, out of a GET nobody had to authenticate.\n *\n * The contract is one function so a deployment can replace it. A Redis `SET key NX PX <window>` returning\n * whether the key was created is the obvious cross-instance implementation, and is a one-liner here.\n */\nexport type TMailThrottle = (key: string) => boolean | Promise<boolean>\n\n/** Options of {@link createMailThrottle}. */\nexport interface ICreateMailThrottleArgs {\n\t/** How long a key stays blocked after a send. Default 15 minutes. */\n\twindowMs?: number\n\t/** Cap on tracked keys, so an attacker cycling addresses cannot grow the map without bound. Default 5000. */\n\tmaxKeys?: number\n}\n\n/**\n * In-process debounce: one send per key per `windowMs`.\n *\n * In-process on purpose — no runtime dependency, nothing to configure, and the amplification it has to\n * stop arrives through one process. Behind several instances it degrades to one mail per instance per\n * window, which is a cap rather than the unbounded fan-out it replaces; pass your own `TMailThrottle`\n * when one mail per address across the fleet matters.\n *\n * State is per instance. `createVerifyEmailFlow` builds one per flow, so two flows never share a window.\n */\nexport const createMailThrottle = ({\n\twindowMs = 15 * 60 * 1000,\n\tmaxKeys = 5000\n}: ICreateMailThrottleArgs = {}): TMailThrottle => {\n\t/** key → epoch ms of the send that blocked it. Insertion-ordered, which is what makes the eviction cheap. */\n\tconst sentAt = new Map<string, number>()\n\n\treturn function maySend(key: string): boolean {\n\t\tconst now = Date.now()\n\t\tconst previous = sentAt.get(key)\n\n\t\tif (previous !== undefined && now - previous < windowMs) {\n\t\t\treturn false\n\t\t}\n\n\t\t// Delete before the set below so the map stays ordered by send time, oldest first.\n\t\tsentAt.delete(key)\n\n\t\tif (sentAt.size >= maxKeys) {\n\t\t\tfor (const [tracked, at] of sentAt) {\n\t\t\t\tif (now - at >= windowMs) {\n\t\t\t\t\tsentAt.delete(tracked)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (sentAt.size >= maxKeys) {\n\t\t\t// Still full, so every tracked key is inside its window: drop the oldest — the first key the\n\t\t\t// insertion-ordered map yields. Refusing to send instead would let a flood of fresh addresses\n\t\t\t// mute the notifications of real ones. `done` is only true for a `maxKeys` of 0, which caps\n\t\t\t// nothing and so has nothing to evict.\n\t\t\tconst oldest = sentAt.keys().next()\n\n\t\t\tif (!oldest.done) {\n\t\t\t\tsentAt.delete(oldest.value)\n\t\t\t}\n\t\t}\n\n\t\tsentAt.set(key, now)\n\t\treturn true\n\t}\n}\n\n/** Never debounce — one mail per request, as 5.6.1 and earlier did. Pass as `mailThrottle` to opt out. */\nexport const ALWAYS_MAIL: TMailThrottle = () => true\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createResetPwdFlow.mjs","sourceRoot":"","sources":["../../../src/lib/access/createResetPwdFlow.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,oDAA8C;AAC1E,OAAO,EAAE,oBAAoB,EAAE,uDAAiD;AAChF,OAAO,EAAE,kBAAkB,EAAE,qDAA+C;AAC5E,OAAO,EAAE,sBAAsB,EAAE,yDAAmD;AAEpF,OAAO,EAAE,sBAAsB,EAAqB,MAAM,6CAA6C,CAAA;AACvG,OAAO,EAAE,4BAA4B,EAA2B,MAAM,mDAAmD,CAAA;AACzH,OAAO,EAAkB,oBAAoB,EAAgB,MAAM,mBAAmB,CAAA;AActF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,EAA2B,EAAiB,EAAE;IAC9F,MAAM,QAAQ,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAA;IAE5C,MAAM,WAAW,GAAG,iBAAiB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;IAEtD,OAAO;QACN,QAAQ,EAAE,sBAAsB,CAAC;YAChC,WAAW;YACX,YAAY,EAAE,kBAAkB,CAAC,KAAK,EAAE,QAAQ,CAAC;SACjD,CAAC;QACF,cAAc,EAAE,4BAA4B,CAAC;YAC5C,WAAW;YACX,gBAAgB,EAAE,sBAAsB,CAAC,KAAK,EAAE,QAAQ,CAAC;YACzD,cAAc,EAAE,oBAAoB,CAAC,KAAK,EAAE,QAAQ,CAAC;SACrD,CAAC;KACF,CAAA;AACF,CAAC,CAAA","sourcesContent":["import { createGetResetPwd } from '@private/lib/access/db/getResetPwd.mjs'\nimport { createRemoveResetReq } from '@private/lib/access/db/removeResetReq.mjs'\nimport { createSaveResetReq } from '@private/lib/access/db/saveResetReq.mjs'\nimport { createUpdatePasswordDb } from '@private/lib/access/db/updatePasswordDb.mjs'\n\nimport { createResetPwdMutation, TResetPwdMutation } from '../../graphQL/schema/mutations/resetPwd.mjs'\nimport { createUpdatePasswordMutation, TUpdatePasswordMutation } from '../../graphQL/schema/mutations/updatePassword.mjs'\nimport { IResetPwdPaths, resolveResetPwdPaths, TAccessModel } from './accessPaths.mjs'\n\n/** What the factory needs: the account model, plus any path that differs from the default layout. */\nexport interface ICreateResetPwdFlowArgs {\n\tmodel: TAccessModel\n\tpaths?: Partial<IResetPwdPaths>\n}\n\n/** The two mutations the flow exposes, bound to the model and paths passed in. */\nexport interface IResetPwdFlow {\n\tresetPwd: TResetPwdMutation\n\tupdatePassword: TUpdatePasswordMutation\n}\n\n/**\n * Build the password-reset mutations against any mongoose model.\n *\n * The package's own `resetPwd` / `updatePassword` exports are this factory applied to `UserBase` with\n * `DEFAULT_RESET_PWD_PATHS`, so switching to it changes nothing until a path is overridden.\n *\n * Every key of `paths` is optional and falls back to the default layout. `resetClear` is the one to\n * look at twice: it is the list of paths the cleanup `$unset`s, and it is NOT derived from\n * `resetDateReq` + `resetHash`. A schema storing the request as one required-members subdocument under\n * `validationLevel: 'strict'` is left invalid by unsetting a single member, and the write is rejected —\n * such a schema must pass the container path instead. See `IResetPwdPaths.resetClear`.\n *\n * ```ts\n * const { resetPwd, updatePassword } = createResetPwdFlow({\n * model: Account,\n * paths: { email: 'mail', password: 'pwd', name: 'profile.fullName', resetClear: ['resetPwd'] }\n * })\n * ```\n */\nexport const createResetPwdFlow = ({ model, paths }: ICreateResetPwdFlowArgs): IResetPwdFlow => {\n\tconst resolved = resolveResetPwdPaths(paths)\n\n\tconst getResetPwd = createGetResetPwd(model, resolved)\n\n\treturn {\n\t\tresetPwd: createResetPwdMutation({\n\t\t\tgetResetPwd,\n\t\t\tsaveResetReq: createSaveResetReq(model, resolved)\n\t\t}),\n\t\tupdatePassword: createUpdatePasswordMutation({\n\t\t\tgetResetPwd,\n\t\t\tupdatePasswordDb: createUpdatePasswordDb(model, resolved),\n\t\t\tremoveResetReq: createRemoveResetReq(model, resolved)\n\t\t})\n\t}\n}\n"]}
|