{"version":3,"sources":["../../../src/captcharator-v1-captcha-entity-captcha.universal.ts","../../../src/captcharator-v1-captcha-entity-captcha.http.ts","../../../src/captcharator-v1-captcha-entity-captcha.public.ts","../../../src/captcharator-v1-captcha-entity-captcha.context.ts"],"sourcesContent":["import { transformError as sdkTransformError } from '@wix/sdk-runtime/transform-error';\nimport {\n  renameKeysFromSDKRequestToRESTRequest,\n  renameKeysFromRESTResponseToSDKResponse,\n} from '@wix/sdk-runtime/rename-all-nested-keys';\nimport { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport * as ambassadorWixCaptcharatorV1CaptchaEntity from './captcharator-v1-captcha-entity-captcha.http.js';\n\nexport interface CaptchaEntity {}\n\nexport interface CaptchaRequest {\n  /** The CAPTCHA token to authorize. */\n  token?: string;\n}\n\nexport interface CaptchaResponse {\n  /** Value is `true` when authorization is successful. */\n  success?: boolean;\n  /** Error information. */\n  errors?: Errors;\n}\n\nexport interface Errors {\n  /** ID of error. */\n  errorId?: number;\n}\n\nexport interface AssessmentResponse {\n  assessment?: string;\n}\n\n/**\n * Authorizes a CAPTCHA token.\n *\n * Following CAPTCHA verification on the client side, you must authorize the generated CAPTCHA\n * token in the backend.\n *\n * `Authorize` checks if the token is valid, making sure it was not tampered with or timed out.\n *\n * If you're developing a Wix site or Blocks app, call this method when working with the\n * [Wix reCAPTCHA](https://dev.wix.com/docs/velo/api-reference/$w/captcha/introduction) element.\n *\n * If CAPTCHA token authorization fails, the method returns an error message containing a status code.\n * The following table lists the possible HTTP error status codes, based on\n * [RFC 2616](https://datatracker.ietf.org/doc/html/rfc2616#section-10):\n *\n *\n * | Status Code | Name | Description |\n * |---|---|---|\n * | 400 | Bad Request | The request could not be understood by the server. This could occur for a number of reasons, such as: <ul> <li>The request was sent without a token.</li> <li>The token is invalid.</li> <li>The token has timed out.</li> </ul> |\n * | 401 | Unauthenticated | No user identity found in passed request. |\n * | 500 | Internal Server Error | The server encountered an unexpected condition, such as a missing or invalid private CAPTCHA key. |\n * | 503 | Unavailable | The service is unavailable due to one of the following: <ul> <li>Throttled error: Server overload due to more than the allowed requests in a given time frame.</li> <li>Request failed: No response following 10 retries with a 1-second interval.</li> </ul> |\n * @param token - The CAPTCHA token to authorize.\n * @public\n * @documentationMaturity preview\n * @requiredField token\n * @fqn com.wixpress.vi.captcharator.CaptchaService.authorize\n */\nexport async function authorize(\n  token: string\n): Promise<NonNullablePaths<CaptchaResponse, `success` | `errors.errorId`, 3>> {\n  // @ts-ignore\n  const { httpClient, sideEffects } = arguments[1] as {\n    httpClient: HttpClient;\n    sideEffects?: any;\n  };\n\n  const payload = renameKeysFromSDKRequestToRESTRequest({ token: token });\n\n  const reqOpts = ambassadorWixCaptcharatorV1CaptchaEntity.authorize(payload);\n\n  sideEffects?.onSiteCall?.();\n  try {\n    const result = await httpClient.request(reqOpts);\n    sideEffects?.onSuccess?.(result);\n\n    return renameKeysFromRESTResponseToSDKResponse(result.data)!;\n  } catch (err: any) {\n    const transformedError = sdkTransformError(\n      err,\n      {\n        spreadPathsToArguments: {},\n        explicitPathsToArguments: { token: '$[0]' },\n        singleArgumentUnchanged: false,\n      },\n      ['token']\n    );\n    sideEffects?.onError?.(err);\n\n    throw transformedError;\n  }\n}\n","import { resolveUrl } from '@wix/sdk-runtime/rest-modules';\nimport { ResolveUrlOpts } from '@wix/sdk-runtime/rest-modules';\nimport { RequestOptionsFactory } from '@wix/sdk-types';\n\nfunction resolveComWixpressViCaptcharatorCaptchaServiceUrl(\n  opts: Omit<ResolveUrlOpts, 'domainToMappings'>\n) {\n  const domainToMappings = {\n    'api._api_base_domain_': [\n      {\n        srcPath: '/captcharator-web',\n        destPath: '',\n      },\n    ],\n    'api._base_domain_': [\n      {\n        srcPath: '/_api/captcharator',\n        destPath: '',\n      },\n    ],\n    'www._base_domain_': [\n      {\n        srcPath: '/_api/captcharator',\n        destPath: '',\n      },\n      {\n        srcPath: '/_api/captcharator-web',\n        destPath: '/api',\n      },\n      {\n        srcPath: '/_api/captcha',\n        destPath: '/api',\n      },\n    ],\n    'manage._base_domain_': [\n      {\n        srcPath: '/_api/captcha',\n        destPath: '/api',\n      },\n      {\n        srcPath: '/_api/captcharator',\n        destPath: '',\n      },\n      {\n        srcPath: '/_api/captcharator-web',\n        destPath: '/api',\n      },\n    ],\n    'www.wixapis.com': [\n      {\n        srcPath: '/captcharator/api/v1/authorize',\n        destPath: '/api/v1/authorize',\n      },\n    ],\n    _: [\n      {\n        srcPath: '/captcharator/api/v1/authorize',\n        destPath: '/api/v1/authorize',\n      },\n    ],\n    '*.dev.wix-code.com': [\n      {\n        srcPath: '/captcharator/api/v1/authorize',\n        destPath: '/api/v1/authorize',\n      },\n    ],\n  };\n\n  return resolveUrl(Object.assign(opts, { domainToMappings }));\n}\n\nconst PACKAGE_NAME = '@wix/auto_sdk_captcha_captcha';\n\n/**\n * Authorizes a CAPTCHA token.\n *\n * Following CAPTCHA verification on the client side, you must authorize the generated CAPTCHA\n * token in the backend.\n *\n * `Authorize` checks if the token is valid, making sure it was not tampered with or timed out.\n *\n * If you're developing a Wix site or Blocks app, call this method when working with the\n * [Wix reCAPTCHA](https://dev.wix.com/docs/velo/api-reference/$w/captcha/introduction) element.\n *\n * If CAPTCHA token authorization fails, the method returns an error message containing a status code.\n * The following table lists the possible HTTP error status codes, based on\n * [RFC 2616](https://datatracker.ietf.org/doc/html/rfc2616#section-10):\n *\n *\n * | Status Code | Name | Description |\n * |---|---|---|\n * | 400 | Bad Request | The request could not be understood by the server. This could occur for a number of reasons, such as: <ul> <li>The request was sent without a token.</li> <li>The token is invalid.</li> <li>The token has timed out.</li> </ul> |\n * | 401 | Unauthenticated | No user identity found in passed request. |\n * | 500 | Internal Server Error | The server encountered an unexpected condition, such as a missing or invalid private CAPTCHA key. |\n * | 503 | Unavailable | The service is unavailable due to one of the following: <ul> <li>Throttled error: Server overload due to more than the allowed requests in a given time frame.</li> <li>Request failed: No response following 10 retries with a 1-second interval.</li> </ul> |\n */\nexport function authorize(payload: object): RequestOptionsFactory<any> {\n  function __authorize({ host }: any) {\n    const metadata = {\n      entityFqdn: 'wix.captcharator.v1.captcha_entity',\n      method: 'POST' as any,\n      methodFqn: 'com.wixpress.vi.captcharator.CaptchaService.authorize',\n      packageName: PACKAGE_NAME,\n      migrationOptions: {\n        optInTransformResponse: true,\n      },\n      url: resolveComWixpressViCaptcharatorCaptchaServiceUrl({\n        protoPath: '/api/v1/authorize',\n        data: payload,\n        host,\n      }),\n      data: payload,\n    };\n\n    return metadata;\n  }\n\n  return __authorize;\n}\n","import { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport {\n  CaptchaResponse,\n  authorize as universalAuthorize,\n} from './captcharator-v1-captcha-entity-captcha.universal.js';\n\nexport const __metadata = { PACKAGE_NAME: '@wix/captcha' };\n\nexport function authorize(httpClient: HttpClient): AuthorizeSignature {\n  return (token: string) =>\n    universalAuthorize(\n      token,\n      // @ts-ignore\n      { httpClient }\n    );\n}\n\ninterface AuthorizeSignature {\n  /**\n   * Authorizes a CAPTCHA token.\n   *\n   * Following CAPTCHA verification on the client side, you must authorize the generated CAPTCHA\n   * token in the backend.\n   *\n   * `Authorize` checks if the token is valid, making sure it was not tampered with or timed out.\n   *\n   * If you're developing a Wix site or Blocks app, call this method when working with the\n   * [Wix reCAPTCHA](https://dev.wix.com/docs/velo/api-reference/$w/captcha/introduction) element.\n   *\n   * If CAPTCHA token authorization fails, the method returns an error message containing a status code.\n   * The following table lists the possible HTTP error status codes, based on\n   * [RFC 2616](https://datatracker.ietf.org/doc/html/rfc2616#section-10):\n   *\n   *\n   * | Status Code | Name | Description |\n   * |---|---|---|\n   * | 400 | Bad Request | The request could not be understood by the server. This could occur for a number of reasons, such as: <ul> <li>The request was sent without a token.</li> <li>The token is invalid.</li> <li>The token has timed out.</li> </ul> |\n   * | 401 | Unauthenticated | No user identity found in passed request. |\n   * | 500 | Internal Server Error | The server encountered an unexpected condition, such as a missing or invalid private CAPTCHA key. |\n   * | 503 | Unavailable | The service is unavailable due to one of the following: <ul> <li>Throttled error: Server overload due to more than the allowed requests in a given time frame.</li> <li>Request failed: No response following 10 retries with a 1-second interval.</li> </ul> |\n   * @param - The CAPTCHA token to authorize.\n   */\n  (token: string): Promise<\n    NonNullablePaths<CaptchaResponse, `success` | `errors.errorId`, 3>\n  >;\n}\n\nexport {\n  AssessmentResponse,\n  CaptchaEntity,\n  CaptchaRequest,\n  CaptchaResponse,\n  Errors,\n} from './captcharator-v1-captcha-entity-captcha.universal.js';\n","import { authorize as publicAuthorize } from './captcharator-v1-captcha-entity-captcha.public.js';\nimport { createRESTModule } from '@wix/sdk-runtime/rest-modules';\nimport { BuildRESTFunction, MaybeContext } from '@wix/sdk-types';\n\nexport const authorize: MaybeContext<\n  BuildRESTFunction<typeof publicAuthorize> & typeof publicAuthorize\n> = /*#__PURE__*/ createRESTModule(publicAuthorize);\n\nexport {\n  CaptchaEntity,\n  CaptchaRequest,\n  CaptchaResponse,\n  Errors,\n  AssessmentResponse,\n} from './captcharator-v1-captcha-entity-captcha.universal.js';\n"],"mappings":";AAAA,SAAS,kBAAkB,yBAAyB;AACpD;AAAA,EACE;AAAA,EACA;AAAA,OACK;;;ACJP,SAAS,kBAAkB;AAI3B,SAAS,kDACP,MACA;AACA,QAAM,mBAAmB;AAAA,IACvB,yBAAyB;AAAA,MACvB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,qBAAqB;AAAA,MACnB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,qBAAqB;AAAA,MACnB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,MACA;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,MACA;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,wBAAwB;AAAA,MACtB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AA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