@reclaimprotocol/js-sdk 4.8.1 → 4.10.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 +35 -17
- package/dist/index.d.ts +39 -19
- package/dist/index.js +101 -38
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -308,32 +308,33 @@ The Reclaim SDK offers several advanced options to customize your integration:
|
|
|
308
308
|
```
|
|
309
309
|
|
|
310
310
|
3. **Custom Redirect URL**:
|
|
311
|
-
Set a custom URL to redirect users after the verification process:
|
|
312
311
|
|
|
313
|
-
|
|
314
|
-
reclaimProofRequest.setRedirectUrl("https://example.com/redirect");
|
|
315
|
-
```
|
|
312
|
+
Set a custom URL to redirect users after the verification process:
|
|
316
313
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
314
|
+
```javascript
|
|
315
|
+
reclaimProofRequest.setRedirectUrl("https://example.com/redirect");
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
4. **Custom Cancel Redirect URL**:
|
|
319
|
+
Set a custom URL to redirect users on a cancellation which aborts the verification process:
|
|
320
|
+
|
|
321
|
+
```javascript
|
|
322
|
+
reclaimProofRequest.setCancelRedirectUrl("https://example.com/error-redirect");
|
|
323
|
+
```
|
|
322
324
|
|
|
323
325
|
5. **Custom Callback URL**:
|
|
324
326
|
Set a custom callback URL for your app which allows you to receive proofs and status updates on your callback URL:
|
|
325
327
|
Pass in `jsonProofResponse: true` to receive the proof in JSON format: By default, the proof is returned as a url encoded string.
|
|
326
328
|
|
|
327
|
-
```javascript
|
|
328
329
|
reclaimProofRequest.setAppCallbackUrl("https://example.com/callback", true);
|
|
329
330
|
```
|
|
330
331
|
|
|
331
332
|
6. **Custom Error Callback URL**:
|
|
332
|
-
Set a custom
|
|
333
|
+
Set a custom cancel callback URL for your app which allows you to receive user or provider initiated cancellation on your callback URL:
|
|
333
334
|
|
|
334
335
|
```javascript
|
|
335
|
-
reclaimProofRequest.
|
|
336
|
-
|
|
336
|
+
reclaimProofRequest.setCancelCallbackUrl("https://example.com/error-callback");
|
|
337
|
+
|
|
337
338
|
|
|
338
339
|
7. **Modal Customization for Desktop Users**:
|
|
339
340
|
Customize the appearance and behavior of the QR code modal shown to desktop users:
|
|
@@ -442,21 +443,38 @@ const proofRequest = await ReclaimProofRequest.init(APP_ID, APP_SECRET, PROVIDER
|
|
|
442
443
|
});
|
|
443
444
|
```
|
|
444
445
|
|
|
446
|
+
15. Set preferred locale for verification client:
|
|
447
|
+
|
|
448
|
+
An identifier used to select a user's language and formatting preferences.
|
|
449
|
+
|
|
450
|
+
This represents a Unicode Language Identifier (i.e. without Locale extensions), except variants are not supported.
|
|
451
|
+
Locales are expected to be canonicalized according to the "preferred value" entries in the [IANA Language Subtag Registry](https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry).
|
|
452
|
+
For example, `he`, and `iw` are equal and both have the languageCode `he`, because `iw` is a deprecated language subtag that was replaced by the subtag `he`.
|
|
453
|
+
|
|
454
|
+
Defaults to the browser's locale if available, otherwise English (en).
|
|
455
|
+
|
|
456
|
+
```js
|
|
457
|
+
// Initialize with options
|
|
458
|
+
const proofRequest = await ReclaimProofRequest.init(APP_ID, APP_SECRET, PROVIDER_ID, {
|
|
459
|
+
preferredLocale: 'en-US',
|
|
460
|
+
});
|
|
461
|
+
```
|
|
462
|
+
|
|
445
463
|
## Handling Proofs on Your Backend
|
|
446
464
|
|
|
447
|
-
For production applications, it's recommended to handle proofs, and
|
|
465
|
+
For production applications, it's recommended to handle proofs, and cancellations on your backend:
|
|
448
466
|
|
|
449
467
|
1. Set a callback URL:
|
|
450
468
|
```javascript
|
|
451
469
|
reclaimProofRequest.setAppCallbackUrl("https://your-backend.com/receive-proofs");
|
|
452
470
|
```
|
|
453
471
|
|
|
454
|
-
2. Set a
|
|
472
|
+
2. Set a cancel callback URL:
|
|
455
473
|
```javascript
|
|
456
|
-
reclaimProofRequest.
|
|
474
|
+
reclaimProofRequest.setCancelCallbackUrl("https://your-backend.com/receive-cancel");
|
|
457
475
|
```
|
|
458
476
|
|
|
459
|
-
These options allow you to securely process proofs
|
|
477
|
+
These options allow you to securely process proofs or cancellations on your server.
|
|
460
478
|
|
|
461
479
|
## Proof Verification
|
|
462
480
|
|
package/dist/index.d.ts
CHANGED
|
@@ -82,8 +82,21 @@ type ProofRequestOptions = {
|
|
|
82
82
|
*/
|
|
83
83
|
canAutoSubmit?: boolean;
|
|
84
84
|
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
85
|
+
* An identifier used to select a user's language and formatting preferences.
|
|
86
|
+
*
|
|
87
|
+
* Locales are expected to be canonicalized according to the "preferred value" entries in the [IANA Language Subtag Registry](https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry).
|
|
88
|
+
* For example, `he`, and `iw` are equal and both have the languageCode `he`, because `iw` is a deprecated language subtag that was replaced by the subtag `he`.
|
|
89
|
+
*
|
|
90
|
+
* Defaults to the browser's locale if available, otherwise English (en).
|
|
91
|
+
*
|
|
92
|
+
* For more info, refer: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#description
|
|
93
|
+
*
|
|
94
|
+
* @since 4.9.0
|
|
95
|
+
*/
|
|
96
|
+
preferredLocale?: string;
|
|
97
|
+
/**
|
|
98
|
+
* Additional metadata to pass to the verification client frontend.
|
|
99
|
+
* This can be used to customize the client UI experience, such as customizing themes or UI by passing context-specific information.
|
|
87
100
|
* The keys and values must be strings. For most clients, this is not required and goes unused.
|
|
88
101
|
*
|
|
89
102
|
* This has no effect on the verification process.
|
|
@@ -145,8 +158,8 @@ type ProofPropertiesJSON = {
|
|
|
145
158
|
timeStamp?: string;
|
|
146
159
|
timestamp?: string;
|
|
147
160
|
appCallbackUrl?: string;
|
|
148
|
-
|
|
149
|
-
|
|
161
|
+
cancelCallbackUrl?: TemplateData['cancelCallbackUrl'];
|
|
162
|
+
cancelRedirectUrl?: TemplateData['cancelRedirectUrl'];
|
|
150
163
|
claimCreationType?: ClaimCreationType;
|
|
151
164
|
options?: ProofRequestOptions;
|
|
152
165
|
sdkVersion: string;
|
|
@@ -166,8 +179,8 @@ type TemplateData = {
|
|
|
166
179
|
[key: string]: string;
|
|
167
180
|
};
|
|
168
181
|
redirectUrl: string;
|
|
169
|
-
|
|
170
|
-
|
|
182
|
+
cancelCallbackUrl?: string | null;
|
|
183
|
+
cancelRedirectUrl?: string | null;
|
|
171
184
|
acceptAiProviders: boolean;
|
|
172
185
|
sdkVersion: string;
|
|
173
186
|
jsonProofResponse?: boolean;
|
|
@@ -176,6 +189,7 @@ type TemplateData = {
|
|
|
176
189
|
log?: boolean;
|
|
177
190
|
canAutoSubmit?: boolean;
|
|
178
191
|
metadata?: Record<string, string>;
|
|
192
|
+
preferredLocale?: ProofRequestOptions['preferredLocale'];
|
|
179
193
|
};
|
|
180
194
|
|
|
181
195
|
/**
|
|
@@ -223,8 +237,8 @@ declare class ReclaimProofRequest {
|
|
|
223
237
|
private resolvedProviderVersion?;
|
|
224
238
|
private parameters;
|
|
225
239
|
private redirectUrl?;
|
|
226
|
-
private
|
|
227
|
-
private
|
|
240
|
+
private cancelCallbackUrl?;
|
|
241
|
+
private cancelRedirectUrl?;
|
|
228
242
|
private intervals;
|
|
229
243
|
private timeStamp;
|
|
230
244
|
private sdkVersion;
|
|
@@ -324,10 +338,13 @@ declare class ReclaimProofRequest {
|
|
|
324
338
|
*
|
|
325
339
|
* @example
|
|
326
340
|
* ```typescript
|
|
327
|
-
* proofRequest.
|
|
341
|
+
* proofRequest.setCancelCallbackUrl('https://your-backend.com/error-callback');
|
|
328
342
|
* ```
|
|
343
|
+
*
|
|
344
|
+
* @since 4.8.1
|
|
345
|
+
*
|
|
329
346
|
*/
|
|
330
|
-
|
|
347
|
+
setCancelCallbackUrl(url: string): void;
|
|
331
348
|
/**
|
|
332
349
|
* Sets an error redirect URL where users will be redirected after an error which aborts the verification process
|
|
333
350
|
*
|
|
@@ -336,10 +353,13 @@ declare class ReclaimProofRequest {
|
|
|
336
353
|
*
|
|
337
354
|
* @example
|
|
338
355
|
* ```typescript
|
|
339
|
-
* proofRequest.
|
|
356
|
+
* proofRequest.setCancelRedirectUrl('https://your-app.com/error');
|
|
340
357
|
* ```
|
|
358
|
+
*
|
|
359
|
+
* @since 4.10.0
|
|
360
|
+
*
|
|
341
361
|
*/
|
|
342
|
-
|
|
362
|
+
setCancelRedirectUrl(url: string): void;
|
|
343
363
|
/**
|
|
344
364
|
* Sets the claim creation type for the proof request
|
|
345
365
|
*
|
|
@@ -444,21 +464,21 @@ declare class ReclaimProofRequest {
|
|
|
444
464
|
*/
|
|
445
465
|
getAppCallbackUrl(): string;
|
|
446
466
|
/**
|
|
447
|
-
* Returns the currently configured
|
|
467
|
+
* Returns the currently configured cancel callback URL
|
|
448
468
|
*
|
|
449
|
-
* If no custom
|
|
450
|
-
* Reclaim service
|
|
469
|
+
* If no custom cancel callback URL was set via setCancelCallbackUrl(), this returns the default
|
|
470
|
+
* Reclaim service cancel callback URL with the current session ID.
|
|
451
471
|
*
|
|
452
|
-
* @returns The
|
|
453
|
-
* @throws {GetAppCallbackUrlError} When unable to retrieve the
|
|
472
|
+
* @returns The cancel callback URL where proofs will be submitted
|
|
473
|
+
* @throws {GetAppCallbackUrlError} When unable to retrieve the cancel callback URL
|
|
454
474
|
*
|
|
455
475
|
* @example
|
|
456
476
|
* ```typescript
|
|
457
|
-
* const callbackUrl = proofRequest.
|
|
477
|
+
* const callbackUrl = proofRequest.getCancelCallbackUrl();
|
|
458
478
|
* console.log('Errors will be sent to:', callbackUrl);
|
|
459
479
|
* ```
|
|
460
480
|
*/
|
|
461
|
-
|
|
481
|
+
getCancelCallbackUrl(): string;
|
|
462
482
|
/**
|
|
463
483
|
* Returns the status URL for monitoring the current session
|
|
464
484
|
*
|
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.
|
|
75
|
+
version: "4.10.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",
|
|
@@ -104,6 +104,7 @@ var require_package = __commonJS({
|
|
|
104
104
|
},
|
|
105
105
|
scripts: {
|
|
106
106
|
build: "sh scripts/build.sh",
|
|
107
|
+
prepare: "npm run build",
|
|
107
108
|
release: "release-it",
|
|
108
109
|
test: "jest",
|
|
109
110
|
"test:watch": "jest --watch",
|
|
@@ -407,7 +408,7 @@ var constants = {
|
|
|
407
408
|
return `${BACKEND_BASE_URL}/api/sdk/callback?callbackId=`;
|
|
408
409
|
},
|
|
409
410
|
// Default error callback URL for Reclaim protocol
|
|
410
|
-
get
|
|
411
|
+
get DEFAULT_RECLAIM_CANCEL_CALLBACK_URL() {
|
|
411
412
|
return `${BACKEND_BASE_URL}/api/sdk/error-callback?callbackId=`;
|
|
412
413
|
},
|
|
413
414
|
// Default status URL for Reclaim sessions
|
|
@@ -442,6 +443,12 @@ function validateFunctionParams(params, functionName) {
|
|
|
442
443
|
}
|
|
443
444
|
});
|
|
444
445
|
}
|
|
446
|
+
function validateFunctionParamsWithFn(param, functionName) {
|
|
447
|
+
if (!param.isValid()) {
|
|
448
|
+
logger3.info(`Validation failed: ${param.paramName} in ${functionName} is not valid`);
|
|
449
|
+
throw new InvalidParamError(`${param.paramName} passed to ${functionName} must be valid.`);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
445
452
|
function validateParameters(parameters) {
|
|
446
453
|
try {
|
|
447
454
|
if (typeof parameters !== "object" || parameters === null) {
|
|
@@ -494,6 +501,18 @@ function validateSignature(providerId, signature, applicationId, timestamp) {
|
|
|
494
501
|
}
|
|
495
502
|
}
|
|
496
503
|
function validateContext(context) {
|
|
504
|
+
if (context && !("contextAddress" in context)) {
|
|
505
|
+
try {
|
|
506
|
+
validateFunctionParams([
|
|
507
|
+
{ input: context, paramName: "context", isString: false }
|
|
508
|
+
], "validateContext");
|
|
509
|
+
JSON.parse(canonicalStringify(context));
|
|
510
|
+
return;
|
|
511
|
+
} catch (e) {
|
|
512
|
+
logger3.info(`Context validation failed: Provided JSON serializable context is not valid`);
|
|
513
|
+
throw new InvalidParamError(`The provided context is not valid`);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
497
516
|
if (!context.contextAddress) {
|
|
498
517
|
logger3.info(`Context validation failed: Provided context address in context is not valid`);
|
|
499
518
|
throw new InvalidParamError(`The provided context address in context is not valid`);
|
|
@@ -1866,8 +1885,8 @@ var emptyTemplateData = {
|
|
|
1866
1885
|
context: "",
|
|
1867
1886
|
parameters: {},
|
|
1868
1887
|
redirectUrl: "",
|
|
1869
|
-
|
|
1870
|
-
|
|
1888
|
+
cancelCallbackUrl: "",
|
|
1889
|
+
cancelRedirectUrl: "",
|
|
1871
1890
|
acceptAiProviders: false,
|
|
1872
1891
|
sdkVersion: "",
|
|
1873
1892
|
providerVersion: "",
|
|
@@ -1889,7 +1908,7 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
|
|
|
1889
1908
|
* @returns
|
|
1890
1909
|
*/
|
|
1891
1910
|
this.getTemplateData = () => {
|
|
1892
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
1911
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
1893
1912
|
if (!this.signature) {
|
|
1894
1913
|
throw new SignatureNotFoundError("Signature is not set.");
|
|
1895
1914
|
}
|
|
@@ -1906,14 +1925,15 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
|
|
|
1906
1925
|
resolvedProviderVersion: (_c = this.resolvedProviderVersion) != null ? _c : "",
|
|
1907
1926
|
parameters: this.parameters,
|
|
1908
1927
|
redirectUrl: (_d = this.redirectUrl) != null ? _d : "",
|
|
1909
|
-
|
|
1910
|
-
|
|
1928
|
+
cancelCallbackUrl: this.getCancelCallbackUrl(),
|
|
1929
|
+
cancelRedirectUrl: this.cancelRedirectUrl,
|
|
1911
1930
|
acceptAiProviders: (_f = (_e = this.options) == null ? void 0 : _e.acceptAiProviders) != null ? _f : false,
|
|
1912
1931
|
sdkVersion: this.sdkVersion,
|
|
1913
1932
|
jsonProofResponse: this.jsonProofResponse,
|
|
1914
1933
|
log: (_h = (_g = this.options) == null ? void 0 : _g.log) != null ? _h : false,
|
|
1915
1934
|
canAutoSubmit: (_j = (_i = this.options) == null ? void 0 : _i.canAutoSubmit) != null ? _j : true,
|
|
1916
|
-
metadata: (_k = this.options) == null ? void 0 : _k.metadata
|
|
1935
|
+
metadata: (_k = this.options) == null ? void 0 : _k.metadata,
|
|
1936
|
+
preferredLocale: (_l = this.options) == null ? void 0 : _l.preferredLocale
|
|
1917
1937
|
};
|
|
1918
1938
|
return templateData;
|
|
1919
1939
|
};
|
|
@@ -2031,6 +2051,24 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
|
|
|
2031
2051
|
{ paramName: "customAppClipUrl", input: options.customAppClipUrl, isString: true }
|
|
2032
2052
|
], "the constructor");
|
|
2033
2053
|
}
|
|
2054
|
+
if (options.preferredLocale) {
|
|
2055
|
+
validateFunctionParams([
|
|
2056
|
+
{ paramName: "preferredLocale", input: options.preferredLocale, isString: true }
|
|
2057
|
+
], "the constructor");
|
|
2058
|
+
validateFunctionParamsWithFn({
|
|
2059
|
+
paramName: "preferredLocale",
|
|
2060
|
+
input: options.preferredLocale,
|
|
2061
|
+
isValid: () => {
|
|
2062
|
+
try {
|
|
2063
|
+
Intl.getCanonicalLocales(options.preferredLocale);
|
|
2064
|
+
return true;
|
|
2065
|
+
} catch (error) {
|
|
2066
|
+
logger7.info("Failed to canonicalize locale", error);
|
|
2067
|
+
return false;
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2070
|
+
}, "the constructor");
|
|
2071
|
+
}
|
|
2034
2072
|
}
|
|
2035
2073
|
const proofRequestInstance = new _ReclaimProofRequest(applicationId, providerId, options);
|
|
2036
2074
|
const signature = yield proofRequestInstance.generateSignature(appSecret);
|
|
@@ -2040,6 +2078,7 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
|
|
|
2040
2078
|
proofRequestInstance.resolvedProviderVersion = data.resolvedProviderVersion;
|
|
2041
2079
|
return proofRequestInstance;
|
|
2042
2080
|
} catch (error) {
|
|
2081
|
+
console.error(error);
|
|
2043
2082
|
logger7.info("Failed to initialize ReclaimProofRequest", error);
|
|
2044
2083
|
throw new InitError("Failed to initialize ReclaimProofRequest", error);
|
|
2045
2084
|
}
|
|
@@ -2073,8 +2112,8 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
|
|
|
2073
2112
|
parameters,
|
|
2074
2113
|
signature,
|
|
2075
2114
|
redirectUrl,
|
|
2076
|
-
|
|
2077
|
-
|
|
2115
|
+
cancelCallbackUrl,
|
|
2116
|
+
cancelRedirectUrl,
|
|
2078
2117
|
timeStamp,
|
|
2079
2118
|
timestamp,
|
|
2080
2119
|
appCallbackUrl,
|
|
@@ -2103,11 +2142,11 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
|
|
|
2103
2142
|
if (appCallbackUrl) {
|
|
2104
2143
|
validateURL(appCallbackUrl, "fromJsonString");
|
|
2105
2144
|
}
|
|
2106
|
-
if (
|
|
2107
|
-
validateURL(
|
|
2145
|
+
if (cancelRedirectUrl) {
|
|
2146
|
+
validateURL(cancelRedirectUrl, "fromJsonString");
|
|
2108
2147
|
}
|
|
2109
|
-
if (
|
|
2110
|
-
validateURL(
|
|
2148
|
+
if (cancelCallbackUrl) {
|
|
2149
|
+
validateURL(cancelCallbackUrl, "fromJsonString");
|
|
2111
2150
|
}
|
|
2112
2151
|
if (context) {
|
|
2113
2152
|
validateContext(context);
|
|
@@ -2127,7 +2166,7 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
|
|
|
2127
2166
|
}
|
|
2128
2167
|
if (options == null ? void 0 : options.providerVersion) {
|
|
2129
2168
|
validateFunctionParams([
|
|
2130
|
-
{ input: options.providerVersion, paramName: "providerVersion", isString: true }
|
|
2169
|
+
{ input: options.providerVersion, paramName: "options.providerVersion", isString: true }
|
|
2131
2170
|
], "fromJsonString");
|
|
2132
2171
|
}
|
|
2133
2172
|
if (resolvedProviderVersion) {
|
|
@@ -2135,6 +2174,24 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
|
|
|
2135
2174
|
{ input: resolvedProviderVersion, paramName: "resolvedProviderVersion", isString: true }
|
|
2136
2175
|
], "fromJsonString");
|
|
2137
2176
|
}
|
|
2177
|
+
if (options == null ? void 0 : options.preferredLocale) {
|
|
2178
|
+
validateFunctionParams([
|
|
2179
|
+
{ paramName: "options.preferredLocale", input: options.preferredLocale, isString: true }
|
|
2180
|
+
], "fromJsonString");
|
|
2181
|
+
validateFunctionParamsWithFn({
|
|
2182
|
+
paramName: "options.preferredLocale",
|
|
2183
|
+
input: options.preferredLocale,
|
|
2184
|
+
isValid: () => {
|
|
2185
|
+
try {
|
|
2186
|
+
Intl.getCanonicalLocales(options.preferredLocale);
|
|
2187
|
+
return true;
|
|
2188
|
+
} catch (error) {
|
|
2189
|
+
logger7.info("Failed to canonicalize locale", error);
|
|
2190
|
+
return false;
|
|
2191
|
+
}
|
|
2192
|
+
}
|
|
2193
|
+
}, "fromJsonString");
|
|
2194
|
+
}
|
|
2138
2195
|
const proofRequestInstance = new _ReclaimProofRequest(applicationId, providerId, options);
|
|
2139
2196
|
proofRequestInstance.sessionId = sessionId;
|
|
2140
2197
|
proofRequestInstance.context = context;
|
|
@@ -2147,8 +2204,8 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
|
|
|
2147
2204
|
proofRequestInstance.resolvedProviderVersion = resolvedProviderVersion;
|
|
2148
2205
|
proofRequestInstance.modalOptions = modalOptions;
|
|
2149
2206
|
proofRequestInstance.jsonProofResponse = jsonProofResponse != null ? jsonProofResponse : false;
|
|
2150
|
-
proofRequestInstance.
|
|
2151
|
-
proofRequestInstance.
|
|
2207
|
+
proofRequestInstance.cancelCallbackUrl = cancelCallbackUrl;
|
|
2208
|
+
proofRequestInstance.cancelRedirectUrl = cancelRedirectUrl;
|
|
2152
2209
|
return proofRequestInstance;
|
|
2153
2210
|
} catch (error) {
|
|
2154
2211
|
logger7.info("Failed to parse JSON string in fromJsonString:", error);
|
|
@@ -2210,12 +2267,15 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
|
|
|
2210
2267
|
*
|
|
2211
2268
|
* @example
|
|
2212
2269
|
* ```typescript
|
|
2213
|
-
* proofRequest.
|
|
2270
|
+
* proofRequest.setCancelCallbackUrl('https://your-backend.com/error-callback');
|
|
2214
2271
|
* ```
|
|
2272
|
+
*
|
|
2273
|
+
* @since 4.8.1
|
|
2274
|
+
*
|
|
2215
2275
|
*/
|
|
2216
|
-
|
|
2217
|
-
validateURL(url, "
|
|
2218
|
-
this.
|
|
2276
|
+
setCancelCallbackUrl(url) {
|
|
2277
|
+
validateURL(url, "setCancelCallbackUrl");
|
|
2278
|
+
this.cancelCallbackUrl = url;
|
|
2219
2279
|
}
|
|
2220
2280
|
/**
|
|
2221
2281
|
* Sets an error redirect URL where users will be redirected after an error which aborts the verification process
|
|
@@ -2225,12 +2285,15 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
|
|
|
2225
2285
|
*
|
|
2226
2286
|
* @example
|
|
2227
2287
|
* ```typescript
|
|
2228
|
-
* proofRequest.
|
|
2288
|
+
* proofRequest.setCancelRedirectUrl('https://your-app.com/error');
|
|
2229
2289
|
* ```
|
|
2290
|
+
*
|
|
2291
|
+
* @since 4.10.0
|
|
2292
|
+
*
|
|
2230
2293
|
*/
|
|
2231
|
-
|
|
2232
|
-
validateURL(url, "
|
|
2233
|
-
this.
|
|
2294
|
+
setCancelRedirectUrl(url) {
|
|
2295
|
+
validateURL(url, "setCancelRedirectUrl");
|
|
2296
|
+
this.cancelRedirectUrl = url;
|
|
2234
2297
|
}
|
|
2235
2298
|
/**
|
|
2236
2299
|
* Sets the claim creation type for the proof request
|
|
@@ -2384,27 +2447,27 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
|
|
|
2384
2447
|
}
|
|
2385
2448
|
}
|
|
2386
2449
|
/**
|
|
2387
|
-
* Returns the currently configured
|
|
2450
|
+
* Returns the currently configured cancel callback URL
|
|
2388
2451
|
*
|
|
2389
|
-
* If no custom
|
|
2390
|
-
* Reclaim service
|
|
2452
|
+
* If no custom cancel callback URL was set via setCancelCallbackUrl(), this returns the default
|
|
2453
|
+
* Reclaim service cancel callback URL with the current session ID.
|
|
2391
2454
|
*
|
|
2392
|
-
* @returns The
|
|
2393
|
-
* @throws {GetAppCallbackUrlError} When unable to retrieve the
|
|
2455
|
+
* @returns The cancel callback URL where proofs will be submitted
|
|
2456
|
+
* @throws {GetAppCallbackUrlError} When unable to retrieve the cancel callback URL
|
|
2394
2457
|
*
|
|
2395
2458
|
* @example
|
|
2396
2459
|
* ```typescript
|
|
2397
|
-
* const callbackUrl = proofRequest.
|
|
2460
|
+
* const callbackUrl = proofRequest.getCancelCallbackUrl();
|
|
2398
2461
|
* console.log('Errors will be sent to:', callbackUrl);
|
|
2399
2462
|
* ```
|
|
2400
2463
|
*/
|
|
2401
|
-
|
|
2464
|
+
getCancelCallbackUrl() {
|
|
2402
2465
|
try {
|
|
2403
|
-
validateFunctionParams([{ input: this.sessionId, paramName: "sessionId", isString: true }], "
|
|
2404
|
-
return this.
|
|
2466
|
+
validateFunctionParams([{ input: this.sessionId, paramName: "sessionId", isString: true }], "getCancelCallbackUrl");
|
|
2467
|
+
return this.cancelCallbackUrl || `${constants.DEFAULT_RECLAIM_CANCEL_CALLBACK_URL}${this.sessionId}`;
|
|
2405
2468
|
} catch (error) {
|
|
2406
|
-
logger7.info("Error getting
|
|
2407
|
-
throw new GetAppCallbackUrlError("Error getting
|
|
2469
|
+
logger7.info("Error getting cancel callback url", error);
|
|
2470
|
+
throw new GetAppCallbackUrlError("Error getting cancel callback url", error);
|
|
2408
2471
|
}
|
|
2409
2472
|
}
|
|
2410
2473
|
/**
|
|
@@ -2519,8 +2582,8 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
|
|
|
2519
2582
|
parameters: this.parameters,
|
|
2520
2583
|
signature: this.signature,
|
|
2521
2584
|
redirectUrl: this.redirectUrl,
|
|
2522
|
-
|
|
2523
|
-
|
|
2585
|
+
cancelCallbackUrl: this.cancelCallbackUrl,
|
|
2586
|
+
cancelRedirectUrl: this.cancelRedirectUrl,
|
|
2524
2587
|
timestamp: this.timeStamp,
|
|
2525
2588
|
// New field with correct spelling
|
|
2526
2589
|
timeStamp: this.timeStamp,
|