fix(core): update

This commit is contained in:
Philipp Kunz 2021-02-20 17:51:30 +00:00
parent 788d74edeb
commit ca381efaec
15 changed files with 10475 additions and 612 deletions

6
dist_ts/index.d.ts vendored Normal file
View File

@ -0,0 +1,6 @@
export * from './smartcrypto.classes.smartcrypto';
export * from './smartcrypto.classes.keypair';
export * from './smartcrypto.classes.privatekey';
export * from './smartcrypto.classes.publickey';
import { nodeForge } from './smartcrypto.plugins';
export { nodeForge };

20
dist_ts/index.js Normal file
View File

@ -0,0 +1,20 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.nodeForge = void 0;
__exportStar(require("./smartcrypto.classes.smartcrypto"), exports);
__exportStar(require("./smartcrypto.classes.keypair"), exports);
__exportStar(require("./smartcrypto.classes.privatekey"), exports);
__exportStar(require("./smartcrypto.classes.publickey"), exports);
const smartcrypto_plugins_1 = require("./smartcrypto.plugins");
Object.defineProperty(exports, "nodeForge", { enumerable: true, get: function () { return smartcrypto_plugins_1.nodeForge; } });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7O0FBQUEsb0VBQWtEO0FBQ2xELGdFQUE4QztBQUM5QyxtRUFBaUQ7QUFDakQsa0VBQWdEO0FBRWhELCtEQUFrRDtBQUdoRCwwRkFITywrQkFBUyxPQUdQIn0=

View File

@ -0,0 +1,11 @@
import { PublicKey } from './smartcrypto.classes.publickey';
import { PrivateKey } from './smartcrypto.classes.privatekey';
export declare class KeyPair {
static createNewKeyPair(): Promise<KeyPair>;
publicKey: PublicKey;
privateKey: PrivateKey;
constructor(optionsArg: {
privateKey: PrivateKey;
publicKey: PublicKey;
});
}

View File

@ -0,0 +1,49 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.KeyPair = void 0;
const plugins = __importStar(require("./smartcrypto.plugins"));
const smartcrypto_classes_publickey_1 = require("./smartcrypto.classes.publickey");
const smartcrypto_classes_privatekey_1 = require("./smartcrypto.classes.privatekey");
class KeyPair {
constructor(optionsArg) {
this.privateKey = optionsArg.privateKey;
this.publicKey = optionsArg.publicKey;
}
// STATIC
static async createNewKeyPair() {
const done = plugins.smartpromise.defer();
const rsa = plugins.nodeForge.pki.rsa;
rsa.generateKeyPair({ bits: 2048, workers: 2 }, async (err, keypair) => {
if (err) {
console.log(err);
throw err;
}
done.resolve(new KeyPair({
privateKey: new smartcrypto_classes_privatekey_1.PrivateKey(keypair.privateKey),
publicKey: new smartcrypto_classes_publickey_1.PublicKey(keypair.publicKey)
}));
});
return done.promise;
}
}
exports.KeyPair = KeyPair;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic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FNBQVMsRUFBRSxJQUFJLHlDQUFTLENBQUMsT0FBTyxDQUFDLFNBQVMsQ0FBQzthQUM1QyxDQUFDLENBQ0gsQ0FBQztRQUNKLENBQUMsQ0FBQyxDQUFDO1FBQ0gsT0FBTyxJQUFJLENBQUMsT0FBTyxDQUFDO0lBQ3RCLENBQUM7Q0FVRjtBQTdCRCwwQkE2QkMifQ==

View File

@ -0,0 +1,9 @@
/// <reference types="node-forge" />
import * as plugins from './smartcrypto.plugins';
export declare class PrivateKey {
static createFromPrivateKey(pemString: string): PrivateKey;
static fromPemString(pemString: string): PrivateKey;
forgePrivateKey: plugins.nodeForge.pki.PrivateKey;
constructor(privateKeyArg: plugins.nodeForge.pki.PrivateKey);
toPemString(): string;
}

View File

@ -0,0 +1,41 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PrivateKey = void 0;
const plugins = __importStar(require("./smartcrypto.plugins"));
class PrivateKey {
constructor(privateKeyArg) {
this.forgePrivateKey = privateKeyArg;
}
// STATIC
static createFromPrivateKey(pemString) {
const privateKey = plugins.nodeForge.pki.privateKeyFromPem(pemString);
return new PrivateKey(privateKey);
}
static fromPemString(pemString) {
return new PrivateKey(plugins.nodeForge.pki.privateKeyFromPem(pemString));
}
toPemString() {
return plugins.nodeForge.pki.privateKeyToPem(this.forgePrivateKey);
}
}
exports.PrivateKey = PrivateKey;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRjcnlwdG8uY2xhc3Nlcy5wcml2YXRla2V5LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRjcnlwdG8uY2xhc3Nlcy5wcml2YXRla2V5LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSwrREFBaUQ7QUFFakQsTUFBYSxVQUFVO0lBY3JCLFlBQVksYUFBK0M7UUFDekQsSUFBSSxDQUFDLGVBQWUsR0FBRyxhQUFhLENBQUM7SUFDdkMsQ0FBQztJQWZELFNBQVM7SUFDRixNQUFNLENBQUMsb0JBQW9CLENBQUMsU0FBaUI7UUFDbEQsTUFBTSxVQUFVLEdBQUcsT0FBTyxDQUFDLFNBQVMsQ0FBQyxHQUFHLENBQUMsaUJBQWlCLENBQUMsU0FBUyxDQUFDLENBQUM7UUFDdEUsT0FBTyxJQUFJLFVBQVUsQ0FBQyxVQUFVLENBQUMsQ0FBQztJQUNwQyxDQUFDO0lBRU0sTUFBTSxDQUFDLGFBQWEsQ0FBQyxTQUFpQjtRQUMzQyxPQUFPLElBQUksVUFBVSxDQUFDLE9BQU8sQ0FBQyxTQUFTLENBQUMsR0FBRyxDQUFDLGlCQUFpQixDQUFDLFNBQVMsQ0FBQyxDQUFDLENBQUM7SUFDNUUsQ0FBQztJQVNNLFdBQVc7UUFDaEIsT0FBTyxPQUFPLENBQUMsU0FBUyxDQUFDLEdBQUcsQ0FBQyxlQUFlLENBQUMsSUFBSSxDQUFDLGVBQWUsQ0FBQyxDQUFDO0lBQ3JFLENBQUM7Q0FDRjtBQXJCRCxnQ0FxQkMifQ==

View File

@ -0,0 +1,9 @@
/// <reference types="node-forge" />
import * as plugins from './smartcrypto.plugins';
export declare class PublicKey {
static createFromPrivateKey(pemString: string): PublicKey;
static fromPemString(pemString: string): PublicKey;
forgePublicKey: plugins.nodeForge.pki.PublicKey;
constructor(publicKeyArg: plugins.nodeForge.pki.PublicKey);
toPemString(): string;
}

View File

@ -0,0 +1,41 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PublicKey = void 0;
const plugins = __importStar(require("./smartcrypto.plugins"));
class PublicKey {
constructor(publicKeyArg) {
this.forgePublicKey = publicKeyArg;
}
// STATIC
static createFromPrivateKey(pemString) {
const privateKey = plugins.nodeForge.pki.publicKeyFromPem(pemString);
return new PublicKey(privateKey);
}
static fromPemString(pemString) {
return new PublicKey(plugins.nodeForge.pki.publicKeyFromPem(pemString));
}
toPemString() {
return plugins.nodeForge.pki.publicKeyToPem(this.forgePublicKey);
}
}
exports.PublicKey = PublicKey;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRjcnlwdG8uY2xhc3Nlcy5wdWJsaWNrZXkuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGNyeXB0by5jbGFzc2VzLnB1YmxpY2tleS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsK0RBQWlEO0FBRWpELE1BQWEsU0FBUztJQWNwQixZQUFZLFlBQTZDO1FBQ3ZELElBQUksQ0FBQyxjQUFjLEdBQUcsWUFBWSxDQUFDO0lBQ3JDLENBQUM7SUFmRCxTQUFTO0lBQ0YsTUFBTSxDQUFDLG9CQUFvQixDQUFDLFNBQWlCO1FBQ2xELE1BQU0sVUFBVSxHQUFHLE9BQU8sQ0FBQyxTQUFTLENBQUMsR0FBRyxDQUFDLGdCQUFnQixDQUFDLFNBQVMsQ0FBQyxDQUFDO1FBQ3JFLE9BQU8sSUFBSSxTQUFTLENBQUMsVUFBVSxDQUFDLENBQUM7SUFDbkMsQ0FBQztJQUVNLE1BQU0sQ0FBQyxhQUFhLENBQUMsU0FBaUI7UUFDM0MsT0FBTyxJQUFJLFNBQVMsQ0FBQyxPQUFPLENBQUMsU0FBUyxDQUFDLEdBQUcsQ0FBQyxnQkFBZ0IsQ0FBQyxTQUFTLENBQUMsQ0FBQyxDQUFDO0lBQzFFLENBQUM7SUFTTSxXQUFXO1FBQ2hCLE9BQU8sT0FBTyxDQUFDLFNBQVMsQ0FBQyxHQUFHLENBQUMsY0FBYyxDQUFDLElBQUksQ0FBQyxjQUFjLENBQUMsQ0FBQztJQUNuRSxDQUFDO0NBQ0Y7QUFyQkQsOEJBcUJDIn0=

View File

@ -0,0 +1,4 @@
import { KeyPair } from './smartcrypto.classes.keypair';
export declare class Smartcrypto {
createKeyPair(): Promise<KeyPair>;
}

View File

@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Smartcrypto = void 0;
const smartcrypto_classes_keypair_1 = require("./smartcrypto.classes.keypair");
class Smartcrypto {
async createKeyPair() {
return smartcrypto_classes_keypair_1.KeyPair.createNewKeyPair();
}
}
exports.Smartcrypto = Smartcrypto;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRjcnlwdG8uY2xhc3Nlcy5zbWFydGNyeXB0by5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Y3J5cHRvLmNsYXNzZXMuc21hcnRjcnlwdG8udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQ0EsK0VBQXdEO0FBRXhELE1BQWEsV0FBVztJQUNmLEtBQUssQ0FBQyxhQUFhO1FBQ3hCLE9BQU8scUNBQU8sQ0FBQyxnQkFBZ0IsRUFBRSxDQUFDO0lBQ3BDLENBQUM7Q0FDRjtBQUpELGtDQUlDIn0=

4
dist_ts/smartcrypto.plugins.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
import * as smartpromise from '@pushrocks/smartpromise';
export { smartpromise };
import * as nodeForge from 'node-forge';
export { nodeForge };

View File

@ -0,0 +1,29 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.nodeForge = exports.smartpromise = void 0;
// @pushrocks scope
const smartpromise = __importStar(require("@pushrocks/smartpromise"));
exports.smartpromise = smartpromise;
// third party scope
const nodeForge = __importStar(require("node-forge"));
exports.nodeForge = nodeForge;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRjcnlwdG8ucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Y3J5cHRvLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLG1CQUFtQjtBQUNuQixzRUFBd0Q7QUFFL0Msb0NBQVk7QUFFckIsb0JBQW9CO0FBQ3BCLHNEQUF3QztBQUUvQiw4QkFBUyJ9

10849
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -3,27 +3,26 @@
"version": "1.0.9", "version": "1.0.9",
"private": false, "private": false,
"description": "easy crypto methods", "description": "easy crypto methods",
"main": "dist/index.js", "main": "dist_ts/index.js",
"typings": "dist/index.d.ts", "typings": "dist_ts/index.d.ts",
"author": "Lossless GmbH", "author": "Lossless GmbH",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"test": "(tstest test/)", "test": "(tstest test/ --web)",
"build": "(tsbuild)", "build": "(tsbuild --web)"
"format": "(gitzone format)"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.17", "@gitzone/tsbuild": "^2.1.25",
"@gitzone/tstest": "^1.0.24", "@gitzone/tstest": "^1.0.52",
"@pushrocks/tapbundle": "^3.0.13", "@pushrocks/tapbundle": "^3.2.14",
"@types/node": "^12.7.8", "@types/node": "^14.14.31",
"tslint": "^5.20.0", "tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0" "tslint-config-prettier": "^1.18.0"
}, },
"dependencies": { "dependencies": {
"@pushrocks/smartpromise": "^3.0.5", "@pushrocks/smartpromise": "^3.1.3",
"@types/node-forge": "^0.8.6", "@types/node-forge": "^0.9.7",
"node-forge": "^0.9.1" "node-forge": "^0.10.0"
}, },
"files": [ "files": [
"ts/*", "ts/*",

View File

@ -1,8 +1,11 @@
import { expect, tap } from '@pushrocks/tapbundle'; import { expect, tap } from '@pushrocks/tapbundle';
import * as smartcrypto from '../ts/index'; import * as smartcrypto from '../ts/index';
let testSmartCrypto: smartcrypto.Smartcrypto;
tap.test('first test', async () => { tap.test('first test', async () => {
console.log('hi'); testSmartCrypto = new smartcrypto.Smartcrypto();
expect(testSmartCrypto).to.be.instanceOf(smartcrypto.Smartcrypto);
}); });
tap.start(); tap.start();