New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@blake.regalia/belt

Package Overview
Dependencies
Maintainers
1
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blake.regalia/belt - npm Package Compare versions

Comparing version 0.32.6 to 0.33.0

14

dist/cjs/data.d.ts
import type { NaiveBase58, NaiveBase64, NaiveBase93, NaiveHexLower } from './strings';
import type { JsonValue, NaiveJsonString } from './types';
export declare const SI_HASH_ALGORITHM_SHA256 = "SHA-256";
export declare const SI_HASH_ALGORITHM_SHA384 = "SHA-384";
export declare const SI_HASH_ALGORITHM_SHA512 = "SHA-512";
export declare const uuid_v4: () => string;

@@ -73,4 +76,13 @@ type Uint8ArrayConstructorParams = [] | [length: number] | [array: ArrayLike<number> | ArrayBufferLike] | [buffer: ArrayBufferLike, byteOffset?: number, length?: number];

*/
export declare const hmac: (atu8_sk: Uint8Array, atu8_message: Uint8Array, si_algo?: 'SHA-256' | 'SHA-512') => Promise<Uint8Array>;
export declare const hmac: (atu8_sk: Uint8Array, atu8_message: Uint8Array, si_algo?: 'SHA-256' | 'SHA-384' | 'SHA-512') => Promise<Uint8Array>;
/**
* Performs HKDF on the given IKM
* @param atu8_ikm - the input key material bytes
* @param ni_bits - number of bits to target
* @param atu8_salt - salt bytes
* @param atu8_info - optional info bytes
* @param si_algo - hashing algorithm to use
*/
export declare const hkdf: (atu8_ikm: Uint8Array, ni_bits: number, atu8_salt: Uint8Array, atu8_info?: Uint8Array, si_algo?: 'SHA-256' | 'SHA-384' | 'SHA-512') => Promise<Uint8Array>;
/**
* Wipe the contents of a buffer so that sensitive data does not outlive garbage collection.

@@ -77,0 +89,0 @@ */

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.crypto_random_int = exports.crypto_random = exports.base58_to_bytes = exports.bytes_to_base58 = exports.base93_to_bytes = exports.bytes_to_base93 = exports.string8_to_bytes = exports.base64_to_bytes = exports.bytes_to_base64 = exports.base64_to_bytes_slim = exports.bytes_to_base64_slim = exports.hex_to_bytes = exports.bytes_to_hex = exports.concat2 = exports.concat = exports.bytes_to_bigint_be = exports.bytes_to_biguint_be = exports.bigint_to_bytes_be = exports.biguint_to_bytes_be = exports.bytes_to_uint32_be = exports.uint32_to_bytes_be = exports.bytes_to_json = exports.json_to_bytes = exports.text_to_base64 = exports.base64_to_text = exports.bytes_to_text = exports.text_to_bytes = exports.decode_length_prefix_u16 = exports.encode_length_prefix_u16 = exports.zero_out = exports.hmac = exports.sha512 = exports.sha384 = exports.sha256d = exports.sha256 = exports.dataview = exports.bytes = exports.canonicalize_json = exports.safe_json = exports.parse_json_safe = exports.parse_json = exports.stringify_json = exports.uuid_v4 = void 0;
exports.crypto_random_int = exports.crypto_random = exports.base58_to_bytes = exports.bytes_to_base58 = exports.base93_to_bytes = exports.bytes_to_base93 = exports.string8_to_bytes = exports.base64_to_bytes = exports.bytes_to_base64 = exports.base64_to_bytes_slim = exports.bytes_to_base64_slim = exports.hex_to_bytes = exports.bytes_to_hex = exports.concat2 = exports.concat = exports.bytes_to_bigint_be = exports.bytes_to_biguint_be = exports.bigint_to_bytes_be = exports.biguint_to_bytes_be = exports.bytes_to_uint32_be = exports.uint32_to_bytes_be = exports.bytes_to_json = exports.json_to_bytes = exports.text_to_base64 = exports.base64_to_text = exports.bytes_to_text = exports.text_to_bytes = exports.decode_length_prefix_u16 = exports.encode_length_prefix_u16 = exports.zero_out = exports.hkdf = exports.hmac = exports.sha512 = exports.sha384 = exports.sha256d = exports.sha256 = exports.dataview = exports.bytes = exports.canonicalize_json = exports.safe_json = exports.parse_json_safe = exports.parse_json = exports.stringify_json = exports.uuid_v4 = exports.SI_HASH_ALGORITHM_SHA512 = exports.SI_HASH_ALGORITHM_SHA384 = exports.SI_HASH_ALGORITHM_SHA256 = void 0;
const belt_js_1 = require("./belt.js");
exports.SI_HASH_ALGORITHM_SHA256 = 'SHA-256';
exports.SI_HASH_ALGORITHM_SHA384 = 'SHA-384';
exports.SI_HASH_ALGORITHM_SHA512 = 'SHA-512';
// eslint-disable-next-line @typescript-eslint/naming-convention

@@ -84,3 +87,3 @@ const S_UUID_V4 = 'xxxxxxxx_xxxx_4xxx_yxxx_xxxxxxxxxxxx';

*/
const sha256 = async (atu8_data) => (0, exports.bytes)(await crypto.subtle.digest('SHA-256', atu8_data));
const sha256 = async (atu8_data) => (0, exports.bytes)(await crypto.subtle.digest(exports.SI_HASH_ALGORITHM_SHA256, atu8_data));
exports.sha256 = sha256;

@@ -104,3 +107,3 @@ /**

*/
const sha384 = async (atu8_data) => (0, exports.bytes)(await crypto.subtle.digest('SHA-384', atu8_data));
const sha384 = async (atu8_data) => (0, exports.bytes)(await crypto.subtle.digest(exports.SI_HASH_ALGORITHM_SHA384, atu8_data));
exports.sha384 = sha384;

@@ -112,5 +115,13 @@ /**

*/
const sha512 = async (atu8_data) => (0, exports.bytes)(await crypto.subtle.digest('SHA-512', atu8_data));
const sha512 = async (atu8_data) => (0, exports.bytes)(await crypto.subtle.digest(exports.SI_HASH_ALGORITHM_SHA512, atu8_data));
exports.sha512 = sha512;
/**
* Imports a {@link CryptoKey} from raw bytes
* @param atu8_sk - the key as raw bytes
* @param z_algo - the algorithm argument
* @param da_usages - key usages argument
* @returns the CryptoKey
*/
const import_key = (atu8_sk, z_algo, da_usages) => crypto.subtle.importKey('raw', atu8_sk, z_algo, false, da_usages);
/**
* Performs HMAC signing of the given message, **not the digest**.

@@ -121,8 +132,8 @@ * @param atu8_sk private key

*/
const hmac = async (atu8_sk, atu8_message, si_algo = 'SHA-256') => {
const hmac = async (atu8_sk, atu8_message, si_algo = exports.SI_HASH_ALGORITHM_SHA256) => {
// import signing private key
const dk_sign = await crypto.subtle.importKey('raw', atu8_sk, {
const dk_sign = await import_key(atu8_sk, {
name: 'HMAC',
hash: { name: si_algo },
}, false, ['sign']);
}, ['sign']);
// construct hmac signature

@@ -133,2 +144,22 @@ return (0, exports.bytes)(await crypto.subtle.sign('HMAC', dk_sign, atu8_message));

/**
* Performs HKDF on the given IKM
* @param atu8_ikm - the input key material bytes
* @param ni_bits - number of bits to target
* @param atu8_salt - salt bytes
* @param atu8_info - optional info bytes
* @param si_algo - hashing algorithm to use
*/
const hkdf = async (atu8_ikm, ni_bits, atu8_salt, atu8_info = (0, exports.bytes)(), si_algo = exports.SI_HASH_ALGORITHM_SHA256) => {
// import deriving key
const dk_derive = await import_key(atu8_ikm, 'HKDF', ['deriveBits']);
// derive the bits
return (0, exports.bytes)(await crypto.subtle.deriveBits({
name: 'HKDF',
hash: si_algo,
salt: atu8_salt,
info: atu8_info,
}, dk_derive, ni_bits));
};
exports.hkdf = hkdf;
/**
* Wipe the contents of a buffer so that sensitive data does not outlive garbage collection.

@@ -135,0 +166,0 @@ */

import type { NaiveBase58, NaiveBase64, NaiveBase93, NaiveHexLower } from './strings';
import type { JsonValue, NaiveJsonString } from './types';
export declare const SI_HASH_ALGORITHM_SHA256 = "SHA-256";
export declare const SI_HASH_ALGORITHM_SHA384 = "SHA-384";
export declare const SI_HASH_ALGORITHM_SHA512 = "SHA-512";
export declare const uuid_v4: () => string;

@@ -73,4 +76,13 @@ type Uint8ArrayConstructorParams = [] | [length: number] | [array: ArrayLike<number> | ArrayBufferLike] | [buffer: ArrayBufferLike, byteOffset?: number, length?: number];

*/
export declare const hmac: (atu8_sk: Uint8Array, atu8_message: Uint8Array, si_algo?: 'SHA-256' | 'SHA-512') => Promise<Uint8Array>;
export declare const hmac: (atu8_sk: Uint8Array, atu8_message: Uint8Array, si_algo?: 'SHA-256' | 'SHA-384' | 'SHA-512') => Promise<Uint8Array>;
/**
* Performs HKDF on the given IKM
* @param atu8_ikm - the input key material bytes
* @param ni_bits - number of bits to target
* @param atu8_salt - salt bytes
* @param atu8_info - optional info bytes
* @param si_algo - hashing algorithm to use
*/
export declare const hkdf: (atu8_ikm: Uint8Array, ni_bits: number, atu8_salt: Uint8Array, atu8_info?: Uint8Array, si_algo?: 'SHA-256' | 'SHA-384' | 'SHA-512') => Promise<Uint8Array>;
/**
* Wipe the contents of a buffer so that sensitive data does not outlive garbage collection.

@@ -77,0 +89,0 @@ */

import { XG_8, is_array, is_dict_es, is_string, entries, from_entries, transform_values, die, try_sync } from './belt.js';
export const SI_HASH_ALGORITHM_SHA256 = 'SHA-256';
export const SI_HASH_ALGORITHM_SHA384 = 'SHA-384';
export const SI_HASH_ALGORITHM_SHA512 = 'SHA-512';
// eslint-disable-next-line @typescript-eslint/naming-convention

@@ -77,3 +80,3 @@ const S_UUID_V4 = 'xxxxxxxx_xxxx_4xxx_yxxx_xxxxxxxxxxxx';

*/
export const sha256 = async (atu8_data) => bytes(await crypto.subtle.digest('SHA-256', atu8_data));
export const sha256 = async (atu8_data) => bytes(await crypto.subtle.digest(SI_HASH_ALGORITHM_SHA256, atu8_data));
/**

@@ -95,3 +98,3 @@ * Performs SHA-256(SHA-256(data))

*/
export const sha384 = async (atu8_data) => bytes(await crypto.subtle.digest('SHA-384', atu8_data));
export const sha384 = async (atu8_data) => bytes(await crypto.subtle.digest(SI_HASH_ALGORITHM_SHA384, atu8_data));
/**

@@ -102,4 +105,12 @@ * Performs SHA-512 hash on the given data.

*/
export const sha512 = async (atu8_data) => bytes(await crypto.subtle.digest('SHA-512', atu8_data));
export const sha512 = async (atu8_data) => bytes(await crypto.subtle.digest(SI_HASH_ALGORITHM_SHA512, atu8_data));
/**
* Imports a {@link CryptoKey} from raw bytes
* @param atu8_sk - the key as raw bytes
* @param z_algo - the algorithm argument
* @param da_usages - key usages argument
* @returns the CryptoKey
*/
const import_key = (atu8_sk, z_algo, da_usages) => crypto.subtle.importKey('raw', atu8_sk, z_algo, false, da_usages);
/**
* Performs HMAC signing of the given message, **not the digest**.

@@ -110,8 +121,8 @@ * @param atu8_sk private key

*/
export const hmac = async (atu8_sk, atu8_message, si_algo = 'SHA-256') => {
export const hmac = async (atu8_sk, atu8_message, si_algo = SI_HASH_ALGORITHM_SHA256) => {
// import signing private key
const dk_sign = await crypto.subtle.importKey('raw', atu8_sk, {
const dk_sign = await import_key(atu8_sk, {
name: 'HMAC',
hash: { name: si_algo },
}, false, ['sign']);
}, ['sign']);
// construct hmac signature

@@ -121,2 +132,21 @@ return bytes(await crypto.subtle.sign('HMAC', dk_sign, atu8_message));

/**
* Performs HKDF on the given IKM
* @param atu8_ikm - the input key material bytes
* @param ni_bits - number of bits to target
* @param atu8_salt - salt bytes
* @param atu8_info - optional info bytes
* @param si_algo - hashing algorithm to use
*/
export const hkdf = async (atu8_ikm, ni_bits, atu8_salt, atu8_info = bytes(), si_algo = SI_HASH_ALGORITHM_SHA256) => {
// import deriving key
const dk_derive = await import_key(atu8_ikm, 'HKDF', ['deriveBits']);
// derive the bits
return bytes(await crypto.subtle.deriveBits({
name: 'HKDF',
hash: si_algo,
salt: atu8_salt,
info: atu8_info,
}, dk_derive, ni_bits));
};
/**
* Wipe the contents of a buffer so that sensitive data does not outlive garbage collection.

@@ -123,0 +153,0 @@ */

18

package.json
{
"name": "@blake.regalia/belt",
"version": "0.32.6",
"version": "0.33.0",
"repository": "github:blake-regalia/belt",

@@ -22,4 +22,4 @@ "license": "ISC",

"scripts": {
"build:mjs": "tsc -p tsconfig.mjs.json",
"build:cjs": "tsc -p tsconfig.cjs.json",
"build:mjs": "yarn tsc -p tsconfig.mjs.json",
"build:cjs": "yarn tsc -p tsconfig.cjs.json",
"build": "yarn build:mjs && yarn build:cjs",

@@ -34,10 +34,10 @@ "bundle": "rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript",

"@rollup/plugin-typescript": "^11.1.6",
"@types/node": "^20.11.24",
"@types/web": "^0.0.140",
"@typescript-eslint/parser": "^7.1.0",
"bun": "^1.0.29",
"bun-types": "^1.0.29",
"@types/node": "^20.11.27",
"@types/web": "^0.0.142",
"@typescript-eslint/parser": "^7.2.0",
"bun": "^1.0.30",
"bun-types": "^1.0.30",
"eslint": "^8.57.0",
"jest": "^29.7.0",
"rollup": "^4.12.0",
"rollup": "^4.13.0",
"ts-node": "^10.9.2",

@@ -44,0 +44,0 @@ "ts-toolbelt": "^9.6.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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