@push.rocks/smartcrypto 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,8 @@
1
+ /**
2
+ * autocreated commitinfo by @pushrocks/commitinfo
3
+ */
4
+ export declare const commitinfo: {
5
+ name: string;
6
+ version: string;
7
+ description: string;
8
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * autocreated commitinfo by @pushrocks/commitinfo
3
+ */
4
+ export const commitinfo = {
5
+ name: '@pushrocks/smartcrypto',
6
+ version: '2.0.1',
7
+ description: 'easy crypto methods'
8
+ };
9
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSx3QkFBd0I7SUFDOUIsT0FBTyxFQUFFLE9BQU87SUFDaEIsV0FBVyxFQUFFLHFCQUFxQjtDQUNuQyxDQUFBIn0=
@@ -0,0 +1,6 @@
1
+ export * from './smartcrypto.classes.smartcrypto.js';
2
+ export * from './smartcrypto.classes.keypair.js';
3
+ export * from './smartcrypto.classes.privatekey.js';
4
+ export * from './smartcrypto.classes.publickey.js';
5
+ import { nodeForge } from './smartcrypto.plugins.js';
6
+ export { nodeForge };
@@ -0,0 +1,7 @@
1
+ export * from './smartcrypto.classes.smartcrypto.js';
2
+ export * from './smartcrypto.classes.keypair.js';
3
+ export * from './smartcrypto.classes.privatekey.js';
4
+ export * from './smartcrypto.classes.publickey.js';
5
+ import { nodeForge } from './smartcrypto.plugins.js';
6
+ export { nodeForge };
7
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLHNDQUFzQyxDQUFDO0FBQ3JELGNBQWMsa0NBQWtDLENBQUM7QUFDakQsY0FBYyxxQ0FBcUMsQ0FBQztBQUNwRCxjQUFjLG9DQUFvQyxDQUFDO0FBRW5ELE9BQU8sRUFBRSxTQUFTLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUVyRCxPQUFPLEVBQUUsU0FBUyxFQUFFLENBQUMifQ==
@@ -0,0 +1,11 @@
1
+ import { PublicKey } from './smartcrypto.classes.publickey.js';
2
+ import { PrivateKey } from './smartcrypto.classes.privatekey.js';
3
+ export declare class KeyPair {
4
+ static createNewKeyPair(): Promise<KeyPair>;
5
+ publicKey: PublicKey;
6
+ privateKey: PrivateKey;
7
+ constructor(optionsArg: {
8
+ privateKey: PrivateKey;
9
+ publicKey: PublicKey;
10
+ });
11
+ }
@@ -0,0 +1,26 @@
1
+ import * as plugins from './smartcrypto.plugins.js';
2
+ import { PublicKey } from './smartcrypto.classes.publickey.js';
3
+ import { PrivateKey } from './smartcrypto.classes.privatekey.js';
4
+ export class KeyPair {
5
+ constructor(optionsArg) {
6
+ this.privateKey = optionsArg.privateKey;
7
+ this.publicKey = optionsArg.publicKey;
8
+ }
9
+ // STATIC
10
+ static async createNewKeyPair() {
11
+ const done = plugins.smartpromise.defer();
12
+ const rsa = plugins.nodeForge.pki.rsa;
13
+ rsa.generateKeyPair({ bits: 2048, workers: 2 }, async (err, keypair) => {
14
+ if (err) {
15
+ console.log(err);
16
+ throw err;
17
+ }
18
+ done.resolve(new KeyPair({
19
+ privateKey: new PrivateKey(keypair.privateKey),
20
+ publicKey: new PublicKey(keypair.publicKey),
21
+ }));
22
+ });
23
+ return done.promise;
24
+ }
25
+ }
26
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRjcnlwdG8uY2xhc3Nlcy5rZXlwYWlyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRjcnlwdG8uY2xhc3Nlcy5rZXlwYWlyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxPQUFPLE1BQU0sMEJBQTBCLENBQUM7QUFDcEQsT0FBTyxFQUFFLFNBQVMsRUFBRSxNQUFNLG9DQUFvQyxDQUFDO0FBQy9ELE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxxQ0FBcUMsQ0FBQztBQUVqRSxNQUFNLE9BQU8sT0FBTztJQXlCbEIsWUFBWSxVQUE0RDtRQUN0RSxJQUFJLENBQUMsVUFBVSxHQUFHLFVBQVUsQ0FBQyxVQUFVLENBQUM7UUFDeEMsSUFBSSxDQUFDLFNBQVMsR0FBRyxVQUFVLENBQUMsU0FBUyxDQUFDO0lBQ3hDLENBQUM7SUEzQkQsU0FBUztJQUNGLE1BQU0sQ0FBQyxLQUFLLENBQUMsZ0JBQWdCO1FBQ2xDLE1BQU0sSUFBSSxHQUFHLE9BQU8sQ0FBQyxZQUFZLENBQUMsS0FBSyxFQUFXLENBQUM7UUFDbkQsTUFBTSxHQUFHLEdBQUcsT0FBTyxDQUFDLFNBQVMsQ0FBQyxHQUFHLENBQUMsR0FBRyxDQUFDO1FBQ3RDLEdBQUcsQ0FBQyxlQUFlLENBQUMsRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFLE9BQU8sRUFBRSxDQUFDLEVBQUUsRUFBRSxLQUFLLEVBQUUsR0FBRyxFQUFFLE9BQU8sRUFBRSxFQUFFO1lBQ3JFLElBQUksR0FBRyxFQUFFO2dCQUNQLE9BQU8sQ0FBQyxHQUFHLENBQUMsR0FBRyxDQUFDLENBQUM7Z0JBQ2pCLE1BQU0sR0FBRyxDQUFDO2FBQ1g7WUFFRCxJQUFJLENBQUMsT0FBTyxDQUNWLElBQUksT0FBTyxDQUFDO2dCQUNWLFVBQVUsRUFBRSxJQUFJLFVBQVUsQ0FBQyxPQUFPLENBQUMsVUFBVSxDQUFDO2dCQUM5QyxTQUFTLEVBQUUsSUFBSSxTQUFTLENBQUMsT0FBTyxDQUFDLFNBQVMsQ0FBQzthQUM1QyxDQUFDLENBQ0gsQ0FBQztRQUNKLENBQUMsQ0FBQyxDQUFDO1FBQ0gsT0FBTyxJQUFJLENBQUMsT0FBTyxDQUFDO0lBQ3RCLENBQUM7Q0FVRiJ9
@@ -0,0 +1,9 @@
1
+ /// <reference types="node-forge" />
2
+ import * as plugins from './smartcrypto.plugins.js';
3
+ export declare class PrivateKey {
4
+ static createFromPrivateKey(pemString: string): PrivateKey;
5
+ static fromPemString(pemString: string): PrivateKey;
6
+ forgePrivateKey: plugins.nodeForge.pki.PrivateKey;
7
+ constructor(privateKeyArg: plugins.nodeForge.pki.PrivateKey);
8
+ toPemString(): string;
9
+ }
@@ -0,0 +1,18 @@
1
+ import * as plugins from './smartcrypto.plugins.js';
2
+ export class PrivateKey {
3
+ constructor(privateKeyArg) {
4
+ this.forgePrivateKey = privateKeyArg;
5
+ }
6
+ // STATIC
7
+ static createFromPrivateKey(pemString) {
8
+ const privateKey = plugins.nodeForge.pki.privateKeyFromPem(pemString);
9
+ return new PrivateKey(privateKey);
10
+ }
11
+ static fromPemString(pemString) {
12
+ return new PrivateKey(plugins.nodeForge.pki.privateKeyFromPem(pemString));
13
+ }
14
+ toPemString() {
15
+ return plugins.nodeForge.pki.privateKeyToPem(this.forgePrivateKey);
16
+ }
17
+ }
18
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRjcnlwdG8uY2xhc3Nlcy5wcml2YXRla2V5LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRjcnlwdG8uY2xhc3Nlcy5wcml2YXRla2V5LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxPQUFPLE1BQU0sMEJBQTBCLENBQUM7QUFFcEQsTUFBTSxPQUFPLFVBQVU7SUFjckIsWUFBWSxhQUErQztRQUN6RCxJQUFJLENBQUMsZUFBZSxHQUFHLGFBQWEsQ0FBQztJQUN2QyxDQUFDO0lBZkQsU0FBUztJQUNGLE1BQU0sQ0FBQyxvQkFBb0IsQ0FBQyxTQUFpQjtRQUNsRCxNQUFNLFVBQVUsR0FBRyxPQUFPLENBQUMsU0FBUyxDQUFDLEdBQUcsQ0FBQyxpQkFBaUIsQ0FBQyxTQUFTLENBQUMsQ0FBQztRQUN0RSxPQUFPLElBQUksVUFBVSxDQUFDLFVBQVUsQ0FBQyxDQUFDO0lBQ3BDLENBQUM7SUFFTSxNQUFNLENBQUMsYUFBYSxDQUFDLFNBQWlCO1FBQzNDLE9BQU8sSUFBSSxVQUFVLENBQUMsT0FBTyxDQUFDLFNBQVMsQ0FBQyxHQUFHLENBQUMsaUJBQWlCLENBQUMsU0FBUyxDQUFDLENBQUMsQ0FBQztJQUM1RSxDQUFDO0lBU00sV0FBVztRQUNoQixPQUFPLE9BQU8sQ0FBQyxTQUFTLENBQUMsR0FBRyxDQUFDLGVBQWUsQ0FBQyxJQUFJLENBQUMsZUFBZSxDQUFDLENBQUM7SUFDckUsQ0FBQztDQUNGIn0=
@@ -0,0 +1,9 @@
1
+ /// <reference types="node-forge" />
2
+ import * as plugins from './smartcrypto.plugins.js';
3
+ export declare class PublicKey {
4
+ static createFromPrivateKey(pemString: string): PublicKey;
5
+ static fromPemString(pemString: string): PublicKey;
6
+ forgePublicKey: plugins.nodeForge.pki.PublicKey;
7
+ constructor(publicKeyArg: plugins.nodeForge.pki.PublicKey);
8
+ toPemString(): string;
9
+ }
@@ -0,0 +1,18 @@
1
+ import * as plugins from './smartcrypto.plugins.js';
2
+ export class PublicKey {
3
+ constructor(publicKeyArg) {
4
+ this.forgePublicKey = publicKeyArg;
5
+ }
6
+ // STATIC
7
+ static createFromPrivateKey(pemString) {
8
+ const privateKey = plugins.nodeForge.pki.publicKeyFromPem(pemString);
9
+ return new PublicKey(privateKey);
10
+ }
11
+ static fromPemString(pemString) {
12
+ return new PublicKey(plugins.nodeForge.pki.publicKeyFromPem(pemString));
13
+ }
14
+ toPemString() {
15
+ return plugins.nodeForge.pki.publicKeyToPem(this.forgePublicKey);
16
+ }
17
+ }
18
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRjcnlwdG8uY2xhc3Nlcy5wdWJsaWNrZXkuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGNyeXB0by5jbGFzc2VzLnB1YmxpY2tleS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssT0FBTyxNQUFNLDBCQUEwQixDQUFDO0FBRXBELE1BQU0sT0FBTyxTQUFTO0lBY3BCLFlBQVksWUFBNkM7UUFDdkQsSUFBSSxDQUFDLGNBQWMsR0FBRyxZQUFZLENBQUM7SUFDckMsQ0FBQztJQWZELFNBQVM7SUFDRixNQUFNLENBQUMsb0JBQW9CLENBQUMsU0FBaUI7UUFDbEQsTUFBTSxVQUFVLEdBQUcsT0FBTyxDQUFDLFNBQVMsQ0FBQyxHQUFHLENBQUMsZ0JBQWdCLENBQUMsU0FBUyxDQUFDLENBQUM7UUFDckUsT0FBTyxJQUFJLFNBQVMsQ0FBQyxVQUFVLENBQUMsQ0FBQztJQUNuQyxDQUFDO0lBRU0sTUFBTSxDQUFDLGFBQWEsQ0FBQyxTQUFpQjtRQUMzQyxPQUFPLElBQUksU0FBUyxDQUFDLE9BQU8sQ0FBQyxTQUFTLENBQUMsR0FBRyxDQUFDLGdCQUFnQixDQUFDLFNBQVMsQ0FBQyxDQUFDLENBQUM7SUFDMUUsQ0FBQztJQVNNLFdBQVc7UUFDaEIsT0FBTyxPQUFPLENBQUMsU0FBUyxDQUFDLEdBQUcsQ0FBQyxjQUFjLENBQUMsSUFBSSxDQUFDLGNBQWMsQ0FBQyxDQUFDO0lBQ25FLENBQUM7Q0FDRiJ9
@@ -0,0 +1,4 @@
1
+ import { KeyPair } from './smartcrypto.classes.keypair.js';
2
+ export declare class Smartcrypto {
3
+ createKeyPair(): Promise<KeyPair>;
4
+ }
@@ -0,0 +1,8 @@
1
+ import './smartcrypto.plugins.js';
2
+ import { KeyPair } from './smartcrypto.classes.keypair.js';
3
+ export class Smartcrypto {
4
+ async createKeyPair() {
5
+ return KeyPair.createNewKeyPair();
6
+ }
7
+ }
8
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRjcnlwdG8uY2xhc3Nlcy5zbWFydGNyeXB0by5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Y3J5cHRvLmNsYXNzZXMuc21hcnRjcnlwdG8udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBeUIsMEJBQTBCLENBQUM7QUFDcEQsT0FBTyxFQUFFLE9BQU8sRUFBRSxNQUFNLGtDQUFrQyxDQUFDO0FBRTNELE1BQU0sT0FBTyxXQUFXO0lBQ2YsS0FBSyxDQUFDLGFBQWE7UUFDeEIsT0FBTyxPQUFPLENBQUMsZ0JBQWdCLEVBQUUsQ0FBQztJQUNwQyxDQUFDO0NBQ0YifQ==
@@ -0,0 +1,4 @@
1
+ import * as smartpromise from '@pushrocks/smartpromise';
2
+ export { smartpromise };
3
+ import nodeForge from 'node-forge';
4
+ export { nodeForge };
@@ -0,0 +1,7 @@
1
+ // @pushrocks scope
2
+ import * as smartpromise from '@pushrocks/smartpromise';
3
+ export { smartpromise };
4
+ // third party scope
5
+ import nodeForge from 'node-forge';
6
+ export { nodeForge };
7
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRjcnlwdG8ucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Y3J5cHRvLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsbUJBQW1CO0FBQ25CLE9BQU8sS0FBSyxZQUFZLE1BQU0seUJBQXlCLENBQUM7QUFFeEQsT0FBTyxFQUFFLFlBQVksRUFBRSxDQUFDO0FBRXhCLG9CQUFvQjtBQUNwQixPQUFPLFNBQVMsTUFBTSxZQUFZLENBQUM7QUFFbkMsT0FBTyxFQUFFLFNBQVMsRUFBRSxDQUFDIn0=
package/license ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2019 Lossless GmbH (hello@lossless.com)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
package/npmextra.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "gitzone": {
3
+ "projectType": "npm",
4
+ "module": {
5
+ "githost": "gitlab.com",
6
+ "gitscope": "pushrocks",
7
+ "gitrepo": "smartcrypto",
8
+ "description": "easy crypto methods",
9
+ "npmPackagename": "@pushrocks/smartcrypto",
10
+ "license": "MIT",
11
+ "projectDomain": "push.rocks"
12
+ }
13
+ },
14
+ "npmci": {
15
+ "npmGlobalTools": [],
16
+ "npmAccessLevel": "public"
17
+ }
18
+ }
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@push.rocks/smartcrypto",
3
+ "version": "2.0.1",
4
+ "private": false,
5
+ "description": "easy crypto methods",
6
+ "main": "dist_ts/index.js",
7
+ "typings": "dist_ts/index.d.ts",
8
+ "author": "Lossless GmbH",
9
+ "license": "MIT",
10
+ "scripts": {
11
+ "test": "(tstest test/ --web)",
12
+ "build": "(tsbuild --web)",
13
+ "buildDocs": "tsdoc"
14
+ },
15
+ "devDependencies": {
16
+ "@gitzone/tsbuild": "^2.1.25",
17
+ "@gitzone/tsrun": "^1.2.39",
18
+ "@gitzone/tstest": "^1.0.52",
19
+ "@pushrocks/tapbundle": "^5.0.4",
20
+ "@types/node": "^18.11.4"
21
+ },
22
+ "dependencies": {
23
+ "@pushrocks/smartpromise": "^3.1.3",
24
+ "@types/node-forge": "^1.3.0",
25
+ "node-forge": "^1.3.1"
26
+ },
27
+ "files": [
28
+ "ts/**/*",
29
+ "ts_web/**/*",
30
+ "dist/**/*",
31
+ "dist_*/**/*",
32
+ "dist_ts/**/*",
33
+ "dist_ts_web/**/*",
34
+ "assets/**/*",
35
+ "cli.js",
36
+ "npmextra.json",
37
+ "readme.md"
38
+ ],
39
+ "browserslist": [
40
+ "last 1 chrome versions"
41
+ ],
42
+ "type": "module"
43
+ }
package/readme.md ADDED
@@ -0,0 +1,42 @@
1
+ # @pushrocks/smartcrypto
2
+ easy crypto methods
3
+
4
+ ## Availabililty and Links
5
+ * [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartcrypto)
6
+ * [gitlab.com (source)](https://gitlab.com/pushrocks/smartcrypto)
7
+ * [github.com (source mirror)](https://github.com/pushrocks/smartcrypto)
8
+ * [docs (typedoc)](https://pushrocks.gitlab.io/smartcrypto/)
9
+
10
+ ## Status for master
11
+
12
+ Status Category | Status Badge
13
+ -- | --
14
+ GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartcrypto/badges/master/pipeline.svg)](https://lossless.cloud)
15
+ GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartcrypto/badges/master/coverage.svg)](https://lossless.cloud)
16
+ npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smartcrypto)](https://lossless.cloud)
17
+ Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartcrypto)](https://lossless.cloud)
18
+ TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
19
+ node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
20
+ Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
21
+ PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/smartcrypto)](https://lossless.cloud)
22
+ PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartcrypto)](https://lossless.cloud)
23
+ BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartcrypto)](https://lossless.cloud)
24
+ Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
25
+
26
+ ## Usage
27
+
28
+ ## Contribution
29
+
30
+ We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
31
+
32
+
33
+ ## Contribution
34
+
35
+ We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
36
+
37
+ For further information read the linked docs at the top of this readme.
38
+
39
+ > MIT licensed | **&copy;** [Lossless GmbH](https://lossless.gmbh)
40
+ | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
41
+
42
+ [![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)
@@ -0,0 +1,8 @@
1
+ /**
2
+ * autocreated commitinfo by @pushrocks/commitinfo
3
+ */
4
+ export const commitinfo = {
5
+ name: '@pushrocks/smartcrypto',
6
+ version: '2.0.1',
7
+ description: 'easy crypto methods'
8
+ }
package/ts/index.ts ADDED
@@ -0,0 +1,8 @@
1
+ export * from './smartcrypto.classes.smartcrypto.js';
2
+ export * from './smartcrypto.classes.keypair.js';
3
+ export * from './smartcrypto.classes.privatekey.js';
4
+ export * from './smartcrypto.classes.publickey.js';
5
+
6
+ import { nodeForge } from './smartcrypto.plugins.js';
7
+
8
+ export { nodeForge };
@@ -0,0 +1,34 @@
1
+ import * as plugins from './smartcrypto.plugins.js';
2
+ import { PublicKey } from './smartcrypto.classes.publickey.js';
3
+ import { PrivateKey } from './smartcrypto.classes.privatekey.js';
4
+
5
+ export class KeyPair {
6
+ // STATIC
7
+ public static async createNewKeyPair(): Promise<KeyPair> {
8
+ const done = plugins.smartpromise.defer<KeyPair>();
9
+ const rsa = plugins.nodeForge.pki.rsa;
10
+ rsa.generateKeyPair({ bits: 2048, workers: 2 }, async (err, keypair) => {
11
+ if (err) {
12
+ console.log(err);
13
+ throw err;
14
+ }
15
+
16
+ done.resolve(
17
+ new KeyPair({
18
+ privateKey: new PrivateKey(keypair.privateKey),
19
+ publicKey: new PublicKey(keypair.publicKey),
20
+ })
21
+ );
22
+ });
23
+ return done.promise;
24
+ }
25
+
26
+ // INSTANCE
27
+ public publicKey: PublicKey;
28
+ public privateKey: PrivateKey;
29
+
30
+ constructor(optionsArg: { privateKey: PrivateKey; publicKey: PublicKey }) {
31
+ this.privateKey = optionsArg.privateKey;
32
+ this.publicKey = optionsArg.publicKey;
33
+ }
34
+ }
@@ -0,0 +1,24 @@
1
+ import * as plugins from './smartcrypto.plugins.js';
2
+
3
+ export class PrivateKey {
4
+ // STATIC
5
+ public static createFromPrivateKey(pemString: string) {
6
+ const privateKey = plugins.nodeForge.pki.privateKeyFromPem(pemString);
7
+ return new PrivateKey(privateKey);
8
+ }
9
+
10
+ public static fromPemString(pemString: string) {
11
+ return new PrivateKey(plugins.nodeForge.pki.privateKeyFromPem(pemString));
12
+ }
13
+
14
+ // INSTANCE
15
+ public forgePrivateKey: plugins.nodeForge.pki.PrivateKey;
16
+
17
+ constructor(privateKeyArg: plugins.nodeForge.pki.PrivateKey) {
18
+ this.forgePrivateKey = privateKeyArg;
19
+ }
20
+
21
+ public toPemString(): string {
22
+ return plugins.nodeForge.pki.privateKeyToPem(this.forgePrivateKey);
23
+ }
24
+ }
@@ -0,0 +1,24 @@
1
+ import * as plugins from './smartcrypto.plugins.js';
2
+
3
+ export class PublicKey {
4
+ // STATIC
5
+ public static createFromPrivateKey(pemString: string) {
6
+ const privateKey = plugins.nodeForge.pki.publicKeyFromPem(pemString);
7
+ return new PublicKey(privateKey);
8
+ }
9
+
10
+ public static fromPemString(pemString: string) {
11
+ return new PublicKey(plugins.nodeForge.pki.publicKeyFromPem(pemString));
12
+ }
13
+
14
+ // INSTANCE
15
+ public forgePublicKey: plugins.nodeForge.pki.PublicKey;
16
+
17
+ constructor(publicKeyArg: plugins.nodeForge.pki.PublicKey) {
18
+ this.forgePublicKey = publicKeyArg;
19
+ }
20
+
21
+ public toPemString(): string {
22
+ return plugins.nodeForge.pki.publicKeyToPem(this.forgePublicKey);
23
+ }
24
+ }
@@ -0,0 +1,8 @@
1
+ import * as plugins from './smartcrypto.plugins.js';
2
+ import { KeyPair } from './smartcrypto.classes.keypair.js';
3
+
4
+ export class Smartcrypto {
5
+ public async createKeyPair(): Promise<KeyPair> {
6
+ return KeyPair.createNewKeyPair();
7
+ }
8
+ }
@@ -0,0 +1,9 @@
1
+ // @pushrocks scope
2
+ import * as smartpromise from '@pushrocks/smartpromise';
3
+
4
+ export { smartpromise };
5
+
6
+ // third party scope
7
+ import nodeForge from 'node-forge';
8
+
9
+ export { nodeForge };