This commit is contained in:
2022-07-21 03:28:35 +00:00
parent d7c883d6df
commit 51b34b0e1d
30103 changed files with 4152204 additions and 23 deletions
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 Jun Kurihara
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+143
View File
@@ -0,0 +1,143 @@
Universal Module for AES Encryption and Decryption in JavaScript
--
[![npm version](https://badge.fury.io/js/js-crypto-aes.svg)](https://badge.fury.io/js/js-crypto-aes)
[![Dependencies](https://david-dm.org/junkurihara/jscu.svg?path=packages/js-crypto-aes)](https://david-dm.org/junkurihara/jscu?path=packages/js-crypto-aes)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
> **WARNING**: At this time this solution should be considered suitable for research and experimentation, further code and security review is needed before utilization in a production application.
# Introduction and Overview
This library is designed to 'universally' provide AES encryption and decryption functions, i.e., it works both on most modern browsers and on Node.js just by importing from NPM/source code. Note that in the design principle, the library fully utilizes native APIs like WebCrypto API to accelerate its operation if available.
# Installation
At your project directory, do either one of the following.
- From npm/yarn:
```shell
$ npm install --save js-crypto-aes // npm
$ yarn add js-crypto-aes // yarn
```
- From GitHub:
```shell
$ git clone https://github.com/junkurihara/jscu.git
$ cd js-crypto-utils/packages/js-crypto-aes
& yarn build
```
Then you should import the package as follows.
```shell
import aes from 'js-crypto-aes'; // for npm
import aes from 'path/to/js-crypto-aes/dist/index.js'; // for github
```
The bundled file is also given as `js-crypto-aes/dist/jscaes.bundle.js` for a use case where the module is imported as a `window.jscaes` object via `script` tags.
# Usage
## Encryption in AES-GCM
```javascript
const msg = ...; // arbitrary length of message in Uint8Array
const key = ...; // 16 bytes or 32 bytes key in Uint8Array
const iv = ...; // 12 bytes IV in Uint8Array for AES-GCM mode
const additionalData = ...; // optional AAD
aes.encrypt(msg, key, {name: 'AES-GCM', iv, additionalData, tagLength: 16}).then( (encrypted) => {
// now you get an Uint8Array of encrypted message
});
```
## Decryption in AES-GCM
```javascript
const data = ...; // encryted message in Uint8Array
const key = ...; // 16 bytes or 32 bytes key in Uint8Array
const iv = ...; // 12 bytes IV in Uint8Array for AES-GCM mode that is exactly same as the one used in encryption
const additionalData = ...; // optional AAD
aes.decrypt(data, key, {name: 'AES-GCM', iv, additionalData, tagLength: 16}).then( (decrypted) => {
// now you get an Uint8Array of decrypted message
});
```
## Encryption in AES-CBC
```javascript
const msg = ...; // arbitrary length of message in Uint8Array
const key = ...; // 16 bytes or 32 bytes key in Uint8Array
const iv = ...; // 16 bytes IV in Uint8Array for AES-CBC mode
aes.encrypt(msg, key, {name: 'AES-CBC', iv}).then( (encrypted) => {
// now you get an Uint8Array of encrypted message
});
```
## Decryption in AES-CBC
```javascript
const data = ...; // encryted message in Uint8Array
const key = ...; // 16 bytes or 32 bytes key in Uint8Array
const iv = ...; // 16 bytes IV in Uint8Array for AES-CBC mode that is exactly same as the one used in encryption
aes.decrypt(data, key, {name: 'AES-CBC', iv}).then( (decrypted) => {
// now you get an Uint8Array of decrypted message
});
```
## Encryption in AES-CTR
```javascript
const msg = ...; // arbitrary length of message in Uint8Array
const key = ...; // 16 bytes or 32 bytes key in Uint8Array
const iv = ...; // 12 bytes IV in Uint8Array for AES-CTR mode
aes.encrypt(msg, key, {name: 'AES-CTR', iv}).then( (encrypted) => {
// now you get an Uint8Array of encrypted message
});
```
The counter block will be `iv||00...01`. If `iv.length = 16`, it should be `iv + 1`.
## Decryption in AES-CTR
```javascript
const data = ...; // encryted message in Uint8Array
const key = ...; // 16 bytes or 32 bytes key in Uint8Array
const iv = ...; // 12 bytes IV in Uint8Array for AES-CTR mode that is exactly same as the one used in encryption
aes.decrypt(data, key, {name: 'AES-CTR', iv}).then( (decrypted) => {
// now you get an Uint8Array of decrypted message
});
```
## AES-KW Key Wrapping (RFC3394)
```javascript
const kEK = ...; // Key Encryption Key in 128, 192, 256 bits (192 only in Node.js)
const cEK = ...; // Key to be wrapped of 128, 192, 256 bits (192 only in Node.js)
aes.wrapKey(cEK, kEK, {name: 'AES-KW'}).then( (wrapped) => {
// wrapped key is here
});
```
## AES-KW Key (RFC3394)
```javascript
const kEK = ...; // Key Encryption Key in 128, 192, 256 bits (192 only in Node.js)
const wrapped = ...; // Wrapped key in Uint8Array
aes.unwrapKey(wrapped, kEK, {name: 'AES-KW'}).then( (cEK) => {
// now you get the plaintext key
});
```
# Note
At this point, this module has the following limitations:
- Supports AES-GCM, AES-CBC and AES-CTR modes
- Supports AES-KW with default initial values (unable to change in WebCrypto)
- Supports 128 bits and 256 bits keys in Chrome (192 bits key works in Node.js)
# License
Licensed under the MIT license, see `LICENSE` file.
+427
View File
@@ -0,0 +1,427 @@
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.unwrapKey = exports.wrapKey = exports.decrypt = exports.encrypt = void 0;
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var util = _interopRequireWildcard(require("js-crypto-env"));
var nodeapi = _interopRequireWildcard(require("./nodeapi.js"));
var webapi = _interopRequireWildcard(require("./webapi.js"));
var _params = _interopRequireDefault(require("./params.js"));
/**
* aes.js
*/
/**
* Check if the given algorithm spec is valid.
* @param {String} name - Name of the specified algorithm like 'AES-GCM'.
* @param {Uint8Array} iv - IV byte array if required
* @param {Number} tagLength - Authentication tag length if required
* @throws {Error} - Throws if UnsupportedAlgorithm, InvalidArguments, InvalidIVLength, or InvalidTagLength.
*/
var assertAlgorithms = function assertAlgorithms(_ref) {
var name = _ref.name,
iv = _ref.iv,
tagLength = _ref.tagLength;
if (Object.keys(_params.default.ciphers).indexOf(name) < 0) throw new Error('UnsupportedAlgorithm');
if (_params.default.ciphers[name].ivLength) {
if (!(iv instanceof Uint8Array)) throw new Error('InvalidArguments');
if (iv.byteLength < 2 || iv.byteLength > 16) throw new Error('InvalidIVLength');
if (_params.default.ciphers[name].staticIvLength && _params.default.ciphers[name].ivLength !== iv.byteLength) throw new Error('InvalidIVLength');
}
if (_params.default.ciphers[name].tagLength && tagLength) {
if (!Number.isInteger(tagLength)) throw new Error('InvalidArguments');
if (tagLength < 4 || tagLength > 16) throw new Error('InvalidTagLength');
}
};
/**
* Encrypt data with AES
* @param {Uint8Array} msg - Message to be encrypted.
* @param {Uint8Array} key - The symmetric key used to encrypt the message.
* @param {String} [name = 'AES-GCM'] - Name of the specified algorithm like 'AES-GCM'.
* @param {Uint8Array} [iv] - Byte array of the initial vector if required.
* @param {Uint8Array} [additionalData = new Uint8Array([])] - Byte array of additional data if required.
* @param {Number} [tagLength = params.ciphers[name].tagLength] - Authentication tag length if required.
* @return {Promise<Uint8Array>} - Encrypted message.
* @throws {Error} - Throws if InvalidArguments, FaildToEncryptWeb/Node, or UnsupportedEnvironment (no webcrypto/nodecrypto).
*/
var encrypt =
/*#__PURE__*/
function () {
var _ref3 = (0, _asyncToGenerator2.default)(
/*#__PURE__*/
_regenerator.default.mark(function _callee(msg, key, _ref2) {
var _ref2$name, name, iv, _ref2$additionalData, additionalData, tagLength, webCrypto, nodeCrypto;
return _regenerator.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_ref2$name = _ref2.name, name = _ref2$name === void 0 ? 'AES-GCM' : _ref2$name, iv = _ref2.iv, _ref2$additionalData = _ref2.additionalData, additionalData = _ref2$additionalData === void 0 ? new Uint8Array([]) : _ref2$additionalData, tagLength = _ref2.tagLength;
if (!(!(msg instanceof Uint8Array) || !(key instanceof Uint8Array))) {
_context.next = 3;
break;
}
throw new Error('InvalidArguments');
case 3:
assertAlgorithms({
name: name,
iv: iv,
tagLength: tagLength
});
if (_params.default.ciphers[name].tagLength && !tagLength) tagLength = _params.default.ciphers[name].tagLength;
_context.next = 7;
return util.getWebCryptoAll();
case 7:
webCrypto = _context.sent;
_context.next = 10;
return util.getNodeCrypto();
case 10:
nodeCrypto = _context.sent;
if (!(typeof webCrypto !== 'undefined' && typeof webCrypto.importKey === 'function' && typeof webCrypto.encrypt === 'function')) {
_context.next = 15;
break;
}
return _context.abrupt("return", webapi.encrypt(msg, key, {
name: name,
iv: iv,
additionalData: additionalData,
tagLength: tagLength
}, webCrypto));
case 15:
if (!(typeof nodeCrypto !== 'undefined')) {
_context.next = 19;
break;
}
return _context.abrupt("return", nodeapi.encrypt(msg, key, {
name: name,
iv: iv,
additionalData: additionalData,
tagLength: tagLength
}, nodeCrypto));
case 19:
throw new Error('UnsupportedEnvironment');
case 20:
case "end":
return _context.stop();
}
}
}, _callee);
}));
return function encrypt(_x, _x2, _x3) {
return _ref3.apply(this, arguments);
};
}();
/**
* Decrypt data with AES
* @param {Uint8Array} data - Byte array of encrypted data.
* @param {Uint8Array} key - Byte array of symmetric key to be used for decryption.
* @param {String} [name = 'AES-GCM'] - Name of the specified algorithm like 'AES-GCM'.
* @param {Uint8Array} [iv] - Byte array of the initial vector if required.
* @param {Uint8Array} [additionalData = new Uint8Array([])] - Byte array of additional data if required.
* @param {Number} [tagLength = params.ciphers[name].tagLength] - Authentication tag length if required.
* @return {Promise<Uint8Array>} - Decrypted plaintext message.
* @throws {Error} - Throws if InvalidArguments, FailedToDecryptWeb/Node, or UnsupportedEnvironment (no webcrypto/nodecrypto).
*/
exports.encrypt = encrypt;
var decrypt =
/*#__PURE__*/
function () {
var _ref5 = (0, _asyncToGenerator2.default)(
/*#__PURE__*/
_regenerator.default.mark(function _callee2(data, key, _ref4) {
var _ref4$name, name, iv, _ref4$additionalData, additionalData, tagLength, webCrypto, nodeCrypto;
return _regenerator.default.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_ref4$name = _ref4.name, name = _ref4$name === void 0 ? 'AES-GCM' : _ref4$name, iv = _ref4.iv, _ref4$additionalData = _ref4.additionalData, additionalData = _ref4$additionalData === void 0 ? new Uint8Array([]) : _ref4$additionalData, tagLength = _ref4.tagLength;
if (!(!(data instanceof Uint8Array) || !(key instanceof Uint8Array))) {
_context2.next = 3;
break;
}
throw new Error('InvalidArguments');
case 3:
assertAlgorithms({
name: name,
iv: iv,
tagLength: tagLength
});
if (_params.default.ciphers[name].tagLength && !tagLength) tagLength = _params.default.ciphers[name].tagLength;
_context2.next = 7;
return util.getWebCryptoAll();
case 7:
webCrypto = _context2.sent;
_context2.next = 10;
return util.getNodeCrypto();
case 10:
nodeCrypto = _context2.sent;
if (!(typeof webCrypto !== 'undefined' && typeof webCrypto.importKey === 'function' && typeof webCrypto.encrypt === 'function')) {
_context2.next = 15;
break;
}
return _context2.abrupt("return", webapi.decrypt(data, key, {
name: name,
iv: iv,
additionalData: additionalData,
tagLength: tagLength
}, webCrypto));
case 15:
if (!(typeof nodeCrypto !== 'undefined')) {
_context2.next = 19;
break;
}
return _context2.abrupt("return", nodeapi.decrypt(data, key, {
name: name,
iv: iv,
additionalData: additionalData,
tagLength: tagLength
}, nodeCrypto));
case 19:
throw new Error('UnsupportedEnvironment');
case 20:
case "end":
return _context2.stop();
}
}
}, _callee2);
}));
return function decrypt(_x4, _x5, _x6) {
return _ref5.apply(this, arguments);
};
}();
/**
* AES-KW wrapping
* @param keyToBeWrapped {Uint8Array} - key bytes to be wrapped
* @param wrappingKey {Uint8Array} - wrapping key encryption key
* @param name {'AES-KW'} - this is simply for future extension
* @return {Promise<Uint8Array>} - output wrapped key
*/
exports.decrypt = decrypt;
var wrapKey =
/*#__PURE__*/
function () {
var _ref7 = (0, _asyncToGenerator2.default)(
/*#__PURE__*/
_regenerator.default.mark(function _callee3(keyToBeWrapped, wrappingKey, _ref6) {
var _ref6$name, name, webCrypto, nodeCrypto, iv;
return _regenerator.default.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_ref6$name = _ref6.name, name = _ref6$name === void 0 ? 'AES-KW' : _ref6$name;
if (keyToBeWrapped instanceof Uint8Array) {
_context3.next = 3;
break;
}
throw new Error('NonUint8ArrayData');
case 3:
if (wrappingKey instanceof Uint8Array) {
_context3.next = 5;
break;
}
throw new Error('NonUint8ArrayKey');
case 5:
if (!(keyToBeWrapped.length % 8 > 0)) {
_context3.next = 7;
break;
}
throw new Error('WrappedKeyMustBeMultipleOf8');
case 7:
_context3.next = 9;
return util.getWebCryptoAll();
case 9:
webCrypto = _context3.sent;
_context3.next = 12;
return util.getNodeCrypto();
case 12:
nodeCrypto = _context3.sent;
// node crypto
iv = _params.default.wrapKeys['AES-KW'].defaultIV;
if (!(typeof webCrypto !== 'undefined' && typeof webCrypto.importKey === 'function' && typeof webCrypto.wrapKey === 'function')) {
_context3.next = 18;
break;
}
return _context3.abrupt("return", webapi.wrapKey(keyToBeWrapped, wrappingKey, {
name: name,
iv: iv
}, webCrypto));
case 18:
if (!(typeof nodeCrypto !== 'undefined')) {
_context3.next = 22;
break;
}
return _context3.abrupt("return", nodeapi.wrapKey(keyToBeWrapped, wrappingKey, {
name: name,
iv: iv
}, nodeCrypto));
case 22:
throw new Error('UnsupportedEnvironment');
case 23:
case "end":
return _context3.stop();
}
}
}, _callee3);
}));
return function wrapKey(_x7, _x8, _x9) {
return _ref7.apply(this, arguments);
};
}();
/**
* AES-KW unwrapping
* @param wrappedKey {Uint8Array} - wrapped key bytes
* @param wrappingKey {Uint8Array} - wrapping key encryption key
* @param name {'AES-KW'} - this is simply for future extension
* @return {Promise<Uint8Array>} - output unwrapped key
*/
exports.wrapKey = wrapKey;
var unwrapKey =
/*#__PURE__*/
function () {
var _ref9 = (0, _asyncToGenerator2.default)(
/*#__PURE__*/
_regenerator.default.mark(function _callee4(wrappedKey, wrappingKey, _ref8) {
var _ref8$name, name, webCrypto, nodeCrypto, iv;
return _regenerator.default.wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
_ref8$name = _ref8.name, name = _ref8$name === void 0 ? 'AES-KW' : _ref8$name;
if (wrappedKey instanceof Uint8Array) {
_context4.next = 3;
break;
}
throw new Error('NonUint8ArrayData');
case 3:
if (wrappingKey instanceof Uint8Array) {
_context4.next = 5;
break;
}
throw new Error('NonUint8ArrayKey');
case 5:
_context4.next = 7;
return util.getWebCryptoAll();
case 7:
webCrypto = _context4.sent;
_context4.next = 10;
return util.getNodeCrypto();
case 10:
nodeCrypto = _context4.sent;
// node crypto
iv = _params.default.wrapKeys['AES-KW'].defaultIV;
if (!(typeof webCrypto !== 'undefined' && typeof webCrypto.importKey === 'function' && typeof webCrypto.wrapKey === 'function')) {
_context4.next = 16;
break;
}
return _context4.abrupt("return", webapi.unwrapKey(wrappedKey, wrappingKey, {
name: name,
iv: iv
}, webCrypto));
case 16:
if (!(typeof nodeCrypto !== 'undefined')) {
_context4.next = 20;
break;
}
return _context4.abrupt("return", nodeapi.unwrapKey(wrappedKey, wrappingKey, {
name: name,
iv: iv
}, nodeCrypto));
case 20:
throw new Error('UnsupportedEnvironment');
case 21:
case "end":
return _context4.stop();
}
}
}, _callee4);
}));
return function unwrapKey(_x10, _x11, _x12) {
return _ref9.apply(this, arguments);
};
}();
exports.unwrapKey = unwrapKey;
+43
View File
@@ -0,0 +1,43 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "encrypt", {
enumerable: true,
get: function get() {
return _aes.encrypt;
}
});
Object.defineProperty(exports, "decrypt", {
enumerable: true,
get: function get() {
return _aes.decrypt;
}
});
Object.defineProperty(exports, "wrapKey", {
enumerable: true,
get: function get() {
return _aes.wrapKey;
}
});
Object.defineProperty(exports, "unwrapKey", {
enumerable: true,
get: function get() {
return _aes.unwrapKey;
}
});
exports.default = void 0;
var _aes = require("./aes.js");
/**
* index.js
*/
var _default = {
encrypt: _aes.encrypt,
decrypt: _aes.decrypt,
wrapKey: _aes.wrapKey,
unwrapKey: _aes.unwrapKey
};
exports.default = _default;
File diff suppressed because one or more lines are too long
+219
View File
@@ -0,0 +1,219 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.decrypt = exports.encrypt = exports.unwrapKey = exports.wrapKey = void 0;
var _params = _interopRequireDefault(require("./params.js"));
/**
* nodeapi.js
*/
/**
* Node.js KeyWrapping function simply uses encrypt function.
* @param keyToBeWrapped {Uint8Array} - plaintext key
* @param wrappingKey {Uint8Array} - wrapping key
* @param name {string} - 'AES-KW'
* @param iv {Uint8Array} - default is '0xA6A6A6A6A6A6A6A6'
* @param nodeCrypto {Object} - NodeCrypto object
* @return {Uint8Array} - Unwrapped Key
*/
var wrapKey = function wrapKey(keyToBeWrapped, wrappingKey, _ref, nodeCrypto) {
var _ref$name = _ref.name,
name = _ref$name === void 0 ? 'AES-KW' : _ref$name,
iv = _ref.iv;
return encrypt(keyToBeWrapped, wrappingKey, {
name: name,
iv: iv
}, nodeCrypto, true);
};
/**
* Node.js KeyUnwrapping function as well as keyWrapping
* @param wrappedKey {Uint8Array} - Wrapped key
* @param unwrappingKey {Uint8Array} - Key used for wrapping
* @param name {string} - 'AES-KW'
* @param iv {Uint8Array} - default is '0xA6A6A6A6A6A6A6A6'
* @param nodeCrypto {Object} - NodeCrypto object
* @return {Uint8Array} - Unwrapped Key
*/
exports.wrapKey = wrapKey;
var unwrapKey = function unwrapKey(wrappedKey, unwrappingKey, _ref2, nodeCrypto) {
var _ref2$name = _ref2.name,
name = _ref2$name === void 0 ? 'AES-KW' : _ref2$name,
iv = _ref2.iv;
return decrypt(wrappedKey, unwrappingKey, {
name: name,
iv: iv
}, nodeCrypto, true);
};
/**
* Encrypt plaintext message via AES Node.js crypto API
* @param {Uint8Array} msg - Plaintext message to be encrypted.
* @param {Uint8Array} key - Byte array of symmetric key.
* @param {String} name - Name of AES algorithm like 'AES-GCM'.
* @param {Uint8Array} [iv] - Byte array of initial vector if required.
* @param {Uint8Array} [additionalData] - Byte array of additional data if required.
* @param {Number} [tagLength] - Authentication tag length if required.
* @param {Object} nodeCrypto - NodeCrypto object, i.e., require(crypto) in Node.js.
* @param wrapKey {Boolean} [false] - true if called as AES-KW
* @return {Uint8Array} - Encrypted message byte array.
* @throws {Error} - Throws error if UnsupportedCipher.
*/
exports.unwrapKey = unwrapKey;
var encrypt = function encrypt(msg, key, _ref3, nodeCrypto) {
var name = _ref3.name,
iv = _ref3.iv,
additionalData = _ref3.additionalData,
tagLength = _ref3.tagLength;
var wrapKey = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
var alg = getNodeName(name, key.byteLength, wrapKey ? _params.default.wrapKeys : _params.default.ciphers);
var cipher;
switch (name) {
case 'AES-GCM':
{
cipher = nodeCrypto.createCipheriv(alg, key, iv, {
authTagLength: tagLength
});
cipher.setAAD(additionalData);
break;
}
case 'AES-CTR':
{
if (iv.length === 0 || iv.length > 16) throw new Error('InvalidIVLength');
var counter = new Uint8Array(16);
counter.set(iv);
counter[15] += 1;
cipher = nodeCrypto.createCipheriv(alg, key, counter);
break;
}
default:
{
// AES-CBC or AES-KW
cipher = nodeCrypto.createCipheriv(alg, key, iv);
break;
}
}
var body;
var final;
var tag;
try {
body = new Uint8Array(cipher.update(msg));
final = new Uint8Array(cipher.final());
tag = new Uint8Array([]);
if (name === 'AES-GCM') tag = new Uint8Array(cipher.getAuthTag());
} catch (e) {
throw new Error('NodeCrypto_EncryptionFailure');
}
var data = new Uint8Array(body.length + final.length + tag.length);
data.set(body);
data.set(final, body.length);
data.set(tag, body.length + final.length);
return data;
};
/**
* Decrypt data through AES Node.js crypto API.
* @param {Uint8Array} data - Encrypted message to be decrypted.
* @param {Uint8Array} key - Byte array of symmetric key.
* @param {String} name - Name of AES algorithm like 'AES-GCM'.
* @param {Uint8Array} [iv] - Byte array of initial vector if required.
* @param {Uint8Array} [additionalData] - Byte array of additional data if required.
* @param {Number} [tagLength] - Authentication tag length if required.
* @param {Object} nodeCrypto - NodeCrypto object, i.e., require(crypto) in Node.js.
* @return {Uint8Array} - Decrypted message byte array.
* @param unwrapKey {Boolean} [false] - true if called as AES-KW
* @throws {Error} - Throws error if UnsupportedCipher or DecryptionFailure.
*/
exports.encrypt = encrypt;
var decrypt = function decrypt(data, key, _ref4, nodeCrypto) {
var name = _ref4.name,
iv = _ref4.iv,
additionalData = _ref4.additionalData,
tagLength = _ref4.tagLength;
var unwrapKey = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
var alg = getNodeName(name, key.byteLength, unwrapKey ? _params.default.wrapKeys : _params.default.ciphers);
var decipher;
var body;
switch (name) {
case 'AES-GCM':
{
decipher = nodeCrypto.createDecipheriv(alg, key, iv, {
authTagLength: tagLength
});
decipher.setAAD(additionalData);
body = data.slice(0, data.length - tagLength);
var tag = data.slice(data.length - tagLength);
decipher.setAuthTag(tag);
break;
}
case 'AES-CTR':
{
if (iv.length === 0 || iv.length > 16) throw new Error('InvalidIVLength');
var counter = new Uint8Array(16);
counter.set(iv);
counter[15] += 1;
decipher = nodeCrypto.createDecipheriv(alg, key, counter);
body = data;
break;
}
default:
{
// AES-CBC or AES-KW
decipher = nodeCrypto.createDecipheriv(alg, key, iv);
body = data;
break;
}
}
var decryptedBody;
var final;
try {
decryptedBody = decipher.update(body);
final = decipher.final();
} catch (e) {
throw new Error('NodeCrypto_DecryptionFailure');
}
var msg = new Uint8Array(final.length + decryptedBody.length);
msg.set(decryptedBody);
msg.set(final, decryptedBody.length);
return msg;
};
/**
* get node algorithm name
* @param name {string} - name of webcrypto alg like AES-GCM
* @param keyLength {number} - aes encryption key
* @param dict {object} - params.ciphers or params.wrapKeys
* @return {string} - node algorithm name
*/
exports.decrypt = decrypt;
var getNodeName = function getNodeName(name, keyLength, dict) {
var alg = dict[name].nodePrefix;
alg = "".concat(alg).concat((keyLength * 8).toString());
return alg + dict[name].nodeSuffix;
};
+48
View File
@@ -0,0 +1,48 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
/**
* params.js
*/
var _default = {
// encryption parameters
ciphers: {
'AES-GCM': {
nodePrefix: 'aes-',
nodeSuffix: '-gcm',
ivLength: 12,
// default value of iv length, 12 bytes is recommended for AES-GCM
tagLength: 16,
staticIvLength: true // if true, IV length must be always ivLength.
},
'AES-CBC': {
nodePrefix: 'aes-',
nodeSuffix: '-cbc',
ivLength: 16,
staticIvLength: true
},
'AES-CTR': {
nodePrefix: 'aes-',
nodeSuffix: '-ctr',
ivLength: 12,
// default value
staticIvLength: false
}
},
// key wrapping parameters
wrapKeys: {
'AES-KW': {
nodePrefix: 'id-aes',
nodeSuffix: '-wrap',
ivLength: 8,
staticIvLength: true,
defaultIV: new Uint8Array([0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6])
}
}
};
exports.default = _default;
+501
View File
@@ -0,0 +1,501 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.decrypt = exports.encrypt = exports.unwrapKey = exports.wrapKey = void 0;
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
/**
* webapi.js
*/
/**
* WebCrypto KeyWrapping function simply uses encrypt function.
* @param keyToBeWrapped {Uint8Array} - plaintext key
* @param wrappingKey {Uint8Array} - wrapping key
* @param name {string} - 'AES-KW'
* @param iv {Uint8Array} - default is '0xA6A6A6A6A6A6A6A6'
* @param nodeCrypto {Object} - crypto.subtle object
* @return {Uint8Array} - Unwrapped Key
*/
var wrapKey =
/*#__PURE__*/
function () {
var _ref2 = (0, _asyncToGenerator2.default)(
/*#__PURE__*/
_regenerator.default.mark(function _callee(keyToBeWrapped, wrappingKey, _ref, webCrypto) {
var _ref$name, name, iv, kek, cek, data;
return _regenerator.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_ref$name = _ref.name, name = _ref$name === void 0 ? 'AES-KW' : _ref$name, iv = _ref.iv;
if (!(typeof window.msCrypto === 'undefined')) {
_context.next = 20;
break;
}
_context.prev = 2;
_context.next = 5;
return webCrypto.importKey('raw', wrappingKey, {
name: name
}, false, ['wrapKey', 'unwrapKey']);
case 5:
kek = _context.sent;
_context.next = 8;
return webCrypto.importKey('raw', keyToBeWrapped, {
name: name
}, true, ['wrapKey', 'unwrapKey']);
case 8:
cek = _context.sent;
_context.next = 11;
return webCrypto.wrapKey('raw', cek, kek, {
name: name,
iv: iv
});
case 11:
data = _context.sent;
return _context.abrupt("return", new Uint8Array(data));
case 15:
_context.prev = 15;
_context.t0 = _context["catch"](2);
throw new Error("WebCrypto_FailedToWrapKey - ".concat(_context.t0.message));
case 18:
_context.next = 21;
break;
case 20:
throw new Error('ThrowAwayIeAsap');
case 21:
case "end":
return _context.stop();
}
}
}, _callee, null, [[2, 15]]);
}));
return function wrapKey(_x, _x2, _x3, _x4) {
return _ref2.apply(this, arguments);
};
}();
/**
* WebCrypto KeyUnwrapping function as well as keyWrapping
* @param wrappedKey {Uint8Array} - Wrapped key
* @param unwrappingKey {Uint8Array} - Key used for wrapping
* @param name {string} - 'AES-KW'
* @param iv {Uint8Array} - default is '0xA6A6A6A6A6A6A6A6'
* @param nodeCrypto {Object} - crypto.subtle object
* @return {Uint8Array} - Unwrapped Key
*/
exports.wrapKey = wrapKey;
var unwrapKey =
/*#__PURE__*/
function () {
var _ref4 = (0, _asyncToGenerator2.default)(
/*#__PURE__*/
_regenerator.default.mark(function _callee2(wrappedKey, unwrappingKey, _ref3, webCrypto) {
var _ref3$name, name, iv, kek, cek;
return _regenerator.default.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_ref3$name = _ref3.name, name = _ref3$name === void 0 ? 'AES-KW' : _ref3$name, iv = _ref3.iv;
if (!(typeof window.msCrypto === 'undefined')) {
_context2.next = 21;
break;
}
_context2.prev = 2;
_context2.next = 5;
return webCrypto.importKey('raw', unwrappingKey, {
name: name
}, false, ['wrapKey', 'unwrapKey']);
case 5:
kek = _context2.sent;
_context2.next = 8;
return webCrypto.unwrapKey('raw', wrappedKey, kek, {
name: name,
iv: iv
}, {
name: 'AES-GCM'
}, true, ['encrypt', 'decrypt']);
case 8:
cek = _context2.sent;
_context2.t0 = Uint8Array;
_context2.next = 12;
return webCrypto.exportKey('raw', cek);
case 12:
_context2.t1 = _context2.sent;
return _context2.abrupt("return", new _context2.t0(_context2.t1));
case 16:
_context2.prev = 16;
_context2.t2 = _context2["catch"](2);
throw new Error("WebCrypto_FailedToUnwrapKey - ".concat(_context2.t2.message));
case 19:
_context2.next = 22;
break;
case 21:
throw new Error('ThrowAwayMsIeAsap');
case 22:
case "end":
return _context2.stop();
}
}
}, _callee2, null, [[2, 16]]);
}));
return function unwrapKey(_x5, _x6, _x7, _x8) {
return _ref4.apply(this, arguments);
};
}();
/**
* Encrypt data through AES of WebCrypto API.
* @param {Uint8Array} msg - Plaintext message to be encrypted.
* @param {Uint8Array} key - Byte array of symmetric key.
* @param {String} name - Name of AES algorithm like 'AES-GCM'.
* @param {Uint8Array} [iv] - Byte array of initial vector if required.
* @param {Uint8Array} [additionalData] - Byte array of additional data if required.
* @param {Number} [tagLength] - Authentication tag length if required.
* @param {Object} webCrypto - WebCrypto object, i.e., window.crypto.subtle or window.msCrypto.subtle
* @return {Promise<Uint8Array>} - Encrypted data byte array.
* @throws {Error} - Throws if UnsupportedCipher.
*/
exports.unwrapKey = unwrapKey;
var encrypt =
/*#__PURE__*/
function () {
var _ref6 = (0, _asyncToGenerator2.default)(
/*#__PURE__*/
_regenerator.default.mark(function _callee3(msg, key, _ref5, webCrypto) {
var _ref5$name, name, iv, additionalData, tagLength, encryptionConfig, sessionKeyObj, data, _sessionKeyObj, encryptedObj, _data;
return _regenerator.default.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_ref5$name = _ref5.name, name = _ref5$name === void 0 ? 'AES-GCM' : _ref5$name, iv = _ref5.iv, additionalData = _ref5.additionalData, tagLength = _ref5.tagLength;
encryptionConfig = setCipherParams({
name: name,
iv: iv,
additionalData: additionalData,
tagLength: tagLength
});
if (!(typeof window.msCrypto === 'undefined')) {
_context3.next = 18;
break;
}
_context3.prev = 3;
_context3.next = 6;
return webCrypto.importKey('raw', key, encryptionConfig, false, ['encrypt', 'decrypt']);
case 6:
sessionKeyObj = _context3.sent;
_context3.next = 9;
return webCrypto.encrypt(encryptionConfig, sessionKeyObj, msg);
case 9:
data = _context3.sent;
return _context3.abrupt("return", new Uint8Array(data));
case 13:
_context3.prev = 13;
_context3.t0 = _context3["catch"](3);
throw new Error("WebCrypto_EncryptionFailure: ".concat(_context3.t0.message));
case 16:
_context3.next = 38;
break;
case 18:
_context3.prev = 18;
_context3.next = 21;
return msImportKey('raw', key, encryptionConfig, false, ['encrypt', 'decrypt'], webCrypto);
case 21:
_sessionKeyObj = _context3.sent;
_context3.next = 24;
return msEncrypt(encryptionConfig, _sessionKeyObj, msg, webCrypto);
case 24:
encryptedObj = _context3.sent;
if (!(name === 'AES-GCM')) {
_context3.next = 32;
break;
}
_data = new Uint8Array(encryptedObj.ciphertext.byteLength + encryptedObj.tag.byteLength);
_data.set(new Uint8Array(encryptedObj.ciphertext));
_data.set(new Uint8Array(encryptedObj.tag), encryptedObj.ciphertext.byteLength);
return _context3.abrupt("return", _data);
case 32:
return _context3.abrupt("return", new Uint8Array(encryptedObj));
case 33:
_context3.next = 38;
break;
case 35:
_context3.prev = 35;
_context3.t1 = _context3["catch"](18);
throw new Error("ThrowAwayMsIeAsap: ".concat(_context3.t1.message));
case 38:
case "end":
return _context3.stop();
}
}
}, _callee3, null, [[3, 13], [18, 35]]);
}));
return function encrypt(_x9, _x10, _x11, _x12) {
return _ref6.apply(this, arguments);
};
}();
/**
* Decrypt data through AES of WebCrypto API.
* @param {Uint8Array} data - Encrypted message to be decrypted.
* @param {Uint8Array} key - Byte array of symmetric key.
* @param {String} name - Name of AES algorithm like 'AES-GCM'.
* @param {Uint8Array} [iv] - Byte array of initial vector if required.
* @param {Uint8Array} [additionalData] - Byte array of additional data if required.
* @param {Number} [tagLength] - Authentication tag length if required.
* @param {Object} webCrypto - WebCrypto object, i.e., window.crypto.subtle or window.msCrypto.subtle
* @return {Promise<Uint8Array>} - Decrypted plaintext message.
* @throws {Error} - Throws if UnsupportedCipher or DecryptionFailure.
*/
exports.encrypt = encrypt;
var decrypt =
/*#__PURE__*/
function () {
var _ref8 = (0, _asyncToGenerator2.default)(
/*#__PURE__*/
_regenerator.default.mark(function _callee4(data, key, _ref7, webCrypto) {
var name, iv, additionalData, tagLength, decryptionConfig, sessionKeyObj, msg, _sessionKeyObj2, _msg, ciphertext, tag;
return _regenerator.default.wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
name = _ref7.name, iv = _ref7.iv, additionalData = _ref7.additionalData, tagLength = _ref7.tagLength;
decryptionConfig = setCipherParams({
name: name,
iv: iv,
additionalData: additionalData,
tagLength: tagLength
});
if (window.msCrypto) {
_context4.next = 18;
break;
}
_context4.prev = 3;
_context4.next = 6;
return webCrypto.importKey('raw', key, decryptionConfig, false, ['encrypt', 'decrypt']);
case 6:
sessionKeyObj = _context4.sent;
_context4.next = 9;
return webCrypto.decrypt(decryptionConfig, sessionKeyObj, data);
case 9:
msg = _context4.sent;
return _context4.abrupt("return", new Uint8Array(msg));
case 13:
_context4.prev = 13;
_context4.t0 = _context4["catch"](3);
throw new Error("WebCrypto_DecryptionFailure: ".concat(_context4.t0.message));
case 16:
_context4.next = 39;
break;
case 18:
_context4.prev = 18;
_context4.next = 21;
return msImportKey('raw', key, decryptionConfig, false, ['encrypt', 'decrypt'], webCrypto);
case 21:
_sessionKeyObj2 = _context4.sent;
if (!(name === 'AES-GCM')) {
_context4.next = 30;
break;
}
ciphertext = data.slice(0, data.length - tagLength);
tag = data.slice(data.length - tagLength, data.length);
_context4.next = 27;
return msDecrypt(Object.assign(decryptionConfig, {
tag: tag
}), _sessionKeyObj2, ciphertext, webCrypto);
case 27:
_msg = _context4.sent;
_context4.next = 33;
break;
case 30:
_context4.next = 32;
return msDecrypt(decryptionConfig, _sessionKeyObj2, data, webCrypto);
case 32:
_msg = _context4.sent;
case 33:
return _context4.abrupt("return", new Uint8Array(_msg));
case 36:
_context4.prev = 36;
_context4.t1 = _context4["catch"](18);
throw new Error("ThrowAwayMsIeAsap: ".concat(_context4.t1.message));
case 39:
case "end":
return _context4.stop();
}
}
}, _callee4, null, [[3, 13], [18, 36]]);
}));
return function decrypt(_x13, _x14, _x15, _x16) {
return _ref8.apply(this, arguments);
};
}();
/**
* Set params for encryption algorithms.
* @param {String} name - Name of AES algorithm like 'AES-GCM'.
* @param {Uint8Array} [iv] - Byte array of initial vector if required.
* @param {Uint8Array} [additionalData] - Byte array of additional data if required.
* @param {Number} [tagLength] - Authentication tag length if required.
*/
exports.decrypt = decrypt;
var setCipherParams = function setCipherParams(_ref9) {
var name = _ref9.name,
iv = _ref9.iv,
additionalData = _ref9.additionalData,
tagLength = _ref9.tagLength;
var alg = {};
switch (name) {
case 'AES-GCM':
{
Object.assign(alg, {
name: name,
iv: iv,
tagLength: tagLength * 8
});
Object.assign(alg, additionalData.length > 0 ? {
additionalData: additionalData
} : {});
break;
}
case 'AES-CBC':
{
alg.name = name;
alg.iv = iv;
break;
}
case 'AES-CTR':
{
if (iv.length === 0 || iv.length > 16) throw new Error('InvalidIVLength');
alg.name = name;
alg.counter = new Uint8Array(16);
alg.counter.set(iv);
alg.counter[15] += 1;
alg.length = 128; // todo: this might be (16 - iv.length) * 8.
break;
}
}
return alg;
}; // function definitions for IE
var msImportKey = function msImportKey(type, key, alg, ext, use, webCrypto) {
return new Promise(function (resolve, reject) {
var op = webCrypto.importKey(type, key, alg, ext, use);
op.oncomplete = function (evt) {
resolve(evt.target.result);
};
op.onerror = function () {
reject('KeyImportingFailed');
};
});
};
var msEncrypt = function msEncrypt(alg, key, msg, webCrypto) {
return new Promise(function (resolve, reject) {
var op = webCrypto.encrypt(alg, key, msg);
op.oncomplete = function (evt) {
resolve(evt.target.result);
};
op.onerror = function () {
reject('EncryptionFailure');
};
});
};
var msDecrypt = function msDecrypt(alg, key, data, webCrypto) {
return new Promise(function (resolve, reject) {
var op = webCrypto.decrypt(alg, key, data);
op.oncomplete = function (evt) {
resolve(evt.target.result);
};
op.onerror = function () {
reject('DecryptionFailure');
};
});
};
+22
View File
@@ -0,0 +1,22 @@
MIT License
Copyright (c) 2014-present Sebastian McKenzie and other contributors
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+19
View File
@@ -0,0 +1,19 @@
# @babel/runtime
> babel's modular runtime helpers
See our website [@babel/runtime](https://babeljs.io/docs/en/next/babel-runtime.html) for more information.
## Install
Using npm:
```sh
npm install --save @babel/runtime
```
or using yarn:
```sh
yarn add @babel/runtime
```
@@ -0,0 +1,100 @@
var AwaitValue = require("./AwaitValue");
function AsyncGenerator(gen) {
var front, back;
function send(key, arg) {
return new Promise(function (resolve, reject) {
var request = {
key: key,
arg: arg,
resolve: resolve,
reject: reject,
next: null
};
if (back) {
back = back.next = request;
} else {
front = back = request;
resume(key, arg);
}
});
}
function resume(key, arg) {
try {
var result = gen[key](arg);
var value = result.value;
var wrappedAwait = value instanceof AwaitValue;
Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) {
if (wrappedAwait) {
resume("next", arg);
return;
}
settle(result.done ? "return" : "normal", arg);
}, function (err) {
resume("throw", err);
});
} catch (err) {
settle("throw", err);
}
}
function settle(type, value) {
switch (type) {
case "return":
front.resolve({
value: value,
done: true
});
break;
case "throw":
front.reject(value);
break;
default:
front.resolve({
value: value,
done: false
});
break;
}
front = front.next;
if (front) {
resume(front.key, front.arg);
} else {
back = null;
}
}
this._invoke = send;
if (typeof gen["return"] !== "function") {
this["return"] = undefined;
}
}
if (typeof Symbol === "function" && Symbol.asyncIterator) {
AsyncGenerator.prototype[Symbol.asyncIterator] = function () {
return this;
};
}
AsyncGenerator.prototype.next = function (arg) {
return this._invoke("next", arg);
};
AsyncGenerator.prototype["throw"] = function (arg) {
return this._invoke("throw", arg);
};
AsyncGenerator.prototype["return"] = function (arg) {
return this._invoke("return", arg);
};
module.exports = AsyncGenerator;
@@ -0,0 +1,5 @@
function _AwaitValue(value) {
this.wrapped = value;
}
module.exports = _AwaitValue;
@@ -0,0 +1,30 @@
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {
var desc = {};
Object.keys(descriptor).forEach(function (key) {
desc[key] = descriptor[key];
});
desc.enumerable = !!desc.enumerable;
desc.configurable = !!desc.configurable;
if ('value' in desc || desc.initializer) {
desc.writable = true;
}
desc = decorators.slice().reverse().reduce(function (desc, decorator) {
return decorator(target, property, desc) || desc;
}, desc);
if (context && desc.initializer !== void 0) {
desc.value = desc.initializer ? desc.initializer.call(context) : void 0;
desc.initializer = undefined;
}
if (desc.initializer === void 0) {
Object.defineProperty(target, property, desc);
desc = null;
}
return desc;
}
module.exports = _applyDecoratedDescriptor;
@@ -0,0 +1,5 @@
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
module.exports = _arrayWithHoles;
@@ -0,0 +1,11 @@
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {
arr2[i] = arr[i];
}
return arr2;
}
}
module.exports = _arrayWithoutHoles;
@@ -0,0 +1,9 @@
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
module.exports = _assertThisInitialized;
@@ -0,0 +1,53 @@
function _asyncGeneratorDelegate(inner, awaitWrap) {
var iter = {},
waiting = false;
function pump(key, value) {
waiting = true;
value = new Promise(function (resolve) {
resolve(inner[key](value));
});
return {
done: false,
value: awaitWrap(value)
};
}
;
if (typeof Symbol === "function" && Symbol.iterator) {
iter[Symbol.iterator] = function () {
return this;
};
}
iter.next = function (value) {
if (waiting) {
waiting = false;
return value;
}
return pump("next", value);
};
if (typeof inner["throw"] === "function") {
iter["throw"] = function (value) {
if (waiting) {
waiting = false;
throw value;
}
return pump("throw", value);
};
}
if (typeof inner["return"] === "function") {
iter["return"] = function (value) {
return pump("return", value);
};
}
return iter;
}
module.exports = _asyncGeneratorDelegate;
@@ -0,0 +1,19 @@
function _asyncIterator(iterable) {
var method;
if (typeof Symbol !== "undefined") {
if (Symbol.asyncIterator) {
method = iterable[Symbol.asyncIterator];
if (method != null) return method.call(iterable);
}
if (Symbol.iterator) {
method = iterable[Symbol.iterator];
if (method != null) return method.call(iterable);
}
}
throw new TypeError("Object is not async iterable");
}
module.exports = _asyncIterator;
@@ -0,0 +1,37 @@
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
module.exports = _asyncToGenerator;
@@ -0,0 +1,7 @@
var AwaitValue = require("./AwaitValue");
function _awaitAsyncGenerator(value) {
return new AwaitValue(value);
}
module.exports = _awaitAsyncGenerator;
@@ -0,0 +1,7 @@
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
module.exports = _classCallCheck;
@@ -0,0 +1,5 @@
function _classNameTDZError(name) {
throw new Error("Class \"" + name + "\" cannot be referenced in computed property keys.");
}
module.exports = _classNameTDZError;
@@ -0,0 +1,28 @@
function _classPrivateFieldDestructureSet(receiver, privateMap) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to set private field on non-instance");
}
var descriptor = privateMap.get(receiver);
if (descriptor.set) {
if (!("__destrObj" in descriptor)) {
descriptor.__destrObj = {
set value(v) {
descriptor.set.call(receiver, v);
}
};
}
return descriptor.__destrObj;
} else {
if (!descriptor.writable) {
throw new TypeError("attempted to set read only private field");
}
return descriptor;
}
}
module.exports = _classPrivateFieldDestructureSet;
@@ -0,0 +1,15 @@
function _classPrivateFieldGet(receiver, privateMap) {
var descriptor = privateMap.get(receiver);
if (!descriptor) {
throw new TypeError("attempted to get private field on non-instance");
}
if (descriptor.get) {
return descriptor.get.call(receiver);
}
return descriptor.value;
}
module.exports = _classPrivateFieldGet;
@@ -0,0 +1,9 @@
function _classPrivateFieldBase(receiver, privateKey) {
if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) {
throw new TypeError("attempted to use private field on non-instance");
}
return receiver;
}
module.exports = _classPrivateFieldBase;
@@ -0,0 +1,7 @@
var id = 0;
function _classPrivateFieldKey(name) {
return "__private_" + id++ + "_" + name;
}
module.exports = _classPrivateFieldKey;
@@ -0,0 +1,21 @@
function _classPrivateFieldSet(receiver, privateMap, value) {
var descriptor = privateMap.get(receiver);
if (!descriptor) {
throw new TypeError("attempted to set private field on non-instance");
}
if (descriptor.set) {
descriptor.set.call(receiver, value);
} else {
if (!descriptor.writable) {
throw new TypeError("attempted to set read only private field");
}
descriptor.value = value;
}
return value;
}
module.exports = _classPrivateFieldSet;
@@ -0,0 +1,9 @@
function _classPrivateMethodGet(receiver, privateSet, fn) {
if (!privateSet.has(receiver)) {
throw new TypeError("attempted to get private field on non-instance");
}
return fn;
}
module.exports = _classPrivateMethodGet;
@@ -0,0 +1,5 @@
function _classPrivateMethodSet() {
throw new TypeError("attempted to reassign private method");
}
module.exports = _classPrivateMethodSet;
@@ -0,0 +1,9 @@
function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) {
if (receiver !== classConstructor) {
throw new TypeError("Private static access of wrong provenance");
}
return descriptor.value;
}
module.exports = _classStaticPrivateFieldSpecGet;
@@ -0,0 +1,14 @@
function _classStaticPrivateFieldSpecSet(receiver, classConstructor, descriptor, value) {
if (receiver !== classConstructor) {
throw new TypeError("Private static access of wrong provenance");
}
if (!descriptor.writable) {
throw new TypeError("attempted to set read only private field");
}
descriptor.value = value;
return value;
}
module.exports = _classStaticPrivateFieldSpecSet;
@@ -0,0 +1,9 @@
function _classStaticPrivateMethodGet(receiver, classConstructor, method) {
if (receiver !== classConstructor) {
throw new TypeError("Private static access of wrong provenance");
}
return method;
}
module.exports = _classStaticPrivateMethodGet;
@@ -0,0 +1,5 @@
function _classStaticPrivateMethodSet() {
throw new TypeError("attempted to set read only static private field");
}
module.exports = _classStaticPrivateMethodSet;
@@ -0,0 +1,33 @@
var setPrototypeOf = require("./setPrototypeOf");
function isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
return true;
} catch (e) {
return false;
}
}
function _construct(Parent, args, Class) {
if (isNativeReflectConstruct()) {
module.exports = _construct = Reflect.construct;
} else {
module.exports = _construct = function _construct(Parent, args, Class) {
var a = [null];
a.push.apply(a, args);
var Constructor = Function.bind.apply(Parent, a);
var instance = new Constructor();
if (Class) setPrototypeOf(instance, Class.prototype);
return instance;
};
}
return _construct.apply(null, arguments);
}
module.exports = _construct;
@@ -0,0 +1,17 @@
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
module.exports = _createClass;
@@ -0,0 +1,400 @@
var toArray = require("./toArray");
var toPropertyKey = require("./toPropertyKey");
function _decorate(decorators, factory, superClass, mixins) {
var api = _getDecoratorsApi();
if (mixins) {
for (var i = 0; i < mixins.length; i++) {
api = mixins[i](api);
}
}
var r = factory(function initialize(O) {
api.initializeInstanceElements(O, decorated.elements);
}, superClass);
var decorated = api.decorateClass(_coalesceClassElements(r.d.map(_createElementDescriptor)), decorators);
api.initializeClassElements(r.F, decorated.elements);
return api.runClassFinishers(r.F, decorated.finishers);
}
function _getDecoratorsApi() {
_getDecoratorsApi = function _getDecoratorsApi() {
return api;
};
var api = {
elementsDefinitionOrder: [["method"], ["field"]],
initializeInstanceElements: function initializeInstanceElements(O, elements) {
["method", "field"].forEach(function (kind) {
elements.forEach(function (element) {
if (element.kind === kind && element.placement === "own") {
this.defineClassElement(O, element);
}
}, this);
}, this);
},
initializeClassElements: function initializeClassElements(F, elements) {
var proto = F.prototype;
["method", "field"].forEach(function (kind) {
elements.forEach(function (element) {
var placement = element.placement;
if (element.kind === kind && (placement === "static" || placement === "prototype")) {
var receiver = placement === "static" ? F : proto;
this.defineClassElement(receiver, element);
}
}, this);
}, this);
},
defineClassElement: function defineClassElement(receiver, element) {
var descriptor = element.descriptor;
if (element.kind === "field") {
var initializer = element.initializer;
descriptor = {
enumerable: descriptor.enumerable,
writable: descriptor.writable,
configurable: descriptor.configurable,
value: initializer === void 0 ? void 0 : initializer.call(receiver)
};
}
Object.defineProperty(receiver, element.key, descriptor);
},
decorateClass: function decorateClass(elements, decorators) {
var newElements = [];
var finishers = [];
var placements = {
"static": [],
prototype: [],
own: []
};
elements.forEach(function (element) {
this.addElementPlacement(element, placements);
}, this);
elements.forEach(function (element) {
if (!_hasDecorators(element)) return newElements.push(element);
var elementFinishersExtras = this.decorateElement(element, placements);
newElements.push(elementFinishersExtras.element);
newElements.push.apply(newElements, elementFinishersExtras.extras);
finishers.push.apply(finishers, elementFinishersExtras.finishers);
}, this);
if (!decorators) {
return {
elements: newElements,
finishers: finishers
};
}
var result = this.decorateConstructor(newElements, decorators);
finishers.push.apply(finishers, result.finishers);
result.finishers = finishers;
return result;
},
addElementPlacement: function addElementPlacement(element, placements, silent) {
var keys = placements[element.placement];
if (!silent && keys.indexOf(element.key) !== -1) {
throw new TypeError("Duplicated element (" + element.key + ")");
}
keys.push(element.key);
},
decorateElement: function decorateElement(element, placements) {
var extras = [];
var finishers = [];
for (var decorators = element.decorators, i = decorators.length - 1; i >= 0; i--) {
var keys = placements[element.placement];
keys.splice(keys.indexOf(element.key), 1);
var elementObject = this.fromElementDescriptor(element);
var elementFinisherExtras = this.toElementFinisherExtras((0, decorators[i])(elementObject) || elementObject);
element = elementFinisherExtras.element;
this.addElementPlacement(element, placements);
if (elementFinisherExtras.finisher) {
finishers.push(elementFinisherExtras.finisher);
}
var newExtras = elementFinisherExtras.extras;
if (newExtras) {
for (var j = 0; j < newExtras.length; j++) {
this.addElementPlacement(newExtras[j], placements);
}
extras.push.apply(extras, newExtras);
}
}
return {
element: element,
finishers: finishers,
extras: extras
};
},
decorateConstructor: function decorateConstructor(elements, decorators) {
var finishers = [];
for (var i = decorators.length - 1; i >= 0; i--) {
var obj = this.fromClassDescriptor(elements);
var elementsAndFinisher = this.toClassDescriptor((0, decorators[i])(obj) || obj);
if (elementsAndFinisher.finisher !== undefined) {
finishers.push(elementsAndFinisher.finisher);
}
if (elementsAndFinisher.elements !== undefined) {
elements = elementsAndFinisher.elements;
for (var j = 0; j < elements.length - 1; j++) {
for (var k = j + 1; k < elements.length; k++) {
if (elements[j].key === elements[k].key && elements[j].placement === elements[k].placement) {
throw new TypeError("Duplicated element (" + elements[j].key + ")");
}
}
}
}
}
return {
elements: elements,
finishers: finishers
};
},
fromElementDescriptor: function fromElementDescriptor(element) {
var obj = {
kind: element.kind,
key: element.key,
placement: element.placement,
descriptor: element.descriptor
};
var desc = {
value: "Descriptor",
configurable: true
};
Object.defineProperty(obj, Symbol.toStringTag, desc);
if (element.kind === "field") obj.initializer = element.initializer;
return obj;
},
toElementDescriptors: function toElementDescriptors(elementObjects) {
if (elementObjects === undefined) return;
return toArray(elementObjects).map(function (elementObject) {
var element = this.toElementDescriptor(elementObject);
this.disallowProperty(elementObject, "finisher", "An element descriptor");
this.disallowProperty(elementObject, "extras", "An element descriptor");
return element;
}, this);
},
toElementDescriptor: function toElementDescriptor(elementObject) {
var kind = String(elementObject.kind);
if (kind !== "method" && kind !== "field") {
throw new TypeError('An element descriptor\'s .kind property must be either "method" or' + ' "field", but a decorator created an element descriptor with' + ' .kind "' + kind + '"');
}
var key = toPropertyKey(elementObject.key);
var placement = String(elementObject.placement);
if (placement !== "static" && placement !== "prototype" && placement !== "own") {
throw new TypeError('An element descriptor\'s .placement property must be one of "static",' + ' "prototype" or "own", but a decorator created an element descriptor' + ' with .placement "' + placement + '"');
}
var descriptor = elementObject.descriptor;
this.disallowProperty(elementObject, "elements", "An element descriptor");
var element = {
kind: kind,
key: key,
placement: placement,
descriptor: Object.assign({}, descriptor)
};
if (kind !== "field") {
this.disallowProperty(elementObject, "initializer", "A method descriptor");
} else {
this.disallowProperty(descriptor, "get", "The property descriptor of a field descriptor");
this.disallowProperty(descriptor, "set", "The property descriptor of a field descriptor");
this.disallowProperty(descriptor, "value", "The property descriptor of a field descriptor");
element.initializer = elementObject.initializer;
}
return element;
},
toElementFinisherExtras: function toElementFinisherExtras(elementObject) {
var element = this.toElementDescriptor(elementObject);
var finisher = _optionalCallableProperty(elementObject, "finisher");
var extras = this.toElementDescriptors(elementObject.extras);
return {
element: element,
finisher: finisher,
extras: extras
};
},
fromClassDescriptor: function fromClassDescriptor(elements) {
var obj = {
kind: "class",
elements: elements.map(this.fromElementDescriptor, this)
};
var desc = {
value: "Descriptor",
configurable: true
};
Object.defineProperty(obj, Symbol.toStringTag, desc);
return obj;
},
toClassDescriptor: function toClassDescriptor(obj) {
var kind = String(obj.kind);
if (kind !== "class") {
throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator' + ' created a class descriptor with .kind "' + kind + '"');
}
this.disallowProperty(obj, "key", "A class descriptor");
this.disallowProperty(obj, "placement", "A class descriptor");
this.disallowProperty(obj, "descriptor", "A class descriptor");
this.disallowProperty(obj, "initializer", "A class descriptor");
this.disallowProperty(obj, "extras", "A class descriptor");
var finisher = _optionalCallableProperty(obj, "finisher");
var elements = this.toElementDescriptors(obj.elements);
return {
elements: elements,
finisher: finisher
};
},
runClassFinishers: function runClassFinishers(constructor, finishers) {
for (var i = 0; i < finishers.length; i++) {
var newConstructor = (0, finishers[i])(constructor);
if (newConstructor !== undefined) {
if (typeof newConstructor !== "function") {
throw new TypeError("Finishers must return a constructor.");
}
constructor = newConstructor;
}
}
return constructor;
},
disallowProperty: function disallowProperty(obj, name, objectType) {
if (obj[name] !== undefined) {
throw new TypeError(objectType + " can't have a ." + name + " property.");
}
}
};
return api;
}
function _createElementDescriptor(def) {
var key = toPropertyKey(def.key);
var descriptor;
if (def.kind === "method") {
descriptor = {
value: def.value,
writable: true,
configurable: true,
enumerable: false
};
} else if (def.kind === "get") {
descriptor = {
get: def.value,
configurable: true,
enumerable: false
};
} else if (def.kind === "set") {
descriptor = {
set: def.value,
configurable: true,
enumerable: false
};
} else if (def.kind === "field") {
descriptor = {
configurable: true,
writable: true,
enumerable: true
};
}
var element = {
kind: def.kind === "field" ? "field" : "method",
key: key,
placement: def["static"] ? "static" : def.kind === "field" ? "own" : "prototype",
descriptor: descriptor
};
if (def.decorators) element.decorators = def.decorators;
if (def.kind === "field") element.initializer = def.value;
return element;
}
function _coalesceGetterSetter(element, other) {
if (element.descriptor.get !== undefined) {
other.descriptor.get = element.descriptor.get;
} else {
other.descriptor.set = element.descriptor.set;
}
}
function _coalesceClassElements(elements) {
var newElements = [];
var isSameElement = function isSameElement(other) {
return other.kind === "method" && other.key === element.key && other.placement === element.placement;
};
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
var other;
if (element.kind === "method" && (other = newElements.find(isSameElement))) {
if (_isDataDescriptor(element.descriptor) || _isDataDescriptor(other.descriptor)) {
if (_hasDecorators(element) || _hasDecorators(other)) {
throw new ReferenceError("Duplicated methods (" + element.key + ") can't be decorated.");
}
other.descriptor = element.descriptor;
} else {
if (_hasDecorators(element)) {
if (_hasDecorators(other)) {
throw new ReferenceError("Decorators can't be placed on different accessors with for " + "the same property (" + element.key + ").");
}
other.decorators = element.decorators;
}
_coalesceGetterSetter(element, other);
}
} else {
newElements.push(element);
}
}
return newElements;
}
function _hasDecorators(element) {
return element.decorators && element.decorators.length;
}
function _isDataDescriptor(desc) {
return desc !== undefined && !(desc.value === undefined && desc.writable === undefined);
}
function _optionalCallableProperty(obj, name) {
var value = obj[name];
if (value !== undefined && typeof value !== "function") {
throw new TypeError("Expected '" + name + "' to be a function");
}
return value;
}
module.exports = _decorate;
@@ -0,0 +1,16 @@
function _defaults(obj, defaults) {
var keys = Object.getOwnPropertyNames(defaults);
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
var value = Object.getOwnPropertyDescriptor(defaults, key);
if (value && value.configurable && obj[key] === undefined) {
Object.defineProperty(obj, key, value);
}
}
return obj;
}
module.exports = _defaults;
@@ -0,0 +1,24 @@
function _defineEnumerableProperties(obj, descs) {
for (var key in descs) {
var desc = descs[key];
desc.configurable = desc.enumerable = true;
if ("value" in desc) desc.writable = true;
Object.defineProperty(obj, key, desc);
}
if (Object.getOwnPropertySymbols) {
var objectSymbols = Object.getOwnPropertySymbols(descs);
for (var i = 0; i < objectSymbols.length; i++) {
var sym = objectSymbols[i];
var desc = descs[sym];
desc.configurable = desc.enumerable = true;
if ("value" in desc) desc.writable = true;
Object.defineProperty(obj, sym, desc);
}
}
return obj;
}
module.exports = _defineEnumerableProperties;
@@ -0,0 +1,16 @@
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
module.exports = _defineProperty;
@@ -0,0 +1,97 @@
import AwaitValue from "./AwaitValue";
export default function AsyncGenerator(gen) {
var front, back;
function send(key, arg) {
return new Promise(function (resolve, reject) {
var request = {
key: key,
arg: arg,
resolve: resolve,
reject: reject,
next: null
};
if (back) {
back = back.next = request;
} else {
front = back = request;
resume(key, arg);
}
});
}
function resume(key, arg) {
try {
var result = gen[key](arg);
var value = result.value;
var wrappedAwait = value instanceof AwaitValue;
Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) {
if (wrappedAwait) {
resume("next", arg);
return;
}
settle(result.done ? "return" : "normal", arg);
}, function (err) {
resume("throw", err);
});
} catch (err) {
settle("throw", err);
}
}
function settle(type, value) {
switch (type) {
case "return":
front.resolve({
value: value,
done: true
});
break;
case "throw":
front.reject(value);
break;
default:
front.resolve({
value: value,
done: false
});
break;
}
front = front.next;
if (front) {
resume(front.key, front.arg);
} else {
back = null;
}
}
this._invoke = send;
if (typeof gen["return"] !== "function") {
this["return"] = undefined;
}
}
if (typeof Symbol === "function" && Symbol.asyncIterator) {
AsyncGenerator.prototype[Symbol.asyncIterator] = function () {
return this;
};
}
AsyncGenerator.prototype.next = function (arg) {
return this._invoke("next", arg);
};
AsyncGenerator.prototype["throw"] = function (arg) {
return this._invoke("throw", arg);
};
AsyncGenerator.prototype["return"] = function (arg) {
return this._invoke("return", arg);
};
@@ -0,0 +1,3 @@
export default function _AwaitValue(value) {
this.wrapped = value;
}
@@ -0,0 +1,28 @@
export default function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {
var desc = {};
Object.keys(descriptor).forEach(function (key) {
desc[key] = descriptor[key];
});
desc.enumerable = !!desc.enumerable;
desc.configurable = !!desc.configurable;
if ('value' in desc || desc.initializer) {
desc.writable = true;
}
desc = decorators.slice().reverse().reduce(function (desc, decorator) {
return decorator(target, property, desc) || desc;
}, desc);
if (context && desc.initializer !== void 0) {
desc.value = desc.initializer ? desc.initializer.call(context) : void 0;
desc.initializer = undefined;
}
if (desc.initializer === void 0) {
Object.defineProperty(target, property, desc);
desc = null;
}
return desc;
}
@@ -0,0 +1,3 @@
export default function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
@@ -0,0 +1,9 @@
export default function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {
arr2[i] = arr[i];
}
return arr2;
}
}
@@ -0,0 +1,7 @@
export default function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
@@ -0,0 +1,51 @@
export default function _asyncGeneratorDelegate(inner, awaitWrap) {
var iter = {},
waiting = false;
function pump(key, value) {
waiting = true;
value = new Promise(function (resolve) {
resolve(inner[key](value));
});
return {
done: false,
value: awaitWrap(value)
};
}
;
if (typeof Symbol === "function" && Symbol.iterator) {
iter[Symbol.iterator] = function () {
return this;
};
}
iter.next = function (value) {
if (waiting) {
waiting = false;
return value;
}
return pump("next", value);
};
if (typeof inner["throw"] === "function") {
iter["throw"] = function (value) {
if (waiting) {
waiting = false;
throw value;
}
return pump("throw", value);
};
}
if (typeof inner["return"] === "function") {
iter["return"] = function (value) {
return pump("return", value);
};
}
return iter;
}
@@ -0,0 +1,17 @@
export default function _asyncIterator(iterable) {
var method;
if (typeof Symbol !== "undefined") {
if (Symbol.asyncIterator) {
method = iterable[Symbol.asyncIterator];
if (method != null) return method.call(iterable);
}
if (Symbol.iterator) {
method = iterable[Symbol.iterator];
if (method != null) return method.call(iterable);
}
}
throw new TypeError("Object is not async iterable");
}
@@ -0,0 +1,35 @@
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
export default function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
@@ -0,0 +1,4 @@
import AwaitValue from "./AwaitValue";
export default function _awaitAsyncGenerator(value) {
return new AwaitValue(value);
}
@@ -0,0 +1,5 @@
export default function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
@@ -0,0 +1,3 @@
export default function _classNameTDZError(name) {
throw new Error("Class \"" + name + "\" cannot be referenced in computed property keys.");
}
@@ -0,0 +1,26 @@
export default function _classPrivateFieldDestructureSet(receiver, privateMap) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to set private field on non-instance");
}
var descriptor = privateMap.get(receiver);
if (descriptor.set) {
if (!("__destrObj" in descriptor)) {
descriptor.__destrObj = {
set value(v) {
descriptor.set.call(receiver, v);
}
};
}
return descriptor.__destrObj;
} else {
if (!descriptor.writable) {
throw new TypeError("attempted to set read only private field");
}
return descriptor;
}
}
@@ -0,0 +1,13 @@
export default function _classPrivateFieldGet(receiver, privateMap) {
var descriptor = privateMap.get(receiver);
if (!descriptor) {
throw new TypeError("attempted to get private field on non-instance");
}
if (descriptor.get) {
return descriptor.get.call(receiver);
}
return descriptor.value;
}
@@ -0,0 +1,7 @@
export default function _classPrivateFieldBase(receiver, privateKey) {
if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) {
throw new TypeError("attempted to use private field on non-instance");
}
return receiver;
}
@@ -0,0 +1,4 @@
var id = 0;
export default function _classPrivateFieldKey(name) {
return "__private_" + id++ + "_" + name;
}
@@ -0,0 +1,19 @@
export default function _classPrivateFieldSet(receiver, privateMap, value) {
var descriptor = privateMap.get(receiver);
if (!descriptor) {
throw new TypeError("attempted to set private field on non-instance");
}
if (descriptor.set) {
descriptor.set.call(receiver, value);
} else {
if (!descriptor.writable) {
throw new TypeError("attempted to set read only private field");
}
descriptor.value = value;
}
return value;
}
@@ -0,0 +1,7 @@
export default function _classPrivateMethodGet(receiver, privateSet, fn) {
if (!privateSet.has(receiver)) {
throw new TypeError("attempted to get private field on non-instance");
}
return fn;
}
@@ -0,0 +1,3 @@
export default function _classPrivateMethodSet() {
throw new TypeError("attempted to reassign private method");
}
@@ -0,0 +1,7 @@
export default function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) {
if (receiver !== classConstructor) {
throw new TypeError("Private static access of wrong provenance");
}
return descriptor.value;
}
@@ -0,0 +1,12 @@
export default function _classStaticPrivateFieldSpecSet(receiver, classConstructor, descriptor, value) {
if (receiver !== classConstructor) {
throw new TypeError("Private static access of wrong provenance");
}
if (!descriptor.writable) {
throw new TypeError("attempted to set read only private field");
}
descriptor.value = value;
return value;
}
@@ -0,0 +1,7 @@
export default function _classStaticPrivateMethodGet(receiver, classConstructor, method) {
if (receiver !== classConstructor) {
throw new TypeError("Private static access of wrong provenance");
}
return method;
}
@@ -0,0 +1,3 @@
export default function _classStaticPrivateMethodSet() {
throw new TypeError("attempted to set read only static private field");
}
@@ -0,0 +1,31 @@
import setPrototypeOf from "./setPrototypeOf";
function isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
return true;
} catch (e) {
return false;
}
}
export default function _construct(Parent, args, Class) {
if (isNativeReflectConstruct()) {
_construct = Reflect.construct;
} else {
_construct = function _construct(Parent, args, Class) {
var a = [null];
a.push.apply(a, args);
var Constructor = Function.bind.apply(Parent, a);
var instance = new Constructor();
if (Class) setPrototypeOf(instance, Class.prototype);
return instance;
};
}
return _construct.apply(null, arguments);
}
@@ -0,0 +1,15 @@
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
export default function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
@@ -0,0 +1,396 @@
import toArray from "./toArray";
import toPropertyKey from "./toPropertyKey";
export default function _decorate(decorators, factory, superClass, mixins) {
var api = _getDecoratorsApi();
if (mixins) {
for (var i = 0; i < mixins.length; i++) {
api = mixins[i](api);
}
}
var r = factory(function initialize(O) {
api.initializeInstanceElements(O, decorated.elements);
}, superClass);
var decorated = api.decorateClass(_coalesceClassElements(r.d.map(_createElementDescriptor)), decorators);
api.initializeClassElements(r.F, decorated.elements);
return api.runClassFinishers(r.F, decorated.finishers);
}
function _getDecoratorsApi() {
_getDecoratorsApi = function _getDecoratorsApi() {
return api;
};
var api = {
elementsDefinitionOrder: [["method"], ["field"]],
initializeInstanceElements: function initializeInstanceElements(O, elements) {
["method", "field"].forEach(function (kind) {
elements.forEach(function (element) {
if (element.kind === kind && element.placement === "own") {
this.defineClassElement(O, element);
}
}, this);
}, this);
},
initializeClassElements: function initializeClassElements(F, elements) {
var proto = F.prototype;
["method", "field"].forEach(function (kind) {
elements.forEach(function (element) {
var placement = element.placement;
if (element.kind === kind && (placement === "static" || placement === "prototype")) {
var receiver = placement === "static" ? F : proto;
this.defineClassElement(receiver, element);
}
}, this);
}, this);
},
defineClassElement: function defineClassElement(receiver, element) {
var descriptor = element.descriptor;
if (element.kind === "field") {
var initializer = element.initializer;
descriptor = {
enumerable: descriptor.enumerable,
writable: descriptor.writable,
configurable: descriptor.configurable,
value: initializer === void 0 ? void 0 : initializer.call(receiver)
};
}
Object.defineProperty(receiver, element.key, descriptor);
},
decorateClass: function decorateClass(elements, decorators) {
var newElements = [];
var finishers = [];
var placements = {
"static": [],
prototype: [],
own: []
};
elements.forEach(function (element) {
this.addElementPlacement(element, placements);
}, this);
elements.forEach(function (element) {
if (!_hasDecorators(element)) return newElements.push(element);
var elementFinishersExtras = this.decorateElement(element, placements);
newElements.push(elementFinishersExtras.element);
newElements.push.apply(newElements, elementFinishersExtras.extras);
finishers.push.apply(finishers, elementFinishersExtras.finishers);
}, this);
if (!decorators) {
return {
elements: newElements,
finishers: finishers
};
}
var result = this.decorateConstructor(newElements, decorators);
finishers.push.apply(finishers, result.finishers);
result.finishers = finishers;
return result;
},
addElementPlacement: function addElementPlacement(element, placements, silent) {
var keys = placements[element.placement];
if (!silent && keys.indexOf(element.key) !== -1) {
throw new TypeError("Duplicated element (" + element.key + ")");
}
keys.push(element.key);
},
decorateElement: function decorateElement(element, placements) {
var extras = [];
var finishers = [];
for (var decorators = element.decorators, i = decorators.length - 1; i >= 0; i--) {
var keys = placements[element.placement];
keys.splice(keys.indexOf(element.key), 1);
var elementObject = this.fromElementDescriptor(element);
var elementFinisherExtras = this.toElementFinisherExtras((0, decorators[i])(elementObject) || elementObject);
element = elementFinisherExtras.element;
this.addElementPlacement(element, placements);
if (elementFinisherExtras.finisher) {
finishers.push(elementFinisherExtras.finisher);
}
var newExtras = elementFinisherExtras.extras;
if (newExtras) {
for (var j = 0; j < newExtras.length; j++) {
this.addElementPlacement(newExtras[j], placements);
}
extras.push.apply(extras, newExtras);
}
}
return {
element: element,
finishers: finishers,
extras: extras
};
},
decorateConstructor: function decorateConstructor(elements, decorators) {
var finishers = [];
for (var i = decorators.length - 1; i >= 0; i--) {
var obj = this.fromClassDescriptor(elements);
var elementsAndFinisher = this.toClassDescriptor((0, decorators[i])(obj) || obj);
if (elementsAndFinisher.finisher !== undefined) {
finishers.push(elementsAndFinisher.finisher);
}
if (elementsAndFinisher.elements !== undefined) {
elements = elementsAndFinisher.elements;
for (var j = 0; j < elements.length - 1; j++) {
for (var k = j + 1; k < elements.length; k++) {
if (elements[j].key === elements[k].key && elements[j].placement === elements[k].placement) {
throw new TypeError("Duplicated element (" + elements[j].key + ")");
}
}
}
}
}
return {
elements: elements,
finishers: finishers
};
},
fromElementDescriptor: function fromElementDescriptor(element) {
var obj = {
kind: element.kind,
key: element.key,
placement: element.placement,
descriptor: element.descriptor
};
var desc = {
value: "Descriptor",
configurable: true
};
Object.defineProperty(obj, Symbol.toStringTag, desc);
if (element.kind === "field") obj.initializer = element.initializer;
return obj;
},
toElementDescriptors: function toElementDescriptors(elementObjects) {
if (elementObjects === undefined) return;
return toArray(elementObjects).map(function (elementObject) {
var element = this.toElementDescriptor(elementObject);
this.disallowProperty(elementObject, "finisher", "An element descriptor");
this.disallowProperty(elementObject, "extras", "An element descriptor");
return element;
}, this);
},
toElementDescriptor: function toElementDescriptor(elementObject) {
var kind = String(elementObject.kind);
if (kind !== "method" && kind !== "field") {
throw new TypeError('An element descriptor\'s .kind property must be either "method" or' + ' "field", but a decorator created an element descriptor with' + ' .kind "' + kind + '"');
}
var key = toPropertyKey(elementObject.key);
var placement = String(elementObject.placement);
if (placement !== "static" && placement !== "prototype" && placement !== "own") {
throw new TypeError('An element descriptor\'s .placement property must be one of "static",' + ' "prototype" or "own", but a decorator created an element descriptor' + ' with .placement "' + placement + '"');
}
var descriptor = elementObject.descriptor;
this.disallowProperty(elementObject, "elements", "An element descriptor");
var element = {
kind: kind,
key: key,
placement: placement,
descriptor: Object.assign({}, descriptor)
};
if (kind !== "field") {
this.disallowProperty(elementObject, "initializer", "A method descriptor");
} else {
this.disallowProperty(descriptor, "get", "The property descriptor of a field descriptor");
this.disallowProperty(descriptor, "set", "The property descriptor of a field descriptor");
this.disallowProperty(descriptor, "value", "The property descriptor of a field descriptor");
element.initializer = elementObject.initializer;
}
return element;
},
toElementFinisherExtras: function toElementFinisherExtras(elementObject) {
var element = this.toElementDescriptor(elementObject);
var finisher = _optionalCallableProperty(elementObject, "finisher");
var extras = this.toElementDescriptors(elementObject.extras);
return {
element: element,
finisher: finisher,
extras: extras
};
},
fromClassDescriptor: function fromClassDescriptor(elements) {
var obj = {
kind: "class",
elements: elements.map(this.fromElementDescriptor, this)
};
var desc = {
value: "Descriptor",
configurable: true
};
Object.defineProperty(obj, Symbol.toStringTag, desc);
return obj;
},
toClassDescriptor: function toClassDescriptor(obj) {
var kind = String(obj.kind);
if (kind !== "class") {
throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator' + ' created a class descriptor with .kind "' + kind + '"');
}
this.disallowProperty(obj, "key", "A class descriptor");
this.disallowProperty(obj, "placement", "A class descriptor");
this.disallowProperty(obj, "descriptor", "A class descriptor");
this.disallowProperty(obj, "initializer", "A class descriptor");
this.disallowProperty(obj, "extras", "A class descriptor");
var finisher = _optionalCallableProperty(obj, "finisher");
var elements = this.toElementDescriptors(obj.elements);
return {
elements: elements,
finisher: finisher
};
},
runClassFinishers: function runClassFinishers(constructor, finishers) {
for (var i = 0; i < finishers.length; i++) {
var newConstructor = (0, finishers[i])(constructor);
if (newConstructor !== undefined) {
if (typeof newConstructor !== "function") {
throw new TypeError("Finishers must return a constructor.");
}
constructor = newConstructor;
}
}
return constructor;
},
disallowProperty: function disallowProperty(obj, name, objectType) {
if (obj[name] !== undefined) {
throw new TypeError(objectType + " can't have a ." + name + " property.");
}
}
};
return api;
}
function _createElementDescriptor(def) {
var key = toPropertyKey(def.key);
var descriptor;
if (def.kind === "method") {
descriptor = {
value: def.value,
writable: true,
configurable: true,
enumerable: false
};
} else if (def.kind === "get") {
descriptor = {
get: def.value,
configurable: true,
enumerable: false
};
} else if (def.kind === "set") {
descriptor = {
set: def.value,
configurable: true,
enumerable: false
};
} else if (def.kind === "field") {
descriptor = {
configurable: true,
writable: true,
enumerable: true
};
}
var element = {
kind: def.kind === "field" ? "field" : "method",
key: key,
placement: def["static"] ? "static" : def.kind === "field" ? "own" : "prototype",
descriptor: descriptor
};
if (def.decorators) element.decorators = def.decorators;
if (def.kind === "field") element.initializer = def.value;
return element;
}
function _coalesceGetterSetter(element, other) {
if (element.descriptor.get !== undefined) {
other.descriptor.get = element.descriptor.get;
} else {
other.descriptor.set = element.descriptor.set;
}
}
function _coalesceClassElements(elements) {
var newElements = [];
var isSameElement = function isSameElement(other) {
return other.kind === "method" && other.key === element.key && other.placement === element.placement;
};
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
var other;
if (element.kind === "method" && (other = newElements.find(isSameElement))) {
if (_isDataDescriptor(element.descriptor) || _isDataDescriptor(other.descriptor)) {
if (_hasDecorators(element) || _hasDecorators(other)) {
throw new ReferenceError("Duplicated methods (" + element.key + ") can't be decorated.");
}
other.descriptor = element.descriptor;
} else {
if (_hasDecorators(element)) {
if (_hasDecorators(other)) {
throw new ReferenceError("Decorators can't be placed on different accessors with for " + "the same property (" + element.key + ").");
}
other.decorators = element.decorators;
}
_coalesceGetterSetter(element, other);
}
} else {
newElements.push(element);
}
}
return newElements;
}
function _hasDecorators(element) {
return element.decorators && element.decorators.length;
}
function _isDataDescriptor(desc) {
return desc !== undefined && !(desc.value === undefined && desc.writable === undefined);
}
function _optionalCallableProperty(obj, name) {
var value = obj[name];
if (value !== undefined && typeof value !== "function") {
throw new TypeError("Expected '" + name + "' to be a function");
}
return value;
}
@@ -0,0 +1,14 @@
export default function _defaults(obj, defaults) {
var keys = Object.getOwnPropertyNames(defaults);
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
var value = Object.getOwnPropertyDescriptor(defaults, key);
if (value && value.configurable && obj[key] === undefined) {
Object.defineProperty(obj, key, value);
}
}
return obj;
}
@@ -0,0 +1,22 @@
export default function _defineEnumerableProperties(obj, descs) {
for (var key in descs) {
var desc = descs[key];
desc.configurable = desc.enumerable = true;
if ("value" in desc) desc.writable = true;
Object.defineProperty(obj, key, desc);
}
if (Object.getOwnPropertySymbols) {
var objectSymbols = Object.getOwnPropertySymbols(descs);
for (var i = 0; i < objectSymbols.length; i++) {
var sym = objectSymbols[i];
var desc = descs[sym];
desc.configurable = desc.enumerable = true;
if ("value" in desc) desc.writable = true;
Object.defineProperty(obj, sym, desc);
}
}
return obj;
}
@@ -0,0 +1,14 @@
export default function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
@@ -0,0 +1,17 @@
export default function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
@@ -0,0 +1,20 @@
import superPropBase from "./superPropBase";
export default function _get(target, property, receiver) {
if (typeof Reflect !== "undefined" && Reflect.get) {
_get = Reflect.get;
} else {
_get = function _get(target, property, receiver) {
var base = superPropBase(target, property);
if (!base) return;
var desc = Object.getOwnPropertyDescriptor(base, property);
if (desc.get) {
return desc.get.call(receiver);
}
return desc.value;
};
}
return _get(target, property, receiver || target);
}
@@ -0,0 +1,6 @@
export default function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);
}
@@ -0,0 +1,15 @@
import setPrototypeOf from "./setPrototypeOf";
export default function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function");
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
if (superClass) setPrototypeOf(subClass, superClass);
}
@@ -0,0 +1,5 @@
export default function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
}
@@ -0,0 +1,9 @@
export default function _initializerDefineProperty(target, property, descriptor, context) {
if (!descriptor) return;
Object.defineProperty(target, property, {
enumerable: descriptor.enumerable,
configurable: descriptor.configurable,
writable: descriptor.writable,
value: descriptor.initializer ? descriptor.initializer.call(context) : void 0
});
}
@@ -0,0 +1,3 @@
export default function _initializerWarningHelper(descriptor, context) {
throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and set to use loose mode. ' + 'To use proposal-class-properties in spec mode with decorators, wait for ' + 'the next major version of decorators in stage 2.');
}
@@ -0,0 +1,7 @@
export default function _instanceof(left, right) {
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
return !!right[Symbol.hasInstance](left);
} else {
return left instanceof right;
}
}
@@ -0,0 +1,5 @@
export default function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
"default": obj
};
}
@@ -0,0 +1,24 @@
export default function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
} else {
var newObj = {};
if (obj != null) {
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
if (desc.get || desc.set) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
}
newObj["default"] = obj;
return newObj;
}
}
@@ -0,0 +1,3 @@
export default function _isNativeFunction(fn) {
return Function.toString.call(fn).indexOf("[native code]") !== -1;
}
@@ -0,0 +1,3 @@
export default function _iterableToArray(iter) {
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
}
@@ -0,0 +1,25 @@
export default function _iterableToArrayLimit(arr, i) {
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
@@ -0,0 +1,11 @@
export default function _iterableToArrayLimitLoose(arr, i) {
var _arr = [];
for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
_arr.push(_step.value);
if (i && _arr.length === i) break;
}
return _arr;
}
@@ -0,0 +1,46 @@
var REACT_ELEMENT_TYPE;
export default function _createRawReactElement(type, props, key, children) {
if (!REACT_ELEMENT_TYPE) {
REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol["for"] && Symbol["for"]("react.element") || 0xeac7;
}
var defaultProps = type && type.defaultProps;
var childrenLength = arguments.length - 3;
if (!props && childrenLength !== 0) {
props = {
children: void 0
};
}
if (props && defaultProps) {
for (var propName in defaultProps) {
if (props[propName] === void 0) {
props[propName] = defaultProps[propName];
}
}
} else if (!props) {
props = defaultProps || {};
}
if (childrenLength === 1) {
props.children = children;
} else if (childrenLength > 1) {
var childArray = new Array(childrenLength);
for (var i = 0; i < childrenLength; i++) {
childArray[i] = arguments[i + 3];
}
props.children = childArray;
}
return {
$$typeof: REACT_ELEMENT_TYPE,
type: type,
key: key === undefined ? null : '' + key,
ref: null,
props: props,
_owner: null
};
}
@@ -0,0 +1,5 @@
export default function _newArrowCheck(innerThis, boundThis) {
if (innerThis !== boundThis) {
throw new TypeError("Cannot instantiate an arrow function");
}
}
@@ -0,0 +1,3 @@
export default function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
@@ -0,0 +1,3 @@
export default function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance");
}
@@ -0,0 +1,3 @@
export default function _objectDestructuringEmpty(obj) {
if (obj == null) throw new TypeError("Cannot destructure undefined");
}
@@ -0,0 +1,19 @@
import defineProperty from "./defineProperty";
export default function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys.forEach(function (key) {
defineProperty(target, key, source[key]);
});
}
return target;
}
@@ -0,0 +1,35 @@
import defineProperty from "./defineProperty";
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly) symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
keys.push.apply(keys, symbols);
}
return keys;
}
export default function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
if (i % 2) {
ownKeys(source, true).forEach(function (key) {
defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(source).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
}
return target;
}
@@ -0,0 +1,19 @@
import objectWithoutPropertiesLoose from "./objectWithoutPropertiesLoose";
export default function _objectWithoutProperties(source, excluded) {
if (source == null) return {};
var target = objectWithoutPropertiesLoose(source, excluded);
var key, i;
if (Object.getOwnPropertySymbols) {
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
for (i = 0; i < sourceSymbolKeys.length; i++) {
key = sourceSymbolKeys[i];
if (excluded.indexOf(key) >= 0) continue;
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
target[key] = source[key];
}
}
return target;
}
@@ -0,0 +1,14 @@
export default function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
}
@@ -0,0 +1,9 @@
import _typeof from "../../helpers/esm/typeof";
import assertThisInitialized from "./assertThisInitialized";
export default function _possibleConstructorReturn(self, call) {
if (call && (_typeof(call) === "object" || typeof call === "function")) {
return call;
}
return assertThisInitialized(self);
}
@@ -0,0 +1,3 @@
export default function _readOnlyError(name) {
throw new Error("\"" + name + "\" is read-only");
}
@@ -0,0 +1,51 @@
import superPropBase from "./superPropBase";
import defineProperty from "./defineProperty";
function set(target, property, value, receiver) {
if (typeof Reflect !== "undefined" && Reflect.set) {
set = Reflect.set;
} else {
set = function set(target, property, value, receiver) {
var base = superPropBase(target, property);
var desc;
if (base) {
desc = Object.getOwnPropertyDescriptor(base, property);
if (desc.set) {
desc.set.call(receiver, value);
return true;
} else if (!desc.writable) {
return false;
}
}
desc = Object.getOwnPropertyDescriptor(receiver, property);
if (desc) {
if (!desc.writable) {
return false;
}
desc.value = value;
Object.defineProperty(receiver, property, desc);
} else {
defineProperty(receiver, property, value);
}
return true;
};
}
return set(target, property, value, receiver);
}
export default function _set(target, property, value, receiver, isStrict) {
var s = set(target, property, value, receiver || target);
if (!s && isStrict) {
throw new Error('failed to set property');
}
return value;
}
@@ -0,0 +1,8 @@
export default function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
@@ -0,0 +1,7 @@
export default function _skipFirstGeneratorNext(fn) {
return function () {
var it = fn.apply(this, arguments);
it.next();
return it;
};
}
@@ -0,0 +1,6 @@
import arrayWithHoles from "./arrayWithHoles";
import iterableToArrayLimit from "./iterableToArrayLimit";
import nonIterableRest from "./nonIterableRest";
export default function _slicedToArray(arr, i) {
return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || nonIterableRest();
}
@@ -0,0 +1,6 @@
import arrayWithHoles from "./arrayWithHoles";
import iterableToArrayLimitLoose from "./iterableToArrayLimitLoose";
import nonIterableRest from "./nonIterableRest";
export default function _slicedToArrayLoose(arr, i) {
return arrayWithHoles(arr) || iterableToArrayLimitLoose(arr, i) || nonIterableRest();
}
@@ -0,0 +1,9 @@
import getPrototypeOf from "./getPrototypeOf";
export default function _superPropBase(object, property) {
while (!Object.prototype.hasOwnProperty.call(object, property)) {
object = getPrototypeOf(object);
if (object === null) break;
}
return object;
}
@@ -0,0 +1,11 @@
export default function _taggedTemplateLiteral(strings, raw) {
if (!raw) {
raw = strings.slice(0);
}
return Object.freeze(Object.defineProperties(strings, {
raw: {
value: Object.freeze(raw)
}
}));
}

Some files were not shown because too many files have changed in this diff Show More