@atproto/oauth-provider 0.6.2 → 0.6.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atproto/oauth-provider
2
2
 
3
+ ## 0.6.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#3688](https://github.com/bluesky-social/atproto/pull/3688) [`98d8a677c`](https://github.com/bluesky-social/atproto/commit/98d8a677ca4671137727d14567c8354c48c9e850) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Add debugging info to HCaptcha validation errors
8
+
9
+ - [#3688](https://github.com/bluesky-social/atproto/pull/3688) [`98d8a677c`](https://github.com/bluesky-social/atproto/commit/98d8a677ca4671137727d14567c8354c48c9e850) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Add hook with hcaptcha result
10
+
3
11
  ## 0.6.2
4
12
 
5
13
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"account-manager.d.ts","sourceRoot":"","sources":["../../src/account/account-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EAEtB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AAEjD,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAGzE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACpD,OAAO,EACL,OAAO,EACP,WAAW,EACX,YAAY,EACZ,wBAAwB,EACxB,wBAAwB,EACxB,UAAU,EACX,MAAM,oBAAoB,CAAA;AAC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,CAAC;CAKrE"}
@@ -28,13 +28,22 @@ class AccountManager {
28
28
  if (!input.hcaptchaToken) {
29
29
  throw new invalid_request_error_js_1.InvalidRequestError('hCaptcha token is required');
30
30
  }
31
- const { allowed, result } = await this.hcaptchaClient
31
+ const result = await this.hcaptchaClient
32
32
  .verify('signup', input.hcaptchaToken, deviceMetadata.ipAddress, input.handle, deviceMetadata.userAgent)
33
33
  .catch((err) => {
34
34
  throw invalid_request_error_js_1.InvalidRequestError.from(err, 'hCaptcha verification failed');
35
35
  });
36
- if (!allowed) {
37
- throw new invalid_request_error_js_1.InvalidRequestError('hCaptcha verification failed');
36
+ await (0, function_js_1.callAsync)(this.hooks.onHcaptchaResult, {
37
+ input,
38
+ deviceId,
39
+ deviceMetadata,
40
+ result,
41
+ });
42
+ try {
43
+ this.hcaptchaClient.checkVerifyResult(result);
44
+ }
45
+ catch (err) {
46
+ throw invalid_request_error_js_1.InvalidRequestError.from(err, 'hCaptcha verification failed');
38
47
  }
39
48
  return result;
40
49
  }
@@ -1 +1 @@
1
- {"version":3,"file":"account-manager.js","sourceRoot":"","sources":["../../src/account/account-manager.ts"],"names":[],"mappings":";;;AAAA,sDAG6B;AAG7B,iFAAwE;AACxE,oDAAyE;AACzE,yDAAmD;AACnD,iDAAkD;AAgBlD,MAAM,8BAA8B,GAAG,GAAG,CAAA;AAC1C,MAAM,4BAA4B,GAAG,GAAG,CAAA;AAExC,MAAa,cAAc;IAMJ;IACA;IANF,kBAAkB,CAAS;IAC3B,cAAc,CAAiB;IAElD,YACE,MAA6B,EACV,KAAmB,EACnB,KAAiB,EACpC,aAA4B;QAFT,UAAK,GAAL,KAAK,CAAc;QACnB,UAAK,GAAL,KAAK,CAAY;QAGpC,IAAI,CAAC,kBAAkB,GAAG,aAAa,CAAC,kBAAkB,KAAK,KAAK,CAAA;QACpE,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC,QAAQ;YAC1C,CAAC,CAAC,IAAI,4BAAc,CAAC,IAAI,GAAG,CA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IAA8B;QAC9D,OAAO,IAAA,sBAAY,EAAC,8BAA8B,EAAE,KAAK,IAAI,EAAE;YAC7D,MAAM,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAA;QAC7C,CAAC,CAAC,CAAA;IACJ,CAAC;IAEM,KAAK,CAAC,oBAAoB,CAAC,IAA8B;QAC9D,OAAO,IAAA,sBAAY,EAAC,8BAA8B,EAAE,KAAK,IAAI,EAAE;YAC7D,MAAM,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAA;QAC7C,CAAC,CAAC,CAAA;IACJ,CAAC;IAEM,KAAK,CAAC,wBAAwB,CAAC,MAAc;QAClD,OAAO,IAAA,sBAAY,EAAC,8BAA8B,EAAE,KAAK,IAAI,EAAE;YAC7D,OAAO,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAA;QACpD,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AA/MD,wCA+MC"}
@@ -148,33 +148,34 @@ export declare const hcaptchaVerifyResultSchema: z.ZodObject<{
148
148
  }>;
149
149
  export type HcaptchaVerifyResult = z.infer<typeof hcaptchaVerifyResultSchema>;
150
150
  export declare class HCaptchaClient {
151
- private readonly hostname;
152
- private readonly config;
151
+ readonly hostname: string;
152
+ readonly config: HcaptchaConfig;
153
153
  protected readonly fetch: FetchBound;
154
154
  constructor(hostname: string, config: HcaptchaConfig, fetch?: Fetch);
155
155
  verify(behaviorType: 'login' | 'signup', response: string, remoteip: string, handle: string, userAgent?: string): Promise<{
156
- allowed: boolean;
157
- result: {
158
- hostname: string | null;
159
- success: boolean;
160
- challenge_ts: string;
161
- 'error-codes'?: string[] | undefined;
162
- score?: number | undefined;
163
- score_reason?: string[] | undefined;
164
- sitekey?: string | undefined;
165
- behavior_counts?: Record<string, unknown> | undefined;
166
- similarity?: number | undefined;
167
- similarity_failures?: number | undefined;
168
- similarity_error_details?: string[] | undefined;
169
- scoped_uid_0?: string | undefined;
170
- scoped_uid_1?: string | undefined;
171
- scoped_uid_2?: string | undefined;
172
- risk_insights?: Record<string, unknown> | undefined;
173
- sigs?: Record<string, unknown> | undefined;
174
- tags?: string[] | undefined;
175
- };
156
+ hostname: string | null;
157
+ success: boolean;
158
+ challenge_ts: string;
159
+ 'error-codes'?: string[] | undefined;
160
+ score?: number | undefined;
161
+ score_reason?: string[] | undefined;
162
+ sitekey?: string | undefined;
163
+ behavior_counts?: Record<string, unknown> | undefined;
164
+ similarity?: number | undefined;
165
+ similarity_failures?: number | undefined;
166
+ similarity_error_details?: string[] | undefined;
167
+ scoped_uid_0?: string | undefined;
168
+ scoped_uid_1?: string | undefined;
169
+ scoped_uid_2?: string | undefined;
170
+ risk_insights?: Record<string, unknown> | undefined;
171
+ sigs?: Record<string, unknown> | undefined;
172
+ tags?: string[] | undefined;
176
173
  }>;
177
- protected isAllowed({ success, hostname, score }: HcaptchaVerifyResult): boolean;
174
+ checkVerifyResult(result: HcaptchaVerifyResult): void;
178
175
  protected hashToken(value: string): string;
179
176
  }
177
+ export declare class HCaptchaVerificationError extends Error {
178
+ readonly result: HcaptchaVerifyResult;
179
+ constructor(result: HcaptchaVerifyResult, message?: string);
180
+ }
180
181
  //# sourceMappingURL=hcaptcha.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hcaptcha.d.ts","sourceRoot":"","sources":["../../src/lib/hcaptcha.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EACL,KAAK,EACL,UAAU,EAKX,MAAM,qBAAqB,CAAA;AAG5B,eAAO,MAAM,mBAAmB,aAAoB,CAAA;AACpD,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAE/D,eAAO,MAAM,oBAAoB;IAC/B;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;;;;;OAMG;;;;;;;;;;;;EAEH,CAAA;AACF,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AS,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM;CAMlC;AAED,qBAAa,yBAA0B,SAAQ,KAAK;IAEhD,QAAQ,CAAC,MAAM,EAAE,oBAAoB;gBAA5B,MAAM,EAAE,oBAAoB,EACrC,OAAO,CAAC,EAAE,MAAM;CAInB"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HCaptchaClient = exports.hcaptchaVerifyResultSchema = exports.hcaptchaConfigSchema = exports.hcaptchaTokenSchema = void 0;
3
+ exports.HCaptchaVerificationError = exports.HCaptchaClient = exports.hcaptchaVerifyResultSchema = exports.hcaptchaConfigSchema = exports.hcaptchaTokenSchema = void 0;
4
4
  const node_crypto_1 = require("node:crypto");
5
5
  const zod_1 = require("zod");
6
6
  const fetch_1 = require("@atproto-labs/fetch");
@@ -114,7 +114,7 @@ class HCaptchaClient {
114
114
  this.fetch = (0, fetch_1.bindFetch)(fetch);
115
115
  }
116
116
  async verify(behaviorType, response, remoteip, handle, userAgent) {
117
- const result = await this.fetch('https://api.hcaptcha.com/siteverify', {
117
+ return this.fetch('https://api.hcaptcha.com/siteverify', {
118
118
  method: 'POST',
119
119
  headers: {
120
120
  'Content-Type': 'application/x-www-form-urlencoded',
@@ -132,21 +132,28 @@ class HCaptchaClient {
132
132
  }),
133
133
  }).toString(),
134
134
  }).then(fetchSuccessHandler);
135
- return {
136
- allowed: this.isAllowed(result),
137
- result,
138
- };
139
135
  }
140
- isAllowed({ success, hostname, score }) {
141
- return (success &&
136
+ checkVerifyResult(result) {
137
+ const { success, hostname, score } = result;
138
+ if (success !== true) {
139
+ throw new HCaptchaVerificationError(result, 'Expected success to be true');
140
+ }
141
+ if (
142
+ // Ignore if enterprise feature is not enabled
143
+ hostname != null &&
142
144
  // Fool-proofing: If this is false, the user is trying to use a token
143
145
  // generated for the same siteKey, but on another domain.
144
- (hostname == null || hostname === this.hostname) &&
145
- // Ignore if enterprise feature is not enabled
146
- (score == null ||
147
- // Ignore if disabled through config
148
- this.config.scoreThreshold == null ||
149
- score < this.config.scoreThreshold));
146
+ hostname !== this.hostname) {
147
+ throw new HCaptchaVerificationError(result, `Hostname ${hostname} does not match ${this.hostname}`);
148
+ }
149
+ if (
150
+ // Ignore if enterprise feature is not enabled
151
+ score != null &&
152
+ // Ignore if disabled through config
153
+ this.config.scoreThreshold != null &&
154
+ score >= this.config.scoreThreshold) {
155
+ throw new HCaptchaVerificationError(result, `Score ${score} is above the threshold ${this.config.scoreThreshold}`);
156
+ }
150
157
  }
151
158
  hashToken(value) {
152
159
  const hash = (0, node_crypto_1.createHash)('sha256');
@@ -156,4 +163,12 @@ class HCaptchaClient {
156
163
  }
157
164
  }
158
165
  exports.HCaptchaClient = HCaptchaClient;
166
+ class HCaptchaVerificationError extends Error {
167
+ result;
168
+ constructor(result, message) {
169
+ super(message);
170
+ this.result = result;
171
+ }
172
+ }
173
+ exports.HCaptchaVerificationError = HCaptchaVerificationError;
159
174
  //# sourceMappingURL=hcaptcha.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hcaptcha.js","sourceRoot":"","sources":["../../src/lib/hcaptcha.ts"],"names":[],"mappings":";;;AAAA,6CAAwC;AACxC,6BAAuB;AACvB,+CAO4B;AAC5B,6CAAyC;AAE5B,QAAA,mBAAmB,GAAG,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;AAGvC,QAAA,oBAAoB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3C;;OAEG;IACH,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1B;;OAEG;IACH,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5B;;OAEG;IACH,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5B;;;;;;OAMG;IACH,cAAc,EAAE,OAAC,CA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MAAM,CAAC,cAAc,IAAI,IAAI;YAClC,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,cAAc,EACnC,CAAC;YACD,MAAM,IAAI,yBAAyB,CACjC,MAAM,EACN,SAAS,KAAK,2BAA2B,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CACtE,CAAA;QACH,CAAC;IACH,CAAC;IAES,SAAS,CAAC,KAAa;QAC/B,MAAM,IAAI,GAAG,IAAA,wBAAU,EAAC,QAAQ,CAAC,CAAA;QACjC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;QAClC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QAClB,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;IACzC,CAAC;CACF;AA7ED,wCA6EC;AAED,MAAa,yBAA0B,SAAQ,KAAK;IAEvC;IADX,YACW,MAA4B,EACrC,OAAgB;QAEhB,KAAK,CAAC,OAAO,CAAC,CAAA;QAHL,WAAM,GAAN,MAAM,CAAsB;IAIvC,CAAC;CACF;AAPD,8DAOC"}
@@ -48,6 +48,12 @@ export type OAuthHooks = {
48
48
  deviceId: DeviceId;
49
49
  deviceMetadata: RequestMetadata;
50
50
  }) => Awaitable<void>;
51
+ onHcaptchaResult?: (data: {
52
+ input: SignUpInput;
53
+ deviceId: DeviceId;
54
+ deviceMetadata: RequestMetadata;
55
+ result: HcaptchaVerifyResult;
56
+ }) => Awaitable<void>;
51
57
  /**
52
58
  * This hook is called when a user successfully signs up.
53
59
  *
@@ -1 +1 @@
1
- {"version":3,"file":"oauth-hooks.d.ts","sourceRoot":"","sources":["../src/oauth-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EACL,yBAAyB,EACzB,mCAAmC,EACnC,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,sBAAsB,CAAA;AAC7B,OAA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,CAAA;QAChB,UAAU,EAAE,mCAAmC,CAAA;QAC/C,QAAQ,EAAE,QAAQ,CAAA;QAClB,cAAc,EAAE,eAAe,CAAA;KAChC,KAAK,SAAS,CAAC,IAAI,CAAC,CAAA;IAErB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE;QACtB,MAAM,EAAE,MAAM,CAAA;QACd,UAAU,EAAE,UAAU,CAAA;QACtB,cAAc,EAAE,eAAe,CAAA;QAC/B,OAAO,EAAE,OAAO,CAAA;QAChB,UAAU,EAAE,mCAAmC,CAAA;QAC/C,kGAAkG;QAClG,QAAQ,EAAE,IAAI,GAAG,QAAQ,CAAA;KAC1B,KAAK,SAAS,CAAC,IAAI,CAAC,CAAA;IAErB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE;QACxB,MAAM,EAAE,MAAM,CAAA;QACd,UAAU,EAAE,UAAU,CAAA;QACtB,cAAc,EAAE,eAAe,CAAA;QAC/B,OAAO,EAAE,OAAO,CAAA;QAChB,UAAU,EAAE,mCAAmC,CAAA;QAC/C,kGAAkG;QAClG,QAAQ,EAAE,IAAI,GAAG,QAAQ,CAAA;KAC1B,KAAK,SAAS,CAAC,IAAI,CAAC,CAAA;CACtB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/oauth-provider",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "license": "MIT",
5
5
  "description": "Generic OAuth2 and OpenID Connect provider for Node.js. Currently only supports features needed for Atproto.",
6
6
  "keywords": [
@@ -43,10 +43,10 @@
43
43
  "jose": "^5.2.0",
44
44
  "psl": "^1.9.0",
45
45
  "zod": "^3.23.8",
46
- "@atproto-labs/fetch-node": "0.1.8",
47
46
  "@atproto-labs/fetch": "0.2.2",
48
- "@atproto-labs/pipe": "0.1.0",
47
+ "@atproto-labs/fetch-node": "0.1.8",
49
48
  "@atproto-labs/simple-store": "0.1.2",
49
+ "@atproto-labs/pipe": "0.1.0",
50
50
  "@atproto-labs/simple-store-memory": "0.1.2",
51
51
  "@atproto/common": "^0.4.8",
52
52
  "@atproto/jwk": "0.1.4",
@@ -55,7 +55,7 @@ export class AccountManager {
55
55
  throw new InvalidRequestError('hCaptcha token is required')
56
56
  }
57
57
 
58
- const { allowed, result } = await this.hcaptchaClient
58
+ const result = await this.hcaptchaClient
59
59
  .verify(
60
60
  'signup',
61
61
  input.hcaptchaToken,
@@ -67,8 +67,17 @@ export class AccountManager {
67
67
  throw InvalidRequestError.from(err, 'hCaptcha verification failed')
68
68
  })
69
69
 
70
- if (!allowed) {
71
- throw new InvalidRequestError('hCaptcha verification failed')
70
+ await callAsync(this.hooks.onHcaptchaResult, {
71
+ input,
72
+ deviceId,
73
+ deviceMetadata,
74
+ result,
75
+ })
76
+
77
+ try {
78
+ this.hcaptchaClient.checkVerifyResult(result)
79
+ } catch (err) {
80
+ throw InvalidRequestError.from(err, 'hCaptcha verification failed')
72
81
  }
73
82
 
74
83
  return result
@@ -124,8 +124,8 @@ const fetchSuccessHandler = pipe(
124
124
  export class HCaptchaClient {
125
125
  protected readonly fetch: FetchBound
126
126
  constructor(
127
- private readonly hostname: string,
128
- private readonly config: HcaptchaConfig,
127
+ readonly hostname: string,
128
+ readonly config: HcaptchaConfig,
129
129
  fetch: Fetch = globalThis.fetch,
130
130
  ) {
131
131
  this.fetch = bindFetch(fetch)
@@ -138,7 +138,7 @@ export class HCaptchaClient {
138
138
  handle: string,
139
139
  userAgent?: string,
140
140
  ) {
141
- const result = await this.fetch('https://api.hcaptcha.com/siteverify', {
141
+ return this.fetch('https://api.hcaptcha.com/siteverify', {
142
142
  method: 'POST',
143
143
  headers: {
144
144
  'Content-Type': 'application/x-www-form-urlencoded',
@@ -156,25 +156,40 @@ export class HCaptchaClient {
156
156
  }),
157
157
  }).toString(),
158
158
  }).then(fetchSuccessHandler)
159
+ }
160
+
161
+ public checkVerifyResult(result: HcaptchaVerifyResult): void {
162
+ const { success, hostname, score } = result
159
163
 
160
- return {
161
- allowed: this.isAllowed(result),
162
- result,
164
+ if (success !== true) {
165
+ throw new HCaptchaVerificationError(result, 'Expected success to be true')
163
166
  }
164
- }
165
167
 
166
- protected isAllowed({ success, hostname, score }: HcaptchaVerifyResult) {
167
- return (
168
- success &&
168
+ if (
169
+ // Ignore if enterprise feature is not enabled
170
+ hostname != null &&
169
171
  // Fool-proofing: If this is false, the user is trying to use a token
170
172
  // generated for the same siteKey, but on another domain.
171
- (hostname == null || hostname === this.hostname) &&
173
+ hostname !== this.hostname
174
+ ) {
175
+ throw new HCaptchaVerificationError(
176
+ result,
177
+ `Hostname ${hostname} does not match ${this.hostname}`,
178
+ )
179
+ }
180
+
181
+ if (
172
182
  // Ignore if enterprise feature is not enabled
173
- (score == null ||
174
- // Ignore if disabled through config
175
- this.config.scoreThreshold == null ||
176
- score < this.config.scoreThreshold)
177
- )
183
+ score != null &&
184
+ // Ignore if disabled through config
185
+ this.config.scoreThreshold != null &&
186
+ score >= this.config.scoreThreshold
187
+ ) {
188
+ throw new HCaptchaVerificationError(
189
+ result,
190
+ `Score ${score} is above the threshold ${this.config.scoreThreshold}`,
191
+ )
192
+ }
178
193
  }
179
194
 
180
195
  protected hashToken(value: string) {
@@ -184,3 +199,12 @@ export class HCaptchaClient {
184
199
  return hash.digest().toString('base64')
185
200
  }
186
201
  }
202
+
203
+ export class HCaptchaVerificationError extends Error {
204
+ constructor(
205
+ readonly result: HcaptchaVerifyResult,
206
+ message?: string,
207
+ ) {
208
+ super(message)
209
+ }
210
+ }
@@ -82,6 +82,13 @@ export type OAuthHooks = {
82
82
  deviceMetadata: RequestMetadata
83
83
  }) => Awaitable<void>
84
84
 
85
+ onHcaptchaResult?: (data: {
86
+ input: SignUpInput
87
+ deviceId: DeviceId
88
+ deviceMetadata: RequestMetadata
89
+ result: HcaptchaVerifyResult
90
+ }) => Awaitable<void>
91
+
85
92
  /**
86
93
  * This hook is called when a user successfully signs up.
87
94
  *