@injectivelabs/wallet-turnkey 1.20.12 → 1.20.14

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.
@@ -2,8 +2,8 @@ let viem = require("viem");
2
2
  let __injectivelabs_utils = require("@injectivelabs/utils");
3
3
  let __injectivelabs_sdk_ts_core_tx = require("@injectivelabs/sdk-ts/core/tx");
4
4
  let __injectivelabs_sdk_ts_utils = require("@injectivelabs/sdk-ts/utils");
5
- let __injectivelabs_exceptions = require("@injectivelabs/exceptions");
6
5
  let __injectivelabs_wallet_base = require("@injectivelabs/wallet-base");
6
+ let __injectivelabs_exceptions = require("@injectivelabs/exceptions");
7
7
  let __turnkey_viem = require("@turnkey/viem");
8
8
  let __turnkey_sdk_browser = require("@turnkey/sdk-browser");
9
9
 
@@ -702,6 +702,21 @@ var TurnkeyWalletStrategy = class extends __injectivelabs_wallet_base.BaseConcre
702
702
  if (!await turnkey.getSession()) return;
703
703
  await Promise.allSettled([turnkey.logout(), indexedDbClient.clear()]);
704
704
  }
705
+ async deleteCurrentSubOrganization() {
706
+ const turnkeyWallet = await this.getTurnkeyWallet();
707
+ const turnkey = await turnkeyWallet.getTurnkey();
708
+ const indexedDbClient = await turnkeyWallet.getIndexedDbClient();
709
+ const activeSession = await turnkey.getSession();
710
+ const organizationId = activeSession === null || activeSession === void 0 ? void 0 : activeSession.organizationId;
711
+ if (!(activeSession === null || activeSession === void 0 ? void 0 : activeSession.token) || !organizationId) throw new __injectivelabs_exceptions.TurnkeyWalletSessionException(/* @__PURE__ */ new Error("Session expired. Please login again."));
712
+ await indexedDbClient.deleteSubOrganization({
713
+ organizationId,
714
+ deleteWithoutExport: true
715
+ });
716
+ await Promise.allSettled([turnkey.logout(), indexedDbClient.clear()]);
717
+ turnkeyWallet.userOrganizationId = void 0;
718
+ return { organizationId };
719
+ }
705
720
  async getAddresses() {
706
721
  const turnkeyWallet = await this.getTurnkeyWallet();
707
722
  try {
@@ -20,6 +20,9 @@ declare class TurnkeyWalletStrategy extends BaseConcreteStrategy implements Conc
20
20
  }): void;
21
21
  enable(): Promise<boolean>;
22
22
  disconnect(): Promise<void>;
23
+ deleteCurrentSubOrganization(): Promise<{
24
+ organizationId: string;
25
+ }>;
23
26
  getAddresses(): Promise<string[]>;
24
27
  getAddressesInfo(): Promise<{
25
28
  address: string;
@@ -20,6 +20,9 @@ declare class TurnkeyWalletStrategy extends BaseConcreteStrategy implements Conc
20
20
  }): void;
21
21
  enable(): Promise<boolean>;
22
22
  disconnect(): Promise<void>;
23
+ deleteCurrentSubOrganization(): Promise<{
24
+ organizationId: string;
25
+ }>;
23
26
  getAddresses(): Promise<string[]>;
24
27
  getAddressesInfo(): Promise<{
25
28
  address: string;
package/dist/esm/index.js CHANGED
@@ -2,8 +2,8 @@ import { getAddress, hashTypedData } from "viem";
2
2
  import { HttpRestClient } from "@injectivelabs/utils";
3
3
  import { TxGrpcApi } from "@injectivelabs/sdk-ts/core/tx";
4
4
  import { getEthereumAddress, getInjectiveAddress, sha256, toUtf8 } from "@injectivelabs/sdk-ts/utils";
5
- import { CosmosWalletException, ErrorType, GeneralException, TransactionException, TurnkeyWalletSessionException, UnspecifiedErrorCode, WalletException } from "@injectivelabs/exceptions";
6
5
  import { BaseConcreteStrategy, TurnkeyProvider, WalletAction, WalletDeviceType, getEvmChainConfig, getViemPublicClient, getViemWalletClient } from "@injectivelabs/wallet-base";
6
+ import { CosmosWalletException, ErrorType, GeneralException, TransactionException, TurnkeyWalletSessionException, UnspecifiedErrorCode, WalletException } from "@injectivelabs/exceptions";
7
7
  import { createAccount } from "@turnkey/viem";
8
8
  import { SessionType, Turnkey } from "@turnkey/sdk-browser";
9
9
 
@@ -702,6 +702,21 @@ var TurnkeyWalletStrategy = class extends BaseConcreteStrategy {
702
702
  if (!await turnkey.getSession()) return;
703
703
  await Promise.allSettled([turnkey.logout(), indexedDbClient.clear()]);
704
704
  }
705
+ async deleteCurrentSubOrganization() {
706
+ const turnkeyWallet = await this.getTurnkeyWallet();
707
+ const turnkey = await turnkeyWallet.getTurnkey();
708
+ const indexedDbClient = await turnkeyWallet.getIndexedDbClient();
709
+ const activeSession = await turnkey.getSession();
710
+ const organizationId = activeSession === null || activeSession === void 0 ? void 0 : activeSession.organizationId;
711
+ if (!(activeSession === null || activeSession === void 0 ? void 0 : activeSession.token) || !organizationId) throw new TurnkeyWalletSessionException(/* @__PURE__ */ new Error("Session expired. Please login again."));
712
+ await indexedDbClient.deleteSubOrganization({
713
+ organizationId,
714
+ deleteWithoutExport: true
715
+ });
716
+ await Promise.allSettled([turnkey.logout(), indexedDbClient.clear()]);
717
+ turnkeyWallet.userOrganizationId = void 0;
718
+ return { organizationId };
719
+ }
705
720
  async getAddresses() {
706
721
  const turnkeyWallet = await this.getTurnkeyWallet();
707
722
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@injectivelabs/wallet-turnkey",
3
- "version": "1.20.12",
3
+ "version": "1.20.14",
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/sdk-ts": "1.20.12",
49
- "@injectivelabs/exceptions": "1.20.12",
50
- "@injectivelabs/ts-types": "1.20.12",
51
- "@injectivelabs/utils": "1.20.12",
52
- "@injectivelabs/wallet-base": "1.20.12"
48
+ "@injectivelabs/exceptions": "1.20.14",
49
+ "@injectivelabs/sdk-ts": "1.20.14",
50
+ "@injectivelabs/ts-types": "1.20.14",
51
+ "@injectivelabs/wallet-base": "1.20.14",
52
+ "@injectivelabs/utils": "1.20.14"
53
53
  },
54
54
  "publishConfig": {
55
55
  "access": "public"