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

@webcrypto/tools

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@webcrypto/tools - npm Package Compare versions

Comparing version 1.2.1 to 2.0.0

12

dist/lib/web-crypto-tools.js

@@ -33,4 +33,7 @@ "use strict";

const isJwkKey = !isTypedArray(rawKey) && typeof rawKey === 'object';
return Promise.resolve(getCryptoObject().subtle.importKey(isJwkKey ? 'jwk' : format, typeof rawKey === 'string' ? encode(rawKey) : rawKey, algorithm, false, // the original value will not be extractable
keyUsages));
return Promise.resolve(isJwkKey
? getCryptoObject().subtle.importKey('jwk', rawKey, algorithm, false, // the original value will not be extractable
keyUsages)
: getCryptoObject().subtle.importKey(format, typeof rawKey === 'string' ? encode(rawKey) : rawKey, algorithm, false, // the original value will not be extractable
keyUsages));
}

@@ -76,3 +79,6 @@ exports.generateBaseCryptoKey = generateBaseCryptoKey;

function encryptValue(data, cryptoKey, algorithm = { name: 'AES-GCM', iv: generateNonce() }) {
return Promise.resolve(getCryptoObject().subtle.encrypt(algorithm, cryptoKey, encode(data))).then(cryptoValue => [cryptoValue, algorithm.iv || null]);
return Promise.resolve(getCryptoObject().subtle.encrypt(algorithm, cryptoKey, encode(data))).then(cryptoValue => [
cryptoValue,
typeof algorithm === 'object' && 'iv' in algorithm ? algorithm.iv : null,
]);
}

@@ -79,0 +85,0 @@ exports.encryptValue = encryptValue;

@@ -36,4 +36,7 @@ 'use strict';

var isJwkKey = !isTypedArray(rawKey) && typeof rawKey === 'object';
return Promise.resolve(getCryptoObject().subtle.importKey(isJwkKey ? 'jwk' : format, typeof rawKey === 'string' ? encode(rawKey) : rawKey, algorithm, false, // the original value will not be extractable
keyUsages));
return Promise.resolve(isJwkKey
? getCryptoObject().subtle.importKey('jwk', rawKey, algorithm, false, // the original value will not be extractable
keyUsages)
: getCryptoObject().subtle.importKey(format, typeof rawKey === 'string' ? encode(rawKey) : rawKey, algorithm, false, // the original value will not be extractable
keyUsages));
}

@@ -79,3 +82,6 @@ function deriveCryptKey(cryptoBaseKey, deriveAlgorithmOrSalt, algorithmForOrIterations, keyUsages) {

if (algorithm === void 0) { algorithm = { name: 'AES-GCM', iv: generateNonce() }; }
return Promise.resolve(getCryptoObject().subtle.encrypt(algorithm, cryptoKey, encode(data))).then(function (cryptoValue) { return [cryptoValue, algorithm.iv || null]; });
return Promise.resolve(getCryptoObject().subtle.encrypt(algorithm, cryptoKey, encode(data))).then(function (cryptoValue) { return [
cryptoValue,
typeof algorithm === 'object' && 'iv' in algorithm ? algorithm.iv : null,
]; });
}

@@ -163,14 +169,14 @@ /**

exports.PBKDF2_ITERATIONS_DEFAULT = PBKDF2_ITERATIONS_DEFAULT;
exports.getCryptoObject = getCryptoObject;
exports.generateBaseCryptoKey = generateBaseCryptoKey;
exports.decode = decode;
exports.decryptValue = decryptValue;
exports.deriveCryptKey = deriveCryptKey;
exports.isTypedArray = isTypedArray;
exports.encode = encode;
exports.encryptValue = encryptValue;
exports.decryptValue = decryptValue;
exports.generateBaseCryptoKey = generateBaseCryptoKey;
exports.generateHash = generateHash;
exports.generateNonce = generateNonce;
exports.generateRandomValues = generateRandomValues;
exports.generateSalt = generateSalt;
exports.generateRandomValues = generateRandomValues;
exports.encode = encode;
exports.decode = decode;
exports.generateHash = generateHash;
exports.getCryptoObject = getCryptoObject;
exports.isTypedArray = isTypedArray;
//# sourceMappingURL=web-crypto-tools.cjs.js.map
/**
* Import Key Algorithms at Web Crypto API
*/
export declare type ImportAlgorithm = string | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | DhImportKeyParams | AesKeyAlgorithm;
export declare type ImportAlgorithm = AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm;
/**
* Import Key Web Crypto Algorithms
*/
export declare type OriginalKeyFormat = 'raw' | 'pkcs8' | 'spki' | 'jwk';
/**
* Derive Key Algorithms at at Web Crypto API
*/
export declare type DeriveAlgorithm = string | EcdhKeyDeriveParams | DhKeyDeriveParams | ConcatParams | HkdfCtrParams | Pbkdf2Params;
export declare type DeriveAlgorithm = AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params;
/**
* Derive Algorithms Params for Web Crypto API
*/
export declare type DerivedAlgorithmFor = string | AesDerivedKeyParams | HmacImportParams | ConcatParams | HkdfCtrParams | Pbkdf2Params;
export declare type DerivedAlgorithmFor = AlgorithmIdentifier | AesDerivedKeyParams | HmacImportParams | HkdfParams | Pbkdf2Params;
/**
* Params for Encrypt / Decrypt Algorithms at Web Crypto API
*/
export declare type CryptoAlgorithm = string | RsaOaepParams | AesCtrParams | AesCbcParams | AesCmacParams | AesGcmParams | AesCfbParams;
export declare type CryptoAlgorithm = AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams;
/**
* TypedArray used in Web Crypto API Algorithms
*/
export declare type TypedArray = Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array | DataView | ArrayBuffer;
/**
* Possible uses of Crypto Keys

@@ -63,3 +55,3 @@ */

*/
export declare function generateBaseCryptoKey(rawKey: string | TypedArray | JsonWebKey, algorithm?: ImportAlgorithm, keyUsages?: KeyUsage[], format?: OriginalKeyFormat): Promise<CryptoKey>;
export declare function generateBaseCryptoKey(rawKey: string | BufferSource | JsonWebKey, algorithm?: ImportAlgorithm, keyUsages?: KeyUsage[], format?: KeyFormat): Promise<CryptoKey>;
/**

@@ -75,3 +67,3 @@ * Derives a base Crypto Key to new one that can be used in encrypt / decrypt algorithms

*/
export declare function deriveCryptKey(cryptoBaseKey: CryptoKey, salt: TypedArray, iterations?: number, keyUsages?: CryptoKeyUsage[]): Promise<CryptoKey>;
export declare function deriveCryptKey(cryptoBaseKey: CryptoKey, salt: BufferSource, iterations?: number, keyUsages?: CryptoKeyUsage[]): Promise<CryptoKey>;
/**

@@ -87,3 +79,3 @@ * Derives a base Crypto Key to new one that can be used in encrypt / decrypt algorithms

*/
export declare function deriveCryptKey(cryptoBaseKey: CryptoKey, salt: TypedArray, algorithmFor?: DerivedAlgorithmFor, keyUsages?: CryptoKeyUsage[]): Promise<CryptoKey>;
export declare function deriveCryptKey(cryptoBaseKey: CryptoKey, salt: BufferSource, algorithmFor?: DerivedAlgorithmFor, keyUsages?: CryptoKeyUsage[]): Promise<CryptoKey>;
/**

@@ -106,3 +98,3 @@ * Derives a base Crypto Key to new one that can be used in encrypt / decrypt algorithms

*/
export declare function isTypedArray(data: unknown): data is TypedArray;
export declare function isTypedArray(data: unknown): data is BufferSource;
/**

@@ -116,3 +108,3 @@ * Encrypt a value with the given Crypto Key and Algorithm

*/
export declare function encryptValue(data: string | TypedArray, cryptoKey: CryptoKey, algorithm?: CryptoAlgorithm): Promise<[ArrayBuffer, TypedArray | null]>;
export declare function encryptValue(data: string | BufferSource, cryptoKey: CryptoKey, algorithm?: CryptoAlgorithm): Promise<[ArrayBuffer, BufferSource | null]>;
/**

@@ -126,3 +118,3 @@ * Decrypt a value with the given Crypto Key and Algorithm

*/
export declare function decryptValue(data: TypedArray, cryptoKey: CryptoKey, nonceOrAlgorithm: TypedArray | CryptoAlgorithm): Promise<ArrayBuffer>;
export declare function decryptValue(data: BufferSource, cryptoKey: CryptoKey, nonceOrAlgorithm: BufferSource | CryptoAlgorithm): Promise<ArrayBuffer>;
/**

@@ -156,3 +148,3 @@ * Generates random value to be used as nonce with encryption algorithms.

*/
export declare function encode(data: string | TypedArray): TypedArray;
export declare function encode(data: string | BufferSource): BufferSource;
/**

@@ -165,3 +157,3 @@ * Decode a ArrayBuffer value to a string.

*/
export declare function decode(data: string | TypedArray): string;
export declare function decode(data: string | BufferSource): string;
/**

@@ -174,2 +166,2 @@ * Generates a hash value for the given value.

*/
export declare function generateHash(data: string | TypedArray, algorithm?: string | Algorithm): Promise<ArrayBuffer>;
export declare function generateHash(data: string | BufferSource, algorithm?: string | Algorithm): Promise<ArrayBuffer>;

@@ -29,4 +29,7 @@ /**

const isJwkKey = !isTypedArray(rawKey) && typeof rawKey === 'object';
return Promise.resolve(getCryptoObject().subtle.importKey(isJwkKey ? 'jwk' : format, typeof rawKey === 'string' ? encode(rawKey) : rawKey, algorithm, false, // the original value will not be extractable
keyUsages));
return Promise.resolve(isJwkKey
? getCryptoObject().subtle.importKey('jwk', rawKey, algorithm, false, // the original value will not be extractable
keyUsages)
: getCryptoObject().subtle.importKey(format, typeof rawKey === 'string' ? encode(rawKey) : rawKey, algorithm, false, // the original value will not be extractable
keyUsages));
}

@@ -69,3 +72,6 @@ function deriveCryptKey(cryptoBaseKey, deriveAlgorithmOrSalt, algorithmForOrIterations = PBKDF2_ITERATIONS_DEFAULT, keyUsages = ['encrypt', 'decrypt']) {

function encryptValue(data, cryptoKey, algorithm = { name: 'AES-GCM', iv: generateNonce() }) {
return Promise.resolve(getCryptoObject().subtle.encrypt(algorithm, cryptoKey, encode(data))).then(cryptoValue => [cryptoValue, algorithm.iv || null]);
return Promise.resolve(getCryptoObject().subtle.encrypt(algorithm, cryptoKey, encode(data))).then(cryptoValue => [
cryptoValue,
typeof algorithm === 'object' && 'iv' in algorithm ? algorithm.iv : null,
]);
}

@@ -148,3 +154,3 @@ /**

export { PBKDF2_ITERATIONS_DEFAULT, getCryptoObject, generateBaseCryptoKey, deriveCryptKey, isTypedArray, encryptValue, decryptValue, generateNonce, generateSalt, generateRandomValues, encode, decode, generateHash };
export { PBKDF2_ITERATIONS_DEFAULT, decode, decryptValue, deriveCryptKey, encode, encryptValue, generateBaseCryptoKey, generateHash, generateNonce, generateRandomValues, generateSalt, getCryptoObject, isTypedArray };
//# sourceMappingURL=web-crypto-tools.es2015.js.map

@@ -32,4 +32,7 @@ /**

var isJwkKey = !isTypedArray(rawKey) && typeof rawKey === 'object';
return Promise.resolve(getCryptoObject().subtle.importKey(isJwkKey ? 'jwk' : format, typeof rawKey === 'string' ? encode(rawKey) : rawKey, algorithm, false, // the original value will not be extractable
keyUsages));
return Promise.resolve(isJwkKey
? getCryptoObject().subtle.importKey('jwk', rawKey, algorithm, false, // the original value will not be extractable
keyUsages)
: getCryptoObject().subtle.importKey(format, typeof rawKey === 'string' ? encode(rawKey) : rawKey, algorithm, false, // the original value will not be extractable
keyUsages));
}

@@ -75,3 +78,6 @@ function deriveCryptKey(cryptoBaseKey, deriveAlgorithmOrSalt, algorithmForOrIterations, keyUsages) {

if (algorithm === void 0) { algorithm = { name: 'AES-GCM', iv: generateNonce() }; }
return Promise.resolve(getCryptoObject().subtle.encrypt(algorithm, cryptoKey, encode(data))).then(function (cryptoValue) { return [cryptoValue, algorithm.iv || null]; });
return Promise.resolve(getCryptoObject().subtle.encrypt(algorithm, cryptoKey, encode(data))).then(function (cryptoValue) { return [
cryptoValue,
typeof algorithm === 'object' && 'iv' in algorithm ? algorithm.iv : null,
]; });
}

@@ -158,3 +164,3 @@ /**

export { PBKDF2_ITERATIONS_DEFAULT, getCryptoObject, generateBaseCryptoKey, deriveCryptKey, isTypedArray, encryptValue, decryptValue, generateNonce, generateSalt, generateRandomValues, encode, decode, generateHash };
export { PBKDF2_ITERATIONS_DEFAULT, decode, decryptValue, deriveCryptKey, encode, encryptValue, generateBaseCryptoKey, generateHash, generateNonce, generateRandomValues, generateSalt, getCryptoObject, isTypedArray };
//# sourceMappingURL=web-crypto-tools.module.js.map
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.webCryptoTools = {})));
(global = global || self, factory(global.webCryptoTools = {}));
}(this, (function (exports) { 'use strict';

@@ -38,4 +38,7 @@

var isJwkKey = !isTypedArray(rawKey) && typeof rawKey === 'object';
return Promise.resolve(getCryptoObject().subtle.importKey(isJwkKey ? 'jwk' : format, typeof rawKey === 'string' ? encode(rawKey) : rawKey, algorithm, false, // the original value will not be extractable
keyUsages));
return Promise.resolve(isJwkKey
? getCryptoObject().subtle.importKey('jwk', rawKey, algorithm, false, // the original value will not be extractable
keyUsages)
: getCryptoObject().subtle.importKey(format, typeof rawKey === 'string' ? encode(rawKey) : rawKey, algorithm, false, // the original value will not be extractable
keyUsages));
}

@@ -81,3 +84,6 @@ function deriveCryptKey(cryptoBaseKey, deriveAlgorithmOrSalt, algorithmForOrIterations, keyUsages) {

if (algorithm === void 0) { algorithm = { name: 'AES-GCM', iv: generateNonce() }; }
return Promise.resolve(getCryptoObject().subtle.encrypt(algorithm, cryptoKey, encode(data))).then(function (cryptoValue) { return [cryptoValue, algorithm.iv || null]; });
return Promise.resolve(getCryptoObject().subtle.encrypt(algorithm, cryptoKey, encode(data))).then(function (cryptoValue) { return [
cryptoValue,
typeof algorithm === 'object' && 'iv' in algorithm ? algorithm.iv : null,
]; });
}

@@ -165,14 +171,14 @@ /**

exports.PBKDF2_ITERATIONS_DEFAULT = PBKDF2_ITERATIONS_DEFAULT;
exports.getCryptoObject = getCryptoObject;
exports.generateBaseCryptoKey = generateBaseCryptoKey;
exports.decode = decode;
exports.decryptValue = decryptValue;
exports.deriveCryptKey = deriveCryptKey;
exports.isTypedArray = isTypedArray;
exports.encode = encode;
exports.encryptValue = encryptValue;
exports.decryptValue = decryptValue;
exports.generateBaseCryptoKey = generateBaseCryptoKey;
exports.generateHash = generateHash;
exports.generateNonce = generateNonce;
exports.generateRandomValues = generateRandomValues;
exports.generateSalt = generateSalt;
exports.generateRandomValues = generateRandomValues;
exports.encode = encode;
exports.decode = decode;
exports.generateHash = generateHash;
exports.getCryptoObject = getCryptoObject;
exports.isTypedArray = isTypedArray;

@@ -179,0 +185,0 @@ Object.defineProperty(exports, '__esModule', { value: true });

{
"name": "@webcrypto/tools",
"version": "1.2.1",
"version": "2.0.0",
"private": false,

@@ -111,4 +111,4 @@ "description": "A set of tools to facilitate and give good defaults for use of the native Web Crypto API.",

"@types/jasmine": "^3.10.3",
"@types/node": "^12.20.46",
"colors": "^1.3.2",
"@types/node": "^17.0.18",
"colors": "^1.4.0",
"commitizen": "^4.2.4",

@@ -119,14 +119,14 @@ "coveralls": "^3.1.1",

"husky": "^4.3.8",
"jasmine-core": "^3.99.0",
"karma": "^5.2.3",
"jasmine-core": "^4.0.0",
"karma": "^6.3.16",
"karma-chrome-launcher": "^3.1.0",
"karma-cli": "^2.0.0",
"karma-jasmine": "^3.3.1",
"karma-jasmine": "^4.0.1",
"karma-mocha-reporter": "^2.2.5",
"karma-typescript": "^5.5.3",
"lint-staged": "^8.0.0",
"lint-staged": "^12.3.4",
"lodash.camelcase": "^4.3.0",
"prettier": "^1.14.3",
"prompt": "^1.2.1",
"rollup": "^0.67.0",
"rollup": "^1.26.3",
"rollup-plugin-commonjs": "^9.1.8",

@@ -140,3 +140,3 @@ "rollup-plugin-json": "^3.1.0",

"shx": "^0.3.4",
"ts-node": "^8.10.2",
"ts-node": "^10.5.0",
"tslint": "^6.1.3",

@@ -146,4 +146,4 @@ "tslint-config-prettier": "^1.18.0",

"typedoc": "^0.22.11",
"typescript": "4.0.8"
"typescript": "^4.5.5"
}
}

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

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