{"version":3,"file":"auth.mjs","sources":["../../../../server/controllers/validation/auth.js"],"sourcesContent":["'use strict';\n\nconst { yup, validateYupSchema } = require('@strapi/utils');\n\nconst callbackSchema = yup.object({\n  identifier: yup.string().required(),\n  password: yup.string().required(),\n});\n\nconst createRegisterSchema = (config) =>\n  yup.object({\n    email: yup.string().email().required(),\n    username: yup.string().required(),\n    password: yup\n      .string()\n      .required()\n      .test(function (value) {\n        if (!value) return true;\n        const isValid = new TextEncoder().encode(value).length <= 72;\n        if (!isValid) {\n          return this.createError({ message: 'Password must be less than 73 bytes' });\n        }\n        return true;\n      })\n      .test(async function (value) {\n        if (typeof config?.validatePassword === 'function') {\n          try {\n            const isValid = await config.validatePassword(value);\n            if (!isValid) {\n              return this.createError({ message: 'Password validation failed.' });\n            }\n          } catch (error) {\n            return this.createError({ message: error.message || 'An error occurred.' });\n          }\n        }\n        return true;\n      }),\n  });\n\nconst sendEmailConfirmationSchema = yup.object({\n  email: yup.string().email().required(),\n});\n\nconst validateEmailConfirmationSchema = yup.object({\n  confirmation: yup.string().required(),\n});\n\nconst forgotPasswordSchema = yup\n  .object({\n    email: yup.string().email().required(),\n  })\n  .noUnknown();\n\nconst createResetPasswordSchema = (config) =>\n  yup\n    .object({\n      password: yup\n        .string()\n        .required()\n        .test(function (value) {\n          if (!value) return true;\n          const isValid = new TextEncoder().encode(value).length <= 72;\n          if (!isValid) {\n            return this.createError({ message: 'Password must be less than 73 bytes' });\n          }\n          return true;\n        })\n        .test(async function (value) {\n          if (typeof config?.validatePassword === 'function') {\n            try {\n              const isValid = await config.validatePassword(value);\n              if (!isValid) {\n                return this.createError({ message: 'Password validation failed.' });\n              }\n            } catch (error) {\n              return this.createError({ message: error.message || 'An error occurred.' });\n            }\n          }\n          return true;\n        }),\n      passwordConfirmation: yup\n        .string()\n        .required()\n        .oneOf([yup.ref('password')], 'Passwords do not match'),\n\n      code: yup.string().required(),\n    })\n    .noUnknown();\n\nconst createChangePasswordSchema = (config) =>\n  yup\n    .object({\n      password: yup\n        .string()\n        .required()\n        .test(function (value) {\n          if (!value) return true;\n          const isValid = new TextEncoder().encode(value).length <= 72;\n          if (!isValid) {\n            return this.createError({ message: 'Password must be less than 73 bytes' });\n          }\n          return true;\n        })\n        .test(async function (value) {\n          if (typeof config?.validatePassword === 'function') {\n            try {\n              const isValid = await config.validatePassword(value);\n              if (!isValid) {\n                return this.createError({ message: 'Password validation failed.' });\n              }\n            } catch (error) {\n              return this.createError({ message: error.message || 'An error occurred.' });\n            }\n          }\n          return true;\n        }),\n      passwordConfirmation: yup\n        .string()\n        .required()\n        .oneOf([yup.ref('password')], 'Passwords do not match'),\n      currentPassword: yup.string().required(),\n    })\n    .noUnknown();\n\nmodule.exports = {\n  validateCallbackBody: validateYupSchema(callbackSchema),\n  validateRegisterBody: (payload, config) =>\n    validateYupSchema(createRegisterSchema(config))(payload),\n  validateSendEmailConfirmationBody: validateYupSchema(sendEmailConfirmationSchema),\n  validateEmailConfirmationBody: validateYupSchema(validateEmailConfirmationSchema),\n  validateForgotPasswordBody: validateYupSchema(forgotPasswordSchema),\n  validateResetPasswordBody: (payload, config) =>\n    validateYupSchema(createResetPasswordSchema(config))(payload),\n  validateChangePasswordBody: (payload, config) =>\n    validateYupSchema(createChangePasswordSchema(config))(payload),\n};\n"],"names":["yup","validateYupSchema","require$$0","callbackSchema","object","identifier","string","required","password","createRegisterSchema","config","email","username","test","value","isValid","TextEncoder","encode","length","createError","message","validatePassword","error","sendEmailConfirmationSchema","validateEmailConfirmationSchema","confirmation","forgotPasswordSchema","noUnknown","createResetPasswordSchema","passwordConfirmation","oneOf","ref","code","createChangePasswordSchema","currentPassword","auth","validateCallbackBody","validateRegisterBody","payload","validateSendEmailConfirmationBody","validateEmailConfirmationBody","validateForgotPasswordBody","validateResetPasswordBody","validateChangePasswordBody"],"mappings":";;;;;;;AAEA,IAAA,MAAM,EAAEA,GAAG,EAAEC,iBAAiB,EAAE,GAAGC,UAAAA;IAEnC,MAAMC,cAAAA,GA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