@injectivelabs/wallet-turnkey 1.19.19 → 1.19.20
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.cjs +9 -8
- package/dist/cjs/index.d.cts +6 -6
- package/dist/esm/index.d.ts +6 -6
- package/dist/esm/index.js +9 -8
- package/package.json +6 -6
package/dist/cjs/index.cjs
CHANGED
|
@@ -155,9 +155,10 @@ function generateTwitterPkce() {
|
|
|
155
155
|
codeChallenge: sha256ToBase64Url(codeVerifier)
|
|
156
156
|
};
|
|
157
157
|
}
|
|
158
|
-
function generateTwitterUrl({ state, clientId, redirectUri, codeChallenge }) {
|
|
158
|
+
function generateTwitterUrl({ state, nonce, clientId, redirectUri, codeChallenge }) {
|
|
159
159
|
const url = new URL("https://twitter.com/i/oauth2/authorize");
|
|
160
160
|
url.searchParams.set("state", state);
|
|
161
|
+
url.searchParams.set("nonce", nonce);
|
|
161
162
|
url.searchParams.set("client_id", clientId);
|
|
162
163
|
url.searchParams.set("response_type", "code");
|
|
163
164
|
url.searchParams.set("redirect_uri", redirectUri);
|
|
@@ -378,18 +379,20 @@ var TurnkeyWallet = class {
|
|
|
378
379
|
if (provider === __injectivelabs_wallet_base.TurnkeyProvider.Twitter) {
|
|
379
380
|
if (!this.metadata.twitterClientId || !this.metadata.twitterRedirectUri) throw new __injectivelabs_exceptions.WalletException(/* @__PURE__ */ new Error("twitterClientId and twitterRedirectUri are required"));
|
|
380
381
|
const indexedDbClient = await this.getIndexedDbClient();
|
|
381
|
-
await
|
|
382
|
+
const nonce = await TurnkeyOauthWallet.generateOAuthNonce(indexedDbClient);
|
|
382
383
|
const targetPublicKey = await indexedDbClient.getPublicKey();
|
|
383
384
|
if (!targetPublicKey) throw new __injectivelabs_exceptions.WalletException(/* @__PURE__ */ new Error("Target public key is missing. Please ensure your wallet is properly initialized."));
|
|
384
385
|
const { state, codeVerifier, codeChallenge } = generateTwitterPkce();
|
|
385
386
|
return {
|
|
386
387
|
pkce: {
|
|
388
|
+
nonce,
|
|
387
389
|
state,
|
|
388
390
|
codeVerifier,
|
|
389
391
|
targetPublicKey
|
|
390
392
|
},
|
|
391
393
|
url: generateTwitterUrl({
|
|
392
394
|
state,
|
|
395
|
+
nonce,
|
|
393
396
|
codeChallenge,
|
|
394
397
|
clientId: this.metadata.twitterClientId,
|
|
395
398
|
redirectUri: this.metadata.twitterRedirectUri
|
|
@@ -413,24 +416,22 @@ var TurnkeyWallet = class {
|
|
|
413
416
|
this.userOrganizationId = oauthResult.organizationId;
|
|
414
417
|
return oauthResult.credentialBundle;
|
|
415
418
|
}
|
|
416
|
-
async confirmOAuth2({ authCode, codeVerifier, providerName, targetPublicKey }) {
|
|
419
|
+
async confirmOAuth2({ nonce, authCode, codeVerifier, providerName, targetPublicKey }) {
|
|
417
420
|
var _response$data, _response$data2;
|
|
418
421
|
const indexedDbClient = await this.getIndexedDbClient();
|
|
419
422
|
const path = this.metadata.oauth2ExchangePath || "turnkey/oauth2";
|
|
420
423
|
const response = await this.client.post(path, {
|
|
424
|
+
nonce,
|
|
421
425
|
authCode,
|
|
422
426
|
codeVerifier,
|
|
423
427
|
targetPublicKey,
|
|
424
428
|
providerName
|
|
425
429
|
});
|
|
426
430
|
if (!(response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.credentialBundle) || !(response === null || response === void 0 || (_response$data2 = response.data) === null || _response$data2 === void 0 ? void 0 : _response$data2.organizationId)) throw new __injectivelabs_exceptions.WalletException(/* @__PURE__ */ new Error(`${providerName} OAuth2 exchange failed`));
|
|
427
|
-
const { credentialBundle, organizationId
|
|
431
|
+
const { credentialBundle, organizationId } = response.data;
|
|
428
432
|
await indexedDbClient.loginWithSession(credentialBundle);
|
|
429
433
|
this.userOrganizationId = organizationId;
|
|
430
|
-
return
|
|
431
|
-
session: credentialBundle,
|
|
432
|
-
email
|
|
433
|
-
};
|
|
434
|
+
return credentialBundle;
|
|
434
435
|
}
|
|
435
436
|
async refreshSession() {
|
|
436
437
|
var _session$session;
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HttpRestClient } from "@injectivelabs/utils";
|
|
2
|
-
import { BaseConcreteStrategy, ConcreteEvmWalletStrategyArgs, ConcreteWalletStrategy, Eip1193Provider, SendTransactionOptions, StdSignDoc, TurnkeyMetadata, TurnkeyOAuthProvider, WalletDeviceType, WalletMetadata, WalletStrategyEvmOptions } from "@injectivelabs/wallet-base";
|
|
2
|
+
import { BaseConcreteStrategy, ConcreteEvmWalletStrategyArgs, ConcreteWalletStrategy, Eip1193Provider, SendTransactionOptions, StdSignDoc, TurnkeyMetadata, TurnkeyOAuthProvider, TurnkeyProvider, WalletDeviceType, WalletMetadata, WalletStrategyEvmOptions } from "@injectivelabs/wallet-base";
|
|
3
3
|
import { AccountAddress, EvmChainId } from "@injectivelabs/ts-types";
|
|
4
4
|
import * as _turnkey_sdk_browser0 from "@turnkey/sdk-browser";
|
|
5
5
|
import { Turnkey, TurnkeyIndexedDbClient } from "@turnkey/sdk-browser";
|
|
@@ -89,9 +89,10 @@ declare class TurnkeyWallet {
|
|
|
89
89
|
initOTP(email: string): Promise<TurnkeyOTPCredentialsResponse>;
|
|
90
90
|
initSms(phone: string): Promise<TurnkeyOTPCredentialsResponse>;
|
|
91
91
|
confirmOTP(otpCode: string): Promise<TurnkeyConfirmEmailOTPResponse>;
|
|
92
|
-
initOAuth(provider:
|
|
92
|
+
initOAuth(provider: TurnkeyProvider): Promise<string>;
|
|
93
93
|
initOAuth2(provider: TurnkeyOAuthProvider): Promise<{
|
|
94
94
|
pkce: {
|
|
95
|
+
nonce: string;
|
|
95
96
|
state: string;
|
|
96
97
|
codeVerifier: string;
|
|
97
98
|
targetPublicKey: string;
|
|
@@ -100,19 +101,18 @@ declare class TurnkeyWallet {
|
|
|
100
101
|
}>;
|
|
101
102
|
confirmOAuth(provider: TurnkeyOAuthProvider, oidcToken: string): Promise<string>;
|
|
102
103
|
confirmOAuth2({
|
|
104
|
+
nonce,
|
|
103
105
|
authCode,
|
|
104
106
|
codeVerifier,
|
|
105
107
|
providerName,
|
|
106
108
|
targetPublicKey
|
|
107
109
|
}: {
|
|
110
|
+
nonce: string;
|
|
108
111
|
authCode: string;
|
|
109
112
|
codeVerifier: string;
|
|
110
113
|
targetPublicKey: string;
|
|
111
114
|
providerName: TurnkeyOAuthProvider;
|
|
112
|
-
}): Promise<
|
|
113
|
-
session: string;
|
|
114
|
-
email: string | undefined;
|
|
115
|
-
}>;
|
|
115
|
+
}): Promise<string>;
|
|
116
116
|
refreshSession(): Promise<string>;
|
|
117
117
|
private initClient;
|
|
118
118
|
}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HttpRestClient } from "@injectivelabs/utils";
|
|
2
|
-
import { BaseConcreteStrategy, ConcreteEvmWalletStrategyArgs, ConcreteWalletStrategy, Eip1193Provider, SendTransactionOptions, StdSignDoc, TurnkeyMetadata, TurnkeyOAuthProvider, WalletDeviceType, WalletMetadata, WalletStrategyEvmOptions } from "@injectivelabs/wallet-base";
|
|
2
|
+
import { BaseConcreteStrategy, ConcreteEvmWalletStrategyArgs, ConcreteWalletStrategy, Eip1193Provider, SendTransactionOptions, StdSignDoc, TurnkeyMetadata, TurnkeyOAuthProvider, TurnkeyProvider, WalletDeviceType, WalletMetadata, WalletStrategyEvmOptions } from "@injectivelabs/wallet-base";
|
|
3
3
|
import { createAccount } from "@turnkey/viem";
|
|
4
4
|
import * as _turnkey_sdk_browser0 from "@turnkey/sdk-browser";
|
|
5
5
|
import { Turnkey, TurnkeyIndexedDbClient } from "@turnkey/sdk-browser";
|
|
@@ -89,9 +89,10 @@ declare class TurnkeyWallet {
|
|
|
89
89
|
initOTP(email: string): Promise<TurnkeyOTPCredentialsResponse>;
|
|
90
90
|
initSms(phone: string): Promise<TurnkeyOTPCredentialsResponse>;
|
|
91
91
|
confirmOTP(otpCode: string): Promise<TurnkeyConfirmEmailOTPResponse>;
|
|
92
|
-
initOAuth(provider:
|
|
92
|
+
initOAuth(provider: TurnkeyProvider): Promise<string>;
|
|
93
93
|
initOAuth2(provider: TurnkeyOAuthProvider): Promise<{
|
|
94
94
|
pkce: {
|
|
95
|
+
nonce: string;
|
|
95
96
|
state: string;
|
|
96
97
|
codeVerifier: string;
|
|
97
98
|
targetPublicKey: string;
|
|
@@ -100,19 +101,18 @@ declare class TurnkeyWallet {
|
|
|
100
101
|
}>;
|
|
101
102
|
confirmOAuth(provider: TurnkeyOAuthProvider, oidcToken: string): Promise<string>;
|
|
102
103
|
confirmOAuth2({
|
|
104
|
+
nonce,
|
|
103
105
|
authCode,
|
|
104
106
|
codeVerifier,
|
|
105
107
|
providerName,
|
|
106
108
|
targetPublicKey
|
|
107
109
|
}: {
|
|
110
|
+
nonce: string;
|
|
108
111
|
authCode: string;
|
|
109
112
|
codeVerifier: string;
|
|
110
113
|
targetPublicKey: string;
|
|
111
114
|
providerName: TurnkeyOAuthProvider;
|
|
112
|
-
}): Promise<
|
|
113
|
-
session: string;
|
|
114
|
-
email: string | undefined;
|
|
115
|
-
}>;
|
|
115
|
+
}): Promise<string>;
|
|
116
116
|
refreshSession(): Promise<string>;
|
|
117
117
|
private initClient;
|
|
118
118
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -155,9 +155,10 @@ function generateTwitterPkce() {
|
|
|
155
155
|
codeChallenge: sha256ToBase64Url(codeVerifier)
|
|
156
156
|
};
|
|
157
157
|
}
|
|
158
|
-
function generateTwitterUrl({ state, clientId, redirectUri, codeChallenge }) {
|
|
158
|
+
function generateTwitterUrl({ state, nonce, clientId, redirectUri, codeChallenge }) {
|
|
159
159
|
const url = new URL("https://twitter.com/i/oauth2/authorize");
|
|
160
160
|
url.searchParams.set("state", state);
|
|
161
|
+
url.searchParams.set("nonce", nonce);
|
|
161
162
|
url.searchParams.set("client_id", clientId);
|
|
162
163
|
url.searchParams.set("response_type", "code");
|
|
163
164
|
url.searchParams.set("redirect_uri", redirectUri);
|
|
@@ -378,18 +379,20 @@ var TurnkeyWallet = class {
|
|
|
378
379
|
if (provider === TurnkeyProvider.Twitter) {
|
|
379
380
|
if (!this.metadata.twitterClientId || !this.metadata.twitterRedirectUri) throw new WalletException(/* @__PURE__ */ new Error("twitterClientId and twitterRedirectUri are required"));
|
|
380
381
|
const indexedDbClient = await this.getIndexedDbClient();
|
|
381
|
-
await
|
|
382
|
+
const nonce = await TurnkeyOauthWallet.generateOAuthNonce(indexedDbClient);
|
|
382
383
|
const targetPublicKey = await indexedDbClient.getPublicKey();
|
|
383
384
|
if (!targetPublicKey) throw new WalletException(/* @__PURE__ */ new Error("Target public key is missing. Please ensure your wallet is properly initialized."));
|
|
384
385
|
const { state, codeVerifier, codeChallenge } = generateTwitterPkce();
|
|
385
386
|
return {
|
|
386
387
|
pkce: {
|
|
388
|
+
nonce,
|
|
387
389
|
state,
|
|
388
390
|
codeVerifier,
|
|
389
391
|
targetPublicKey
|
|
390
392
|
},
|
|
391
393
|
url: generateTwitterUrl({
|
|
392
394
|
state,
|
|
395
|
+
nonce,
|
|
393
396
|
codeChallenge,
|
|
394
397
|
clientId: this.metadata.twitterClientId,
|
|
395
398
|
redirectUri: this.metadata.twitterRedirectUri
|
|
@@ -413,24 +416,22 @@ var TurnkeyWallet = class {
|
|
|
413
416
|
this.userOrganizationId = oauthResult.organizationId;
|
|
414
417
|
return oauthResult.credentialBundle;
|
|
415
418
|
}
|
|
416
|
-
async confirmOAuth2({ authCode, codeVerifier, providerName, targetPublicKey }) {
|
|
419
|
+
async confirmOAuth2({ nonce, authCode, codeVerifier, providerName, targetPublicKey }) {
|
|
417
420
|
var _response$data, _response$data2;
|
|
418
421
|
const indexedDbClient = await this.getIndexedDbClient();
|
|
419
422
|
const path = this.metadata.oauth2ExchangePath || "turnkey/oauth2";
|
|
420
423
|
const response = await this.client.post(path, {
|
|
424
|
+
nonce,
|
|
421
425
|
authCode,
|
|
422
426
|
codeVerifier,
|
|
423
427
|
targetPublicKey,
|
|
424
428
|
providerName
|
|
425
429
|
});
|
|
426
430
|
if (!(response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.credentialBundle) || !(response === null || response === void 0 || (_response$data2 = response.data) === null || _response$data2 === void 0 ? void 0 : _response$data2.organizationId)) throw new WalletException(/* @__PURE__ */ new Error(`${providerName} OAuth2 exchange failed`));
|
|
427
|
-
const { credentialBundle, organizationId
|
|
431
|
+
const { credentialBundle, organizationId } = response.data;
|
|
428
432
|
await indexedDbClient.loginWithSession(credentialBundle);
|
|
429
433
|
this.userOrganizationId = organizationId;
|
|
430
|
-
return
|
|
431
|
-
session: credentialBundle,
|
|
432
|
-
email
|
|
433
|
-
};
|
|
434
|
+
return credentialBundle;
|
|
434
435
|
}
|
|
435
436
|
async refreshSession() {
|
|
436
437
|
var _session$session;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@injectivelabs/wallet-turnkey",
|
|
3
|
-
"version": "1.19.
|
|
3
|
+
"version": "1.19.20",
|
|
4
4
|
"description": "Turnkey wallet strategy for use with @injectivelabs/wallet-core.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
"@turnkey/sdk-browser": "5.16.1",
|
|
46
46
|
"@turnkey/viem": "0.13.1",
|
|
47
47
|
"viem": "^2.41.2",
|
|
48
|
-
"@injectivelabs/exceptions": "1.19.
|
|
49
|
-
"@injectivelabs/sdk-ts": "1.19.
|
|
50
|
-
"@injectivelabs/ts-types": "1.19.
|
|
51
|
-
"@injectivelabs/utils": "1.19.
|
|
52
|
-
"@injectivelabs/wallet-base": "1.19.
|
|
48
|
+
"@injectivelabs/exceptions": "1.19.20",
|
|
49
|
+
"@injectivelabs/sdk-ts": "1.19.20",
|
|
50
|
+
"@injectivelabs/ts-types": "1.19.20",
|
|
51
|
+
"@injectivelabs/utils": "1.19.20",
|
|
52
|
+
"@injectivelabs/wallet-base": "1.19.20"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|