@reclaimprotocol/js-sdk 5.1.0 → 5.2.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 +50 -19
- package/dist/index.d.ts +58 -16
- package/dist/index.js +328 -712
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ Install the Reclaim Protocol SDK and a QR code generator:
|
|
|
37
37
|
npm install @reclaimprotocol/js-sdk react-qr-code
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
**Current SDK Version**:
|
|
40
|
+
**Current SDK Version**: 5.2.0
|
|
41
41
|
|
|
42
42
|
## Step 3: Set up your React component
|
|
43
43
|
|
|
@@ -703,7 +703,7 @@ const { isVerified } = await verifyProof(proof, {
|
|
|
703
703
|
|
|
704
704
|
## TEE Attestation Verification
|
|
705
705
|
|
|
706
|
-
The SDK supports verifying TEE (Trusted Execution Environment) attestations included in proofs.
|
|
706
|
+
The SDK supports verifying TEE (Trusted Execution Environment) attestations included in proofs. The attestation flow verifies the Google Confidential Computing OIDC token returned by Popcorn's GCP attestor and checks that it is bound to the proof nonce, application identity, and image digests.
|
|
707
707
|
|
|
708
708
|
### Enabling TEE Attestation
|
|
709
709
|
|
|
@@ -715,19 +715,23 @@ const proofRequest = await ReclaimProofRequest.init(APP_ID, APP_SECRET, PROVIDER
|
|
|
715
715
|
});
|
|
716
716
|
```
|
|
717
717
|
|
|
718
|
-
### Verifying TEE Attestation
|
|
718
|
+
### Verifying TEE Attestation via `verifyProof`
|
|
719
719
|
|
|
720
|
-
|
|
720
|
+
Provide a `teeAttestation` config to require and verify TEE attestation. The application ID is derived automatically from `appSecret`. If TEE data is missing or invalid, verification will fail with a `TeeVerificationError`.
|
|
721
721
|
|
|
722
722
|
```javascript
|
|
723
723
|
import { verifyProof, TeeVerificationError } from "@reclaimprotocol/js-sdk";
|
|
724
724
|
|
|
725
|
-
|
|
726
|
-
|
|
725
|
+
const { isVerified, isTeeAttestationVerified, data, error } = await verifyProof(proof, {
|
|
726
|
+
hashes: ['0xAbC...'],
|
|
727
|
+
teeAttestation: {
|
|
728
|
+
appSecret: APP_SECRET,
|
|
729
|
+
},
|
|
730
|
+
});
|
|
727
731
|
|
|
728
732
|
if (isVerified) {
|
|
729
|
-
console.log("Proof
|
|
730
|
-
console.log("TEE verified:",
|
|
733
|
+
console.log("Proof verified with hardware attestation");
|
|
734
|
+
console.log("TEE verified:", isTeeAttestationVerified); // always true when teeAttestation is provided and passes
|
|
731
735
|
console.log("Extracted parameters:", data[0].extractedParameters);
|
|
732
736
|
} else if (error instanceof TeeVerificationError) {
|
|
733
737
|
console.log("TEE verification failed:", error.message);
|
|
@@ -736,27 +740,54 @@ if (isVerified) {
|
|
|
736
740
|
}
|
|
737
741
|
```
|
|
738
742
|
|
|
739
|
-
|
|
743
|
+
The result includes `isTeeAttestationVerified`. It is `true` when `teeAttestation` was provided and verification passed, and `undefined` when `teeAttestation` was not requested.
|
|
744
|
+
|
|
745
|
+
### What TEE verification checks
|
|
740
746
|
|
|
741
|
-
|
|
747
|
+
- **Application binding**: Derives the application ID from `appSecret` and confirms the attestation was generated for your application
|
|
742
748
|
- **Nonce binding**: Ensures the attestation nonce matches the proof context
|
|
743
|
-
- **
|
|
744
|
-
- **
|
|
745
|
-
- **
|
|
746
|
-
- **
|
|
747
|
-
- **Report data**: Confirms the workload and verifier digests match the attestation
|
|
749
|
+
- **Session and timestamp binding**: Verifies the nonce metadata matches the proof session and is within the allowed skew
|
|
750
|
+
- **OIDC token signature**: Validates the Google Confidential Computing attestation JWT against Google's JWKS (responses are cached for 5 minutes)
|
|
751
|
+
- **Platform claims**: Confirms the expected GCP confidential-computing claims (issuer, secure boot, hardware model, GCE instance metadata)
|
|
752
|
+
- **Digest binding**: Confirms the workload and verifier image digests are present in the attestation token nonce list
|
|
748
753
|
|
|
749
|
-
|
|
754
|
+
### Standalone `verifyTeeAttestation`
|
|
755
|
+
|
|
756
|
+
You can verify TEE attestation for a single proof without running full proof verification:
|
|
750
757
|
|
|
751
758
|
```javascript
|
|
752
759
|
import { verifyTeeAttestation } from "@reclaimprotocol/js-sdk";
|
|
753
760
|
|
|
754
|
-
const
|
|
755
|
-
if (
|
|
756
|
-
console.log("TEE attestation verified
|
|
761
|
+
const { isVerified, error } = await verifyTeeAttestation(proof, APP_SECRET);
|
|
762
|
+
if (isVerified) {
|
|
763
|
+
console.log("TEE attestation verified");
|
|
764
|
+
} else {
|
|
765
|
+
console.log("TEE verification failed:", error);
|
|
757
766
|
}
|
|
758
767
|
```
|
|
759
768
|
|
|
769
|
+
`appSecret` is your Reclaim application secret. The application ID is derived from it automatically.
|
|
770
|
+
|
|
771
|
+
### Browser vs Server Verification
|
|
772
|
+
|
|
773
|
+
TEE verification fetches Google's OIDC metadata and JWKS endpoints. In browser-only environments this may fail due to cross-origin restrictions.
|
|
774
|
+
|
|
775
|
+
For web apps, verify TEE attestations on the server:
|
|
776
|
+
|
|
777
|
+
```javascript
|
|
778
|
+
const response = await fetch('/api/verify-tee', {
|
|
779
|
+
method: 'POST',
|
|
780
|
+
headers: { 'Content-Type': 'application/json' },
|
|
781
|
+
body: JSON.stringify({ proofs }),
|
|
782
|
+
});
|
|
783
|
+
|
|
784
|
+
const { results } = await response.json();
|
|
785
|
+
console.log(results);
|
|
786
|
+
```
|
|
787
|
+
|
|
788
|
+
The server route should read the app secret from environment variables only (never accept it from the client request body). See the example app for a reference implementation:
|
|
789
|
+
- `example/src/app/api/verify-tee/route.ts`
|
|
790
|
+
|
|
760
791
|
## Error Handling
|
|
761
792
|
|
|
762
793
|
The SDK provides specific error types for different failure scenarios. Here's how to handle them:
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
interface TeeAttestation {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
proof_version: string;
|
|
3
|
+
tee_provider: string;
|
|
4
|
+
tee_technology: string;
|
|
4
5
|
nonce: string;
|
|
5
|
-
snp_report: string;
|
|
6
|
-
vlek_cert: string;
|
|
7
6
|
timestamp: string;
|
|
7
|
+
workload: {
|
|
8
|
+
container_name: string;
|
|
9
|
+
image_digest: string;
|
|
10
|
+
};
|
|
11
|
+
verifier: {
|
|
12
|
+
container_name: string;
|
|
13
|
+
image_digest: string;
|
|
14
|
+
};
|
|
15
|
+
attestation: {
|
|
16
|
+
token: string;
|
|
17
|
+
};
|
|
18
|
+
error?: {
|
|
19
|
+
code: string;
|
|
20
|
+
message: string;
|
|
21
|
+
};
|
|
8
22
|
}
|
|
9
23
|
interface Proof {
|
|
10
24
|
identifier: string;
|
|
@@ -345,13 +359,22 @@ type ValidationConfig = ValidationConfigWithHash | ValidationConfigWithProviderI
|
|
|
345
359
|
* Describes the comprehensive configuration required to initialize the proof verification process.
|
|
346
360
|
* Aligns with `ValidationConfig` options for verifying signatures alongside proof contents.
|
|
347
361
|
*/
|
|
362
|
+
type TeeAttestationConfig = {
|
|
363
|
+
/**
|
|
364
|
+
* Your application secret (Ethereum private key).
|
|
365
|
+
* Used to recompute the TEE attestation nonce and to derive the application ID
|
|
366
|
+
* for binding the attestation to your application.
|
|
367
|
+
*/
|
|
368
|
+
appSecret: string;
|
|
369
|
+
};
|
|
348
370
|
type VerificationConfig = ValidationConfig & {
|
|
349
371
|
/**
|
|
350
|
-
*
|
|
351
|
-
* When
|
|
352
|
-
*
|
|
372
|
+
* TEE attestation verification configuration.
|
|
373
|
+
* When provided, verifies the TEE attestation included in the proof.
|
|
374
|
+
* The result will include `isTeeAttestationVerified` and `isVerified` will be false
|
|
375
|
+
* if TEE attestation data is missing or verification fails.
|
|
353
376
|
*/
|
|
354
|
-
|
|
377
|
+
teeAttestation?: TeeAttestationConfig;
|
|
355
378
|
};
|
|
356
379
|
declare function assertValidProofsByHash(proofs: Proof[], config: ProviderHashRequirementsConfig): void;
|
|
357
380
|
declare function isHttpProviderClaimParams(claimParams: unknown): claimParams is HttpProviderClaimParams;
|
|
@@ -672,14 +695,14 @@ type TrustedData = {
|
|
|
672
695
|
};
|
|
673
696
|
type VerifyProofResultSuccess = {
|
|
674
697
|
isVerified: true;
|
|
675
|
-
|
|
698
|
+
isTeeAttestationVerified?: boolean;
|
|
676
699
|
error: undefined;
|
|
677
700
|
data: TrustedData[];
|
|
678
701
|
publicData: any[];
|
|
679
702
|
};
|
|
680
703
|
type VerifyProofResultFailure = {
|
|
681
704
|
isVerified: false;
|
|
682
|
-
|
|
705
|
+
isTeeAttestationVerified?: boolean;
|
|
683
706
|
error: Error;
|
|
684
707
|
data: [];
|
|
685
708
|
publicData: [];
|
|
@@ -743,8 +766,8 @@ type ProviderHashRequirementsResponse = {
|
|
|
743
766
|
* * 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.
|
|
744
767
|
*
|
|
745
768
|
* @param proofOrProofs - A single proof object or an array of proof objects to be verified.
|
|
746
|
-
* @param config - Verification configuration that specifies required hashes, allowed extra hashes, or disables content validation. Optionally includes `
|
|
747
|
-
* @returns Verification result with `isVerified`, extracted `data` from each proof, optional `error` on failure
|
|
769
|
+
* @param config - Verification configuration that specifies required hashes, allowed extra hashes, or disables content validation. Optionally includes `teeAttestation` to require TEE attestation verification.
|
|
770
|
+
* @returns Verification result with `isVerified`, `isTeeAttestationVerified` (always boolean), extracted `data` from each proof, and optional `error` on failure. The application ID is derived from `appSecret` automatically.
|
|
748
771
|
*
|
|
749
772
|
* @example
|
|
750
773
|
* ```typescript
|
|
@@ -752,7 +775,7 @@ type ProviderHashRequirementsResponse = {
|
|
|
752
775
|
* const { isVerified, data } = await verifyProof(proof, request.getProviderVersion());
|
|
753
776
|
*
|
|
754
777
|
* // With TEE attestation verification (fails if TEE data is missing or invalid)
|
|
755
|
-
* const { isVerified,
|
|
778
|
+
* const { isVerified, isTeeAttestationVerified, data } = await verifyProof(proof, { ...request.getProviderVersion(), teeAttestation: { appSecret: APP_SECRET } });
|
|
756
779
|
*
|
|
757
780
|
* // Or, by manually providing the details:
|
|
758
781
|
*
|
|
@@ -1469,11 +1492,30 @@ declare function hashProofClaimParams(params: HttpProviderClaimParams): string |
|
|
|
1469
1492
|
*/
|
|
1470
1493
|
declare function getProviderParamsAsCanonicalizedString(params: HttpProviderClaimParams): string[];
|
|
1471
1494
|
|
|
1495
|
+
type TeeVerificationResult = {
|
|
1496
|
+
isVerified: boolean;
|
|
1497
|
+
error?: string;
|
|
1498
|
+
};
|
|
1472
1499
|
/**
|
|
1473
1500
|
* Validates the hardware TEE attestation included in the proof.
|
|
1474
|
-
*
|
|
1501
|
+
* Derives the application ID from `appSecret` and verifies the attestation
|
|
1502
|
+
* was generated for your application.
|
|
1503
|
+
* Returns a result object with `isVerified` and an optional `error` message.
|
|
1504
|
+
*
|
|
1505
|
+
* @param proof - The proof containing TEE attestation data
|
|
1506
|
+
* @param appSecret - Your application secret (Ethereum private key). Used to
|
|
1507
|
+
* derive the application ID and recompute the attestation nonce.
|
|
1508
|
+
*/
|
|
1509
|
+
declare function verifyTeeAttestation(proof: Proof, appSecret: string): Promise<TeeVerificationResult>;
|
|
1510
|
+
/**
|
|
1511
|
+
* Verifies TEE attestation for all proofs.
|
|
1512
|
+
* Throws `TeeVerificationError` if any proof is missing TEE data or fails verification.
|
|
1513
|
+
*
|
|
1514
|
+
* @param proofs - The proofs to verify
|
|
1515
|
+
* @param config - TEE attestation configuration containing the app secret
|
|
1516
|
+
* @throws {TeeVerificationError} When TEE data is missing or verification fails
|
|
1475
1517
|
*/
|
|
1476
|
-
declare function
|
|
1518
|
+
declare function runTeeVerification(proofs: Proof[], config: TeeAttestationConfig): Promise<void>;
|
|
1477
1519
|
|
|
1478
1520
|
declare const TeeVerificationError: {
|
|
1479
1521
|
new (message?: string, innerError?: unknown | undefined): {
|
|
@@ -1516,4 +1558,4 @@ declare function isDesktopDevice(): boolean;
|
|
|
1516
1558
|
*/
|
|
1517
1559
|
declare function clearDeviceCache(): void;
|
|
1518
1560
|
|
|
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 };
|
|
1561
|
+
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, type TeeAttestationConfig, TeeVerificationError, type TeeVerificationResult, 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, runTeeVerification, takePairsWhereValueIsArray, takeTemplateParametersFromProofs, transformForOnchain, updateSession, verifyProof, verifyTeeAttestation };
|