lint
This commit is contained in:
parent
6f188cefb8
commit
d63d8e1aed
|
@ -1,6 +1,7 @@
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
/*global URLSearchParams,Headers*/
|
||||||
var BROWSER_SUPPORTS_ECDSA = navigator.userAgent.toLowerCase().indexOf('firefox') === -1;
|
var BROWSER_SUPPORTS_ECDSA = navigator.userAgent.toLowerCase().indexOf('firefox') === -1;
|
||||||
var $qs = function (s) { return window.document.querySelector(s); };
|
var $qs = function (s) { return window.document.querySelector(s); };
|
||||||
var $qsa = function (s) { return window.document.querySelectorAll(s); };
|
var $qsa = function (s) { return window.document.querySelectorAll(s); };
|
||||||
|
@ -9,10 +10,14 @@
|
||||||
var nonce;
|
var nonce;
|
||||||
var kid;
|
var kid;
|
||||||
var i = 1;
|
var i = 1;
|
||||||
|
var BACME = window.BACME;
|
||||||
|
var PromiseA = window.Promise;
|
||||||
|
var crypto = window.crypto;
|
||||||
|
|
||||||
var apiUrl = 'https://acme-{{env}}.api.letsencrypt.org/directory';
|
var apiUrl = 'https://acme-{{env}}.api.letsencrypt.org/directory';
|
||||||
function updateApiType() {
|
function updateApiType() {
|
||||||
console.log("type updated");
|
console.log("type updated");
|
||||||
|
/*jshint validthis: true */
|
||||||
var input = this || Array.prototype.filter.call(
|
var input = this || Array.prototype.filter.call(
|
||||||
$qsa('.js-acme-api-type'), function ($el) { return $el.checked; }
|
$qsa('.js-acme-api-type'), function ($el) { return $el.checked; }
|
||||||
)[0];
|
)[0];
|
||||||
|
@ -43,13 +48,13 @@
|
||||||
progressSteps[j].classList.remove("js-progress-step-complete");
|
progressSteps[j].classList.remove("js-progress-step-complete");
|
||||||
progressSteps[j].classList.remove("js-progress-step-started");
|
progressSteps[j].classList.remove("js-progress-step-started");
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function submitForm(ev) {
|
function submitForm(ev) {
|
||||||
var j = i;
|
var j = i;
|
||||||
i += 1;
|
i += 1;
|
||||||
|
|
||||||
steps[j].submit(ev);
|
steps[j].submit(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,6 +66,7 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
function updateChallengeType() {
|
function updateChallengeType() {
|
||||||
|
/*jshint validthis: true*/
|
||||||
var input = this || Array.prototype.filter.call(
|
var input = this || Array.prototype.filter.call(
|
||||||
$qsa('.js-acme-challenge-type'), function ($el) { return $el.checked; }
|
$qsa('.js-acme-challenge-type'), function ($el) { return $el.checked; }
|
||||||
)[0];
|
)[0];
|
||||||
|
@ -87,22 +93,11 @@
|
||||||
, headers: new Headers({ 'Content-Type': 'application/json' })
|
, headers: new Headers({ 'Content-Type': 'application/json' })
|
||||||
, body: JSON.stringify({
|
, body: JSON.stringify({
|
||||||
address: email
|
address: email
|
||||||
, list: 'greenlock@ppl.family'
|
, list: 'web@greenlock.domains'
|
||||||
, domain: domains.join(',')
|
, domain: domains.join(',')
|
||||||
})
|
})
|
||||||
}).then(function (resp) {
|
}).catch(function (err) {
|
||||||
return resp.json().then(function (data) {
|
console.error(err);
|
||||||
/*
|
|
||||||
if (data.error) {
|
|
||||||
window.alert("Couldn't save your contact. Email coolaj86@gmail.com instead.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
});
|
|
||||||
}).catch(function () {
|
|
||||||
/*
|
|
||||||
window.alert("Didn't get your contact. Bad network connection? Email coolaj86@gmail.com instead.");
|
|
||||||
*/
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,17 +150,28 @@
|
||||||
var p;
|
var p;
|
||||||
|
|
||||||
function createKeypair() {
|
function createKeypair() {
|
||||||
return BACME.accounts.generateKeypair({
|
var opts;
|
||||||
type: 'ECDSA'
|
|
||||||
, bitlength: '256'
|
if(BROWSER_SUPPORTS_ECDSA) {
|
||||||
}).then(function (jwk) {
|
opts = {
|
||||||
|
type: 'ECDSA'
|
||||||
|
, bitlength: '256'
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
opts = {
|
||||||
|
type: 'RSA'
|
||||||
|
, bitlength: '2048'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return BACME.accounts.generateKeypair(opts).then(function (jwk) {
|
||||||
localStorage.setItem('account:' + email, JSON.stringify(jwk));
|
localStorage.setItem('account:' + email, JSON.stringify(jwk));
|
||||||
return jwk;
|
return jwk;
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jwk) {
|
if (jwk) {
|
||||||
p = Promise.resolve(jwk);
|
p = PromiseA.resolve(jwk);
|
||||||
} else {
|
} else {
|
||||||
p = createKeypair();
|
p = createKeypair();
|
||||||
}
|
}
|
||||||
|
@ -196,11 +202,11 @@
|
||||||
return p.then(function (_jwk) {
|
return p.then(function (_jwk) {
|
||||||
jwk = _jwk;
|
jwk = _jwk;
|
||||||
kid = JSON.parse(localStorage.getItem('account-kid:' + email) || 'null');
|
kid = JSON.parse(localStorage.getItem('account-kid:' + email) || 'null');
|
||||||
var p2
|
var p2;
|
||||||
|
|
||||||
// TODO save account id rather than always retrieving it
|
// TODO save account id rather than always retrieving it
|
||||||
if (kid) {
|
if (kid) {
|
||||||
p2 = Promise.resolve(kid);
|
p2 = PromiseA.resolve(kid);
|
||||||
} else {
|
} else {
|
||||||
p2 = createAccount(jwk);
|
p2 = createAccount(jwk);
|
||||||
}
|
}
|
||||||
|
@ -228,7 +234,7 @@
|
||||||
'http-01': '.js-acme-verification-http-01'
|
'http-01': '.js-acme-verification-http-01'
|
||||||
, 'dns-01': '.js-acme-verification-dns-01'
|
, 'dns-01': '.js-acme-verification-dns-01'
|
||||||
, 'wildcard': '.js-acme-verification-wildcard'
|
, 'wildcard': '.js-acme-verification-wildcard'
|
||||||
}
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
var tpls = {};
|
var tpls = {};
|
||||||
|
@ -241,9 +247,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// TODO make Promise-friendly
|
// TODO make Promise-friendly
|
||||||
return Promise.all(claims.map(function (claim) {
|
return PromiseA.all(claims.map(function (claim) {
|
||||||
var hostname = claim.identifier.value;
|
var hostname = claim.identifier.value;
|
||||||
return Promise.all(claim.challenges.map(function (c) {
|
return PromiseA.all(claim.challenges.map(function (c) {
|
||||||
var keyAuth = BACME.challenges['http-01']({
|
var keyAuth = BACME.challenges['http-01']({
|
||||||
token: c.token
|
token: c.token
|
||||||
, thumbprint: thumbprint
|
, thumbprint: thumbprint
|
||||||
|
@ -374,10 +380,10 @@
|
||||||
var allsWell = true;
|
var allsWell = true;
|
||||||
|
|
||||||
function checkPolls() {
|
function checkPolls() {
|
||||||
return new Promise(function (resolve) {
|
return new PromiseA(function (resolve) {
|
||||||
setTimeout(resolve, 1000);
|
setTimeout(resolve, 1000);
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
return Promise.all(polls.map(function (poll) {
|
return PromiseA.all(polls.map(function (poll) {
|
||||||
return BACME.challenges.check({ challengePollUrl: poll.url });
|
return BACME.challenges.check({ challengePollUrl: poll.url });
|
||||||
})).then(function (polls) {
|
})).then(function (polls) {
|
||||||
console.log(polls);
|
console.log(polls);
|
||||||
|
@ -415,7 +421,7 @@
|
||||||
updateProgress(1);
|
updateProgress(1);
|
||||||
hideForms();
|
hideForms();
|
||||||
$qs('.js-acme-form-poll').hidden = false;
|
$qs('.js-acme-form-poll').hidden = false;
|
||||||
}
|
};
|
||||||
steps[4].submit = function () {
|
steps[4].submit = function () {
|
||||||
console.log('Congrats! Auto advancing...');
|
console.log('Congrats! Auto advancing...');
|
||||||
|
|
||||||
|
@ -424,7 +430,7 @@
|
||||||
var p;
|
var p;
|
||||||
|
|
||||||
function createKeypair() {
|
function createKeypair() {
|
||||||
let opts;
|
var opts;
|
||||||
|
|
||||||
if(BROWSER_SUPPORTS_ECDSA) {
|
if(BROWSER_SUPPORTS_ECDSA) {
|
||||||
opts = {
|
opts = {
|
||||||
|
@ -441,11 +447,11 @@
|
||||||
return BACME.accounts.generateKeypair(opts).then(function (serverJwk) {
|
return BACME.accounts.generateKeypair(opts).then(function (serverJwk) {
|
||||||
localStorage.setItem('server:' + key, JSON.stringify(serverJwk));
|
localStorage.setItem('server:' + key, JSON.stringify(serverJwk));
|
||||||
return serverJwk;
|
return serverJwk;
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (serverJwk) {
|
if (serverJwk) {
|
||||||
p = Promise.resolve(serverJwk);
|
p = PromiseA.resolve(serverJwk);
|
||||||
} else {
|
} else {
|
||||||
p = createKeypair();
|
p = createKeypair();
|
||||||
}
|
}
|
||||||
|
@ -468,7 +474,7 @@
|
||||||
});
|
});
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
function checkCert() {
|
function checkCert() {
|
||||||
return new Promise(function (resolve) {
|
return new PromiseA(function (resolve) {
|
||||||
setTimeout(resolve, 1000);
|
setTimeout(resolve, 1000);
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
return BACME.orders.check({ orderUrl: info.orderUrl });
|
return BACME.orders.check({ orderUrl: info.orderUrl });
|
||||||
|
@ -535,7 +541,7 @@
|
||||||
wcOpts = {
|
wcOpts = {
|
||||||
name: "ECDSA"
|
name: "ECDSA"
|
||||||
, namedCurve: "P-256"
|
, namedCurve: "P-256"
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
return crypto.subtle.importKey(
|
return crypto.subtle.importKey(
|
||||||
"jwk"
|
"jwk"
|
||||||
|
@ -559,10 +565,10 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
steps[5] = function () {
|
steps[5] = function () {
|
||||||
updateProgress(2)
|
updateProgress(2);
|
||||||
hideForms();
|
hideForms();
|
||||||
$qs('.js-acme-form-download').hidden = false;
|
$qs('.js-acme-form-download').hidden = false;
|
||||||
}
|
};
|
||||||
steps[1]();
|
steps[1]();
|
||||||
|
|
||||||
var params = new URLSearchParams(window.location.search);
|
var params = new URLSearchParams(window.location.search);
|
||||||
|
@ -570,7 +576,7 @@
|
||||||
|
|
||||||
if(params.has('acme-domains')) {
|
if(params.has('acme-domains')) {
|
||||||
console.log("acme-domains param: ", params.get('acme-domains'));
|
console.log("acme-domains param: ", params.get('acme-domains'));
|
||||||
$qs('.js-acme-domains').value = params.get('acme-domains');
|
$qs('.js-acme-domains').value = params.get('acme-domains');
|
||||||
|
|
||||||
$qsa('.js-acme-api-type').forEach(function(ele) {
|
$qsa('.js-acme-api-type').forEach(function(ele) {
|
||||||
if(ele.value === apiType) {
|
if(ele.value === apiType) {
|
||||||
|
|
Loading…
Reference in New Issue