Skip to content

Commit

Permalink
style: remove no-await-in-loop restriction
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Nov 7, 2023
1 parent a8e8006 commit 8230b2c
Show file tree
Hide file tree
Showing 13 changed files with 18 additions and 27 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"rules": {
"no-empty": ["error", { "allowEmptyCatch": true }],
"no-underscore-dangle": ["error", { "allow": ["_claim_names", "_claim_sources", "_matchedRouteName", "__dirname"] }],
"no-await-in-loop": ["off"],
"import/order": ["error", { "groups": ["builtin", "external", "internal", "parent", "sibling", "index"], "newlines-between": "always" }],
"symbol-description": ["off"],
"import/extensions": ["error", "ignorePackages"],
Expand Down
1 change: 0 additions & 1 deletion certification/runner/api.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-await-in-loop */
import { strict as assert } from 'node:assert';
import { createWriteStream, writeFileSync } from 'node:fs';
import * as stream from 'node:stream';
Expand Down
2 changes: 1 addition & 1 deletion certification/runner/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-env mocha */
/* eslint-disable no-bitwise, func-names, no-console, no-await-in-loop, no-multi-assign */
/* eslint-disable no-bitwise, func-names, no-console, no-multi-assign */

import { strict as assert } from 'node:assert';
import * as fs from 'node:fs';
Expand Down
2 changes: 0 additions & 2 deletions lib/actions/authorization/interactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import * as errors from '../../helpers/errors.js';
import instance from '../../helpers/weak_cache.js';
import nanoid from '../../helpers/nanoid.js';

/* eslint-disable no-await-in-loop */

export default async function interactions(resumeRouteName, ctx, next) {
const { oidc } = ctx;
let failedCheck;
Expand Down
2 changes: 1 addition & 1 deletion lib/actions/end_session.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export const confirm = [

for (const clientId of clientIds) {
if (params.logout || clientId === state.clientId) {
const client = await ctx.oidc.provider.Client.find(clientId); // eslint-disable-line no-await-in-loop
const client = await ctx.oidc.provider.Client.find(clientId);
if (client) {
const sid = session.sidFor(client.clientId);
if (client.backchannelLogoutUri) {
Expand Down
4 changes: 2 additions & 2 deletions lib/actions/registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export const post = [
const { policies } = ctx.oidc.entities.InitialAccessToken;
const implementations = instance(provider).configuration('features.registration.policies');
for (const policy of policies) {
await implementations[policy](ctx, properties); // eslint-disable-line no-await-in-loop
await implementations[policy](ctx, properties);
}

if (rat && !('policies' in rat)) {
Expand Down Expand Up @@ -233,7 +233,7 @@ export const put = [
const { policies } = ctx.oidc.entities.RegistrationAccessToken;
const implementations = instance(provider).configuration('features.registration.policies');
for (const policy of policies) {
await implementations[policy](ctx, properties); // eslint-disable-line no-await-in-loop
await implementations[policy](ctx, properties);
}
}

Expand Down
3 changes: 0 additions & 3 deletions lib/helpers/jwt.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,8 @@ export async function verify(jwt, keystore, options = {}) {
} else {
for (const key of keys) {
try {
// eslint-disable-next-line no-await-in-loop
verified = await compactVerify(
jwt,
// eslint-disable-next-line no-await-in-loop
await keystore.getKeyObject(key, protectedHeader.alg),
{ algorithms: options.algorithm ? [options.algorithm] : undefined },
);
Expand Down Expand Up @@ -196,7 +194,6 @@ export async function decrypt(jwe, keystore) {
} else {
for (const key of keys) {
try {
// eslint-disable-next-line no-await-in-loop
decrypted = await compactDecrypt(jwe, await keystore.getKeyObject(key, protectedHeader.alg === 'dir' ? protectedHeader.enc : protectedHeader.alg));
} catch {}
}
Expand Down
1 change: 0 additions & 1 deletion lib/shared/check_resource.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable no-underscore-dangle */
/* eslint-disable no-await-in-loop */
import instance from '../helpers/weak_cache.js';
import { InvalidTarget } from '../helpers/errors.js';

Expand Down
2 changes: 1 addition & 1 deletion test/base_token/base_token.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('BaseToken', () => {

it('handles invalid inputs', async function () {
for (const input of [true, Boolean, 1, Infinity, {}, [], new Set()]) {
const result = await this.provider.RefreshToken.find(input); // eslint-disable-line no-await-in-loop
const result = await this.provider.RefreshToken.find(input);
expect(result).to.be.undefined;
}
});
Expand Down
1 change: 0 additions & 1 deletion test/ci.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-await-in-loop */
import { spawn } from 'node:child_process';

function pass({ mountTo, mountVia } = {}) {
Expand Down
2 changes: 0 additions & 2 deletions test/ciba/ciba.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ describe('features.ciba', () => {
const result = new AccessDenied();

for (const request of [{}, [], 0, 1, true, false, new Set(), new Error()]) {
// eslint-disable-next-line no-await-in-loop
await assert.rejects(this.provider.backchannelResult(request, result), { name: 'TypeError', message: 'invalid "request" argument' });
}
});
Expand All @@ -67,7 +66,6 @@ describe('features.ciba', () => {
const request = new this.provider.BackchannelAuthenticationRequest({ clientId: 'client' });

for (const result of [{}, [], 0, 1, true, false, new Set(), new Error()]) {
// eslint-disable-next-line no-await-in-loop
await assert.rejects(this.provider.backchannelResult(request, result), { name: 'TypeError', message: 'invalid "result" argument' });
}
});
Expand Down
22 changes: 11 additions & 11 deletions test/dpop/dpop.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ describe('features.dPoP', () => {
this.provider.on('userinfo.error', spy);

for (const value of ['JWT', 'secevent+jwt']) {
await this.agent.get('/me') // eslint-disable-line no-await-in-loop
.set('DPoP', await new SignJWT({}) // eslint-disable-line no-await-in-loop
await this.agent.get('/me')
.set('DPoP', await new SignJWT({})
.setProtectedHeader({
alg: 'ES256',
jwk: this.jwk,
Expand All @@ -140,7 +140,7 @@ describe('features.dPoP', () => {
const spy = sinon.spy();
this.provider.on('userinfo.error', spy);
for (const value of [1, true, 'none', 'HS256', 'unsupported']) {
await this.agent.get('/me') // eslint-disable-line no-await-in-loop
await this.agent.get('/me')
.set('DPoP', `${base64url.encode(JSON.stringify({ jwk: this.jwk, typ: 'dpop+jwt', alg: value }))}.e30.`)
.set('Authorization', `DPoP ${this.access_token}`)
.expect(401)
Expand All @@ -159,8 +159,8 @@ describe('features.dPoP', () => {
const spy = sinon.spy();
this.provider.on('userinfo.error', spy);
for (const value of [undefined, '', 1, true, null, 'foo', []]) {
await this.agent.get('/me') // eslint-disable-line no-await-in-loop
.set('DPoP', await new SignJWT({}) // eslint-disable-line no-await-in-loop
await this.agent.get('/me')
.set('DPoP', await new SignJWT({})
.setProtectedHeader({
alg: 'ES256',
jwk: value,
Expand Down Expand Up @@ -206,7 +206,7 @@ describe('features.dPoP', () => {
it('no symmetric key in header', async function () {
const spy = sinon.spy();
this.provider.on('userinfo.error', spy);
await this.agent.get('/me') // eslint-disable-line no-await-in-loop
await this.agent.get('/me')
.set('DPoP', await new SignJWT({})
.setProtectedHeader({
alg: 'ES256',
Expand All @@ -227,7 +227,7 @@ describe('features.dPoP', () => {
});

it('missing jti', async function () {
await this.agent.get('/me') // eslint-disable-line no-await-in-loop
await this.agent.get('/me')
.set('DPoP', await new SignJWT({ htm: 'POST', htu: `${this.provider.issuer}${this.suitePath('/me')}` })
.setProtectedHeader({ alg: 'ES256', typ: 'dpop+jwt', jwk: this.jwk })
.setIssuedAt()
Expand All @@ -241,7 +241,7 @@ describe('features.dPoP', () => {
});

it('htm mismatch', async function () {
await this.agent.get('/me') // eslint-disable-line no-await-in-loop
await this.agent.get('/me')
.set('DPoP', await new SignJWT({ htm: 'POST', htu: `${this.provider.issuer}${this.suitePath('/me')}`, ath: this.ath })
.setProtectedHeader({ alg: 'ES256', typ: 'dpop+jwt', jwk: this.jwk })
.setIssuedAt()
Expand All @@ -256,7 +256,7 @@ describe('features.dPoP', () => {
});

it('htu mismatch', async function () {
await this.agent.get('/me') // eslint-disable-line no-await-in-loop
await this.agent.get('/me')
.set('DPoP', await new SignJWT({ htm: 'GET', htu: `${this.provider.issuer}${this.suitePath('/token')}`, ath: this.ath })
.setProtectedHeader({ alg: 'ES256', typ: 'dpop+jwt', jwk: this.jwk })
.setIssuedAt()
Expand All @@ -271,7 +271,7 @@ describe('features.dPoP', () => {
});

it('iat too old', async function () {
await this.agent.get('/me') // eslint-disable-line no-await-in-loop
await this.agent.get('/me')
.set('DPoP', await new SignJWT({ htm: 'GET', htu: `${this.provider.issuer}${this.suitePath('/me')}`, ath: this.ath })
.setProtectedHeader({ alg: 'ES256', typ: 'dpop+jwt', jwk: this.jwk })
.setIssuedAt(epochTime() - 301)
Expand All @@ -286,7 +286,7 @@ describe('features.dPoP', () => {
});

it('iat too in the future', async function () {
await this.agent.get('/me') // eslint-disable-line no-await-in-loop
await this.agent.get('/me')
.set('DPoP', await new SignJWT({ htm: 'GET', htu: `${this.provider.issuer}${this.suitePath('/me')}`, ath: this.ath })
.setProtectedHeader({ alg: 'ES256', typ: 'dpop+jwt', jwk: this.jwk })
.setIssuedAt(epochTime() + 301)
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export default function testHelper(importMetaUrl, {
for (const [key, value] of Object.entries(resources)) {
grant.addResourceScope(key, value);
}
// eslint-disable-next-line no-await-in-loop

const grantId = await grant.save();
session.authorizations[cl.client_id] = {
sid: nanoid(),
Expand Down

0 comments on commit 8230b2c

Please sign in to comment.