1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', {
|
4 | value: true
|
5 | });
|
6 |
|
7 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
8 |
|
9 | var _globalWindow = require('global/window');
|
10 |
|
11 | var _globalWindow2 = _interopRequireDefault(_globalWindow);
|
12 |
|
13 | var _aesDecrypter = require('aes-decrypter');
|
14 |
|
15 | var _binUtils = require('./bin-utils');
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 | var DecrypterWorker = function DecrypterWorker(self) {
|
26 | self.onmessage = function (event) {
|
27 | var data = event.data;
|
28 | var encrypted = new Uint8Array(data.encrypted.bytes, data.encrypted.byteOffset, data.encrypted.byteLength);
|
29 | var key = new Uint32Array(data.key.bytes, data.key.byteOffset, data.key.byteLength / 4);
|
30 | var iv = new Uint32Array(data.iv.bytes, data.iv.byteOffset, data.iv.byteLength / 4);
|
31 |
|
32 |
|
33 | new _aesDecrypter.Decrypter(encrypted, key, iv, function (err, bytes) {
|
34 | _globalWindow2['default'].postMessage((0, _binUtils.createTransferableMessage)({
|
35 | source: data.source,
|
36 | decrypted: bytes
|
37 | }), [bytes.buffer]);
|
38 | });
|
39 |
|
40 | };
|
41 | };
|
42 |
|
43 | exports['default'] = function (self) {
|
44 | return new DecrypterWorker(self);
|
45 | };
|
46 |
|
47 | module.exports = exports['default']; |
\ | No newline at end of file |