Compare commits

..

No commits in common. "master" and "v1.0.11" have entirely different histories.

32 changed files with 11629 additions and 6240 deletions

View File

@ -1,66 +0,0 @@
name: Default (not tags)
on:
push:
tags-ignore:
- '**'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Install pnpm and npmci
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
- name: Run npm prepare
run: npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build

View File

@ -1,124 +0,0 @@
name: Default (tags)
on:
push:
tags:
- '*'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build
release:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Release
run: |
npmci node install stable
npmci npm publish
metadata:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
continue-on-error: true
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Code quality
run: |
npmci command npm install -g typescript
npmci npm install
- name: Trigger
run: npmci trigger
- name: Build docs and upload artifacts
run: |
npmci node install stable
npmci npm install
pnpm install -g @git.zone/tsdoc
npmci command tsdoc
continue-on-error: true

View File

@ -12,36 +12,40 @@ stages:
- release
- metadata
before_script:
- pnpm install -g pnpm
- pnpm install -g @shipzone/npmci
- npmci npm prepare
# ====================
# security stage
# ====================
mirror:
stage: security
script:
- npmci git mirror
only:
- tags
tags:
- lossless
- docker
- notpriv
# ====================
# security stage
# ====================
# ====================
# security stage
# ====================
auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --production --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command pnpm audit --audit-level=high --prod
- npmci command npm audit --audit-level=high --only=prod --production
tags:
- lossless
- docker
allow_failure: true
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command pnpm audit --audit-level=high --dev
- npmci command npm audit --audit-level=high --only=dev
tags:
- lossless
- docker
allow_failure: true
@ -52,6 +56,7 @@ auditDevDependencies:
testStable:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
@ -62,6 +67,7 @@ testStable:
testBuild:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command npm run build
@ -90,9 +96,10 @@ codequality:
only:
- tags
script:
- npmci command npm install -g typescript
- npmci command npm install -g tslint typescript
- npmci npm prepare
- npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags:
- lossless
- docker
@ -112,9 +119,11 @@ trigger:
pages:
stage: metadata
script:
- npmci node install stable
- npmci node install lts
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare
- npmci npm install
- npmci command npm run buildDocs
- npmci command tsdoc
tags:
- lossless
- docker

24
.vscode/launch.json vendored
View File

@ -2,10 +2,28 @@
"version": "0.2.0",
"configurations": [
{
"command": "npm test",
"name": "Run npm test",
"name": "current file",
"type": "node",
"request": "launch",
"type": "node-terminal"
"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"
}
]
}

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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRjcnlwdG8uY2xhc3Nlcy5rZXlwYWlyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRjcnlwdG8uY2xhc3Nlcy5rZXlwYWlyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSwrREFBaUQ7QUFDakQsbUZBQTREO0FBQzVELHFGQUE4RDtBQUU5RCxNQUFhLE9BQU87SUF5QmxCLFlBQVksVUFBNEQ7UUFDdEUsSUFBSSxDQUFDLFVBQVUsR0FBRyxVQUFVLENBQUMsVUFBVSxDQUFDO1FBQ3hDLElBQUksQ0FBQyxTQUFTLEdBQUcsVUFBVSxDQUFDLFNBQVMsQ0FBQztJQUN4QyxDQUFDO0lBM0JELFNBQVM7SUFDRixNQUFNLENBQUMsS0FBSyxDQUFDLGdCQUFnQjtRQUNsQyxNQUFNLElBQUksR0FBRyxPQUFPLENBQUMsWUFBWSxDQUFDLEtBQUssRUFBVyxDQUFDO1FBQ25ELE1BQU0sR0FBRyxHQUFHLE9BQU8sQ0FBQyxTQUFTLENBQUMsR0FBRyxDQUFDLEdBQUcsQ0FBQztRQUN0QyxHQUFHLENBQUMsZUFBZSxDQUFDLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRSxPQUFPLEVBQUUsQ0FBQyxFQUFFLEVBQUUsS0FBSyxFQUFFLEdBQUcsRUFBRSxPQUFPLEVBQUUsRUFBRTtZQUNyRSxJQUFJLEdBQUcsRUFBRTtnQkFDUCxPQUFPLENBQUMsR0FBRyxDQUFDLEdBQUcsQ0FBQyxDQUFDO2dCQUNqQixNQUFNLEdBQUcsQ0FBQzthQUNYO1lBRUQsSUFBSSxDQUFDLE9BQU8sQ0FDVixJQUFJLE9BQU8sQ0FBQztnQkFDVixVQUFVLEVBQUUsSUFBSSwyQ0FBVSxDQUFDLE9BQU8sQ0FBQyxVQUFVLENBQUM7Z0JBQzlDLFNBQVMsRUFBRSxJQUFJLHlDQUFTLENBQUMsT0FBTyxDQUFDLFNBQVMsQ0FBQzthQUM1QyxDQUFDLENBQ0gsQ0FBQztRQUNKLENBQUMsQ0FBQyxDQUFDO1FBQ0gsT0FBTyxJQUFJLENBQUMsT0FBTyxDQUFDO0lBQ3RCLENBQUM7Q0FVRjtBQTdCRCwwQkE2QkMifQ==

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

View File

@ -2,31 +2,17 @@
"gitzone": {
"projectType": "npm",
"module": {
"githost": "code.foss.global",
"gitscope": "push.rocks",
"githost": "gitlab.com",
"gitscope": "pushrocks",
"gitrepo": "smartcrypto",
"description": "A library providing easy methods for cryptographic operations, including key pair generation.",
"npmPackagename": "@push.rocks/smartcrypto",
"shortDescription": "easy crypto methods",
"npmPackagename": "@pushrocks/smartcrypto",
"license": "MIT",
"projectDomain": "push.rocks",
"keywords": [
"cryptography",
"encryption",
"security",
"public key",
"private key",
"RSA",
"key pair generation",
"node-forge",
"typescript"
]
"projectDomain": "push.rocks"
}
},
"npmci": {
"npmGlobalTools": [],
"npmAccessLevel": "public"
},
"tsdoc": {
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
}
}

11264
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,28 +1,28 @@
{
"name": "@push.rocks/smartcrypto",
"version": "2.0.5",
"name": "@pushrocks/smartcrypto",
"version": "1.0.11",
"private": false,
"description": "A library providing easy methods for cryptographic operations, including key pair generation.",
"description": "easy crypto methods",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"author": "Lossless GmbH",
"license": "MIT",
"scripts": {
"test": "(tstest test/ --web)",
"build": "(tsbuild --web)",
"buildDocs": "tsdoc"
"build": "(tsbuild --web)"
},
"devDependencies": {
"@git.zone/tsbuild": "^2.1.72",
"@git.zone/tsrun": "^1.2.46",
"@git.zone/tstest": "^1.0.86",
"@push.rocks/tapbundle": "^5.0.15",
"@types/node": "^20.11.17"
"@gitzone/tsbuild": "^2.1.25",
"@gitzone/tstest": "^1.0.52",
"@pushrocks/tapbundle": "^3.2.14",
"@types/node": "^14.14.31",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0"
},
"dependencies": {
"@push.rocks/smartpromise": "^4.0.3",
"@types/node-forge": "^1.3.11",
"node-forge": "^1.3.1"
"@pushrocks/smartpromise": "^3.1.3",
"@types/node-forge": "^0.9.7",
"node-forge": "^0.10.0"
},
"files": [
"ts/**/*",
@ -38,22 +38,5 @@
],
"browserslist": [
"last 1 chrome versions"
],
"type": "module",
"keywords": [
"cryptography",
"encryption",
"security",
"public key",
"private key",
"RSA",
"key pair generation",
"node-forge",
"typescript"
],
"homepage": "https://code.foss.global/push.rocks/smartcrypto",
"repository": {
"type": "git",
"url": "https://code.foss.global/push.rocks/smartcrypto.git"
}
]
}

5832
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -1 +0,0 @@

120
readme.md
View File

@ -1,102 +1,38 @@
# @push.rocks/smartcrypto
# @pushrocks/smartcrypto
easy crypto methods
## Install
To install `@push.rocks/smartcrypto`, open a terminal and run the following command:
```bash
npm install @push.rocks/smartcrypto
```
This will add `@push.rocks/smartcrypto` to your project's dependencies.
## 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 | [![pipeline status](https://gitlab.com/pushrocks/smartcrypto/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartcrypto/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smartcrypto)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartcrypto)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/smartcrypto)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartcrypto)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartcrypto)](https://lossless.cloud)
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)
## Usage
This guide demonstrates how to use `@push.rocks/smartcrypto` effectively by covering its main functionalities. The module offers straightforward methods for handling cryptographic operations. We'll go through generating keys, encrypting and decrypting data, and converting keys to various formats.
### Setting up your project
Firstly, ensure you have a TypeScript project configured to use ES Modules. Initialize `@push.rocks/smartcrypto` in your project as shown:
```typescript
import { Smartcrypto } from '@push.rocks/smartcrypto';
## Contribution
const smartCrypto = new Smartcrypto();
```
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). :)
### Generating a Key Pair
Generating a new RSA key pair is a common requirement. Let's see how `@push.rocks/smartcrypto` simplifies this process:
For further information read the linked docs at the top of this readme.
```typescript
(async () => {
const keyPair = await smartCrypto.createKeyPair();
console.log('Public Key:', keyPair.publicKey.toPemString());
console.log('Private Key:', keyPair.privateKey.toPemString());
})();
```
> MIT licensed | **&copy;** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
This asynchronous function generates a new RSA key pair and logs the PEM-formatted public and private keys. This is particularly useful for creating keys for secure communication.
### Working with Public and Private Keys
You can manipulate public and private keys using their respective classes. For instance, converting a private key to a PEM string for storage or transmission is straightforward:
```typescript
import { PrivateKey } from '@push.rocks/smartcrypto';
// Assuming you already have a privateKey object:
const privateKeyPemString = privateKey.toPemString();
console.log(privateKeyPemString);
```
Similarly, you can create a `PrivateKey` object from a PEM string. This is useful when you retrieve a stored key and need to use it in your application:
```typescript
const privateKeyFromPem = PrivateKey.fromPemString(privateKeyPemString);
```
The same methods apply to public keys with the `PublicKey` class:
```typescript
import { PublicKey } from '@push.rocks/smartcrypto';
const publicKeyPemString = publicKey.toPemString();
console.log(publicKeyPemString);
const publicKeyFromPem = PublicKey.fromPemString(publicKeyPemString);
```
### Advanced Usage
Beyond basic key generation and format conversion, `@push.rocks/smartcrypto` leverages `node-forge` for advanced cryptographic operations. You can engage in more complex scenarios such as signing data, verifying signatures, and even using the library for SSH key generation.
```typescript
// Example: Signing a message with RSA private key
const message = 'Hello, SmartCrypto!';
const signedMessage = privateKey.signMessage(message);
console.log('Signed Message:', signedMessage);
// Example: Verifying a signature with the corresponding public key
const isVerified = publicKey.verifyMessage(message, signedMessage);
console.log('Is the message verified?', isVerified);
```
Note: The `.signMessage` and `.verifyMessage` methods are conceptual and may require specific implementation or extension of the base classes provided by `@push.rocks/smartcrypto`.
### Conclusion
`@push.rocks/smartcrypto` provides an easy-to-use interface for cryptographic operations, significantly reducing the complexity of managing keys and performing secure data transmission. The examples above showcase a subset of what's possible, encouraging you to explore further and integrate cryptography seamlessly into your Node.js applications.
For more advanced use cases and customization, refer to the [node-forge](https://github.com/digitalbazaar/forge) documentation. `@push.rocks/smartcrypto` is designed to work smoothly with `node-forge`, enabling you to extend its functionalities according to your project's needs.
## License and Legal Information
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
### Trademarks
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
### Company Information
Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)

View File

@ -1,16 +1,11 @@
import { expect, tap } from '@push.rocks/tapbundle';
import * as smartcrypto from '../ts/index.js';
import { expect, tap } from '@pushrocks/tapbundle';
import * as smartcrypto from '../ts/index';
let testSmartCrypto: smartcrypto.Smartcrypto;
tap.test('first test', async () => {
testSmartCrypto = new smartcrypto.Smartcrypto();
expect(testSmartCrypto).toBeInstanceOf(smartcrypto.Smartcrypto);
});
tap.test('should create a private public keypair', async () => {
const keypair = await testSmartCrypto.createKeyPair();
console.log(keypair);
expect(testSmartCrypto).to.be.instanceOf(smartcrypto.Smartcrypto);
});
tap.start();

View File

@ -1,8 +0,0 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@push.rocks/smartcrypto',
version: '2.0.5',
description: 'easy crypto methods'
}

View File

@ -1,8 +1,8 @@
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 * from './smartcrypto.classes.smartcrypto';
export * from './smartcrypto.classes.keypair';
export * from './smartcrypto.classes.privatekey';
export * from './smartcrypto.classes.publickey';
import { nodeForge } from './smartcrypto.plugins.js';
import { nodeForge } from './smartcrypto.plugins';
export { nodeForge };

View File

@ -1,6 +1,6 @@
import * as plugins from './smartcrypto.plugins.js';
import { PublicKey } from './smartcrypto.classes.publickey.js';
import { PrivateKey } from './smartcrypto.classes.privatekey.js';
import * as plugins from './smartcrypto.plugins';
import { PublicKey } from './smartcrypto.classes.publickey';
import { PrivateKey } from './smartcrypto.classes.privatekey';
export class KeyPair {
// STATIC

View File

@ -1,4 +1,4 @@
import * as plugins from './smartcrypto.plugins.js';
import * as plugins from './smartcrypto.plugins';
export class PrivateKey {
// STATIC
@ -21,8 +21,4 @@ export class PrivateKey {
public toPemString(): string {
return plugins.nodeForge.pki.privateKeyToPem(this.forgePrivateKey);
}
public toOpenSSH(): string {
return plugins.nodeForge.ssh.privateKeyToOpenSSH(this.forgePrivateKey, 'user@host');
}
}

View File

@ -1,4 +1,4 @@
import * as plugins from './smartcrypto.plugins.js';
import * as plugins from './smartcrypto.plugins';
export class PublicKey {
// STATIC
@ -21,8 +21,4 @@ export class PublicKey {
public toPemString(): string {
return plugins.nodeForge.pki.publicKeyToPem(this.forgePublicKey);
}
public toOpenSSH(): string {
return plugins.nodeForge.ssh.publicKeyToOpenSSH(this.forgePublicKey, 'user@host');
}
}

View File

@ -1,5 +1,5 @@
import * as plugins from './smartcrypto.plugins.js';
import { KeyPair } from './smartcrypto.classes.keypair.js';
import * as plugins from './smartcrypto.plugins';
import { KeyPair } from './smartcrypto.classes.keypair';
export class Smartcrypto {
public async createKeyPair(): Promise<KeyPair> {

View File

@ -1,9 +1,9 @@
// @pushrocks scope
import * as smartpromise from '@push.rocks/smartpromise';
import * as smartpromise from '@pushrocks/smartpromise';
export { smartpromise };
// third party scope
import nodeForge from 'node-forge';
import * as nodeForge from 'node-forge';
export { nodeForge };

View File

@ -1,14 +0,0 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"verbatimModuleSyntax": true
},
"exclude": [
"dist_*/**/*.d.ts"
]
}

17
tslint.json Normal file
View File

@ -0,0 +1,17 @@
{
"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"
}