Compare commits

..

34 Commits

Author SHA1 Message Date
8cda69b3c2 4.0.6 2023-07-21 19:01:26 +02:00
3641d75e2f fix(core): update 2023-07-21 19:01:26 +02:00
fd343c1558 4.0.5 2023-07-21 18:59:18 +02:00
76650ac199 fix(core): update 2023-07-21 18:59:17 +02:00
d9ba5f20b1 4.0.4 2023-07-21 18:49:19 +02:00
941923e90f fix(core): update 2023-07-21 18:49:18 +02:00
e38b4c1215 switch to new org scheme 2023-07-11 00:09:13 +02:00
d405bf63a3 switch to new org scheme 2023-07-10 02:41:58 +02:00
737f5bf5cc 4.0.3 2023-01-06 14:08:18 +01:00
149cdf67bb fix(core): update 2023-01-06 14:08:18 +01:00
c35ff8d711 4.0.2 2022-09-27 19:55:38 +02:00
f2bd9b65aa fix(core): update 2022-09-27 19:55:38 +02:00
018a25ba6a 4.0.1 2022-09-27 15:44:06 +02:00
3c052df1e7 fix(core): update 2022-09-27 15:44:06 +02:00
17c85eb8b9 4.0.0 2022-09-27 15:40:55 +02:00
2bcb31e4d6 BREAKING CHANGE(core): update 2022-09-27 15:40:55 +02:00
70aef3fe7e 3.0.15 2021-01-22 23:43:22 +00:00
734bde4a98 fix(core): update 2021-01-22 23:43:21 +00:00
c7d9a42feb 3.0.14 2021-01-22 23:32:34 +00:00
f20bc72abb fix(core): update 2021-01-22 23:32:34 +00:00
cd2cfce683 3.0.13 2021-01-22 22:59:28 +00:00
44ab180474 fix(core): update 2021-01-22 22:59:27 +00:00
15557dfdd6 3.0.12 2021-01-22 20:31:56 +00:00
488f616d34 fix(core): update 2021-01-22 20:31:55 +00:00
e920406ce9 3.0.11 2021-01-22 18:47:02 +00:00
e044fd81bd fix(core): update 2021-01-22 18:47:01 +00:00
edaccc357d 3.0.10 2021-01-22 18:33:53 +00:00
67f645ad50 fix(core): update 2021-01-22 18:33:53 +00:00
bfeced5f34 3.0.9 2020-11-18 16:52:50 +00:00
24b9794a18 fix(core): update 2020-11-18 16:52:49 +00:00
a781329a47 3.0.8 2020-08-13 03:10:38 +00:00
6b5e0a1207 fix(core): update 2020-08-13 03:10:37 +00:00
2455adfbca 3.0.7 2020-08-12 16:36:06 +00:00
a2cf86b62f fix(core): update 2020-08-12 16:36:06 +00:00
23 changed files with 6317 additions and 3400 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 @gitzone/tsdoc
npmci command tsdoc
continue-on-error: true

View File

@ -1,127 +0,0 @@
# gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache:
paths:
- .npmci_cache/
key: '$CI_BUILD_STAGE'
stages:
- security
- test
- release
- metadata
# ====================
# security stage
# ====================
mirror:
stage: security
script:
- npmci git mirror
tags:
- lossless
- docker
- notpriv
audit:
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 npm audit --audit-level=high
tags:
- lossless
- docker
- notpriv
# ====================
# test stage
# ====================
testStable:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- lossless
- docker
- priv
testBuild:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- lossless
- docker
- notpriv
release:
stage: release
script:
- npmci node install stable
- npmci npm publish
only:
- tags
tags:
- lossless
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
allow_failure: true
script:
- npmci command npm install -g tslint typescript
- npmci npm prepare
- npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags:
- lossless
- docker
- priv
trigger:
stage: metadata
script:
- npmci trigger
only:
- tags
tags:
- lossless
- docker
- notpriv
pages:
stage: metadata
script:
- npmci node install lts
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare
- npmci npm install
- npmci command tsdoc
tags:
- lossless
- docker
- notpriv
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public
allow_failure: true

12
.snyk
View File

@ -1,12 +0,0 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
'npm:node-forge:20180226':
- rsa-compat > node-forge:
reason: None given
expires: '2018-09-11T19:17:24.148Z'
- acme-v2 > rsa-compat > node-forge:
reason: None given
expires: '2018-09-11T19:17:24.148Z'
patch: {}

24
.vscode/launch.json vendored
View File

@ -2,28 +2,10 @@
"version": "0.2.0",
"configurations": [
{
"name": "current file",
"type": "node",
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"args": [
"${relativeFile}"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "test.ts",
"type": "node",
"request": "launch",
"args": [
"test/test.ts"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
"type": "node-terminal"
}
]
}

View File

@ -15,7 +15,7 @@
"properties": {
"projectType": {
"type": "string",
"enum": ["website", "element", "service", "npm"]
"enum": ["website", "element", "service", "npm", "wcc"]
}
}
}

View File

@ -3,10 +3,10 @@
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "pushrocks",
"gitrepo": "smartuniverse",
"shortDescription": "acme with an easy yet powerful interface in TypeScript",
"npmPackagename": "@pushrocks/smartuniverse",
"gitscope": "push.rocks",
"gitrepo": "smartacme",
"description": "acme with an easy yet powerful interface in TypeScript",
"npmPackagename": "@push.rocks/smartacme",
"license": "MIT",
"projectDomain": "push.rocks"
}

3100
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,15 @@
{
"name": "@pushrocks/smartacme",
"version": "3.0.6",
"name": "@push.rocks/smartacme",
"version": "4.0.6",
"private": false,
"description": "acme with an easy yet powerful interface in TypeScript",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
"scripts": {
"test": "(tstest test/)",
"build": "(tsbuild)"
"build": "(tsbuild --web --allowimplicitany)",
"buildDocs": "tsdoc"
},
"repository": {
"type": "git",
@ -25,30 +27,28 @@
},
"homepage": "https://gitlab.com/umbrellazone/smartacme#README",
"dependencies": {
"@pushrocks/lik": "^3.0.19",
"@pushrocks/smartdata": "^3.1.26",
"@pushrocks/smartdelay": "^2.0.6",
"@pushrocks/smartdns": "^4.0.2",
"@pushrocks/smartexpress": "^3.0.57",
"@pushrocks/smartlog": "^2.0.21",
"@pushrocks/smartpromise": "^3.0.6",
"@pushrocks/smartrequest": "^1.1.47",
"@pushrocks/smartstring": "^3.0.18",
"@pushrocks/smarttime": "^3.0.12",
"@pushrocks/smartunique": "^3.0.1",
"@tsclass/tsclass": "^3.0.7",
"acme-client": "^3.3.1"
"@apiglobal/typedserver": "^2.0.65",
"@push.rocks/lik": "^6.0.3",
"@push.rocks/smartdata": "^5.0.8",
"@push.rocks/smartdelay": "^3.0.5",
"@push.rocks/smartdns": "^5.0.2",
"@push.rocks/smartlog": "^3.0.3",
"@push.rocks/smartpromise": "^4.0.3",
"@push.rocks/smartrequest": "^2.0.18",
"@push.rocks/smartstring": "^4.0.5",
"@push.rocks/smarttime": "^4.0.4",
"@push.rocks/smartunique": "^3.0.3",
"@tsclass/tsclass": "^4.0.42",
"acme-client": "^4.2.5"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.17",
"@gitzone/tsrun": "^1.2.8",
"@gitzone/tstest": "^1.0.28",
"@mojoio/cloudflare": "^4.0.3",
"@pushrocks/qenv": "^4.0.6",
"@pushrocks/tapbundle": "^3.2.0",
"@types/node": "^13.7.4",
"tslint": "^6.0.0",
"tslint-config-prettier": "^1.18.0"
"@apiclient.xyz/cloudflare": "^6.0.3",
"@gitzone/tsbuild": "^2.1.66",
"@gitzone/tsrun": "^1.2.44",
"@gitzone/tstest": "^1.0.77",
"@push.rocks/qenv": "^5.0.2",
"@push.rocks/tapbundle": "^5.0.12",
"@types/node": "^20.4.2"
},
"files": [
"ts/**/*",
@ -61,5 +61,8 @@
"cli.js",
"npmextra.json",
"readme.md"
],
"browserslist": [
"last 1 chrome versions"
]
}

5981
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,5 @@
required:
- CF_EMAIL
- CF_KEY
- CF_TOKEN
- MONGODB_URL
- MONGODB_PASSWORD
- MONGODB_DATABASE

View File

@ -1,20 +1,26 @@
# @pushrocks/smartuniverse
# @push.rocks/smartacme
acme with an easy yet powerful interface in TypeScript
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartuniverse)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartuniverse)
* [github.com (source mirror)](https://github.com/pushrocks/smartuniverse)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartuniverse/)
* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartacme)
* [gitlab.com (source)](https://gitlab.com/push.rocks/smartacme)
* [github.com (source mirror)](https://github.com/push.rocks/smartacme)
* [docs (typedoc)](https://push.rocks.gitlab.io/smartacme/)
## Status for master
[![pipeline status](https://gitlab.com/pushrocks/smartuniverse/badges/master/pipeline.svg)](https://gitlab.com/pushrocks/smartuniverse/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartuniverse/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartuniverse/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartuniverse.svg)](https://www.npmjs.com/package/@pushrocks/smartuniverse)
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartuniverse/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartuniverse)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/push.rocks/smartacme/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/push.rocks/smartacme/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@push.rocks/smartacme)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/push.rocks/smartacme)](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/@push.rocks/smartacme)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@push.rocks/smartacme)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@push.rocks/smartacme)](https://lossless.cloud)
## Usage
@ -30,15 +36,15 @@ const run = async () => {
mongoDescriptor: {
mongoDbName: testQenv.getEnvVarRequired('MONGODB_DATABASE'),
mongoDbPass: testQenv.getEnvVarRequired('MONGODB_PASSWORD'),
mongoDbUrl: testQenv.getEnvVarRequired('MONGODB_URL')
mongoDbUrl: testQenv.getEnvVarRequired('MONGODB_URL'),
},
removeChallenge: async dnsChallenge => {
removeChallenge: async (dnsChallenge) => {
// somehow provide a function that is able to remove the dns challenge
},
setChallenge: async dnsChallenge => {
setChallenge: async (dnsChallenge) => {
// somehow provide a function that is able to the dns challenge
},
environment: 'integration'
environment: 'integration',
});
await smartAcmeInstance.init();
@ -53,7 +59,6 @@ We are always happy for code contributions. If you are not the code contributing
For further information read the linked docs at the top of this readme.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
## Legal
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)

View File

@ -1,14 +1,11 @@
import { tap, expect } from '@pushrocks/tapbundle';
import { Qenv } from '@pushrocks/qenv';
import * as cloudflare from '@mojoio/cloudflare';
import { tap, expect } from '@push.rocks/tapbundle';
import { Qenv } from '@push.rocks/qenv';
import * as cloudflare from '@apiclient.xyz/cloudflare';
const testQenv = new Qenv('./', './.nogit/');
const testCloudflare = new cloudflare.CloudflareAccount({
email: testQenv.getEnvVarOnDemand('CF_EMAIL'),
key: testQenv.getEnvVarOnDemand('CF_KEY')
});
const testCloudflare = new cloudflare.CloudflareAccount(testQenv.getEnvVarOnDemand('CF_TOKEN'));
import * as smartacme from '../ts/index';
import * as smartacme from '../ts/index.js';
let smartAcmeInstance: smartacme.SmartAcme;
@ -19,28 +16,29 @@ tap.test('should create a valid instance of SmartAcme', async () => {
mongoDescriptor: {
mongoDbName: testQenv.getEnvVarRequired('MONGODB_DATABASE'),
mongoDbPass: testQenv.getEnvVarRequired('MONGODB_PASSWORD'),
mongoDbUrl: testQenv.getEnvVarRequired('MONGODB_URL')
mongoDbUrl: testQenv.getEnvVarRequired('MONGODB_URL'),
},
removeChallenge: async dnsChallenge => {
removeChallenge: async (dnsChallenge) => {
testCloudflare.convenience.acmeRemoveDnsChallenge(dnsChallenge);
},
setChallenge: async dnsChallenge => {
setChallenge: async (dnsChallenge) => {
testCloudflare.convenience.acmeSetDnsChallenge(dnsChallenge);
},
environment: 'integration'
environment: 'integration',
});
await smartAcmeInstance.init();
});
tap.test('should get a domain certificate', async () => {
await smartAcmeInstance.getCertificateForDomain('bleu.de');
const certificate = await smartAcmeInstance.getCertificateForDomain('bleu.de');
console.log(certificate);
});
tap.test('certmatcher should correctly match domains', async () => {
const certMatcherMod = await import('../ts/smartacme.classes.certmatcher');
const certMatcherMod = await import('../ts/smartacme.classes.certmatcher.js');
const certMatcher = new certMatcherMod.CertMatcher();
const matchedCert = certMatcher.getCertificateDomainNameByDomainName('level3.level2.level1');
expect(matchedCert).to.equal('level2.level1');
expect(matchedCert).toEqual('level2.level1');
});
tap.test('should stop correctly', async () => {

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/smartacme',
version: '4.0.6',
description: 'acme with an easy yet powerful interface in TypeScript'
}

View File

@ -1 +1 @@
export * from './smartacme.classes.smartacme';
export * from './smartacme.classes.smartacme.js';

View File

@ -1 +1 @@
export * from './accountdata';
export * from './accountdata.js';

View File

@ -1,16 +1,18 @@
import * as plugins from './smartacme.plugins';
import * as plugins from './smartacme.plugins.js';
import * as interfaces from './interfaces';
import * as interfaces from './interfaces/index.js';
import { CertManager } from './smartacme.classes.certmanager';
import { CertManager } from './smartacme.classes.certmanager.js';
import { Collection, svDb, unI } from '@pushrocks/smartdata';
import { Collection, svDb, unI } from '@push.rocks/smartdata';
@plugins.smartdata.Collection(() => {
return CertManager.activeDB;
})
export class Cert extends plugins.smartdata.SmartDataDbDoc<Cert, plugins.tsclass.network.ICert>
implements plugins.tsclass.network.ICert {
export class Cert
extends plugins.smartdata.SmartDataDbDoc<Cert, plugins.tsclass.network.ICert>
implements plugins.tsclass.network.ICert
{
@unI()
public id: string;
@ -40,13 +42,13 @@ export class Cert extends plugins.smartdata.SmartDataDbDoc<Cert, plugins.tsclass
const shouldBeValidAtLeastUntil =
Date.now() +
plugins.smarttime.getMilliSecondsFromUnits({
days: 10
days: 10,
});
return !(this.validUntil >= shouldBeValidAtLeastUntil);
}
public update(certDataArg: plugins.tsclass.network.ICert) {
Object.keys(certDataArg).forEach(key => {
Object.keys(certDataArg).forEach((key) => {
this[key] = certDataArg[key];
});
}
@ -54,7 +56,7 @@ export class Cert extends plugins.smartdata.SmartDataDbDoc<Cert, plugins.tsclass
constructor(optionsArg: plugins.tsclass.network.ICert) {
super();
if (optionsArg) {
Object.keys(optionsArg).forEach(key => {
Object.keys(optionsArg).forEach((key) => {
this[key] = optionsArg[key];
});
}

View File

@ -1,8 +1,8 @@
import * as plugins from './smartacme.plugins';
import { Cert } from './smartacme.classes.cert';
import { SmartAcme } from './smartacme.classes.smartacme';
import * as plugins from './smartacme.plugins.js';
import { Cert } from './smartacme.classes.cert.js';
import { SmartAcme } from './smartacme.classes.smartacme.js';
import * as interfaces from './interfaces';
import * as interfaces from './interfaces/index.js';
export class CertManager {
// =========
@ -34,7 +34,7 @@ export class CertManager {
CertManager.activeDB = this.smartdataDb;
// Pending Map
this.interestMap = new plugins.lik.InterestMap(certName => certName);
this.interestMap = new plugins.lik.InterestMap((certName) => certName);
}
/**
@ -43,8 +43,8 @@ export class CertManager {
* @param certDomainNameArg the domain Name to retrieve the vcertificate for
*/
public async retrieveCertificate(certDomainNameArg: string): Promise<Cert> {
const existingCertificate: Cert = await Cert.getInstance({
domainName: certDomainNameArg
const existingCertificate: Cert = await Cert.getInstance<Cert>({
domainName: certDomainNameArg,
});
if (existingCertificate) {
@ -69,8 +69,8 @@ export class CertManager {
}
public async deleteCertificate(certDomainNameArg: string) {
const cert: Cert = await Cert.getInstance({
domainName: certDomainNameArg
const cert: Cert = await Cert.getInstance<Cert>({
domainName: certDomainNameArg,
});
await cert.delete();
}

View File

@ -1,5 +1,5 @@
import * as plugins from './smartacme.plugins';
import * as interfaces from './interfaces';
import * as plugins from './smartacme.plugins.js';
import * as interfaces from './interfaces/index.js';
/**
* certmatcher is responsible for matching certificates

View File

@ -1,7 +1,7 @@
import * as plugins from './smartacme.plugins';
import { Cert } from './smartacme.classes.cert';
import { CertManager } from './smartacme.classes.certmanager';
import { CertMatcher } from './smartacme.classes.certmatcher';
import * as plugins from './smartacme.plugins.js';
import { Cert } from './smartacme.classes.cert.js';
import { CertManager } from './smartacme.classes.certmanager.js';
import { CertMatcher } from './smartacme.classes.certmatcher.js';
/**
* the options for the class @see SmartAcme
@ -13,7 +13,6 @@ export interface ISmartAcmeOptions {
setChallenge: (dnsChallengeArg: plugins.tsclass.network.IDnsChallenge) => Promise<any>;
removeChallenge: (dnsChallengeArg: plugins.tsclass.network.IDnsChallenge) => Promise<any>;
environment: 'production' | 'integration';
logger?: plugins.smartlog.Smartlog;
}
/**
@ -32,7 +31,7 @@ export class SmartAcme {
// the acme client
private client: any;
private smartdns = new plugins.smartdns.Smartdns({});
public logger: plugins.smartlog.Smartlog;
public logger: plugins.smartlog.ConsoleLog;
// the account private key
private privateKey: string;
@ -47,9 +46,7 @@ export class SmartAcme {
constructor(optionsArg: ISmartAcmeOptions) {
this.options = optionsArg;
this.options.logger
? (this.logger = optionsArg.logger)
: (this.logger = plugins.smartlog.defaultLogger);
this.logger = new plugins.smartlog.ConsoleLog();
}
/**
@ -66,7 +63,7 @@ export class SmartAcme {
// CertMangaer
this.certmanager = new CertManager(this, {
mongoDescriptor: this.options.mongoDescriptor
mongoDescriptor: this.options.mongoDescriptor,
});
await this.certmanager.init();
@ -82,13 +79,13 @@ export class SmartAcme {
return plugins.acme.directory.letsencrypt.staging;
}
})(),
accountKey: this.privateKey
accountKey: this.privateKey,
});
/* Register account */
await this.client.createAccount({
termsOfServiceAgreed: true,
contact: [`mailto:${this.options.accountEmail}`]
contact: [`mailto:${this.options.accountEmail}`],
});
}
@ -134,8 +131,8 @@ export class SmartAcme {
const order = await this.client.createOrder({
identifiers: [
{ type: 'dns', value: certDomainName },
{ type: 'dns', value: `*.${certDomainName}` }
]
{ type: 'dns', value: `*.${certDomainName}` },
],
});
/* Get authorizations and select challenges */
@ -144,7 +141,7 @@ export class SmartAcme {
for (const authz of authorizations) {
console.log(authz);
const fullHostName: string = `_acme-challenge.${authz.identifier.value}`;
const dnsChallenge: string = authz.challenges.find(challengeArg => {
const dnsChallenge: string = authz.challenges.find((challengeArg) => {
return challengeArg.type === 'dns-01';
});
// process.exit(1);
@ -154,8 +151,9 @@ export class SmartAcme {
/* Satisfy challenge */
await this.setChallenge({
hostName: fullHostName,
challenge: keyAuthorization
challenge: keyAuthorization,
});
await plugins.smartdelay.delayFor(30000);
await this.smartdns.checkUntilAvailable(fullHostName, 'TXT', keyAuthorization, 100, 5000);
console.log('Cool down an extra 60 second for region availability');
await plugins.smartdelay.delayFor(60000);
@ -173,7 +171,7 @@ export class SmartAcme {
try {
await this.removeChallenge({
hostName: fullHostName,
challenge: keyAuthorization
challenge: keyAuthorization,
});
} catch (e) {
console.log(e);
@ -184,7 +182,7 @@ export class SmartAcme {
/* Finalize order */
const [key, csr] = await plugins.acme.forge.createCsr({
commonName: `*.${certDomainName}`,
altNames: [certDomainName]
altNames: [certDomainName],
});
await this.client.finalizeOrder(order, csr);
@ -202,8 +200,8 @@ export class SmartAcme {
validUntil:
Date.now() +
plugins.smarttime.getMilliSecondsFromUnits({
days: 90
})
days: 90,
}),
});
const newCertificate = await this.certmanager.retrieveCertificate(certDomainName);

View File

@ -1,28 +1,31 @@
// @apiglobal scope
import * as typedserver from '@apiglobal/typedserver';
export { typedserver };
// @pushrocks scope
import * as lik from '@pushrocks/lik';
import * as smartdata from '@pushrocks/smartdata';
import * as smartdelay from '@pushrocks/smartdelay';
import * as smartdns from '@pushrocks/smartdns';
import * as smartexpress from '@pushrocks/smartexpress';
import * as smartlog from '@pushrocks/smartlog';
import * as smartpromise from '@pushrocks/smartpromise';
import * as smartrequest from '@pushrocks/smartrequest';
import * as smartunique from '@pushrocks/smartunique';
import * as smartstring from '@pushrocks/smartstring';
import * as smarttime from '@pushrocks/smarttime';
import * as lik from '@push.rocks/lik';
import * as smartdata from '@push.rocks/smartdata';
import * as smartdelay from '@push.rocks/smartdelay';
import * as smartdns from '@push.rocks/smartdns';
import * as smartlog from '@push.rocks/smartlog';
import * as smartpromise from '@push.rocks/smartpromise';
import * as smartrequest from '@push.rocks/smartrequest';
import * as smartunique from '@push.rocks/smartunique';
import * as smartstring from '@push.rocks/smartstring';
import * as smarttime from '@push.rocks/smarttime';
export {
lik,
smartdata,
smartdelay,
smartdns,
smartexpress,
smartlog,
smartpromise,
smartrequest,
smartunique,
smartstring,
smarttime
smarttime,
};
// @tsclass scope

View File

@ -1,7 +1,11 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"target": "es2017",
"module": "commonjs"
"useDefineForClassFields": false,
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "nodenext",
"esModuleInterop": true,
"verbatimModuleSyntax": true,
}
}

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