forked from Mirrors/keyoxide-web
first stab at it from keyoxide-web end
This commit is contained in:
parent
5e0561df7e
commit
ecc789a4a9
6 changed files with 21 additions and 15 deletions
|
@ -192,7 +192,8 @@ const doVerification = async (data) => {
|
|||
const verificationOptions = {
|
||||
proxy: {
|
||||
hostname: process.env.PROXY_HOSTNAME,
|
||||
policy: (process.env.PROXY_HOSTNAME !== '') ? 'adaptive' : 'never'
|
||||
policy: (process.env.PROXY_HOSTNAME !== '') ? 'adaptive' : 'never',
|
||||
scheme: (process.env.PROXY_SCHEME !== '') ? process.env.PROXY_SCHEME : (process.env.SCHEME !== '') ? process.env.SCHEME : 'https'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -195,7 +195,8 @@ const doVerification = async (data) => {
|
|||
const verificationOptions = {
|
||||
proxy: {
|
||||
hostname: process.env.PROXY_HOSTNAME,
|
||||
policy: (process.env.PROXY_HOSTNAME !== '') ? 'adaptive' : 'never'
|
||||
policy: (process.env.PROXY_HOSTNAME !== '') ? 'adaptive' : 'never',
|
||||
scheme: (process.env.PROXY_SCHEME !== '') ? process.env.PROXY_SCHEME : (process.env.SCHEME !== '') ? process.env.SCHEME : 'https'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ app.set('env', process.env.NODE_ENV || 'production')
|
|||
app.engine('pug', pug.__express).set('view engine', 'pug')
|
||||
app.set('port', process.env.PORT || 3000)
|
||||
app.set('domain', process.env.DOMAIN)
|
||||
app.set('scheme', process.env.SCHEME || 'https')
|
||||
app.set('keyoxide_version', packageData.version)
|
||||
app.set('onion_url', process.env.ONION_URL)
|
||||
|
||||
|
@ -65,7 +66,8 @@ if (app.get('onion_url')) {
|
|||
}
|
||||
|
||||
app.use(stringReplace({
|
||||
PLACEHOLDER__PROXY_HOSTNAME: process.env.PROXY_HOSTNAME || process.env.DOMAIN || 'null'
|
||||
PLACEHOLDER__PROXY_HOSTNAME: process.env.PROXY_HOSTNAME || process.env.DOMAIN || 'null',
|
||||
PLACEHOLDER__PROXY_SCHEME: process.env.PROXY_SCHEME || process.env.SCHEME || 'https'
|
||||
}, {
|
||||
contentTypeFilterRegexp: /application\/javascript/
|
||||
}))
|
||||
|
|
|
@ -46,7 +46,7 @@ const generateWKDProfile = async (id) => {
|
|||
keyData = processKeyData(keyData)
|
||||
|
||||
const keyoxideData = {}
|
||||
keyoxideData.url = `https://${process.env.DOMAIN}/wkd/${id}`
|
||||
keyoxideData.url = `${process.env.SCHEME}://${process.env.DOMAIN}/wkd/${id}`
|
||||
|
||||
logger.debug('Generating a WKD profile',
|
||||
{ component: 'wkd_profile_generator', action: 'done', profile_id: id })
|
||||
|
@ -88,9 +88,9 @@ const generateHKPProfile = async (id, keyserverDomain) => {
|
|||
|
||||
const keyoxideData = {}
|
||||
if (!keyserverDomain || keyserverDomain === 'keys.openpgp.org') {
|
||||
keyoxideData.url = `https://${process.env.DOMAIN}/hkp/${id}`
|
||||
keyoxideData.url = `${process.env.SCHEME}://${process.env.DOMAIN}/hkp/${id}`
|
||||
} else {
|
||||
keyoxideData.url = `https://${process.env.DOMAIN}/hkp/${keyserverDomain}/${id}`
|
||||
keyoxideData.url = `${process.env.SCHEME}://${process.env.DOMAIN}/hkp/${keyserverDomain}/${id}`
|
||||
}
|
||||
|
||||
logger.debug('Generating a HKP profile',
|
||||
|
@ -196,7 +196,7 @@ const generateKeybaseProfile = async (username, fingerprint) => {
|
|||
keyData = processKeyData(keyData)
|
||||
|
||||
const keyoxideData = {}
|
||||
keyoxideData.url = `https://${process.env.DOMAIN}/keybase/${username}/${fingerprint}`
|
||||
keyoxideData.url = `${process.env.SCHEME}://${process.env.DOMAIN}/keybase/${username}/${fingerprint}`
|
||||
|
||||
logger.debug('Generating a Keybase profile',
|
||||
{ component: 'keybase_profile_generator', action: 'done', username, fingerprint })
|
||||
|
|
|
@ -49,7 +49,8 @@ export class Claim extends HTMLElement {
|
|||
await claim.verify({
|
||||
proxy: {
|
||||
policy: 'adaptive',
|
||||
hostname: 'PLACEHOLDER__PROXY_HOSTNAME'
|
||||
hostname: 'PLACEHOLDER__PROXY_HOSTNAME',
|
||||
scheme: 'PLACEHOLDER__PROXY_SCHEME'
|
||||
}
|
||||
});
|
||||
this.setAttribute('data-claim', JSON.stringify(claim));
|
||||
|
@ -192,7 +193,7 @@ export class Claim extends HTMLElement {
|
|||
const subsection_info_text = subsection_info.appendChild(document.createElement('div'));
|
||||
|
||||
const result_proxyUsed = subsection_info_text.appendChild(document.createElement('p'));
|
||||
result_proxyUsed.innerHTML = `A proxy was used to fetch the proof: <a href="https://PLACEHOLDER__PROXY_HOSTNAME" aria-label="Link to proxy server">PLACEHOLDER__PROXY_HOSTNAME</a>`;
|
||||
result_proxyUsed.innerHTML = `A proxy was used to fetch the proof: <a href="PLACEHOLDER__PROXY_SCHEME://PLACEHOLDER__PROXY_HOSTNAME" aria-label="Link to proxy server">PLACEHOLDER__PROXY_HOSTNAME</a>`;
|
||||
}
|
||||
|
||||
// TODO Display errors
|
||||
|
@ -217,4 +218,4 @@ export class Claim extends HTMLElement {
|
|||
// });
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,19 +46,20 @@ export async function computeWKDLocalPart(localPart) {
|
|||
// Generate Keyoxide profile URL
|
||||
export async function generateProfileURL(data) {
|
||||
let hostname = data.hostname || window.location.hostname;
|
||||
let scheme = data.scheme || window.location.protocol.slice(0,-1);
|
||||
|
||||
if (data.input == "") {
|
||||
return "Waiting for input…";
|
||||
}
|
||||
switch (data.source) {
|
||||
case "wkd":
|
||||
return `https://${hostname}/${data.input}`;
|
||||
return `${scheme}://${hostname}/${data.input}`;
|
||||
break;
|
||||
case "hkp":
|
||||
if (/.*@.*\..*/.test(data.input)) {
|
||||
return `https://${hostname}/hkp/${data.input}`;
|
||||
return `${scheme}://${hostname}/hkp/${data.input}`;
|
||||
} else {
|
||||
return `https://${hostname}/${data.input}`;
|
||||
return `${scheme}://${hostname}/${data.input}`;
|
||||
}
|
||||
break;
|
||||
case "keybase":
|
||||
|
@ -67,7 +68,7 @@ export async function generateProfileURL(data) {
|
|||
return "Incorrect Keybase public key URL.";
|
||||
}
|
||||
const match = data.input.match(re);
|
||||
return `https://${hostname}/keybase/${match[1]}/${match[2]}`;
|
||||
return `${scheme}://${hostname}/keybase/${match[1]}/${match[2]}`;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -240,4 +241,4 @@ export async function verifyBcryptHash(input, hash) {
|
|||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue