opcjs-base 0.1.13 → 0.1.16-alpha

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/index.d.cts CHANGED
@@ -154,6 +154,38 @@ declare class ExpandedNodeId extends NodeId {
154
154
  toString(): string;
155
155
  }
156
156
 
157
+ /**
158
+ * Enumeration of variant types based on BuiltinType NodeIds.
159
+ */
160
+ declare enum BuiltInType {
161
+ Null = 0,
162
+ Boolean = 1,
163
+ SByte = 2,
164
+ Byte = 3,
165
+ Int16 = 4,
166
+ UInt16 = 5,
167
+ Int32 = 6,
168
+ UInt32 = 7,
169
+ Int64 = 8,
170
+ UInt64 = 9,
171
+ Float = 10,
172
+ Double = 11,
173
+ String = 12,
174
+ DateTime = 13,
175
+ Guid = 14,
176
+ ByteString = 15,
177
+ XmlElement = 16,
178
+ NodeId = 17,
179
+ ExpandedNodeId = 18,
180
+ StatusCode = 19,
181
+ QualifiedName = 20,
182
+ LocalizedText = 21,
183
+ ExtensionObject = 22,
184
+ DataValue = 23,
185
+ Variant = 24,
186
+ DiagnosticInfo = 25
187
+ }
188
+
157
189
  /**
158
190
  * OPC UA StatusCode Type (i=19)
159
191
  *
@@ -163,6 +195,7 @@ declare class ExpandedNodeId extends NodeId {
163
195
  * @see OPC UA Part 4, Section 7.34
164
196
  * @see OPC UA Part 6, Section 5.1.1
165
197
  */
198
+
166
199
  declare enum StatusCode {
167
200
  Good,
168
201
  Uncertain,
@@ -717,26 +750,6 @@ declare class XmlElement {
717
750
  * @returns The number of characters
718
751
  */
719
752
  get length(): number;
720
- /**
721
- * Validate if this XmlElement contains valid XML
722
- *
723
- * Note: This is a simple check, not a full XML validator.
724
- * For production use, consider using a proper XML parser.
725
- *
726
- * @returns true if the string appears to be valid XML
727
- *
728
- * @example
729
- * ```typescript
730
- * const xml = new XmlElement("<root></root>");
731
- * xml.isValid(); // true
732
- * ```
733
- */
734
- isValid(): boolean;
735
- /**
736
- * Basic XML structure validation (for Node.js environment)
737
- * Checks for matching opening and closing tags
738
- */
739
- private static checkBasicXmlStructure;
740
753
  /**
741
754
  * Escape special XML characters in text content
742
755
  *
@@ -925,6 +938,95 @@ declare class DiagnosticInfo {
925
938
  toString(includeInner?: boolean): string;
926
939
  }
927
940
 
941
+ /**
942
+ * OPC UA Primitive Type Mappings
943
+ *
944
+ * We try to use the JS built in types wherever we can. But sometimes, often in the context
945
+ * where Variant is involved, we need to have a wrapper type that includes the BuiltInType
946
+ * for type checking and encoding purposes. In those cases, we define a wrapper type with a
947
+ * value and a type field. For simple cases like boolean, we can just use the native boolean
948
+ * type directly as UaBoolean.
949
+ * @module primitives
950
+ */
951
+
952
+ type UaBoolean = boolean;
953
+ /**
954
+ * OPC UA Builtin Type Numeric IDs
955
+ *
956
+ * These correspond to the NodeId numeric identifiers defined in OPC UA Part 6, Table 1.
957
+ */
958
+ type UaSbyte = {
959
+ value: number;
960
+ readonly type: BuiltInType.SByte;
961
+ };
962
+ declare const uaSbyte: (value: number) => UaSbyte;
963
+ type UaByte = {
964
+ value: number;
965
+ readonly type: BuiltInType.Byte;
966
+ };
967
+ declare const uaByte: (value: number) => UaByte;
968
+ type UaInt16 = {
969
+ value: number;
970
+ readonly type: BuiltInType.Int16;
971
+ };
972
+ declare const uaInt16: (value: number) => UaInt16;
973
+ type UaUint16 = {
974
+ value: number;
975
+ readonly type: BuiltInType.UInt16;
976
+ };
977
+ declare const uaUint16: (value: number) => UaUint16;
978
+ type UaInt32 = {
979
+ value: number;
980
+ readonly type: BuiltInType.Int32;
981
+ };
982
+ declare const uaInt32: (value: number) => UaInt32;
983
+ type UaUint32 = {
984
+ value: number;
985
+ readonly type: BuiltInType.UInt32;
986
+ };
987
+ declare const uaUint32: (value: number) => UaUint32;
988
+ type UaInt64 = {
989
+ value: bigint;
990
+ readonly type: BuiltInType.Int64;
991
+ };
992
+ declare const uaInt64: (value: bigint) => UaInt64;
993
+ type UaUint64 = {
994
+ value: bigint;
995
+ readonly type: BuiltInType.UInt64;
996
+ };
997
+ declare const uaUint64: (value: bigint) => UaUint64;
998
+ type UaFloat = {
999
+ value: number;
1000
+ readonly type: BuiltInType.Float;
1001
+ };
1002
+ declare const uaFloat: (value: number) => UaFloat;
1003
+ type UaDouble = {
1004
+ value: number;
1005
+ readonly type: BuiltInType.Double;
1006
+ };
1007
+ declare const uaDouble: (value: number) => UaDouble;
1008
+ /**
1009
+ * OPC UA String primitive type.
1010
+ *
1011
+ * A String in OPC UA can be null (encoded as length -1 in binary).
1012
+ * Using `string | null` instead of `string | undefined` aligns with the
1013
+ * OPC UA specification where null is an explicit, valid value distinct
1014
+ * from an empty string. Same is true for ByteString which can be null (length -1)
1015
+ * or a Uint8Array.
1016
+ */
1017
+ type UaString = string | null;
1018
+ type UaByteString = Uint8Array | null;
1019
+ type UaGuid = {
1020
+ value: string;
1021
+ readonly type: BuiltInType.Guid;
1022
+ };
1023
+ declare const uaGuid: (value: string) => UaGuid;
1024
+ type UaDateTime = Date;
1025
+ /**
1026
+ * Union of all OPC UA primitive types accepted by {@link Variant.newFrom}.
1027
+ */
1028
+ type UaPrimitive = UaBoolean | UaSbyte | UaByte | UaInt16 | UaUint16 | UaInt32 | UaUint32 | UaInt64 | UaUint64 | UaFloat | UaDouble | UaString | UaDateTime | UaGuid | UaByteString;
1029
+
928
1030
  /**
929
1031
  * OPC UA Variant Type (i=24)
930
1032
  *
@@ -934,41 +1036,10 @@ declare class DiagnosticInfo {
934
1036
  * @see OPC UA Part 6, Section 5.1.2
935
1037
  */
936
1038
 
937
- /**
938
- * Enumeration of variant types based on BuiltinType NodeIds.
939
- */
940
- declare enum VariantType {
941
- Null = 0,
942
- Boolean = 1,
943
- SByte = 2,
944
- Byte = 3,
945
- Int16 = 4,
946
- UInt16 = 5,
947
- Int32 = 6,
948
- UInt32 = 7,
949
- Int64 = 8,
950
- UInt64 = 9,
951
- Float = 10,
952
- Double = 11,
953
- String = 12,
954
- DateTime = 13,
955
- Guid = 14,
956
- ByteString = 15,
957
- XmlElement = 16,
958
- NodeId = 17,
959
- ExpandedNodeId = 18,
960
- StatusCode = 19,
961
- QualifiedName = 20,
962
- LocalizedText = 21,
963
- ExtensionObject = 22,
964
- DataValue = 23,
965
- Variant = 24,
966
- DiagnosticInfo = 25
967
- }
968
1039
  /**
969
1040
  * Type union representing all possible variant values.
970
1041
  */
971
- type VariantValue = undefined | boolean | number | bigint | string | Date | Uint8Array | NodeId | ExpandedNodeId | QualifiedName | LocalizedText | Uint8Array | XmlElement | ExtensionObject | DataValue | StatusCode | DiagnosticInfo | Variant;
1042
+ type VariantValue = null | undefined | boolean | number | bigint | string | Date | Uint8Array | NodeId | ExpandedNodeId | QualifiedName | LocalizedText | XmlElement | ExtensionObject | DataValue | StatusCode | DiagnosticInfo | Variant;
972
1043
  /**
973
1044
  * Type for variant arrays.
974
1045
  */
@@ -997,7 +1068,7 @@ declare class Variant {
997
1068
  /**
998
1069
  * The variant type identifier.
999
1070
  */
1000
- readonly variantType: VariantType;
1071
+ readonly type: BuiltInType;
1001
1072
  /**
1002
1073
  * The variant value (scalar or array).
1003
1074
  */
@@ -1008,20 +1079,6 @@ declare class Variant {
1008
1079
  * For 2D arrays, this is [rows, cols], etc.
1009
1080
  */
1010
1081
  readonly arrayDimensions: number[] | undefined;
1011
- /**
1012
- * Creates a new Variant.
1013
- *
1014
- * @param variantType - The type of value stored in the variant
1015
- * @param value - The scalar or array value
1016
- * @param arrayDimensions - Optional array dimensions for structured arrays
1017
- */
1018
- constructor(variantType?: VariantType, value?: VariantValue | VariantArrayValue, arrayDimensions?: number[] | undefined);
1019
- /**
1020
- * Creates a undefined variant.
1021
- *
1022
- * @returns A new Variant with undefined value
1023
- */
1024
- static createNull(): Variant;
1025
1082
  /**
1026
1083
  * Checks if this variant is null.
1027
1084
  *
@@ -1059,6 +1116,30 @@ declare class Variant {
1059
1116
  * @returns A string representation of the variant
1060
1117
  */
1061
1118
  toString(): string;
1119
+ /**
1120
+ * Creates a Variant from a typed OPC UA primitive value.
1121
+ *
1122
+ * Uses the `.type` discriminant on tagged primitives to determine the
1123
+ * VariantType exactly — no heuristic inference based on value ranges.
1124
+ *
1125
+ * @param value - A typed OPC UA primitive value.
1126
+ * @returns A new Variant wrapping the inner value with the correct VariantType.
1127
+ */
1128
+ static newFrom<T extends UaPrimitive>(value: T): Variant;
1129
+ /**
1130
+ * Creates a undefined variant.
1131
+ *
1132
+ * @returns A new Variant with undefined value
1133
+ */
1134
+ static newNull(): Variant;
1135
+ /**
1136
+ * Creates a new Variant.
1137
+ *
1138
+ * @param variantType - The type of value stored in the variant
1139
+ * @param value - The scalar or array value
1140
+ * @param arrayDimensions - Optional array dimensions for structured arrays
1141
+ */
1142
+ constructor(variantType?: BuiltInType, value?: VariantValue | VariantArrayValue, arrayDimensions?: number[] | undefined);
1062
1143
  }
1063
1144
 
1064
1145
  /**
@@ -1192,130 +1273,12 @@ declare class Decoder {
1192
1273
  private encodingIdMap;
1193
1274
  registerReaderFactory(writerId: string, factory: (data: unknown) => IReader): void;
1194
1275
  registerEncodingId(encodingId: number, writerId: string, typeId: number): void;
1195
- registerType<T>(typeId: number, decoder: (decoder: IReader) => unknown): void;
1276
+ registerType(typeId: number, decoder: (decoder: IReader) => unknown): void;
1196
1277
  decode<T extends IOpcType>(data: unknown, encodingType: string): T;
1197
1278
  decodeWithEncodingId<T extends IOpcType>(encodingId: number, reader: IReader): T;
1198
1279
  decodeWithTypeId<T extends IOpcType>(typeId: number, reader: IReader): T;
1199
1280
  }
1200
1281
 
1201
- /**
1202
- * OPC UA Primitive Type Mappings
1203
- *
1204
- * Defines TypeScript type mappings for OPC UA primitive types.
1205
- * Primitives map directly to native TypeScript types without wrapper classes.
1206
- *
1207
- * @module primitives
1208
- */
1209
- /**
1210
- * OPC UA Builtin Type Numeric IDs
1211
- *
1212
- * These correspond to the NodeId numeric identifiers defined in OPC UA Part 6, Table 1.
1213
- */
1214
- declare const BuiltinTypeId: {
1215
- readonly Boolean: 1;
1216
- readonly SByte: 2;
1217
- readonly Byte: 3;
1218
- readonly Int16: 4;
1219
- readonly UInt16: 5;
1220
- readonly Int32: 6;
1221
- readonly UInt32: 7;
1222
- readonly Int64: 8;
1223
- readonly UInt64: 9;
1224
- readonly Float: 10;
1225
- readonly Double: 11;
1226
- readonly String: 12;
1227
- readonly DateTime: 13;
1228
- readonly Guid: 14;
1229
- readonly ByteString: 15;
1230
- readonly XmlElement: 16;
1231
- readonly NodeId: 17;
1232
- readonly ExpandedNodeId: 18;
1233
- readonly StatusCode: 19;
1234
- readonly QualifiedName: 20;
1235
- readonly LocalizedText: 21;
1236
- readonly ExtensionObject: 22;
1237
- readonly DataValue: 23;
1238
- readonly Variant: 24;
1239
- readonly DiagnosticInfo: 25;
1240
- };
1241
- /**
1242
- * Type representing any builtin type ID
1243
- */
1244
- type BuiltinTypeIdValue = typeof BuiltinTypeId[keyof typeof BuiltinTypeId];
1245
- /**
1246
- * OPC UA String primitive type.
1247
- *
1248
- * A String in OPC UA can be null (encoded as length -1 in binary).
1249
- * Using `string | null` instead of `string | undefined` aligns with the
1250
- * OPC UA specification where null is an explicit, valid value distinct
1251
- * from an empty string.
1252
- */
1253
- type UaString = string | null;
1254
- /**
1255
- * OPC UA ByteString primitive type.
1256
- *
1257
- * A ByteString in OPC UA can be null (encoded as length -1 in binary).
1258
- * Using `Uint8Array | null` instead of `Uint8Array | undefined` aligns
1259
- * with the OPC UA specification where null is an explicit, valid value
1260
- * distinct from an empty byte array.
1261
- */
1262
- type UaByteString = Uint8Array | null;
1263
- /**
1264
- * Primitive type mappings: OPC UA type → TypeScript type
1265
- *
1266
- * Primitives use native TypeScript types directly:
1267
- * - Boolean → boolean
1268
- * - All numeric types → number (TypeScript doesn't distinguish integer types)
1269
- * - String → string
1270
- * - DateTime → Date
1271
- * - Guid → string (UUID format)
1272
- */
1273
- type PrimitiveTypeMap = {
1274
- [BuiltinTypeId.Boolean]: boolean;
1275
- [BuiltinTypeId.SByte]: number;
1276
- [BuiltinTypeId.Byte]: number;
1277
- [BuiltinTypeId.Int16]: number;
1278
- [BuiltinTypeId.UInt16]: number;
1279
- [BuiltinTypeId.Int32]: number;
1280
- [BuiltinTypeId.UInt32]: number;
1281
- [BuiltinTypeId.Int64]: bigint;
1282
- [BuiltinTypeId.UInt64]: bigint;
1283
- [BuiltinTypeId.Float]: number;
1284
- [BuiltinTypeId.Double]: number;
1285
- [BuiltinTypeId.String]: UaString;
1286
- [BuiltinTypeId.DateTime]: Date;
1287
- [BuiltinTypeId.Guid]: string;
1288
- [BuiltinTypeId.ByteString]: UaByteString;
1289
- };
1290
- /**
1291
- * Get the TypeScript type name for a primitive builtin type
1292
- *
1293
- * @param typeId - The numeric builtin type ID
1294
- * @returns The TypeScript type name as a string, or undefined if not a primitive
1295
- *
1296
- * @example
1297
- * ```typescript
1298
- * getPrimitiveTypeName(1); // "boolean"
1299
- * getPrimitiveTypeName(6); // "number"
1300
- * getPrimitiveTypeName(12); // "string"
1301
- * getPrimitiveTypeName(17); // undefined (NodeId is complex, not primitive)
1302
- * ```
1303
- */
1304
- declare function getPrimitiveTypeName(typeId: number): string | undefined;
1305
- /**
1306
- * Check if a builtin type ID represents a primitive type
1307
- *
1308
- * @param typeId - The numeric builtin type ID
1309
- * @returns true if the type is primitive, false otherwise
1310
- *
1311
- * @example
1312
- * ```typescript
1313
- * isPrimitive(1); // true (Boolean)
1314
- * isPrimitive(17); // false (NodeId is complex)
1315
- * ```
1316
- */
1317
- declare function isPrimitive(typeId: number): boolean;
1318
-
1319
1282
  /**
1320
1283
  * @fileoverview Decoder interface for OPC UA data decoding
1321
1284
  * @module codec/interfaces/decoder
@@ -1401,7 +1364,7 @@ interface IReader {
1401
1364
  * Binary: Int32 length prefix + UTF-8 bytes (-1 indicates null)
1402
1365
  * @returns The string value, or null if the length prefix is -1 (OPC UA null)
1403
1366
  */
1404
- readString(): UaString;
1367
+ readString(): string | null;
1405
1368
  /**
1406
1369
  * Decode a DateTime value.
1407
1370
  * Binary: Int64 representing 100-nanosecond intervals since January 1, 1601 UTC
@@ -1488,7 +1451,7 @@ declare class Encoder {
1488
1451
  private encoders;
1489
1452
  private writerFactories;
1490
1453
  registerWriterFactory(writerId: string, factory: () => IWriter): void;
1491
- registerType<T>(typeId: number, encoder: (encoder: IWriter, value: any) => void): void;
1454
+ registerType(typeId: number, encoder: (encoder: IWriter, value: unknown) => void): void;
1492
1455
  encode<T extends IOpcType>(value: T, encodingType: string): unknown;
1493
1456
  encodeWithoutId<T extends IOpcType>(value: T, encodingType: string): unknown;
1494
1457
  }
@@ -1579,7 +1542,7 @@ interface IWriter {
1579
1542
  * Binary: Int32 length prefix + UTF-8 bytes
1580
1543
  * @param value The string value; null or undefined is encoded as length -1 (OPC UA null)
1581
1544
  */
1582
- writeString(value: UaString): void;
1545
+ writeString(value: string | null): void;
1583
1546
  /**
1584
1547
  * Encode a DateTime value.
1585
1548
  * Binary: Int64 representing 100-nanosecond intervals since January 1, 1601 UTC
@@ -1603,7 +1566,7 @@ interface IWriter {
1603
1566
  * Binary: Int32 length prefix + UTF-8 encoded XML
1604
1567
  * @param value The XML string (undefined encoded as length -1)
1605
1568
  */
1606
- writeXmlElement(value: string): void;
1569
+ writeXmlElement(value: XmlElement | string): void;
1607
1570
  /**
1608
1571
  * Encode an array with Int32 length prefix.
1609
1572
  * Binary: Int32 length where -1=undefined, 0=empty, positive=count
@@ -1696,7 +1659,7 @@ declare class BinaryReader implements IReader {
1696
1659
  readUInt64(): bigint;
1697
1660
  readFloat(): number;
1698
1661
  readDouble(): number;
1699
- readString(): UaString;
1662
+ readString(): string | null;
1700
1663
  readDateTime(): Date;
1701
1664
  readGuid(): string;
1702
1665
  readByteString(): Uint8Array | null;
@@ -1758,11 +1721,6 @@ declare class BinaryReader implements IReader {
1758
1721
  * @see OPC 10000-6 Table 24
1759
1722
  */
1760
1723
  readDiagnosticInfo(): DiagnosticInfo;
1761
- /**
1762
- * Decode a NodeId with optional flag masking (used internally by readExpandedNodeId).
1763
- */
1764
- private readNodeIdWithMask;
1765
- private readVariantValue;
1766
1724
  getPosition(): number;
1767
1725
  /**
1768
1726
  * Read all remaining bytes from the current position to the end of the buffer.
@@ -1830,11 +1788,11 @@ declare class BinaryWriter implements IWriter {
1830
1788
  writeUInt64(value: bigint): void;
1831
1789
  writeFloat(value: number): void;
1832
1790
  writeDouble(value: number): void;
1833
- writeString(value: UaString): void;
1791
+ writeString(value: string | null): void;
1834
1792
  writeDateTime(value: Date): void;
1835
1793
  writeGuid(value: string): void;
1836
1794
  writeByteString(value: Uint8Array | null | undefined): void;
1837
- writeXmlElement(value: string): void;
1795
+ writeXmlElement(value: XmlElement | string): void;
1838
1796
  /**
1839
1797
  * Write an array with Int32 length prefix.
1840
1798
  * Per FR-011: -1 = null, 0 = empty, positive = element count
@@ -1892,18 +1850,87 @@ declare class BinaryWriter implements IWriter {
1892
1850
  * @see OPC 10000-6 Table 24
1893
1851
  */
1894
1852
  writeDiagnosticInfo(value: DiagnosticInfo): void;
1895
- private writeVariantValue;
1896
1853
  constructor(initialSize?: number);
1897
1854
  }
1898
1855
 
1899
- declare abstract class Configuration {
1900
- applicationName: string;
1901
- applicationUri: string;
1902
- productName: string;
1903
- productUri: string;
1904
- encoder: Encoder;
1905
- decoder: Decoder;
1906
- constructor(applicationName: string, applicationUri: string, productName: string, productUri: string, encoder: Encoder, decoder: Decoder);
1856
+ interface IEncryptionAlgorithm {
1857
+ IsAuthenticated(): boolean;
1858
+ GetMaxPayload(maxCipherTextSize: number): number;
1859
+ GetEncryptedSize(dataSize: number): number;
1860
+ GetPadding(bytesToWrite: number): Uint8Array;
1861
+ HasPadding(): boolean;
1862
+ Encrypt(cleartext: Uint8Array): Uint8Array;
1863
+ Decrypt(ciphertext: Uint8Array): Uint8Array;
1864
+ CalculateSignature(message: Uint8Array): Uint8Array;
1865
+ VerifySignature(message: Uint8Array, signature: Uint8Array): boolean;
1866
+ GetSignatureLength(): number;
1867
+ SignatureUri(): string;
1868
+ }
1869
+
1870
+ type MsgType = number;
1871
+
1872
+ declare class MsgHeader$1 {
1873
+ msgType: MsgType;
1874
+ messageSize: number;
1875
+ secureChannelId: number;
1876
+ static Size: number;
1877
+ static decode(buffer: BinaryReader): MsgHeader$1;
1878
+ encode(buffer: BinaryWriter): void;
1879
+ constructor(msgType: MsgType, messageSize: number, secureChannelId: number);
1880
+ }
1881
+
1882
+ declare class MsgSequenceHeader {
1883
+ sequenceNumber: number;
1884
+ requestId: number;
1885
+ static Size: number;
1886
+ static decode(buffer: BinaryReader): MsgSequenceHeader;
1887
+ encode(buffer: BinaryWriter): void;
1888
+ constructor(sequenceNumber: number, requestId: number);
1889
+ }
1890
+
1891
+ declare abstract class MsgBase$1 {
1892
+ header: MsgHeader$1;
1893
+ sequenceHeader: MsgSequenceHeader;
1894
+ body: unknown;
1895
+ static DecryptAndVerify(data: Uint8Array, encryptionAlgorithm: IEncryptionAlgorithm, headerLength: number): Uint8Array;
1896
+ protected Encrypt(buffer: BinaryWriter, encryptionAlgorithm: IEncryptionAlgorithm, headerSize: number, paddingPosition: number): Uint8Array;
1897
+ abstract encode(buffer: BinaryWriter, encryptionAlgorithm: IEncryptionAlgorithm): void;
1898
+ constructor(header: MsgHeader$1, sequenceHeader: MsgSequenceHeader, body: unknown);
1899
+ }
1900
+
1901
+ /**
1902
+ * TransformStream that binary-encodes each {@link IOpcType} chunk into a
1903
+ * {@link Uint8Array} using the supplied {@link Encoder}.
1904
+ *
1905
+ * Use this to separate the OPC UA service-encoding step from the secure-channel
1906
+ * framing step, keeping each stage composable:
1907
+ *
1908
+ * ```ts
1909
+ * requestStream
1910
+ * .pipeThrough(new SecureChannelTypeEncoder(config.encoder))
1911
+ * .pipeThrough(new SecureChannelFramingTransform(context))
1912
+ * .pipeTo(wsSendable);
1913
+ * ```
1914
+ */
1915
+ declare class SecureChannelTypeEncoder extends TransformStream<MsgBase$1, MsgBase$1> {
1916
+ constructor(encoder: Encoder);
1917
+ }
1918
+
1919
+ /**
1920
+ * TransformStream that binary-decodes each raw-body {@link Uint8Array} into
1921
+ * the corresponding {@link IOpcType} using the supplied {@link Decoder}.
1922
+ *
1923
+ * Use this to separate the OPC UA service-decoding step from the secure-channel
1924
+ * framing step, keeping each stage composable:
1925
+ *
1926
+ * ```ts
1927
+ * bodyBytesReadable
1928
+ * .pipeThrough(new BinaryDecoderTransform(config.decoder))
1929
+ * .pipeTo(responseHandler.writable);
1930
+ * ```
1931
+ */
1932
+ declare class SecureChannelTypeDecoder extends TransformStream<MsgBase$1, MsgBase$1> {
1933
+ constructor(decoder: Decoder);
1907
1934
  }
1908
1935
 
1909
1936
  /**
@@ -1912,7 +1939,7 @@ declare abstract class Configuration {
1912
1939
  * This file was automatically generated from OPC UA NodeSet2 XML.
1913
1940
  *
1914
1941
  * Source: Opc.Ua.NodeSet2.Services.xml
1915
- * Generated: 2026-02-27T12:42:09.143Z
1942
+ * Generated: 2026-03-16T04:16:36.493Z
1916
1943
  * Generator: @opcua/nodeset-generator
1917
1944
  *
1918
1945
  * Any changes made to this file will be lost when regenerated.
@@ -2489,15 +2516,6 @@ declare enum UserTokenTypeEnum {
2489
2516
  IssuedToken = 3
2490
2517
  }
2491
2518
 
2492
- interface ITransportChannel {
2493
- connect(): Promise<boolean>;
2494
- disconnect(): void;
2495
- send(data: Uint8Array): Promise<void>;
2496
- onMessage?: (data: Uint8Array) => void;
2497
- getEndpointUrl(): string;
2498
- getCodecType(): string;
2499
- }
2500
-
2501
2519
  interface ISecureChannel {
2502
2520
  getSecurityPolicy(): string;
2503
2521
  getSecurityMode(): MessageSecurityModeEnum;
@@ -2505,29 +2523,28 @@ interface ISecureChannel {
2505
2523
  issueServiceRequest(request: IOpcType): Promise<IOpcType>;
2506
2524
  }
2507
2525
 
2508
- declare class SecureChannel implements ISecureChannel {
2509
- private channel;
2510
- private configuration;
2511
- private sequenceNumber;
2512
- private requestNumber;
2513
- private securityPolicy;
2514
- private resolvers;
2515
- private id;
2516
- private token;
2517
- private chunkBuffers;
2518
- openSecureChannelRequest(): Promise<void>;
2519
- disconnect(): Promise<void>;
2520
- getSecurityPolicy(): string;
2521
- getSecurityMode(): MessageSecurityModeEnum;
2522
- getEndpointUrl(): string;
2523
- issueServiceRequest(request: IOpcType): Promise<IOpcType>;
2524
- private onMessage;
2525
- private onReceivedMessage;
2526
- constructor(channel: ITransportChannel, configuration: Configuration);
2526
+ interface ILogger {
2527
+ trace(msg: string | (() => string), ...args: unknown[]): void;
2528
+ debug(msg: string | (() => string), ...args: unknown[]): void;
2529
+ info(msg: string | (() => string), ...args: unknown[]): void;
2530
+ warn(msg: string | (() => string), ...args: unknown[]): void;
2531
+ error(msg: string | (() => string), ...args: unknown[]): void;
2532
+ fatal(msg: string | (() => string), ...args: unknown[]): void;
2527
2533
  }
2528
2534
 
2529
- declare class ChannelFactory {
2530
- static createChannel(endpointUrl: string): ITransportChannel;
2535
+ interface ILoggerFactory {
2536
+ getLogger(category: string): ILogger;
2537
+ }
2538
+
2539
+ declare abstract class Configuration {
2540
+ applicationName: string;
2541
+ applicationUri: string;
2542
+ productName: string;
2543
+ productUri: string;
2544
+ encoder: Encoder;
2545
+ decoder: Decoder;
2546
+ loggerFactory: ILoggerFactory;
2547
+ constructor(applicationName: string, applicationUri: string, productName: string, productUri: string, encoder: Encoder, decoder: Decoder, loggerFactory: ILoggerFactory);
2531
2548
  }
2532
2549
 
2533
2550
  /**
@@ -2536,7 +2553,7 @@ declare class ChannelFactory {
2536
2553
  * This file was automatically generated from OPC UA NodeSet2 XML.
2537
2554
  *
2538
2555
  * Source: Opc.Ua.NodeSet2.Services.xml
2539
- * Generated: 2026-02-27T12:42:09.143Z
2556
+ * Generated: 2026-03-16T04:16:36.493Z
2540
2557
  * Generator: @opcua/nodeset-generator
2541
2558
  *
2542
2559
  * Any changes made to this file will be lost when regenerated.
@@ -2550,7 +2567,7 @@ declare function registerEncoders(encoder: Encoder): void;
2550
2567
  * This file was automatically generated from OPC UA NodeSet2 XML.
2551
2568
  *
2552
2569
  * Source: Opc.Ua.NodeSet2.Services.xml
2553
- * Generated: 2026-02-27T12:42:09.143Z
2570
+ * Generated: 2026-03-16T04:16:36.493Z
2554
2571
  * Generator: @opcua/nodeset-generator
2555
2572
  *
2556
2573
  * Any changes made to this file will be lost when regenerated.
@@ -2567,7 +2584,7 @@ declare function registerXmlDecoders(decoder: Decoder): void;
2567
2584
  * This file was automatically generated from OPC UA NodeSet2 XML.
2568
2585
  *
2569
2586
  * Source: Opc.Ua.NodeSet2.Services.xml
2570
- * Generated: 2026-02-27T12:42:09.143Z
2587
+ * Generated: 2026-03-16T04:16:36.493Z
2571
2588
  * Generator: @opcua/nodeset-generator
2572
2589
  *
2573
2590
  * Any changes made to this file will be lost when regenerated.
@@ -4438,7 +4455,7 @@ declare class ReferenceListEntryDataType extends Structure implements IOpcType {
4438
4455
  * NodeId: i=19361
4439
4456
  * Extends: Structure
4440
4457
  */
4441
- declare class LogRecord extends Structure implements IOpcType {
4458
+ declare class LogRecord$1 extends Structure implements IOpcType {
4442
4459
  time: Date;
4443
4460
  severity: number;
4444
4461
  eventType?: NodeId | null;
@@ -4458,7 +4475,7 @@ declare class LogRecord extends Structure implements IOpcType {
4458
4475
  * Extends: Structure
4459
4476
  */
4460
4477
  declare class LogRecordsDataType extends Structure implements IOpcType {
4461
- logRecordArray: LogRecord[];
4478
+ logRecordArray: LogRecord$1[];
4462
4479
  getTypeId(): number;
4463
4480
  getBinaryEncodingId(): number;
4464
4481
  getXmlEncodingId(): number;
@@ -7897,4 +7914,285 @@ declare class Annotation extends Structure implements IOpcType {
7897
7914
  getJsonEncodingId(): number;
7898
7915
  }
7899
7916
 
7900
- export { ActionMethodDataType, ActionStateEnum, ActionTargetDataType, ActivateSessionRequest, ActivateSessionResponse, AddNodesItem, AddNodesRequest, AddNodesResponse, AddNodesResult, AddReferencesItem, AddReferencesRequest, AddReferencesResponse, AdditionalParametersType, AggregateConfiguration, AggregateFilter, AggregateFilterResult, AliasNameDataType, Annotation, AnnotationDataType, AnonymousIdentityToken, ApplicationConfigurationDataType, ApplicationDescription, ApplicationIdentityDataType, ApplicationTypeEnum, Argument, AttributeOperand, AuthorizationServiceConfigurationDataType, AxisInformation, AxisScaleEnumerationEnum, BaseConfigurationDataType, BaseConfigurationRecordDataType, BinaryReader, BinaryWriter, BitFieldDefinition, BrokerConnectionTransportDataType, BrokerDataSetReaderTransportDataType, BrokerDataSetWriterTransportDataType, BrokerTransportQualityOfServiceEnum, BrokerWriterGroupTransportDataType, BrowseDescription, BrowseDirectionEnum, BrowseNextRequest, BrowseNextResponse, BrowsePath, BrowsePathResult, BrowsePathTarget, BrowseRequest, BrowseResponse, BrowseResult, BrowseResultMaskEnum, BuildInfo, BuiltinTypeId, type BuiltinTypeIdValue, CallMethodRequest, CallMethodResult, CallRequest, CallResponse, CancelRequest, CancelResponse, CartesianCoordinates, CertificateGroupDataType, ChannelFactory, ChannelSecurityToken, ChassisIdSubtypeEnum, CloseSecureChannelRequest, CloseSecureChannelResponse, CloseSessionRequest, CloseSessionResponse, ComplexNumberType, Configuration, ConfigurationUpdateTargetType, ConfigurationUpdateTypeEnum, ConfigurationVersionDataType, ConnectionTransportDataType, ContentFilter, ContentFilterElement, ContentFilterElementResult, ContentFilterResult, ConversionLimitEnumEnum, CreateMonitoredItemsRequest, CreateMonitoredItemsResponse, CreateSessionRequest, CreateSessionResponse, CreateSubscriptionRequest, CreateSubscriptionResponse, CurrencyUnitType, DataChangeFilter, DataChangeNotification, DataChangeTriggerEnum, DataSetMetaDataType, DataSetOrderingTypeEnum, DataSetReaderDataType, DataSetReaderMessageDataType, DataSetReaderTransportDataType, DataSetWriterDataType, DataSetWriterMessageDataType, DataSetWriterTransportDataType, DataTypeAttributes, DataTypeDefinition, DataTypeDescription, DataTypeNode, DataTypeSchemaHeader, DataValue, DatagramConnectionTransport2DataType, DatagramConnectionTransportDataType, DatagramDataSetReaderTransportDataType, DatagramWriterGroupTransport2DataType, DatagramWriterGroupTransportDataType, DeadbandTypeEnum, DecimalDataType, Decoder, DeleteAtTimeDetails, DeleteEventDetails, DeleteMonitoredItemsRequest, DeleteMonitoredItemsResponse, DeleteNodesItem, DeleteNodesRequest, DeleteNodesResponse, DeleteRawModifiedDetails, DeleteReferencesItem, DeleteReferencesRequest, DeleteReferencesResponse, DeleteSubscriptionsRequest, DeleteSubscriptionsResponse, DiagnosticInfo, DiagnosticsLevelEnum, DiscoveryConfiguration, DoubleComplexNumberType, DtlsPubSubConnectionDataType, DuplexEnum, EUInformation, ElementOperand, Encoder, EndpointConfiguration, EndpointDataType, EndpointDescription, EndpointType, EndpointUrlListDataType, EnumDefinition, EnumDescription, EnumField, EnumValueType, EphemeralKeyType, EventFieldList, EventFilter, EventFilterResult, EventNotificationList, ExceptionDeviationFormatEnum, ExpandedNodeId, ExtensionObject, FieldMetaData, FieldTargetDataType, FilterOperand, FilterOperatorEnum, FindServersOnNetworkRequest, FindServersOnNetworkResponse, FindServersRequest, FindServersResponse, Frame, GenericAttributeValue, GenericAttributes, GetEndpointsRequest, GetEndpointsResponse, HistoryData, HistoryEvent, HistoryEventFieldList, HistoryModifiedData, HistoryModifiedEvent, HistoryReadDetails, HistoryReadRequest, HistoryReadResponse, HistoryReadResult, HistoryReadValueId, HistoryUpdateDetails, HistoryUpdateRequest, HistoryUpdateResponse, HistoryUpdateResult, HistoryUpdateTypeEnum, type IOpcType, type IReader, type ISecureChannel, type IWriter, IdTypeEnum, IdentityCriteriaTypeEnum, IdentityMappingRuleType, InstanceNode, InterfaceAdminStatusEnum, InterfaceOperStatusEnum, IssuedIdentityToken, JsonActionMetaDataMessage, JsonActionNetworkMessage, JsonActionRequestMessage, JsonActionResponderMessage, JsonActionResponseMessage, JsonApplicationDescriptionMessage, JsonDataSetMessage, JsonDataSetMetaDataMessage, JsonDataSetReaderMessageDataType, JsonDataSetWriterMessageDataType, JsonNetworkMessage, JsonPubSubConnectionMessage, JsonServerEndpointsMessage, JsonStatusMessage, JsonWriterGroupMessageDataType, KeyValuePair, LinearConversionDataType, LiteralOperand, LldpManagementAddressTxPortType, LldpManagementAddressType, LldpTlvType, LocalizedText, LogRecord, LogRecordsDataType, ManAddrIfSubtypeEnum, MdnsDiscoveryConfiguration, MessageSecurityModeEnum, MethodAttributes, MethodNode, ModelChangeStructureDataType, ModelChangeStructureVerbMaskEnum, ModificationInfo, ModifyMonitoredItemsRequest, ModifyMonitoredItemsResponse, ModifySubscriptionRequest, ModifySubscriptionResponse, MonitoredItemCreateRequest, MonitoredItemCreateResult, MonitoredItemModifyRequest, MonitoredItemModifyResult, MonitoredItemNotification, MonitoringFilter, MonitoringFilterResult, MonitoringModeEnum, MonitoringParameters, NameValuePair, NamingRuleTypeEnum, NegotiationStatusEnum, NetworkAddressDataType, NetworkAddressUrlDataType, NetworkGroupDataType, Node, NodeAttributes, NodeAttributesMaskEnum, NodeClassEnum, NodeId, NodeIdType, NodeReference, NodeTypeDescription, NotificationData, NotificationMessage, ObjectAttributes, ObjectNode, ObjectTypeAttributes, ObjectTypeNode, OpenFileModeEnum, OpenSecureChannelRequest, OpenSecureChannelResponse, OptionSet, Orientation, OverrideValueHandlingEnum, ParsingResult, PerformUpdateTypeEnum, PortIdSubtypeEnum, PortableNodeId, PortableQualifiedName, type PrimitiveTypeMap, PriorityMappingEntryType, ProgramDiagnostic2DataType, ProgramDiagnosticDataType, PubSubConfiguration2DataType, PubSubConfigurationDataType, PubSubConfigurationRefDataType, PubSubConfigurationValueDataType, PubSubConnectionDataType, PubSubDiagnosticsCounterClassificationEnum, PubSubGroupDataType, PubSubKeyPushTargetDataType, PubSubStateEnum, PublishRequest, PublishResponse, PublishedActionDataType, PublishedActionMethodDataType, PublishedDataItemsDataType, PublishedDataSetCustomSourceDataType, PublishedDataSetDataType, PublishedDataSetSourceDataType, PublishedEventsDataType, PublishedVariableDataType, QosDataType, QualifiedName, QuantityDimension, QueryDataDescription, QueryDataSet, QueryFirstRequest, QueryFirstResponse, QueryNextRequest, QueryNextResponse, Range, RationalNumber, ReadAnnotationDataDetails, ReadAtTimeDetails, ReadEventDetails, ReadEventDetails2, ReadEventDetailsSorted, ReadProcessedDetails, ReadRawModifiedDetails, ReadRequest, ReadResponse, ReadValueId, ReaderGroupDataType, ReaderGroupMessageDataType, ReaderGroupTransportDataType, ReceiveQosDataType, ReceiveQosPriorityDataType, RedundancySupportEnum, RedundantServerDataType, RedundantServerModeEnum, ReferenceDescription, ReferenceDescriptionDataType, ReferenceListEntryDataType, ReferenceNode, ReferenceTypeAttributes, ReferenceTypeNode, RegisterNodesRequest, RegisterNodesResponse, RegisterServer2Request, RegisterServer2Response, RegisterServerRequest, RegisterServerResponse, RegisteredServer, RelativePath, RelativePathElement, RepublishRequest, RepublishResponse, RequestHeader, ResponseHeader, RolePermissionType, SamplingIntervalDiagnosticsDataType, SecureChannel, SecurityGroupDataType, SecuritySettingsDataType, SecurityTokenRequestTypeEnum, SemanticChangeStructureDataType, ServerDiagnosticsSummaryDataType, ServerEndpointDataType, ServerOnNetwork, ServerStateEnum, ServerStatusDataType, ServiceCertificateDataType, ServiceCounterDataType, ServiceFault, SessionDiagnosticsDataType, SessionSecurityDiagnosticsDataType, SessionlessInvokeRequestType, SessionlessInvokeResponseType, SetMonitoringModeRequest, SetMonitoringModeResponse, SetPublishingModeRequest, SetPublishingModeResponse, SetTriggeringRequest, SetTriggeringResponse, SignatureData, SignedSoftwareCertificate, SimpleAttributeOperand, SimpleTypeDescription, SortOrderTypeEnum, SortRuleElement, SpanContextDataType, StandaloneSubscribedDataSetDataType, StandaloneSubscribedDataSetRefDataType, StatusChangeNotification, StatusResult, Structure, StructureDefinition, StructureDescription, StructureField, StructureTypeEnum, SubscribedDataSetDataType, SubscribedDataSetMirrorDataType, SubscriptionAcknowledgement, SubscriptionDiagnosticsDataType, TargetVariablesDataType, TimeZoneDataType, TimestampsToReturnEnum, TraceContextDataType, TransactionErrorType, TransferResult, TransferSubscriptionsRequest, TransferSubscriptionsResponse, TranslateBrowsePathsToNodeIdsRequest, TranslateBrowsePathsToNodeIdsResponse, TransmitQosDataType, TransmitQosPriorityDataType, TrustListDataType, TrustListMasksEnum, TsnFailureCodeEnum, TsnListenerStatusEnum, TsnStreamStateEnum, TsnTalkerStatusEnum, TypeNode, UABinaryFileDataType, type UaByteString, type UaString, UadpDataSetReaderMessageDataType, UadpDataSetWriterMessageDataType, UadpWriterGroupMessageDataType, Union, UnregisterNodesRequest, UnregisterNodesResponse, UnsignedRationalNumber, UpdateDataDetails, UpdateEventDetails, UpdateStructureDataDetails, UserIdentityToken, UserManagementDataType, UserNameIdentityToken, UserTokenPolicy, UserTokenSettingsDataType, UserTokenTypeEnum, VariableAttributes, VariableNode, VariableTypeAttributes, VariableTypeNode, Variant, type VariantArrayValue, VariantType, type VariantValue, Vector, ViewAttributes, ViewDescription, ViewNode, WriteRequest, WriteResponse, WriteValue, WriterGroupDataType, WriterGroupMessageDataType, WriterGroupTransportDataType, X509IdentityToken, XVType, XmlElement, _3DCartesianCoordinates, _3DFrame, _3DOrientation, _3DVector, getPrimitiveTypeName, isPrimitive, registerBinaryDecoders, registerEncoders, registerJsonDecoders, registerTypeDecoders, registerXmlDecoders };
7917
+ type LevelName = "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR" | "FATAL" | "OFF";
7918
+
7919
+ interface LogRecord {
7920
+ time: Date;
7921
+ level: LevelName;
7922
+ levelValue: number;
7923
+ category: string;
7924
+ message: string;
7925
+ args: unknown[];
7926
+ }
7927
+
7928
+ interface ISink {
7929
+ log(record: LogRecord): void;
7930
+ }
7931
+
7932
+ interface LoggerConfig {
7933
+ defaultLevel: LevelName;
7934
+ categoryLevels?: Record<string, LevelName>;
7935
+ sink?: ISink;
7936
+ includeTimestamp?: boolean;
7937
+ }
7938
+
7939
+ declare class LoggerFactory implements ILoggerFactory {
7940
+ private config;
7941
+ private cache;
7942
+ constructor(config?: Partial<LoggerConfig>);
7943
+ getLogger(category: string): ILogger;
7944
+ setDefaultLevel(level: LevelName): void;
7945
+ setCategoryLevel(categoryOrPattern: string, level: LevelName): void;
7946
+ removeCategoryLevel(categoryOrPattern: string): void;
7947
+ setSink(sink: ISink): void;
7948
+ }
7949
+
7950
+ declare class ConsoleSink implements ISink {
7951
+ private opts;
7952
+ constructor(opts?: {
7953
+ includeTimestamp: boolean;
7954
+ });
7955
+ log(record: LogRecord): void;
7956
+ }
7957
+
7958
+ declare function getLogger(category: string): ILogger;
7959
+ declare function initLoggerProvider(provider: ILoggerFactory): void;
7960
+
7961
+ type WebSocketOptions = {
7962
+ endpoint: string;
7963
+ openTimeoutMs?: number;
7964
+ maxBufferedMessages?: number;
7965
+ };
7966
+ declare class WebSocketFascade {
7967
+ private options;
7968
+ private logger;
7969
+ private webSocket?;
7970
+ onMessageHandler: ((event: MessageEvent) => void) | null;
7971
+ onErrorHandler: ((event: Event) => void) | null;
7972
+ onCloseHandler: ((event: Event) => void) | null;
7973
+ connect(): Promise<void>;
7974
+ send(data: Uint8Array): void;
7975
+ close(): void;
7976
+ setOnMessage(handler: (event: MessageEvent) => void): void;
7977
+ setOnClose(handler: (event: Event) => void): void;
7978
+ setOnError(handler: (event: Event) => void): void;
7979
+ private describeCloseCode;
7980
+ constructor(options: WebSocketOptions);
7981
+ }
7982
+
7983
+ declare class WebSocketReadableStream extends ReadableStream<Uint8Array> {
7984
+ private readonly ws;
7985
+ private readonly maxBufferedMessages;
7986
+ private readonly logger;
7987
+ private buffer;
7988
+ private closed;
7989
+ private errored;
7990
+ private notifyPull;
7991
+ private bufferPush;
7992
+ private cleanup;
7993
+ private sourceOnPull;
7994
+ private sourceOnCancel;
7995
+ private wsOnMessage;
7996
+ constructor(ws: WebSocketFascade, maxBufferedMessages: number);
7997
+ }
7998
+
7999
+ declare class WebSocketWritableStream extends WritableStream<Uint8Array> {
8000
+ private ws;
8001
+ private logger;
8002
+ private sinkOnWrite;
8003
+ private sinkOnClose;
8004
+ private sinkOnAbort;
8005
+ constructor(ws: WebSocketFascade);
8006
+ }
8007
+
8008
+ declare class MsgHeader {
8009
+ messageType: number;
8010
+ messageSize: number;
8011
+ constructor(messageType: number, messageSize: number);
8012
+ static decode(buffer: IReader): MsgHeader;
8013
+ encode(buffer: IWriter): void;
8014
+ }
8015
+
8016
+ declare class MsgBase {
8017
+ header: MsgHeader;
8018
+ constructor(header: MsgHeader);
8019
+ }
8020
+
8021
+ declare class TcpMessageDecoupler extends TransformStream<Uint8Array, Uint8Array> {
8022
+ private onTcpMessage;
8023
+ private logger;
8024
+ private transform;
8025
+ constructor(onTcpMessage: (message: MsgBase) => void);
8026
+ }
8027
+
8028
+ declare class TcpMessageInjector extends TransformStream<Uint8Array, Uint8Array> {
8029
+ private logger;
8030
+ private controller;
8031
+ constructor();
8032
+ sendMessage(message: Uint8Array): void;
8033
+ }
8034
+
8035
+ interface ICertificate {
8036
+ getBytes(): Uint8Array;
8037
+ }
8038
+
8039
+ declare class SecurityPolicyNone {
8040
+ getSecurityMode(): MessageSecurityModeEnum;
8041
+ getSecurityPolicyUri(): string;
8042
+ getSecurityLevel(): number;
8043
+ getCertificate(): Uint8Array;
8044
+ createNonce(): Uint8Array;
8045
+ verifyNonce(nonce: Uint8Array): boolean;
8046
+ getAlgorithmSymmetric(localCertificate: ICertificate, remoteCertificate: ICertificate): IEncryptionAlgorithm;
8047
+ getAlgorithmAsymmetric(localNonce: Uint8Array, remoteNonce: Uint8Array): IEncryptionAlgorithm;
8048
+ }
8049
+
8050
+ /**
8051
+ * Shared mutable state for the OPC UA Secure Conversation layer.
8052
+ * Passed to both {@link SecureChannelReadable} and {@link SecureChannelWritable}
8053
+ * so they operate on the same channel identity and sequence counters.
8054
+ */
8055
+ declare class SecureChannelContext {
8056
+ readonly endpointUrl: string;
8057
+ sequenceNumber: number;
8058
+ requestNumber: number;
8059
+ channelId: number;
8060
+ tokenId: number;
8061
+ maxSendBufferSize: number;
8062
+ maxRecvBufferSize: number;
8063
+ chunkBuffers: Uint8Array[];
8064
+ securityAlgorithm?: IEncryptionAlgorithm;
8065
+ readonly securityPolicy: SecurityPolicyNone;
8066
+ /**
8067
+ * Atomically increments and returns the next sequence number and request id.
8068
+ * Call once per outgoing message so both counters stay in sync.
8069
+ */
8070
+ nextIds(): {
8071
+ sequenceNumber: number;
8072
+ requestId: number;
8073
+ };
8074
+ constructor(endpointUrl: string);
8075
+ }
8076
+
8077
+ declare class TcpConnectionHandler {
8078
+ private injector;
8079
+ private context;
8080
+ private connectResolve?;
8081
+ private logger;
8082
+ private buf;
8083
+ /**
8084
+ * Sends the OPC UA Hello message over `wsSendable` and waits for the server
8085
+ * Acknowledge. The WebSocket readable **must** already be piped into
8086
+ * `this.writable` before calling this method.
8087
+ *
8088
+ * @param endpointUrl The OPC UA endpoint URL (e.g. `"opc.wss://host:4840/"`).
8089
+ * @param wsSendable The writable side of the WebSocket duplex, used for
8090
+ * sending the Hello frame.
8091
+ * @returns `true` on a successful Acknowledge, `false` on a server Error.
8092
+ */
8093
+ connect(endpointUrl: string): Promise<boolean>;
8094
+ onTcpMessage(msg: MsgBase): void;
8095
+ constructor(injector: TcpMessageInjector, context: SecureChannelContext);
8096
+ }
8097
+
8098
+ /**
8099
+ * Facade for the OPC UA Secure Conversation layer.
8100
+ *
8101
+ * Owns the correlation between outgoing requests and incoming responses.
8102
+ * Wires together {@link SecureChannelMessageDecoder} (inbound) and the raw
8103
+ * WebSocket writer (outbound) so callers only need to interact with this single
8104
+ * object.
8105
+ *
8106
+ * ```ts
8107
+ * const context = new SecureChannelContext(configuration);
8108
+ * const facade = new SecureChannelFacade(context, tcpHandler.readable, wsWritable);
8109
+ *
8110
+ * await facade.openSecureChannel();
8111
+ * const response = await facade.send(readValueRequest);
8112
+ *
8113
+ * // Unsolicited server messages (e.g. Publish notifications):
8114
+ * facade.unsolicited.pipeTo(notificationHandler.writable);
8115
+ * ```
8116
+ */
8117
+ declare class SecureChannelFacade implements ISecureChannel {
8118
+ private readonly context;
8119
+ private readerTransform;
8120
+ private writerTransform;
8121
+ private readonly pending;
8122
+ private readonly logger;
8123
+ private readonly writer;
8124
+ private readonly reader;
8125
+ /**
8126
+ * Sends the OpenSecureChannel request and resolves once the server replies.
8127
+ * Updates `context.channelId` and `context.tokenId` on success.
8128
+ */
8129
+ openSecureChannel(): Promise<void>;
8130
+ getSecurityPolicy(): string;
8131
+ getSecurityMode(): MessageSecurityModeEnum;
8132
+ getEndpointUrl(): string;
8133
+ /**
8134
+ * Sends a service request and returns a Promise that resolves with the
8135
+ * matched response decoded by {@link SecureChannelReadable}.
8136
+ */
8137
+ issueServiceRequest(request: IOpcType): Promise<IOpcType>;
8138
+ private routeFrames;
8139
+ private pushMessage;
8140
+ constructor(context: SecureChannelContext, readerTransform: TransformStream<MsgBase$1, MsgBase$1>, writerTransform: TransformStream<MsgBase$1, MsgBase$1>);
8141
+ }
8142
+
8143
+ /**
8144
+ * Deframing transform for pipe use.
8145
+ *
8146
+ * Accepts raw OPC UA secure-conversation frame bytes, strips the message
8147
+ * framing, and emits decoded {@link DecodedFrame} objects.
8148
+ * Routing (pending request settlement vs. unsolicited) is the caller's
8149
+ * responsibility — use {@link SecureChannelFacade} for that.
8150
+ *
8151
+ * ```ts
8152
+ * tcpReadable
8153
+ * .pipeThrough(new SecureChannelDeframingTransform(context))
8154
+ * .pipeTo(routerWritable);
8155
+ * ```
8156
+ */
8157
+ declare class SecureChannelMessageDecoder extends TransformStream<Uint8Array, MsgBase$1> {
8158
+ private context;
8159
+ private logger;
8160
+ private transform;
8161
+ constructor(context: SecureChannelContext);
8162
+ }
8163
+
8164
+ /**
8165
+ * Framing-only transform for pipe use.
8166
+ *
8167
+ * Accepts a stream of pre-encoded binary body {@link Uint8Array}s, wraps each
8168
+ * in a symmetric OPC UA message frame, and emits the framed bytes.
8169
+ * Pipe the output directly to the wire transport.
8170
+ * No request/response correlation is performed — use {@link SecureChannelFacade}
8171
+ * for that. Pair with {@link BinaryEncoderTransform} upstream:
8172
+ *
8173
+ * ```ts
8174
+ * requestStream
8175
+ * .pipeThrough(new SecureChannelTypeEncoder(config.encoder))
8176
+ * .pipeThrough(new SecureChannelMesssageEncoder(context))
8177
+ * .pipeTo(wsSendable);
8178
+ * ```
8179
+ */
8180
+ declare class SecureChannelMesssageEncoder extends TransformStream<MsgBase$1, Uint8Array> {
8181
+ constructor(context: SecureChannelContext);
8182
+ }
8183
+
8184
+ declare class SecureChannelChunkReader extends TransformStream<MsgBase$1, MsgBase$1> {
8185
+ private logger;
8186
+ private prependChunk;
8187
+ private transform;
8188
+ constructor(context: SecureChannelContext);
8189
+ }
8190
+
8191
+ declare class SecureChannelChunkWriter extends TransformStream<MsgBase$1, MsgBase$1> {
8192
+ private context;
8193
+ private logger;
8194
+ private transform;
8195
+ constructor(context: SecureChannelContext);
8196
+ }
8197
+
8198
+ export { ActionMethodDataType, ActionStateEnum, ActionTargetDataType, ActivateSessionRequest, ActivateSessionResponse, AddNodesItem, AddNodesRequest, AddNodesResponse, AddNodesResult, AddReferencesItem, AddReferencesRequest, AddReferencesResponse, AdditionalParametersType, AggregateConfiguration, AggregateFilter, AggregateFilterResult, AliasNameDataType, Annotation, AnnotationDataType, AnonymousIdentityToken, ApplicationConfigurationDataType, ApplicationDescription, ApplicationIdentityDataType, ApplicationTypeEnum, Argument, AttributeOperand, AuthorizationServiceConfigurationDataType, AxisInformation, AxisScaleEnumerationEnum, BaseConfigurationDataType, BaseConfigurationRecordDataType, SecureChannelTypeDecoder as BinaryDecoderTransform, SecureChannelTypeEncoder as BinaryEncoderTransform, BinaryReader, BinaryWriter, BitFieldDefinition, BrokerConnectionTransportDataType, BrokerDataSetReaderTransportDataType, BrokerDataSetWriterTransportDataType, BrokerTransportQualityOfServiceEnum, BrokerWriterGroupTransportDataType, BrowseDescription, BrowseDirectionEnum, BrowseNextRequest, BrowseNextResponse, BrowsePath, BrowsePathResult, BrowsePathTarget, BrowseRequest, BrowseResponse, BrowseResult, BrowseResultMaskEnum, BuildInfo, CallMethodRequest, CallMethodResult, CallRequest, CallResponse, CancelRequest, CancelResponse, CartesianCoordinates, CertificateGroupDataType, ChannelSecurityToken, ChassisIdSubtypeEnum, CloseSecureChannelRequest, CloseSecureChannelResponse, CloseSessionRequest, CloseSessionResponse, ComplexNumberType, Configuration, ConfigurationUpdateTargetType, ConfigurationUpdateTypeEnum, ConfigurationVersionDataType, ConnectionTransportDataType, ConsoleSink, ContentFilter, ContentFilterElement, ContentFilterElementResult, ContentFilterResult, ConversionLimitEnumEnum, CreateMonitoredItemsRequest, CreateMonitoredItemsResponse, CreateSessionRequest, CreateSessionResponse, CreateSubscriptionRequest, CreateSubscriptionResponse, CurrencyUnitType, DataChangeFilter, DataChangeNotification, DataChangeTriggerEnum, DataSetMetaDataType, DataSetOrderingTypeEnum, DataSetReaderDataType, DataSetReaderMessageDataType, DataSetReaderTransportDataType, DataSetWriterDataType, DataSetWriterMessageDataType, DataSetWriterTransportDataType, DataTypeAttributes, DataTypeDefinition, DataTypeDescription, DataTypeNode, DataTypeSchemaHeader, DataValue, DatagramConnectionTransport2DataType, DatagramConnectionTransportDataType, DatagramDataSetReaderTransportDataType, DatagramWriterGroupTransport2DataType, DatagramWriterGroupTransportDataType, DeadbandTypeEnum, DecimalDataType, Decoder, DeleteAtTimeDetails, DeleteEventDetails, DeleteMonitoredItemsRequest, DeleteMonitoredItemsResponse, DeleteNodesItem, DeleteNodesRequest, DeleteNodesResponse, DeleteRawModifiedDetails, DeleteReferencesItem, DeleteReferencesRequest, DeleteReferencesResponse, DeleteSubscriptionsRequest, DeleteSubscriptionsResponse, DiagnosticInfo, DiagnosticsLevelEnum, DiscoveryConfiguration, DoubleComplexNumberType, DtlsPubSubConnectionDataType, DuplexEnum, EUInformation, ElementOperand, Encoder, EndpointConfiguration, EndpointDataType, EndpointDescription, EndpointType, EndpointUrlListDataType, EnumDefinition, EnumDescription, EnumField, EnumValueType, EphemeralKeyType, EventFieldList, EventFilter, EventFilterResult, EventNotificationList, ExceptionDeviationFormatEnum, ExpandedNodeId, ExtensionObject, FieldMetaData, FieldTargetDataType, FilterOperand, FilterOperatorEnum, FindServersOnNetworkRequest, FindServersOnNetworkResponse, FindServersRequest, FindServersResponse, Frame, GenericAttributeValue, GenericAttributes, GetEndpointsRequest, GetEndpointsResponse, HistoryData, HistoryEvent, HistoryEventFieldList, HistoryModifiedData, HistoryModifiedEvent, HistoryReadDetails, HistoryReadRequest, HistoryReadResponse, HistoryReadResult, HistoryReadValueId, HistoryUpdateDetails, HistoryUpdateRequest, HistoryUpdateResponse, HistoryUpdateResult, HistoryUpdateTypeEnum, type ILogger, type ILoggerFactory, type IOpcType, type IReader, type ISecureChannel, type ISink, type IWriter, IdTypeEnum, IdentityCriteriaTypeEnum, IdentityMappingRuleType, InstanceNode, InterfaceAdminStatusEnum, InterfaceOperStatusEnum, IssuedIdentityToken, JsonActionMetaDataMessage, JsonActionNetworkMessage, JsonActionRequestMessage, JsonActionResponderMessage, JsonActionResponseMessage, JsonApplicationDescriptionMessage, JsonDataSetMessage, JsonDataSetMetaDataMessage, JsonDataSetReaderMessageDataType, JsonDataSetWriterMessageDataType, JsonNetworkMessage, JsonPubSubConnectionMessage, JsonServerEndpointsMessage, JsonStatusMessage, JsonWriterGroupMessageDataType, KeyValuePair, type LevelName, LinearConversionDataType, LiteralOperand, LldpManagementAddressTxPortType, LldpManagementAddressType, LldpTlvType, LocalizedText, type LogRecord, LogRecordsDataType, LoggerFactory, ManAddrIfSubtypeEnum, MdnsDiscoveryConfiguration, MessageSecurityModeEnum, MethodAttributes, MethodNode, ModelChangeStructureDataType, ModelChangeStructureVerbMaskEnum, ModificationInfo, ModifyMonitoredItemsRequest, ModifyMonitoredItemsResponse, ModifySubscriptionRequest, ModifySubscriptionResponse, MonitoredItemCreateRequest, MonitoredItemCreateResult, MonitoredItemModifyRequest, MonitoredItemModifyResult, MonitoredItemNotification, MonitoringFilter, MonitoringFilterResult, MonitoringModeEnum, MonitoringParameters, NameValuePair, NamingRuleTypeEnum, NegotiationStatusEnum, NetworkAddressDataType, NetworkAddressUrlDataType, NetworkGroupDataType, Node, NodeAttributes, NodeAttributesMaskEnum, NodeClassEnum, NodeId, NodeIdType, NodeReference, NodeTypeDescription, NotificationData, NotificationMessage, ObjectAttributes, ObjectNode, ObjectTypeAttributes, ObjectTypeNode, OpenFileModeEnum, OpenSecureChannelRequest, OpenSecureChannelResponse, OptionSet, Orientation, OverrideValueHandlingEnum, ParsingResult, PerformUpdateTypeEnum, PortIdSubtypeEnum, PortableNodeId, PortableQualifiedName, PriorityMappingEntryType, ProgramDiagnostic2DataType, ProgramDiagnosticDataType, PubSubConfiguration2DataType, PubSubConfigurationDataType, PubSubConfigurationRefDataType, PubSubConfigurationValueDataType, PubSubConnectionDataType, PubSubDiagnosticsCounterClassificationEnum, PubSubGroupDataType, PubSubKeyPushTargetDataType, PubSubStateEnum, PublishRequest, PublishResponse, PublishedActionDataType, PublishedActionMethodDataType, PublishedDataItemsDataType, PublishedDataSetCustomSourceDataType, PublishedDataSetDataType, PublishedDataSetSourceDataType, PublishedEventsDataType, PublishedVariableDataType, QosDataType, QualifiedName, QuantityDimension, QueryDataDescription, QueryDataSet, QueryFirstRequest, QueryFirstResponse, QueryNextRequest, QueryNextResponse, Range, RationalNumber, ReadAnnotationDataDetails, ReadAtTimeDetails, ReadEventDetails, ReadEventDetails2, ReadEventDetailsSorted, ReadProcessedDetails, ReadRawModifiedDetails, ReadRequest, ReadResponse, ReadValueId, ReaderGroupDataType, ReaderGroupMessageDataType, ReaderGroupTransportDataType, ReceiveQosDataType, ReceiveQosPriorityDataType, RedundancySupportEnum, RedundantServerDataType, RedundantServerModeEnum, ReferenceDescription, ReferenceDescriptionDataType, ReferenceListEntryDataType, ReferenceNode, ReferenceTypeAttributes, ReferenceTypeNode, RegisterNodesRequest, RegisterNodesResponse, RegisterServer2Request, RegisterServer2Response, RegisterServerRequest, RegisterServerResponse, RegisteredServer, RelativePath, RelativePathElement, RepublishRequest, RepublishResponse, RequestHeader, ResponseHeader, RolePermissionType, SamplingIntervalDiagnosticsDataType, SecureChannelChunkReader, SecureChannelChunkWriter, SecureChannelContext, SecureChannelFacade, SecureChannelMessageDecoder, SecureChannelMesssageEncoder, SecureChannelTypeDecoder, SecureChannelTypeEncoder, SecurityGroupDataType, SecuritySettingsDataType, SecurityTokenRequestTypeEnum, SemanticChangeStructureDataType, ServerDiagnosticsSummaryDataType, ServerEndpointDataType, ServerOnNetwork, ServerStateEnum, ServerStatusDataType, ServiceCertificateDataType, ServiceCounterDataType, ServiceFault, SessionDiagnosticsDataType, SessionSecurityDiagnosticsDataType, SessionlessInvokeRequestType, SessionlessInvokeResponseType, SetMonitoringModeRequest, SetMonitoringModeResponse, SetPublishingModeRequest, SetPublishingModeResponse, SetTriggeringRequest, SetTriggeringResponse, SignatureData, SignedSoftwareCertificate, SimpleAttributeOperand, SimpleTypeDescription, SortOrderTypeEnum, SortRuleElement, SpanContextDataType, StandaloneSubscribedDataSetDataType, StandaloneSubscribedDataSetRefDataType, StatusChangeNotification, StatusCode, StatusResult, Structure, StructureDefinition, StructureDescription, StructureField, StructureTypeEnum, SubscribedDataSetDataType, SubscribedDataSetMirrorDataType, SubscriptionAcknowledgement, SubscriptionDiagnosticsDataType, TargetVariablesDataType, TcpConnectionHandler, TcpMessageDecoupler, TcpMessageInjector, TimeZoneDataType, TimestampsToReturnEnum, TraceContextDataType, TransactionErrorType, TransferResult, TransferSubscriptionsRequest, TransferSubscriptionsResponse, TranslateBrowsePathsToNodeIdsRequest, TranslateBrowsePathsToNodeIdsResponse, TransmitQosDataType, TransmitQosPriorityDataType, TrustListDataType, TrustListMasksEnum, TsnFailureCodeEnum, TsnListenerStatusEnum, TsnStreamStateEnum, TsnTalkerStatusEnum, TypeNode, UABinaryFileDataType, type UaBoolean, type UaByte, type UaByteString, type UaDateTime, type UaDouble, type UaFloat, type UaGuid, type UaInt16, type UaInt32, type UaInt64, type UaPrimitive, type UaSbyte, type UaString, type UaUint16, type UaUint32, type UaUint64, UadpDataSetReaderMessageDataType, UadpDataSetWriterMessageDataType, UadpWriterGroupMessageDataType, Union, UnregisterNodesRequest, UnregisterNodesResponse, UnsignedRationalNumber, UpdateDataDetails, UpdateEventDetails, UpdateStructureDataDetails, UserIdentityToken, UserManagementDataType, UserNameIdentityToken, UserTokenPolicy, UserTokenSettingsDataType, UserTokenTypeEnum, VariableAttributes, VariableNode, VariableTypeAttributes, VariableTypeNode, Variant, type VariantArrayValue, type VariantValue, Vector, ViewAttributes, ViewDescription, ViewNode, WebSocketFascade, WebSocketReadableStream, WebSocketWritableStream, WriteRequest, WriteResponse, WriteValue, WriterGroupDataType, WriterGroupMessageDataType, WriterGroupTransportDataType, X509IdentityToken, XVType, XmlElement, _3DCartesianCoordinates, _3DFrame, _3DOrientation, _3DVector, getLogger, initLoggerProvider, registerBinaryDecoders, registerEncoders, registerJsonDecoders, registerTypeDecoders, registerXmlDecoders, uaByte, uaDouble, uaFloat, uaGuid, uaInt16, uaInt32, uaInt64, uaSbyte, uaUint16, uaUint32, uaUint64 };