@turnkey/core 2.5.0 → 2.7.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/dist/__clients__/core.d.ts +36 -3
- package/dist/__clients__/core.d.ts.map +1 -1
- package/dist/__clients__/core.js +123 -40
- package/dist/__clients__/core.js.map +1 -1
- package/dist/__clients__/core.mjs +116 -33
- package/dist/__clients__/core.mjs.map +1 -1
- package/dist/__generated__/sdk-client-base.d.ts +21 -0
- package/dist/__generated__/sdk-client-base.d.ts.map +1 -1
- package/dist/__generated__/sdk-client-base.js +267 -1
- package/dist/__generated__/sdk-client-base.js.map +1 -1
- package/dist/__generated__/sdk-client-base.mjs +268 -2
- package/dist/__generated__/sdk-client-base.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/__stampers__/api/base.d.ts +2 -1
- package/dist/__stampers__/api/base.d.ts.map +1 -1
- package/dist/__stampers__/api/base.js +11 -14
- package/dist/__stampers__/api/base.js.map +1 -1
- package/dist/__stampers__/api/base.mjs +11 -14
- package/dist/__stampers__/api/base.mjs.map +1 -1
- package/dist/__stampers__/attested/base.d.ts +22 -0
- package/dist/__stampers__/attested/base.d.ts.map +1 -0
- package/dist/__stampers__/attested/base.js +50 -0
- package/dist/__stampers__/attested/base.js.map +1 -0
- package/dist/__stampers__/attested/base.mjs +48 -0
- package/dist/__stampers__/attested/base.mjs.map +1 -0
- package/dist/__types__/config.d.ts +42 -1
- package/dist/__types__/config.d.ts.map +1 -1
- package/dist/__types__/enums.d.ts +2 -1
- package/dist/__types__/enums.d.ts.map +1 -1
- package/dist/__types__/enums.js +1 -0
- package/dist/__types__/enums.js.map +1 -1
- package/dist/__types__/enums.mjs +1 -0
- package/dist/__types__/enums.mjs.map +1 -1
- package/dist/__types__/method-types/shared.d.ts +21 -1
- package/dist/__types__/method-types/shared.d.ts.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +3 -1
- package/dist/utils.js.map +1 -1
- package/dist/utils.mjs +3 -1
- package/dist/utils.mjs.map +1 -1
- package/package.json +6 -6
|
@@ -1,8 +1,9 @@
|
|
|
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, type PasskeyAuthResult, type v1BootProof, type TGetSendTransactionStatusResponse, AuthAction } 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 InitOtpResult, 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 EthSendErc20TransferParams, type EthSendTransactionParams, type SolSendTransactionParams, 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 SignWithApiKeyParams, type FetchBootProofForAppProofParams, type CreateHttpClientParams, type BuildWalletLoginRequestResult, type BuildWalletLoginRequestParams, type VerifyAppProofsParams, type PollTransactionStatusParams, type OverrideApiKeyStamperParams, type OverridePasskeyStamperParams, type DeleteApiKeyPairParams } 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 InitOtpResult, 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 EthSendErc20TransferParams, type EthSendTransactionParams, type SolSendTransactionParams, 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 SignWithApiKeyParams, type FetchBootProofForAppProofParams, type CreateHttpClientParams, type BuildWalletLoginRequestResult, type BuildWalletLoginRequestParams, type VerifyAppProofsParams, type PollTransactionStatusParams, type OverrideApiKeyStamperParams, type OverridePasskeyStamperParams, type OverrideAttestedStamperParams, type DeleteApiKeyPairParams } from "../__types__";
|
|
4
4
|
import { CrossPlatformApiKeyStamper } from "../__stampers__/api/base";
|
|
5
5
|
import { CrossPlatformPasskeyStamper } from "../__stampers__/passkey/base";
|
|
6
|
+
import { AttestedStamper } from "../__stampers__/attested/base";
|
|
6
7
|
/**
|
|
7
8
|
* @internal
|
|
8
9
|
* Gathers all public methods exposed in our core client and turns it into a type that
|
|
@@ -20,9 +21,10 @@ export declare class TurnkeyClient {
|
|
|
20
21
|
httpClient: TurnkeySDKClientBase;
|
|
21
22
|
private apiKeyStamper?;
|
|
22
23
|
private passkeyStamper?;
|
|
24
|
+
private attestedStamper?;
|
|
23
25
|
private walletManager?;
|
|
24
26
|
private storageManager;
|
|
25
|
-
constructor(config: TurnkeySDKClientConfig, apiKeyStamper?: CrossPlatformApiKeyStamper, passkeyStamper?: CrossPlatformPasskeyStamper, walletManager?: WalletManagerBase);
|
|
27
|
+
constructor(config: TurnkeySDKClientConfig, apiKeyStamper?: CrossPlatformApiKeyStamper, passkeyStamper?: CrossPlatformPasskeyStamper, attestedStamper?: AttestedStamper, walletManager?: WalletManagerBase);
|
|
26
28
|
init(): Promise<void>;
|
|
27
29
|
/**
|
|
28
30
|
* Overrides the API key stamper configuration.
|
|
@@ -49,6 +51,23 @@ export declare class TurnkeyClient {
|
|
|
49
51
|
* @throws {TurnkeyError} If there is an error updating the stamper configuration or if the passkey stamper is not initialized.
|
|
50
52
|
*/
|
|
51
53
|
overridePasskeyStamper: (params: OverridePasskeyStamperParams) => Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Overrides the attested stamper with a verification token or OIDC token.
|
|
56
|
+
*
|
|
57
|
+
* - This function updates the attested stamper's identity and automatically sets the correct scheme.
|
|
58
|
+
* - Pass `verificationToken` to set the attestation identity and scheme to STAMP_ATTESTED_SCHEME_P256_VERIFICATION_TOKEN.
|
|
59
|
+
* - Pass `oidcToken` to set the attestation identity and scheme to STAMP_ATTESTED_SCHEME_P256_OIDC.
|
|
60
|
+
* - Only one of `verificationToken` or `oidcToken` can be provided at a time.
|
|
61
|
+
* - If neither token is provided, the attestation identity is cleared.
|
|
62
|
+
* - Useful for dynamically changing the attested identity and scheme used for signing requests.
|
|
63
|
+
*
|
|
64
|
+
* @param params.verificationToken - verification token to use as the attested identity with STAMP_ATTESTED_SCHEME_P256_VERIFICATION_TOKEN scheme.
|
|
65
|
+
* @param params.oidcToken - OIDC token to use as the attested identity with STAMP_ATTESTED_SCHEME_P256_OIDC scheme.
|
|
66
|
+
* @param params.publicKey - public key that signs the attested stamp. Must match the key bound to the token.
|
|
67
|
+
* @returns A promise that resolves when the stamper has been updated.
|
|
68
|
+
* @throws {TurnkeyError} If the attested stamper is not initialized, if both tokens are provided, or if there is an error updating it.
|
|
69
|
+
*/
|
|
70
|
+
overrideAttestedStamper: (params: OverrideAttestedStamperParams) => Promise<void>;
|
|
52
71
|
/**
|
|
53
72
|
* Creates a new TurnkeySDKClientBase instance with the provided configuration.
|
|
54
73
|
* This method is used internally to create the HTTP client for making API requests,
|
|
@@ -1238,10 +1257,24 @@ export declare class TurnkeyClient {
|
|
|
1238
1257
|
*/
|
|
1239
1258
|
fetchBootProofForAppProof: (params: FetchBootProofForAppProofParams) => Promise<v1BootProof>;
|
|
1240
1259
|
/**
|
|
1241
|
-
* Verifies a list of app proofs against their corresponding boot proofs
|
|
1260
|
+
* Verifies a list of app proofs against their corresponding boot proofs using
|
|
1261
|
+
* the example/reference-grade check from `@turnkey/crypto`.
|
|
1242
1262
|
*
|
|
1243
1263
|
* - This function iterates through each provided app proof, fetches the corresponding boot proof, and verifies the app proof against the boot proof.
|
|
1244
1264
|
* - If any app proof fails verification, an error is thrown.
|
|
1265
|
+
*
|
|
1266
|
+
* @remarks
|
|
1267
|
+
* WARNING: This is not full verification of a Turnkey enclave. It verifies
|
|
1268
|
+
* that the proof came from a genuine AWS Nitro enclave and that proof
|
|
1269
|
+
* signatures chain correctly, but it does not verify enclave identity or image
|
|
1270
|
+
* measurements. It does not inspect `attestationDoc.pcrs` (PCR0-3 image
|
|
1271
|
+
* measurements), and it does not compare the QOS manifest content against a
|
|
1272
|
+
* known-good or pinned Turnkey manifest. Any party with an AWS account can
|
|
1273
|
+
* produce attestations from their own Nitro enclave that pass this check.
|
|
1274
|
+
*
|
|
1275
|
+
* For full verification, callers must additionally pin and verify expected
|
|
1276
|
+
* PCR measurements and manifest content. See https://github.com/tkhq/qos.
|
|
1277
|
+
*
|
|
1245
1278
|
* @param params.appProofs - the app proofs to verify.
|
|
1246
1279
|
* @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
|
|
1247
1280
|
* @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
|
|
@@ -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,EACX,KAAK,gCAAgC,EAErC,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EAEtB,KAAK,WAAW,EAChB,KAAK,iCAAiC,EAQtC,UAAU,EACX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAML,KAAK,EAKL,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,KAAK,MAAM,EAMX,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAGnB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,YAAY,E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U,YACC,gBAAgB,KACxB,QAAQ,OAAO,GAAG,SAAS,CAAC,CAY7B;IAEF;;;;;;;;;;OAUG;IACH,cAAc,QAAa,QAAQ,OAAO,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,CAqBrE;IAEF;;;;;;;;;;;OAWG;IACH,gBAAgB,WAAkB,sBAAsB,KAAG,QAAQ,IAAI,CAAC,CAWtE;IAEF;;;;;;;;;;OAUG;IACH,mBAAmB,QAAa,QAAQ,MAAM,GAAG,SAAS,CAAC,CAUzD;IAEF;;;;;;;;;;OAUG;IACH,mBAAmB,QAAa,QAAQ,IAAI,CAAC,CAoC3C;IAEF;;;;;;;;;;;OAWG;IACH,gBAAgB,YACL,sBAAsB,KAC9B,QAAQ,MAAM,CAAC,CAsBhB;IAEF;;;;;;;;;;;OAWG;IACH,gBAAgB,WAAkB,sBAAsB,KAAG,QAAQ,IAAI,CAAC,CAkBtE;IAEF;;;;;;;;;;;;OAYG;IACH,cAAc,WAAkB,oBAAoB,KAAG,QAAQ,MAAM,CAAC,CA6BpE;IAEF;;;;;;;;;;OAUG;IACH,kBAAkB,QAAa,QAAQ,gCAAgC,CAAC,CAmBtE;IAEF;;;;;;;;;;;;;OAaG;IACH,yBAAyB,WACf,+BAA+B,KACtC,QAAQ,WAAW,CAAC,CAoDrB;IAEF;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,eAAe,WAAkB,qBAAqB,KAAG,QAAQ,IAAI,CAAC,CA+DpE;CACH"}
|
package/dist/__clients__/core.js
CHANGED
|
@@ -6,20 +6,21 @@ var auth = require('../__types__/auth.js');
|
|
|
6
6
|
var enums = require('../__types__/enums.js');
|
|
7
7
|
var utils = require('../utils.js');
|
|
8
8
|
var crypto = require('@turnkey/crypto');
|
|
9
|
-
var base = require('../__storage__/base.js');
|
|
10
|
-
var base$
|
|
11
|
-
var base$
|
|
9
|
+
var base$1 = require('../__storage__/base.js');
|
|
10
|
+
var base$2 = require('../__stampers__/api/base.js');
|
|
11
|
+
var base$3 = require('../__stampers__/passkey/base.js');
|
|
12
12
|
var turnkeyHelpers = require('../turnkey-helpers.js');
|
|
13
13
|
var jwtDecode = require('jwt-decode');
|
|
14
|
-
var base$
|
|
14
|
+
var base$4 = require('../__wallet__/base.js');
|
|
15
15
|
var ethers = require('ethers');
|
|
16
16
|
var apiKeyStamper = require('@turnkey/api-key-stamper');
|
|
17
17
|
var viem = require('viem');
|
|
18
|
+
var base = require('../__stampers__/attested/base.js');
|
|
18
19
|
|
|
19
20
|
class TurnkeyClient {
|
|
20
21
|
constructor(config,
|
|
21
22
|
// Users can pass in their own stampers, or we will create them. Should we remove this?
|
|
22
|
-
apiKeyStamper$1, passkeyStamper, walletManager) {
|
|
23
|
+
apiKeyStamper$1, passkeyStamper, attestedStamper, walletManager) {
|
|
23
24
|
/**
|
|
24
25
|
* Overrides the API key stamper configuration.
|
|
25
26
|
*
|
|
@@ -75,6 +76,58 @@ class TurnkeyClient {
|
|
|
75
76
|
errorCode: sdkTypes.TurnkeyErrorCodes.INITIALIZE_PASSKEY_STAMPER_ERROR,
|
|
76
77
|
});
|
|
77
78
|
};
|
|
79
|
+
/**
|
|
80
|
+
* Overrides the attested stamper with a verification token or OIDC token.
|
|
81
|
+
*
|
|
82
|
+
* - This function updates the attested stamper's identity and automatically sets the correct scheme.
|
|
83
|
+
* - Pass `verificationToken` to set the attestation identity and scheme to STAMP_ATTESTED_SCHEME_P256_VERIFICATION_TOKEN.
|
|
84
|
+
* - Pass `oidcToken` to set the attestation identity and scheme to STAMP_ATTESTED_SCHEME_P256_OIDC.
|
|
85
|
+
* - Only one of `verificationToken` or `oidcToken` can be provided at a time.
|
|
86
|
+
* - If neither token is provided, the attestation identity is cleared.
|
|
87
|
+
* - Useful for dynamically changing the attested identity and scheme used for signing requests.
|
|
88
|
+
*
|
|
89
|
+
* @param params.verificationToken - verification token to use as the attested identity with STAMP_ATTESTED_SCHEME_P256_VERIFICATION_TOKEN scheme.
|
|
90
|
+
* @param params.oidcToken - OIDC token to use as the attested identity with STAMP_ATTESTED_SCHEME_P256_OIDC scheme.
|
|
91
|
+
* @param params.publicKey - public key that signs the attested stamp. Must match the key bound to the token.
|
|
92
|
+
* @returns A promise that resolves when the stamper has been updated.
|
|
93
|
+
* @throws {TurnkeyError} If the attested stamper is not initialized, if both tokens are provided, or if there is an error updating it.
|
|
94
|
+
*/
|
|
95
|
+
this.overrideAttestedStamper = async (params) => {
|
|
96
|
+
return utils.withTurnkeyErrorHandling(async () => {
|
|
97
|
+
if (!this.attestedStamper) {
|
|
98
|
+
throw new sdkTypes.TurnkeyError("Attested stamper is not initialized", sdkTypes.TurnkeyErrorCodes.INTERNAL_ERROR);
|
|
99
|
+
}
|
|
100
|
+
const { verificationToken, oidcToken, publicKey } = params;
|
|
101
|
+
// we enforce that you cannot set both a verificationToken and an oidcToken
|
|
102
|
+
if (verificationToken && oidcToken) {
|
|
103
|
+
throw new sdkTypes.TurnkeyError("Cannot set both verificationToken and oidcToken. Please provide only one.", sdkTypes.TurnkeyErrorCodes.INVALID_REQUEST);
|
|
104
|
+
}
|
|
105
|
+
// we require a publicKey if either a verificationToken or an oidcToken is provided
|
|
106
|
+
if ((verificationToken || oidcToken) && !publicKey) {
|
|
107
|
+
throw new sdkTypes.TurnkeyError("A publicKey must be provided when setting a verificationToken or oidcToken.", sdkTypes.TurnkeyErrorCodes.INVALID_REQUEST);
|
|
108
|
+
}
|
|
109
|
+
if (verificationToken) {
|
|
110
|
+
this.attestedStamper.configure({
|
|
111
|
+
attestedIdentity: verificationToken,
|
|
112
|
+
publicKey: publicKey,
|
|
113
|
+
scheme: base.AttestedScheme.P256_VERIFICATION_TOKEN,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
else if (oidcToken) {
|
|
117
|
+
this.attestedStamper.configure({
|
|
118
|
+
attestedIdentity: oidcToken,
|
|
119
|
+
publicKey: publicKey,
|
|
120
|
+
scheme: base.AttestedScheme.P256_OIDC,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
this.attestedStamper.clear();
|
|
125
|
+
}
|
|
126
|
+
}, {
|
|
127
|
+
errorMessage: "Failed to override attested stamper",
|
|
128
|
+
errorCode: sdkTypes.TurnkeyErrorCodes.INTERNAL_ERROR,
|
|
129
|
+
});
|
|
130
|
+
};
|
|
78
131
|
/**
|
|
79
132
|
* Creates a new TurnkeySDKClientBase instance with the provided configuration.
|
|
80
133
|
* This method is used internally to create the HTTP client for making API requests,
|
|
@@ -106,6 +159,7 @@ class TurnkeyClient {
|
|
|
106
159
|
organizationId,
|
|
107
160
|
apiKeyStamper: this.apiKeyStamper,
|
|
108
161
|
passkeyStamper: this.passkeyStamper,
|
|
162
|
+
attestedStamper: this.attestedStamper,
|
|
109
163
|
walletStamper: this.walletManager?.stamper,
|
|
110
164
|
storageManager: this.storageManager,
|
|
111
165
|
});
|
|
@@ -247,6 +301,7 @@ class TurnkeyClient {
|
|
|
247
301
|
};
|
|
248
302
|
await this.overridePasskeyStamper({ config: mergedConfig });
|
|
249
303
|
}
|
|
304
|
+
const sessionProfileId = params?.sessionProfileId;
|
|
250
305
|
if (!generatedPublicKey) {
|
|
251
306
|
throw new sdkTypes.TurnkeyError("A publickey could not be found or generated.", sdkTypes.TurnkeyErrorCodes.INTERNAL_ERROR);
|
|
252
307
|
}
|
|
@@ -254,6 +309,7 @@ class TurnkeyClient {
|
|
|
254
309
|
publicKey: generatedPublicKey,
|
|
255
310
|
organizationId: params?.organizationId ?? this.config.organizationId,
|
|
256
311
|
expirationSeconds,
|
|
312
|
+
...(sessionProfileId && { sessionProfileId }),
|
|
257
313
|
};
|
|
258
314
|
const passkeyLoginRequest = await this.httpClient.stampStampLogin(loginPayload, enums.StamperType.Passkey);
|
|
259
315
|
if (!passkeyLoginRequest) {
|
|
@@ -321,7 +377,7 @@ class TurnkeyClient {
|
|
|
321
377
|
* @throws {TurnkeyError} If there is an error during passkey creation, sub-organization creation, or session storage.
|
|
322
378
|
*/
|
|
323
379
|
this.signUpWithPasskey = async (params) => {
|
|
324
|
-
const { passkeyDisplayName, challenge, expirationSeconds = auth.DEFAULT_SESSION_EXPIRATION_IN_SECONDS, createSubOrgParams, sessionKey = enums.SessionKey.DefaultSessionkey, captchaToken, } = params || {};
|
|
380
|
+
const { passkeyDisplayName, challenge, expirationSeconds = auth.DEFAULT_SESSION_EXPIRATION_IN_SECONDS, createSubOrgParams, sessionKey = enums.SessionKey.DefaultSessionkey, sessionProfileId, captchaToken, } = params || {};
|
|
325
381
|
const generatedPublicKey = await this.createApiKeyPair();
|
|
326
382
|
return utils.withTurnkeyErrorHandling(async () => {
|
|
327
383
|
if (!this.passkeyStamper) {
|
|
@@ -370,6 +426,7 @@ class TurnkeyClient {
|
|
|
370
426
|
publicKey: newGeneratedKeyPair,
|
|
371
427
|
organizationId: res.organizationId,
|
|
372
428
|
expirationSeconds,
|
|
429
|
+
...(sessionProfileId && { sessionProfileId }),
|
|
373
430
|
});
|
|
374
431
|
await this.storeSession({
|
|
375
432
|
sessionToken: sessionResponse.session,
|
|
@@ -528,7 +585,7 @@ class TurnkeyClient {
|
|
|
528
585
|
* or the public key cannot be derived or generated.
|
|
529
586
|
*/
|
|
530
587
|
this.buildWalletLoginRequest = async (params) => {
|
|
531
|
-
const { walletProvider, publicKey: providedPublicKey } = params;
|
|
588
|
+
const { walletProvider, publicKey: providedPublicKey, sessionProfileId, } = params;
|
|
532
589
|
const expirationSeconds = params.expirationSeconds || auth.DEFAULT_SESSION_EXPIRATION_IN_SECONDS;
|
|
533
590
|
const futureSessionPublicKey = providedPublicKey ?? (await this.createApiKeyPair());
|
|
534
591
|
return utils.withTurnkeyErrorHandling(async () => {
|
|
@@ -547,6 +604,7 @@ class TurnkeyClient {
|
|
|
547
604
|
publicKey: futureSessionPublicKey,
|
|
548
605
|
organizationId: this.config.organizationId,
|
|
549
606
|
expirationSeconds,
|
|
607
|
+
...(sessionProfileId && { sessionProfileId }),
|
|
550
608
|
}, enums.StamperType.Wallet);
|
|
551
609
|
}, {
|
|
552
610
|
errorMessage: "Failed to create stamped request for wallet login",
|
|
@@ -889,34 +947,27 @@ class TurnkeyClient {
|
|
|
889
947
|
* @throws {TurnkeyError} If there is an error during the OTP login process or if key pair cleanup fails.
|
|
890
948
|
*/
|
|
891
949
|
this.loginWithOtp = async (params) => {
|
|
892
|
-
const { verificationToken, invalidateExisting = false, organizationId, sessionKey = enums.SessionKey.DefaultSessionkey, } = params;
|
|
950
|
+
const { verificationToken, invalidateExisting = false, organizationId, sessionKey = enums.SessionKey.DefaultSessionkey, expirationSeconds = auth.DEFAULT_SESSION_EXPIRATION_IN_SECONDS, sessionProfileId, } = params;
|
|
893
951
|
return utils.withTurnkeyErrorHandling(async () => {
|
|
894
|
-
const {
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
const signature = await this.signWithApiKey({
|
|
898
|
-
message,
|
|
899
|
-
publicKey: verificationPublicKey,
|
|
900
|
-
});
|
|
901
|
-
if (!signature) {
|
|
902
|
-
throw new sdkTypes.TurnkeyError(`Failed to sign client signature for OTP login`, sdkTypes.TurnkeyErrorCodes.INTERNAL_ERROR);
|
|
952
|
+
const { public_key: verificationPublicKey } = utils.decodeVerificationToken(verificationToken);
|
|
953
|
+
if (!verificationPublicKey) {
|
|
954
|
+
throw new sdkTypes.TurnkeyError("Invalid verification token: missing publicKey", sdkTypes.TurnkeyErrorCodes.INVALID_REQUEST);
|
|
903
955
|
}
|
|
904
|
-
|
|
905
|
-
|
|
956
|
+
// We override the attested stamper with the verification token so the stampLogin request can be stamped with it.
|
|
957
|
+
await this.overrideAttestedStamper({
|
|
958
|
+
verificationToken,
|
|
906
959
|
publicKey: verificationPublicKey,
|
|
907
|
-
|
|
908
|
-
signature: signature,
|
|
909
|
-
};
|
|
960
|
+
});
|
|
910
961
|
// the verification token's public key is also used as the session public key for login
|
|
911
|
-
const loginRes = await this.httpClient.
|
|
912
|
-
verificationToken,
|
|
962
|
+
const loginRes = await this.httpClient.stampLogin({
|
|
913
963
|
publicKey: verificationPublicKey,
|
|
914
|
-
|
|
964
|
+
expirationSeconds,
|
|
915
965
|
invalidateExisting,
|
|
916
966
|
...(organizationId && { organizationId }),
|
|
917
|
-
|
|
967
|
+
...(sessionProfileId && { sessionProfileId }),
|
|
968
|
+
}, enums.StamperType.Attested);
|
|
918
969
|
if (!loginRes) {
|
|
919
|
-
throw new sdkTypes.TurnkeyError(`
|
|
970
|
+
throw new sdkTypes.TurnkeyError(`OTP login failed`, sdkTypes.TurnkeyErrorCodes.OTP_LOGIN_ERROR);
|
|
920
971
|
}
|
|
921
972
|
if (!loginRes.session) {
|
|
922
973
|
throw new sdkTypes.TurnkeyError("No session returned from OTP login", sdkTypes.TurnkeyErrorCodes.OTP_LOGIN_ERROR);
|
|
@@ -954,7 +1005,7 @@ class TurnkeyClient {
|
|
|
954
1005
|
* @throws {TurnkeyError} If there is an error during the OTP sign-up process or session storage.
|
|
955
1006
|
*/
|
|
956
1007
|
this.signUpWithOtp = async (params) => {
|
|
957
|
-
const { verificationToken, contact, otpType, createSubOrgParams, invalidateExisting, sessionKey, captchaToken, } = params;
|
|
1008
|
+
const { verificationToken, contact, otpType, createSubOrgParams, invalidateExisting, sessionKey, sessionProfileId, captchaToken, } = params;
|
|
958
1009
|
// build sign up body without client signature first
|
|
959
1010
|
const signUpBody = utils.buildSignUpBody({
|
|
960
1011
|
createSubOrgParams: {
|
|
@@ -1002,6 +1053,7 @@ class TurnkeyClient {
|
|
|
1002
1053
|
verificationToken,
|
|
1003
1054
|
...(invalidateExisting && { invalidateExisting }),
|
|
1004
1055
|
...(sessionKey && { sessionKey }),
|
|
1056
|
+
...(sessionProfileId && { sessionProfileId }),
|
|
1005
1057
|
});
|
|
1006
1058
|
return {
|
|
1007
1059
|
...otpRes,
|
|
@@ -1039,7 +1091,7 @@ class TurnkeyClient {
|
|
|
1039
1091
|
* @throws {TurnkeyError} If there is an error during OTP verification, sign-up, or login.
|
|
1040
1092
|
*/
|
|
1041
1093
|
this.completeOtp = async (params) => {
|
|
1042
|
-
const { otpId, otpCode, otpEncryptionTargetBundle, contact, otpType, invalidateExisting = false, sessionKey, createSubOrgParams, captchaToken, } = params;
|
|
1094
|
+
const { otpId, otpCode, otpEncryptionTargetBundle, contact, otpType, invalidateExisting = false, sessionKey, createSubOrgParams, sessionProfileId, captchaToken, } = params;
|
|
1043
1095
|
const publicKey = params.publicKey ?? (await this.createApiKeyPair());
|
|
1044
1096
|
if (!publicKey) {
|
|
1045
1097
|
throw new sdkTypes.TurnkeyError("No public key available. Either pass a publicKey or ensure apiKeyStamper is configured.", sdkTypes.TurnkeyErrorCodes.INVALID_REQUEST);
|
|
@@ -1071,6 +1123,7 @@ class TurnkeyClient {
|
|
|
1071
1123
|
...(createSubOrgParams && { createSubOrgParams }),
|
|
1072
1124
|
...(invalidateExisting && { invalidateExisting }),
|
|
1073
1125
|
...(sessionKey && { sessionKey }),
|
|
1126
|
+
...(sessionProfileId && { sessionProfileId }),
|
|
1074
1127
|
...(captchaToken && { captchaToken }),
|
|
1075
1128
|
});
|
|
1076
1129
|
return {
|
|
@@ -1084,6 +1137,7 @@ class TurnkeyClient {
|
|
|
1084
1137
|
verificationToken,
|
|
1085
1138
|
...(invalidateExisting && { invalidateExisting }),
|
|
1086
1139
|
...(sessionKey && { sessionKey }),
|
|
1140
|
+
...(sessionProfileId && { sessionProfileId }),
|
|
1087
1141
|
});
|
|
1088
1142
|
return {
|
|
1089
1143
|
...loginRes,
|
|
@@ -1129,7 +1183,7 @@ class TurnkeyClient {
|
|
|
1129
1183
|
* @throws {TurnkeyError} If there is an error during the OAuth completion process, such as account lookup, sign-up, or login.
|
|
1130
1184
|
*/
|
|
1131
1185
|
this.completeOauth = async (params) => {
|
|
1132
|
-
const { oidcToken, publicKey, providerName, createSubOrgParams, invalidateExisting, sessionKey, captchaToken, } = params;
|
|
1186
|
+
const { oidcToken, publicKey, providerName, createSubOrgParams, invalidateExisting, sessionKey, sessionProfileId, captchaToken, } = params;
|
|
1133
1187
|
return utils.withTurnkeyErrorHandling(async () => {
|
|
1134
1188
|
const accountRes = await this.httpClient.proxyGetAccount({
|
|
1135
1189
|
filterType: "OIDC_TOKEN",
|
|
@@ -1145,6 +1199,7 @@ class TurnkeyClient {
|
|
|
1145
1199
|
publicKey,
|
|
1146
1200
|
...(invalidateExisting && { invalidateExisting }),
|
|
1147
1201
|
...(sessionKey && { sessionKey }),
|
|
1202
|
+
...(sessionProfileId && { sessionProfileId }),
|
|
1148
1203
|
});
|
|
1149
1204
|
return {
|
|
1150
1205
|
...loginRes,
|
|
@@ -1163,6 +1218,7 @@ class TurnkeyClient {
|
|
|
1163
1218
|
}),
|
|
1164
1219
|
...(invalidateExisting && { invalidateExisting }),
|
|
1165
1220
|
...(sessionKey && { sessionKey }),
|
|
1221
|
+
...(sessionProfileId && { sessionProfileId }),
|
|
1166
1222
|
...(captchaToken && { captchaToken }),
|
|
1167
1223
|
});
|
|
1168
1224
|
return {
|
|
@@ -1195,19 +1251,25 @@ class TurnkeyClient {
|
|
|
1195
1251
|
* @throws {TurnkeyError} If there is an error during the OAuth login process or if key pair cleanup fails.
|
|
1196
1252
|
*/
|
|
1197
1253
|
this.loginWithOauth = async (params) => {
|
|
1198
|
-
const { oidcToken, publicKey, organizationId, invalidateExisting = false, sessionKey = enums.SessionKey.DefaultSessionkey, } = params;
|
|
1254
|
+
const { oidcToken, publicKey, organizationId, invalidateExisting = false, sessionKey = enums.SessionKey.DefaultSessionkey, expirationSeconds = auth.DEFAULT_SESSION_EXPIRATION_IN_SECONDS, sessionProfileId, } = params;
|
|
1199
1255
|
return utils.withTurnkeyErrorHandling(async () => {
|
|
1200
1256
|
if (!publicKey) {
|
|
1201
1257
|
throw new sdkTypes.TurnkeyError("Public key must be provided to log in with OAuth. Please create a key pair first.", sdkTypes.TurnkeyErrorCodes.MISSING_PARAMS);
|
|
1202
1258
|
}
|
|
1203
|
-
|
|
1259
|
+
// We override the attested stamper with the oidcToken so the stampLogin request can be stamped with it.
|
|
1260
|
+
await this.overrideAttestedStamper({
|
|
1204
1261
|
oidcToken,
|
|
1205
1262
|
publicKey,
|
|
1263
|
+
});
|
|
1264
|
+
const loginRes = await this.httpClient.stampLogin({
|
|
1265
|
+
publicKey,
|
|
1266
|
+
expirationSeconds,
|
|
1206
1267
|
invalidateExisting,
|
|
1207
1268
|
...(organizationId && { organizationId }),
|
|
1208
|
-
|
|
1269
|
+
...(sessionProfileId && { sessionProfileId }),
|
|
1270
|
+
}, enums.StamperType.Attested);
|
|
1209
1271
|
if (!loginRes) {
|
|
1210
|
-
throw new sdkTypes.TurnkeyError(`
|
|
1272
|
+
throw new sdkTypes.TurnkeyError(`OAuth login failed`, sdkTypes.TurnkeyErrorCodes.OAUTH_LOGIN_ERROR);
|
|
1211
1273
|
}
|
|
1212
1274
|
if (!loginRes.session) {
|
|
1213
1275
|
throw new sdkTypes.TurnkeyError("No session returned from oauth login", sdkTypes.TurnkeyErrorCodes.OAUTH_LOGIN_ERROR);
|
|
@@ -1258,7 +1320,7 @@ class TurnkeyClient {
|
|
|
1258
1320
|
* @throws {TurnkeyError} If there is an error during the OAuth sign-up or login process.
|
|
1259
1321
|
*/
|
|
1260
1322
|
this.signUpWithOauth = async (params) => {
|
|
1261
|
-
const { oidcToken, publicKey, providerName = "OpenID Connect Provider" + " " + Date.now(), createSubOrgParams, sessionKey, captchaToken, } = params;
|
|
1323
|
+
const { oidcToken, publicKey, providerName = "OpenID Connect Provider" + " " + Date.now(), createSubOrgParams, sessionKey, sessionProfileId, captchaToken, } = params;
|
|
1262
1324
|
return utils.withTurnkeyErrorHandling(async () => {
|
|
1263
1325
|
const signUpBody = utils.buildSignUpBody({
|
|
1264
1326
|
createSubOrgParams: {
|
|
@@ -1280,6 +1342,7 @@ class TurnkeyClient {
|
|
|
1280
1342
|
oidcToken,
|
|
1281
1343
|
publicKey: publicKey,
|
|
1282
1344
|
...(sessionKey && { sessionKey }),
|
|
1345
|
+
...(sessionProfileId && { sessionProfileId }),
|
|
1283
1346
|
});
|
|
1284
1347
|
return {
|
|
1285
1348
|
...oauthRes,
|
|
@@ -3137,6 +3200,9 @@ class TurnkeyClient {
|
|
|
3137
3200
|
publicKey: keyPair,
|
|
3138
3201
|
expirationSeconds,
|
|
3139
3202
|
invalidateExisting: invalidateExisitng,
|
|
3203
|
+
...(session.sessionProfileId && {
|
|
3204
|
+
sessionProfileId: session.sessionProfileId,
|
|
3205
|
+
}),
|
|
3140
3206
|
}, stampWith);
|
|
3141
3207
|
if (!res || !res.session) {
|
|
3142
3208
|
throw new sdkTypes.TurnkeyError("No session found in the refresh response", sdkTypes.TurnkeyErrorCodes.BAD_RESPONSE);
|
|
@@ -3437,10 +3503,24 @@ class TurnkeyClient {
|
|
|
3437
3503
|
});
|
|
3438
3504
|
};
|
|
3439
3505
|
/**
|
|
3440
|
-
* Verifies a list of app proofs against their corresponding boot proofs
|
|
3506
|
+
* Verifies a list of app proofs against their corresponding boot proofs using
|
|
3507
|
+
* the example/reference-grade check from `@turnkey/crypto`.
|
|
3441
3508
|
*
|
|
3442
3509
|
* - This function iterates through each provided app proof, fetches the corresponding boot proof, and verifies the app proof against the boot proof.
|
|
3443
3510
|
* - If any app proof fails verification, an error is thrown.
|
|
3511
|
+
*
|
|
3512
|
+
* @remarks
|
|
3513
|
+
* WARNING: This is not full verification of a Turnkey enclave. It verifies
|
|
3514
|
+
* that the proof came from a genuine AWS Nitro enclave and that proof
|
|
3515
|
+
* signatures chain correctly, but it does not verify enclave identity or image
|
|
3516
|
+
* measurements. It does not inspect `attestationDoc.pcrs` (PCR0-3 image
|
|
3517
|
+
* measurements), and it does not compare the QOS manifest content against a
|
|
3518
|
+
* known-good or pinned Turnkey manifest. Any party with an AWS account can
|
|
3519
|
+
* produce attestations from their own Nitro enclave that pass this check.
|
|
3520
|
+
*
|
|
3521
|
+
* For full verification, callers must additionally pin and verify expected
|
|
3522
|
+
* PCR measurements and manifest content. See https://github.com/tkhq/qos.
|
|
3523
|
+
*
|
|
3444
3524
|
* @param params.appProofs - the app proofs to verify.
|
|
3445
3525
|
* @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
|
|
3446
3526
|
* @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
|
|
@@ -3488,29 +3568,32 @@ class TurnkeyClient {
|
|
|
3488
3568
|
// Just store any explicitly provided stampers
|
|
3489
3569
|
this.apiKeyStamper = apiKeyStamper$1;
|
|
3490
3570
|
this.passkeyStamper = passkeyStamper;
|
|
3571
|
+
this.attestedStamper = attestedStamper;
|
|
3491
3572
|
this.walletManager = walletManager;
|
|
3492
3573
|
// Actual initialization will happen in init()
|
|
3493
3574
|
}
|
|
3494
3575
|
async init() {
|
|
3495
3576
|
// Initialize storage manager
|
|
3496
3577
|
// TODO (Amir): StorageManager should be a class that extends StorageBase and has an init method
|
|
3497
|
-
this.storageManager = await base.createStorageManager();
|
|
3578
|
+
this.storageManager = await base$1.createStorageManager();
|
|
3498
3579
|
// Initialize the API key stamper
|
|
3499
|
-
this.apiKeyStamper = new base$
|
|
3580
|
+
this.apiKeyStamper = new base$2.CrossPlatformApiKeyStamper(this.storageManager);
|
|
3581
|
+
// Then use it to initialize the attested stamper
|
|
3582
|
+
this.attestedStamper = new base.AttestedStamper(this.apiKeyStamper);
|
|
3500
3583
|
// we parallelize independent initializations:
|
|
3501
3584
|
// - API key stamper init
|
|
3502
3585
|
// - Passkey stamper creation and init (if configured)
|
|
3503
3586
|
// - Wallet manager creation (if configured)
|
|
3504
3587
|
const initTasks = [this.apiKeyStamper.init()];
|
|
3505
3588
|
if (this.config.passkeyConfig) {
|
|
3506
|
-
const passkeyStamper = new base$
|
|
3589
|
+
const passkeyStamper = new base$3.CrossPlatformPasskeyStamper(this.config.passkeyConfig);
|
|
3507
3590
|
initTasks.push(passkeyStamper.init().then(() => {
|
|
3508
3591
|
this.passkeyStamper = passkeyStamper;
|
|
3509
3592
|
}));
|
|
3510
3593
|
}
|
|
3511
3594
|
if (this.config.walletConfig?.features?.auth ||
|
|
3512
3595
|
this.config.walletConfig?.features?.connecting) {
|
|
3513
|
-
initTasks.push(base$
|
|
3596
|
+
initTasks.push(base$4.createWalletManager(this.config.walletConfig).then((manager) => {
|
|
3514
3597
|
this.walletManager = manager;
|
|
3515
3598
|
}));
|
|
3516
3599
|
}
|