import * as session_service from '../service-session'; import { ClientSubscription } from './ClientSubscription'; import 'setimmediate'; /** * import all the generated classes (they have side effects --> do not tree shake them away) */ import '../generated'; import * as endpoints_service from '../service-endpoints'; import { SignatureData } from '../service-secure-channel'; import { ClientSession } from './client_session'; import { OPCUAClientBase, ErrorCallback, ResponseCallback } from './client_base'; import { UserIdentityToken } from '../generated/UserIdentityToken'; import { ICreateSubscriptionRequest, IX509IdentityToken } from '../generated'; import { ClientSecureChannelLayer } from '../secure-channel/client_secure_channel_layer'; import { OPCUAClientOptions } from '../common/client_options'; export interface UserIdentityInfoUserName { userName: string; password: string; } export interface UserIdentityInfoIssued { tokenData: Uint8Array; } export interface UserIdentityInfoX509 extends IX509IdentityToken { } export interface UserIdentityInfoAnonymous { } export type UserIdentityInfo = Partial; export interface SessionActivationOptions { /** * the user identity to activate the session with. * * When omitted (`undefined`) the identity the session was last activated * with is replayed, which is what a re-activation on a new SecureChannel has * to do: a Server refuses to change the UserTokenType of an existing * session. Pass `null` to explicitly go (back) to an anonymous identity. */ userIdentityInfo?: UserIdentityInfo | null; localeIds?: string[]; } /** * @class OPCUAClient * @extends OPCUAClientBase * @param options * @param [options.securityMode=MessageSecurityMode.None] {MessageSecurityMode} the default security mode. * @param [options.securityPolicy =SecurityPolicy.NONE] {SecurityPolicy} the security mode. * @param [options.requestedSessionTimeout= 60000] {Number} the requested session time out in CreateSession * @param [options.applicationName="NodeOPCUA-Client"] {string} the client application name * @param [options.endpoint_must_exist=true] {Boolean} set to false if the client should accept server endpoint mismatch * @param [options.keepSessionAlive=false]{Boolean} * @param [options.clientName=""] {String} a client name string that will be used to generate session names. * @constructor */ export declare class OPCUAClient extends OPCUAClientBase { protected _clientNonce: any; protected _serverUri?: string; private ___sessionName_counter; requestedSessionTimeout: any; endpoint_must_exist: boolean; get clientNonce(): any; constructor(options: OPCUAClientOptions); protected _nextSessionName(): string; protected __resolveEndPoint(): boolean; protected _createSession(callback: ResponseCallback): void; protected static verifyEndpointDescriptionMatches(client: OPCUAClient, responseServerEndpoints: endpoints_service.EndpointDescription[]): boolean; protected __createSession_step2(session: ClientSession, callback: ResponseCallback): Promise; computeClientSignature(channel: ClientSecureChannelLayer, serverCertificate?: Uint8Array, serverNonce?: Uint8Array): Promise | undefined; protected createUserIdentityTokenP(session: ClientSession, userIdentityInfo: UserIdentityToken | UserIdentityInfo): Promise; protected createUserIdentityToken(session: ClientSession, userIdentityInfo: UserIdentityInfo | null, callback: ResponseCallback): void; protected _activateSession(session: ClientSession, options: SessionActivationOptions | null, callback: ResponseCallback): void; /** * transfer session to this client * @method reactivateSession * @param session * @param callback * @return {*} */ reactivateSession(session: ClientSession, options: SessionActivationOptions, callback: ErrorCallback): void; /** * transfer session to this client * @method reactivateSession * @param session * @param callback * @return {*} */ reactivateSessionP(session: ClientSession, options: SessionActivationOptions): Promise; /** * create and activate a new session * @async * @method createSession * * @param [userIdentityInfo {Object} ] optional * @param [userIdentityInfo.userName {String} ] * @param [userIdentityInfo.password {String} ] * * @param callback {ErrorCallback} * @param callback.err {Error|null} - the Error if the async method has failed * @param callback.session {ClientSession} - the created session object. * * * @example : * // create a anonymous session * client.createSession(function(err,session) { * if (err) {} else {} * }); * * @example : * // create a session with a userName and password * client.createSession({userName: "JoeDoe", password:"secret"}, function(err,session) { * if (err) {} else {} * }); * */ createSession(options: SessionActivationOptions | null, callback: ResponseCallback): void; /** * @method createSessionAsync * @param [userIdentityInfo {Object} ] optional * @param [userIdentityInfo.userName {String} ] * @param [userIdentityInfo.password {String} ] * @return {Promise} * @async * * @example * // create a anonymous session * const session = await client.createSession(); * * @example * // create a session with a userName and password * const userIdentityInfo = { userName: "JoeDoe", password:"secret"}; * const session = client.createSession(userIdentityInfo); * */ createSessionP(options: SessionActivationOptions | null): Promise; /** * @method changeSessionIdentity * @param session * @param userIdentityInfo // set to null to go back to anonymous user * @param callback * @async */ changeSessionIdentity(session: ClientSession | null, options: SessionActivationOptions | null, callback: ErrorCallback): void; changeSessionIdentityP(session: ClientSession | null, options: SessionActivationOptions | null): Promise; protected _closeSession(session: ClientSession, deleteSubscriptions: boolean, callback: ResponseCallback): void; /** * * @method closeSession * @async * @param session {ClientSession} - the created client session * @param deleteSubscriptions {Boolean} - whether to delete subscriptions or not * @param callback {ErrorCallback} - the callback * @param callback.err {Error|null} - the Error if the async method has failed */ closeSession(session: ClientSession, deleteSubscriptions: boolean, callback: ErrorCallback): void; /** * * @method closeSessionAsync * @async * @param session {ClientSession} - the created client session * @param deleteSubscriptions {Boolean} - whether to delete subscriptions or not */ closeSessionP(session: ClientSession, deleteSubscriptions: boolean): Promise; protected _on_connection_reestablished(callback: ErrorCallback): void; toString(): string; /** * @method withSession * @param inner_func {function} * @param inner_func.session {ClientSession} * @param inner_func.callback {function} * @param callback {function} */ withSession(endpointUrl: string, inner_func: (sess: ClientSession, cb: ErrorCallback) => void, callback: ErrorCallback): void; withSubscription(endpointUrl: string, subscriptionParameters: ICreateSubscriptionRequest, innerFunc: (arg0: ClientSession, arg1: ClientSubscription, arg2: () => void) => void, callback: ErrorCallback): void; } export declare function isAnonymous(userIdentityInfo: UserIdentityInfo): userIdentityInfo is UserIdentityInfoAnonymous; export declare function isUserNamePassword(userIdentityInfo: UserIdentityInfo): userIdentityInfo is UserIdentityInfoUserName; export declare function isIssued(userIdentityInfo: UserIdentityInfo): userIdentityInfo is UserIdentityInfoIssued; /** * Returns true when the server has provided a usable application instance certificate. * * An empty `Uint8Array` is truthy in JavaScript, so a plain `!cert` check would * wrongly conclude that a certificate is present when the server sent a * zero-length buffer. In that case the client must fall back to sending the * credentials unencrypted instead of attempting to encrypt against an empty key. */ export declare function serverHasCertificate(cert?: Uint8Array | null): boolean; //# sourceMappingURL=opcua_client.d.ts.map