@injectivelabs/wallet-turnkey 1.15.17 → 1.15.19
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/index.d.ts +2 -3
- package/dist/cjs/index.js +4 -6
- package/dist/cjs/strategy/consts.d.ts +1 -0
- package/dist/cjs/strategy/consts.js +2 -1
- package/dist/cjs/strategy/{strategy/base.d.ts → strategy.d.ts} +5 -7
- package/dist/cjs/strategy/{strategy/base.js → strategy.js} +14 -135
- package/dist/cjs/strategy/turnkey/oauth.d.ts +1 -1
- package/dist/cjs/strategy/turnkey/oauth.js +2 -1
- package/dist/cjs/strategy/turnkey/otp.d.ts +3 -2
- package/dist/cjs/strategy/turnkey/otp.js +2 -1
- package/dist/cjs/strategy/turnkey/turnkey.d.ts +16 -6
- package/dist/cjs/strategy/turnkey/turnkey.js +117 -10
- package/dist/cjs/strategy/types.d.ts +1 -0
- package/dist/esm/index.d.ts +2 -3
- package/dist/esm/index.js +2 -3
- package/dist/esm/strategy/consts.d.ts +1 -0
- package/dist/esm/strategy/consts.js +1 -0
- package/dist/esm/strategy/{strategy/base.d.ts → strategy.d.ts} +5 -7
- package/dist/esm/strategy/{strategy/base.js → strategy.js} +13 -134
- package/dist/esm/strategy/turnkey/oauth.d.ts +1 -1
- package/dist/esm/strategy/turnkey/oauth.js +3 -2
- package/dist/esm/strategy/turnkey/otp.d.ts +3 -2
- package/dist/esm/strategy/turnkey/otp.js +3 -2
- package/dist/esm/strategy/turnkey/turnkey.d.ts +16 -6
- package/dist/esm/strategy/turnkey/turnkey.js +119 -12
- package/dist/esm/strategy/types.d.ts +1 -0
- package/package.json +7 -7
- package/dist/cjs/strategy/strategy/oauth.d.ts +0 -5
- package/dist/cjs/strategy/strategy/oauth.js +0 -14
- package/dist/cjs/strategy/strategy/otp.d.ts +0 -5
- package/dist/cjs/strategy/strategy/otp.js +0 -14
- package/dist/esm/strategy/strategy/oauth.d.ts +0 -5
- package/dist/esm/strategy/strategy/oauth.js +0 -10
- package/dist/esm/strategy/strategy/otp.d.ts +0 -5
- package/dist/esm/strategy/strategy/otp.js +0 -10
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export
|
|
3
|
-
export * from './strategy/strategy/base.js';
|
|
1
|
+
export { TurnkeyWalletStrategy } from './strategy/strategy.js';
|
|
2
|
+
export * from './strategy/strategy.js';
|
|
4
3
|
export * from './strategy/turnkey/turnkey.js';
|
package/dist/cjs/index.js
CHANGED
|
@@ -14,10 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
18
|
-
var
|
|
19
|
-
Object.defineProperty(exports, "
|
|
20
|
-
|
|
21
|
-
Object.defineProperty(exports, "TurnkeyOauthWalletStrategy", { enumerable: true, get: function () { return oauth_js_1.TurnkeyOauthWalletStrategy; } });
|
|
22
|
-
__exportStar(require("./strategy/strategy/base.js"), exports);
|
|
17
|
+
exports.TurnkeyWalletStrategy = void 0;
|
|
18
|
+
var strategy_js_1 = require("./strategy/strategy.js");
|
|
19
|
+
Object.defineProperty(exports, "TurnkeyWalletStrategy", { enumerable: true, get: function () { return strategy_js_1.TurnkeyWalletStrategy; } });
|
|
20
|
+
__exportStar(require("./strategy/strategy.js"), exports);
|
|
23
21
|
__exportStar(require("./strategy/turnkey/turnkey.js"), exports);
|
|
@@ -2,3 +2,4 @@ export declare const TURNKEY_OAUTH_PATH = "turnkey/oauth";
|
|
|
2
2
|
export declare const TURNKEY_OTP_PATH = "turnkey/otp";
|
|
3
3
|
export declare const TURNKEY_OTP_INIT_PATH = "turnkey/otp/init";
|
|
4
4
|
export declare const TURNKEY_OTP_VERIFY_PATH = "turnkey/otp/verify";
|
|
5
|
+
export declare const DEFAULT_TURNKEY_REFRESH_SECONDS = "86400";
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TURNKEY_OTP_VERIFY_PATH = exports.TURNKEY_OTP_INIT_PATH = exports.TURNKEY_OTP_PATH = exports.TURNKEY_OAUTH_PATH = void 0;
|
|
3
|
+
exports.DEFAULT_TURNKEY_REFRESH_SECONDS = exports.TURNKEY_OTP_VERIFY_PATH = exports.TURNKEY_OTP_INIT_PATH = exports.TURNKEY_OTP_PATH = exports.TURNKEY_OAUTH_PATH = void 0;
|
|
4
4
|
exports.TURNKEY_OAUTH_PATH = 'turnkey/oauth';
|
|
5
5
|
exports.TURNKEY_OTP_PATH = 'turnkey/otp';
|
|
6
6
|
exports.TURNKEY_OTP_INIT_PATH = `${exports.TURNKEY_OTP_PATH}/init`;
|
|
7
7
|
exports.TURNKEY_OTP_VERIFY_PATH = `${exports.TURNKEY_OTP_PATH}/verify`;
|
|
8
|
+
exports.DEFAULT_TURNKEY_REFRESH_SECONDS = '86400';
|
|
@@ -1,26 +1,24 @@
|
|
|
1
1
|
import { TxRaw, AminoSignResponse, DirectSignResponse } from '@injectivelabs/sdk-ts';
|
|
2
2
|
import { HttpRestClient } from '@injectivelabs/utils';
|
|
3
3
|
import { AccountAddress, EthereumChainId } from '@injectivelabs/ts-types';
|
|
4
|
-
import { StdSignDoc, TurnkeyProvider, WalletDeviceType, type WalletMetadata, BaseConcreteStrategy, ConcreteWalletStrategy, SendTransactionOptions, ConcreteEthereumWalletStrategyArgs } from '@injectivelabs/wallet-base';
|
|
5
|
-
import { TurnkeyWallet } from '../turnkey/turnkey.js';
|
|
6
4
|
import { TurnkeyIframeClient } from '@turnkey/sdk-browser';
|
|
7
|
-
|
|
5
|
+
import { StdSignDoc, WalletDeviceType, type WalletMetadata, BaseConcreteStrategy, ConcreteWalletStrategy, SendTransactionOptions, ConcreteEthereumWalletStrategyArgs } from '@injectivelabs/wallet-base';
|
|
6
|
+
import { TurnkeyWallet } from './turnkey/turnkey.js';
|
|
7
|
+
export declare class TurnkeyWalletStrategy extends BaseConcreteStrategy implements ConcreteWalletStrategy {
|
|
8
8
|
turnkeyWallet: TurnkeyWallet | undefined;
|
|
9
|
-
turnkeyProvider: TurnkeyProvider;
|
|
10
9
|
client: HttpRestClient;
|
|
11
10
|
constructor(args: ConcreteEthereumWalletStrategyArgs & {
|
|
12
|
-
provider: TurnkeyProvider;
|
|
13
11
|
apiServerEndpoint?: string;
|
|
14
12
|
});
|
|
15
13
|
getWalletDeviceType(): Promise<WalletDeviceType>;
|
|
16
14
|
setMetadata(metadata?: {
|
|
17
15
|
turnkey?: Partial<WalletMetadata['turnkey']>;
|
|
18
16
|
}): void;
|
|
19
|
-
private setOrganizationId;
|
|
20
17
|
enable(): Promise<boolean>;
|
|
21
18
|
disconnect(): Promise<void>;
|
|
22
19
|
getAddresses(): Promise<string[]>;
|
|
23
|
-
getSessionOrConfirm(): Promise<string>;
|
|
20
|
+
getSessionOrConfirm(_address?: string): Promise<string>;
|
|
21
|
+
getWalletClient<TurnkeyWallet>(): Promise<TurnkeyWallet>;
|
|
24
22
|
sendEthereumTransaction(_transaction: unknown, _options: {
|
|
25
23
|
address: AccountAddress;
|
|
26
24
|
ethereumChainId: EthereumChainId;
|
|
@@ -1,25 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.TurnkeyWalletStrategy = void 0;
|
|
4
4
|
/* eslint-disable class-methods-use-this */
|
|
5
|
-
const exceptions_1 = require("@injectivelabs/exceptions");
|
|
6
5
|
const sdk_ts_1 = require("@injectivelabs/sdk-ts");
|
|
6
|
+
const exceptions_1 = require("@injectivelabs/exceptions");
|
|
7
|
+
const viem_1 = require("viem");
|
|
7
8
|
const utils_1 = require("@injectivelabs/utils");
|
|
8
9
|
const wallet_base_1 = require("@injectivelabs/wallet-base");
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
const oauth_js_1 = require("../turnkey/oauth.js");
|
|
13
|
-
const sdk_browser_1 = require("@turnkey/sdk-browser");
|
|
14
|
-
const viem_1 = require("viem");
|
|
15
|
-
const utils_js_1 = require("../../utils.js");
|
|
16
|
-
class BaseTurnkeyWalletStrategy extends wallet_base_1.BaseConcreteStrategy {
|
|
10
|
+
const types_js_1 = require("./types.js");
|
|
11
|
+
const turnkey_js_1 = require("./turnkey/turnkey.js");
|
|
12
|
+
class TurnkeyWalletStrategy extends wallet_base_1.BaseConcreteStrategy {
|
|
17
13
|
turnkeyWallet;
|
|
18
|
-
turnkeyProvider;
|
|
19
14
|
client;
|
|
20
15
|
constructor(args) {
|
|
21
16
|
super(args);
|
|
22
|
-
this.turnkeyProvider = args.provider;
|
|
23
17
|
const endpoint = args.apiServerEndpoint || this.metadata?.turnkey?.apiServerEndpoint;
|
|
24
18
|
if (!endpoint) {
|
|
25
19
|
throw new exceptions_1.WalletException(new Error('apiServerEndpoint is required'));
|
|
@@ -38,13 +32,9 @@ class BaseTurnkeyWalletStrategy extends wallet_base_1.BaseConcreteStrategy {
|
|
|
38
32
|
...metadata.turnkey,
|
|
39
33
|
},
|
|
40
34
|
};
|
|
35
|
+
this.turnkeyWallet?.setMetadata(this.metadata?.turnkey);
|
|
41
36
|
}
|
|
42
37
|
}
|
|
43
|
-
//? This is here specifically because we have to ensure we set the organizationId on TurnkeyWallet as well
|
|
44
|
-
setOrganizationId(organizationId) {
|
|
45
|
-
this.setMetadata({ turnkey: { organizationId } });
|
|
46
|
-
this.turnkeyWallet?.setMetadata({ organizationId });
|
|
47
|
-
}
|
|
48
38
|
async enable() {
|
|
49
39
|
const turnkeyWallet = await this.getTurnkeyWallet();
|
|
50
40
|
try {
|
|
@@ -73,48 +63,7 @@ class BaseTurnkeyWalletStrategy extends wallet_base_1.BaseConcreteStrategy {
|
|
|
73
63
|
}
|
|
74
64
|
async getAddresses() {
|
|
75
65
|
const turnkeyWallet = await this.getTurnkeyWallet();
|
|
76
|
-
|
|
77
|
-
// CHeck if the user is already connected
|
|
78
|
-
const session = await turnkeyWallet.getSession();
|
|
79
|
-
if (!session.session) {
|
|
80
|
-
const iframeClient = await turnkeyWallet.getIframeClient();
|
|
81
|
-
// Check the provider type and perform auth step accordingly
|
|
82
|
-
if (this.turnkeyProvider === wallet_base_1.TurnkeyProvider.Email) {
|
|
83
|
-
if (!this.metadata?.turnkey?.otpId) {
|
|
84
|
-
throw new exceptions_1.WalletException(new Error('OTP ID is required'));
|
|
85
|
-
}
|
|
86
|
-
if (!this.metadata?.turnkey?.otpCode) {
|
|
87
|
-
throw new exceptions_1.WalletException(new Error('OTP code is required'));
|
|
88
|
-
}
|
|
89
|
-
const result = await otp_js_1.TurnkeyOtpWallet.confirmEmailOTP({
|
|
90
|
-
iframeClient,
|
|
91
|
-
organizationId,
|
|
92
|
-
client: this.client,
|
|
93
|
-
otpCode: this.metadata?.turnkey?.otpCode,
|
|
94
|
-
emailOTPId: this.metadata?.turnkey?.otpId,
|
|
95
|
-
});
|
|
96
|
-
if (result?.credentialBundle) {
|
|
97
|
-
this.metadata.turnkey.credentialBundle = result.credentialBundle;
|
|
98
|
-
await turnkeyWallet.injectAndRefresh(result.credentialBundle);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
if (!this.metadata?.turnkey?.oidcToken) {
|
|
103
|
-
throw new exceptions_1.WalletException(new Error('Oidc token is required'));
|
|
104
|
-
}
|
|
105
|
-
const result = await oauth_js_1.TurnkeyOauthWallet.oauthLogin({
|
|
106
|
-
client: this.client,
|
|
107
|
-
iframeClient,
|
|
108
|
-
oidcToken: this.metadata?.turnkey?.oidcToken,
|
|
109
|
-
providerName: this.turnkeyProvider.toString(),
|
|
110
|
-
});
|
|
111
|
-
if (result?.credentialBundle) {
|
|
112
|
-
this.metadata.turnkey.organizationId = result.organizationId;
|
|
113
|
-
this.metadata.turnkey.credentialBundle = result.credentialBundle;
|
|
114
|
-
await turnkeyWallet.injectAndRefresh(result.credentialBundle);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
66
|
+
await turnkeyWallet.getSession();
|
|
118
67
|
try {
|
|
119
68
|
return await turnkeyWallet.getAccounts();
|
|
120
69
|
}
|
|
@@ -130,82 +79,12 @@ class BaseTurnkeyWalletStrategy extends wallet_base_1.BaseConcreteStrategy {
|
|
|
130
79
|
});
|
|
131
80
|
}
|
|
132
81
|
}
|
|
133
|
-
async getSessionOrConfirm() {
|
|
134
|
-
const { turnkeyProvider, metadata, client } = this;
|
|
82
|
+
async getSessionOrConfirm(_address) {
|
|
135
83
|
const turnkeyWallet = await this.getTurnkeyWallet();
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
!this.metadata?.turnkey?.email &&
|
|
141
|
-
!this.metadata?.turnkey?.oidcToken &&
|
|
142
|
-
session.session?.token) {
|
|
143
|
-
await iframeClient.injectCredentialBundle(session.session?.token);
|
|
144
|
-
this.setOrganizationId(session.organizationId);
|
|
145
|
-
await iframeClient.refreshSession({
|
|
146
|
-
sessionType: sdk_browser_1.SessionType.READ_WRITE,
|
|
147
|
-
targetPublicKey: iframeClient.iframePublicKey,
|
|
148
|
-
expirationSeconds: '900',
|
|
149
|
-
});
|
|
150
|
-
return session.session.token;
|
|
151
|
-
}
|
|
152
|
-
if (turnkeyProvider === wallet_base_1.TurnkeyProvider.Email) {
|
|
153
|
-
if (!metadata?.turnkey?.email) {
|
|
154
|
-
throw new exceptions_1.WalletException(new Error('Email is required'));
|
|
155
|
-
}
|
|
156
|
-
const result = await otp_js_1.TurnkeyOtpWallet.initEmailOTP({
|
|
157
|
-
client,
|
|
158
|
-
iframeClient,
|
|
159
|
-
email: metadata.turnkey.email,
|
|
160
|
-
otpInitPath: metadata.turnkey.otpInitPath,
|
|
161
|
-
});
|
|
162
|
-
if (result?.organizationId && this.metadata?.turnkey) {
|
|
163
|
-
this.metadata.turnkey.organizationId = result.organizationId;
|
|
164
|
-
}
|
|
165
|
-
if (result?.otpId && this.metadata?.turnkey) {
|
|
166
|
-
this.metadata.turnkey.otpId = result.otpId;
|
|
167
|
-
}
|
|
168
|
-
return result?.otpId || '';
|
|
169
|
-
}
|
|
170
|
-
if ([wallet_base_1.TurnkeyProvider.Google, wallet_base_1.TurnkeyProvider.Apple].includes(turnkeyProvider)) {
|
|
171
|
-
if (metadata?.turnkey?.oidcToken) {
|
|
172
|
-
const oauthResult = await oauth_js_1.TurnkeyOauthWallet.oauthLogin({
|
|
173
|
-
client,
|
|
174
|
-
iframeClient,
|
|
175
|
-
oidcToken: metadata.turnkey.oidcToken,
|
|
176
|
-
providerName: turnkeyProvider.toString(),
|
|
177
|
-
oauthLoginPath: metadata.turnkey.oauthLoginPath,
|
|
178
|
-
});
|
|
179
|
-
if (oauthResult?.credentialBundle) {
|
|
180
|
-
await turnkeyWallet.injectAndRefresh(oauthResult.credentialBundle);
|
|
181
|
-
}
|
|
182
|
-
if (oauthResult?.credentialBundle) {
|
|
183
|
-
const session = await turnkeyWallet.getSession();
|
|
184
|
-
if (this.metadata?.turnkey && session.organizationId) {
|
|
185
|
-
this.metadata.turnkey.organizationId = session.organizationId;
|
|
186
|
-
}
|
|
187
|
-
return oauthResult.credentialBundle;
|
|
188
|
-
}
|
|
189
|
-
throw new exceptions_1.WalletException(new Error('Oauth result not found'));
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
const nonce = await oauth_js_1.TurnkeyOauthWallet.generateOAuthNonce(iframeClient);
|
|
193
|
-
if (!metadata?.turnkey?.googleClientId ||
|
|
194
|
-
!metadata?.turnkey?.googleRedirectUri) {
|
|
195
|
-
throw new exceptions_1.WalletException(new Error('googleClientId and googleRedirectUri are required'));
|
|
196
|
-
}
|
|
197
|
-
if (turnkeyProvider === wallet_base_1.TurnkeyProvider.Google) {
|
|
198
|
-
return (0, utils_js_1.generateGoogleUrl)({
|
|
199
|
-
nonce,
|
|
200
|
-
clientId: metadata.turnkey.googleClientId,
|
|
201
|
-
redirectUri: metadata.turnkey.googleRedirectUri,
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
//? When we add Apple support, we might also want to return the URL as well
|
|
205
|
-
return nonce;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
return '';
|
|
84
|
+
return await turnkeyWallet.refreshSession();
|
|
85
|
+
}
|
|
86
|
+
async getWalletClient() {
|
|
87
|
+
return (await this.getTurnkeyWallet());
|
|
209
88
|
}
|
|
210
89
|
async sendEthereumTransaction(_transaction, _options) {
|
|
211
90
|
throw new exceptions_1.WalletException(new Error('sendEthereumTransaction is not supported. Turnkey only supports sending cosmos transactions'), {
|
|
@@ -324,4 +203,4 @@ class BaseTurnkeyWalletStrategy extends wallet_base_1.BaseConcreteStrategy {
|
|
|
324
203
|
return organizationId;
|
|
325
204
|
}
|
|
326
205
|
}
|
|
327
|
-
exports.
|
|
206
|
+
exports.TurnkeyWalletStrategy = TurnkeyWalletStrategy;
|
|
@@ -6,9 +6,9 @@ export declare class TurnkeyOauthWallet {
|
|
|
6
6
|
oidcToken: string;
|
|
7
7
|
client: HttpRestClient;
|
|
8
8
|
oauthLoginPath?: string;
|
|
9
|
-
expirationSeconds?: number;
|
|
10
9
|
providerName: 'google' | 'apple';
|
|
11
10
|
iframeClient: TurnkeyIframeClient;
|
|
11
|
+
expirationSeconds?: number;
|
|
12
12
|
}): Promise<{
|
|
13
13
|
organizationId: string;
|
|
14
14
|
credentialBundle: string;
|
|
@@ -24,7 +24,7 @@ class TurnkeyOauthWallet {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
static async oauthLogin(args) {
|
|
27
|
-
const { client, iframeClient } = args;
|
|
27
|
+
const { client, iframeClient, expirationSeconds } = args;
|
|
28
28
|
const path = args.oauthLoginPath || consts_js_1.TURNKEY_OAUTH_PATH;
|
|
29
29
|
try {
|
|
30
30
|
const targetPublicKey = iframeClient.iframePublicKey;
|
|
@@ -36,6 +36,7 @@ class TurnkeyOauthWallet {
|
|
|
36
36
|
targetPublicKey,
|
|
37
37
|
oidcToken: args.oidcToken,
|
|
38
38
|
providerName: args.providerName,
|
|
39
|
+
expirationSeconds: (expirationSeconds || consts_js_1.DEFAULT_TURNKEY_REFRESH_SECONDS)?.toString(),
|
|
39
40
|
});
|
|
40
41
|
return response.data;
|
|
41
42
|
}
|
|
@@ -12,10 +12,11 @@ export declare class TurnkeyOtpWallet {
|
|
|
12
12
|
}): Promise<TurnkeyOTPCredentialsResponse | undefined>;
|
|
13
13
|
static confirmEmailOTP(args: {
|
|
14
14
|
otpCode: string;
|
|
15
|
-
emailOTPId
|
|
15
|
+
emailOTPId: string;
|
|
16
16
|
client: HttpRestClient;
|
|
17
|
-
organizationId
|
|
17
|
+
organizationId: string;
|
|
18
18
|
iframeClient: TurnkeyIframeClient;
|
|
19
19
|
otpVerifyPath?: string;
|
|
20
|
+
expirationSeconds?: number;
|
|
20
21
|
}): Promise<TurnkeyConfirmEmailOTPResponse | undefined>;
|
|
21
22
|
}
|
|
@@ -29,7 +29,7 @@ class TurnkeyOtpWallet {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
static async confirmEmailOTP(args) {
|
|
32
|
-
const { client, iframeClient } = args;
|
|
32
|
+
const { client, iframeClient, expirationSeconds } = args;
|
|
33
33
|
try {
|
|
34
34
|
const organizationId = args.organizationId;
|
|
35
35
|
const emailOTPId = args.emailOTPId;
|
|
@@ -49,6 +49,7 @@ class TurnkeyOtpWallet {
|
|
|
49
49
|
otpId: emailOTPId,
|
|
50
50
|
otpCode: args.otpCode,
|
|
51
51
|
suborgID: organizationId,
|
|
52
|
+
expirationSeconds: (expirationSeconds || consts_js_1.DEFAULT_TURNKEY_REFRESH_SECONDS)?.toString(),
|
|
52
53
|
});
|
|
53
54
|
return response?.data;
|
|
54
55
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { TurnkeyMetadata } from '@injectivelabs/wallet-base';
|
|
1
|
+
import { TurnkeyMetadata, TurnkeyProvider } from '@injectivelabs/wallet-base';
|
|
3
2
|
import { HttpRestClient } from '@injectivelabs/utils';
|
|
3
|
+
import { Turnkey, TurnkeyIframeClient } from '@turnkey/sdk-browser';
|
|
4
4
|
export declare class TurnkeyWallet {
|
|
5
|
-
protected iframeClient: TurnkeyIframeClient | undefined;
|
|
6
|
-
protected turnkey: Turnkey | undefined;
|
|
7
5
|
protected client: HttpRestClient;
|
|
8
6
|
private metadata;
|
|
7
|
+
protected turnkey: Turnkey | undefined;
|
|
8
|
+
protected iframeClient: TurnkeyIframeClient | undefined;
|
|
9
|
+
organizationId: string;
|
|
10
|
+
private otpId;
|
|
9
11
|
private accountMap;
|
|
10
12
|
setMetadata(metadata: Partial<TurnkeyMetadata>): void;
|
|
11
13
|
constructor(metadata: TurnkeyMetadata);
|
|
@@ -20,7 +22,7 @@ export declare class TurnkeyWallet {
|
|
|
20
22
|
organizationId: string;
|
|
21
23
|
}>;
|
|
22
24
|
getAccounts(): Promise<string[]>;
|
|
23
|
-
getOrCreateAndGetAccount(address: string, organizationId
|
|
25
|
+
getOrCreateAndGetAccount(address: string, organizationId: string): Promise<{
|
|
24
26
|
address: import("abitype").Address;
|
|
25
27
|
nonceManager?: import("viem").NonceManager | undefined;
|
|
26
28
|
sign?: ((parameters: {
|
|
@@ -38,6 +40,14 @@ export declare class TurnkeyWallet {
|
|
|
38
40
|
source: string;
|
|
39
41
|
type: "local";
|
|
40
42
|
}>;
|
|
41
|
-
injectAndRefresh(credentialBundle: string
|
|
43
|
+
injectAndRefresh(credentialBundle: string, options: {
|
|
44
|
+
expirationSeconds?: string;
|
|
45
|
+
organizationId?: string;
|
|
46
|
+
}): Promise<void>;
|
|
47
|
+
initOTP(email: string): Promise<import("../types.js").TurnkeyOTPCredentialsResponse>;
|
|
48
|
+
confirmOTP(otpCode: string): Promise<import("../types.js").TurnkeyConfirmEmailOTPResponse>;
|
|
49
|
+
initOAuth(provider: TurnkeyProvider.Google | TurnkeyProvider.Apple): Promise<string>;
|
|
50
|
+
confirmOAuth(provider: TurnkeyProvider.Google | TurnkeyProvider.Apple, oidcToken: string): Promise<string>;
|
|
51
|
+
refreshSession(): Promise<string>;
|
|
42
52
|
private initFrame;
|
|
43
53
|
}
|
|
@@ -1,24 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TurnkeyWallet = void 0;
|
|
4
|
-
const sdk_browser_1 = require("@turnkey/sdk-browser");
|
|
5
4
|
const exceptions_1 = require("@injectivelabs/exceptions");
|
|
6
5
|
const wallet_base_1 = require("@injectivelabs/wallet-base");
|
|
7
|
-
const sdk_ts_1 = require("@injectivelabs/sdk-ts");
|
|
8
|
-
const utils_1 = require("@injectivelabs/utils");
|
|
9
6
|
const viem_1 = require("@turnkey/viem");
|
|
7
|
+
const utils_1 = require("@injectivelabs/utils");
|
|
8
|
+
const sdk_ts_1 = require("@injectivelabs/sdk-ts");
|
|
9
|
+
const sdk_browser_1 = require("@turnkey/sdk-browser");
|
|
10
|
+
const consts_js_1 = require("../consts.js");
|
|
11
|
+
const otp_js_1 = require("./otp.js");
|
|
10
12
|
const types_js_1 = require("../types.js");
|
|
13
|
+
const oauth_js_1 = require("./oauth.js");
|
|
14
|
+
const utils_js_1 = require("../../utils.js");
|
|
11
15
|
class TurnkeyWallet {
|
|
12
|
-
iframeClient;
|
|
13
|
-
turnkey;
|
|
14
16
|
client;
|
|
15
17
|
metadata;
|
|
18
|
+
turnkey;
|
|
19
|
+
iframeClient;
|
|
20
|
+
organizationId;
|
|
21
|
+
otpId;
|
|
16
22
|
accountMap = {};
|
|
17
23
|
setMetadata(metadata) {
|
|
18
24
|
this.metadata = { ...this.metadata, ...metadata };
|
|
19
25
|
}
|
|
20
26
|
constructor(metadata) {
|
|
21
27
|
this.metadata = metadata;
|
|
28
|
+
this.organizationId = metadata.organizationId;
|
|
22
29
|
this.client = new utils_1.HttpRestClient(metadata.apiServerEndpoint);
|
|
23
30
|
}
|
|
24
31
|
static async getTurnkeyInstance(metadata) {
|
|
@@ -93,16 +100,16 @@ class TurnkeyWallet {
|
|
|
93
100
|
}
|
|
94
101
|
async getAccounts() {
|
|
95
102
|
const iframeClient = await this.getIframeClient();
|
|
96
|
-
if (!this.
|
|
103
|
+
if (!this.organizationId) {
|
|
97
104
|
return [];
|
|
98
105
|
}
|
|
99
106
|
try {
|
|
100
107
|
const response = await iframeClient.getWallets({
|
|
101
|
-
organizationId: this.
|
|
108
|
+
organizationId: this.organizationId,
|
|
102
109
|
});
|
|
103
110
|
const accounts = await Promise.allSettled(response.wallets.map((wallet) => iframeClient.getWalletAccounts({
|
|
104
111
|
walletId: wallet.walletId,
|
|
105
|
-
organizationId: this.
|
|
112
|
+
organizationId: this.organizationId,
|
|
106
113
|
})));
|
|
107
114
|
const filteredAccounts = accounts
|
|
108
115
|
.filter((account) => account.status === 'fulfilled')
|
|
@@ -149,16 +156,116 @@ class TurnkeyWallet {
|
|
|
149
156
|
this.accountMap[address] = turnkeyAccount;
|
|
150
157
|
return turnkeyAccount;
|
|
151
158
|
}
|
|
152
|
-
async injectAndRefresh(credentialBundle) {
|
|
159
|
+
async injectAndRefresh(credentialBundle, options) {
|
|
160
|
+
const expirationSeconds = options.expirationSeconds || consts_js_1.DEFAULT_TURNKEY_REFRESH_SECONDS;
|
|
153
161
|
const iframeClient = await this.getIframeClient();
|
|
154
162
|
await iframeClient.injectCredentialBundle(credentialBundle);
|
|
155
163
|
await iframeClient.refreshSession({
|
|
156
164
|
sessionType: sdk_browser_1.SessionType.READ_WRITE,
|
|
157
165
|
targetPublicKey: iframeClient.iframePublicKey,
|
|
158
|
-
expirationSeconds
|
|
166
|
+
expirationSeconds,
|
|
159
167
|
});
|
|
168
|
+
const session = await this.turnkey?.getSession();
|
|
169
|
+
if (!session) {
|
|
170
|
+
throw new exceptions_1.WalletException(new Error('Failed to refresh session'));
|
|
171
|
+
}
|
|
172
|
+
this.organizationId = session.organizationId;
|
|
173
|
+
this.metadata.organizationId = session.organizationId;
|
|
174
|
+
// Refresh the session 2 minutes before it expires
|
|
175
|
+
setTimeout(() => {
|
|
176
|
+
iframeClient.refreshSession({
|
|
177
|
+
expirationSeconds: session?.expiry,
|
|
178
|
+
sessionType: sdk_browser_1.SessionType.READ_WRITE,
|
|
179
|
+
targetPublicKey: iframeClient.iframePublicKey,
|
|
180
|
+
});
|
|
181
|
+
}, (parseInt(expirationSeconds) - 120) * 1000);
|
|
160
182
|
return;
|
|
161
183
|
}
|
|
184
|
+
async initOTP(email) {
|
|
185
|
+
const iframeClient = await this.getIframeClient();
|
|
186
|
+
const result = await otp_js_1.TurnkeyOtpWallet.initEmailOTP({
|
|
187
|
+
client: this.client,
|
|
188
|
+
iframeClient,
|
|
189
|
+
email,
|
|
190
|
+
otpInitPath: this.metadata.otpInitPath || consts_js_1.TURNKEY_OTP_INIT_PATH,
|
|
191
|
+
});
|
|
192
|
+
if (!result || !result.otpId) {
|
|
193
|
+
throw new exceptions_1.WalletException(new Error('Failed to initialize OTP'));
|
|
194
|
+
}
|
|
195
|
+
if (result?.organizationId) {
|
|
196
|
+
this.organizationId = result.organizationId;
|
|
197
|
+
}
|
|
198
|
+
if (result?.otpId) {
|
|
199
|
+
this.otpId = result.otpId;
|
|
200
|
+
}
|
|
201
|
+
return result;
|
|
202
|
+
}
|
|
203
|
+
async confirmOTP(otpCode) {
|
|
204
|
+
const iframeClient = await this.getIframeClient();
|
|
205
|
+
if (!this.otpId) {
|
|
206
|
+
throw new exceptions_1.WalletException(new Error('OTP ID is required'));
|
|
207
|
+
}
|
|
208
|
+
const result = await otp_js_1.TurnkeyOtpWallet.confirmEmailOTP({
|
|
209
|
+
otpCode,
|
|
210
|
+
iframeClient,
|
|
211
|
+
client: this.client,
|
|
212
|
+
emailOTPId: this.otpId,
|
|
213
|
+
organizationId: this.organizationId,
|
|
214
|
+
otpVerifyPath: this.metadata.otpVerifyPath || consts_js_1.TURNKEY_OTP_VERIFY_PATH,
|
|
215
|
+
});
|
|
216
|
+
if (!result || !result.credentialBundle) {
|
|
217
|
+
throw new exceptions_1.WalletException(new Error('Failed to confirm OTP'));
|
|
218
|
+
}
|
|
219
|
+
await this.injectAndRefresh(result.credentialBundle, {
|
|
220
|
+
organizationId: result.organizationId,
|
|
221
|
+
expirationSeconds: this.metadata.expirationSeconds,
|
|
222
|
+
});
|
|
223
|
+
return result;
|
|
224
|
+
}
|
|
225
|
+
async initOAuth(provider) {
|
|
226
|
+
const iframeClient = await this.getIframeClient();
|
|
227
|
+
const nonce = await oauth_js_1.TurnkeyOauthWallet.generateOAuthNonce(iframeClient);
|
|
228
|
+
if (provider === wallet_base_1.TurnkeyProvider.Apple) {
|
|
229
|
+
// TODO: implement the ability to generate Apple OAuth URL
|
|
230
|
+
return nonce;
|
|
231
|
+
}
|
|
232
|
+
if (!this.metadata?.googleClientId || !this.metadata?.googleRedirectUri) {
|
|
233
|
+
throw new exceptions_1.WalletException(new Error('googleClientId and googleRedirectUri are required'));
|
|
234
|
+
}
|
|
235
|
+
return (0, utils_js_1.generateGoogleUrl)({
|
|
236
|
+
nonce,
|
|
237
|
+
clientId: this.metadata.googleClientId,
|
|
238
|
+
redirectUri: this.metadata.googleRedirectUri,
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
async confirmOAuth(provider, oidcToken) {
|
|
242
|
+
const iframeClient = await this.getIframeClient();
|
|
243
|
+
const oauthResult = await oauth_js_1.TurnkeyOauthWallet.oauthLogin({
|
|
244
|
+
oidcToken,
|
|
245
|
+
iframeClient,
|
|
246
|
+
client: this.client,
|
|
247
|
+
providerName: provider.toString(),
|
|
248
|
+
oauthLoginPath: this.metadata.oauthLoginPath || consts_js_1.TURNKEY_OAUTH_PATH,
|
|
249
|
+
});
|
|
250
|
+
if (!oauthResult || !oauthResult.credentialBundle) {
|
|
251
|
+
throw new exceptions_1.WalletException(new Error('Unexpected OAuth result'));
|
|
252
|
+
}
|
|
253
|
+
await this.injectAndRefresh(oauthResult.credentialBundle, {
|
|
254
|
+
organizationId: oauthResult.organizationId,
|
|
255
|
+
expirationSeconds: this.metadata.expirationSeconds,
|
|
256
|
+
});
|
|
257
|
+
return oauthResult.credentialBundle;
|
|
258
|
+
}
|
|
259
|
+
async refreshSession() {
|
|
260
|
+
const session = await this.getSession();
|
|
261
|
+
if (session.session?.token) {
|
|
262
|
+
await this.injectAndRefresh(session.session.token, {
|
|
263
|
+
expirationSeconds: this.metadata.expirationSeconds || consts_js_1.DEFAULT_TURNKEY_REFRESH_SECONDS,
|
|
264
|
+
});
|
|
265
|
+
return session.session.token;
|
|
266
|
+
}
|
|
267
|
+
throw new exceptions_1.TurnkeyWalletSessionException(new Error('Session expired. Please login again.'));
|
|
268
|
+
}
|
|
162
269
|
async initFrame() {
|
|
163
270
|
const { metadata } = this;
|
|
164
271
|
const { turnkey, iframeClient } = await createTurnkeyIFrame(metadata);
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export
|
|
3
|
-
export * from './strategy/strategy/base.js';
|
|
1
|
+
export { TurnkeyWalletStrategy } from './strategy/strategy.js';
|
|
2
|
+
export * from './strategy/strategy.js';
|
|
4
3
|
export * from './strategy/turnkey/turnkey.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export
|
|
3
|
-
export * from './strategy/strategy/base.js';
|
|
1
|
+
export { TurnkeyWalletStrategy } from './strategy/strategy.js';
|
|
2
|
+
export * from './strategy/strategy.js';
|
|
4
3
|
export * from './strategy/turnkey/turnkey.js';
|
|
@@ -2,3 +2,4 @@ export declare const TURNKEY_OAUTH_PATH = "turnkey/oauth";
|
|
|
2
2
|
export declare const TURNKEY_OTP_PATH = "turnkey/otp";
|
|
3
3
|
export declare const TURNKEY_OTP_INIT_PATH = "turnkey/otp/init";
|
|
4
4
|
export declare const TURNKEY_OTP_VERIFY_PATH = "turnkey/otp/verify";
|
|
5
|
+
export declare const DEFAULT_TURNKEY_REFRESH_SECONDS = "86400";
|
|
@@ -2,3 +2,4 @@ export const TURNKEY_OAUTH_PATH = 'turnkey/oauth';
|
|
|
2
2
|
export const TURNKEY_OTP_PATH = 'turnkey/otp';
|
|
3
3
|
export const TURNKEY_OTP_INIT_PATH = `${TURNKEY_OTP_PATH}/init`;
|
|
4
4
|
export const TURNKEY_OTP_VERIFY_PATH = `${TURNKEY_OTP_PATH}/verify`;
|
|
5
|
+
export const DEFAULT_TURNKEY_REFRESH_SECONDS = '86400';
|
|
@@ -1,26 +1,24 @@
|
|
|
1
1
|
import { TxRaw, AminoSignResponse, DirectSignResponse } from '@injectivelabs/sdk-ts';
|
|
2
2
|
import { HttpRestClient } from '@injectivelabs/utils';
|
|
3
3
|
import { AccountAddress, EthereumChainId } from '@injectivelabs/ts-types';
|
|
4
|
-
import { StdSignDoc, TurnkeyProvider, WalletDeviceType, type WalletMetadata, BaseConcreteStrategy, ConcreteWalletStrategy, SendTransactionOptions, ConcreteEthereumWalletStrategyArgs } from '@injectivelabs/wallet-base';
|
|
5
|
-
import { TurnkeyWallet } from '../turnkey/turnkey.js';
|
|
6
4
|
import { TurnkeyIframeClient } from '@turnkey/sdk-browser';
|
|
7
|
-
|
|
5
|
+
import { StdSignDoc, WalletDeviceType, type WalletMetadata, BaseConcreteStrategy, ConcreteWalletStrategy, SendTransactionOptions, ConcreteEthereumWalletStrategyArgs } from '@injectivelabs/wallet-base';
|
|
6
|
+
import { TurnkeyWallet } from './turnkey/turnkey.js';
|
|
7
|
+
export declare class TurnkeyWalletStrategy extends BaseConcreteStrategy implements ConcreteWalletStrategy {
|
|
8
8
|
turnkeyWallet: TurnkeyWallet | undefined;
|
|
9
|
-
turnkeyProvider: TurnkeyProvider;
|
|
10
9
|
client: HttpRestClient;
|
|
11
10
|
constructor(args: ConcreteEthereumWalletStrategyArgs & {
|
|
12
|
-
provider: TurnkeyProvider;
|
|
13
11
|
apiServerEndpoint?: string;
|
|
14
12
|
});
|
|
15
13
|
getWalletDeviceType(): Promise<WalletDeviceType>;
|
|
16
14
|
setMetadata(metadata?: {
|
|
17
15
|
turnkey?: Partial<WalletMetadata['turnkey']>;
|
|
18
16
|
}): void;
|
|
19
|
-
private setOrganizationId;
|
|
20
17
|
enable(): Promise<boolean>;
|
|
21
18
|
disconnect(): Promise<void>;
|
|
22
19
|
getAddresses(): Promise<string[]>;
|
|
23
|
-
getSessionOrConfirm(): Promise<string>;
|
|
20
|
+
getSessionOrConfirm(_address?: string): Promise<string>;
|
|
21
|
+
getWalletClient<TurnkeyWallet>(): Promise<TurnkeyWallet>;
|
|
24
22
|
sendEthereumTransaction(_transaction: unknown, _options: {
|
|
25
23
|
address: AccountAddress;
|
|
26
24
|
ethereumChainId: EthereumChainId;
|
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
/* eslint-disable class-methods-use-this */
|
|
2
|
-
import { ErrorType, WalletException, UnspecifiedErrorCode, TransactionException, CosmosWalletException, } from '@injectivelabs/exceptions';
|
|
3
2
|
import { TxGrpcApi, } from '@injectivelabs/sdk-ts';
|
|
4
|
-
import {
|
|
5
|
-
import { WalletAction, TurnkeyProvider, WalletDeviceType, BaseConcreteStrategy, } from '@injectivelabs/wallet-base';
|
|
6
|
-
import { TurnkeyWallet } from '../turnkey/turnkey.js';
|
|
7
|
-
import { TurnkeyErrorCodes } from '../types.js';
|
|
8
|
-
import { TurnkeyOtpWallet } from '../turnkey/otp.js';
|
|
9
|
-
import { TurnkeyOauthWallet } from '../turnkey/oauth.js';
|
|
10
|
-
import { SessionType } from '@turnkey/sdk-browser';
|
|
3
|
+
import { ErrorType, WalletException, UnspecifiedErrorCode, TransactionException, CosmosWalletException, } from '@injectivelabs/exceptions';
|
|
11
4
|
import { getAddress } from 'viem';
|
|
12
|
-
import {
|
|
13
|
-
|
|
5
|
+
import { HttpRestClient } from '@injectivelabs/utils';
|
|
6
|
+
import { WalletAction, WalletDeviceType, BaseConcreteStrategy, } from '@injectivelabs/wallet-base';
|
|
7
|
+
import { TurnkeyErrorCodes } from './types.js';
|
|
8
|
+
import { TurnkeyWallet } from './turnkey/turnkey.js';
|
|
9
|
+
export class TurnkeyWalletStrategy extends BaseConcreteStrategy {
|
|
14
10
|
turnkeyWallet;
|
|
15
|
-
turnkeyProvider;
|
|
16
11
|
client;
|
|
17
12
|
constructor(args) {
|
|
18
13
|
super(args);
|
|
19
|
-
this.turnkeyProvider = args.provider;
|
|
20
14
|
const endpoint = args.apiServerEndpoint || this.metadata?.turnkey?.apiServerEndpoint;
|
|
21
15
|
if (!endpoint) {
|
|
22
16
|
throw new WalletException(new Error('apiServerEndpoint is required'));
|
|
@@ -35,13 +29,9 @@ export class BaseTurnkeyWalletStrategy extends BaseConcreteStrategy {
|
|
|
35
29
|
...metadata.turnkey,
|
|
36
30
|
},
|
|
37
31
|
};
|
|
32
|
+
this.turnkeyWallet?.setMetadata(this.metadata?.turnkey);
|
|
38
33
|
}
|
|
39
34
|
}
|
|
40
|
-
//? This is here specifically because we have to ensure we set the organizationId on TurnkeyWallet as well
|
|
41
|
-
setOrganizationId(organizationId) {
|
|
42
|
-
this.setMetadata({ turnkey: { organizationId } });
|
|
43
|
-
this.turnkeyWallet?.setMetadata({ organizationId });
|
|
44
|
-
}
|
|
45
35
|
async enable() {
|
|
46
36
|
const turnkeyWallet = await this.getTurnkeyWallet();
|
|
47
37
|
try {
|
|
@@ -70,48 +60,7 @@ export class BaseTurnkeyWalletStrategy extends BaseConcreteStrategy {
|
|
|
70
60
|
}
|
|
71
61
|
async getAddresses() {
|
|
72
62
|
const turnkeyWallet = await this.getTurnkeyWallet();
|
|
73
|
-
|
|
74
|
-
// CHeck if the user is already connected
|
|
75
|
-
const session = await turnkeyWallet.getSession();
|
|
76
|
-
if (!session.session) {
|
|
77
|
-
const iframeClient = await turnkeyWallet.getIframeClient();
|
|
78
|
-
// Check the provider type and perform auth step accordingly
|
|
79
|
-
if (this.turnkeyProvider === TurnkeyProvider.Email) {
|
|
80
|
-
if (!this.metadata?.turnkey?.otpId) {
|
|
81
|
-
throw new WalletException(new Error('OTP ID is required'));
|
|
82
|
-
}
|
|
83
|
-
if (!this.metadata?.turnkey?.otpCode) {
|
|
84
|
-
throw new WalletException(new Error('OTP code is required'));
|
|
85
|
-
}
|
|
86
|
-
const result = await TurnkeyOtpWallet.confirmEmailOTP({
|
|
87
|
-
iframeClient,
|
|
88
|
-
organizationId,
|
|
89
|
-
client: this.client,
|
|
90
|
-
otpCode: this.metadata?.turnkey?.otpCode,
|
|
91
|
-
emailOTPId: this.metadata?.turnkey?.otpId,
|
|
92
|
-
});
|
|
93
|
-
if (result?.credentialBundle) {
|
|
94
|
-
this.metadata.turnkey.credentialBundle = result.credentialBundle;
|
|
95
|
-
await turnkeyWallet.injectAndRefresh(result.credentialBundle);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
if (!this.metadata?.turnkey?.oidcToken) {
|
|
100
|
-
throw new WalletException(new Error('Oidc token is required'));
|
|
101
|
-
}
|
|
102
|
-
const result = await TurnkeyOauthWallet.oauthLogin({
|
|
103
|
-
client: this.client,
|
|
104
|
-
iframeClient,
|
|
105
|
-
oidcToken: this.metadata?.turnkey?.oidcToken,
|
|
106
|
-
providerName: this.turnkeyProvider.toString(),
|
|
107
|
-
});
|
|
108
|
-
if (result?.credentialBundle) {
|
|
109
|
-
this.metadata.turnkey.organizationId = result.organizationId;
|
|
110
|
-
this.metadata.turnkey.credentialBundle = result.credentialBundle;
|
|
111
|
-
await turnkeyWallet.injectAndRefresh(result.credentialBundle);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
63
|
+
await turnkeyWallet.getSession();
|
|
115
64
|
try {
|
|
116
65
|
return await turnkeyWallet.getAccounts();
|
|
117
66
|
}
|
|
@@ -127,82 +76,12 @@ export class BaseTurnkeyWalletStrategy extends BaseConcreteStrategy {
|
|
|
127
76
|
});
|
|
128
77
|
}
|
|
129
78
|
}
|
|
130
|
-
async getSessionOrConfirm() {
|
|
131
|
-
const { turnkeyProvider, metadata, client } = this;
|
|
79
|
+
async getSessionOrConfirm(_address) {
|
|
132
80
|
const turnkeyWallet = await this.getTurnkeyWallet();
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
!this.metadata?.turnkey?.email &&
|
|
138
|
-
!this.metadata?.turnkey?.oidcToken &&
|
|
139
|
-
session.session?.token) {
|
|
140
|
-
await iframeClient.injectCredentialBundle(session.session?.token);
|
|
141
|
-
this.setOrganizationId(session.organizationId);
|
|
142
|
-
await iframeClient.refreshSession({
|
|
143
|
-
sessionType: SessionType.READ_WRITE,
|
|
144
|
-
targetPublicKey: iframeClient.iframePublicKey,
|
|
145
|
-
expirationSeconds: '900',
|
|
146
|
-
});
|
|
147
|
-
return session.session.token;
|
|
148
|
-
}
|
|
149
|
-
if (turnkeyProvider === TurnkeyProvider.Email) {
|
|
150
|
-
if (!metadata?.turnkey?.email) {
|
|
151
|
-
throw new WalletException(new Error('Email is required'));
|
|
152
|
-
}
|
|
153
|
-
const result = await TurnkeyOtpWallet.initEmailOTP({
|
|
154
|
-
client,
|
|
155
|
-
iframeClient,
|
|
156
|
-
email: metadata.turnkey.email,
|
|
157
|
-
otpInitPath: metadata.turnkey.otpInitPath,
|
|
158
|
-
});
|
|
159
|
-
if (result?.organizationId && this.metadata?.turnkey) {
|
|
160
|
-
this.metadata.turnkey.organizationId = result.organizationId;
|
|
161
|
-
}
|
|
162
|
-
if (result?.otpId && this.metadata?.turnkey) {
|
|
163
|
-
this.metadata.turnkey.otpId = result.otpId;
|
|
164
|
-
}
|
|
165
|
-
return result?.otpId || '';
|
|
166
|
-
}
|
|
167
|
-
if ([TurnkeyProvider.Google, TurnkeyProvider.Apple].includes(turnkeyProvider)) {
|
|
168
|
-
if (metadata?.turnkey?.oidcToken) {
|
|
169
|
-
const oauthResult = await TurnkeyOauthWallet.oauthLogin({
|
|
170
|
-
client,
|
|
171
|
-
iframeClient,
|
|
172
|
-
oidcToken: metadata.turnkey.oidcToken,
|
|
173
|
-
providerName: turnkeyProvider.toString(),
|
|
174
|
-
oauthLoginPath: metadata.turnkey.oauthLoginPath,
|
|
175
|
-
});
|
|
176
|
-
if (oauthResult?.credentialBundle) {
|
|
177
|
-
await turnkeyWallet.injectAndRefresh(oauthResult.credentialBundle);
|
|
178
|
-
}
|
|
179
|
-
if (oauthResult?.credentialBundle) {
|
|
180
|
-
const session = await turnkeyWallet.getSession();
|
|
181
|
-
if (this.metadata?.turnkey && session.organizationId) {
|
|
182
|
-
this.metadata.turnkey.organizationId = session.organizationId;
|
|
183
|
-
}
|
|
184
|
-
return oauthResult.credentialBundle;
|
|
185
|
-
}
|
|
186
|
-
throw new WalletException(new Error('Oauth result not found'));
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
const nonce = await TurnkeyOauthWallet.generateOAuthNonce(iframeClient);
|
|
190
|
-
if (!metadata?.turnkey?.googleClientId ||
|
|
191
|
-
!metadata?.turnkey?.googleRedirectUri) {
|
|
192
|
-
throw new WalletException(new Error('googleClientId and googleRedirectUri are required'));
|
|
193
|
-
}
|
|
194
|
-
if (turnkeyProvider === TurnkeyProvider.Google) {
|
|
195
|
-
return generateGoogleUrl({
|
|
196
|
-
nonce,
|
|
197
|
-
clientId: metadata.turnkey.googleClientId,
|
|
198
|
-
redirectUri: metadata.turnkey.googleRedirectUri,
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
//? When we add Apple support, we might also want to return the URL as well
|
|
202
|
-
return nonce;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
return '';
|
|
81
|
+
return await turnkeyWallet.refreshSession();
|
|
82
|
+
}
|
|
83
|
+
async getWalletClient() {
|
|
84
|
+
return (await this.getTurnkeyWallet());
|
|
206
85
|
}
|
|
207
86
|
async sendEthereumTransaction(_transaction, _options) {
|
|
208
87
|
throw new WalletException(new Error('sendEthereumTransaction is not supported. Turnkey only supports sending cosmos transactions'), {
|
|
@@ -6,9 +6,9 @@ export declare class TurnkeyOauthWallet {
|
|
|
6
6
|
oidcToken: string;
|
|
7
7
|
client: HttpRestClient;
|
|
8
8
|
oauthLoginPath?: string;
|
|
9
|
-
expirationSeconds?: number;
|
|
10
9
|
providerName: 'google' | 'apple';
|
|
11
10
|
iframeClient: TurnkeyIframeClient;
|
|
11
|
+
expirationSeconds?: number;
|
|
12
12
|
}): Promise<{
|
|
13
13
|
organizationId: string;
|
|
14
14
|
credentialBundle: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ErrorType, WalletException, UnspecifiedErrorCode, } from '@injectivelabs/exceptions';
|
|
2
2
|
import { sha256 } from '@injectivelabs/sdk-ts';
|
|
3
|
-
import { TURNKEY_OAUTH_PATH } from '../consts.js';
|
|
3
|
+
import { DEFAULT_TURNKEY_REFRESH_SECONDS, TURNKEY_OAUTH_PATH, } from '../consts.js';
|
|
4
4
|
export class TurnkeyOauthWallet {
|
|
5
5
|
static async generateOAuthNonce(iframeClient) {
|
|
6
6
|
try {
|
|
@@ -21,7 +21,7 @@ export class TurnkeyOauthWallet {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
static async oauthLogin(args) {
|
|
24
|
-
const { client, iframeClient } = args;
|
|
24
|
+
const { client, iframeClient, expirationSeconds } = args;
|
|
25
25
|
const path = args.oauthLoginPath || TURNKEY_OAUTH_PATH;
|
|
26
26
|
try {
|
|
27
27
|
const targetPublicKey = iframeClient.iframePublicKey;
|
|
@@ -33,6 +33,7 @@ export class TurnkeyOauthWallet {
|
|
|
33
33
|
targetPublicKey,
|
|
34
34
|
oidcToken: args.oidcToken,
|
|
35
35
|
providerName: args.providerName,
|
|
36
|
+
expirationSeconds: (expirationSeconds || DEFAULT_TURNKEY_REFRESH_SECONDS)?.toString(),
|
|
36
37
|
});
|
|
37
38
|
return response.data;
|
|
38
39
|
}
|
|
@@ -12,10 +12,11 @@ export declare class TurnkeyOtpWallet {
|
|
|
12
12
|
}): Promise<TurnkeyOTPCredentialsResponse | undefined>;
|
|
13
13
|
static confirmEmailOTP(args: {
|
|
14
14
|
otpCode: string;
|
|
15
|
-
emailOTPId
|
|
15
|
+
emailOTPId: string;
|
|
16
16
|
client: HttpRestClient;
|
|
17
|
-
organizationId
|
|
17
|
+
organizationId: string;
|
|
18
18
|
iframeClient: TurnkeyIframeClient;
|
|
19
19
|
otpVerifyPath?: string;
|
|
20
|
+
expirationSeconds?: number;
|
|
20
21
|
}): Promise<TurnkeyConfirmEmailOTPResponse | undefined>;
|
|
21
22
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ErrorType, WalletException, UnspecifiedErrorCode, } from '@injectivelabs/exceptions';
|
|
2
|
-
import { TURNKEY_OTP_INIT_PATH, TURNKEY_OTP_VERIFY_PATH } from '../consts.js';
|
|
2
|
+
import { DEFAULT_TURNKEY_REFRESH_SECONDS, TURNKEY_OTP_INIT_PATH, TURNKEY_OTP_VERIFY_PATH, } from '../consts.js';
|
|
3
3
|
export class TurnkeyOtpWallet {
|
|
4
4
|
static async initEmailOTP(args) {
|
|
5
5
|
const { client, iframeClient } = args;
|
|
@@ -26,7 +26,7 @@ export class TurnkeyOtpWallet {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
static async confirmEmailOTP(args) {
|
|
29
|
-
const { client, iframeClient } = args;
|
|
29
|
+
const { client, iframeClient, expirationSeconds } = args;
|
|
30
30
|
try {
|
|
31
31
|
const organizationId = args.organizationId;
|
|
32
32
|
const emailOTPId = args.emailOTPId;
|
|
@@ -46,6 +46,7 @@ export class TurnkeyOtpWallet {
|
|
|
46
46
|
otpId: emailOTPId,
|
|
47
47
|
otpCode: args.otpCode,
|
|
48
48
|
suborgID: organizationId,
|
|
49
|
+
expirationSeconds: (expirationSeconds || DEFAULT_TURNKEY_REFRESH_SECONDS)?.toString(),
|
|
49
50
|
});
|
|
50
51
|
return response?.data;
|
|
51
52
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { TurnkeyMetadata } from '@injectivelabs/wallet-base';
|
|
1
|
+
import { TurnkeyMetadata, TurnkeyProvider } from '@injectivelabs/wallet-base';
|
|
3
2
|
import { HttpRestClient } from '@injectivelabs/utils';
|
|
3
|
+
import { Turnkey, TurnkeyIframeClient } from '@turnkey/sdk-browser';
|
|
4
4
|
export declare class TurnkeyWallet {
|
|
5
|
-
protected iframeClient: TurnkeyIframeClient | undefined;
|
|
6
|
-
protected turnkey: Turnkey | undefined;
|
|
7
5
|
protected client: HttpRestClient;
|
|
8
6
|
private metadata;
|
|
7
|
+
protected turnkey: Turnkey | undefined;
|
|
8
|
+
protected iframeClient: TurnkeyIframeClient | undefined;
|
|
9
|
+
organizationId: string;
|
|
10
|
+
private otpId;
|
|
9
11
|
private accountMap;
|
|
10
12
|
setMetadata(metadata: Partial<TurnkeyMetadata>): void;
|
|
11
13
|
constructor(metadata: TurnkeyMetadata);
|
|
@@ -20,7 +22,7 @@ export declare class TurnkeyWallet {
|
|
|
20
22
|
organizationId: string;
|
|
21
23
|
}>;
|
|
22
24
|
getAccounts(): Promise<string[]>;
|
|
23
|
-
getOrCreateAndGetAccount(address: string, organizationId
|
|
25
|
+
getOrCreateAndGetAccount(address: string, organizationId: string): Promise<{
|
|
24
26
|
address: import("abitype").Address;
|
|
25
27
|
nonceManager?: import("viem").NonceManager | undefined;
|
|
26
28
|
sign?: ((parameters: {
|
|
@@ -38,6 +40,14 @@ export declare class TurnkeyWallet {
|
|
|
38
40
|
source: string;
|
|
39
41
|
type: "local";
|
|
40
42
|
}>;
|
|
41
|
-
injectAndRefresh(credentialBundle: string
|
|
43
|
+
injectAndRefresh(credentialBundle: string, options: {
|
|
44
|
+
expirationSeconds?: string;
|
|
45
|
+
organizationId?: string;
|
|
46
|
+
}): Promise<void>;
|
|
47
|
+
initOTP(email: string): Promise<import("../types.js").TurnkeyOTPCredentialsResponse>;
|
|
48
|
+
confirmOTP(otpCode: string): Promise<import("../types.js").TurnkeyConfirmEmailOTPResponse>;
|
|
49
|
+
initOAuth(provider: TurnkeyProvider.Google | TurnkeyProvider.Apple): Promise<string>;
|
|
50
|
+
confirmOAuth(provider: TurnkeyProvider.Google | TurnkeyProvider.Apple, oidcToken: string): Promise<string>;
|
|
51
|
+
refreshSession(): Promise<string>;
|
|
42
52
|
private initFrame;
|
|
43
53
|
}
|
|
@@ -1,21 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { WalletAction } from '@injectivelabs/wallet-base';
|
|
4
|
-
import { getInjectiveAddress } from '@injectivelabs/sdk-ts';
|
|
5
|
-
import { HttpRestClient } from '@injectivelabs/utils';
|
|
1
|
+
import { ErrorType, WalletException, GeneralException, UnspecifiedErrorCode, TurnkeyWalletSessionException, } from '@injectivelabs/exceptions';
|
|
2
|
+
import { WalletAction, TurnkeyProvider, } from '@injectivelabs/wallet-base';
|
|
6
3
|
import { createAccount } from '@turnkey/viem';
|
|
4
|
+
import { HttpRestClient } from '@injectivelabs/utils';
|
|
5
|
+
import { getInjectiveAddress } from '@injectivelabs/sdk-ts';
|
|
6
|
+
import { Turnkey, SessionType } from '@turnkey/sdk-browser';
|
|
7
|
+
import { TURNKEY_OAUTH_PATH, TURNKEY_OTP_INIT_PATH, TURNKEY_OTP_VERIFY_PATH, DEFAULT_TURNKEY_REFRESH_SECONDS, } from '../consts.js';
|
|
8
|
+
import { TurnkeyOtpWallet } from './otp.js';
|
|
7
9
|
import { TurnkeyErrorCodes } from '../types.js';
|
|
10
|
+
import { TurnkeyOauthWallet } from './oauth.js';
|
|
11
|
+
import { generateGoogleUrl } from '../../utils.js';
|
|
8
12
|
export class TurnkeyWallet {
|
|
9
|
-
iframeClient;
|
|
10
|
-
turnkey;
|
|
11
13
|
client;
|
|
12
14
|
metadata;
|
|
15
|
+
turnkey;
|
|
16
|
+
iframeClient;
|
|
17
|
+
organizationId;
|
|
18
|
+
otpId;
|
|
13
19
|
accountMap = {};
|
|
14
20
|
setMetadata(metadata) {
|
|
15
21
|
this.metadata = { ...this.metadata, ...metadata };
|
|
16
22
|
}
|
|
17
23
|
constructor(metadata) {
|
|
18
24
|
this.metadata = metadata;
|
|
25
|
+
this.organizationId = metadata.organizationId;
|
|
19
26
|
this.client = new HttpRestClient(metadata.apiServerEndpoint);
|
|
20
27
|
}
|
|
21
28
|
static async getTurnkeyInstance(metadata) {
|
|
@@ -90,16 +97,16 @@ export class TurnkeyWallet {
|
|
|
90
97
|
}
|
|
91
98
|
async getAccounts() {
|
|
92
99
|
const iframeClient = await this.getIframeClient();
|
|
93
|
-
if (!this.
|
|
100
|
+
if (!this.organizationId) {
|
|
94
101
|
return [];
|
|
95
102
|
}
|
|
96
103
|
try {
|
|
97
104
|
const response = await iframeClient.getWallets({
|
|
98
|
-
organizationId: this.
|
|
105
|
+
organizationId: this.organizationId,
|
|
99
106
|
});
|
|
100
107
|
const accounts = await Promise.allSettled(response.wallets.map((wallet) => iframeClient.getWalletAccounts({
|
|
101
108
|
walletId: wallet.walletId,
|
|
102
|
-
organizationId: this.
|
|
109
|
+
organizationId: this.organizationId,
|
|
103
110
|
})));
|
|
104
111
|
const filteredAccounts = accounts
|
|
105
112
|
.filter((account) => account.status === 'fulfilled')
|
|
@@ -146,16 +153,116 @@ export class TurnkeyWallet {
|
|
|
146
153
|
this.accountMap[address] = turnkeyAccount;
|
|
147
154
|
return turnkeyAccount;
|
|
148
155
|
}
|
|
149
|
-
async injectAndRefresh(credentialBundle) {
|
|
156
|
+
async injectAndRefresh(credentialBundle, options) {
|
|
157
|
+
const expirationSeconds = options.expirationSeconds || DEFAULT_TURNKEY_REFRESH_SECONDS;
|
|
150
158
|
const iframeClient = await this.getIframeClient();
|
|
151
159
|
await iframeClient.injectCredentialBundle(credentialBundle);
|
|
152
160
|
await iframeClient.refreshSession({
|
|
153
161
|
sessionType: SessionType.READ_WRITE,
|
|
154
162
|
targetPublicKey: iframeClient.iframePublicKey,
|
|
155
|
-
expirationSeconds
|
|
163
|
+
expirationSeconds,
|
|
156
164
|
});
|
|
165
|
+
const session = await this.turnkey?.getSession();
|
|
166
|
+
if (!session) {
|
|
167
|
+
throw new WalletException(new Error('Failed to refresh session'));
|
|
168
|
+
}
|
|
169
|
+
this.organizationId = session.organizationId;
|
|
170
|
+
this.metadata.organizationId = session.organizationId;
|
|
171
|
+
// Refresh the session 2 minutes before it expires
|
|
172
|
+
setTimeout(() => {
|
|
173
|
+
iframeClient.refreshSession({
|
|
174
|
+
expirationSeconds: session?.expiry,
|
|
175
|
+
sessionType: SessionType.READ_WRITE,
|
|
176
|
+
targetPublicKey: iframeClient.iframePublicKey,
|
|
177
|
+
});
|
|
178
|
+
}, (parseInt(expirationSeconds) - 120) * 1000);
|
|
157
179
|
return;
|
|
158
180
|
}
|
|
181
|
+
async initOTP(email) {
|
|
182
|
+
const iframeClient = await this.getIframeClient();
|
|
183
|
+
const result = await TurnkeyOtpWallet.initEmailOTP({
|
|
184
|
+
client: this.client,
|
|
185
|
+
iframeClient,
|
|
186
|
+
email,
|
|
187
|
+
otpInitPath: this.metadata.otpInitPath || TURNKEY_OTP_INIT_PATH,
|
|
188
|
+
});
|
|
189
|
+
if (!result || !result.otpId) {
|
|
190
|
+
throw new WalletException(new Error('Failed to initialize OTP'));
|
|
191
|
+
}
|
|
192
|
+
if (result?.organizationId) {
|
|
193
|
+
this.organizationId = result.organizationId;
|
|
194
|
+
}
|
|
195
|
+
if (result?.otpId) {
|
|
196
|
+
this.otpId = result.otpId;
|
|
197
|
+
}
|
|
198
|
+
return result;
|
|
199
|
+
}
|
|
200
|
+
async confirmOTP(otpCode) {
|
|
201
|
+
const iframeClient = await this.getIframeClient();
|
|
202
|
+
if (!this.otpId) {
|
|
203
|
+
throw new WalletException(new Error('OTP ID is required'));
|
|
204
|
+
}
|
|
205
|
+
const result = await TurnkeyOtpWallet.confirmEmailOTP({
|
|
206
|
+
otpCode,
|
|
207
|
+
iframeClient,
|
|
208
|
+
client: this.client,
|
|
209
|
+
emailOTPId: this.otpId,
|
|
210
|
+
organizationId: this.organizationId,
|
|
211
|
+
otpVerifyPath: this.metadata.otpVerifyPath || TURNKEY_OTP_VERIFY_PATH,
|
|
212
|
+
});
|
|
213
|
+
if (!result || !result.credentialBundle) {
|
|
214
|
+
throw new WalletException(new Error('Failed to confirm OTP'));
|
|
215
|
+
}
|
|
216
|
+
await this.injectAndRefresh(result.credentialBundle, {
|
|
217
|
+
organizationId: result.organizationId,
|
|
218
|
+
expirationSeconds: this.metadata.expirationSeconds,
|
|
219
|
+
});
|
|
220
|
+
return result;
|
|
221
|
+
}
|
|
222
|
+
async initOAuth(provider) {
|
|
223
|
+
const iframeClient = await this.getIframeClient();
|
|
224
|
+
const nonce = await TurnkeyOauthWallet.generateOAuthNonce(iframeClient);
|
|
225
|
+
if (provider === TurnkeyProvider.Apple) {
|
|
226
|
+
// TODO: implement the ability to generate Apple OAuth URL
|
|
227
|
+
return nonce;
|
|
228
|
+
}
|
|
229
|
+
if (!this.metadata?.googleClientId || !this.metadata?.googleRedirectUri) {
|
|
230
|
+
throw new WalletException(new Error('googleClientId and googleRedirectUri are required'));
|
|
231
|
+
}
|
|
232
|
+
return generateGoogleUrl({
|
|
233
|
+
nonce,
|
|
234
|
+
clientId: this.metadata.googleClientId,
|
|
235
|
+
redirectUri: this.metadata.googleRedirectUri,
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
async confirmOAuth(provider, oidcToken) {
|
|
239
|
+
const iframeClient = await this.getIframeClient();
|
|
240
|
+
const oauthResult = await TurnkeyOauthWallet.oauthLogin({
|
|
241
|
+
oidcToken,
|
|
242
|
+
iframeClient,
|
|
243
|
+
client: this.client,
|
|
244
|
+
providerName: provider.toString(),
|
|
245
|
+
oauthLoginPath: this.metadata.oauthLoginPath || TURNKEY_OAUTH_PATH,
|
|
246
|
+
});
|
|
247
|
+
if (!oauthResult || !oauthResult.credentialBundle) {
|
|
248
|
+
throw new WalletException(new Error('Unexpected OAuth result'));
|
|
249
|
+
}
|
|
250
|
+
await this.injectAndRefresh(oauthResult.credentialBundle, {
|
|
251
|
+
organizationId: oauthResult.organizationId,
|
|
252
|
+
expirationSeconds: this.metadata.expirationSeconds,
|
|
253
|
+
});
|
|
254
|
+
return oauthResult.credentialBundle;
|
|
255
|
+
}
|
|
256
|
+
async refreshSession() {
|
|
257
|
+
const session = await this.getSession();
|
|
258
|
+
if (session.session?.token) {
|
|
259
|
+
await this.injectAndRefresh(session.session.token, {
|
|
260
|
+
expirationSeconds: this.metadata.expirationSeconds || DEFAULT_TURNKEY_REFRESH_SECONDS,
|
|
261
|
+
});
|
|
262
|
+
return session.session.token;
|
|
263
|
+
}
|
|
264
|
+
throw new TurnkeyWalletSessionException(new Error('Session expired. Please login again.'));
|
|
265
|
+
}
|
|
159
266
|
async initFrame() {
|
|
160
267
|
const { metadata } = this;
|
|
161
268
|
const { turnkey, iframeClient } = await createTurnkeyIFrame(metadata);
|
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.15.
|
|
4
|
+
"version": "1.15.19",
|
|
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.15.
|
|
63
|
-
"@injectivelabs/sdk-ts": "^1.15.
|
|
64
|
-
"@injectivelabs/ts-types": "^1.15.
|
|
65
|
-
"@injectivelabs/utils": "^1.15.
|
|
66
|
-
"@injectivelabs/wallet-base": "^1.15.
|
|
62
|
+
"@injectivelabs/exceptions": "^1.15.16",
|
|
63
|
+
"@injectivelabs/sdk-ts": "^1.15.19",
|
|
64
|
+
"@injectivelabs/ts-types": "^1.15.17",
|
|
65
|
+
"@injectivelabs/utils": "^1.15.17",
|
|
66
|
+
"@injectivelabs/wallet-base": "^1.15.19",
|
|
67
67
|
"@turnkey/sdk-browser": "^4.1.0",
|
|
68
68
|
"@turnkey/viem": "^0.9.0",
|
|
69
69
|
"viem": "^2.28.1"
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"tsconfig-paths": "^4.2.0",
|
|
78
78
|
"typescript": "^5.0.0"
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "fdf4de5ba62e2cd9fa95daba61a327d9a0b2a037"
|
|
81
81
|
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { BaseTurnkeyWalletStrategy } from './base.js';
|
|
2
|
-
import { ConcreteEthereumWalletStrategyArgs } from '@injectivelabs/wallet-base';
|
|
3
|
-
export declare class TurnkeyOauthWalletStrategy extends BaseTurnkeyWalletStrategy {
|
|
4
|
-
constructor(args: ConcreteEthereumWalletStrategyArgs);
|
|
5
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TurnkeyOauthWalletStrategy = void 0;
|
|
4
|
-
const base_js_1 = require("./base.js");
|
|
5
|
-
const wallet_base_1 = require("@injectivelabs/wallet-base");
|
|
6
|
-
class TurnkeyOauthWalletStrategy extends base_js_1.BaseTurnkeyWalletStrategy {
|
|
7
|
-
constructor(args) {
|
|
8
|
-
super({
|
|
9
|
-
...args,
|
|
10
|
-
provider: wallet_base_1.TurnkeyProvider.Google,
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.TurnkeyOauthWalletStrategy = TurnkeyOauthWalletStrategy;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { BaseTurnkeyWalletStrategy } from './base.js';
|
|
2
|
-
import { ConcreteEthereumWalletStrategyArgs } from '@injectivelabs/wallet-base';
|
|
3
|
-
export declare class TurnkeyOtpWalletStrategy extends BaseTurnkeyWalletStrategy {
|
|
4
|
-
constructor(args: ConcreteEthereumWalletStrategyArgs);
|
|
5
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TurnkeyOtpWalletStrategy = void 0;
|
|
4
|
-
const base_js_1 = require("./base.js");
|
|
5
|
-
const wallet_base_1 = require("@injectivelabs/wallet-base");
|
|
6
|
-
class TurnkeyOtpWalletStrategy extends base_js_1.BaseTurnkeyWalletStrategy {
|
|
7
|
-
constructor(args) {
|
|
8
|
-
super({
|
|
9
|
-
...args,
|
|
10
|
-
provider: wallet_base_1.TurnkeyProvider.Email,
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.TurnkeyOtpWalletStrategy = TurnkeyOtpWalletStrategy;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { BaseTurnkeyWalletStrategy } from './base.js';
|
|
2
|
-
import { ConcreteEthereumWalletStrategyArgs } from '@injectivelabs/wallet-base';
|
|
3
|
-
export declare class TurnkeyOauthWalletStrategy extends BaseTurnkeyWalletStrategy {
|
|
4
|
-
constructor(args: ConcreteEthereumWalletStrategyArgs);
|
|
5
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { BaseTurnkeyWalletStrategy } from './base.js';
|
|
2
|
-
import { TurnkeyProvider, } from '@injectivelabs/wallet-base';
|
|
3
|
-
export class TurnkeyOauthWalletStrategy extends BaseTurnkeyWalletStrategy {
|
|
4
|
-
constructor(args) {
|
|
5
|
-
super({
|
|
6
|
-
...args,
|
|
7
|
-
provider: TurnkeyProvider.Google,
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { BaseTurnkeyWalletStrategy } from './base.js';
|
|
2
|
-
import { ConcreteEthereumWalletStrategyArgs } from '@injectivelabs/wallet-base';
|
|
3
|
-
export declare class TurnkeyOtpWalletStrategy extends BaseTurnkeyWalletStrategy {
|
|
4
|
-
constructor(args: ConcreteEthereumWalletStrategyArgs);
|
|
5
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { BaseTurnkeyWalletStrategy } from './base.js';
|
|
2
|
-
import { TurnkeyProvider } from '@injectivelabs/wallet-base';
|
|
3
|
-
export class TurnkeyOtpWalletStrategy extends BaseTurnkeyWalletStrategy {
|
|
4
|
-
constructor(args) {
|
|
5
|
-
super({
|
|
6
|
-
...args,
|
|
7
|
-
provider: TurnkeyProvider.Email,
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
}
|