Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
0d3a8dde59 | |||
548c8147e6 | |||
cf6d1b2b04 | |||
214677b3c4 | |||
0f0cfdae77 | |||
ca381efaec | |||
788d74edeb | |||
0719484f64 | |||
bd94115cb7 | |||
72a696908a | |||
f3d63e027f | |||
5192008320 | |||
6595d61562 | |||
9e6cb240dd | |||
03175e208a | |||
2be99bdf48 | |||
0e21c84ab4 | |||
c4c205066c | |||
44c2adf45d |
4
.gitignore
vendored
4
.gitignore
vendored
@ -15,8 +15,6 @@ node_modules/
|
||||
|
||||
# builds
|
||||
dist/
|
||||
dist_web/
|
||||
dist_serve/
|
||||
dist_ts_web/
|
||||
dist_*/
|
||||
|
||||
# custom
|
106
.gitlab-ci.yml
106
.gitlab-ci.yml
@ -3,36 +3,47 @@ image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- .npmci_cache/
|
||||
key: "$CI_BUILD_STAGE"
|
||||
- .npmci_cache/
|
||||
key: '$CI_BUILD_STAGE'
|
||||
|
||||
stages:
|
||||
- security
|
||||
- test
|
||||
- release
|
||||
- metadata
|
||||
- security
|
||||
- test
|
||||
- release
|
||||
- metadata
|
||||
|
||||
before_script:
|
||||
- pnpm install -g pnpm
|
||||
- pnpm install -g @shipzone/npmci
|
||||
- npmci npm prepare
|
||||
|
||||
# ====================
|
||||
# security stage
|
||||
# ====================
|
||||
mirror:
|
||||
# ====================
|
||||
# security stage
|
||||
# ====================
|
||||
auditProductionDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command pnpm audit --audit-level=high --prod
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
- lossless
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
snyk:
|
||||
auditDevDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install -g snyk
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command snyk test
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command pnpm audit --audit-level=high --dev
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
- lossless
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
# ====================
|
||||
# test stage
|
||||
@ -41,37 +52,34 @@ snyk:
|
||||
testStable:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- priv
|
||||
- docker
|
||||
|
||||
testBuild:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci command npm run build
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci command npm run build
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
- docker
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci node install stable
|
||||
- npmci npm publish
|
||||
- npmci node install stable
|
||||
- npmci npm publish
|
||||
only:
|
||||
- tags
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
# ====================
|
||||
# metadata stage
|
||||
@ -79,36 +87,36 @@ release:
|
||||
codequality:
|
||||
stage: metadata
|
||||
allow_failure: true
|
||||
only:
|
||||
- tags
|
||||
script:
|
||||
- npmci command npm install -g tslint typescript
|
||||
- npmci command npm install -g typescript
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||
tags:
|
||||
- docker
|
||||
- priv
|
||||
- lossless
|
||||
- docker
|
||||
- priv
|
||||
|
||||
trigger:
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci trigger
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
pages:
|
||||
image: hosttoday/ht-docker-dbase:npmci
|
||||
services:
|
||||
- docker:stable-dind
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci command npm install -g @gitzone/tsdoc
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci command tsdoc
|
||||
- npmci command npm run buildDocs
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
only:
|
||||
@ -116,5 +124,5 @@ pages:
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- public
|
||||
- public
|
||||
allow_failure: true
|
||||
|
24
.vscode/launch.json
vendored
24
.vscode/launch.json
vendored
@ -2,28 +2,10 @@
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "current file",
|
||||
"type": "node",
|
||||
"command": "npm test",
|
||||
"name": "Run npm test",
|
||||
"request": "launch",
|
||||
"args": [
|
||||
"${relativeFile}"
|
||||
],
|
||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"protocol": "inspector",
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
},
|
||||
{
|
||||
"name": "test.ts",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"args": [
|
||||
"test/test.ts"
|
||||
],
|
||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"protocol": "inspector",
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
"type": "node-terminal"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
8
.vscode/settings.json
vendored
8
.vscode/settings.json
vendored
@ -11,7 +11,13 @@
|
||||
},
|
||||
"gitzone": {
|
||||
"type": "object",
|
||||
"description": "settings for gitzone"
|
||||
"description": "settings for gitzone",
|
||||
"properties": {
|
||||
"projectType": {
|
||||
"type": "string",
|
||||
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
6
dist_ts/index.d.ts
vendored
Normal file
6
dist_ts/index.d.ts
vendored
Normal 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
20
dist_ts/index.js
Normal 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=
|
11
dist_ts/smartcrypto.classes.keypair.d.ts
vendored
Normal file
11
dist_ts/smartcrypto.classes.keypair.d.ts
vendored
Normal 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;
|
||||
});
|
||||
}
|
49
dist_ts/smartcrypto.classes.keypair.js
Normal file
49
dist_ts/smartcrypto.classes.keypair.js
Normal 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRjcnlwdG8uY2xhc3Nlcy5rZXlwYWlyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRjcnlwdG8uY2xhc3Nlcy5rZXlwYWlyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSwrREFBaUQ7QUFDakQsbUZBQTREO0FBQzVELHFGQUE4RDtBQUU5RCxNQUFhLE9BQU87SUF5QmxCLFlBQVksVUFBNEQ7UUFDdEUsSUFBSSxDQUFDLFVBQVUsR0FBRyxVQUFVLENBQUMsVUFBVSxDQUFDO1FBQ3hDLElBQUksQ0FBQyxTQUFTLEdBQUcsVUFBVSxDQUFDLFNBQVMsQ0FBQztJQUN4QyxDQUFDO0lBM0JELFNBQVM7SUFDRixNQUFNLENBQUMsS0FBSyxDQUFDLGdCQUFnQjtRQUNsQyxNQUFNLElBQUksR0FBRyxPQUFPLENBQUMsWUFBWSxDQUFDLEtBQUssRUFBVyxDQUFDO1FBQ25ELE1BQU0sR0FBRyxHQUFHLE9BQU8sQ0FBQyxTQUFTLENBQUMsR0FBRyxDQUFDLEdBQUcsQ0FBQztRQUN0QyxHQUFHLENBQUMsZUFBZSxDQUFDLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRSxPQUFPLEVBQUUsQ0FBQyxFQUFFLEVBQUUsS0FBSyxFQUFFLEdBQUcsRUFBRSxPQUFPLEVBQUUsRUFBRTtZQUNyRSxJQUFJLEdBQUcsRUFBRTtnQkFDUCxPQUFPLENBQUMsR0FBRyxDQUFDLEdBQUcsQ0FBQyxDQUFDO2dCQUNqQixNQUFNLEdBQUcsQ0FBQzthQUNYO1lBRUQsSUFBSSxDQUFDLE9BQU8sQ0FDVixJQUFJLE9BQU8sQ0FBQztnQkFDVixVQUFVLEVBQUUsSUFBSSwyQ0FBVSxDQUFDLE9BQU8sQ0FBQyxVQUFVLENBQUM7Z0JBQzlDLFNBQVMsRUFBRSxJQUFJLHlDQUFTLENBQUMsT0FBTyxDQUFDLFNBQVMsQ0FBQzthQUM1QyxDQUFDLENBQ0gsQ0FBQztRQUNKLENBQUMsQ0FBQyxDQUFDO1FBQ0gsT0FBTyxJQUFJLENBQUMsT0FBTyxDQUFDO0lBQ3RCLENBQUM7Q0FVRjtBQTdCRCwwQkE2QkMifQ==
|
9
dist_ts/smartcrypto.classes.privatekey.d.ts
vendored
Normal file
9
dist_ts/smartcrypto.classes.privatekey.d.ts
vendored
Normal 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;
|
||||
}
|
41
dist_ts/smartcrypto.classes.privatekey.js
Normal file
41
dist_ts/smartcrypto.classes.privatekey.js
Normal 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==
|
9
dist_ts/smartcrypto.classes.publickey.d.ts
vendored
Normal file
9
dist_ts/smartcrypto.classes.publickey.d.ts
vendored
Normal 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;
|
||||
}
|
41
dist_ts/smartcrypto.classes.publickey.js
Normal file
41
dist_ts/smartcrypto.classes.publickey.js
Normal 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=
|
4
dist_ts/smartcrypto.classes.smartcrypto.d.ts
vendored
Normal file
4
dist_ts/smartcrypto.classes.smartcrypto.d.ts
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
import { KeyPair } from './smartcrypto.classes.keypair';
|
||||
export declare class Smartcrypto {
|
||||
createKeyPair(): Promise<KeyPair>;
|
||||
}
|
11
dist_ts/smartcrypto.classes.smartcrypto.js
Normal file
11
dist_ts/smartcrypto.classes.smartcrypto.js
Normal 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
4
dist_ts/smartcrypto.plugins.d.ts
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
export { smartpromise };
|
||||
import * as nodeForge from 'node-forge';
|
||||
export { nodeForge };
|
29
dist_ts/smartcrypto.plugins.js
Normal file
29
dist_ts/smartcrypto.plugins.js
Normal 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
|
@ -1,10 +1,11 @@
|
||||
{
|
||||
"gitzone": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "gitlab.com",
|
||||
"gitscope": "pushrocks",
|
||||
"gitrepo": "smartcrypto",
|
||||
"shortDescription": "easy crypto methods",
|
||||
"description": "easy crypto methods",
|
||||
"npmPackagename": "@pushrocks/smartcrypto",
|
||||
"license": "MIT",
|
||||
"projectDomain": "push.rocks"
|
||||
@ -14,4 +15,4 @@
|
||||
"npmGlobalTools": [],
|
||||
"npmAccessLevel": "public"
|
||||
}
|
||||
}
|
||||
}
|
1626
package-lock.json
generated
1626
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
45
package.json
45
package.json
@ -1,24 +1,43 @@
|
||||
{
|
||||
"name": "@pushrocks/smartcrypto",
|
||||
"version": "1.0.2",
|
||||
"version": "2.0.0",
|
||||
"private": false,
|
||||
"description": "easy crypto methods",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "(tstest test/)",
|
||||
"build": "(tsbuild)",
|
||||
"format": "(gitzone format)"
|
||||
"test": "(tstest test/ --web)",
|
||||
"build": "(tsbuild --web)",
|
||||
"buildDocs": "tsdoc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.17",
|
||||
"@gitzone/tstest": "^1.0.24",
|
||||
"@pushrocks/tapbundle": "^3.0.13",
|
||||
"@types/node": "^12.7.8",
|
||||
"tslint": "^5.20.0",
|
||||
"tslint-config-prettier": "^1.18.0"
|
||||
"@gitzone/tsbuild": "^2.1.25",
|
||||
"@gitzone/tsrun": "^1.2.39",
|
||||
"@gitzone/tstest": "^1.0.52",
|
||||
"@pushrocks/tapbundle": "^5.0.4",
|
||||
"@types/node": "^18.11.4"
|
||||
},
|
||||
"dependencies": {}
|
||||
"dependencies": {
|
||||
"@pushrocks/smartpromise": "^3.1.3",
|
||||
"@types/node-forge": "^1.3.0",
|
||||
"node-forge": "^1.3.1"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
"ts_web/**/*",
|
||||
"dist/**/*",
|
||||
"dist_*/**/*",
|
||||
"dist_ts/**/*",
|
||||
"dist_ts_web/**/*",
|
||||
"assets/**/*",
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
],
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
],
|
||||
"type": "module"
|
||||
}
|
||||
|
4351
pnpm-lock.yaml
generated
Normal file
4351
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
42
readme.md
Normal file
42
readme.md
Normal file
@ -0,0 +1,42 @@
|
||||
# @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
|
||||
|
||||
Status Category | Status Badge
|
||||
-- | --
|
||||
GitLab Pipelines | [](https://lossless.cloud)
|
||||
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||
npm | [](https://lossless.cloud)
|
||||
Snyk | [](https://lossless.cloud)
|
||||
TypeScript Support | [](https://lossless.cloud)
|
||||
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
Code Style | [](https://lossless.cloud)
|
||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
||||
|
||||
## Usage
|
||||
|
||||
## Contribution
|
||||
|
||||
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). :)
|
||||
|
||||
|
||||
## Contribution
|
||||
|
||||
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). :)
|
||||
|
||||
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)
|
11
test/test.ts
11
test/test.ts
@ -1,8 +1,11 @@
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import * as smartcrypto from '../ts/index'
|
||||
import * as smartcrypto from '../ts/index.js';
|
||||
|
||||
let testSmartCrypto: smartcrypto.Smartcrypto;
|
||||
|
||||
tap.test('first test', async () => {
|
||||
console.log(smartcrypto.standardExport)
|
||||
})
|
||||
testSmartCrypto = new smartcrypto.Smartcrypto();
|
||||
expect(testSmartCrypto).toBeInstanceOf(smartcrypto.Smartcrypto);
|
||||
});
|
||||
|
||||
tap.start()
|
||||
tap.start();
|
||||
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @pushrocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@pushrocks/smartcrypto',
|
||||
version: '2.0.0',
|
||||
description: 'easy crypto methods'
|
||||
}
|
@ -1,3 +1,8 @@
|
||||
import * as plugins from './smartcrypto.plugins';
|
||||
export * from './smartcrypto.classes.smartcrypto.js';
|
||||
export * from './smartcrypto.classes.keypair.js';
|
||||
export * from './smartcrypto.classes.privatekey.js';
|
||||
export * from './smartcrypto.classes.publickey.js';
|
||||
|
||||
export let standardExport = 'Hi there! :) This is an exported string';
|
||||
import { nodeForge } from './smartcrypto.plugins.js';
|
||||
|
||||
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.js';
|
||||
import { PublicKey } from './smartcrypto.classes.publickey.js';
|
||||
import { PrivateKey } from './smartcrypto.classes.privatekey.js';
|
||||
|
||||
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.js';
|
||||
|
||||
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.js';
|
||||
|
||||
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.js';
|
||||
import { KeyPair } from './smartcrypto.classes.keypair.js';
|
||||
|
||||
export class Smartcrypto {
|
||||
public async createKeyPair(): Promise<KeyPair> {
|
||||
return KeyPair.createNewKeyPair();
|
||||
}
|
||||
}
|
@ -1,4 +1,9 @@
|
||||
const removeme = {};
|
||||
export {
|
||||
removeme
|
||||
}
|
||||
// @pushrocks scope
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
|
||||
export { smartpromise };
|
||||
|
||||
// third party scope
|
||||
import * as nodeForge from 'node-forge';
|
||||
|
||||
export { nodeForge };
|
||||
|
10
tsconfig.json
Normal file
10
tsconfig.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "ES2022",
|
||||
"moduleResolution": "nodenext",
|
||||
"esModuleInterop": true
|
||||
}
|
||||
}
|
17
tslint.json
17
tslint.json
@ -1,17 +0,0 @@
|
||||
{
|
||||
"extends": ["tslint:latest", "tslint-config-prettier"],
|
||||
"rules": {
|
||||
"semicolon": [true, "always"],
|
||||
"no-console": false,
|
||||
"ordered-imports": false,
|
||||
"object-literal-sort-keys": false,
|
||||
"member-ordering": {
|
||||
"options":{
|
||||
"order": [
|
||||
"static-method"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"defaultSeverity": "warning"
|
||||
}
|
Reference in New Issue
Block a user