Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
3a48cb4ea8 | |||
a035c5c0b0 | |||
f9c521b7b3 | |||
19cfe8bdc5 | |||
601d6b30d3 | |||
57ffc82c43 | |||
312d3c01cd | |||
8814c1fc62 | |||
223a47c997 |
@ -3,69 +3,140 @@ image: hosttoday/ht-docker-node:npmci
|
|||||||
|
|
||||||
cache:
|
cache:
|
||||||
paths:
|
paths:
|
||||||
- .yarn/
|
- .npmci_cache/
|
||||||
key: "$CI_BUILD_STAGE"
|
key: "$CI_BUILD_STAGE"
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
|
- security
|
||||||
- test
|
- test
|
||||||
- release
|
- release
|
||||||
- trigger
|
- metadata
|
||||||
- pages
|
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# security stage
|
||||||
|
# ====================
|
||||||
|
mirror:
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci git mirror
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
snyk:
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci command npm install -g snyk
|
||||||
|
- npmci command npm install --ignore-scripts
|
||||||
|
- npmci command snyk test
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# test stage
|
||||||
|
# ====================
|
||||||
testLEGACY:
|
testLEGACY:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test legacy
|
- npmci node install legacy
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
|
||||||
testLTS:
|
testLTS:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test lts
|
- npmci node install lts
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
testSTABLE:
|
testSTABLE:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test stable
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
script:
|
script:
|
||||||
- npmci publish
|
- npmci node install stable
|
||||||
|
- npmci npm publish
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# metadata stage
|
||||||
|
# ====================
|
||||||
|
codequality:
|
||||||
|
stage: metadata
|
||||||
|
image: docker:stable
|
||||||
|
allow_failure: true
|
||||||
|
services:
|
||||||
|
- docker:stable-dind
|
||||||
|
script:
|
||||||
|
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
||||||
|
- docker run
|
||||||
|
--env SOURCE_CODE="$PWD"
|
||||||
|
--volume "$PWD":/code
|
||||||
|
--volume /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
|
||||||
|
artifacts:
|
||||||
|
paths: [codeclimate.json]
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
stage: trigger
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci trigger
|
- npmci trigger
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
image: hosttoday/ht-docker-node:npmci
|
image: hosttoday/ht-docker-node:npmci
|
||||||
stage: pages
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci command yarn global add npmpage
|
- npmci command npm install -g typedoc typescript
|
||||||
- npmci command npmpage
|
- npmci npm install
|
||||||
|
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
artifacts:
|
artifacts:
|
||||||
expire_in: 1 week
|
expire_in: 1 week
|
||||||
paths:
|
paths:
|
||||||
- public
|
- public
|
||||||
|
allow_failure: true
|
||||||
|
|
||||||
|
windowsCompatibility:
|
||||||
|
image: stefanscherer/node-windows:10-build-tools
|
||||||
|
stage: metadata
|
||||||
|
script:
|
||||||
|
- npm install & npm test
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
|
tags:
|
||||||
|
- windows
|
||||||
|
allow_failure: true
|
||||||
|
12
.snyk
Normal file
12
.snyk
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# 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: {}
|
@ -1,13 +1,16 @@
|
|||||||
# smartacme
|
# smartacme
|
||||||
|
|
||||||
acme implementation in TypeScript
|
acme implementation in TypeScript
|
||||||
|
|
||||||
## Availabililty
|
## Availabililty
|
||||||
|
|
||||||
[](https://www.npmjs.com/package/smartacme)
|
[](https://www.npmjs.com/package/smartacme)
|
||||||
[](https://GitLab.com/umbrellazone/smartacme)
|
[](https://GitLab.com/umbrellazone/smartacme)
|
||||||
[](https://github.com/umbrellazone/smartacme)
|
[](https://github.com/umbrellazone/smartacme)
|
||||||
[](https://umbrellazone.gitlab.io/smartacme/)
|
[](https://umbrellazone.gitlab.io/smartacme/)
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
|
|
||||||
[](https://GitLab.com/umbrellazone/smartacme/commits/master)
|
[](https://GitLab.com/umbrellazone/smartacme/commits/master)
|
||||||
[](https://GitLab.com/umbrellazone/smartacme/commits/master)
|
[](https://GitLab.com/umbrellazone/smartacme/commits/master)
|
||||||
[](https://www.npmjs.com/package/smartacme)
|
[](https://www.npmjs.com/package/smartacme)
|
||||||
@ -19,11 +22,12 @@ acme implementation in TypeScript
|
|||||||
[](http://standardjs.com/)
|
[](http://standardjs.com/)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Use TypeScript for best in class instellisense.
|
Use TypeScript for best in class instellisense.
|
||||||
|
|
||||||
For further information read the linked docs at the top of this README.
|
For further information read the linked docs at the top of this README.
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||||
|
|
||||||
[](https://umbrella.zone)
|
[](https://umbrella.zone)
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
# smartacme
|
# smartacme
|
||||||
|
|
||||||
acme implementation in TypeScript
|
acme implementation in TypeScript
|
||||||
|
|
||||||
## Availabililty
|
## Availabililty
|
||||||
|
|
||||||
[](https://www.npmjs.com/package/smartacme)
|
[](https://www.npmjs.com/package/smartacme)
|
||||||
[](https://GitLab.com/umbrellazone/smartacme)
|
[](https://GitLab.com/umbrellazone/smartacme)
|
||||||
[](https://github.com/umbrellazone/smartacme)
|
[](https://github.com/umbrellazone/smartacme)
|
||||||
[](https://umbrellazone.gitlab.io/smartacme/)
|
[](https://umbrellazone.gitlab.io/smartacme/)
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
|
|
||||||
[](https://GitLab.com/umbrellazone/smartacme/commits/master)
|
[](https://GitLab.com/umbrellazone/smartacme/commits/master)
|
||||||
[](https://GitLab.com/umbrellazone/smartacme/commits/master)
|
[](https://GitLab.com/umbrellazone/smartacme/commits/master)
|
||||||
[](https://www.npmjs.com/package/smartacme)
|
[](https://www.npmjs.com/package/smartacme)
|
||||||
@ -19,41 +22,42 @@ acme implementation in TypeScript
|
|||||||
[](http://standardjs.com/)
|
[](http://standardjs.com/)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Use TypeScript for best in class instellisense.
|
Use TypeScript for best in class instellisense.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
import { SmartAcme } from 'smartacme'
|
import { SmartAcme } from 'smartacme';
|
||||||
|
|
||||||
let smac = new SmartAcme()
|
let smac = new SmartAcme()(async () => {
|
||||||
|
// learn async/await, it'll make your life easier
|
||||||
(async () => { // learn async/await, it'll make your life easier
|
|
||||||
|
|
||||||
// optionally accepts a filePath Arg with a stored acmeaccount.json
|
// optionally accepts a filePath Arg with a stored acmeaccount.json
|
||||||
// will create an account and
|
// will create an account and
|
||||||
let myAccount = await smac.createAcmeAccount()
|
let myAccount = await smac.createAcmeAccount();
|
||||||
|
|
||||||
// will return a dnsHash to set in your DNS record
|
// will return a dnsHash to set in your DNS record
|
||||||
let myCert = await myAccount.createAcmeCert('example.com')
|
let myCert = await myAccount.createAcmeCert('example.com');
|
||||||
|
|
||||||
// gets and accepts the specified challenge
|
// gets and accepts the specified challenge
|
||||||
// first argument optional, defaults to dns-01 (which is the cleanest method for production use)
|
// first argument optional, defaults to dns-01 (which is the cleanest method for production use)
|
||||||
let myChallenge = await myCert.getChallenge('dns-01')
|
let myChallenge = await myCert.getChallenge('dns-01');
|
||||||
|
|
||||||
/* ----------
|
/* ----------
|
||||||
Now you need to set the challenge in your DNS
|
Now you need to set the challenge in your DNS
|
||||||
myChallenge.domainNamePrefixed is the address for the record
|
myChallenge.domainNamePrefixed is the address for the record
|
||||||
myChallenge.dnsKeyHash is the ready to use txt record value expected by letsencrypt
|
myChallenge.dnsKeyHash is the ready to use txt record value expected by letsencrypt
|
||||||
-------------*/
|
-------------*/
|
||||||
})()
|
})();
|
||||||
```
|
```
|
||||||
|
|
||||||
## Other relevant npm modules
|
## Other relevant npm modules
|
||||||
module name | description
|
|
||||||
--- | ---
|
| module name | description |
|
||||||
cert | a higlevel production module that uses smartacme to manage certs
|
| ----------- | ------------------------------------------------------------------- |
|
||||||
smartnginx | a highlevel production tool for docker environments to manage nginx
|
| cert | a higlevel production module that uses smartacme to manage certs |
|
||||||
|
| smartnginx | a highlevel production tool for docker environments to manage nginx |
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||||
|
|
||||||
[](https://umbrella.zone
|
[](https://umbrella.zone
|
@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"npmci": {
|
"npmci": {
|
||||||
"globalNpmTools": [
|
"npmGlobalTools": [],
|
||||||
"npmts"
|
"npmAccessLevel": "public"
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
10
package-lock.json
generated
10
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "smartacme",
|
"name": "smartacme",
|
||||||
"version": "1.1.0",
|
"version": "2.0.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -69,6 +69,14 @@
|
|||||||
"ansi-256-colors": "^1.1.0"
|
"ansi-256-colors": "^1.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@pushrocks/smartdelay": {
|
||||||
|
"version": "2.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@pushrocks/smartdelay/-/smartdelay-2.0.2.tgz",
|
||||||
|
"integrity": "sha512-4xf6tMKwZcxBynKgXrM4SQKgeASfRvx43LUmR5DkStp26ZHAsarCXUdKJS6y8QIPygEOTOCP8we97JAcCzBuMg==",
|
||||||
|
"requires": {
|
||||||
|
"@pushrocks/smartpromise": "^2.0.5"
|
||||||
|
}
|
||||||
|
},
|
||||||
"@pushrocks/smartfile": {
|
"@pushrocks/smartfile": {
|
||||||
"version": "6.0.6",
|
"version": "6.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/@pushrocks/smartfile/-/smartfile-6.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/@pushrocks/smartfile/-/smartfile-6.0.6.tgz",
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "smartacme",
|
"name": "@pushrocks/smartacme",
|
||||||
"version": "1.1.0",
|
"version": "2.0.0",
|
||||||
|
"private": false,
|
||||||
"description": "acme implementation in TypeScript",
|
"description": "acme implementation in TypeScript",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/)"
|
"test": "(tstest test/)",
|
||||||
|
"build": "echo \"Not needed for now\""
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -23,6 +25,7 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/umbrellazone/smartacme#README",
|
"homepage": "https://gitlab.com/umbrellazone/smartacme#README",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@pushrocks/smartdelay": "^2.0.2",
|
||||||
"@pushrocks/smartpromise": "^2.0.5",
|
"@pushrocks/smartpromise": "^2.0.5",
|
||||||
"acme-v2": "^1.2.0",
|
"acme-v2": "^1.2.0",
|
||||||
"rsa-compat": "^1.5.1"
|
"rsa-compat": "^1.5.1"
|
||||||
|
@ -6,8 +6,9 @@ let smartAcmeInstance: smartacme.SmartAcme;
|
|||||||
|
|
||||||
tap.test('should create a valid instance of SmartAcme', async () => {
|
tap.test('should create a valid instance of SmartAcme', async () => {
|
||||||
smartAcmeInstance = new smartacme.SmartAcme();
|
smartAcmeInstance = new smartacme.SmartAcme();
|
||||||
await smartAcmeInstance.init()
|
await smartAcmeInstance.init();
|
||||||
console.log(smartAcmeInstance.directoryUrls);
|
console.log(smartAcmeInstance.directoryUrls);
|
||||||
})
|
await smartAcmeInstance.getCertificateForDomain('bleu.de');
|
||||||
|
});
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
@ -1 +1 @@
|
|||||||
export * from './smartacme.classes.smartacme'
|
export * from './smartacme.classes.smartacme';
|
||||||
|
@ -2,7 +2,7 @@ import * as plugins from './smartacme.plugins';
|
|||||||
const rsa = require('rsa-compat').RSA;
|
const rsa = require('rsa-compat').RSA;
|
||||||
|
|
||||||
export class KeyPair {
|
export class KeyPair {
|
||||||
rsaKeyPair: any
|
rsaKeyPair: any;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* generates a fresh rsa keyPair
|
* generates a fresh rsa keyPair
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
const acme = require('acme-v2').ACME.create({
|
const acme = require('acme-v2').ACME.create({
|
||||||
RSA: require('rsa-compat').RSA,
|
RSA: require('rsa-compat').RSA,
|
||||||
|
|
||||||
// other overrides
|
|
||||||
promisify: require('util').promisify,
|
|
||||||
|
|
||||||
// used for constructing user-agent
|
// used for constructing user-agent
|
||||||
os: require('os'),
|
os: require('os'),
|
||||||
process: require('process'),
|
process: require('process'),
|
||||||
@ -15,33 +12,75 @@ const acme = require('acme-v2').ACME.create({
|
|||||||
},
|
},
|
||||||
|
|
||||||
// don't try to validate challenges locally
|
// don't try to validate challenges locally
|
||||||
skipChallengeTest: false
|
skipChallengeTest: true
|
||||||
});
|
});
|
||||||
|
|
||||||
import { KeyPair } from './smartacme.classes.keypair';
|
import { KeyPair } from './smartacme.classes.keypair';
|
||||||
|
import * as plugins from './smartacme.plugins';
|
||||||
|
const rsa = require('rsa-compat').RSA;
|
||||||
|
|
||||||
export class SmartAcme {
|
export class SmartAcme {
|
||||||
keyPair: KeyPair;
|
domainKeyPair: KeyPair;
|
||||||
|
accountKeyPair: KeyPair;
|
||||||
|
accountData: any;
|
||||||
directoryUrls: any;
|
directoryUrls: any;
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
// get directory url
|
// get directory url
|
||||||
this.directoryUrls = await acme.init('https://acme-staging-v02.api.letsencrypt.org/directory');
|
this.directoryUrls = await acme.init('https://acme-staging-v02.api.letsencrypt.org/directory');
|
||||||
|
|
||||||
// create keyPair
|
// create keyPairs
|
||||||
this.keyPair = await KeyPair.generateFresh();
|
this.domainKeyPair = await KeyPair.generateFresh();
|
||||||
|
this.accountKeyPair = await KeyPair.generateFresh();
|
||||||
|
|
||||||
// get account
|
// get account
|
||||||
const registrationData = await acme.accounts.create({
|
const registrationData = await acme.accounts
|
||||||
|
.create({
|
||||||
email: 'domains@lossless.org', // valid email (server checks MX records)
|
email: 'domains@lossless.org', // valid email (server checks MX records)
|
||||||
accountKeypair: this.keyPair.rsaKeyPair,
|
accountKeypair: this.accountKeyPair.rsaKeyPair,
|
||||||
agreeToTerms: async tosUrl => {
|
agreeToTerms: async tosUrl => {
|
||||||
return tosUrl;
|
return tosUrl;
|
||||||
}
|
}
|
||||||
}).catch(e => {
|
})
|
||||||
|
.catch(e => {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
});
|
});
|
||||||
|
this.accountData = registrationData;
|
||||||
|
}
|
||||||
|
|
||||||
console.log(registrationData);
|
async getCertificateForDomain(domain) {
|
||||||
|
const result = await acme.certificates
|
||||||
|
.create({
|
||||||
|
domainKeypair: this.domainKeyPair.rsaKeyPair,
|
||||||
|
accountKeypair: this.accountKeyPair.rsaKeyPair,
|
||||||
|
domains: ['bleu.de'],
|
||||||
|
challengeType: 'dns-01',
|
||||||
|
|
||||||
|
setChallenge: async (hostname, key, val, cb) => {
|
||||||
|
console.log('set challenge');
|
||||||
|
console.log(hostname);
|
||||||
|
//console.log(key);
|
||||||
|
//console.log(val);
|
||||||
|
const dnsKey = rsa.utils.toWebsafeBase64(
|
||||||
|
require('crypto')
|
||||||
|
.createHash('sha256')
|
||||||
|
.update(val)
|
||||||
|
.digest('base64')
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(dnsKey);
|
||||||
|
await plugins.smartdelay.delayFor(20000);
|
||||||
|
console.log('ready!');
|
||||||
|
cb();
|
||||||
|
}, // return Promise
|
||||||
|
removeChallenge: async (hostname, key) => {
|
||||||
|
console.log('removing challenge');
|
||||||
|
return;
|
||||||
|
} // return Promise
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
|
console.log(e);
|
||||||
|
}); // returns Promise<pems={ privkey (key), cert, chain (ca) }>
|
||||||
|
console.log(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import * as smartpromise from '@pushrocks/smartpromise';
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
|
import * as smartdelay from '@pushrocks/smartdelay';
|
||||||
|
|
||||||
export {
|
export { smartpromise, smartdelay };
|
||||||
smartpromise
|
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user