@vue-solana/core 0.4.0 → 0.4.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/dist/ios-wallet.cjs +26 -8
- package/dist/ios-wallet.mjs +7 -1
- package/package.json +1 -1
package/dist/ios-wallet.cjs
CHANGED
|
@@ -2,13 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
const web3Compat = require('@solana/web3-compat');
|
|
4
4
|
const bs58 = require('bs58');
|
|
5
|
-
const
|
|
5
|
+
const naclModule = require('tweetnacl');
|
|
6
6
|
|
|
7
7
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
8
8
|
|
|
9
|
+
function _interopNamespaceCompat(e) {
|
|
10
|
+
if (e && typeof e === 'object' && 'default' in e) return e;
|
|
11
|
+
const n = Object.create(null);
|
|
12
|
+
if (e) {
|
|
13
|
+
for (const k in e) {
|
|
14
|
+
n[k] = e[k];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
n.default = e;
|
|
18
|
+
return n;
|
|
19
|
+
}
|
|
20
|
+
|
|
9
21
|
const bs58__default = /*#__PURE__*/_interopDefaultCompat(bs58);
|
|
10
|
-
const
|
|
22
|
+
const naclModule__namespace = /*#__PURE__*/_interopNamespaceCompat(naclModule);
|
|
11
23
|
|
|
24
|
+
const nacl = resolveTweetNaCl();
|
|
25
|
+
function resolveTweetNaCl() {
|
|
26
|
+
const moduleDefault = naclModule__namespace.default;
|
|
27
|
+
const globalNacl = globalThis.nacl;
|
|
28
|
+
return "box" in naclModule__namespace ? naclModule__namespace : moduleDefault ?? globalNacl;
|
|
29
|
+
}
|
|
12
30
|
const DEFAULT_IOS_WALLET_CHAINS = ["solana:mainnet", "solana:devnet"];
|
|
13
31
|
const PENDING_REQUEST_KEY = "vue-solana:ios-wallet:pending";
|
|
14
32
|
const SESSION_PREFIX = "vue-solana:ios-wallet:session:";
|
|
@@ -239,7 +257,7 @@ function getDefaultIosWalletRedirectUrl() {
|
|
|
239
257
|
return url.toString();
|
|
240
258
|
}
|
|
241
259
|
function launchConnect(definition, options) {
|
|
242
|
-
const keyPair =
|
|
260
|
+
const keyPair = nacl.box.keyPair();
|
|
243
261
|
const pending = createPendingRequest(definition.id, "connect", keyPair, options.redirectUrl);
|
|
244
262
|
const appIdentity = options.appIdentity ?? getDefaultIosWalletAppIdentity();
|
|
245
263
|
const url = new URL(definition.connectUrl);
|
|
@@ -300,7 +318,7 @@ async function launchEncryptedWalletRequest(definition, method, options, payload
|
|
|
300
318
|
},
|
|
301
319
|
options.redirectUrl
|
|
302
320
|
);
|
|
303
|
-
const nonce =
|
|
321
|
+
const nonce = nacl.randomBytes(nacl.box.nonceLength);
|
|
304
322
|
const encryptedPayload = encryptPayload(
|
|
305
323
|
{ ...payload, session: session.session },
|
|
306
324
|
nonce,
|
|
@@ -369,13 +387,13 @@ function getSharedSecret(walletEncryptionPublicKey, dappSecretKey) {
|
|
|
369
387
|
if (!walletEncryptionPublicKey) {
|
|
370
388
|
throw new Error("Missing iOS wallet encryption public key");
|
|
371
389
|
}
|
|
372
|
-
return
|
|
390
|
+
return nacl.box.before(bs58__default.decode(walletEncryptionPublicKey), bs58__default.decode(dappSecretKey));
|
|
373
391
|
}
|
|
374
392
|
function encryptPayload(payload, nonce, sharedSecret) {
|
|
375
|
-
return bs58__default.encode(
|
|
393
|
+
return bs58__default.encode(nacl.box.after(encodeJson(payload), nonce, sharedSecret));
|
|
376
394
|
}
|
|
377
395
|
function decryptPayload(data, nonce, sharedSecret) {
|
|
378
|
-
const decrypted =
|
|
396
|
+
const decrypted = nacl.box.open.after(bs58__default.decode(data), bs58__default.decode(nonce), sharedSecret);
|
|
379
397
|
if (!decrypted) {
|
|
380
398
|
throw new Error("Unable to decrypt iOS wallet callback");
|
|
381
399
|
}
|
|
@@ -483,7 +501,7 @@ function cleanCallbackUrl(url, clearUrl) {
|
|
|
483
501
|
window.history.replaceState(window.history.state, document.title, url.toString());
|
|
484
502
|
}
|
|
485
503
|
function createRequestId() {
|
|
486
|
-
return bs58__default.encode(
|
|
504
|
+
return bs58__default.encode(nacl.randomBytes(16));
|
|
487
505
|
}
|
|
488
506
|
function getStringField(payload, field) {
|
|
489
507
|
const value = payload[field];
|
package/dist/ios-wallet.mjs
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { PublicKey, Transaction, VersionedTransaction } from '@solana/web3-compat';
|
|
2
2
|
import bs58 from 'bs58';
|
|
3
|
-
import
|
|
3
|
+
import * as naclModule from 'tweetnacl';
|
|
4
4
|
|
|
5
|
+
const nacl = resolveTweetNaCl();
|
|
6
|
+
function resolveTweetNaCl() {
|
|
7
|
+
const moduleDefault = naclModule.default;
|
|
8
|
+
const globalNacl = globalThis.nacl;
|
|
9
|
+
return "box" in naclModule ? naclModule : moduleDefault ?? globalNacl;
|
|
10
|
+
}
|
|
5
11
|
const DEFAULT_IOS_WALLET_CHAINS = ["solana:mainnet", "solana:devnet"];
|
|
6
12
|
const PENDING_REQUEST_KEY = "vue-solana:ios-wallet:pending";
|
|
7
13
|
const SESSION_PREFIX = "vue-solana:ios-wallet:session:";
|