@vue-solana/core 3.0.0 → 3.0.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/errors.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- type SolanaErrorCode = "NO_WALLET_SELECTED" | "WALLET_NOT_CONNECTED" | "WALLET_FEATURE_UNSUPPORTED" | "USER_REJECTED" | "INVALID_ADDRESS" | "TRANSACTION_TIMEOUT" | "RPC_FAILURE" | "STORAGE_FAILURE";
1
+ type SolanaErrorCode = "NO_WALLET_SELECTED" | "WALLET_NOT_CONNECTED" | "WALLET_FEATURE_UNSUPPORTED" | "USER_REJECTED" | "INVALID_ADDRESS" | "TRANSACTION_TIMEOUT" | "RPC_FAILURE" | "STORAGE_FAILURE" | "INVALID_INPUT" | "DECRYPTION_FAILED";
2
2
  interface SolanaErrorOptions {
3
3
  cause?: unknown;
4
4
  feature?: string;
package/dist/errors.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- type SolanaErrorCode = "NO_WALLET_SELECTED" | "WALLET_NOT_CONNECTED" | "WALLET_FEATURE_UNSUPPORTED" | "USER_REJECTED" | "INVALID_ADDRESS" | "TRANSACTION_TIMEOUT" | "RPC_FAILURE" | "STORAGE_FAILURE";
1
+ type SolanaErrorCode = "NO_WALLET_SELECTED" | "WALLET_NOT_CONNECTED" | "WALLET_FEATURE_UNSUPPORTED" | "USER_REJECTED" | "INVALID_ADDRESS" | "TRANSACTION_TIMEOUT" | "RPC_FAILURE" | "STORAGE_FAILURE" | "INVALID_INPUT" | "DECRYPTION_FAILED";
2
2
  interface SolanaErrorOptions {
3
3
  cause?: unknown;
4
4
  feature?: string;
package/dist/index.d.mts CHANGED
@@ -5,7 +5,7 @@ export { AddressInput, MaybeAddressInput, parseAddress } from './address.mjs';
5
5
  export { installSolanaBufferPolyfill } from './buffer-polyfill.mjs';
6
6
  export { SolanaError, SolanaErrorCode, SolanaErrorOptions, createSolanaError, isSolanaError, normalizeSolanaError } from './errors.mjs';
7
7
  export { C as ConfirmTransactionOptions, S as SendTransactionOptions, a as SolanaChain, b as SolanaClient, c as SolanaCluster, d as SolanaConfig, e as SolanaContext, f as SolanaSignInAccount, g as SolanaSignInInput, h as SolanaSignInResult, i as SolanaSignMessageResult, j as SolanaTransaction, k as SolanaWallet, l as SolanaWalletInfo, T as TransactionConfirmation, m as TransactionStatus, n as createSolanaClient } from './shared/core.C9vxHRXl.mjs';
8
- export { RegisterSolanaMobileWalletOptions, SolanaMobileWalletAppIdentity, getDefaultMobileWalletAppIdentity, isSolanaMobileWalletSupported, registerSolanaMobileWallet } from './mobile-wallet.mjs';
8
+ export { RegisterSolanaMobileWalletOptions, SolanaMobileWalletAppIdentity, getDefaultMobileWalletAppIdentity, registerSolanaMobileWallet } from './mobile-wallet.mjs';
9
9
  export { createSolanaContext } from './rpc.mjs';
10
10
  export { TokenAccountInfo, TokenAccountsByOwnerOptions, TokenBalanceResult, getTokenAccount, getTokenAccountsByOwner, getTokenBalance } from './token-accounts.mjs';
11
11
  export { confirmTransactionSignature, signAndSendTransaction } from './transaction.mjs';
@@ -16,5 +16,6 @@ export { isAbortError } from '@solana/kit';
16
16
  export { AdaptSolanaIosWalletOptions, GetSolanaIosWalletsOptions, IosWalletCallbackResult, IosWalletInfo, IosWalletMethod, SolanaIosWalletAppIdentity, adaptSolanaIosWallet, getDefaultIosWalletAppIdentity, getDefaultIosWalletRedirectUrl, getSolanaIosWallets, handleSolanaIosWalletCallback, isIosBrowser, isSolanaIosBrowserWalletSupported, isSolanaIosWalletInfo } from './ios-wallet.mjs';
17
17
  export { AdaptSolanaWalletOptions, SOLANA_CHAINS, SOLANA_MOBILE_WALLET_ADAPTER_WALLET_NAME, adaptSolanaStandardWallet, getRegisteredSolanaWallets, getSolanaChain, isSolanaStandardWallet, subscribeSolanaWallets } from './wallet-standard.mjs';
18
18
  export { Buffer } from 'buffer/';
19
+ export { isSolanaMobileWalletSupported } from './mobile-wallet-support.mjs';
19
20
  import '@solana/kit-plugin-rpc';
20
21
  import '@wallet-standard/base';
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ export { AddressInput, MaybeAddressInput, parseAddress } from './address.js';
5
5
  export { installSolanaBufferPolyfill } from './buffer-polyfill.js';
6
6
  export { SolanaError, SolanaErrorCode, SolanaErrorOptions, createSolanaError, isSolanaError, normalizeSolanaError } from './errors.js';
7
7
  export { C as ConfirmTransactionOptions, S as SendTransactionOptions, a as SolanaChain, b as SolanaClient, c as SolanaCluster, d as SolanaConfig, e as SolanaContext, f as SolanaSignInAccount, g as SolanaSignInInput, h as SolanaSignInResult, i as SolanaSignMessageResult, j as SolanaTransaction, k as SolanaWallet, l as SolanaWalletInfo, T as TransactionConfirmation, m as TransactionStatus, n as createSolanaClient } from './shared/core.C9vxHRXl.js';
8
- export { RegisterSolanaMobileWalletOptions, SolanaMobileWalletAppIdentity, getDefaultMobileWalletAppIdentity, isSolanaMobileWalletSupported, registerSolanaMobileWallet } from './mobile-wallet.js';
8
+ export { RegisterSolanaMobileWalletOptions, SolanaMobileWalletAppIdentity, getDefaultMobileWalletAppIdentity, registerSolanaMobileWallet } from './mobile-wallet.js';
9
9
  export { createSolanaContext } from './rpc.js';
10
10
  export { TokenAccountInfo, TokenAccountsByOwnerOptions, TokenBalanceResult, getTokenAccount, getTokenAccountsByOwner, getTokenBalance } from './token-accounts.js';
11
11
  export { confirmTransactionSignature, signAndSendTransaction } from './transaction.js';
@@ -16,5 +16,6 @@ export { isAbortError } from '@solana/kit';
16
16
  export { AdaptSolanaIosWalletOptions, GetSolanaIosWalletsOptions, IosWalletCallbackResult, IosWalletInfo, IosWalletMethod, SolanaIosWalletAppIdentity, adaptSolanaIosWallet, getDefaultIosWalletAppIdentity, getDefaultIosWalletRedirectUrl, getSolanaIosWallets, handleSolanaIosWalletCallback, isIosBrowser, isSolanaIosBrowserWalletSupported, isSolanaIosWalletInfo } from './ios-wallet.js';
17
17
  export { AdaptSolanaWalletOptions, SOLANA_CHAINS, SOLANA_MOBILE_WALLET_ADAPTER_WALLET_NAME, adaptSolanaStandardWallet, getRegisteredSolanaWallets, getSolanaChain, isSolanaStandardWallet, subscribeSolanaWallets } from './wallet-standard.js';
18
18
  export { Buffer } from 'buffer/';
19
+ export { isSolanaMobileWalletSupported } from './mobile-wallet-support.js';
19
20
  import '@solana/kit-plugin-rpc';
20
21
  import '@wallet-standard/base';
package/dist/index.mjs CHANGED
@@ -4,7 +4,7 @@ export { parseAddress } from './address.mjs';
4
4
  export { installSolanaBufferPolyfill } from './buffer-polyfill.mjs';
5
5
  export { SolanaError, createSolanaError, isSolanaError, normalizeSolanaError } from './errors.mjs';
6
6
  export { createSolanaClient } from './kit.mjs';
7
- export { getDefaultMobileWalletAppIdentity, isSolanaMobileWalletSupported, registerSolanaMobileWallet } from './mobile-wallet.mjs';
7
+ export { getDefaultMobileWalletAppIdentity, registerSolanaMobileWallet } from './mobile-wallet.mjs';
8
8
  export { createSolanaContext } from './rpc.mjs';
9
9
  export { getTokenAccount, getTokenAccountsByOwner, getTokenBalance } from './token-accounts.mjs';
10
10
  export { confirmTransactionSignature, signAndSendTransaction } from './transaction.mjs';
@@ -14,11 +14,5 @@ export * from '@solana/kit';
14
14
  export { isAbortError } from '@solana/kit';
15
15
  export { Buffer } from 'buffer/';
16
16
  export { S as SOLANA_CHAINS, a as SOLANA_MOBILE_WALLET_ADAPTER_WALLET_NAME, b as adaptSolanaStandardWallet, g as getRegisteredSolanaWallets, c as getSolanaChain, i as isSolanaStandardWallet, s as subscribeSolanaWallets } from './shared/core.DaUlAmcN.mjs';
17
- export { a as adaptSolanaIosWallet, g as getDefaultIosWalletAppIdentity, b as getDefaultIosWalletRedirectUrl, c as getSolanaIosWallets, h as handleSolanaIosWalletCallback, i as isIosBrowser, d as isSolanaIosBrowserWalletSupported, e as isSolanaIosWalletInfo } from './shared/core.DuQGQqnc.mjs';
18
- import '@solana/kit-plugin-rpc';
19
- import '@solana-mobile/wallet-standard-mobile';
20
- import '@wallet-standard/features';
21
- import '@solana/wallet-standard-features';
22
- import 'bs58';
23
- import '@wallet-standard/app';
24
- import 'tweetnacl';
17
+ export { a as adaptSolanaIosWallet, g as getDefaultIosWalletAppIdentity, b as getDefaultIosWalletRedirectUrl, c as getSolanaIosWallets, h as handleSolanaIosWalletCallback, i as isIosBrowser, d as isSolanaIosBrowserWalletSupported, e as isSolanaIosWalletInfo } from './shared/core.DJsPYgx_.mjs';
18
+ export { isSolanaMobileWalletSupported } from './mobile-wallet-support.mjs';
@@ -1,4 +1 @@
1
- export { a as adaptSolanaIosWallet, g as getDefaultIosWalletAppIdentity, b as getDefaultIosWalletRedirectUrl, c as getSolanaIosWallets, h as handleSolanaIosWalletCallback, i as isIosBrowser, d as isSolanaIosBrowserWalletSupported, e as isSolanaIosWalletInfo } from './shared/core.DuQGQqnc.mjs';
2
- import '@solana/kit';
3
- import 'bs58';
4
- import 'tweetnacl';
1
+ export { a as adaptSolanaIosWallet, g as getDefaultIosWalletAppIdentity, b as getDefaultIosWalletRedirectUrl, c as getSolanaIosWallets, h as handleSolanaIosWalletCallback, i as isIosBrowser, d as isSolanaIosBrowserWalletSupported, e as isSolanaIosWalletInfo } from './shared/core.DJsPYgx_.mjs';
@@ -0,0 +1,3 @@
1
+ declare function isSolanaMobileWalletSupported(): boolean;
2
+
3
+ export { isSolanaMobileWalletSupported };
@@ -0,0 +1,3 @@
1
+ declare function isSolanaMobileWalletSupported(): boolean;
2
+
3
+ export { isSolanaMobileWalletSupported };
@@ -0,0 +1,5 @@
1
+ function isSolanaMobileWalletSupported() {
2
+ return typeof window !== "undefined" && window.isSecureContext && /android/i.test(navigator.userAgent);
3
+ }
4
+
5
+ export { isSolanaMobileWalletSupported };
@@ -1,3 +1,4 @@
1
+ export { isSolanaMobileWalletSupported } from './mobile-wallet-support.mjs';
1
2
  import { a as SolanaChain } from './shared/core.C9vxHRXl.mjs';
2
3
  import '@solana/kit-plugin-rpc';
3
4
  import '@solana/kit';
@@ -13,8 +14,7 @@ interface RegisterSolanaMobileWalletOptions {
13
14
  remoteHostAuthority?: string;
14
15
  }
15
16
  declare function registerSolanaMobileWallet(options?: RegisterSolanaMobileWalletOptions): boolean;
16
- declare function isSolanaMobileWalletSupported(): boolean;
17
17
  declare function getDefaultMobileWalletAppIdentity(): SolanaMobileWalletAppIdentity;
18
18
 
19
- export { getDefaultMobileWalletAppIdentity, isSolanaMobileWalletSupported, registerSolanaMobileWallet };
19
+ export { getDefaultMobileWalletAppIdentity, registerSolanaMobileWallet };
20
20
  export type { RegisterSolanaMobileWalletOptions, SolanaMobileWalletAppIdentity };
@@ -1,3 +1,4 @@
1
+ export { isSolanaMobileWalletSupported } from './mobile-wallet-support.js';
1
2
  import { a as SolanaChain } from './shared/core.C9vxHRXl.js';
2
3
  import '@solana/kit-plugin-rpc';
3
4
  import '@solana/kit';
@@ -13,8 +14,7 @@ interface RegisterSolanaMobileWalletOptions {
13
14
  remoteHostAuthority?: string;
14
15
  }
15
16
  declare function registerSolanaMobileWallet(options?: RegisterSolanaMobileWalletOptions): boolean;
16
- declare function isSolanaMobileWalletSupported(): boolean;
17
17
  declare function getDefaultMobileWalletAppIdentity(): SolanaMobileWalletAppIdentity;
18
18
 
19
- export { getDefaultMobileWalletAppIdentity, isSolanaMobileWalletSupported, registerSolanaMobileWallet };
19
+ export { getDefaultMobileWalletAppIdentity, registerSolanaMobileWallet };
20
20
  export type { RegisterSolanaMobileWalletOptions, SolanaMobileWalletAppIdentity };
@@ -1,4 +1,5 @@
1
1
  import { registerMwa, createDefaultWalletNotFoundHandler, createDefaultChainSelector, createDefaultAuthorizationCache } from '@solana-mobile/wallet-standard-mobile';
2
+ import { isSolanaMobileWalletSupported } from './mobile-wallet-support.mjs';
2
3
 
3
4
  const DEFAULT_MOBILE_WALLET_CHAINS = ["solana:mainnet", "solana:devnet"];
4
5
  const registeredMobileWalletKeys = /* @__PURE__ */ new Set();
@@ -27,15 +28,6 @@ function registerSolanaMobileWallet(options = {}) {
27
28
  registeredMobileWalletKeys.add(registrationKey);
28
29
  return true;
29
30
  }
30
- function isSolanaMobileWalletSupported() {
31
- if (typeof window === "undefined" || typeof navigator === "undefined") {
32
- return false;
33
- }
34
- const userAgent = navigator.userAgent;
35
- const isAndroid = /Android/i.test(userAgent);
36
- const isChrome = /Chrome|CriOS/i.test(userAgent) && !/Edg|OPR|Firefox|FxiOS/i.test(userAgent);
37
- return isAndroid && isChrome;
38
- }
39
31
  function getDefaultMobileWalletAppIdentity() {
40
32
  if (typeof window === "undefined") {
41
33
  return {
package/dist/rpc.mjs CHANGED
@@ -1,7 +1,5 @@
1
1
  import { DEFAULT_CLUSTER, getClusterEndpoint, getWebSocketEndpoint, getClusterWebSocketEndpoint } from './clusters.mjs';
2
2
  import { createSolanaClient } from './kit.mjs';
3
- import '@solana/kit';
4
- import '@solana/kit-plugin-rpc';
5
3
 
6
4
  function createSolanaContext(config = {}) {
7
5
  const cluster = config.cluster ?? DEFAULT_CLUSTER;
@@ -1,6 +1,7 @@
1
1
  import { isAddress } from '@solana/kit';
2
2
  import bs58 from 'bs58';
3
3
  import * as naclModule from 'tweetnacl';
4
+ import { createSolanaError } from '../errors.mjs';
4
5
 
5
6
  const DEFAULT_IOS_WALLET_CHAINS = [
6
7
  "solana:mainnet",
@@ -106,25 +107,74 @@ function isObjectRecord(value) {
106
107
  return typeof value === "object" && value !== null;
107
108
  }
108
109
 
109
- const nacl = resolveTweetNaCl();
110
+ let cachedNacl;
111
+ function getNacl() {
112
+ return cachedNacl ??= resolveTweetNaCl();
113
+ }
110
114
  function createRequestId() {
111
- return bs58.encode(nacl.randomBytes(16));
115
+ return bs58.encode(getNacl().randomBytes(16));
112
116
  }
113
117
  function getSharedSecret(walletEncryptionPublicKey, dappSecretKey) {
114
118
  if (!walletEncryptionPublicKey) {
115
- throw new Error("Missing iOS wallet encryption public key");
119
+ throw createSolanaError("INVALID_INPUT", "Missing iOS wallet encryption public key");
120
+ }
121
+ let walletPk;
122
+ let dappSk;
123
+ try {
124
+ walletPk = bs58.decode(walletEncryptionPublicKey);
125
+ dappSk = bs58.decode(dappSecretKey);
126
+ } catch (cause) {
127
+ throw createSolanaError("INVALID_INPUT", "Invalid iOS wallet encryption key encoding", {
128
+ cause
129
+ });
130
+ }
131
+ if (walletPk.length !== getNacl().box.publicKeyLength) {
132
+ throw createSolanaError("INVALID_INPUT", "Invalid iOS wallet encryption public key length");
116
133
  }
117
- return nacl.box.before(bs58.decode(walletEncryptionPublicKey), bs58.decode(dappSecretKey));
134
+ if (dappSk.length !== getNacl().box.secretKeyLength) {
135
+ throw createSolanaError("INVALID_INPUT", "Invalid iOS wallet dapp secret key length");
136
+ }
137
+ return getNacl().box.before(walletPk, dappSk);
118
138
  }
119
139
  function encryptPayload(payload, nonce, sharedSecret) {
120
- return bs58.encode(nacl.box.after(encodeJson(payload), nonce, sharedSecret));
140
+ if (sharedSecret.length !== getNacl().box.sharedKeyLength) {
141
+ throw createSolanaError("INVALID_INPUT", "Invalid iOS wallet shared secret length");
142
+ }
143
+ if (nonce.length !== getNacl().box.nonceLength) {
144
+ throw createSolanaError("INVALID_INPUT", "Invalid iOS wallet nonce length");
145
+ }
146
+ try {
147
+ return bs58.encode(getNacl().box.after(encodeJson(payload), nonce, sharedSecret));
148
+ } catch (cause) {
149
+ throw createSolanaError("INVALID_INPUT", "Failed to encrypt iOS wallet payload", { cause });
150
+ }
121
151
  }
122
152
  function decryptPayload(data, nonce, sharedSecret) {
123
- const decrypted = nacl.box.open.after(bs58.decode(data), bs58.decode(nonce), sharedSecret);
153
+ let decodedData;
154
+ let decodedNonce;
155
+ try {
156
+ decodedData = bs58.decode(data);
157
+ decodedNonce = bs58.decode(nonce);
158
+ } catch (cause) {
159
+ throw createSolanaError("INVALID_INPUT", "Invalid iOS wallet callback encoding", { cause });
160
+ }
161
+ if (sharedSecret.length !== getNacl().box.sharedKeyLength) {
162
+ throw createSolanaError("INVALID_INPUT", "Invalid iOS wallet shared secret length");
163
+ }
164
+ if (decodedNonce.length !== getNacl().box.nonceLength) {
165
+ throw createSolanaError("INVALID_INPUT", "Invalid iOS wallet callback nonce length");
166
+ }
167
+ const decrypted = getNacl().box.open.after(decodedData, decodedNonce, sharedSecret);
124
168
  if (!decrypted) {
125
- throw new Error("Unable to decrypt iOS wallet callback");
169
+ throw createSolanaError("DECRYPTION_FAILED", "Unable to decrypt iOS wallet callback");
170
+ }
171
+ try {
172
+ return JSON.parse(new TextDecoder().decode(decrypted));
173
+ } catch (cause) {
174
+ throw createSolanaError("DECRYPTION_FAILED", "Unable to decode iOS wallet callback payload", {
175
+ cause
176
+ });
126
177
  }
127
- return JSON.parse(new TextDecoder().decode(decrypted));
128
178
  }
129
179
  function resolveTweetNaCl() {
130
180
  const moduleDefault = naclModule.default;
@@ -383,7 +433,7 @@ function getPublicKeyField(payload, field) {
383
433
  }
384
434
 
385
435
  function launchConnect(definition, options) {
386
- const keyPair = nacl.box.keyPair();
436
+ const keyPair = getNacl().box.keyPair();
387
437
  const pending = createPendingRequest(definition.id, "connect", keyPair, options.redirectUrl);
388
438
  const appIdentity = options.appIdentity ?? getDefaultIosWalletAppIdentity();
389
439
  const url = new URL(definition.connectUrl);
@@ -445,7 +495,7 @@ async function launchEncryptedWalletRequest(definition, method, options, payload
445
495
  options.redirectUrl,
446
496
  method === "signAllTransactions" && Array.isArray(payload.transactions) ? payload.transactions.length : void 0
447
497
  );
448
- const nonce = nacl.randomBytes(nacl.box.nonceLength);
498
+ const nonce = getNacl().randomBytes(getNacl().box.nonceLength);
449
499
  const encryptedPayload = encryptPayload(
450
500
  { ...payload, session: session.session },
451
501
  nonce,
@@ -1,5 +1 @@
1
1
  export { S as SOLANA_CHAINS, a as SOLANA_MOBILE_WALLET_ADAPTER_WALLET_NAME, b as adaptSolanaStandardWallet, g as getRegisteredSolanaWallets, c as getSolanaChain, i as isSolanaStandardWallet, s as subscribeSolanaWallets } from './shared/core.DaUlAmcN.mjs';
2
- import '@wallet-standard/features';
3
- import '@solana/wallet-standard-features';
4
- import 'bs58';
5
- import '@wallet-standard/app';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue-solana/core",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "Framework-agnostic primitives for Vue Solana libraries.",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -65,6 +65,10 @@
65
65
  "types": "./dist/mobile-wallet.d.ts",
66
66
  "import": "./dist/mobile-wallet.mjs"
67
67
  },
68
+ "./mobile-wallet-support": {
69
+ "types": "./dist/mobile-wallet-support.d.ts",
70
+ "import": "./dist/mobile-wallet-support.mjs"
71
+ },
68
72
  "./rpc": {
69
73
  "types": "./dist/rpc.d.ts",
70
74
  "import": "./dist/rpc.mjs"