@cocreate/acme 1.2.2 → 1.2.4

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.4](https://github.com/CoCreate-app/CoCreate-acme/compare/v1.2.3...v1.2.4) (2024-01-30)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * removed getHost ([3d58b30](https://github.com/CoCreate-app/CoCreate-acme/commit/3d58b3046f2444b76c9ce6a3f5dd78c6a17d3ca6))
7
+
8
+ ## [1.2.3](https://github.com/CoCreate-app/CoCreate-acme/compare/v1.2.2...v1.2.3) (2024-01-08)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * update to logging ([8e3946d](https://github.com/CoCreate-app/CoCreate-acme/commit/8e3946d6dc8af2719c9d76484e2f35d5b3dbee7b))
14
+
1
15
  ## [1.2.2](https://github.com/CoCreate-app/CoCreate-acme/compare/v1.2.1...v1.2.2) (2024-01-08)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/acme",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "description": "An intergration with ACME and CoCreateJS.",
5
5
  "keywords": [
6
6
  "acme",
package/src/index.js CHANGED
@@ -169,8 +169,6 @@ class CoCreateAcme {
169
169
  expires = expires.notAfter;
170
170
  this.setCertificate(host, expires, organization_id, hostKeyPath, cert, key)
171
171
 
172
- console.log(`saving host: ${host} at postion: ${hostPosition}`)
173
-
174
172
  this.crud.send({
175
173
  method: 'object.update',
176
174
  host,
@@ -196,16 +194,7 @@ class CoCreateAcme {
196
194
  const hostKeyPath = keyPath + host + '/';
197
195
  let hostPosition
198
196
 
199
- if (!organization_id) {
200
- let org = await this.crud.getHost(host)
201
- if (org.error)
202
- // console.log('Organization could not be found');
203
- return false
204
- else
205
- organization_id = org._id
206
- }
207
-
208
- let organization = await this.crud.getOrganization(organization_id, false);
197
+ let organization = await this.crud.getOrganization({ host, organization_id });
209
198
  if (organization.error)
210
199
  return false
211
200
 
@@ -248,57 +237,6 @@ class CoCreateAcme {
248
237
  expires = expires.notAfter;
249
238
  if (this.isValid(expires)) {
250
239
  this.setCertificate(host, expires, organization_id)
251
-
252
- // TODO: remove after certs are synced
253
- let key = fs.readFileSync(hostKeyPath + 'private-key.pem', 'utf8');
254
- let hostPosition, org
255
-
256
- if (!organization_id) {
257
- let org = await this.crud.getHost(host)
258
- if (org.error)
259
- // console.log('Organization could not be found');
260
- return false
261
- else
262
- organization_id = org._id
263
- }
264
-
265
- let organization = await this.crud.getOrganization(organization_id, false);
266
- if (organization.error)
267
- return false
268
-
269
- if (organization.host) {
270
- for (let i = 0; i < organization.host.length; i++) {
271
- if (organization.host[i].name === host) {
272
- hostPosition = i
273
- console.log(`Found host: ${host} at postion: ${hostPosition}`)
274
-
275
- if (organization.host[i].cert && organization.host[i].key) {
276
- let expires = await forge.readCertificateInfo(organization.host[i].cert);
277
- expires = expires.notAfter;
278
- if (this.isValid(expires)) {
279
- this.setCertificate(host, expires, organization_id, hostKeyPath, organization.host[i].cert, organization.host[i].key)
280
- return true
281
- }
282
- }
283
- break
284
- }
285
- }
286
-
287
- if (!hostPosition && hostPosition !== 0)
288
- return false
289
- }
290
-
291
- this.crud.send({
292
- method: 'object.update',
293
- host,
294
- array: 'organizations',
295
- object: {
296
- _id: organization_id,
297
- [`host[${hostPosition}]`]: { name: host, cert, key, expires },
298
- },
299
- organization_id
300
- });
301
-
302
240
  return true
303
241
  }
304
242
  }