@blake.regalia/belt
Advanced tools
Comparing version 0.34.1 to 0.35.0
@@ -0,1 +1,3 @@ | ||
/// <reference types="web" /> | ||
/// <reference types="web" /> | ||
import type { NaiveBase58, NaiveBase64, NaiveBase93, NaiveHexLower } from './strings'; | ||
@@ -71,2 +73,10 @@ import type { JsonValue, NaiveJsonString } from './types'; | ||
/** | ||
* Imports a {@link CryptoKey} from raw bytes | ||
* @param atu8_sk - the key's raw bytes | ||
* @param z_algo - the algorithm argument passed to `SubtleCrypto#importKey()` | ||
* @param da_usages - key usages argument | ||
* @returns the imported {@link CryptoKey} | ||
*/ | ||
export declare const import_key: (atu8_sk: Uint8Array, z_algo: Parameters<SubtleCrypto['importKey']>[2], da_usages: Parameters<SubtleCrypto['importKey']>[4], b_extractable?: boolean) => Promise<CryptoKey>; | ||
/** | ||
* Performs HMAC signing of the given message, **not the digest**. | ||
@@ -73,0 +83,0 @@ * @param atu8_sk private key |
"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.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; | ||
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.import_key = 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"); | ||
@@ -117,8 +117,9 @@ exports.SI_HASH_ALGORITHM_SHA256 = 'SHA-256'; | ||
* Imports a {@link CryptoKey} from raw bytes | ||
* @param atu8_sk - the key as raw bytes | ||
* @param z_algo - the algorithm argument | ||
* @param atu8_sk - the key's raw bytes | ||
* @param z_algo - the algorithm argument passed to `SubtleCrypto#importKey()` | ||
* @param da_usages - key usages argument | ||
* @returns the CryptoKey | ||
* @returns the imported {@link CryptoKey} | ||
*/ | ||
const import_key = (atu8_sk, z_algo, da_usages) => crypto.subtle.importKey('raw', atu8_sk, z_algo, false, da_usages); | ||
const import_key = (atu8_sk, z_algo, da_usages, b_extractable = false) => crypto.subtle.importKey('raw', atu8_sk, z_algo, b_extractable, da_usages); | ||
exports.import_key = import_key; | ||
/** | ||
@@ -132,3 +133,3 @@ * Performs HMAC signing of the given message, **not the digest**. | ||
// import signing private key | ||
const dk_sign = await import_key(atu8_sk, { | ||
const dk_sign = await (0, exports.import_key)(atu8_sk, { | ||
name: 'HMAC', | ||
@@ -151,3 +152,3 @@ hash: { name: si_algo }, | ||
// import deriving key | ||
const dk_derive = await import_key(atu8_ikm, 'HKDF', ['deriveBits']); | ||
const dk_derive = await (0, exports.import_key)(atu8_ikm, 'HKDF', ['deriveBits']); | ||
// derive the bits | ||
@@ -154,0 +155,0 @@ return (0, exports.bytes)(await crypto.subtle.deriveBits({ |
@@ -0,1 +1,3 @@ | ||
/// <reference types="web" /> | ||
/// <reference types="web" /> | ||
import type { NaiveBase58, NaiveBase64, NaiveBase93, NaiveHexLower } from './strings'; | ||
@@ -71,2 +73,10 @@ import type { JsonValue, NaiveJsonString } from './types'; | ||
/** | ||
* Imports a {@link CryptoKey} from raw bytes | ||
* @param atu8_sk - the key's raw bytes | ||
* @param z_algo - the algorithm argument passed to `SubtleCrypto#importKey()` | ||
* @param da_usages - key usages argument | ||
* @returns the imported {@link CryptoKey} | ||
*/ | ||
export declare const import_key: (atu8_sk: Uint8Array, z_algo: Parameters<SubtleCrypto['importKey']>[2], da_usages: Parameters<SubtleCrypto['importKey']>[4], b_extractable?: boolean) => Promise<CryptoKey>; | ||
/** | ||
* Performs HMAC signing of the given message, **not the digest**. | ||
@@ -73,0 +83,0 @@ * @param atu8_sk private key |
@@ -106,8 +106,8 @@ import { XG_8, is_array, is_dict_es, is_string, entries, from_entries, transform_values, die, try_sync } from './belt.js'; | ||
* Imports a {@link CryptoKey} from raw bytes | ||
* @param atu8_sk - the key as raw bytes | ||
* @param z_algo - the algorithm argument | ||
* @param atu8_sk - the key's raw bytes | ||
* @param z_algo - the algorithm argument passed to `SubtleCrypto#importKey()` | ||
* @param da_usages - key usages argument | ||
* @returns the CryptoKey | ||
* @returns the imported {@link CryptoKey} | ||
*/ | ||
const import_key = (atu8_sk, z_algo, da_usages) => crypto.subtle.importKey('raw', atu8_sk, z_algo, false, da_usages); | ||
export const import_key = (atu8_sk, z_algo, da_usages, b_extractable = false) => crypto.subtle.importKey('raw', atu8_sk, z_algo, b_extractable, da_usages); | ||
/** | ||
@@ -114,0 +114,0 @@ * Performs HMAC signing of the given message, **not the digest**. |
{ | ||
"name": "@blake.regalia/belt", | ||
"version": "0.34.1", | ||
"version": "0.35.0", | ||
"repository": "github:blake-regalia/belt", | ||
@@ -22,7 +22,7 @@ "license": "ISC", | ||
"scripts": { | ||
"build:mjs": "yarn tsc -p tsconfig.mjs.json", | ||
"build:cjs": "yarn tsc -p tsconfig.cjs.json", | ||
"build": "yarn build:mjs && yarn build:cjs", | ||
"build:mjs": "tsc -p tsconfig.mjs.json", | ||
"build:cjs": "tsc -p tsconfig.cjs.json", | ||
"build": "pnpm run build:mjs && pnpm run build:cjs", | ||
"bundle": "rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript", | ||
"test": "yarn build && bun test ./test/*.ts" | ||
"test": "pnpm run build && bun test ./test/*.ts" | ||
}, | ||
@@ -36,3 +36,3 @@ "devDependencies": { | ||
"@types/web": "^0.0.142", | ||
"@typescript-eslint/parser": "^7.3.1", | ||
"@typescript-eslint/parser": "^7.4.0", | ||
"bun": "^1.0.35", | ||
@@ -39,0 +39,0 @@ "bun-types": "^1.0.35", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
273633
5239