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

libskynet

Package Overview
Dependencies
Maintainers
1
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

libskynet - npm Package Compare versions

Comparing version 0.0.53 to 0.0.55

dist/objAsString.d.ts

6

dist/apidownloadskylink.js
import { verifyDownloadResponse } from "./apidownloadverifyresponse.js";
import { progressiveFetch } from "./apiprogressivefetch.js";
import { defaultPortalList } from "./defaultportals.js";
import { addContextToErr } from "./err.js";
import { b64ToBuf } from "./encoding.js";
import { defaultPortalList } from "./defaultportals.js";
import { objAsString } from "./objAsString.js";
import { validSkylink } from "./skylinkvalidate.js";
import { tryStringify } from "./stringifytry.js";
// downloadSkylink will download the provided skylink.

@@ -39,3 +39,3 @@ function downloadSkylink(skylink) {

// Error is not a 404, return the logs as the error.
let err = tryStringify(result.logs);
let err = objAsString(result.logs);
resolve([new Uint8Array(0), addContextToErr(err, "unable to complete download")]);

@@ -42,0 +42,0 @@ return;

import { verifyDownload } from "./apidownloadverify.js";
import { addContextToErr } from "./err.js";
import { objAsString } from "./objAsString.js";
import { parseJSON } from "./parse.js";
import { parseSkylinkBitfield } from "./skylinkbitfield.js";
import { verifyResolverLinkProofs } from "./skylinkverifyresolver.js";
import { tryStringify } from "./stringifytry.js";
// Establish the function that verifies the result is correct.

@@ -20,3 +20,3 @@ //

if (response.status !== 200) {
resolve("unrecognized response status " + tryStringify(response.status) + ", expecting 200");
resolve("unrecognized response status " + objAsString(response.status) + ", expecting 200");
return;

@@ -23,0 +23,0 @@ }

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

import { tryStringify } from "./stringifytry.js";
import { objAsString } from "./objAsString.js";
// progressiveFetchHelper is the full progressiveFetch function, split out into

@@ -52,7 +52,7 @@ // a helper because the inptus/api is more complicated but only necessary for

if (!("status" in response) || typeof response.status !== "number") {
nextPortal(response, "portal has returned invalid response\n" + tryStringify({ portal, query }));
nextPortal(response, "portal has returned invalid response\n" + objAsString({ portal, query }));
return;
}
if (response.status < 200 || response.status >= 300) {
nextPortal(response, "portal has returned error status\n" + tryStringify({ portal, query }));
nextPortal(response, "portal has returned error status\n" + objAsString({ portal, query }));
return;

@@ -81,3 +81,3 @@ }

// This portal failed, try again with the next portal.
nextPortal(null, "fetch returned an error\n" + tryStringify(err) + tryStringify(pfm.fetchOpts));
nextPortal(null, "fetch returned an error\n" + objAsString(err) + objAsString(pfm.fetchOpts));
return;

@@ -84,0 +84,0 @@ });

import { hexToBuf } from "./encoding.js";
import { addContextToErr } from "./err.js";
import { objAsString } from "./objAsString.js";
import { parseJSON } from "./parse.js";
import { verifyRegistrySignature } from "./registry.js";
import { tryStringify } from "./stringifytry.js";
// verifyDecodedResp will verify the decoded response from a portal for a

@@ -11,3 +11,3 @@ // regRead call.

if (resp.status !== 200) {
return "expected 200 response status, got: " + tryStringify(resp.status);
return "expected 200 response status, got: " + objAsString(resp.status);
}

@@ -70,3 +70,3 @@ // Verify that all required fields were provided.

.catch((err) => {
resolve(addContextToErr(tryStringify(err), "unable to decode response"));
resolve(addContextToErr(objAsString(err), "unable to decode response"));
});

@@ -73,0 +73,0 @@ });

declare const BLAKE2B_HASH_SIZE = 32;
declare function blake2b(input: Uint8Array): Uint8Array;
export { blake2b, BLAKE2B_HASH_SIZE };
export { BLAKE2B_HASH_SIZE, blake2b };

@@ -181,2 +181,2 @@ // Blake2B, adapted from the reference implementation in RFC7693

}
export { blake2b, BLAKE2B_HASH_SIZE };
export { BLAKE2B_HASH_SIZE, blake2b };

@@ -1,8 +0,8 @@

interface ed25519Keypair {
interface Ed25519Keypair {
publicKey: Uint8Array;
secretKey: Uint8Array;
}
declare function ed25519KeypairFromEntropy(seed: Uint8Array): [ed25519Keypair, string | null];
declare function ed25519KeypairFromEntropy(seed: Uint8Array): [Ed25519Keypair, string | null];
declare function ed25519Sign(msg: Uint8Array, secretKey: Uint8Array): [Uint8Array, string | null];
declare function ed25519Verify(msg: Uint8Array, sig: Uint8Array, publicKey: Uint8Array): boolean;
export { ed25519Keypair, ed25519KeypairFromEntropy, ed25519Sign, ed25519Verify };
export { Ed25519Keypair, ed25519KeypairFromEntropy, ed25519Sign, ed25519Verify };
import { addContextToErr } from "./err.js";
import { sha512internal } from "./sha512.js";
let crypto_sign_BYTES = 64, crypto_sign_PUBLICKEYBYTES = 32, crypto_sign_SECRETKEYBYTES = 64, crypto_sign_SEEDBYTES = 32;
let gf = function () {
let r = new Float64Array(16);
const crypto_sign_BYTES = 64, crypto_sign_PUBLICKEYBYTES = 32, crypto_sign_SECRETKEYBYTES = 64, crypto_sign_SEEDBYTES = 32;
const gf = function () {
const r = new Float64Array(16);
return r;
};
let gfi = function (init) {
let i, r = new Float64Array(16);
const gfi = function (init) {
let i;
const r = new Float64Array(16);
if (init)

@@ -15,3 +16,3 @@ for (i = 0; i < init.length; i++)

};
let gf0 = gf(), gf1 = gfi([1]), D = gfi([
const gf0 = gf(), gf1 = gfi([1]), D = gfi([
0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f,

@@ -56,3 +57,4 @@ 0x6cee, 0x5203,

function sel25519(p, q, b) {
let t, c = ~(b - 1);
let t;
const c = ~(b - 1);
for (let i = 0; i < 16; i++) {

@@ -66,3 +68,3 @@ t = c & (p[i] ^ q[i]);

let i, j, b;
let m = gf(), t = gf();
const m = gf(), t = gf();
for (i = 0; i < 16; i++)

@@ -90,3 +92,3 @@ t[i] = n[i];

function neq25519(a, b) {
let c = new Uint8Array(32), d = new Uint8Array(32);
const c = new Uint8Array(32), d = new Uint8Array(32);
pack25519(c, a);

@@ -97,3 +99,3 @@ pack25519(d, b);

function par25519(a) {
let d = new Uint8Array(32);
const d = new Uint8Array(32);
pack25519(d, a);

@@ -117,3 +119,4 @@ return d[0] & 1;

function M(o, a, b) {
let v, c, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7], b8 = b[8], b9 = b[9], b10 = b[10], b11 = b[11], b12 = b[12], b13 = b[13], b14 = b[14], b15 = b[15];
let v, c, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0;
const b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7], b8 = b[8], b9 = b[9], b10 = b[10], b11 = b[11], b12 = b[12], b13 = b[13], b14 = b[14], b15 = b[15];
v = a[0];

@@ -530,3 +533,3 @@ t0 += v * b0;

function inv25519(o, i) {
let c = gf();
const c = gf();
let a;

@@ -544,3 +547,3 @@ for (a = 0; a < 16; a++)

function pow2523(o, i) {
let c = gf();
const c = gf();
let a;

@@ -558,3 +561,3 @@ for (a = 0; a < 16; a++)

function add(p, q) {
let a = gf(), b = gf(), c = gf(), d = gf(), e = gf(), f = gf(), g = gf(), h = gf(), t = gf();
const a = gf(), b = gf(), c = gf(), d = gf(), e = gf(), f = gf(), g = gf(), h = gf(), t = gf();
Z(a, p[1], p[0]);

@@ -586,3 +589,3 @@ Z(t, q[1], q[0]);

function pack(r, p) {
let tx = gf(), ty = gf(), zi = gf();
const tx = gf(), ty = gf(), zi = gf();
inv25519(zi, p[2]);

@@ -609,3 +612,3 @@ M(tx, p[0], zi);

function scalarbase(p, s) {
let q = [gf(), gf(), gf(), gf()];
const q = [gf(), gf(), gf(), gf()];
set25519(q[0], X);

@@ -617,3 +620,3 @@ set25519(q[1], Y);

}
let L = new Float64Array([
const L = new Float64Array([
0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0,

@@ -648,3 +651,3 @@ 0, 0, 0, 0, 0, 0, 0, 0, 0x10,

function unpackneg(r, p) {
let t = gf(), chk = gf(), num = gf(), den = gf(), den2 = gf(), den4 = gf(), den6 = gf();
const t = gf(), chk = gf(), num = gf(), den = gf(), den2 = gf(), den4 = gf(), den6 = gf();
set25519(r[2], gf1);

@@ -680,3 +683,4 @@ unpack25519(r[1], p);

function reduce(r) {
let x = new Float64Array(64), i;
const x = new Float64Array(64);
let i;
for (i = 0; i < 64; i++)

@@ -689,4 +693,4 @@ x[i] = r[i];

function crypto_sign_keypair(pk, sk) {
let d = new Uint8Array(64);
let p = [gf(), gf(), gf(), gf()];
const d = new Uint8Array(64);
const p = [gf(), gf(), gf(), gf()];
let i;

@@ -705,4 +709,4 @@ sha512internal(d, sk, 32);

let i;
let t = new Uint8Array(32), h = new Uint8Array(64);
let p = [gf(), gf(), gf(), gf()], q = [gf(), gf(), gf(), gf()];
const t = new Uint8Array(32), h = new Uint8Array(64);
const p = [gf(), gf(), gf(), gf()], q = [gf(), gf(), gf(), gf()];
if (n < 64)

@@ -734,5 +738,6 @@ return -1;

function crypto_sign(sm, m, n, sk) {
let d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);
let i, j, x = new Float64Array(64);
let p = [gf(), gf(), gf(), gf()];
const d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);
let i, j;
const x = new Float64Array(64);
const p = [gf(), gf(), gf(), gf()];
sha512internal(d, sk, 32);

@@ -742,3 +747,3 @@ d[0] &= 248;

d[31] |= 64;
let smlen = n + 64;
const smlen = n + 64;
for (i = 0; i < n; i++)

@@ -786,3 +791,3 @@ sm[64 + i] = m[i];

// Input checking.
let errU8 = checkAllUint8Array(seed);
const errU8 = checkAllUint8Array(seed);
if (errU8 !== null) {

@@ -795,4 +800,4 @@ return [nkp, addContextToErr(errU8, "seed is invalid")];

// Build the keypair.
let pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
let sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
const pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
const sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
for (let i = 0; i < 32; i++) {

@@ -813,3 +818,3 @@ sk[i] = seed[i];

// Input checking.
let errU8 = checkAllUint8Array(msg, secretKey);
const errU8 = checkAllUint8Array(msg, secretKey);
if (errU8 !== null) {

@@ -822,5 +827,5 @@ return [nu8, addContextToErr(errU8, "inputs are invalid")];

// Build the signature.
let signedMsg = new Uint8Array(crypto_sign_BYTES + msg.length);
const signedMsg = new Uint8Array(crypto_sign_BYTES + msg.length);
crypto_sign(signedMsg, msg, msg.length, secretKey);
let sig = new Uint8Array(crypto_sign_BYTES);
const sig = new Uint8Array(crypto_sign_BYTES);
for (let i = 0; i < sig.length; i++) {

@@ -834,3 +839,3 @@ sig[i] = signedMsg[i];

function ed25519Verify(msg, sig, publicKey) {
let errU8 = checkAllUint8Array(msg, sig, publicKey);
const errU8 = checkAllUint8Array(msg, sig, publicKey);
if (errU8 !== null) {

@@ -845,4 +850,4 @@ return false;

}
let sm = new Uint8Array(crypto_sign_BYTES + msg.length);
let m = new Uint8Array(crypto_sign_BYTES + msg.length);
const sm = new Uint8Array(crypto_sign_BYTES + msg.length);
const m = new Uint8Array(crypto_sign_BYTES + msg.length);
let i;

@@ -849,0 +854,0 @@ for (i = 0; i < crypto_sign_BYTES; i++) {

import { encodeU64 } from "./encoding.js";
import { sha512, sha512HashSize } from "./sha512.js";
import { SHA512_HASH_SIZE, sha512 } from "./sha512.js";
// otpEncrypt takes a key and some data and encrypts the data with the key. The

@@ -37,3 +37,3 @@ // encryption happens by generating a sequence of bytes using sha512 hashes and

// Iterate over the data and encrypt each section.
for (let i = skip; i < data.length; i += sha512HashSize) {
for (let i = skip; i < data.length; i += SHA512_HASH_SIZE) {
// Set the nonce for this shard and then create the pad data.

@@ -40,0 +40,0 @@ let [iBytes] = encodeU64(BigInt(i));

declare function addContextToErr(err: any, context: string): string;
declare function composeErr(...inputs: any): string | null;
export { addContextToErr, composeErr };
export { addContextToErr };

@@ -1,45 +0,14 @@

import { tryStringify } from "./stringifytry.js";
import { objAsString } from "./objAsString.js";
// addContextToErr is a helper function that standardizes the formatting of
// adding context to an error. Within the world of go we discovered that being
// persistent about layering context onto errors is helpful when debugging,
// even though it often creates rather verbose error messages.
// adding context to an error.
//
// addContextToErr will return null if the input err is null.
//
// NOTE: To protect against accidental situations where an Error type or some
// other type is provided instead of a string, we wrap both of the inputs with
// tryStringify before returning them. This prevents runtime failures.
// objAsString before returning them. This prevents runtime failures.
function addContextToErr(err, context) {
if (err === null) {
if (err === null || err === undefined) {
err = "[no error provided]";
}
err = tryStringify(err);
return tryStringify(context) + ": " + tryStringify(err);
return objAsString(context) + ": " + objAsString(err);
}
// composeErr takes a series of inputs and composes them into a single string.
// Each element will be separated by a newline. If the input is not a string,
// it will be transformed into a string with JSON.stringify.
//
// Any object that cannot be stringified will be skipped, though an error will
// be logged.
function composeErr(...inputs) {
let result = "";
let resultEmpty = true;
for (let i = 0; i < inputs.length; i++) {
if (inputs[i] === null) {
continue;
}
if (resultEmpty) {
resultEmpty = false;
}
else {
result += "\n";
}
result += tryStringify(inputs[i]);
}
if (resultEmpty) {
return null;
}
return result;
}
export { addContextToErr, composeErr };
export { addContextToErr };

@@ -9,12 +9,13 @@ export { downloadSkylink } from "./apidownloadskylink.js";

export { dictionary } from "./dictionary.js";
export { ed25519Keypair, ed25519Sign, ed25519Verify } from "./ed25519.js";
export { Ed25519Keypair, ed25519KeypairFromEntropy, ed25519Sign, ed25519Verify } from "./ed25519.js";
export { b64ToBuf, bufToB64, bufToHex, bufToStr, encodePrefixedBytes, encodeU64, hexToBuf } from "./encoding.js";
export { addContextToErr, composeErr } from "./err.js";
export { addContextToErr } from "./err.js";
export { decryptFileSmall, encryptFileSmall } from "./fileprivate.js";
export { namespaceInode } from "./inode.js";
export { blake2bAddLeafBytesToProofStack, blake2bMerkleRoot, blake2bProofStackRoot } from "./merkle.js";
export { objAsString } from "./objAsString.js";
export { parseJSON } from "./parse.js";
export { computeRegistrySignature, deriveRegistryEntryID, entryIDToSkylink, skylinkToResolverEntryData, taggedRegistryEntryKeys, verifyRegistrySignature, } from "./registry.js";
export { deriveChildSeed, deriveMyskyRootKeypair, generateSeedPhraseDeterministic, seedPhraseToSeed, validSeedPhrase, } from "./seed.js";
export { sha512 } from "./sha512.js";
export { SHA512_HASH_SIZE, sha512 } from "./sha512.js";
export { parseSkylinkBitfield, skylinkV1Bitfield } from "./skylinkbitfield.js";

@@ -24,3 +25,2 @@ export { validateSkyfileMetadata, validateSkyfilePath, validSkylink } from "./skylinkvalidate.js";

export { jsonStringify } from "./stringifyjson.js";
export { tryStringify } from "./stringifytry.js";
export { dataFn, error, errFn, errTuple, kernelAuthStatus, requestOverrideResponse } from "./types.js";

@@ -9,12 +9,13 @@ export { downloadSkylink } from "./apidownloadskylink.js";

export { dictionary } from "./dictionary.js";
export { ed25519Sign, ed25519Verify } from "./ed25519.js";
export { ed25519KeypairFromEntropy, ed25519Sign, ed25519Verify } from "./ed25519.js";
export { b64ToBuf, bufToB64, bufToHex, bufToStr, encodePrefixedBytes, encodeU64, hexToBuf } from "./encoding.js";
export { addContextToErr, composeErr } from "./err.js";
export { addContextToErr } from "./err.js";
export { decryptFileSmall, encryptFileSmall } from "./fileprivate.js";
export { namespaceInode } from "./inode.js";
export { blake2bAddLeafBytesToProofStack, blake2bMerkleRoot, blake2bProofStackRoot } from "./merkle.js";
export { objAsString } from "./objAsString.js";
export { parseJSON } from "./parse.js";
export { computeRegistrySignature, deriveRegistryEntryID, entryIDToSkylink, skylinkToResolverEntryData, taggedRegistryEntryKeys, verifyRegistrySignature, } from "./registry.js";
export { deriveChildSeed, deriveMyskyRootKeypair, generateSeedPhraseDeterministic, seedPhraseToSeed, validSeedPhrase, } from "./seed.js";
export { sha512 } from "./sha512.js";
export { SHA512_HASH_SIZE, sha512 } from "./sha512.js";
export { parseSkylinkBitfield, skylinkV1Bitfield } from "./skylinkbitfield.js";

@@ -24,2 +25,1 @@ export { validateSkyfileMetadata, validateSkyfilePath, validSkylink } from "./skylinkvalidate.js";

export { jsonStringify } from "./stringifyjson.js";
export { tryStringify } from "./stringifytry.js";
// @ts-nocheck
import { tryStringify } from "./stringifytry.js";
import { objAsString } from "./objAsString.js";
// json_parse extracted from the json-bigint npm library

@@ -331,5 +331,5 @@ // regexpxs extracted from

catch (err) {
return [{}, tryStringify(err)];
return [{}, objAsString(err)];
}
}
export { parseJSON };

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

import { ed25519Keypair } from "./ed25519.js";
import { Ed25519Keypair } from "./ed25519.js";
import { error } from "./types.js";

@@ -7,4 +7,4 @@ declare function computeRegistrySignature(secretKey: Uint8Array, dataKey: Uint8Array, data: Uint8Array, revision: bigint): [signature: Uint8Array, err: error];

declare function skylinkToResolverEntryData(skylink: string): [Uint8Array, error];
declare function taggedRegistryEntryKeys(seed: Uint8Array, keypairTagStr: string, datakeyTagStr?: string): [ed25519Keypair, Uint8Array, string | null];
declare function taggedRegistryEntryKeys(seed: Uint8Array, keypairTagStr: string, datakeyTagStr?: string): [Ed25519Keypair, Uint8Array, string | null];
declare function verifyRegistrySignature(pubkey: Uint8Array, datakey: Uint8Array, data: Uint8Array, revision: bigint, sig: Uint8Array): boolean;
export { computeRegistrySignature, deriveRegistryEntryID, entryIDToSkylink, skylinkToResolverEntryData, taggedRegistryEntryKeys, verifyRegistrySignature, };

@@ -1,5 +0,5 @@

import { ed25519Keypair } from "./ed25519.js";
import { Ed25519Keypair } from "./ed25519.js";
declare const SEED_BYTES = 16;
declare function deriveChildSeed(parentSeed: Uint8Array, derivationTag: string): Uint8Array;
declare function deriveMyskyRootKeypair(userSeed: Uint8Array): ed25519Keypair;
declare function deriveMyskyRootKeypair(userSeed: Uint8Array): Ed25519Keypair;
declare function generateSeedPhraseDeterministic(password: string): [string, string | null];

@@ -6,0 +6,0 @@ declare function seedToChecksumWords(seed: Uint8Array): [string, string, string | null];

@@ -0,4 +1,4 @@

declare const SHA512_HASH_SIZE = 64;
declare const sha512internal: (out: Uint8Array, m: Uint8Array, n: number) => number;
declare function sha512(m: Uint8Array): Uint8Array;
declare const sha512HashSize = 64;
export { sha512, sha512internal, sha512HashSize };
export { SHA512_HASH_SIZE, sha512, sha512internal };

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

const HASH_SIZE = 64;
const SHA512_HASH_SIZE = 64;
const K = [

@@ -33,3 +33,4 @@ 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc, 0x3956c25b,

function crypto_hashblocks_hl(hh, hl, m, n) {
let wh = new Int32Array(16), wl = new Int32Array(16), bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7, bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7, th, tl, i, j, h, l, a, b, c, d;
const wh = new Int32Array(16), wl = new Int32Array(16);
let bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7, bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7, th, tl, i, j, h, l, a, b, c, d;
let ah0 = hh[0], ah1 = hh[1], ah2 = hh[2], ah3 = hh[3], ah4 = hh[4], ah5 = hh[5], ah6 = hh[6], ah7 = hh[7], al0 = hl[0], al1 = hl[1], al2 = hl[2], al3 = hl[3], al4 = hl[4], al5 = hl[5], al6 = hl[6], al7 = hl[7];

@@ -359,3 +360,4 @@ let pos = 0;

const sha512internal = function (out, m, n) {
let hh = new Int32Array(8), hl = new Int32Array(8), x = new Uint8Array(256), i, b = n;
const hh = new Int32Array(8), hl = new Int32Array(8), x = new Uint8Array(256), b = n;
let i;
hh[0] = 0x6a09e667;

@@ -394,7 +396,6 @@ hh[1] = 0xbb67ae85;

function sha512(m) {
const out = new Uint8Array(HASH_SIZE);
const out = new Uint8Array(SHA512_HASH_SIZE);
sha512internal(out, m, m.length);
return out;
}
const sha512HashSize = HASH_SIZE;
export { sha512, sha512internal, sha512HashSize };
export { SHA512_HASH_SIZE, sha512, sha512internal };
import { b64ToBuf, hexToBuf } from "./encoding.js";
import { addContextToErr } from "./err.js";
import { objAsString } from "./objAsString.js";
import { deriveRegistryEntryID, verifyRegistrySignature } from "./registry.js";
import { parseSkylinkBitfield } from "./skylinkbitfield.js";
import { validSkylink } from "./skylinkvalidate.js";
import { tryStringify } from "./stringifytry.js";
// Helper consts to make returning empty values alongside errors more

@@ -50,3 +50,3 @@ // convenient.

if (proof.type !== 1n) {
return [nu8, "registry entry has unrecognized type: " + tryStringify(proof.type)];
return [nu8, "registry entry has unrecognized type: " + objAsString(proof.type)];
}

@@ -109,3 +109,3 @@ let sigStr = proof.signature;

if (!Array.isArray(proof)) {
return [nu8, "provided proof is not an array: " + tryStringify(proof)];
return [nu8, "provided proof is not an array: " + objAsString(proof)];
}

@@ -112,0 +112,0 @@ if (proof.length === 0) {

import { addContextToErr } from "./err.js";
import { tryStringify } from "./stringifytry.js";
// stringifyjson.ts is split into a separate file to avoid a circular
// dependency. If you merge it with stringifytry.ts you have a circular import
// where err.js is importing stringify.js and stringify.js is importing err.js.
// Splitting the functions out resolves this issue.
import { objAsString } from "./objAsString.js";
// jsonStringify is a replacement for JSON.stringify that returns an error

@@ -20,5 +16,5 @@ // rather than throwing.

catch (err) {
return ["", addContextToErr(tryStringify(err), "unable to stringify object")];
return ["", addContextToErr(objAsString(err), "unable to stringify object")];
}
}
export { jsonStringify };

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

declare function tryStringify(obj: any): string;
export { tryStringify };
declare function tryStringify(obj: any): string
export { tryStringify }

@@ -7,39 +7,39 @@ // tryStringify will try to turn the provided input into a string. If the input

function tryStringify(obj) {
// Check for undefined input.
if (obj === undefined) {
return "[cannot stringify undefined input]";
}
if (obj === null) {
return "[null]";
}
// Parse the error into a string.
if (typeof obj === "string") {
return obj;
}
// Check if the object has a 'toString' method defined on it. To ensure
// that we don't crash or throw, check that the toString is a function, and
// also that the return value of toString is a string.
if (Object.prototype.hasOwnProperty.call(obj, "toString")) {
if (typeof obj.toString === "function") {
let str = obj.toString();
if (typeof str === "string") {
return str;
}
}
}
// If the object does not have a custom toString, attempt to perform a
// JSON.stringify. We add custom handling for bigints so that objects with
// bigints in them can still be stringified.
try {
return JSON.stringify(obj, (_, v) => {
if (typeof v === "bigint") {
return v.toString() + "n";
}
return v;
});
}
catch {
return "[stringify failed]";
}
// Check for undefined input.
if (obj === undefined) {
return "[cannot stringify undefined input]"
}
if (obj === null) {
return "[null]"
}
// Parse the error into a string.
if (typeof obj === "string") {
return obj
}
// Check if the object has a 'toString' method defined on it. To ensure
// that we don't crash or throw, check that the toString is a function, and
// also that the return value of toString is a string.
if (Object.prototype.hasOwnProperty.call(obj, "toString")) {
if (typeof obj.toString === "function") {
const str = obj.toString()
if (typeof str === "string") {
return str
}
}
}
// If the object does not have a custom toString, attempt to perform a
// JSON.stringify. We use a lot of bigints in libskynet, and calling
// JSON.stringify on an object with a bigint will cause a throw, so we add
// some custom handling to allow bigint objects to still be encoded.
try {
return JSON.stringify(obj, (_, v) => {
if (typeof v === "bigint") {
return Number(v)
}
return v
})
} catch {
return "[stringify failed]"
}
}
export { tryStringify };
export { tryStringify }
{
"name": "libskynet",
"version": "0.0.53",
"version": "0.0.55",
"author": "Skynet Labs",

@@ -5,0 +5,0 @@ "description": "helper library to interact with skynet's low level primitives",

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