add sites or whateva
parent
570e97ca87
commit
0750b9714e
|
@ -1,5 +1,9 @@
|
|||
import axios, { AxiosResponse } from 'axios';
|
||||
import { Route, Server } from '../../../class';
|
||||
|
||||
import { X509Certificate } from '../../../commands/x509';
|
||||
import { PGPKey, PublicKeyAlgorithm } from '../../../commands/pgp';
|
||||
|
||||
export default class Keys extends Route {
|
||||
constructor(server: Server) {
|
||||
super(server);
|
||||
|
@ -29,5 +33,95 @@ export default class Keys extends Route {
|
|||
if (!member || !memberDoc || !memberDoc?.pgp) return res.status(404).json({ code: this.constants.codes.NOT_FOUND, message: this.constants.messages.NOT_FOUND });
|
||||
return res.status(200).send(memberDoc.pgp);
|
||||
});
|
||||
|
||||
// this.router.get('/confirm/pgp/:jwt', async (req, res) => {
|
||||
// const data: { pgp: string, userID: string } = jwt.verify(req.params.jwt, this.server.client.config.internalKey);
|
||||
// })
|
||||
|
||||
this.router.get('/~/x509/:userID', async (req, res) => {
|
||||
const memberDoc = await this.server.client.db.Member.findOne({ userID: req.params.userID }).lean().exec();
|
||||
const member = this.mainGuild.members.get(req.params.userID);
|
||||
if (!member || !memberDoc || !memberDoc?.x509) return res.status(404).json({ code: this.constants.codes.NOT_FOUND, message: this.constants.messages.NOT_FOUND });
|
||||
|
||||
const x509: AxiosResponse<X509Certificate> = await axios.post('https://certapi.libraryofcode.org/parse', memberDoc.x509);
|
||||
|
||||
res.status(200).send(`
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<meta property="og:title" content="x509 Certificate Information">
|
||||
<meta property="og:type" content="website">
|
||||
<meta property="og:description" content="x509 Certificate Information for ${x509.data.subject.commonName}">
|
||||
</head>
|
||||
<body>
|
||||
<p><strong>Discord Username + Discriminator</strong> ${member.username}#${member.discriminator} (${member.id})</p>
|
||||
|
||||
<p><strong>Common Name:</strong> ${x509.data.subject.commonName}</p>
|
||||
<p><strong>Email Address:</strong> ${x509.data.emailAddresses[0]}</p>
|
||||
<p><strong>Expires on:</strong> ${x509.data.notAfter.toLocaleString('en-us')}</p>
|
||||
|
||||
<p><strong>Public Key Algorithm</strong> ${x509.data.publicKeyAlgorithm}</p>
|
||||
<p><strong>Key Bit Length</strong> ${x509.data.bitLength}</p>
|
||||
<p><strong>Signature Algorithm</strong> ${x509.data.signatureAlgorithm}</p>
|
||||
<p><strong>Serial Number</strong> ${x509.data.serialNumber}</p>
|
||||
<p><strong>Fingerprint</strong> ${x509.data.fingerprint}</p>
|
||||
|
||||
<p><strong>Issuer:</strong> ${x509.data.issuer.organization} (${x509.data.issuer.commonName})</p>
|
||||
<br><br><br>
|
||||
${memberDoc.pgp}
|
||||
`);
|
||||
});
|
||||
|
||||
this.router.get('/~/pgp/:userID', async (req, res) => {
|
||||
const memberDoc = await this.server.client.db.Member.findOne({ userID: req.params.userID }).lean().exec();
|
||||
const member = this.mainGuild.members.get(req.params.userID);
|
||||
if (!member || !memberDoc || !memberDoc?.pgp) return res.status(404).json({ code: this.constants.codes.NOT_FOUND, message: this.constants.messages.NOT_FOUND });
|
||||
|
||||
const pgp: AxiosResponse<PGPKey> = await axios.post('https://certapi.libraryofcode.org/pgp', memberDoc.pgp);
|
||||
|
||||
let algo: string;
|
||||
switch (pgp.data.publicKeyAlgorithm) {
|
||||
case PublicKeyAlgorithm.DSA:
|
||||
algo = 'DSA';
|
||||
break;
|
||||
case PublicKeyAlgorithm.ECDH:
|
||||
algo = 'ECDH';
|
||||
break;
|
||||
case PublicKeyAlgorithm.ECDSA:
|
||||
algo = 'ECDSA';
|
||||
break;
|
||||
case PublicKeyAlgorithm.ElGamal:
|
||||
algo = 'ElGamal';
|
||||
break;
|
||||
case PublicKeyAlgorithm.RSA:
|
||||
algo = 'RSA';
|
||||
break;
|
||||
default:
|
||||
algo = 'N/A';
|
||||
break;
|
||||
}
|
||||
|
||||
res.status(200).send(`
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<meta property="og:title" content="PGP Key Information">
|
||||
<meta property="og:type" content="website">
|
||||
<meta property="og:description" content="PGP Key Information for ${pgp.data.fullName}">
|
||||
</head>
|
||||
<body>
|
||||
<p><strong>Discord Username + Discriminator</strong> ${member.username}#${member.discriminator} (${member.id})</p>
|
||||
|
||||
<p><strong>Name:</strong> ${pgp.data.name}</p>
|
||||
<p><strong>Email Address:</strong> ${pgp.data.email}</p>
|
||||
<p><strong>Comment:</strong> ${pgp.data.comment}</p>
|
||||
|
||||
<p><strong>Public Key Algorithm:</strong> ${algo}</p>
|
||||
<p><strong>Key ID:</strong> ${pgp.data.keyID}</p>
|
||||
<p><strong>Fingerprint:</strong> ${pgp.data.fingerprint}</p>
|
||||
<br><br><br>
|
||||
${memberDoc.x509}
|
||||
`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ export default class Apply extends Command {
|
|||
constructor(client: Client) {
|
||||
super(client);
|
||||
this.name = 'apply';
|
||||
this.description = 'apply';
|
||||
this.description = 'Application frontend for EDS.';
|
||||
this.usage = `${this.client.config.prefix}apply [serviceName]\n${this.client.config.prefix}apply full`;
|
||||
this.permissions = 0;
|
||||
this.guildOnly = true;
|
||||
|
|
|
@ -7,7 +7,7 @@ export default class Eris extends Command {
|
|||
super(client);
|
||||
this.name = 'eris';
|
||||
this.description = 'Get information about Eris.';
|
||||
this.usage = 'eris <query>';
|
||||
this.usage = `${this.client.config.prefix}eris <query`;
|
||||
this.permissions = 0;
|
||||
this.guildOnly = false;
|
||||
this.enabled = true;
|
||||
|
|
|
@ -5,7 +5,7 @@ import { Client, Command, RichEmbed } from '../class';
|
|||
import PGP_Upload from './pgp_upload';
|
||||
import PGP_Remove from './pgp_remove';
|
||||
|
||||
enum PublicKeyAlgorithm {
|
||||
export enum PublicKeyAlgorithm {
|
||||
RSA = 1,
|
||||
ElGamal = 16,
|
||||
DSA = 17,
|
||||
|
@ -13,7 +13,7 @@ enum PublicKeyAlgorithm {
|
|||
ECDSA = 19,
|
||||
}
|
||||
|
||||
interface PGPKey {
|
||||
export interface PGPKey {
|
||||
status: true;
|
||||
fullName: string;
|
||||
name: string;
|
||||
|
|
|
@ -5,7 +5,7 @@ import { Client, Command, RichEmbed } from '../class';
|
|||
import X509_Upload from './x509_upload';
|
||||
import X509_Remove from './x509_remove';
|
||||
|
||||
interface X509Certificate {
|
||||
export interface X509Certificate {
|
||||
status: boolean,
|
||||
message?: string,
|
||||
subject: {
|
||||
|
@ -41,6 +41,8 @@ interface X509Certificate {
|
|||
extendedKeyUsageAsText: ['All/Any Usages'?, 'TLS Web Server Authentication'?, 'TLS Web Client Authentication'?, 'Code Signing'?, 'E-mail Protection (S/MIME)'?],
|
||||
san: string[],
|
||||
fingerprint: string,
|
||||
emailAddresses: string[],
|
||||
bitLength: number,
|
||||
}
|
||||
|
||||
export default class X509 extends Command {
|
||||
|
|
Loading…
Reference in New Issue