@reclaimprotocol/js-sdk 5.1.0-dev.1 → 5.1.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/dist/index.d.ts +1 -3
- package/dist/index.js +136 -154
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -791,8 +791,6 @@ type ProviderHashRequirementsResponse = {
|
|
|
791
791
|
* ```
|
|
792
792
|
*/
|
|
793
793
|
declare function verifyProof(proofOrProofs: Proof | Proof[], config: VerificationConfig): Promise<VerifyProofResult>;
|
|
794
|
-
declare function createTrustedDataFromProofData(proof: Proof): TrustedData;
|
|
795
|
-
declare function getPublicDataFromProofs(proofs: Proof[]): any[];
|
|
796
794
|
/**
|
|
797
795
|
* Transforms a Reclaim proof into a format suitable for on-chain verification
|
|
798
796
|
*
|
|
@@ -1518,4 +1516,4 @@ declare function isDesktopDevice(): boolean;
|
|
|
1518
1516
|
*/
|
|
1519
1517
|
declare function clearDeviceCache(): void;
|
|
1520
1518
|
|
|
1521
|
-
export { type Beacon, type BeaconState, type BodySniff, ClaimCreationType, type ClaimID, type ClaimInfo, type CompleteClaimData, type Context, type CreateVerificationRequest, DeviceType, type EmbeddedFlowHandle, type ExtensionMessage, type FlowHandle, type HashRequirement, type HashableHttpProviderClaimParams, type HttpFormEntry, type HttpProviderClaimParams, type HttpRedirectionMethod, type HttpRedirectionOptions, type InitSessionResponse, type InjectedRequestSpec, type InterceptorRequestSpec, type ModalOptions, type OnError, type OnSuccess, type Proof, type ProofPropertiesJSON, type ProofRequestOptions, type ProviderClaimData, type ProviderConfigResponse, type ProviderHashRequirementSpec, type ProviderHashRequirementsConfig, type ProviderHashRequirementsResponse, type ProviderVersionConfig, type ProviderVersionInfo, RECLAIM_EXTENSION_ACTIONS, type ReclaimFlowInitOptions, type ReclaimFlowLaunchOptions, ReclaimProofRequest, type ReclaimProviderConfig, type ReclaimProviderConfigWithRequestSpec, type RequestSpec, type ResponseMatchSpec, type ResponseRedactionSpec, type SerializableModalOptions, SessionStatus, type SignedClaim, type StartSessionParams, type StatusUrlResponse, type TeeAttestation, TeeVerificationError, type TemplateData, type TrustedData, type UpdateSessionResponse, type ValidationConfig, type ValidationConfigWithDisabledValidation, type ValidationConfigWithHash, type ValidationConfigWithProviderInformation, type VerificationConfig, type VerifyProofResult, type VerifyProofResultFailure, type VerifyProofResultSuccess, type WitnessData, assertValidProofsByHash, assertValidateProof, assertVerifiedProof, clearDeviceCache, createLinkWithTemplateData, createSignDataForClaim,
|
|
1519
|
+
export { type Beacon, type BeaconState, type BodySniff, ClaimCreationType, type ClaimID, type ClaimInfo, type CompleteClaimData, type Context, type CreateVerificationRequest, DeviceType, type EmbeddedFlowHandle, type ExtensionMessage, type FlowHandle, type HashRequirement, type HashableHttpProviderClaimParams, type HttpFormEntry, type HttpProviderClaimParams, type HttpRedirectionMethod, type HttpRedirectionOptions, type InitSessionResponse, type InjectedRequestSpec, type InterceptorRequestSpec, type ModalOptions, type OnError, type OnSuccess, type Proof, type ProofPropertiesJSON, type ProofRequestOptions, type ProviderClaimData, type ProviderConfigResponse, type ProviderHashRequirementSpec, type ProviderHashRequirementsConfig, type ProviderHashRequirementsResponse, type ProviderVersionConfig, type ProviderVersionInfo, RECLAIM_EXTENSION_ACTIONS, type ReclaimFlowInitOptions, type ReclaimFlowLaunchOptions, ReclaimProofRequest, type ReclaimProviderConfig, type ReclaimProviderConfigWithRequestSpec, type RequestSpec, type ResponseMatchSpec, type ResponseRedactionSpec, type SerializableModalOptions, SessionStatus, type SignedClaim, type StartSessionParams, type StatusUrlResponse, type TeeAttestation, TeeVerificationError, type TemplateData, type TrustedData, type UpdateSessionResponse, type ValidationConfig, type ValidationConfigWithDisabledValidation, type ValidationConfigWithHash, type ValidationConfigWithProviderInformation, type VerificationConfig, type VerifyProofResult, type VerifyProofResultFailure, type VerifyProofResultSuccess, type WitnessData, assertValidProofsByHash, assertValidateProof, assertVerifiedProof, clearDeviceCache, createLinkWithTemplateData, createSignDataForClaim, fetchProviderConfigs, fetchProviderHashRequirementsBy, fetchStatusUrl, generateSpecsFromRequestSpecTemplate, getAttestors, getDeviceType, getHttpProviderClaimParamsFromProof, getIdentifierFromClaimInfo, getMobileDeviceType, getProviderHashRequirementSpecFromProviderConfig, getProviderHashRequirementsFromSpec, getProviderParamsAsCanonicalizedString, getShortenedUrl, hashProofClaimParams, hashRequestSpec, initSession, isDesktopDevice, isHttpProviderClaimParams, isMobileDevice, recoverSignersOfSignedClaim, takePairsWhereValueIsArray, takeTemplateParametersFromProofs, transformForOnchain, updateSession, verifyProof, verifyTeeAttestation };
|
package/dist/index.js
CHANGED
|
@@ -84,7 +84,7 @@ var require_package = __commonJS({
|
|
|
84
84
|
"package.json"(exports2, module2) {
|
|
85
85
|
module2.exports = {
|
|
86
86
|
name: "@reclaimprotocol/js-sdk",
|
|
87
|
-
version: "5.1.0
|
|
87
|
+
version: "5.1.0",
|
|
88
88
|
description: "Designed to request proofs from the Reclaim protocol and manage the flow of claims and witness interactions.",
|
|
89
89
|
main: "dist/index.js",
|
|
90
90
|
types: "dist/index.d.ts",
|
|
@@ -200,7 +200,6 @@ __export(index_exports, {
|
|
|
200
200
|
clearDeviceCache: () => clearDeviceCache,
|
|
201
201
|
createLinkWithTemplateData: () => createLinkWithTemplateData,
|
|
202
202
|
createSignDataForClaim: () => createSignDataForClaim,
|
|
203
|
-
createTrustedDataFromProofData: () => createTrustedDataFromProofData,
|
|
204
203
|
fetchProviderConfigs: () => fetchProviderConfigs,
|
|
205
204
|
fetchProviderHashRequirementsBy: () => fetchProviderHashRequirementsBy,
|
|
206
205
|
fetchStatusUrl: () => fetchStatusUrl,
|
|
@@ -213,7 +212,6 @@ __export(index_exports, {
|
|
|
213
212
|
getProviderHashRequirementSpecFromProviderConfig: () => getProviderHashRequirementSpecFromProviderConfig,
|
|
214
213
|
getProviderHashRequirementsFromSpec: () => getProviderHashRequirementsFromSpec,
|
|
215
214
|
getProviderParamsAsCanonicalizedString: () => getProviderParamsAsCanonicalizedString,
|
|
216
|
-
getPublicDataFromProofs: () => getPublicDataFromProofs,
|
|
217
215
|
getShortenedUrl: () => getShortenedUrl,
|
|
218
216
|
hashProofClaimParams: () => hashProofClaimParams,
|
|
219
217
|
hashRequestSpec: () => hashRequestSpec,
|
|
@@ -340,62 +338,6 @@ var logger_default = {
|
|
|
340
338
|
setLogLevel
|
|
341
339
|
};
|
|
342
340
|
|
|
343
|
-
// src/utils/helper.ts
|
|
344
|
-
var logger2 = logger_default.logger;
|
|
345
|
-
function escapeRegExp(string) {
|
|
346
|
-
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
347
|
-
}
|
|
348
|
-
function replaceAll(str, find, replace) {
|
|
349
|
-
if (find === "") return str;
|
|
350
|
-
return str.replace(new RegExp(escapeRegExp(find), "g"), replace);
|
|
351
|
-
}
|
|
352
|
-
function scheduleIntervalEndingTask(sessionId, intervals, onFailureCallback, timeout = 1e3 * 60 * 10) {
|
|
353
|
-
setTimeout(() => {
|
|
354
|
-
if (intervals.has(sessionId)) {
|
|
355
|
-
const message = "Interval ended without receiving proofs";
|
|
356
|
-
onFailureCallback(new TimeoutError(message));
|
|
357
|
-
logger2.info(message);
|
|
358
|
-
clearInterval(intervals.get(sessionId));
|
|
359
|
-
intervals.delete(sessionId);
|
|
360
|
-
}
|
|
361
|
-
}, timeout);
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
// src/utils/constants.ts
|
|
365
|
-
var BACKEND_BASE_URL = "https://api.reclaimprotocol.org";
|
|
366
|
-
function setBackendBaseUrl(url) {
|
|
367
|
-
BACKEND_BASE_URL = url;
|
|
368
|
-
}
|
|
369
|
-
var constants = {
|
|
370
|
-
// Default callback URL for Reclaim protocol
|
|
371
|
-
get DEFAULT_RECLAIM_CALLBACK_URL() {
|
|
372
|
-
return `${BACKEND_BASE_URL}/api/sdk/callback?callbackId=`;
|
|
373
|
-
},
|
|
374
|
-
// Default error callback URL for Reclaim protocol
|
|
375
|
-
get DEFAULT_RECLAIM_CANCEL_CALLBACK_URL() {
|
|
376
|
-
return `${BACKEND_BASE_URL}/api/sdk/error-callback?callbackId=`;
|
|
377
|
-
},
|
|
378
|
-
// Default status URL for Reclaim sessions
|
|
379
|
-
get DEFAULT_RECLAIM_STATUS_URL() {
|
|
380
|
-
return `${BACKEND_BASE_URL}/api/sdk/session/`;
|
|
381
|
-
},
|
|
382
|
-
// Default attestors URL for Reclaim sessions
|
|
383
|
-
get DEFAULT_ATTESTORS_URL() {
|
|
384
|
-
return `${BACKEND_BASE_URL}/api/attestors`;
|
|
385
|
-
},
|
|
386
|
-
DEFAULT_PROVIDER_CONFIGS_URL(providerId, exactProviderVersionString, allowedTags) {
|
|
387
|
-
return `${BACKEND_BASE_URL}/api/providers/${providerId}/configs?versionNumber=${exactProviderVersionString || ""}&allowedTags=${(allowedTags == null ? void 0 : allowedTags.join(",")) || ""}`;
|
|
388
|
-
},
|
|
389
|
-
// Default portal URL
|
|
390
|
-
DEFAULT_PORTAL_URL: "https://portal.reclaimprotocol.org",
|
|
391
|
-
// Default sharepage URL
|
|
392
|
-
DEFAULT_APP_SHARE_PAGE_URL: "https://share.reclaimprotocol.org/verifier",
|
|
393
|
-
// URL for sharing Reclaim templates
|
|
394
|
-
RECLAIM_SHARE_URL: "https://share.reclaimprotocol.org/verifier/?template=",
|
|
395
|
-
// Chrome extension URL for Reclaim Protocol
|
|
396
|
-
CHROME_EXTENSION_URL: "https://chromewebstore.google.com/detail/reclaim-extension/oafieibbbcepkmenknelhmgaoahamdeh"
|
|
397
|
-
};
|
|
398
|
-
|
|
399
341
|
// src/utils/validationUtils.ts
|
|
400
342
|
var import_ethers = require("ethers");
|
|
401
343
|
var import_canonicalize2 = __toESM(require("canonicalize"));
|
|
@@ -410,43 +352,43 @@ function canonicalStringify(params) {
|
|
|
410
352
|
}
|
|
411
353
|
|
|
412
354
|
// src/utils/validationUtils.ts
|
|
413
|
-
var
|
|
355
|
+
var logger2 = logger_default.logger;
|
|
414
356
|
function validateFunctionParams(params, functionName) {
|
|
415
357
|
params.forEach(({ input, paramName, isString }) => {
|
|
416
358
|
if (input == null) {
|
|
417
|
-
|
|
359
|
+
logger2.info(`Validation failed: ${paramName} in ${functionName} is null or undefined`);
|
|
418
360
|
throw new InvalidParamError(`${paramName} passed to ${functionName} must not be null or undefined.`);
|
|
419
361
|
}
|
|
420
362
|
if (isString && typeof input !== "string") {
|
|
421
|
-
|
|
363
|
+
logger2.info(`Validation failed: ${paramName} in ${functionName} is not a string`);
|
|
422
364
|
throw new InvalidParamError(`${paramName} passed to ${functionName} must be a string.`);
|
|
423
365
|
}
|
|
424
366
|
if (isString && input.trim() === "") {
|
|
425
|
-
|
|
367
|
+
logger2.info(`Validation failed: ${paramName} in ${functionName} is an empty string`);
|
|
426
368
|
throw new InvalidParamError(`${paramName} passed to ${functionName} must not be an empty string.`);
|
|
427
369
|
}
|
|
428
370
|
});
|
|
429
371
|
}
|
|
430
372
|
function validateFunctionParamsWithFn(param, functionName) {
|
|
431
373
|
if (!param.isValid()) {
|
|
432
|
-
|
|
374
|
+
logger2.info(`Validation failed: ${param.paramName} in ${functionName} is not valid`);
|
|
433
375
|
throw new InvalidParamError(`${param.paramName} passed to ${functionName} must be valid.`);
|
|
434
376
|
}
|
|
435
377
|
}
|
|
436
378
|
function validateParameters(parameters) {
|
|
437
379
|
try {
|
|
438
380
|
if (typeof parameters !== "object" || parameters === null) {
|
|
439
|
-
|
|
381
|
+
logger2.info(`Parameters validation failed: Provided parameters is not an object`);
|
|
440
382
|
throw new InavlidParametersError(`The provided parameters is not an object`);
|
|
441
383
|
}
|
|
442
384
|
for (const [key, value] of Object.entries(parameters)) {
|
|
443
385
|
if (typeof key !== "string" || typeof value !== "string") {
|
|
444
|
-
|
|
386
|
+
logger2.info(`Parameters validation failed: Provided parameters is not an object of key value pairs of string and string`);
|
|
445
387
|
throw new InavlidParametersError(`The provided parameters is not an object of key value pairs of string and string`);
|
|
446
388
|
}
|
|
447
389
|
}
|
|
448
390
|
} catch (e) {
|
|
449
|
-
|
|
391
|
+
logger2.info(`Parameters validation failed: ${e.message}`);
|
|
450
392
|
throw new InavlidParametersError(`Invalid parameters passed to validateParameters.`, e);
|
|
451
393
|
}
|
|
452
394
|
}
|
|
@@ -454,7 +396,7 @@ function validateURL(url, functionName) {
|
|
|
454
396
|
try {
|
|
455
397
|
new URL(url);
|
|
456
398
|
} catch (e) {
|
|
457
|
-
|
|
399
|
+
logger2.info(`URL validation failed for ${url} in ${functionName}: ${e.message}`);
|
|
458
400
|
throw new InvalidParamError(`Invalid URL format ${url} passed to ${functionName}.`, e);
|
|
459
401
|
}
|
|
460
402
|
}
|
|
@@ -467,7 +409,7 @@ function validateRedirectionMethod(method, functionName) {
|
|
|
467
409
|
throw new Error(`Invalid redirection method ${method} passed to ${functionName}.`);
|
|
468
410
|
}
|
|
469
411
|
} catch (e) {
|
|
470
|
-
|
|
412
|
+
logger2.info(`Redirection method validation failed for ${method} in ${functionName}: ${e.message}`);
|
|
471
413
|
throw new InvalidParamError(`Invalid redirection method ${method} passed to ${functionName}.`, e);
|
|
472
414
|
}
|
|
473
415
|
}
|
|
@@ -489,16 +431,16 @@ function validateRedirectionBody(records, functionName) {
|
|
|
489
431
|
throw new Error("Redirection body must be an array of objects with name, and value");
|
|
490
432
|
}
|
|
491
433
|
} catch (e) {
|
|
492
|
-
|
|
434
|
+
logger2.info(`Redirection body validation failed for ${records} in ${functionName}: ${e.message}`);
|
|
493
435
|
throw new InvalidParamError(`Invalid redirection body ${records} passed to ${functionName}.`, e);
|
|
494
436
|
}
|
|
495
437
|
}
|
|
496
438
|
function validateSignature(providerId, signature, applicationId, timestamp) {
|
|
497
439
|
try {
|
|
498
|
-
|
|
440
|
+
logger2.info(`Starting signature validation for providerId: ${providerId}, applicationId: ${applicationId}, timestamp: ${timestamp}`);
|
|
499
441
|
const message = (0, import_canonicalize2.default)({ providerId, timestamp });
|
|
500
442
|
if (!message) {
|
|
501
|
-
|
|
443
|
+
logger2.info("Failed to canonicalize message for signature validation");
|
|
502
444
|
throw new Error("Failed to canonicalize message");
|
|
503
445
|
}
|
|
504
446
|
const messageHash = import_ethers.ethers.keccak256(new TextEncoder().encode(message));
|
|
@@ -507,12 +449,12 @@ function validateSignature(providerId, signature, applicationId, timestamp) {
|
|
|
507
449
|
import_ethers.ethers.hexlify(signature)
|
|
508
450
|
).toLowerCase();
|
|
509
451
|
if (import_ethers.ethers.getAddress(appId) !== import_ethers.ethers.getAddress(applicationId)) {
|
|
510
|
-
|
|
452
|
+
logger2.info(`Signature validation failed: Mismatch between derived appId (${appId}) and provided applicationId (${applicationId})`);
|
|
511
453
|
throw new InvalidSignatureError(`Signature does not match the application id: ${appId}`);
|
|
512
454
|
}
|
|
513
|
-
|
|
455
|
+
logger2.info(`Signature validated successfully for applicationId: ${applicationId}`);
|
|
514
456
|
} catch (err) {
|
|
515
|
-
|
|
457
|
+
logger2.info(`Signature validation failed: ${err.message}`);
|
|
516
458
|
if (err instanceof InvalidSignatureError) {
|
|
517
459
|
throw err;
|
|
518
460
|
}
|
|
@@ -528,16 +470,16 @@ function validateContext(context) {
|
|
|
528
470
|
JSON.parse(canonicalStringify(context));
|
|
529
471
|
return;
|
|
530
472
|
} catch (e) {
|
|
531
|
-
|
|
473
|
+
logger2.info(`Context validation failed: Provided JSON serializable context is not valid`);
|
|
532
474
|
throw new InvalidParamError(`The provided context is not valid`);
|
|
533
475
|
}
|
|
534
476
|
}
|
|
535
477
|
if (!context.contextAddress) {
|
|
536
|
-
|
|
478
|
+
logger2.info(`Context validation failed: Provided context address in context is not valid`);
|
|
537
479
|
throw new InvalidParamError(`The provided context address in context is not valid`);
|
|
538
480
|
}
|
|
539
481
|
if (!context.contextMessage) {
|
|
540
|
-
|
|
482
|
+
logger2.info(`Context validation failed: Provided context message in context is not valid`);
|
|
541
483
|
throw new InvalidParamError(`The provided context message in context is not valid`);
|
|
542
484
|
}
|
|
543
485
|
validateFunctionParams([
|
|
@@ -593,11 +535,120 @@ function hashObject(o) {
|
|
|
593
535
|
const messageHash = import_ethers.ethers.keccak256(new TextEncoder().encode(canonicalData));
|
|
594
536
|
return messageHash;
|
|
595
537
|
} catch (e) {
|
|
596
|
-
|
|
538
|
+
logger2.info(`Failed to hash object: ${e.message}`);
|
|
597
539
|
throw new Error(`Failed to hash object: ${e.message}`);
|
|
598
540
|
}
|
|
599
541
|
}
|
|
600
542
|
|
|
543
|
+
// src/utils/helper.ts
|
|
544
|
+
var logger3 = logger_default.logger;
|
|
545
|
+
function escapeRegExp(string) {
|
|
546
|
+
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
547
|
+
}
|
|
548
|
+
function replaceAll(str, find, replace) {
|
|
549
|
+
if (find === "") return str;
|
|
550
|
+
return str.replace(new RegExp(escapeRegExp(find), "g"), replace);
|
|
551
|
+
}
|
|
552
|
+
function scheduleIntervalEndingTask(sessionId, intervals, onFailureCallback, timeout = 1e3 * 60 * 10) {
|
|
553
|
+
setTimeout(() => {
|
|
554
|
+
if (intervals.has(sessionId)) {
|
|
555
|
+
const message = "Interval ended without receiving proofs";
|
|
556
|
+
onFailureCallback(new TimeoutError(message));
|
|
557
|
+
logger3.info(message);
|
|
558
|
+
clearInterval(intervals.get(sessionId));
|
|
559
|
+
intervals.delete(sessionId);
|
|
560
|
+
}
|
|
561
|
+
}, timeout);
|
|
562
|
+
}
|
|
563
|
+
var createVerifyProofResultSuccess = (proofs, isTeeVerified) => {
|
|
564
|
+
return {
|
|
565
|
+
isVerified: true,
|
|
566
|
+
isTeeVerified,
|
|
567
|
+
error: void 0,
|
|
568
|
+
data: proofs.map(createTrustedDataFromProofData),
|
|
569
|
+
publicData: getPublicDataFromProofs(proofs)
|
|
570
|
+
};
|
|
571
|
+
};
|
|
572
|
+
var createVerifyProofResultFailure = (error, isTeeVerified) => {
|
|
573
|
+
return {
|
|
574
|
+
isVerified: false,
|
|
575
|
+
isTeeVerified,
|
|
576
|
+
error,
|
|
577
|
+
data: [],
|
|
578
|
+
publicData: []
|
|
579
|
+
};
|
|
580
|
+
};
|
|
581
|
+
function createTrustedDataFromProofData(proof) {
|
|
582
|
+
try {
|
|
583
|
+
const context = JSON.parse(proof.claimData.context);
|
|
584
|
+
const _a = context, { extractedParameters } = _a, rest = __objRest(_a, ["extractedParameters"]);
|
|
585
|
+
return {
|
|
586
|
+
context: rest,
|
|
587
|
+
extractedParameters: extractedParameters != null ? extractedParameters : {}
|
|
588
|
+
};
|
|
589
|
+
} catch (e) {
|
|
590
|
+
return {
|
|
591
|
+
context: {},
|
|
592
|
+
extractedParameters: {}
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
function getPublicDataFromProofs(proofs) {
|
|
597
|
+
const data = [];
|
|
598
|
+
const seenData = /* @__PURE__ */ new Set();
|
|
599
|
+
for (const proof of proofs) {
|
|
600
|
+
const publicData = proof.publicData;
|
|
601
|
+
if (publicData === null || publicData === void 0) {
|
|
602
|
+
continue;
|
|
603
|
+
}
|
|
604
|
+
try {
|
|
605
|
+
const hash = hashObject(publicData);
|
|
606
|
+
if (seenData.has(hash)) {
|
|
607
|
+
continue;
|
|
608
|
+
}
|
|
609
|
+
seenData.add(hash);
|
|
610
|
+
} catch (_) {
|
|
611
|
+
}
|
|
612
|
+
data.push(publicData);
|
|
613
|
+
}
|
|
614
|
+
return data;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
// src/utils/constants.ts
|
|
618
|
+
var BACKEND_BASE_URL = "https://api.reclaimprotocol.org";
|
|
619
|
+
function setBackendBaseUrl(url) {
|
|
620
|
+
BACKEND_BASE_URL = url;
|
|
621
|
+
}
|
|
622
|
+
var constants = {
|
|
623
|
+
// Default callback URL for Reclaim protocol
|
|
624
|
+
get DEFAULT_RECLAIM_CALLBACK_URL() {
|
|
625
|
+
return `${BACKEND_BASE_URL}/api/sdk/callback?callbackId=`;
|
|
626
|
+
},
|
|
627
|
+
// Default error callback URL for Reclaim protocol
|
|
628
|
+
get DEFAULT_RECLAIM_CANCEL_CALLBACK_URL() {
|
|
629
|
+
return `${BACKEND_BASE_URL}/api/sdk/error-callback?callbackId=`;
|
|
630
|
+
},
|
|
631
|
+
// Default status URL for Reclaim sessions
|
|
632
|
+
get DEFAULT_RECLAIM_STATUS_URL() {
|
|
633
|
+
return `${BACKEND_BASE_URL}/api/sdk/session/`;
|
|
634
|
+
},
|
|
635
|
+
// Default attestors URL for Reclaim sessions
|
|
636
|
+
get DEFAULT_ATTESTORS_URL() {
|
|
637
|
+
return `${BACKEND_BASE_URL}/api/attestors`;
|
|
638
|
+
},
|
|
639
|
+
DEFAULT_PROVIDER_CONFIGS_URL(providerId, exactProviderVersionString, allowedTags) {
|
|
640
|
+
return `${BACKEND_BASE_URL}/api/providers/${providerId}/configs?versionNumber=${exactProviderVersionString || ""}&allowedTags=${(allowedTags == null ? void 0 : allowedTags.join(",")) || ""}`;
|
|
641
|
+
},
|
|
642
|
+
// Default portal URL
|
|
643
|
+
DEFAULT_PORTAL_URL: "https://portal.reclaimprotocol.org",
|
|
644
|
+
// Default sharepage URL
|
|
645
|
+
DEFAULT_APP_SHARE_PAGE_URL: "https://share.reclaimprotocol.org/verifier",
|
|
646
|
+
// URL for sharing Reclaim templates
|
|
647
|
+
RECLAIM_SHARE_URL: "https://share.reclaimprotocol.org/verifier/?template=",
|
|
648
|
+
// Chrome extension URL for Reclaim Protocol
|
|
649
|
+
CHROME_EXTENSION_URL: "https://chromewebstore.google.com/detail/reclaim-extension/oafieibbbcepkmenknelhmgaoahamdeh"
|
|
650
|
+
};
|
|
651
|
+
|
|
601
652
|
// src/utils/fetch.ts
|
|
602
653
|
var import_fetch_retry = __toESM(require("fetch-retry"));
|
|
603
654
|
var MAX_RETRIES = 3;
|
|
@@ -2368,14 +2419,7 @@ function verifyProof(proofOrProofs, config) {
|
|
|
2368
2419
|
if (!hasTeeData) {
|
|
2369
2420
|
const teeError = new TeeVerificationError("TEE verification requested but one or more proofs are missing TEE attestation data");
|
|
2370
2421
|
logger10.error(teeError.message);
|
|
2371
|
-
|
|
2372
|
-
isVerified: false,
|
|
2373
|
-
isTeeVerified: false,
|
|
2374
|
-
error: teeError,
|
|
2375
|
-
data: [],
|
|
2376
|
-
publicData: []
|
|
2377
|
-
};
|
|
2378
|
-
return errorResult;
|
|
2422
|
+
return createVerifyProofResultFailure(teeError, false);
|
|
2379
2423
|
}
|
|
2380
2424
|
try {
|
|
2381
2425
|
const teeResults = yield Promise.all(proofs.map((proof) => verifyTeeAttestation(proof)));
|
|
@@ -2383,82 +2427,22 @@ function verifyProof(proofOrProofs, config) {
|
|
|
2383
2427
|
if (!isTeeVerified) {
|
|
2384
2428
|
const teeError = new TeeVerificationError("TEE attestation verification failed for one or more proofs");
|
|
2385
2429
|
logger10.error(teeError.message);
|
|
2386
|
-
|
|
2387
|
-
isVerified: false,
|
|
2388
|
-
isTeeVerified: false,
|
|
2389
|
-
error: teeError,
|
|
2390
|
-
data: [],
|
|
2391
|
-
publicData: []
|
|
2392
|
-
};
|
|
2393
|
-
return errorResult;
|
|
2430
|
+
return createVerifyProofResultFailure(teeError, false);
|
|
2394
2431
|
}
|
|
2395
2432
|
} catch (error) {
|
|
2396
2433
|
const teeError = new TeeVerificationError("Error verifying TEE attestation", error);
|
|
2397
2434
|
logger10.error(teeError.message);
|
|
2398
|
-
|
|
2399
|
-
isVerified: false,
|
|
2400
|
-
isTeeVerified: false,
|
|
2401
|
-
error: teeError,
|
|
2402
|
-
data: [],
|
|
2403
|
-
publicData: []
|
|
2404
|
-
};
|
|
2405
|
-
return errorResult;
|
|
2435
|
+
return createVerifyProofResultFailure(teeError, false);
|
|
2406
2436
|
}
|
|
2407
2437
|
}
|
|
2408
|
-
|
|
2409
|
-
isVerified: true,
|
|
2410
|
-
isTeeVerified,
|
|
2411
|
-
data: proofs.map(createTrustedDataFromProofData),
|
|
2412
|
-
publicData: getPublicDataFromProofs(proofs),
|
|
2413
|
-
error: void 0
|
|
2414
|
-
};
|
|
2415
|
-
return result;
|
|
2438
|
+
return createVerifyProofResultSuccess(proofs, isTeeVerified);
|
|
2416
2439
|
} catch (error) {
|
|
2417
2440
|
logger10.error("Error in validating proof:", error);
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
error: error instanceof Error ? error : new Error(String(error)),
|
|
2421
|
-
data: [],
|
|
2422
|
-
publicData: []
|
|
2423
|
-
};
|
|
2441
|
+
const _error = error instanceof Error ? error : new Error(String(error));
|
|
2442
|
+
return createVerifyProofResultFailure(_error);
|
|
2424
2443
|
}
|
|
2425
2444
|
});
|
|
2426
2445
|
}
|
|
2427
|
-
function createTrustedDataFromProofData(proof) {
|
|
2428
|
-
try {
|
|
2429
|
-
const context = JSON.parse(proof.claimData.context);
|
|
2430
|
-
const _a = context, { extractedParameters } = _a, rest = __objRest(_a, ["extractedParameters"]);
|
|
2431
|
-
return {
|
|
2432
|
-
context: rest,
|
|
2433
|
-
extractedParameters: extractedParameters != null ? extractedParameters : {}
|
|
2434
|
-
};
|
|
2435
|
-
} catch (e) {
|
|
2436
|
-
return {
|
|
2437
|
-
context: {},
|
|
2438
|
-
extractedParameters: {}
|
|
2439
|
-
};
|
|
2440
|
-
}
|
|
2441
|
-
}
|
|
2442
|
-
function getPublicDataFromProofs(proofs) {
|
|
2443
|
-
const data = [];
|
|
2444
|
-
const seenData = /* @__PURE__ */ new Set();
|
|
2445
|
-
for (const proof of proofs) {
|
|
2446
|
-
const publicData = proof.publicData;
|
|
2447
|
-
if (publicData === null || publicData === void 0) {
|
|
2448
|
-
continue;
|
|
2449
|
-
}
|
|
2450
|
-
try {
|
|
2451
|
-
const hash = hashObject(publicData);
|
|
2452
|
-
if (seenData.has(hash)) {
|
|
2453
|
-
continue;
|
|
2454
|
-
}
|
|
2455
|
-
seenData.add(hash);
|
|
2456
|
-
} catch (_) {
|
|
2457
|
-
}
|
|
2458
|
-
data.push(publicData);
|
|
2459
|
-
}
|
|
2460
|
-
return data;
|
|
2461
|
-
}
|
|
2462
2446
|
function transformForOnchain(proof) {
|
|
2463
2447
|
const claimInfoBuilder = /* @__PURE__ */ new Map([
|
|
2464
2448
|
["context", proof.claimData.context],
|
|
@@ -3913,7 +3897,6 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
|
|
|
3913
3897
|
clearDeviceCache,
|
|
3914
3898
|
createLinkWithTemplateData,
|
|
3915
3899
|
createSignDataForClaim,
|
|
3916
|
-
createTrustedDataFromProofData,
|
|
3917
3900
|
fetchProviderConfigs,
|
|
3918
3901
|
fetchProviderHashRequirementsBy,
|
|
3919
3902
|
fetchStatusUrl,
|
|
@@ -3926,7 +3909,6 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
|
|
|
3926
3909
|
getProviderHashRequirementSpecFromProviderConfig,
|
|
3927
3910
|
getProviderHashRequirementsFromSpec,
|
|
3928
3911
|
getProviderParamsAsCanonicalizedString,
|
|
3929
|
-
getPublicDataFromProofs,
|
|
3930
3912
|
getShortenedUrl,
|
|
3931
3913
|
hashProofClaimParams,
|
|
3932
3914
|
hashRequestSpec,
|