@turnkey/core 1.4.2 → 1.5.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/__clients__/core.d.ts +16 -1
- package/dist/__clients__/core.d.ts.map +1 -1
- package/dist/__clients__/core.js +85 -15
- package/dist/__clients__/core.js.map +1 -1
- package/dist/__clients__/core.mjs +85 -15
- package/dist/__clients__/core.mjs.map +1 -1
- package/dist/__generated__/version.d.ts +1 -1
- package/dist/__generated__/version.js +1 -1
- package/dist/__generated__/version.mjs +1 -1
- package/dist/__types__/method-types.d.ts +5 -0
- package/dist/__types__/method-types.d.ts.map +1 -1
- package/package.json +5 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TurnkeySDKClientBase } from "../__generated__/sdk-client-base";
|
|
2
2
|
import { type TDeleteSubOrganizationResponse, type Session, type TStampLoginResponse, type v1SignRawPayloadResult, type v1User, type ProxyTGetWalletKitConfigResponse, type v1PrivateKey, type WalletAuthResult, type BaseAuthResult, AuthAction, type PasskeyAuthResult, type v1BootProof } from "@turnkey/sdk-types";
|
|
3
|
-
import { Chain, type ExportBundle, type TurnkeySDKClientConfig, type WalletAccount, type Wallet, type WalletManagerBase, type WalletProvider, type CreatePasskeyParams, type CreatePasskeyResult, type LogoutParams, type LoginWithPasskeyParams, type SignUpWithPasskeyParams, type SwitchWalletAccountChainParams, type LoginWithWalletParams, type SignUpWithWalletParams, type LoginOrSignupWithWalletParams, type InitOtpParams, type VerifyOtpParams, type VerifyOtpResult, type LoginWithOtpParams, type SignUpWithOtpParams, type CompleteOtpParams, type CompleteOauthParams, type LoginWithOauthParams, type SignUpWithOauthParams, type FetchWalletsParams, type FetchWalletAccountsParams, type FetchPrivateKeysParams, type SignMessageParams, type SignTransactionParams, type SignAndSendTransactionParams, type FetchUserParams, type FetchOrCreateP256ApiKeyUserParams, type FetchOrCreatePoliciesParams, type FetchOrCreatePoliciesResult, type UpdateUserEmailParams, type RemoveUserEmailParams, type UpdateUserPhoneNumberParams, type RemoveUserPhoneNumberParams, type UpdateUserNameParams, type AddOauthProviderParams, type RemoveOauthProvidersParams, type AddPasskeyParams, type RemovePasskeyParams, type CreateWalletParams, type CreateWalletAccountsParams, type ExportWalletParams, type ExportPrivateKeyParams, type ExportWalletAccountParams, type ImportWalletParams, type ImportPrivateKeyParams, type DeleteSubOrganizationParams, type StoreSessionParams, type ClearSessionParams, type RefreshSessionParams, type GetSessionParams, type SetActiveSessionParams, type CreateApiKeyPairParams, type FetchBootProofForAppProofParams, type CreateHttpClientParams, type BuildWalletLoginRequestResult, type BuildWalletLoginRequestParams } from "../__types__";
|
|
3
|
+
import { Chain, type ExportBundle, type TurnkeySDKClientConfig, type WalletAccount, type Wallet, type WalletManagerBase, type WalletProvider, type CreatePasskeyParams, type CreatePasskeyResult, type LogoutParams, type LoginWithPasskeyParams, type SignUpWithPasskeyParams, type SwitchWalletAccountChainParams, type LoginWithWalletParams, type SignUpWithWalletParams, type LoginOrSignupWithWalletParams, type InitOtpParams, type VerifyOtpParams, type VerifyOtpResult, type LoginWithOtpParams, type SignUpWithOtpParams, type CompleteOtpParams, type CompleteOauthParams, type LoginWithOauthParams, type SignUpWithOauthParams, type FetchWalletsParams, type FetchWalletAccountsParams, type FetchPrivateKeysParams, type SignMessageParams, type SignTransactionParams, type SignAndSendTransactionParams, type FetchUserParams, type FetchOrCreateP256ApiKeyUserParams, type FetchOrCreatePoliciesParams, type FetchOrCreatePoliciesResult, type UpdateUserEmailParams, type RemoveUserEmailParams, type UpdateUserPhoneNumberParams, type RemoveUserPhoneNumberParams, type UpdateUserNameParams, type AddOauthProviderParams, type RemoveOauthProvidersParams, type AddPasskeyParams, type RemovePasskeyParams, type CreateWalletParams, type CreateWalletAccountsParams, type ExportWalletParams, type ExportPrivateKeyParams, type ExportWalletAccountParams, type ImportWalletParams, type ImportPrivateKeyParams, type DeleteSubOrganizationParams, type StoreSessionParams, type ClearSessionParams, type RefreshSessionParams, type GetSessionParams, type SetActiveSessionParams, type CreateApiKeyPairParams, type FetchBootProofForAppProofParams, type CreateHttpClientParams, type BuildWalletLoginRequestResult, type BuildWalletLoginRequestParams, type VerifyAppProofsParams } from "../__types__";
|
|
4
4
|
import { CrossPlatformApiKeyStamper } from "../__stampers__/api/base";
|
|
5
5
|
import { CrossPlatformPasskeyStamper } from "../__stampers__/passkey/base";
|
|
6
6
|
/**
|
|
@@ -500,6 +500,9 @@ export declare class TurnkeyClient {
|
|
|
500
500
|
* - Delegates signing to the Turnkey API, which returns the signed transaction.
|
|
501
501
|
* - Supports all Turnkey-supported transaction types (e.g., Ethereum, Solana, Tron).
|
|
502
502
|
* - Optionally allows stamping with a specific stamper (`StamperType.Passkey`, `StamperType.ApiKey`, or `StamperType.Wallet`).
|
|
503
|
+
* - Note: For embedded Ethereum wallets, the returned signature doesn’t include the `0x` prefix. You should add `0x` before
|
|
504
|
+
* broadcasting if it’s missing. It’s a good idea to check whether the signature already starts with `0x` before adding it,
|
|
505
|
+
* since we plan to include the prefix by default in a future breaking change.
|
|
503
506
|
*
|
|
504
507
|
* @param params.walletAccount - wallet account to use for signing.
|
|
505
508
|
* @param params.unsignedTransaction - unsigned transaction data as a serialized
|
|
@@ -1059,6 +1062,18 @@ export declare class TurnkeyClient {
|
|
|
1059
1062
|
* @throws {TurnkeyError} If there is no active session, if the input is invalid, or if boot proof retrieval fails.
|
|
1060
1063
|
*/
|
|
1061
1064
|
fetchBootProofForAppProof: (params: FetchBootProofForAppProofParams) => Promise<v1BootProof>;
|
|
1065
|
+
/**
|
|
1066
|
+
* Verifies a list of app proofs against their corresponding boot proofs.
|
|
1067
|
+
*
|
|
1068
|
+
* - This function iterates through each provided app proof, fetches the corresponding boot proof, and verifies the app proof against the boot proof.
|
|
1069
|
+
* - If any app proof fails verification, an error is thrown.
|
|
1070
|
+
* @param params.appProofs - the app proofs to verify.
|
|
1071
|
+
* @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
|
|
1072
|
+
* @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
|
|
1073
|
+
* @returns A promise that resolves when all app proofs have been successfully verified.
|
|
1074
|
+
* @throws {TurnkeyError} If there is no active session, if the input is invalid, or if verification fails.
|
|
1075
|
+
*/
|
|
1076
|
+
verifyAppProofs: (params: VerifyAppProofsParams) => Promise<void>;
|
|
1062
1077
|
}
|
|
1063
1078
|
export {};
|
|
1064
1079
|
//# sourceMappingURL=core.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/__clients__/core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EACL,KAAK,8BAA8B,EACnC,KAAK,OAAO,EACZ,KAAK,mBAAmB,EAExB,KAAK,sBAAsB,EAC3B,KAAK,MAAM,EAGX,KAAK,gCAAgC,EAErC,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,UAAU,EACV,KAAK,iBAAiB,EAEtB,KAAK,WAAW,
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/__clients__/core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EACL,KAAK,8BAA8B,EACnC,KAAK,OAAO,EACZ,KAAK,mBAAmB,EAExB,KAAK,sBAAsB,EAC3B,KAAK,MAAM,EAGX,KAAK,gCAAgC,EAErC,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,UAAU,EACV,KAAK,iBAAiB,EAEtB,KAAK,WAAW,EAEjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAML,KAAK,EAKL,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,KAAK,MAAM,EAMX,KAAK,iBAAiB,EACtB,K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QAAQ,gCAAgC,CAAC,CAmBtE;IAEF;;;;;;;;;;;;;OAaG;IACH,yBAAyB,WACf,+BAA+B,KACtC,QAAQ,WAAW,CAAC,CAoDrB;IAEF;;;;;;;;;;OAUG;IACH,eAAe,WAAkB,qBAAqB,KAAG,QAAQ,IAAI,CAAC,CA+DpE;CACH"}
|
package/dist/__clients__/core.js
CHANGED
|
@@ -12,6 +12,7 @@ var turnkeyHelpers = require('../turnkey-helpers.js');
|
|
|
12
12
|
var jwtDecode = require('jwt-decode');
|
|
13
13
|
var base$3 = require('../__wallet__/base.js');
|
|
14
14
|
var ethers = require('ethers');
|
|
15
|
+
var crypto = require('@turnkey/crypto');
|
|
15
16
|
|
|
16
17
|
class TurnkeyClient {
|
|
17
18
|
constructor(config,
|
|
@@ -294,6 +295,7 @@ class TurnkeyClient {
|
|
|
294
295
|
generatedPublicKey = undefined; // Key pair was successfully used, set to null to prevent cleanup
|
|
295
296
|
return {
|
|
296
297
|
sessionToken: sessionResponse.session,
|
|
298
|
+
appProofs: res.appProofs,
|
|
297
299
|
credentialId: passkey.attestation.credentialId,
|
|
298
300
|
};
|
|
299
301
|
}, {
|
|
@@ -543,7 +545,7 @@ class TurnkeyClient {
|
|
|
543
545
|
* @throws {TurnkeyError} If the wallet stamper is uninitialized, a public key cannot be found or generated, or login fails.
|
|
544
546
|
*/
|
|
545
547
|
this.loginWithWallet = async (params) => {
|
|
546
|
-
|
|
548
|
+
let generatedPublicKey = params.publicKey || (await this.apiKeyStamper?.createKeyPair());
|
|
547
549
|
return utils.withTurnkeyErrorHandling(async () => {
|
|
548
550
|
if (!this.walletManager?.stamper) {
|
|
549
551
|
throw new sdkTypes.TurnkeyError("Wallet stamper is not initialized", sdkTypes.TurnkeyErrorCodes.WALLET_MANAGER_COMPONENT_NOT_INITIALIZED);
|
|
@@ -551,12 +553,12 @@ class TurnkeyClient {
|
|
|
551
553
|
const sessionKey = params.sessionKey || enums.SessionKey.DefaultSessionkey;
|
|
552
554
|
const walletProvider = params.walletProvider;
|
|
553
555
|
const expirationSeconds = params?.expirationSeconds || auth.DEFAULT_SESSION_EXPIRATION_IN_SECONDS;
|
|
554
|
-
if (!
|
|
556
|
+
if (!generatedPublicKey) {
|
|
555
557
|
throw new sdkTypes.TurnkeyError("A publickey could not be found or generated.", sdkTypes.TurnkeyErrorCodes.INTERNAL_ERROR);
|
|
556
558
|
}
|
|
557
559
|
this.walletManager.stamper.setProvider(walletProvider.interfaceType, walletProvider);
|
|
558
560
|
const sessionResponse = await this.httpClient.stampLogin({
|
|
559
|
-
publicKey,
|
|
561
|
+
publicKey: generatedPublicKey,
|
|
560
562
|
organizationId: params?.organizationId ?? this.config.organizationId,
|
|
561
563
|
expirationSeconds,
|
|
562
564
|
}, enums.StamperType.Wallet);
|
|
@@ -566,9 +568,11 @@ class TurnkeyClient {
|
|
|
566
568
|
});
|
|
567
569
|
// TODO (Moe): What happens if a user connects to MetaMask on Ethereum,
|
|
568
570
|
// then switches to a Solana account within MetaMask? Will this flow break?
|
|
571
|
+
const address = utils.addressFromPublicKey(walletProvider.chainInfo.namespace, generatedPublicKey);
|
|
572
|
+
generatedPublicKey = undefined; // Key pair was successfully used, set to null to prevent cleanup
|
|
569
573
|
return {
|
|
570
574
|
sessionToken: sessionResponse.session,
|
|
571
|
-
address
|
|
575
|
+
address,
|
|
572
576
|
};
|
|
573
577
|
}, {
|
|
574
578
|
errorMessage: "Unable to log in with the provided wallet",
|
|
@@ -577,9 +581,9 @@ class TurnkeyClient {
|
|
|
577
581
|
finallyFn: async () => {
|
|
578
582
|
// Clean up the generated key pair if it wasn't successfully used
|
|
579
583
|
this.apiKeyStamper?.clearTemporaryPublicKey();
|
|
580
|
-
if (
|
|
584
|
+
if (generatedPublicKey) {
|
|
581
585
|
try {
|
|
582
|
-
await this.apiKeyStamper?.deleteKeyPair(
|
|
586
|
+
await this.apiKeyStamper?.deleteKeyPair(generatedPublicKey);
|
|
583
587
|
}
|
|
584
588
|
catch (cleanupError) {
|
|
585
589
|
throw new sdkTypes.TurnkeyError("Failed to clean up generated key pair", sdkTypes.TurnkeyErrorCodes.KEY_PAIR_CLEANUP_ERROR, cleanupError);
|
|
@@ -659,6 +663,7 @@ class TurnkeyClient {
|
|
|
659
663
|
// then switches to a Solana account within MetaMask? Will this flow break?
|
|
660
664
|
return {
|
|
661
665
|
sessionToken: sessionResponse.session,
|
|
666
|
+
appProofs: res.appProofs,
|
|
662
667
|
address: utils.addressFromPublicKey(walletProvider.chainInfo.namespace, publicKey),
|
|
663
668
|
};
|
|
664
669
|
}, {
|
|
@@ -718,6 +723,7 @@ class TurnkeyClient {
|
|
|
718
723
|
}
|
|
719
724
|
const subOrganizationId = accountRes.organizationId;
|
|
720
725
|
// if there is no subOrganizationId, we create one
|
|
726
|
+
let signupRes;
|
|
721
727
|
if (!subOrganizationId) {
|
|
722
728
|
const signUpBody = utils.buildSignUpBody({
|
|
723
729
|
createSubOrgParams: {
|
|
@@ -731,8 +737,8 @@ class TurnkeyClient {
|
|
|
731
737
|
],
|
|
732
738
|
},
|
|
733
739
|
});
|
|
734
|
-
|
|
735
|
-
if (!
|
|
740
|
+
signupRes = await this.httpClient.proxySignup(signUpBody);
|
|
741
|
+
if (!signupRes) {
|
|
736
742
|
throw new sdkTypes.TurnkeyError(`Sign up failed`, sdkTypes.TurnkeyErrorCodes.WALLET_SIGNUP_AUTH_ERROR);
|
|
737
743
|
}
|
|
738
744
|
}
|
|
@@ -748,6 +754,7 @@ class TurnkeyClient {
|
|
|
748
754
|
});
|
|
749
755
|
return {
|
|
750
756
|
sessionToken: sessionToken,
|
|
757
|
+
appProofs: signupRes?.appProofs,
|
|
751
758
|
address: utils.addressFromPublicKey(walletProvider.chainInfo.namespace, publicKey),
|
|
752
759
|
// if the subOrganizationId exists, it means the user is logging in
|
|
753
760
|
action: subOrganizationId ? sdkTypes.AuthAction.LOGIN : sdkTypes.AuthAction.SIGNUP,
|
|
@@ -929,16 +936,20 @@ class TurnkeyClient {
|
|
|
929
936
|
});
|
|
930
937
|
return utils.withTurnkeyErrorHandling(async () => {
|
|
931
938
|
const generatedPublicKey = await this.apiKeyStamper?.createKeyPair();
|
|
932
|
-
const
|
|
933
|
-
if (!
|
|
939
|
+
const signupRes = await this.httpClient.proxySignup(signUpBody);
|
|
940
|
+
if (!signupRes) {
|
|
934
941
|
throw new sdkTypes.TurnkeyError(`Auth proxy OTP sign up failed`, sdkTypes.TurnkeyErrorCodes.OTP_SIGNUP_ERROR);
|
|
935
942
|
}
|
|
936
|
-
|
|
943
|
+
const otpRes = await this.loginWithOtp({
|
|
937
944
|
verificationToken,
|
|
938
945
|
publicKey: generatedPublicKey,
|
|
939
946
|
...(invalidateExisting && { invalidateExisting }),
|
|
940
947
|
...(sessionKey && { sessionKey }),
|
|
941
948
|
});
|
|
949
|
+
return {
|
|
950
|
+
...otpRes,
|
|
951
|
+
appProofs: signupRes.appProofs,
|
|
952
|
+
};
|
|
942
953
|
}, {
|
|
943
954
|
errorCode: sdkTypes.TurnkeyErrorCodes.OTP_SIGNUP_ERROR,
|
|
944
955
|
errorMessage: "Failed to sign up with OTP",
|
|
@@ -1166,15 +1177,19 @@ class TurnkeyClient {
|
|
|
1166
1177
|
],
|
|
1167
1178
|
},
|
|
1168
1179
|
});
|
|
1169
|
-
const
|
|
1170
|
-
if (!
|
|
1180
|
+
const signupRes = await this.httpClient.proxySignup(signUpBody);
|
|
1181
|
+
if (!signupRes) {
|
|
1171
1182
|
throw new sdkTypes.TurnkeyError(`Auth proxy OAuth signup failed`, sdkTypes.TurnkeyErrorCodes.OAUTH_SIGNUP_ERROR);
|
|
1172
1183
|
}
|
|
1173
|
-
|
|
1184
|
+
const oauthRes = await this.loginWithOauth({
|
|
1174
1185
|
oidcToken,
|
|
1175
1186
|
publicKey: publicKey,
|
|
1176
1187
|
...(sessionKey && { sessionKey }),
|
|
1177
1188
|
});
|
|
1189
|
+
return {
|
|
1190
|
+
...oauthRes,
|
|
1191
|
+
appProofs: signupRes.appProofs,
|
|
1192
|
+
};
|
|
1178
1193
|
}, {
|
|
1179
1194
|
errorMessage: "Failed to sign up with OAuth",
|
|
1180
1195
|
errorCode: sdkTypes.TurnkeyErrorCodes.OAUTH_SIGNUP_ERROR,
|
|
@@ -1552,6 +1567,9 @@ class TurnkeyClient {
|
|
|
1552
1567
|
* - Delegates signing to the Turnkey API, which returns the signed transaction.
|
|
1553
1568
|
* - Supports all Turnkey-supported transaction types (e.g., Ethereum, Solana, Tron).
|
|
1554
1569
|
* - Optionally allows stamping with a specific stamper (`StamperType.Passkey`, `StamperType.ApiKey`, or `StamperType.Wallet`).
|
|
1570
|
+
* - Note: For embedded Ethereum wallets, the returned signature doesn’t include the `0x` prefix. You should add `0x` before
|
|
1571
|
+
* broadcasting if it’s missing. It’s a good idea to check whether the signature already starts with `0x` before adding it,
|
|
1572
|
+
* since we plan to include the prefix by default in a future breaking change.
|
|
1555
1573
|
*
|
|
1556
1574
|
* @param params.walletAccount - wallet account to use for signing.
|
|
1557
1575
|
* @param params.unsignedTransaction - unsigned transaction data as a serialized
|
|
@@ -1584,6 +1602,8 @@ class TurnkeyClient {
|
|
|
1584
1602
|
type: transactionType,
|
|
1585
1603
|
...(organizationId && { organizationId }),
|
|
1586
1604
|
}, stampWith);
|
|
1605
|
+
// TODO (breaking change): eventually we should append a `0x` prefix for ethereum signatures here
|
|
1606
|
+
// then we should remove the note in the comment header
|
|
1587
1607
|
return signTransaction.signedTransaction;
|
|
1588
1608
|
}, {
|
|
1589
1609
|
errorMessage: "Failed to sign transaction",
|
|
@@ -1655,7 +1675,9 @@ class TurnkeyClient {
|
|
|
1655
1675
|
type: transactionType,
|
|
1656
1676
|
...(organizationId && { organizationId }),
|
|
1657
1677
|
}, stampWith);
|
|
1658
|
-
const signedTx =
|
|
1678
|
+
const signedTx = transactionType === "TRANSACTION_TYPE_ETHEREUM"
|
|
1679
|
+
? `0x${signTransactionResponse.signedTransaction}`
|
|
1680
|
+
: signTransactionResponse.signedTransaction;
|
|
1659
1681
|
const txHash = await utils.broadcastTransaction({
|
|
1660
1682
|
signedTransaction: signedTx,
|
|
1661
1683
|
rpcUrl,
|
|
@@ -2990,6 +3012,54 @@ class TurnkeyClient {
|
|
|
2990
3012
|
errorCode: sdkTypes.TurnkeyErrorCodes.FETCH_BOOT_PROOF_ERROR,
|
|
2991
3013
|
});
|
|
2992
3014
|
};
|
|
3015
|
+
/**
|
|
3016
|
+
* Verifies a list of app proofs against their corresponding boot proofs.
|
|
3017
|
+
*
|
|
3018
|
+
* - This function iterates through each provided app proof, fetches the corresponding boot proof, and verifies the app proof against the boot proof.
|
|
3019
|
+
* - If any app proof fails verification, an error is thrown.
|
|
3020
|
+
* @param params.appProofs - the app proofs to verify.
|
|
3021
|
+
* @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
|
|
3022
|
+
* @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
|
|
3023
|
+
* @returns A promise that resolves when all app proofs have been successfully verified.
|
|
3024
|
+
* @throws {TurnkeyError} If there is no active session, if the input is invalid, or if verification fails.
|
|
3025
|
+
*/
|
|
3026
|
+
this.verifyAppProofs = async (params) => {
|
|
3027
|
+
const { appProofs, stampWith = this.config.defaultStamperType, organizationId: organizationIdFromParams, } = params;
|
|
3028
|
+
return utils.withTurnkeyErrorHandling(async () => {
|
|
3029
|
+
const session = await utils.getActiveSessionOrThrowIfRequired(stampWith, this.storageManager.getActiveSession);
|
|
3030
|
+
const organizationId = organizationIdFromParams || session?.organizationId;
|
|
3031
|
+
if (!organizationId) {
|
|
3032
|
+
throw new sdkTypes.TurnkeyError("Organization ID is required to verify app proofs.", sdkTypes.TurnkeyErrorCodes.INVALID_REQUEST);
|
|
3033
|
+
}
|
|
3034
|
+
if (!appProofs || appProofs.length === 0) {
|
|
3035
|
+
throw new sdkTypes.TurnkeyError("'appProofs' is required and cannot be empty.", sdkTypes.TurnkeyErrorCodes.INVALID_REQUEST);
|
|
3036
|
+
}
|
|
3037
|
+
let lastPublicKey;
|
|
3038
|
+
let lastBootProof;
|
|
3039
|
+
for (const appProof of appProofs) {
|
|
3040
|
+
if (!appProof.publicKey) {
|
|
3041
|
+
throw new sdkTypes.TurnkeyError("App proof publicKey is missing.", sdkTypes.TurnkeyErrorCodes.INVALID_REQUEST);
|
|
3042
|
+
}
|
|
3043
|
+
let bootProof;
|
|
3044
|
+
if (appProof.publicKey === lastPublicKey && lastBootProof) {
|
|
3045
|
+
bootProof = lastBootProof;
|
|
3046
|
+
}
|
|
3047
|
+
else {
|
|
3048
|
+
bootProof = await this.fetchBootProofForAppProof({
|
|
3049
|
+
appProof,
|
|
3050
|
+
organizationId,
|
|
3051
|
+
stampWith,
|
|
3052
|
+
});
|
|
3053
|
+
lastPublicKey = appProof.publicKey;
|
|
3054
|
+
lastBootProof = bootProof;
|
|
3055
|
+
}
|
|
3056
|
+
await crypto.verify(appProof, bootProof); // throws if invalid
|
|
3057
|
+
}
|
|
3058
|
+
}, {
|
|
3059
|
+
errorMessage: "Failed to verify app proofs",
|
|
3060
|
+
errorCode: sdkTypes.TurnkeyErrorCodes.VERIFY_APP_PROOFS_ERROR,
|
|
3061
|
+
});
|
|
3062
|
+
};
|
|
2993
3063
|
this.config = config;
|
|
2994
3064
|
// Just store any explicitly provided stampers
|
|
2995
3065
|
this.apiKeyStamper = apiKeyStamper;
|