diff --git a/src/lib/services/proxy-service.ts b/src/lib/services/proxy-service.ts index 2f84d32b51..b832990319 100644 --- a/src/lib/services/proxy-service.ts +++ b/src/lib/services/proxy-service.ts @@ -15,8 +15,7 @@ import { frontendSettingsKey, } from '../types/settings/frontend-settings'; import { validateOrigins } from '../util'; -import { BadDataError } from '../error'; -import assert from 'assert'; +import { BadDataError, InvalidTokenError } from '../error'; import { minutesToMilliseconds } from 'date-fns'; type Config = Pick< @@ -159,7 +158,9 @@ export class ProxyService { } private static assertExpectedTokenType({ type }: ApiUser) { - assert(type === ApiTokenType.FRONTEND || type === ApiTokenType.ADMIN); + if (!(type === ApiTokenType.FRONTEND || type === ApiTokenType.ADMIN)) { + throw new InvalidTokenError(); + } } async setFrontendSettings(