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

@vercel/stega

Package Overview
Dependencies
Maintainers
8
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vercel/stega - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

50

dist/cjs/decode.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.vercelStegaDecode = exports.VERCEL_STEGA_REGEX = void 0;
exports.vercelStegaDecodeAll = exports.vercelStegaDecode = exports.VERCEL_STEGA_REGEX = void 0;
const map_1 = require("./map");

@@ -11,14 +11,27 @@ const REVERSE_HEX_DIGIT_MAP = Object.fromEntries(Object.entries(map_1.HEX_DIGIT_MAP).map((x) => x.reverse()));

/**
* Decodes a hidden string back into its original value
* @param encoded - The encoded (hidden) string
* Decodes the first hidden string that's found in the source string back into its original value
* @param source - The source string with encoded data
* @returns The decoded JSON value
*/
function vercelStegaDecode(encoded) {
const match = encoded.match(exports.VERCEL_STEGA_REGEX);
if (!match)
function vercelStegaDecode(source) {
const matches = source.match(exports.VERCEL_STEGA_REGEX);
if (!matches)
return;
return decode(match[0]);
return decode(matches[0], true)[0];
}
exports.vercelStegaDecode = vercelStegaDecode;
function decode(encodedString) {
/**
* Decodes every hidden string that's found in the source string back into their original values
* @param source - The source string with encoded data
* @returns The decoded JSON values
*/
function vercelStegaDecodeAll(source) {
const matches = source.match(exports.VERCEL_STEGA_REGEX);
if (!matches)
return;
return matches.map((match) => decode(match)).flat();
}
exports.vercelStegaDecodeAll = vercelStegaDecodeAll;
function decode(encodedString, firstOnly = false) {
var _a;
const encoded = Array.from(encodedString);

@@ -33,3 +46,22 @@ if (encoded.length % 2) {

}
return JSON.parse(chars.join(''));
const results = [];
const queue = [chars.join('')];
let breakLimit = 10;
while (queue.length) {
const string = queue.shift();
try {
results.push(JSON.parse(string));
if (firstOnly)
return results;
}
catch (error) {
if (!breakLimit--)
throw error;
const position = +((_a = error.message.match(/\sposition\s(\d+)$/)) === null || _a === void 0 ? void 0 : _a[1]);
if (!position)
throw error;
queue.unshift(string.substring(0, position), string.substring(position));
}
}
return results;
}

12

dist/decode.d.ts
export declare const VERCEL_STEGA_REGEX: RegExp;
/**
* Decodes a hidden string back into its original value
* @param encoded - The encoded (hidden) string
* Decodes the first hidden string that's found in the source string back into its original value
* @param source - The source string with encoded data
* @returns The decoded JSON value
*/
export declare function vercelStegaDecode<T>(encoded: string): T | undefined;
export declare function vercelStegaDecode<T>(source: string): T | undefined;
/**
* Decodes every hidden string that's found in the source string back into their original values
* @param source - The source string with encoded data
* @returns The decoded JSON values
*/
export declare function vercelStegaDecodeAll<T>(source: string): T[];

@@ -8,13 +8,25 @@ import { HEX_DIGIT_MAP } from './map';

/**
* Decodes a hidden string back into its original value
* @param encoded - The encoded (hidden) string
* Decodes the first hidden string that's found in the source string back into its original value
* @param source - The source string with encoded data
* @returns The decoded JSON value
*/
export function vercelStegaDecode(encoded) {
const match = encoded.match(VERCEL_STEGA_REGEX);
if (!match)
export function vercelStegaDecode(source) {
const matches = source.match(VERCEL_STEGA_REGEX);
if (!matches)
return;
return decode(match[0]);
return decode(matches[0], true)[0];
}
function decode(encodedString) {
/**
* Decodes every hidden string that's found in the source string back into their original values
* @param source - The source string with encoded data
* @returns The decoded JSON values
*/
export function vercelStegaDecodeAll(source) {
const matches = source.match(VERCEL_STEGA_REGEX);
if (!matches)
return;
return matches.map((match) => decode(match)).flat();
}
function decode(encodedString, firstOnly = false) {
var _a;
const encoded = Array.from(encodedString);

@@ -29,3 +41,22 @@ if (encoded.length % 2) {

}
return JSON.parse(chars.join(''));
const results = [];
const queue = [chars.join('')];
let breakLimit = 10;
while (queue.length) {
const string = queue.shift();
try {
results.push(JSON.parse(string));
if (firstOnly)
return results;
}
catch (error) {
if (!breakLimit--)
throw error;
const position = +((_a = error.message.match(/\sposition\s(\d+)$/)) === null || _a === void 0 ? void 0 : _a[1]);
if (!position)
throw error;
queue.unshift(string.substring(0, position), string.substring(position));
}
}
return results;
}
{
"name": "@vercel/stega",
"version": "0.0.3",
"version": "0.0.4",
"description": "Utilities for steganography",

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

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