Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cocreate/acme

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cocreate/acme - npm Package Compare versions

Comparing version 1.1.2 to 1.1.3

8

CHANGELOG.md

@@ -0,1 +1,9 @@

## [1.1.3](https://github.com/CoCreate-app/CoCreate-acme/compare/v1.1.2...v1.1.3) (2024-01-03)
### Bug Fixes
* added licencing details ([220ee61](https://github.com/CoCreate-app/CoCreate-acme/commit/220ee61a9d954a62a5c505a34995e287f6f01c12))
* get organization_id and update certificate paths ([6ae3c71](https://github.com/CoCreate-app/CoCreate-acme/commit/6ae3c71cc1f16d6f93ec767bd5b4dae28b669764))
## [1.1.2](https://github.com/CoCreate-app/CoCreate-acme/compare/v1.1.1...v1.1.2) (2024-01-01)

@@ -2,0 +10,0 @@

5

package.json
{
"name": "@cocreate/acme",
"version": "1.1.2",
"version": "1.1.3",
"description": "An intergration with ACME and CoCreateJS.",
"keywords": [
"acme",
"chain-functions",
"cocreate",

@@ -38,3 +37,3 @@ "low-code-framework",

"author": "CoCreate LLC",
"license": "MIT",
"license": "AGPL-3.0",
"bugs": {

@@ -41,0 +40,0 @@ "url": "https://github.com/CoCreate-app/CoCreate-acme/issues"

8

README.md

@@ -85,2 +85,8 @@ # CoCreate-acme

[The MIT License (MIT)](https://github.com/CoCreate-app/CoCreate-acme/blob/master/LICENSE)
This software is dual-licensed under the GNU Affero General Public License version 3 (AGPLv3) and a commercial license.
- **Open Source Use**: For open-source projects and non-commercial use, this software is available under the AGPLv3. The AGPLv3 allows you to freely use, modify, and distribute this software, provided that all modifications and derivative works are also licensed under the AGPLv3. For the full license text, see the [LICENSE file](https://github.com/CoCreate-app/CoCreate-socket-client/blob/master/LICENSE).
- **Commercial Use**: For-profit companies and individuals intending to use this software for commercial purposes must obtain a commercial license. The commercial license is available when you sign up for an API key on our [website](https://cocreate.app). This license permits proprietary use and modification of the software without the copyleft requirements of the AGPLv3. It is ideal for integrating this software into proprietary commercial products and applications.
If you have not purchased a commercial license and intend to use this software for commercial purposes, you are required to sign up for an API key on our website.
const { Client, forge } = require('acme-client');
const fs = require('fs');
const util = require('node:util');
const exec = util.promisify(require('node:child_process').exec);
const certificates = new Map()
const certificates = {}
const email = 'ssl@cocreate.app';
const keyPath = 'certificates/';
const keyPath = '/etc/certificates/';
let client

@@ -21,2 +23,3 @@ const hosts = {}

this.crud = crud
// this.check = this.checkCertificate
this.init().catch(err => {

@@ -30,6 +33,9 @@ console.error('Error initializing ACME client:', err);

async init() {
if (!fs.existsSync(keyPath)) {
fs.mkdirSync(keyPath, { recursive: true }); // Create the directory if it doesn't exist
}
await exec('sudo mkdir -p /etc/certificates');
await exec('sudo chmod 777 /etc/certificates');
// if (!fs.existsSync(keyPath)) {
// fs.mkdirSync(keyPath, { recursive: true }); // Create the directory if it doesn't exist
// }
const accountKeyPath = keyPath + 'account.pem';

@@ -53,3 +59,3 @@

client = new Client({
directoryUrl: 'https://acme-staging-v02.api.letsencrypt.org/directory',
directoryUrl: 'https://acme-v02.api.letsencrypt.org/directory', // https://acme-v02.api.letsencrypt.org/directory https://acme-staging-v02.api.letsencrypt.org/directory
accountKey: accountKey

@@ -163,3 +169,3 @@ });

expires = expires.notAfter;
certificates.set(host, expires)
this.setCertificate(host, expires, organization_id)

@@ -199,2 +205,23 @@ /* Save the certificate and key */

if (!organization_id) {
let org = await this.crud.send({
method: 'object.read',
array: 'organizations',
$filter: {
query: [
{ key: "host", value: [host], operator: "$in" }
]
},
organization_id: process.env.organization_id
})
if (!org || !org.object || !org.object[0]) {
console.log('Organization could not be found');
return false
} else {
organization_id = org.object[0]._id
}
}
let organization = await this.crud.send({

@@ -222,3 +249,3 @@ method: 'object.read',

if (this.isValid(expires)) {
certificates.set(host, expires)
this.setCertificate(host, expires, organization_id)
if (!fs.existsSync(hostKeyPath)) {

@@ -233,3 +260,3 @@ fs.mkdirSync(hostKeyPath, { recursive: true });

// TODO: emit change so that nginx can reload
this.proxy.createServer(host)
return true

@@ -249,4 +276,3 @@ }

let expires = certificates.get(host)
if (expires && this.isValid(expires)) {
if (certificates[host]) {
return true

@@ -257,7 +283,7 @@ }

if (fs.existsSync(hostKeyPath + 'fullchain.pem')) {
expires = fs.readFileSync(hostKeyPath + 'fullchain.pem', 'utf8');
let expires = fs.readFileSync(hostKeyPath + 'fullchain.pem', 'utf8');
expires = await forge.readCertificateInfo(expires);
expires = expires.notAfter;
if (this.isValid(expires)) {
certificates.set(host, expires)
this.setCertificate(host, expires, organization_id)
return true

@@ -283,4 +309,34 @@ }

setCertificate(host, expires, organization_id) {
// let expireDate = new Date(expires);
// let currentDate = new Date();
// Adjust the expireDate by the DAYS, HOURS, and MINUTES constants
// expireDate.setDate(expireDate.getDate() - DAYS); // Subtracting to renew earlier
// expireDate.setHours(expireDate.getHours() - HOURS);
// expireDate.setMinutes(expireDate.getMinutes() - MINUTES);
// Calculate the time difference in milliseconds
// let timeoutDuration = expireDate.getTime() - currentDate.getTime();
// Ensure we're not setting a negative timeout in case of past dates or errors
// timeoutDuration = Math.max(timeoutDuration, 0);
// Clear any existing timeout for the host
// if (certificates[host] && certificates[host].timeout) {
// clearTimeout(certificates[host].timeout);
// }
// Set the timeout to call checkCertificate before the actual expiration
// let timeout = setTimeout(() => {
// this.checkCertificate(host, organization_id);
// }, timeoutDuration);
// Store the timeout and organization_id for later reference or cancellation
certificates[host] = { expires, organization_id }
}
}
module.exports = CoCreateAcme;

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc