node-opcua-client 2.77.0 → 2.79.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client_monitored_item_group.d.ts +3 -0
- package/dist/client_monitored_item_group.js.map +1 -1
- package/dist/client_session.d.ts +46 -2
- package/dist/client_session.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/opcua_client.d.ts +7 -21
- package/dist/opcua_client.js.map +1 -1
- package/dist/private/client_base_impl.d.ts +2 -1
- package/dist/private/client_base_impl.js +1 -1
- package/dist/private/client_base_impl.js.map +1 -1
- package/dist/private/client_monitored_item_impl.js +4 -4
- package/dist/private/client_monitored_item_impl.js.map +1 -1
- package/dist/private/client_session_impl.d.ts +10 -2
- package/dist/private/client_session_impl.js +31 -2
- package/dist/private/client_session_impl.js.map +1 -1
- package/dist/private/i_private_client.d.ts +2 -1
- package/dist/private/opcua_client_impl.d.ts +7 -5
- package/dist/private/opcua_client_impl.js +24 -21
- package/dist/private/opcua_client_impl.js.map +1 -1
- package/dist/reconnection.js +2 -2
- package/dist/reconnection.js.map +1 -1
- package/dist/user_identity_info.d.ts +1 -0
- package/dist/user_identity_info.js +3 -0
- package/dist/user_identity_info.js.map +1 -0
- package/package.json +31 -31
- package/source/client_monitored_item_group.ts +4 -0
- package/source/client_session.ts +97 -15
- package/source/index.ts +1 -0
- package/source/opcua_client.ts +5 -20
- package/source/private/client_base_impl.ts +6 -1
- package/source/private/client_monitored_item_impl.ts +10 -4
- package/source/private/client_session_impl.ts +73 -3
- package/source/private/i_private_client.ts +6 -1
- package/source/private/opcua_client_impl.ts +64 -54
- package/source/reconnection.ts +32 -23
- package/source/user_identity_info.ts +6 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user_identity_info.js","sourceRoot":"","sources":["../source/user_identity_info.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-opcua-client",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.79.0",
|
|
4
4
|
"description": "pure nodejs OPCUA SDK - module -client",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"clean": "npx rimraf node_modules dist *.tsbuildinfo certificates",
|
|
@@ -20,43 +20,43 @@
|
|
|
20
20
|
"callbackify": "^1.1.0",
|
|
21
21
|
"chalk": "4.1.2",
|
|
22
22
|
"node-opcua-assert": "2.77.0",
|
|
23
|
-
"node-opcua-basic-types": "2.
|
|
23
|
+
"node-opcua-basic-types": "2.79.0",
|
|
24
24
|
"node-opcua-buffer-utils": "2.77.0",
|
|
25
25
|
"node-opcua-certificate-manager": "2.77.0",
|
|
26
|
-
"node-opcua-client-dynamic-extension-object": "2.
|
|
27
|
-
"node-opcua-common": "2.
|
|
26
|
+
"node-opcua-client-dynamic-extension-object": "2.79.0",
|
|
27
|
+
"node-opcua-common": "2.79.0",
|
|
28
28
|
"node-opcua-constants": "2.77.0",
|
|
29
29
|
"node-opcua-crypto": "^1.11.0",
|
|
30
|
-
"node-opcua-data-model": "2.
|
|
31
|
-
"node-opcua-data-value": "2.
|
|
30
|
+
"node-opcua-data-model": "2.79.0",
|
|
31
|
+
"node-opcua-data-value": "2.79.0",
|
|
32
32
|
"node-opcua-date-time": "2.77.0",
|
|
33
33
|
"node-opcua-debug": "2.77.0",
|
|
34
|
-
"node-opcua-extension-object": "2.
|
|
34
|
+
"node-opcua-extension-object": "2.79.0",
|
|
35
35
|
"node-opcua-hostname": "2.77.0",
|
|
36
|
-
"node-opcua-nodeid": "2.
|
|
36
|
+
"node-opcua-nodeid": "2.79.0",
|
|
37
37
|
"node-opcua-object-registry": "2.77.0",
|
|
38
38
|
"node-opcua-pki": "^2.17.0",
|
|
39
|
-
"node-opcua-pseudo-session": "2.
|
|
40
|
-
"node-opcua-schemas": "2.
|
|
41
|
-
"node-opcua-secure-channel": "2.
|
|
42
|
-
"node-opcua-service-browse": "2.
|
|
43
|
-
"node-opcua-service-call": "2.
|
|
44
|
-
"node-opcua-service-discovery": "2.
|
|
45
|
-
"node-opcua-service-endpoints": "2.
|
|
46
|
-
"node-opcua-service-filter": "2.
|
|
47
|
-
"node-opcua-service-history": "2.
|
|
48
|
-
"node-opcua-service-query": "2.
|
|
49
|
-
"node-opcua-service-read": "2.
|
|
50
|
-
"node-opcua-service-register-node": "2.
|
|
51
|
-
"node-opcua-service-secure-channel": "2.
|
|
52
|
-
"node-opcua-service-session": "2.
|
|
53
|
-
"node-opcua-service-subscription": "2.
|
|
54
|
-
"node-opcua-service-translate-browse-path": "2.
|
|
55
|
-
"node-opcua-service-write": "2.
|
|
39
|
+
"node-opcua-pseudo-session": "2.79.0",
|
|
40
|
+
"node-opcua-schemas": "2.79.0",
|
|
41
|
+
"node-opcua-secure-channel": "2.79.0",
|
|
42
|
+
"node-opcua-service-browse": "2.79.0",
|
|
43
|
+
"node-opcua-service-call": "2.79.0",
|
|
44
|
+
"node-opcua-service-discovery": "2.79.0",
|
|
45
|
+
"node-opcua-service-endpoints": "2.79.0",
|
|
46
|
+
"node-opcua-service-filter": "2.79.0",
|
|
47
|
+
"node-opcua-service-history": "2.79.0",
|
|
48
|
+
"node-opcua-service-query": "2.79.0",
|
|
49
|
+
"node-opcua-service-read": "2.79.0",
|
|
50
|
+
"node-opcua-service-register-node": "2.79.0",
|
|
51
|
+
"node-opcua-service-secure-channel": "2.79.0",
|
|
52
|
+
"node-opcua-service-session": "2.79.0",
|
|
53
|
+
"node-opcua-service-subscription": "2.79.0",
|
|
54
|
+
"node-opcua-service-translate-browse-path": "2.79.0",
|
|
55
|
+
"node-opcua-service-write": "2.79.0",
|
|
56
56
|
"node-opcua-status-code": "2.77.0",
|
|
57
|
-
"node-opcua-types": "2.
|
|
57
|
+
"node-opcua-types": "2.79.0",
|
|
58
58
|
"node-opcua-utils": "2.77.0",
|
|
59
|
-
"node-opcua-variant": "2.
|
|
59
|
+
"node-opcua-variant": "2.79.0",
|
|
60
60
|
"once": "^1.4.0",
|
|
61
61
|
"thenify": "^3.3.1"
|
|
62
62
|
},
|
|
@@ -64,14 +64,14 @@
|
|
|
64
64
|
"@types/underscore": "^1.11.4",
|
|
65
65
|
"dequeue": "^1.0.5",
|
|
66
66
|
"mocha": "^10.0.0",
|
|
67
|
-
"node-opcua-address-space": "2.
|
|
67
|
+
"node-opcua-address-space": "2.79.0",
|
|
68
68
|
"node-opcua-binary-stream": "2.77.0",
|
|
69
|
-
"node-opcua-factory": "2.
|
|
69
|
+
"node-opcua-factory": "2.79.0",
|
|
70
70
|
"node-opcua-leak-detector": "2.77.0",
|
|
71
71
|
"node-opcua-nodesets": "2.77.0",
|
|
72
72
|
"should": "^13.2.3",
|
|
73
73
|
"sinon": "^14.0.0",
|
|
74
|
-
"underscore": "^1.13.
|
|
74
|
+
"underscore": "^1.13.6"
|
|
75
75
|
},
|
|
76
76
|
"eslintConfig": {
|
|
77
77
|
"env": {
|
|
@@ -93,5 +93,5 @@
|
|
|
93
93
|
"internet of things"
|
|
94
94
|
],
|
|
95
95
|
"homepage": "http://node-opcua.github.io/",
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "1a6d41827954dccf2c2cdff9344cc11fc99767f3"
|
|
97
97
|
}
|
|
@@ -20,6 +20,10 @@ export interface ClientMonitoredItemGroup extends EventEmitter, ClientMonitoredI
|
|
|
20
20
|
on(event: "initialized", eventHandler: () => void): this;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
export interface ClientMonitoredItemGroup {
|
|
24
|
+
monitoredItems: ClientMonitoredItemBase[];
|
|
25
|
+
}
|
|
26
|
+
|
|
23
27
|
export class ClientMonitoredItemGroup {
|
|
24
28
|
public static create(
|
|
25
29
|
subscription: ClientSubscription,
|
package/source/client_session.ts
CHANGED
|
@@ -56,10 +56,16 @@ import { WriteValue, WriteValueOptions } from "node-opcua-service-write";
|
|
|
56
56
|
import { StatusCode } from "node-opcua-status-code";
|
|
57
57
|
import { DataType, Variant } from "node-opcua-variant";
|
|
58
58
|
import { Callback } from "node-opcua-status-code";
|
|
59
|
+
import { IBasicSessionChangeUser } from "node-opcua-pseudo-session";
|
|
59
60
|
import { ExtensionObject } from "node-opcua-extension-object";
|
|
60
61
|
import { ArgumentDefinition, CallMethodRequestLike, MethodId } from "node-opcua-pseudo-session";
|
|
61
62
|
import { AggregateFunction } from "node-opcua-constants";
|
|
62
|
-
import {
|
|
63
|
+
import {
|
|
64
|
+
AggregateConfigurationOptions,
|
|
65
|
+
HistoryReadRequest,
|
|
66
|
+
HistoryReadResponse,
|
|
67
|
+
HistoryReadValueIdOptions
|
|
68
|
+
} from "node-opcua-types";
|
|
63
69
|
|
|
64
70
|
import { ExtraDataTypeManager } from "node-opcua-client-dynamic-extension-object";
|
|
65
71
|
export { ExtraDataTypeManager } from "node-opcua-client-dynamic-extension-object";
|
|
@@ -418,6 +424,10 @@ export interface ClientSessionSubscriptionService {
|
|
|
418
424
|
): void;
|
|
419
425
|
}
|
|
420
426
|
|
|
427
|
+
export interface ClientSessionChangeUser extends IBasicSessionChangeUser {
|
|
428
|
+
/* */
|
|
429
|
+
}
|
|
430
|
+
|
|
421
431
|
export interface HistoryReadValueIdOptions2 extends HistoryReadValueIdOptions {
|
|
422
432
|
nodeId: NodeIdLike; // nodeId is mandatory here
|
|
423
433
|
}
|
|
@@ -505,6 +515,43 @@ export interface ClientSessionReadHistoryService {
|
|
|
505
515
|
* @param aggregateFn
|
|
506
516
|
* @param processingInterval in milliseconds
|
|
507
517
|
* @param callback
|
|
518
|
+
*
|
|
519
|
+
*
|
|
520
|
+
* aggregateConfiguration contains additional parameters
|
|
521
|
+
*
|
|
522
|
+
* - The TreatUncertainAsBad Variable indicates how the Server treats data returned with a
|
|
523
|
+
* StatusCode severity Uncertain with respect to Aggregate calculations. A value of True
|
|
524
|
+
* indicates the Server considers the severity equivalent to Bad, a value of False indicates
|
|
525
|
+
* the Server considers the severity equivalent to Good, unless the Aggregate definition says
|
|
526
|
+
* otherwise. The default value is True. Note that the value is still treated as Uncertain when
|
|
527
|
+
* the StatusCode for the result is calculated.
|
|
528
|
+
*
|
|
529
|
+
* - The PercentDataBad Variable indicates the minimum percentage of Bad data in a given interval
|
|
530
|
+
* required for the StatusCode for the given interval for processed data request to be set to Bad.
|
|
531
|
+
* (Uncertain is treated as defined above.) Refer to 5.4.3 for details on using this Variable when
|
|
532
|
+
* assigning StatusCodes. For details on which Aggregates use the PercentDataBad Variable, see the
|
|
533
|
+
* definition of each Aggregate. The default value is 100.
|
|
534
|
+
*
|
|
535
|
+
* - The PercentDataGood Variable indicates the minimum percentage of Good data in a given interval
|
|
536
|
+
* required for the StatusCode for the given interval for the processed data requests to be set to
|
|
537
|
+
* Good. Refer to 5.4.3 for details on using this Variable when assigning StatusCodes. For details
|
|
538
|
+
* on which Aggregates use the PercentDataGood Variable, see the definition of each Aggregate.
|
|
539
|
+
* The default value is 100.
|
|
540
|
+
*
|
|
541
|
+
* - The PercentDataGood and PercentDataBad shall follow the following relationship
|
|
542
|
+
* PercentDataGood ≥ (100 – PercentDataBad).
|
|
543
|
+
* If they are equal the result of the PercentDataGood calculation is used. If the values
|
|
544
|
+
* entered for PercentDataGood and PercentDataBad do not result in a valid calculation
|
|
545
|
+
* (e.g. Bad = 80; Good = 0) the result will have a StatusCode of Bad_AggregateInvalidInputs
|
|
546
|
+
* The StatusCode Bad_AggregateInvalidInputs will be returned if the value of PercentDataGood
|
|
547
|
+
* or PercentDataBad exceed 100.
|
|
548
|
+
*
|
|
549
|
+
* - The UseSlopedExtrapolation Variable indicates how the Server interpolates data when no boundary
|
|
550
|
+
* value exists (i.e. extrapolating into the future from the last known value). A value of False
|
|
551
|
+
* indicates that the Server will use a SteppedExtrapolation format, and hold the last known value
|
|
552
|
+
* constant. A value of True indicates the Server will project the value using UseSlopedExtrapolation
|
|
553
|
+
* mode. The default value is False. For SimpleBounds this value is ignored.
|
|
554
|
+
*
|
|
508
555
|
*/
|
|
509
556
|
readAggregateValue(
|
|
510
557
|
nodesToRead: HistoryReadValueIdOptions[],
|
|
@@ -536,6 +583,40 @@ export interface ClientSessionReadHistoryService {
|
|
|
536
583
|
aggregateFn: AggregateFunction,
|
|
537
584
|
processingInterval: number
|
|
538
585
|
): Promise<HistoryReadResult>;
|
|
586
|
+
readAggregateValue(
|
|
587
|
+
nodesToRead: HistoryReadValueIdOptions[],
|
|
588
|
+
startTime: DateTime,
|
|
589
|
+
endTime: DateTime,
|
|
590
|
+
aggregateFn: AggregateFunction[],
|
|
591
|
+
processingInterval: number,
|
|
592
|
+
aggregateConfiguration: AggregateConfigurationOptions,
|
|
593
|
+
callback: Callback<HistoryReadResult[]>
|
|
594
|
+
): void;
|
|
595
|
+
readAggregateValue(
|
|
596
|
+
nodesToRead: HistoryReadValueIdOptions[],
|
|
597
|
+
startTime: DateTime,
|
|
598
|
+
endTime: DateTime,
|
|
599
|
+
aggregateFn: AggregateFunction[],
|
|
600
|
+
processingInterval: number,
|
|
601
|
+
aggregateConfiguration: AggregateConfigurationOptions
|
|
602
|
+
): Promise<HistoryReadResult[]>;
|
|
603
|
+
readAggregateValue(
|
|
604
|
+
nodeToRead: HistoryReadValueIdOptions,
|
|
605
|
+
startTime: DateTime,
|
|
606
|
+
endTime: DateTime,
|
|
607
|
+
aggregateFn: AggregateFunction,
|
|
608
|
+
processingInterval: number,
|
|
609
|
+
aggregateConfiguration: AggregateConfigurationOptions,
|
|
610
|
+
callback: Callback<HistoryReadResult>
|
|
611
|
+
): void;
|
|
612
|
+
readAggregateValue(
|
|
613
|
+
nodeToRead: HistoryReadValueIdOptions,
|
|
614
|
+
startTime: DateTime,
|
|
615
|
+
endTime: DateTime,
|
|
616
|
+
aggregateFn: AggregateFunction,
|
|
617
|
+
processingInterval: number,
|
|
618
|
+
aggregateConfiguration: AggregateConfigurationOptions
|
|
619
|
+
): Promise<HistoryReadResult>;
|
|
539
620
|
|
|
540
621
|
historyRead(request: HistoryReadRequest, callback: Callback<HistoryReadResponse>): void;
|
|
541
622
|
historyRead(request: HistoryReadRequest): Promise<HistoryReadResponse>;
|
|
@@ -701,17 +782,18 @@ export interface ClientSessionPublishService {
|
|
|
701
782
|
|
|
702
783
|
export interface ClientSession
|
|
703
784
|
extends ClientSessionTranslateBrowsePathService,
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
785
|
+
ClientSessionQueryService,
|
|
786
|
+
ClientSessionBrowseService,
|
|
787
|
+
// ClientSessionRawSubscriptionService,
|
|
788
|
+
ClientSessionSubscriptionService,
|
|
789
|
+
ClientSessionCallService,
|
|
790
|
+
ClientSessionRegisterService,
|
|
791
|
+
ClientSessionReadService,
|
|
792
|
+
// ClientSessionWriteService,
|
|
793
|
+
ClientSessionReadHistoryService,
|
|
794
|
+
ClientSessionConditionService,
|
|
795
|
+
ClientSessionExtensionObjectService,
|
|
796
|
+
ClientSessionNamespaceService,
|
|
797
|
+
ClientSessionDataTypeService,
|
|
798
|
+
ClientSessionChangeUser,
|
|
799
|
+
IBasicSession {}
|
package/source/index.ts
CHANGED
|
@@ -20,6 +20,7 @@ export * from "./tools/findservers";
|
|
|
20
20
|
export * from "./tools/read_history_server_capabilities";
|
|
21
21
|
export * from "./client_utils";
|
|
22
22
|
export * from "./verify";
|
|
23
|
+
export * from "./user_identity_info";
|
|
23
24
|
|
|
24
25
|
export { assert } from "node-opcua-assert";
|
|
25
26
|
export * from "node-opcua-utils";
|
package/source/opcua_client.ts
CHANGED
|
@@ -8,29 +8,14 @@ import { ConnectionStrategyOptions, Message, SecurityPolicy } from "node-opcua-s
|
|
|
8
8
|
import { ApplicationDescription, EndpointDescription, UserTokenType } from "node-opcua-service-endpoints";
|
|
9
9
|
import { MessageSecurityMode } from "node-opcua-service-secure-channel";
|
|
10
10
|
import { X509IdentityTokenOptions } from "node-opcua-types";
|
|
11
|
-
import { ErrorCallback } from "node-opcua-status-code";
|
|
11
|
+
import { CallbackT, ErrorCallback, StatusCode } from "node-opcua-status-code";
|
|
12
12
|
import { FindServersRequestLike, GetEndpointsOptions, OPCUAClientBase, OPCUAClientBaseOptions } from "./client_base";
|
|
13
13
|
|
|
14
14
|
import { ClientSession, ResponseCallback } from "./client_session";
|
|
15
15
|
import { ClientSubscription, ClientSubscriptionOptions } from "./client_subscription";
|
|
16
16
|
import { OPCUAClientImpl } from "./private/opcua_client_impl";
|
|
17
|
+
import { UserIdentityInfo } from "./user_identity_info";
|
|
17
18
|
|
|
18
|
-
export interface UserIdentityInfoUserName {
|
|
19
|
-
type: UserTokenType.UserName;
|
|
20
|
-
userName: string;
|
|
21
|
-
password: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface UserIdentityInfoX509 extends X509IdentityTokenOptions {
|
|
25
|
-
type: UserTokenType.Certificate;
|
|
26
|
-
certificateData: ByteString;
|
|
27
|
-
privateKey: PrivateKeyPEM;
|
|
28
|
-
}
|
|
29
|
-
export interface AnonymousIdentity {
|
|
30
|
-
type: UserTokenType.Anonymous;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export type UserIdentityInfo = AnonymousIdentity | UserIdentityInfoX509 | UserIdentityInfoUserName;
|
|
34
19
|
|
|
35
20
|
export interface OPCUAClientOptions extends OPCUAClientBaseOptions {
|
|
36
21
|
/**
|
|
@@ -136,9 +121,9 @@ export interface OPCUAClient extends OPCUAClientBase {
|
|
|
136
121
|
|
|
137
122
|
createSession2(callback: (err: Error | null, session?: ClientSession) => void): void;
|
|
138
123
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
changeSessionIdentity(session: ClientSession, userIdentityInfo: UserIdentityInfo, callback:
|
|
124
|
+
/** @deprecated */
|
|
125
|
+
changeSessionIdentity(session: ClientSession, userIdentityInfo: UserIdentityInfo): Promise<StatusCode>;
|
|
126
|
+
changeSessionIdentity(session: ClientSession, userIdentityInfo: UserIdentityInfo, callback: CallbackT<StatusCode>): void;
|
|
142
127
|
|
|
143
128
|
closeSession(session: ClientSession, deleteSubscriptions: boolean): Promise<void>;
|
|
144
129
|
|
|
@@ -64,6 +64,7 @@ import {
|
|
|
64
64
|
OPCUAClientBaseOptions,
|
|
65
65
|
TransportSettings
|
|
66
66
|
} from "../client_base";
|
|
67
|
+
import { UserIdentityInfo } from "../user_identity_info";
|
|
67
68
|
import { performCertificateSanityCheck } from "../verify";
|
|
68
69
|
import { ClientSessionImpl } from "./client_session_impl";
|
|
69
70
|
import { IClientBase } from "./i_private_client";
|
|
@@ -1646,7 +1647,11 @@ export class ClientBaseImpl extends OPCUASecureObject implements OPCUAClientBase
|
|
|
1646
1647
|
): void {
|
|
1647
1648
|
throw new Error("Please override");
|
|
1648
1649
|
}
|
|
1649
|
-
public _activateSession(
|
|
1650
|
+
public _activateSession(
|
|
1651
|
+
session: ClientSessionImpl,
|
|
1652
|
+
userIdentity: UserIdentityInfo,
|
|
1653
|
+
callback: (err: Error | null, session?: ClientSessionImpl) => void
|
|
1654
|
+
): void {
|
|
1650
1655
|
throw new Error("Please override");
|
|
1651
1656
|
}
|
|
1652
1657
|
}
|
|
@@ -193,8 +193,11 @@ export class ClientMonitoredItemImpl extends EventEmitter implements ClientMonit
|
|
|
193
193
|
try {
|
|
194
194
|
this.emit("changed", value);
|
|
195
195
|
} catch (err) {
|
|
196
|
-
|
|
197
|
-
|
|
196
|
+
warningLog(
|
|
197
|
+
"[NODE-OPCUA-W28] Exception raised inside the event handler called by ClientMonitoredItem.on('change')",
|
|
198
|
+
err
|
|
199
|
+
);
|
|
200
|
+
warningLog(" Please verify the application using this node-opcua client");
|
|
198
201
|
}
|
|
199
202
|
}
|
|
200
203
|
|
|
@@ -217,8 +220,11 @@ export class ClientMonitoredItemImpl extends EventEmitter implements ClientMonit
|
|
|
217
220
|
try {
|
|
218
221
|
this.emit("changed", eventFields);
|
|
219
222
|
} catch (err) {
|
|
220
|
-
warningLog(
|
|
221
|
-
|
|
223
|
+
warningLog(
|
|
224
|
+
"[NODE-OPCUA-W29] Exception raised inside the event handler called by ClientMonitoredItem.on('change')",
|
|
225
|
+
err
|
|
226
|
+
);
|
|
227
|
+
warningLog(" Please verify the application using this node-opcua client");
|
|
222
228
|
}
|
|
223
229
|
}
|
|
224
230
|
|
|
@@ -83,10 +83,11 @@ import { WriteRequest, WriteResponse, WriteValue } from "node-opcua-service-writ
|
|
|
83
83
|
import { StatusCode, StatusCodes, Callback, CallbackT } from "node-opcua-status-code";
|
|
84
84
|
import { ErrorCallback } from "node-opcua-status-code";
|
|
85
85
|
import {
|
|
86
|
+
AggregateConfigurationOptions,
|
|
86
87
|
BrowseNextRequest,
|
|
87
88
|
BrowseNextResponse,
|
|
88
89
|
HistoryReadValueIdOptions,
|
|
89
|
-
|
|
90
|
+
UserTokenType,
|
|
90
91
|
WriteValueOptions
|
|
91
92
|
} from "node-opcua-types";
|
|
92
93
|
import { buffer_ellipsis, getFunctionParameterNames, isNullOrUndefined, lowerFirstLetter } from "node-opcua-utils";
|
|
@@ -117,6 +118,7 @@ import { ClientSessionKeepAliveManager } from "../client_session_keepalive_manag
|
|
|
117
118
|
import { ClientSubscription } from "../client_subscription";
|
|
118
119
|
import { Request, Response } from "../common";
|
|
119
120
|
import { repair_client_session } from "../reconnection";
|
|
121
|
+
import { UserIdentityInfo } from "../user_identity_info";
|
|
120
122
|
|
|
121
123
|
import { ClientSidePublishEngine } from "./client_publish_engine";
|
|
122
124
|
import { ClientSubscriptionImpl } from "./client_subscription_impl";
|
|
@@ -238,6 +240,7 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession {
|
|
|
238
240
|
public lastRequestSentTime: Date;
|
|
239
241
|
public lastResponseReceivedTime: Date;
|
|
240
242
|
public serverCertificate: Certificate;
|
|
243
|
+
public userIdentityInfo?: UserIdentityInfo;
|
|
241
244
|
public name = "";
|
|
242
245
|
|
|
243
246
|
public serverNonce?: Nonce;
|
|
@@ -312,6 +315,29 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession {
|
|
|
312
315
|
return this._publishEngine!;
|
|
313
316
|
}
|
|
314
317
|
|
|
318
|
+
public changeUser(userIdentityInfo: UserIdentityInfo): Promise<StatusCode>;
|
|
319
|
+
public changeUser(userIdentityInfo: UserIdentityInfo, callback: CallbackT<StatusCode>): void;
|
|
320
|
+
public changeUser(userIdentityInfo: UserIdentityInfo, callback?: CallbackT<StatusCode>): any {
|
|
321
|
+
userIdentityInfo = userIdentityInfo || {
|
|
322
|
+
type: UserTokenType.Anonymous
|
|
323
|
+
};
|
|
324
|
+
if (!this._client || !this.userIdentityInfo) {
|
|
325
|
+
warningLog("changeUser: invalid session");
|
|
326
|
+
return callback!(null, StatusCodes.BadInternalError);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
const old_userIdentity: UserIdentityInfo = this.userIdentityInfo;
|
|
330
|
+
|
|
331
|
+
this._client._activateSession(this, userIdentityInfo, (err1: Error | null, session2?: ClientSessionImpl) => {
|
|
332
|
+
if (err1) {
|
|
333
|
+
this.userIdentityInfo = old_userIdentity;
|
|
334
|
+
console.log("err1 = ", err1.message);
|
|
335
|
+
return callback!(null, StatusCodes.BadUserAccessDenied);
|
|
336
|
+
}
|
|
337
|
+
this.userIdentityInfo = userIdentityInfo;
|
|
338
|
+
callback!(null, StatusCodes.Good);
|
|
339
|
+
});
|
|
340
|
+
}
|
|
315
341
|
/**
|
|
316
342
|
* @method browse
|
|
317
343
|
* @async
|
|
@@ -763,6 +789,40 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession {
|
|
|
763
789
|
aggregateFn: AggregateFunction,
|
|
764
790
|
processingInterval: number
|
|
765
791
|
): Promise<HistoryReadResult>;
|
|
792
|
+
public readAggregateValue(
|
|
793
|
+
nodesToRead: HistoryReadValueIdOptions[],
|
|
794
|
+
startTime: DateTime,
|
|
795
|
+
endTime: DateTime,
|
|
796
|
+
aggregateFn: AggregateFunction[],
|
|
797
|
+
processingInterval: number,
|
|
798
|
+
aggregateConfiguration: AggregateConfigurationOptions,
|
|
799
|
+
callback: Callback<HistoryReadResult[]>
|
|
800
|
+
): void;
|
|
801
|
+
public async readAggregateValue(
|
|
802
|
+
nodesToRead: HistoryReadValueIdOptions[],
|
|
803
|
+
startTime: DateTime,
|
|
804
|
+
endTime: DateTime,
|
|
805
|
+
aggregateFn: AggregateFunction[],
|
|
806
|
+
processingInterval: number,
|
|
807
|
+
aggregateConfiguration: AggregateConfigurationOptions
|
|
808
|
+
): Promise<HistoryReadResult[]>;
|
|
809
|
+
public readAggregateValue(
|
|
810
|
+
nodeToRead: HistoryReadValueIdOptions,
|
|
811
|
+
startTime: DateTime,
|
|
812
|
+
endTime: DateTime,
|
|
813
|
+
aggregateFn: AggregateFunction,
|
|
814
|
+
processingInterval: number,
|
|
815
|
+
aggregateConfiguration: AggregateConfigurationOptions,
|
|
816
|
+
callback: Callback<HistoryReadResult>
|
|
817
|
+
): void;
|
|
818
|
+
public async readAggregateValue(
|
|
819
|
+
nodeToRead: HistoryReadValueIdOptions,
|
|
820
|
+
startTime: DateTime,
|
|
821
|
+
endTime: DateTime,
|
|
822
|
+
aggregateFn: AggregateFunction,
|
|
823
|
+
processingInterval: number,
|
|
824
|
+
aggregateConfiguration: AggregateConfigurationOptions
|
|
825
|
+
): Promise<HistoryReadResult>;
|
|
766
826
|
|
|
767
827
|
public readAggregateValue(
|
|
768
828
|
arg0: HistoryReadValueIdOptions[] | HistoryReadValueIdOptions,
|
|
@@ -772,8 +832,16 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession {
|
|
|
772
832
|
processingInterval: number,
|
|
773
833
|
...args: any[]
|
|
774
834
|
): any {
|
|
775
|
-
const callback = args[0];
|
|
835
|
+
const callback = typeof args[0] === "function" ? args[0] : args[1];
|
|
776
836
|
assert(typeof callback === "function");
|
|
837
|
+
const defaultAggregateFunction = {
|
|
838
|
+
percentDataBad: 100,
|
|
839
|
+
percentDataGood: 100,
|
|
840
|
+
treatUncertainAsBad: true,
|
|
841
|
+
useServerCapabilitiesDefaults: true,
|
|
842
|
+
useSlopedExtrapolation: false
|
|
843
|
+
};
|
|
844
|
+
const aggregateConfiguration = typeof args[0] === "function" ? defaultAggregateFunction : args[0];
|
|
777
845
|
|
|
778
846
|
const isArray = Array.isArray(arg0);
|
|
779
847
|
|
|
@@ -791,7 +859,8 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession {
|
|
|
791
859
|
aggregateType: aggregateFns,
|
|
792
860
|
endTime,
|
|
793
861
|
processingInterval,
|
|
794
|
-
startTime
|
|
862
|
+
startTime,
|
|
863
|
+
aggregateConfiguration
|
|
795
864
|
});
|
|
796
865
|
|
|
797
866
|
const request = new HistoryReadRequest({
|
|
@@ -2277,3 +2346,4 @@ ClientSessionImpl.prototype.unregisterNodes = thenify.withCallback(ClientSession
|
|
|
2277
2346
|
ClientSessionImpl.prototype.readNamespaceArray = thenify.withCallback(ClientSessionImpl.prototype.readNamespaceArray, opts);
|
|
2278
2347
|
ClientSessionImpl.prototype.getBuiltInDataType = thenify.withCallback(ClientSessionImpl.prototype.getBuiltInDataType, opts);
|
|
2279
2348
|
ClientSessionImpl.prototype.constructExtensionObject = callbackify(ClientSessionImpl.prototype.constructExtensionObject);
|
|
2349
|
+
ClientSessionImpl.prototype.changeUser = thenify.withCallback(ClientSessionImpl.prototype.changeUser, opts);
|
|
@@ -2,11 +2,16 @@ import { ClientSecureChannelLayer } from "node-opcua-secure-channel";
|
|
|
2
2
|
import { EndpointDescription } from "node-opcua-service-endpoints";
|
|
3
3
|
import { ClientSession, ResponseCallback } from "../client_session";
|
|
4
4
|
import { Request, Response } from "../common";
|
|
5
|
+
import { UserIdentityInfo } from "../user_identity_info";
|
|
5
6
|
import { ClientSessionImpl } from "./client_session_impl";
|
|
6
7
|
|
|
7
8
|
export interface IClientBase {
|
|
8
9
|
__createSession_step2(session: ClientSessionImpl, callback: (err: Error | null, session?: ClientSessionImpl) => void): void;
|
|
9
|
-
_activateSession(
|
|
10
|
+
_activateSession(
|
|
11
|
+
session: ClientSessionImpl,
|
|
12
|
+
userIdentity: UserIdentityInfo,
|
|
13
|
+
callback: (err: Error | null, session?: ClientSessionImpl) => void
|
|
14
|
+
): void;
|
|
10
15
|
_removeSession(session: ClientSessionImpl): void;
|
|
11
16
|
closeSession(session: ClientSession, deleteSubscription: any, arg2: (err?: Error | undefined) => void): void;
|
|
12
17
|
|