@swishapp/node
Version:
JS library to integrate Swish on a Node.js server.
34 lines (33 loc) • 1.69 kB
TypeScript
import { CreateProfileTokenResponse } from "@swishapp/api-client";
import type { ProxyOptions } from "./types";
export declare const createAppProxy: (options: ProxyOptions) => AppProxy;
export declare class AppProxy {
private readonly storage;
private readonly apiProxyPath;
private readonly assetProxyPath;
private readonly apiHost;
private readonly authenticate;
private readonly onError?;
private readonly authToken;
constructor({ authToken, storage, basePath, apiHost, authenticate, onError, }: ProxyOptions);
forward(request: Request): Promise<Response>;
forwardAssetRequest(request: Request): Promise<Response>;
getFileContent(assetPath: string): Promise<Response>;
loadAsset(assetsHost: string, assetPath: string): Promise<string>;
forwardApiRequest(request: Request, loggedInCustomerId: string | null): Promise<Response>;
createForwardingHeaders(request: Request, options?: {
authToken?: string;
}): Headers;
createForwardingUrl(request: Request): URL;
getContentType(assetPath: string): "application/javascript" | "application/json" | "text/plain";
getToken(request: Request, customerId: string | null): Promise<string>;
getCachedToken(sessionId?: string | null, customerId?: string | null): Promise<string | null>;
createToken(request: Request, input?: {
sessionId?: string | null;
customerId?: string | null;
}): Promise<NonNullable<CreateProfileTokenResponse["data"]>>;
extractHeaderSid(request: Request): string | null;
parseToken(token: string): any;
createGid(type: "session" | "customer", id: string): string;
isTokenExpired(tokenData: any): boolean;
}