Compare commits

...

19 Commits

Author SHA1 Message Date
016ae2a7b3 update description 2024-05-29 14:12:18 +02:00
2fff5eec4b update tsconfig 2024-04-14 17:26:24 +02:00
3aa4678053 update npmextra.json: githost 2024-04-01 21:34:18 +02:00
1344695d46 update npmextra.json: githost 2024-04-01 19:57:54 +02:00
0b2f66e0fd update npmextra.json: githost 2024-03-30 21:46:51 +01:00
6e53d69194 2.0.5 2024-02-09 17:53:20 +01:00
5129377992 fix(core): update 2024-02-09 17:53:20 +01:00
316470fd97 2.0.4 2024-02-09 17:53:09 +01:00
6c464b047d fix(core): update 2024-02-09 17:53:08 +01:00
73df372f70 2.0.3 2024-02-09 17:52:14 +01:00
2aedc2232b fix(core): update 2024-02-09 17:52:13 +01:00
515257ff48 2.0.2 2023-08-21 08:29:28 +02:00
52ca7c298b fix(core): update 2023-08-21 08:29:27 +02:00
4e88c65901 switch to new org scheme 2023-07-11 00:28:48 +02:00
ac84ec9327 switch to new org scheme 2023-07-10 02:42:50 +02:00
038f7e2e9f 2.0.1 2022-10-24 07:06:14 +02:00
f3fca605a4 fix(core): update 2022-10-24 07:06:13 +02:00
0d3a8dde59 2.0.0 2022-10-23 23:53:34 +02:00
548c8147e6 BREAKING CHANGE(core): switch to esm 2022-10-23 23:53:34 +02:00
32 changed files with 6238 additions and 11627 deletions

View File

@ -0,0 +1,66 @@
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

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

24
.vscode/launch.json vendored
View File

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

@ -1,6 +0,0 @@
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 };

View File

@ -1,20 +0,0 @@
"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

@ -1,11 +0,0 @@
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

@ -1,49 +0,0 @@
"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

@ -1,9 +0,0 @@
/// <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

@ -1,41 +0,0 @@
"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

@ -1,9 +0,0 @@
/// <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

@ -1,41 +0,0 @@
"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

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

View File

@ -1,11 +0,0 @@
"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=

View File

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

View File

@ -1,29 +0,0 @@
"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,17 +2,31 @@
"gitzone": { "gitzone": {
"projectType": "npm", "projectType": "npm",
"module": { "module": {
"githost": "gitlab.com", "githost": "code.foss.global",
"gitscope": "pushrocks", "gitscope": "push.rocks",
"gitrepo": "smartcrypto", "gitrepo": "smartcrypto",
"shortDescription": "easy crypto methods", "description": "A library providing easy methods for cryptographic operations, including key pair generation.",
"npmPackagename": "@pushrocks/smartcrypto", "npmPackagename": "@push.rocks/smartcrypto",
"license": "MIT", "license": "MIT",
"projectDomain": "push.rocks" "projectDomain": "push.rocks",
"keywords": [
"cryptography",
"encryption",
"security",
"public key",
"private key",
"RSA",
"key pair generation",
"node-forge",
"typescript"
]
} }
}, },
"npmci": { "npmci": {
"npmGlobalTools": [], "npmGlobalTools": [],
"npmAccessLevel": "public" "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

File diff suppressed because it is too large Load Diff

View File

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

File diff suppressed because it is too large Load Diff

1
readme.hints.md Normal file
View File

@ -0,0 +1 @@

120
readme.md
View File

@ -1,38 +1,102 @@
# @pushrocks/smartcrypto # @push.rocks/smartcrypto
easy crypto methods easy crypto methods
## Availabililty and Links ## Install
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartcrypto) To install `@push.rocks/smartcrypto`, open a terminal and run the following command:
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartcrypto) ```bash
* [github.com (source mirror)](https://github.com/pushrocks/smartcrypto) npm install @push.rocks/smartcrypto
* [docs (typedoc)](https://pushrocks.gitlab.io/smartcrypto/) ```
This will add `@push.rocks/smartcrypto` to your project's dependencies.
## 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 ## 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:
## Contribution ```typescript
import { Smartcrypto } from '@push.rocks/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). :) const smartCrypto = new Smartcrypto();
```
For further information read the linked docs at the top of this readme. ### Generating a Key Pair
Generating a new RSA key pair is a common requirement. Let's see how `@push.rocks/smartcrypto` simplifies this process:
> MIT licensed | **&copy;** [Lossless GmbH](https://lossless.gmbh) ```typescript
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy) (async () => {
const keyPair = await smartCrypto.createKeyPair();
console.log('Public Key:', keyPair.publicKey.toPemString());
console.log('Private Key:', keyPair.privateKey.toPemString());
})();
```
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com) 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.

View File

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

8
ts/00_commitinfo_data.ts Normal file
View File

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

View File

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

View File

@ -1,4 +1,4 @@
import * as plugins from './smartcrypto.plugins'; import * as plugins from './smartcrypto.plugins.js';
export class PrivateKey { export class PrivateKey {
// STATIC // STATIC
@ -21,4 +21,8 @@ export class PrivateKey {
public toPemString(): string { public toPemString(): string {
return plugins.nodeForge.pki.privateKeyToPem(this.forgePrivateKey); 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'; import * as plugins from './smartcrypto.plugins.js';
export class PublicKey { export class PublicKey {
// STATIC // STATIC
@ -21,4 +21,8 @@ export class PublicKey {
public toPemString(): string { public toPemString(): string {
return plugins.nodeForge.pki.publicKeyToPem(this.forgePublicKey); 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'; import * as plugins from './smartcrypto.plugins.js';
import { KeyPair } from './smartcrypto.classes.keypair'; import { KeyPair } from './smartcrypto.classes.keypair.js';
export class Smartcrypto { export class Smartcrypto {
public async createKeyPair(): Promise<KeyPair> { public async createKeyPair(): Promise<KeyPair> {

View File

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

14
tsconfig.json Normal file
View File

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

View File

@ -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"
}