This commit is contained in:
darenhsu
2022-07-17 13:16:16 +08:00
parent 84759556ff
commit befd344ab0
28070 changed files with 4008428 additions and 1 deletions
+10
View File
@@ -0,0 +1,10 @@
{
"include": [ "src/**/*.ts" ],
"exclude": [ "**/*.d.ts/", "webpack.*.js", "**/dist/**", "**/obsolete/**", "**/node_modules/**", "**/test/**" ],
"reporter": [ "lcov", "text-summary" ],
"require": [ "ts-node/register" ],
"report-dir": "./coverage/nyc",
"extension": [ ".ts", ".tsx" ],
"sourceMap": true,
"all": true
}
+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.
+82
View File
@@ -0,0 +1,82 @@
Miscellaneous Encoding Utilities for Crypto-related Objects in JavaScript
--
[![npm version](https://badge.fury.io/js/js-encoding-utils.svg)](https://badge.fury.io/js/js-encoding-utils)
[![CircleCI](https://circleci.com/gh/junkurihara/jseu.svg?style=svg)](https://circleci.com/gh/junkurihara/jseu)
[![Dependencies](https://david-dm.org/junkurihara/jseu.svg)](https://david-dm.org/junkurihara/jseu)
[![codecov](https://codecov.io/gh/junkurihara/jseu/branch/develop/graph/badge.svg)](https://codecov.io/gh/junkurihara/jseu)
[![Maintainability](https://api.codeclimate.com/v1/badges/771abd93ae5d986f1e0a/maintainability)](https://codeclimate.com/github/junkurihara/jseu/maintainability)
[![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 being developed to handle cryptographic data objects, e.g., PEM-formatted X.509 certificate, in JavaScript. Note that this library provides no cryptographic functions like encryption, but provides encoders, decoders and formatters of data formats related to cryptographic data objects. In particular, this introduces Base64(Url)-ArrayBuffer en/decoder, HexString-ArrayBuffer en/decoder and PEM-Binary formatter at this point. Moreover, this library is designed to be 'universal', i.e., it works both on most browsers and on Node.js just by importing from npm/source code.
# Installation
At your project directory, do either one of the following.
- From npm/yarn:
```shell
$ npm install --save js-encoding-utils // npm
$ yarn add js-encoding-utils // yarn
```
- From GitHub:
```shell
$ git clone https://github.com/junkurihara/jseu.git
```
Then you should import the package as follows.
```javascript
import jseu from 'js-encoding-utils'; // for npm
import jseu from 'jseu/dist/index.js'; // for github
```
# Usage
## Base64 <-> Binary
```javascript
// msg is an ArrayBuffer or Typed Array
const encoded = jseu.encoder.encodeBase64(msg);
// now you get Base64 string
const decoded = jseu.encoder.decodeBase64(encoded);
// now you get the original message in Uint8Array
```
## Base64Url <-> Binary
```javascript
// msg is an ArrayBuffer or Typed Array
const encoded = jseu.encoder.encodeBase64Url(msg);
// now you get Base64Url string
const decoded = jseu.encoder.decodeBase64Url(encoded);
// now you get the original message in Uint8Array
```
## HexString <-> Binary
```javascript
// msg is an ArrayBuffer or Typed Array
const encoded = jseu.encoder.arrayBufferToHexString(msg);
// now you get the hex-stringified message string
const decoded = jseu.encoder.hexStringToArrayBuffer(encoded);
// now you get the original message in Uint8Array
```
## PEM <-> Binary (usually DER encoding)
```javascript
// X.509 formatted certificate
const certPEM ='-----BEGIN CERTIFICATE-----...';
const binCert = jseu.formatter.pemToBin(certPEM);
// now you get the DER encoded certificate in Uint8Array
const pemCert = jseu.formatter.binToPem(binCert, 'certificate');
// now you get the original certificate.
```
# License
Licensed under the MIT license, see `LICENSE` file.
+141
View File
@@ -0,0 +1,141 @@
"use strict";
/**
* encoder.js
*/
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var env = __importStar(require("./env"));
/**
* Encode ArrayBuffer or TypedArray To Base64
* @param data
* @return {*}
*/
exports.encodeBase64 = function (data) {
var str = '';
if (typeof data === 'string')
str = data;
else
str = exports.arrayBufferToString(data);
var btoa = env.getEnvBtoa();
return btoa(str);
};
/**
* Decode Base64 to Uint8Array
* @param str
* @return {Uint8Array|string|*}
*/
exports.decodeBase64 = function (str) {
var atob = env.getEnvAtob();
var binary = atob(str);
var data = exports.stringToArrayBuffer(binary);
return getAsciiIfAscii(data);
};
/**
* if input data is an ArrayBuffer or TypedArray, it would be returned as Uint8Array
* @param data
* @return {Uint8Array}
*/
var sanitizeTypedArrayAndArrayBuffer = function (data) {
if (data instanceof Uint8Array)
return data;
if (ArrayBuffer.isView(data) && typeof data.buffer !== 'undefined') { // TypedArray except Uint8Array
return new Uint8Array(data.buffer);
}
else if (data instanceof ArrayBuffer) { // ArrayBuffer
return new Uint8Array(data);
}
else
throw new Error('Input must be an ArrayBuffer or a TypedArray');
};
/**
* Check if the given Uint8Array can be expressed in Ascii Text
* @param data
* @return {Uint8Array|string|*}
*/
var getAsciiIfAscii = function (data) {
var flag = true;
for (var i = 0; i < data.length; i++) {
if (data[i] > 0x7e || (data[i] < 0x20 && data[i] !== 0x0d && data[i] !== 0x0a)) {
flag = false;
break;
}
}
var returnData = null;
if (flag) {
returnData = '';
for (var i = 0; i < data.length; i++)
returnData += String.fromCharCode(data[i]);
}
else
returnData = data;
return returnData;
};
/**
* Encode ArrayBuffer or TypedArray to base64url string
* @param data
* @return {string}
*/
exports.encodeBase64Url = function (data) { return exports.encodeBase64(data).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, ''); };
/**
* Decode Base64Url string to Uint8Array
* @param str
* @return {Uint8Array}
*/
exports.decodeBase64Url = function (str) {
str = str.replace(/-/g, '+').replace(/_/g, '/');
// str = str + "=".repeat(str.length % 4); // this sometimes causes error...
return exports.decodeBase64(str);
};
/**
* Encode ArrayBuffer or TypedArray to hex string
* @param data
* @return {string}
*/
exports.arrayBufferToHexString = function (data) {
var arr = sanitizeTypedArrayAndArrayBuffer(data);
var hexStr = '';
for (var i = 0; i < arr.length; i++) {
var hex = (arr[i] & 0xff).toString(16);
hex = (hex.length === 1) ? "0" + hex : hex;
hexStr += hex;
}
return hexStr;
};
/**
* Decode hex string to Uint8Array
* @param str
* @return {Uint8Array}
*/
exports.hexStringToArrayBuffer = function (str) {
var arr = [];
var len = str.length;
for (var i = 0; i < len; i += 2)
arr.push(parseInt(str.substr(i, 2), 16));
return new Uint8Array(arr);
};
/**
* Encode ArrayBuffer or TypedArray to string with code (like output of legacy atob)
* @param data
* @return {string}
*/
exports.arrayBufferToString = function (data) {
var bytes = sanitizeTypedArrayAndArrayBuffer(data);
var arr = new Array(bytes.length);
bytes.forEach(function (x, i) { arr[i] = x; });
return String.fromCharCode.apply(null, arr);
};
/**
* Decode string with code (like output of legacy atob) to Uint8Array
* @param str
* @return {Uint8Array}
*/
exports.stringToArrayBuffer = function (str) {
var bytes = new Uint8Array(str.length);
return bytes.map(function (_x, i) { return str.charCodeAt(i); });
};
+40
View File
@@ -0,0 +1,40 @@
"use strict";
/**
* this module handles the difference between window (browser) and node js for specific functions and libraries.
* env.js
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.getEnvBtoa = function () {
if (typeof window !== 'undefined')
return window.btoa; // browser
else
return nodeBtoa; // node
};
exports.getEnvAtob = function () {
if (typeof window !== 'undefined')
return window.atob; // browser
else
return nodeAtob; // node
};
var nodeBtoa = function (str) {
if (typeof Buffer === 'undefined')
throw new Error('UnsupportedEnvironment');
var buffer;
var type = Object.prototype.toString.call(str).slice(8, -1);
var typedArrays = ['ArrayBuffer', 'TypedArray', 'Uint8Array', 'Int8Array', 'Uint8ClampedArray', 'Int16Array', 'Uint16Array', 'Int32Array', 'Uint32Array', 'Float32Array', 'Float64Array'];
if (Buffer.isBuffer(str)) {
buffer = str;
}
else if (typedArrays.indexOf(type) >= 0) {
buffer = Buffer.from(str);
}
else {
buffer = Buffer.from(str.toString(), 'binary');
}
return buffer.toString('base64');
};
var nodeAtob = function (str) {
if (typeof Buffer === 'undefined')
throw new Error('UnsupportedEnvironment');
return Buffer.from(str, 'base64').toString('binary');
};
+77
View File
@@ -0,0 +1,77 @@
"use strict";
/**
* formatter.js
*/
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var encoder = __importStar(require("./encoder"));
var supportedPEMTypes = {
'public': 'PUBLIC KEY',
'private': 'PRIVATE KEY',
'encryptedPrivate': 'ENCRYPTED PRIVATE KEY',
'certificate': 'CERTIFICATE',
'certRequest': 'CERTIFICATE REQUEST'
};
/**
* Convert PEM armored string to Uint8Array
* @param keydataB64Pem
* @return {Uint8Array}
*/
exports.pemToBin = function (keydataB64Pem) {
var keydataB64 = dearmorPem(keydataB64Pem);
return encoder.decodeBase64(keydataB64);
};
/**
* Convert ArrayBuffer or TypedArray to PEM armored string with a specified type
* @param keydata
* @param type
* @return {string}
*/
exports.binToPem = function (keydata, type) {
var keydataB64 = encoder.encodeBase64(keydata);
return formatAsPem(keydataB64, type);
};
/**
* Armor the given Base64 string and return PEM formatted string
* @param str
* @param type
* @return {string}
*/
var formatAsPem = function (str, type) {
if (Object.keys(supportedPEMTypes).indexOf(type) < 0)
throw new Error('Unsupported type');
var typeString = supportedPEMTypes[type];
var finalString = "-----BEGIN " + typeString + "-----\n";
while (str.length > 0) {
finalString += str.substring(0, 64) + "\n";
str = str.substring(64);
}
finalString = finalString + "-----END " + typeString + "-----";
return finalString;
};
/**
* Dearmor the given PEM string and return Base64 string
* @param str
* @return {string}
*/
var dearmorPem = function (str) {
// const beginRegExp = RegExp('^-----[\s]*BEGIN[^-]*KEY-----$', 'gm');
// const endRegExp = RegExp('^-----[\s]*END[^-]*KEY-----$', 'gm');
var beginRegExp = RegExp('^-----[\s]*BEGIN[^-]*-----$', 'gm');
var endRegExp = RegExp('^-----[\s]*END[^-]*-----$', 'gm');
// check if the object starts from 'begin'
try {
var dearmored = str.split(beginRegExp)[1].split(endRegExp)[0];
dearmored = dearmored.replace(/\r?\n/g, '');
return dearmored;
}
catch (e) {
throw new Error('Invalid format as PEM');
}
};
+17
View File
@@ -0,0 +1,17 @@
"use strict";
/**
* index.ts
**/
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var encoder = __importStar(require("./encoder"));
exports.encoder = encoder;
var formatter = __importStar(require("./formatter"));
exports.formatter = formatter;
exports.default = { encoder: encoder, formatter: formatter };
+1
View File
@@ -0,0 +1 @@
!function(r,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.jseu=e():r.jseu=e()}(this,function(){return function(r){var e={};function t(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return r[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=r,t.c=e,t.d=function(r,e,n){t.o(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:n})},t.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},t.t=function(r,e){if(1&e&&(r=t(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var o in r)t.d(n,o,function(e){return r[e]}.bind(null,o));return n},t.n=function(r){var e=r&&r.__esModule?function(){return r.default}:function(){return r};return t.d(e,"a",e),e},t.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},t.p="/home/circleci/repo/dist",t(t.s=1)}([function(r,e,t){"use strict";var n=this&&this.__importStar||function(r){if(r&&r.__esModule)return r;var e={};if(null!=r)for(var t in r)Object.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e.default=r,e};Object.defineProperty(e,"__esModule",{value:!0});var o=n(t(3));e.encodeBase64=function(r){var t="";return t="string"==typeof r?r:e.arrayBufferToString(r),o.getEnvBtoa()(t)},e.decodeBase64=function(r){var t=o.getEnvAtob()(r),n=e.stringToArrayBuffer(t);return i(n)};var u=function(r){if(r instanceof Uint8Array)return r;if(ArrayBuffer.isView(r)&&void 0!==r.buffer)return new Uint8Array(r.buffer);if(r instanceof ArrayBuffer)return new Uint8Array(r);throw new Error("Input must be an ArrayBuffer or a TypedArray")},i=function(r){for(var e=!0,t=0;t<r.length;t++)if(r[t]>126||r[t]<32&&13!==r[t]&&10!==r[t]){e=!1;break}var n=null;if(e){n="";for(t=0;t<r.length;t++)n+=String.fromCharCode(r[t])}else n=r;return n};e.encodeBase64Url=function(r){return e.encodeBase64(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")},e.decodeBase64Url=function(r){return r=r.replace(/-/g,"+").replace(/_/g,"/"),e.decodeBase64(r)},e.arrayBufferToHexString=function(r){for(var e=u(r),t="",n=0;n<e.length;n++){var o=(255&e[n]).toString(16);t+=o=1===o.length?"0"+o:o}return t},e.hexStringToArrayBuffer=function(r){for(var e=[],t=r.length,n=0;n<t;n+=2)e.push(parseInt(r.substr(n,2),16));return new Uint8Array(e)},e.arrayBufferToString=function(r){var e=u(r),t=new Array(e.length);return e.forEach(function(r,e){t[e]=r}),String.fromCharCode.apply(null,t)},e.stringToArrayBuffer=function(r){return new Uint8Array(r.length).map(function(e,t){return r.charCodeAt(t)})}},function(r,e,t){r.exports=t(2)},function(r,e,t){"use strict";var n=this&&this.__importStar||function(r){if(r&&r.__esModule)return r;var e={};if(null!=r)for(var t in r)Object.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e.default=r,e};Object.defineProperty(e,"__esModule",{value:!0});n(t(0)),n(t(4))},function(r,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getEnvBtoa=function(){return"undefined"!=typeof window?window.btoa:n},e.getEnvAtob=function(){return"undefined"!=typeof window?window.atob:o};var n=function(r){if("undefined"==typeof Buffer)throw new Error("UnsupportedEnvironment");var e=Object.prototype.toString.call(r).slice(8,-1);return(Buffer.isBuffer(r)?r:["ArrayBuffer","TypedArray","Uint8Array","Int8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array"].indexOf(e)>=0?Buffer.from(r):Buffer.from(r.toString(),"binary")).toString("base64")},o=function(r){if("undefined"==typeof Buffer)throw new Error("UnsupportedEnvironment");return Buffer.from(r,"base64").toString("binary")}},function(r,e,t){"use strict";var n=this&&this.__importStar||function(r){if(r&&r.__esModule)return r;var e={};if(null!=r)for(var t in r)Object.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e.default=r,e};Object.defineProperty(e,"__esModule",{value:!0});var o=n(t(0)),u={public:"PUBLIC KEY",private:"PRIVATE KEY",encryptedPrivate:"ENCRYPTED PRIVATE KEY",certificate:"CERTIFICATE",certRequest:"CERTIFICATE REQUEST"};e.pemToBin=function(r){var e=f(r);return o.decodeBase64(e)},e.binToPem=function(r,e){var t=o.encodeBase64(r);return i(t,e)};var i=function(r,e){if(Object.keys(u).indexOf(e)<0)throw new Error("Unsupported type");for(var t=u[e],n="-----BEGIN "+t+"-----\n";r.length>0;)n+=r.substring(0,64)+"\n",r=r.substring(64);return n=n+"-----END "+t+"-----"},f=function(r){var e=RegExp("^-----[s]*BEGIN[^-]*-----$","gm"),t=RegExp("^-----[s]*END[^-]*-----$","gm");try{var n=r.split(e)[1].split(t)[0];return n=n.replace(/\r?\n/g,"")}catch(r){throw new Error("Invalid format as PEM")}}}])});
+109
View File
@@ -0,0 +1,109 @@
{
"_args": [
[
"js-encoding-utils@0.5.3",
"/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series"
]
],
"_from": "js-encoding-utils@0.5.3",
"_id": "js-encoding-utils@0.5.3",
"_inBundle": false,
"_integrity": "sha512-GWEeXCVERJvMX/V8VLaJHIHe5K2m4dCXYujmbipK9NIUVxNS4J/PZfgIE+lveCvZgZpSY5tMUHOkh/ZHhPx84A==",
"_location": "/js-encoding-utils",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "js-encoding-utils@0.5.3",
"name": "js-encoding-utils",
"escapedName": "js-encoding-utils",
"rawSpec": "0.5.3",
"saveSpec": null,
"fetchSpec": "0.5.3"
},
"_requiredBy": [
"/js-crypto-ec",
"/js-crypto-key-utils",
"/js-crypto-pbkdf"
],
"_resolved": "https://registry.npmjs.org/js-encoding-utils/-/js-encoding-utils-0.5.3.tgz",
"_spec": "0.5.3",
"_where": "/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series",
"author": {
"name": "Jun Kurihara"
},
"bugs": {
"url": "https://github.com/junkurihara/jseu/issues"
},
"dependencies": {},
"description": "Miscellaneous Encoding Utilities for Crypto-related Objects in JavaScript",
"devDependencies": {
"@types/chai": "4.2.0",
"@types/mocha": "5.2.7",
"@types/node": "10.14.15",
"@typescript-eslint/eslint-plugin": "2.0.0",
"can-npm-publish": "1.3.1",
"chai": "4.2.0",
"cross-env": "5.2.0",
"eslint": "6.1.0",
"istanbul-instrumenter-loader": "3.0.1",
"jsdom": "15.1.1",
"karma": "4.2.0",
"karma-chrome-launcher": "3.1.0",
"karma-cli": "2.0.0",
"karma-coverage": "1.1.2",
"karma-coverage-istanbul-reporter": "2.1.0",
"karma-mocha": "1.3.0",
"karma-mocha-reporter": "2.2.5",
"karma-webpack": "4.0.2",
"lcov-result-merger": "^3.1.0",
"mocha": "6.2.0",
"mocha-sinon": "2.1.0",
"nyc": "14.1.1",
"ts-loader": "6.0.4",
"ts-node": "8.3.0",
"tsc": "1.20150623.0",
"typescript": "3.5.3",
"webpack": "4.39.2",
"webpack-cli": "3.3.6",
"webpack-common-shake": "2.1.0",
"webpack-merge": "4.2.1"
},
"homepage": "https://github.com/junkurihara/jseu#readme",
"keywords": [
"pem",
"der",
"base64",
"base64url",
"es6"
],
"license": "MIT",
"main": "dist/index.js",
"name": "js-encoding-utils",
"repository": {
"type": "git",
"url": "git+https://github.com/junkurihara/jseu.git"
},
"scripts": {
"analyze": "cross-env NODE_ENV=production webpack --mode production --optimize-minimize --json --config webpack.prod.js | webpack-bundle-size-analyzer",
"build": "rm -rf ./dist && cross-env NODE_ENV=production yarn tsc && yarn webpack:prod",
"cleanup": "rm -rf ./dist coverage .nyc_output ./node_modules ./test/html/*.bundle.js ./test/html/test.html",
"flow:version": "npm version --no-git-tag-version",
"html": "yarn webpack && yarn html:source && yarn html:bundle && yarn html:window",
"html:bundle": "cross-env TEST_ENV=bundle NODE_ENV=html yarn webpack",
"html:source": "cross-env TEST_ENV=source NODE_ENV=html yarn webpack",
"html:window": "cross-env TEST_ENV=window NODE_ENV=html yarn webpack",
"karma": "cross-env TEST_ENV=source ./node_modules/.bin/karma start",
"karma:bundle": "yarn webpack && cross-env TEST_ENV=bundle karma start",
"karma:window": "yarn webpack && cross-env TEST_ENV=window karma start",
"release:finish": "git flow release finish v$npm_package_version",
"release:push": "git push --all && git push origin v$npm_package_version",
"release:start": "can-npm-publish --vorbose && git flow release start v$npm_package_version",
"test": "nyc mocha --recursive $(find test -name '*.spec.ts')",
"test:bundle": "yarn webpack && cross-env TEST_ENV=bundle yarn test",
"tsc": "tsc --build ./tsconfig.json",
"webpack": "webpack --mode development --config webpack.dev.js",
"webpack:prod": "cross-env NODE_ENV=production webpack --optimize-minimize --mode production --config webpack.prod.js"
},
"version": "0.5.3"
}
+80
View File
@@ -0,0 +1,80 @@
{
"compilerOptions": {
/* Basic Options */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"lib": [
"dom",
"esnext",
"esnext.asynciterable"
], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "./dist", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
"strictNullChecks": true, /* Enable strict null checks. */
"strictFunctionTypes": true, /* Enable strict checking of function types. */
"strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
"strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
"noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
"alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
"noUnusedLocals": true, /* Report errors on unused locals. */
"noUnusedParameters": true, /* Report errors on unused parameters. */
"noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
"noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
"baseUrl": "./", /* Base directory to resolve non-absolute module names. */
"paths": {
"*": [
"./typings/*"
]
}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
"typeRoots": [
"node_modules/@types"
], /* List of folders to include type definitions from. */
"types": [
"node",
"mocha"
], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
/* Source Map Options */
// "sourceRoot": "./src" /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
"experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
"emitDecoratorMetadata": true /* Enables experimental support for emitting type metadata for decorators. */
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules",
"**/*.spec.ts"
]
}