@esri/telemetry-google-analytics
Advanced tools
Comparing version 0.4.3 to 0.4.4
@@ -36,4 +36,15 @@ (function (global, factory) { | ||
function commonjsRequire (path) { | ||
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); | ||
function getAugmentedNamespace(n) { | ||
if (n.__esModule) return n; | ||
var a = Object.defineProperty({}, '__esModule', {value: true}); | ||
Object.keys(n).forEach(function (k) { | ||
var d = Object.getOwnPropertyDescriptor(n, k); | ||
Object.defineProperty(a, k, d.get ? d : { | ||
enumerable: true, | ||
get: function () { | ||
return n[k]; | ||
} | ||
}); | ||
}); | ||
return a; | ||
} | ||
@@ -43,1015 +54,534 @@ | ||
var core = {exports: {}}; | ||
var _nodeResolve_empty = {}; | ||
(function (module, exports) { | ||
(function (root, factory) { | ||
{ | ||
// CommonJS | ||
module.exports = factory(); | ||
} | ||
}(commonjsGlobal, function () { | ||
var _nodeResolve_empty$1 = /*#__PURE__*/Object.freeze({ | ||
__proto__: null, | ||
'default': _nodeResolve_empty | ||
}); | ||
/*globals window, global, require*/ | ||
var require$$1 = /*@__PURE__*/getAugmentedNamespace(_nodeResolve_empty$1); | ||
/** | ||
* CryptoJS core components. | ||
*/ | ||
var CryptoJS = CryptoJS || (function (Math, undefined$1) { | ||
/** | ||
* [js-sha256]{@link https://github.com/emn178/js-sha256} | ||
* | ||
* @version 0.11.0 | ||
* @author Chen, Yi-Cyuan [emn178@gmail.com] | ||
* @copyright Chen, Yi-Cyuan 2014-2024 | ||
* @license MIT | ||
*/ | ||
var crypto; | ||
(function (module) { | ||
/*jslint bitwise: true */ | ||
(function () { | ||
// Native crypto from window (Browser) | ||
if (typeof window !== 'undefined' && window.crypto) { | ||
crypto = window.crypto; | ||
} | ||
var ERROR = 'input is invalid type'; | ||
var WINDOW = typeof window === 'object'; | ||
var root = WINDOW ? window : {}; | ||
if (root.JS_SHA256_NO_WINDOW) { | ||
WINDOW = false; | ||
} | ||
var WEB_WORKER = !WINDOW && typeof self === 'object'; | ||
var NODE_JS = !root.JS_SHA256_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node; | ||
if (NODE_JS) { | ||
root = commonjsGlobal; | ||
} else if (WEB_WORKER) { | ||
root = self; | ||
} | ||
var COMMON_JS = !root.JS_SHA256_NO_COMMON_JS && 'object' === 'object' && module.exports; | ||
var ARRAY_BUFFER = !root.JS_SHA256_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined'; | ||
var HEX_CHARS = '0123456789abcdef'.split(''); | ||
var EXTRA = [-2147483648, 8388608, 32768, 128]; | ||
var SHIFT = [24, 16, 8, 0]; | ||
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 OUTPUT_TYPES = ['hex', 'array', 'digest', 'arrayBuffer']; | ||
// Native crypto in web worker (Browser) | ||
if (typeof self !== 'undefined' && self.crypto) { | ||
crypto = self.crypto; | ||
} | ||
var blocks = []; | ||
// Native crypto from worker | ||
if (typeof globalThis !== 'undefined' && globalThis.crypto) { | ||
crypto = globalThis.crypto; | ||
} | ||
if (root.JS_SHA256_NO_NODE_JS || !Array.isArray) { | ||
Array.isArray = function (obj) { | ||
return Object.prototype.toString.call(obj) === '[object Array]'; | ||
}; | ||
} | ||
// Native (experimental IE 11) crypto from window (Browser) | ||
if (!crypto && typeof window !== 'undefined' && window.msCrypto) { | ||
crypto = window.msCrypto; | ||
} | ||
if (ARRAY_BUFFER && (root.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) { | ||
ArrayBuffer.isView = function (obj) { | ||
return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer; | ||
}; | ||
} | ||
// Native crypto from global (NodeJS) | ||
if (!crypto && typeof commonjsGlobal !== 'undefined' && commonjsGlobal.crypto) { | ||
crypto = commonjsGlobal.crypto; | ||
} | ||
var createOutputMethod = function (outputType, is224) { | ||
return function (message) { | ||
return new Sha256(is224, true).update(message)[outputType](); | ||
}; | ||
}; | ||
// Native crypto import via require (NodeJS) | ||
if (!crypto && typeof commonjsRequire === 'function') { | ||
try { | ||
crypto = require('crypto'); | ||
} catch (err) {} | ||
} | ||
var createMethod = function (is224) { | ||
var method = createOutputMethod('hex', is224); | ||
if (NODE_JS) { | ||
method = nodeWrap(method, is224); | ||
} | ||
method.create = function () { | ||
return new Sha256(is224); | ||
}; | ||
method.update = function (message) { | ||
return method.create().update(message); | ||
}; | ||
for (var i = 0; i < OUTPUT_TYPES.length; ++i) { | ||
var type = OUTPUT_TYPES[i]; | ||
method[type] = createOutputMethod(type, is224); | ||
} | ||
return method; | ||
}; | ||
/* | ||
* Cryptographically secure pseudorandom number generator | ||
* | ||
* As Math.random() is cryptographically not safe to use | ||
*/ | ||
var cryptoSecureRandomInt = function () { | ||
if (crypto) { | ||
// Use getRandomValues method (Browser) | ||
if (typeof crypto.getRandomValues === 'function') { | ||
try { | ||
return crypto.getRandomValues(new Uint32Array(1))[0]; | ||
} catch (err) {} | ||
} | ||
var nodeWrap = function (method, is224) { | ||
var crypto = require$$1; | ||
var Buffer = require$$1.Buffer; | ||
var algorithm = is224 ? 'sha224' : 'sha256'; | ||
var bufferFrom; | ||
if (Buffer.from && !root.JS_SHA256_NO_BUFFER_FROM) { | ||
bufferFrom = Buffer.from; | ||
} else { | ||
bufferFrom = function (message) { | ||
return new Buffer(message); | ||
}; | ||
} | ||
var nodeMethod = function (message) { | ||
if (typeof message === 'string') { | ||
return crypto.createHash(algorithm).update(message, 'utf8').digest('hex'); | ||
} else { | ||
if (message === null || message === undefined) { | ||
throw new Error(ERROR); | ||
} else if (message.constructor === ArrayBuffer) { | ||
message = new Uint8Array(message); | ||
} | ||
} | ||
if (Array.isArray(message) || ArrayBuffer.isView(message) || | ||
message.constructor === Buffer) { | ||
return crypto.createHash(algorithm).update(bufferFrom(message)).digest('hex'); | ||
} else { | ||
return method(message); | ||
} | ||
}; | ||
return nodeMethod; | ||
}; | ||
// Use randomBytes method (NodeJS) | ||
if (typeof crypto.randomBytes === 'function') { | ||
try { | ||
return crypto.randomBytes(4).readInt32LE(); | ||
} catch (err) {} | ||
} | ||
} | ||
var createHmacOutputMethod = function (outputType, is224) { | ||
return function (key, message) { | ||
return new HmacSha256(key, is224, true).update(message)[outputType](); | ||
}; | ||
}; | ||
throw new Error('Native crypto module could not be used to get secure random number.'); | ||
}; | ||
var createHmacMethod = function (is224) { | ||
var method = createHmacOutputMethod('hex', is224); | ||
method.create = function (key) { | ||
return new HmacSha256(key, is224); | ||
}; | ||
method.update = function (key, message) { | ||
return method.create(key).update(message); | ||
}; | ||
for (var i = 0; i < OUTPUT_TYPES.length; ++i) { | ||
var type = OUTPUT_TYPES[i]; | ||
method[type] = createHmacOutputMethod(type, is224); | ||
} | ||
return method; | ||
}; | ||
/* | ||
* Local polyfill of Object.create | ||
function Sha256(is224, sharedMemory) { | ||
if (sharedMemory) { | ||
blocks[0] = blocks[16] = blocks[1] = blocks[2] = blocks[3] = | ||
blocks[4] = blocks[5] = blocks[6] = blocks[7] = | ||
blocks[8] = blocks[9] = blocks[10] = blocks[11] = | ||
blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0; | ||
this.blocks = blocks; | ||
} else { | ||
this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; | ||
} | ||
*/ | ||
var create = Object.create || (function () { | ||
function F() {} | ||
if (is224) { | ||
this.h0 = 0xc1059ed8; | ||
this.h1 = 0x367cd507; | ||
this.h2 = 0x3070dd17; | ||
this.h3 = 0xf70e5939; | ||
this.h4 = 0xffc00b31; | ||
this.h5 = 0x68581511; | ||
this.h6 = 0x64f98fa7; | ||
this.h7 = 0xbefa4fa4; | ||
} else { // 256 | ||
this.h0 = 0x6a09e667; | ||
this.h1 = 0xbb67ae85; | ||
this.h2 = 0x3c6ef372; | ||
this.h3 = 0xa54ff53a; | ||
this.h4 = 0x510e527f; | ||
this.h5 = 0x9b05688c; | ||
this.h6 = 0x1f83d9ab; | ||
this.h7 = 0x5be0cd19; | ||
} | ||
return function (obj) { | ||
var subtype; | ||
this.block = this.start = this.bytes = this.hBytes = 0; | ||
this.finalized = this.hashed = false; | ||
this.first = true; | ||
this.is224 = is224; | ||
} | ||
F.prototype = obj; | ||
Sha256.prototype.update = function (message) { | ||
if (this.finalized) { | ||
return; | ||
} | ||
var notString, type = typeof message; | ||
if (type !== 'string') { | ||
if (type === 'object') { | ||
if (message === null) { | ||
throw new Error(ERROR); | ||
} else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) { | ||
message = new Uint8Array(message); | ||
} else if (!Array.isArray(message)) { | ||
if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) { | ||
throw new Error(ERROR); | ||
} | ||
} | ||
} else { | ||
throw new Error(ERROR); | ||
} | ||
notString = true; | ||
} | ||
var code, index = 0, i, length = message.length, blocks = this.blocks; | ||
while (index < length) { | ||
if (this.hashed) { | ||
this.hashed = false; | ||
blocks[0] = this.block; | ||
this.block = blocks[16] = blocks[1] = blocks[2] = blocks[3] = | ||
blocks[4] = blocks[5] = blocks[6] = blocks[7] = | ||
blocks[8] = blocks[9] = blocks[10] = blocks[11] = | ||
blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0; | ||
} | ||
subtype = new F(); | ||
if (notString) { | ||
for (i = this.start; index < length && i < 64; ++index) { | ||
blocks[i >>> 2] |= message[index] << SHIFT[i++ & 3]; | ||
} | ||
} else { | ||
for (i = this.start; index < length && i < 64; ++index) { | ||
code = message.charCodeAt(index); | ||
if (code < 0x80) { | ||
blocks[i >>> 2] |= code << SHIFT[i++ & 3]; | ||
} else if (code < 0x800) { | ||
blocks[i >>> 2] |= (0xc0 | (code >>> 6)) << SHIFT[i++ & 3]; | ||
blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; | ||
} else if (code < 0xd800 || code >= 0xe000) { | ||
blocks[i >>> 2] |= (0xe0 | (code >>> 12)) << SHIFT[i++ & 3]; | ||
blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3]; | ||
blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; | ||
} else { | ||
code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); | ||
blocks[i >>> 2] |= (0xf0 | (code >>> 18)) << SHIFT[i++ & 3]; | ||
blocks[i >>> 2] |= (0x80 | ((code >>> 12) & 0x3f)) << SHIFT[i++ & 3]; | ||
blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3]; | ||
blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; | ||
} | ||
} | ||
} | ||
F.prototype = null; | ||
this.lastByteIndex = i; | ||
this.bytes += i - this.start; | ||
if (i >= 64) { | ||
this.block = blocks[16]; | ||
this.start = i - 64; | ||
this.hash(); | ||
this.hashed = true; | ||
} else { | ||
this.start = i; | ||
} | ||
} | ||
if (this.bytes > 4294967295) { | ||
this.hBytes += this.bytes / 4294967296 << 0; | ||
this.bytes = this.bytes % 4294967296; | ||
} | ||
return this; | ||
}; | ||
return subtype; | ||
}; | ||
}()); | ||
Sha256.prototype.finalize = function () { | ||
if (this.finalized) { | ||
return; | ||
} | ||
this.finalized = true; | ||
var blocks = this.blocks, i = this.lastByteIndex; | ||
blocks[16] = this.block; | ||
blocks[i >>> 2] |= EXTRA[i & 3]; | ||
this.block = blocks[16]; | ||
if (i >= 56) { | ||
if (!this.hashed) { | ||
this.hash(); | ||
} | ||
blocks[0] = this.block; | ||
blocks[16] = blocks[1] = blocks[2] = blocks[3] = | ||
blocks[4] = blocks[5] = blocks[6] = blocks[7] = | ||
blocks[8] = blocks[9] = blocks[10] = blocks[11] = | ||
blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0; | ||
} | ||
blocks[14] = this.hBytes << 3 | this.bytes >>> 29; | ||
blocks[15] = this.bytes << 3; | ||
this.hash(); | ||
}; | ||
/** | ||
* CryptoJS namespace. | ||
*/ | ||
var C = {}; | ||
Sha256.prototype.hash = function () { | ||
var a = this.h0, b = this.h1, c = this.h2, d = this.h3, e = this.h4, f = this.h5, g = this.h6, | ||
h = this.h7, blocks = this.blocks, j, s0, s1, maj, t1, t2, ch, ab, da, cd, bc; | ||
/** | ||
* Library namespace. | ||
*/ | ||
var C_lib = C.lib = {}; | ||
for (j = 16; j < 64; ++j) { | ||
// rightrotate | ||
t1 = blocks[j - 15]; | ||
s0 = ((t1 >>> 7) | (t1 << 25)) ^ ((t1 >>> 18) | (t1 << 14)) ^ (t1 >>> 3); | ||
t1 = blocks[j - 2]; | ||
s1 = ((t1 >>> 17) | (t1 << 15)) ^ ((t1 >>> 19) | (t1 << 13)) ^ (t1 >>> 10); | ||
blocks[j] = blocks[j - 16] + s0 + blocks[j - 7] + s1 << 0; | ||
} | ||
/** | ||
* Base object for prototypal inheritance. | ||
*/ | ||
var Base = C_lib.Base = (function () { | ||
bc = b & c; | ||
for (j = 0; j < 64; j += 4) { | ||
if (this.first) { | ||
if (this.is224) { | ||
ab = 300032; | ||
t1 = blocks[0] - 1413257819; | ||
h = t1 - 150054599 << 0; | ||
d = t1 + 24177077 << 0; | ||
} else { | ||
ab = 704751109; | ||
t1 = blocks[0] - 210244248; | ||
h = t1 - 1521486534 << 0; | ||
d = t1 + 143694565 << 0; | ||
} | ||
this.first = false; | ||
} else { | ||
s0 = ((a >>> 2) | (a << 30)) ^ ((a >>> 13) | (a << 19)) ^ ((a >>> 22) | (a << 10)); | ||
s1 = ((e >>> 6) | (e << 26)) ^ ((e >>> 11) | (e << 21)) ^ ((e >>> 25) | (e << 7)); | ||
ab = a & b; | ||
maj = ab ^ (a & c) ^ bc; | ||
ch = (e & f) ^ (~e & g); | ||
t1 = h + s1 + ch + K[j] + blocks[j]; | ||
t2 = s0 + maj; | ||
h = d + t1 << 0; | ||
d = t1 + t2 << 0; | ||
} | ||
s0 = ((d >>> 2) | (d << 30)) ^ ((d >>> 13) | (d << 19)) ^ ((d >>> 22) | (d << 10)); | ||
s1 = ((h >>> 6) | (h << 26)) ^ ((h >>> 11) | (h << 21)) ^ ((h >>> 25) | (h << 7)); | ||
da = d & a; | ||
maj = da ^ (d & b) ^ ab; | ||
ch = (h & e) ^ (~h & f); | ||
t1 = g + s1 + ch + K[j + 1] + blocks[j + 1]; | ||
t2 = s0 + maj; | ||
g = c + t1 << 0; | ||
c = t1 + t2 << 0; | ||
s0 = ((c >>> 2) | (c << 30)) ^ ((c >>> 13) | (c << 19)) ^ ((c >>> 22) | (c << 10)); | ||
s1 = ((g >>> 6) | (g << 26)) ^ ((g >>> 11) | (g << 21)) ^ ((g >>> 25) | (g << 7)); | ||
cd = c & d; | ||
maj = cd ^ (c & a) ^ da; | ||
ch = (g & h) ^ (~g & e); | ||
t1 = f + s1 + ch + K[j + 2] + blocks[j + 2]; | ||
t2 = s0 + maj; | ||
f = b + t1 << 0; | ||
b = t1 + t2 << 0; | ||
s0 = ((b >>> 2) | (b << 30)) ^ ((b >>> 13) | (b << 19)) ^ ((b >>> 22) | (b << 10)); | ||
s1 = ((f >>> 6) | (f << 26)) ^ ((f >>> 11) | (f << 21)) ^ ((f >>> 25) | (f << 7)); | ||
bc = b & c; | ||
maj = bc ^ (b & d) ^ cd; | ||
ch = (f & g) ^ (~f & h); | ||
t1 = e + s1 + ch + K[j + 3] + blocks[j + 3]; | ||
t2 = s0 + maj; | ||
e = a + t1 << 0; | ||
a = t1 + t2 << 0; | ||
this.chromeBugWorkAround = true; | ||
} | ||
this.h0 = this.h0 + a << 0; | ||
this.h1 = this.h1 + b << 0; | ||
this.h2 = this.h2 + c << 0; | ||
this.h3 = this.h3 + d << 0; | ||
this.h4 = this.h4 + e << 0; | ||
this.h5 = this.h5 + f << 0; | ||
this.h6 = this.h6 + g << 0; | ||
this.h7 = this.h7 + h << 0; | ||
}; | ||
return { | ||
/** | ||
* Creates a new object that inherits from this object. | ||
* | ||
* @param {Object} overrides Properties to copy into the new object. | ||
* | ||
* @return {Object} The new object. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var MyType = CryptoJS.lib.Base.extend({ | ||
* field: 'value', | ||
* | ||
* method: function () { | ||
* } | ||
* }); | ||
*/ | ||
extend: function (overrides) { | ||
// Spawn | ||
var subtype = create(this); | ||
Sha256.prototype.hex = function () { | ||
this.finalize(); | ||
// Augment | ||
if (overrides) { | ||
subtype.mixIn(overrides); | ||
} | ||
var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4, h5 = this.h5, | ||
h6 = this.h6, h7 = this.h7; | ||
// Create default initializer | ||
if (!subtype.hasOwnProperty('init') || this.init === subtype.init) { | ||
subtype.init = function () { | ||
subtype.$super.init.apply(this, arguments); | ||
}; | ||
} | ||
var hex = HEX_CHARS[(h0 >>> 28) & 0x0F] + HEX_CHARS[(h0 >>> 24) & 0x0F] + | ||
HEX_CHARS[(h0 >>> 20) & 0x0F] + HEX_CHARS[(h0 >>> 16) & 0x0F] + | ||
HEX_CHARS[(h0 >>> 12) & 0x0F] + HEX_CHARS[(h0 >>> 8) & 0x0F] + | ||
HEX_CHARS[(h0 >>> 4) & 0x0F] + HEX_CHARS[h0 & 0x0F] + | ||
HEX_CHARS[(h1 >>> 28) & 0x0F] + HEX_CHARS[(h1 >>> 24) & 0x0F] + | ||
HEX_CHARS[(h1 >>> 20) & 0x0F] + HEX_CHARS[(h1 >>> 16) & 0x0F] + | ||
HEX_CHARS[(h1 >>> 12) & 0x0F] + HEX_CHARS[(h1 >>> 8) & 0x0F] + | ||
HEX_CHARS[(h1 >>> 4) & 0x0F] + HEX_CHARS[h1 & 0x0F] + | ||
HEX_CHARS[(h2 >>> 28) & 0x0F] + HEX_CHARS[(h2 >>> 24) & 0x0F] + | ||
HEX_CHARS[(h2 >>> 20) & 0x0F] + HEX_CHARS[(h2 >>> 16) & 0x0F] + | ||
HEX_CHARS[(h2 >>> 12) & 0x0F] + HEX_CHARS[(h2 >>> 8) & 0x0F] + | ||
HEX_CHARS[(h2 >>> 4) & 0x0F] + HEX_CHARS[h2 & 0x0F] + | ||
HEX_CHARS[(h3 >>> 28) & 0x0F] + HEX_CHARS[(h3 >>> 24) & 0x0F] + | ||
HEX_CHARS[(h3 >>> 20) & 0x0F] + HEX_CHARS[(h3 >>> 16) & 0x0F] + | ||
HEX_CHARS[(h3 >>> 12) & 0x0F] + HEX_CHARS[(h3 >>> 8) & 0x0F] + | ||
HEX_CHARS[(h3 >>> 4) & 0x0F] + HEX_CHARS[h3 & 0x0F] + | ||
HEX_CHARS[(h4 >>> 28) & 0x0F] + HEX_CHARS[(h4 >>> 24) & 0x0F] + | ||
HEX_CHARS[(h4 >>> 20) & 0x0F] + HEX_CHARS[(h4 >>> 16) & 0x0F] + | ||
HEX_CHARS[(h4 >>> 12) & 0x0F] + HEX_CHARS[(h4 >>> 8) & 0x0F] + | ||
HEX_CHARS[(h4 >>> 4) & 0x0F] + HEX_CHARS[h4 & 0x0F] + | ||
HEX_CHARS[(h5 >>> 28) & 0x0F] + HEX_CHARS[(h5 >>> 24) & 0x0F] + | ||
HEX_CHARS[(h5 >>> 20) & 0x0F] + HEX_CHARS[(h5 >>> 16) & 0x0F] + | ||
HEX_CHARS[(h5 >>> 12) & 0x0F] + HEX_CHARS[(h5 >>> 8) & 0x0F] + | ||
HEX_CHARS[(h5 >>> 4) & 0x0F] + HEX_CHARS[h5 & 0x0F] + | ||
HEX_CHARS[(h6 >>> 28) & 0x0F] + HEX_CHARS[(h6 >>> 24) & 0x0F] + | ||
HEX_CHARS[(h6 >>> 20) & 0x0F] + HEX_CHARS[(h6 >>> 16) & 0x0F] + | ||
HEX_CHARS[(h6 >>> 12) & 0x0F] + HEX_CHARS[(h6 >>> 8) & 0x0F] + | ||
HEX_CHARS[(h6 >>> 4) & 0x0F] + HEX_CHARS[h6 & 0x0F]; | ||
if (!this.is224) { | ||
hex += HEX_CHARS[(h7 >>> 28) & 0x0F] + HEX_CHARS[(h7 >>> 24) & 0x0F] + | ||
HEX_CHARS[(h7 >>> 20) & 0x0F] + HEX_CHARS[(h7 >>> 16) & 0x0F] + | ||
HEX_CHARS[(h7 >>> 12) & 0x0F] + HEX_CHARS[(h7 >>> 8) & 0x0F] + | ||
HEX_CHARS[(h7 >>> 4) & 0x0F] + HEX_CHARS[h7 & 0x0F]; | ||
} | ||
return hex; | ||
}; | ||
// Initializer's prototype is the subtype object | ||
subtype.init.prototype = subtype; | ||
Sha256.prototype.toString = Sha256.prototype.hex; | ||
// Reference supertype | ||
subtype.$super = this; | ||
Sha256.prototype.digest = function () { | ||
this.finalize(); | ||
return subtype; | ||
}, | ||
var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4, h5 = this.h5, | ||
h6 = this.h6, h7 = this.h7; | ||
/** | ||
* Extends this object and runs the init method. | ||
* Arguments to create() will be passed to init(). | ||
* | ||
* @return {Object} The new object. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var instance = MyType.create(); | ||
*/ | ||
create: function () { | ||
var instance = this.extend(); | ||
instance.init.apply(instance, arguments); | ||
var arr = [ | ||
(h0 >>> 24) & 0xFF, (h0 >>> 16) & 0xFF, (h0 >>> 8) & 0xFF, h0 & 0xFF, | ||
(h1 >>> 24) & 0xFF, (h1 >>> 16) & 0xFF, (h1 >>> 8) & 0xFF, h1 & 0xFF, | ||
(h2 >>> 24) & 0xFF, (h2 >>> 16) & 0xFF, (h2 >>> 8) & 0xFF, h2 & 0xFF, | ||
(h3 >>> 24) & 0xFF, (h3 >>> 16) & 0xFF, (h3 >>> 8) & 0xFF, h3 & 0xFF, | ||
(h4 >>> 24) & 0xFF, (h4 >>> 16) & 0xFF, (h4 >>> 8) & 0xFF, h4 & 0xFF, | ||
(h5 >>> 24) & 0xFF, (h5 >>> 16) & 0xFF, (h5 >>> 8) & 0xFF, h5 & 0xFF, | ||
(h6 >>> 24) & 0xFF, (h6 >>> 16) & 0xFF, (h6 >>> 8) & 0xFF, h6 & 0xFF | ||
]; | ||
if (!this.is224) { | ||
arr.push((h7 >>> 24) & 0xFF, (h7 >>> 16) & 0xFF, (h7 >>> 8) & 0xFF, h7 & 0xFF); | ||
} | ||
return arr; | ||
}; | ||
return instance; | ||
}, | ||
Sha256.prototype.array = Sha256.prototype.digest; | ||
/** | ||
* Initializes a newly created object. | ||
* Override this method to add some logic when your objects are created. | ||
* | ||
* @example | ||
* | ||
* var MyType = CryptoJS.lib.Base.extend({ | ||
* init: function () { | ||
* // ... | ||
* } | ||
* }); | ||
*/ | ||
init: function () { | ||
}, | ||
Sha256.prototype.arrayBuffer = function () { | ||
this.finalize(); | ||
/** | ||
* Copies properties into this object. | ||
* | ||
* @param {Object} properties The properties to mix in. | ||
* | ||
* @example | ||
* | ||
* MyType.mixIn({ | ||
* field: 'value' | ||
* }); | ||
*/ | ||
mixIn: function (properties) { | ||
for (var propertyName in properties) { | ||
if (properties.hasOwnProperty(propertyName)) { | ||
this[propertyName] = properties[propertyName]; | ||
} | ||
} | ||
var buffer = new ArrayBuffer(this.is224 ? 28 : 32); | ||
var dataView = new DataView(buffer); | ||
dataView.setUint32(0, this.h0); | ||
dataView.setUint32(4, this.h1); | ||
dataView.setUint32(8, this.h2); | ||
dataView.setUint32(12, this.h3); | ||
dataView.setUint32(16, this.h4); | ||
dataView.setUint32(20, this.h5); | ||
dataView.setUint32(24, this.h6); | ||
if (!this.is224) { | ||
dataView.setUint32(28, this.h7); | ||
} | ||
return buffer; | ||
}; | ||
// IE won't copy toString using the loop above | ||
if (properties.hasOwnProperty('toString')) { | ||
this.toString = properties.toString; | ||
} | ||
}, | ||
function HmacSha256(key, is224, sharedMemory) { | ||
var i, type = typeof key; | ||
if (type === 'string') { | ||
var bytes = [], length = key.length, index = 0, code; | ||
for (i = 0; i < length; ++i) { | ||
code = key.charCodeAt(i); | ||
if (code < 0x80) { | ||
bytes[index++] = code; | ||
} else if (code < 0x800) { | ||
bytes[index++] = (0xc0 | (code >>> 6)); | ||
bytes[index++] = (0x80 | (code & 0x3f)); | ||
} else if (code < 0xd800 || code >= 0xe000) { | ||
bytes[index++] = (0xe0 | (code >>> 12)); | ||
bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); | ||
bytes[index++] = (0x80 | (code & 0x3f)); | ||
} else { | ||
code = 0x10000 + (((code & 0x3ff) << 10) | (key.charCodeAt(++i) & 0x3ff)); | ||
bytes[index++] = (0xf0 | (code >>> 18)); | ||
bytes[index++] = (0x80 | ((code >>> 12) & 0x3f)); | ||
bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); | ||
bytes[index++] = (0x80 | (code & 0x3f)); | ||
} | ||
} | ||
key = bytes; | ||
} else { | ||
if (type === 'object') { | ||
if (key === null) { | ||
throw new Error(ERROR); | ||
} else if (ARRAY_BUFFER && key.constructor === ArrayBuffer) { | ||
key = new Uint8Array(key); | ||
} else if (!Array.isArray(key)) { | ||
if (!ARRAY_BUFFER || !ArrayBuffer.isView(key)) { | ||
throw new Error(ERROR); | ||
} | ||
} | ||
} else { | ||
throw new Error(ERROR); | ||
} | ||
} | ||
/** | ||
* Creates a copy of this object. | ||
* | ||
* @return {Object} The clone. | ||
* | ||
* @example | ||
* | ||
* var clone = instance.clone(); | ||
*/ | ||
clone: function () { | ||
return this.init.prototype.extend(this); | ||
} | ||
}; | ||
}()); | ||
if (key.length > 64) { | ||
key = (new Sha256(is224, true)).update(key).array(); | ||
} | ||
/** | ||
* An array of 32-bit words. | ||
* | ||
* @property {Array} words The array of 32-bit words. | ||
* @property {number} sigBytes The number of significant bytes in this word array. | ||
*/ | ||
var WordArray = C_lib.WordArray = Base.extend({ | ||
/** | ||
* Initializes a newly created word array. | ||
* | ||
* @param {Array} words (Optional) An array of 32-bit words. | ||
* @param {number} sigBytes (Optional) The number of significant bytes in the words. | ||
* | ||
* @example | ||
* | ||
* var wordArray = CryptoJS.lib.WordArray.create(); | ||
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]); | ||
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6); | ||
*/ | ||
init: function (words, sigBytes) { | ||
words = this.words = words || []; | ||
var oKeyPad = [], iKeyPad = []; | ||
for (i = 0; i < 64; ++i) { | ||
var b = key[i] || 0; | ||
oKeyPad[i] = 0x5c ^ b; | ||
iKeyPad[i] = 0x36 ^ b; | ||
} | ||
if (sigBytes != undefined$1) { | ||
this.sigBytes = sigBytes; | ||
} else { | ||
this.sigBytes = words.length * 4; | ||
} | ||
}, | ||
Sha256.call(this, is224, sharedMemory); | ||
/** | ||
* Converts this word array to a string. | ||
* | ||
* @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex | ||
* | ||
* @return {string} The stringified word array. | ||
* | ||
* @example | ||
* | ||
* var string = wordArray + ''; | ||
* var string = wordArray.toString(); | ||
* var string = wordArray.toString(CryptoJS.enc.Utf8); | ||
*/ | ||
toString: function (encoder) { | ||
return (encoder || Hex).stringify(this); | ||
}, | ||
this.update(iKeyPad); | ||
this.oKeyPad = oKeyPad; | ||
this.inner = true; | ||
this.sharedMemory = sharedMemory; | ||
} | ||
HmacSha256.prototype = new Sha256(); | ||
/** | ||
* Concatenates a word array to this word array. | ||
* | ||
* @param {WordArray} wordArray The word array to append. | ||
* | ||
* @return {WordArray} This word array. | ||
* | ||
* @example | ||
* | ||
* wordArray1.concat(wordArray2); | ||
*/ | ||
concat: function (wordArray) { | ||
// Shortcuts | ||
var thisWords = this.words; | ||
var thatWords = wordArray.words; | ||
var thisSigBytes = this.sigBytes; | ||
var thatSigBytes = wordArray.sigBytes; | ||
HmacSha256.prototype.finalize = function () { | ||
Sha256.prototype.finalize.call(this); | ||
if (this.inner) { | ||
this.inner = false; | ||
var innerHash = this.array(); | ||
Sha256.call(this, this.is224, this.sharedMemory); | ||
this.update(this.oKeyPad); | ||
this.update(innerHash); | ||
Sha256.prototype.finalize.call(this); | ||
} | ||
}; | ||
// Clamp excess bits | ||
this.clamp(); | ||
var exports = createMethod(); | ||
exports.sha256 = exports; | ||
exports.sha224 = createMethod(true); | ||
exports.sha256.hmac = createHmacMethod(); | ||
exports.sha224.hmac = createHmacMethod(true); | ||
// Concat | ||
if (thisSigBytes % 4) { | ||
// Copy one byte at a time | ||
for (var i = 0; i < thatSigBytes; i++) { | ||
var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; | ||
thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8); | ||
} | ||
} else { | ||
// Copy one word at a time | ||
for (var j = 0; j < thatSigBytes; j += 4) { | ||
thisWords[(thisSigBytes + j) >>> 2] = thatWords[j >>> 2]; | ||
} | ||
} | ||
this.sigBytes += thatSigBytes; | ||
// Chainable | ||
return this; | ||
}, | ||
/** | ||
* Removes insignificant bits. | ||
* | ||
* @example | ||
* | ||
* wordArray.clamp(); | ||
*/ | ||
clamp: function () { | ||
// Shortcuts | ||
var words = this.words; | ||
var sigBytes = this.sigBytes; | ||
// Clamp | ||
words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8); | ||
words.length = Math.ceil(sigBytes / 4); | ||
}, | ||
/** | ||
* Creates a copy of this word array. | ||
* | ||
* @return {WordArray} The clone. | ||
* | ||
* @example | ||
* | ||
* var clone = wordArray.clone(); | ||
*/ | ||
clone: function () { | ||
var clone = Base.clone.call(this); | ||
clone.words = this.words.slice(0); | ||
return clone; | ||
}, | ||
/** | ||
* Creates a word array filled with random bytes. | ||
* | ||
* @param {number} nBytes The number of random bytes to generate. | ||
* | ||
* @return {WordArray} The random word array. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var wordArray = CryptoJS.lib.WordArray.random(16); | ||
*/ | ||
random: function (nBytes) { | ||
var words = []; | ||
for (var i = 0; i < nBytes; i += 4) { | ||
words.push(cryptoSecureRandomInt()); | ||
} | ||
return new WordArray.init(words, nBytes); | ||
} | ||
}); | ||
/** | ||
* Encoder namespace. | ||
*/ | ||
var C_enc = C.enc = {}; | ||
/** | ||
* Hex encoding strategy. | ||
*/ | ||
var Hex = C_enc.Hex = { | ||
/** | ||
* Converts a word array to a hex string. | ||
* | ||
* @param {WordArray} wordArray The word array. | ||
* | ||
* @return {string} The hex string. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var hexString = CryptoJS.enc.Hex.stringify(wordArray); | ||
*/ | ||
stringify: function (wordArray) { | ||
// Shortcuts | ||
var words = wordArray.words; | ||
var sigBytes = wordArray.sigBytes; | ||
// Convert | ||
var hexChars = []; | ||
for (var i = 0; i < sigBytes; i++) { | ||
var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; | ||
hexChars.push((bite >>> 4).toString(16)); | ||
hexChars.push((bite & 0x0f).toString(16)); | ||
} | ||
return hexChars.join(''); | ||
}, | ||
/** | ||
* Converts a hex string to a word array. | ||
* | ||
* @param {string} hexStr The hex string. | ||
* | ||
* @return {WordArray} The word array. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var wordArray = CryptoJS.enc.Hex.parse(hexString); | ||
*/ | ||
parse: function (hexStr) { | ||
// Shortcut | ||
var hexStrLength = hexStr.length; | ||
// Convert | ||
var words = []; | ||
for (var i = 0; i < hexStrLength; i += 2) { | ||
words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4); | ||
} | ||
return new WordArray.init(words, hexStrLength / 2); | ||
} | ||
}; | ||
/** | ||
* Latin1 encoding strategy. | ||
*/ | ||
var Latin1 = C_enc.Latin1 = { | ||
/** | ||
* Converts a word array to a Latin1 string. | ||
* | ||
* @param {WordArray} wordArray The word array. | ||
* | ||
* @return {string} The Latin1 string. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var latin1String = CryptoJS.enc.Latin1.stringify(wordArray); | ||
*/ | ||
stringify: function (wordArray) { | ||
// Shortcuts | ||
var words = wordArray.words; | ||
var sigBytes = wordArray.sigBytes; | ||
// Convert | ||
var latin1Chars = []; | ||
for (var i = 0; i < sigBytes; i++) { | ||
var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; | ||
latin1Chars.push(String.fromCharCode(bite)); | ||
} | ||
return latin1Chars.join(''); | ||
}, | ||
/** | ||
* Converts a Latin1 string to a word array. | ||
* | ||
* @param {string} latin1Str The Latin1 string. | ||
* | ||
* @return {WordArray} The word array. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var wordArray = CryptoJS.enc.Latin1.parse(latin1String); | ||
*/ | ||
parse: function (latin1Str) { | ||
// Shortcut | ||
var latin1StrLength = latin1Str.length; | ||
// Convert | ||
var words = []; | ||
for (var i = 0; i < latin1StrLength; i++) { | ||
words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8); | ||
} | ||
return new WordArray.init(words, latin1StrLength); | ||
} | ||
}; | ||
/** | ||
* UTF-8 encoding strategy. | ||
*/ | ||
var Utf8 = C_enc.Utf8 = { | ||
/** | ||
* Converts a word array to a UTF-8 string. | ||
* | ||
* @param {WordArray} wordArray The word array. | ||
* | ||
* @return {string} The UTF-8 string. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var utf8String = CryptoJS.enc.Utf8.stringify(wordArray); | ||
*/ | ||
stringify: function (wordArray) { | ||
try { | ||
return decodeURIComponent(escape(Latin1.stringify(wordArray))); | ||
} catch (e) { | ||
throw new Error('Malformed UTF-8 data'); | ||
} | ||
}, | ||
/** | ||
* Converts a UTF-8 string to a word array. | ||
* | ||
* @param {string} utf8Str The UTF-8 string. | ||
* | ||
* @return {WordArray} The word array. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var wordArray = CryptoJS.enc.Utf8.parse(utf8String); | ||
*/ | ||
parse: function (utf8Str) { | ||
return Latin1.parse(unescape(encodeURIComponent(utf8Str))); | ||
} | ||
}; | ||
/** | ||
* Abstract buffered block algorithm template. | ||
* | ||
* The property blockSize must be implemented in a concrete subtype. | ||
* | ||
* @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0 | ||
*/ | ||
var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({ | ||
/** | ||
* Resets this block algorithm's data buffer to its initial state. | ||
* | ||
* @example | ||
* | ||
* bufferedBlockAlgorithm.reset(); | ||
*/ | ||
reset: function () { | ||
// Initial values | ||
this._data = new WordArray.init(); | ||
this._nDataBytes = 0; | ||
}, | ||
/** | ||
* Adds new data to this block algorithm's buffer. | ||
* | ||
* @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8. | ||
* | ||
* @example | ||
* | ||
* bufferedBlockAlgorithm._append('data'); | ||
* bufferedBlockAlgorithm._append(wordArray); | ||
*/ | ||
_append: function (data) { | ||
// Convert string to WordArray, else assume WordArray already | ||
if (typeof data == 'string') { | ||
data = Utf8.parse(data); | ||
} | ||
// Append | ||
this._data.concat(data); | ||
this._nDataBytes += data.sigBytes; | ||
}, | ||
/** | ||
* Processes available data blocks. | ||
* | ||
* This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype. | ||
* | ||
* @param {boolean} doFlush Whether all blocks and partial blocks should be processed. | ||
* | ||
* @return {WordArray} The processed data. | ||
* | ||
* @example | ||
* | ||
* var processedData = bufferedBlockAlgorithm._process(); | ||
* var processedData = bufferedBlockAlgorithm._process(!!'flush'); | ||
*/ | ||
_process: function (doFlush) { | ||
var processedWords; | ||
// Shortcuts | ||
var data = this._data; | ||
var dataWords = data.words; | ||
var dataSigBytes = data.sigBytes; | ||
var blockSize = this.blockSize; | ||
var blockSizeBytes = blockSize * 4; | ||
// Count blocks ready | ||
var nBlocksReady = dataSigBytes / blockSizeBytes; | ||
if (doFlush) { | ||
// Round up to include partial blocks | ||
nBlocksReady = Math.ceil(nBlocksReady); | ||
} else { | ||
// Round down to include only full blocks, | ||
// less the number of blocks that must remain in the buffer | ||
nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0); | ||
} | ||
// Count words ready | ||
var nWordsReady = nBlocksReady * blockSize; | ||
// Count bytes ready | ||
var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes); | ||
// Process blocks | ||
if (nWordsReady) { | ||
for (var offset = 0; offset < nWordsReady; offset += blockSize) { | ||
// Perform concrete-algorithm logic | ||
this._doProcessBlock(dataWords, offset); | ||
} | ||
// Remove processed words | ||
processedWords = dataWords.splice(0, nWordsReady); | ||
data.sigBytes -= nBytesReady; | ||
} | ||
// Return processed words | ||
return new WordArray.init(processedWords, nBytesReady); | ||
}, | ||
/** | ||
* Creates a copy of this object. | ||
* | ||
* @return {Object} The clone. | ||
* | ||
* @example | ||
* | ||
* var clone = bufferedBlockAlgorithm.clone(); | ||
*/ | ||
clone: function () { | ||
var clone = Base.clone.call(this); | ||
clone._data = this._data.clone(); | ||
return clone; | ||
}, | ||
_minBufferSize: 0 | ||
}); | ||
/** | ||
* Abstract hasher template. | ||
* | ||
* @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits) | ||
*/ | ||
C_lib.Hasher = BufferedBlockAlgorithm.extend({ | ||
/** | ||
* Configuration options. | ||
*/ | ||
cfg: Base.extend(), | ||
/** | ||
* Initializes a newly created hasher. | ||
* | ||
* @param {Object} cfg (Optional) The configuration options to use for this hash computation. | ||
* | ||
* @example | ||
* | ||
* var hasher = CryptoJS.algo.SHA256.create(); | ||
*/ | ||
init: function (cfg) { | ||
// Apply config defaults | ||
this.cfg = this.cfg.extend(cfg); | ||
// Set initial values | ||
this.reset(); | ||
}, | ||
/** | ||
* Resets this hasher to its initial state. | ||
* | ||
* @example | ||
* | ||
* hasher.reset(); | ||
*/ | ||
reset: function () { | ||
// Reset data buffer | ||
BufferedBlockAlgorithm.reset.call(this); | ||
// Perform concrete-hasher logic | ||
this._doReset(); | ||
}, | ||
/** | ||
* Updates this hasher with a message. | ||
* | ||
* @param {WordArray|string} messageUpdate The message to append. | ||
* | ||
* @return {Hasher} This hasher. | ||
* | ||
* @example | ||
* | ||
* hasher.update('message'); | ||
* hasher.update(wordArray); | ||
*/ | ||
update: function (messageUpdate) { | ||
// Append | ||
this._append(messageUpdate); | ||
// Update the hash | ||
this._process(); | ||
// Chainable | ||
return this; | ||
}, | ||
/** | ||
* Finalizes the hash computation. | ||
* Note that the finalize operation is effectively a destructive, read-once operation. | ||
* | ||
* @param {WordArray|string} messageUpdate (Optional) A final message update. | ||
* | ||
* @return {WordArray} The hash. | ||
* | ||
* @example | ||
* | ||
* var hash = hasher.finalize(); | ||
* var hash = hasher.finalize('message'); | ||
* var hash = hasher.finalize(wordArray); | ||
*/ | ||
finalize: function (messageUpdate) { | ||
// Final message update | ||
if (messageUpdate) { | ||
this._append(messageUpdate); | ||
} | ||
// Perform concrete-hasher logic | ||
var hash = this._doFinalize(); | ||
return hash; | ||
}, | ||
blockSize: 512/32, | ||
/** | ||
* Creates a shortcut function to a hasher's object interface. | ||
* | ||
* @param {Hasher} hasher The hasher to create a helper for. | ||
* | ||
* @return {Function} The shortcut function. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256); | ||
*/ | ||
_createHelper: function (hasher) { | ||
return function (message, cfg) { | ||
return new hasher.init(cfg).finalize(message); | ||
}; | ||
}, | ||
/** | ||
* Creates a shortcut function to the HMAC's object interface. | ||
* | ||
* @param {Hasher} hasher The hasher to use in this HMAC helper. | ||
* | ||
* @return {Function} The shortcut function. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256); | ||
*/ | ||
_createHmacHelper: function (hasher) { | ||
return function (message, key) { | ||
return new C_algo.HMAC.init(hasher, key).finalize(message); | ||
}; | ||
} | ||
}); | ||
/** | ||
* Algorithm namespace. | ||
*/ | ||
var C_algo = C.algo = {}; | ||
return C; | ||
}(Math)); | ||
return CryptoJS; | ||
})); | ||
}(core)); | ||
(function (module, exports) { | ||
(function (root, factory) { | ||
{ | ||
// CommonJS | ||
module.exports = factory(core.exports); | ||
} | ||
}(commonjsGlobal, function (CryptoJS) { | ||
(function (Math) { | ||
// Shortcuts | ||
var C = CryptoJS; | ||
var C_lib = C.lib; | ||
var WordArray = C_lib.WordArray; | ||
var Hasher = C_lib.Hasher; | ||
var C_algo = C.algo; | ||
// Initialization and round constants tables | ||
var H = []; | ||
var K = []; | ||
// Compute constants | ||
(function () { | ||
function isPrime(n) { | ||
var sqrtN = Math.sqrt(n); | ||
for (var factor = 2; factor <= sqrtN; factor++) { | ||
if (!(n % factor)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
function getFractionalBits(n) { | ||
return ((n - (n | 0)) * 0x100000000) | 0; | ||
} | ||
var n = 2; | ||
var nPrime = 0; | ||
while (nPrime < 64) { | ||
if (isPrime(n)) { | ||
if (nPrime < 8) { | ||
H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2)); | ||
} | ||
K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3)); | ||
nPrime++; | ||
} | ||
n++; | ||
} | ||
}()); | ||
// Reusable object | ||
var W = []; | ||
/** | ||
* SHA-256 hash algorithm. | ||
*/ | ||
var SHA256 = C_algo.SHA256 = Hasher.extend({ | ||
_doReset: function () { | ||
this._hash = new WordArray.init(H.slice(0)); | ||
}, | ||
_doProcessBlock: function (M, offset) { | ||
// Shortcut | ||
var H = this._hash.words; | ||
// Working variables | ||
var a = H[0]; | ||
var b = H[1]; | ||
var c = H[2]; | ||
var d = H[3]; | ||
var e = H[4]; | ||
var f = H[5]; | ||
var g = H[6]; | ||
var h = H[7]; | ||
// Computation | ||
for (var i = 0; i < 64; i++) { | ||
if (i < 16) { | ||
W[i] = M[offset + i] | 0; | ||
} else { | ||
var gamma0x = W[i - 15]; | ||
var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^ | ||
((gamma0x << 14) | (gamma0x >>> 18)) ^ | ||
(gamma0x >>> 3); | ||
var gamma1x = W[i - 2]; | ||
var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^ | ||
((gamma1x << 13) | (gamma1x >>> 19)) ^ | ||
(gamma1x >>> 10); | ||
W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]; | ||
} | ||
var ch = (e & f) ^ (~e & g); | ||
var maj = (a & b) ^ (a & c) ^ (b & c); | ||
var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22)); | ||
var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25)); | ||
var t1 = h + sigma1 + ch + K[i] + W[i]; | ||
var t2 = sigma0 + maj; | ||
h = g; | ||
g = f; | ||
f = e; | ||
e = (d + t1) | 0; | ||
d = c; | ||
c = b; | ||
b = a; | ||
a = (t1 + t2) | 0; | ||
} | ||
// Intermediate hash value | ||
H[0] = (H[0] + a) | 0; | ||
H[1] = (H[1] + b) | 0; | ||
H[2] = (H[2] + c) | 0; | ||
H[3] = (H[3] + d) | 0; | ||
H[4] = (H[4] + e) | 0; | ||
H[5] = (H[5] + f) | 0; | ||
H[6] = (H[6] + g) | 0; | ||
H[7] = (H[7] + h) | 0; | ||
}, | ||
_doFinalize: function () { | ||
// Shortcuts | ||
var data = this._data; | ||
var dataWords = data.words; | ||
var nBitsTotal = this._nDataBytes * 8; | ||
var nBitsLeft = data.sigBytes * 8; | ||
// Add padding | ||
dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); | ||
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000); | ||
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal; | ||
data.sigBytes = dataWords.length * 4; | ||
// Hash final blocks | ||
this._process(); | ||
// Return final computed hash | ||
return this._hash; | ||
}, | ||
clone: function () { | ||
var clone = Hasher.clone.call(this); | ||
clone._hash = this._hash.clone(); | ||
return clone; | ||
} | ||
}); | ||
/** | ||
* Shortcut function to the hasher's object interface. | ||
* | ||
* @param {WordArray|string} message The message to hash. | ||
* | ||
* @return {WordArray} The hash. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var hash = CryptoJS.SHA256('message'); | ||
* var hash = CryptoJS.SHA256(wordArray); | ||
*/ | ||
C.SHA256 = Hasher._createHelper(SHA256); | ||
/** | ||
* Shortcut function to the HMAC's object interface. | ||
* | ||
* @param {WordArray|string} message The message to hash. | ||
* @param {WordArray|string} key The secret key. | ||
* | ||
* @return {WordArray} The HMAC. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var hmac = CryptoJS.HmacSHA256(message, key); | ||
*/ | ||
C.HmacSHA256 = Hasher._createHmacHelper(SHA256); | ||
}(Math)); | ||
return CryptoJS.SHA256; | ||
})); | ||
if (COMMON_JS) { | ||
module.exports = exports; | ||
} else { | ||
root.sha256 = exports.sha256; | ||
root.sha224 = exports.sha224; | ||
} | ||
})(); | ||
}(sha256)); | ||
var encHex = {exports: {}}; | ||
(function (module, exports) { | ||
(function (root, factory) { | ||
{ | ||
// CommonJS | ||
module.exports = factory(core.exports); | ||
} | ||
}(commonjsGlobal, function (CryptoJS) { | ||
return CryptoJS.enc.Hex; | ||
})); | ||
}(encHex)); | ||
const ESRI_TELEMETRY_DATA_ATTRIBUTE = 'esri-telemetry'; | ||
@@ -1058,0 +588,0 @@ function injectScriptElementAsync(attributes) { |
@@ -36,4 +36,15 @@ (function (global, factory) { | ||
function commonjsRequire (path) { | ||
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); | ||
function getAugmentedNamespace(n) { | ||
if (n.__esModule) return n; | ||
var a = Object.defineProperty({}, '__esModule', {value: true}); | ||
Object.keys(n).forEach(function (k) { | ||
var d = Object.getOwnPropertyDescriptor(n, k); | ||
Object.defineProperty(a, k, d.get ? d : { | ||
enumerable: true, | ||
get: function () { | ||
return n[k]; | ||
} | ||
}); | ||
}); | ||
return a; | ||
} | ||
@@ -43,1015 +54,534 @@ | ||
var core = {exports: {}}; | ||
var _nodeResolve_empty = {}; | ||
(function (module, exports) { | ||
(function (root, factory) { | ||
{ | ||
// CommonJS | ||
module.exports = factory(); | ||
} | ||
}(commonjsGlobal, function () { | ||
var _nodeResolve_empty$1 = /*#__PURE__*/Object.freeze({ | ||
__proto__: null, | ||
'default': _nodeResolve_empty | ||
}); | ||
/*globals window, global, require*/ | ||
var require$$1 = /*@__PURE__*/getAugmentedNamespace(_nodeResolve_empty$1); | ||
/** | ||
* CryptoJS core components. | ||
*/ | ||
var CryptoJS = CryptoJS || (function (Math, undefined$1) { | ||
/** | ||
* [js-sha256]{@link https://github.com/emn178/js-sha256} | ||
* | ||
* @version 0.11.0 | ||
* @author Chen, Yi-Cyuan [emn178@gmail.com] | ||
* @copyright Chen, Yi-Cyuan 2014-2024 | ||
* @license MIT | ||
*/ | ||
var crypto; | ||
(function (module) { | ||
/*jslint bitwise: true */ | ||
(function () { | ||
// Native crypto from window (Browser) | ||
if (typeof window !== 'undefined' && window.crypto) { | ||
crypto = window.crypto; | ||
} | ||
var ERROR = 'input is invalid type'; | ||
var WINDOW = typeof window === 'object'; | ||
var root = WINDOW ? window : {}; | ||
if (root.JS_SHA256_NO_WINDOW) { | ||
WINDOW = false; | ||
} | ||
var WEB_WORKER = !WINDOW && typeof self === 'object'; | ||
var NODE_JS = !root.JS_SHA256_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node; | ||
if (NODE_JS) { | ||
root = commonjsGlobal; | ||
} else if (WEB_WORKER) { | ||
root = self; | ||
} | ||
var COMMON_JS = !root.JS_SHA256_NO_COMMON_JS && 'object' === 'object' && module.exports; | ||
var ARRAY_BUFFER = !root.JS_SHA256_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined'; | ||
var HEX_CHARS = '0123456789abcdef'.split(''); | ||
var EXTRA = [-2147483648, 8388608, 32768, 128]; | ||
var SHIFT = [24, 16, 8, 0]; | ||
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 OUTPUT_TYPES = ['hex', 'array', 'digest', 'arrayBuffer']; | ||
// Native crypto in web worker (Browser) | ||
if (typeof self !== 'undefined' && self.crypto) { | ||
crypto = self.crypto; | ||
} | ||
var blocks = []; | ||
// Native crypto from worker | ||
if (typeof globalThis !== 'undefined' && globalThis.crypto) { | ||
crypto = globalThis.crypto; | ||
} | ||
if (root.JS_SHA256_NO_NODE_JS || !Array.isArray) { | ||
Array.isArray = function (obj) { | ||
return Object.prototype.toString.call(obj) === '[object Array]'; | ||
}; | ||
} | ||
// Native (experimental IE 11) crypto from window (Browser) | ||
if (!crypto && typeof window !== 'undefined' && window.msCrypto) { | ||
crypto = window.msCrypto; | ||
} | ||
if (ARRAY_BUFFER && (root.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) { | ||
ArrayBuffer.isView = function (obj) { | ||
return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer; | ||
}; | ||
} | ||
// Native crypto from global (NodeJS) | ||
if (!crypto && typeof commonjsGlobal !== 'undefined' && commonjsGlobal.crypto) { | ||
crypto = commonjsGlobal.crypto; | ||
} | ||
var createOutputMethod = function (outputType, is224) { | ||
return function (message) { | ||
return new Sha256(is224, true).update(message)[outputType](); | ||
}; | ||
}; | ||
// Native crypto import via require (NodeJS) | ||
if (!crypto && typeof commonjsRequire === 'function') { | ||
try { | ||
crypto = require('crypto'); | ||
} catch (err) {} | ||
} | ||
var createMethod = function (is224) { | ||
var method = createOutputMethod('hex', is224); | ||
if (NODE_JS) { | ||
method = nodeWrap(method, is224); | ||
} | ||
method.create = function () { | ||
return new Sha256(is224); | ||
}; | ||
method.update = function (message) { | ||
return method.create().update(message); | ||
}; | ||
for (var i = 0; i < OUTPUT_TYPES.length; ++i) { | ||
var type = OUTPUT_TYPES[i]; | ||
method[type] = createOutputMethod(type, is224); | ||
} | ||
return method; | ||
}; | ||
/* | ||
* Cryptographically secure pseudorandom number generator | ||
* | ||
* As Math.random() is cryptographically not safe to use | ||
*/ | ||
var cryptoSecureRandomInt = function () { | ||
if (crypto) { | ||
// Use getRandomValues method (Browser) | ||
if (typeof crypto.getRandomValues === 'function') { | ||
try { | ||
return crypto.getRandomValues(new Uint32Array(1))[0]; | ||
} catch (err) {} | ||
} | ||
var nodeWrap = function (method, is224) { | ||
var crypto = require$$1; | ||
var Buffer = require$$1.Buffer; | ||
var algorithm = is224 ? 'sha224' : 'sha256'; | ||
var bufferFrom; | ||
if (Buffer.from && !root.JS_SHA256_NO_BUFFER_FROM) { | ||
bufferFrom = Buffer.from; | ||
} else { | ||
bufferFrom = function (message) { | ||
return new Buffer(message); | ||
}; | ||
} | ||
var nodeMethod = function (message) { | ||
if (typeof message === 'string') { | ||
return crypto.createHash(algorithm).update(message, 'utf8').digest('hex'); | ||
} else { | ||
if (message === null || message === undefined) { | ||
throw new Error(ERROR); | ||
} else if (message.constructor === ArrayBuffer) { | ||
message = new Uint8Array(message); | ||
} | ||
} | ||
if (Array.isArray(message) || ArrayBuffer.isView(message) || | ||
message.constructor === Buffer) { | ||
return crypto.createHash(algorithm).update(bufferFrom(message)).digest('hex'); | ||
} else { | ||
return method(message); | ||
} | ||
}; | ||
return nodeMethod; | ||
}; | ||
// Use randomBytes method (NodeJS) | ||
if (typeof crypto.randomBytes === 'function') { | ||
try { | ||
return crypto.randomBytes(4).readInt32LE(); | ||
} catch (err) {} | ||
} | ||
} | ||
var createHmacOutputMethod = function (outputType, is224) { | ||
return function (key, message) { | ||
return new HmacSha256(key, is224, true).update(message)[outputType](); | ||
}; | ||
}; | ||
throw new Error('Native crypto module could not be used to get secure random number.'); | ||
}; | ||
var createHmacMethod = function (is224) { | ||
var method = createHmacOutputMethod('hex', is224); | ||
method.create = function (key) { | ||
return new HmacSha256(key, is224); | ||
}; | ||
method.update = function (key, message) { | ||
return method.create(key).update(message); | ||
}; | ||
for (var i = 0; i < OUTPUT_TYPES.length; ++i) { | ||
var type = OUTPUT_TYPES[i]; | ||
method[type] = createHmacOutputMethod(type, is224); | ||
} | ||
return method; | ||
}; | ||
/* | ||
* Local polyfill of Object.create | ||
function Sha256(is224, sharedMemory) { | ||
if (sharedMemory) { | ||
blocks[0] = blocks[16] = blocks[1] = blocks[2] = blocks[3] = | ||
blocks[4] = blocks[5] = blocks[6] = blocks[7] = | ||
blocks[8] = blocks[9] = blocks[10] = blocks[11] = | ||
blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0; | ||
this.blocks = blocks; | ||
} else { | ||
this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; | ||
} | ||
*/ | ||
var create = Object.create || (function () { | ||
function F() {} | ||
if (is224) { | ||
this.h0 = 0xc1059ed8; | ||
this.h1 = 0x367cd507; | ||
this.h2 = 0x3070dd17; | ||
this.h3 = 0xf70e5939; | ||
this.h4 = 0xffc00b31; | ||
this.h5 = 0x68581511; | ||
this.h6 = 0x64f98fa7; | ||
this.h7 = 0xbefa4fa4; | ||
} else { // 256 | ||
this.h0 = 0x6a09e667; | ||
this.h1 = 0xbb67ae85; | ||
this.h2 = 0x3c6ef372; | ||
this.h3 = 0xa54ff53a; | ||
this.h4 = 0x510e527f; | ||
this.h5 = 0x9b05688c; | ||
this.h6 = 0x1f83d9ab; | ||
this.h7 = 0x5be0cd19; | ||
} | ||
return function (obj) { | ||
var subtype; | ||
this.block = this.start = this.bytes = this.hBytes = 0; | ||
this.finalized = this.hashed = false; | ||
this.first = true; | ||
this.is224 = is224; | ||
} | ||
F.prototype = obj; | ||
Sha256.prototype.update = function (message) { | ||
if (this.finalized) { | ||
return; | ||
} | ||
var notString, type = typeof message; | ||
if (type !== 'string') { | ||
if (type === 'object') { | ||
if (message === null) { | ||
throw new Error(ERROR); | ||
} else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) { | ||
message = new Uint8Array(message); | ||
} else if (!Array.isArray(message)) { | ||
if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) { | ||
throw new Error(ERROR); | ||
} | ||
} | ||
} else { | ||
throw new Error(ERROR); | ||
} | ||
notString = true; | ||
} | ||
var code, index = 0, i, length = message.length, blocks = this.blocks; | ||
while (index < length) { | ||
if (this.hashed) { | ||
this.hashed = false; | ||
blocks[0] = this.block; | ||
this.block = blocks[16] = blocks[1] = blocks[2] = blocks[3] = | ||
blocks[4] = blocks[5] = blocks[6] = blocks[7] = | ||
blocks[8] = blocks[9] = blocks[10] = blocks[11] = | ||
blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0; | ||
} | ||
subtype = new F(); | ||
if (notString) { | ||
for (i = this.start; index < length && i < 64; ++index) { | ||
blocks[i >>> 2] |= message[index] << SHIFT[i++ & 3]; | ||
} | ||
} else { | ||
for (i = this.start; index < length && i < 64; ++index) { | ||
code = message.charCodeAt(index); | ||
if (code < 0x80) { | ||
blocks[i >>> 2] |= code << SHIFT[i++ & 3]; | ||
} else if (code < 0x800) { | ||
blocks[i >>> 2] |= (0xc0 | (code >>> 6)) << SHIFT[i++ & 3]; | ||
blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; | ||
} else if (code < 0xd800 || code >= 0xe000) { | ||
blocks[i >>> 2] |= (0xe0 | (code >>> 12)) << SHIFT[i++ & 3]; | ||
blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3]; | ||
blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; | ||
} else { | ||
code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); | ||
blocks[i >>> 2] |= (0xf0 | (code >>> 18)) << SHIFT[i++ & 3]; | ||
blocks[i >>> 2] |= (0x80 | ((code >>> 12) & 0x3f)) << SHIFT[i++ & 3]; | ||
blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3]; | ||
blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; | ||
} | ||
} | ||
} | ||
F.prototype = null; | ||
this.lastByteIndex = i; | ||
this.bytes += i - this.start; | ||
if (i >= 64) { | ||
this.block = blocks[16]; | ||
this.start = i - 64; | ||
this.hash(); | ||
this.hashed = true; | ||
} else { | ||
this.start = i; | ||
} | ||
} | ||
if (this.bytes > 4294967295) { | ||
this.hBytes += this.bytes / 4294967296 << 0; | ||
this.bytes = this.bytes % 4294967296; | ||
} | ||
return this; | ||
}; | ||
return subtype; | ||
}; | ||
}()); | ||
Sha256.prototype.finalize = function () { | ||
if (this.finalized) { | ||
return; | ||
} | ||
this.finalized = true; | ||
var blocks = this.blocks, i = this.lastByteIndex; | ||
blocks[16] = this.block; | ||
blocks[i >>> 2] |= EXTRA[i & 3]; | ||
this.block = blocks[16]; | ||
if (i >= 56) { | ||
if (!this.hashed) { | ||
this.hash(); | ||
} | ||
blocks[0] = this.block; | ||
blocks[16] = blocks[1] = blocks[2] = blocks[3] = | ||
blocks[4] = blocks[5] = blocks[6] = blocks[7] = | ||
blocks[8] = blocks[9] = blocks[10] = blocks[11] = | ||
blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0; | ||
} | ||
blocks[14] = this.hBytes << 3 | this.bytes >>> 29; | ||
blocks[15] = this.bytes << 3; | ||
this.hash(); | ||
}; | ||
/** | ||
* CryptoJS namespace. | ||
*/ | ||
var C = {}; | ||
Sha256.prototype.hash = function () { | ||
var a = this.h0, b = this.h1, c = this.h2, d = this.h3, e = this.h4, f = this.h5, g = this.h6, | ||
h = this.h7, blocks = this.blocks, j, s0, s1, maj, t1, t2, ch, ab, da, cd, bc; | ||
/** | ||
* Library namespace. | ||
*/ | ||
var C_lib = C.lib = {}; | ||
for (j = 16; j < 64; ++j) { | ||
// rightrotate | ||
t1 = blocks[j - 15]; | ||
s0 = ((t1 >>> 7) | (t1 << 25)) ^ ((t1 >>> 18) | (t1 << 14)) ^ (t1 >>> 3); | ||
t1 = blocks[j - 2]; | ||
s1 = ((t1 >>> 17) | (t1 << 15)) ^ ((t1 >>> 19) | (t1 << 13)) ^ (t1 >>> 10); | ||
blocks[j] = blocks[j - 16] + s0 + blocks[j - 7] + s1 << 0; | ||
} | ||
/** | ||
* Base object for prototypal inheritance. | ||
*/ | ||
var Base = C_lib.Base = (function () { | ||
bc = b & c; | ||
for (j = 0; j < 64; j += 4) { | ||
if (this.first) { | ||
if (this.is224) { | ||
ab = 300032; | ||
t1 = blocks[0] - 1413257819; | ||
h = t1 - 150054599 << 0; | ||
d = t1 + 24177077 << 0; | ||
} else { | ||
ab = 704751109; | ||
t1 = blocks[0] - 210244248; | ||
h = t1 - 1521486534 << 0; | ||
d = t1 + 143694565 << 0; | ||
} | ||
this.first = false; | ||
} else { | ||
s0 = ((a >>> 2) | (a << 30)) ^ ((a >>> 13) | (a << 19)) ^ ((a >>> 22) | (a << 10)); | ||
s1 = ((e >>> 6) | (e << 26)) ^ ((e >>> 11) | (e << 21)) ^ ((e >>> 25) | (e << 7)); | ||
ab = a & b; | ||
maj = ab ^ (a & c) ^ bc; | ||
ch = (e & f) ^ (~e & g); | ||
t1 = h + s1 + ch + K[j] + blocks[j]; | ||
t2 = s0 + maj; | ||
h = d + t1 << 0; | ||
d = t1 + t2 << 0; | ||
} | ||
s0 = ((d >>> 2) | (d << 30)) ^ ((d >>> 13) | (d << 19)) ^ ((d >>> 22) | (d << 10)); | ||
s1 = ((h >>> 6) | (h << 26)) ^ ((h >>> 11) | (h << 21)) ^ ((h >>> 25) | (h << 7)); | ||
da = d & a; | ||
maj = da ^ (d & b) ^ ab; | ||
ch = (h & e) ^ (~h & f); | ||
t1 = g + s1 + ch + K[j + 1] + blocks[j + 1]; | ||
t2 = s0 + maj; | ||
g = c + t1 << 0; | ||
c = t1 + t2 << 0; | ||
s0 = ((c >>> 2) | (c << 30)) ^ ((c >>> 13) | (c << 19)) ^ ((c >>> 22) | (c << 10)); | ||
s1 = ((g >>> 6) | (g << 26)) ^ ((g >>> 11) | (g << 21)) ^ ((g >>> 25) | (g << 7)); | ||
cd = c & d; | ||
maj = cd ^ (c & a) ^ da; | ||
ch = (g & h) ^ (~g & e); | ||
t1 = f + s1 + ch + K[j + 2] + blocks[j + 2]; | ||
t2 = s0 + maj; | ||
f = b + t1 << 0; | ||
b = t1 + t2 << 0; | ||
s0 = ((b >>> 2) | (b << 30)) ^ ((b >>> 13) | (b << 19)) ^ ((b >>> 22) | (b << 10)); | ||
s1 = ((f >>> 6) | (f << 26)) ^ ((f >>> 11) | (f << 21)) ^ ((f >>> 25) | (f << 7)); | ||
bc = b & c; | ||
maj = bc ^ (b & d) ^ cd; | ||
ch = (f & g) ^ (~f & h); | ||
t1 = e + s1 + ch + K[j + 3] + blocks[j + 3]; | ||
t2 = s0 + maj; | ||
e = a + t1 << 0; | ||
a = t1 + t2 << 0; | ||
this.chromeBugWorkAround = true; | ||
} | ||
this.h0 = this.h0 + a << 0; | ||
this.h1 = this.h1 + b << 0; | ||
this.h2 = this.h2 + c << 0; | ||
this.h3 = this.h3 + d << 0; | ||
this.h4 = this.h4 + e << 0; | ||
this.h5 = this.h5 + f << 0; | ||
this.h6 = this.h6 + g << 0; | ||
this.h7 = this.h7 + h << 0; | ||
}; | ||
return { | ||
/** | ||
* Creates a new object that inherits from this object. | ||
* | ||
* @param {Object} overrides Properties to copy into the new object. | ||
* | ||
* @return {Object} The new object. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var MyType = CryptoJS.lib.Base.extend({ | ||
* field: 'value', | ||
* | ||
* method: function () { | ||
* } | ||
* }); | ||
*/ | ||
extend: function (overrides) { | ||
// Spawn | ||
var subtype = create(this); | ||
Sha256.prototype.hex = function () { | ||
this.finalize(); | ||
// Augment | ||
if (overrides) { | ||
subtype.mixIn(overrides); | ||
} | ||
var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4, h5 = this.h5, | ||
h6 = this.h6, h7 = this.h7; | ||
// Create default initializer | ||
if (!subtype.hasOwnProperty('init') || this.init === subtype.init) { | ||
subtype.init = function () { | ||
subtype.$super.init.apply(this, arguments); | ||
}; | ||
} | ||
var hex = HEX_CHARS[(h0 >>> 28) & 0x0F] + HEX_CHARS[(h0 >>> 24) & 0x0F] + | ||
HEX_CHARS[(h0 >>> 20) & 0x0F] + HEX_CHARS[(h0 >>> 16) & 0x0F] + | ||
HEX_CHARS[(h0 >>> 12) & 0x0F] + HEX_CHARS[(h0 >>> 8) & 0x0F] + | ||
HEX_CHARS[(h0 >>> 4) & 0x0F] + HEX_CHARS[h0 & 0x0F] + | ||
HEX_CHARS[(h1 >>> 28) & 0x0F] + HEX_CHARS[(h1 >>> 24) & 0x0F] + | ||
HEX_CHARS[(h1 >>> 20) & 0x0F] + HEX_CHARS[(h1 >>> 16) & 0x0F] + | ||
HEX_CHARS[(h1 >>> 12) & 0x0F] + HEX_CHARS[(h1 >>> 8) & 0x0F] + | ||
HEX_CHARS[(h1 >>> 4) & 0x0F] + HEX_CHARS[h1 & 0x0F] + | ||
HEX_CHARS[(h2 >>> 28) & 0x0F] + HEX_CHARS[(h2 >>> 24) & 0x0F] + | ||
HEX_CHARS[(h2 >>> 20) & 0x0F] + HEX_CHARS[(h2 >>> 16) & 0x0F] + | ||
HEX_CHARS[(h2 >>> 12) & 0x0F] + HEX_CHARS[(h2 >>> 8) & 0x0F] + | ||
HEX_CHARS[(h2 >>> 4) & 0x0F] + HEX_CHARS[h2 & 0x0F] + | ||
HEX_CHARS[(h3 >>> 28) & 0x0F] + HEX_CHARS[(h3 >>> 24) & 0x0F] + | ||
HEX_CHARS[(h3 >>> 20) & 0x0F] + HEX_CHARS[(h3 >>> 16) & 0x0F] + | ||
HEX_CHARS[(h3 >>> 12) & 0x0F] + HEX_CHARS[(h3 >>> 8) & 0x0F] + | ||
HEX_CHARS[(h3 >>> 4) & 0x0F] + HEX_CHARS[h3 & 0x0F] + | ||
HEX_CHARS[(h4 >>> 28) & 0x0F] + HEX_CHARS[(h4 >>> 24) & 0x0F] + | ||
HEX_CHARS[(h4 >>> 20) & 0x0F] + HEX_CHARS[(h4 >>> 16) & 0x0F] + | ||
HEX_CHARS[(h4 >>> 12) & 0x0F] + HEX_CHARS[(h4 >>> 8) & 0x0F] + | ||
HEX_CHARS[(h4 >>> 4) & 0x0F] + HEX_CHARS[h4 & 0x0F] + | ||
HEX_CHARS[(h5 >>> 28) & 0x0F] + HEX_CHARS[(h5 >>> 24) & 0x0F] + | ||
HEX_CHARS[(h5 >>> 20) & 0x0F] + HEX_CHARS[(h5 >>> 16) & 0x0F] + | ||
HEX_CHARS[(h5 >>> 12) & 0x0F] + HEX_CHARS[(h5 >>> 8) & 0x0F] + | ||
HEX_CHARS[(h5 >>> 4) & 0x0F] + HEX_CHARS[h5 & 0x0F] + | ||
HEX_CHARS[(h6 >>> 28) & 0x0F] + HEX_CHARS[(h6 >>> 24) & 0x0F] + | ||
HEX_CHARS[(h6 >>> 20) & 0x0F] + HEX_CHARS[(h6 >>> 16) & 0x0F] + | ||
HEX_CHARS[(h6 >>> 12) & 0x0F] + HEX_CHARS[(h6 >>> 8) & 0x0F] + | ||
HEX_CHARS[(h6 >>> 4) & 0x0F] + HEX_CHARS[h6 & 0x0F]; | ||
if (!this.is224) { | ||
hex += HEX_CHARS[(h7 >>> 28) & 0x0F] + HEX_CHARS[(h7 >>> 24) & 0x0F] + | ||
HEX_CHARS[(h7 >>> 20) & 0x0F] + HEX_CHARS[(h7 >>> 16) & 0x0F] + | ||
HEX_CHARS[(h7 >>> 12) & 0x0F] + HEX_CHARS[(h7 >>> 8) & 0x0F] + | ||
HEX_CHARS[(h7 >>> 4) & 0x0F] + HEX_CHARS[h7 & 0x0F]; | ||
} | ||
return hex; | ||
}; | ||
// Initializer's prototype is the subtype object | ||
subtype.init.prototype = subtype; | ||
Sha256.prototype.toString = Sha256.prototype.hex; | ||
// Reference supertype | ||
subtype.$super = this; | ||
Sha256.prototype.digest = function () { | ||
this.finalize(); | ||
return subtype; | ||
}, | ||
var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4, h5 = this.h5, | ||
h6 = this.h6, h7 = this.h7; | ||
/** | ||
* Extends this object and runs the init method. | ||
* Arguments to create() will be passed to init(). | ||
* | ||
* @return {Object} The new object. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var instance = MyType.create(); | ||
*/ | ||
create: function () { | ||
var instance = this.extend(); | ||
instance.init.apply(instance, arguments); | ||
var arr = [ | ||
(h0 >>> 24) & 0xFF, (h0 >>> 16) & 0xFF, (h0 >>> 8) & 0xFF, h0 & 0xFF, | ||
(h1 >>> 24) & 0xFF, (h1 >>> 16) & 0xFF, (h1 >>> 8) & 0xFF, h1 & 0xFF, | ||
(h2 >>> 24) & 0xFF, (h2 >>> 16) & 0xFF, (h2 >>> 8) & 0xFF, h2 & 0xFF, | ||
(h3 >>> 24) & 0xFF, (h3 >>> 16) & 0xFF, (h3 >>> 8) & 0xFF, h3 & 0xFF, | ||
(h4 >>> 24) & 0xFF, (h4 >>> 16) & 0xFF, (h4 >>> 8) & 0xFF, h4 & 0xFF, | ||
(h5 >>> 24) & 0xFF, (h5 >>> 16) & 0xFF, (h5 >>> 8) & 0xFF, h5 & 0xFF, | ||
(h6 >>> 24) & 0xFF, (h6 >>> 16) & 0xFF, (h6 >>> 8) & 0xFF, h6 & 0xFF | ||
]; | ||
if (!this.is224) { | ||
arr.push((h7 >>> 24) & 0xFF, (h7 >>> 16) & 0xFF, (h7 >>> 8) & 0xFF, h7 & 0xFF); | ||
} | ||
return arr; | ||
}; | ||
return instance; | ||
}, | ||
Sha256.prototype.array = Sha256.prototype.digest; | ||
/** | ||
* Initializes a newly created object. | ||
* Override this method to add some logic when your objects are created. | ||
* | ||
* @example | ||
* | ||
* var MyType = CryptoJS.lib.Base.extend({ | ||
* init: function () { | ||
* // ... | ||
* } | ||
* }); | ||
*/ | ||
init: function () { | ||
}, | ||
Sha256.prototype.arrayBuffer = function () { | ||
this.finalize(); | ||
/** | ||
* Copies properties into this object. | ||
* | ||
* @param {Object} properties The properties to mix in. | ||
* | ||
* @example | ||
* | ||
* MyType.mixIn({ | ||
* field: 'value' | ||
* }); | ||
*/ | ||
mixIn: function (properties) { | ||
for (var propertyName in properties) { | ||
if (properties.hasOwnProperty(propertyName)) { | ||
this[propertyName] = properties[propertyName]; | ||
} | ||
} | ||
var buffer = new ArrayBuffer(this.is224 ? 28 : 32); | ||
var dataView = new DataView(buffer); | ||
dataView.setUint32(0, this.h0); | ||
dataView.setUint32(4, this.h1); | ||
dataView.setUint32(8, this.h2); | ||
dataView.setUint32(12, this.h3); | ||
dataView.setUint32(16, this.h4); | ||
dataView.setUint32(20, this.h5); | ||
dataView.setUint32(24, this.h6); | ||
if (!this.is224) { | ||
dataView.setUint32(28, this.h7); | ||
} | ||
return buffer; | ||
}; | ||
// IE won't copy toString using the loop above | ||
if (properties.hasOwnProperty('toString')) { | ||
this.toString = properties.toString; | ||
} | ||
}, | ||
function HmacSha256(key, is224, sharedMemory) { | ||
var i, type = typeof key; | ||
if (type === 'string') { | ||
var bytes = [], length = key.length, index = 0, code; | ||
for (i = 0; i < length; ++i) { | ||
code = key.charCodeAt(i); | ||
if (code < 0x80) { | ||
bytes[index++] = code; | ||
} else if (code < 0x800) { | ||
bytes[index++] = (0xc0 | (code >>> 6)); | ||
bytes[index++] = (0x80 | (code & 0x3f)); | ||
} else if (code < 0xd800 || code >= 0xe000) { | ||
bytes[index++] = (0xe0 | (code >>> 12)); | ||
bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); | ||
bytes[index++] = (0x80 | (code & 0x3f)); | ||
} else { | ||
code = 0x10000 + (((code & 0x3ff) << 10) | (key.charCodeAt(++i) & 0x3ff)); | ||
bytes[index++] = (0xf0 | (code >>> 18)); | ||
bytes[index++] = (0x80 | ((code >>> 12) & 0x3f)); | ||
bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); | ||
bytes[index++] = (0x80 | (code & 0x3f)); | ||
} | ||
} | ||
key = bytes; | ||
} else { | ||
if (type === 'object') { | ||
if (key === null) { | ||
throw new Error(ERROR); | ||
} else if (ARRAY_BUFFER && key.constructor === ArrayBuffer) { | ||
key = new Uint8Array(key); | ||
} else if (!Array.isArray(key)) { | ||
if (!ARRAY_BUFFER || !ArrayBuffer.isView(key)) { | ||
throw new Error(ERROR); | ||
} | ||
} | ||
} else { | ||
throw new Error(ERROR); | ||
} | ||
} | ||
/** | ||
* Creates a copy of this object. | ||
* | ||
* @return {Object} The clone. | ||
* | ||
* @example | ||
* | ||
* var clone = instance.clone(); | ||
*/ | ||
clone: function () { | ||
return this.init.prototype.extend(this); | ||
} | ||
}; | ||
}()); | ||
if (key.length > 64) { | ||
key = (new Sha256(is224, true)).update(key).array(); | ||
} | ||
/** | ||
* An array of 32-bit words. | ||
* | ||
* @property {Array} words The array of 32-bit words. | ||
* @property {number} sigBytes The number of significant bytes in this word array. | ||
*/ | ||
var WordArray = C_lib.WordArray = Base.extend({ | ||
/** | ||
* Initializes a newly created word array. | ||
* | ||
* @param {Array} words (Optional) An array of 32-bit words. | ||
* @param {number} sigBytes (Optional) The number of significant bytes in the words. | ||
* | ||
* @example | ||
* | ||
* var wordArray = CryptoJS.lib.WordArray.create(); | ||
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]); | ||
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6); | ||
*/ | ||
init: function (words, sigBytes) { | ||
words = this.words = words || []; | ||
var oKeyPad = [], iKeyPad = []; | ||
for (i = 0; i < 64; ++i) { | ||
var b = key[i] || 0; | ||
oKeyPad[i] = 0x5c ^ b; | ||
iKeyPad[i] = 0x36 ^ b; | ||
} | ||
if (sigBytes != undefined$1) { | ||
this.sigBytes = sigBytes; | ||
} else { | ||
this.sigBytes = words.length * 4; | ||
} | ||
}, | ||
Sha256.call(this, is224, sharedMemory); | ||
/** | ||
* Converts this word array to a string. | ||
* | ||
* @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex | ||
* | ||
* @return {string} The stringified word array. | ||
* | ||
* @example | ||
* | ||
* var string = wordArray + ''; | ||
* var string = wordArray.toString(); | ||
* var string = wordArray.toString(CryptoJS.enc.Utf8); | ||
*/ | ||
toString: function (encoder) { | ||
return (encoder || Hex).stringify(this); | ||
}, | ||
this.update(iKeyPad); | ||
this.oKeyPad = oKeyPad; | ||
this.inner = true; | ||
this.sharedMemory = sharedMemory; | ||
} | ||
HmacSha256.prototype = new Sha256(); | ||
/** | ||
* Concatenates a word array to this word array. | ||
* | ||
* @param {WordArray} wordArray The word array to append. | ||
* | ||
* @return {WordArray} This word array. | ||
* | ||
* @example | ||
* | ||
* wordArray1.concat(wordArray2); | ||
*/ | ||
concat: function (wordArray) { | ||
// Shortcuts | ||
var thisWords = this.words; | ||
var thatWords = wordArray.words; | ||
var thisSigBytes = this.sigBytes; | ||
var thatSigBytes = wordArray.sigBytes; | ||
HmacSha256.prototype.finalize = function () { | ||
Sha256.prototype.finalize.call(this); | ||
if (this.inner) { | ||
this.inner = false; | ||
var innerHash = this.array(); | ||
Sha256.call(this, this.is224, this.sharedMemory); | ||
this.update(this.oKeyPad); | ||
this.update(innerHash); | ||
Sha256.prototype.finalize.call(this); | ||
} | ||
}; | ||
// Clamp excess bits | ||
this.clamp(); | ||
var exports = createMethod(); | ||
exports.sha256 = exports; | ||
exports.sha224 = createMethod(true); | ||
exports.sha256.hmac = createHmacMethod(); | ||
exports.sha224.hmac = createHmacMethod(true); | ||
// Concat | ||
if (thisSigBytes % 4) { | ||
// Copy one byte at a time | ||
for (var i = 0; i < thatSigBytes; i++) { | ||
var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; | ||
thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8); | ||
} | ||
} else { | ||
// Copy one word at a time | ||
for (var j = 0; j < thatSigBytes; j += 4) { | ||
thisWords[(thisSigBytes + j) >>> 2] = thatWords[j >>> 2]; | ||
} | ||
} | ||
this.sigBytes += thatSigBytes; | ||
// Chainable | ||
return this; | ||
}, | ||
/** | ||
* Removes insignificant bits. | ||
* | ||
* @example | ||
* | ||
* wordArray.clamp(); | ||
*/ | ||
clamp: function () { | ||
// Shortcuts | ||
var words = this.words; | ||
var sigBytes = this.sigBytes; | ||
// Clamp | ||
words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8); | ||
words.length = Math.ceil(sigBytes / 4); | ||
}, | ||
/** | ||
* Creates a copy of this word array. | ||
* | ||
* @return {WordArray} The clone. | ||
* | ||
* @example | ||
* | ||
* var clone = wordArray.clone(); | ||
*/ | ||
clone: function () { | ||
var clone = Base.clone.call(this); | ||
clone.words = this.words.slice(0); | ||
return clone; | ||
}, | ||
/** | ||
* Creates a word array filled with random bytes. | ||
* | ||
* @param {number} nBytes The number of random bytes to generate. | ||
* | ||
* @return {WordArray} The random word array. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var wordArray = CryptoJS.lib.WordArray.random(16); | ||
*/ | ||
random: function (nBytes) { | ||
var words = []; | ||
for (var i = 0; i < nBytes; i += 4) { | ||
words.push(cryptoSecureRandomInt()); | ||
} | ||
return new WordArray.init(words, nBytes); | ||
} | ||
}); | ||
/** | ||
* Encoder namespace. | ||
*/ | ||
var C_enc = C.enc = {}; | ||
/** | ||
* Hex encoding strategy. | ||
*/ | ||
var Hex = C_enc.Hex = { | ||
/** | ||
* Converts a word array to a hex string. | ||
* | ||
* @param {WordArray} wordArray The word array. | ||
* | ||
* @return {string} The hex string. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var hexString = CryptoJS.enc.Hex.stringify(wordArray); | ||
*/ | ||
stringify: function (wordArray) { | ||
// Shortcuts | ||
var words = wordArray.words; | ||
var sigBytes = wordArray.sigBytes; | ||
// Convert | ||
var hexChars = []; | ||
for (var i = 0; i < sigBytes; i++) { | ||
var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; | ||
hexChars.push((bite >>> 4).toString(16)); | ||
hexChars.push((bite & 0x0f).toString(16)); | ||
} | ||
return hexChars.join(''); | ||
}, | ||
/** | ||
* Converts a hex string to a word array. | ||
* | ||
* @param {string} hexStr The hex string. | ||
* | ||
* @return {WordArray} The word array. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var wordArray = CryptoJS.enc.Hex.parse(hexString); | ||
*/ | ||
parse: function (hexStr) { | ||
// Shortcut | ||
var hexStrLength = hexStr.length; | ||
// Convert | ||
var words = []; | ||
for (var i = 0; i < hexStrLength; i += 2) { | ||
words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4); | ||
} | ||
return new WordArray.init(words, hexStrLength / 2); | ||
} | ||
}; | ||
/** | ||
* Latin1 encoding strategy. | ||
*/ | ||
var Latin1 = C_enc.Latin1 = { | ||
/** | ||
* Converts a word array to a Latin1 string. | ||
* | ||
* @param {WordArray} wordArray The word array. | ||
* | ||
* @return {string} The Latin1 string. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var latin1String = CryptoJS.enc.Latin1.stringify(wordArray); | ||
*/ | ||
stringify: function (wordArray) { | ||
// Shortcuts | ||
var words = wordArray.words; | ||
var sigBytes = wordArray.sigBytes; | ||
// Convert | ||
var latin1Chars = []; | ||
for (var i = 0; i < sigBytes; i++) { | ||
var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; | ||
latin1Chars.push(String.fromCharCode(bite)); | ||
} | ||
return latin1Chars.join(''); | ||
}, | ||
/** | ||
* Converts a Latin1 string to a word array. | ||
* | ||
* @param {string} latin1Str The Latin1 string. | ||
* | ||
* @return {WordArray} The word array. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var wordArray = CryptoJS.enc.Latin1.parse(latin1String); | ||
*/ | ||
parse: function (latin1Str) { | ||
// Shortcut | ||
var latin1StrLength = latin1Str.length; | ||
// Convert | ||
var words = []; | ||
for (var i = 0; i < latin1StrLength; i++) { | ||
words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8); | ||
} | ||
return new WordArray.init(words, latin1StrLength); | ||
} | ||
}; | ||
/** | ||
* UTF-8 encoding strategy. | ||
*/ | ||
var Utf8 = C_enc.Utf8 = { | ||
/** | ||
* Converts a word array to a UTF-8 string. | ||
* | ||
* @param {WordArray} wordArray The word array. | ||
* | ||
* @return {string} The UTF-8 string. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var utf8String = CryptoJS.enc.Utf8.stringify(wordArray); | ||
*/ | ||
stringify: function (wordArray) { | ||
try { | ||
return decodeURIComponent(escape(Latin1.stringify(wordArray))); | ||
} catch (e) { | ||
throw new Error('Malformed UTF-8 data'); | ||
} | ||
}, | ||
/** | ||
* Converts a UTF-8 string to a word array. | ||
* | ||
* @param {string} utf8Str The UTF-8 string. | ||
* | ||
* @return {WordArray} The word array. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var wordArray = CryptoJS.enc.Utf8.parse(utf8String); | ||
*/ | ||
parse: function (utf8Str) { | ||
return Latin1.parse(unescape(encodeURIComponent(utf8Str))); | ||
} | ||
}; | ||
/** | ||
* Abstract buffered block algorithm template. | ||
* | ||
* The property blockSize must be implemented in a concrete subtype. | ||
* | ||
* @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0 | ||
*/ | ||
var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({ | ||
/** | ||
* Resets this block algorithm's data buffer to its initial state. | ||
* | ||
* @example | ||
* | ||
* bufferedBlockAlgorithm.reset(); | ||
*/ | ||
reset: function () { | ||
// Initial values | ||
this._data = new WordArray.init(); | ||
this._nDataBytes = 0; | ||
}, | ||
/** | ||
* Adds new data to this block algorithm's buffer. | ||
* | ||
* @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8. | ||
* | ||
* @example | ||
* | ||
* bufferedBlockAlgorithm._append('data'); | ||
* bufferedBlockAlgorithm._append(wordArray); | ||
*/ | ||
_append: function (data) { | ||
// Convert string to WordArray, else assume WordArray already | ||
if (typeof data == 'string') { | ||
data = Utf8.parse(data); | ||
} | ||
// Append | ||
this._data.concat(data); | ||
this._nDataBytes += data.sigBytes; | ||
}, | ||
/** | ||
* Processes available data blocks. | ||
* | ||
* This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype. | ||
* | ||
* @param {boolean} doFlush Whether all blocks and partial blocks should be processed. | ||
* | ||
* @return {WordArray} The processed data. | ||
* | ||
* @example | ||
* | ||
* var processedData = bufferedBlockAlgorithm._process(); | ||
* var processedData = bufferedBlockAlgorithm._process(!!'flush'); | ||
*/ | ||
_process: function (doFlush) { | ||
var processedWords; | ||
// Shortcuts | ||
var data = this._data; | ||
var dataWords = data.words; | ||
var dataSigBytes = data.sigBytes; | ||
var blockSize = this.blockSize; | ||
var blockSizeBytes = blockSize * 4; | ||
// Count blocks ready | ||
var nBlocksReady = dataSigBytes / blockSizeBytes; | ||
if (doFlush) { | ||
// Round up to include partial blocks | ||
nBlocksReady = Math.ceil(nBlocksReady); | ||
} else { | ||
// Round down to include only full blocks, | ||
// less the number of blocks that must remain in the buffer | ||
nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0); | ||
} | ||
// Count words ready | ||
var nWordsReady = nBlocksReady * blockSize; | ||
// Count bytes ready | ||
var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes); | ||
// Process blocks | ||
if (nWordsReady) { | ||
for (var offset = 0; offset < nWordsReady; offset += blockSize) { | ||
// Perform concrete-algorithm logic | ||
this._doProcessBlock(dataWords, offset); | ||
} | ||
// Remove processed words | ||
processedWords = dataWords.splice(0, nWordsReady); | ||
data.sigBytes -= nBytesReady; | ||
} | ||
// Return processed words | ||
return new WordArray.init(processedWords, nBytesReady); | ||
}, | ||
/** | ||
* Creates a copy of this object. | ||
* | ||
* @return {Object} The clone. | ||
* | ||
* @example | ||
* | ||
* var clone = bufferedBlockAlgorithm.clone(); | ||
*/ | ||
clone: function () { | ||
var clone = Base.clone.call(this); | ||
clone._data = this._data.clone(); | ||
return clone; | ||
}, | ||
_minBufferSize: 0 | ||
}); | ||
/** | ||
* Abstract hasher template. | ||
* | ||
* @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits) | ||
*/ | ||
C_lib.Hasher = BufferedBlockAlgorithm.extend({ | ||
/** | ||
* Configuration options. | ||
*/ | ||
cfg: Base.extend(), | ||
/** | ||
* Initializes a newly created hasher. | ||
* | ||
* @param {Object} cfg (Optional) The configuration options to use for this hash computation. | ||
* | ||
* @example | ||
* | ||
* var hasher = CryptoJS.algo.SHA256.create(); | ||
*/ | ||
init: function (cfg) { | ||
// Apply config defaults | ||
this.cfg = this.cfg.extend(cfg); | ||
// Set initial values | ||
this.reset(); | ||
}, | ||
/** | ||
* Resets this hasher to its initial state. | ||
* | ||
* @example | ||
* | ||
* hasher.reset(); | ||
*/ | ||
reset: function () { | ||
// Reset data buffer | ||
BufferedBlockAlgorithm.reset.call(this); | ||
// Perform concrete-hasher logic | ||
this._doReset(); | ||
}, | ||
/** | ||
* Updates this hasher with a message. | ||
* | ||
* @param {WordArray|string} messageUpdate The message to append. | ||
* | ||
* @return {Hasher} This hasher. | ||
* | ||
* @example | ||
* | ||
* hasher.update('message'); | ||
* hasher.update(wordArray); | ||
*/ | ||
update: function (messageUpdate) { | ||
// Append | ||
this._append(messageUpdate); | ||
// Update the hash | ||
this._process(); | ||
// Chainable | ||
return this; | ||
}, | ||
/** | ||
* Finalizes the hash computation. | ||
* Note that the finalize operation is effectively a destructive, read-once operation. | ||
* | ||
* @param {WordArray|string} messageUpdate (Optional) A final message update. | ||
* | ||
* @return {WordArray} The hash. | ||
* | ||
* @example | ||
* | ||
* var hash = hasher.finalize(); | ||
* var hash = hasher.finalize('message'); | ||
* var hash = hasher.finalize(wordArray); | ||
*/ | ||
finalize: function (messageUpdate) { | ||
// Final message update | ||
if (messageUpdate) { | ||
this._append(messageUpdate); | ||
} | ||
// Perform concrete-hasher logic | ||
var hash = this._doFinalize(); | ||
return hash; | ||
}, | ||
blockSize: 512/32, | ||
/** | ||
* Creates a shortcut function to a hasher's object interface. | ||
* | ||
* @param {Hasher} hasher The hasher to create a helper for. | ||
* | ||
* @return {Function} The shortcut function. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256); | ||
*/ | ||
_createHelper: function (hasher) { | ||
return function (message, cfg) { | ||
return new hasher.init(cfg).finalize(message); | ||
}; | ||
}, | ||
/** | ||
* Creates a shortcut function to the HMAC's object interface. | ||
* | ||
* @param {Hasher} hasher The hasher to use in this HMAC helper. | ||
* | ||
* @return {Function} The shortcut function. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256); | ||
*/ | ||
_createHmacHelper: function (hasher) { | ||
return function (message, key) { | ||
return new C_algo.HMAC.init(hasher, key).finalize(message); | ||
}; | ||
} | ||
}); | ||
/** | ||
* Algorithm namespace. | ||
*/ | ||
var C_algo = C.algo = {}; | ||
return C; | ||
}(Math)); | ||
return CryptoJS; | ||
})); | ||
}(core)); | ||
(function (module, exports) { | ||
(function (root, factory) { | ||
{ | ||
// CommonJS | ||
module.exports = factory(core.exports); | ||
} | ||
}(commonjsGlobal, function (CryptoJS) { | ||
(function (Math) { | ||
// Shortcuts | ||
var C = CryptoJS; | ||
var C_lib = C.lib; | ||
var WordArray = C_lib.WordArray; | ||
var Hasher = C_lib.Hasher; | ||
var C_algo = C.algo; | ||
// Initialization and round constants tables | ||
var H = []; | ||
var K = []; | ||
// Compute constants | ||
(function () { | ||
function isPrime(n) { | ||
var sqrtN = Math.sqrt(n); | ||
for (var factor = 2; factor <= sqrtN; factor++) { | ||
if (!(n % factor)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
function getFractionalBits(n) { | ||
return ((n - (n | 0)) * 0x100000000) | 0; | ||
} | ||
var n = 2; | ||
var nPrime = 0; | ||
while (nPrime < 64) { | ||
if (isPrime(n)) { | ||
if (nPrime < 8) { | ||
H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2)); | ||
} | ||
K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3)); | ||
nPrime++; | ||
} | ||
n++; | ||
} | ||
}()); | ||
// Reusable object | ||
var W = []; | ||
/** | ||
* SHA-256 hash algorithm. | ||
*/ | ||
var SHA256 = C_algo.SHA256 = Hasher.extend({ | ||
_doReset: function () { | ||
this._hash = new WordArray.init(H.slice(0)); | ||
}, | ||
_doProcessBlock: function (M, offset) { | ||
// Shortcut | ||
var H = this._hash.words; | ||
// Working variables | ||
var a = H[0]; | ||
var b = H[1]; | ||
var c = H[2]; | ||
var d = H[3]; | ||
var e = H[4]; | ||
var f = H[5]; | ||
var g = H[6]; | ||
var h = H[7]; | ||
// Computation | ||
for (var i = 0; i < 64; i++) { | ||
if (i < 16) { | ||
W[i] = M[offset + i] | 0; | ||
} else { | ||
var gamma0x = W[i - 15]; | ||
var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^ | ||
((gamma0x << 14) | (gamma0x >>> 18)) ^ | ||
(gamma0x >>> 3); | ||
var gamma1x = W[i - 2]; | ||
var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^ | ||
((gamma1x << 13) | (gamma1x >>> 19)) ^ | ||
(gamma1x >>> 10); | ||
W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]; | ||
} | ||
var ch = (e & f) ^ (~e & g); | ||
var maj = (a & b) ^ (a & c) ^ (b & c); | ||
var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22)); | ||
var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25)); | ||
var t1 = h + sigma1 + ch + K[i] + W[i]; | ||
var t2 = sigma0 + maj; | ||
h = g; | ||
g = f; | ||
f = e; | ||
e = (d + t1) | 0; | ||
d = c; | ||
c = b; | ||
b = a; | ||
a = (t1 + t2) | 0; | ||
} | ||
// Intermediate hash value | ||
H[0] = (H[0] + a) | 0; | ||
H[1] = (H[1] + b) | 0; | ||
H[2] = (H[2] + c) | 0; | ||
H[3] = (H[3] + d) | 0; | ||
H[4] = (H[4] + e) | 0; | ||
H[5] = (H[5] + f) | 0; | ||
H[6] = (H[6] + g) | 0; | ||
H[7] = (H[7] + h) | 0; | ||
}, | ||
_doFinalize: function () { | ||
// Shortcuts | ||
var data = this._data; | ||
var dataWords = data.words; | ||
var nBitsTotal = this._nDataBytes * 8; | ||
var nBitsLeft = data.sigBytes * 8; | ||
// Add padding | ||
dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); | ||
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000); | ||
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal; | ||
data.sigBytes = dataWords.length * 4; | ||
// Hash final blocks | ||
this._process(); | ||
// Return final computed hash | ||
return this._hash; | ||
}, | ||
clone: function () { | ||
var clone = Hasher.clone.call(this); | ||
clone._hash = this._hash.clone(); | ||
return clone; | ||
} | ||
}); | ||
/** | ||
* Shortcut function to the hasher's object interface. | ||
* | ||
* @param {WordArray|string} message The message to hash. | ||
* | ||
* @return {WordArray} The hash. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var hash = CryptoJS.SHA256('message'); | ||
* var hash = CryptoJS.SHA256(wordArray); | ||
*/ | ||
C.SHA256 = Hasher._createHelper(SHA256); | ||
/** | ||
* Shortcut function to the HMAC's object interface. | ||
* | ||
* @param {WordArray|string} message The message to hash. | ||
* @param {WordArray|string} key The secret key. | ||
* | ||
* @return {WordArray} The HMAC. | ||
* | ||
* @static | ||
* | ||
* @example | ||
* | ||
* var hmac = CryptoJS.HmacSHA256(message, key); | ||
*/ | ||
C.HmacSHA256 = Hasher._createHmacHelper(SHA256); | ||
}(Math)); | ||
return CryptoJS.SHA256; | ||
})); | ||
if (COMMON_JS) { | ||
module.exports = exports; | ||
} else { | ||
root.sha256 = exports.sha256; | ||
root.sha224 = exports.sha224; | ||
} | ||
})(); | ||
}(sha256)); | ||
var encHex = {exports: {}}; | ||
(function (module, exports) { | ||
(function (root, factory) { | ||
{ | ||
// CommonJS | ||
module.exports = factory(core.exports); | ||
} | ||
}(commonjsGlobal, function (CryptoJS) { | ||
return CryptoJS.enc.Hex; | ||
})); | ||
}(encHex)); | ||
const ESRI_TELEMETRY_DATA_ATTRIBUTE = 'esri-telemetry'; | ||
@@ -1058,0 +588,0 @@ function injectScriptElementAsync(attributes) { |
{ | ||
"name": "@esri/telemetry-google-analytics", | ||
"version": "0.4.3", | ||
"version": "0.4.4", | ||
"description": "Google Analytics plugin for 'Telemetry.js' library", | ||
@@ -40,3 +40,3 @@ "license": "Apache-2.0", | ||
"devDependencies": { | ||
"@esri/telemetry": "^6.1.3" | ||
"@esri/telemetry": "^6.1.4" | ||
}, | ||
@@ -49,3 +49,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "c3db5ed0a550a08818ca96cdb6bf8ae508325937" | ||
"gitHead": "78bda95fdceb434a7703a3370592193af756f6cf" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
327520
2550