import { SecurityModeImplementation } from "./securityMode"; const jwt = require("jsonwebtoken"); function getJwt(secret: string, login: string) { return jwt.sign({ sub: login }, secret); } export class JwtSymmetricSecurityMode implements SecurityModeImplementation { getSecurityHeaderParams( secretKey: string, login: string, date: Date ): Record { const jwt = getJwt(secretKey, login); return { Authorization: `bearer ${jwt}` }; } getSecurityQueryParams( secretKey: string, login: string, date: Date ): Record { const jwt = getJwt(secretKey, login); return { token: jwt }; } }