@sigiljs-community/auth-plugin
Version:
Plugin for SigilJS framework that provides authentication with JWT-like tokens
22 lines (21 loc) • 613 B
JavaScript
import { Modifier as i } from "@sigiljs/sigil";
import { InternalServerError as a } from "@sigiljs/sigil/responses";
import l from "./auth-plugin2.mjs";
class h extends i {
constructor() {
super();
}
onRequest(s) {
const e = this.sigil?.plugin(l);
if (!e) throw new a("Auth plugin not installed");
const { refreshTokenHeader: t, accessTokenHeader: n } = e.__$getAuthHeaders(), o = s.headers.get(t) || null, r = s.headers.get(n) || null;
return {
refreshToken: o,
accessToken: r,
accessTokenValid: r ? e.verifyAccessToken(r) : !1
};
}
}
export {
h as default
};