aesgcm_password_codec
Advanced tools
Comparing version 0.2.0 to 0.2.2
130
cjs/index.js
'use strict'; | ||
function aesgcm_password_codec_options(options) { | ||
if ('string' === typeof options) { | ||
options = { salt: options }; | ||
} else if (null == options) { | ||
options = {}; | ||
} | ||
if ('string' === typeof options) { | ||
options ={salt: options}; } | ||
else if (null == options) { | ||
options = {};} | ||
const pbkdf2 = Object.assign({ hash: 'SHA-256', | ||
salt: options.salt, | ||
iterations: options.iterations || 100000, | ||
__proto__: { | ||
salt_bytes: 16 } }, options.pbkdf2); | ||
const pbkdf2 = Object.assign( | ||
{hash: 'SHA-256' | ||
, salt: options.salt | ||
, iterations: options.iterations || 100000 | ||
, __proto__:{ | ||
salt_bytes: 16} } | ||
, options.pbkdf2); | ||
const cipher = Object.assign({ alg: 'AES-GCM', length: 128, tagLength: 128, | ||
__proto__: { | ||
iv_bytes: 12 } }, options.cipher); | ||
const cipher = Object.assign( | ||
{alg: 'AES-GCM', length: 128, tagLength: 128 | ||
, __proto__:{ | ||
iv_bytes: 12} } | ||
, options.cipher); | ||
pbkdf2.keylen = cipher.length / 8; | ||
return { pbkdf2, cipher, | ||
get extractable() { | ||
return true === options.extractable; | ||
} }; | ||
} | ||
return {pbkdf2, cipher | ||
, get extractable() {return true === options.extractable} } } | ||
function aesgcm_password_codec_api(base_api) { | ||
const { encrypt_u8, decrypt_u8, utf8_to_u8, u8_to_utf8 } = base_api; | ||
return { | ||
__proto__: base_api, | ||
__proto__: base_api | ||
encrypt_json: obj => encrypt_u8(utf8_to_u8(JSON.stringify(obj))), | ||
, encrypt_json: obj => | ||
encrypt_u8( | ||
utf8_to_u8( | ||
JSON.stringify(obj)) ) | ||
decrypt_json: enc_rec_b64 => decrypt_u8(enc_rec_b64).then(u8 => JSON.parse(u8_to_utf8(u8))), | ||
, decrypt_json: enc_rec_b64 => | ||
decrypt_u8(enc_rec_b64) | ||
.then(u8 => JSON.parse(u8_to_utf8(u8) )) | ||
encrypt_utf8: str => encrypt_u8(utf8_to_u8(str)), | ||
, encrypt_utf8: str => | ||
encrypt_u8(utf8_to_u8(str)) | ||
decrypt_utf8: enc_rec_b64 => decrypt_u8(enc_rec_b64).then(u8 => u8_to_utf8(u8)) }; | ||
} | ||
, decrypt_utf8: enc_rec_b64 => | ||
decrypt_u8(enc_rec_b64) | ||
.then(u8 => u8_to_utf8(u8)) } } | ||
@@ -49,11 +57,15 @@ const { promisify } = require('util'); | ||
if (null == options.pbkdf2.salt) { | ||
options.pbkdf2.salt = u8_to_base64(randomBytes(options.pbkdf2.salt_bytes)); | ||
} | ||
options.pbkdf2.salt = u8_to_base64( | ||
randomBytes(options.pbkdf2.salt_bytes) ); } | ||
if ('string' === typeof password) { | ||
return aes_key_from_password(password, options).then(with_aes_key); | ||
} | ||
if ('string' === typeof password) { | ||
return aes_key_from_password(password, options) | ||
.then(with_aes_key) } | ||
return Promise.resolve(with_aes_key(Buffer.from(password.aes_key, 'base64'))); | ||
return Promise.resolve( | ||
with_aes_key( | ||
Buffer.from( | ||
password.aes_key, 'base64') ) ) | ||
function with_aes_key(sk_aes_p) { | ||
@@ -67,45 +79,55 @@ const sk_aes = sk_aes_p; | ||
utf8_to_u8, u8_to_utf8, | ||
u8_to_base64, base64_to_u8 }); | ||
u8_to_base64, base64_to_u8, }) | ||
function export_aeskey() { | ||
return Promise.resolve(!options.extractable ? null : { aes_key: sk_aes.toString('base64') }); | ||
} | ||
return Promise.resolve( | ||
! options.extractable ? null | ||
:{aes_key: sk_aes.toString('base64')} ) } | ||
function encrypt_u8(u8) { | ||
const iv = randomBytes(iv_bytes); | ||
const cipher = createCipheriv(`aes-${options.cipher.length}-gcm`, sk_aes, iv, { authTagLength: options.cipher.tagLength / 8 }); | ||
const cipher = createCipheriv( | ||
`aes-${options.cipher.length}-gcm`, sk_aes, iv | ||
, {authTagLength: options.cipher.tagLength/8} ); | ||
const enc_data = Buffer.concat([cipher.update(Buffer.from(u8)), cipher.final(), cipher.getAuthTag()]); | ||
return Promise.resolve(`${u8_to_base64(iv)} ${u8_to_base64(enc_data)}`); | ||
} | ||
const enc_data = Buffer.concat([ | ||
cipher.update(Buffer.from(u8)) | ||
, cipher.final() | ||
, cipher.getAuthTag()]); | ||
return Promise.resolve( | ||
`${u8_to_base64(iv)} ${u8_to_base64(enc_data)}`) } | ||
function decrypt_u8(enc_rec_b64) { | ||
const [iv, enc_data] = enc_rec_b64.split(' ').map(base64_to_u8); | ||
const decipher = createDecipheriv(`aes-${options.cipher.length}-gcm`, sk_aes, Buffer.from(iv), { authTagLength: options.cipher.tagLength / 8 }); | ||
const decipher = createDecipheriv( | ||
`aes-${options.cipher.length}-gcm`, sk_aes, Buffer.from(iv) | ||
, {authTagLength: options.cipher.tagLength/8} ); | ||
decipher.setAuthTag(enc_data.slice(-tag_bytes)); | ||
const buf = Buffer.concat([decipher.update(enc_data.slice(0, -tag_bytes)), decipher.final()]); | ||
return Promise.resolve(Uint8Array.from(buf).buffer); | ||
} | ||
} | ||
} | ||
const buf = Buffer.concat([ | ||
decipher.update(enc_data.slice(0,-tag_bytes)) | ||
, decipher.final()]); | ||
return Promise.resolve( | ||
Uint8Array.from(buf).buffer) } } } | ||
function aes_key_from_password(password, options) { | ||
return async_pbkdf2(Buffer.from(password), Buffer.from(options.pbkdf2.salt, 'base64'), options.pbkdf2.iterations, options.pbkdf2.keylen, options.pbkdf2.hash.toLowerCase().replace('-', '')); | ||
} | ||
return async_pbkdf2( | ||
Buffer.from(password) | ||
, Buffer.from(options.pbkdf2.salt, 'base64') | ||
, options.pbkdf2.iterations | ||
, options.pbkdf2.keylen | ||
, options.pbkdf2.hash.toLowerCase().replace('-','')) } | ||
function utf8_to_u8(utf8) { | ||
return Buffer.from(utf8, 'utf-8'); | ||
} | ||
return Buffer.from(utf8, 'utf-8')} | ||
function u8_to_utf8(u8) { | ||
return Buffer.from(u8).toString('utf-8'); | ||
} | ||
return Buffer.from(u8).toString('utf-8')} | ||
function u8_to_base64(u8) { | ||
return Buffer.from(u8).toString('base64'); | ||
} | ||
return Buffer.from(u8).toString('base64')} | ||
function base64_to_u8(str_b64) { | ||
return new Uint8Array(Buffer.from(str_b64, 'base64')); | ||
} | ||
return new Uint8Array(Buffer.from(str_b64, 'base64')) } | ||
module.exports = aesgcm_password_codec_nodejs; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VzIjpbIi4uL2NvZGUvaW1wbF9jb21tb24uanN5IiwiLi4vY29kZS9pbXBsX25vZGVqcy5qc3kiXSwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGZ1bmN0aW9uIGFlc2djbV9wYXNzd29yZF9jb2RlY19vcHRpb25zKG9wdGlvbnMpIDo6XG4gIGlmICdzdHJpbmcnID09PSB0eXBlb2Ygb3B0aW9ucyA6OlxuICAgIG9wdGlvbnMgPSBAe30gc2FsdDogb3B0aW9uc1xuICBlbHNlIGlmIG51bGwgPT0gb3B0aW9ucyA6OlxuICAgIG9wdGlvbnMgPSB7fVxuXG4gIGNvbnN0IHBia2RmMiA9IE9iamVjdC5hc3NpZ24gQFxuICAgIEB7fSBoYXNoOiAnU0hBLTI1NidcbiAgICAgICAgc2FsdDogb3B0aW9ucy5zYWx0XG4gICAgICAgIGl0ZXJhdGlvbnM6IG9wdGlvbnMuaXRlcmF0aW9ucyB8fCAxMDAwMDBcbiAgICAgICAgX19wcm90b19fOiBAe31cbiAgICAgICAgICBzYWx0X2J5dGVzOiAxNlxuICAgIG9wdGlvbnMucGJrZGYyXG5cbiAgY29uc3QgY2lwaGVyID0gT2JqZWN0LmFzc2lnbiBAXG4gICAgQHt9IGFsZzogJ0FFUy1HQ00nLCBsZW5ndGg6IDEyOCwgdGFnTGVuZ3RoOiAxMjhcbiAgICAgICAgX19wcm90b19fOiBAe31cbiAgICAgICAgICBpdl9ieXRlczogMTJcbiAgICBvcHRpb25zLmNpcGhlclxuXG4gIHBia2RmMi5rZXlsZW4gPSBjaXBoZXIubG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QUU3QyxvQkFBcUI7TUFDckI7UUFDRSxnQkFBaUI7UUFDakI7TUFDRjtRQUNFOztBQUVSO0VBQ0U7SUFDRSxZQUFhO0lBQ2IsWUFBYSxxQkFBc0I7SUFDbkM7SUFDQTtJQUNBLDBDQUEwQyxHQUFHLENBQUMsRUFBRTs7OztBQUlwRDtFQUNFLHlCQUF5QixPQUFPO0FBQ2xDO0VBQ0UsZ0NBQWdDLE9BQU87QUFDekM7RUFDRSxnQ0FBZ0MsUUFBUTtBQUMxQztFQUNFLHNCQUF1QixxQkFBc0IsUUFBUTs7OzsifQ== |
{ | ||
"name": "aesgcm_password_codec", | ||
"version": "0.2.0", | ||
"version": "0.2.2", | ||
"description": "Isomorphic PBKDF2 + AES-GCM password codec", | ||
@@ -26,14 +26,9 @@ "license": "BSD-2-Clause", | ||
"aesgcm_password_codec": "file:.", | ||
"babel-cli": "^6.26.0", | ||
"babel-core": "^6.26.3", | ||
"babel-preset-jsy": "^0.11.2", | ||
"chai": "^4.1.2", | ||
"jsy-transpile": "^0.2.5", | ||
"mocha": "^5.2.0", | ||
"rollup": "^0.63.4", | ||
"rollup-plugin-jsy-babel": "^2.1.2", | ||
"rollup-plugin-terser": "^1.0.1" | ||
"rollup": "^0.65.0", | ||
"rollup-plugin-jsy-lite": "^1.2.1", | ||
"rollup-plugin-terser": "^2.0.2" | ||
}, | ||
"babel": { | ||
"presets": "jsy/lean" | ||
}, | ||
"scripts": { | ||
@@ -40,0 +35,0 @@ "clean": "rm -rf ./cjs/* ./esm/* ./umd/*", |
@@ -26,6 +26,6 @@ # AES GCM Password Codec | ||
console.log(aes_codec.options) | ||
/* --> | ||
{ pbkdf2: { hash: 'SHA-256', salt: '+t07slf9nBY9Z5PPynvF2g==', iterations: 1000000, keylen: 16 }, | ||
cipher: { alg: 'AES-GCM', length: 128, tagLength: 128 }, | ||
iv_size: 12, extractable: undefined } | ||
/* --> { pbkdf2: { hash: 'SHA-256', salt: '+t07slf9nBY9Z5PPynvF2g==', | ||
iterations: 100000, keylen: 16 }, | ||
cipher: { alg: 'AES-GCM', length: 128, tagLength: 128 }, | ||
extractable: [Getter] } | ||
*/ | ||
@@ -32,0 +32,0 @@ |
@@ -8,39 +8,47 @@ (function (global, factory) { | ||
function aesgcm_password_codec_options(options) { | ||
if ('string' === typeof options) { | ||
options = { salt: options }; | ||
} else if (null == options) { | ||
options = {}; | ||
} | ||
if ('string' === typeof options) { | ||
options ={salt: options}; } | ||
else if (null == options) { | ||
options = {};} | ||
const pbkdf2 = Object.assign({ hash: 'SHA-256', | ||
salt: options.salt, | ||
iterations: options.iterations || 100000, | ||
__proto__: { | ||
salt_bytes: 16 } }, options.pbkdf2); | ||
const pbkdf2 = Object.assign( | ||
{hash: 'SHA-256' | ||
, salt: options.salt | ||
, iterations: options.iterations || 100000 | ||
, __proto__:{ | ||
salt_bytes: 16} } | ||
, options.pbkdf2); | ||
const cipher = Object.assign({ alg: 'AES-GCM', length: 128, tagLength: 128, | ||
__proto__: { | ||
iv_bytes: 12 } }, options.cipher); | ||
const cipher = Object.assign( | ||
{alg: 'AES-GCM', length: 128, tagLength: 128 | ||
, __proto__:{ | ||
iv_bytes: 12} } | ||
, options.cipher); | ||
pbkdf2.keylen = cipher.length / 8; | ||
return { pbkdf2, cipher, | ||
get extractable() { | ||
return true === options.extractable; | ||
} }; | ||
} | ||
return {pbkdf2, cipher | ||
, get extractable() {return true === options.extractable} } } | ||
function aesgcm_password_codec_api(base_api) { | ||
const { encrypt_u8, decrypt_u8, utf8_to_u8, u8_to_utf8 } = base_api; | ||
return { | ||
__proto__: base_api, | ||
__proto__: base_api | ||
encrypt_json: obj => encrypt_u8(utf8_to_u8(JSON.stringify(obj))), | ||
, encrypt_json: obj => | ||
encrypt_u8( | ||
utf8_to_u8( | ||
JSON.stringify(obj)) ) | ||
decrypt_json: enc_rec_b64 => decrypt_u8(enc_rec_b64).then(u8 => JSON.parse(u8_to_utf8(u8))), | ||
, decrypt_json: enc_rec_b64 => | ||
decrypt_u8(enc_rec_b64) | ||
.then(u8 => JSON.parse(u8_to_utf8(u8) )) | ||
encrypt_utf8: str => encrypt_u8(utf8_to_u8(str)), | ||
, encrypt_utf8: str => | ||
encrypt_u8(utf8_to_u8(str)) | ||
decrypt_utf8: enc_rec_b64 => decrypt_u8(enc_rec_b64).then(u8 => u8_to_utf8(u8)) }; | ||
} | ||
, decrypt_utf8: enc_rec_b64 => | ||
decrypt_u8(enc_rec_b64) | ||
.then(u8 => u8_to_utf8(u8)) } } | ||
@@ -51,10 +59,12 @@ function aesgcm_password_codec_web(password, options) { | ||
if (null == options.pbkdf2.salt) { | ||
options.pbkdf2.salt = u8_to_base64(crypto.getRandomValues(new Uint8Array(options.pbkdf2.salt_bytes))); | ||
} | ||
options.pbkdf2.salt = u8_to_base64( | ||
crypto.getRandomValues( | ||
new Uint8Array(options.pbkdf2.salt_bytes) ) ); } | ||
if ('string' === typeof password) { | ||
return aes_key_from_password(password, options).then(with_aes_key); | ||
} else { | ||
return aes_key_from_base64(password.aes_key, options).then(with_aes_key); | ||
} | ||
if ('string' === typeof password) { | ||
return aes_key_from_password(password, options) | ||
.then(with_aes_key) } | ||
else { | ||
return aes_key_from_base64(password.aes_key, options) | ||
.then(with_aes_key) } | ||
@@ -69,44 +79,62 @@ function with_aes_key(sk_aes_p) { | ||
utf8_to_u8, u8_to_utf8, | ||
u8_to_base64, base64_to_u8 }); | ||
u8_to_base64, base64_to_u8, }) | ||
function export_aeskey() { | ||
if (!options.extractable) { | ||
return Promise.resolve(null); | ||
} | ||
return crypto.subtle.exportKey('raw', sk_aes).then(jwk => ({ | ||
aes_key: u8_to_base64(jwk) })); | ||
} | ||
if (! options.extractable) { | ||
return Promise.resolve(null)} | ||
return crypto.subtle | ||
.exportKey('raw', sk_aes) | ||
.then(jwk =>({ | ||
aes_key: u8_to_base64(jwk) }) ) } | ||
function encrypt_u8(u8) { | ||
const iv = crypto.getRandomValues(new Uint8Array(iv_bytes)); | ||
return crypto.subtle.encrypt({ name: 'AES-GCM', iv, tagLength }, sk_aes, u8).then(enc_data => `${u8_to_base64(iv)} ${u8_to_base64(enc_data)}`); | ||
} | ||
return crypto.subtle | ||
.encrypt( | ||
{name: 'AES-GCM', iv, tagLength} | ||
, sk_aes, u8) | ||
.then(enc_data => | ||
`${u8_to_base64(iv)} ${u8_to_base64(enc_data)}`) } | ||
function decrypt_u8(enc_rec_b64) { | ||
const [iv, enc_data] = enc_rec_b64.split(' ').map(base64_to_u8); | ||
return crypto.subtle.decrypt({ name: 'AES-GCM', iv, tagLength }, sk_aes, enc_data); | ||
} | ||
} | ||
} | ||
return crypto.subtle.decrypt( | ||
{name: 'AES-GCM', iv, tagLength} | ||
, sk_aes, enc_data) } } } | ||
function aes_key_from_password(password, options) { | ||
return crypto.subtle.importKey('raw', utf8_to_u8(password), { name: 'PBKDF2' }, false, ['deriveKey', 'deriveBits']).then(sk_passwd => crypto.subtle.deriveKey({ name: 'PBKDF2', | ||
iterations: options.pbkdf2.iterations, | ||
salt: base64_to_u8(options.pbkdf2.salt), | ||
hash: { name: options.pbkdf2.hash } }, sk_passwd, { name: 'AES-GCM', | ||
length: options.cipher.length }, true === options.extractable, ['encrypt', 'decrypt'])); | ||
} | ||
return crypto.subtle | ||
.importKey( | ||
'raw', utf8_to_u8(password) | ||
, {name: 'PBKDF2'}, false, [ 'deriveKey', 'deriveBits' ]) | ||
.then(sk_passwd => | ||
crypto.subtle.deriveKey( | ||
{name: 'PBKDF2' | ||
, iterations: options.pbkdf2.iterations | ||
, salt: base64_to_u8(options.pbkdf2.salt) | ||
, hash:{name: options.pbkdf2.hash} } | ||
, sk_passwd | ||
, {name: 'AES-GCM' | ||
, length: options.cipher.length} | ||
, true === options.extractable | ||
, ['encrypt', 'decrypt'] ) ) } | ||
function aes_key_from_base64(aes_key, options) { | ||
return crypto.subtle.importKey('raw', base64_to_u8(aes_key), { name: 'AES-GCM', | ||
length: options.cipher.length }, true === options.extractable, ['encrypt', 'decrypt']); | ||
} | ||
return crypto.subtle.importKey( | ||
'raw', base64_to_u8(aes_key) | ||
, {name: 'AES-GCM' | ||
, length: options.cipher.length} | ||
, true === options.extractable | ||
, ['encrypt', 'decrypt'] ) } | ||
function utf8_to_u8(utf8) { | ||
return new TextEncoder('utf-8').encode(utf8.normalize('NFKC')); | ||
} | ||
return new TextEncoder('utf-8').encode(utf8.normalize('NFKC')) } | ||
function u8_to_utf8(u8) { | ||
return new TextDecoder('utf-8').decode(u8); | ||
} | ||
return new TextDecoder('utf-8').decode(u8) } | ||
@@ -116,26 +144,18 @@ const _fromCharCode = String.fromCharCode; | ||
if (u8 instanceof ArrayBuffer) { | ||
u8 = new Uint8Array(u8); | ||
} | ||
u8 = new Uint8Array(u8);} | ||
let res = ''; | ||
let res=''; | ||
const len = u8.byteLength; | ||
for (let i = 0; i < len; i++) { | ||
res += _fromCharCode(u8[i]); | ||
} | ||
return btoa(res); | ||
} | ||
for (let i=0; i<len; i++) { | ||
res += _fromCharCode(u8[i]);} | ||
return btoa(res)} | ||
const _charCodeAt = ''.charCodeAt; | ||
function base64_to_u8(str_b64) { | ||
if (null == str_b64) { | ||
throw new TypeError('WTF'); | ||
} | ||
const sz = atob(str_b64); | ||
const sz = atob(str_b64.replace(/-/g, '+').replace(/_/g, '/')); | ||
const len = sz.length; | ||
const res = new Uint8Array(len); | ||
for (let i = 0; i < len; i++) { | ||
res[i] = _charCodeAt.call(sz, i); | ||
} | ||
return res; | ||
} | ||
for (let i=0; i<len; i++) { | ||
res[i] = _charCodeAt.call(sz, i);} | ||
return res} | ||
@@ -145,2 +165,2 @@ return aesgcm_password_codec_web; | ||
}))); | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWVzZ2NtX3Bhc3N3b3JkX2NvZGVjLmRiZy5qcyIsInNvdXJjZXMiOlsiLi4vY29kZS9pbXBsX2NvbW1vbi5qc3kiLCIuLi9jb2RlL2ltcGxfd2ViLmpzeSJdLCJzb3VyY2VzQ29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NBQVM7VUFDbkI7OztFQUdSO0lBQ0U7O1FBRUksS0FBSztRQUNMLE9BQU8sUUFBUSxZQUFZLFdBQVcsRUFBRSxZQUFZOztZQUUvQztRQUNMO1dBQ0ssTUFBTztjQUNOO2NBQ0EsbUJBQW9CO2NBQ3BCLE1BQVM7VUFDYjtXQUNHLE1BQU87Y0FDTjtVQUNKO1dBQ0ksU0FBUyxFQUFFOztFQUV2QjtJQUNFO01BQ0UsS0FBSztPQUNGLE1BQU87VUFDTjtNQUNKO09BQ0ksU0FBUyxFQUFFOzs7OztFQUtuQjtJQUNFLHVCQUF1QixPQUFPLFNBQVUsZUFBZ0IsTUFBTTs7RUFFaEU7SUFDRSx1QkFBdUIsT0FBTyxTQUFVOztFQUUxQztFQUNBO0lBQ0UsSUFBRTtNQUNBOztJQUVGLFFBQVE7SUFDUjtJQUNBLEtBQUc7TUFDRDtJQUNGOztFQUVGLG9CQUFvQixFQUFFO0VBQ3RCO0lBQ0UsZ0JBQWlCLGdCQUFpQixNQUFNLEdBQUcsVUFBVSxNQUFNLEdBQUc7SUFDOUQ7SUFDQTtJQUNBLEtBQUc7TUFDRDtJQUNGOzs7Ozs7OzsifQ== |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.aesgcm_password_codec=e()}(this,function(){"use strict";function t(t){return new TextEncoder("utf-8").encode(t.normalize("NFKC"))}function e(t){return new TextDecoder("utf-8").decode(t)}const n=String.fromCharCode;function r(t){t instanceof ArrayBuffer&&(t=new Uint8Array(t));let e="";const r=t.byteLength;for(let o=0;o<r;o++)e+=n(t[o]);return btoa(e)}const o="".charCodeAt;function c(t){if(null==t)throw new TypeError("WTF");const e=atob(t),n=e.length,r=new Uint8Array(n);for(let t=0;t<n;t++)r[t]=o.call(e,t);return r}return function(n,o){return null==(o=function(t){"string"==typeof t?t={salt:t}:null==t&&(t={});const e=Object.assign({hash:"SHA-256",salt:t.salt,iterations:t.iterations||1e5,__proto__:{salt_bytes:16}},t.pbkdf2),n=Object.assign({alg:"AES-GCM",length:128,tagLength:128,__proto__:{iv_bytes:12}},t.cipher);return e.keylen=n.length/8,{pbkdf2:e,cipher:n,get extractable(){return!0===t.extractable}}}(o)).pbkdf2.salt&&(o.pbkdf2.salt=r(crypto.getRandomValues(new Uint8Array(o.pbkdf2.salt_bytes)))),"string"==typeof n?function(e,n){return crypto.subtle.importKey("raw",t(e),{name:"PBKDF2"},!1,["deriveKey","deriveBits"]).then(t=>crypto.subtle.deriveKey({name:"PBKDF2",iterations:n.pbkdf2.iterations,salt:c(n.pbkdf2.salt),hash:{name:n.pbkdf2.hash}},t,{name:"AES-GCM",length:n.cipher.length},!0===n.extractable,["encrypt","decrypt"]))}(n,o).then(a):function(t,e){return crypto.subtle.importKey("raw",c(t),{name:"AES-GCM",length:e.cipher.length},!0===e.extractable,["encrypt","decrypt"])}(n.aes_key,o).then(a);function a(n){const a=n,s=o.cipher.iv_bytes,u=o.cipher.tagLength;return function(t){const{encrypt_u8:e,decrypt_u8:n,utf8_to_u8:r,u8_to_utf8:o}=t;return{__proto__:t,encrypt_json:t=>e(r(JSON.stringify(t))),decrypt_json:t=>n(t).then(t=>JSON.parse(o(t))),encrypt_utf8:t=>e(r(t)),decrypt_utf8:t=>n(t).then(t=>o(t))}}({options:o,encrypt_u8:function(t){const e=crypto.getRandomValues(new Uint8Array(s));return crypto.subtle.encrypt({name:"AES-GCM",iv:e,tagLength:u},a,t).then(t=>`${r(e)} ${r(t)}`)},decrypt_u8:function(t){const[e,n]=t.split(" ").map(c);return crypto.subtle.decrypt({name:"AES-GCM",iv:e,tagLength:u},a,n)},export_aeskey:function(){return o.extractable?crypto.subtle.exportKey("raw",a).then(t=>({aes_key:r(t)})):Promise.resolve(null)},utf8_to_u8:t,u8_to_utf8:e,u8_to_base64:r,base64_to_u8:c})}}}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.aesgcm_password_codec=e()}(this,function(){"use strict";function t(t){return new TextEncoder("utf-8").encode(t.normalize("NFKC"))}function e(t){return new TextDecoder("utf-8").decode(t)}const n=String.fromCharCode;function r(t){t instanceof ArrayBuffer&&(t=new Uint8Array(t));let e="";const r=t.byteLength;for(let o=0;o<r;o++)e+=n(t[o]);return btoa(e)}const o="".charCodeAt;function c(t){const e=atob(t.replace(/-/g,"+").replace(/_/g,"/")),n=e.length,r=new Uint8Array(n);for(let t=0;t<n;t++)r[t]=o.call(e,t);return r}return function(n,o){return null==(o=function(t){"string"==typeof t?t={salt:t}:null==t&&(t={});const e=Object.assign({hash:"SHA-256",salt:t.salt,iterations:t.iterations||1e5,__proto__:{salt_bytes:16}},t.pbkdf2),n=Object.assign({alg:"AES-GCM",length:128,tagLength:128,__proto__:{iv_bytes:12}},t.cipher);return e.keylen=n.length/8,{pbkdf2:e,cipher:n,get extractable(){return!0===t.extractable}}}(o)).pbkdf2.salt&&(o.pbkdf2.salt=r(crypto.getRandomValues(new Uint8Array(o.pbkdf2.salt_bytes)))),"string"==typeof n?function(e,n){return crypto.subtle.importKey("raw",t(e),{name:"PBKDF2"},!1,["deriveKey","deriveBits"]).then(t=>crypto.subtle.deriveKey({name:"PBKDF2",iterations:n.pbkdf2.iterations,salt:c(n.pbkdf2.salt),hash:{name:n.pbkdf2.hash}},t,{name:"AES-GCM",length:n.cipher.length},!0===n.extractable,["encrypt","decrypt"]))}(n,o).then(a):function(t,e){return crypto.subtle.importKey("raw",c(t),{name:"AES-GCM",length:e.cipher.length},!0===e.extractable,["encrypt","decrypt"])}(n.aes_key,o).then(a);function a(n){const a=n,s=o.cipher.iv_bytes,u=o.cipher.tagLength;return function(t){const{encrypt_u8:e,decrypt_u8:n,utf8_to_u8:r,u8_to_utf8:o}=t;return{__proto__:t,encrypt_json:t=>e(r(JSON.stringify(t))),decrypt_json:t=>n(t).then(t=>JSON.parse(o(t))),encrypt_utf8:t=>e(r(t)),decrypt_utf8:t=>n(t).then(t=>o(t))}}({options:o,encrypt_u8:function(t){const e=crypto.getRandomValues(new Uint8Array(s));return crypto.subtle.encrypt({name:"AES-GCM",iv:e,tagLength:u},a,t).then(t=>`${r(e)} ${r(t)}`)},decrypt_u8:function(t){const[e,n]=t.split(" ").map(c);return crypto.subtle.decrypt({name:"AES-GCM",iv:e,tagLength:u},a,n)},export_aeskey:function(){return o.extractable?crypto.subtle.exportKey("raw",a).then(t=>({aes_key:r(t)})):Promise.resolve(null)},utf8_to_u8:t,u8_to_utf8:e,u8_to_base64:r,base64_to_u8:c})}}}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7
40641
425
1