From 4c7f211ceec4ac5712904e75bfc682429659979f Mon Sep 17 00:00:00 2001 From: Bsian Date: Mon, 20 Jan 2020 10:53:44 +0000 Subject: [PATCH 1/3] Stop throwing errors with C3 ECC --- src/commands/securesign_createcrt.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/commands/securesign_createcrt.ts b/src/commands/securesign_createcrt.ts index 05d9937..1128cf3 100644 --- a/src/commands/securesign_createcrt.ts +++ b/src/commands/securesign_createcrt.ts @@ -24,6 +24,7 @@ export default class SecureSign_Init extends Command { if (options.s && options.s.toLowerCase() !== 'ecc' && options.s.toLowerCase() !== 'rsa') return message.channel.createMessage(`${this.client.stores.emojis.error} ***Invalid signing type, choose between \`ecc\` or \`rsa\``); if (options.c && (!Number(options.c) || Number(options.c) < 1 || Number(options.c) > 3)) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Invalid class selected, choose between Class \`1\`, \`2\` or \`3\``); if (options.m && (!Number(options.m) || (options.m !== '256' && options.m !== '384' && options.m !== '512'))) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Invalid SHA Digest selected, choose between \`256\`, \`384\` or \`512\``); + if (Number(options.c) === 3 && (!options.s || options.s === 'ecc')) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Class 3 ECC certificates are not supported, please use the \`-s rsa\` option instead***`); const msg = await message.channel.createMessage(`${this.client.stores.emojis.loading} ***Creating certificate...***`); const hash = this.client.util.getAcctHash(account.homepath); From 66d28e4e753474cc871f068a886e8e554bfe037f Mon Sep 17 00:00:00 2001 From: Bsian Date: Mon, 20 Jan 2020 19:59:43 +0000 Subject: [PATCH 2/3] Fix --- src/commands/securesign_createcrt.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/securesign_createcrt.ts b/src/commands/securesign_createcrt.ts index 1128cf3..21cc1dc 100644 --- a/src/commands/securesign_createcrt.ts +++ b/src/commands/securesign_createcrt.ts @@ -24,7 +24,7 @@ export default class SecureSign_Init extends Command { if (options.s && options.s.toLowerCase() !== 'ecc' && options.s.toLowerCase() !== 'rsa') return message.channel.createMessage(`${this.client.stores.emojis.error} ***Invalid signing type, choose between \`ecc\` or \`rsa\``); if (options.c && (!Number(options.c) || Number(options.c) < 1 || Number(options.c) > 3)) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Invalid class selected, choose between Class \`1\`, \`2\` or \`3\``); if (options.m && (!Number(options.m) || (options.m !== '256' && options.m !== '384' && options.m !== '512'))) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Invalid SHA Digest selected, choose between \`256\`, \`384\` or \`512\``); - if (Number(options.c) === 3 && (!options.s || options.s === 'ecc')) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Class 3 ECC certificates are not supported, please use the \`-s rsa\` option instead***`); + if (Number(options.c) === 3 && (!options.s || options.s.toLowerCase() === 'ecc')) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Class 3 ECC certificates are not supported, please use the \`-s rsa\` option instead***`); const msg = await message.channel.createMessage(`${this.client.stores.emojis.loading} ***Creating certificate...***`); const hash = this.client.util.getAcctHash(account.homepath); From 4549da9ba354896d1bb955a83a2e615a52aaa418 Mon Sep 17 00:00:00 2001 From: Bsian Date: Mon, 20 Jan 2020 23:01:01 +0000 Subject: [PATCH 3/3] Better error handling --- src/functions/checkSS.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/functions/checkSS.ts b/src/functions/checkSS.ts index 3a8e75e..e6ed824 100644 --- a/src/functions/checkSS.ts +++ b/src/functions/checkSS.ts @@ -23,10 +23,14 @@ export default function checkSS(client: Client) { } } catch (error) { if (!hash) return; - const { status } = error.response; - if (status === 400 || status === 401 || status === 403 || status === 404) { - await client.db.Account.updateOne({ userID }, { $set: { hash: false } }); - client.getDMChannel(userID).then((channel) => channel.createMessage('Your SecureSign password has been reset - please reinitialize your SecureSign account. Run `=securesign init` for more information')).catch(); + try { + const { status } = error.response; + if (status === 400 || status === 401 || status === 403 || status === 404) { + await client.db.Account.updateOne({ userID }, { $set: { hash: false } }); + client.getDMChannel(userID).then((channel) => channel.createMessage('Your SecureSign password has been reset - please reinitialize your SecureSign account. Run `=securesign init` for more information')).catch(); + } + } catch (e) { + throw error; } } }