@turnkey/core 1.9.0 → 1.11.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 +2 -1
- package/dist/__clients__/core.d.ts.map +1 -1
- package/dist/__clients__/core.js +112 -18
- package/dist/__clients__/core.js.map +1 -1
- package/dist/__clients__/core.mjs +111 -17
- package/dist/__clients__/core.mjs.map +1 -1
- package/dist/__generated__/sdk-client-base.d.ts.map +1 -1
- package/dist/__generated__/sdk-client-base.js +314 -122
- package/dist/__generated__/sdk-client-base.js.map +1 -1
- package/dist/__generated__/sdk-client-base.mjs +314 -122
- package/dist/__generated__/sdk-client-base.mjs.map +1 -1
- package/dist/__generated__/version.d.ts +1 -1
- package/dist/__generated__/version.d.ts.map +1 -1
- package/dist/__generated__/version.js +1 -1
- package/dist/__generated__/version.mjs +1 -1
- package/dist/__stampers__/api/base.d.ts +2 -0
- package/dist/__stampers__/api/base.d.ts.map +1 -1
- package/dist/__stampers__/api/base.js +19 -0
- package/dist/__stampers__/api/base.js.map +1 -1
- package/dist/__stampers__/api/base.mjs +19 -0
- package/dist/__stampers__/api/base.mjs.map +1 -1
- package/dist/__stampers__/api/mobile/stamper.d.ts +2 -0
- package/dist/__stampers__/api/mobile/stamper.d.ts.map +1 -1
- package/dist/__stampers__/api/mobile/stamper.js +19 -0
- package/dist/__stampers__/api/mobile/stamper.js.map +1 -1
- package/dist/__stampers__/api/mobile/stamper.mjs +20 -1
- package/dist/__stampers__/api/mobile/stamper.mjs.map +1 -1
- package/dist/__stampers__/api/web/stamper.d.ts +2 -1
- package/dist/__stampers__/api/web/stamper.d.ts.map +1 -1
- package/dist/__stampers__/api/web/stamper.js +9 -4
- package/dist/__stampers__/api/web/stamper.js.map +1 -1
- package/dist/__stampers__/api/web/stamper.mjs +9 -4
- package/dist/__stampers__/api/web/stamper.mjs.map +1 -1
- package/dist/__types__/auth.d.ts +2 -0
- package/dist/__types__/auth.d.ts.map +1 -1
- package/dist/__types__/auth.js.map +1 -1
- package/dist/__types__/auth.mjs.map +1 -1
- package/dist/__types__/method-types/shared.d.ts +2 -0
- package/dist/__types__/method-types/shared.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/utils.d.ts +20 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +57 -0
- package/dist/utils.js.map +1 -1
- package/dist/utils.mjs +55 -1
- package/dist/utils.mjs.map +1 -1
- package/package.json +7 -7
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TurnkeySDKClientBase } from "../__generated__/sdk-client-base";
|
|
2
|
-
import { type TDeleteSubOrganizationResponse, type Session, type TStampLoginResponse, type v1SignRawPayloadResult, type v1User, type ProxyTGetWalletKitConfigResponse, type v1PrivateKey, type WalletAuthResult, type BaseAuthResult,
|
|
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
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 EthSendTransactionParams, 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, type PollTransactionStatusParams } from "../__types__";
|
|
4
4
|
import { CrossPlatformApiKeyStamper } from "../__stampers__/api/base";
|
|
5
5
|
import { CrossPlatformPasskeyStamper } from "../__stampers__/passkey/base";
|
|
@@ -267,6 +267,7 @@ export declare class TurnkeyClient {
|
|
|
267
267
|
* @param params.otpCode - OTP code entered by the user.
|
|
268
268
|
* @param params.contact - contact information for the user (e.g., email address or phone number).
|
|
269
269
|
* @param params.otpType - type of OTP being verified (OtpType.Email or OtpType.Sms).
|
|
270
|
+
* @param params.publicKey - public key the verification token is bound to for ownership verification (client signature verification during login/signup). This public key is optional; if not provided, a new key pair will be generated.
|
|
270
271
|
* @returns A promise that resolves to an object containing:
|
|
271
272
|
* - subOrganizationId: sub-organization ID if the contact is already associated with a sub-organization, or an empty string if not.
|
|
272
273
|
* - verificationToken: verification token to be used for login or sign-up.
|
|
@@ -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,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et__/base.js');
|
|
14
14
|
var ethers = require('ethers');
|
|
15
15
|
var crypto = require('@turnkey/crypto');
|
|
16
|
+
var apiKeyStamper = require('@turnkey/api-key-stamper');
|
|
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$1, passkeyStamper, walletManager) {
|
|
21
22
|
/**
|
|
22
23
|
* Creates a new TurnkeySDKClientBase instance with the provided configuration.
|
|
23
24
|
* This method is used internally to create the HTTP client for making API requests,
|
|
@@ -810,6 +811,7 @@ class TurnkeyClient {
|
|
|
810
811
|
* @param params.otpCode - OTP code entered by the user.
|
|
811
812
|
* @param params.contact - contact information for the user (e.g., email address or phone number).
|
|
812
813
|
* @param params.otpType - type of OTP being verified (OtpType.Email or OtpType.Sms).
|
|
814
|
+
* @param params.publicKey - public key the verification token is bound to for ownership verification (client signature verification during login/signup). This public key is optional; if not provided, a new key pair will be generated.
|
|
813
815
|
* @returns A promise that resolves to an object containing:
|
|
814
816
|
* - subOrganizationId: sub-organization ID if the contact is already associated with a sub-organization, or an empty string if not.
|
|
815
817
|
* - verificationToken: verification token to be used for login or sign-up.
|
|
@@ -817,10 +819,12 @@ class TurnkeyClient {
|
|
|
817
819
|
*/
|
|
818
820
|
this.verifyOtp = async (params) => {
|
|
819
821
|
const { otpId, otpCode, contact, otpType } = params;
|
|
822
|
+
const resolvedPublicKey = params.publicKey ?? (await this.apiKeyStamper?.createKeyPair());
|
|
820
823
|
return utils.withTurnkeyErrorHandling(async () => {
|
|
821
824
|
const verifyOtpRes = await this.httpClient.proxyVerifyOtp({
|
|
822
825
|
otpId: otpId,
|
|
823
826
|
otpCode: otpCode,
|
|
827
|
+
publicKey: resolvedPublicKey,
|
|
824
828
|
});
|
|
825
829
|
if (!verifyOtpRes) {
|
|
826
830
|
throw new sdkTypes.TurnkeyError(`OTP verification failed`, sdkTypes.TurnkeyErrorCodes.INTERNAL_ERROR);
|
|
@@ -828,6 +832,7 @@ class TurnkeyClient {
|
|
|
828
832
|
const accountRes = await this.httpClient.proxyGetAccount({
|
|
829
833
|
filterType: enums.OtpTypeToFilterTypeMap[otpType],
|
|
830
834
|
filterValue: contact,
|
|
835
|
+
verificationToken: verifyOtpRes.verificationToken,
|
|
831
836
|
});
|
|
832
837
|
if (!accountRes) {
|
|
833
838
|
throw new sdkTypes.TurnkeyError(`Account fetch failed`, sdkTypes.TurnkeyErrorCodes.ACCOUNT_FETCH_ERROR);
|
|
@@ -869,10 +874,26 @@ class TurnkeyClient {
|
|
|
869
874
|
this.loginWithOtp = async (params) => {
|
|
870
875
|
const { verificationToken, invalidateExisting = false, publicKey = await this.apiKeyStamper?.createKeyPair(), organizationId, sessionKey = enums.SessionKey.DefaultSessionkey, } = params;
|
|
871
876
|
return utils.withTurnkeyErrorHandling(async () => {
|
|
877
|
+
const { message, publicKey: clientSignaturePublicKey } = utils.getClientSignatureMessageForLogin({
|
|
878
|
+
verificationToken,
|
|
879
|
+
sessionPublicKey: publicKey,
|
|
880
|
+
});
|
|
881
|
+
this.apiKeyStamper?.setTemporaryPublicKey(publicKey);
|
|
882
|
+
const signature = await this.apiKeyStamper?.sign(message, apiKeyStamper.SignatureFormat.Raw);
|
|
883
|
+
if (!signature) {
|
|
884
|
+
throw new sdkTypes.TurnkeyError(`Failed to sign client signature for OTP login`, sdkTypes.TurnkeyErrorCodes.INTERNAL_ERROR);
|
|
885
|
+
}
|
|
886
|
+
const clientSignature = {
|
|
887
|
+
message: message,
|
|
888
|
+
publicKey: clientSignaturePublicKey,
|
|
889
|
+
scheme: "CLIENT_SIGNATURE_SCHEME_API_P256",
|
|
890
|
+
signature: signature,
|
|
891
|
+
};
|
|
872
892
|
const res = await this.httpClient.proxyOtpLogin({
|
|
873
893
|
verificationToken,
|
|
874
894
|
publicKey: publicKey,
|
|
875
895
|
invalidateExisting,
|
|
896
|
+
clientSignature,
|
|
876
897
|
...(organizationId && { organizationId }),
|
|
877
898
|
});
|
|
878
899
|
if (!res) {
|
|
@@ -903,6 +924,10 @@ class TurnkeyClient {
|
|
|
903
924
|
}
|
|
904
925
|
}
|
|
905
926
|
},
|
|
927
|
+
}, {
|
|
928
|
+
finallyFn: async () => {
|
|
929
|
+
this.apiKeyStamper?.clearTemporaryPublicKey();
|
|
930
|
+
},
|
|
906
931
|
});
|
|
907
932
|
};
|
|
908
933
|
/**
|
|
@@ -925,7 +950,8 @@ class TurnkeyClient {
|
|
|
925
950
|
* @throws {TurnkeyError} If there is an error during the OTP sign-up process or session storage.
|
|
926
951
|
*/
|
|
927
952
|
this.signUpWithOtp = async (params) => {
|
|
928
|
-
const { verificationToken, contact, otpType, createSubOrgParams, invalidateExisting, sessionKey, } = params;
|
|
953
|
+
const { verificationToken, contact, otpType, createSubOrgParams, invalidateExisting, sessionKey, publicKey = await this.apiKeyStamper?.createKeyPair(), } = params;
|
|
954
|
+
// build sign up body without client signature first
|
|
929
955
|
const signUpBody = utils.buildSignUpBody({
|
|
930
956
|
createSubOrgParams: {
|
|
931
957
|
...createSubOrgParams,
|
|
@@ -936,14 +962,37 @@ class TurnkeyClient {
|
|
|
936
962
|
},
|
|
937
963
|
});
|
|
938
964
|
return utils.withTurnkeyErrorHandling(async () => {
|
|
939
|
-
const
|
|
940
|
-
|
|
965
|
+
const { message, publicKey: clientSignaturePublicKey } = utils.getClientSignatureMessageForSignup({
|
|
966
|
+
verificationToken,
|
|
967
|
+
...(signUpBody.userEmail && { email: signUpBody.userEmail }),
|
|
968
|
+
...(signUpBody.userPhoneNumber && {
|
|
969
|
+
phoneNumber: signUpBody.userPhoneNumber,
|
|
970
|
+
}),
|
|
971
|
+
apiKeys: signUpBody.apiKeys,
|
|
972
|
+
authenticators: signUpBody.authenticators,
|
|
973
|
+
oauthProviders: signUpBody.oauthProviders,
|
|
974
|
+
});
|
|
975
|
+
this.apiKeyStamper?.setTemporaryPublicKey(publicKey);
|
|
976
|
+
const signature = await this.apiKeyStamper?.sign(message, apiKeyStamper.SignatureFormat.Raw);
|
|
977
|
+
if (!signature) {
|
|
978
|
+
throw new sdkTypes.TurnkeyError(`Failed to sign client signature for OTP sign up`, sdkTypes.TurnkeyErrorCodes.INTERNAL_ERROR);
|
|
979
|
+
}
|
|
980
|
+
const clientSignature = {
|
|
981
|
+
message: message,
|
|
982
|
+
publicKey: clientSignaturePublicKey,
|
|
983
|
+
scheme: "CLIENT_SIGNATURE_SCHEME_API_P256",
|
|
984
|
+
signature: signature,
|
|
985
|
+
};
|
|
986
|
+
const signupRes = await this.httpClient.proxySignup({
|
|
987
|
+
...signUpBody,
|
|
988
|
+
clientSignature,
|
|
989
|
+
});
|
|
941
990
|
if (!signupRes) {
|
|
942
991
|
throw new sdkTypes.TurnkeyError(`Auth proxy OTP sign up failed`, sdkTypes.TurnkeyErrorCodes.OTP_SIGNUP_ERROR);
|
|
943
992
|
}
|
|
944
993
|
const otpRes = await this.loginWithOtp({
|
|
945
994
|
verificationToken,
|
|
946
|
-
publicKey:
|
|
995
|
+
publicKey: publicKey,
|
|
947
996
|
...(invalidateExisting && { invalidateExisting }),
|
|
948
997
|
...(sessionKey && { sessionKey }),
|
|
949
998
|
});
|
|
@@ -952,8 +1001,23 @@ class TurnkeyClient {
|
|
|
952
1001
|
appProofs: signupRes.appProofs,
|
|
953
1002
|
};
|
|
954
1003
|
}, {
|
|
1004
|
+
catchFn: async () => {
|
|
1005
|
+
// Clean up the generated key pair if it wasn't successfully used
|
|
1006
|
+
if (publicKey) {
|
|
1007
|
+
try {
|
|
1008
|
+
await this.apiKeyStamper?.deleteKeyPair(publicKey);
|
|
1009
|
+
}
|
|
1010
|
+
catch (cleanupError) {
|
|
1011
|
+
throw new sdkTypes.TurnkeyError(`Failed to clean up generated key pair`, sdkTypes.TurnkeyErrorCodes.KEY_PAIR_CLEANUP_ERROR, cleanupError);
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
},
|
|
955
1015
|
errorCode: sdkTypes.TurnkeyErrorCodes.OTP_SIGNUP_ERROR,
|
|
956
1016
|
errorMessage: "Failed to sign up with OTP",
|
|
1017
|
+
}, {
|
|
1018
|
+
finallyFn: async () => {
|
|
1019
|
+
this.apiKeyStamper?.clearTemporaryPublicKey();
|
|
1020
|
+
},
|
|
957
1021
|
});
|
|
958
1022
|
};
|
|
959
1023
|
/**
|
|
@@ -980,13 +1044,14 @@ class TurnkeyClient {
|
|
|
980
1044
|
* @throws {TurnkeyError} If there is an error during OTP verification, sign-up, or login.
|
|
981
1045
|
*/
|
|
982
1046
|
this.completeOtp = async (params) => {
|
|
983
|
-
const { otpId, otpCode, contact, otpType, publicKey, invalidateExisting = false, sessionKey, createSubOrgParams, } = params;
|
|
1047
|
+
const { otpId, otpCode, contact, otpType, publicKey = await this.apiKeyStamper?.createKeyPair(), invalidateExisting = false, sessionKey, createSubOrgParams, } = params;
|
|
984
1048
|
return utils.withTurnkeyErrorHandling(async () => {
|
|
985
1049
|
const { subOrganizationId, verificationToken } = await this.verifyOtp({
|
|
986
1050
|
otpId: otpId,
|
|
987
1051
|
otpCode: otpCode,
|
|
988
1052
|
contact: contact,
|
|
989
1053
|
otpType: otpType,
|
|
1054
|
+
publicKey: publicKey,
|
|
990
1055
|
});
|
|
991
1056
|
if (!verificationToken) {
|
|
992
1057
|
throw new sdkTypes.TurnkeyError("No verification token returned from OTP verification", sdkTypes.TurnkeyErrorCodes.VERIFY_OTP_ERROR);
|
|
@@ -999,6 +1064,7 @@ class TurnkeyClient {
|
|
|
999
1064
|
...(createSubOrgParams && { createSubOrgParams }),
|
|
1000
1065
|
...(invalidateExisting && { invalidateExisting }),
|
|
1001
1066
|
...(sessionKey && { sessionKey }),
|
|
1067
|
+
publicKey: publicKey,
|
|
1002
1068
|
});
|
|
1003
1069
|
return {
|
|
1004
1070
|
...signUpRes,
|
|
@@ -1009,7 +1075,7 @@ class TurnkeyClient {
|
|
|
1009
1075
|
else {
|
|
1010
1076
|
const loginRes = await this.loginWithOtp({
|
|
1011
1077
|
verificationToken,
|
|
1012
|
-
|
|
1078
|
+
publicKey: publicKey,
|
|
1013
1079
|
...(invalidateExisting && { invalidateExisting }),
|
|
1014
1080
|
...(sessionKey && { sessionKey }),
|
|
1015
1081
|
});
|
|
@@ -2062,12 +2128,15 @@ class TurnkeyClient {
|
|
|
2062
2128
|
throw new sdkTypes.TurnkeyError("User ID must be provided to update user email", sdkTypes.TurnkeyErrorCodes.INVALID_REQUEST);
|
|
2063
2129
|
}
|
|
2064
2130
|
return utils.withTurnkeyErrorHandling(async () => {
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2131
|
+
if (verificationToken) {
|
|
2132
|
+
const existingUser = await this.httpClient.proxyGetAccount({
|
|
2133
|
+
filterType: enums.FilterType.Email,
|
|
2134
|
+
filterValue: email,
|
|
2135
|
+
verificationToken,
|
|
2136
|
+
});
|
|
2137
|
+
if (existingUser.organizationId) {
|
|
2138
|
+
throw new sdkTypes.TurnkeyError(`Email ${email} is already associated with another user.`, sdkTypes.TurnkeyErrorCodes.ACCOUNT_ALREADY_EXISTS);
|
|
2139
|
+
}
|
|
2071
2140
|
}
|
|
2072
2141
|
const res = await this.httpClient.updateUserEmail({
|
|
2073
2142
|
userId: userId,
|
|
@@ -2145,6 +2214,16 @@ class TurnkeyClient {
|
|
|
2145
2214
|
throw new sdkTypes.TurnkeyError("User ID must be provided to update user phone number", sdkTypes.TurnkeyErrorCodes.INVALID_REQUEST);
|
|
2146
2215
|
}
|
|
2147
2216
|
return utils.withTurnkeyErrorHandling(async () => {
|
|
2217
|
+
if (verificationToken) {
|
|
2218
|
+
const existingUser = await this.httpClient.proxyGetAccount({
|
|
2219
|
+
filterType: enums.FilterType.Sms,
|
|
2220
|
+
filterValue: phoneNumber,
|
|
2221
|
+
verificationToken,
|
|
2222
|
+
});
|
|
2223
|
+
if (existingUser.organizationId) {
|
|
2224
|
+
throw new sdkTypes.TurnkeyError(`Phone number ${phoneNumber} is already associated with another user.`, sdkTypes.TurnkeyErrorCodes.ACCOUNT_ALREADY_EXISTS);
|
|
2225
|
+
}
|
|
2226
|
+
}
|
|
2148
2227
|
const res = await this.httpClient.updateUserPhoneNumber({
|
|
2149
2228
|
userId,
|
|
2150
2229
|
userPhoneNumber: phoneNumber,
|
|
@@ -2280,18 +2359,33 @@ class TurnkeyClient {
|
|
|
2280
2359
|
const verifiedSuborg = await this.httpClient.proxyGetAccount({
|
|
2281
2360
|
filterType: "EMAIL",
|
|
2282
2361
|
filterValue: oidcEmail,
|
|
2362
|
+
oidcToken: oidcToken,
|
|
2283
2363
|
});
|
|
2284
2364
|
const isVerified = verifiedSuborg.organizationId === organizationId;
|
|
2285
2365
|
const user = await this.fetchUser({
|
|
2286
2366
|
userId,
|
|
2287
2367
|
stampWith,
|
|
2288
2368
|
});
|
|
2369
|
+
// this block's pupose is for social linking, it's important that we update the email BEFORE we call createOauthProviders
|
|
2370
|
+
// since for social linking createOauthProviders will mark the email as verified as long as it's the same one that lives in the
|
|
2371
|
+
// OIDC token.
|
|
2289
2372
|
if (!user?.userEmail && !isVerified) {
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2373
|
+
// we cannot use our sugared updateUserEmail here since we need to pass in the oidcToken in case Require Verification Token On Account Lookup is enabled
|
|
2374
|
+
// in the dashboard
|
|
2375
|
+
const existingUser = await this.httpClient.proxyGetAccount({
|
|
2376
|
+
filterType: enums.FilterType.Email,
|
|
2377
|
+
filterValue: oidcEmail,
|
|
2378
|
+
oidcToken: oidcToken,
|
|
2294
2379
|
});
|
|
2380
|
+
if (existingUser.organizationId) {
|
|
2381
|
+
throw new sdkTypes.TurnkeyError(`Email ${oidcEmail} is already associated with another user.`, sdkTypes.TurnkeyErrorCodes.ACCOUNT_ALREADY_EXISTS);
|
|
2382
|
+
}
|
|
2383
|
+
// update and verify their email since we got it from a verified OIDC token
|
|
2384
|
+
await this.httpClient.updateUserEmail({
|
|
2385
|
+
userId,
|
|
2386
|
+
userEmail: oidcEmail,
|
|
2387
|
+
organizationId,
|
|
2388
|
+
}, stampWith);
|
|
2295
2389
|
}
|
|
2296
2390
|
}
|
|
2297
2391
|
const createProviderRes = await this.httpClient.createOauthProviders({
|
|
@@ -3211,7 +3305,7 @@ class TurnkeyClient {
|
|
|
3211
3305
|
};
|
|
3212
3306
|
this.config = config;
|
|
3213
3307
|
// Just store any explicitly provided stampers
|
|
3214
|
-
this.apiKeyStamper = apiKeyStamper;
|
|
3308
|
+
this.apiKeyStamper = apiKeyStamper$1;
|
|
3215
3309
|
this.passkeyStamper = passkeyStamper;
|
|
3216
3310
|
this.walletManager = walletManager;
|
|
3217
3311
|
// Actual initialization will happen in init()
|