Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
0719484f64 | |||
bd94115cb7 | |||
72a696908a | |||
f3d63e027f | |||
5192008320 | |||
6595d61562 | |||
9e6cb240dd | |||
03175e208a | |||
2be99bdf48 | |||
0e21c84ab4 | |||
c4c205066c | |||
44c2adf45d |
@ -14,4 +14,4 @@
|
|||||||
"npmGlobalTools": [],
|
"npmGlobalTools": [],
|
||||||
"npmAccessLevel": "public"
|
"npmAccessLevel": "public"
|
||||||
}
|
}
|
||||||
}
|
}
|
21
package-lock.json
generated
21
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartcrypto",
|
"name": "@pushrocks/smartcrypto",
|
||||||
"version": "1.0.2",
|
"version": "1.0.8",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -259,8 +259,7 @@
|
|||||||
"@pushrocks/smartpromise": {
|
"@pushrocks/smartpromise": {
|
||||||
"version": "3.0.5",
|
"version": "3.0.5",
|
||||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-3.0.5.tgz",
|
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-3.0.5.tgz",
|
||||||
"integrity": "sha512-9kHBWyDFjQ6cV1rseOfge02EH6huh/mrtqxlFoJoxnMaGWf5F8H3UEsskBBUGI6QKE1Bl8evr74AIKWwJ0r/bA==",
|
"integrity": "sha512-9kHBWyDFjQ6cV1rseOfge02EH6huh/mrtqxlFoJoxnMaGWf5F8H3UEsskBBUGI6QKE1Bl8evr74AIKWwJ0r/bA=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"@pushrocks/smartrequest": {
|
"@pushrocks/smartrequest": {
|
||||||
"version": "1.1.36",
|
"version": "1.1.36",
|
||||||
@ -406,8 +405,15 @@
|
|||||||
"@types/node": {
|
"@types/node": {
|
||||||
"version": "12.7.8",
|
"version": "12.7.8",
|
||||||
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-12.7.8.tgz",
|
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-12.7.8.tgz",
|
||||||
"integrity": "sha512-FMdVn84tJJdV+xe+53sYiZS4R5yn1mAIxfj+DVoNiQjTYz1+OYmjwEZr1ev9nU0axXwda0QDbYl06QHanRVH3A==",
|
"integrity": "sha512-FMdVn84tJJdV+xe+53sYiZS4R5yn1mAIxfj+DVoNiQjTYz1+OYmjwEZr1ev9nU0axXwda0QDbYl06QHanRVH3A=="
|
||||||
"dev": true
|
},
|
||||||
|
"@types/node-forge": {
|
||||||
|
"version": "0.8.6",
|
||||||
|
"resolved": "https://verdaccio.lossless.one/@types%2fnode-forge/-/node-forge-0.8.6.tgz",
|
||||||
|
"integrity": "sha512-m2G+ipvx+1+BU4LrwrHcEGDk1MnioEVxTnCrkFsKT+BdDl/8OD3WbtspPFj3osnix9fzDIfy2O9p/AFyH3fTzg==",
|
||||||
|
"requires": {
|
||||||
|
"@types/node": "*"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"@types/through2": {
|
"@types/through2": {
|
||||||
"version": "2.0.34",
|
"version": "2.0.34",
|
||||||
@ -1075,6 +1081,11 @@
|
|||||||
"integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==",
|
"integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node-forge": {
|
||||||
|
"version": "0.9.1",
|
||||||
|
"resolved": "https://verdaccio.lossless.one/node-forge/-/node-forge-0.9.1.tgz",
|
||||||
|
"integrity": "sha512-G6RlQt5Sb4GMBzXvhfkeFmbqR6MzhtnT7VTHuLadjkii3rdYHNdw0m8zA4BTxVIh68FicCQ2NSUANpsqkr9jvQ=="
|
||||||
|
},
|
||||||
"npm-run-path": {
|
"npm-run-path": {
|
||||||
"version": "2.0.2",
|
"version": "2.0.2",
|
||||||
"resolved": "https://verdaccio.lossless.one/npm-run-path/-/npm-run-path-2.0.2.tgz",
|
"resolved": "https://verdaccio.lossless.one/npm-run-path/-/npm-run-path-2.0.2.tgz",
|
||||||
|
19
package.json
19
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartcrypto",
|
"name": "@pushrocks/smartcrypto",
|
||||||
"version": "1.0.2",
|
"version": "1.0.8",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "easy crypto methods",
|
"description": "easy crypto methods",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
@ -20,5 +20,20 @@
|
|||||||
"tslint": "^5.20.0",
|
"tslint": "^5.20.0",
|
||||||
"tslint-config-prettier": "^1.18.0"
|
"tslint-config-prettier": "^1.18.0"
|
||||||
},
|
},
|
||||||
"dependencies": {}
|
"dependencies": {
|
||||||
|
"@pushrocks/smartpromise": "^3.0.5",
|
||||||
|
"@types/node-forge": "^0.8.6",
|
||||||
|
"node-forge": "^0.9.1"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"ts/*",
|
||||||
|
"ts_web/*",
|
||||||
|
"dist/*",
|
||||||
|
"dist_web/*",
|
||||||
|
"dist_ts_web/*",
|
||||||
|
"assets/*",
|
||||||
|
"cli.js",
|
||||||
|
"npmextra.json",
|
||||||
|
"readme.md"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
26
readme.md
Normal file
26
readme.md
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# @pushrocks/smartcrypto
|
||||||
|
easy crypto methods
|
||||||
|
|
||||||
|
## Availabililty and Links
|
||||||
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartcrypto)
|
||||||
|
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartcrypto)
|
||||||
|
* [github.com (source mirror)](https://github.com/pushrocks/smartcrypto)
|
||||||
|
* [docs (typedoc)](https://pushrocks.gitlab.io/smartcrypto/)
|
||||||
|
|
||||||
|
## Status for master
|
||||||
|
[](https://gitlab.com/pushrocks/smartcrypto/commits/master)
|
||||||
|
[](https://gitlab.com/pushrocks/smartcrypto/commits/master)
|
||||||
|
[](https://www.npmjs.com/package/@pushrocks/smartcrypto)
|
||||||
|
[](https://snyk.io/test/npm/@pushrocks/smartcrypto)
|
||||||
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
[](https://prettier.io/)
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||||
|
|
||||||
|
[](https://maintainedby.lossless.com)
|
@ -1,8 +1,8 @@
|
|||||||
import { expect, tap } from '@pushrocks/tapbundle';
|
import { expect, tap } from '@pushrocks/tapbundle';
|
||||||
import * as smartcrypto from '../ts/index'
|
import * as smartcrypto from '../ts/index';
|
||||||
|
|
||||||
tap.test('first test', async () => {
|
tap.test('first test', async () => {
|
||||||
console.log(smartcrypto.standardExport)
|
console.log('hi');
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.start()
|
tap.start();
|
||||||
|
11
ts/index.ts
11
ts/index.ts
@ -1,3 +1,10 @@
|
|||||||
import * as plugins from './smartcrypto.plugins';
|
export * from './smartcrypto.classes.smartcrypto';
|
||||||
|
export * from './smartcrypto.classes.keypair';
|
||||||
|
export * from './smartcrypto.classes.privatekey';
|
||||||
|
export * from './smartcrypto.classes.publickey';
|
||||||
|
|
||||||
export let standardExport = 'Hi there! :) This is an exported string';
|
import { nodeForge } from './smartcrypto.plugins';
|
||||||
|
|
||||||
|
export {
|
||||||
|
nodeForge
|
||||||
|
};
|
||||||
|
34
ts/smartcrypto.classes.keypair.ts
Normal file
34
ts/smartcrypto.classes.keypair.ts
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import * as plugins from './smartcrypto.plugins';
|
||||||
|
import { PublicKey } from './smartcrypto.classes.publickey';
|
||||||
|
import { PrivateKey } from './smartcrypto.classes.privatekey';
|
||||||
|
|
||||||
|
export class KeyPair {
|
||||||
|
// STATIC
|
||||||
|
public static async createNewKeyPair(): Promise<KeyPair> {
|
||||||
|
const done = plugins.smartpromise.defer<KeyPair>();
|
||||||
|
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 PrivateKey(keypair.privateKey),
|
||||||
|
publicKey: new PublicKey(keypair.publicKey)
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
// INSTANCE
|
||||||
|
public publicKey: PublicKey;
|
||||||
|
public privateKey: PrivateKey;
|
||||||
|
|
||||||
|
constructor(optionsArg: { privateKey: PrivateKey; publicKey: PublicKey }) {
|
||||||
|
this.privateKey = optionsArg.privateKey;
|
||||||
|
this.publicKey = optionsArg.publicKey;
|
||||||
|
}
|
||||||
|
}
|
24
ts/smartcrypto.classes.privatekey.ts
Normal file
24
ts/smartcrypto.classes.privatekey.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import * as plugins from './smartcrypto.plugins';
|
||||||
|
|
||||||
|
export class PrivateKey {
|
||||||
|
// STATIC
|
||||||
|
public static createFromPrivateKey(pemString: string) {
|
||||||
|
const privateKey = plugins.nodeForge.pki.privateKeyFromPem(pemString);
|
||||||
|
return new PrivateKey(privateKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static fromPemString(pemString: string) {
|
||||||
|
return new PrivateKey(plugins.nodeForge.pki.privateKeyFromPem(pemString));
|
||||||
|
}
|
||||||
|
|
||||||
|
// INSTANCE
|
||||||
|
public forgePrivateKey: plugins.nodeForge.pki.PrivateKey;
|
||||||
|
|
||||||
|
constructor(privateKeyArg: plugins.nodeForge.pki.PrivateKey) {
|
||||||
|
this.forgePrivateKey = privateKeyArg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public toPemString(): string {
|
||||||
|
return plugins.nodeForge.pki.privateKeyToPem(this.forgePrivateKey);
|
||||||
|
}
|
||||||
|
}
|
24
ts/smartcrypto.classes.publickey.ts
Normal file
24
ts/smartcrypto.classes.publickey.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import * as plugins from './smartcrypto.plugins';
|
||||||
|
|
||||||
|
export class PublicKey {
|
||||||
|
// STATIC
|
||||||
|
public static createFromPrivateKey(pemString: string) {
|
||||||
|
const privateKey = plugins.nodeForge.pki.publicKeyFromPem(pemString);
|
||||||
|
return new PublicKey(privateKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static fromPemString(pemString: string) {
|
||||||
|
return new PublicKey(plugins.nodeForge.pki.publicKeyFromPem(pemString));
|
||||||
|
}
|
||||||
|
|
||||||
|
// INSTANCE
|
||||||
|
public forgePublicKey: plugins.nodeForge.pki.PublicKey;
|
||||||
|
|
||||||
|
constructor(publicKeyArg: plugins.nodeForge.pki.PublicKey) {
|
||||||
|
this.forgePublicKey = publicKeyArg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public toPemString(): string {
|
||||||
|
return plugins.nodeForge.pki.publicKeyToPem(this.forgePublicKey);
|
||||||
|
}
|
||||||
|
}
|
8
ts/smartcrypto.classes.smartcrypto.ts
Normal file
8
ts/smartcrypto.classes.smartcrypto.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import * as plugins from './smartcrypto.plugins';
|
||||||
|
import { KeyPair } from './smartcrypto.classes.keypair';
|
||||||
|
|
||||||
|
export class Smartcrypto {
|
||||||
|
public async createKeyPair(): Promise<KeyPair> {
|
||||||
|
return KeyPair.createNewKeyPair();
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,9 @@
|
|||||||
const removeme = {};
|
// @pushrocks scope
|
||||||
export {
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
removeme
|
|
||||||
}
|
export { smartpromise };
|
||||||
|
|
||||||
|
// third party scope
|
||||||
|
import * as nodeForge from 'node-forge';
|
||||||
|
|
||||||
|
export { nodeForge };
|
||||||
|
Reference in New Issue
Block a user