@turnkey/core 2.6.0 → 2.7.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.
Files changed (43) hide show
  1. package/dist/__clients__/core.d.ts +22 -2
  2. package/dist/__clients__/core.d.ts.map +1 -1
  3. package/dist/__clients__/core.js +111 -41
  4. package/dist/__clients__/core.js.map +1 -1
  5. package/dist/__clients__/core.mjs +104 -34
  6. package/dist/__clients__/core.mjs.map +1 -1
  7. package/dist/__generated__/sdk-client-base.d.ts +9 -0
  8. package/dist/__generated__/sdk-client-base.d.ts.map +1 -1
  9. package/dist/__generated__/sdk-client-base.js +59 -1
  10. package/dist/__generated__/sdk-client-base.js.map +1 -1
  11. package/dist/__generated__/sdk-client-base.mjs +60 -2
  12. package/dist/__generated__/sdk-client-base.mjs.map +1 -1
  13. package/dist/__generated__/version.d.ts +1 -1
  14. package/dist/__generated__/version.js +1 -1
  15. package/dist/__generated__/version.mjs +1 -1
  16. package/dist/__stampers__/api/base.d.ts +2 -1
  17. package/dist/__stampers__/api/base.d.ts.map +1 -1
  18. package/dist/__stampers__/api/base.js +11 -14
  19. package/dist/__stampers__/api/base.js.map +1 -1
  20. package/dist/__stampers__/api/base.mjs +11 -14
  21. package/dist/__stampers__/api/base.mjs.map +1 -1
  22. package/dist/__stampers__/attested/base.d.ts +22 -0
  23. package/dist/__stampers__/attested/base.d.ts.map +1 -0
  24. package/dist/__stampers__/attested/base.js +50 -0
  25. package/dist/__stampers__/attested/base.js.map +1 -0
  26. package/dist/__stampers__/attested/base.mjs +48 -0
  27. package/dist/__stampers__/attested/base.mjs.map +1 -0
  28. package/dist/__types__/config.d.ts +42 -1
  29. package/dist/__types__/config.d.ts.map +1 -1
  30. package/dist/__types__/enums.d.ts +2 -1
  31. package/dist/__types__/enums.d.ts.map +1 -1
  32. package/dist/__types__/enums.js +1 -0
  33. package/dist/__types__/enums.js.map +1 -1
  34. package/dist/__types__/enums.mjs +1 -0
  35. package/dist/__types__/enums.mjs.map +1 -1
  36. package/dist/__types__/method-types/shared.d.ts +21 -1
  37. package/dist/__types__/method-types/shared.d.ts.map +1 -1
  38. package/dist/utils.d.ts.map +1 -1
  39. package/dist/utils.js +3 -1
  40. package/dist/utils.js.map +1 -1
  41. package/dist/utils.mjs +3 -1
  42. package/dist/utils.mjs.map +1 -1
  43. package/package.json +8 -8
@@ -2,7 +2,7 @@ import { TurnkeySDKClientBase } from '../__generated__/sdk-client-base.mjs';
2
2
  import { TurnkeyErrorCodes, TurnkeyError, AuthAction } from '@turnkey/sdk-types';
3
3
  import { DEFAULT_SESSION_EXPIRATION_IN_SECONDS } from '../__types__/auth.mjs';
4
4
  import { SessionKey, StamperType, WalletSource, FilterType, OtpType, OtpTypeToFilterTypeMap, Curve, Chain, SignIntent } from '../__types__/enums.mjs';
5
- import { withTurnkeyErrorHandling, isValidPasskeyName, isWeb, isReactNative, buildSignUpBody, findWalletProviderFromAddress, getPublicKeyFromStampHeader, addressFromPublicKey, getCurveTypeFromProvider, getClientSignatureMessageForLogin, getClientSignatureMessageForSignup, getAuthenticatorAddresses, fetchAllWalletAccountsWithCursor, mapAccountsToWallet, toExternalTimestamp, isEthereumProvider, isSolanaProvider, getActiveSessionOrThrowIfRequired, getHashFunction, getEncodingType, getEncodedMessage, splitSignature, broadcastTransaction, ERC20_TRANSFER_ABI, getPolicySignature, googleISS, isWalletAccountArray, generateWalletAccountsFromAddressFormat } from '../utils.mjs';
5
+ import { withTurnkeyErrorHandling, isValidPasskeyName, isWeb, isReactNative, buildSignUpBody, findWalletProviderFromAddress, getPublicKeyFromStampHeader, addressFromPublicKey, getCurveTypeFromProvider, decodeVerificationToken, getClientSignatureMessageForSignup, getAuthenticatorAddresses, fetchAllWalletAccountsWithCursor, mapAccountsToWallet, toExternalTimestamp, isEthereumProvider, isSolanaProvider, getActiveSessionOrThrowIfRequired, getHashFunction, getEncodingType, getEncodedMessage, splitSignature, broadcastTransaction, ERC20_TRANSFER_ABI, getPolicySignature, googleISS, isWalletAccountArray, generateWalletAccountsFromAddressFormat } from '../utils.mjs';
6
6
  import { encryptOtpCodeToBundle, verify } from '@turnkey/crypto';
7
7
  import { createStorageManager } from '../__storage__/base.mjs';
8
8
  import { CrossPlatformApiKeyStamper } from '../__stampers__/api/base.mjs';
@@ -13,11 +13,12 @@ import { createWalletManager } from '../__wallet__/base.mjs';
13
13
  import { toUtf8Bytes } from 'ethers';
14
14
  import { SignatureFormat } from '@turnkey/api-key-stamper';
15
15
  import { encodeFunctionData } from 'viem';
16
+ import { AttestedScheme, AttestedStamper } from '../__stampers__/attested/base.mjs';
16
17
 
17
18
  class TurnkeyClient {
18
19
  constructor(config,
19
20
  // Users can pass in their own stampers, or we will create them. Should we remove this?
20
- apiKeyStamper, passkeyStamper, walletManager) {
21
+ apiKeyStamper, passkeyStamper, attestedStamper, walletManager) {
21
22
  /**
22
23
  * Overrides the API key stamper configuration.
23
24
  *
@@ -73,6 +74,58 @@ class TurnkeyClient {
73
74
  errorCode: TurnkeyErrorCodes.INITIALIZE_PASSKEY_STAMPER_ERROR,
74
75
  });
75
76
  };
77
+ /**
78
+ * Overrides the attested stamper with a verification token or OIDC token.
79
+ *
80
+ * - This function updates the attested stamper's identity and automatically sets the correct scheme.
81
+ * - Pass `verificationToken` to set the attestation identity and scheme to STAMP_ATTESTED_SCHEME_P256_VERIFICATION_TOKEN.
82
+ * - Pass `oidcToken` to set the attestation identity and scheme to STAMP_ATTESTED_SCHEME_P256_OIDC.
83
+ * - Only one of `verificationToken` or `oidcToken` can be provided at a time.
84
+ * - If neither token is provided, the attestation identity is cleared.
85
+ * - Useful for dynamically changing the attested identity and scheme used for signing requests.
86
+ *
87
+ * @param params.verificationToken - verification token to use as the attested identity with STAMP_ATTESTED_SCHEME_P256_VERIFICATION_TOKEN scheme.
88
+ * @param params.oidcToken - OIDC token to use as the attested identity with STAMP_ATTESTED_SCHEME_P256_OIDC scheme.
89
+ * @param params.publicKey - public key that signs the attested stamp. Must match the key bound to the token.
90
+ * @returns A promise that resolves when the stamper has been updated.
91
+ * @throws {TurnkeyError} If the attested stamper is not initialized, if both tokens are provided, or if there is an error updating it.
92
+ */
93
+ this.overrideAttestedStamper = async (params) => {
94
+ return withTurnkeyErrorHandling(async () => {
95
+ if (!this.attestedStamper) {
96
+ throw new TurnkeyError("Attested stamper is not initialized", TurnkeyErrorCodes.INTERNAL_ERROR);
97
+ }
98
+ const { verificationToken, oidcToken, publicKey } = params;
99
+ // we enforce that you cannot set both a verificationToken and an oidcToken
100
+ if (verificationToken && oidcToken) {
101
+ throw new TurnkeyError("Cannot set both verificationToken and oidcToken. Please provide only one.", TurnkeyErrorCodes.INVALID_REQUEST);
102
+ }
103
+ // we require a publicKey if either a verificationToken or an oidcToken is provided
104
+ if ((verificationToken || oidcToken) && !publicKey) {
105
+ throw new TurnkeyError("A publicKey must be provided when setting a verificationToken or oidcToken.", TurnkeyErrorCodes.INVALID_REQUEST);
106
+ }
107
+ if (verificationToken) {
108
+ this.attestedStamper.configure({
109
+ attestedIdentity: verificationToken,
110
+ publicKey: publicKey,
111
+ scheme: AttestedScheme.P256_VERIFICATION_TOKEN,
112
+ });
113
+ }
114
+ else if (oidcToken) {
115
+ this.attestedStamper.configure({
116
+ attestedIdentity: oidcToken,
117
+ publicKey: publicKey,
118
+ scheme: AttestedScheme.P256_OIDC,
119
+ });
120
+ }
121
+ else {
122
+ this.attestedStamper.clear();
123
+ }
124
+ }, {
125
+ errorMessage: "Failed to override attested stamper",
126
+ errorCode: TurnkeyErrorCodes.INTERNAL_ERROR,
127
+ });
128
+ };
76
129
  /**
77
130
  * Creates a new TurnkeySDKClientBase instance with the provided configuration.
78
131
  * This method is used internally to create the HTTP client for making API requests,
@@ -104,6 +157,7 @@ class TurnkeyClient {
104
157
  organizationId,
105
158
  apiKeyStamper: this.apiKeyStamper,
106
159
  passkeyStamper: this.passkeyStamper,
160
+ attestedStamper: this.attestedStamper,
107
161
  walletStamper: this.walletManager?.stamper,
108
162
  storageManager: this.storageManager,
109
163
  });
@@ -245,6 +299,7 @@ class TurnkeyClient {
245
299
  };
246
300
  await this.overridePasskeyStamper({ config: mergedConfig });
247
301
  }
302
+ const sessionProfileId = params?.sessionProfileId;
248
303
  if (!generatedPublicKey) {
249
304
  throw new TurnkeyError("A publickey could not be found or generated.", TurnkeyErrorCodes.INTERNAL_ERROR);
250
305
  }
@@ -252,6 +307,7 @@ class TurnkeyClient {
252
307
  publicKey: generatedPublicKey,
253
308
  organizationId: params?.organizationId ?? this.config.organizationId,
254
309
  expirationSeconds,
310
+ ...(sessionProfileId && { sessionProfileId }),
255
311
  };
256
312
  const passkeyLoginRequest = await this.httpClient.stampStampLogin(loginPayload, StamperType.Passkey);
257
313
  if (!passkeyLoginRequest) {
@@ -319,7 +375,7 @@ class TurnkeyClient {
319
375
  * @throws {TurnkeyError} If there is an error during passkey creation, sub-organization creation, or session storage.
320
376
  */
321
377
  this.signUpWithPasskey = async (params) => {
322
- const { passkeyDisplayName, challenge, expirationSeconds = DEFAULT_SESSION_EXPIRATION_IN_SECONDS, createSubOrgParams, sessionKey = SessionKey.DefaultSessionkey, captchaToken, } = params || {};
378
+ const { passkeyDisplayName, challenge, expirationSeconds = DEFAULT_SESSION_EXPIRATION_IN_SECONDS, createSubOrgParams, sessionKey = SessionKey.DefaultSessionkey, sessionProfileId, captchaToken, } = params || {};
323
379
  const generatedPublicKey = await this.createApiKeyPair();
324
380
  return withTurnkeyErrorHandling(async () => {
325
381
  if (!this.passkeyStamper) {
@@ -368,6 +424,7 @@ class TurnkeyClient {
368
424
  publicKey: newGeneratedKeyPair,
369
425
  organizationId: res.organizationId,
370
426
  expirationSeconds,
427
+ ...(sessionProfileId && { sessionProfileId }),
371
428
  });
372
429
  await this.storeSession({
373
430
  sessionToken: sessionResponse.session,
@@ -526,7 +583,7 @@ class TurnkeyClient {
526
583
  * or the public key cannot be derived or generated.
527
584
  */
528
585
  this.buildWalletLoginRequest = async (params) => {
529
- const { walletProvider, publicKey: providedPublicKey } = params;
586
+ const { walletProvider, publicKey: providedPublicKey, sessionProfileId, } = params;
530
587
  const expirationSeconds = params.expirationSeconds || DEFAULT_SESSION_EXPIRATION_IN_SECONDS;
531
588
  const futureSessionPublicKey = providedPublicKey ?? (await this.createApiKeyPair());
532
589
  return withTurnkeyErrorHandling(async () => {
@@ -545,6 +602,7 @@ class TurnkeyClient {
545
602
  publicKey: futureSessionPublicKey,
546
603
  organizationId: this.config.organizationId,
547
604
  expirationSeconds,
605
+ ...(sessionProfileId && { sessionProfileId }),
548
606
  }, StamperType.Wallet);
549
607
  }, {
550
608
  errorMessage: "Failed to create stamped request for wallet login",
@@ -643,13 +701,14 @@ class TurnkeyClient {
643
701
  * @param params.sessionKey - session key to use for storing the session (defaults to the default session key).
644
702
  * @param params.expirationSeconds - session expiration time in seconds (defaults to the configured default).
645
703
  * @param params.organizationId - organization ID to target (defaults to the session's organization ID or the parent organization ID).
704
+ * @param params.captchaToken - optional captcha token for bot prevention during sign up (must be enabled in the auth proxy config to take effect).
646
705
  * @returns A promise that resolves to a {@link WalletAuthResult}, which includes:
647
706
  * - `sessionToken`: the signed JWT session token.
648
707
  * - `address`: the authenticated wallet address.
649
708
  * @throws {TurnkeyError} If there is an error during wallet authentication, sub-organization creation, session storage, or cleanup.
650
709
  */
651
710
  this.signUpWithWallet = async (params) => {
652
- const { walletProvider, createSubOrgParams, sessionKey = SessionKey.DefaultSessionkey, } = params;
711
+ const { walletProvider, createSubOrgParams, sessionKey = SessionKey.DefaultSessionkey, captchaToken, } = params;
653
712
  return withTurnkeyErrorHandling(async () => {
654
713
  const { signedRequest, publicKey } = await this.buildWalletLoginRequest(params);
655
714
  const signUpBody = buildSignUpBody({
@@ -664,7 +723,7 @@ class TurnkeyClient {
664
723
  ],
665
724
  },
666
725
  });
667
- const res = await this.httpClient.proxySignupV2(signUpBody);
726
+ const res = await this.httpClient.proxySignupV2(signUpBody, captchaToken);
668
727
  if (!res) {
669
728
  throw new TurnkeyError(`Sign up failed`, TurnkeyErrorCodes.WALLET_SIGNUP_AUTH_ERROR);
670
729
  }
@@ -887,34 +946,27 @@ class TurnkeyClient {
887
946
  * @throws {TurnkeyError} If there is an error during the OTP login process or if key pair cleanup fails.
888
947
  */
889
948
  this.loginWithOtp = async (params) => {
890
- const { verificationToken, invalidateExisting = false, organizationId, sessionKey = SessionKey.DefaultSessionkey, } = params;
949
+ const { verificationToken, invalidateExisting = false, organizationId, sessionKey = SessionKey.DefaultSessionkey, expirationSeconds = DEFAULT_SESSION_EXPIRATION_IN_SECONDS, sessionProfileId, } = params;
891
950
  return withTurnkeyErrorHandling(async () => {
892
- const { message, publicKey: verificationPublicKey } = getClientSignatureMessageForLogin({ verificationToken });
893
- // we sign with the verification token key. This is the key bound during
894
- // verifyOtp() and is what Turnkey expects to sign the client signature for login
895
- const signature = await this.signWithApiKey({
896
- message,
897
- publicKey: verificationPublicKey,
898
- });
899
- if (!signature) {
900
- throw new TurnkeyError(`Failed to sign client signature for OTP login`, TurnkeyErrorCodes.INTERNAL_ERROR);
951
+ const { public_key: verificationPublicKey } = decodeVerificationToken(verificationToken);
952
+ if (!verificationPublicKey) {
953
+ throw new TurnkeyError("Invalid verification token: missing publicKey", TurnkeyErrorCodes.INVALID_REQUEST);
901
954
  }
902
- const clientSignature = {
903
- message: message,
955
+ // We override the attested stamper with the verification token so the stampLogin request can be stamped with it.
956
+ await this.overrideAttestedStamper({
957
+ verificationToken,
904
958
  publicKey: verificationPublicKey,
905
- scheme: "CLIENT_SIGNATURE_SCHEME_API_P256",
906
- signature: signature,
907
- };
959
+ });
908
960
  // the verification token's public key is also used as the session public key for login
909
- const loginRes = await this.httpClient.proxyOtpLoginV2({
910
- verificationToken,
961
+ const loginRes = await this.httpClient.stampLogin({
911
962
  publicKey: verificationPublicKey,
912
- clientSignature,
963
+ expirationSeconds,
913
964
  invalidateExisting,
914
965
  ...(organizationId && { organizationId }),
915
- });
966
+ ...(sessionProfileId && { sessionProfileId }),
967
+ }, StamperType.Attested);
916
968
  if (!loginRes) {
917
- throw new TurnkeyError(`Auth proxy OTP login failed`, TurnkeyErrorCodes.OTP_LOGIN_ERROR);
969
+ throw new TurnkeyError(`OTP login failed`, TurnkeyErrorCodes.OTP_LOGIN_ERROR);
918
970
  }
919
971
  if (!loginRes.session) {
920
972
  throw new TurnkeyError("No session returned from OTP login", TurnkeyErrorCodes.OTP_LOGIN_ERROR);
@@ -952,7 +1004,7 @@ class TurnkeyClient {
952
1004
  * @throws {TurnkeyError} If there is an error during the OTP sign-up process or session storage.
953
1005
  */
954
1006
  this.signUpWithOtp = async (params) => {
955
- const { verificationToken, contact, otpType, createSubOrgParams, invalidateExisting, sessionKey, captchaToken, } = params;
1007
+ const { verificationToken, contact, otpType, createSubOrgParams, invalidateExisting, sessionKey, sessionProfileId, captchaToken, } = params;
956
1008
  // build sign up body without client signature first
957
1009
  const signUpBody = buildSignUpBody({
958
1010
  createSubOrgParams: {
@@ -1000,6 +1052,7 @@ class TurnkeyClient {
1000
1052
  verificationToken,
1001
1053
  ...(invalidateExisting && { invalidateExisting }),
1002
1054
  ...(sessionKey && { sessionKey }),
1055
+ ...(sessionProfileId && { sessionProfileId }),
1003
1056
  });
1004
1057
  return {
1005
1058
  ...otpRes,
@@ -1037,7 +1090,7 @@ class TurnkeyClient {
1037
1090
  * @throws {TurnkeyError} If there is an error during OTP verification, sign-up, or login.
1038
1091
  */
1039
1092
  this.completeOtp = async (params) => {
1040
- const { otpId, otpCode, otpEncryptionTargetBundle, contact, otpType, invalidateExisting = false, sessionKey, createSubOrgParams, captchaToken, } = params;
1093
+ const { otpId, otpCode, otpEncryptionTargetBundle, contact, otpType, invalidateExisting = false, sessionKey, createSubOrgParams, sessionProfileId, captchaToken, } = params;
1041
1094
  const publicKey = params.publicKey ?? (await this.createApiKeyPair());
1042
1095
  if (!publicKey) {
1043
1096
  throw new TurnkeyError("No public key available. Either pass a publicKey or ensure apiKeyStamper is configured.", TurnkeyErrorCodes.INVALID_REQUEST);
@@ -1069,6 +1122,7 @@ class TurnkeyClient {
1069
1122
  ...(createSubOrgParams && { createSubOrgParams }),
1070
1123
  ...(invalidateExisting && { invalidateExisting }),
1071
1124
  ...(sessionKey && { sessionKey }),
1125
+ ...(sessionProfileId && { sessionProfileId }),
1072
1126
  ...(captchaToken && { captchaToken }),
1073
1127
  });
1074
1128
  return {
@@ -1082,6 +1136,7 @@ class TurnkeyClient {
1082
1136
  verificationToken,
1083
1137
  ...(invalidateExisting && { invalidateExisting }),
1084
1138
  ...(sessionKey && { sessionKey }),
1139
+ ...(sessionProfileId && { sessionProfileId }),
1085
1140
  });
1086
1141
  return {
1087
1142
  ...loginRes,
@@ -1127,7 +1182,7 @@ class TurnkeyClient {
1127
1182
  * @throws {TurnkeyError} If there is an error during the OAuth completion process, such as account lookup, sign-up, or login.
1128
1183
  */
1129
1184
  this.completeOauth = async (params) => {
1130
- const { oidcToken, publicKey, providerName, createSubOrgParams, invalidateExisting, sessionKey, captchaToken, } = params;
1185
+ const { oidcToken, publicKey, providerName, createSubOrgParams, invalidateExisting, sessionKey, sessionProfileId, captchaToken, } = params;
1131
1186
  return withTurnkeyErrorHandling(async () => {
1132
1187
  const accountRes = await this.httpClient.proxyGetAccount({
1133
1188
  filterType: "OIDC_TOKEN",
@@ -1143,6 +1198,7 @@ class TurnkeyClient {
1143
1198
  publicKey,
1144
1199
  ...(invalidateExisting && { invalidateExisting }),
1145
1200
  ...(sessionKey && { sessionKey }),
1201
+ ...(sessionProfileId && { sessionProfileId }),
1146
1202
  });
1147
1203
  return {
1148
1204
  ...loginRes,
@@ -1161,6 +1217,7 @@ class TurnkeyClient {
1161
1217
  }),
1162
1218
  ...(invalidateExisting && { invalidateExisting }),
1163
1219
  ...(sessionKey && { sessionKey }),
1220
+ ...(sessionProfileId && { sessionProfileId }),
1164
1221
  ...(captchaToken && { captchaToken }),
1165
1222
  });
1166
1223
  return {
@@ -1193,19 +1250,25 @@ class TurnkeyClient {
1193
1250
  * @throws {TurnkeyError} If there is an error during the OAuth login process or if key pair cleanup fails.
1194
1251
  */
1195
1252
  this.loginWithOauth = async (params) => {
1196
- const { oidcToken, publicKey, organizationId, invalidateExisting = false, sessionKey = SessionKey.DefaultSessionkey, } = params;
1253
+ const { oidcToken, publicKey, organizationId, invalidateExisting = false, sessionKey = SessionKey.DefaultSessionkey, expirationSeconds = DEFAULT_SESSION_EXPIRATION_IN_SECONDS, sessionProfileId, } = params;
1197
1254
  return withTurnkeyErrorHandling(async () => {
1198
1255
  if (!publicKey) {
1199
1256
  throw new TurnkeyError("Public key must be provided to log in with OAuth. Please create a key pair first.", TurnkeyErrorCodes.MISSING_PARAMS);
1200
1257
  }
1201
- const loginRes = await this.httpClient.proxyOAuthLogin({
1258
+ // We override the attested stamper with the oidcToken so the stampLogin request can be stamped with it.
1259
+ await this.overrideAttestedStamper({
1202
1260
  oidcToken,
1203
1261
  publicKey,
1262
+ });
1263
+ const loginRes = await this.httpClient.stampLogin({
1264
+ publicKey,
1265
+ expirationSeconds,
1204
1266
  invalidateExisting,
1205
1267
  ...(organizationId && { organizationId }),
1206
- });
1268
+ ...(sessionProfileId && { sessionProfileId }),
1269
+ }, StamperType.Attested);
1207
1270
  if (!loginRes) {
1208
- throw new TurnkeyError(`Auth proxy OAuth login failed`, TurnkeyErrorCodes.OAUTH_LOGIN_ERROR);
1271
+ throw new TurnkeyError(`OAuth login failed`, TurnkeyErrorCodes.OAUTH_LOGIN_ERROR);
1209
1272
  }
1210
1273
  if (!loginRes.session) {
1211
1274
  throw new TurnkeyError("No session returned from oauth login", TurnkeyErrorCodes.OAUTH_LOGIN_ERROR);
@@ -1256,7 +1319,7 @@ class TurnkeyClient {
1256
1319
  * @throws {TurnkeyError} If there is an error during the OAuth sign-up or login process.
1257
1320
  */
1258
1321
  this.signUpWithOauth = async (params) => {
1259
- const { oidcToken, publicKey, providerName = "OpenID Connect Provider" + " " + Date.now(), createSubOrgParams, sessionKey, captchaToken, } = params;
1322
+ const { oidcToken, publicKey, providerName = "OpenID Connect Provider" + " " + Date.now(), createSubOrgParams, sessionKey, sessionProfileId, captchaToken, } = params;
1260
1323
  return withTurnkeyErrorHandling(async () => {
1261
1324
  const signUpBody = buildSignUpBody({
1262
1325
  createSubOrgParams: {
@@ -1278,6 +1341,7 @@ class TurnkeyClient {
1278
1341
  oidcToken,
1279
1342
  publicKey: publicKey,
1280
1343
  ...(sessionKey && { sessionKey }),
1344
+ ...(sessionProfileId && { sessionProfileId }),
1281
1345
  });
1282
1346
  return {
1283
1347
  ...oauthRes,
@@ -3135,6 +3199,9 @@ class TurnkeyClient {
3135
3199
  publicKey: keyPair,
3136
3200
  expirationSeconds,
3137
3201
  invalidateExisting: invalidateExisitng,
3202
+ ...(session.sessionProfileId && {
3203
+ sessionProfileId: session.sessionProfileId,
3204
+ }),
3138
3205
  }, stampWith);
3139
3206
  if (!res || !res.session) {
3140
3207
  throw new TurnkeyError("No session found in the refresh response", TurnkeyErrorCodes.BAD_RESPONSE);
@@ -3500,6 +3567,7 @@ class TurnkeyClient {
3500
3567
  // Just store any explicitly provided stampers
3501
3568
  this.apiKeyStamper = apiKeyStamper;
3502
3569
  this.passkeyStamper = passkeyStamper;
3570
+ this.attestedStamper = attestedStamper;
3503
3571
  this.walletManager = walletManager;
3504
3572
  // Actual initialization will happen in init()
3505
3573
  }
@@ -3509,6 +3577,8 @@ class TurnkeyClient {
3509
3577
  this.storageManager = await createStorageManager();
3510
3578
  // Initialize the API key stamper
3511
3579
  this.apiKeyStamper = new CrossPlatformApiKeyStamper(this.storageManager);
3580
+ // Then use it to initialize the attested stamper
3581
+ this.attestedStamper = new AttestedStamper(this.apiKeyStamper);
3512
3582
  // we parallelize independent initializations:
3513
3583
  // - API key stamper init
3514
3584
  // - Passkey stamper creation and init (if configured)