update to new standards
This commit is contained in:
@ -71,7 +71,7 @@ export class AcmeAccount {
|
||||
companyShortArg = 'SC'
|
||||
|
||||
) {
|
||||
let done = q.defer()
|
||||
let done = q.defer<AcmeCert>()
|
||||
let acmeCert = new AcmeCert(
|
||||
{
|
||||
bit: 2064,
|
||||
|
@ -25,7 +25,9 @@ export interface ISmartAcmeChallenge {
|
||||
}
|
||||
|
||||
export interface ISmartAcmeChallengeAccepted extends ISmartAcmeChallenge {
|
||||
keyHash: string
|
||||
dnsKeyHash: string
|
||||
domainName: string
|
||||
domainNamePrefixed: string
|
||||
}
|
||||
|
||||
export interface IAcmeCsrConstructorOptions {
|
||||
@ -42,6 +44,9 @@ export interface IAcmeCsrConstructorOptions {
|
||||
subject_alt_names: string[]
|
||||
}
|
||||
|
||||
// Dnsly instance (we really just need one)
|
||||
let myDnsly = new plugins.dnsly.Dnsly('google')
|
||||
|
||||
/**
|
||||
* class AcmeCert represents a cert for domain
|
||||
*/
|
||||
@ -125,6 +130,19 @@ export class AcmeCert {
|
||||
return done.promise
|
||||
}
|
||||
|
||||
/**
|
||||
* checks if DNS records are set
|
||||
*/
|
||||
async checkDns() {
|
||||
let myRecord
|
||||
try {
|
||||
myRecord = await myDnsly.getRecord(helpers.prefixName(this.domainName), 'TXT')
|
||||
} catch (err) {
|
||||
await this.checkDns()
|
||||
}
|
||||
return myRecord[0][0]
|
||||
}
|
||||
|
||||
/**
|
||||
* validates a challenge, only call after you have set the challenge at the expected location
|
||||
*/
|
||||
@ -227,8 +245,10 @@ export class AcmeCert {
|
||||
type: res.body.type,
|
||||
token: res.body.token,
|
||||
keyAuthorization: res.body.keyAuthorization,
|
||||
keyHash: keyHash,
|
||||
status: res.body.status
|
||||
status: res.body.status,
|
||||
dnsKeyHash: keyHash,
|
||||
domainName: this.domainName,
|
||||
domainNamePrefixed: helpers.prefixName(this.domainName)
|
||||
}
|
||||
this.acceptedChallenge = returnDNSChallenge
|
||||
done.resolve(returnDNSChallenge)
|
||||
|
@ -17,6 +17,13 @@ export let createKeypair = (bit = 2048): IRsaKeypair => {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* prefix a domain name to make sure it complies with letsencrypt
|
||||
*/
|
||||
export let prefixName = (domainNameArg: string): string => {
|
||||
return '_acme-challenge.' + domainNameArg
|
||||
}
|
||||
|
||||
/**
|
||||
* gets an existing registration
|
||||
* @executes ASYNC
|
||||
|
@ -6,15 +6,15 @@ let rawacme = require('rawacme') // acme helper functions
|
||||
let nodeForge = require('node-forge')
|
||||
|
||||
// push.rocks modules here
|
||||
import * as dnsly from 'dnsly'
|
||||
import * as smartfile from 'smartfile'
|
||||
import * as smartstring from 'smartstring'
|
||||
import * as paths from './smartacme.paths'
|
||||
|
||||
export {
|
||||
dnsly,
|
||||
rsaKeygen,
|
||||
rawacme,
|
||||
nodeForge,
|
||||
smartfile,
|
||||
smartstring,
|
||||
paths
|
||||
smartstring
|
||||
}
|
||||
|
Reference in New Issue
Block a user