@injectivelabs/wallet-base 1.15.6 → 1.15.7

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.
@@ -1,8 +1,9 @@
1
1
  import { ChainId, CosmosChainId, EthereumChainId } from '@injectivelabs/ts-types';
2
- import { WalletEventListener, ConcreteWalletStrategyArgs, ConcreteCosmosWalletStrategyArgs, ConcreteEthereumWalletStrategyArgs } from './types/index.js';
2
+ import { WalletMetadata, WalletEventListener, ConcreteWalletStrategyArgs, ConcreteCosmosWalletStrategyArgs, ConcreteEthereumWalletStrategyArgs } from './types/index.js';
3
3
  export default abstract class BaseConcreteStrategy {
4
4
  protected chainId: ChainId | CosmosChainId;
5
5
  protected ethereumChainId?: EthereumChainId;
6
6
  protected listeners: Partial<Record<WalletEventListener, any>>;
7
- protected constructor(args: ConcreteWalletStrategyArgs | ConcreteEthereumWalletStrategyArgs | ConcreteCosmosWalletStrategyArgs);
7
+ metadata?: WalletMetadata;
8
+ constructor(args: ConcreteWalletStrategyArgs | ConcreteEthereumWalletStrategyArgs | ConcreteCosmosWalletStrategyArgs);
8
9
  }
package/dist/cjs/base.js CHANGED
@@ -4,11 +4,14 @@ class BaseConcreteStrategy {
4
4
  chainId;
5
5
  ethereumChainId;
6
6
  listeners = {};
7
+ metadata;
7
8
  constructor(args) {
8
- this.ethereumChainId = 'ethereumOptions' in args && args.ethereumOptions
9
- ? args.ethereumOptions.ethereumChainId
10
- : undefined;
9
+ this.ethereumChainId =
10
+ 'ethereumOptions' in args && args.ethereumOptions
11
+ ? args.ethereumOptions.ethereumChainId
12
+ : undefined;
11
13
  this.chainId = args.chainId;
14
+ this.metadata = args.metadata;
12
15
  }
13
16
  }
14
17
  exports.default = BaseConcreteStrategy;
@@ -10,6 +10,8 @@ export declare enum Wallet {
10
10
  Phantom = "phantom",
11
11
  Metamask = "metamask",
12
12
  OkxWallet = "okx-wallet",
13
+ TurnkeyOtp = "turnkey-otp",
14
+ TurnkeyOauth = "turnkey-oauth",
13
15
  TrustWallet = "trust-wallet",
14
16
  PrivateKey = "private-key",
15
17
  TrezorBip32 = "trezor-bip32",
@@ -14,6 +14,8 @@ var Wallet;
14
14
  Wallet["Phantom"] = "phantom";
15
15
  Wallet["Metamask"] = "metamask";
16
16
  Wallet["OkxWallet"] = "okx-wallet";
17
+ Wallet["TurnkeyOtp"] = "turnkey-otp";
18
+ Wallet["TurnkeyOauth"] = "turnkey-oauth";
17
19
  Wallet["TrustWallet"] = "trust-wallet";
18
20
  Wallet["PrivateKey"] = "private-key";
19
21
  Wallet["TrezorBip32"] = "trezor-bip32";
@@ -1,4 +1,4 @@
1
- import { ChainId, CosmosChainId, AccountAddress, EthereumChainId } from '@injectivelabs/ts-types';
1
+ import { ChainId, AccountAddress, EthereumChainId } from '@injectivelabs/ts-types';
2
2
  import type { TxRaw, TxResponse, AminoSignResponse, DirectSignResponse } from '@injectivelabs/sdk-ts';
3
3
  import { StdSignDoc } from '@keplr-wallet/types';
4
4
  import { WalletDeviceType, Wallet } from './enums.js';
@@ -16,7 +16,12 @@ export type MagicMetadata = {
16
16
  apiKey?: string;
17
17
  rpcEndpoint?: string;
18
18
  };
19
- export type WalletConnectMetadata = Record<string, string | Record<string, string> | Record<string, string[]>>;
19
+ export type PrivateKeyMetadata = {
20
+ privateKey: string;
21
+ };
22
+ export type WalletConnectMetadata = {
23
+ projectId?: string;
24
+ };
20
25
  export interface WalletStrategyEthereumOptions {
21
26
  ethereumChainId: EthereumChainId;
22
27
  rpcUrl?: string;
@@ -31,23 +36,58 @@ export interface SendTransactionOptions {
31
36
  tm?: string;
32
37
  };
33
38
  }
34
- export interface ConcreteWalletStrategyOptions {
35
- privateKey?: string;
36
- metadata?: Record<string, string | Record<string, string>>;
39
+ export declare enum TurnkeyProvider {
40
+ Email = "email",
41
+ Google = "google",
42
+ Apple = "apple"
43
+ }
44
+ export type TurnkeySession = {
45
+ sessionType: any;
46
+ userId: string;
47
+ organizationId: string;
48
+ expiry: number;
49
+ token: string;
50
+ };
51
+ export interface TurnkeyMetadata {
52
+ defaultOrganizationId: string;
53
+ apiBaseUrl: string;
54
+ apiServerEndpoint: string;
55
+ iframeUrl?: string;
56
+ email?: string;
57
+ session?: TurnkeySession;
58
+ otpId?: string;
59
+ otpCode?: string;
60
+ oidcToken?: string;
61
+ iframeElementId?: string;
62
+ iframeContainerId: string;
63
+ credentialBundle?: string;
64
+ organizationId?: string;
65
+ provider?: TurnkeyProvider;
66
+ otpInitPath?: string;
67
+ otpVerifyPath?: string;
68
+ oauthLoginPath?: string;
69
+ googleClientId?: string;
70
+ googleRedirectUri?: string;
71
+ }
72
+ export interface WalletMetadata {
73
+ magic?: MagicMetadata;
74
+ turnkey?: Partial<TurnkeyMetadata>;
75
+ walletConnect?: WalletConnectMetadata;
76
+ privateKey?: PrivateKeyMetadata;
37
77
  }
38
78
  export interface ConcreteWalletStrategyArgs {
39
79
  chainId: ChainId;
40
- options?: ConcreteWalletStrategyOptions;
80
+ metadata?: WalletMetadata;
41
81
  }
42
- export interface ConcreteCosmosWalletStrategyArgs {
43
- chainId: CosmosChainId | ChainId;
82
+ export interface ConcreteCosmosWalletStrategyArgs extends ConcreteWalletStrategyArgs {
44
83
  wallet?: Wallet;
45
- options?: ConcreteWalletStrategyOptions;
46
84
  }
47
85
  export interface ConcreteEthereumWalletStrategyArgs extends ConcreteWalletStrategyArgs {
48
86
  ethereumOptions: WalletStrategyEthereumOptions;
49
87
  }
50
88
  export interface ConcreteCosmosWalletStrategy {
89
+ metadata?: WalletMetadata;
90
+ setMetadata?(metadata?: WalletMetadata): void;
51
91
  /**
52
92
  * The accounts from the wallet (addresses)
53
93
  */
@@ -89,7 +129,7 @@ export type ConcreteStrategiesArg = {
89
129
  };
90
130
  export interface WalletStrategyArguments {
91
131
  chainId: ChainId;
92
- options?: ConcreteWalletStrategyOptions;
132
+ metadata?: WalletMetadata;
93
133
  ethereumOptions?: WalletStrategyEthereumOptions;
94
134
  disabledWallets?: Wallet[];
95
135
  wallet?: Wallet;
@@ -165,9 +205,10 @@ export interface WalletStrategy {
165
205
  strategies: ConcreteStrategiesArg;
166
206
  wallet: Wallet;
167
207
  args: WalletStrategyArguments;
208
+ metadata?: WalletMetadata;
168
209
  getWallet(): Wallet;
169
210
  setWallet(wallet: Wallet): void;
170
- setOptions(options?: ConcreteWalletStrategyOptions): void;
211
+ setMetadata(metadata?: WalletMetadata): void;
171
212
  getStrategy(): ConcreteWalletStrategy;
172
213
  getAddresses(args?: unknown): Promise<AccountAddress[]>;
173
214
  getWalletDeviceType(): Promise<WalletDeviceType>;
@@ -1,2 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TurnkeyProvider = void 0;
4
+ var TurnkeyProvider;
5
+ (function (TurnkeyProvider) {
6
+ TurnkeyProvider["Email"] = "email";
7
+ TurnkeyProvider["Google"] = "google";
8
+ TurnkeyProvider["Apple"] = "apple";
9
+ })(TurnkeyProvider || (exports.TurnkeyProvider = TurnkeyProvider = {}));
@@ -6,12 +6,14 @@ const isEvmWallet = (wallet) => [
6
6
  enums_js_1.Wallet.Magic,
7
7
  enums_js_1.Wallet.BitGet,
8
8
  enums_js_1.Wallet.Ledger,
9
- enums_js_1.Wallet.TrezorBip32,
10
- enums_js_1.Wallet.TrezorBip44,
11
9
  enums_js_1.Wallet.Phantom,
12
10
  enums_js_1.Wallet.Metamask,
13
11
  enums_js_1.Wallet.OkxWallet,
14
12
  enums_js_1.Wallet.PrivateKey,
13
+ enums_js_1.Wallet.TrezorBip32,
14
+ enums_js_1.Wallet.TurnkeyOtp,
15
+ enums_js_1.Wallet.TurnkeyOauth,
16
+ enums_js_1.Wallet.TrezorBip44,
15
17
  enums_js_1.Wallet.TrustWallet,
16
18
  enums_js_1.Wallet.LedgerLegacy,
17
19
  enums_js_1.Wallet.WalletConnect,
@@ -26,6 +28,8 @@ const isEvmBrowserWallet = (wallet) => [
26
28
  enums_js_1.Wallet.Metamask,
27
29
  enums_js_1.Wallet.OkxWallet,
28
30
  enums_js_1.Wallet.TrustWallet,
31
+ enums_js_1.Wallet.TurnkeyOtp,
32
+ enums_js_1.Wallet.TurnkeyOauth,
29
33
  ].includes(wallet);
30
34
  exports.isEvmBrowserWallet = isEvmBrowserWallet;
31
35
  const isCosmosBrowserWallet = (wallet) => [
@@ -1,8 +1,9 @@
1
1
  import { ChainId, CosmosChainId, EthereumChainId } from '@injectivelabs/ts-types';
2
- import { WalletEventListener, ConcreteWalletStrategyArgs, ConcreteCosmosWalletStrategyArgs, ConcreteEthereumWalletStrategyArgs } from './types/index.js';
2
+ import { WalletMetadata, WalletEventListener, ConcreteWalletStrategyArgs, ConcreteCosmosWalletStrategyArgs, ConcreteEthereumWalletStrategyArgs } from './types/index.js';
3
3
  export default abstract class BaseConcreteStrategy {
4
4
  protected chainId: ChainId | CosmosChainId;
5
5
  protected ethereumChainId?: EthereumChainId;
6
6
  protected listeners: Partial<Record<WalletEventListener, any>>;
7
- protected constructor(args: ConcreteWalletStrategyArgs | ConcreteEthereumWalletStrategyArgs | ConcreteCosmosWalletStrategyArgs);
7
+ metadata?: WalletMetadata;
8
+ constructor(args: ConcreteWalletStrategyArgs | ConcreteEthereumWalletStrategyArgs | ConcreteCosmosWalletStrategyArgs);
8
9
  }
package/dist/esm/base.js CHANGED
@@ -2,10 +2,13 @@ export default class BaseConcreteStrategy {
2
2
  chainId;
3
3
  ethereumChainId;
4
4
  listeners = {};
5
+ metadata;
5
6
  constructor(args) {
6
- this.ethereumChainId = 'ethereumOptions' in args && args.ethereumOptions
7
- ? args.ethereumOptions.ethereumChainId
8
- : undefined;
7
+ this.ethereumChainId =
8
+ 'ethereumOptions' in args && args.ethereumOptions
9
+ ? args.ethereumOptions.ethereumChainId
10
+ : undefined;
9
11
  this.chainId = args.chainId;
12
+ this.metadata = args.metadata;
10
13
  }
11
14
  }
@@ -10,6 +10,8 @@ export declare enum Wallet {
10
10
  Phantom = "phantom",
11
11
  Metamask = "metamask",
12
12
  OkxWallet = "okx-wallet",
13
+ TurnkeyOtp = "turnkey-otp",
14
+ TurnkeyOauth = "turnkey-oauth",
13
15
  TrustWallet = "trust-wallet",
14
16
  PrivateKey = "private-key",
15
17
  TrezorBip32 = "trezor-bip32",
@@ -11,6 +11,8 @@ export var Wallet;
11
11
  Wallet["Phantom"] = "phantom";
12
12
  Wallet["Metamask"] = "metamask";
13
13
  Wallet["OkxWallet"] = "okx-wallet";
14
+ Wallet["TurnkeyOtp"] = "turnkey-otp";
15
+ Wallet["TurnkeyOauth"] = "turnkey-oauth";
14
16
  Wallet["TrustWallet"] = "trust-wallet";
15
17
  Wallet["PrivateKey"] = "private-key";
16
18
  Wallet["TrezorBip32"] = "trezor-bip32";
@@ -1,4 +1,4 @@
1
- import { ChainId, CosmosChainId, AccountAddress, EthereumChainId } from '@injectivelabs/ts-types';
1
+ import { ChainId, AccountAddress, EthereumChainId } from '@injectivelabs/ts-types';
2
2
  import type { TxRaw, TxResponse, AminoSignResponse, DirectSignResponse } from '@injectivelabs/sdk-ts';
3
3
  import { StdSignDoc } from '@keplr-wallet/types';
4
4
  import { WalletDeviceType, Wallet } from './enums.js';
@@ -16,7 +16,12 @@ export type MagicMetadata = {
16
16
  apiKey?: string;
17
17
  rpcEndpoint?: string;
18
18
  };
19
- export type WalletConnectMetadata = Record<string, string | Record<string, string> | Record<string, string[]>>;
19
+ export type PrivateKeyMetadata = {
20
+ privateKey: string;
21
+ };
22
+ export type WalletConnectMetadata = {
23
+ projectId?: string;
24
+ };
20
25
  export interface WalletStrategyEthereumOptions {
21
26
  ethereumChainId: EthereumChainId;
22
27
  rpcUrl?: string;
@@ -31,23 +36,58 @@ export interface SendTransactionOptions {
31
36
  tm?: string;
32
37
  };
33
38
  }
34
- export interface ConcreteWalletStrategyOptions {
35
- privateKey?: string;
36
- metadata?: Record<string, string | Record<string, string>>;
39
+ export declare enum TurnkeyProvider {
40
+ Email = "email",
41
+ Google = "google",
42
+ Apple = "apple"
43
+ }
44
+ export type TurnkeySession = {
45
+ sessionType: any;
46
+ userId: string;
47
+ organizationId: string;
48
+ expiry: number;
49
+ token: string;
50
+ };
51
+ export interface TurnkeyMetadata {
52
+ defaultOrganizationId: string;
53
+ apiBaseUrl: string;
54
+ apiServerEndpoint: string;
55
+ iframeUrl?: string;
56
+ email?: string;
57
+ session?: TurnkeySession;
58
+ otpId?: string;
59
+ otpCode?: string;
60
+ oidcToken?: string;
61
+ iframeElementId?: string;
62
+ iframeContainerId: string;
63
+ credentialBundle?: string;
64
+ organizationId?: string;
65
+ provider?: TurnkeyProvider;
66
+ otpInitPath?: string;
67
+ otpVerifyPath?: string;
68
+ oauthLoginPath?: string;
69
+ googleClientId?: string;
70
+ googleRedirectUri?: string;
71
+ }
72
+ export interface WalletMetadata {
73
+ magic?: MagicMetadata;
74
+ turnkey?: Partial<TurnkeyMetadata>;
75
+ walletConnect?: WalletConnectMetadata;
76
+ privateKey?: PrivateKeyMetadata;
37
77
  }
38
78
  export interface ConcreteWalletStrategyArgs {
39
79
  chainId: ChainId;
40
- options?: ConcreteWalletStrategyOptions;
80
+ metadata?: WalletMetadata;
41
81
  }
42
- export interface ConcreteCosmosWalletStrategyArgs {
43
- chainId: CosmosChainId | ChainId;
82
+ export interface ConcreteCosmosWalletStrategyArgs extends ConcreteWalletStrategyArgs {
44
83
  wallet?: Wallet;
45
- options?: ConcreteWalletStrategyOptions;
46
84
  }
47
85
  export interface ConcreteEthereumWalletStrategyArgs extends ConcreteWalletStrategyArgs {
48
86
  ethereumOptions: WalletStrategyEthereumOptions;
49
87
  }
50
88
  export interface ConcreteCosmosWalletStrategy {
89
+ metadata?: WalletMetadata;
90
+ setMetadata?(metadata?: WalletMetadata): void;
51
91
  /**
52
92
  * The accounts from the wallet (addresses)
53
93
  */
@@ -89,7 +129,7 @@ export type ConcreteStrategiesArg = {
89
129
  };
90
130
  export interface WalletStrategyArguments {
91
131
  chainId: ChainId;
92
- options?: ConcreteWalletStrategyOptions;
132
+ metadata?: WalletMetadata;
93
133
  ethereumOptions?: WalletStrategyEthereumOptions;
94
134
  disabledWallets?: Wallet[];
95
135
  wallet?: Wallet;
@@ -165,9 +205,10 @@ export interface WalletStrategy {
165
205
  strategies: ConcreteStrategiesArg;
166
206
  wallet: Wallet;
167
207
  args: WalletStrategyArguments;
208
+ metadata?: WalletMetadata;
168
209
  getWallet(): Wallet;
169
210
  setWallet(wallet: Wallet): void;
170
- setOptions(options?: ConcreteWalletStrategyOptions): void;
211
+ setMetadata(metadata?: WalletMetadata): void;
171
212
  getStrategy(): ConcreteWalletStrategy;
172
213
  getAddresses(args?: unknown): Promise<AccountAddress[]>;
173
214
  getWalletDeviceType(): Promise<WalletDeviceType>;
@@ -1 +1,6 @@
1
- export {};
1
+ export var TurnkeyProvider;
2
+ (function (TurnkeyProvider) {
3
+ TurnkeyProvider["Email"] = "email";
4
+ TurnkeyProvider["Google"] = "google";
5
+ TurnkeyProvider["Apple"] = "apple";
6
+ })(TurnkeyProvider || (TurnkeyProvider = {}));
@@ -3,12 +3,14 @@ export const isEvmWallet = (wallet) => [
3
3
  Wallet.Magic,
4
4
  Wallet.BitGet,
5
5
  Wallet.Ledger,
6
- Wallet.TrezorBip32,
7
- Wallet.TrezorBip44,
8
6
  Wallet.Phantom,
9
7
  Wallet.Metamask,
10
8
  Wallet.OkxWallet,
11
9
  Wallet.PrivateKey,
10
+ Wallet.TrezorBip32,
11
+ Wallet.TurnkeyOtp,
12
+ Wallet.TurnkeyOauth,
13
+ Wallet.TrezorBip44,
12
14
  Wallet.TrustWallet,
13
15
  Wallet.LedgerLegacy,
14
16
  Wallet.WalletConnect,
@@ -21,6 +23,8 @@ export const isEvmBrowserWallet = (wallet) => [
21
23
  Wallet.Metamask,
22
24
  Wallet.OkxWallet,
23
25
  Wallet.TrustWallet,
26
+ Wallet.TurnkeyOtp,
27
+ Wallet.TurnkeyOauth,
24
28
  ].includes(wallet);
25
29
  export const isCosmosBrowserWallet = (wallet) => [
26
30
  Wallet.Leap,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@injectivelabs/wallet-base",
3
3
  "description": "Base wallet strategy for use with @injectivelabs/wallet-core.",
4
- "version": "1.15.6",
4
+ "version": "1.15.7",
5
5
  "sideEffects": false,
6
6
  "type": "module",
7
7
  "author": {
@@ -56,14 +56,14 @@
56
56
  "start": "node dist/index.js"
57
57
  },
58
58
  "dependencies": {
59
- "@injectivelabs/exceptions": "^1.15.3",
60
- "@injectivelabs/networks": "^1.15.4",
61
- "@injectivelabs/sdk-ts": "^1.15.6",
62
- "@injectivelabs/ts-types": "^1.15.4",
59
+ "@injectivelabs/exceptions": "^1.15.4",
60
+ "@injectivelabs/networks": "^1.15.5",
61
+ "@injectivelabs/sdk-ts": "^1.15.7",
62
+ "@injectivelabs/ts-types": "^1.15.5",
63
63
  "eip1193-provider": "^1.0.1"
64
64
  },
65
65
  "devDependencies": {
66
66
  "shx": "^0.3.3"
67
67
  },
68
- "gitHead": "de7c94dbd9f169649cab7bcc66d16fa73a2bd8a3"
68
+ "gitHead": "9beac4caf49a97d0d64bde184c4fc603696b81c0"
69
69
  }