🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

@switchboard-xyz/common

Package Overview
Dependencies
Maintainers
5
Versions
165
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@switchboard-xyz/common - npm Package Compare versions

Comparing version

to
3.2.2

2

lib/secrets.js

@@ -1,2 +0,2 @@

import { AxiosUtils } from './utils';
import { AxiosUtils } from './utils/index.js';
import { Buffer } from 'buffer';

@@ -3,0 +3,0 @@ import { sha256 } from 'js-sha256';

@@ -46,2 +46,20 @@ import { Buffer } from 'buffer';

/**
* Converts a string to a hex string with 0x prefix.
*
* Supported input formats:
* - Byte array string: "[1, 2, 3, ...]"
* - Hex string: "0xabc123..." or "abc123..."
* - Base64 string: "VGhpcyBpcyBhIHRlc3Qgc3RyaW5nLg=="
* - Base58 string: "12DsSDs23..."
*
* @param value - The string to convert to hex
* @returns A hex string with 0x prefix
* @throws Error if the input cannot be decoded into a valid format
*
* @example
* toHex("[1, 2, 3]") // returns "0x010203"
* toHex("0xabc123") // returns "0xabc123"
*/
export declare const toHex: (value: string) => string;
/**
* Determine whether a given string is base64 encoded

@@ -48,0 +66,0 @@ * @param value - the string to verify

@@ -66,2 +66,27 @@ import bs58 from 'bs58';

/**
* Converts a string to a hex string with 0x prefix.
*
* Supported input formats:
* - Byte array string: "[1, 2, 3, ...]"
* - Hex string: "0xabc123..." or "abc123..."
* - Base64 string: "VGhpcyBpcyBhIHRlc3Qgc3RyaW5nLg=="
* - Base58 string: "12DsSDs23..."
*
* @param value - The string to convert to hex
* @returns A hex string with 0x prefix
* @throws Error if the input cannot be decoded into a valid format
*
* @example
* toHex("[1, 2, 3]") // returns "0x010203"
* toHex("0xabc123") // returns "0xabc123"
*/
export const toHex = (value) => {
if (!value)
throw new Error('Input string cannot be empty');
const decoded = decodeString(value);
if (decoded)
return `0x${decoded.toString('hex')}`;
throw new Error('Failed to decode string');
};
/**
* Determine whether a given string is base64 encoded

@@ -68,0 +93,0 @@ * @param value - the string to verify

{
"name": "@switchboard-xyz/common",
"version": "3.2.1",
"version": "3.2.2",
"description": "common type definitions and utils for interacting with switchboard",

@@ -5,0 +5,0 @@ "license": "MIT",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet