import { Middleware } from "@swirl/api"; import { Connection } from "@swirl/salesforce"; import { Request, Response } from "express"; import { IdentityResponse } from "@swirl/salesforce/auth/auth"; /** Validates requests using a Salesforce session id and a list of allowed organizations. */ export declare class SalesforceValidator extends Middleware { private readonly options?; /** The allowed list of Salesforce organization Ids */ private validOrgIds; /** Construct with the required information */ constructor(options?: SalesforceValidatorOptions); /** Validates the session */ run(req: Request, res: Response): Promise; /** Parses the user info from the given JSON string */ private parseUserInfo; } /** The Salesforce session information */ export declare class SalesforceSession { readonly info: IdentityResponse; readonly options: SalesforceSessionOptions; /** The connection for this Salesforce session */ readonly conn: Connection; constructor(info: IdentityResponse, options: SalesforceSessionOptions); } /** Extend the Express request interface to include the Salesforce session */ declare module "express" { interface Request { sfSession?: SalesforceSession; } } /** Configuration options for the Salesforce Validator */ export interface SalesforceValidatorOptions { /** * The hostname of the login server to use when validating Salesforce sessions. * If NOT specified then production is used (login.salesforce.com). */ loginServer?: string; /** * The login server to use when validation Salesforce Sandbox sessions. * This will only be used if sandboxHeader is set and the request has that header. * If NOT specified then test.salesforce.com is used. */ sandboxLoginServer?: string; /** * The HTTP header that, if set, will cause the sandboxLoginServer to be used * instead of the loginServer. */ sandboxHeader?: string; /** * A list of Organization Ids to restrict access to. * Any session NOT belonging to one of these orgs is not valid. * If NOT specified then valid Salesforce sessions from ANY organization are valid. */ organizationIds?: string[]; /** * The HTTP header that might contain the Salesforce session Id. * If NOT specified then searching for the session Id in an HTTP header will be disabled. */ httpHeaderName?: string; /** * The URL parameter name that might contain the Salesforce session Id. * If NOT specified then searching for the session Id in an URL parameter will be disabled. */ urlParameterName?: string; /** * If set to true then unauthorized error messages describe exactly why the request was unauthorized. * DO NOT set this to true in production. */ unauthorizedDetails?: boolean; } export interface SalesforceSessionOptions { loginServer: string; accessToken: string; }