now has working requestValidation method
This commit is contained in:
parent
4dadcf227c
commit
dfd7edd330
5
dist/smartacme.classes.acmecert.d.ts
vendored
5
dist/smartacme.classes.acmecert.d.ts
vendored
@ -39,6 +39,7 @@ export interface IAcmeCsrConstructorOptions {
|
||||
export declare class AcmeCert {
|
||||
domainName: string;
|
||||
attributes: any;
|
||||
acceptedChallenge: ISmartAcmeChallengeAccepted;
|
||||
fullchain: string;
|
||||
parentAcmeAccount: AcmeAccount;
|
||||
csr: any;
|
||||
@ -56,7 +57,7 @@ export declare class AcmeCert {
|
||||
/**
|
||||
* validates a challenge, only call after you have set the challenge at the expected location
|
||||
*/
|
||||
validate(challenge: ISmartAcmeChallengeAccepted): q.Promise<{}>;
|
||||
requestValidation(): q.Promise<{}>;
|
||||
/**
|
||||
* requests a certificate
|
||||
*/
|
||||
@ -68,5 +69,5 @@ export declare class AcmeCert {
|
||||
/**
|
||||
* accept a challenge - for private use only
|
||||
*/
|
||||
private acceptChallenge(challenge);
|
||||
private acceptChallenge(challengeArg);
|
||||
}
|
||||
|
27
dist/smartacme.classes.acmecert.js
vendored
27
dist/smartacme.classes.acmecert.js
vendored
File diff suppressed because one or more lines are too long
@ -30,7 +30,7 @@ describe('smartacme', function () {
|
||||
});
|
||||
});
|
||||
it('should create a AcmeCert', function () {
|
||||
testAcmeAccount.createAcmeCert('bleu.de').then(x => {
|
||||
testAcmeAccount.createAcmeCert('test1.bleu.de').then(x => {
|
||||
testAcmeCert = x;
|
||||
should(testAcmeAccount).be.instanceOf(smartacme.AcmeCert);
|
||||
});
|
||||
@ -43,11 +43,11 @@ describe('smartacme', function () {
|
||||
done();
|
||||
});
|
||||
});
|
||||
it.skip('should poll for validation of a challenge', function (done) {
|
||||
it('should poll for validation of a challenge', function (done) {
|
||||
this.timeout(10000);
|
||||
testSmartAcme.validate(testChallenge).then(x => {
|
||||
testAcmeCert.requestValidation().then(x => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=data:application/json;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0FBQTtJQUNOLENBQUMsQ0FBQyxDQUFBO0lBRUYsRUFBRSxDQUFDLHVDQUF1QyxFQUFFLFVBQVUsSUFBSTtRQUN0RCxJQUFJLENBQUMsT0FBTyxDQUFDLEtBQUssQ0FBQyxDQUFBO1FBQ25CLFlBQVksQ0FBQyxnQkFBZ0IsRUFBRSxDQUFDLElBQUksQ0FBQyxDQUFDLGlCQUFpQjtZQUNuRCxPQUFPLENBQUMsR0FBRyxDQUFDLGlCQUFpQixDQUFDLENBQUE7WUFDOUIsYUFBYSxHQUFHLGlCQUFpQixDQUFBO1lBQ2pDLElBQUksRUFBRSxDQUFBO1FBQ1YsQ0FBQyxDQUFDLENBQUE7SUFDTixDQUFDLENBQUMsQ0FBQTtJQUVGLEVBQUUsQ0FBQywyQ0FBMkMsRUFBRSxVQUFVLElBQUk7UUFDMUQsSUFBSSxDQUFDLE9BQU8sQ0FBQyxLQUFLLENBQUMsQ0FBQTtRQUNuQixZQUFZLENBQUMsaUJBQWlCLEVBQUUsQ0FBQyxJQUFJLENBQUMsQ0FBQztZQUNuQyxJQUFJLEVBQUUsQ0FBQTtRQUNWLENBQUMsQ0FBQyxDQUFBO0lBQ04sQ0FBQyxDQUFDLENBQUE7QUFDTixDQUFDLENBQUMsQ0FBQSJ9
|
@ -10,6 +10,7 @@ describe('smartacme', function () {
|
||||
let testAcmeAccount: smartacme.AcmeAccount
|
||||
let testAcmeCert: smartacme.AcmeCert
|
||||
let testChallenge: smartacme.ISmartAcmeChallengeAccepted
|
||||
|
||||
it('should create a valid instance', function (done) {
|
||||
this.timeout(10000)
|
||||
testSmartAcme = new smartacme.SmartAcme()
|
||||
@ -35,7 +36,7 @@ describe('smartacme', function () {
|
||||
})
|
||||
|
||||
it('should create a AcmeCert', function() {
|
||||
testAcmeAccount.createAcmeCert('bleu.de').then(x => {
|
||||
testAcmeAccount.createAcmeCert('test1.bleu.de').then(x => {
|
||||
testAcmeCert = x
|
||||
should(testAcmeAccount).be.instanceOf(smartacme.AcmeCert)
|
||||
})
|
||||
@ -50,9 +51,9 @@ describe('smartacme', function () {
|
||||
})
|
||||
})
|
||||
|
||||
it.skip('should poll for validation of a challenge', function (done) {
|
||||
it('should poll for validation of a challenge', function (done) {
|
||||
this.timeout(10000)
|
||||
testSmartAcme.validate(testChallenge).then(x => {
|
||||
testAcmeCert.requestValidation().then(x => {
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
@ -48,6 +48,7 @@ export interface IAcmeCsrConstructorOptions {
|
||||
export class AcmeCert {
|
||||
domainName: string
|
||||
attributes
|
||||
acceptedChallenge: ISmartAcmeChallengeAccepted
|
||||
fullchain: string
|
||||
parentAcmeAccount: AcmeAccount
|
||||
csr
|
||||
@ -112,7 +113,6 @@ export class AcmeCert {
|
||||
console.log(err)
|
||||
done.reject(err)
|
||||
}
|
||||
console.log(JSON.stringify(res.body))
|
||||
let dnsChallenge = res.body.challenges.filter(x => {
|
||||
return x.type === challengeTypeArg
|
||||
})[0]
|
||||
@ -128,16 +128,25 @@ export class AcmeCert {
|
||||
/**
|
||||
* validates a challenge, only call after you have set the challenge at the expected location
|
||||
*/
|
||||
validate(challenge: ISmartAcmeChallengeAccepted) {
|
||||
requestValidation() {
|
||||
let done = q.defer()
|
||||
this.parentAcmeAccount.parentSmartAcme.rawacmeClient.poll(challenge.uri, function (err, res) {
|
||||
this.parentAcmeAccount.parentSmartAcme.rawacmeClient.poll(this.acceptedChallenge.uri, (err, res) => {
|
||||
if (err) {
|
||||
console.log(err)
|
||||
done.reject(err)
|
||||
}
|
||||
console.log(res.status)
|
||||
console.log(`Validation response:`)
|
||||
console.log(JSON.stringify(res.body))
|
||||
done.resolve()
|
||||
if (res.body.status === 'pending' || 'invalid') {
|
||||
setTimeout(
|
||||
() => {
|
||||
this.requestValidation().then(x => { done.resolve(x) })
|
||||
},
|
||||
2000
|
||||
)
|
||||
} else {
|
||||
done.resolve(res.body)
|
||||
}
|
||||
})
|
||||
return done.promise
|
||||
}
|
||||
@ -166,6 +175,8 @@ export class AcmeCert {
|
||||
console.log(err)
|
||||
done.reject(err)
|
||||
}
|
||||
console.log(res.body)
|
||||
done.resolve(res.body)
|
||||
})
|
||||
return done.promise
|
||||
}
|
||||
@ -180,14 +191,14 @@ export class AcmeCert {
|
||||
/**
|
||||
* accept a challenge - for private use only
|
||||
*/
|
||||
private acceptChallenge(challenge: ISmartAcmeChallenge) {
|
||||
private acceptChallenge(challengeArg: ISmartAcmeChallenge) {
|
||||
let done = q.defer()
|
||||
|
||||
/**
|
||||
* the key is needed to accept the challenge
|
||||
*/
|
||||
let authKey: string = plugins.rawacme.keyAuthz(
|
||||
challenge.token,
|
||||
challengeArg.token,
|
||||
this.parentAcmeAccount.parentSmartAcme.keyPair.publicKey
|
||||
)
|
||||
|
||||
@ -197,7 +208,7 @@ export class AcmeCert {
|
||||
let keyHash: string = plugins.rawacme.dnsKeyAuthzHash(authKey) // needed if dns challenge is chosen
|
||||
|
||||
this.parentAcmeAccount.parentSmartAcme.rawacmeClient.post(
|
||||
challenge.uri,
|
||||
challengeArg.uri,
|
||||
{
|
||||
resource: 'challenge',
|
||||
keyAuthorization: authKey
|
||||
@ -219,6 +230,7 @@ export class AcmeCert {
|
||||
keyHash: keyHash,
|
||||
status: res.body.status
|
||||
}
|
||||
this.acceptedChallenge = returnDNSChallenge
|
||||
done.resolve(returnDNSChallenge)
|
||||
}
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user