Skip to content

Commit

Permalink
fix: linter warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
emrahcom committed Aug 7, 2024
1 parent 6e1ae77 commit c3dd7b7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions sip-dial-plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import { HOSTNAME, PORT, TOKEN_ALGORITHM, TOKEN_SECRET } from "./config.ts";
import { serve } from "https://deno.land/[email protected]/http/server.ts";
import { STATUS_CODE } from "https://deno.land/[email protected]/http/status.ts";
import { verify } from "https://deno.land/x/[email protected].1/mod.ts";
import { type Payload } from "https://deno.land/x/[email protected].1/mod.ts";
import { verify } from "https://deno.land/x/[email protected].2/mod.ts";
import { type Payload } from "https://deno.land/x/[email protected].2/mod.ts";

const DIAL_PLAN = "./dial-plan.json";

Expand Down Expand Up @@ -64,6 +64,8 @@ async function getCryptoKey(secret: string, hash: string): Promise<CryptoKey> {
// ----------------------------------------------------------------------------
async function verifyToken(token: string): Promise<Payload> {
let hash = "SHA-256";

// @ts-expect-error TS2367
if (TOKEN_ALGORITHM === "HS512") hash = "SHA-512";

const cryptoKey = await getCryptoKey(TOKEN_SECRET, hash);
Expand Down Expand Up @@ -96,14 +98,17 @@ async function getDialPlan(qs: URLSearchParams): Promise<Response> {
}

try {
// @ts-expect-error TS18046
if (jwt.context.user.affiliation === "owner") return readDialPlan();
} catch {
// no affiliation field in token
}

try {
if (
// @ts-expect-error TS18046
jwt.context.user.moderator === "true" ||
// @ts-expect-error TS18046
jwt.context.user.moderator === true
) {
return readDialPlan();
Expand Down

0 comments on commit c3dd7b7

Please sign in to comment.