Skip to content

Commit 3dc95a9

Browse files
Your Nameclaude
andcommitted
fix: Resolve all deno lint errors
- Remove async from functions without await - Remove unused imports - Rename unused parameters with underscore prefix - Fix no-this-alias violations Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent e2ab4af commit 3dc95a9

File tree

15 files changed

+175
-181
lines changed

15 files changed

+175
-181
lines changed

src/auth/jwt.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: PMPL-1.0-or-later
22
// JWT verification for Svalinn
33

4-
import type { TokenPayload, OIDCConfig } from "./types.ts";
4+
import type { OIDCConfig, TokenPayload } from "./types.ts";
55

66
/**
77
* JWKS key
@@ -67,7 +67,9 @@ export async function fetchJWKS(jwksUri: string): Promise<JWKS> {
6767
/**
6868
* Decode JWT without verification (for header inspection)
6969
*/
70-
export function decodeJWT(token: string): { header: Record<string, unknown>; payload: TokenPayload } {
70+
export function decodeJWT(
71+
token: string,
72+
): { header: Record<string, unknown>; payload: TokenPayload } {
7173
const parts = token.split(".");
7274
if (parts.length !== 3) {
7375
throw new Error("Invalid JWT format");
@@ -84,7 +86,7 @@ export function decodeJWT(token: string): { header: Record<string, unknown>; pay
8486
*/
8587
export async function verifyJWT(
8688
token: string,
87-
config: OIDCConfig
89+
config: OIDCConfig,
8890
): Promise<TokenPayload> {
8991
const { header, payload } = decodeJWT(token);
9092

@@ -140,7 +142,7 @@ async function importJWK(jwk: JWK, alg: string): Promise<CryptoKey> {
140142
jwk as JsonWebKey,
141143
algorithm,
142144
true,
143-
["verify"]
145+
["verify"],
144146
);
145147
}
146148

@@ -182,7 +184,7 @@ async function verifySignature(token: string, key: CryptoKey): Promise<boolean>
182184
algorithm,
183185
key,
184186
signature.buffer as ArrayBuffer,
185-
data.buffer as ArrayBuffer
187+
data.buffer as ArrayBuffer,
186188
);
187189
}
188190

src/auth/middleware.ts

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,8 @@
22
// Authentication middleware for Svalinn
33

44
import type { Context, Next } from "npm:hono@4";
5-
import type {
6-
AuthConfig,
7-
AuthResult,
8-
AuthMethod,
9-
UserContext,
10-
TokenPayload,
11-
ApiKeyInfo,
12-
} from "./types.ts";
13-
import { verifyJWT, decodeJWT } from "./jwt.ts";
5+
import type { AuthConfig, AuthMethod, AuthResult, TokenPayload, UserContext } from "./types.ts";
6+
import { decodeJWT, verifyJWT } from "./jwt.ts";
147

158
/**
169
* Extended context with user info
@@ -63,7 +56,7 @@ export function authMiddleware(config: AuthConfig) {
6356
error: "Unauthorized",
6457
message: result.error,
6558
},
66-
401
59+
401,
6760
);
6861
}
6962

@@ -91,7 +84,7 @@ export function authMiddleware(config: AuthConfig) {
9184
async function tryAuthenticate(
9285
c: Context,
9386
config: AuthConfig,
94-
method: AuthMethod
87+
method: AuthMethod,
9588
): Promise<AuthResult> {
9689
switch (method) {
9790
case "oauth2":
@@ -113,7 +106,7 @@ async function tryAuthenticate(
113106
*/
114107
async function authenticateBearerToken(
115108
c: Context,
116-
config: AuthConfig
109+
config: AuthConfig,
117110
): Promise<AuthResult> {
118111
const auth = c.req.header("Authorization");
119112
if (!auth || !auth.startsWith("Bearer ")) {
@@ -139,9 +132,7 @@ async function authenticateBearerToken(
139132
}
140133

141134
// Extract scopes
142-
const scopes = payload.scope
143-
? payload.scope.split(" ")
144-
: [];
135+
const scopes = payload.scope ? payload.scope.split(" ") : [];
145136

146137
return {
147138
authenticated: true,
@@ -164,7 +155,7 @@ async function authenticateBearerToken(
164155
*/
165156
function authenticateApiKey(
166157
c: Context,
167-
config: AuthConfig
158+
config: AuthConfig,
168159
): AuthResult {
169160
if (!config.apiKey) {
170161
return {
@@ -266,7 +257,7 @@ export function requireScopes(...requiredScopes: string[]) {
266257
}
267258

268259
const missingScopes = requiredScopes.filter(
269-
(s) => !user.scopes.includes(s) && !user.scopes.includes("svalinn:admin")
260+
(s) => !user.scopes.includes(s) && !user.scopes.includes("svalinn:admin"),
270261
);
271262

272263
if (missingScopes.length > 0) {
@@ -277,7 +268,7 @@ export function requireScopes(...requiredScopes: string[]) {
277268
required: requiredScopes,
278269
missing: missingScopes,
279270
},
280-
403
271+
403,
281272
);
282273
}
283274

@@ -305,7 +296,7 @@ export function requireGroups(...requiredGroups: string[]) {
305296
message: "Not a member of required groups",
306297
required: requiredGroups,
307298
},
308-
403
299+
403,
309300
);
310301
}
311302

src/auth/oauth2.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export interface TokenResponse {
2222
export function getAuthorizationUrl(
2323
config: OAuth2Config | OIDCConfig,
2424
state: string,
25-
nonce?: string
25+
nonce?: string,
2626
): string {
2727
const params = new URLSearchParams({
2828
response_type: "code",
@@ -45,7 +45,7 @@ export function getAuthorizationUrl(
4545
*/
4646
export async function exchangeCode(
4747
config: OAuth2Config,
48-
code: string
48+
code: string,
4949
): Promise<TokenResponse> {
5050
const params = new URLSearchParams({
5151
grant_type: "authorization_code",
@@ -76,7 +76,7 @@ export async function exchangeCode(
7676
*/
7777
export async function refreshToken(
7878
config: OAuth2Config,
79-
refreshToken: string
79+
refreshToken: string,
8080
): Promise<TokenResponse> {
8181
const params = new URLSearchParams({
8282
grant_type: "refresh_token",
@@ -106,7 +106,7 @@ export async function refreshToken(
106106
*/
107107
export async function getUserInfo(
108108
config: OIDCConfig,
109-
accessToken: string
109+
accessToken: string,
110110
): Promise<Record<string, unknown>> {
111111
const response = await fetch(config.userInfoEndpoint, {
112112
headers: {
@@ -128,7 +128,7 @@ export async function getUserInfo(
128128
export function getLogoutUrl(
129129
config: OIDCConfig,
130130
idToken: string,
131-
postLogoutRedirectUri: string
131+
postLogoutRedirectUri: string,
132132
): string | null {
133133
if (!config.endSessionEndpoint) {
134134
return null;
@@ -164,7 +164,7 @@ export function generateNonce(): string {
164164
export async function handleCallback(
165165
c: Context,
166166
config: OAuth2Config | OIDCConfig,
167-
expectedState: string
167+
expectedState: string,
168168
): Promise<TokenResponse> {
169169
const code = c.req.query("code");
170170
const state = c.req.query("state");
@@ -191,7 +191,7 @@ export async function handleCallback(
191191
*/
192192
export async function clientCredentials(
193193
config: OAuth2Config,
194-
scopes?: string[]
194+
scopes?: string[],
195195
): Promise<TokenResponse> {
196196
const params = new URLSearchParams({
197197
grant_type: "client_credentials",
@@ -226,7 +226,7 @@ export async function introspectToken(
226226
introspectionEndpoint: string,
227227
token: string,
228228
clientId: string,
229-
clientSecret: string
229+
clientSecret: string,
230230
): Promise<Record<string, unknown>> {
231231
const params = new URLSearchParams({
232232
token,
@@ -258,7 +258,7 @@ export async function revokeToken(
258258
token: string,
259259
clientId: string,
260260
clientSecret: string,
261-
tokenTypeHint?: "access_token" | "refresh_token"
261+
tokenTypeHint?: "access_token" | "refresh_token",
262262
): Promise<void> {
263263
const params = new URLSearchParams({
264264
token,

src/compose/cli.ts

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { parseArgs } from "jsr:@std/cli@^1/parse-args";
66
import { join } from "@std/path";
77
import { exists } from "@std/fs";
88
import { ComposeOrchestrator } from "./orchestrator.ts";
9-
import type { ComposeFile, ProjectState } from "./types.ts";
9+
import type { ComposeFile } from "./types.ts";
1010

1111
const VERSION = "0.1.0";
1212

@@ -96,7 +96,7 @@ async function findComposeFile(specified?: string): Promise<string> {
9696
}
9797

9898
throw new Error(
99-
"No compose file found. Create svalinn-compose.yaml or specify with -f"
99+
"No compose file found. Create svalinn-compose.yaml or specify with -f",
100100
);
101101
}
102102

@@ -109,22 +109,17 @@ function formatDuration(ms: number): string {
109109
function formatTable(
110110
headers: string[],
111111
rows: string[][],
112-
columnWidths?: number[]
112+
columnWidths?: number[],
113113
): string {
114-
const widths =
115-
columnWidths ||
116-
headers.map((h, i) =>
117-
Math.max(h.length, ...rows.map((r) => (r[i] || "").length))
118-
);
114+
const widths = columnWidths ||
115+
headers.map((h, i) => Math.max(h.length, ...rows.map((r) => (r[i] || "").length)));
119116

120117
const separator = widths.map((w) => "─".repeat(w + 2)).join("┼");
121118
const headerRow = headers
122119
.map((h, i) => ` ${h.padEnd(widths[i])} `)
123120
.join("│");
124121
const dataRows = rows
125-
.map((row) =>
126-
row.map((cell, i) => ` ${(cell || "").padEnd(widths[i])} `).join("│")
127-
)
122+
.map((row) => row.map((cell, i) => ` ${(cell || "").padEnd(widths[i])} `).join("│"))
128123
.join("\n");
129124

130125
return `${headerRow}\n─${separator}─\n${dataRows}`;
@@ -133,7 +128,7 @@ function formatTable(
133128
async function cmdUp(
134129
orchestrator: ComposeOrchestrator,
135130
composeFile: ComposeFile,
136-
args: ReturnType<typeof parseArgs>
131+
args: ReturnType<typeof parseArgs>,
137132
): Promise<void> {
138133
console.log(`\n🚀 Starting project: ${composeFile.name}\n`);
139134

@@ -168,7 +163,7 @@ async function cmdUp(
168163
async function cmdDown(
169164
orchestrator: ComposeOrchestrator,
170165
composeFile: ComposeFile,
171-
args: ReturnType<typeof parseArgs>
166+
args: ReturnType<typeof parseArgs>,
172167
): Promise<void> {
173168
console.log(`\n🛑 Stopping project: ${composeFile.name}\n`);
174169

@@ -188,7 +183,7 @@ async function cmdDown(
188183

189184
async function cmdPs(
190185
orchestrator: ComposeOrchestrator,
191-
composeFile: ComposeFile
186+
composeFile: ComposeFile,
192187
): Promise<void> {
193188
const projects = await orchestrator.ps(composeFile.name);
194189

@@ -207,19 +202,19 @@ async function cmdPs(
207202
instance.image,
208203
instance.state,
209204
instance.ports.map((p) => `${p.hostPort}:${p.containerPort}`).join(", ") ||
210-
"-",
205+
"-",
211206
]);
212207

213208
console.log(
214-
formatTable(["SERVICE", "CONTAINER ID", "IMAGE", "STATUS", "PORTS"], rows)
209+
formatTable(["SERVICE", "CONTAINER ID", "IMAGE", "STATUS", "PORTS"], rows),
215210
);
216211
}
217212
}
218213

219214
async function cmdLogs(
220215
orchestrator: ComposeOrchestrator,
221216
composeFile: ComposeFile,
222-
args: ReturnType<typeof parseArgs>
217+
args: ReturnType<typeof parseArgs>,
223218
): Promise<void> {
224219
const services = args._.slice(1).map(String);
225220

@@ -237,15 +232,15 @@ async function cmdLogs(
237232
async function cmdRestart(
238233
orchestrator: ComposeOrchestrator,
239234
composeFile: ComposeFile,
240-
args: ReturnType<typeof parseArgs>
235+
args: ReturnType<typeof parseArgs>,
241236
): Promise<void> {
242237
const services = args._.slice(1).map(String);
243238

244239
console.log(`\n🔄 Restarting services...\n`);
245240

246241
await orchestrator.restart(
247242
composeFile.name!,
248-
services.length > 0 ? services : undefined
243+
services.length > 0 ? services : undefined,
249244
);
250245

251246
console.log("✓ Services restarted");
@@ -254,7 +249,7 @@ async function cmdRestart(
254249
async function cmdScale(
255250
orchestrator: ComposeOrchestrator,
256251
composeFile: ComposeFile,
257-
args: ReturnType<typeof parseArgs>
252+
args: ReturnType<typeof parseArgs>,
258253
): Promise<void> {
259254
const scaleArgs = args._.slice(1).map(String);
260255

@@ -273,10 +268,10 @@ async function cmdScale(
273268
}
274269
}
275270

276-
async function cmdConfig(
277-
orchestrator: ComposeOrchestrator,
278-
composeFile: ComposeFile
279-
): Promise<void> {
271+
function cmdConfig(
272+
_orchestrator: ComposeOrchestrator,
273+
composeFile: ComposeFile,
274+
): void {
280275
console.log("\n✓ Compose file is valid\n");
281276
console.log(`Project: ${composeFile.name}`);
282277
console.log(`Version: ${composeFile.version}`);
@@ -382,7 +377,7 @@ async function main(): Promise<void> {
382377
break;
383378

384379
case "config":
385-
await cmdConfig(orchestrator, composeFile);
380+
cmdConfig(orchestrator, composeFile);
386381
break;
387382

388383
default:

src/compose/mod.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
export { ComposeOrchestrator } from "./orchestrator.ts";
55
export type {
66
ComposeFile,
7-
Service,
8-
ServiceInstance,
9-
ProjectState,
107
ComposeResult,
118
Network,
12-
Volume,
9+
ProjectState,
1310
Secret,
11+
Service,
12+
ServiceInstance,
1413
SvalinnExtension,
14+
Volume,
1515
} from "./types.ts";

0 commit comments

Comments
 (0)