@dynamic-labs/solana 2.0.0-alpha.7 → 2.0.0-alpha.9
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,4 +1,21 @@
|
|
|
1
1
|
|
|
2
|
+
## [2.0.0-alpha.9](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.0-alpha.8...v2.0.0-alpha.9) (2024-03-06)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* solana connector new sendTransaction method ([#4842](https://github.com/dynamic-labs/DynamicAuth/issues/4842)) ([0b198e3](https://github.com/dynamic-labs/DynamicAuth/commit/0b198e30d83fbbc8d506654d87cbfad403fda289))
|
|
8
|
+
* specify solana network when using phantom redirect deeplinking ([#4863](https://github.com/dynamic-labs/DynamicAuth/issues/4863)) ([fb4ee7c](https://github.com/dynamic-labs/DynamicAuth/commit/fb4ee7cfc0493c9c85b6ccb31954842556c58aa4))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* isLoggedIn should return true even when there is no primary wallet ([#4875](https://github.com/dynamic-labs/DynamicAuth/issues/4875)) ([f396e22](https://github.com/dynamic-labs/DynamicAuth/commit/f396e22b9d809b05ac52194ffa4346f3591d17fe))
|
|
14
|
+
* update btckit network conversion for signPsbt ([a6009e1](https://github.com/dynamic-labs/DynamicAuth/commit/a6009e18c453b4e65545455fea0e52ed7a983b4d))
|
|
15
|
+
* user getting logged out when signing in with email linked to a unavailable wallet ([#4858](https://github.com/dynamic-labs/DynamicAuth/issues/4858)) ([8653e13](https://github.com/dynamic-labs/DynamicAuth/commit/8653e13d2067dd0161e660b4374c08a9fe0bc203))
|
|
16
|
+
|
|
17
|
+
## [2.0.0-alpha.8](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.0-alpha.7...v2.0.0-alpha.8) (2024-03-04)
|
|
18
|
+
|
|
2
19
|
## [2.0.0-alpha.7](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.0-alpha.6...v2.0.0-alpha.7) (2024-02-28)
|
|
3
20
|
|
|
4
21
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/solana",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.9",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -30,13 +30,13 @@
|
|
|
30
30
|
"@dynamic-labs/sdk-api": "0.0.376",
|
|
31
31
|
"bs58": "5.0.0",
|
|
32
32
|
"tweetnacl": "1.0.3",
|
|
33
|
-
"@dynamic-labs/rpc-provider-solana": "2.0.0-alpha.
|
|
34
|
-
"@dynamic-labs/rpc-providers": "2.0.0-alpha.
|
|
35
|
-
"@dynamic-labs/turnkey": "2.0.0-alpha.
|
|
36
|
-
"@dynamic-labs/types": "2.0.0-alpha.
|
|
37
|
-
"@dynamic-labs/utils": "2.0.0-alpha.
|
|
38
|
-
"@dynamic-labs/wallet-book": "2.0.0-alpha.
|
|
39
|
-
"@dynamic-labs/wallet-connector-core": "2.0.0-alpha.
|
|
33
|
+
"@dynamic-labs/rpc-provider-solana": "2.0.0-alpha.9",
|
|
34
|
+
"@dynamic-labs/rpc-providers": "2.0.0-alpha.9",
|
|
35
|
+
"@dynamic-labs/turnkey": "2.0.0-alpha.9",
|
|
36
|
+
"@dynamic-labs/types": "2.0.0-alpha.9",
|
|
37
|
+
"@dynamic-labs/utils": "2.0.0-alpha.9",
|
|
38
|
+
"@dynamic-labs/wallet-book": "2.0.0-alpha.9",
|
|
39
|
+
"@dynamic-labs/wallet-connector-core": "2.0.0-alpha.9",
|
|
40
40
|
"eventemitter3": "5.0.1"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {}
|
|
@@ -32,6 +32,7 @@ class PhantomRedirect extends solWalletConnector.SolWalletConnector {
|
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
connect() {
|
|
35
|
+
var _a, _b;
|
|
35
36
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
36
37
|
// Generate a new key pair
|
|
37
38
|
const keyPair = nacl__default["default"].box.keyPair();
|
|
@@ -40,9 +41,10 @@ class PhantomRedirect extends solWalletConnector.SolWalletConnector {
|
|
|
40
41
|
const isLocalHost = window.location.href.includes('localhost') ||
|
|
41
42
|
window.location.href.includes('0.0.0.0') ||
|
|
42
43
|
window.location.href.includes('127.0.0.1');
|
|
44
|
+
const rpc = (_b = (_a = this.solNetworks[0].privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : this.solNetworks[0].rpcUrls[0];
|
|
43
45
|
const params = new URLSearchParams({
|
|
44
46
|
app_url: isLocalHost ? 'https://demo.dynamic.xyz' : window.location.href,
|
|
45
|
-
cluster:
|
|
47
|
+
cluster: yield utils.fetchCluster(rpc),
|
|
46
48
|
dapp_encryption_public_key: bs58__default["default"].encode(keyPair.publicKey),
|
|
47
49
|
redirect_link: window.location.href,
|
|
48
50
|
});
|
|
@@ -3,7 +3,7 @@ import nacl from 'tweetnacl';
|
|
|
3
3
|
import bs58 from 'bs58';
|
|
4
4
|
import { PublicKey } from '@solana/web3.js';
|
|
5
5
|
import { SolWalletConnector } from '../solWalletConnector.js';
|
|
6
|
-
import { buildUrl, decryptPayload, encryptPayload } from './utils.js';
|
|
6
|
+
import { fetchCluster, buildUrl, decryptPayload, encryptPayload } from './utils.js';
|
|
7
7
|
import { storage } from './storage.js';
|
|
8
8
|
|
|
9
9
|
class PhantomRedirect extends SolWalletConnector {
|
|
@@ -23,6 +23,7 @@ class PhantomRedirect extends SolWalletConnector {
|
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
connect() {
|
|
26
|
+
var _a, _b;
|
|
26
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
28
|
// Generate a new key pair
|
|
28
29
|
const keyPair = nacl.box.keyPair();
|
|
@@ -31,9 +32,10 @@ class PhantomRedirect extends SolWalletConnector {
|
|
|
31
32
|
const isLocalHost = window.location.href.includes('localhost') ||
|
|
32
33
|
window.location.href.includes('0.0.0.0') ||
|
|
33
34
|
window.location.href.includes('127.0.0.1');
|
|
35
|
+
const rpc = (_b = (_a = this.solNetworks[0].privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : this.solNetworks[0].rpcUrls[0];
|
|
34
36
|
const params = new URLSearchParams({
|
|
35
37
|
app_url: isLocalHost ? 'https://demo.dynamic.xyz' : window.location.href,
|
|
36
|
-
cluster:
|
|
38
|
+
cluster: yield fetchCluster(rpc),
|
|
37
39
|
dapp_encryption_public_key: bs58.encode(keyPair.publicKey),
|
|
38
40
|
redirect_link: window.location.href,
|
|
39
41
|
});
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
5
6
|
var nacl = require('tweetnacl');
|
|
6
7
|
var bs58 = require('bs58');
|
|
7
8
|
|
|
@@ -23,7 +24,32 @@ const encryptPayload = (payload, sharedSecret) => {
|
|
|
23
24
|
const encryptedPayload = nacl__default["default"].box.after(Buffer.from(JSON.stringify(payload)), nonce, sharedSecret);
|
|
24
25
|
return [nonce, encryptedPayload];
|
|
25
26
|
};
|
|
27
|
+
const GENESIS_HASHES = {
|
|
28
|
+
'4uhcVJyU9pJkvQyS88uRDiswHXSCkY3zQawwpjk2NsNY': 'testnet',
|
|
29
|
+
'5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d': 'mainnet-beta',
|
|
30
|
+
EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG: 'devnet',
|
|
31
|
+
};
|
|
32
|
+
const fetchCluster = (rpc) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
+
try {
|
|
34
|
+
const { result } = yield (yield fetch(rpc, {
|
|
35
|
+
body: JSON.stringify({
|
|
36
|
+
id: 1,
|
|
37
|
+
jsonrpc: '2.0',
|
|
38
|
+
method: 'getGenesisHash',
|
|
39
|
+
}),
|
|
40
|
+
headers: {
|
|
41
|
+
'Content-Type': 'application/json',
|
|
42
|
+
},
|
|
43
|
+
method: 'POST',
|
|
44
|
+
})).json();
|
|
45
|
+
return GENESIS_HASHES[result];
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
return 'mainnet-beta';
|
|
49
|
+
}
|
|
50
|
+
});
|
|
26
51
|
|
|
27
52
|
exports.buildUrl = buildUrl;
|
|
28
53
|
exports.decryptPayload = decryptPayload;
|
|
29
54
|
exports.encryptPayload = encryptPayload;
|
|
55
|
+
exports.fetchCluster = fetchCluster;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export declare const buildUrl: (path: string, params: URLSearchParams) => string;
|
|
2
2
|
export declare const decryptPayload: (data: string, nonce: string, sharedSecret: Uint8Array) => any;
|
|
3
3
|
export declare const encryptPayload: (payload: any, sharedSecret: Uint8Array) => Uint8Array[];
|
|
4
|
+
export declare const fetchCluster: (rpc: string) => Promise<string>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
1
2
|
import nacl from 'tweetnacl';
|
|
2
3
|
import bs58 from 'bs58';
|
|
3
4
|
|
|
@@ -14,5 +15,29 @@ const encryptPayload = (payload, sharedSecret) => {
|
|
|
14
15
|
const encryptedPayload = nacl.box.after(Buffer.from(JSON.stringify(payload)), nonce, sharedSecret);
|
|
15
16
|
return [nonce, encryptedPayload];
|
|
16
17
|
};
|
|
18
|
+
const GENESIS_HASHES = {
|
|
19
|
+
'4uhcVJyU9pJkvQyS88uRDiswHXSCkY3zQawwpjk2NsNY': 'testnet',
|
|
20
|
+
'5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d': 'mainnet-beta',
|
|
21
|
+
EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG: 'devnet',
|
|
22
|
+
};
|
|
23
|
+
const fetchCluster = (rpc) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
+
try {
|
|
25
|
+
const { result } = yield (yield fetch(rpc, {
|
|
26
|
+
body: JSON.stringify({
|
|
27
|
+
id: 1,
|
|
28
|
+
jsonrpc: '2.0',
|
|
29
|
+
method: 'getGenesisHash',
|
|
30
|
+
}),
|
|
31
|
+
headers: {
|
|
32
|
+
'Content-Type': 'application/json',
|
|
33
|
+
},
|
|
34
|
+
method: 'POST',
|
|
35
|
+
})).json();
|
|
36
|
+
return GENESIS_HASHES[result];
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
return 'mainnet-beta';
|
|
40
|
+
}
|
|
41
|
+
});
|
|
17
42
|
|
|
18
|
-
export { buildUrl, decryptPayload, encryptPayload };
|
|
43
|
+
export { buildUrl, decryptPayload, encryptPayload, fetchCluster };
|