@vue-solana/core 4.1.5 → 4.1.6
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/index.mjs
CHANGED
|
@@ -12,4 +12,4 @@ export { createSolanaPayReference, findTransactionSignaturesByReference, verifyS
|
|
|
12
12
|
export { getSolanaPayPaymentStatus } from './solana-pay-status.mjs';
|
|
13
13
|
export * from '@solana/kit';
|
|
14
14
|
export { C as CreateTransferError, H as HTTPS_PROTOCOL, M as MEMO_PROGRAM_ID, P as ParseURLError, S as SOLANA_PROTOCOL, a as SOL_DECIMALS, T as TEN, b as TOKEN_PROGRAM_ID, c as createQR, d as createQRCanvas, e as createQRDataURL, f as createQROptions, g as createRecipient, h as createSPLToken, i as createStyledQRCode, j as encodeTransactionRequestURL, k as encodeTransferRequestURL, l as encodeURL, m as isValidSolanaAddress, p as parseURL } from './shared/core.CQFtdLrA.mjs';
|
|
15
|
-
export { S as SOLANA_CHAINS, a as SOLANA_MOBILE_WALLET_ADAPTER_WALLET_NAME, b as adaptSolanaStandardWallet, d as disconnectSolanaStandardWallet, g as getRegisteredSolanaWallets, c as getSolanaChain, i as isSolanaStandardWallet, s as subscribeSolanaWallets } from './shared/core.
|
|
15
|
+
export { S as SOLANA_CHAINS, a as SOLANA_MOBILE_WALLET_ADAPTER_WALLET_NAME, b as adaptSolanaStandardWallet, d as disconnectSolanaStandardWallet, g as getRegisteredSolanaWallets, c as getSolanaChain, i as isSolanaStandardWallet, s as subscribeSolanaWallets } from './shared/core.CSMFFbai.mjs';
|
package/dist/mobile-wallet.mjs
CHANGED
|
@@ -1,7 +1,72 @@
|
|
|
1
1
|
import { createDefaultAuthorizationCache, registerMwa, createDefaultWalletNotFoundHandler, createDefaultChainSelector } from '@solana-mobile/wallet-standard-mobile';
|
|
2
2
|
import { s as setSolanaMobileWalletAuthorizationStore } from './shared/core.DQCWbyEu.mjs';
|
|
3
|
+
import { transact } from '@solana-mobile/mobile-wallet-adapter-protocol';
|
|
4
|
+
import { getBase64Decoder, getBase64Encoder } from '@solana/kit';
|
|
5
|
+
import { createSolanaError } from './errors.mjs';
|
|
3
6
|
import { isSolanaMobileWalletSupported } from './mobile-wallet-support.mjs';
|
|
4
7
|
|
|
8
|
+
async function signMobileWalletMessages({
|
|
9
|
+
appIdentity,
|
|
10
|
+
authorizationCache,
|
|
11
|
+
publicKey,
|
|
12
|
+
messages
|
|
13
|
+
}) {
|
|
14
|
+
const cachedAuthorization = await authorizationCache.get();
|
|
15
|
+
if (!cachedAuthorization) {
|
|
16
|
+
throw createSolanaError("WALLET_NOT_CONNECTED", "Solana wallet is not connected");
|
|
17
|
+
}
|
|
18
|
+
const base64Decoder = getBase64Decoder();
|
|
19
|
+
const base64Encoder = getBase64Encoder();
|
|
20
|
+
const address = base64Decoder.decode(publicKey);
|
|
21
|
+
const chain = cachedAuthorization.chain;
|
|
22
|
+
return transact(async (wallet) => {
|
|
23
|
+
const authorization = await authorizeSession(
|
|
24
|
+
wallet,
|
|
25
|
+
appIdentity,
|
|
26
|
+
chain,
|
|
27
|
+
cachedAuthorization.auth_token
|
|
28
|
+
);
|
|
29
|
+
if (!authorization.accounts.some((account) => account.address === address)) {
|
|
30
|
+
throw createSolanaError(
|
|
31
|
+
"WALLET_NOT_CONNECTED",
|
|
32
|
+
"The wallet authorized a different account than the connected one. Connect the wallet again and retry."
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
if (authorization.auth_token !== cachedAuthorization.auth_token) {
|
|
36
|
+
await authorizationCache.set({
|
|
37
|
+
...cachedAuthorization,
|
|
38
|
+
auth_token: authorization.auth_token,
|
|
39
|
+
wallet_uri_base: authorization.wallet_uri_base
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
const { signed_payloads } = await wallet.signMessages({
|
|
43
|
+
addresses: messages.map(() => address),
|
|
44
|
+
payloads: messages.map((message) => base64Decoder.decode(message))
|
|
45
|
+
});
|
|
46
|
+
return signed_payloads.map((payload) => Uint8Array.from(base64Encoder.encode(payload)));
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
async function authorizeSession(wallet, identity, chain, authToken) {
|
|
50
|
+
let reauthorizationError;
|
|
51
|
+
try {
|
|
52
|
+
return await wallet.authorize({ auth_token: authToken, identity, chain });
|
|
53
|
+
} catch (error) {
|
|
54
|
+
reauthorizationError = error;
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
return await wallet.authorize({ identity, chain });
|
|
58
|
+
} catch (authorizationError) {
|
|
59
|
+
throw createSolanaError(
|
|
60
|
+
"WALLET_FAILURE",
|
|
61
|
+
`The wallet rejected the saved authorization (${getErrorMessage(reauthorizationError)}) and a fresh one (${getErrorMessage(authorizationError)}).`,
|
|
62
|
+
{ cause: authorizationError }
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function getErrorMessage(error) {
|
|
67
|
+
return error instanceof Error ? error.message : String(error);
|
|
68
|
+
}
|
|
69
|
+
|
|
5
70
|
const DEFAULT_MOBILE_WALLET_CHAINS = ["solana:mainnet", "solana:devnet"];
|
|
6
71
|
const registeredMobileWalletKeys = /* @__PURE__ */ new Set();
|
|
7
72
|
function registerSolanaMobileWallet(options = {}) {
|
|
@@ -30,7 +95,8 @@ function registerSolanaMobileWallet(options = {}) {
|
|
|
30
95
|
registeredMobileWalletKeys.add(registrationKey);
|
|
31
96
|
setSolanaMobileWalletAuthorizationStore({
|
|
32
97
|
get: () => authorizationCache.get(),
|
|
33
|
-
set: (authorization) => authorizationCache.set(authorization)
|
|
98
|
+
set: (authorization) => authorizationCache.set(authorization),
|
|
99
|
+
signMessages: (publicKey, messages) => signMobileWalletMessages({ appIdentity, authorizationCache, publicKey, messages })
|
|
34
100
|
});
|
|
35
101
|
return true;
|
|
36
102
|
}
|
|
@@ -108,6 +108,15 @@ function adaptSolanaStandardWallet(walletInfo, options = {}) {
|
|
|
108
108
|
pendingMobileWalletRequests.delete(reject);
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
|
+
function signMessageThroughMobileWalletSession(activeAccount, message) {
|
|
112
|
+
const signMessages = isMobileWalletAdapter ? getSolanaMobileWalletAuthorizationStore()?.signMessages : void 0;
|
|
113
|
+
return signMessages?.(Uint8Array.from(activeAccount.publicKey), [message]).then(
|
|
114
|
+
(signedPayloads) => signedPayloads.map((signedMessage) => ({
|
|
115
|
+
signedMessage,
|
|
116
|
+
signature: signedMessage.slice(-64)
|
|
117
|
+
}))
|
|
118
|
+
);
|
|
119
|
+
}
|
|
111
120
|
function rejectPendingMobileWalletRequests() {
|
|
112
121
|
for (const reject of pendingMobileWalletRequests) {
|
|
113
122
|
reject(
|
|
@@ -271,7 +280,7 @@ function adaptSolanaStandardWallet(walletInfo, options = {}) {
|
|
|
271
280
|
signMessage: hasSignMessage(wallet) ? async (message) => {
|
|
272
281
|
const activeAccount = getActiveAccount(account);
|
|
273
282
|
const [result] = await whileMobileWalletAuthorized(
|
|
274
|
-
() => wallet.features[SolanaSignMessage].signMessage({
|
|
283
|
+
() => signMessageThroughMobileWalletSession(activeAccount, message) ?? wallet.features[SolanaSignMessage].signMessage({
|
|
275
284
|
account: activeAccount,
|
|
276
285
|
message
|
|
277
286
|
})
|
package/dist/wallet-standard.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { S as SOLANA_CHAINS, a as SOLANA_MOBILE_WALLET_ADAPTER_WALLET_NAME, b as adaptSolanaStandardWallet, d as disconnectSolanaStandardWallet, g as getRegisteredSolanaWallets, c as getSolanaChain, i as isSolanaStandardWallet, s as subscribeSolanaWallets } from './shared/core.
|
|
1
|
+
export { S as SOLANA_CHAINS, a as SOLANA_MOBILE_WALLET_ADAPTER_WALLET_NAME, b as adaptSolanaStandardWallet, d as disconnectSolanaStandardWallet, g as getRegisteredSolanaWallets, c as getSolanaChain, i as isSolanaStandardWallet, s as subscribeSolanaWallets } from './shared/core.CSMFFbai.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue-solana/core",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.6",
|
|
4
4
|
"description": "Framework-agnostic primitives for Vue Solana libraries.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -115,6 +115,7 @@
|
|
|
115
115
|
"access": "public"
|
|
116
116
|
},
|
|
117
117
|
"dependencies": {
|
|
118
|
+
"@solana-mobile/mobile-wallet-adapter-protocol": "^2.2.9",
|
|
118
119
|
"@solana-mobile/wallet-standard-mobile": "^0.5.3",
|
|
119
120
|
"@solana/kit": "^8.6.0",
|
|
120
121
|
"@solana/kit-plugin-rpc": "^0.19.0",
|