@reclaimprotocol/js-sdk 4.10.1 → 4.11.0

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 CHANGED
@@ -8,6 +8,8 @@
8
8
 
9
9
  This guide will walk you through integrating the Reclaim Protocol JavaScript SDK into your application. We'll create a simple React application that demonstrates how to use the SDK to generate proofs and verify claims.
10
10
 
11
+ [Official documentation](https://docs.reclaimprotocol.org/js-sdk/installation)
12
+
11
13
  ## Prerequisites
12
14
 
13
15
  Before we begin, make sure you have:
@@ -312,19 +314,56 @@ The Reclaim SDK offers several advanced options to customize your integration:
312
314
 
313
315
  3. **Custom Redirect URL**:
314
316
 
315
- Set a custom URL to redirect users after the verification process:
317
+ Set a custom URL to redirect users after the verification process.
316
318
 
317
319
  ```javascript
318
320
  reclaimProofRequest.setRedirectUrl("https://example.com/redirect");
319
321
  ```
320
322
 
323
+ Redirection with body:
324
+
325
+ - **url**: The URL where users should be redirected after successful proof generation.
326
+ - **method** (optional): The redirection method to use. Allowed options: `GET` (default) and `POST`.
327
+ *Note: `POST` form redirection is only supported in In-Browser SDK.*
328
+ - **body** (optional): List of name-value pairs to be sent as the body of the form request.
329
+ - When `method` is `POST`, `body` is sent with `application/x-www-form-urlencoded` content type.
330
+ - When `method` is `GET`, if `body` is set, it is sent as query parameters.
331
+ *Note: Sending `body` on redirection is only supported in In-Browser SDK.*
332
+
333
+ ```javascript
334
+ reclaimProofRequest.setRedirectUrl(
335
+ "https://example.com/redirect",
336
+ "POST", // In-Browser SDK only
337
+ [{ name: "foo", value: "bar" }] // In-Browser SDK only
338
+ );
339
+ ```
340
+
321
341
  4. **Custom Cancel Redirect URL**:
322
- Set a custom URL to redirect users on a cancellation which aborts the verification process:
342
+ Set a custom URL to redirect users on a cancellation which aborts the verification process.
343
+
323
344
 
324
345
  ```javascript
325
346
  reclaimProofRequest.setCancelRedirectUrl("https://example.com/error-redirect");
326
347
  ```
327
348
 
349
+ Redirection with body:
350
+
351
+ - **url**: The URL where users should be redirected after an error which aborts the verification process.
352
+ - **method** (optional): The redirection method to use. Allowed options: `GET` (default) and `POST`.
353
+ *Note: `POST` form redirection is only supported in In-Browser SDK.*
354
+ - **body** (optional): List of name-value pairs to be sent as the body of the form request.
355
+ - When `method` is `POST`, `body` is sent with `application/x-www-form-urlencoded` content type.
356
+ - When `method` is `GET`, if `body` is set, it is sent as query parameters.
357
+ *Note: Sending `body` on redirection is only supported in In-Browser SDK.*
358
+
359
+ ```javascript
360
+ reclaimProofRequest.setCancelRedirectUrl(
361
+ "https://example.com/error-redirect",
362
+ "POST", // In-Browser SDK only
363
+ [{ name: "error_code", value: "1001" }] // In-Browser SDK only
364
+ );
365
+ ```
366
+
328
367
  5. **Custom Callback URL**:
329
368
  Set a custom callback URL for your app which allows you to receive proofs and status updates on your callback URL:
330
369
 
@@ -335,12 +374,36 @@ reclaimProofRequest.setCancelRedirectUrl("https://example.com/error-redirect");
335
374
  reclaimProofRequest.setAppCallbackUrl("https://example.com/callback", true);
336
375
  ```
337
376
 
377
+ This verification session's id will also be present in `X-Reclaim-Session-Id` header of the request.
378
+
379
+ The request URL will contain query param `allowAiWitness` with value `true` when AI Witness should be allowed by handler of the request.
380
+
338
381
  6. **Custom Error Callback URL**:
339
- Set a custom cancel callback URL for your app which allows you to receive user or provider initiated cancellation on your callback URL:
340
382
 
341
- ```javascript
342
- reclaimProofRequest.setCancelCallbackUrl("https://example.com/error-callback");
343
-
383
+ Set a custom cancel callback URL for your app which allows you to receive user- or provider-initiated cancellation on your callback URL:
384
+
385
+ ```javascript
386
+ reclaimProofRequest.setCancelCallbackUrl("https://example.com/error-callback");
387
+ ```
388
+
389
+ When verificaiton is cancelled by user (or upon error when auto-submit is enabled), following data is sent as an HTTP POST request to the url with `Content-Type: application/json`:
390
+
391
+ ```json
392
+ {
393
+ "type": "string", // Name of the exception
394
+ "message": "string",
395
+ "sessionId": "string",
396
+ // context as canonicalized json string
397
+ "context": "string",
398
+ // Other fields with more details about error may be present
399
+ // [key: any]: any
400
+ }
401
+ ```
402
+
403
+ This verification session's id will also be present in `X-Reclaim-Session-Id` header of the request.
404
+
405
+ For more details about response format, check out [official documentation of Error Callback URL](https://docs.reclaimprotocol.org/js-sdk/preparing-request#cancel-callback).
406
+
344
407
 
345
408
  7. **Modal Customization for Desktop Users**:
346
409
  Customize the appearance and behavior of the QR code modal shown to desktop users:
package/dist/index.d.ts CHANGED
@@ -49,6 +49,20 @@ type BeaconState = {
49
49
  nextEpochTimestampS: number;
50
50
  };
51
51
 
52
+ type ClaimID = ProviderClaimData['identifier'];
53
+ type ClaimInfo = Pick<ProviderClaimData, 'context' | 'provider' | 'parameters'>;
54
+ type AnyClaimInfo = ClaimInfo | {
55
+ identifier: ClaimID;
56
+ };
57
+ type CompleteClaimData = Pick<ProviderClaimData, 'owner' | 'timestampS' | 'epoch'> & AnyClaimInfo;
58
+ type SignedClaim = {
59
+ claim: CompleteClaimData;
60
+ signatures: Uint8Array[];
61
+ };
62
+ type CreateVerificationRequest = {
63
+ providerIds: string[];
64
+ applicationSecret?: string;
65
+ };
52
66
  type StartSessionParams = {
53
67
  onSuccess: OnSuccess;
54
68
  onError: OnError;
@@ -142,6 +156,29 @@ declare enum DeviceType {
142
156
  DESKTOP = "desktop",
143
157
  MOBILE = "mobile"
144
158
  }
159
+ type InitSessionResponse = {
160
+ sessionId: string;
161
+ resolvedProviderVersion: string;
162
+ };
163
+ interface UpdateSessionResponse {
164
+ success: boolean;
165
+ message?: string;
166
+ }
167
+ declare enum SessionStatus {
168
+ SESSION_INIT = "SESSION_INIT",
169
+ SESSION_STARTED = "SESSION_STARTED",
170
+ USER_INIT_VERIFICATION = "USER_INIT_VERIFICATION",
171
+ USER_STARTED_VERIFICATION = "USER_STARTED_VERIFICATION",
172
+ PROOF_GENERATION_STARTED = "PROOF_GENERATION_STARTED",
173
+ PROOF_GENERATION_SUCCESS = "PROOF_GENERATION_SUCCESS",
174
+ PROOF_GENERATION_FAILED = "PROOF_GENERATION_FAILED",
175
+ PROOF_SUBMITTED = "PROOF_SUBMITTED",
176
+ AI_PROOF_SUBMITTED = "AI_PROOF_SUBMITTED",
177
+ PROOF_SUBMISSION_FAILED = "PROOF_SUBMISSION_FAILED",
178
+ ERROR_SUBMITTED = "ERROR_SUBMITTED",
179
+ ERROR_SUBMISSION_FAILED = "ERROR_SUBMISSION_FAILED",
180
+ PROOF_MANUAL_VERIFICATION_SUBMITED = "PROOF_MANUAL_VERIFICATION_SUBMITED"
181
+ }
145
182
  type ProofPropertiesJSON = {
146
183
  applicationId: string;
147
184
  providerId: string;
@@ -149,6 +186,7 @@ type ProofPropertiesJSON = {
149
186
  context: Context;
150
187
  signature: string;
151
188
  redirectUrl?: string;
189
+ redirectUrlOptions?: TemplateData['redirectUrlOptions'];
152
190
  parameters: {
153
191
  [key: string]: string;
154
192
  };
@@ -160,6 +198,7 @@ type ProofPropertiesJSON = {
160
198
  appCallbackUrl?: string;
161
199
  cancelCallbackUrl?: TemplateData['cancelCallbackUrl'];
162
200
  cancelRedirectUrl?: TemplateData['cancelRedirectUrl'];
201
+ cancelRedirectUrlOptions?: TemplateData['cancelRedirectUrlOptions'];
163
202
  claimCreationType?: ClaimCreationType;
164
203
  options?: ProofRequestOptions;
165
204
  sdkVersion: string;
@@ -167,6 +206,41 @@ type ProofPropertiesJSON = {
167
206
  resolvedProviderVersion: string;
168
207
  modalOptions?: SerializableModalOptions;
169
208
  };
209
+ type HttpFormEntry = {
210
+ name: string;
211
+ value: string;
212
+ };
213
+ type HttpRedirectionMethod = 'GET' | 'POST';
214
+ /**
215
+ * Options for HTTP redirection.
216
+ *
217
+ * Only supported by In-Browser SDK.
218
+ * On other SDKs, this will be ignored and a GET redirection will be performed with the URL.
219
+ *
220
+ * @since 4.11.0
221
+ * @default "{ method: 'GET' }"
222
+ */
223
+ type HttpRedirectionOptions = {
224
+ /**
225
+ * List of name-value pairs to be sent as the body of the form request.
226
+ * When `method` is set to `POST`, `body` will be sent with 'application/x-www-form-urlencoded' content type.
227
+ * When `method` is set to `GET`, `body` will be sent as query parameters.
228
+ *
229
+ * @default undefined
230
+ */
231
+ body?: HttpFormEntry[] | null | undefined;
232
+ /**
233
+ * HTTP method to use for the redirection.
234
+ *
235
+ * POST will result in `body` being sent with 'application/x-www-form-urlencoded' content type.
236
+ * GET will result in `body`, if present, being sent as query parameters.
237
+ *
238
+ * With `method` set to `GET` and no `body`, this will result in a simple GET redirection using `window.location.href`.
239
+ *
240
+ * @default 'GET'
241
+ */
242
+ method?: HttpRedirectionMethod;
243
+ };
170
244
  type TemplateData = {
171
245
  sessionId: string;
172
246
  providerId: string;
@@ -179,8 +253,10 @@ type TemplateData = {
179
253
  [key: string]: string;
180
254
  };
181
255
  redirectUrl: string;
256
+ redirectUrlOptions?: HttpRedirectionOptions;
182
257
  cancelCallbackUrl?: string | null;
183
258
  cancelRedirectUrl?: string | null;
259
+ cancelRedirectUrlOptions?: HttpRedirectionOptions;
184
260
  acceptAiProviders: boolean;
185
261
  sdkVersion: string;
186
262
  jsonProofResponse?: boolean;
@@ -191,6 +267,18 @@ type TemplateData = {
191
267
  metadata?: Record<string, string>;
192
268
  preferredLocale?: ProofRequestOptions['preferredLocale'];
193
269
  };
270
+ type StatusUrlResponse = {
271
+ message: string;
272
+ session?: {
273
+ id: string;
274
+ appId: string;
275
+ httpProviderId: string[];
276
+ sessionId: string;
277
+ proofs?: Proof[];
278
+ statusV2: string;
279
+ };
280
+ providerId?: string;
281
+ };
194
282
 
195
283
  /**
196
284
  * Verifies one or more Reclaim proofs by validating signatures and witness information
@@ -237,8 +325,10 @@ declare class ReclaimProofRequest {
237
325
  private resolvedProviderVersion?;
238
326
  private parameters;
239
327
  private redirectUrl?;
328
+ private redirectUrlOptions?;
240
329
  private cancelCallbackUrl?;
241
330
  private cancelRedirectUrl?;
331
+ private cancelRedirectUrlOptions?;
242
332
  private intervals;
243
333
  private timeStamp;
244
334
  private sdkVersion;
@@ -301,6 +391,9 @@ declare class ReclaimProofRequest {
301
391
  * Consequently, the startSession `onSuccess` callback will be invoked with an empty array (`[]`)
302
392
  * instead of the proof data, as the proof is not available to the SDK in this flow.
303
393
  *
394
+ * This verification session's id will be present in `X-Reclaim-Session-Id` header of the request.
395
+ * The request URL will contain query param `allowAiWitness` with value `true` when AI Witness should be allowed by handler of the request.
396
+ *
304
397
  * Note: InApp SDKs are unaffected by this property as they do not handle proof submission.
305
398
  *
306
399
  * @param url - The URL where proofs should be submitted via HTTP `POST`
@@ -319,6 +412,13 @@ declare class ReclaimProofRequest {
319
412
  * Sets a redirect URL where users will be redirected after successfully acquiring and submitting proof
320
413
  *
321
414
  * @param url - The URL where users should be redirected after successful proof generation
415
+ * @param method - The redirection method that should be used for redirection. Allowed options: `GET`, and `POST`.
416
+ * `POST` form redirection is only supported in In-Browser SDK.
417
+ * @param body - List of name-value pairs to be sent as the body of the form request.
418
+ * `When `method` is set to `POST`, `body` will be sent with 'application/x-www-form-urlencoded' content type.
419
+ * When `method` is set to `GET`, if `body` is set then `body` will be sent as query parameters.
420
+ * Sending `body` on redirection is only supported in In-Browser SDK.
421
+ *
322
422
  * @throws {InvalidParamError} When URL is invalid
323
423
  *
324
424
  * @example
@@ -326,7 +426,7 @@ declare class ReclaimProofRequest {
326
426
  * proofRequest.setRedirectUrl('https://your-app.com/success');
327
427
  * ```
328
428
  */
329
- setRedirectUrl(url: string): void;
429
+ setRedirectUrl(url: string, method?: HttpRedirectionMethod, body?: HttpFormEntry[] | undefined): void;
330
430
  /**
331
431
  * Sets a custom callback URL where errors that abort the verification process will be submitted via HTTP POST
332
432
  *
@@ -335,6 +435,24 @@ declare class ReclaimProofRequest {
335
435
  * and listeners on the startSession method will not be triggered. Your application must
336
436
  * coordinate with your backend to receive errors.
337
437
  *
438
+ * This verification session's id will be present in `X-Reclaim-Session-Id` header of the request.
439
+ *
440
+ * Following is the data format which is sent as an HTTP POST request to the url with `Content-Type: application/json`:
441
+
442
+ * ```json
443
+ * {
444
+ * "type": "string", // Name of the exception
445
+ * "message": "string",
446
+ * "sessionId": "string",
447
+ * // context as canonicalized json string
448
+ * "context": "string",
449
+ * // Other fields with more details about error may be present
450
+ * // [key: any]: any
451
+ * }
452
+ * ```
453
+ *
454
+ * For more details about response format, check out [official documentation of Error Callback URL](https://docs.reclaimprotocol.org/js-sdk/preparing-request#cancel-callback).
455
+ *
338
456
  * @param url - The URL where errors should be submitted via HTTP POST
339
457
  * @throws {InvalidParamError} When URL is invalid
340
458
  *
@@ -351,6 +469,12 @@ declare class ReclaimProofRequest {
351
469
  * Sets an error redirect URL where users will be redirected after an error which aborts the verification process
352
470
  *
353
471
  * @param url - The URL where users should be redirected after an error which aborts the verification process
472
+ * @param method - The redirection method that should be used for redirection. Allowed options: `GET`, and `POST`.
473
+ * `POST` form redirection is only supported in In-Browser SDK.
474
+ * @param body - List of name-value pairs to be sent as the body of the form request.
475
+ * When `method` is set to `POST`, `body` will be sent with 'application/x-www-form-urlencoded' content type.
476
+ * When `method` is set to `GET`, if `body` is set then `body` will be sent as query parameters.
477
+ * Sending `body` on redirection is only supported in In-Browser SDK.
354
478
  * @throws {InvalidParamError} When URL is invalid
355
479
  *
356
480
  * @example
@@ -361,7 +485,7 @@ declare class ReclaimProofRequest {
361
485
  * @since 4.10.0
362
486
  *
363
487
  */
364
- setCancelRedirectUrl(url: string): void;
488
+ setCancelRedirectUrl(url: string, method?: HttpRedirectionMethod, body?: HttpFormEntry[] | undefined): void;
365
489
  /**
366
490
  * Sets the claim creation type for the proof request
367
491
  *
@@ -700,4 +824,4 @@ declare function isDesktopDevice(): boolean;
700
824
  */
701
825
  declare function clearDeviceCache(): void;
702
826
 
703
- export { type Beacon, type BeaconState, ClaimCreationType, type Context, DeviceType, type ExtensionMessage, type ModalOptions, type Proof, type ProofPropertiesJSON, type ProviderClaimData, RECLAIM_EXTENSION_ACTIONS, ReclaimProofRequest, type WitnessData, clearDeviceCache, getDeviceType, getMobileDeviceType, isDesktopDevice, isMobileDevice, transformForOnchain, verifyProof };
827
+ export { type AnyClaimInfo, type Beacon, type BeaconState, ClaimCreationType, type ClaimID, type ClaimInfo, type CompleteClaimData, type Context, type CreateVerificationRequest, DeviceType, type ExtensionMessage, type HttpFormEntry, type HttpRedirectionMethod, type HttpRedirectionOptions, type InitSessionResponse, type ModalOptions, type OnError, type OnSuccess, type Proof, type ProofPropertiesJSON, type ProofRequestOptions, type ProviderClaimData, RECLAIM_EXTENSION_ACTIONS, type ReclaimFlowLaunchOptions, ReclaimProofRequest, type SerializableModalOptions, SessionStatus, type SignedClaim, type StartSessionParams, type StatusUrlResponse, type TemplateData, type UpdateSessionResponse, type WitnessData, clearDeviceCache, getDeviceType, getMobileDeviceType, isDesktopDevice, isMobileDevice, transformForOnchain, verifyProof };
package/dist/index.js CHANGED
@@ -72,7 +72,7 @@ var require_package = __commonJS({
72
72
  "package.json"(exports2, module2) {
73
73
  module2.exports = {
74
74
  name: "@reclaimprotocol/js-sdk",
75
- version: "4.10.1",
75
+ version: "4.11.0",
76
76
  description: "Designed to request proofs from the Reclaim protocol and manage the flow of claims and witness interactions.",
77
77
  main: "dist/index.js",
78
78
  types: "dist/index.d.ts",
@@ -179,6 +179,7 @@ __export(index_exports, {
179
179
  DeviceType: () => DeviceType,
180
180
  RECLAIM_EXTENSION_ACTIONS: () => RECLAIM_EXTENSION_ACTIONS,
181
181
  ReclaimProofRequest: () => ReclaimProofRequest,
182
+ SessionStatus: () => SessionStatus,
182
183
  clearDeviceCache: () => clearDeviceCache,
183
184
  getDeviceType: () => getDeviceType,
184
185
  getMobileDeviceType: () => getMobileDeviceType,
@@ -280,6 +281,22 @@ var DeviceType = /* @__PURE__ */ ((DeviceType2) => {
280
281
  DeviceType2["MOBILE"] = "mobile";
281
282
  return DeviceType2;
282
283
  })(DeviceType || {});
284
+ var SessionStatus = /* @__PURE__ */ ((SessionStatus2) => {
285
+ SessionStatus2["SESSION_INIT"] = "SESSION_INIT";
286
+ SessionStatus2["SESSION_STARTED"] = "SESSION_STARTED";
287
+ SessionStatus2["USER_INIT_VERIFICATION"] = "USER_INIT_VERIFICATION";
288
+ SessionStatus2["USER_STARTED_VERIFICATION"] = "USER_STARTED_VERIFICATION";
289
+ SessionStatus2["PROOF_GENERATION_STARTED"] = "PROOF_GENERATION_STARTED";
290
+ SessionStatus2["PROOF_GENERATION_SUCCESS"] = "PROOF_GENERATION_SUCCESS";
291
+ SessionStatus2["PROOF_GENERATION_FAILED"] = "PROOF_GENERATION_FAILED";
292
+ SessionStatus2["PROOF_SUBMITTED"] = "PROOF_SUBMITTED";
293
+ SessionStatus2["AI_PROOF_SUBMITTED"] = "AI_PROOF_SUBMITTED";
294
+ SessionStatus2["PROOF_SUBMISSION_FAILED"] = "PROOF_SUBMISSION_FAILED";
295
+ SessionStatus2["ERROR_SUBMITTED"] = "ERROR_SUBMITTED";
296
+ SessionStatus2["ERROR_SUBMISSION_FAILED"] = "ERROR_SUBMISSION_FAILED";
297
+ SessionStatus2["PROOF_MANUAL_VERIFICATION_SUBMITED"] = "PROOF_MANUAL_VERIFICATION_SUBMITED";
298
+ return SessionStatus2;
299
+ })(SessionStatus || {});
283
300
 
284
301
  // src/Reclaim.ts
285
302
  var import_ethers6 = require("ethers");
@@ -474,6 +491,41 @@ function validateURL(url, functionName) {
474
491
  throw new InvalidParamError(`Invalid URL format ${url} passed to ${functionName}.`, e);
475
492
  }
476
493
  }
494
+ function validateRedirectionMethod(method, functionName) {
495
+ try {
496
+ if (method === null || method === void 0) {
497
+ return;
498
+ }
499
+ if (method !== "GET" && method !== "POST") {
500
+ throw new Error(`Invalid redirection method ${method} passed to ${functionName}.`);
501
+ }
502
+ } catch (e) {
503
+ logger3.info(`Redirection method validation failed for ${method} in ${functionName}: ${e.message}`);
504
+ throw new InvalidParamError(`Invalid redirection method ${method} passed to ${functionName}.`, e);
505
+ }
506
+ }
507
+ function validateRedirectionBody(records, functionName) {
508
+ try {
509
+ if (records === null || records === void 0) {
510
+ return;
511
+ }
512
+ if (Array.isArray(records)) {
513
+ for (const record of records) {
514
+ if ("name" in record && record.name && typeof record.name === "string") {
515
+ if ("value" in record && typeof record.value === "string") {
516
+ continue;
517
+ }
518
+ }
519
+ throw new Error("Record in form entries do not have a valid name and/or value");
520
+ }
521
+ } else {
522
+ throw new Error("Redirection body must be an array of objects with name, and value");
523
+ }
524
+ } catch (e) {
525
+ logger3.info(`Redirection body validation failed for ${records} in ${functionName}: ${e.message}`);
526
+ throw new InvalidParamError(`Invalid redirection body ${records} passed to ${functionName}.`, e);
527
+ }
528
+ }
477
529
  function validateSignature(providerId, signature, applicationId, timestamp) {
478
530
  try {
479
531
  logger3.info(`Starting signature validation for providerId: ${providerId}, applicationId: ${applicationId}, timestamp: ${timestamp}`);
@@ -1885,8 +1937,10 @@ var emptyTemplateData = {
1885
1937
  context: "",
1886
1938
  parameters: {},
1887
1939
  redirectUrl: "",
1940
+ redirectUrlOptions: { method: "GET" },
1888
1941
  cancelCallbackUrl: "",
1889
1942
  cancelRedirectUrl: "",
1943
+ cancelRedirectUrlOptions: { method: "GET" },
1890
1944
  acceptAiProviders: false,
1891
1945
  sdkVersion: "",
1892
1946
  providerVersion: "",
@@ -1925,8 +1979,10 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
1925
1979
  resolvedProviderVersion: (_c = this.resolvedProviderVersion) != null ? _c : "",
1926
1980
  parameters: this.parameters,
1927
1981
  redirectUrl: (_d = this.redirectUrl) != null ? _d : "",
1982
+ redirectUrlOptions: this.redirectUrlOptions,
1928
1983
  cancelCallbackUrl: this.getCancelCallbackUrl(),
1929
1984
  cancelRedirectUrl: this.cancelRedirectUrl,
1985
+ cancelRedirectUrlOptions: this.cancelRedirectUrlOptions,
1930
1986
  acceptAiProviders: (_f = (_e = this.options) == null ? void 0 : _e.acceptAiProviders) != null ? _f : false,
1931
1987
  sdkVersion: this.sdkVersion,
1932
1988
  jsonProofResponse: this.jsonProofResponse,
@@ -2112,8 +2168,10 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
2112
2168
  parameters,
2113
2169
  signature,
2114
2170
  redirectUrl,
2171
+ redirectUrlOptions,
2115
2172
  cancelCallbackUrl,
2116
2173
  cancelRedirectUrl,
2174
+ cancelRedirectUrlOptions,
2117
2175
  timeStamp,
2118
2176
  timestamp,
2119
2177
  appCallbackUrl,
@@ -2139,12 +2197,20 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
2139
2197
  if (redirectUrl) {
2140
2198
  validateURL(redirectUrl, "fromJsonString");
2141
2199
  }
2200
+ if (redirectUrlOptions) {
2201
+ validateRedirectionMethod(redirectUrlOptions.method, "fromJsonString");
2202
+ validateRedirectionBody(redirectUrlOptions.body, "fromJsonString");
2203
+ }
2142
2204
  if (appCallbackUrl) {
2143
2205
  validateURL(appCallbackUrl, "fromJsonString");
2144
2206
  }
2145
2207
  if (cancelRedirectUrl) {
2146
2208
  validateURL(cancelRedirectUrl, "fromJsonString");
2147
2209
  }
2210
+ if (cancelRedirectUrlOptions) {
2211
+ validateRedirectionMethod(cancelRedirectUrlOptions.method, "fromJsonString");
2212
+ validateRedirectionBody(cancelRedirectUrlOptions.body, "fromJsonString");
2213
+ }
2148
2214
  if (cancelCallbackUrl) {
2149
2215
  validateURL(cancelCallbackUrl, "fromJsonString");
2150
2216
  }
@@ -2198,6 +2264,7 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
2198
2264
  proofRequestInstance.parameters = parameters;
2199
2265
  proofRequestInstance.appCallbackUrl = appCallbackUrl;
2200
2266
  proofRequestInstance.redirectUrl = redirectUrl;
2267
+ proofRequestInstance.redirectUrlOptions = redirectUrlOptions;
2201
2268
  proofRequestInstance.timeStamp = resolvedTimestamp;
2202
2269
  proofRequestInstance.signature = signature;
2203
2270
  proofRequestInstance.sdkVersion = sdkVersion2;
@@ -2206,6 +2273,7 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
2206
2273
  proofRequestInstance.jsonProofResponse = jsonProofResponse != null ? jsonProofResponse : false;
2207
2274
  proofRequestInstance.cancelCallbackUrl = cancelCallbackUrl;
2208
2275
  proofRequestInstance.cancelRedirectUrl = cancelRedirectUrl;
2276
+ proofRequestInstance.cancelRedirectUrlOptions = cancelRedirectUrlOptions;
2209
2277
  return proofRequestInstance;
2210
2278
  } catch (error) {
2211
2279
  logger7.info("Failed to parse JSON string in fromJsonString:", error);
@@ -2222,7 +2290,10 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
2222
2290
  * When a custom callback URL is set, proofs are sent to the custom URL *instead* of the Reclaim backend.
2223
2291
  * Consequently, the startSession `onSuccess` callback will be invoked with an empty array (`[]`)
2224
2292
  * instead of the proof data, as the proof is not available to the SDK in this flow.
2225
- *
2293
+ *
2294
+ * This verification session's id will be present in `X-Reclaim-Session-Id` header of the request.
2295
+ * The request URL will contain query param `allowAiWitness` with value `true` when AI Witness should be allowed by handler of the request.
2296
+ *
2226
2297
  * Note: InApp SDKs are unaffected by this property as they do not handle proof submission.
2227
2298
  *
2228
2299
  * @param url - The URL where proofs should be submitted via HTTP `POST`
@@ -2245,6 +2316,13 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
2245
2316
  * Sets a redirect URL where users will be redirected after successfully acquiring and submitting proof
2246
2317
  *
2247
2318
  * @param url - The URL where users should be redirected after successful proof generation
2319
+ * @param method - The redirection method that should be used for redirection. Allowed options: `GET`, and `POST`.
2320
+ * `POST` form redirection is only supported in In-Browser SDK.
2321
+ * @param body - List of name-value pairs to be sent as the body of the form request.
2322
+ * `When `method` is set to `POST`, `body` will be sent with 'application/x-www-form-urlencoded' content type.
2323
+ * When `method` is set to `GET`, if `body` is set then `body` will be sent as query parameters.
2324
+ * Sending `body` on redirection is only supported in In-Browser SDK.
2325
+ *
2248
2326
  * @throws {InvalidParamError} When URL is invalid
2249
2327
  *
2250
2328
  * @example
@@ -2252,29 +2330,50 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
2252
2330
  * proofRequest.setRedirectUrl('https://your-app.com/success');
2253
2331
  * ```
2254
2332
  */
2255
- setRedirectUrl(url) {
2333
+ setRedirectUrl(url, method = "GET", body) {
2256
2334
  validateURL(url, "setRedirectUrl");
2335
+ validateRedirectionMethod(method, "setRedirectUrl");
2336
+ validateRedirectionBody(body, "setRedirectUrl");
2257
2337
  this.redirectUrl = url;
2338
+ this.redirectUrlOptions = { method: method || "GET", body };
2258
2339
  }
2259
2340
  /**
2260
- * Sets a custom callback URL where errors that abort the verification process will be submitted via HTTP POST
2261
- *
2262
- * Errors will be HTTP POSTed with `header 'Content-Type': 'application/json'`.
2263
- * When a custom error callback URL is set, Reclaim will no longer receive errors upon submission,
2264
- * and listeners on the startSession method will not be triggered. Your application must
2265
- * coordinate with your backend to receive errors.
2266
- *
2267
- * @param url - The URL where errors should be submitted via HTTP POST
2268
- * @throws {InvalidParamError} When URL is invalid
2269
- *
2270
- * @example
2271
- * ```typescript
2272
- * proofRequest.setCancelCallbackUrl('https://your-backend.com/error-callback');
2273
- * ```
2274
- *
2275
- * @since 4.8.1
2276
- *
2277
- */
2341
+ * Sets a custom callback URL where errors that abort the verification process will be submitted via HTTP POST
2342
+ *
2343
+ * Errors will be HTTP POSTed with `header 'Content-Type': 'application/json'`.
2344
+ * When a custom error callback URL is set, Reclaim will no longer receive errors upon submission,
2345
+ * and listeners on the startSession method will not be triggered. Your application must
2346
+ * coordinate with your backend to receive errors.
2347
+ *
2348
+ * This verification session's id will be present in `X-Reclaim-Session-Id` header of the request.
2349
+ *
2350
+ * Following is the data format which is sent as an HTTP POST request to the url with `Content-Type: application/json`:
2351
+
2352
+ * ```json
2353
+ * {
2354
+ * "type": "string", // Name of the exception
2355
+ * "message": "string",
2356
+ * "sessionId": "string",
2357
+ * // context as canonicalized json string
2358
+ * "context": "string",
2359
+ * // Other fields with more details about error may be present
2360
+ * // [key: any]: any
2361
+ * }
2362
+ * ```
2363
+ *
2364
+ * For more details about response format, check out [official documentation of Error Callback URL](https://docs.reclaimprotocol.org/js-sdk/preparing-request#cancel-callback).
2365
+ *
2366
+ * @param url - The URL where errors should be submitted via HTTP POST
2367
+ * @throws {InvalidParamError} When URL is invalid
2368
+ *
2369
+ * @example
2370
+ * ```typescript
2371
+ * proofRequest.setCancelCallbackUrl('https://your-backend.com/error-callback');
2372
+ * ```
2373
+ *
2374
+ * @since 4.8.1
2375
+ *
2376
+ */
2278
2377
  setCancelCallbackUrl(url) {
2279
2378
  validateURL(url, "setCancelCallbackUrl");
2280
2379
  this.cancelCallbackUrl = url;
@@ -2283,6 +2382,12 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
2283
2382
  * Sets an error redirect URL where users will be redirected after an error which aborts the verification process
2284
2383
  *
2285
2384
  * @param url - The URL where users should be redirected after an error which aborts the verification process
2385
+ * @param method - The redirection method that should be used for redirection. Allowed options: `GET`, and `POST`.
2386
+ * `POST` form redirection is only supported in In-Browser SDK.
2387
+ * @param body - List of name-value pairs to be sent as the body of the form request.
2388
+ * When `method` is set to `POST`, `body` will be sent with 'application/x-www-form-urlencoded' content type.
2389
+ * When `method` is set to `GET`, if `body` is set then `body` will be sent as query parameters.
2390
+ * Sending `body` on redirection is only supported in In-Browser SDK.
2286
2391
  * @throws {InvalidParamError} When URL is invalid
2287
2392
  *
2288
2393
  * @example
@@ -2293,9 +2398,12 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
2293
2398
  * @since 4.10.0
2294
2399
  *
2295
2400
  */
2296
- setCancelRedirectUrl(url) {
2401
+ setCancelRedirectUrl(url, method = "GET", body) {
2297
2402
  validateURL(url, "setCancelRedirectUrl");
2403
+ validateRedirectionMethod(method, "setCancelRedirectUrl");
2404
+ validateRedirectionBody(body, "setCancelRedirectUrl");
2298
2405
  this.cancelRedirectUrl = url;
2406
+ this.cancelRedirectUrlOptions = { method: method || "GET", body };
2299
2407
  }
2300
2408
  /**
2301
2409
  * Sets the claim creation type for the proof request
@@ -2590,8 +2698,10 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
2590
2698
  parameters: this.parameters,
2591
2699
  signature: this.signature,
2592
2700
  redirectUrl: this.redirectUrl,
2701
+ redirectUrlOptions: this.redirectUrlOptions,
2593
2702
  cancelCallbackUrl: this.cancelCallbackUrl,
2594
2703
  cancelRedirectUrl: this.cancelRedirectUrl,
2704
+ cancelRedirectUrlOptions: this.cancelRedirectUrlOptions,
2595
2705
  timestamp: this.timeStamp,
2596
2706
  // New field with correct spelling
2597
2707
  timeStamp: this.timeStamp,
@@ -3029,6 +3139,7 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
3029
3139
  DeviceType,
3030
3140
  RECLAIM_EXTENSION_ACTIONS,
3031
3141
  ReclaimProofRequest,
3142
+ SessionStatus,
3032
3143
  clearDeviceCache,
3033
3144
  getDeviceType,
3034
3145
  getMobileDeviceType,