UNPKG

pl4y-data-library

Version:

This library contains the dtos, enums, schemas, and other data objects needed in the pl4y ecosystem.

27 lines (21 loc) 878 B
import { Request } from "express"; export function extractTokenFromHeader(request: Request): string | undefined { return request.headers.authorization?.split(" ")[1]; } export function extractTenantIdFromHeader(request: Request): string | undefined { let tenantId: string = request.headers["x-tenant-id"]?.toString(); if (!tenantId) { // try looking in the query state tenantId = request.query?.state as string; } return tenantId; } export function extractRefreshTokenFromRequest(request: Request): string | undefined { return request.cookies["Refresh"]; } export function extractAuthenticationTokenFromRequest(request: Request): string | undefined { return request.cookies["Authentication"]; } export function extractClientTokenFromHeaders(request: Request): string { return request.headers["x-client-token"]?.toString(); }