@injectivelabs/wallet-turnkey 1.16.25-alpha.0 → 1.16.25

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 (41) hide show
  1. package/dist/cjs/index.d.ts +3 -0
  2. package/dist/cjs/index.js +21 -0
  3. package/dist/cjs/package.json +2 -2
  4. package/dist/cjs/strategy/Eip1193Provider.d.ts +3 -0
  5. package/dist/cjs/strategy/Eip1193Provider.js +173 -0
  6. package/dist/cjs/strategy/consts.d.ts +13 -0
  7. package/dist/cjs/strategy/consts.js +16 -0
  8. package/dist/cjs/strategy/strategy.d.ts +48 -0
  9. package/dist/cjs/strategy/strategy.js +295 -0
  10. package/dist/cjs/strategy/turnkey/oauth.d.ts +16 -0
  11. package/dist/cjs/strategy/turnkey/oauth.js +53 -0
  12. package/dist/cjs/strategy/turnkey/otp.d.ts +23 -0
  13. package/dist/cjs/strategy/turnkey/otp.js +65 -0
  14. package/dist/cjs/strategy/turnkey/turnkey.d.ts +35 -0
  15. package/dist/cjs/strategy/turnkey/turnkey.js +259 -0
  16. package/dist/cjs/strategy/types.d.ts +28 -0
  17. package/dist/cjs/strategy/types.js +6 -0
  18. package/dist/cjs/utils.d.ts +7 -0
  19. package/dist/cjs/utils.js +10 -0
  20. package/dist/esm/index.d.ts +3 -92
  21. package/dist/esm/index.js +3 -711
  22. package/dist/esm/package.json +2 -2
  23. package/dist/esm/strategy/Eip1193Provider.d.ts +3 -0
  24. package/dist/esm/strategy/Eip1193Provider.js +136 -0
  25. package/dist/esm/strategy/consts.d.ts +13 -0
  26. package/dist/esm/strategy/consts.js +13 -0
  27. package/dist/esm/strategy/strategy.d.ts +48 -0
  28. package/dist/esm/strategy/strategy.js +291 -0
  29. package/dist/esm/strategy/turnkey/oauth.d.ts +16 -0
  30. package/dist/esm/strategy/turnkey/oauth.js +49 -0
  31. package/dist/esm/strategy/turnkey/otp.d.ts +23 -0
  32. package/dist/esm/strategy/turnkey/otp.js +61 -0
  33. package/dist/esm/strategy/turnkey/turnkey.d.ts +35 -0
  34. package/dist/esm/strategy/turnkey/turnkey.js +255 -0
  35. package/dist/esm/strategy/types.d.ts +28 -0
  36. package/dist/esm/strategy/types.js +3 -0
  37. package/dist/esm/utils.d.ts +7 -0
  38. package/dist/esm/utils.js +7 -0
  39. package/package.json +20 -18
  40. package/dist/cjs/index.cjs +0 -736
  41. package/dist/cjs/index.d.cts +0 -92
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TurnkeyOtpWallet = void 0;
4
+ const exceptions_1 = require("@injectivelabs/exceptions");
5
+ const consts_js_1 = require("../consts.js");
6
+ class TurnkeyOtpWallet {
7
+ static async initEmailOTP(args) {
8
+ const { client, indexedDbClient, expirationSeconds } = args;
9
+ try {
10
+ await indexedDbClient.resetKeyPair();
11
+ let publicKey = await indexedDbClient.getPublicKey();
12
+ if (!publicKey) {
13
+ throw new exceptions_1.WalletException(new Error('Public key not found'));
14
+ }
15
+ // client.$post is undefined, resorting to this for now
16
+ const response = await client.post(args.otpInitPath || consts_js_1.TURNKEY_OTP_INIT_PATH, {
17
+ targetPublicKey: publicKey,
18
+ email: args.email,
19
+ suborgId: args.subOrgId,
20
+ invalidateExistingSessions: args.invalidateExistingSessions,
21
+ isUsingIndexedDB: true,
22
+ expirationSeconds: expirationSeconds || consts_js_1.DEFAULT_TURNKEY_REFRESH_SECONDS,
23
+ });
24
+ return response?.data;
25
+ }
26
+ catch (e) {
27
+ throw new exceptions_1.WalletException(new Error(e.message), {
28
+ code: exceptions_1.UnspecifiedErrorCode,
29
+ type: exceptions_1.ErrorType.WalletError,
30
+ contextModule: 'turnkey-init-email-otp',
31
+ });
32
+ }
33
+ }
34
+ static async confirmEmailOTP(args) {
35
+ const { client, expirationSeconds, targetPublicKey } = args;
36
+ try {
37
+ const organizationId = args.organizationId;
38
+ const emailOTPId = args.emailOTPId;
39
+ const otpVerifyPath = args.otpVerifyPath || consts_js_1.TURNKEY_OTP_VERIFY_PATH;
40
+ if (!emailOTPId) {
41
+ throw new exceptions_1.WalletException(new Error('Email OTP ID is required'));
42
+ }
43
+ if (!organizationId) {
44
+ throw new exceptions_1.WalletException(new Error('Organization ID is required'));
45
+ }
46
+ const response = await client.post(otpVerifyPath, {
47
+ isUsingIndexedDB: true,
48
+ targetPublicKey,
49
+ otpId: emailOTPId,
50
+ otpCode: args.otpCode,
51
+ suborgID: organizationId,
52
+ expirationSeconds: (expirationSeconds || consts_js_1.DEFAULT_TURNKEY_REFRESH_SECONDS)?.toString(),
53
+ });
54
+ return response?.data;
55
+ }
56
+ catch (e) {
57
+ throw new exceptions_1.WalletException(new Error(e.message), {
58
+ code: exceptions_1.UnspecifiedErrorCode,
59
+ type: exceptions_1.ErrorType.WalletError,
60
+ contextModule: 'turnkey-confirm-email-otp',
61
+ });
62
+ }
63
+ }
64
+ }
65
+ exports.TurnkeyOtpWallet = TurnkeyOtpWallet;
@@ -0,0 +1,35 @@
1
+ import { createAccount } from '@turnkey/viem';
2
+ import { HttpRestClient } from '@injectivelabs/utils';
3
+ import { Turnkey } from '@turnkey/sdk-browser';
4
+ import { TurnkeyProvider } from '@injectivelabs/wallet-base';
5
+ import type { TurnkeyMetadata } from '@injectivelabs/wallet-base';
6
+ import type { TurnkeyIndexedDbClient } from '@turnkey/sdk-browser';
7
+ export declare class TurnkeyWallet {
8
+ private otpId?;
9
+ protected turnkey?: Turnkey;
10
+ userOrganizationId?: string;
11
+ protected client: HttpRestClient;
12
+ private metadata;
13
+ protected indexedDbClient?: TurnkeyIndexedDbClient;
14
+ private accountMap;
15
+ setMetadata(metadata: Partial<TurnkeyMetadata>): void;
16
+ constructor(metadata: TurnkeyMetadata);
17
+ static getTurnkeyInstance(metadata: TurnkeyMetadata): Promise<{
18
+ turnkey: Turnkey;
19
+ indexedDbClient: TurnkeyIndexedDbClient;
20
+ }>;
21
+ getTurnkey(): Promise<Turnkey>;
22
+ getIndexedDbClient(): Promise<TurnkeyIndexedDbClient>;
23
+ getSession(existingCredentialBundle?: string): Promise<{
24
+ session: import("@turnkey/sdk-browser").Session | undefined;
25
+ organizationId: string;
26
+ }>;
27
+ getAccounts(): Promise<string[]>;
28
+ getOrCreateAndGetAccount(address: string): Promise<ReturnType<typeof createAccount>>;
29
+ initOTP(email: string): Promise<import("../types.js").TurnkeyOTPCredentialsResponse>;
30
+ confirmOTP(otpCode: string): Promise<import("../types.js").TurnkeyConfirmEmailOTPResponse>;
31
+ initOAuth(provider: TurnkeyProvider): Promise<string>;
32
+ confirmOAuth(provider: TurnkeyProvider, oidcToken: string): Promise<string>;
33
+ refreshSession(): Promise<string>;
34
+ private initClient;
35
+ }
@@ -0,0 +1,259 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TurnkeyWallet = void 0;
4
+ const viem_1 = require("@turnkey/viem");
5
+ const utils_1 = require("@injectivelabs/utils");
6
+ const sdk_ts_1 = require("@injectivelabs/sdk-ts");
7
+ const sdk_browser_1 = require("@turnkey/sdk-browser");
8
+ const wallet_base_1 = require("@injectivelabs/wallet-base");
9
+ const exceptions_1 = require("@injectivelabs/exceptions");
10
+ const otp_js_1 = require("./otp.js");
11
+ const types_js_1 = require("../types.js");
12
+ const oauth_js_1 = require("./oauth.js");
13
+ const utils_js_1 = require("../../utils.js");
14
+ const consts_js_1 = require("../consts.js");
15
+ class TurnkeyWallet {
16
+ otpId;
17
+ turnkey;
18
+ userOrganizationId;
19
+ client;
20
+ metadata;
21
+ indexedDbClient;
22
+ accountMap = {};
23
+ setMetadata(metadata) {
24
+ this.metadata = { ...this.metadata, ...metadata };
25
+ }
26
+ constructor(metadata) {
27
+ this.metadata = metadata;
28
+ this.client = new utils_1.HttpRestClient(metadata.apiServerEndpoint);
29
+ }
30
+ static async getTurnkeyInstance(metadata) {
31
+ const { turnkey, indexedDbClient } = await createTurnkeyClient(metadata);
32
+ return {
33
+ turnkey,
34
+ indexedDbClient,
35
+ };
36
+ }
37
+ async getTurnkey() {
38
+ if (!this.indexedDbClient) {
39
+ await this.initClient();
40
+ }
41
+ if (!this.turnkey) {
42
+ this.turnkey = new sdk_browser_1.Turnkey(this.metadata);
43
+ }
44
+ return this.turnkey;
45
+ }
46
+ async getIndexedDbClient() {
47
+ if (!this.indexedDbClient) {
48
+ await this.initClient();
49
+ }
50
+ if (!this.indexedDbClient) {
51
+ throw new exceptions_1.WalletException(new Error('Indexed DB client not initialized'));
52
+ }
53
+ return this.indexedDbClient;
54
+ }
55
+ async getSession(existingCredentialBundle) {
56
+ try {
57
+ const { metadata } = this;
58
+ const indexedDbClient = await this.getIndexedDbClient();
59
+ const turnkey = await this.getTurnkey();
60
+ const session = await turnkey.getSession();
61
+ const organizationId = session?.organizationId || metadata.defaultOrganizationId;
62
+ const credentialBundle = existingCredentialBundle || session?.token;
63
+ if (!credentialBundle) {
64
+ return {
65
+ session: undefined,
66
+ organizationId,
67
+ };
68
+ }
69
+ const user = await indexedDbClient.getWhoami();
70
+ const actualOrganizationId = user?.organizationId || session?.organizationId || organizationId;
71
+ if (!user) {
72
+ return {
73
+ session: undefined,
74
+ organizationId: actualOrganizationId,
75
+ };
76
+ }
77
+ this.userOrganizationId = actualOrganizationId;
78
+ return {
79
+ session,
80
+ organizationId: actualOrganizationId,
81
+ };
82
+ }
83
+ catch {
84
+ throw new exceptions_1.TurnkeyWalletSessionException(new Error('Session expired. Please login again.'));
85
+ }
86
+ }
87
+ async getAccounts() {
88
+ const indexedDbClient = await this.getIndexedDbClient();
89
+ if (!this.userOrganizationId) {
90
+ return [];
91
+ }
92
+ try {
93
+ const response = await indexedDbClient.getWallets({
94
+ organizationId: this.userOrganizationId,
95
+ });
96
+ const accounts = await Promise.allSettled(response.wallets.map((wallet) => indexedDbClient.getWalletAccounts({
97
+ walletId: wallet.walletId,
98
+ organizationId: this.userOrganizationId,
99
+ })));
100
+ const filteredAccounts = accounts
101
+ .filter((account) => account.status === 'fulfilled')
102
+ .flatMap((result) => result.value?.accounts)
103
+ .filter((wa) => !!wa &&
104
+ wa.addressFormat === 'ADDRESS_FORMAT_ETHEREUM' &&
105
+ !!wa.address);
106
+ return filteredAccounts.map((account) => (0, sdk_ts_1.getInjectiveAddress)(account.address));
107
+ }
108
+ catch (e) {
109
+ if (e.code === types_js_1.TurnkeyErrorCodes.UserLoggedOut) {
110
+ throw new exceptions_1.WalletException(new Error('User is not logged in'), {
111
+ code: exceptions_1.UnspecifiedErrorCode,
112
+ type: exceptions_1.ErrorType.WalletError,
113
+ contextModule: wallet_base_1.WalletAction.GetAccounts,
114
+ contextCode: types_js_1.TurnkeyErrorCodes.UserLoggedOut,
115
+ });
116
+ }
117
+ throw new exceptions_1.WalletException(new Error(e.message), {
118
+ code: exceptions_1.UnspecifiedErrorCode,
119
+ type: exceptions_1.ErrorType.WalletError,
120
+ contextModule: 'turnkey-wallet-get-accounts',
121
+ });
122
+ }
123
+ }
124
+ async getOrCreateAndGetAccount(address) {
125
+ const { accountMap } = this;
126
+ const indexedDbClient = await this.getIndexedDbClient();
127
+ const organizationId = this.userOrganizationId;
128
+ if (accountMap[address] || accountMap[address.toLowerCase()]) {
129
+ return accountMap[address] || accountMap[address.toLowerCase()];
130
+ }
131
+ if (!organizationId) {
132
+ throw new exceptions_1.WalletException(new Error('Organization ID is required'));
133
+ }
134
+ indexedDbClient.config.organizationId = organizationId;
135
+ if (!address) {
136
+ throw new exceptions_1.WalletException(new Error('Account address not found'));
137
+ }
138
+ const turnkeyAccount = await (0, viem_1.createAccount)({
139
+ organizationId,
140
+ signWith: address,
141
+ client: indexedDbClient,
142
+ });
143
+ this.accountMap[address] = turnkeyAccount;
144
+ return turnkeyAccount;
145
+ }
146
+ async initOTP(email) {
147
+ const indexedDbClient = await this.getIndexedDbClient();
148
+ const result = await otp_js_1.TurnkeyOtpWallet.initEmailOTP({
149
+ client: this.client,
150
+ indexedDbClient,
151
+ email,
152
+ otpInitPath: this.metadata.otpInitPath || consts_js_1.TURNKEY_OTP_INIT_PATH,
153
+ });
154
+ if (!result || !result.otpId) {
155
+ throw new exceptions_1.WalletException(new Error('Failed to initialize OTP'));
156
+ }
157
+ if (result?.organizationId) {
158
+ this.userOrganizationId = result.organizationId;
159
+ }
160
+ if (result?.otpId) {
161
+ this.otpId = result.otpId;
162
+ }
163
+ return result;
164
+ }
165
+ async confirmOTP(otpCode) {
166
+ const indexedDbClient = await this.getIndexedDbClient();
167
+ const targetPublicKey = await indexedDbClient.getPublicKey();
168
+ if (!this.otpId) {
169
+ throw new exceptions_1.WalletException(new Error('OTP ID is required'));
170
+ }
171
+ if (!targetPublicKey) {
172
+ throw new exceptions_1.WalletException(new Error('Target public key not found'));
173
+ }
174
+ if (!this.userOrganizationId) {
175
+ throw new exceptions_1.WalletException(new Error('Organization ID is required'));
176
+ }
177
+ const result = await otp_js_1.TurnkeyOtpWallet.confirmEmailOTP({
178
+ otpCode,
179
+ client: this.client,
180
+ emailOTPId: this.otpId,
181
+ organizationId: this.userOrganizationId,
182
+ targetPublicKey,
183
+ otpVerifyPath: this.metadata.otpVerifyPath || consts_js_1.TURNKEY_OTP_VERIFY_PATH,
184
+ });
185
+ if (!result || !result.session) {
186
+ throw new exceptions_1.WalletException(new Error('Failed to confirm OTP'));
187
+ }
188
+ await indexedDbClient.loginWithSession(result.session);
189
+ this.userOrganizationId = result.organizationId;
190
+ return result;
191
+ }
192
+ async initOAuth(provider) {
193
+ if (provider === wallet_base_1.TurnkeyProvider.Apple) {
194
+ throw new exceptions_1.WalletException(new Error('Apple sign in option is currently not supported'));
195
+ }
196
+ const indexedDbClient = await this.getIndexedDbClient();
197
+ const nonce = await oauth_js_1.TurnkeyOauthWallet.generateOAuthNonce(indexedDbClient);
198
+ if (!this.metadata?.googleClientId || !this.metadata?.googleRedirectUri) {
199
+ throw new exceptions_1.WalletException(new Error('googleClientId and googleRedirectUri are required'));
200
+ }
201
+ return (0, utils_js_1.generateGoogleUrl)({
202
+ nonce,
203
+ clientId: this.metadata.googleClientId,
204
+ redirectUri: this.metadata.googleRedirectUri,
205
+ });
206
+ }
207
+ async confirmOAuth(provider, oidcToken) {
208
+ if (provider === wallet_base_1.TurnkeyProvider.Apple) {
209
+ throw new exceptions_1.WalletException(new Error('Apple sign in option is currently not supported'));
210
+ }
211
+ const indexedDbClient = await this.getIndexedDbClient();
212
+ const oauthResult = await oauth_js_1.TurnkeyOauthWallet.oauthLogin({
213
+ oidcToken,
214
+ indexedDbClient,
215
+ client: this.client,
216
+ providerName: provider.toString(),
217
+ oauthLoginPath: this.metadata.oauthLoginPath || consts_js_1.TURNKEY_OAUTH_PATH,
218
+ });
219
+ if (!oauthResult || !oauthResult.credentialBundle) {
220
+ throw new exceptions_1.WalletException(new Error('Unexpected OAuth result'));
221
+ }
222
+ await indexedDbClient.loginWithSession(oauthResult.credentialBundle);
223
+ this.userOrganizationId = oauthResult.organizationId;
224
+ return oauthResult.credentialBundle;
225
+ }
226
+ async refreshSession() {
227
+ const session = await this.getSession();
228
+ const indexedDbClient = await this.getIndexedDbClient();
229
+ if (session.session?.token) {
230
+ await indexedDbClient.refreshSession({
231
+ sessionType: sdk_browser_1.SessionType.READ_WRITE,
232
+ expirationSeconds: this.metadata.expirationSeconds,
233
+ });
234
+ this.userOrganizationId = session.organizationId;
235
+ return session.session.token;
236
+ }
237
+ throw new exceptions_1.TurnkeyWalletSessionException(new Error('Session expired. Please login again.'));
238
+ }
239
+ async initClient() {
240
+ const { metadata } = this;
241
+ const { turnkey, indexedDbClient } = await createTurnkeyClient(metadata);
242
+ this.turnkey = turnkey;
243
+ this.indexedDbClient = indexedDbClient;
244
+ return { turnkey, indexedDbClient };
245
+ }
246
+ }
247
+ exports.TurnkeyWallet = TurnkeyWallet;
248
+ async function createTurnkeyClient(metadata) {
249
+ const turnkey = new sdk_browser_1.Turnkey(metadata);
250
+ const indexedDbClient = await turnkey.indexedDbClient();
251
+ await indexedDbClient.init();
252
+ if (!turnkey) {
253
+ throw new exceptions_1.GeneralException(new Error('Turnkey is not initialized'));
254
+ }
255
+ return {
256
+ turnkey,
257
+ indexedDbClient,
258
+ };
259
+ }
@@ -0,0 +1,28 @@
1
+ export declare const TurnkeyErrorCodes: {
2
+ readonly UserLoggedOut: 7;
3
+ };
4
+ export type TurnkeyErrorCodes = (typeof TurnkeyErrorCodes)[keyof typeof TurnkeyErrorCodes];
5
+ export type TurnkeyOAuthArgs = {
6
+ provider: 'google';
7
+ oidcToken: string;
8
+ oauthLoginEndpoint: string;
9
+ };
10
+ export type TurnkeyEmailArgs = {
11
+ provider: 'email';
12
+ email: string;
13
+ initEmailOTPEndpoint: string;
14
+ };
15
+ export type TurnkeyEnableArgs = TurnkeyOAuthArgs | TurnkeyEmailArgs;
16
+ export type TurnkeyOTPCredentialsResponse = {
17
+ otpId: string;
18
+ organizationId: string;
19
+ };
20
+ export type TurnkeyConfirmEmailOTPResponse = {
21
+ session: string;
22
+ organizationId: string;
23
+ };
24
+ export type TurnkeyOauthLoginResponse = {
25
+ organizationId: string;
26
+ credentialBundle: string;
27
+ message: string;
28
+ };
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TurnkeyErrorCodes = void 0;
4
+ exports.TurnkeyErrorCodes = {
5
+ UserLoggedOut: 7,
6
+ };
@@ -0,0 +1,7 @@
1
+ export declare function generateGoogleUrl({ nonce, clientId, redirectUri, scope, prompt, }: {
2
+ nonce: string;
3
+ clientId: string;
4
+ redirectUri: string;
5
+ scope?: string;
6
+ prompt?: string;
7
+ }): string;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateGoogleUrl = generateGoogleUrl;
4
+ function generateGoogleUrl({ nonce, clientId, redirectUri, scope = 'openid profile email', prompt = 'consent', }) {
5
+ if (!clientId) {
6
+ throw new Error('Google client ID not found');
7
+ }
8
+ const responseType = 'id_token';
9
+ return `https://accounts.google.com/o/oauth2/v2/auth?prompt=${prompt}&client_id=${clientId}&redirect_uri=${redirectUri}&response_type=${responseType}&scope=${scope}&nonce=${nonce}`;
10
+ }
@@ -1,92 +1,3 @@
1
- import { AminoSignResponse, DirectSignResponse, TxRaw } from "@injectivelabs/sdk-ts";
2
- import { HttpRestClient } from "@injectivelabs/utils";
3
- import { BaseConcreteStrategy, ConcreteEvmWalletStrategyArgs, ConcreteWalletStrategy, Eip1193Provider, SendTransactionOptions, StdSignDoc, TurnkeyMetadata, TurnkeyProvider, WalletDeviceType, WalletMetadata, WalletStrategyEvmOptions } from "@injectivelabs/wallet-base";
4
- import { createAccount } from "@turnkey/viem";
5
- import * as _turnkey_sdk_browser0 from "@turnkey/sdk-browser";
6
- import { Turnkey, TurnkeyIndexedDbClient } from "@turnkey/sdk-browser";
7
- import { AccountAddress, EvmChainId } from "@injectivelabs/ts-types";
8
-
9
- //#region src/strategy/strategy.d.ts
10
- declare class TurnkeyWalletStrategy extends BaseConcreteStrategy implements ConcreteWalletStrategy {
11
- turnkeyWallet?: TurnkeyWallet$1;
12
- evmOptions: WalletStrategyEvmOptions;
13
- client: HttpRestClient;
14
- constructor(args: ConcreteEvmWalletStrategyArgs & {
15
- apiServerEndpoint?: string;
16
- });
17
- getWalletDeviceType(): Promise<WalletDeviceType>;
18
- setMetadata(metadata?: {
19
- turnkey?: Partial<WalletMetadata['turnkey']>;
20
- }): void;
21
- enable(): Promise<boolean>;
22
- disconnect(): Promise<void>;
23
- getAddresses(): Promise<string[]>;
24
- getSessionOrConfirm(_address?: string): Promise<string>;
25
- getWalletClient<TurnkeyWallet$1>(): Promise<TurnkeyWallet$1>;
26
- sendEvmTransaction(transaction: unknown, args: {
27
- address: AccountAddress;
28
- evmChainId: EvmChainId;
29
- }): Promise<string>;
30
- sendTransaction(transaction: TxRaw, options: SendTransactionOptions): Promise<any>;
31
- signEip712TypedData(eip712json: string, address: AccountAddress): Promise<string>;
32
- signCosmosTransaction(_transaction: {
33
- txRaw: TxRaw;
34
- accountNumber: number;
35
- chainId: string;
36
- address: string;
37
- }): Promise<DirectSignResponse>;
38
- signAminoCosmosTransaction(_transaction: {
39
- address: string;
40
- signDoc: StdSignDoc;
41
- }): Promise<AminoSignResponse>;
42
- signArbitrary(_signer: AccountAddress, _data: string | Uint8Array): Promise<string>;
43
- getEthereumChainId(): Promise<string>;
44
- getEvmTransactionReceipt(txHash: string, evmChainId?: EvmChainId): Promise<Record<string, any>>;
45
- getPubKey(): Promise<string>;
46
- getIndexedDbClient(): Promise<TurnkeyIndexedDbClient>;
47
- private getTurnkeyWallet;
48
- getEip1193Provider(): Promise<Eip1193Provider>;
49
- }
50
- //#endregion
51
- //#region src/strategy/types.d.ts
52
- type TurnkeyOTPCredentialsResponse = {
53
- otpId: string;
54
- organizationId: string;
55
- };
56
- type TurnkeyConfirmEmailOTPResponse = {
57
- session: string;
58
- organizationId: string;
59
- };
60
- //#endregion
61
- //#region src/strategy/turnkey/turnkey.d.ts
62
- declare class TurnkeyWallet {
63
- private otpId?;
64
- protected turnkey?: Turnkey;
65
- userOrganizationId?: string;
66
- protected client: HttpRestClient;
67
- private metadata;
68
- protected indexedDbClient?: TurnkeyIndexedDbClient;
69
- private accountMap;
70
- setMetadata(metadata: Partial<TurnkeyMetadata>): void;
71
- constructor(metadata: TurnkeyMetadata);
72
- static getTurnkeyInstance(metadata: TurnkeyMetadata): Promise<{
73
- turnkey: Turnkey;
74
- indexedDbClient: TurnkeyIndexedDbClient;
75
- }>;
76
- getTurnkey(): Promise<Turnkey>;
77
- getIndexedDbClient(): Promise<TurnkeyIndexedDbClient>;
78
- getSession(existingCredentialBundle?: string): Promise<{
79
- session: _turnkey_sdk_browser0.Session | undefined;
80
- organizationId: string;
81
- }>;
82
- getAccounts(): Promise<string[]>;
83
- getOrCreateAndGetAccount(address: string): Promise<ReturnType<typeof createAccount>>;
84
- initOTP(email: string): Promise<TurnkeyOTPCredentialsResponse>;
85
- confirmOTP(otpCode: string): Promise<TurnkeyConfirmEmailOTPResponse>;
86
- initOAuth(provider: TurnkeyProvider): Promise<string>;
87
- confirmOAuth(provider: TurnkeyProvider, oidcToken: string): Promise<string>;
88
- refreshSession(): Promise<string>;
89
- private initClient;
90
- }
91
- //#endregion
92
- export { TurnkeyWallet, TurnkeyWalletStrategy };
1
+ export { TurnkeyWalletStrategy } from './strategy/strategy.js';
2
+ export * from './strategy/strategy.js';
3
+ export * from './strategy/turnkey/turnkey.js';