@reclaimprotocol/js-sdk 5.2.0 → 5.3.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 +53 -5
- package/dist/index.d.ts +21 -3
- package/dist/index.js +42 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -701,20 +701,68 @@ const { isVerified } = await verifyProof(proof, {
|
|
|
701
701
|
});
|
|
702
702
|
```
|
|
703
703
|
|
|
704
|
+
### Replay Protection
|
|
705
|
+
|
|
706
|
+
Proofs are submitted by the user, so the server must not trust any field on the proof in isolation. `verifyProof` (and `verifyTeeAttestation`) cryptographically bind a proof to a specific session, but **the SDK is stateless** — it cannot tell whether the same valid proof has already been verified. Preventing replay is the caller's responsibility.
|
|
707
|
+
|
|
708
|
+
**What the SDK guarantees**
|
|
709
|
+
|
|
710
|
+
The `attestationNonce` baked into the proof context is computed as `keccak256("RECLAIM_TEE_NONCE_V1" : applicationId : sessionId : timestamp : appSecret)`. When you call `verifyProof` with `teeAttestation: { appSecret }`, the SDK:
|
|
711
|
+
|
|
712
|
+
- Recomputes the nonce from `(applicationId, sessionId, timestamp)` in the proof context using **your** `appSecret` and asserts it matches — only the holder of the app secret can mint a valid nonce, so the user cannot rebind a proof to a different `sessionId` or `applicationId`.
|
|
713
|
+
- Confirms the recomputed nonce appears in the TEE attestation token's `eat_nonce` (signed by Google's Confidential Computing OIDC issuer), so the TEE-signed binding cannot be forged either.
|
|
714
|
+
- Asserts the `applicationId` in the nonce data matches the address derived from `appSecret`, and that `sessionId` in the nonce data agrees with `reclaimSessionId` in `claimData.context` and `proxySessionId`/`sessionId` in `claimData.parameters`.
|
|
715
|
+
- Asserts `claimData.timestampS` is within 10 minutes of the nonce timestamp.
|
|
716
|
+
|
|
717
|
+
In short: the user cannot mutate `sessionId`, `applicationId`, or `timestamp` on a proof without invalidating it. They *can*, however, resubmit the same valid proof.
|
|
718
|
+
|
|
719
|
+
**What you must do on your server**
|
|
720
|
+
|
|
721
|
+
1. **Use a session you initiated.** Call `ReclaimProofRequest.init(...)` and `getSessionId()` server-side (or record the `sessionId` returned to your callback). When verifying, reject any proof whose `sessionId` you did not issue.
|
|
722
|
+
2. **Dedupe by `sessionId`.** Persist accepted `sessionId`s (e.g., a unique index in your DB or a TTL cache) and reject a `sessionId` that has already been verified. This is the primary replay defense.
|
|
723
|
+
3. **Require `teeAttestation`** in `verifyProof` for any flow where replay or tampering matters — without it, the cryptographic binding to `appSecret` is not checked.
|
|
724
|
+
4. **Enforce a freshness window.** Reject proofs whose `claimData.timestampS` is older than your business policy allows (the SDK only enforces a 10-minute skew between the nonce timestamp and claim timestamp, not absolute freshness).
|
|
725
|
+
|
|
726
|
+
```javascript
|
|
727
|
+
// Pseudocode for a server-side verification handler
|
|
728
|
+
const expectedSessionId = await loadSessionForUser(req.user); // session you created
|
|
729
|
+
const sessionId = JSON.parse(proof.claimData.context).reclaimSessionId;
|
|
730
|
+
|
|
731
|
+
if (sessionId !== expectedSessionId) {
|
|
732
|
+
throw new Error("session mismatch");
|
|
733
|
+
}
|
|
734
|
+
if (await db.consumedSessions.has(sessionId)) {
|
|
735
|
+
throw new Error("proof already used"); // replay
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
const { isVerified, error } = await verifyProof(proof, {
|
|
739
|
+
...providerVersion,
|
|
740
|
+
teeAttestation: { appSecret: process.env.APP_SECRET },
|
|
741
|
+
});
|
|
742
|
+
if (!isVerified) throw error;
|
|
743
|
+
|
|
744
|
+
await db.consumedSessions.add(sessionId); // mark consumed atomically
|
|
745
|
+
```
|
|
746
|
+
|
|
747
|
+
> [!WARNING]
|
|
748
|
+
> Without server-side session tracking and dedup, a malicious user can submit the same valid proof repeatedly. The cryptographic checks in `verifyProof` are necessary but not sufficient for replay protection.
|
|
749
|
+
|
|
704
750
|
## TEE Attestation Verification
|
|
705
751
|
|
|
706
752
|
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
753
|
|
|
708
|
-
###
|
|
754
|
+
### Requesting TEE Attestation
|
|
709
755
|
|
|
710
|
-
|
|
756
|
+
TEE attestation is requested by default during proof generation:
|
|
711
757
|
|
|
712
758
|
```javascript
|
|
713
|
-
const proofRequest = await ReclaimProofRequest.init(APP_ID, APP_SECRET, PROVIDER_ID
|
|
714
|
-
acceptTeeAttestation: true,
|
|
715
|
-
});
|
|
759
|
+
const proofRequest = await ReclaimProofRequest.init(APP_ID, APP_SECRET, PROVIDER_ID);
|
|
716
760
|
```
|
|
717
761
|
|
|
762
|
+
The request includes the SDK's attestation version so the attestor can continue serving older SDK clients when newer attestation formats are introduced.
|
|
763
|
+
|
|
764
|
+
To opt out, set `acceptTeeAttestation: false` during initialization.
|
|
765
|
+
|
|
718
766
|
### Verifying TEE Attestation via `verifyProof`
|
|
719
767
|
|
|
720
768
|
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`.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
declare const SUPPORTED_TEE_ATTESTATION_VERSIONS: readonly ["v2", "v3"];
|
|
2
|
+
type TeeAttestationVersion = typeof SUPPORTED_TEE_ATTESTATION_VERSIONS[number];
|
|
1
3
|
interface TeeAttestation {
|
|
2
|
-
proof_version:
|
|
4
|
+
proof_version: TeeAttestationVersion;
|
|
3
5
|
tee_provider: string;
|
|
4
6
|
tee_technology: string;
|
|
5
7
|
nonce: string;
|
|
@@ -70,6 +72,7 @@ interface Context {
|
|
|
70
72
|
applicationId: string;
|
|
71
73
|
sessionId: string;
|
|
72
74
|
timestamp: string;
|
|
75
|
+
attestationVersion?: TeeAttestationVersion;
|
|
73
76
|
};
|
|
74
77
|
}
|
|
75
78
|
interface Beacon {
|
|
@@ -503,7 +506,9 @@ type ProofRequestOptions = {
|
|
|
503
506
|
*/
|
|
504
507
|
metadata?: Record<string, string>;
|
|
505
508
|
/**
|
|
506
|
-
*
|
|
509
|
+
* Generates a TEE attestation nonce during session initialization and expects a TEE attestation in the proof.
|
|
510
|
+
*
|
|
511
|
+
* @default true
|
|
507
512
|
*/
|
|
508
513
|
acceptTeeAttestation?: boolean;
|
|
509
514
|
};
|
|
@@ -688,6 +693,8 @@ type TemplateData = {
|
|
|
688
693
|
canAutoSubmit?: boolean;
|
|
689
694
|
metadata?: Record<string, string>;
|
|
690
695
|
preferredLocale?: ProofRequestOptions['preferredLocale'];
|
|
696
|
+
acceptTeeAttestation?: boolean;
|
|
697
|
+
teeAttestationVersion?: TeeAttestationVersion;
|
|
691
698
|
};
|
|
692
699
|
type TrustedData = {
|
|
693
700
|
context: Record<string, unknown>;
|
|
@@ -765,6 +772,13 @@ type ProviderHashRequirementsResponse = {
|
|
|
765
772
|
* * `getProviderHashRequirementsFromSpec()` - To get the expected proof hash requirements from a provider spec.
|
|
766
773
|
* * 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.
|
|
767
774
|
*
|
|
775
|
+
* Replay protection: this function is stateless. It verifies that a proof is cryptographically
|
|
776
|
+
* bound to a specific `sessionId`/`applicationId` (via the `appSecret`-keyed attestation nonce
|
|
777
|
+
* when `teeAttestation` is provided) but does not track which proofs have already been
|
|
778
|
+
* verified. Callers must (a) verify the proof's `sessionId` matches a session they initiated
|
|
779
|
+
* and (b) persist accepted `sessionId`s and reject duplicates. See the README's
|
|
780
|
+
* "Replay Protection" section for details.
|
|
781
|
+
*
|
|
768
782
|
* @param proofOrProofs - A single proof object or an array of proof objects to be verified.
|
|
769
783
|
* @param config - Verification configuration that specifies required hashes, allowed extra hashes, or disables content validation. Optionally includes `teeAttestation` to require TEE attestation verification.
|
|
770
784
|
* @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.
|
|
@@ -1502,6 +1516,10 @@ type TeeVerificationResult = {
|
|
|
1502
1516
|
* was generated for your application.
|
|
1503
1517
|
* Returns a result object with `isVerified` and an optional `error` message.
|
|
1504
1518
|
*
|
|
1519
|
+
* This check is stateless and does not protect against replay of a previously
|
|
1520
|
+
* valid proof. Callers must enforce session matching and dedup `sessionId` on
|
|
1521
|
+
* their server. See the README's "Replay Protection" section.
|
|
1522
|
+
*
|
|
1505
1523
|
* @param proof - The proof containing TEE attestation data
|
|
1506
1524
|
* @param appSecret - Your application secret (Ethereum private key). Used to
|
|
1507
1525
|
* derive the application ID and recompute the attestation nonce.
|
|
@@ -1558,4 +1576,4 @@ declare function isDesktopDevice(): boolean;
|
|
|
1558
1576
|
*/
|
|
1559
1577
|
declare function clearDeviceCache(): void;
|
|
1560
1578
|
|
|
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 };
|
|
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 };
|
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.
|
|
87
|
+
version: "5.3.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",
|
|
@@ -1694,6 +1694,7 @@ var EXPECTED_ISSUER = "https://confidentialcomputing.googleapis.com";
|
|
|
1694
1694
|
var EXPECTED_HW_MODEL = "GCP_AMD_SEV";
|
|
1695
1695
|
var EXPECTED_TEE_PROVIDER = "gcp";
|
|
1696
1696
|
var EXPECTED_TEE_TECHNOLOGY = "amd-sev";
|
|
1697
|
+
var SUPPORTED_PROOF_VERSIONS = ["v2", "v3"];
|
|
1697
1698
|
var TOKEN_CLOCK_SKEW_S = 60;
|
|
1698
1699
|
var NONCE_TIMESTAMP_MAX_SKEW_MS = 10 * 60 * 1e3;
|
|
1699
1700
|
var BROWSER_ENVIRONMENT_ERROR = "TEE attestation verification is only supported in non-browser environments. Run verifyTeeAttestation on your server or API route.";
|
|
@@ -1933,12 +1934,17 @@ function assertAudienceClaim(aud) {
|
|
|
1933
1934
|
}
|
|
1934
1935
|
throw new Error("attestation token audience is missing");
|
|
1935
1936
|
}
|
|
1937
|
+
function getProofVersion(teeAttestation) {
|
|
1938
|
+
var _a;
|
|
1939
|
+
return (_a = teeAttestation.proof_version) != null ? _a : teeAttestation.proofVersion;
|
|
1940
|
+
}
|
|
1936
1941
|
function assertProofShape(teeAttestation) {
|
|
1937
1942
|
var _a, _b, _c;
|
|
1938
1943
|
if (teeAttestation.error) {
|
|
1939
1944
|
throw new Error(`${teeAttestation.error.code}: ${teeAttestation.error.message}`);
|
|
1940
1945
|
}
|
|
1941
|
-
|
|
1946
|
+
const proofVersion = getProofVersion(teeAttestation);
|
|
1947
|
+
assert(typeof proofVersion === "string" && SUPPORTED_PROOF_VERSIONS.includes(proofVersion), `unexpected proof version: ${proofVersion}`);
|
|
1942
1948
|
assert(teeAttestation.tee_provider === EXPECTED_TEE_PROVIDER, `unexpected tee provider: ${teeAttestation.tee_provider}`);
|
|
1943
1949
|
assert(teeAttestation.tee_technology === EXPECTED_TEE_TECHNOLOGY, `unexpected tee technology: ${teeAttestation.tee_technology}`);
|
|
1944
1950
|
assert(typeof teeAttestation.nonce === "string" && teeAttestation.nonce.length > 0, "tee attestation nonce missing");
|
|
@@ -1948,6 +1954,26 @@ function assertProofShape(teeAttestation) {
|
|
|
1948
1954
|
assert(typeof ((_b = teeAttestation.verifier) == null ? void 0 : _b.image_digest) === "string" && teeAttestation.verifier.image_digest.length > 0, "verifier image digest missing");
|
|
1949
1955
|
assert(typeof ((_c = teeAttestation.attestation) == null ? void 0 : _c.token) === "string" && teeAttestation.attestation.token.length > 0, "attestation token missing");
|
|
1950
1956
|
}
|
|
1957
|
+
function computeDigestBinding(teeAttestation) {
|
|
1958
|
+
return __async(this, null, function* () {
|
|
1959
|
+
const proofVersion = getProofVersion(teeAttestation);
|
|
1960
|
+
if (proofVersion === "v3") {
|
|
1961
|
+
assert(typeof teeAttestation.workload.container_name === "string" && teeAttestation.workload.container_name.length > 0, "workload container name missing");
|
|
1962
|
+
assert(typeof teeAttestation.verifier.container_name === "string" && teeAttestation.verifier.container_name.length > 0, "verifier container name missing");
|
|
1963
|
+
return sha256Hex([
|
|
1964
|
+
"v3",
|
|
1965
|
+
`workload.container_name=${teeAttestation.workload.container_name}`,
|
|
1966
|
+
`workload.image_digest=${teeAttestation.workload.image_digest}`,
|
|
1967
|
+
`verifier.container_name=${teeAttestation.verifier.container_name}`,
|
|
1968
|
+
`verifier.image_digest=${teeAttestation.verifier.image_digest}`
|
|
1969
|
+
].join("\n"));
|
|
1970
|
+
}
|
|
1971
|
+
return sha256Hex(
|
|
1972
|
+
`${teeAttestation.workload.image_digest}
|
|
1973
|
+
${teeAttestation.verifier.image_digest}`
|
|
1974
|
+
);
|
|
1975
|
+
});
|
|
1976
|
+
}
|
|
1951
1977
|
function verifyGcpClaims(teeAttestation, expectedNonce) {
|
|
1952
1978
|
return __async(this, null, function* () {
|
|
1953
1979
|
var _a;
|
|
@@ -1955,10 +1981,7 @@ function verifyGcpClaims(teeAttestation, expectedNonce) {
|
|
|
1955
1981
|
assert(claims.iss === EXPECTED_ISSUER, `unexpected issuer: ${claims.iss}`);
|
|
1956
1982
|
assertAudienceClaim(claims.aud);
|
|
1957
1983
|
assert(Array.isArray(claims.eat_nonce), "eat_nonce claim missing");
|
|
1958
|
-
const digestBinding = yield
|
|
1959
|
-
`${teeAttestation.workload.image_digest}
|
|
1960
|
-
${teeAttestation.verifier.image_digest}`
|
|
1961
|
-
);
|
|
1984
|
+
const digestBinding = yield computeDigestBinding(teeAttestation);
|
|
1962
1985
|
assert(claims.eat_nonce.includes(expectedNonce), "request nonce is not present in attestation token");
|
|
1963
1986
|
assert(claims.eat_nonce.includes(digestBinding), "digest-binding nonce is not present in attestation token");
|
|
1964
1987
|
assert(claims.hwmodel === EXPECTED_HW_MODEL, `unexpected hwmodel: ${claims.hwmodel}`);
|
|
@@ -2025,6 +2048,7 @@ function runTeeVerification(proofs, config) {
|
|
|
2025
2048
|
// src/Reclaim.ts
|
|
2026
2049
|
var logger10 = logger_default.logger;
|
|
2027
2050
|
var sdkVersion = require_package().version;
|
|
2051
|
+
var SDK_TEE_ATTESTATION_VERSION = "v3";
|
|
2028
2052
|
function verifyProof(proofOrProofs, config) {
|
|
2029
2053
|
return __async(this, null, function* () {
|
|
2030
2054
|
const proofs = Array.isArray(proofOrProofs) ? proofOrProofs : [proofOrProofs];
|
|
@@ -2111,7 +2135,7 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
|
|
|
2111
2135
|
* @returns
|
|
2112
2136
|
*/
|
|
2113
2137
|
this.getTemplateData = () => {
|
|
2114
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
2138
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
2115
2139
|
if (!this.signature) {
|
|
2116
2140
|
throw new SignatureNotFoundError("Signature is not set.");
|
|
2117
2141
|
}
|
|
@@ -2151,7 +2175,9 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
|
|
|
2151
2175
|
log: (_h = (_g = this.options) == null ? void 0 : _g.log) != null ? _h : false,
|
|
2152
2176
|
canAutoSubmit: (_j = (_i = this.options) == null ? void 0 : _i.canAutoSubmit) != null ? _j : true,
|
|
2153
2177
|
metadata: (_k = this.options) == null ? void 0 : _k.metadata,
|
|
2154
|
-
preferredLocale: (_l = this.options) == null ? void 0 : _l.preferredLocale
|
|
2178
|
+
preferredLocale: (_l = this.options) == null ? void 0 : _l.preferredLocale,
|
|
2179
|
+
acceptTeeAttestation: (_m = this.options) == null ? void 0 : _m.acceptTeeAttestation,
|
|
2180
|
+
teeAttestationVersion: (_o = (_n = this.context.attestationNonceData) == null ? void 0 : _n.attestationVersion) != null ? _o : SDK_TEE_ATTESTATION_VERSION
|
|
2155
2181
|
};
|
|
2156
2182
|
return templateData;
|
|
2157
2183
|
};
|
|
@@ -2222,6 +2248,7 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
|
|
|
2222
2248
|
*/
|
|
2223
2249
|
static init(applicationId, appSecret, providerId, options) {
|
|
2224
2250
|
return __async(this, null, function* () {
|
|
2251
|
+
var _a;
|
|
2225
2252
|
try {
|
|
2226
2253
|
validateFunctionParams([
|
|
2227
2254
|
{ paramName: "applicationId", input: applicationId, isString: true },
|
|
@@ -2303,14 +2330,17 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
|
|
|
2303
2330
|
}, "the constructor");
|
|
2304
2331
|
}
|
|
2305
2332
|
}
|
|
2306
|
-
const
|
|
2333
|
+
const proofRequestOptions = __spreadProps(__spreadValues({}, options), {
|
|
2334
|
+
acceptTeeAttestation: (_a = options == null ? void 0 : options.acceptTeeAttestation) != null ? _a : true
|
|
2335
|
+
});
|
|
2336
|
+
const proofRequestInstance = new _ReclaimProofRequest(applicationId, providerId, proofRequestOptions);
|
|
2307
2337
|
const signature = yield proofRequestInstance.generateSignature(appSecret);
|
|
2308
2338
|
proofRequestInstance.setSignature(signature);
|
|
2309
2339
|
const data = yield initSession(providerId, applicationId, proofRequestInstance.timeStamp, signature, options == null ? void 0 : options.providerVersion);
|
|
2310
2340
|
proofRequestInstance.sessionId = data.sessionId;
|
|
2311
2341
|
proofRequestInstance.resolvedProviderVersion = data.resolvedProviderVersion;
|
|
2312
2342
|
proofRequestInstance.context.reclaimSessionId = data.sessionId;
|
|
2313
|
-
if (
|
|
2343
|
+
if (proofRequestOptions.acceptTeeAttestation) {
|
|
2314
2344
|
const attestationNonce = generateAttestationNonce(
|
|
2315
2345
|
appSecret,
|
|
2316
2346
|
applicationId,
|
|
@@ -2320,7 +2350,8 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
|
|
|
2320
2350
|
proofRequestInstance.setAttestationContext(attestationNonce, {
|
|
2321
2351
|
applicationId,
|
|
2322
2352
|
sessionId: data.sessionId,
|
|
2323
|
-
timestamp: proofRequestInstance.timeStamp
|
|
2353
|
+
timestamp: proofRequestInstance.timeStamp,
|
|
2354
|
+
attestationVersion: SDK_TEE_ATTESTATION_VERSION
|
|
2324
2355
|
});
|
|
2325
2356
|
}
|
|
2326
2357
|
return proofRequestInstance;
|