@talentsoft-opensource/widget-display-tool
Version:
Widget Simulator
31 lines (27 loc) • 792 B
text/typescript
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<string, string> {
const jwt = getJwt(secretKey, login);
return {
Authorization: `bearer ${jwt}`
};
}
getSecurityQueryParams(
secretKey: string,
login: string,
date: Date
): Record<string, string> {
const jwt = getJwt(secretKey, login);
return {
token: jwt
};
}
}