@dynamic-labs/solana 1.2.1 → 1.3.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
 
2
- ### [1.2.1](https://github.com/dynamic-labs/DynamicAuth/compare/v1.2.0...v1.2.1) (2024-03-05)
2
+ ### [1.3.1](https://github.com/dynamic-labs/DynamicAuth/compare/v1.3.0...v1.3.1) (2024-03-08)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * pass account and chain to walletClient ([#4865](https://github.com/dynamic-labs/DynamicAuth/issues/4865)) ([#4905](https://github.com/dynamic-labs/DynamicAuth/issues/4905)) ([0f4e79f](https://github.com/dynamic-labs/DynamicAuth/commit/0f4e79ff36f8a3ef63c59bb9f80429cdefbe7307))
8
+ * update btckit network conversion for signpsbt to use correct network ([#4882](https://github.com/dynamic-labs/DynamicAuth/issues/4882)) ([3c14f55](https://github.com/dynamic-labs/DynamicAuth/commit/3c14f55f6e37718a095752d0e04bfbac45fee75c))
9
+ * better auth state handling when logged in with disabled wallets ([#4862](https://github.com/dynamic-labs/DynamicAuth/issues/4862)) ([8cc2a1c](https://github.com/dynamic-labs/DynamicAuth/commit/8cc2a1c4f31cf6acb61d814a3410c5e77da21c50))
10
+
11
+ ## [1.3.0](https://github.com/dynamic-labs/DynamicAuth/compare/v1.2.0...v1.3.0) (2024-03-05)
3
12
 
4
13
 
5
14
  ### Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/solana",
3
- "version": "1.2.1",
3
+ "version": "1.3.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dynamic-labs/DynamicAuth.git",
@@ -30,12 +30,12 @@
30
30
  "@dynamic-labs/sdk-api": "0.0.363",
31
31
  "bs58": "^5.0.0",
32
32
  "tweetnacl": "^1.0.3",
33
- "@dynamic-labs/rpc-providers": "1.2.1",
34
- "@dynamic-labs/turnkey": "1.2.1",
35
- "@dynamic-labs/types": "1.2.1",
36
- "@dynamic-labs/utils": "1.2.1",
37
- "@dynamic-labs/wallet-book": "1.2.1",
38
- "@dynamic-labs/wallet-connector-core": "1.2.1",
33
+ "@dynamic-labs/rpc-providers": "1.3.1",
34
+ "@dynamic-labs/turnkey": "1.3.1",
35
+ "@dynamic-labs/types": "1.3.1",
36
+ "@dynamic-labs/utils": "1.3.1",
37
+ "@dynamic-labs/wallet-book": "1.3.1",
38
+ "@dynamic-labs/wallet-connector-core": "1.3.1",
39
39
  "eventemitter3": "5.0.1"
40
40
  },
41
41
  "peerDependencies": {}
@@ -116,13 +116,25 @@ class PhantomRedirect extends solWalletConnector.SolWalletConnector {
116
116
  }
117
117
  endSession() {
118
118
  return _tslib.__awaiter(this, void 0, void 0, function* () {
119
- // for establishing the shared secret. NOT the wallet address
120
- storage.storage.address.remove();
121
- storage.storage.encryptionPublicKey.remove();
122
- storage.storage.encryptionSecretKey.remove();
123
- storage.storage.message.remove();
124
- storage.storage.session.remove();
125
- storage.storage.sharedSecret.remove();
119
+ const address = storage.storage.address.get();
120
+ const session = storage.storage.session.get();
121
+ const sharedSecret = storage.storage.sharedSecret.get();
122
+ const encryptionPublicKey = storage.storage.encryptionPublicKey.get();
123
+ // Clear all local storage in case of any stale state
124
+ storage.clearStorage();
125
+ // if there is no session/encrytion keys, then we don't need to disconnect
126
+ if (!address || !session || !encryptionPublicKey || !sharedSecret)
127
+ return;
128
+ const payload = { session };
129
+ const [nonce, encryptedPayload] = utils.encryptPayload(payload, sharedSecret);
130
+ const params = new URLSearchParams({
131
+ dapp_encryption_public_key: bs58__default["default"].encode(encryptionPublicKey),
132
+ nonce: bs58__default["default"].encode(nonce),
133
+ payload: bs58__default["default"].encode(encryptedPayload),
134
+ redirect_link: window.location.href,
135
+ });
136
+ const url = utils.buildUrl('disconnect', params);
137
+ window.location.href = url;
126
138
  });
127
139
  }
128
140
  /**
@@ -4,7 +4,7 @@ import bs58 from 'bs58';
4
4
  import { PublicKey } from '@solana/web3.js';
5
5
  import { SolWalletConnector } from '../solWalletConnector.js';
6
6
  import { buildUrl, decryptPayload, encryptPayload } from './utils.js';
7
- import { storage } from './storage.js';
7
+ import { storage, clearStorage } from './storage.js';
8
8
 
9
9
  class PhantomRedirect extends SolWalletConnector {
10
10
  constructor(props) {
@@ -107,13 +107,25 @@ class PhantomRedirect extends SolWalletConnector {
107
107
  }
108
108
  endSession() {
109
109
  return __awaiter(this, void 0, void 0, function* () {
110
- // for establishing the shared secret. NOT the wallet address
111
- storage.address.remove();
112
- storage.encryptionPublicKey.remove();
113
- storage.encryptionSecretKey.remove();
114
- storage.message.remove();
115
- storage.session.remove();
116
- storage.sharedSecret.remove();
110
+ const address = storage.address.get();
111
+ const session = storage.session.get();
112
+ const sharedSecret = storage.sharedSecret.get();
113
+ const encryptionPublicKey = storage.encryptionPublicKey.get();
114
+ // Clear all local storage in case of any stale state
115
+ clearStorage();
116
+ // if there is no session/encrytion keys, then we don't need to disconnect
117
+ if (!address || !session || !encryptionPublicKey || !sharedSecret)
118
+ return;
119
+ const payload = { session };
120
+ const [nonce, encryptedPayload] = encryptPayload(payload, sharedSecret);
121
+ const params = new URLSearchParams({
122
+ dapp_encryption_public_key: bs58.encode(encryptionPublicKey),
123
+ nonce: bs58.encode(nonce),
124
+ payload: bs58.encode(encryptedPayload),
125
+ redirect_link: window.location.href,
126
+ });
127
+ const url = buildUrl('disconnect', params);
128
+ window.location.href = url;
117
129
  });
118
130
  }
119
131
  /**
@@ -76,5 +76,11 @@ const storage = {
76
76
  },
77
77
  },
78
78
  };
79
+ const clearStorage = () => {
80
+ for (const key in storage) {
81
+ storage[key].remove();
82
+ }
83
+ };
79
84
 
85
+ exports.clearStorage = clearStorage;
80
86
  exports.storage = storage;
@@ -31,3 +31,4 @@ export declare const storage: {
31
31
  set: (sharedSecret: Uint8Array) => void;
32
32
  };
33
33
  };
34
+ export declare const clearStorage: () => void;
@@ -72,5 +72,10 @@ const storage = {
72
72
  },
73
73
  },
74
74
  };
75
+ const clearStorage = () => {
76
+ for (const key in storage) {
77
+ storage[key].remove();
78
+ }
79
+ };
75
80
 
76
- export { storage };
81
+ export { clearStorage, storage };