fix(core): update
This commit is contained in:
		
							
								
								
									
										6
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										6
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							@@ -1614,9 +1614,9 @@
 | 
			
		||||
      "integrity": "sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU="
 | 
			
		||||
    },
 | 
			
		||||
    "luxon": {
 | 
			
		||||
      "version": "1.9.0",
 | 
			
		||||
      "resolved": "https://verdaccio.lossless.one/luxon/-/luxon-1.9.0.tgz",
 | 
			
		||||
      "integrity": "sha512-N1kSwtIEhM/gIRGASXPgi1CwfQZX5VTjndYFjOsZdEEtWij2uSoRrgDGWwViZCUNY9Rwh4UVG/TLcUinHM20cA=="
 | 
			
		||||
      "version": "1.10.0",
 | 
			
		||||
      "resolved": "https://verdaccio.lossless.one/luxon/-/luxon-1.10.0.tgz",
 | 
			
		||||
      "integrity": "sha512-ry3GKh//v3isD6oJN5pFWmdh+3GiScwv9q8VgG6fZ2j1guGOol2vVVdo4GBAWCrcq5RHOqSeipqHBnOu/u024Q=="
 | 
			
		||||
    },
 | 
			
		||||
    "make-error": {
 | 
			
		||||
      "version": "1.3.5",
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@ import * as interfaces from './interfaces';
 | 
			
		||||
import { CertManager } from './smartacme.classes.certmanager';
 | 
			
		||||
 | 
			
		||||
import { Collection, svDb, unI } from '@pushrocks/smartdata';
 | 
			
		||||
import { ICert } from './interfaces';
 | 
			
		||||
 | 
			
		||||
@plugins.smartdata.Collection(() => {
 | 
			
		||||
  return CertManager.activeDB;
 | 
			
		||||
@@ -28,10 +29,12 @@ export class Cert extends plugins.smartdata.SmartDataDbDoc<Cert> implements inte
 | 
			
		||||
  @svDb()
 | 
			
		||||
  public csr: string;
 | 
			
		||||
 | 
			
		||||
  constructor(privateKeyArg: string, publicKeyArg: string, csrArg: string) {
 | 
			
		||||
  constructor(optionsArg: ICert) {
 | 
			
		||||
    super();
 | 
			
		||||
    this.privateKey = privateKeyArg;
 | 
			
		||||
    this.publicKey = publicKeyArg;
 | 
			
		||||
    this.csr = csrArg;
 | 
			
		||||
    this.created = optionsArg.created;
 | 
			
		||||
    this.domainName = optionsArg.domainName;
 | 
			
		||||
    this.privateKey = optionsArg.privateKey;
 | 
			
		||||
    this.publicKey = optionsArg.publicKey;
 | 
			
		||||
    this.csr = optionsArg.csr;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -3,6 +3,7 @@ import { Cert } from './smartacme.classes.cert';
 | 
			
		||||
import { SmartAcme } from './smartacme.classes.smartacme';
 | 
			
		||||
 | 
			
		||||
import * as interfaces from './interfaces';
 | 
			
		||||
import { ICert } from './interfaces';
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
export class CertManager {
 | 
			
		||||
@@ -61,8 +62,8 @@ export class CertManager {
 | 
			
		||||
   * @param privateKeyArg 
 | 
			
		||||
   * @param csrArg 
 | 
			
		||||
   */
 | 
			
		||||
  public async storeCertificate(privateKeyArg: string, publicKeyArg: string, csrArg: string) {
 | 
			
		||||
    const cert = new Cert(privateKeyArg, publicKeyArg, csrArg);
 | 
			
		||||
  public async storeCertificate(optionsArg: ICert) {
 | 
			
		||||
    const cert = new Cert(optionsArg);
 | 
			
		||||
    cert.save();
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -41,6 +41,9 @@ export class SmartAcme {
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * inits the instance
 | 
			
		||||
   * ```ts
 | 
			
		||||
   * await myCloudlyInstance.init() // does not support options
 | 
			
		||||
   * ```
 | 
			
		||||
   */
 | 
			
		||||
  public async init() {
 | 
			
		||||
    this.privateKey =
 | 
			
		||||
@@ -99,6 +102,8 @@ export class SmartAcme {
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public async stop() {};
 | 
			
		||||
 | 
			
		||||
  public async getCertificateForDomain(domainArg: string) {
 | 
			
		||||
    const domain = domainArg;
 | 
			
		||||
 | 
			
		||||
@@ -162,6 +167,15 @@ export class SmartAcme {
 | 
			
		||||
    console.log(`Private key:\n${key.toString()}`);
 | 
			
		||||
    console.log(`Certificate:\n${cert.toString()}`);
 | 
			
		||||
 | 
			
		||||
    this.certmanager.storeCertificate(key.toString(), cert.toString(), csr.toString());
 | 
			
		||||
    await this.certmanager.storeCertificate({
 | 
			
		||||
      domainName: domainArg,
 | 
			
		||||
      privateKey: key.toString(),
 | 
			
		||||
      publicKey: cert.toString(),
 | 
			
		||||
      csr: csr.toString(),
 | 
			
		||||
      created: Date.now()
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    const newCertificate = await this.certmanager.retrieveCertificate(domainArg);
 | 
			
		||||
    return newCertificate;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user