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

scrypt-async-modern

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scrypt-async-modern - npm Package Compare versions

Comparing version 3.0.6 to 3.0.7

717

dist/index.js

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

(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("@babel/runtime/helpers/interopRequireDefault"), require("@babel/runtime/core-js/set-immediate"), require("@babel/runtime/core-js/promise"));
else if(typeof define === 'function' && define.amd)
define(["@babel/runtime/helpers/interopRequireDefault", "@babel/runtime/core-js/set-immediate", "@babel/runtime/core-js/promise"], factory);
else if(typeof exports === 'object')
exports["scrypt-async-modern"] = factory(require("@babel/runtime/helpers/interopRequireDefault"), require("@babel/runtime/core-js/set-immediate"), require("@babel/runtime/core-js/promise"));
else
root["scrypt-async-modern"] = factory(root["@babel/runtime/helpers/interopRequireDefault"], root["@babel/runtime/core-js/set-immediate"], root["@babel/runtime/core-js/promise"]);
})(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE_2__, __WEBPACK_EXTERNAL_MODULE_3__, __WEBPACK_EXTERNAL_MODULE_4__) {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(1);
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _interopRequireDefault = __webpack_require__(2);
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = scrypt;
var _setImmediate2 = _interopRequireDefault(__webpack_require__(3));
var _promise = _interopRequireDefault(__webpack_require__(4));
!function(r,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@babel/runtime-corejs2/core-js/set-immediate"),require("@babel/runtime-corejs2/helpers/toConsumableArray"),require("@babel/runtime-corejs2/core-js/promise")):"function"==typeof define&&define.amd?define(["@babel/runtime-corejs2/core-js/set-immediate","@babel/runtime-corejs2/helpers/toConsumableArray","@babel/runtime-corejs2/core-js/promise"],e):"object"==typeof exports?exports["scrypt-async-modern"]=e(require("@babel/runtime-corejs2/core-js/set-immediate"),require("@babel/runtime-corejs2/helpers/toConsumableArray"),require("@babel/runtime-corejs2/core-js/promise")):r["scrypt-async-modern"]=e(r["@babel/runtime-corejs2/core-js/set-immediate"],r["@babel/runtime-corejs2/helpers/toConsumableArray"],r["@babel/runtime-corejs2/core-js/promise"])}(global,function(r,e,n){return function(r){var e={};function n(t){if(e[t])return e[t].exports;var o=e[t]={i:t,l:!1,exports:{}};return r[t].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=r,n.c=e,n.d=function(r,e,t){n.o(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:t})},n.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},n.t=function(r,e){if(1&e&&(r=n(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var t=Object.create(null);if(n.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var o in r)n.d(t,o,function(e){return r[e]}.bind(null,o));return t},n.n=function(r){var e=r&&r.__esModule?function(){return r.default}:function(){return r};return n.d(e,"a",e),e},n.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},n.p="",n(n.s=3)}([function(e,n){e.exports=r},function(r,n){r.exports=e},function(r,e){r.exports=n},function(r,e,n){r.exports=n(4)},function(r,e,n){"use strict";n.r(e),n.d(e,"default",function(){return a});var t=n(0),o=n.n(t),i=n(1),u=n.n(i),s=n(2),f=n.n(s);
/*!

@@ -106,616 +7,2 @@ * Fast "async" scrypt implementation in modern JavaScript.

*/
/**
* scrypt(password, salt, options): Promise
*
* where
*
* password and salt are strings or arrays of bytes (Array of Uint8Array)
* options is
*
* {
* N: // CPU/memory cost parameter, must be power of two,
* // default = 16384
* // (alternatively, you can specify logN)
* r: // block size, default = 8
* p: // parallelization parameter, default = 1
* dkLen: // length of derived key, default = 32
* encoding: // optional encoding:
* "base64" - standard Base64 encoding
* "hex" — hex encoding,
* "binary" — Uint8Array,
* undefined/null - Array of bytes (default)
* interruptStep: // optional, steps to split calculations, default = 0
* }
*
* Derives a key from password and salt and fulfills Promise
* with derived key as the only argument.
*
* Calculations are interrupted with setImmediate (or zero setTimeout) at the
* given interruptSteps to avoid freezing the browser. If it's undefined or zero,
* the callback is called immediately after the calculation, avoiding setImmediate.
*
*/
function scrypt(password, salt) {
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
_ref$N = _ref.N,
N = _ref$N === void 0 ? 16384 : _ref$N,
logN = _ref.logN,
_ref$r = _ref.r,
r = _ref$r === void 0 ? 8 : _ref$r,
_ref$p = _ref.p,
p = _ref$p === void 0 ? 1 : _ref$p,
_ref$dkLen = _ref.dkLen,
dkLen = _ref$dkLen === void 0 ? 32 : _ref$dkLen,
_ref$interruptStep = _ref.interruptStep,
interruptStep = _ref$interruptStep === void 0 ? 0 : _ref$interruptStep,
encoding = _ref.encoding;
return new _promise.default(function (resolve, reject) {
if (!logN && !N) {
return reject(new Error("scrypt: missing N or logN parameter"));
}
if (logN || logN === 0) {
if (logN < 1 || logN > 31) {
return reject(new Error("scrypt: logN must be between 1 and 31"));
}
N = 1 << logN >>> 0;
} else {
if (N < 2 || N > MAX_UINT) {
return reject(new Error("scrypt: N is out of range"));
} else if ((N & N - 1) !== 0) {
return reject(Error("scrypt: N is not a power of 2"));
}
}
if (p < 1) {
return reject(new Error("scrypt: invalid p"));
}
if (r < 1) {
return reject(new Error("scrypt: invalid r"));
}
run({
password: password,
salt: salt,
N: N,
r: r,
p: p,
dkLen: dkLen,
interruptStep: interruptStep,
encoding: encoding
}, resolve);
});
} // Internal scrypt function
function run(_ref2, callback) {
var password = _ref2.password,
salt = _ref2.salt,
N = _ref2.N,
r = _ref2.r,
p = _ref2.p,
dkLen = _ref2.dkLen,
interruptStep = _ref2.interruptStep,
encoding = _ref2.encoding;
function SHA256(m) {
var K = [0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2];
var h0 = 0x6a09e667,
h1 = 0xbb67ae85,
h2 = 0x3c6ef372,
h3 = 0xa54ff53a,
h4 = 0x510e527f,
h5 = 0x9b05688c,
h6 = 0x1f83d9ab,
h7 = 0x5be0cd19,
w = new Array(64);
function blocks(p) {
var off = 0,
len = p.length;
while (len >= 64) {
var a = h0,
b = h1,
c = h2,
d = h3,
e = h4,
f = h5,
g = h6,
h = h7,
u = void 0,
_i = void 0,
j = void 0,
t1 = void 0,
t2 = void 0;
for (_i = 0; _i < 16; _i++) {
j = off + _i * 4;
w[_i] = (p[j] & 0xff) << 24 | (p[j + 1] & 0xff) << 16 | (p[j + 2] & 0xff) << 8 | p[j + 3] & 0xff;
}
for (_i = 16; _i < 64; _i++) {
u = w[_i - 2];
t1 = (u >>> 17 | u << 32 - 17) ^ (u >>> 19 | u << 32 - 19) ^ u >>> 10;
u = w[_i - 15];
t2 = (u >>> 7 | u << 32 - 7) ^ (u >>> 18 | u << 32 - 18) ^ u >>> 3;
w[_i] = (t1 + w[_i - 7] | 0) + (t2 + w[_i - 16] | 0) | 0;
}
for (_i = 0; _i < 64; _i++) {
t1 = (((e >>> 6 | e << 32 - 6) ^ (e >>> 11 | e << 32 - 11) ^ (e >>> 25 | e << 32 - 25)) + (e & f ^ ~e & g) | 0) + (h + (K[_i] + w[_i] | 0) | 0) | 0;
t2 = ((a >>> 2 | a << 32 - 2) ^ (a >>> 13 | a << 32 - 13) ^ (a >>> 22 | a << 32 - 22)) + (a & b ^ a & c ^ b & c) | 0;
h = g;
g = f;
f = e;
e = d + t1 | 0;
d = c;
c = b;
b = a;
a = t1 + t2 | 0;
}
h0 = h0 + a | 0;
h1 = h1 + b | 0;
h2 = h2 + c | 0;
h3 = h3 + d | 0;
h4 = h4 + e | 0;
h5 = h5 + f | 0;
h6 = h6 + g | 0;
h7 = h7 + h | 0;
off += 64;
len -= 64;
}
}
blocks(m);
var i,
bytesLeft = m.length % 64,
bitLenHi = m.length / 0x20000000 | 0,
bitLenLo = m.length << 3,
numZeros = bytesLeft < 56 ? 56 : 120,
p = m.slice(m.length - bytesLeft, m.length);
p.push(0x80);
for (i = bytesLeft + 1; i < numZeros; i++) {
p.push(0);
}
p.push(bitLenHi >>> 24 & 0xff);
p.push(bitLenHi >>> 16 & 0xff);
p.push(bitLenHi >>> 8 & 0xff);
p.push(bitLenHi >>> 0 & 0xff);
p.push(bitLenLo >>> 24 & 0xff);
p.push(bitLenLo >>> 16 & 0xff);
p.push(bitLenLo >>> 8 & 0xff);
p.push(bitLenLo >>> 0 & 0xff);
blocks(p);
return [h0 >>> 24 & 0xff, h0 >>> 16 & 0xff, h0 >>> 8 & 0xff, h0 >>> 0 & 0xff, h1 >>> 24 & 0xff, h1 >>> 16 & 0xff, h1 >>> 8 & 0xff, h1 >>> 0 & 0xff, h2 >>> 24 & 0xff, h2 >>> 16 & 0xff, h2 >>> 8 & 0xff, h2 >>> 0 & 0xff, h3 >>> 24 & 0xff, h3 >>> 16 & 0xff, h3 >>> 8 & 0xff, h3 >>> 0 & 0xff, h4 >>> 24 & 0xff, h4 >>> 16 & 0xff, h4 >>> 8 & 0xff, h4 >>> 0 & 0xff, h5 >>> 24 & 0xff, h5 >>> 16 & 0xff, h5 >>> 8 & 0xff, h5 >>> 0 & 0xff, h6 >>> 24 & 0xff, h6 >>> 16 & 0xff, h6 >>> 8 & 0xff, h6 >>> 0 & 0xff, h7 >>> 24 & 0xff, h7 >>> 16 & 0xff, h7 >>> 8 & 0xff, h7 >>> 0 & 0xff];
}
function PBKDF2_HMAC_SHA256_OneIter(password, salt, dkLen) {
// compress password if it's longer than hash block length
password = password.length <= 64 ? password : SHA256(password);
var i,
innerLen = 64 + salt.length + 4,
inner = new Array(innerLen),
outerKey = new Array(64),
dk = []; // inner = (password ^ ipad) || salt || counter
for (i = 0; i < 64; i++) {
inner[i] = 0x36;
}
for (i = 0; i < password.length; i++) {
inner[i] ^= password[i];
}
for (i = 0; i < salt.length; i++) {
inner[64 + i] = salt[i];
}
for (i = innerLen - 4; i < innerLen; i++) {
inner[i] = 0;
} // outerKey = password ^ opad
for (i = 0; i < 64; i++) {
outerKey[i] = 0x5c;
}
for (i = 0; i < password.length; i++) {
outerKey[i] ^= password[i];
} // increments counter inside inner
function incrementCounter() {
for (var _i2 = innerLen - 1; _i2 >= innerLen - 4; _i2--) {
inner[_i2]++;
if (inner[_i2] <= 0xff) return;
inner[_i2] = 0;
}
} // output blocks = SHA256(outerKey || SHA256(inner)) ...
while (dkLen >= 32) {
incrementCounter();
dk = dk.concat(SHA256(outerKey.concat(SHA256(inner))));
dkLen -= 32;
}
if (dkLen > 0) {
incrementCounter();
dk = dk.concat(SHA256(outerKey.concat(SHA256(inner))).slice(0, dkLen));
}
return dk;
}
function salsaXOR(tmp, B, bin, bout) {
var j0 = tmp[0] ^ B[bin++],
j1 = tmp[1] ^ B[bin++],
j2 = tmp[2] ^ B[bin++],
j3 = tmp[3] ^ B[bin++],
j4 = tmp[4] ^ B[bin++],
j5 = tmp[5] ^ B[bin++],
j6 = tmp[6] ^ B[bin++],
j7 = tmp[7] ^ B[bin++],
j8 = tmp[8] ^ B[bin++],
j9 = tmp[9] ^ B[bin++],
j10 = tmp[10] ^ B[bin++],
j11 = tmp[11] ^ B[bin++],
j12 = tmp[12] ^ B[bin++],
j13 = tmp[13] ^ B[bin++],
j14 = tmp[14] ^ B[bin++],
j15 = tmp[15] ^ B[bin++],
u,
i;
var x0 = j0,
x1 = j1,
x2 = j2,
x3 = j3,
x4 = j4,
x5 = j5,
x6 = j6,
x7 = j7,
x8 = j8,
x9 = j9,
x10 = j10,
x11 = j11,
x12 = j12,
x13 = j13,
x14 = j14,
x15 = j15;
for (i = 0; i < 8; i += 2) {
u = x0 + x12;
x4 ^= u << 7 | u >>> 32 - 7;
u = x4 + x0;
x8 ^= u << 9 | u >>> 32 - 9;
u = x8 + x4;
x12 ^= u << 13 | u >>> 32 - 13;
u = x12 + x8;
x0 ^= u << 18 | u >>> 32 - 18;
u = x5 + x1;
x9 ^= u << 7 | u >>> 32 - 7;
u = x9 + x5;
x13 ^= u << 9 | u >>> 32 - 9;
u = x13 + x9;
x1 ^= u << 13 | u >>> 32 - 13;
u = x1 + x13;
x5 ^= u << 18 | u >>> 32 - 18;
u = x10 + x6;
x14 ^= u << 7 | u >>> 32 - 7;
u = x14 + x10;
x2 ^= u << 9 | u >>> 32 - 9;
u = x2 + x14;
x6 ^= u << 13 | u >>> 32 - 13;
u = x6 + x2;
x10 ^= u << 18 | u >>> 32 - 18;
u = x15 + x11;
x3 ^= u << 7 | u >>> 32 - 7;
u = x3 + x15;
x7 ^= u << 9 | u >>> 32 - 9;
u = x7 + x3;
x11 ^= u << 13 | u >>> 32 - 13;
u = x11 + x7;
x15 ^= u << 18 | u >>> 32 - 18;
u = x0 + x3;
x1 ^= u << 7 | u >>> 32 - 7;
u = x1 + x0;
x2 ^= u << 9 | u >>> 32 - 9;
u = x2 + x1;
x3 ^= u << 13 | u >>> 32 - 13;
u = x3 + x2;
x0 ^= u << 18 | u >>> 32 - 18;
u = x5 + x4;
x6 ^= u << 7 | u >>> 32 - 7;
u = x6 + x5;
x7 ^= u << 9 | u >>> 32 - 9;
u = x7 + x6;
x4 ^= u << 13 | u >>> 32 - 13;
u = x4 + x7;
x5 ^= u << 18 | u >>> 32 - 18;
u = x10 + x9;
x11 ^= u << 7 | u >>> 32 - 7;
u = x11 + x10;
x8 ^= u << 9 | u >>> 32 - 9;
u = x8 + x11;
x9 ^= u << 13 | u >>> 32 - 13;
u = x9 + x8;
x10 ^= u << 18 | u >>> 32 - 18;
u = x15 + x14;
x12 ^= u << 7 | u >>> 32 - 7;
u = x12 + x15;
x13 ^= u << 9 | u >>> 32 - 9;
u = x13 + x12;
x14 ^= u << 13 | u >>> 32 - 13;
u = x14 + x13;
x15 ^= u << 18 | u >>> 32 - 18;
}
B[bout++] = tmp[0] = x0 + j0 | 0;
B[bout++] = tmp[1] = x1 + j1 | 0;
B[bout++] = tmp[2] = x2 + j2 | 0;
B[bout++] = tmp[3] = x3 + j3 | 0;
B[bout++] = tmp[4] = x4 + j4 | 0;
B[bout++] = tmp[5] = x5 + j5 | 0;
B[bout++] = tmp[6] = x6 + j6 | 0;
B[bout++] = tmp[7] = x7 + j7 | 0;
B[bout++] = tmp[8] = x8 + j8 | 0;
B[bout++] = tmp[9] = x9 + j9 | 0;
B[bout++] = tmp[10] = x10 + j10 | 0;
B[bout++] = tmp[11] = x11 + j11 | 0;
B[bout++] = tmp[12] = x12 + j12 | 0;
B[bout++] = tmp[13] = x13 + j13 | 0;
B[bout++] = tmp[14] = x14 + j14 | 0;
B[bout++] = tmp[15] = x15 + j15 | 0;
}
function blockCopy(dst, di, src, si, len) {
while (len--) {
dst[di++] = src[si++];
}
}
function blockXOR(dst, di, src, si, len) {
while (len--) {
dst[di++] ^= src[si++];
}
}
function blockMix(tmp, B, bin, bout, r) {
blockCopy(tmp, 0, B, bin + (2 * r - 1) * 16, 16);
for (var i = 0; i < 2 * r; i += 2) {
salsaXOR(tmp, B, bin + i * 16, bout + i * 8);
salsaXOR(tmp, B, bin + i * 16 + 16, bout + i * 8 + r * 16);
}
}
function integerify(B, bi, r) {
return B[bi + (2 * r - 1) * 16];
}
function stringToUTF8Bytes(s) {
var arr = [];
for (var i = 0; i < s.length; i++) {
var c = s.charCodeAt(i);
if (c < 0x80) {
arr.push(c);
} else if (c < 0x800) {
arr.push(0xc0 | c >> 6);
arr.push(0x80 | c & 0x3f);
} else if (c < 0xd800) {
arr.push(0xe0 | c >> 12);
arr.push(0x80 | c >> 6 & 0x3f);
arr.push(0x80 | c & 0x3f);
} else {
if (i >= s.length - 1) {
throw new Error("invalid string");
}
i++; // get one more character
c = (c & 0x3ff) << 10;
c |= s.charCodeAt(i) & 0x3ff;
c += 0x10000;
arr.push(0xf0 | c >> 18);
arr.push(0x80 | c >> 12 & 0x3f);
arr.push(0x80 | c >> 6 & 0x3f);
arr.push(0x80 | c & 0x3f);
}
}
return arr;
}
function bytesToHex(p) {
var enc = "0123456789abcdef".split("");
var len = p.length,
arr = [];
for (var i = 0; i < len; i++) {
arr.push(enc[p[i] >>> 4 & 15]);
arr.push(enc[p[i] >>> 0 & 15]);
}
return arr.join("");
}
function bytesToBase64(p) {
/** @const */
var enc = ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" + "0123456789+/").split("");
var len = p.length,
arr = [];
var i = 0,
a,
b,
c,
t;
while (i < len) {
a = i < len ? p[i++] : 0;
b = i < len ? p[i++] : 0;
c = i < len ? p[i++] : 0;
t = (a << 16) + (b << 8) + c;
arr.push(enc[t >>> 3 * 6 & 63]);
arr.push(enc[t >>> 2 * 6 & 63]);
arr.push(enc[t >>> 1 * 6 & 63]);
arr.push(enc[t >>> 0 * 6 & 63]);
}
if (len % 3 > 0) {
arr[arr.length - 1] = "=";
if (len % 3 === 1) arr[arr.length - 2] = "=";
}
return arr.join("");
}
var XY, V, B, tmp;
if (r * p >= 1 << 30 || r > MAX_UINT / 128 / p || r > MAX_UINT / 256 || N > MAX_UINT / 128 / r) {
return reject(new Error("scrypt: parameters are too large"));
} // Decode strings.
if (typeof password === "string") password = stringToUTF8Bytes(password);
if (typeof salt === "string") salt = stringToUTF8Bytes(salt);
if (typeof Int32Array !== "undefined") {
//XXX We can use Uint32Array, but Int32Array is faster in Safari.
XY = new Int32Array(64 * r);
V = new Int32Array(32 * N * r);
tmp = new Int32Array(16);
} else {
XY = [];
V = [];
tmp = new Array(16);
}
B = PBKDF2_HMAC_SHA256_OneIter(password, salt, p * 128 * r);
var xi = 0,
yi = 32 * r;
function smixStart(pos) {
for (var i = 0; i < 32 * r; i++) {
var j = pos + i * 4;
XY[xi + i] = (B[j + 3] & 0xff) << 24 | (B[j + 2] & 0xff) << 16 | (B[j + 1] & 0xff) << 8 | (B[j + 0] & 0xff) << 0;
}
}
function smixStep1(start, end) {
for (var i = start; i < end; i += 2) {
blockCopy(V, i * (32 * r), XY, xi, 32 * r);
blockMix(tmp, XY, xi, yi, r);
blockCopy(V, (i + 1) * (32 * r), XY, yi, 32 * r);
blockMix(tmp, XY, yi, xi, r);
}
}
function smixStep2(start, end) {
for (var i = start; i < end; i += 2) {
var j = integerify(XY, xi, r) & N - 1;
blockXOR(XY, xi, V, j * (32 * r), 32 * r);
blockMix(tmp, XY, xi, yi, r);
j = integerify(XY, yi, r) & N - 1;
blockXOR(XY, yi, V, j * (32 * r), 32 * r);
blockMix(tmp, XY, yi, xi, r);
}
}
function smixFinish(pos) {
for (var i = 0; i < 32 * r; i++) {
var j = XY[xi + i];
B[pos + i * 4 + 0] = j >>> 0 & 0xff;
B[pos + i * 4 + 1] = j >>> 8 & 0xff;
B[pos + i * 4 + 2] = j >>> 16 & 0xff;
B[pos + i * 4 + 3] = j >>> 24 & 0xff;
}
}
var nextTick = typeof _setImmediate2.default !== "undefined" ? _setImmediate2.default : setTimeout;
function interruptedFor(start, end, step, fn, donefn) {
(function performStep() {
nextTick(function () {
fn(start, start + step < end ? start + step : end);
start += step;
if (start < end) performStep();else donefn();
});
})();
}
function getResult(enc) {
var result = PBKDF2_HMAC_SHA256_OneIter(password, B, dkLen);
if (enc === "base64") return bytesToBase64(result);else if (enc === "hex") return bytesToHex(result);else if (enc === "binary") return new Uint8Array(result);else return result;
} // Blocking variant.
function calculateSync() {
for (var i = 0; i < p; i++) {
smixStart(i * 128 * r);
smixStep1(0, N);
smixStep2(0, N);
smixFinish(i * 128 * r);
}
callback(getResult(encoding));
} // Async variant.
function calculateAsync(i) {
smixStart(i * 128 * r);
interruptedFor(0, N, interruptStep * 2, smixStep1, function () {
interruptedFor(0, N, interruptStep * 2, smixStep2, function () {
smixFinish(i * 128 * r);
if (i + 1 < p) {
nextTick(function () {
calculateAsync(i + 1);
});
} else {
callback(getResult(encoding));
}
});
});
}
if (interruptStep <= 0) {
calculateSync();
} else {
calculateAsync(0);
}
}
var MAX_UINT = -1 >>> 0;
/***/ }),
/* 2 */
/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE_2__;
/***/ }),
/* 3 */
/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE_3__;
/***/ }),
/* 4 */
/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE_4__;
/***/ })
/******/ ]);
});
//# sourceMappingURL=index.js.map
function a(r,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},t=n.N,o=void 0===t?16384:t,i=n.logN,u=n.r,s=void 0===u?8:u,a=n.p,l=void 0===a?1:a,d=n.dkLen,h=void 0===d?32:d,v=n.interruptStep,b=void 0===v?0:v,m=n.encoding;return new f.a(function(n,t){if(!i&&!o)return t(new Error("scrypt: missing N or logN parameter"));if(i||0===i){if(i<1||i>31)return t(new Error("scrypt: logN must be between 1 and 31"));o=1<<i>>>0}else{if(o<2||o>p)return t(new Error("scrypt: N is out of range"));if(0!=(o&o-1))return t(Error("scrypt: N is not a power of 2"))}return l<1?t(new Error("scrypt: invalid p")):s<1?t(new Error("scrypt: invalid r")):void c({password:r,salt:e,N:o,r:s,p:l,dkLen:h,interruptStep:b,encoding:m},n)})}function c(r,e){var n,t,i,s,f=r.password,a=r.salt,c=r.N,l=r.r,d=r.p,h=r.dkLen,v=r.interruptStep,b=r.encoding;function m(r){var e=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],n=1779033703,t=3144134277,o=1013904242,i=2773480762,u=1359893119,s=2600822924,f=528734635,a=1541459225,c=new Array(64);function p(r){for(var p=0,l=r.length;l>=64;){var d=n,h=t,v=o,b=i,m=u,y=s,g=f,j=a,w=void 0,A=void 0,x=void 0,N=void 0,E=void 0;for(A=0;A<16;A++)x=p+4*A,c[A]=(255&r[x])<<24|(255&r[x+1])<<16|(255&r[x+2])<<8|255&r[x+3];for(A=16;A<64;A++)N=((w=c[A-2])>>>17|w<<15)^(w>>>19|w<<13)^w>>>10,E=((w=c[A-15])>>>7|w<<25)^(w>>>18|w<<14)^w>>>3,c[A]=(N+c[A-7]|0)+(E+c[A-16]|0)|0;for(A=0;A<64;A++)N=(((m>>>6|m<<26)^(m>>>11|m<<21)^(m>>>25|m<<7))+(m&y^~m&g)|0)+(j+(e[A]+c[A]|0)|0)|0,E=((d>>>2|d<<30)^(d>>>13|d<<19)^(d>>>22|d<<10))+(d&h^d&v^h&v)|0,j=g,g=y,y=m,m=b+N|0,b=v,v=h,h=d,d=N+E|0;n=n+d|0,t=t+h|0,o=o+v|0,i=i+b|0,u=u+m|0,s=s+y|0,f=f+g|0,a=a+j|0,p+=64,l-=64}}p(r);var l,d=r.length%64,h=r.length/536870912|0,v=r.length<<3,b=d<56?56:120,m=r.slice(r.length-d,r.length);for(m.push(128),l=d+1;l<b;l++)m.push(0);return m.push(h>>>24&255),m.push(h>>>16&255),m.push(h>>>8&255),m.push(h>>>0&255),m.push(v>>>24&255),m.push(v>>>16&255),m.push(v>>>8&255),m.push(v>>>0&255),p(m),[n>>>24&255,n>>>16&255,n>>>8&255,n>>>0&255,t>>>24&255,t>>>16&255,t>>>8&255,t>>>0&255,o>>>24&255,o>>>16&255,o>>>8&255,o>>>0&255,i>>>24&255,i>>>16&255,i>>>8&255,i>>>0&255,u>>>24&255,u>>>16&255,u>>>8&255,u>>>0&255,s>>>24&255,s>>>16&255,s>>>8&255,s>>>0&255,f>>>24&255,f>>>16&255,f>>>8&255,f>>>0&255,a>>>24&255,a>>>16&255,a>>>8&255,a>>>0&255]}function y(r,e,n){r.length>64&&(r=m(r.push?r:u()(r)));var t,o=64+e.length+4,i=new Array(o),s=new Array(64),f=[];for(t=0;t<64;t++)i[t]=54;for(t=0;t<r.length;t++)i[t]^=r[t];for(t=0;t<e.length;t++)i[64+t]=e[t];for(t=o-4;t<o;t++)i[t]=0;for(t=0;t<64;t++)s[t]=92;for(t=0;t<r.length;t++)s[t]^=r[t];function a(){for(var r=o-1;r>=o-4;r--){if(i[r]++,i[r]<=255)return;i[r]=0}}for(;n>=32;)a(),f=f.concat(m(s.concat(m(i)))),n-=32;return n>0&&(a(),f=f.concat(m(s.concat(m(i))).slice(0,n))),f}function g(r,e,n,t){var o,i,u=r[0]^e[n++],s=r[1]^e[n++],f=r[2]^e[n++],a=r[3]^e[n++],c=r[4]^e[n++],p=r[5]^e[n++],l=r[6]^e[n++],d=r[7]^e[n++],h=r[8]^e[n++],v=r[9]^e[n++],b=r[10]^e[n++],m=r[11]^e[n++],y=r[12]^e[n++],g=r[13]^e[n++],j=r[14]^e[n++],w=r[15]^e[n++],A=u,x=s,N=f,E=a,S=c,O=p,q=l,C=d,P=h,_=v,I=b,M=m,k=y,L=g,T=j,U=w;for(i=0;i<8;i+=2)A^=(o=(k^=(o=(P^=(o=(S^=(o=A+k)<<7|o>>>25)+A)<<9|o>>>23)+S)<<13|o>>>19)+P)<<18|o>>>14,O^=(o=(x^=(o=(L^=(o=(_^=(o=O+x)<<7|o>>>25)+O)<<9|o>>>23)+_)<<13|o>>>19)+L)<<18|o>>>14,I^=(o=(q^=(o=(N^=(o=(T^=(o=I+q)<<7|o>>>25)+I)<<9|o>>>23)+T)<<13|o>>>19)+N)<<18|o>>>14,U^=(o=(M^=(o=(C^=(o=(E^=(o=U+M)<<7|o>>>25)+U)<<9|o>>>23)+E)<<13|o>>>19)+C)<<18|o>>>14,A^=(o=(E^=(o=(N^=(o=(x^=(o=A+E)<<7|o>>>25)+A)<<9|o>>>23)+x)<<13|o>>>19)+N)<<18|o>>>14,O^=(o=(S^=(o=(C^=(o=(q^=(o=O+S)<<7|o>>>25)+O)<<9|o>>>23)+q)<<13|o>>>19)+C)<<18|o>>>14,I^=(o=(_^=(o=(P^=(o=(M^=(o=I+_)<<7|o>>>25)+I)<<9|o>>>23)+M)<<13|o>>>19)+P)<<18|o>>>14,U^=(o=(T^=(o=(L^=(o=(k^=(o=U+T)<<7|o>>>25)+U)<<9|o>>>23)+k)<<13|o>>>19)+L)<<18|o>>>14;e[t++]=r[0]=A+u|0,e[t++]=r[1]=x+s|0,e[t++]=r[2]=N+f|0,e[t++]=r[3]=E+a|0,e[t++]=r[4]=S+c|0,e[t++]=r[5]=O+p|0,e[t++]=r[6]=q+l|0,e[t++]=r[7]=C+d|0,e[t++]=r[8]=P+h|0,e[t++]=r[9]=_+v|0,e[t++]=r[10]=I+b|0,e[t++]=r[11]=M+m|0,e[t++]=r[12]=k+y|0,e[t++]=r[13]=L+g|0,e[t++]=r[14]=T+j|0,e[t++]=r[15]=U+w|0}function j(r,e,n,t,o){for(;o--;)r[e++]=n[t++]}function w(r,e,n,t,o){for(;o--;)r[e++]^=n[t++]}function A(r,e,n,t,o){j(r,0,e,n+16*(2*o-1),16);for(var i=0;i<2*o;i+=2)g(r,e,n+16*i,t+8*i),g(r,e,n+16*i+16,t+8*i+16*o)}function x(r,e,n){return r[e+16*(2*n-1)]}function N(r){for(var e=[],n=0;n<r.length;n++){var t=r.charCodeAt(n);if(t<128)e.push(t);else if(t<2048)e.push(192|t>>6),e.push(128|63&t);else if(t<55296)e.push(224|t>>12),e.push(128|t>>6&63),e.push(128|63&t);else{if(n>=r.length-1)throw new Error("invalid string");n++,t=(1023&t)<<10,t|=1023&r.charCodeAt(n),t+=65536,e.push(240|t>>18),e.push(128|t>>12&63),e.push(128|t>>6&63),e.push(128|63&t)}}return e}if(l*d>=1<<30||l>p/128/d||l>p/256||c>p/128/l)return reject(new Error("scrypt: parameters are too large"));"string"==typeof f&&(f=N(f)),"string"==typeof a&&(a=N(a)),"undefined"!=typeof Int32Array?(n=new Int32Array(64*l),t=new Int32Array(32*c*l),s=new Int32Array(16)):(n=[],t=[],s=new Array(16)),i=y(f,a,128*d*l);var E=0,S=32*l;function O(r){for(var e=0;e<32*l;e++){var t=r+4*e;n[E+e]=(255&i[t+3])<<24|(255&i[t+2])<<16|(255&i[t+1])<<8|(255&i[t+0])<<0}}function q(r,e){for(var o=r;o<e;o+=2)j(t,o*(32*l),n,E,32*l),A(s,n,E,S,l),j(t,(o+1)*(32*l),n,S,32*l),A(s,n,S,E,l)}function C(r,e){for(var o=r;o<e;o+=2){var i=x(n,E,l)&c-1;w(n,E,t,i*(32*l),32*l),A(s,n,E,S,l),i=x(n,S,l)&c-1,w(n,S,t,i*(32*l),32*l),A(s,n,S,E,l)}}function P(r){for(var e=0;e<32*l;e++){var t=n[E+e];i[r+4*e+0]=t>>>0&255,i[r+4*e+1]=t>>>8&255,i[r+4*e+2]=t>>>16&255,i[r+4*e+3]=t>>>24&255}}var _=void 0!==o.a?o.a:setTimeout;function I(r,e,n,t,o){!function i(){_(function(){t(r,r+n<e?r+n:e),(r+=n)<e?i():o()})}()}function M(r){var e=y(f,i,h);return"base64"===r?function(r){for(var e,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),t=r.length,o=[],i=0;i<t;)e=((i<t?r[i++]:0)<<16)+((i<t?r[i++]:0)<<8)+(i<t?r[i++]:0),o.push(n[e>>>18&63]),o.push(n[e>>>12&63]),o.push(n[e>>>6&63]),o.push(n[e>>>0&63]);return t%3>0&&(o[o.length-1]="=",t%3==1&&(o[o.length-2]="=")),o.join("")}(e):"hex"===r?function(r){for(var e="0123456789abcdef".split(""),n=r.length,t=[],o=0;o<n;o++)t.push(e[r[o]>>>4&15]),t.push(e[r[o]>>>0&15]);return t.join("")}(e):"binary"===r?new Uint8Array(e):e}v<=0?function(){for(var r=0;r<d;r++)O(128*r*l),q(0,c),C(0,c),P(128*r*l);e(M(b))}():function r(n){O(128*n*l),I(0,c,2*v,q,function(){I(0,c,2*v,C,function(){P(128*n*l),n+1<d?_(function(){r(n+1)}):e(M(b))})})}(0)}var p=-1>>>0}])});

6

package.json
{
"name": "scrypt-async-modern",
"version": "3.0.6",
"version": "3.0.7",
"description": "Fast \"async\" scrypt implementation in modern JavaScript.",

@@ -16,3 +16,3 @@ "main": "dist/index.js",

"devDependencies": {
"@noderize/scripts": "^0.3.11"
"@noderize/scripts": "^0.7.5"
},

@@ -39,4 +39,4 @@ "repository": {

"dependencies": {
"@noderize/runtime": "^0.3.11"
"@noderize/runtime": "^0.7.5"
}
}

@@ -309,3 +309,6 @@ /*!

// compress password if it's longer than hash block length
password = password.length <= 64 ? password : SHA256(password);
if (password.length > 64) {
// coerces the structure into an array type if it lacks support for the .push operation
password = SHA256(password.push ? password : [...password]);
}

@@ -312,0 +315,0 @@ let i,

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