@cocreate/acme 1.2.8 → 1.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [1.2.10](https://github.com/CoCreate-app/CoCreate-acme/compare/v1.2.9...v1.2.10) (2024-04-26)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * merge hostObject to retain previous configuration reltaed to database ([c9d7c16](https://github.com/CoCreate-app/CoCreate-acme/commit/c9d7c160dfd07f3f5a91c9e2cebab5da2d86ec1c))
7
+
8
+ ## [1.2.9](https://github.com/CoCreate-app/CoCreate-acme/compare/v1.2.8...v1.2.9) (2024-04-10)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * handling organization_id if undefined ([c537cd1](https://github.com/CoCreate-app/CoCreate-acme/commit/c537cd18ef84d4b6d102e2028321a623756c0dfc))
14
+
1
15
  ## [1.2.8](https://github.com/CoCreate-app/CoCreate-acme/compare/v1.2.7...v1.2.8) (2024-03-18)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/acme",
3
- "version": "1.2.8",
3
+ "version": "1.2.10",
4
4
  "description": "Dynamic SSL certificate management leveraging the ACME protocol, designed for direct API accessibility within applications. Automates certificate creation, renewal, and retrieval, ideal for distributed applications requiring real-time, secure certificate operations.",
5
5
  "keywords": [
6
6
  "acme",
package/src/index.js CHANGED
@@ -76,7 +76,7 @@ class CoCreateAcme {
76
76
  }
77
77
  }
78
78
 
79
- async requestCertificate(host, hostPosition, organization_id, wildcard = false) {
79
+ async requestCertificate(host, hostPosition, hostObject, organization_id, wildcard = false) {
80
80
  try {
81
81
 
82
82
  const self = this
@@ -175,7 +175,7 @@ class CoCreateAcme {
175
175
  array: 'organizations',
176
176
  object: {
177
177
  _id: organization_id,
178
- [`host[${hostPosition}]`]: { name: host, cert, key, expires },
178
+ [`host[${hostPosition}]`]: { ...hostObject, name: host, cert, key, expires },
179
179
  },
180
180
  organization_id
181
181
  });
@@ -192,16 +192,19 @@ class CoCreateAcme {
192
192
 
193
193
  async getCertificate(host, organization_id) {
194
194
  const hostKeyPath = keyPath + host + '/';
195
- let hostPosition
195
+ let hostPosition, hostObject
196
196
 
197
197
  let organization = await this.crud.getOrganization({ host, organization_id });
198
198
  if (organization.error)
199
199
  return false
200
+ if (!organization_id)
201
+ organization_id = organization._id
200
202
 
201
203
  if (organization.host) {
202
204
  for (let i = 0; i < organization.host.length; i++) {
203
205
  if (organization.host[i].name === host) {
204
206
  hostPosition = i
207
+ hostObject = organization.host[i]
205
208
  if (organization.host[i].cert && organization.host[i].key) {
206
209
  let expires = await forge.readCertificateInfo(organization.host[i].cert);
207
210
  expires = expires.notAfter;
@@ -218,7 +221,7 @@ class CoCreateAcme {
218
221
  return false
219
222
  }
220
223
 
221
- return await this.requestCertificate(host, hostPosition, organization_id, false)
224
+ return await this.requestCertificate(host, hostPosition, hostObject, organization_id, false)
222
225
  }
223
226
 
224
227
  async checkCertificate(host, organization_id, pathname = '') {