import { HTTPRequest } from './HTTPRequest.js'; import { IHttpResponse } from './IHttpResponse.js'; import { IRequestHandler } from './IRequestHandler.js'; import { Cookie } from 'tough-cookie'; import { ICookieStore } from './ICookieStore.js'; import { IAuthenticationHandler } from '../../auth/IAuthenticationHandler.js'; import { Logger } from '../../util/Logger.js'; import { IServiceNowInstance } from '../../sn/IServiceNowInstance.js'; export declare class RequestHandler implements IRequestHandler { _logger: Logger; _cookies: Cookie[]; _cookieStore: ICookieStore; _authHandler: IAuthenticationHandler; _session: any; /** Identity of the instance this handler serves. Set once, at construction. */ private _boundInstanceId; /** Identity of the instance the current `_session` was minted for. Written with the session. */ private _sessionInstanceId; /** * The Singleton's constructor should always be private to prevent direct * construction calls with the `new` operator. */ constructor(authHandler: IAuthenticationHandler); setSession(session: any, instance?: IServiceNowInstance): void; bindInstance(instance: IServiceNowInstance): void; /** * Refuses to build a request whose session belongs to a different instance. * * Placed immediately before `this._session` is read into the outgoing config, * because that is the one point every request passes through — both the * SessionManager-managed handlers and the ~21 managers that construct their own * ServiceNowRequest and never touch SessionManager at all. * * Permissive when either side is unknown. A handler built without an instance * (ATFTestExecutor does this, then immediately replaces it) or a session set by * a caller that predates the second parameter would otherwise start throwing on * a path that was never actually unsafe. */ /** * Prepares a caught value for rethrowing. * * The original error is preserved rather than wrapped: `new Error(ex)` stringified * the cause, discarded the stack, and flattened typed errors so `instanceof` failed * at every call site — which would make StaleInstanceError unidentifiable. Secrets * are stripped first, because the consumer's logger has no redaction format of its * own. */ private toThrowable; /** * Refuses the request when policy does not permit what it would do. * * No-op until an application installs a policy, so embedding this library is * unaffected. The `nex` CLI and the MCP server install a deny-by-default policy at * startup, because those are the surfaces an agent drives. * * Allowed mutations are logged at info with the deciding layer. That log is the * only thing that surfaces a missing floor rule — a mutating endpoint nobody * classified shows up as a write that was permitted for the wrong reason — and it * is what answers "why was this refused" when someone asks. */ private assertPermitted; private assertSessionMatchesBoundInstance; isValidXmlString(xmlString: any): boolean; private doRequest; post(request: HTTPRequest): Promise>; put(request: HTTPRequest): Promise>; get(request: HTTPRequest): Promise>; delete(request: HTTPRequest): Promise>; private getRequestConfig; private getQueryString; }