@abtnode/certificate-manager 1.17.3-beta-20251123-232619-53258789 → 1.17.3-beta-20251125-042047-1bcefd39

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abtnode/certificate-manager",
3
- "version": "1.17.3-beta-20251123-232619-53258789",
3
+ "version": "1.17.3-beta-20251125-042047-1bcefd39",
4
4
  "description": "Manage ABT Node SSL certificates",
5
5
  "author": "polunzh <polunzh@gmail.com>",
6
6
  "homepage": "https://github.com/ArcBlock/blocklet-server#readme",
@@ -30,11 +30,11 @@
30
30
  "url": "https://github.com/ArcBlock/blocklet-server/issues"
31
31
  },
32
32
  "dependencies": {
33
- "@abtnode/cron": "1.17.3-beta-20251123-232619-53258789",
34
- "@abtnode/logger": "1.17.3-beta-20251123-232619-53258789",
35
- "@abtnode/models": "1.17.3-beta-20251123-232619-53258789",
36
- "@abtnode/queue": "1.17.3-beta-20251123-232619-53258789",
37
- "@abtnode/util": "1.17.3-beta-20251123-232619-53258789",
33
+ "@abtnode/cron": "1.17.3-beta-20251125-042047-1bcefd39",
34
+ "@abtnode/logger": "1.17.3-beta-20251125-042047-1bcefd39",
35
+ "@abtnode/models": "1.17.3-beta-20251125-042047-1bcefd39",
36
+ "@abtnode/queue": "1.17.3-beta-20251125-042047-1bcefd39",
37
+ "@abtnode/util": "1.17.3-beta-20251125-042047-1bcefd39",
38
38
  "@blocklet/error": "^0.3.3",
39
39
  "@fidm/x509": "^1.2.1",
40
40
  "@greenlock/manager": "^3.1.0",
@@ -47,5 +47,5 @@
47
47
  "joi": "17.12.2",
48
48
  "punycode": "^2.3.1"
49
49
  },
50
- "gitHead": "d37497a49c982e82ba60249ed06c1b73f340b893"
50
+ "gitHead": "aa12c79fd75c9e7e06c3f3255bb73e278eec02d4"
51
51
  }
package/sdk/manager.js CHANGED
@@ -175,6 +175,20 @@ class Manager extends EventEmitter {
175
175
  throw new Error('Can not update non-upload certificate');
176
176
  }
177
177
 
178
+ if (data.certificate && data.privateKey) {
179
+ validateCertificate(data);
180
+
181
+ const info = Certificate.fromPEM(data.certificate);
182
+ data.domain = info?.subject?.commonName || '';
183
+ if (!data.domain && Array.isArray(info.dnsNames) && info.dnsNames.length) {
184
+ [data.domain] = info.dnsNames;
185
+ }
186
+
187
+ if (data.domain !== existed.domain) {
188
+ throw new Error('Can not update certificate domain, because the domain is not the same as the original domain');
189
+ }
190
+ }
191
+
178
192
  return states.certificate.update({ id }, { $set: data });
179
193
  }
180
194
 
@@ -12,7 +12,17 @@ const addSchema = Joi.object({
12
12
 
13
13
  const updateSchema = Joi.object({
14
14
  name: nameSchema.required(),
15
+ certificate: Joi.string(),
16
+ privateKey: Joi.string(),
15
17
  public: publicSchema,
18
+ }).custom((value, helpers) => {
19
+ // certificate and privateKey must be provided together or both omitted
20
+ const hasCert = !!value.certificate;
21
+ const hasKey = !!value.privateKey;
22
+ if (hasCert !== hasKey) {
23
+ return helpers.error('any.invalid', { message: 'Certificate and privateKey must be provided together' });
24
+ }
25
+ return value;
16
26
  });
17
27
 
18
28
  const upsertByDomainSchema = Joi.object({