smartacme/ts/smartacme.classes.smartacme.ts

48 lines
1.2 KiB
TypeScript
Raw Normal View History

const acme = require('acme-v2').ACME.create({
RSA: require('rsa-compat').RSA,
2017-01-14 13:14:50 +00:00
// other overrides
promisify: require('util').promisify,
2017-01-14 17:36:33 +00:00
// used for constructing user-agent
os: require('os'),
process: require('process'),
2017-01-01 23:18:51 +00:00
// used for overriding the default user-agent
userAgent: 'My custom UA String',
getUserAgentString: function(deps) {
return 'My custom UA String';
},
2016-11-01 19:16:43 +00:00
// don't try to validate challenges locally
skipChallengeTest: false
});
2016-11-07 17:41:52 +00:00
import { KeyPair } from './smartacme.classes.keypair';
2016-11-01 19:16:43 +00:00
export class SmartAcme {
keyPair: KeyPair;
directoryUrls: any;
async init() {
// get directory url
this.directoryUrls = await acme.init('https://acme-staging-v02.api.letsencrypt.org/directory');
// create keyPair
this.keyPair = await KeyPair.generateFresh();
// get account
const registrationData = await acme.accounts.create({
email: 'domains@lossless.org', // valid email (server checks MX records)
accountKeypair: this.keyPair.rsaKeyPair,
agreeToTerms: async tosUrl => {
return tosUrl;
2017-04-28 16:56:55 +00:00
}
}).catch(e => {
console.log(e);
});
2017-01-01 23:18:51 +00:00
console.log(registrationData);
2017-04-28 16:56:55 +00:00
}
2016-11-01 17:27:57 +00:00
}