Repository: toeverything/AFFiNE
File: packages/backend/server/src/base/error/def.ts (TypeScript)

Code before:
    type: 'invalid_input',
    args: { email: 'string' },
    message: ({ email }) => `Wrong user email or password: ${email}`,
  },
  unknown_oauth_provider: {
    type: 'invalid_input',
    args: { name: 'string' },
    message: ({ name }) => `Unknown authentication provider ${name}.`,
  },
  oauth_state_expired: {
    type: 'bad_request',
    message: 'OAuth state expired, please try again.',
  },
  invalid_oauth_callback_state: {
    type: 'bad_request',
    message: 'Invalid callback state parameter.',
  },
  invalid_oauth_callback_code: {
    type: 'bad_request',
    args: { status: 'number', body: 'string' },
    message: ({ status, body }) =>
      `Invalid callback code parameter, provider response status: ${status} and body: ${body}.`,
  },
  invalid_oauth_callback_client_nonce: {
    type: 'bad_request',
    message: 'Invalid callback client_nonce parameter.',
  },
  missing_oauth_query_parameter: {
    type: 'bad_request',
    args: { name: 'string' },
    message: ({ name }) => `Missing query parameter \`${name}\`.`,
  },
  oauth_account_already_connected: {
    type: 'bad_request',
    message:
      'The third-party account has already been connected to another user.',
  },
  invalid_email: {
    type: 'invalid_input',
    args: { email: 'string' },
    message: ({ email }) => `An invalid email provided: ${email}`,
  },
  invalid_password_length: {
    type: 'invalid_input',
    args: { min: 'number', max: 'number' },
    message: ({ min, max }) =>
      `Password must be between ${min} and ${max} characters`,
  },
  password_required: {
    type: 'invalid_input',
    message: 'Password is required.',

Review comment (security):
users have no idea what client nonce is
`Invalid auth state. You might start the auth progress from another device`

![image.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/5c0ymolP9B7QStCsS1RP/79523b1c-63ba-47f0-a56e-a2d9c68055a9.png)



Code after:
    type: 'invalid_input',
    args: { email: 'string' },
    message: ({ email }) => `Wrong user email or password: ${email}`,
  },
  unknown_oauth_provider: {
    type: 'invalid_input',
    args: { name: 'string' },
    message: ({ name }) => `Unknown authentication provider ${name}.`,
  },
  oauth_state_expired: {
    type: 'bad_request',
    message: 'OAuth state expired, please try again.',
  },
  invalid_oauth_callback_state: {
    type: 'bad_request',
    message: 'Invalid callback state parameter.',
  },
  invalid_oauth_callback_code: {
    type: 'bad_request',
    args: { status: 'number', body: 'string' },
    message: ({ status, body }) =>
      `Invalid callback code parameter, provider response status: ${status} and body: ${body}.`,
  },
  invalid_auth_state: {
    type: 'bad_request',
    message:
      'Invalid auth state. You might start the auth progress from another device.',
  },
  missing_oauth_query_parameter: {
    type: 'bad_request',
    args: { name: 'string' },
    message: ({ name }) => `Missing query parameter \`${name}\`.`,
  },
  oauth_account_already_connected: {
    type: 'bad_request',
    message:
      'The third-party account has already been connected to another user.',
  },
  invalid_email: {
    type: 'invalid_input',
    args: { email: 'string' },
    message: ({ email }) => `An invalid email provided: ${email}`,
  },
  invalid_password_length: {
    type: 'invalid_input',
    args: { min: 'number', max: 'number' },
    message: ({ min, max }) =>
      `Password must be between ${min} and ${max} characters`,
  },
  password_required: {
    type: 'invalid_input',