import { CommerceRole } from "ordercloud-javascript-sdk"; import { ApiHandler } from "../Types/ApiHandler"; import { FullDecodedToken } from "../Types/ExtendedToken"; /** * @description A middleware that executes before a route handler. Same as `withOcUserAuth()` except sends error responses instead of throwing. * @param {Function} routeHandler A function to handle the request and response. * @param {string[]} rolesWithAccess Optional list of OrderCloud security roles. If there are elements in the list, a JWT without any of these roles is not permited. * @param {CommerceRole[]} typesWithAccess Optional list of OrderCloud user types (Buyer, Seller, Supplier). If there are elements in the list, a JWT without one of these user types is not permited. * @param {string[]} clientIDsWithAccess Optional list of OrderCloud API Client IDs that have permission to access. If null or empty, process.env.OC_API_CLIENTS_WITH_ACCESS must be defined as a comma-separated list of client ids. * @returns {Function} A function to handle the request and response. */ export declare function withErrorHandledOcUserAuth(routeHandler: ApiHandler, rolesWithAccess?: string[], typesWithAccess?: CommerceRole[], clientIDsWithAccess?: string[]): ApiHandler; /** * @description A middleware that executes before a route handler. Verifies the request includes an OrderCloud bearer token with correct permissions. * @param {Function} req The request object. * @param {string[]} rolesWithAccess Optional list of OrderCloud security roles. If provided, a JWT without any of these roles is not permited. * @param {CommerceRole[]} typesWithAccess Optional list of OrderCloud user types (Buyer, Seller, Supplier). If provided, a JWT without any of these roles is not permited. * @param {string[]} clientIDsWithAccess Optional list of OrderCloud API Client IDs that have permission to access. If null or empty, process.env.OC_API_CLIENTS_WITH_ACCESS must be a comma-separated list of client ids. * @returns {Function} A function to handle the request and response. */ export declare function withOcUserAuth(routeHandler: ApiHandler, rolesWithAccess?: string[], typesWithAccess?: CommerceRole[], clientIDsWithAccess?: string[]): ApiHandler; /** * @description Verifies an OrderCloud JWT is valid, unexpired, active, and has correct permissions. * @param {Function} token The raw OrderCloud JWT * @param {string[]} rolesWithAccess Optional list of OrderCloud security roles. If provided, a JWT without any of these roles is not permited. * @param {CommerceRole[]} typesWithAccess Optional list of OrderCloud user types (Buyer, Seller, Supplier). If provided, a JWT without any of these roles is not permited. * @param {string[]} clientIDsWithAccess Optional list of OrderCloud API Client IDs that have permission to access. If null or empty, process.env.OC_API_CLIENTS_WITH_ACCESS must be a comma-separated list of client ids. * @returns {boolean} Is valid JWT? */ export declare function verifyTokenAsync(token: string, rolesWithAccess?: string[], typesWithAccess?: CommerceRole[], clientIDsWithAccess?: string[]): Promise; /** * @description Get the authorization Bearer token from the request headers as a string * @param {Function} req The request object. * @returns {string | null} The JWT Bearer token */ export declare function getToken(req: any): string | null;