@reclaimprotocol/js-sdk 5.0.0-dev.3 → 5.0.0-dev.4

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 CHANGED
@@ -133,6 +133,16 @@ declare function fetchProviderHashRequirementsBy(providerId: string, exactProvid
133
133
  declare function generateSpecsFromRequestSpecTemplate(requestSpecTemplates: RequestSpec[], templateParameters: Record<string, string[]>): RequestSpec[];
134
134
  declare function takeTemplateParametersFromProofs(proofs?: Proof[]): Record<string, string[]>;
135
135
  declare function takePairsWhereValueIsArray(o: Record<string, string> | undefined): Record<string, string[]>;
136
+ /**
137
+ * Builds and returns raw hash requirement spec that can be used with `getProviderHashRequirementsFromSpec` to computes the expected proof hashes for a provider configuration
138
+ * by combining its explicitly required requests and allowed injected requests.
139
+ * It resolves template parameters from provided proofs to generate the final request specifications.
140
+ *
141
+ * @param providerConfig - The provider configuration containing request data and allowed injected requests.
142
+ * @param proofs - Optional array of proofs used to extract template parameters for resolving placeholders in injected requests.
143
+ * @returns A structured configuration containing that can be used with `getProviderHashRequirementsFromSpec` to compute the hashes.
144
+ */
145
+ declare function getProviderHashRequirementSpecFromProviderConfig(providerConfig: ReclaimProviderConfigWithRequestSpec, proofs?: Proof[]): ProviderHashRequirementSpec;
136
146
  /**
137
147
  * Transforms a raw provider hash requirement specification into a structured configuration for proof validation.
138
148
  * It computes the proof hashes for both required and allowed extra requests to correctly match uploaded proofs.
@@ -188,6 +198,10 @@ type HashRequirement = {
188
198
  */
189
199
  multiple?: boolean;
190
200
  };
201
+ interface ReclaimProviderConfigWithRequestSpec {
202
+ requestData: InterceptorRequestSpec[];
203
+ allowedInjectedRequestData: InjectedRequestSpec[];
204
+ }
191
205
  /**
192
206
  * Specific marker interface for intercepted request specifications.
193
207
  */
@@ -257,7 +271,7 @@ interface ResponseMatchSpec {
257
271
  */
258
272
  interface ResponseRedactionSpec {
259
273
  /** Optional hashing method applied to the redacted content (e.g., 'oprf') */
260
- hash?: "oprf" | undefined;
274
+ hash?: "oprf" | "oprf-mpc" | undefined;
261
275
  /** JSON path for locating the value to redact */
262
276
  jsonPath: string;
263
277
  /** RegEx applied to correctly parse and extract/redact value */
@@ -583,15 +597,13 @@ type ProviderConfigResponse = {
583
597
  providerId?: string;
584
598
  providerVersionString?: string;
585
599
  };
586
- interface ReclaimProviderConfig {
600
+ interface ReclaimProviderConfig extends ReclaimProviderConfigWithRequestSpec {
587
601
  loginUrl: string;
588
602
  customInjection: string;
589
603
  geoLocation: string;
590
604
  injectionType: string;
591
605
  disableRequestReplay: boolean;
592
606
  verificationType: string;
593
- requestData: InterceptorRequestSpec[];
594
- allowedInjectedRequestData: InjectedRequestSpec[];
595
607
  }
596
608
  type ProviderHashRequirementsResponse = {
597
609
  message?: string;
@@ -1376,6 +1388,49 @@ declare function updateSession(sessionId: string, status: SessionStatus): Promis
1376
1388
  declare function fetchStatusUrl(sessionId: string): Promise<StatusUrlResponse>;
1377
1389
  declare function fetchProviderConfigs(providerId: string, exactProviderVersionString: string | null | undefined, allowedTags: string[] | null | undefined): Promise<ProviderConfigResponse>;
1378
1390
 
1391
+ declare function createSignDataForClaim(data: CompleteClaimData): string;
1392
+ declare function getIdentifierFromClaimInfo(info: ClaimInfo): ClaimID;
1393
+ /**
1394
+ * Computes the cryptographic claim hash(es) for the HTTP provider payload parameters.
1395
+ *
1396
+ * If the parameters comprise solely of rigid/required rules (or represents an extracted
1397
+ * attested payload that enforces all its defined elements), this computes and returns a single deterministic string.
1398
+ *
1399
+ * **Combinatorial Hashes Intention:**
1400
+ * If the payload configuration defines optional elements (`isOptional: true` on ResponseMatchSpec),
1401
+ * a single rule configuration inherently encompasses multiple logical subset definitions.
1402
+ * Since cryptographic hashes strictly enforce exact data byte-by-byte,
1403
+ * this function recursively computes a hash for every mathematically valid permutation of the optional subsets
1404
+ * (inclusive and exclusive) so the validator can verify the proof against any of the legitimate subset match signatures.
1405
+ *
1406
+ * @param params - The HTTP provider claim configuration or extracted attested parameters.
1407
+ * @returns A single keccak256 hash string, or an array of hex-string hashes if parameter optionality generates combinations.
1408
+ */
1409
+ declare function hashProofClaimParams(params: HttpProviderClaimParams): string | string[];
1410
+ /**
1411
+ * Computes canonicalized string(s) for the provided HTTP parameter payload.
1412
+ *
1413
+ * **Architectural Concept**:
1414
+ * In Reclaim, proof security revolves around generating a deterministic Hash based on the JSON stringified keys
1415
+ * of matched specifications (e.g. `responseMatches` and `responseRedactions`).
1416
+ * When processing a Provider Configuration containing `isOptional` rules, the protocol doesn't require users to generate a
1417
+ * proof that matched *all* of the rules. A client could inherently omit any optional rules from claim before
1418
+ * starting claim creation to make a valid proof if the server payload may not contain them.
1419
+ *
1420
+ * To ensure the eventual Proof's Hash safely validates against the parent template's Requirement Hash, logic here
1421
+ * loops $2^N$ times using bitmask computation (where N = number of rule pairs) and yields canonically sorted
1422
+ * permutations for every sub-set of optional combinations.
1423
+ * Any combination forcefully omitting a mathematically required (`isOptional: false`) rule is stripped out.
1424
+ *
1425
+ * Note: When a user successfully generates a proof, their attested parameter payload does not contain `isOptional` tags
1426
+ * because the client sending request to attestor omits rules where data may not be present in response,
1427
+ * producing exactly 1 deterministic configuration subset (what the user actually proved!).
1428
+ *
1429
+ * @param params - The structured parameters.
1430
+ * @returns Serialized string or array of strings.
1431
+ */
1432
+ declare function getProviderParamsAsCanonicalizedString(params: HttpProviderClaimParams): string[];
1433
+
1379
1434
  /**
1380
1435
  * Validates the hardware TEE attestation included in the proof.
1381
1436
  * Throws an error if the attestation is invalid or compromised.
@@ -1423,4 +1478,4 @@ declare function isDesktopDevice(): boolean;
1423
1478
  */
1424
1479
  declare function clearDeviceCache(): void;
1425
1480
 
1426
- 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 ReclaimFlowLaunchOptions, ReclaimProofRequest, type ReclaimProviderConfig, 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 WitnessData, assertValidProofsByHash, assertValidateProof, assertVerifiedProof, clearDeviceCache, createLinkWithTemplateData, fetchProviderConfigs, fetchProviderHashRequirementsBy, fetchStatusUrl, generateSpecsFromRequestSpecTemplate, getAttestors, getDeviceType, getHttpProviderClaimParamsFromProof, getMobileDeviceType, getProviderHashRequirementsFromSpec, getShortenedUrl, hashRequestSpec, initSession, isDesktopDevice, isHttpProviderClaimParams, isMobileDevice, recoverSignersOfSignedClaim, takePairsWhereValueIsArray, takeTemplateParametersFromProofs, transformForOnchain, updateSession, verifyProof, verifyTeeAttestation };
1481
+ 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 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 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.0.0-dev.3",
87
+ version: "5.0.0-dev.4",
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",
@@ -199,6 +199,7 @@ __export(index_exports, {
199
199
  assertVerifiedProof: () => assertVerifiedProof,
200
200
  clearDeviceCache: () => clearDeviceCache,
201
201
  createLinkWithTemplateData: () => createLinkWithTemplateData,
202
+ createSignDataForClaim: () => createSignDataForClaim,
202
203
  fetchProviderConfigs: () => fetchProviderConfigs,
203
204
  fetchProviderHashRequirementsBy: () => fetchProviderHashRequirementsBy,
204
205
  fetchStatusUrl: () => fetchStatusUrl,
@@ -206,9 +207,13 @@ __export(index_exports, {
206
207
  getAttestors: () => getAttestors,
207
208
  getDeviceType: () => getDeviceType,
208
209
  getHttpProviderClaimParamsFromProof: () => getHttpProviderClaimParamsFromProof,
210
+ getIdentifierFromClaimInfo: () => getIdentifierFromClaimInfo,
209
211
  getMobileDeviceType: () => getMobileDeviceType,
212
+ getProviderHashRequirementSpecFromProviderConfig: () => getProviderHashRequirementSpecFromProviderConfig,
210
213
  getProviderHashRequirementsFromSpec: () => getProviderHashRequirementsFromSpec,
214
+ getProviderParamsAsCanonicalizedString: () => getProviderParamsAsCanonicalizedString,
211
215
  getShortenedUrl: () => getShortenedUrl,
216
+ hashProofClaimParams: () => hashProofClaimParams,
212
217
  hashRequestSpec: () => hashRequestSpec,
213
218
  initSession: () => initSession,
214
219
  isDesktopDevice: () => isDesktopDevice,
@@ -838,9 +843,9 @@ function getProviderParamsAsCanonicalizedString(params) {
838
843
  responseMatches: [],
839
844
  responseRedactions: []
840
845
  };
841
- return canonicalStringify(filteredParams);
846
+ return [canonicalStringify(filteredParams)];
842
847
  }
843
- return validCanonicalizedStrings.length === 1 ? validCanonicalizedStrings[0] : validCanonicalizedStrings;
848
+ return validCanonicalizedStrings;
844
849
  }
845
850
 
846
851
  // src/utils/proofUtils.ts
@@ -1378,7 +1383,6 @@ function clearDeviceCache() {
1378
1383
  var logger7 = logger_default.logger;
1379
1384
  function fetchProviderHashRequirementsBy(providerId, exactProviderVersionString, allowedTags, proofs) {
1380
1385
  return __async(this, null, function* () {
1381
- var _a, _b;
1382
1386
  const providerResponse = yield fetchProviderConfigs(providerId, exactProviderVersionString, allowedTags);
1383
1387
  try {
1384
1388
  const providerConfigs = providerResponse.providers;
@@ -1387,9 +1391,8 @@ function fetchProviderHashRequirementsBy(providerId, exactProviderVersionString,
1387
1391
  }
1388
1392
  const hashRequirements = [];
1389
1393
  for (const providerConfig of providerConfigs) {
1390
- hashRequirements.push(getProviderHashRequirementsFromSpec({
1391
- requests: [...(_a = providerConfig == null ? void 0 : providerConfig.requestData) != null ? _a : [], ...generateSpecsFromRequestSpecTemplate((_b = providerConfig == null ? void 0 : providerConfig.allowedInjectedRequestData) != null ? _b : [], takeTemplateParametersFromProofs(proofs))]
1392
- }));
1394
+ const requestSpec = getProviderHashRequirementSpecFromProviderConfig(providerConfig, proofs);
1395
+ hashRequirements.push(getProviderHashRequirementsFromSpec(requestSpec));
1393
1396
  }
1394
1397
  return hashRequirements;
1395
1398
  } catch (e) {
@@ -1469,6 +1472,12 @@ function takePairsWhereValueIsArray(o) {
1469
1472
  }
1470
1473
  return pairs;
1471
1474
  }
1475
+ function getProviderHashRequirementSpecFromProviderConfig(providerConfig, proofs) {
1476
+ var _a, _b;
1477
+ return {
1478
+ requests: [...(_a = providerConfig == null ? void 0 : providerConfig.requestData) != null ? _a : [], ...generateSpecsFromRequestSpecTemplate((_b = providerConfig == null ? void 0 : providerConfig.allowedInjectedRequestData) != null ? _b : [], takeTemplateParametersFromProofs(proofs))]
1479
+ };
1480
+ }
1472
1481
  function getProviderHashRequirementsFromSpec(spec) {
1473
1482
  var _a;
1474
1483
  return {
@@ -3846,6 +3855,7 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
3846
3855
  assertVerifiedProof,
3847
3856
  clearDeviceCache,
3848
3857
  createLinkWithTemplateData,
3858
+ createSignDataForClaim,
3849
3859
  fetchProviderConfigs,
3850
3860
  fetchProviderHashRequirementsBy,
3851
3861
  fetchStatusUrl,
@@ -3853,9 +3863,13 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
3853
3863
  getAttestors,
3854
3864
  getDeviceType,
3855
3865
  getHttpProviderClaimParamsFromProof,
3866
+ getIdentifierFromClaimInfo,
3856
3867
  getMobileDeviceType,
3868
+ getProviderHashRequirementSpecFromProviderConfig,
3857
3869
  getProviderHashRequirementsFromSpec,
3870
+ getProviderParamsAsCanonicalizedString,
3858
3871
  getShortenedUrl,
3872
+ hashProofClaimParams,
3859
3873
  hashRequestSpec,
3860
3874
  initSession,
3861
3875
  isDesktopDevice,