node-opcua-address-space 2.165.2 → 2.167.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-opcua-address-space",
3
- "version": "2.165.2",
3
+ "version": "2.167.0",
4
4
  "description": "pure nodejs OPCUA SDK - module address-space",
5
5
  "main": "./dist/src/index_current.js",
6
6
  "types": "./dist/source/index.d.ts",
@@ -10,6 +10,7 @@
10
10
  "scripts": {
11
11
  "build": "tsc -b",
12
12
  "test": "mocha",
13
+ "test:check": "tsc --noEmit -p test/tsconfig.json",
13
14
  "lint": "eslint source test src source_nodejs test_helpers",
14
15
  "format": "prettier --write source test src source_nodejs test_helpers",
15
16
  "clean": "npx rimraf -g node_modules dist *.tsbuildinfo",
@@ -22,48 +23,48 @@
22
23
  "chalk": "4.1.2",
23
24
  "dequeue": "^1.0.5",
24
25
  "lodash": "4.17.23",
25
- "node-opcua-address-space-base": "2.165.0",
26
+ "node-opcua-address-space-base": "2.167.0",
26
27
  "node-opcua-assert": "2.164.0",
27
- "node-opcua-basic-types": "2.165.0",
28
- "node-opcua-binary-stream": "2.165.0",
29
- "node-opcua-client-dynamic-extension-object": "2.165.2",
28
+ "node-opcua-basic-types": "2.167.0",
29
+ "node-opcua-binary-stream": "2.167.0",
30
+ "node-opcua-client-dynamic-extension-object": "2.167.0",
30
31
  "node-opcua-constants": "2.157.0",
31
- "node-opcua-crypto": "5.3.0",
32
- "node-opcua-data-access": "2.165.0",
33
- "node-opcua-data-model": "2.165.0",
34
- "node-opcua-data-value": "2.165.0",
35
- "node-opcua-date-time": "2.165.0",
32
+ "node-opcua-crypto": "5.3.3",
33
+ "node-opcua-data-access": "2.167.0",
34
+ "node-opcua-data-model": "2.167.0",
35
+ "node-opcua-data-value": "2.167.0",
36
+ "node-opcua-date-time": "2.167.0",
36
37
  "node-opcua-debug": "2.165.0",
37
- "node-opcua-enum": "2.165.0",
38
- "node-opcua-extension-object": "2.165.0",
39
- "node-opcua-factory": "2.165.0",
40
- "node-opcua-nodeid": "2.165.0",
41
- "node-opcua-nodeset-ua": "2.165.0",
42
- "node-opcua-numeric-range": "2.165.0",
38
+ "node-opcua-enum": "2.167.0",
39
+ "node-opcua-extension-object": "2.167.0",
40
+ "node-opcua-factory": "2.167.0",
41
+ "node-opcua-nodeid": "2.167.0",
42
+ "node-opcua-nodeset-ua": "2.167.0",
43
+ "node-opcua-numeric-range": "2.167.0",
43
44
  "node-opcua-object-registry": "2.165.0",
44
- "node-opcua-pseudo-session": "2.165.2",
45
- "node-opcua-service-browse": "2.165.0",
46
- "node-opcua-service-call": "2.165.0",
47
- "node-opcua-service-history": "2.165.0",
48
- "node-opcua-service-translate-browse-path": "2.165.0",
49
- "node-opcua-service-write": "2.165.0",
50
- "node-opcua-status-code": "2.165.0",
51
- "node-opcua-types": "2.165.0",
45
+ "node-opcua-pseudo-session": "2.167.0",
46
+ "node-opcua-service-browse": "2.167.0",
47
+ "node-opcua-service-call": "2.167.0",
48
+ "node-opcua-service-history": "2.167.0",
49
+ "node-opcua-service-translate-browse-path": "2.167.0",
50
+ "node-opcua-service-write": "2.167.0",
51
+ "node-opcua-status-code": "2.167.0",
52
+ "node-opcua-types": "2.167.0",
52
53
  "node-opcua-utils": "2.165.0",
53
- "node-opcua-variant": "2.165.0",
54
- "node-opcua-xml2json": "2.165.0",
54
+ "node-opcua-variant": "2.167.0",
55
+ "node-opcua-xml2json": "2.167.0",
55
56
  "semver": "^7.7.4",
56
57
  "thenify-ex": "4.4.0",
57
58
  "xml-writer": "^1.7.0"
58
59
  },
59
60
  "devDependencies": {
60
61
  "humanize": "0.0.9",
61
- "node-opcua-benchmarker": "2.165.0",
62
+ "node-opcua-benchmarker": "2.167.0",
62
63
  "node-opcua-leak-detector": "2.165.0",
63
64
  "node-opcua-nodesets": "2.163.1",
64
- "node-opcua-packet-analyzer": "2.165.0",
65
- "node-opcua-schemas": "2.165.0",
66
- "node-opcua-service-filter": "2.165.0",
65
+ "node-opcua-packet-analyzer": "2.167.0",
66
+ "node-opcua-schemas": "2.167.0",
67
+ "node-opcua-service-filter": "2.167.0",
67
68
  "node-opcua-test-fixtures": "2.157.0"
68
69
  },
69
70
  "author": "Etienne Rossignon",
@@ -81,7 +82,7 @@
81
82
  "internet of things"
82
83
  ],
83
84
  "homepage": "http://node-opcua.github.io/",
84
- "gitHead": "4002059a60bf085329c59f5f404f73415f4b640a",
85
+ "gitHead": "5decfa86ee53a36ecd3bb454e7bf6e3dd27c7a4e",
85
86
  "files": [
86
87
  "dist",
87
88
  "distHelpers",
@@ -1,25 +1,26 @@
1
1
  /**
2
2
  * @module node-opcua-address-space
3
3
  */
4
+ /** biome-ignore-all lint/style/useLiteralEnumMembers: still needed */
4
5
 
6
+ import type { BaseNode, ISessionBase, ISessionContext, UAObject, UAObjectType, UAVariable } from "node-opcua-address-space-base";
5
7
  import { assert } from "node-opcua-assert";
6
- import { Certificate, CertificateInternals, exploreCertificate } from "node-opcua-crypto/web";
7
- import { AccessRestrictionsFlag, allPermissions, AttributeIds, PermissionFlag } from "node-opcua-data-model";
8
- import { PreciseClock } from "node-opcua-date-time";
9
- import { NodeId, NodeIdLike, resolveNodeId, sameNodeId } from "node-opcua-nodeid";
8
+ import { ObjectIds } from "node-opcua-constants";
9
+ import { type Certificate, type CertificateInternals, exploreCertificate } from "node-opcua-crypto/web";
10
+ import { AccessRestrictionsFlag, AttributeIds, allPermissions, PermissionFlag } from "node-opcua-data-model";
11
+ import type { PreciseClock } from "node-opcua-date-time";
12
+ import { type NodeId, type NodeIdLike, resolveNodeId, sameNodeId } from "node-opcua-nodeid";
10
13
  import {
11
14
  AnonymousIdentityToken,
12
15
  MessageSecurityMode,
13
16
  PermissionType,
14
- RolePermissionType,
17
+ type RolePermissionType,
15
18
  UserNameIdentityToken,
16
19
  X509IdentityToken
17
20
  } from "node-opcua-types";
18
- import { ISessionContext, UAObject, UAObjectType, UAVariable, BaseNode, ISessionBase } from "node-opcua-address-space-base";
19
- import { ObjectIds } from "node-opcua-constants";
20
- import { NamespacePrivate } from "../src/namespace_private";
21
+ import type { NamespacePrivate } from "../src/namespace_private";
21
22
 
22
- export { RolePermissionType, RolePermissionTypeOptions, PermissionType } from "node-opcua-types";
23
+ export { PermissionType, RolePermissionType, RolePermissionTypeOptions } from "node-opcua-types";
23
24
 
24
25
  type AnyUserIdentityToken = UserNameIdentityToken | AnonymousIdentityToken | X509IdentityToken;
25
26
 
@@ -28,7 +29,10 @@ function getUserName(userIdentityToken: AnyUserIdentityToken): string {
28
29
  return "anonymous";
29
30
  }
30
31
  if (userIdentityToken instanceof X509IdentityToken) {
31
- const certInfo: CertificateInternals = exploreCertificate(userIdentityToken.certificateData);
32
+ const cert = Array.isArray(userIdentityToken.certificateData)
33
+ ? userIdentityToken.certificateData[0]
34
+ : userIdentityToken.certificateData;
35
+ const certInfo: CertificateInternals = exploreCertificate(cert);
32
36
  const userName = certInfo.tbsCertificate.subject.commonName || "";
33
37
  if (typeof userName !== "string") {
34
38
  throw new Error("Invalid username");
@@ -39,8 +43,7 @@ function getUserName(userIdentityToken: AnyUserIdentityToken): string {
39
43
  if (userIdentityToken.policyId === "anonymous") {
40
44
  return "anonymous";
41
45
  }
42
- assert(Object.prototype.hasOwnProperty.call(userIdentityToken, "userName"));
43
- return userIdentityToken.userName!;
46
+ return typeof userIdentityToken.userName === "string" ? userIdentityToken.userName : "";
44
47
  }
45
48
  throw new Error("Invalid user identity token");
46
49
  }
@@ -48,7 +51,6 @@ function getUserName(userIdentityToken: AnyUserIdentityToken): string {
48
51
  /**
49
52
  *
50
53
  */
51
-
52
54
  export enum WellKnownRoles {
53
55
  Anonymous = ObjectIds.WellKnownRole_Anonymous,
54
56
  AuthenticatedUser = ObjectIds.WellKnownRole_AuthenticatedUser,
@@ -128,9 +130,12 @@ function getPermissionForRole(rolePermissions: RolePermissionType[] | null, role
128
130
  return allPermissions;
129
131
  }
130
132
  const a = rolePermissions.find((r) => {
131
- return sameNodeId(resolveNodeId(r.roleId!), role);
133
+ if (!r.roleId) {
134
+ return false;
135
+ }
136
+ return sameNodeId(resolveNodeId(r.roleId), role);
132
137
  });
133
- return a !== undefined ? a.permissions! | PermissionFlag.None : PermissionFlag.None;
138
+ return a?.permissions !== undefined ? a.permissions | PermissionFlag.None : PermissionFlag.None;
134
139
  }
135
140
 
136
141
  function isDefaultContext(context: SessionContext) {
@@ -152,7 +157,7 @@ function getAccessRestrictionsOnNamespace(namespace: NamespacePrivate, context:
152
157
  const defaultAccessRestriction = namespaceObject.getChildByName("defaultAccessRestriction");
153
158
  if (defaultAccessRestriction) {
154
159
  const dataValue = defaultAccessRestriction.readAttribute(null, AttributeIds.Value);
155
- if (dataValue && dataValue.statusCode.isGood()) {
160
+ if (dataValue?.statusCode.isGood()) {
156
161
  return dataValue.value.value as AccessRestrictionsFlag;
157
162
  }
158
163
  }
@@ -179,14 +184,14 @@ function getDefaultUserRolePermissionsOnNamespace(
179
184
  const defaultUserRolePermissions = uaNamespaceObject.getChildByName("DefaultUserRolePermissions") as UAVariable;
180
185
  if (defaultUserRolePermissions) {
181
186
  const dataValue = defaultUserRolePermissions.readValue();
182
- if (dataValue && dataValue.statusCode.isGood() && dataValue.value.value && dataValue.value.value.length > 0) {
187
+ if (dataValue?.statusCode.isGood() && dataValue.value.value && dataValue.value.value.length > 0) {
183
188
  return dataValue.value.value as RolePermissionType[];
184
189
  }
185
190
  }
186
191
  const defaultRolePermissions = uaNamespaceObject.getChildByName("DefaultRolePermissions") as UAVariable;
187
192
  if (defaultRolePermissions) {
188
193
  const dataValue = defaultRolePermissions.readValue();
189
- if (dataValue && dataValue.statusCode.isGood()) {
194
+ if (dataValue?.statusCode.isGood()) {
190
195
  return dataValue.value.value as RolePermissionType[] | null;
191
196
  }
192
197
  }
@@ -198,14 +203,14 @@ export function makeRoles(roleIds: NodeIdLike[] | string | WellKnownRoles): Node
198
203
  roleIds = [roleIds];
199
204
  }
200
205
  if (typeof roleIds === "string") {
201
- roleIds = roleIds.split(";").map((r) => resolveNodeId("WellKnownRole_" + r));
206
+ roleIds = roleIds.split(";").map((r) => resolveNodeId(`WellKnownRole_${r}`));
202
207
  }
203
208
  return roleIds.map((r) => resolveNodeId(r));
204
209
  }
205
210
  export class SessionContext implements ISessionContext {
206
211
  public static defaultContext = new SessionContext({});
207
212
 
208
- public object: any;
213
+ public object: UAObject | UAObjectType | undefined;
209
214
  public currentTime?: PreciseClock;
210
215
  public continuationPoints: Buffer[] = [];
211
216
  public userIdentity?: string;
@@ -355,7 +360,9 @@ export class SessionContext implements ISessionContext {
355
360
  return true;
356
361
  }
357
362
  }
358
- if (!this.session) { return false; }
363
+ if (!this.session) {
364
+ return false;
365
+ }
359
366
  const securityMode = this.session?.channel?.securityMode;
360
367
  if (accessRestrictions & AccessRestrictionsFlag.SigningRequired) {
361
368
  if (securityMode !== MessageSecurityMode.Sign && securityMode !== MessageSecurityMode.SignAndEncrypt) {