Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@solflare-wallet/oh-snap

Package Overview
Dependencies
Maintainers
7
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solflare-wallet/oh-snap - npm Package Compare versions

Comparing version 0.0.11 to 0.0.12

2

package.json
{
"name": "@solflare-wallet/oh-snap",
"version": "0.0.11",
"version": "0.0.12",
"description": "",

@@ -5,0 +5,0 @@ "main": "src/index.js",

{
"version": "0.0.11",
"version": "0.0.12",
"description": "The Solana Snap.",
"proposedName": "Solana Manager",
"source": {
"shasum": "VB3fXA8zk2wted0DniyQcRsB9D8x9O8tu4eseBo7wlI=",
"shasum": "28vfi9o1TbOvQJHFEUKS8WMEColVkgTOOJmVLguhmzU=",
"location": {

@@ -8,0 +8,0 @@ "npm": {

import nacl from 'tweetnacl';
import bs58 from 'bs58';
import { panel, heading, text, copyable, divider } from '@metamask/snaps-ui';
import { deriveKeyPair } from './privateKey';
import { assertInput, assertConfirmation } from './utils';
import { assertInput, assertConfirmation, assertAllStrings, assertIsString, assertIsBoolean, assertIsArray } from './utils';
import { renderGetPublicKey, renderSignTransaction, renderSignAllTransactions, renderSignMessage } from './ui';
module.exports.onRpcRequest = async ({ origin, request }) => {
// if (
// !origin ||
// (
// !origin.match(/^https?:\/\/localhost:[0-9]{1,4}$/) &&
// !origin.match(/^https?:\/\/(?:\S+\.)?solflare\.com$/) &&
// !origin.match(/^https?:\/\/(?:\S+\.)?solflare\.dev$/)
// )
// ) {
// throw new Error('Invalid origin');
// }
if (
!origin ||
(
!origin.match(/^https?:\/\/localhost:[0-9]{1,4}$/) &&
!origin.match(/^https?:\/\/(?:\S+\.)?solflare\.com$/) &&
!origin.match(/^https?:\/\/(?:\S+\.)?solflare\.dev$/)
)
) {
throw new Error('Invalid origin');
}

@@ -27,2 +27,4 @@ const dappOrigin = request?.params?.origin || origin;

assertInput(derivationPath);
assertIsString(derivationPath);
assertIsBoolean(confirm);

@@ -33,15 +35,3 @@ const keyPair = await deriveKeyPair(derivationPath);

if (confirm) {
const accepted = await snap.request({
method: 'snap_dialog',
params: {
type: 'confirmation',
content: panel([
heading('Confirm access'),
text(dappHost),
divider(),
text(pubkey)
])
}
});
const accepted = await renderGetPublicKey(dappHost, pubkey);
assertConfirmation(accepted);

@@ -53,23 +43,13 @@ }

case 'signTransaction': {
const { derivationPath, message, simulationResult } = request.params || {};
const { derivationPath, message, simulationResult = [], displayMessage = true } = request.params || {};
assertInput(derivationPath);
assertIsString(derivationPath);
assertInput(message);
assertIsString(message);
assertIsArray(simulationResult);
assertAllStrings(simulationResult);
assertIsBoolean(displayMessage);
const simulationResultItems = Array.isArray(simulationResult) ? simulationResult.map((item) => text(item)) : [];
const accepted = await snap.request({
method: 'snap_dialog',
params: {
type: 'confirmation',
content: panel([
heading('Sign transaction'),
text(dappHost),
divider(),
...simulationResultItems,
copyable(message)
])
}
});
const accepted = await renderSignTransaction(dappHost, message, simulationResult, displayMessage);
assertConfirmation(accepted);

@@ -79,2 +59,3 @@

const signature = nacl.sign.detached(bs58.decode(message), keyPair.secretKey);
return {

@@ -86,35 +67,18 @@ publicKey: bs58.encode(keyPair.publicKey),

case 'signAllTransactions': {
const { derivationPath, messages, simulationResults } = request.params || {};
const { derivationPath, messages, simulationResults = [], displayMessage = true } = request.params || {};
assertInput(derivationPath);
assertIsString(derivationPath);
assertInput(messages);
assertIsArray(messages);
assertInput(messages.length);
assertAllStrings(messages);
assertIsArray(simulationResults);
assertInput(messages.length === simulationResults.length);
assertIsBoolean(displayMessage);
const keyPair = await deriveKeyPair(derivationPath);
const uiElements = [];
for (let i = 0; i < messages?.length; i++) {
uiElements.push(divider());
uiElements.push(text(`Transaction ${i + 1}`));
if (Array.isArray(simulationResults?.[i])) {
simulationResults[i].forEach((item) => uiElements.push(text(item)));
}
uiElements.push(copyable(messages?.[i]));
}
const accepted = await snap.request({
method: 'snap_dialog',
params: {
type: 'confirmation',
content: panel([
heading('Sign transactions'),
text(dappHost),
...uiElements
])
}
});
const accepted = await renderSignAllTransactions(dappHost, messages, simulationResults, displayMessage);
assertConfirmation(accepted);
const keyPair = await deriveKeyPair(derivationPath);
const signatures = messages

@@ -134,3 +98,6 @@ .map((message) => bs58.decode(message))

assertInput(derivationPath);
assertIsString(derivationPath);
assertInput(message);
assertIsString(message);
assertIsString(display);

@@ -150,15 +117,3 @@ const keyPair = await deriveKeyPair(derivationPath);

const accepted = await snap.request({
method: 'snap_dialog',
params: {
type: 'confirmation',
content: panel([
heading('Sign message'),
text(dappHost),
divider(),
copyable(decodedMessage)
])
}
});
const accepted = await renderSignMessage(dappHost, decodedMessage);
assertConfirmation(accepted);

@@ -165,0 +120,0 @@

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc