@reclaimprotocol/js-sdk 5.3.0 → 5.4.1
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 +144 -1
- package/dist/index.js +502 -135
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -51,6 +51,22 @@ interface ExtensionMessage {
|
|
|
51
51
|
interface WitnessData {
|
|
52
52
|
id: string;
|
|
53
53
|
url: string;
|
|
54
|
+
claimAttestation?: AttestorClaimAttestation;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Attestation produced by an attestor running inside a Trusted Execution
|
|
58
|
+
* Environment. Binds the attestor's signing key (and its signature over
|
|
59
|
+
* the claim) to a hardware-backed enclave identity.
|
|
60
|
+
*
|
|
61
|
+
* Verified by `runAttestorTeeVerification`.
|
|
62
|
+
*/
|
|
63
|
+
interface AttestorClaimAttestation {
|
|
64
|
+
/** ETH address of the attestor whose enclave produced the attestation. Matches `WitnessData.id`. */
|
|
65
|
+
attestor_address: string;
|
|
66
|
+
/** Attestor signature over the claim. Must equal the corresponding entry in `Proof.signatures`. */
|
|
67
|
+
claim_signature: string;
|
|
68
|
+
/** Raw attestation report. For GCP Confidential Space, a JWT (header.payload.signature). */
|
|
69
|
+
attestation_report: string;
|
|
54
70
|
}
|
|
55
71
|
interface ProviderClaimData {
|
|
56
72
|
provider: string;
|
|
@@ -299,6 +315,59 @@ interface ResponseRedactionSpec {
|
|
|
299
315
|
xPath: string;
|
|
300
316
|
}
|
|
301
317
|
|
|
318
|
+
/**
|
|
319
|
+
* Result of verifying an attestor TEE attestation.
|
|
320
|
+
*/
|
|
321
|
+
type AttestorTeeVerificationResult = {
|
|
322
|
+
isVerified: boolean;
|
|
323
|
+
error?: string;
|
|
324
|
+
/** sha256 image digest of the attestor container, on success. */
|
|
325
|
+
imageDigest?: string;
|
|
326
|
+
};
|
|
327
|
+
/**
|
|
328
|
+
* Validates a GCP Confidential Space attestation JWT produced by an
|
|
329
|
+
* attestor running in a Confidential Space VM, and asserts that the
|
|
330
|
+
* attestation binds to the given attestor address.
|
|
331
|
+
*
|
|
332
|
+
* The attestor (running inside the TEE) calls the Confidential Space
|
|
333
|
+
* launcher's attestation endpoint with two nonces:
|
|
334
|
+
* - `attestor_public_key:<eth-address>` - binds to the signing key.
|
|
335
|
+
* - `attestor_cert_hash:<sha256-hex>` - binds to the live TLS cert.
|
|
336
|
+
*
|
|
337
|
+
* This function only verifies the public-key nonce. The TLS cert hash
|
|
338
|
+
* binding is informational and not checked here. Callers that need to
|
|
339
|
+
* pin to a specific attestor image should compare the returned
|
|
340
|
+
* `imageDigest` against a known-good value.
|
|
341
|
+
*
|
|
342
|
+
* The JWT signature is verified by walking the x5c certificate chain
|
|
343
|
+
* to a pinned GCP Confidential Space Root CA. No outbound network
|
|
344
|
+
* calls are made.
|
|
345
|
+
*
|
|
346
|
+
* Node-only (uses node:crypto). Mirrors the environment restriction in
|
|
347
|
+
* the existing `verifyTeeAttestation` helper.
|
|
348
|
+
*
|
|
349
|
+
* @param report - the raw JWT string (header.payload.signature).
|
|
350
|
+
* @param expectedAttestorAddress - hex ETH address (0x-prefixed or
|
|
351
|
+
* unprefixed) that the attestation should be bound to.
|
|
352
|
+
*/
|
|
353
|
+
declare function verifyAttestorTeeAttestation(report: string, expectedAttestorAddress: string): Promise<AttestorTeeVerificationResult>;
|
|
354
|
+
/**
|
|
355
|
+
* Configuration for verifying the attestor's TEE attestation on each
|
|
356
|
+
* witness of the proof.
|
|
357
|
+
*/
|
|
358
|
+
type AttestorTeeAttestationConfig = {
|
|
359
|
+
/**
|
|
360
|
+
* Optional allowlist of expected attestor container image digests
|
|
361
|
+
* (e.g. `"sha256:4906340f..."`). When provided, the attestation's
|
|
362
|
+
* `submods.container.image_digest` must be in this list.
|
|
363
|
+
*
|
|
364
|
+
* Leave undefined to skip image pinning and rely solely on the JWT
|
|
365
|
+
* chain rooting to the GCP Confidential Space Root CA + nonce
|
|
366
|
+
* binding to the attestor address.
|
|
367
|
+
*/
|
|
368
|
+
expectedImageDigests?: string[];
|
|
369
|
+
};
|
|
370
|
+
|
|
302
371
|
/**
|
|
303
372
|
* Content validation configuration specifying essential required hashes and optional extra proofs.
|
|
304
373
|
* Used to explicitly validate that a generated proof matches the exact request structure expected.
|
|
@@ -378,6 +447,20 @@ type VerificationConfig = ValidationConfig & {
|
|
|
378
447
|
* if TEE attestation data is missing or verification fails.
|
|
379
448
|
*/
|
|
380
449
|
teeAttestation?: TeeAttestationConfig;
|
|
450
|
+
/**
|
|
451
|
+
* Attestor TEE attestation verification configuration.
|
|
452
|
+
* When provided, verifies that every witness on every proof has a valid
|
|
453
|
+
* `claimAttestation` from an attestor running inside a TEE (GCP
|
|
454
|
+
* Confidential Space).
|
|
455
|
+
*
|
|
456
|
+
* Independent of `teeAttestation`, which verifies the verifier-app's
|
|
457
|
+
* own TEE attestation. Both can be enabled together.
|
|
458
|
+
*
|
|
459
|
+
* The result will include `isAttestorTeeAttestationVerified` and
|
|
460
|
+
* `isVerified` will be false if any witness is missing TEE attestation
|
|
461
|
+
* data or its verification fails.
|
|
462
|
+
*/
|
|
463
|
+
attestorTeeAttestation?: AttestorTeeAttestationConfig;
|
|
381
464
|
};
|
|
382
465
|
declare function assertValidProofsByHash(proofs: Proof[], config: ProviderHashRequirementsConfig): void;
|
|
383
466
|
declare function isHttpProviderClaimParams(claimParams: unknown): claimParams is HttpProviderClaimParams;
|
|
@@ -703,6 +786,7 @@ type TrustedData = {
|
|
|
703
786
|
type VerifyProofResultSuccess = {
|
|
704
787
|
isVerified: true;
|
|
705
788
|
isTeeAttestationVerified?: boolean;
|
|
789
|
+
isAttestorTeeAttestationVerified?: boolean;
|
|
706
790
|
error: undefined;
|
|
707
791
|
data: TrustedData[];
|
|
708
792
|
publicData: any[];
|
|
@@ -710,6 +794,7 @@ type VerifyProofResultSuccess = {
|
|
|
710
794
|
type VerifyProofResultFailure = {
|
|
711
795
|
isVerified: false;
|
|
712
796
|
isTeeAttestationVerified?: boolean;
|
|
797
|
+
isAttestorTeeAttestationVerified?: boolean;
|
|
713
798
|
error: Error;
|
|
714
799
|
data: [];
|
|
715
800
|
publicData: [];
|
|
@@ -899,6 +984,47 @@ declare class ReclaimProofRequest {
|
|
|
899
984
|
* ```
|
|
900
985
|
*/
|
|
901
986
|
static init(applicationId: string, appSecret: string, providerId: string, options?: ProofRequestOptions): Promise<ReclaimProofRequest>;
|
|
987
|
+
/**
|
|
988
|
+
* Initializes a new Reclaim proof request using a signature computed externally
|
|
989
|
+
* (e.g. on a trusted backend), so `appSecret` never has to live on the client.
|
|
990
|
+
*
|
|
991
|
+
* The signature must be produced over `canonicalize({ providerId, timestamp })`
|
|
992
|
+
* using the application's `appSecret` — see `generateInitSignature()` for the
|
|
993
|
+
* exact algorithm. The same `timestamp` used at signing time must be passed here.
|
|
994
|
+
*
|
|
995
|
+
* TEE attestation: the attestation nonce depends on `sessionId`, which is only
|
|
996
|
+
* known after the backend init call. To use TEE without exposing `appSecret`,
|
|
997
|
+
* pass an async `getAttestationNonce` callback that derives the nonce on your
|
|
998
|
+
* server using `generateAttestationNonce(appSecret, applicationId, sessionId, timestamp)`.
|
|
999
|
+
* If `acceptTeeAttestation` is left enabled but no callback is provided, init throws.
|
|
1000
|
+
*
|
|
1001
|
+
* @param applicationId - Your Reclaim application ID
|
|
1002
|
+
* @param providerId - The ID of the provider to use for proof generation
|
|
1003
|
+
* @param sessionAuth - Pre-computed signature, the timestamp it was signed over,
|
|
1004
|
+
* and an optional async callback to compute the attestation nonce.
|
|
1005
|
+
* @param options - Optional configuration options for the proof request
|
|
1006
|
+
*
|
|
1007
|
+
* @example
|
|
1008
|
+
* ```typescript
|
|
1009
|
+
* // Backend (Node):
|
|
1010
|
+
* const timestamp = Date.now().toString();
|
|
1011
|
+
* const signature = await generateInitSignature(APP_SECRET, providerId, timestamp);
|
|
1012
|
+
* // ...return { signature, timestamp } to the client...
|
|
1013
|
+
*
|
|
1014
|
+
* // Client:
|
|
1015
|
+
* const proofRequest = await ReclaimProofRequest.initWithSignature(
|
|
1016
|
+
* applicationId,
|
|
1017
|
+
* providerId,
|
|
1018
|
+
* { signature, timestamp },
|
|
1019
|
+
* { acceptTeeAttestation: false }
|
|
1020
|
+
* );
|
|
1021
|
+
* ```
|
|
1022
|
+
*/
|
|
1023
|
+
static initWithSignature(applicationId: string, providerId: string, sessionAuth: {
|
|
1024
|
+
signature: string;
|
|
1025
|
+
timestamp: string;
|
|
1026
|
+
getAttestationNonce?: (sessionId: string) => Promise<string> | string;
|
|
1027
|
+
}, options?: ProofRequestOptions): Promise<ReclaimProofRequest>;
|
|
902
1028
|
/**
|
|
903
1029
|
* Creates a ReclaimProofRequest instance from a JSON string representation
|
|
904
1030
|
*
|
|
@@ -1178,6 +1304,7 @@ declare class ReclaimProofRequest {
|
|
|
1178
1304
|
* ```
|
|
1179
1305
|
*/
|
|
1180
1306
|
getSessionId(): string;
|
|
1307
|
+
private static validateInitOptions;
|
|
1181
1308
|
private setSignature;
|
|
1182
1309
|
private generateSignature;
|
|
1183
1310
|
private clearInterval;
|
|
@@ -1463,6 +1590,22 @@ declare function updateSession(sessionId: string, status: SessionStatus): Promis
|
|
|
1463
1590
|
declare function fetchStatusUrl(sessionId: string): Promise<StatusUrlResponse>;
|
|
1464
1591
|
declare function fetchProviderConfigs(providerId: string, exactProviderVersionString: string | null | undefined, allowedTags: string[] | null | undefined): Promise<ProviderConfigResponse>;
|
|
1465
1592
|
|
|
1593
|
+
/**
|
|
1594
|
+
* Computes the signature required by `initSession` over `{providerId, timestamp}`.
|
|
1595
|
+
*
|
|
1596
|
+
* Use this on a trusted server (where `appSecret` lives) to produce a signature
|
|
1597
|
+
* that can then be passed to `ReclaimProofRequest.initWithSignature(...)` from a
|
|
1598
|
+
* client that never sees the secret.
|
|
1599
|
+
*
|
|
1600
|
+
* @param appSecret - The application secret (private key). Must remain server-side.
|
|
1601
|
+
* @param providerId - The provider id the session will be initialized against.
|
|
1602
|
+
* @param timestamp - The timestamp (ms epoch as string) that will be sent with init.
|
|
1603
|
+
* The same value MUST be passed to `initWithSignature`.
|
|
1604
|
+
*/
|
|
1605
|
+
declare function generateInitSignature(appSecret: string, providerId: string, timestamp: string): Promise<string>;
|
|
1606
|
+
|
|
1607
|
+
declare function generateAttestationNonce(appSecret: string, applicationId: string, sessionId: string, timestamp: string): string;
|
|
1608
|
+
|
|
1466
1609
|
declare function createSignDataForClaim(data: CompleteClaimData): string;
|
|
1467
1610
|
declare function getIdentifierFromClaimInfo(info: ClaimInfo): ClaimID;
|
|
1468
1611
|
/**
|
|
@@ -1576,4 +1719,4 @@ declare function isDesktopDevice(): boolean;
|
|
|
1576
1719
|
*/
|
|
1577
1720
|
declare function clearDeviceCache(): void;
|
|
1578
1721
|
|
|
1579
|
-
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, SUPPORTED_TEE_ATTESTATION_VERSIONS, type SerializableModalOptions, SessionStatus, type SignedClaim, type StartSessionParams, type StatusUrlResponse, type TeeAttestation, type TeeAttestationConfig, type TeeAttestationVersion, 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 };
|
|
1722
|
+
export { type AttestorClaimAttestation, type AttestorTeeVerificationResult, 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, SUPPORTED_TEE_ATTESTATION_VERSIONS, type SerializableModalOptions, SessionStatus, type SignedClaim, type StartSessionParams, type StatusUrlResponse, type TeeAttestation, type TeeAttestationConfig, type TeeAttestationVersion, 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, generateAttestationNonce, generateInitSignature, generateSpecsFromRequestSpecTemplate, getAttestors, getDeviceType, getHttpProviderClaimParamsFromProof, getIdentifierFromClaimInfo, getMobileDeviceType, getProviderHashRequirementSpecFromProviderConfig, getProviderHashRequirementsFromSpec, getProviderParamsAsCanonicalizedString, getShortenedUrl, hashProofClaimParams, hashRequestSpec, initSession, isDesktopDevice, isHttpProviderClaimParams, isMobileDevice, recoverSignersOfSignedClaim, runTeeVerification, takePairsWhereValueIsArray, takeTemplateParametersFromProofs, transformForOnchain, updateSession, verifyAttestorTeeAttestation, verifyProof, verifyTeeAttestation };
|