import type { ContinuationData, IChannelBase, IContinuationPointInfo, IContinuationPointManager, ISessionBase, UAObject, UAObjectType } from "node-opcua-address-space-base"; import type { Certificate } from "node-opcua-crypto/web"; import type { DataValue } from "node-opcua-data-value"; import type { ReferenceDescription } from "node-opcua-service-browse"; import { MessageSecurityMode } from "node-opcua-types"; import { type AnyUserIdentityToken, type IServerBase, SessionContext } from "../dist/api/index.js"; export declare class MockContinuationPointManager implements IContinuationPointManager { registerHistoryReadRaw(_maxElements: number, _dataValues: DataValue[], _cnt: ContinuationData): IContinuationPointInfo; getNextHistoryReadRaw(_numValues: number, _cnt: ContinuationData): IContinuationPointInfo; registerReferences(_maxElements: number, _values: ReferenceDescription[], _cnt: ContinuationData): IContinuationPointInfo; getNextReferences(_numValue: number, _cnt: ContinuationData): IContinuationPointInfo; dispose(): void; } export declare const mockSession: ISessionBase; export interface MockSessionContextOptions { /** * user name carried by the Session's UserIdentityToken. * `"anonymous"` produces an AnonymousIdentityToken; omitting it produces a Session * with no token at all, i.e. one that was never activated. Either way the Session * exists, which is what distinguishes this from SessionContext.defaultContext. */ userName?: string; /** * the UserIdentityToken itself, when `userName` cannot express it — an X509IdentityToken, * or a UserNameIdentityToken carrying a policyId. Takes precedence over `userName`. */ userIdentityToken?: AnyUserIdentityToken; /** * SecureChannel security mode seen by isAccessRestricted(). * * Leaving this undefined is the trap this helper exists to avoid: a node carrying * AccessRestrictions SigningRequired then fails with BadSecurityModeInsufficient, * because a hand-written mock that omits `channel` reads back securityMode === * undefined rather than "no restriction". * @default MessageSecurityMode.None */ securityMode?: MessageSecurityMode; /** @default "" */ securityPolicy?: string; /** client application-instance certificate, for the X509 / applicationUri paths */ clientCertificate?: Certificate | null; /** * pass `null` to attach no SecureChannel at all — a Session created but not yet bound * to a channel. Otherwise a channel is synthesized from securityMode / securityPolicy / * clientCertificate, or you may supply a complete one. */ channel?: IChannelBase | null; /** * the Session's continuation point manager. The default throws on use, which is what * you want unless the code under test really browses or reads history through it. */ continuationPointManager?: IContinuationPointManager; /** the server whose userManager / roleResolvers resolve this user's Roles */ server?: IServerBase; /** the object a Method is being called on */ object?: UAObject | UAObjectType; /** endpoint URL the Session was created on */ endpointUrl?: string; } /** * Build a SessionContext that simulates a remote Session on a SecureChannel. * * Writing this by hand means assembling an ISessionBase and an IChannelBase and casting * through `any`; every field omitted silently reads back as undefined, which is not the * same as a permissive default. Use this instead: * * ```ts * const context = makeMockSessionContext({ * userName: "admin", * securityMode: MessageSecurityMode.SignAndEncrypt, * server * }); * ``` * * For an in-process caller with no Session at all, use SessionContext.defaultContext — * that one is granted every permission by design. */ export declare function makeMockSessionContext(options?: MockSessionContextOptions): SessionContext;