@injectivelabs/wallet-turnkey 1.16.12 → 1.16.13-alpha.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/cjs/strategy/Eip1193Provider.d.ts +2 -2
- package/dist/cjs/strategy/Eip1193Provider.js +1 -1
- package/dist/cjs/strategy/strategy.d.ts +6 -4
- package/dist/cjs/strategy/strategy.js +6 -8
- package/dist/cjs/strategy/turnkey/oauth.d.ts +1 -1
- package/dist/cjs/strategy/turnkey/oauth.js +1 -1
- package/dist/cjs/strategy/turnkey/otp.d.ts +2 -2
- package/dist/cjs/strategy/turnkey/turnkey.d.ts +6 -4
- package/dist/cjs/strategy/turnkey/turnkey.js +9 -7
- package/dist/cjs/strategy/types.d.ts +4 -3
- package/dist/cjs/strategy/types.js +3 -4
- package/dist/esm/strategy/Eip1193Provider.d.ts +2 -2
- package/dist/esm/strategy/Eip1193Provider.js +1 -1
- package/dist/esm/strategy/strategy.d.ts +6 -4
- package/dist/esm/strategy/strategy.js +7 -9
- package/dist/esm/strategy/turnkey/oauth.d.ts +1 -1
- package/dist/esm/strategy/turnkey/oauth.js +2 -2
- package/dist/esm/strategy/turnkey/otp.d.ts +2 -2
- package/dist/esm/strategy/turnkey/turnkey.d.ts +6 -4
- package/dist/esm/strategy/turnkey/turnkey.js +10 -8
- package/dist/esm/strategy/types.d.ts +4 -3
- package/dist/esm/strategy/types.js +3 -4
- package/package.json +7 -7
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { LocalAccount } from 'viem';
|
|
2
|
+
import type { Eip1193Provider } from '@injectivelabs/wallet-base';
|
|
3
3
|
export declare const getEip1193ProviderForTurnkey: (account: LocalAccount, chainId: string) => Promise<Eip1193Provider>;
|
|
@@ -34,8 +34,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.getEip1193ProviderForTurnkey = void 0;
|
|
37
|
-
const viem_1 = require("viem");
|
|
38
37
|
const viemChains = __importStar(require("viem/chains"));
|
|
38
|
+
const viem_1 = require("viem");
|
|
39
39
|
const getEip1193ProviderForTurnkey = async (account, chainId) => {
|
|
40
40
|
const provider = new CustomEip1193Provider({
|
|
41
41
|
chainId: parseInt(chainId, 16),
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { TxRaw, AminoSignResponse, DirectSignResponse } from '@injectivelabs/sdk-ts';
|
|
2
|
-
import { StdSignDoc, WalletDeviceType, type WalletMetadata, BaseConcreteStrategy, ConcreteWalletStrategy, SendTransactionOptions, WalletStrategyEvmOptions, ConcreteEvmWalletStrategyArgs, Eip1193Provider } from '@injectivelabs/wallet-base';
|
|
3
1
|
import { HttpRestClient } from '@injectivelabs/utils';
|
|
4
|
-
import {
|
|
5
|
-
import { AccountAddress, EvmChainId } from '@injectivelabs/ts-types';
|
|
2
|
+
import { WalletDeviceType, type WalletMetadata, BaseConcreteStrategy } from '@injectivelabs/wallet-base';
|
|
6
3
|
import { TurnkeyWallet } from './turnkey/turnkey.js';
|
|
4
|
+
import type { EvmChainId } from '@injectivelabs/ts-types';
|
|
5
|
+
import type { AccountAddress } from '@injectivelabs/ts-types';
|
|
6
|
+
import type { TurnkeyIndexedDbClient } from '@turnkey/sdk-browser';
|
|
7
|
+
import type { TxRaw, AminoSignResponse, DirectSignResponse } from '@injectivelabs/sdk-ts';
|
|
8
|
+
import type { StdSignDoc, Eip1193Provider, ConcreteWalletStrategy, SendTransactionOptions, WalletStrategyEvmOptions, ConcreteEvmWalletStrategyArgs } from '@injectivelabs/wallet-base';
|
|
7
9
|
export declare class TurnkeyWalletStrategy extends BaseConcreteStrategy implements ConcreteWalletStrategy {
|
|
8
10
|
turnkeyWallet?: TurnkeyWallet;
|
|
9
11
|
evmOptions: WalletStrategyEvmOptions;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TurnkeyWalletStrategy = void 0;
|
|
4
|
-
/* eslint-disable class-methods-use-this */
|
|
5
4
|
const sdk_ts_1 = require("@injectivelabs/sdk-ts");
|
|
6
|
-
const
|
|
5
|
+
const sdk_ts_2 = require("@injectivelabs/sdk-ts");
|
|
6
|
+
const utils_1 = require("@injectivelabs/utils");
|
|
7
7
|
const viem_1 = require("viem");
|
|
8
8
|
const wallet_base_1 = require("@injectivelabs/wallet-base");
|
|
9
|
-
const
|
|
9
|
+
const exceptions_1 = require("@injectivelabs/exceptions");
|
|
10
10
|
const types_js_1 = require("./types.js");
|
|
11
11
|
const turnkey_js_1 = require("./turnkey/turnkey.js");
|
|
12
12
|
const consts_js_1 = require("./consts.js");
|
|
@@ -52,7 +52,7 @@ class TurnkeyWalletStrategy extends wallet_base_1.BaseConcreteStrategy {
|
|
|
52
52
|
}
|
|
53
53
|
return !!(await turnkeyWallet.getIndexedDbClient());
|
|
54
54
|
}
|
|
55
|
-
catch
|
|
55
|
+
catch {
|
|
56
56
|
return false;
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -159,7 +159,7 @@ class TurnkeyWalletStrategy extends wallet_base_1.BaseConcreteStrategy {
|
|
|
159
159
|
try {
|
|
160
160
|
parsedData = JSON.parse(eip712json);
|
|
161
161
|
}
|
|
162
|
-
catch
|
|
162
|
+
catch {
|
|
163
163
|
throw new exceptions_1.WalletException(new Error('Failed to parse EIP-712 data: Invalid JSON format'), {
|
|
164
164
|
code: exceptions_1.UnspecifiedErrorCode,
|
|
165
165
|
type: exceptions_1.ErrorType.WalletError,
|
|
@@ -169,7 +169,6 @@ class TurnkeyWalletStrategy extends wallet_base_1.BaseConcreteStrategy {
|
|
|
169
169
|
const signature = await account.signTypedData(parsedData);
|
|
170
170
|
return signature;
|
|
171
171
|
}
|
|
172
|
-
// eslint-disable-next-line class-methods-use-this
|
|
173
172
|
async signCosmosTransaction(_transaction) {
|
|
174
173
|
throw new exceptions_1.WalletException(new Error('This wallet does not support signing Cosmos transactions'), {
|
|
175
174
|
code: exceptions_1.UnspecifiedErrorCode,
|
|
@@ -237,7 +236,6 @@ class TurnkeyWalletStrategy extends wallet_base_1.BaseConcreteStrategy {
|
|
|
237
236
|
}
|
|
238
237
|
throw new Error(`Failed to retrieve transaction receipt for txHash: ${txHash}`);
|
|
239
238
|
}
|
|
240
|
-
// eslint-disable-next-line class-methods-use-this
|
|
241
239
|
async getPubKey() {
|
|
242
240
|
throw new exceptions_1.WalletException(new Error('You can only fetch PubKey from Cosmos native wallets'));
|
|
243
241
|
}
|
|
@@ -266,7 +264,7 @@ class TurnkeyWalletStrategy extends wallet_base_1.BaseConcreteStrategy {
|
|
|
266
264
|
const turnkeyWallet = await this.getTurnkeyWallet();
|
|
267
265
|
const addresses = await turnkeyWallet.getAccounts();
|
|
268
266
|
//? Turnkey expects the case sensitive address and the current impl of getChecksumAddress from sdk-ts doesn't play nice with browser envs
|
|
269
|
-
const checksumAddress = (0, viem_1.getAddress)((0,
|
|
267
|
+
const checksumAddress = (0, viem_1.getAddress)((0, sdk_ts_2.getEthereumAddress)(addresses[0]));
|
|
270
268
|
const account = await turnkeyWallet.getOrCreateAndGetAccount(checksumAddress);
|
|
271
269
|
const eip1193Provider = await (0, Eip1193Provider_js_1.getEip1193ProviderForTurnkey)(account, String(this.evmOptions.evmChainId));
|
|
272
270
|
return eip1193Provider;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { HttpRestClient } from '@injectivelabs/utils';
|
|
1
2
|
import type { TurnkeyIndexedDbClient } from '@turnkey/sdk-browser';
|
|
2
|
-
import { type HttpRestClient } from '@injectivelabs/utils';
|
|
3
3
|
export declare class TurnkeyOauthWallet {
|
|
4
4
|
static generateOAuthNonce(indexedDbClient: TurnkeyIndexedDbClient): Promise<string>;
|
|
5
5
|
static oauthLogin(args: {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TurnkeyOauthWallet = void 0;
|
|
4
|
-
const exceptions_1 = require("@injectivelabs/exceptions");
|
|
5
4
|
const sdk_ts_1 = require("@injectivelabs/sdk-ts");
|
|
5
|
+
const exceptions_1 = require("@injectivelabs/exceptions");
|
|
6
6
|
const consts_js_1 = require("../consts.js");
|
|
7
7
|
class TurnkeyOauthWallet {
|
|
8
8
|
static async generateOAuthNonce(indexedDbClient) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { TurnkeyIndexedDbClient } from '@turnkey/sdk-browser';
|
|
2
1
|
import { type TurnkeyConfirmEmailOTPResponse, type TurnkeyOTPCredentialsResponse } from './../types.js';
|
|
3
|
-
import {
|
|
2
|
+
import type { HttpRestClient } from '@injectivelabs/utils';
|
|
3
|
+
import type { TurnkeyIndexedDbClient } from '@turnkey/sdk-browser';
|
|
4
4
|
export declare class TurnkeyOtpWallet {
|
|
5
5
|
static initEmailOTP(args: {
|
|
6
6
|
email: string;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { TurnkeyMetadata, TurnkeyProvider } from '@injectivelabs/wallet-base';
|
|
2
1
|
import { createAccount } from '@turnkey/viem';
|
|
3
2
|
import { HttpRestClient } from '@injectivelabs/utils';
|
|
4
|
-
import { Turnkey
|
|
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';
|
|
5
7
|
export declare class TurnkeyWallet {
|
|
6
8
|
private otpId?;
|
|
7
9
|
protected turnkey?: Turnkey;
|
|
@@ -26,8 +28,8 @@ export declare class TurnkeyWallet {
|
|
|
26
28
|
getOrCreateAndGetAccount(address: string): Promise<ReturnType<typeof createAccount>>;
|
|
27
29
|
initOTP(email: string): Promise<import("../types.js").TurnkeyOTPCredentialsResponse>;
|
|
28
30
|
confirmOTP(otpCode: string): Promise<import("../types.js").TurnkeyConfirmEmailOTPResponse>;
|
|
29
|
-
initOAuth(provider: TurnkeyProvider
|
|
30
|
-
confirmOAuth(provider: TurnkeyProvider
|
|
31
|
+
initOAuth(provider: TurnkeyProvider): Promise<string>;
|
|
32
|
+
confirmOAuth(provider: TurnkeyProvider, oidcToken: string): Promise<string>;
|
|
31
33
|
refreshSession(): Promise<string>;
|
|
32
34
|
private initClient;
|
|
33
35
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TurnkeyWallet = void 0;
|
|
4
|
-
const exceptions_1 = require("@injectivelabs/exceptions");
|
|
5
|
-
const wallet_base_1 = require("@injectivelabs/wallet-base");
|
|
6
4
|
const viem_1 = require("@turnkey/viem");
|
|
7
5
|
const utils_1 = require("@injectivelabs/utils");
|
|
8
6
|
const sdk_ts_1 = require("@injectivelabs/sdk-ts");
|
|
9
7
|
const sdk_browser_1 = require("@turnkey/sdk-browser");
|
|
10
|
-
const
|
|
8
|
+
const wallet_base_1 = require("@injectivelabs/wallet-base");
|
|
9
|
+
const exceptions_1 = require("@injectivelabs/exceptions");
|
|
11
10
|
const otp_js_1 = require("./otp.js");
|
|
12
11
|
const types_js_1 = require("../types.js");
|
|
13
12
|
const oauth_js_1 = require("./oauth.js");
|
|
14
13
|
const utils_js_1 = require("../../utils.js");
|
|
14
|
+
const consts_js_1 = require("../consts.js");
|
|
15
15
|
class TurnkeyWallet {
|
|
16
16
|
otpId;
|
|
17
17
|
turnkey;
|
|
@@ -190,12 +190,11 @@ class TurnkeyWallet {
|
|
|
190
190
|
return result;
|
|
191
191
|
}
|
|
192
192
|
async initOAuth(provider) {
|
|
193
|
-
const indexedDbClient = await this.getIndexedDbClient();
|
|
194
|
-
const nonce = await oauth_js_1.TurnkeyOauthWallet.generateOAuthNonce(indexedDbClient);
|
|
195
193
|
if (provider === wallet_base_1.TurnkeyProvider.Apple) {
|
|
196
|
-
|
|
197
|
-
return nonce;
|
|
194
|
+
throw new exceptions_1.WalletException(new Error('Apple sign in option is currently not supported'));
|
|
198
195
|
}
|
|
196
|
+
const indexedDbClient = await this.getIndexedDbClient();
|
|
197
|
+
const nonce = await oauth_js_1.TurnkeyOauthWallet.generateOAuthNonce(indexedDbClient);
|
|
199
198
|
if (!this.metadata?.googleClientId || !this.metadata?.googleRedirectUri) {
|
|
200
199
|
throw new exceptions_1.WalletException(new Error('googleClientId and googleRedirectUri are required'));
|
|
201
200
|
}
|
|
@@ -206,6 +205,9 @@ class TurnkeyWallet {
|
|
|
206
205
|
});
|
|
207
206
|
}
|
|
208
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
|
+
}
|
|
209
211
|
const indexedDbClient = await this.getIndexedDbClient();
|
|
210
212
|
const oauthResult = await oauth_js_1.TurnkeyOauthWallet.oauthLogin({
|
|
211
213
|
oidcToken,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
UserLoggedOut
|
|
3
|
-
}
|
|
1
|
+
export declare const TurnkeyErrorCodes: {
|
|
2
|
+
readonly UserLoggedOut: 7;
|
|
3
|
+
};
|
|
4
|
+
export type TurnkeyErrorCodes = typeof TurnkeyErrorCodes[keyof typeof TurnkeyErrorCodes];
|
|
4
5
|
export type TurnkeyOAuthArgs = {
|
|
5
6
|
provider: 'google';
|
|
6
7
|
oidcToken: string;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TurnkeyErrorCodes = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
})(TurnkeyErrorCodes || (exports.TurnkeyErrorCodes = TurnkeyErrorCodes = {}));
|
|
4
|
+
exports.TurnkeyErrorCodes = {
|
|
5
|
+
UserLoggedOut: 7,
|
|
6
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { LocalAccount } from 'viem';
|
|
2
|
+
import type { Eip1193Provider } from '@injectivelabs/wallet-base';
|
|
3
3
|
export declare const getEip1193ProviderForTurnkey: (account: LocalAccount, chainId: string) => Promise<Eip1193Provider>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { extractChain, createWalletClient, http, createPublicClient, } from 'viem';
|
|
2
1
|
import * as viemChains from 'viem/chains';
|
|
2
|
+
import { extractChain, createWalletClient, http, createPublicClient, } from 'viem';
|
|
3
3
|
export const getEip1193ProviderForTurnkey = async (account, chainId) => {
|
|
4
4
|
const provider = new CustomEip1193Provider({
|
|
5
5
|
chainId: parseInt(chainId, 16),
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { TxRaw, AminoSignResponse, DirectSignResponse } from '@injectivelabs/sdk-ts';
|
|
2
|
-
import { StdSignDoc, WalletDeviceType, type WalletMetadata, BaseConcreteStrategy, ConcreteWalletStrategy, SendTransactionOptions, WalletStrategyEvmOptions, ConcreteEvmWalletStrategyArgs, Eip1193Provider } from '@injectivelabs/wallet-base';
|
|
3
1
|
import { HttpRestClient } from '@injectivelabs/utils';
|
|
4
|
-
import {
|
|
5
|
-
import { AccountAddress, EvmChainId } from '@injectivelabs/ts-types';
|
|
2
|
+
import { WalletDeviceType, type WalletMetadata, BaseConcreteStrategy } from '@injectivelabs/wallet-base';
|
|
6
3
|
import { TurnkeyWallet } from './turnkey/turnkey.js';
|
|
4
|
+
import type { EvmChainId } from '@injectivelabs/ts-types';
|
|
5
|
+
import type { AccountAddress } from '@injectivelabs/ts-types';
|
|
6
|
+
import type { TurnkeyIndexedDbClient } from '@turnkey/sdk-browser';
|
|
7
|
+
import type { TxRaw, AminoSignResponse, DirectSignResponse } from '@injectivelabs/sdk-ts';
|
|
8
|
+
import type { StdSignDoc, Eip1193Provider, ConcreteWalletStrategy, SendTransactionOptions, WalletStrategyEvmOptions, ConcreteEvmWalletStrategyArgs } from '@injectivelabs/wallet-base';
|
|
7
9
|
export declare class TurnkeyWalletStrategy extends BaseConcreteStrategy implements ConcreteWalletStrategy {
|
|
8
10
|
turnkeyWallet?: TurnkeyWallet;
|
|
9
11
|
evmOptions: WalletStrategyEvmOptions;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { ErrorType, WalletException, UnspecifiedErrorCode, TransactionException, CosmosWalletException, } from '@injectivelabs/exceptions';
|
|
4
|
-
import { http, getAddress, createPublicClient, createWalletClient, } from 'viem';
|
|
5
|
-
import { WalletAction, WalletDeviceType, BaseConcreteStrategy, } from '@injectivelabs/wallet-base';
|
|
1
|
+
import { TxGrpcApi } from '@injectivelabs/sdk-ts';
|
|
2
|
+
import { getEthereumAddress } from '@injectivelabs/sdk-ts';
|
|
6
3
|
import { sleep, HttpRestClient } from '@injectivelabs/utils';
|
|
4
|
+
import { http, getAddress, createPublicClient, createWalletClient } from 'viem';
|
|
5
|
+
import { WalletAction, WalletDeviceType, BaseConcreteStrategy } from '@injectivelabs/wallet-base';
|
|
6
|
+
import { ErrorType, WalletException, UnspecifiedErrorCode, TransactionException, CosmosWalletException, } from '@injectivelabs/exceptions';
|
|
7
7
|
import { TurnkeyErrorCodes } from './types.js';
|
|
8
8
|
import { TurnkeyWallet } from './turnkey/turnkey.js';
|
|
9
9
|
import { DEFAULT_EVM_CHAIN_CONFIG } from './consts.js';
|
|
@@ -49,7 +49,7 @@ export class TurnkeyWalletStrategy extends BaseConcreteStrategy {
|
|
|
49
49
|
}
|
|
50
50
|
return !!(await turnkeyWallet.getIndexedDbClient());
|
|
51
51
|
}
|
|
52
|
-
catch
|
|
52
|
+
catch {
|
|
53
53
|
return false;
|
|
54
54
|
}
|
|
55
55
|
}
|
|
@@ -156,7 +156,7 @@ export class TurnkeyWalletStrategy extends BaseConcreteStrategy {
|
|
|
156
156
|
try {
|
|
157
157
|
parsedData = JSON.parse(eip712json);
|
|
158
158
|
}
|
|
159
|
-
catch
|
|
159
|
+
catch {
|
|
160
160
|
throw new WalletException(new Error('Failed to parse EIP-712 data: Invalid JSON format'), {
|
|
161
161
|
code: UnspecifiedErrorCode,
|
|
162
162
|
type: ErrorType.WalletError,
|
|
@@ -166,7 +166,6 @@ export class TurnkeyWalletStrategy extends BaseConcreteStrategy {
|
|
|
166
166
|
const signature = await account.signTypedData(parsedData);
|
|
167
167
|
return signature;
|
|
168
168
|
}
|
|
169
|
-
// eslint-disable-next-line class-methods-use-this
|
|
170
169
|
async signCosmosTransaction(_transaction) {
|
|
171
170
|
throw new WalletException(new Error('This wallet does not support signing Cosmos transactions'), {
|
|
172
171
|
code: UnspecifiedErrorCode,
|
|
@@ -234,7 +233,6 @@ export class TurnkeyWalletStrategy extends BaseConcreteStrategy {
|
|
|
234
233
|
}
|
|
235
234
|
throw new Error(`Failed to retrieve transaction receipt for txHash: ${txHash}`);
|
|
236
235
|
}
|
|
237
|
-
// eslint-disable-next-line class-methods-use-this
|
|
238
236
|
async getPubKey() {
|
|
239
237
|
throw new WalletException(new Error('You can only fetch PubKey from Cosmos native wallets'));
|
|
240
238
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { HttpRestClient } from '@injectivelabs/utils';
|
|
1
2
|
import type { TurnkeyIndexedDbClient } from '@turnkey/sdk-browser';
|
|
2
|
-
import { type HttpRestClient } from '@injectivelabs/utils';
|
|
3
3
|
export declare class TurnkeyOauthWallet {
|
|
4
4
|
static generateOAuthNonce(indexedDbClient: TurnkeyIndexedDbClient): Promise<string>;
|
|
5
5
|
static oauthLogin(args: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ErrorType, WalletException, UnspecifiedErrorCode, } from '@injectivelabs/exceptions';
|
|
2
1
|
import { sha256 } from '@injectivelabs/sdk-ts';
|
|
3
|
-
import {
|
|
2
|
+
import { ErrorType, WalletException, UnspecifiedErrorCode, } from '@injectivelabs/exceptions';
|
|
3
|
+
import { TURNKEY_OAUTH_PATH, DEFAULT_TURNKEY_REFRESH_SECONDS, } from '../consts.js';
|
|
4
4
|
export class TurnkeyOauthWallet {
|
|
5
5
|
static async generateOAuthNonce(indexedDbClient) {
|
|
6
6
|
try {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { TurnkeyIndexedDbClient } from '@turnkey/sdk-browser';
|
|
2
1
|
import { type TurnkeyConfirmEmailOTPResponse, type TurnkeyOTPCredentialsResponse } from './../types.js';
|
|
3
|
-
import {
|
|
2
|
+
import type { HttpRestClient } from '@injectivelabs/utils';
|
|
3
|
+
import type { TurnkeyIndexedDbClient } from '@turnkey/sdk-browser';
|
|
4
4
|
export declare class TurnkeyOtpWallet {
|
|
5
5
|
static initEmailOTP(args: {
|
|
6
6
|
email: string;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { TurnkeyMetadata, TurnkeyProvider } from '@injectivelabs/wallet-base';
|
|
2
1
|
import { createAccount } from '@turnkey/viem';
|
|
3
2
|
import { HttpRestClient } from '@injectivelabs/utils';
|
|
4
|
-
import { Turnkey
|
|
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';
|
|
5
7
|
export declare class TurnkeyWallet {
|
|
6
8
|
private otpId?;
|
|
7
9
|
protected turnkey?: Turnkey;
|
|
@@ -26,8 +28,8 @@ export declare class TurnkeyWallet {
|
|
|
26
28
|
getOrCreateAndGetAccount(address: string): Promise<ReturnType<typeof createAccount>>;
|
|
27
29
|
initOTP(email: string): Promise<import("../types.js").TurnkeyOTPCredentialsResponse>;
|
|
28
30
|
confirmOTP(otpCode: string): Promise<import("../types.js").TurnkeyConfirmEmailOTPResponse>;
|
|
29
|
-
initOAuth(provider: TurnkeyProvider
|
|
30
|
-
confirmOAuth(provider: TurnkeyProvider
|
|
31
|
+
initOAuth(provider: TurnkeyProvider): Promise<string>;
|
|
32
|
+
confirmOAuth(provider: TurnkeyProvider, oidcToken: string): Promise<string>;
|
|
31
33
|
refreshSession(): Promise<string>;
|
|
32
34
|
private initClient;
|
|
33
35
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { ErrorType, WalletException, GeneralException, UnspecifiedErrorCode, TurnkeyWalletSessionException, } from '@injectivelabs/exceptions';
|
|
2
|
-
import { WalletAction, TurnkeyProvider, } from '@injectivelabs/wallet-base';
|
|
3
1
|
import { createAccount } from '@turnkey/viem';
|
|
4
2
|
import { HttpRestClient } from '@injectivelabs/utils';
|
|
5
3
|
import { getInjectiveAddress } from '@injectivelabs/sdk-ts';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { Turnkey, SessionType, } from '@turnkey/sdk-browser';
|
|
5
|
+
import { WalletAction, TurnkeyProvider, } from '@injectivelabs/wallet-base';
|
|
6
|
+
import { ErrorType, WalletException, GeneralException, UnspecifiedErrorCode, TurnkeyWalletSessionException, } from '@injectivelabs/exceptions';
|
|
8
7
|
import { TurnkeyOtpWallet } from './otp.js';
|
|
9
8
|
import { TurnkeyErrorCodes } from '../types.js';
|
|
10
9
|
import { TurnkeyOauthWallet } from './oauth.js';
|
|
11
10
|
import { generateGoogleUrl } from '../../utils.js';
|
|
11
|
+
import { TURNKEY_OAUTH_PATH, TURNKEY_OTP_INIT_PATH, TURNKEY_OTP_VERIFY_PATH, } from '../consts.js';
|
|
12
12
|
export class TurnkeyWallet {
|
|
13
13
|
otpId;
|
|
14
14
|
turnkey;
|
|
@@ -187,12 +187,11 @@ export class TurnkeyWallet {
|
|
|
187
187
|
return result;
|
|
188
188
|
}
|
|
189
189
|
async initOAuth(provider) {
|
|
190
|
-
const indexedDbClient = await this.getIndexedDbClient();
|
|
191
|
-
const nonce = await TurnkeyOauthWallet.generateOAuthNonce(indexedDbClient);
|
|
192
190
|
if (provider === TurnkeyProvider.Apple) {
|
|
193
|
-
|
|
194
|
-
return nonce;
|
|
191
|
+
throw new WalletException(new Error('Apple sign in option is currently not supported'));
|
|
195
192
|
}
|
|
193
|
+
const indexedDbClient = await this.getIndexedDbClient();
|
|
194
|
+
const nonce = await TurnkeyOauthWallet.generateOAuthNonce(indexedDbClient);
|
|
196
195
|
if (!this.metadata?.googleClientId || !this.metadata?.googleRedirectUri) {
|
|
197
196
|
throw new WalletException(new Error('googleClientId and googleRedirectUri are required'));
|
|
198
197
|
}
|
|
@@ -203,6 +202,9 @@ export class TurnkeyWallet {
|
|
|
203
202
|
});
|
|
204
203
|
}
|
|
205
204
|
async confirmOAuth(provider, oidcToken) {
|
|
205
|
+
if (provider === TurnkeyProvider.Apple) {
|
|
206
|
+
throw new WalletException(new Error('Apple sign in option is currently not supported'));
|
|
207
|
+
}
|
|
206
208
|
const indexedDbClient = await this.getIndexedDbClient();
|
|
207
209
|
const oauthResult = await TurnkeyOauthWallet.oauthLogin({
|
|
208
210
|
oidcToken,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
UserLoggedOut
|
|
3
|
-
}
|
|
1
|
+
export declare const TurnkeyErrorCodes: {
|
|
2
|
+
readonly UserLoggedOut: 7;
|
|
3
|
+
};
|
|
4
|
+
export type TurnkeyErrorCodes = typeof TurnkeyErrorCodes[keyof typeof TurnkeyErrorCodes];
|
|
4
5
|
export type TurnkeyOAuthArgs = {
|
|
5
6
|
provider: 'google';
|
|
6
7
|
oidcToken: string;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
})(TurnkeyErrorCodes || (TurnkeyErrorCodes = {}));
|
|
1
|
+
export const TurnkeyErrorCodes = {
|
|
2
|
+
UserLoggedOut: 7,
|
|
3
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@injectivelabs/wallet-turnkey",
|
|
3
3
|
"description": "Turnkey wallet strategy for use with @injectivelabs/wallet-core.",
|
|
4
|
-
"version": "1.16.
|
|
4
|
+
"version": "1.16.13-alpha.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -59,11 +59,11 @@
|
|
|
59
59
|
"start": "node dist/index.js"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@injectivelabs/exceptions": "1.16.
|
|
63
|
-
"@injectivelabs/sdk-ts": "1.16.
|
|
64
|
-
"@injectivelabs/ts-types": "1.16.
|
|
65
|
-
"@injectivelabs/utils": "1.16.
|
|
66
|
-
"@injectivelabs/wallet-base": "1.16.
|
|
62
|
+
"@injectivelabs/exceptions": "1.16.13-alpha.0",
|
|
63
|
+
"@injectivelabs/sdk-ts": "1.16.13-alpha.0",
|
|
64
|
+
"@injectivelabs/ts-types": "1.16.13-alpha.0",
|
|
65
|
+
"@injectivelabs/utils": "1.16.13-alpha.0",
|
|
66
|
+
"@injectivelabs/wallet-base": "1.16.13-alpha.0",
|
|
67
67
|
"@turnkey/sdk-browser": "5.2.3",
|
|
68
68
|
"@turnkey/viem": "^0.9.10",
|
|
69
69
|
"viem": "^2.33.2"
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"tsconfig-paths": "^4.2.0",
|
|
78
78
|
"typescript": "^5.0.0"
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "bb71ac9147c0a2f0946ea0c316caf094fbbe2f2c"
|
|
81
81
|
}
|