larvitar 2.0.2 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/imaging/MetaDataReadable.d.ts +1 -0
- package/dist/imaging/imageAnonymization.d.ts +3 -4
- package/dist/larvitar.js +106 -1192
- package/dist/larvitar.js.map +1 -1
- package/imaging/MetaDataReadable.ts +1 -0
- package/imaging/imageAnonymization.ts +114 -165
- package/imaging/imageParsing.ts +1 -0
- package/imaging/imageTags.ts +2 -2
- package/imaging/tools/main.ts +1 -1
- package/imaging/tools/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/larvitar.js
CHANGED
|
@@ -52026,1027 +52026,6 @@ __nested_webpack_require_1640476__.r(__nested_webpack_exports__);
|
|
|
52026
52026
|
|
|
52027
52027
|
/***/ }),
|
|
52028
52028
|
|
|
52029
|
-
/***/ 8249:
|
|
52030
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
52031
|
-
|
|
52032
|
-
;(function (root, factory) {
|
|
52033
|
-
if (true) {
|
|
52034
|
-
// CommonJS
|
|
52035
|
-
module.exports = exports = factory();
|
|
52036
|
-
}
|
|
52037
|
-
else {}
|
|
52038
|
-
}(this, function () {
|
|
52039
|
-
|
|
52040
|
-
/*globals window, global, require*/
|
|
52041
|
-
|
|
52042
|
-
/**
|
|
52043
|
-
* CryptoJS core components.
|
|
52044
|
-
*/
|
|
52045
|
-
var CryptoJS = CryptoJS || (function (Math, undefined) {
|
|
52046
|
-
|
|
52047
|
-
var crypto;
|
|
52048
|
-
|
|
52049
|
-
// Native crypto from window (Browser)
|
|
52050
|
-
if (typeof window !== 'undefined' && window.crypto) {
|
|
52051
|
-
crypto = window.crypto;
|
|
52052
|
-
}
|
|
52053
|
-
|
|
52054
|
-
// Native crypto in web worker (Browser)
|
|
52055
|
-
if (typeof self !== 'undefined' && self.crypto) {
|
|
52056
|
-
crypto = self.crypto;
|
|
52057
|
-
}
|
|
52058
|
-
|
|
52059
|
-
// Native crypto from worker
|
|
52060
|
-
if (typeof globalThis !== 'undefined' && globalThis.crypto) {
|
|
52061
|
-
crypto = globalThis.crypto;
|
|
52062
|
-
}
|
|
52063
|
-
|
|
52064
|
-
// Native (experimental IE 11) crypto from window (Browser)
|
|
52065
|
-
if (!crypto && typeof window !== 'undefined' && window.msCrypto) {
|
|
52066
|
-
crypto = window.msCrypto;
|
|
52067
|
-
}
|
|
52068
|
-
|
|
52069
|
-
// Native crypto from global (NodeJS)
|
|
52070
|
-
if (!crypto && typeof __webpack_require__.g !== 'undefined' && __webpack_require__.g.crypto) {
|
|
52071
|
-
crypto = __webpack_require__.g.crypto;
|
|
52072
|
-
}
|
|
52073
|
-
|
|
52074
|
-
// Native crypto import via require (NodeJS)
|
|
52075
|
-
if (!crypto && "function" === 'function') {
|
|
52076
|
-
try {
|
|
52077
|
-
crypto = __webpack_require__(2480);
|
|
52078
|
-
} catch (err) {}
|
|
52079
|
-
}
|
|
52080
|
-
|
|
52081
|
-
/*
|
|
52082
|
-
* Cryptographically secure pseudorandom number generator
|
|
52083
|
-
*
|
|
52084
|
-
* As Math.random() is cryptographically not safe to use
|
|
52085
|
-
*/
|
|
52086
|
-
var cryptoSecureRandomInt = function () {
|
|
52087
|
-
if (crypto) {
|
|
52088
|
-
// Use getRandomValues method (Browser)
|
|
52089
|
-
if (typeof crypto.getRandomValues === 'function') {
|
|
52090
|
-
try {
|
|
52091
|
-
return crypto.getRandomValues(new Uint32Array(1))[0];
|
|
52092
|
-
} catch (err) {}
|
|
52093
|
-
}
|
|
52094
|
-
|
|
52095
|
-
// Use randomBytes method (NodeJS)
|
|
52096
|
-
if (typeof crypto.randomBytes === 'function') {
|
|
52097
|
-
try {
|
|
52098
|
-
return crypto.randomBytes(4).readInt32LE();
|
|
52099
|
-
} catch (err) {}
|
|
52100
|
-
}
|
|
52101
|
-
}
|
|
52102
|
-
|
|
52103
|
-
throw new Error('Native crypto module could not be used to get secure random number.');
|
|
52104
|
-
};
|
|
52105
|
-
|
|
52106
|
-
/*
|
|
52107
|
-
* Local polyfill of Object.create
|
|
52108
|
-
|
|
52109
|
-
*/
|
|
52110
|
-
var create = Object.create || (function () {
|
|
52111
|
-
function F() {}
|
|
52112
|
-
|
|
52113
|
-
return function (obj) {
|
|
52114
|
-
var subtype;
|
|
52115
|
-
|
|
52116
|
-
F.prototype = obj;
|
|
52117
|
-
|
|
52118
|
-
subtype = new F();
|
|
52119
|
-
|
|
52120
|
-
F.prototype = null;
|
|
52121
|
-
|
|
52122
|
-
return subtype;
|
|
52123
|
-
};
|
|
52124
|
-
}());
|
|
52125
|
-
|
|
52126
|
-
/**
|
|
52127
|
-
* CryptoJS namespace.
|
|
52128
|
-
*/
|
|
52129
|
-
var C = {};
|
|
52130
|
-
|
|
52131
|
-
/**
|
|
52132
|
-
* Library namespace.
|
|
52133
|
-
*/
|
|
52134
|
-
var C_lib = C.lib = {};
|
|
52135
|
-
|
|
52136
|
-
/**
|
|
52137
|
-
* Base object for prototypal inheritance.
|
|
52138
|
-
*/
|
|
52139
|
-
var Base = C_lib.Base = (function () {
|
|
52140
|
-
|
|
52141
|
-
|
|
52142
|
-
return {
|
|
52143
|
-
/**
|
|
52144
|
-
* Creates a new object that inherits from this object.
|
|
52145
|
-
*
|
|
52146
|
-
* @param {Object} overrides Properties to copy into the new object.
|
|
52147
|
-
*
|
|
52148
|
-
* @return {Object} The new object.
|
|
52149
|
-
*
|
|
52150
|
-
* @static
|
|
52151
|
-
*
|
|
52152
|
-
* @example
|
|
52153
|
-
*
|
|
52154
|
-
* var MyType = CryptoJS.lib.Base.extend({
|
|
52155
|
-
* field: 'value',
|
|
52156
|
-
*
|
|
52157
|
-
* method: function () {
|
|
52158
|
-
* }
|
|
52159
|
-
* });
|
|
52160
|
-
*/
|
|
52161
|
-
extend: function (overrides) {
|
|
52162
|
-
// Spawn
|
|
52163
|
-
var subtype = create(this);
|
|
52164
|
-
|
|
52165
|
-
// Augment
|
|
52166
|
-
if (overrides) {
|
|
52167
|
-
subtype.mixIn(overrides);
|
|
52168
|
-
}
|
|
52169
|
-
|
|
52170
|
-
// Create default initializer
|
|
52171
|
-
if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {
|
|
52172
|
-
subtype.init = function () {
|
|
52173
|
-
subtype.$super.init.apply(this, arguments);
|
|
52174
|
-
};
|
|
52175
|
-
}
|
|
52176
|
-
|
|
52177
|
-
// Initializer's prototype is the subtype object
|
|
52178
|
-
subtype.init.prototype = subtype;
|
|
52179
|
-
|
|
52180
|
-
// Reference supertype
|
|
52181
|
-
subtype.$super = this;
|
|
52182
|
-
|
|
52183
|
-
return subtype;
|
|
52184
|
-
},
|
|
52185
|
-
|
|
52186
|
-
/**
|
|
52187
|
-
* Extends this object and runs the init method.
|
|
52188
|
-
* Arguments to create() will be passed to init().
|
|
52189
|
-
*
|
|
52190
|
-
* @return {Object} The new object.
|
|
52191
|
-
*
|
|
52192
|
-
* @static
|
|
52193
|
-
*
|
|
52194
|
-
* @example
|
|
52195
|
-
*
|
|
52196
|
-
* var instance = MyType.create();
|
|
52197
|
-
*/
|
|
52198
|
-
create: function () {
|
|
52199
|
-
var instance = this.extend();
|
|
52200
|
-
instance.init.apply(instance, arguments);
|
|
52201
|
-
|
|
52202
|
-
return instance;
|
|
52203
|
-
},
|
|
52204
|
-
|
|
52205
|
-
/**
|
|
52206
|
-
* Initializes a newly created object.
|
|
52207
|
-
* Override this method to add some logic when your objects are created.
|
|
52208
|
-
*
|
|
52209
|
-
* @example
|
|
52210
|
-
*
|
|
52211
|
-
* var MyType = CryptoJS.lib.Base.extend({
|
|
52212
|
-
* init: function () {
|
|
52213
|
-
* // ...
|
|
52214
|
-
* }
|
|
52215
|
-
* });
|
|
52216
|
-
*/
|
|
52217
|
-
init: function () {
|
|
52218
|
-
},
|
|
52219
|
-
|
|
52220
|
-
/**
|
|
52221
|
-
* Copies properties into this object.
|
|
52222
|
-
*
|
|
52223
|
-
* @param {Object} properties The properties to mix in.
|
|
52224
|
-
*
|
|
52225
|
-
* @example
|
|
52226
|
-
*
|
|
52227
|
-
* MyType.mixIn({
|
|
52228
|
-
* field: 'value'
|
|
52229
|
-
* });
|
|
52230
|
-
*/
|
|
52231
|
-
mixIn: function (properties) {
|
|
52232
|
-
for (var propertyName in properties) {
|
|
52233
|
-
if (properties.hasOwnProperty(propertyName)) {
|
|
52234
|
-
this[propertyName] = properties[propertyName];
|
|
52235
|
-
}
|
|
52236
|
-
}
|
|
52237
|
-
|
|
52238
|
-
// IE won't copy toString using the loop above
|
|
52239
|
-
if (properties.hasOwnProperty('toString')) {
|
|
52240
|
-
this.toString = properties.toString;
|
|
52241
|
-
}
|
|
52242
|
-
},
|
|
52243
|
-
|
|
52244
|
-
/**
|
|
52245
|
-
* Creates a copy of this object.
|
|
52246
|
-
*
|
|
52247
|
-
* @return {Object} The clone.
|
|
52248
|
-
*
|
|
52249
|
-
* @example
|
|
52250
|
-
*
|
|
52251
|
-
* var clone = instance.clone();
|
|
52252
|
-
*/
|
|
52253
|
-
clone: function () {
|
|
52254
|
-
return this.init.prototype.extend(this);
|
|
52255
|
-
}
|
|
52256
|
-
};
|
|
52257
|
-
}());
|
|
52258
|
-
|
|
52259
|
-
/**
|
|
52260
|
-
* An array of 32-bit words.
|
|
52261
|
-
*
|
|
52262
|
-
* @property {Array} words The array of 32-bit words.
|
|
52263
|
-
* @property {number} sigBytes The number of significant bytes in this word array.
|
|
52264
|
-
*/
|
|
52265
|
-
var WordArray = C_lib.WordArray = Base.extend({
|
|
52266
|
-
/**
|
|
52267
|
-
* Initializes a newly created word array.
|
|
52268
|
-
*
|
|
52269
|
-
* @param {Array} words (Optional) An array of 32-bit words.
|
|
52270
|
-
* @param {number} sigBytes (Optional) The number of significant bytes in the words.
|
|
52271
|
-
*
|
|
52272
|
-
* @example
|
|
52273
|
-
*
|
|
52274
|
-
* var wordArray = CryptoJS.lib.WordArray.create();
|
|
52275
|
-
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
|
|
52276
|
-
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
|
|
52277
|
-
*/
|
|
52278
|
-
init: function (words, sigBytes) {
|
|
52279
|
-
words = this.words = words || [];
|
|
52280
|
-
|
|
52281
|
-
if (sigBytes != undefined) {
|
|
52282
|
-
this.sigBytes = sigBytes;
|
|
52283
|
-
} else {
|
|
52284
|
-
this.sigBytes = words.length * 4;
|
|
52285
|
-
}
|
|
52286
|
-
},
|
|
52287
|
-
|
|
52288
|
-
/**
|
|
52289
|
-
* Converts this word array to a string.
|
|
52290
|
-
*
|
|
52291
|
-
* @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
|
|
52292
|
-
*
|
|
52293
|
-
* @return {string} The stringified word array.
|
|
52294
|
-
*
|
|
52295
|
-
* @example
|
|
52296
|
-
*
|
|
52297
|
-
* var string = wordArray + '';
|
|
52298
|
-
* var string = wordArray.toString();
|
|
52299
|
-
* var string = wordArray.toString(CryptoJS.enc.Utf8);
|
|
52300
|
-
*/
|
|
52301
|
-
toString: function (encoder) {
|
|
52302
|
-
return (encoder || Hex).stringify(this);
|
|
52303
|
-
},
|
|
52304
|
-
|
|
52305
|
-
/**
|
|
52306
|
-
* Concatenates a word array to this word array.
|
|
52307
|
-
*
|
|
52308
|
-
* @param {WordArray} wordArray The word array to append.
|
|
52309
|
-
*
|
|
52310
|
-
* @return {WordArray} This word array.
|
|
52311
|
-
*
|
|
52312
|
-
* @example
|
|
52313
|
-
*
|
|
52314
|
-
* wordArray1.concat(wordArray2);
|
|
52315
|
-
*/
|
|
52316
|
-
concat: function (wordArray) {
|
|
52317
|
-
// Shortcuts
|
|
52318
|
-
var thisWords = this.words;
|
|
52319
|
-
var thatWords = wordArray.words;
|
|
52320
|
-
var thisSigBytes = this.sigBytes;
|
|
52321
|
-
var thatSigBytes = wordArray.sigBytes;
|
|
52322
|
-
|
|
52323
|
-
// Clamp excess bits
|
|
52324
|
-
this.clamp();
|
|
52325
|
-
|
|
52326
|
-
// Concat
|
|
52327
|
-
if (thisSigBytes % 4) {
|
|
52328
|
-
// Copy one byte at a time
|
|
52329
|
-
for (var i = 0; i < thatSigBytes; i++) {
|
|
52330
|
-
var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
|
52331
|
-
thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
|
|
52332
|
-
}
|
|
52333
|
-
} else {
|
|
52334
|
-
// Copy one word at a time
|
|
52335
|
-
for (var j = 0; j < thatSigBytes; j += 4) {
|
|
52336
|
-
thisWords[(thisSigBytes + j) >>> 2] = thatWords[j >>> 2];
|
|
52337
|
-
}
|
|
52338
|
-
}
|
|
52339
|
-
this.sigBytes += thatSigBytes;
|
|
52340
|
-
|
|
52341
|
-
// Chainable
|
|
52342
|
-
return this;
|
|
52343
|
-
},
|
|
52344
|
-
|
|
52345
|
-
/**
|
|
52346
|
-
* Removes insignificant bits.
|
|
52347
|
-
*
|
|
52348
|
-
* @example
|
|
52349
|
-
*
|
|
52350
|
-
* wordArray.clamp();
|
|
52351
|
-
*/
|
|
52352
|
-
clamp: function () {
|
|
52353
|
-
// Shortcuts
|
|
52354
|
-
var words = this.words;
|
|
52355
|
-
var sigBytes = this.sigBytes;
|
|
52356
|
-
|
|
52357
|
-
// Clamp
|
|
52358
|
-
words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
|
|
52359
|
-
words.length = Math.ceil(sigBytes / 4);
|
|
52360
|
-
},
|
|
52361
|
-
|
|
52362
|
-
/**
|
|
52363
|
-
* Creates a copy of this word array.
|
|
52364
|
-
*
|
|
52365
|
-
* @return {WordArray} The clone.
|
|
52366
|
-
*
|
|
52367
|
-
* @example
|
|
52368
|
-
*
|
|
52369
|
-
* var clone = wordArray.clone();
|
|
52370
|
-
*/
|
|
52371
|
-
clone: function () {
|
|
52372
|
-
var clone = Base.clone.call(this);
|
|
52373
|
-
clone.words = this.words.slice(0);
|
|
52374
|
-
|
|
52375
|
-
return clone;
|
|
52376
|
-
},
|
|
52377
|
-
|
|
52378
|
-
/**
|
|
52379
|
-
* Creates a word array filled with random bytes.
|
|
52380
|
-
*
|
|
52381
|
-
* @param {number} nBytes The number of random bytes to generate.
|
|
52382
|
-
*
|
|
52383
|
-
* @return {WordArray} The random word array.
|
|
52384
|
-
*
|
|
52385
|
-
* @static
|
|
52386
|
-
*
|
|
52387
|
-
* @example
|
|
52388
|
-
*
|
|
52389
|
-
* var wordArray = CryptoJS.lib.WordArray.random(16);
|
|
52390
|
-
*/
|
|
52391
|
-
random: function (nBytes) {
|
|
52392
|
-
var words = [];
|
|
52393
|
-
|
|
52394
|
-
for (var i = 0; i < nBytes; i += 4) {
|
|
52395
|
-
words.push(cryptoSecureRandomInt());
|
|
52396
|
-
}
|
|
52397
|
-
|
|
52398
|
-
return new WordArray.init(words, nBytes);
|
|
52399
|
-
}
|
|
52400
|
-
});
|
|
52401
|
-
|
|
52402
|
-
/**
|
|
52403
|
-
* Encoder namespace.
|
|
52404
|
-
*/
|
|
52405
|
-
var C_enc = C.enc = {};
|
|
52406
|
-
|
|
52407
|
-
/**
|
|
52408
|
-
* Hex encoding strategy.
|
|
52409
|
-
*/
|
|
52410
|
-
var Hex = C_enc.Hex = {
|
|
52411
|
-
/**
|
|
52412
|
-
* Converts a word array to a hex string.
|
|
52413
|
-
*
|
|
52414
|
-
* @param {WordArray} wordArray The word array.
|
|
52415
|
-
*
|
|
52416
|
-
* @return {string} The hex string.
|
|
52417
|
-
*
|
|
52418
|
-
* @static
|
|
52419
|
-
*
|
|
52420
|
-
* @example
|
|
52421
|
-
*
|
|
52422
|
-
* var hexString = CryptoJS.enc.Hex.stringify(wordArray);
|
|
52423
|
-
*/
|
|
52424
|
-
stringify: function (wordArray) {
|
|
52425
|
-
// Shortcuts
|
|
52426
|
-
var words = wordArray.words;
|
|
52427
|
-
var sigBytes = wordArray.sigBytes;
|
|
52428
|
-
|
|
52429
|
-
// Convert
|
|
52430
|
-
var hexChars = [];
|
|
52431
|
-
for (var i = 0; i < sigBytes; i++) {
|
|
52432
|
-
var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
|
52433
|
-
hexChars.push((bite >>> 4).toString(16));
|
|
52434
|
-
hexChars.push((bite & 0x0f).toString(16));
|
|
52435
|
-
}
|
|
52436
|
-
|
|
52437
|
-
return hexChars.join('');
|
|
52438
|
-
},
|
|
52439
|
-
|
|
52440
|
-
/**
|
|
52441
|
-
* Converts a hex string to a word array.
|
|
52442
|
-
*
|
|
52443
|
-
* @param {string} hexStr The hex string.
|
|
52444
|
-
*
|
|
52445
|
-
* @return {WordArray} The word array.
|
|
52446
|
-
*
|
|
52447
|
-
* @static
|
|
52448
|
-
*
|
|
52449
|
-
* @example
|
|
52450
|
-
*
|
|
52451
|
-
* var wordArray = CryptoJS.enc.Hex.parse(hexString);
|
|
52452
|
-
*/
|
|
52453
|
-
parse: function (hexStr) {
|
|
52454
|
-
// Shortcut
|
|
52455
|
-
var hexStrLength = hexStr.length;
|
|
52456
|
-
|
|
52457
|
-
// Convert
|
|
52458
|
-
var words = [];
|
|
52459
|
-
for (var i = 0; i < hexStrLength; i += 2) {
|
|
52460
|
-
words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
|
|
52461
|
-
}
|
|
52462
|
-
|
|
52463
|
-
return new WordArray.init(words, hexStrLength / 2);
|
|
52464
|
-
}
|
|
52465
|
-
};
|
|
52466
|
-
|
|
52467
|
-
/**
|
|
52468
|
-
* Latin1 encoding strategy.
|
|
52469
|
-
*/
|
|
52470
|
-
var Latin1 = C_enc.Latin1 = {
|
|
52471
|
-
/**
|
|
52472
|
-
* Converts a word array to a Latin1 string.
|
|
52473
|
-
*
|
|
52474
|
-
* @param {WordArray} wordArray The word array.
|
|
52475
|
-
*
|
|
52476
|
-
* @return {string} The Latin1 string.
|
|
52477
|
-
*
|
|
52478
|
-
* @static
|
|
52479
|
-
*
|
|
52480
|
-
* @example
|
|
52481
|
-
*
|
|
52482
|
-
* var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
|
|
52483
|
-
*/
|
|
52484
|
-
stringify: function (wordArray) {
|
|
52485
|
-
// Shortcuts
|
|
52486
|
-
var words = wordArray.words;
|
|
52487
|
-
var sigBytes = wordArray.sigBytes;
|
|
52488
|
-
|
|
52489
|
-
// Convert
|
|
52490
|
-
var latin1Chars = [];
|
|
52491
|
-
for (var i = 0; i < sigBytes; i++) {
|
|
52492
|
-
var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
|
52493
|
-
latin1Chars.push(String.fromCharCode(bite));
|
|
52494
|
-
}
|
|
52495
|
-
|
|
52496
|
-
return latin1Chars.join('');
|
|
52497
|
-
},
|
|
52498
|
-
|
|
52499
|
-
/**
|
|
52500
|
-
* Converts a Latin1 string to a word array.
|
|
52501
|
-
*
|
|
52502
|
-
* @param {string} latin1Str The Latin1 string.
|
|
52503
|
-
*
|
|
52504
|
-
* @return {WordArray} The word array.
|
|
52505
|
-
*
|
|
52506
|
-
* @static
|
|
52507
|
-
*
|
|
52508
|
-
* @example
|
|
52509
|
-
*
|
|
52510
|
-
* var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
|
|
52511
|
-
*/
|
|
52512
|
-
parse: function (latin1Str) {
|
|
52513
|
-
// Shortcut
|
|
52514
|
-
var latin1StrLength = latin1Str.length;
|
|
52515
|
-
|
|
52516
|
-
// Convert
|
|
52517
|
-
var words = [];
|
|
52518
|
-
for (var i = 0; i < latin1StrLength; i++) {
|
|
52519
|
-
words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
|
|
52520
|
-
}
|
|
52521
|
-
|
|
52522
|
-
return new WordArray.init(words, latin1StrLength);
|
|
52523
|
-
}
|
|
52524
|
-
};
|
|
52525
|
-
|
|
52526
|
-
/**
|
|
52527
|
-
* UTF-8 encoding strategy.
|
|
52528
|
-
*/
|
|
52529
|
-
var Utf8 = C_enc.Utf8 = {
|
|
52530
|
-
/**
|
|
52531
|
-
* Converts a word array to a UTF-8 string.
|
|
52532
|
-
*
|
|
52533
|
-
* @param {WordArray} wordArray The word array.
|
|
52534
|
-
*
|
|
52535
|
-
* @return {string} The UTF-8 string.
|
|
52536
|
-
*
|
|
52537
|
-
* @static
|
|
52538
|
-
*
|
|
52539
|
-
* @example
|
|
52540
|
-
*
|
|
52541
|
-
* var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
|
|
52542
|
-
*/
|
|
52543
|
-
stringify: function (wordArray) {
|
|
52544
|
-
try {
|
|
52545
|
-
return decodeURIComponent(escape(Latin1.stringify(wordArray)));
|
|
52546
|
-
} catch (e) {
|
|
52547
|
-
throw new Error('Malformed UTF-8 data');
|
|
52548
|
-
}
|
|
52549
|
-
},
|
|
52550
|
-
|
|
52551
|
-
/**
|
|
52552
|
-
* Converts a UTF-8 string to a word array.
|
|
52553
|
-
*
|
|
52554
|
-
* @param {string} utf8Str The UTF-8 string.
|
|
52555
|
-
*
|
|
52556
|
-
* @return {WordArray} The word array.
|
|
52557
|
-
*
|
|
52558
|
-
* @static
|
|
52559
|
-
*
|
|
52560
|
-
* @example
|
|
52561
|
-
*
|
|
52562
|
-
* var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
|
|
52563
|
-
*/
|
|
52564
|
-
parse: function (utf8Str) {
|
|
52565
|
-
return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
|
|
52566
|
-
}
|
|
52567
|
-
};
|
|
52568
|
-
|
|
52569
|
-
/**
|
|
52570
|
-
* Abstract buffered block algorithm template.
|
|
52571
|
-
*
|
|
52572
|
-
* The property blockSize must be implemented in a concrete subtype.
|
|
52573
|
-
*
|
|
52574
|
-
* @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
|
|
52575
|
-
*/
|
|
52576
|
-
var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
|
|
52577
|
-
/**
|
|
52578
|
-
* Resets this block algorithm's data buffer to its initial state.
|
|
52579
|
-
*
|
|
52580
|
-
* @example
|
|
52581
|
-
*
|
|
52582
|
-
* bufferedBlockAlgorithm.reset();
|
|
52583
|
-
*/
|
|
52584
|
-
reset: function () {
|
|
52585
|
-
// Initial values
|
|
52586
|
-
this._data = new WordArray.init();
|
|
52587
|
-
this._nDataBytes = 0;
|
|
52588
|
-
},
|
|
52589
|
-
|
|
52590
|
-
/**
|
|
52591
|
-
* Adds new data to this block algorithm's buffer.
|
|
52592
|
-
*
|
|
52593
|
-
* @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
|
|
52594
|
-
*
|
|
52595
|
-
* @example
|
|
52596
|
-
*
|
|
52597
|
-
* bufferedBlockAlgorithm._append('data');
|
|
52598
|
-
* bufferedBlockAlgorithm._append(wordArray);
|
|
52599
|
-
*/
|
|
52600
|
-
_append: function (data) {
|
|
52601
|
-
// Convert string to WordArray, else assume WordArray already
|
|
52602
|
-
if (typeof data == 'string') {
|
|
52603
|
-
data = Utf8.parse(data);
|
|
52604
|
-
}
|
|
52605
|
-
|
|
52606
|
-
// Append
|
|
52607
|
-
this._data.concat(data);
|
|
52608
|
-
this._nDataBytes += data.sigBytes;
|
|
52609
|
-
},
|
|
52610
|
-
|
|
52611
|
-
/**
|
|
52612
|
-
* Processes available data blocks.
|
|
52613
|
-
*
|
|
52614
|
-
* This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
|
|
52615
|
-
*
|
|
52616
|
-
* @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
|
|
52617
|
-
*
|
|
52618
|
-
* @return {WordArray} The processed data.
|
|
52619
|
-
*
|
|
52620
|
-
* @example
|
|
52621
|
-
*
|
|
52622
|
-
* var processedData = bufferedBlockAlgorithm._process();
|
|
52623
|
-
* var processedData = bufferedBlockAlgorithm._process(!!'flush');
|
|
52624
|
-
*/
|
|
52625
|
-
_process: function (doFlush) {
|
|
52626
|
-
var processedWords;
|
|
52627
|
-
|
|
52628
|
-
// Shortcuts
|
|
52629
|
-
var data = this._data;
|
|
52630
|
-
var dataWords = data.words;
|
|
52631
|
-
var dataSigBytes = data.sigBytes;
|
|
52632
|
-
var blockSize = this.blockSize;
|
|
52633
|
-
var blockSizeBytes = blockSize * 4;
|
|
52634
|
-
|
|
52635
|
-
// Count blocks ready
|
|
52636
|
-
var nBlocksReady = dataSigBytes / blockSizeBytes;
|
|
52637
|
-
if (doFlush) {
|
|
52638
|
-
// Round up to include partial blocks
|
|
52639
|
-
nBlocksReady = Math.ceil(nBlocksReady);
|
|
52640
|
-
} else {
|
|
52641
|
-
// Round down to include only full blocks,
|
|
52642
|
-
// less the number of blocks that must remain in the buffer
|
|
52643
|
-
nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
|
|
52644
|
-
}
|
|
52645
|
-
|
|
52646
|
-
// Count words ready
|
|
52647
|
-
var nWordsReady = nBlocksReady * blockSize;
|
|
52648
|
-
|
|
52649
|
-
// Count bytes ready
|
|
52650
|
-
var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
|
|
52651
|
-
|
|
52652
|
-
// Process blocks
|
|
52653
|
-
if (nWordsReady) {
|
|
52654
|
-
for (var offset = 0; offset < nWordsReady; offset += blockSize) {
|
|
52655
|
-
// Perform concrete-algorithm logic
|
|
52656
|
-
this._doProcessBlock(dataWords, offset);
|
|
52657
|
-
}
|
|
52658
|
-
|
|
52659
|
-
// Remove processed words
|
|
52660
|
-
processedWords = dataWords.splice(0, nWordsReady);
|
|
52661
|
-
data.sigBytes -= nBytesReady;
|
|
52662
|
-
}
|
|
52663
|
-
|
|
52664
|
-
// Return processed words
|
|
52665
|
-
return new WordArray.init(processedWords, nBytesReady);
|
|
52666
|
-
},
|
|
52667
|
-
|
|
52668
|
-
/**
|
|
52669
|
-
* Creates a copy of this object.
|
|
52670
|
-
*
|
|
52671
|
-
* @return {Object} The clone.
|
|
52672
|
-
*
|
|
52673
|
-
* @example
|
|
52674
|
-
*
|
|
52675
|
-
* var clone = bufferedBlockAlgorithm.clone();
|
|
52676
|
-
*/
|
|
52677
|
-
clone: function () {
|
|
52678
|
-
var clone = Base.clone.call(this);
|
|
52679
|
-
clone._data = this._data.clone();
|
|
52680
|
-
|
|
52681
|
-
return clone;
|
|
52682
|
-
},
|
|
52683
|
-
|
|
52684
|
-
_minBufferSize: 0
|
|
52685
|
-
});
|
|
52686
|
-
|
|
52687
|
-
/**
|
|
52688
|
-
* Abstract hasher template.
|
|
52689
|
-
*
|
|
52690
|
-
* @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
|
|
52691
|
-
*/
|
|
52692
|
-
var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
|
|
52693
|
-
/**
|
|
52694
|
-
* Configuration options.
|
|
52695
|
-
*/
|
|
52696
|
-
cfg: Base.extend(),
|
|
52697
|
-
|
|
52698
|
-
/**
|
|
52699
|
-
* Initializes a newly created hasher.
|
|
52700
|
-
*
|
|
52701
|
-
* @param {Object} cfg (Optional) The configuration options to use for this hash computation.
|
|
52702
|
-
*
|
|
52703
|
-
* @example
|
|
52704
|
-
*
|
|
52705
|
-
* var hasher = CryptoJS.algo.SHA256.create();
|
|
52706
|
-
*/
|
|
52707
|
-
init: function (cfg) {
|
|
52708
|
-
// Apply config defaults
|
|
52709
|
-
this.cfg = this.cfg.extend(cfg);
|
|
52710
|
-
|
|
52711
|
-
// Set initial values
|
|
52712
|
-
this.reset();
|
|
52713
|
-
},
|
|
52714
|
-
|
|
52715
|
-
/**
|
|
52716
|
-
* Resets this hasher to its initial state.
|
|
52717
|
-
*
|
|
52718
|
-
* @example
|
|
52719
|
-
*
|
|
52720
|
-
* hasher.reset();
|
|
52721
|
-
*/
|
|
52722
|
-
reset: function () {
|
|
52723
|
-
// Reset data buffer
|
|
52724
|
-
BufferedBlockAlgorithm.reset.call(this);
|
|
52725
|
-
|
|
52726
|
-
// Perform concrete-hasher logic
|
|
52727
|
-
this._doReset();
|
|
52728
|
-
},
|
|
52729
|
-
|
|
52730
|
-
/**
|
|
52731
|
-
* Updates this hasher with a message.
|
|
52732
|
-
*
|
|
52733
|
-
* @param {WordArray|string} messageUpdate The message to append.
|
|
52734
|
-
*
|
|
52735
|
-
* @return {Hasher} This hasher.
|
|
52736
|
-
*
|
|
52737
|
-
* @example
|
|
52738
|
-
*
|
|
52739
|
-
* hasher.update('message');
|
|
52740
|
-
* hasher.update(wordArray);
|
|
52741
|
-
*/
|
|
52742
|
-
update: function (messageUpdate) {
|
|
52743
|
-
// Append
|
|
52744
|
-
this._append(messageUpdate);
|
|
52745
|
-
|
|
52746
|
-
// Update the hash
|
|
52747
|
-
this._process();
|
|
52748
|
-
|
|
52749
|
-
// Chainable
|
|
52750
|
-
return this;
|
|
52751
|
-
},
|
|
52752
|
-
|
|
52753
|
-
/**
|
|
52754
|
-
* Finalizes the hash computation.
|
|
52755
|
-
* Note that the finalize operation is effectively a destructive, read-once operation.
|
|
52756
|
-
*
|
|
52757
|
-
* @param {WordArray|string} messageUpdate (Optional) A final message update.
|
|
52758
|
-
*
|
|
52759
|
-
* @return {WordArray} The hash.
|
|
52760
|
-
*
|
|
52761
|
-
* @example
|
|
52762
|
-
*
|
|
52763
|
-
* var hash = hasher.finalize();
|
|
52764
|
-
* var hash = hasher.finalize('message');
|
|
52765
|
-
* var hash = hasher.finalize(wordArray);
|
|
52766
|
-
*/
|
|
52767
|
-
finalize: function (messageUpdate) {
|
|
52768
|
-
// Final message update
|
|
52769
|
-
if (messageUpdate) {
|
|
52770
|
-
this._append(messageUpdate);
|
|
52771
|
-
}
|
|
52772
|
-
|
|
52773
|
-
// Perform concrete-hasher logic
|
|
52774
|
-
var hash = this._doFinalize();
|
|
52775
|
-
|
|
52776
|
-
return hash;
|
|
52777
|
-
},
|
|
52778
|
-
|
|
52779
|
-
blockSize: 512/32,
|
|
52780
|
-
|
|
52781
|
-
/**
|
|
52782
|
-
* Creates a shortcut function to a hasher's object interface.
|
|
52783
|
-
*
|
|
52784
|
-
* @param {Hasher} hasher The hasher to create a helper for.
|
|
52785
|
-
*
|
|
52786
|
-
* @return {Function} The shortcut function.
|
|
52787
|
-
*
|
|
52788
|
-
* @static
|
|
52789
|
-
*
|
|
52790
|
-
* @example
|
|
52791
|
-
*
|
|
52792
|
-
* var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
|
|
52793
|
-
*/
|
|
52794
|
-
_createHelper: function (hasher) {
|
|
52795
|
-
return function (message, cfg) {
|
|
52796
|
-
return new hasher.init(cfg).finalize(message);
|
|
52797
|
-
};
|
|
52798
|
-
},
|
|
52799
|
-
|
|
52800
|
-
/**
|
|
52801
|
-
* Creates a shortcut function to the HMAC's object interface.
|
|
52802
|
-
*
|
|
52803
|
-
* @param {Hasher} hasher The hasher to use in this HMAC helper.
|
|
52804
|
-
*
|
|
52805
|
-
* @return {Function} The shortcut function.
|
|
52806
|
-
*
|
|
52807
|
-
* @static
|
|
52808
|
-
*
|
|
52809
|
-
* @example
|
|
52810
|
-
*
|
|
52811
|
-
* var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
|
|
52812
|
-
*/
|
|
52813
|
-
_createHmacHelper: function (hasher) {
|
|
52814
|
-
return function (message, key) {
|
|
52815
|
-
return new C_algo.HMAC.init(hasher, key).finalize(message);
|
|
52816
|
-
};
|
|
52817
|
-
}
|
|
52818
|
-
});
|
|
52819
|
-
|
|
52820
|
-
/**
|
|
52821
|
-
* Algorithm namespace.
|
|
52822
|
-
*/
|
|
52823
|
-
var C_algo = C.algo = {};
|
|
52824
|
-
|
|
52825
|
-
return C;
|
|
52826
|
-
}(Math));
|
|
52827
|
-
|
|
52828
|
-
|
|
52829
|
-
return CryptoJS;
|
|
52830
|
-
|
|
52831
|
-
}));
|
|
52832
|
-
|
|
52833
|
-
/***/ }),
|
|
52834
|
-
|
|
52835
|
-
/***/ 3465:
|
|
52836
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
52837
|
-
|
|
52838
|
-
;(function (root, factory) {
|
|
52839
|
-
if (true) {
|
|
52840
|
-
// CommonJS
|
|
52841
|
-
module.exports = exports = factory(__webpack_require__(8249));
|
|
52842
|
-
}
|
|
52843
|
-
else {}
|
|
52844
|
-
}(this, function (CryptoJS) {
|
|
52845
|
-
|
|
52846
|
-
return CryptoJS.enc.Hex;
|
|
52847
|
-
|
|
52848
|
-
}));
|
|
52849
|
-
|
|
52850
|
-
/***/ }),
|
|
52851
|
-
|
|
52852
|
-
/***/ 2153:
|
|
52853
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
52854
|
-
|
|
52855
|
-
;(function (root, factory) {
|
|
52856
|
-
if (true) {
|
|
52857
|
-
// CommonJS
|
|
52858
|
-
module.exports = exports = factory(__webpack_require__(8249));
|
|
52859
|
-
}
|
|
52860
|
-
else {}
|
|
52861
|
-
}(this, function (CryptoJS) {
|
|
52862
|
-
|
|
52863
|
-
(function (Math) {
|
|
52864
|
-
// Shortcuts
|
|
52865
|
-
var C = CryptoJS;
|
|
52866
|
-
var C_lib = C.lib;
|
|
52867
|
-
var WordArray = C_lib.WordArray;
|
|
52868
|
-
var Hasher = C_lib.Hasher;
|
|
52869
|
-
var C_algo = C.algo;
|
|
52870
|
-
|
|
52871
|
-
// Initialization and round constants tables
|
|
52872
|
-
var H = [];
|
|
52873
|
-
var K = [];
|
|
52874
|
-
|
|
52875
|
-
// Compute constants
|
|
52876
|
-
(function () {
|
|
52877
|
-
function isPrime(n) {
|
|
52878
|
-
var sqrtN = Math.sqrt(n);
|
|
52879
|
-
for (var factor = 2; factor <= sqrtN; factor++) {
|
|
52880
|
-
if (!(n % factor)) {
|
|
52881
|
-
return false;
|
|
52882
|
-
}
|
|
52883
|
-
}
|
|
52884
|
-
|
|
52885
|
-
return true;
|
|
52886
|
-
}
|
|
52887
|
-
|
|
52888
|
-
function getFractionalBits(n) {
|
|
52889
|
-
return ((n - (n | 0)) * 0x100000000) | 0;
|
|
52890
|
-
}
|
|
52891
|
-
|
|
52892
|
-
var n = 2;
|
|
52893
|
-
var nPrime = 0;
|
|
52894
|
-
while (nPrime < 64) {
|
|
52895
|
-
if (isPrime(n)) {
|
|
52896
|
-
if (nPrime < 8) {
|
|
52897
|
-
H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));
|
|
52898
|
-
}
|
|
52899
|
-
K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));
|
|
52900
|
-
|
|
52901
|
-
nPrime++;
|
|
52902
|
-
}
|
|
52903
|
-
|
|
52904
|
-
n++;
|
|
52905
|
-
}
|
|
52906
|
-
}());
|
|
52907
|
-
|
|
52908
|
-
// Reusable object
|
|
52909
|
-
var W = [];
|
|
52910
|
-
|
|
52911
|
-
/**
|
|
52912
|
-
* SHA-256 hash algorithm.
|
|
52913
|
-
*/
|
|
52914
|
-
var SHA256 = C_algo.SHA256 = Hasher.extend({
|
|
52915
|
-
_doReset: function () {
|
|
52916
|
-
this._hash = new WordArray.init(H.slice(0));
|
|
52917
|
-
},
|
|
52918
|
-
|
|
52919
|
-
_doProcessBlock: function (M, offset) {
|
|
52920
|
-
// Shortcut
|
|
52921
|
-
var H = this._hash.words;
|
|
52922
|
-
|
|
52923
|
-
// Working variables
|
|
52924
|
-
var a = H[0];
|
|
52925
|
-
var b = H[1];
|
|
52926
|
-
var c = H[2];
|
|
52927
|
-
var d = H[3];
|
|
52928
|
-
var e = H[4];
|
|
52929
|
-
var f = H[5];
|
|
52930
|
-
var g = H[6];
|
|
52931
|
-
var h = H[7];
|
|
52932
|
-
|
|
52933
|
-
// Computation
|
|
52934
|
-
for (var i = 0; i < 64; i++) {
|
|
52935
|
-
if (i < 16) {
|
|
52936
|
-
W[i] = M[offset + i] | 0;
|
|
52937
|
-
} else {
|
|
52938
|
-
var gamma0x = W[i - 15];
|
|
52939
|
-
var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^
|
|
52940
|
-
((gamma0x << 14) | (gamma0x >>> 18)) ^
|
|
52941
|
-
(gamma0x >>> 3);
|
|
52942
|
-
|
|
52943
|
-
var gamma1x = W[i - 2];
|
|
52944
|
-
var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^
|
|
52945
|
-
((gamma1x << 13) | (gamma1x >>> 19)) ^
|
|
52946
|
-
(gamma1x >>> 10);
|
|
52947
|
-
|
|
52948
|
-
W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
|
|
52949
|
-
}
|
|
52950
|
-
|
|
52951
|
-
var ch = (e & f) ^ (~e & g);
|
|
52952
|
-
var maj = (a & b) ^ (a & c) ^ (b & c);
|
|
52953
|
-
|
|
52954
|
-
var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));
|
|
52955
|
-
var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25));
|
|
52956
|
-
|
|
52957
|
-
var t1 = h + sigma1 + ch + K[i] + W[i];
|
|
52958
|
-
var t2 = sigma0 + maj;
|
|
52959
|
-
|
|
52960
|
-
h = g;
|
|
52961
|
-
g = f;
|
|
52962
|
-
f = e;
|
|
52963
|
-
e = (d + t1) | 0;
|
|
52964
|
-
d = c;
|
|
52965
|
-
c = b;
|
|
52966
|
-
b = a;
|
|
52967
|
-
a = (t1 + t2) | 0;
|
|
52968
|
-
}
|
|
52969
|
-
|
|
52970
|
-
// Intermediate hash value
|
|
52971
|
-
H[0] = (H[0] + a) | 0;
|
|
52972
|
-
H[1] = (H[1] + b) | 0;
|
|
52973
|
-
H[2] = (H[2] + c) | 0;
|
|
52974
|
-
H[3] = (H[3] + d) | 0;
|
|
52975
|
-
H[4] = (H[4] + e) | 0;
|
|
52976
|
-
H[5] = (H[5] + f) | 0;
|
|
52977
|
-
H[6] = (H[6] + g) | 0;
|
|
52978
|
-
H[7] = (H[7] + h) | 0;
|
|
52979
|
-
},
|
|
52980
|
-
|
|
52981
|
-
_doFinalize: function () {
|
|
52982
|
-
// Shortcuts
|
|
52983
|
-
var data = this._data;
|
|
52984
|
-
var dataWords = data.words;
|
|
52985
|
-
|
|
52986
|
-
var nBitsTotal = this._nDataBytes * 8;
|
|
52987
|
-
var nBitsLeft = data.sigBytes * 8;
|
|
52988
|
-
|
|
52989
|
-
// Add padding
|
|
52990
|
-
dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
|
|
52991
|
-
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
|
|
52992
|
-
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
|
|
52993
|
-
data.sigBytes = dataWords.length * 4;
|
|
52994
|
-
|
|
52995
|
-
// Hash final blocks
|
|
52996
|
-
this._process();
|
|
52997
|
-
|
|
52998
|
-
// Return final computed hash
|
|
52999
|
-
return this._hash;
|
|
53000
|
-
},
|
|
53001
|
-
|
|
53002
|
-
clone: function () {
|
|
53003
|
-
var clone = Hasher.clone.call(this);
|
|
53004
|
-
clone._hash = this._hash.clone();
|
|
53005
|
-
|
|
53006
|
-
return clone;
|
|
53007
|
-
}
|
|
53008
|
-
});
|
|
53009
|
-
|
|
53010
|
-
/**
|
|
53011
|
-
* Shortcut function to the hasher's object interface.
|
|
53012
|
-
*
|
|
53013
|
-
* @param {WordArray|string} message The message to hash.
|
|
53014
|
-
*
|
|
53015
|
-
* @return {WordArray} The hash.
|
|
53016
|
-
*
|
|
53017
|
-
* @static
|
|
53018
|
-
*
|
|
53019
|
-
* @example
|
|
53020
|
-
*
|
|
53021
|
-
* var hash = CryptoJS.SHA256('message');
|
|
53022
|
-
* var hash = CryptoJS.SHA256(wordArray);
|
|
53023
|
-
*/
|
|
53024
|
-
C.SHA256 = Hasher._createHelper(SHA256);
|
|
53025
|
-
|
|
53026
|
-
/**
|
|
53027
|
-
* Shortcut function to the HMAC's object interface.
|
|
53028
|
-
*
|
|
53029
|
-
* @param {WordArray|string} message The message to hash.
|
|
53030
|
-
* @param {WordArray|string} key The secret key.
|
|
53031
|
-
*
|
|
53032
|
-
* @return {WordArray} The HMAC.
|
|
53033
|
-
*
|
|
53034
|
-
* @static
|
|
53035
|
-
*
|
|
53036
|
-
* @example
|
|
53037
|
-
*
|
|
53038
|
-
* var hmac = CryptoJS.HmacSHA256(message, key);
|
|
53039
|
-
*/
|
|
53040
|
-
C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
|
|
53041
|
-
}(Math));
|
|
53042
|
-
|
|
53043
|
-
|
|
53044
|
-
return CryptoJS.SHA256;
|
|
53045
|
-
|
|
53046
|
-
}));
|
|
53047
|
-
|
|
53048
|
-
/***/ }),
|
|
53049
|
-
|
|
53050
52029
|
/***/ 4222:
|
|
53051
52030
|
/***/ (function(module) {
|
|
53052
52031
|
|
|
@@ -80600,189 +79579,130 @@ License: MIT
|
|
|
80600
79579
|
/***/ }),
|
|
80601
79580
|
|
|
80602
79581
|
/***/ 32:
|
|
80603
|
-
/***/ (
|
|
79582
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
80604
79583
|
|
|
80605
79584
|
"use strict";
|
|
80606
79585
|
|
|
80607
79586
|
/** @module imaging/imageAnonymization
|
|
80608
79587
|
* @desc This file provides anonymization functionalities on DICOM images
|
|
80609
|
-
* following http://dicom.nema.org/medical/dicom/current/output/html/part15.html#chapter_E
|
|
80610
79588
|
*/
|
|
80611
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
80612
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
80613
|
-
};
|
|
80614
79589
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
80615
79590
|
exports.anonymize = void 0;
|
|
80616
|
-
// external libraries
|
|
80617
|
-
const sha256_1 = __importDefault(__webpack_require__(2153));
|
|
80618
|
-
const enc_hex_1 = __importDefault(__webpack_require__(3465));
|
|
80619
|
-
const lodash_1 = __webpack_require__(6486);
|
|
80620
|
-
const SH = (/* unused pure expression or super */ null && ([
|
|
80621
|
-
"x00080050" // Accession Number,
|
|
80622
|
-
]));
|
|
80623
|
-
const OPTIONAL = (/* unused pure expression or super */ null && ([
|
|
80624
|
-
"x00100030",
|
|
80625
|
-
"x00080090",
|
|
80626
|
-
"x00100020",
|
|
80627
|
-
"x00100040",
|
|
80628
|
-
"x00200010" // Study ID
|
|
80629
|
-
]));
|
|
80630
|
-
const REMOVE = [
|
|
80631
|
-
"x00080014",
|
|
80632
|
-
"x00080080",
|
|
80633
|
-
"x00080081",
|
|
80634
|
-
"x00080092",
|
|
80635
|
-
"x00080094",
|
|
80636
|
-
"x00081010",
|
|
80637
|
-
"x00081030",
|
|
80638
|
-
"x0008103e",
|
|
80639
|
-
"x00081040",
|
|
80640
|
-
"x00081048",
|
|
80641
|
-
"x00081050",
|
|
80642
|
-
"x00081060",
|
|
80643
|
-
"x00081070",
|
|
80644
|
-
"x00081080",
|
|
80645
|
-
"x00082111",
|
|
80646
|
-
"x00100032",
|
|
80647
|
-
"x00101000",
|
|
80648
|
-
"x00101001",
|
|
80649
|
-
"x00101010",
|
|
80650
|
-
"x00101020",
|
|
80651
|
-
"x00101030",
|
|
80652
|
-
"x00101090",
|
|
80653
|
-
"x00102160",
|
|
80654
|
-
"x00102180",
|
|
80655
|
-
"x001021b0",
|
|
80656
|
-
"x00104000",
|
|
80657
|
-
"x00181000",
|
|
80658
|
-
"x00181030",
|
|
80659
|
-
"x00204000",
|
|
80660
|
-
"x00400275" // Request Attributes Sequence
|
|
80661
|
-
];
|
|
80662
|
-
// global vars
|
|
80663
|
-
const TAGS = [
|
|
80664
|
-
"x00080014",
|
|
80665
|
-
"x00080050",
|
|
80666
|
-
"x00080080",
|
|
80667
|
-
"x00080081",
|
|
80668
|
-
"x00080090",
|
|
80669
|
-
"x00080092",
|
|
80670
|
-
"x00080094",
|
|
80671
|
-
"x00081010",
|
|
80672
|
-
"x00081030",
|
|
80673
|
-
"x0008103e",
|
|
80674
|
-
"x00081040",
|
|
80675
|
-
"x00081048",
|
|
80676
|
-
"x00081050",
|
|
80677
|
-
"x00081060",
|
|
80678
|
-
"x00081070",
|
|
80679
|
-
"x00081080",
|
|
80680
|
-
"x00082111",
|
|
80681
|
-
"x00100010",
|
|
80682
|
-
"x00100020",
|
|
80683
|
-
"x00100030",
|
|
80684
|
-
"x00100032",
|
|
80685
|
-
"x00100040",
|
|
80686
|
-
"x00101000",
|
|
80687
|
-
"x00101001",
|
|
80688
|
-
"x00101010",
|
|
80689
|
-
"x00101020",
|
|
80690
|
-
"x00101030",
|
|
80691
|
-
"x00101090",
|
|
80692
|
-
"x00102160",
|
|
80693
|
-
"x00102180",
|
|
80694
|
-
"x001021b0",
|
|
80695
|
-
"x00104000",
|
|
80696
|
-
"x00181000",
|
|
80697
|
-
"x00181030",
|
|
80698
|
-
"x00200010",
|
|
80699
|
-
"x00200052",
|
|
80700
|
-
"x00200200",
|
|
80701
|
-
"x00204000",
|
|
80702
|
-
"x00400275",
|
|
80703
|
-
"x0040a124",
|
|
80704
|
-
"x00880140",
|
|
80705
|
-
"x30060024",
|
|
80706
|
-
"x300600c2" // Related Frame of Reference UID
|
|
80707
|
-
];
|
|
80708
79591
|
/*
|
|
80709
79592
|
* This module provides the following functions to be exported:
|
|
80710
|
-
* anonymize(series)
|
|
79593
|
+
* anonymize(series: Series): Series
|
|
80711
79594
|
*/
|
|
80712
79595
|
/**
|
|
80713
|
-
* Anonymize
|
|
79596
|
+
* Anonymize a series by replacing all metadata with random values
|
|
80714
79597
|
* @function anonymize
|
|
80715
|
-
* @param {
|
|
80716
|
-
* @returns {
|
|
79598
|
+
* @param {Series} series - series to anonymize
|
|
79599
|
+
* @returns {Series} anonymized series
|
|
80717
79600
|
*/
|
|
80718
79601
|
const anonymize = function (series) {
|
|
80719
|
-
|
|
80720
|
-
|
|
80721
|
-
|
|
80722
|
-
|
|
80723
|
-
|
|
80724
|
-
|
|
80725
|
-
|
|
80726
|
-
|
|
80727
|
-
|
|
80728
|
-
|
|
80729
|
-
|
|
80730
|
-
|
|
80731
|
-
|
|
80732
|
-
|
|
80733
|
-
// Required, empty if unknown
|
|
80734
|
-
/*else if (OPTIONAL.includes(tag) === true) {
|
|
80735
|
-
tag_meta = tag as keyof MetaData;
|
|
80736
|
-
instance.metadata[tag_meta] = "";
|
|
80737
|
-
}*/
|
|
80738
|
-
else if (tag_meta === "x00100030") {
|
|
80739
|
-
instance.metadata[tag_meta] = "";
|
|
80740
|
-
}
|
|
80741
|
-
else if (tag_meta === "x00080090") {
|
|
80742
|
-
instance.metadata[tag_meta] = "";
|
|
80743
|
-
}
|
|
80744
|
-
else if (tag_meta === "x00100020") {
|
|
80745
|
-
instance.metadata[tag_meta] = "";
|
|
80746
|
-
}
|
|
80747
|
-
else if (tag_meta === "x00100040") {
|
|
80748
|
-
instance.metadata[tag_meta] = "";
|
|
80749
|
-
}
|
|
80750
|
-
else if (tag_meta === "x00200010") {
|
|
80751
|
-
instance.metadata[tag_meta] = "";
|
|
80752
|
-
}
|
|
80753
|
-
// Optional
|
|
80754
|
-
else if (REMOVE.includes(tag) === true) {
|
|
80755
|
-
//tag_meta = tag as keyof MetaData;
|
|
80756
|
-
delete instance.metadata[tag_meta];
|
|
79602
|
+
// anonymize series bytearray
|
|
79603
|
+
for (const id in series.imageIds) {
|
|
79604
|
+
const imageId = series.imageIds[id];
|
|
79605
|
+
let image = series.instances[imageId];
|
|
79606
|
+
if (image.dataSet) {
|
|
79607
|
+
for (const tag in image.dataSet.elements) {
|
|
79608
|
+
let element = image.dataSet.elements[tag];
|
|
79609
|
+
let text = "";
|
|
79610
|
+
const vr = element.vr;
|
|
79611
|
+
if (element !== undefined) {
|
|
79612
|
+
let str = image.dataSet.string(tag);
|
|
79613
|
+
if (str !== undefined) {
|
|
79614
|
+
text = str;
|
|
79615
|
+
}
|
|
80757
79616
|
}
|
|
80758
|
-
|
|
80759
|
-
|
|
80760
|
-
|
|
80761
|
-
|
|
80762
|
-
|
|
79617
|
+
if (vr) {
|
|
79618
|
+
const deIdentifiedValue = makeDeIdentifiedValue(text.length, vr);
|
|
79619
|
+
if (deIdentifiedValue !== undefined) {
|
|
79620
|
+
for (let i = 0; i < element.length; i++) {
|
|
79621
|
+
const char = deIdentifiedValue.length > i
|
|
79622
|
+
? deIdentifiedValue.charCodeAt(i)
|
|
79623
|
+
: 32;
|
|
79624
|
+
image.dataSet.byteArray[element.dataOffset + i] = char;
|
|
79625
|
+
}
|
|
79626
|
+
// @ts-ignore always string
|
|
79627
|
+
image.metadata[tag] = deIdentifiedValue;
|
|
80763
79628
|
}
|
|
80764
|
-
//TODO-ts: check if this case has to be applied only on strings
|
|
80765
|
-
//or also on numbers and if any type could be correct to force solution
|
|
80766
|
-
//or find another solution
|
|
80767
79629
|
}
|
|
80768
79630
|
}
|
|
80769
|
-
|
|
80770
|
-
|
|
80771
|
-
|
|
80772
|
-
|
|
80773
|
-
|
|
80774
|
-
|
|
80775
|
-
|
|
80776
|
-
|
|
80777
|
-
|
|
80778
|
-
|
|
80779
|
-
|
|
80780
|
-
|
|
80781
|
-
|
|
79631
|
+
image.metadata.seriesUID = image.metadata["x0020000e"];
|
|
79632
|
+
image.metadata.instanceUID = image.metadata["x00080018"];
|
|
79633
|
+
image.metadata.studyUID = image.metadata["x0020000d"];
|
|
79634
|
+
image.metadata.accessionNumber = image.metadata["x00080050"];
|
|
79635
|
+
image.metadata.studyDescription = image.metadata["x00081030"];
|
|
79636
|
+
image.metadata.patientName = image.metadata["x00100010"];
|
|
79637
|
+
image.metadata.patientBirthdate = image.metadata["x00100030"];
|
|
79638
|
+
image.metadata.seriesDescription = image.metadata["x0008103e"];
|
|
79639
|
+
image.metadata.anonymized = true;
|
|
79640
|
+
}
|
|
79641
|
+
else {
|
|
79642
|
+
console.warn(`No dataset found for image ${imageId}`);
|
|
79643
|
+
}
|
|
79644
|
+
}
|
|
79645
|
+
// update parsed metadata
|
|
80782
79646
|
series.anonymized = true;
|
|
79647
|
+
series.seriesDescription = series.instances[series.imageIds[0]].metadata["x0008103e"];
|
|
80783
79648
|
return series;
|
|
80784
79649
|
};
|
|
80785
79650
|
exports.anonymize = anonymize;
|
|
79651
|
+
// Internal functions
|
|
79652
|
+
/**
|
|
79653
|
+
* Generate a random string of a given length
|
|
79654
|
+
* @function makeRandomString
|
|
79655
|
+
* @param {number} length - length of the string to generate
|
|
79656
|
+
* @returns {string} random string
|
|
79657
|
+
*/
|
|
79658
|
+
const makeRandomString = function (length) {
|
|
79659
|
+
let text = "";
|
|
79660
|
+
const possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
79661
|
+
for (let i = 0; i < length; i++) {
|
|
79662
|
+
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
|
79663
|
+
}
|
|
79664
|
+
return text;
|
|
79665
|
+
};
|
|
79666
|
+
/**
|
|
79667
|
+
* Pad a number with 0s to a given size
|
|
79668
|
+
* @function pad
|
|
79669
|
+
* @param {number} num - number to pad
|
|
79670
|
+
* @param {number} size - size of the padded number
|
|
79671
|
+
* @returns {string} padded number
|
|
79672
|
+
*/
|
|
79673
|
+
const pad = function (num, size) {
|
|
79674
|
+
var s = num + "";
|
|
79675
|
+
while (s.length < size)
|
|
79676
|
+
s = "0" + s;
|
|
79677
|
+
return s;
|
|
79678
|
+
};
|
|
79679
|
+
/**
|
|
79680
|
+
* Make a de-identified value for a given length and VR
|
|
79681
|
+
* @function makeDeIdentifiedValue
|
|
79682
|
+
* @param {number} length - length of the value to generate
|
|
79683
|
+
* @param {string} vr - VR of the value to generate
|
|
79684
|
+
* @returns {string} de-identified value
|
|
79685
|
+
*/
|
|
79686
|
+
const makeDeIdentifiedValue = function (length, vr) {
|
|
79687
|
+
if (vr === "LO" || vr === "SH" || vr === "PN") {
|
|
79688
|
+
return makeRandomString(length);
|
|
79689
|
+
}
|
|
79690
|
+
else if (vr === "DA") {
|
|
79691
|
+
let oldDate = new Date(1900, 0, 1);
|
|
79692
|
+
return (oldDate.getFullYear() +
|
|
79693
|
+
pad(oldDate.getMonth() + 1, 2) +
|
|
79694
|
+
pad(oldDate.getDate(), 2));
|
|
79695
|
+
}
|
|
79696
|
+
else if (vr === "TM") {
|
|
79697
|
+
var now = new Date();
|
|
79698
|
+
return (pad(now.getHours(), 2) +
|
|
79699
|
+
pad(now.getMinutes(), 2) +
|
|
79700
|
+
pad(now.getSeconds(), 2));
|
|
79701
|
+
}
|
|
79702
|
+
else {
|
|
79703
|
+
return undefined;
|
|
79704
|
+
}
|
|
79705
|
+
};
|
|
80786
79706
|
|
|
80787
79707
|
|
|
80788
79708
|
/***/ }),
|
|
@@ -82061,6 +80981,7 @@ const parseFile = function (file) {
|
|
|
82061
80981
|
imageObject.metadata = metadata;
|
|
82062
80982
|
imageObject.metadata.anonymized = false;
|
|
82063
80983
|
imageObject.metadata.larvitarSeriesInstanceUID = uniqueId;
|
|
80984
|
+
imageObject.metadata.sopClassUID = metadata["x00080016"];
|
|
82064
80985
|
imageObject.metadata.seriesUID = seriesInstanceUID;
|
|
82065
80986
|
imageObject.metadata.instanceUID = instanceUID;
|
|
82066
80987
|
imageObject.metadata.studyUID = metadata["x0020000d"];
|
|
@@ -83956,8 +82877,8 @@ function parseTag(dataSet, propertyName, //x0000000 string
|
|
|
83956
82877
|
element // TODO-ts better type @szanchi
|
|
83957
82878
|
) {
|
|
83958
82879
|
// GET VR
|
|
83959
|
-
var tagData = dataSet.elements[propertyName]
|
|
83960
|
-
var vr = tagData.vr;
|
|
82880
|
+
var tagData = dataSet.elements[propertyName];
|
|
82881
|
+
var vr = tagData === null || tagData === void 0 ? void 0 : tagData.vr;
|
|
83961
82882
|
if (!vr) {
|
|
83962
82883
|
// use dicom dict to get VR
|
|
83963
82884
|
var tag = getDICOMTag(propertyName);
|
|
@@ -88190,7 +87111,7 @@ const isToolMissing = function (toolName) {
|
|
|
88190
87111
|
*/
|
|
88191
87112
|
const addTool = function (toolName, customConfig, targetElementId) {
|
|
88192
87113
|
// extend defaults with user custom props
|
|
88193
|
-
let defaultConfig = default_1.DEFAULT_TOOLS[toolName]
|
|
87114
|
+
let defaultConfig = default_1.DEFAULT_TOOLS[toolName];
|
|
88194
87115
|
(0, lodash_1.extend)(defaultConfig, customConfig);
|
|
88195
87116
|
if (isToolMissing(toolName)) {
|
|
88196
87117
|
const toolClassName = defaultConfig.class;
|
|
@@ -89967,13 +88888,6 @@ function version(uuid) {
|
|
|
89967
88888
|
|
|
89968
88889
|
|
|
89969
88890
|
|
|
89970
|
-
/***/ }),
|
|
89971
|
-
|
|
89972
|
-
/***/ 2480:
|
|
89973
|
-
/***/ (() => {
|
|
89974
|
-
|
|
89975
|
-
/* (ignored) */
|
|
89976
|
-
|
|
89977
88891
|
/***/ }),
|
|
89978
88892
|
|
|
89979
88893
|
/***/ 3848:
|
|
@@ -89995,7 +88909,7 @@ module.exports = JSON.parse('{"x00000000":{"tag":"x00000000","vr":"UL","vm":"1",
|
|
|
89995
88909
|
/***/ ((module) => {
|
|
89996
88910
|
|
|
89997
88911
|
"use strict";
|
|
89998
|
-
module.exports = JSON.parse('{"name":"larvitar","keywords":["DICOM","imaging","medical","cornerstone"],"version":"2.0.
|
|
88912
|
+
module.exports = JSON.parse('{"name":"larvitar","keywords":["DICOM","imaging","medical","cornerstone"],"version":"2.0.4","description":"typescript library for parsing, loading, rendering and interacting with DICOM images","repository":{"url":"https://github.com/dvisionlab/Larvitar.git","type":"git"},"main":"index.ts","scripts":{"coverage":"typescript-coverage-report","generate-docs":"node_modules/.bin/jsdoc -c jsdoc.json","build":"webpack --config ./bundler/webpack.prod.js && cp ./dist/larvitar.js ./docs/examples/larvitar.js","dev":"webpack --progress --config ./bundler/webpack.dev.js && cp ./dist/larvitar.js ./docs/examples/larvitar.js","dev-wip":"webpack serve --config ./bundler/webpack.dev-wip.js"},"author":"Simone Manini <simone.manini@dvisionlab.com> (https://www.dvisionlab.com)","contributors":["Mattia Ronzoni <mattia.ronzoni@dvisionlab.com> (https://www.dvisionlab.com)","Sara Zanchi <sara.zanchi@dvisionlab.com> (https://www.dvisionlab.com)","Ale Re <ale.re@dvisionlab.com> (https://www.dvisionlab.com)","Laura Borghesi Re <laura.borghesi@dvisionlab.com> (https://www.dvisionlab.com)"],"license":"MIT","dependencies":{"@rollup/plugin-commonjs":"^17.1.0","cornerstone-core":"^2.6.1","cornerstone-file-image-loader":"^0.3.0","cornerstone-tools":"^6.0.7","cornerstone-wado-image-loader":"^4.13.2","cornerstone-web-image-loader":"^2.1.1","crypto-js":"^4.1.1","dicom-character-set":"^1.0.3","dicom-parser":"^1.8.13","docdash":"^1.2.0","hammerjs":"^2.0.8","jpeg-lossless-decoder-js":"^2.0.7","keycode-js":"^3.1.0","lodash":"^4.17.15","pako":"^1.0.10","papaparse":"^5.3.0","plotly.js-dist-min":"^2.27.1","uuid":"^8.3.2"},"devDependencies":{"@babel/core":"^7.21.8","@types/cornerstone-core":"^2.3.0","@types/crypto-js":"^4.1.1","@types/hammerjs":"^2.0.41","@types/lodash":"^4.14.192","@types/papaparse":"^5.3.7","@types/plotly.js":"^2.12.30","@types/plotly.js-dist-min":"^2.3.4","@types/uuid":"^9.0.1","babel-loader":"^9.1.2","clean-webpack-plugin":"^4.0.0","copy-webpack-plugin":"^11.0.0","fs":"^0.0.1-security","html-loader":"^4.2.0","html-webpack-plugin":"^5.5.0","ip":"^1.1.8","jsdoc":"^3.6.4","portfinder-sync":"^0.0.2","ts-loader":"^9.4.2","typescript":"^5.0.2","typescript-coverage-report":"^0.7.0","webpack":"^5.76.3","webpack-bundle-analyzer":"^4.8.0","webpack-cli":"^5.0.1","webpack-dev-server":"^4.13.1"}}');
|
|
89999
88913
|
|
|
90000
88914
|
/***/ })
|
|
90001
88915
|
|