import * as plugins from '../../plugins.ts'; import type { AuthHandler } from '../handlers/auth.handler.ts'; import * as interfaces from '../../../ts_interfaces/index.ts'; export async function requireValidIdentity( authHandler: AuthHandler, dataArg: T, ): Promise { if (!dataArg.identity) { throw new plugins.typedrequest.TypedResponseError('No identity provided'); } const passed = await authHandler.validIdentityGuard.exec({ identity: dataArg.identity }); if (!passed) { throw new plugins.typedrequest.TypedResponseError('Valid identity required'); } } export async function requireAdminIdentity( authHandler: AuthHandler, dataArg: T, ): Promise { if (!dataArg.identity) { throw new plugins.typedrequest.TypedResponseError('No identity provided'); } const passed = await authHandler.adminIdentityGuard.exec({ identity: dataArg.identity }); if (!passed) { throw new plugins.typedrequest.TypedResponseError('Admin access required'); } }