• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

node-opcua / node-opcua / 23974043205

04 Apr 2026 07:17AM UTC coverage: 92.589% (+0.01%) from 92.576%
23974043205

push

github

erossignon
chore: fix Mocha.Suite.settimeout misused

18408 of 21832 branches covered (84.32%)

161708 of 174651 relevant lines covered (92.59%)

461089.77 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.11
/packages/node-opcua-server/source/server_capabilities.ts
1
/**
2✔
2
 * @module node-opcua-server
2✔
3
 */
2✔
4
// tslint:disable:max-classes-per-file
2✔
5
import type { Double, UInt32 } from "node-opcua-basic-types";
2✔
6
import { BinaryStream } from "node-opcua-binary-stream";
2✔
7
import type { QualifiedName } from "node-opcua-data-model";
2✔
8
import { make_warningLog } from "node-opcua-debug";
2✔
9
import type { SignedSoftwareCertificate } from "node-opcua-types";
2✔
10

2✔
11
const warningLog = make_warningLog(__filename);
2✔
12

2✔
13
/**
2✔
14
 */
2✔
15
export interface OperationLimitsOptions {
2✔
16
    maxNodesPerRead?: number;
2✔
17
    maxNodesPerBrowse?: number;
2✔
18
    maxNodesPerWrite?: number;
2✔
19
    maxNodesPerMethodCall?: number;
2✔
20
    maxNodesPerRegisterNodes?: number;
2✔
21
    maxNodesPerNodeManagement?: number;
2✔
22
    maxMonitoredItemsPerCall?: number;
2✔
23
    maxNodesPerHistoryReadData?: number;
2✔
24
    maxNodesPerHistoryReadEvents?: number;
2✔
25
    maxNodesPerHistoryUpdateData?: number;
2✔
26
    maxNodesPerHistoryUpdateEvents?: number;
2✔
27
    maxNodesPerTranslateBrowsePathsToNodeIds?: number;
2✔
28
}
2✔
29

2✔
30
export class ServerOperationLimits {
268✔
31
    public maxNodesPerRead: number;
268✔
32
    public maxNodesPerBrowse: number;
268✔
33
    public maxNodesPerWrite: number;
268✔
34
    public maxNodesPerMethodCall: number;
268✔
35
    public maxNodesPerRegisterNodes: number;
268✔
36
    public maxNodesPerNodeManagement: number;
268✔
37
    public maxMonitoredItemsPerCall: number;
268✔
38
    public maxNodesPerHistoryReadData: number;
268✔
39
    public maxNodesPerHistoryReadEvents: number;
268✔
40
    public maxNodesPerHistoryUpdateData: number;
268✔
41
    public maxNodesPerHistoryUpdateEvents: number;
268✔
42
    public maxNodesPerTranslateBrowsePathsToNodeIds: number;
268✔
43

268✔
44
    constructor(options: OperationLimitsOptions) {
268✔
45
        this.maxNodesPerRead = options.maxNodesPerRead || 0;
268✔
46
        this.maxNodesPerWrite = options.maxNodesPerWrite || 0;
268✔
47
        this.maxNodesPerMethodCall = options.maxNodesPerMethodCall || 0;
268✔
48
        this.maxNodesPerBrowse = options.maxNodesPerBrowse || 0;
268✔
49
        this.maxNodesPerRegisterNodes = options.maxNodesPerRegisterNodes || 0;
268✔
50
        this.maxNodesPerNodeManagement = options.maxNodesPerNodeManagement || 0;
268✔
51
        this.maxMonitoredItemsPerCall = options.maxMonitoredItemsPerCall || 0;
268✔
52
        this.maxNodesPerHistoryReadData = options.maxNodesPerHistoryReadData || 0;
268✔
53
        this.maxNodesPerHistoryReadEvents = options.maxNodesPerHistoryReadEvents || 0;
268✔
54
        this.maxNodesPerHistoryUpdateData = options.maxNodesPerHistoryUpdateData || 0;
268✔
55
        this.maxNodesPerHistoryUpdateEvents = options.maxNodesPerHistoryUpdateEvents || 0;
268✔
56
        this.maxNodesPerTranslateBrowsePathsToNodeIds = options.maxNodesPerTranslateBrowsePathsToNodeIds || 0;
268✔
57
    }
268✔
58
}
268✔
59

2✔
60
export interface IServerCapabilities {
2✔
61
    maxBrowseContinuationPoints: number;
2✔
62
    maxHistoryContinuationPoints: number;
2✔
63
    maxStringLength: number;
2✔
64
    maxArrayLength: number;
2✔
65
    maxByteStringLength: number;
2✔
66
    maxQueryContinuationPoints: number;
2✔
67
    minSupportedSampleRate: Double;
2✔
68
    operationLimits: OperationLimitsOptions;
2✔
69

2✔
70
    serverProfileArray: string[];
2✔
71
    localeIdArray: string[];
2✔
72
    softwareCertificates: SignedSoftwareCertificate[];
2✔
73

2✔
74
    // new in 1.05
2✔
75
    /**
2✔
76
     * MaxSessions is an integer specifying the maximum number of concurrent
2✔
77
     * Sessions the Server can support. The value specifies the
2✔
78
     * maximum the Server can support under normal circumstances,
2✔
79
     * therefore there is no guarantee the Server can always support
2✔
80
     * the maximum.
2✔
81
     */
2✔
82
    maxSessions: UInt32;
2✔
83

2✔
84
    /**
2✔
85
     * MaxSubscriptions is an integer specifying the maximum number of
2✔
86
     * Subscriptions the Server can support. The value specifies the
2✔
87
     * maximum the Server can support under normal circumstances,
2✔
88
     * therefore there is no guarantee the Server can always support
2✔
89
     * the maximum.
2✔
90
     */
2✔
91
    maxSubscriptions: UInt32;
2✔
92

2✔
93
    /**
2✔
94
     * MaxMonitoredItems is an integer specifying the maximum number of
2✔
95
     * MonitoredItems the Server can support. The value specifies the
2✔
96
     * maximum the Server can support under normal circumstances,
2✔
97
     * therefore there is no guarantee the Server can always support
2✔
98
     * the maximum.
2✔
99
     */
2✔
100
    maxMonitoredItems: UInt32;
2✔
101

2✔
102
    /**
2✔
103
     * MaxSubscriptionsPerSession is an integer specifying the maximum number of
2✔
104
     * Subscriptions per Session the Server can support. The value specifies the
2✔
105
     * maximum the Server can support under normal circumstances,
2✔
106
     * therefore there is no guarantee the Server can always support
2✔
107
     * the maximum.
2✔
108
     */
2✔
109
    maxSubscriptionsPerSession: UInt32;
2✔
110

2✔
111
    /**
2✔
112
     * MaxMonitoredItemsPerSubscription is an integer specifying the maximum number of
2✔
113
     * MonitoredItems per Subscription the Server can support. The value specifies the
2✔
114
     * maximum the Server can support under normal circumstances,
2✔
115
     * therefore there is no guarantee the Server can always support
2✔
116
     * the maximum
2✔
117
     */
2✔
118
    maxMonitoredItemsPerSubscription: UInt32;
2✔
119

2✔
120
    /**
2✔
121
     * MaxSelectClauseParameters is an integer specifying the maximum number of
2✔
122
     * EventField SelectClause Parameters the Server can support for an EventFilter.
2✔
123
     * The value specifies the maximum the Server can support under normal circumstances,
2✔
124
     * therefore there is no guarantee the Server can always support
2✔
125
     * the maximum.
2✔
126
     */
2✔
127
    maxSelectClauseParameters: UInt32;
2✔
128

2✔
129
    /**
2✔
130
     * MaxWhereClauseParameters is an integer specifying the maximum number of
2✔
131
     * EventField WhereClause Parameters the Server can support for an EventFilter.
2✔
132
     * The value specifies the maximum the Server can support under normal circumstances,
2✔
133
     * therefore there is no guarantee the Server can always support the maximum
2✔
134
     */
2✔
135
    maxWhereClauseParameters: UInt32;
2✔
136

2✔
137
    /**
2✔
138
     * (draft)
2✔
139
     * MaxMonitoredItemsQueueSize is an integer specifying the maximum size of MonitoredItem
2✔
140
     * queues. The value specifies the maximum the Server can support under normal circumstances,
2✔
141
     * therefore there is no guarantee the Server can always support the maximum.
2✔
142
     *
2✔
143
     */
2✔
144
    maxMonitoredItemsQueueSize: UInt32;
2✔
145

2✔
146
    /**
2✔
147
     *
2✔
148
     * ConformanceUnits is a QualifiedName array specifying the set of conformance units
2✔
149
     * the Server supports. This list should be limited to the ConformanceUnits the Server
2✔
150
     * supports in its current configuration.
2✔
151
     *
2✔
152
     */
2✔
153
    conformanceUnits: QualifiedName[];
2✔
154
}
2✔
155
export type ServerCapabilitiesOptions = Partial<IServerCapabilities>;
2✔
156

2✔
157
export const defaultServerCapabilities: IServerCapabilities = {
2✔
158
    maxBrowseContinuationPoints: 0,
2✔
159
    maxHistoryContinuationPoints: 0,
2✔
160
    maxStringLength: 16 * 1024 * 1024,
2✔
161
    maxArrayLength: 1024 * 1024,
2✔
162
    maxByteStringLength: 16 * 1024 * 1024,
2✔
163
    maxQueryContinuationPoints: 0,
2✔
164

2✔
165
    minSupportedSampleRate: 100,
2✔
166

2✔
167
    operationLimits: {
2✔
168
        maxNodesPerBrowse: 0,
2✔
169
        maxNodesPerHistoryReadData: 0,
2✔
170
        maxNodesPerHistoryReadEvents: 0,
2✔
171
        maxNodesPerHistoryUpdateData: 0,
2✔
172
        maxNodesPerHistoryUpdateEvents: 0,
2✔
173
        maxNodesPerMethodCall: 0,
2✔
174
        maxNodesPerNodeManagement: 0,
2✔
175
        maxNodesPerRead: 0,
2✔
176
        maxNodesPerRegisterNodes: 0,
2✔
177
        maxNodesPerWrite: 0,
2✔
178
        maxNodesPerTranslateBrowsePathsToNodeIds: 0,
2✔
179
        maxMonitoredItemsPerCall: 0
2✔
180
    },
2✔
181

2✔
182
    serverProfileArray: [],
2✔
183
    localeIdArray: [],
2✔
184
    softwareCertificates: [],
2✔
185

2✔
186
    maxSessions: 10,
2✔
187
    maxSubscriptions: 100,
2✔
188
    maxMonitoredItems: 1000000, // 1 million
2✔
189
    maxSubscriptionsPerSession: 10,
2✔
190
    maxMonitoredItemsPerSubscription: 100000, // one hundred thousand
2✔
191
    maxSelectClauseParameters: 100,
2✔
192
    maxWhereClauseParameters: 100,
2✔
193
    maxMonitoredItemsQueueSize: 60000,
2✔
194

2✔
195
    conformanceUnits: []
2✔
196
};
2✔
197

2✔
198
/**
2✔
199
 */
2✔
200
export class ServerCapabilities implements IServerCapabilities {
268✔
201
    public maxBrowseContinuationPoints: number;
335✔
202
    public maxHistoryContinuationPoints: number;
335✔
203
    public maxStringLength: number;
335✔
204
    public maxArrayLength: number;
335✔
205
    public maxByteStringLength: number;
335✔
206
    public maxQueryContinuationPoints: number;
335✔
207
    public minSupportedSampleRate: number;
335✔
208
    public operationLimits: ServerOperationLimits;
335✔
209

335✔
210
    public serverProfileArray: string[];
335✔
211
    public localeIdArray: string[];
335✔
212
    public softwareCertificates: SignedSoftwareCertificate[];
335✔
213

335✔
214
    // new in 1.05
335✔
215
    public maxSessions: UInt32;
335✔
216
    public maxSubscriptions: UInt32;
335✔
217
    public maxMonitoredItems: UInt32;
335✔
218
    public maxSubscriptionsPerSession: UInt32;
335✔
219
    public maxMonitoredItemsPerSubscription: UInt32;
335✔
220
    public maxSelectClauseParameters: UInt32;
335✔
221
    public maxWhereClauseParameters: UInt32;
335✔
222
    public maxMonitoredItemsQueueSize: UInt32;
335✔
223
    public conformanceUnits: QualifiedName[];
335✔
224

335✔
225
    // eslint-disable-next-line complexity
335✔
226
    constructor(options: ServerCapabilitiesOptions) {
335✔
227
        options = options || {};
335!
228
        options.operationLimits = options.operationLimits || {};
335✔
229

335✔
230
        this.serverProfileArray = options.serverProfileArray || [];
335!
231
        this.localeIdArray = options.localeIdArray || [];
335!
232
        this.softwareCertificates = options.softwareCertificates || [];
335✔
233

335✔
234
        this.maxArrayLength = options.maxArrayLength || defaultServerCapabilities.maxArrayLength;
335✔
235

335✔
236
        this.maxStringLength = options.maxStringLength || defaultServerCapabilities.maxStringLength;
335✔
237
        this.maxByteStringLength = options.maxByteStringLength || defaultServerCapabilities.maxByteStringLength;
335✔
238

335✔
239
        if (BinaryStream.maxStringLength < this.maxStringLength) {
335!
240
            warningLog(
×
241
                `ServerCapabilities.maxStringLength ${this.maxStringLength} is greater that the allowed limite BinaryStream.maxStringLength = ${BinaryStream.maxStringLength}\nPlease adjust the value.`
×
242
            );
×
243
        }
×
244

335✔
245
        if (BinaryStream.maxByteStringLength < this.maxByteStringLength) {
335!
246
            warningLog(
×
247
                `ServerCapabilities.maxByteStringLength ${this.maxByteStringLength} is greater that the allowed limite BinaryStream.maxByteStringLength = ${BinaryStream.maxByteStringLength}\nPlease adjust the value.`
×
248
            );
×
249
        }
×
250

335✔
251
        this.maxBrowseContinuationPoints =
335✔
252
            options.maxBrowseContinuationPoints || defaultServerCapabilities.maxBrowseContinuationPoints;
335✔
253
        this.maxQueryContinuationPoints =
335✔
254
            options.maxQueryContinuationPoints || defaultServerCapabilities.maxQueryContinuationPoints;
335✔
255
        this.maxHistoryContinuationPoints =
335✔
256
            options.maxHistoryContinuationPoints || defaultServerCapabilities.maxHistoryContinuationPoints;
335✔
257

335✔
258
        this.operationLimits = new ServerOperationLimits(options.operationLimits);
335✔
259

335✔
260
        this.minSupportedSampleRate = options.minSupportedSampleRate || defaultServerCapabilities.minSupportedSampleRate; // to do adjust me
335✔
261

335✔
262
        // new in 1.05
335✔
263
        this.maxSessions = options.maxSessions || defaultServerCapabilities.maxSessions;
335✔
264

335✔
265
        this.maxSubscriptionsPerSession =
335✔
266
            options.maxSubscriptionsPerSession || defaultServerCapabilities.maxSubscriptionsPerSession;
335✔
267
        this.maxSubscriptions = options.maxSubscriptions || defaultServerCapabilities.maxSubscriptions;
335✔
268
        this.maxMonitoredItems = options.maxMonitoredItems || defaultServerCapabilities.maxMonitoredItems;
335✔
269
        this.maxMonitoredItemsPerSubscription =
335✔
270
            options.maxMonitoredItemsPerSubscription || defaultServerCapabilities.maxMonitoredItemsPerSubscription;
335✔
271
        this.maxSelectClauseParameters = options.maxSelectClauseParameters || defaultServerCapabilities.maxSelectClauseParameters;
335✔
272
        this.maxWhereClauseParameters = options.maxWhereClauseParameters || defaultServerCapabilities.maxWhereClauseParameters;
335✔
273
        this.maxMonitoredItemsQueueSize =
335✔
274
            options.maxMonitoredItemsQueueSize || defaultServerCapabilities.maxMonitoredItemsQueueSize;
335✔
275
        this.conformanceUnits = options.conformanceUnits || defaultServerCapabilities.conformanceUnits;
335✔
276
    }
335✔
277
}
335✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc