chore: fix lint

This commit is contained in:
syuilo
2022-04-03 15:33:22 +09:00
parent b8360313e8
commit 41c2aed7dc
17 changed files with 43 additions and 44 deletions

View File

@ -121,14 +121,14 @@ export function verifyLogin({
signature: Buffer,
challenge: string
}) {
if (clientData.type != 'webauthn.get') {
if (clientData.type !== 'webauthn.get') {
throw new Error('type is not webauthn.get');
}
if (hash(clientData.challenge).toString('hex') != challenge) {
if (hash(clientData.challenge).toString('hex') !== challenge) {
throw new Error('challenge mismatch');
}
if (clientData.origin != config.scheme + '://' + config.host) {
if (clientData.origin !== config.scheme + '://' + config.host) {
throw new Error('origin mismatch');
}
@ -148,11 +148,11 @@ export const procedures = {
verify({ publicKey }: {publicKey: Map<number, Buffer>}) {
const negTwo = publicKey.get(-2);
if (!negTwo || negTwo.length != 32) {
if (!negTwo || negTwo.length !== 32) {
throw new Error('invalid or no -2 key given');
}
const negThree = publicKey.get(-3);
if (!negThree || negThree.length != 32) {
if (!negThree || negThree.length !== 32) {
throw new Error('invalid or no -3 key given');
}
@ -183,7 +183,7 @@ export const procedures = {
rpIdHash: Buffer,
credentialId: Buffer,
}) {
if (attStmt.alg != -7) {
if (attStmt.alg !== -7) {
throw new Error('alg mismatch');
}
@ -196,11 +196,11 @@ export const procedures = {
const negTwo = publicKey.get(-2);
if (!negTwo || negTwo.length != 32) {
if (!negTwo || negTwo.length !== 32) {
throw new Error('invalid or no -2 key given');
}
const negThree = publicKey.get(-3);
if (!negThree || negThree.length != 32) {
if (!negThree || negThree.length !== 32) {
throw new Error('invalid or no -3 key given');
}
@ -263,7 +263,7 @@ export const procedures = {
.map((key: any) => PEMString(key))
.concat([GSR2]);
if (getCertSubject(certificateChain[0]).CN != 'attest.android.com') {
if (getCertSubject(certificateChain[0]).CN !== 'attest.android.com') {
throw new Error('invalid common name');
}
@ -283,11 +283,11 @@ export const procedures = {
const negTwo = publicKey.get(-2);
if (!negTwo || negTwo.length != 32) {
if (!negTwo || negTwo.length !== 32) {
throw new Error('invalid or no -2 key given');
}
const negThree = publicKey.get(-3);
if (!negThree || negThree.length != 32) {
if (!negThree || negThree.length !== 32) {
throw new Error('invalid or no -3 key given');
}
@ -332,11 +332,11 @@ export const procedures = {
const negTwo = publicKey.get(-2);
if (!negTwo || negTwo.length != 32) {
if (!negTwo || negTwo.length !== 32) {
throw new Error('invalid or no -2 key given');
}
const negThree = publicKey.get(-3);
if (!negThree || negThree.length != 32) {
if (!negThree || negThree.length !== 32) {
throw new Error('invalid or no -3 key given');
}
@ -353,7 +353,7 @@ export const procedures = {
// https://fidoalliance.org/specs/fido-v2.0-id-20180227/fido-ecdaa-algorithm-v2.0-id-20180227.html#ecdaa-verify-operation
throw new Error('ECDAA-Verify is not supported');
} else {
if (attStmt.alg != -7) throw new Error('alg mismatch');
if (attStmt.alg !== -7) throw new Error('alg mismatch');
throw new Error('self attestation is not supported');
}
@ -377,7 +377,7 @@ export const procedures = {
credentialId: Buffer
}) {
const x5c: Buffer[] = attStmt.x5c;
if (x5c.length != 1) {
if (x5c.length !== 1) {
throw new Error('x5c length does not match expectation');
}
@ -387,11 +387,11 @@ export const procedures = {
const negTwo: Buffer = publicKey.get(-2);
if (!negTwo || negTwo.length != 32) {
if (!negTwo || negTwo.length !== 32) {
throw new Error('invalid or no -2 key given');
}
const negThree: Buffer = publicKey.get(-3);
if (!negThree || negThree.length != 32) {
if (!negThree || negThree.length !== 32) {
throw new Error('invalid or no -3 key given');
}

View File

@ -48,7 +48,6 @@ export const paramDef = {
} as const;
// eslint-disable-next-line import/no-default-export
// @ts-ignore
export default define(meta, paramDef, async (ps, user, _, file, cleanup) => {
// Get 'name' parameter
let name = ps.name || file.originalname;

View File

@ -50,10 +50,10 @@ export default define(meta, paramDef, async (ps, user) => {
const clientData = JSON.parse(ps.clientDataJSON);
if (clientData.type != 'webauthn.create') {
if (clientData.type !== 'webauthn.create') {
throw new Error('not a creation attestation');
}
if (clientData.origin != config.scheme + '://' + config.host) {
if (clientData.origin !== config.scheme + '://' + config.host) {
throw new Error('origin mismatch');
}
@ -78,7 +78,7 @@ export default define(meta, paramDef, async (ps, user) => {
const credentialId = authData.slice(55, 55 + credentialIdLength);
const publicKeyData = authData.slice(55 + credentialIdLength);
const publicKey: Map<number, any> = await cborDecodeFirst(publicKeyData);
if (publicKey.get(3) != -7) {
if (publicKey.get(3) !== -7) {
throw new Error('alg mismatch');
}

View File

@ -27,7 +27,7 @@ export default define(meta, paramDef, async (ps, user) => {
take: ps.limit,
skip: ps.offset,
order: {
id: ps.sort == 'asc' ? 1 : -1,
id: ps.sort === 'asc' ? 1 : -1,
},
});

View File

@ -52,19 +52,19 @@ export default define(meta, paramDef, async (ps) => {
query.andWhere('note.userHost IS NULL');
}
if (ps.reply != undefined) {
if (ps.reply !== undefined) {
query.andWhere(ps.reply ? 'note.replyId IS NOT NULL' : 'note.replyId IS NULL');
}
if (ps.renote != undefined) {
if (ps.renote !== undefined) {
query.andWhere(ps.renote ? 'note.renoteId IS NOT NULL' : 'note.renoteId IS NULL');
}
if (ps.withFiles != undefined) {
if (ps.withFiles !== undefined) {
query.andWhere(ps.withFiles ? `note.fileIds != '{}'` : `note.fileIds = '{}'`);
}
if (ps.poll != undefined) {
if (ps.poll !== undefined) {
query.andWhere(ps.poll ? 'note.hasPoll = TRUE' : 'note.hasPoll = FALSE');
}

View File

@ -57,7 +57,7 @@ export default define(meta, paramDef, async (ps, user) => {
conversation.push(p);
}
if (conversation.length == ps.limit) {
if (conversation.length === ps.limit) {
return;
}

View File

@ -110,7 +110,7 @@ export default define(meta, paramDef, async (ps, user) => {
if (exist.length) {
if (poll.multiple) {
if (exist.some(x => x.choice == ps.choice)) {
if (exist.some(x => x.choice === ps.choice)) {
throw new ApiError(meta.errors.alreadyVoted);
}
} else {

View File

@ -24,17 +24,17 @@ export default async (ctx: Koa.Context) => {
ctx.body = { error };
}
if (typeof username != 'string') {
if (typeof username !== 'string') {
ctx.status = 400;
return;
}
if (typeof password != 'string') {
if (typeof password !== 'string') {
ctx.status = 400;
return;
}
if (token != null && typeof token != 'string') {
if (token != null && typeof token !== 'string') {
ctx.status = 400;
return;
}