Compare commits
No commits in common. "master" and "v1.0.4" have entirely different histories.
@ -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
|
|
@ -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
|
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -15,6 +15,8 @@ node_modules/
|
|||||||
|
|
||||||
# builds
|
# builds
|
||||||
dist/
|
dist/
|
||||||
dist_*/
|
dist_web/
|
||||||
|
dist_serve/
|
||||||
|
dist_ts_web/
|
||||||
|
|
||||||
# custom
|
# custom
|
106
.gitlab-ci.yml
106
.gitlab-ci.yml
@ -3,47 +3,36 @@ image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
|||||||
|
|
||||||
cache:
|
cache:
|
||||||
paths:
|
paths:
|
||||||
- .npmci_cache/
|
- .npmci_cache/
|
||||||
key: '$CI_BUILD_STAGE'
|
key: "$CI_BUILD_STAGE"
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- security
|
- security
|
||||||
- test
|
- test
|
||||||
- release
|
- release
|
||||||
- metadata
|
- metadata
|
||||||
|
|
||||||
before_script:
|
|
||||||
- pnpm install -g pnpm
|
|
||||||
- pnpm install -g @shipzone/npmci
|
|
||||||
- npmci npm prepare
|
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# security stage
|
# security stage
|
||||||
# ====================
|
# ====================
|
||||||
# ====================
|
mirror:
|
||||||
# security stage
|
|
||||||
# ====================
|
|
||||||
auditProductionDependencies:
|
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci command npm config set registry https://registry.npmjs.org
|
- npmci git mirror
|
||||||
- npmci command pnpm audit --audit-level=high --prod
|
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- docker
|
||||||
- docker
|
- notpriv
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
auditDevDependencies:
|
snyk:
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci command npm config set registry https://registry.npmjs.org
|
- npmci npm prepare
|
||||||
- npmci command pnpm audit --audit-level=high --dev
|
- npmci command npm install -g snyk
|
||||||
|
- npmci command npm install --ignore-scripts
|
||||||
|
- npmci command snyk test
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- docker
|
||||||
- docker
|
- notpriv
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# test stage
|
# test stage
|
||||||
@ -52,34 +41,37 @@ auditDevDependencies:
|
|||||||
testStable:
|
testStable:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci node install stable
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci node install stable
|
||||||
- npmci npm test
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
testBuild:
|
testBuild:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci node install stable
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci node install stable
|
||||||
- npmci command npm run build
|
- npmci npm install
|
||||||
|
- npmci command npm run build
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
script:
|
script:
|
||||||
- npmci node install stable
|
- npmci node install stable
|
||||||
- npmci npm publish
|
- npmci npm publish
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- docker
|
||||||
- docker
|
- notpriv
|
||||||
- notpriv
|
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# metadata stage
|
# metadata stage
|
||||||
@ -87,36 +79,36 @@ release:
|
|||||||
codequality:
|
codequality:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g typescript
|
- npmci command npm install -g tslint typescript
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
|
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- docker
|
||||||
- docker
|
- priv
|
||||||
- priv
|
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci trigger
|
- npmci trigger
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- docker
|
||||||
- docker
|
- notpriv
|
||||||
- notpriv
|
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
|
image: hosttoday/ht-docker-dbase:npmci
|
||||||
|
services:
|
||||||
|
- docker:stable-dind
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci node install stable
|
- npmci command npm install -g @gitzone/tsdoc
|
||||||
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command npm run buildDocs
|
- npmci command tsdoc
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
only:
|
only:
|
||||||
@ -124,5 +116,5 @@ pages:
|
|||||||
artifacts:
|
artifacts:
|
||||||
expire_in: 1 week
|
expire_in: 1 week
|
||||||
paths:
|
paths:
|
||||||
- public
|
- public
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
24
.vscode/launch.json
vendored
24
.vscode/launch.json
vendored
@ -2,10 +2,28 @@
|
|||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"command": "npm test",
|
"name": "current file",
|
||||||
"name": "Run npm test",
|
"type": "node",
|
||||||
"request": "launch",
|
"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"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
8
.vscode/settings.json
vendored
8
.vscode/settings.json
vendored
@ -11,13 +11,7 @@
|
|||||||
},
|
},
|
||||||
"gitzone": {
|
"gitzone": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"description": "settings for gitzone",
|
"description": "settings for gitzone"
|
||||||
"properties": {
|
|
||||||
"projectType": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": ["website", "element", "service", "npm", "wcc"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,32 +1,17 @@
|
|||||||
{
|
{
|
||||||
"gitzone": {
|
"gitzone": {
|
||||||
"projectType": "npm",
|
|
||||||
"module": {
|
"module": {
|
||||||
"githost": "code.foss.global",
|
"githost": "gitlab.com",
|
||||||
"gitscope": "push.rocks",
|
"gitscope": "pushrocks",
|
||||||
"gitrepo": "smartcrypto",
|
"gitrepo": "smartcrypto",
|
||||||
"description": "A library providing easy methods for cryptographic operations, including key pair generation.",
|
"shortDescription": "easy crypto methods",
|
||||||
"npmPackagename": "@push.rocks/smartcrypto",
|
"npmPackagename": "@pushrocks/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"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
1637
package-lock.json
generated
Normal file
1637
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
65
package.json
65
package.json
@ -1,59 +1,28 @@
|
|||||||
{
|
{
|
||||||
"name": "@push.rocks/smartcrypto",
|
"name": "@pushrocks/smartcrypto",
|
||||||
"version": "2.0.5",
|
"version": "1.0.4",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "A library providing easy methods for cryptographic operations, including key pair generation.",
|
"description": "easy crypto methods",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist/index.d.ts",
|
||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/ --web)",
|
"test": "(tstest test/)",
|
||||||
"build": "(tsbuild --web)",
|
"build": "(tsbuild)",
|
||||||
"buildDocs": "tsdoc"
|
"format": "(gitzone format)"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@git.zone/tsbuild": "^2.1.72",
|
"@gitzone/tsbuild": "^2.1.17",
|
||||||
"@git.zone/tsrun": "^1.2.46",
|
"@gitzone/tstest": "^1.0.24",
|
||||||
"@git.zone/tstest": "^1.0.86",
|
"@pushrocks/tapbundle": "^3.0.13",
|
||||||
"@push.rocks/tapbundle": "^5.0.15",
|
"@types/node": "^12.7.8",
|
||||||
"@types/node": "^20.11.17"
|
"tslint": "^5.20.0",
|
||||||
|
"tslint-config-prettier": "^1.18.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@push.rocks/smartpromise": "^4.0.3",
|
"@pushrocks/smartpromise": "^3.0.5",
|
||||||
"@types/node-forge": "^1.3.11",
|
"@types/node-forge": "^0.8.6",
|
||||||
"node-forge": "^1.3.1"
|
"node-forge": "^0.9.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",
|
|
||||||
"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
5832
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -1 +0,0 @@
|
|||||||
|
|
102
readme.md
102
readme.md
@ -1,102 +0,0 @@
|
|||||||
# @push.rocks/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.
|
|
||||||
|
|
||||||
## 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';
|
|
||||||
|
|
||||||
const smartCrypto = new Smartcrypto();
|
|
||||||
```
|
|
||||||
|
|
||||||
### Generating a Key Pair
|
|
||||||
Generating a new RSA key pair is a common requirement. Let's see how `@push.rocks/smartcrypto` simplifies this process:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
(async () => {
|
|
||||||
const keyPair = await smartCrypto.createKeyPair();
|
|
||||||
console.log('Public Key:', keyPair.publicKey.toPemString());
|
|
||||||
console.log('Private Key:', keyPair.privateKey.toPemString());
|
|
||||||
})();
|
|
||||||
```
|
|
||||||
|
|
||||||
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.
|
|
14
test/test.ts
14
test/test.ts
@ -1,16 +1,8 @@
|
|||||||
import { expect, tap } from '@push.rocks/tapbundle';
|
import { expect, tap } from '@pushrocks/tapbundle';
|
||||||
import * as smartcrypto from '../ts/index.js';
|
import * as smartcrypto from '../ts/index';
|
||||||
|
|
||||||
let testSmartCrypto: smartcrypto.Smartcrypto;
|
|
||||||
|
|
||||||
tap.test('first test', async () => {
|
tap.test('first test', async () => {
|
||||||
testSmartCrypto = new smartcrypto.Smartcrypto();
|
console.log('hi');
|
||||||
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();
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
/**
|
|
||||||
* autocreated commitinfo by @pushrocks/commitinfo
|
|
||||||
*/
|
|
||||||
export const commitinfo = {
|
|
||||||
name: '@push.rocks/smartcrypto',
|
|
||||||
version: '2.0.5',
|
|
||||||
description: 'easy crypto methods'
|
|
||||||
}
|
|
@ -1,8 +1 @@
|
|||||||
export * from './smartcrypto.classes.smartcrypto.js';
|
export * from './smartcrypto.classes.smartcrypto';
|
||||||
export * from './smartcrypto.classes.keypair.js';
|
|
||||||
export * from './smartcrypto.classes.privatekey.js';
|
|
||||||
export * from './smartcrypto.classes.publickey.js';
|
|
||||||
|
|
||||||
import { nodeForge } from './smartcrypto.plugins.js';
|
|
||||||
|
|
||||||
export { nodeForge };
|
|
||||||
|
@ -1,24 +1,23 @@
|
|||||||
import * as plugins from './smartcrypto.plugins.js';
|
import * as plugins from './smartcrypto.plugins';
|
||||||
import { PublicKey } from './smartcrypto.classes.publickey.js';
|
import { PublicKey } from './smartcrypto.classes.publickey';
|
||||||
import { PrivateKey } from './smartcrypto.classes.privatekey.js';
|
import { PrivateKey } from './smartcrypto.classes.privatekey';
|
||||||
|
|
||||||
export class KeyPair {
|
export class KeyPair {
|
||||||
// STATIC
|
// STATIC
|
||||||
public static async createNewKeyPair(): Promise<KeyPair> {
|
public static async createNewKeyPair(): Promise<KeyPair> {
|
||||||
const done = plugins.smartpromise.defer<KeyPair>();
|
const done = plugins.smartpromise.defer<KeyPair>();
|
||||||
const rsa = plugins.nodeForge.pki.rsa;
|
const rsa = plugins.nodeForge.pki.rsa;
|
||||||
rsa.generateKeyPair({ bits: 2048, workers: 2 }, async (err, keypair) => {
|
rsa.generateKeyPair({bits: 2048, workers: 2}, async (err, keypair) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
||||||
done.resolve(
|
done.resolve(new KeyPair({
|
||||||
new KeyPair({
|
privateKey: new PrivateKey(keypair.privateKey),
|
||||||
privateKey: new PrivateKey(keypair.privateKey),
|
publicKey: new PublicKey(keypair.publicKey),
|
||||||
publicKey: new PublicKey(keypair.publicKey),
|
}));
|
||||||
})
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
return done.promise;
|
return done.promise;
|
||||||
}
|
}
|
||||||
@ -27,7 +26,10 @@ export class KeyPair {
|
|||||||
public publicKey: PublicKey;
|
public publicKey: PublicKey;
|
||||||
public privateKey: PrivateKey;
|
public privateKey: PrivateKey;
|
||||||
|
|
||||||
constructor(optionsArg: { privateKey: PrivateKey; publicKey: PublicKey }) {
|
constructor(optionsArg: {
|
||||||
|
privateKey: PrivateKey;
|
||||||
|
publicKey: PublicKey;
|
||||||
|
}) {
|
||||||
this.privateKey = optionsArg.privateKey;
|
this.privateKey = optionsArg.privateKey;
|
||||||
this.publicKey = optionsArg.publicKey;
|
this.publicKey = optionsArg.publicKey;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import * as plugins from './smartcrypto.plugins.js';
|
import * as plugins from './smartcrypto.plugins';
|
||||||
|
|
||||||
export class PrivateKey {
|
export class PrivateKey {
|
||||||
// STATIC
|
// STATIC
|
||||||
@ -7,10 +7,6 @@ export class PrivateKey {
|
|||||||
return new PrivateKey(privateKey);
|
return new PrivateKey(privateKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static fromPemString(pemString: string) {
|
|
||||||
return new PrivateKey(plugins.nodeForge.pki.privateKeyFromPem(pemString));
|
|
||||||
}
|
|
||||||
|
|
||||||
// INSTANCE
|
// INSTANCE
|
||||||
public forgePrivateKey: plugins.nodeForge.pki.PrivateKey;
|
public forgePrivateKey: plugins.nodeForge.pki.PrivateKey;
|
||||||
|
|
||||||
@ -21,8 +17,4 @@ 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');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import * as plugins from './smartcrypto.plugins.js';
|
import * as plugins from './smartcrypto.plugins';
|
||||||
|
|
||||||
export class PublicKey {
|
export class PublicKey {
|
||||||
// STATIC
|
// STATIC
|
||||||
@ -7,22 +7,15 @@ export class PublicKey {
|
|||||||
return new PublicKey(privateKey);
|
return new PublicKey(privateKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static fromPemString(pemString: string) {
|
|
||||||
return new PublicKey(plugins.nodeForge.pki.publicKeyFromPem(pemString));
|
|
||||||
}
|
|
||||||
|
|
||||||
// INSTANCE
|
// INSTANCE
|
||||||
public forgePublicKey: plugins.nodeForge.pki.PublicKey;
|
public forgePublicKey: plugins.nodeForge.pki.PublicKey;
|
||||||
|
|
||||||
constructor(publicKeyArg: plugins.nodeForge.pki.PublicKey) {
|
constructor (publicKeyArg: plugins.nodeForge.pki.PublicKey) {
|
||||||
this.forgePublicKey = publicKeyArg;
|
this.forgePublicKey = publicKeyArg;
|
||||||
}
|
}
|
||||||
|
|
||||||
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');
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,8 +1,5 @@
|
|||||||
import * as plugins from './smartcrypto.plugins.js';
|
import * as plugins from './smartcrypto.plugins';
|
||||||
import { KeyPair } from './smartcrypto.classes.keypair.js';
|
|
||||||
|
|
||||||
export class Smartcrypto {
|
export class Smartcrypto {
|
||||||
public async createKeyPair(): Promise<KeyPair> {
|
|
||||||
return KeyPair.createNewKeyPair();
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,9 +1,13 @@
|
|||||||
// @pushrocks scope
|
// @pushrocks scope
|
||||||
import * as smartpromise from '@push.rocks/smartpromise';
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
|
|
||||||
export { smartpromise };
|
export {
|
||||||
|
smartpromise
|
||||||
|
};
|
||||||
|
|
||||||
// third party scope
|
// third party scope
|
||||||
import nodeForge from 'node-forge';
|
import * as nodeForge from 'node-forge';
|
||||||
|
|
||||||
export { nodeForge };
|
export {
|
||||||
|
nodeForge
|
||||||
|
};
|
||||||
|
@ -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
17
tslint.json
Normal 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"
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user