@reclaimprotocol/js-sdk 5.0.0-dev.2 → 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/README.md +82 -41
- package/dist/index.d.ts +229 -104
- package/dist/index.js +186 -83
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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 */
|
|
@@ -266,81 +280,6 @@ interface ResponseRedactionSpec {
|
|
|
266
280
|
xPath: string;
|
|
267
281
|
}
|
|
268
282
|
|
|
269
|
-
/**
|
|
270
|
-
* Content validation configuration specifying essential required hashes and optional extra proofs.
|
|
271
|
-
* Used to explicitly validate that a generated proof matches the exact request structure expected.
|
|
272
|
-
*/
|
|
273
|
-
type ValidationConfigWithHash = {
|
|
274
|
-
/**
|
|
275
|
-
* Array of computed hashes that must be satisfied by the proofs.
|
|
276
|
-
*
|
|
277
|
-
* An element can be a `HashRequirement` object or a string that is equivalent to
|
|
278
|
-
* a `{ value: '<hash>', required: true, multiple: false }` as `HashRequirement`.
|
|
279
|
-
*/
|
|
280
|
-
hashes: (string | HashRequirement)[];
|
|
281
|
-
};
|
|
282
|
-
/**
|
|
283
|
-
* Content validation configuration specifying the provider id and version used in the verification session that generated the proofs.
|
|
284
|
-
* Used to explicitly validate that a generated proof matches the exact request structure expected.
|
|
285
|
-
*
|
|
286
|
-
* See also:
|
|
287
|
-
*
|
|
288
|
-
* * `ReclaimProofRequest.getProviderVersion()` - With a ReclaimProofRequest object, you can get the provider id & exact version of provider used in verification session.
|
|
289
|
-
*/
|
|
290
|
-
interface ValidationConfigWithProviderInformation {
|
|
291
|
-
/**
|
|
292
|
-
* The identifier of provider used in verifications that resulted in a proof
|
|
293
|
-
*
|
|
294
|
-
* See also:
|
|
295
|
-
*
|
|
296
|
-
* * `ReclaimProofRequest.getProviderVersion()` - With a ReclaimProofRequest object, you can get the provider id & exact version of provider used in verification session.
|
|
297
|
-
**/
|
|
298
|
-
providerId: string;
|
|
299
|
-
/**
|
|
300
|
-
* The exact version of provider used in verifications that resulted in a proof.
|
|
301
|
-
*
|
|
302
|
-
* This cannot be a version constaint or version expression. It can be undefined or left blank if proof must be validated with latest version of provider.
|
|
303
|
-
* Patches for the next provider version are also fetched and hashes from that spec is also be used to compare the hashes from proof.
|
|
304
|
-
*
|
|
305
|
-
* See also:
|
|
306
|
-
*
|
|
307
|
-
* * `ReclaimProofRequest.getProviderVersion()` - With a ReclaimProofRequest object, you can get the provider id & exact version of provider used in verification session.
|
|
308
|
-
**/
|
|
309
|
-
providerVersion?: string;
|
|
310
|
-
/**
|
|
311
|
-
* List of allowed pre-release tags.
|
|
312
|
-
* For example, if you are using AI, provide `['ai']` to allow AI patch versions of the provider.
|
|
313
|
-
*/
|
|
314
|
-
allowedTags?: string[];
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* Legacy configuration to completely bypass content validation during verification.
|
|
318
|
-
* Warning: Using this poses a risk as it avoids strictly matching proof parameters to expected hashes.
|
|
319
|
-
*/
|
|
320
|
-
interface ValidationConfigWithDisabledValidation {
|
|
321
|
-
dangerouslyDisableContentValidation: true;
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* Represents the configuration options applied when validating proof contents, allowing
|
|
325
|
-
* strict hash checking or intentionally skipping validation if flagged.
|
|
326
|
-
*/
|
|
327
|
-
type ValidationConfig = ValidationConfigWithHash | ValidationConfigWithProviderInformation | ValidationConfigWithDisabledValidation;
|
|
328
|
-
/**
|
|
329
|
-
* Describes the comprehensive configuration required to initialize the proof verification process.
|
|
330
|
-
* Aligns with `ValidationConfig` options for verifying signatures alongside proof contents.
|
|
331
|
-
*/
|
|
332
|
-
type VerificationConfig = ValidationConfig;
|
|
333
|
-
declare function assertValidProofsByHash(proofs: Proof[], config: ProviderHashRequirementsConfig): void;
|
|
334
|
-
declare function isHttpProviderClaimParams(claimParams: unknown): claimParams is HttpProviderClaimParams;
|
|
335
|
-
declare function getHttpProviderClaimParamsFromProof(proof: Proof): HttpProviderClaimParams;
|
|
336
|
-
/**
|
|
337
|
-
* Asserts that the proof is validated by checking the content of proof with with expectations from provider config or hash based on [options]
|
|
338
|
-
* @param proofs - The proofs to validate
|
|
339
|
-
* @param config - The validation config
|
|
340
|
-
* @throws {ProofNotValidatedError} When the proof is not validated
|
|
341
|
-
*/
|
|
342
|
-
declare function assertValidateProof(proofs: Proof[], config: VerificationConfig): Promise<void>;
|
|
343
|
-
|
|
344
283
|
type ClaimID = ProviderClaimData['identifier'];
|
|
345
284
|
type ClaimInfo = Pick<ProviderClaimData, 'context' | 'provider' | 'parameters'>;
|
|
346
285
|
type CompleteClaimData = Pick<ProviderClaimData, 'owner' | 'timestampS' | 'epoch'> & ClaimInfo;
|
|
@@ -369,7 +308,6 @@ type CreateVerificationRequest = {
|
|
|
369
308
|
type StartSessionParams = {
|
|
370
309
|
onSuccess: OnSuccess;
|
|
371
310
|
onError: OnError;
|
|
372
|
-
verificationConfig?: VerificationConfig;
|
|
373
311
|
};
|
|
374
312
|
type OnSuccess = (proof?: Proof | Proof[]) => void;
|
|
375
313
|
type OnError = (error: Error) => void;
|
|
@@ -456,7 +394,7 @@ type ReclaimFlowLaunchOptions = {
|
|
|
456
394
|
* Verification mode for the flow.
|
|
457
395
|
*
|
|
458
396
|
* - `'portal'`: Opens the portal URL in the browser (remote browser verification).
|
|
459
|
-
* - `'app'`:
|
|
397
|
+
* - `'app'`: Verifier app flow via the share page. If `useAppClip` is `true`, uses App Clip on iOS.
|
|
460
398
|
*
|
|
461
399
|
* Can be set at call time via `triggerReclaimFlow({ verificationMode })` or `getRequestUrl({ verificationMode })`,
|
|
462
400
|
* or at init time via `launchOptions: { verificationMode }`.
|
|
@@ -464,7 +402,28 @@ type ReclaimFlowLaunchOptions = {
|
|
|
464
402
|
* @default 'portal'
|
|
465
403
|
*/
|
|
466
404
|
verificationMode?: 'app' | 'portal';
|
|
405
|
+
/**
|
|
406
|
+
* Target DOM element to embed the verification flow in an iframe.
|
|
407
|
+
* When provided, the portal opens inside the element instead of a new tab.
|
|
408
|
+
* Use `closeEmbeddedFlow()` to remove the iframe programmatically.
|
|
409
|
+
*
|
|
410
|
+
* Only applies to portal mode.
|
|
411
|
+
*/
|
|
412
|
+
target?: HTMLElement;
|
|
467
413
|
};
|
|
414
|
+
/**
|
|
415
|
+
* Handle returned by `triggerReclaimFlow` to control the launched flow.
|
|
416
|
+
*/
|
|
417
|
+
type FlowHandle = {
|
|
418
|
+
/** Closes the flow (removes iframe, closes tab, stops polling) */
|
|
419
|
+
close: () => void;
|
|
420
|
+
/** The iframe element when using embedded mode, `undefined` otherwise */
|
|
421
|
+
iframe?: HTMLIFrameElement;
|
|
422
|
+
/** The tab/window reference when using new tab mode, `undefined` otherwise */
|
|
423
|
+
tab?: Window | null;
|
|
424
|
+
};
|
|
425
|
+
/** Alias for `FlowHandle` */
|
|
426
|
+
type EmbeddedFlowHandle = FlowHandle;
|
|
468
427
|
type ModalOptions = {
|
|
469
428
|
title?: string;
|
|
470
429
|
description?: string;
|
|
@@ -544,7 +503,7 @@ type HttpRedirectionMethod = 'GET' | 'POST';
|
|
|
544
503
|
/**
|
|
545
504
|
* Options for HTTP redirection.
|
|
546
505
|
*
|
|
547
|
-
* Only supported by
|
|
506
|
+
* Only supported by Portal flow.
|
|
548
507
|
* On other SDKs, this will be ignored and a GET redirection will be performed with the URL.
|
|
549
508
|
*
|
|
550
509
|
* @since 4.11.0
|
|
@@ -597,13 +556,15 @@ type TemplateData = {
|
|
|
597
556
|
metadata?: Record<string, string>;
|
|
598
557
|
preferredLocale?: ProofRequestOptions['preferredLocale'];
|
|
599
558
|
};
|
|
559
|
+
type TrustedData = {
|
|
560
|
+
context: Record<string, unknown>;
|
|
561
|
+
extractedParameters: Record<string, string>;
|
|
562
|
+
};
|
|
600
563
|
type VerifyProofResult = {
|
|
601
564
|
isVerified: boolean;
|
|
602
565
|
isTeeVerified?: boolean;
|
|
603
|
-
data:
|
|
604
|
-
|
|
605
|
-
extractedParameters: Record<string, string>;
|
|
606
|
-
}[];
|
|
566
|
+
data: TrustedData[];
|
|
567
|
+
error?: Error;
|
|
607
568
|
};
|
|
608
569
|
type ProviderVersionConfig = {
|
|
609
570
|
major?: number;
|
|
@@ -636,15 +597,13 @@ type ProviderConfigResponse = {
|
|
|
636
597
|
providerId?: string;
|
|
637
598
|
providerVersionString?: string;
|
|
638
599
|
};
|
|
639
|
-
interface ReclaimProviderConfig {
|
|
600
|
+
interface ReclaimProviderConfig extends ReclaimProviderConfigWithRequestSpec {
|
|
640
601
|
loginUrl: string;
|
|
641
602
|
customInjection: string;
|
|
642
603
|
geoLocation: string;
|
|
643
604
|
injectionType: string;
|
|
644
605
|
disableRequestReplay: boolean;
|
|
645
606
|
verificationType: string;
|
|
646
|
-
requestData: InterceptorRequestSpec[];
|
|
647
|
-
allowedInjectedRequestData: InjectedRequestSpec[];
|
|
648
607
|
}
|
|
649
608
|
type ProviderHashRequirementsResponse = {
|
|
650
609
|
message?: string;
|
|
@@ -653,6 +612,88 @@ type ProviderHashRequirementsResponse = {
|
|
|
653
612
|
providerVersionString?: string;
|
|
654
613
|
};
|
|
655
614
|
|
|
615
|
+
/**
|
|
616
|
+
* Content validation configuration specifying essential required hashes and optional extra proofs.
|
|
617
|
+
* Used to explicitly validate that a generated proof matches the exact request structure expected.
|
|
618
|
+
*/
|
|
619
|
+
type ValidationConfigWithHash = {
|
|
620
|
+
/**
|
|
621
|
+
* Array of computed hashes that must be satisfied by the proofs.
|
|
622
|
+
*
|
|
623
|
+
* An element can be a `HashRequirement` object or a string that is equivalent to
|
|
624
|
+
* a `{ value: '<hash>', required: true, multiple: false }` as `HashRequirement`.
|
|
625
|
+
*/
|
|
626
|
+
hashes: (string | HashRequirement)[];
|
|
627
|
+
};
|
|
628
|
+
/**
|
|
629
|
+
* Content validation configuration specifying the provider id and version used in the verification session that generated the proofs.
|
|
630
|
+
* Used to explicitly validate that a generated proof matches the exact request structure expected.
|
|
631
|
+
*
|
|
632
|
+
* See also:
|
|
633
|
+
*
|
|
634
|
+
* * `ReclaimProofRequest.getProviderVersion()` - With a ReclaimProofRequest object, you can get the provider id & exact version of provider used in verification session.
|
|
635
|
+
*/
|
|
636
|
+
interface ValidationConfigWithProviderInformation {
|
|
637
|
+
/**
|
|
638
|
+
* The identifier of provider used in verifications that resulted in a proof
|
|
639
|
+
*
|
|
640
|
+
* See also:
|
|
641
|
+
*
|
|
642
|
+
* * `ReclaimProofRequest.getProviderVersion()` - With a ReclaimProofRequest object, you can get the provider id & exact version of provider used in verification session.
|
|
643
|
+
**/
|
|
644
|
+
providerId: string;
|
|
645
|
+
/**
|
|
646
|
+
* The exact version of provider used in verifications that resulted in a proof.
|
|
647
|
+
*
|
|
648
|
+
* This cannot be a version constaint or version expression. It can be undefined or left blank if proof must be validated with latest version of provider.
|
|
649
|
+
* Patches for the next provider version are also fetched and hashes from that spec is also be used to compare the hashes from proof.
|
|
650
|
+
*
|
|
651
|
+
* See also:
|
|
652
|
+
*
|
|
653
|
+
* * `ReclaimProofRequest.getProviderVersion()` - With a ReclaimProofRequest object, you can get the provider id & exact version of provider used in verification session.
|
|
654
|
+
**/
|
|
655
|
+
providerVersion?: string;
|
|
656
|
+
/**
|
|
657
|
+
* List of allowed pre-release tags.
|
|
658
|
+
* For example, if you are using AI, provide `['ai']` to allow AI patch versions of the provider.
|
|
659
|
+
*/
|
|
660
|
+
allowedTags?: string[];
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* Legacy configuration to completely bypass content validation during verification.
|
|
664
|
+
* Warning: Using this poses a risk as it avoids strictly matching proof parameters to expected hashes.
|
|
665
|
+
*/
|
|
666
|
+
interface ValidationConfigWithDisabledValidation {
|
|
667
|
+
dangerouslyDisableContentValidation: true;
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* Represents the configuration options applied when validating proof contents, allowing
|
|
671
|
+
* strict hash checking or intentionally skipping validation if flagged.
|
|
672
|
+
*/
|
|
673
|
+
type ValidationConfig = ValidationConfigWithHash | ValidationConfigWithProviderInformation | ValidationConfigWithDisabledValidation;
|
|
674
|
+
/**
|
|
675
|
+
* Describes the comprehensive configuration required to initialize the proof verification process.
|
|
676
|
+
* Aligns with `ValidationConfig` options for verifying signatures alongside proof contents.
|
|
677
|
+
*/
|
|
678
|
+
type VerificationConfig = ValidationConfig & {
|
|
679
|
+
/**
|
|
680
|
+
* If true, verifies TEE (Trusted Execution Environment) attestation included in the proof.
|
|
681
|
+
* When enabled, the result will include `isTeeVerified` and `isVerified` will be false
|
|
682
|
+
* if TEE data is missing or TEE verification fails.
|
|
683
|
+
*/
|
|
684
|
+
verifyTEE?: boolean;
|
|
685
|
+
};
|
|
686
|
+
declare function assertValidProofsByHash(proofs: Proof[], config: ProviderHashRequirementsConfig): void;
|
|
687
|
+
declare function isHttpProviderClaimParams(claimParams: unknown): claimParams is HttpProviderClaimParams;
|
|
688
|
+
declare function getHttpProviderClaimParamsFromProof(proof: Proof): HttpProviderClaimParams;
|
|
689
|
+
/**
|
|
690
|
+
* Asserts that the proof is validated by checking the content of proof with with expectations from provider config or hash based on [options]
|
|
691
|
+
* @param proofs - The proofs to validate
|
|
692
|
+
* @param config - The validation config
|
|
693
|
+
* @throws {ProofNotValidatedError} When the proof is not validated
|
|
694
|
+
*/
|
|
695
|
+
declare function assertValidateProof(proofs: Proof[], config: VerificationConfig): Promise<void>;
|
|
696
|
+
|
|
656
697
|
/**
|
|
657
698
|
* Verifies one or more Reclaim proofs by validating signatures, verifying witness information,
|
|
658
699
|
* and performing content validation against the expected configuration.
|
|
@@ -665,9 +706,8 @@ type ProviderHashRequirementsResponse = {
|
|
|
665
706
|
* * All 3 functions above are alternatives of each other and result from these functions can be directly used as `config` parameter in this function for proof validation.
|
|
666
707
|
*
|
|
667
708
|
* @param proofOrProofs - A single proof object or an array of proof objects to be verified.
|
|
668
|
-
* @param config - Verification configuration that specifies required hashes, allowed extra hashes, or disables content validation.
|
|
669
|
-
* @
|
|
670
|
-
* @returns Verification result with `isVerified`, extracted `data` from each proof, and `isTeeVerified` when `verifyTEE` is `true`
|
|
709
|
+
* @param config - Verification configuration that specifies required hashes, allowed extra hashes, or disables content validation. Optionally includes `verifyTEE` to require TEE attestation verification.
|
|
710
|
+
* @returns Verification result with `isVerified`, extracted `data` from each proof, optional `error` on failure, and `isTeeVerified` when `verifyTEE` is enabled.
|
|
671
711
|
*
|
|
672
712
|
* @example
|
|
673
713
|
* ```typescript
|
|
@@ -675,7 +715,7 @@ type ProviderHashRequirementsResponse = {
|
|
|
675
715
|
* const { isVerified, data } = await verifyProof(proof, request.getProviderVersion());
|
|
676
716
|
*
|
|
677
717
|
* // With TEE attestation verification (fails if TEE data is missing or invalid)
|
|
678
|
-
* const { isVerified, isTeeVerified, data } = await verifyProof(proof, request.getProviderVersion(), true);
|
|
718
|
+
* const { isVerified, isTeeVerified, data } = await verifyProof(proof, { ...request.getProviderVersion(), verifyTEE: true });
|
|
679
719
|
*
|
|
680
720
|
* // Or, by manually providing the details:
|
|
681
721
|
*
|
|
@@ -713,7 +753,7 @@ type ProviderHashRequirementsResponse = {
|
|
|
713
753
|
* });
|
|
714
754
|
* ```
|
|
715
755
|
*/
|
|
716
|
-
declare function verifyProof(proofOrProofs: Proof | Proof[], config: VerificationConfig
|
|
756
|
+
declare function verifyProof(proofOrProofs: Proof | Proof[], config: VerificationConfig): Promise<VerifyProofResult>;
|
|
717
757
|
/**
|
|
718
758
|
* Transforms a Reclaim proof into a format suitable for on-chain verification
|
|
719
759
|
*
|
|
@@ -756,7 +796,10 @@ declare class ReclaimProofRequest {
|
|
|
756
796
|
private templateData;
|
|
757
797
|
private extensionID;
|
|
758
798
|
private customSharePageUrl?;
|
|
799
|
+
private appSharePageUrl;
|
|
759
800
|
private customAppClipUrl?;
|
|
801
|
+
private portalTab?;
|
|
802
|
+
private portalIframe?;
|
|
760
803
|
private modalOptions?;
|
|
761
804
|
private modal?;
|
|
762
805
|
private readonly FAILURE_TIMEOUT;
|
|
@@ -832,11 +875,11 @@ declare class ReclaimProofRequest {
|
|
|
832
875
|
*
|
|
833
876
|
* @param url - The URL where users should be redirected after successful proof generation
|
|
834
877
|
* @param method - The redirection method that should be used for redirection. Allowed options: `GET`, and `POST`.
|
|
835
|
-
* `POST` form redirection is only supported in
|
|
878
|
+
* `POST` form redirection is only supported in Portal flow.
|
|
836
879
|
* @param body - List of name-value pairs to be sent as the body of the form request.
|
|
837
880
|
* `When `method` is set to `POST`, `body` will be sent with 'application/x-www-form-urlencoded' content type.
|
|
838
881
|
* When `method` is set to `GET`, if `body` is set then `body` will be sent as query parameters.
|
|
839
|
-
* Sending `body` on redirection is only supported in
|
|
882
|
+
* Sending `body` on redirection is only supported in Portal flow.
|
|
840
883
|
*
|
|
841
884
|
* @throws {InvalidParamError} When URL is invalid
|
|
842
885
|
*
|
|
@@ -889,11 +932,11 @@ declare class ReclaimProofRequest {
|
|
|
889
932
|
*
|
|
890
933
|
* @param url - The URL where users should be redirected after an error which aborts the verification process
|
|
891
934
|
* @param method - The redirection method that should be used for redirection. Allowed options: `GET`, and `POST`.
|
|
892
|
-
* `POST` form redirection is only supported in
|
|
935
|
+
* `POST` form redirection is only supported in Portal flow.
|
|
893
936
|
* @param body - List of name-value pairs to be sent as the body of the form request.
|
|
894
937
|
* When `method` is set to `POST`, `body` will be sent with 'application/x-www-form-urlencoded' content type.
|
|
895
938
|
* When `method` is set to `GET`, if `body` is set then `body` will be sent as query parameters.
|
|
896
|
-
* Sending `body` on redirection is only supported in
|
|
939
|
+
* Sending `body` on redirection is only supported in Portal flow.
|
|
897
940
|
* @throws {InvalidParamError} When URL is invalid
|
|
898
941
|
*
|
|
899
942
|
* @example
|
|
@@ -1066,7 +1109,24 @@ declare class ReclaimProofRequest {
|
|
|
1066
1109
|
private clearInterval;
|
|
1067
1110
|
private setAttestationContext;
|
|
1068
1111
|
private applyAttestationContext;
|
|
1112
|
+
private encodeTemplateData;
|
|
1069
1113
|
private buildSharePageUrl;
|
|
1114
|
+
private openPortalTab;
|
|
1115
|
+
private closePortalTab;
|
|
1116
|
+
private embedPortalIframe;
|
|
1117
|
+
/**
|
|
1118
|
+
* Closes the embedded portal iframe and stops the session polling.
|
|
1119
|
+
*
|
|
1120
|
+
* Call this to programmatically cancel the embedded verification flow
|
|
1121
|
+
* that was started with `triggerReclaimFlow({ target: element })`.
|
|
1122
|
+
* Also called automatically when verification succeeds or fails.
|
|
1123
|
+
*
|
|
1124
|
+
* @example
|
|
1125
|
+
* ```typescript
|
|
1126
|
+
* proofRequest.closeEmbeddedFlow();
|
|
1127
|
+
* ```
|
|
1128
|
+
*/
|
|
1129
|
+
closeEmbeddedFlow(): void;
|
|
1070
1130
|
/**
|
|
1071
1131
|
* Exports the Reclaim proof verification request as a JSON string
|
|
1072
1132
|
*
|
|
@@ -1109,7 +1169,7 @@ declare class ReclaimProofRequest {
|
|
|
1109
1169
|
* // Portal URL (default)
|
|
1110
1170
|
* const url = await proofRequest.getRequestUrl();
|
|
1111
1171
|
*
|
|
1112
|
-
* //
|
|
1172
|
+
* // Verifier app flow URL
|
|
1113
1173
|
* const url = await proofRequest.getRequestUrl({ verificationMode: 'app' });
|
|
1114
1174
|
* ```
|
|
1115
1175
|
*/
|
|
@@ -1118,8 +1178,9 @@ declare class ReclaimProofRequest {
|
|
|
1118
1178
|
* Triggers the appropriate Reclaim verification flow based on device type and configuration.
|
|
1119
1179
|
*
|
|
1120
1180
|
* Defaults to portal mode (remote browser verification). Pass `{ verificationMode: 'app' }`
|
|
1121
|
-
* for
|
|
1181
|
+
* for verifier app flow via the share page.
|
|
1122
1182
|
*
|
|
1183
|
+
* - **Embedded iframe**: Pass `{ target: element }` to embed the portal inside a DOM element instead of a new tab
|
|
1123
1184
|
* - Desktop: browser extension takes priority in both modes
|
|
1124
1185
|
* - Desktop portal mode (no extension): opens portal in new tab
|
|
1125
1186
|
* - Desktop app mode (no extension): shows QR code modal with share page URL
|
|
@@ -1127,15 +1188,22 @@ declare class ReclaimProofRequest {
|
|
|
1127
1188
|
* - Mobile app mode: opens share page (or App Clip on iOS if `useAppClip` is `true`)
|
|
1128
1189
|
*
|
|
1129
1190
|
* @param launchOptions - Optional launch configuration to override default behavior
|
|
1130
|
-
* @returns Promise<
|
|
1191
|
+
* @returns Promise<FlowHandle> - Handle to control the flow (close, access iframe)
|
|
1131
1192
|
* @throws {SignatureNotFoundError} When signature is not set
|
|
1132
1193
|
*
|
|
1133
1194
|
* @example
|
|
1134
1195
|
* ```typescript
|
|
1135
|
-
* // Portal flow (default)
|
|
1136
|
-
* await proofRequest.triggerReclaimFlow();
|
|
1196
|
+
* // Portal flow (default) — opens in new tab
|
|
1197
|
+
* const handle = await proofRequest.triggerReclaimFlow();
|
|
1198
|
+
* handle.tab; // Window reference to the opened tab
|
|
1199
|
+
* handle.close(); // close tab and stop polling
|
|
1200
|
+
*
|
|
1201
|
+
* // Embed portal in an iframe inside a DOM element
|
|
1202
|
+
* const handle = await proofRequest.triggerReclaimFlow({ target: document.getElementById('reclaim-container') });
|
|
1203
|
+
* handle.iframe; // HTMLIFrameElement reference
|
|
1204
|
+
* handle.close(); // remove iframe and stop polling
|
|
1137
1205
|
*
|
|
1138
|
-
* //
|
|
1206
|
+
* // Verifier app flow
|
|
1139
1207
|
* await proofRequest.triggerReclaimFlow({ verificationMode: 'app' });
|
|
1140
1208
|
*
|
|
1141
1209
|
* // App Clip on iOS (requires useAppClip: true at init)
|
|
@@ -1149,7 +1217,7 @@ declare class ReclaimProofRequest {
|
|
|
1149
1217
|
* await request.triggerReclaimFlow(); // uses 'app' mode from init
|
|
1150
1218
|
* ```
|
|
1151
1219
|
*/
|
|
1152
|
-
triggerReclaimFlow(launchOptions?: ReclaimFlowLaunchOptions): Promise<
|
|
1220
|
+
triggerReclaimFlow(launchOptions?: ReclaimFlowLaunchOptions): Promise<FlowHandle>;
|
|
1153
1221
|
/**
|
|
1154
1222
|
* Checks if the Reclaim browser extension is installed and available
|
|
1155
1223
|
*
|
|
@@ -1233,7 +1301,7 @@ declare class ReclaimProofRequest {
|
|
|
1233
1301
|
* });
|
|
1234
1302
|
* ```
|
|
1235
1303
|
*/
|
|
1236
|
-
startSession({ onSuccess, onError
|
|
1304
|
+
startSession({ onSuccess, onError }: StartSessionParams): Promise<void>;
|
|
1237
1305
|
/**
|
|
1238
1306
|
* Closes the QR code modal if it is currently open
|
|
1239
1307
|
*
|
|
@@ -1320,12 +1388,69 @@ declare function updateSession(sessionId: string, status: SessionStatus): Promis
|
|
|
1320
1388
|
declare function fetchStatusUrl(sessionId: string): Promise<StatusUrlResponse>;
|
|
1321
1389
|
declare function fetchProviderConfigs(providerId: string, exactProviderVersionString: string | null | undefined, allowedTags: string[] | null | undefined): Promise<ProviderConfigResponse>;
|
|
1322
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
|
+
|
|
1323
1434
|
/**
|
|
1324
1435
|
* Validates the hardware TEE attestation included in the proof.
|
|
1325
1436
|
* Throws an error if the attestation is invalid or compromised.
|
|
1326
1437
|
*/
|
|
1327
1438
|
declare function verifyTeeAttestation(proof: Proof, expectedApplicationId?: string): Promise<boolean>;
|
|
1328
1439
|
|
|
1440
|
+
declare const TeeVerificationError: {
|
|
1441
|
+
new (message?: string, innerError?: unknown | undefined): {
|
|
1442
|
+
innerError?: unknown | undefined;
|
|
1443
|
+
name: string;
|
|
1444
|
+
message: string;
|
|
1445
|
+
stack?: string;
|
|
1446
|
+
cause?: unknown;
|
|
1447
|
+
};
|
|
1448
|
+
isError(error: unknown): error is Error;
|
|
1449
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
1450
|
+
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
|
1451
|
+
stackTraceLimit: number;
|
|
1452
|
+
};
|
|
1453
|
+
|
|
1329
1454
|
/**
|
|
1330
1455
|
* Highly accurate device type detection - returns only 'desktop' or 'mobile'
|
|
1331
1456
|
* Uses multiple detection methods and scoring system for maximum accuracy
|
|
@@ -1353,4 +1478,4 @@ declare function isDesktopDevice(): boolean;
|
|
|
1353
1478
|
*/
|
|
1354
1479
|
declare function clearDeviceCache(): void;
|
|
1355
1480
|
|
|
1356
|
-
export { type Beacon, type BeaconState, type BodySniff, ClaimCreationType, type ClaimID, type ClaimInfo, type CompleteClaimData, type Context, type CreateVerificationRequest, DeviceType, type ExtensionMessage, 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, type TemplateData, 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 };
|