@vue-solana/core 2.6.0 → 2.6.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/kit.cjs CHANGED
@@ -40,17 +40,25 @@ function resolvePayerFromSecretKey(payerSecretKey) {
40
40
  }
41
41
  const address2 = kit.getBase58Decoder().decode(keyPairBytes.slice(32));
42
42
  let privateKey;
43
- const getPrivateKey = () => privateKey ??= kit.createKeyPairFromBytes(keyPairBytes).then(
44
- (keyPair) => keyPair.privateKey,
45
- () => {
43
+ const getPrivateKey = () => privateKey ??= (async () => {
44
+ if (!globalThis.crypto?.subtle) {
45
+ throw new Error(
46
+ "`payerSecretKey` signing needs WebCrypto, which browsers only expose in a secure context (https, or http on localhost)."
47
+ );
48
+ }
49
+ return (await kit.createKeyPairFromBytes(keyPairBytes)).privateKey;
50
+ })().catch((cause) => {
51
+ if (kit.isSolanaError(cause, kit.SOLANA_ERROR__KEYS__PUBLIC_KEY_MUST_MATCH_PRIVATE_KEY)) {
46
52
  throw invalidError();
47
53
  }
48
- );
54
+ throw cause;
55
+ });
49
56
  return {
50
57
  address: address2,
51
58
  async signTransactions(transactions, config) {
52
59
  config?.abortSignal?.throwIfAborted();
53
60
  const key = await getPrivateKey();
61
+ config?.abortSignal?.throwIfAborted();
54
62
  return Promise.all(
55
63
  transactions.map(async (transaction) => ({
56
64
  [address2]: await kit.signBytes(key, transaction.messageBytes)
package/dist/kit.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { getBase64Encoder, getBase58Decoder, signBytes, createClient, extendClient, createKeyPairFromBytes } from '@solana/kit';
1
+ import { getBase64Encoder, getBase58Decoder, signBytes, createClient, extendClient, createKeyPairFromBytes, isSolanaError, SOLANA_ERROR__KEYS__PUBLIC_KEY_MUST_MATCH_PRIVATE_KEY } from '@solana/kit';
2
2
  export { AccountRole, address, appendTransactionMessageInstruction, compileTransaction, createReactiveActionStore, createReactiveStoreWithInitialValueAndSlotTracking, createTransactionMessage, extendClient, generateKeyPairSigner, getAbortablePromise, getTransactionEncoder, isAbortError, isAddress, lamports, setTransactionMessageFeePayer, setTransactionMessageLifetimeUsingBlockhash, summarizeTransactionPlanResult } from '@solana/kit';
3
3
  import { solanaRpc, rpcAirdrop } from '@solana/kit-plugin-rpc';
4
4
  import { DEFAULT_CLUSTER, getClusterEndpoint, getWebSocketEndpoint, getClusterWebSocketEndpoint } from './clusters.mjs';
@@ -39,17 +39,25 @@ function resolvePayerFromSecretKey(payerSecretKey) {
39
39
  }
40
40
  const address2 = getBase58Decoder().decode(keyPairBytes.slice(32));
41
41
  let privateKey;
42
- const getPrivateKey = () => privateKey ??= createKeyPairFromBytes(keyPairBytes).then(
43
- (keyPair) => keyPair.privateKey,
44
- () => {
42
+ const getPrivateKey = () => privateKey ??= (async () => {
43
+ if (!globalThis.crypto?.subtle) {
44
+ throw new Error(
45
+ "`payerSecretKey` signing needs WebCrypto, which browsers only expose in a secure context (https, or http on localhost)."
46
+ );
47
+ }
48
+ return (await createKeyPairFromBytes(keyPairBytes)).privateKey;
49
+ })().catch((cause) => {
50
+ if (isSolanaError(cause, SOLANA_ERROR__KEYS__PUBLIC_KEY_MUST_MATCH_PRIVATE_KEY)) {
45
51
  throw invalidError();
46
52
  }
47
- );
53
+ throw cause;
54
+ });
48
55
  return {
49
56
  address: address2,
50
57
  async signTransactions(transactions, config) {
51
58
  config?.abortSignal?.throwIfAborted();
52
59
  const key = await getPrivateKey();
60
+ config?.abortSignal?.throwIfAborted();
53
61
  return Promise.all(
54
62
  transactions.map(async (transaction) => ({
55
63
  [address2]: await signBytes(key, transaction.messageBytes)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue-solana/core",
3
- "version": "2.6.0",
3
+ "version": "2.6.1",
4
4
  "description": "Framework-agnostic primitives for Vue Solana libraries.",
5
5
  "license": "MIT",
6
6
  "keywords": [