node-opcua-client-browser 2.179.0 → 2.181.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_ws_transport.d.ts +1 -1
- package/dist/client_ws_transport.js +2 -2
- package/dist/client_ws_transport.js.map +1 -1
- package/dist/create_browser_client.js +2 -2
- package/dist/create_browser_client.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist-esm/client_ws_transport.js +163 -0
- package/dist-esm/client_ws_transport.js.map +1 -0
- package/dist-esm/create_browser_client.js +69 -0
- package/dist-esm/create_browser_client.js.map +1 -0
- package/dist-esm/index.js +48 -0
- package/dist-esm/index.js.map +1 -0
- package/dist-esm/uacp.js +15 -0
- package/dist-esm/uacp.js.map +1 -0
- package/dist-esm/ws_socket_adapter.js +191 -0
- package/dist-esm/ws_socket_adapter.js.map +1 -0
- package/package.json +11 -10
- package/source/client_ws_transport.ts +1 -1
- package/source/create_browser_client.ts +1 -1
- package/source/index.ts +3 -3
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
*/
|
|
21
21
|
import type { ErrorCallback } from "node-opcua-status-code";
|
|
22
22
|
import { ClientTransportBase, type IClientTransportFactory, type TransportSettingsOptions } from "node-opcua-transport";
|
|
23
|
-
import { type WebSocketLike } from "./ws_socket_adapter";
|
|
23
|
+
import { type WebSocketLike } from "./ws_socket_adapter.js";
|
|
24
24
|
/** WebSocket subprotocol name defined by OPC UA Part 6 §7.5 */
|
|
25
25
|
export declare const OPCUA_UACP_SUBPROTOCOL = "opcua+uacp";
|
|
26
26
|
/**
|
|
@@ -26,7 +26,7 @@ exports.parseWsEndpointUrl = parseWsEndpointUrl;
|
|
|
26
26
|
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
27
27
|
const node_opcua_debug_1 = require("node-opcua-debug");
|
|
28
28
|
const node_opcua_transport_1 = require("node-opcua-transport");
|
|
29
|
-
const
|
|
29
|
+
const ws_socket_adapter_js_1 = require("./ws_socket_adapter.js");
|
|
30
30
|
const debugLog = (0, node_opcua_debug_1.make_debugLog)("ClientWS_transport");
|
|
31
31
|
const warningLog = (0, node_opcua_debug_1.make_warningLog)("ClientWS_transport");
|
|
32
32
|
const doDebug = (0, node_opcua_debug_1.checkDebugFlag)("ClientWS_transport");
|
|
@@ -93,7 +93,7 @@ class ClientWS_transport extends node_opcua_transport_1.ClientTransportBase {
|
|
|
93
93
|
callback(err);
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
|
-
const socket = new
|
|
96
|
+
const socket = new ws_socket_adapter_js_1.WsSocketAdapter(ws, parsed.wsUrl);
|
|
97
97
|
const onEarlyError = (err) => {
|
|
98
98
|
callback(err);
|
|
99
99
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client_ws_transport.js","sourceRoot":"","sources":["../source/client_ws_transport.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAgEH,gDAYC;AA1ED,sBAAsB;AAEtB,yDAA2C;AAC3C,uDAAkF;AAElF,+DAM8B;AAE9B,
|
|
1
|
+
{"version":3,"file":"client_ws_transport.js","sourceRoot":"","sources":["../source/client_ws_transport.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAgEH,gDAYC;AA1ED,sBAAsB;AAEtB,yDAA2C;AAC3C,uDAAkF;AAElF,+DAM8B;AAE9B,iEAA6E;AAE7E,MAAM,QAAQ,GAAG,IAAA,gCAAa,EAAC,oBAAoB,CAAC,CAAC;AACrD,MAAM,UAAU,GAAG,IAAA,kCAAe,EAAC,oBAAoB,CAAC,CAAC;AACzD,MAAM,OAAO,GAAG,IAAA,iCAAc,EAAC,oBAAoB,CAAC,CAAC;AAErD,+DAA+D;AAClD,QAAA,sBAAsB,GAAG,YAAY,CAAC;AAoCnD;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAC,WAAmB;IAClD,MAAM,CAAC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,CAAC;CACJ,CAAC"}
|
|
@@ -31,7 +31,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
31
31
|
exports.createBrowserClient = createBrowserClient;
|
|
32
32
|
const node_opcua_client_1 = require("node-opcua-client");
|
|
33
33
|
const node_opcua_common_1 = require("node-opcua-common");
|
|
34
|
-
const
|
|
34
|
+
const client_ws_transport_js_1 = require("./client_ws_transport.js");
|
|
35
35
|
/**
|
|
36
36
|
* Construct an `OPCUAClient` with browser-appropriate defaults.
|
|
37
37
|
*
|
|
@@ -54,7 +54,7 @@ function createBrowserClient(options = {}) {
|
|
|
54
54
|
const { clientCertificate, clientPrivateKey, ...clientOptions } = options;
|
|
55
55
|
// Default to the browser WS transport factory unless the caller supplies one.
|
|
56
56
|
if (!clientOptions.transportFactory) {
|
|
57
|
-
clientOptions.transportFactory =
|
|
57
|
+
clientOptions.transportFactory = client_ws_transport_js_1.browserWsTransportFactory;
|
|
58
58
|
}
|
|
59
59
|
// Default to an in-memory cert/key provider unless the caller supplies one.
|
|
60
60
|
// If the caller provided a client cert + private key, pre-populate the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create_browser_client.js","sourceRoot":"","sources":["../source/create_browser_client.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;;AAqDH,kDAsBC;AAzED,yDAAyE;AACzE,yDAAiG;AAGjG
|
|
1
|
+
{"version":3,"file":"create_browser_client.js","sourceRoot":"","sources":["../source/create_browser_client.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;;AAqDH,kDAsBC;AAzED,yDAAyE;AACzE,yDAAiG;AAGjG,qEAAqE;AA6BrE;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,mBAAmB,CAAC,UAAsC,EAAgC;IACtG,MAAM,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,GAAG,aAAa,EAAE,GAAG,OAAO,CAAC;IAE1E,8EAA8E;IAC9E,IAAI,CAAC,aAAa,CAAC,gBAAgB,EAAE,CAAC;QAClC,aAAa,CAAC,gBAAgB,GAAG,kDAAyB,CAAC;IAC/D,CAAC;IAED,4EAA4E;IAC5E,uEAAuE;IACvE,4EAA4E;IAC5E,IAAI,CAAC,aAAa,CAAC,0BAA0B,EAAE,CAAC;QAC5C,MAAM,KAAK,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC3H,aAAa,CAAC,0BAA0B,GAAG,IAAI,sDAAkC,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;IAC/G,CAAC;IAED,sEAAsE;IACtE,IAAI,CAAC,aAAa,CAAC,wBAAwB,EAAE,CAAC;QAC1C,aAAa,CAAC,wBAAwB,GAAG,IAAI,4CAAwB,CAAC,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;IACvG,CAAC;IAED,OAAO,+BAAW,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;AAC7C,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
* directly from `../../dist`. Re-export will be restored in Step 5 of
|
|
42
42
|
* the plan once Steps 1–4 land.
|
|
43
43
|
*/
|
|
44
|
-
export * from "./client_ws_transport";
|
|
45
|
-
export * as uacp from "./uacp";
|
|
46
|
-
export { type WebSocketLike, WsSocketAdapter } from "./ws_socket_adapter";
|
|
44
|
+
export * from "./client_ws_transport.js";
|
|
45
|
+
export * as uacp from "./uacp.js";
|
|
46
|
+
export { type WebSocketLike, WsSocketAdapter } from "./ws_socket_adapter.js";
|
|
47
47
|
export declare const VERSION = "2.172.0";
|
package/dist/index.js
CHANGED
|
@@ -80,9 +80,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
80
80
|
})();
|
|
81
81
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
82
82
|
exports.VERSION = exports.WsSocketAdapter = exports.uacp = void 0;
|
|
83
|
-
__exportStar(require("./client_ws_transport"), exports);
|
|
84
|
-
exports.uacp = __importStar(require("./uacp"));
|
|
85
|
-
var
|
|
86
|
-
Object.defineProperty(exports, "WsSocketAdapter", { enumerable: true, get: function () { return
|
|
83
|
+
__exportStar(require("./client_ws_transport.js"), exports);
|
|
84
|
+
exports.uacp = __importStar(require("./uacp.js"));
|
|
85
|
+
var ws_socket_adapter_js_1 = require("./ws_socket_adapter.js");
|
|
86
|
+
Object.defineProperty(exports, "WsSocketAdapter", { enumerable: true, get: function () { return ws_socket_adapter_js_1.WsSocketAdapter; } });
|
|
87
87
|
exports.VERSION = "2.172.0";
|
|
88
88
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH;;;;;;;;;;;;;;;;;;;;;GAqBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH;;;;;;;;;;;;;;;;;;;;;GAqBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2DAAyC;AACzC,kDAAkC;AAClC,+DAA6E;AAAhD,uHAAA,eAAe,OAAA;AAE/B,QAAA,OAAO,GAAG,SAAS,CAAC"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module node-opcua-client-browser
|
|
3
|
+
*
|
|
4
|
+
* `ClientWS_transport` — OPC UA WebSocket client transport (Part 6 §7.5).
|
|
5
|
+
*
|
|
6
|
+
* Subclasses `ClientTCP_transport` and reuses its HEL/ACK + chunk-reassembly
|
|
7
|
+
* machinery unchanged. The only swap is the socket-creation step: instead of
|
|
8
|
+
* opening a TCP connection, we open a `WebSocket` and hand a
|
|
9
|
+
* {@link WsSocketAdapter} to `TCP_transport._install_socket`.
|
|
10
|
+
*
|
|
11
|
+
* OPC UA WebSocket framing:
|
|
12
|
+
* - One UACP chunk per outgoing binary WebSocket frame (handled naturally —
|
|
13
|
+
* each `write(chunk)` call invokes `ws.send(chunk)` once).
|
|
14
|
+
* - Incoming bytes are fed into `TCP_transport`'s packet-assembler, which
|
|
15
|
+
* re-combines split chunks.
|
|
16
|
+
* - Subprotocol `opcua+uacp` is requested on the handshake. If the server
|
|
17
|
+
* echoes it back we record that; if not (common with a `websockify`
|
|
18
|
+
* bridge) we continue without failing — browsers still accept the
|
|
19
|
+
* connection provided the server's bytes are valid UACP.
|
|
20
|
+
*/
|
|
21
|
+
/* global WebSocket */
|
|
22
|
+
import { assert } from "node-opcua-assert";
|
|
23
|
+
import { checkDebugFlag, make_debugLog, make_warningLog } from "node-opcua-debug";
|
|
24
|
+
import { ClientTransportBase } from "node-opcua-transport";
|
|
25
|
+
import { WsSocketAdapter } from "./ws_socket_adapter.js";
|
|
26
|
+
const debugLog = make_debugLog("ClientWS_transport");
|
|
27
|
+
const warningLog = make_warningLog("ClientWS_transport");
|
|
28
|
+
const doDebug = checkDebugFlag("ClientWS_transport");
|
|
29
|
+
/** WebSocket subprotocol name defined by OPC UA Part 6 §7.5 */
|
|
30
|
+
export const OPCUA_UACP_SUBPROTOCOL = "opcua+uacp";
|
|
31
|
+
/**
|
|
32
|
+
* Parse and normalise an OPC UA WebSocket endpoint URL. Accepts all four
|
|
33
|
+
* forms: `opc.ws://`, `opc.wss://`, `ws://`, `wss://`. Anything else throws.
|
|
34
|
+
*
|
|
35
|
+
* @throws {Error} if the scheme is not one of the four accepted forms.
|
|
36
|
+
*/
|
|
37
|
+
export function parseWsEndpointUrl(endpointUrl) {
|
|
38
|
+
const m = /^(opc\.ws|opc\.wss|ws|wss):\/\/(.+)$/i.exec(endpointUrl);
|
|
39
|
+
if (!m) {
|
|
40
|
+
throw new Error(`[node-opcua-client-browser] unsupported endpoint URL scheme for WebSocket transport: ${endpointUrl} ` +
|
|
41
|
+
`(expected one of opc.ws://, opc.wss://, ws://, wss://)`);
|
|
42
|
+
}
|
|
43
|
+
const scheme = m[1].toLowerCase();
|
|
44
|
+
const secure = scheme === "opc.wss" || scheme === "wss";
|
|
45
|
+
const wsUrl = `${secure ? "wss" : "ws"}://${m[2]}`;
|
|
46
|
+
return { wsUrl, secure };
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* WebSocket-backed client transport. A sibling of `ClientTCP_transport`: both extend
|
|
50
|
+
* {@link ClientTransportBase} and reuse its UACP HEL/ACK machinery; the only
|
|
51
|
+
* difference is the socket flavour (`WebSocket` here, `net.Socket` in TCP).
|
|
52
|
+
*/
|
|
53
|
+
export class ClientWS_transport extends ClientTransportBase {
|
|
54
|
+
_webSocketCtor;
|
|
55
|
+
_strictSubprotocol;
|
|
56
|
+
constructor(options) {
|
|
57
|
+
super(options);
|
|
58
|
+
const resolvedCtor = options?.webSocketCtor ??
|
|
59
|
+
(typeof globalThis !== "undefined" ? globalThis.WebSocket : undefined);
|
|
60
|
+
if (!resolvedCtor) {
|
|
61
|
+
throw new Error("[ClientWS_transport] no WebSocket constructor available: pass `webSocketCtor` explicitly or run in a browser / Node 22+");
|
|
62
|
+
}
|
|
63
|
+
this._webSocketCtor = resolvedCtor;
|
|
64
|
+
this._strictSubprotocol = !!options?.strictSubprotocol;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Opens a WebSocket to `endpointUrl`, adapts it to `ISocketLike`, and
|
|
68
|
+
* drives the inherited HEL/ACK transaction from `ClientTransportBase`.
|
|
69
|
+
*/
|
|
70
|
+
connect(endpointUrl, callback) {
|
|
71
|
+
this.endpointUrl = endpointUrl;
|
|
72
|
+
/* c8 ignore next */
|
|
73
|
+
doDebug && debugLog(`ClientWS_transport#connect(endpointUrl = ${endpointUrl})`);
|
|
74
|
+
let parsed;
|
|
75
|
+
try {
|
|
76
|
+
parsed = parseWsEndpointUrl(endpointUrl);
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
callback(err);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
let ws;
|
|
83
|
+
try {
|
|
84
|
+
ws = new this._webSocketCtor(parsed.wsUrl, OPCUA_UACP_SUBPROTOCOL);
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
/* c8 ignore next */
|
|
88
|
+
doDebug && debugLog("WebSocket construction failed", err.message);
|
|
89
|
+
callback(err);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const socket = new WsSocketAdapter(ws, parsed.wsUrl);
|
|
93
|
+
const onEarlyError = (err) => {
|
|
94
|
+
callback(err);
|
|
95
|
+
};
|
|
96
|
+
socket.once("error", onEarlyError);
|
|
97
|
+
socket.once("connect", () => {
|
|
98
|
+
socket.removeListener("error", onEarlyError);
|
|
99
|
+
// Subprotocol negotiation check. Browser WS exposes `protocol` on the
|
|
100
|
+
// instance; `ws` package exposes it too. When the peer doesn't
|
|
101
|
+
// negotiate (e.g. a websockify bridge), `protocol` is an empty
|
|
102
|
+
// string. Only fail in strict mode.
|
|
103
|
+
const negotiated = ws.protocol;
|
|
104
|
+
if (negotiated && negotiated !== OPCUA_UACP_SUBPROTOCOL) {
|
|
105
|
+
const msg = `unexpected WebSocket subprotocol negotiated: "${negotiated}" (expected "${OPCUA_UACP_SUBPROTOCOL}")`;
|
|
106
|
+
if (this._strictSubprotocol) {
|
|
107
|
+
callback(new Error(`[ClientWS_transport] ${msg}`));
|
|
108
|
+
socket.destroy();
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
warningLog(msg);
|
|
112
|
+
}
|
|
113
|
+
else if (!negotiated) {
|
|
114
|
+
/* c8 ignore next */
|
|
115
|
+
doDebug &&
|
|
116
|
+
debugLog(`peer did not echo the "${OPCUA_UACP_SUBPROTOCOL}" subprotocol; continuing ` +
|
|
117
|
+
`(set strictSubprotocol=true to reject this)`);
|
|
118
|
+
}
|
|
119
|
+
// Install the WebSocket-backed socket adapter into the inherited TCP_transport machinery.
|
|
120
|
+
assert(!this._socket, "transport should not have a socket yet");
|
|
121
|
+
this._install_socket(socket);
|
|
122
|
+
this._perform_HEL_ACK_transaction((err) => {
|
|
123
|
+
if (!err) {
|
|
124
|
+
/* c8 ignore next */
|
|
125
|
+
if (!this._socket) {
|
|
126
|
+
return callback(new Error("Abandoned"));
|
|
127
|
+
}
|
|
128
|
+
this._install_post_connect_error_handler(endpointUrl);
|
|
129
|
+
this.emit("connect");
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
// c8 ignore next
|
|
133
|
+
doDebug && debugLog("_perform_HEL_ACK_transaction has failed with err=", err.message);
|
|
134
|
+
}
|
|
135
|
+
callback(err);
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
dispose() {
|
|
140
|
+
/* c8 ignore next */
|
|
141
|
+
doDebug && debugLog(" ClientWS_transport disposed");
|
|
142
|
+
super.dispose();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* A factory that produces {@link ClientWS_transport} instances. Pass to
|
|
147
|
+
* `ClientSecureChannelLayerOptions.transportFactory` to route all channel
|
|
148
|
+
* traffic through a WebSocket.
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* const ws = browserWsTransportFactory.create({});
|
|
152
|
+
* // or, on Node:
|
|
153
|
+
* import WebSocket from "ws";
|
|
154
|
+
* const factory: IClientTransportFactory = {
|
|
155
|
+
* create(s) { return new ClientWS_transport({ ...s, webSocketCtor: WebSocket as any }); }
|
|
156
|
+
* };
|
|
157
|
+
*/
|
|
158
|
+
export const browserWsTransportFactory = {
|
|
159
|
+
create(settings) {
|
|
160
|
+
return new ClientWS_transport(settings);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
//# sourceMappingURL=client_ws_transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client_ws_transport.js","sourceRoot":"","sources":["../source/client_ws_transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,sBAAsB;AAEtB,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAElF,OAAO,EACH,mBAAmB,EAKtB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAsB,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE7E,MAAM,QAAQ,GAAG,aAAa,CAAC,oBAAoB,CAAC,CAAC;AACrD,MAAM,UAAU,GAAG,eAAe,CAAC,oBAAoB,CAAC,CAAC;AACzD,MAAM,OAAO,GAAG,cAAc,CAAC,oBAAoB,CAAC,CAAC;AAErD,+DAA+D;AAC/D,MAAM,CAAC,MAAM,sBAAsB,GAAG,YAAY,CAAC;AAoCnD;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,WAAmB;IAClD,MAAM,CAAC,GAAG,uCAAuC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACpE,IAAI,CAAC,CAAC,EAAE,CAAC;QACL,MAAM,IAAI,KAAK,CACX,wFAAwF,WAAW,GAAG;YAClG,wDAAwD,CAC/D,CAAC;IACN,CAAC;IACD,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IAClC,MAAM,MAAM,GAAG,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,KAAK,CAAC;IACxD,MAAM,KAAK,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC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AAE;gBACtC,IAAI,CAAC,GAAG,EAAE,CAAC;oBACP,oBAAoB;oBACpB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;wBAChB,OAAO,QAAQ,CAAC,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;oBAC5C,CAAC;oBACD,IAAI,CAAC,mCAAmC,CAAC,WAAW,CAAC,CAAC;oBACtD,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;gBACzB,CAAC;qBAAM,CAAC;oBACJ,iBAAiB;oBACjB,OAAO,IAAI,QAAQ,CAAC,mDAAmD,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;gBAC1F,CAAC;gBACD,QAAQ,CAAC,GAAG,CAAC,CAAC;YAClB,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;IACe,OAAO;QACnB,oBAAoB;QACpB,OAAO,IAAI,QAAQ,CAAC,8BAA8B,CAAC,CAAC;QAEpD,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAA4B;IAC9D,MAAM,CAAC,QAAmC;QACtC,OAAO,IAAI,kBAAkB,CAAC,QAAgD,CAAC,CAAC;IACpF,CAAC;CACJ,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module node-opcua-client-browser
|
|
3
|
+
*
|
|
4
|
+
* Thin helper that constructs an `OPCUAClient` (from `node-opcua-client`)
|
|
5
|
+
* pre-wired with the browser WebSocket transport factory and, when no
|
|
6
|
+
* credentials are supplied, an in-memory certificate/key pair provider so
|
|
7
|
+
* no disk paths are touched.
|
|
8
|
+
*
|
|
9
|
+
* All other `OPCUAClient` configuration passes through unchanged — callers
|
|
10
|
+
* configure session timeouts, reconnection strategies, security policies,
|
|
11
|
+
* etc. exactly as they would for the Node client.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { createBrowserClient, AttributeIds, MessageSecurityMode, SecurityPolicy } from "node-opcua-client-browser";
|
|
16
|
+
*
|
|
17
|
+
* const client = createBrowserClient({
|
|
18
|
+
* endpointMustExist: false,
|
|
19
|
+
* securityMode: MessageSecurityMode.None,
|
|
20
|
+
* securityPolicy: SecurityPolicy.None,
|
|
21
|
+
* });
|
|
22
|
+
* await client.connect("opc.ws://localhost:4840");
|
|
23
|
+
* const session = await client.createSession();
|
|
24
|
+
* const dv = await session.read({ nodeId: "ns=1;s=Counter", attributeId: AttributeIds.Value });
|
|
25
|
+
* await session.close();
|
|
26
|
+
* await client.disconnect();
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
import { OPCUAClient } from "node-opcua-client";
|
|
30
|
+
import { InMemoryCertificateKeyPairProvider, InMemoryCertificateStore } from "node-opcua-common";
|
|
31
|
+
import { browserWsTransportFactory } from "./client_ws_transport.js";
|
|
32
|
+
/**
|
|
33
|
+
* Construct an `OPCUAClient` with browser-appropriate defaults.
|
|
34
|
+
*
|
|
35
|
+
* - `transportFactory` defaults to `browserWsTransportFactory` so the
|
|
36
|
+
* underlying secure channel opens a WebSocket. Callers can override by
|
|
37
|
+
* passing a different `transportFactory`.
|
|
38
|
+
* - `certificateKeyPairProvider` defaults to an
|
|
39
|
+
* `InMemoryCertificateKeyPairProvider`, populated with
|
|
40
|
+
* `clientCertificate` / `clientPrivateKey` when those are supplied.
|
|
41
|
+
* When they are NOT supplied, the provider is constructed empty —
|
|
42
|
+
* callers are expected to await `ensureCertificateExists(...)` on the
|
|
43
|
+
* returned client's credentials before connecting with a non-None
|
|
44
|
+
* security policy.
|
|
45
|
+
* - `clientCertificateManager` defaults to an `InMemoryCertificateStore`
|
|
46
|
+
* (auto-accept unknown peer certs). Callers can override by passing
|
|
47
|
+
* their own `clientCertificateManager` (e.g. one backed by IndexedDB
|
|
48
|
+
* or OPFS).
|
|
49
|
+
*/
|
|
50
|
+
export function createBrowserClient(options = {}) {
|
|
51
|
+
const { clientCertificate, clientPrivateKey, ...clientOptions } = options;
|
|
52
|
+
// Default to the browser WS transport factory unless the caller supplies one.
|
|
53
|
+
if (!clientOptions.transportFactory) {
|
|
54
|
+
clientOptions.transportFactory = browserWsTransportFactory;
|
|
55
|
+
}
|
|
56
|
+
// Default to an in-memory cert/key provider unless the caller supplies one.
|
|
57
|
+
// If the caller provided a client cert + private key, pre-populate the
|
|
58
|
+
// provider so the owning client can reach them without further async setup.
|
|
59
|
+
if (!clientOptions.certificateKeyPairProvider) {
|
|
60
|
+
const chain = clientCertificate ? (Array.isArray(clientCertificate) ? clientCertificate : [clientCertificate]) : undefined;
|
|
61
|
+
clientOptions.certificateKeyPairProvider = new InMemoryCertificateKeyPairProvider(chain, clientPrivateKey);
|
|
62
|
+
}
|
|
63
|
+
// Default to an in-memory trust store unless the caller supplies one.
|
|
64
|
+
if (!clientOptions.clientCertificateManager) {
|
|
65
|
+
clientOptions.clientCertificateManager = new InMemoryCertificateStore({ autoAcceptUnknown: true });
|
|
66
|
+
}
|
|
67
|
+
return OPCUAClient.create(clientOptions);
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=create_browser_client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create_browser_client.js","sourceRoot":"","sources":["../source/create_browser_client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,WAAW,EAA2B,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,kCAAkC,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAGjG,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AA6BrE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,mBAAmB,CAAC,UAAsC,EAAgC;IACtG,MAAM,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,GAAG,aAAa,EAAE,GAAG,OAAO,CAAC;IAE1E,8EAA8E;IAC9E,IAAI,CAAC,aAAa,CAAC,gBAAgB,EAAE,CAAC;QAClC,aAAa,CAAC,gBAAgB,GAAG,yBAAyB,CAAC;IAC/D,CAAC;IAED,4EAA4E;IAC5E,uEAAuE;IACvE,4EAA4E;IAC5E,IAAI,CAAC,aAAa,CAAC,0BAA0B,EAAE,CAAC;QAC5C,MAAM,KAAK,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC3H,aAAa,CAAC,0BAA0B,GAAG,IAAI,kCAAkC,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;IAC/G,CAAC;IAED,sEAAsE;IACtE,IAAI,CAAC,aAAa,CAAC,wBAAwB,EAAE,CAAC;QAC1C,aAAa,CAAC,wBAAwB,GAAG,IAAI,wBAAwB,CAAC,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;IACvG,CAAC;IAED,OAAO,WAAW,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
* Copyright (c) 2022-2025 Sterfive SAS - 833264583 RCS ORLEANS - France (https://www.sterfive.com)
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
* this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
* the Software without restriction, including without limitation the rights to
|
|
8
|
+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
* the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
* subject to the following conditions:
|
|
11
|
+
*
|
|
12
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
* copies or substantial portions of the Software.
|
|
14
|
+
*
|
|
15
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* @module node-opcua-client-browser
|
|
24
|
+
*
|
|
25
|
+
* Browser entry point for `node-opcua-client`. Exposes the OPC UA WebSocket
|
|
26
|
+
* transport (`ClientWS_transport`, `browserWsTransportFactory`,
|
|
27
|
+
* `parseWsEndpointUrl`).
|
|
28
|
+
*
|
|
29
|
+
* Target environments: modern evergreen browsers (Chromium, Firefox, WebKit).
|
|
30
|
+
* The transport uses the OPC UA WebSocket mapping per Part 6 §7.5
|
|
31
|
+
* (`opcua+uacp` subprotocol, one UACP chunk per binary frame).
|
|
32
|
+
*
|
|
33
|
+
* NOTE: `createBrowserClient` is temporarily NOT re-exported from this
|
|
34
|
+
* barrel. Its `OPCUAClient` import drags in `node-opcua-client`, which
|
|
35
|
+
* still transitively pulls Node-only modules (`node:crypto`, `node:fs`,
|
|
36
|
+
* `node:dns`, `@ster5/global-mutex`, `multicast-dns`, …) at bundle
|
|
37
|
+
* time. The full plan to make those packages browser-safe lives at
|
|
38
|
+
* `C:\Users\etien\.claude\plans\run-pnpm-filter-node-opcua-client-browse-vivid-sparkle.md`.
|
|
39
|
+
* The Node-side helper itself is still built and unit-tested — its 8
|
|
40
|
+
* mocha cases in `test/unit/test_create_browser_client.ts` import it
|
|
41
|
+
* directly from `../../dist`. Re-export will be restored in Step 5 of
|
|
42
|
+
* the plan once Steps 1–4 land.
|
|
43
|
+
*/
|
|
44
|
+
export * from "./client_ws_transport.js";
|
|
45
|
+
export * as uacp from "./uacp.js";
|
|
46
|
+
export { WsSocketAdapter } from "./ws_socket_adapter.js";
|
|
47
|
+
export const VERSION = "2.172.0";
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,cAAc,0BAA0B,CAAC;AACzC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAsB,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE7E,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAC"}
|
package/dist-esm/uacp.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module node-opcua-client-browser
|
|
3
|
+
* @internal
|
|
4
|
+
*
|
|
5
|
+
* UACP primitives usable in the browser.
|
|
6
|
+
*
|
|
7
|
+
* These are thin re-exports of the byte-level encoders/decoders from
|
|
8
|
+
* `node-opcua-transport`. Those modules are pure-JS (only `node:events` is
|
|
9
|
+
* pulled in, which Vite polyfills automatically) and are therefore safe to
|
|
10
|
+
* bundle for the browser. Consolidating them here gives us a single point of
|
|
11
|
+
* audit if a future release of `node-opcua-transport` introduces a Node-only
|
|
12
|
+
* import.
|
|
13
|
+
*/
|
|
14
|
+
export { AcknowledgeMessage, HelloMessage, packTcpMessage, readRawMessageHeader, TCPErrorMessage } from "node-opcua-transport";
|
|
15
|
+
//# sourceMappingURL=uacp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uacp.js","sourceRoot":"","sources":["../source/uacp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACH,kBAAkB,EAClB,YAAY,EACZ,cAAc,EACd,oBAAoB,EACpB,eAAe,EAElB,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module node-opcua-client-browser
|
|
3
|
+
* @internal
|
|
4
|
+
*
|
|
5
|
+
* WebSocket → {@link ISocketLike} adapter.
|
|
6
|
+
*
|
|
7
|
+
* {@link TCP_transport} in `node-opcua-transport` expects an `ISocketLike` that
|
|
8
|
+
* emits `data`, `close`, `end`, `error`, `timeout` events and provides
|
|
9
|
+
* `write`, `end`, `destroy`, `setKeepAlive`, `setNoDelay`, `setTimeout`.
|
|
10
|
+
*
|
|
11
|
+
* This adapter turns a browser `WebSocket` (or the `ws` package used during
|
|
12
|
+
* unit tests) into that shape so the full HEL/ACK + chunk-assembly machinery
|
|
13
|
+
* in `TCP_transport` can be reused without change.
|
|
14
|
+
*
|
|
15
|
+
* Framing per OPC UA Part 6 §7.5: each outgoing UACP chunk is sent as exactly
|
|
16
|
+
* one binary WebSocket message. Incoming binary messages are concatenated via
|
|
17
|
+
* the `TCP_transport` packet-assembler, so even if a peer (e.g. `websockify`)
|
|
18
|
+
* splits a chunk across multiple frames, the assembler re-combines them.
|
|
19
|
+
* Text frames are ignored with a warning.
|
|
20
|
+
*/
|
|
21
|
+
import { EventEmitter } from "events";
|
|
22
|
+
// WebSocket readyState constants (avoid importing the DOM lib to stay Node-side compatible)
|
|
23
|
+
const WS_OPEN = 1;
|
|
24
|
+
const WS_CLOSING = 2;
|
|
25
|
+
const WS_CLOSED = 3;
|
|
26
|
+
function toBuffer(data) {
|
|
27
|
+
if (!data)
|
|
28
|
+
return null;
|
|
29
|
+
if (typeof Buffer !== "undefined" && Buffer.isBuffer(data))
|
|
30
|
+
return data;
|
|
31
|
+
if (data instanceof ArrayBuffer)
|
|
32
|
+
return Buffer.from(new Uint8Array(data));
|
|
33
|
+
if (ArrayBuffer.isView(data)) {
|
|
34
|
+
const view = data;
|
|
35
|
+
return Buffer.from(view.buffer, view.byteOffset, view.byteLength);
|
|
36
|
+
}
|
|
37
|
+
// Blob path: the transport's HEL/ACK uses `binaryType = "arraybuffer"`,
|
|
38
|
+
// so this should never hit. Fail loud if it does.
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Wrap a {@link WebSocketLike} as an {@link ISocketLike}. The returned socket
|
|
43
|
+
* forwards `data` events once the WS is open, and cleans up the WS listeners
|
|
44
|
+
* on `destroy` or `end`.
|
|
45
|
+
*
|
|
46
|
+
* The WebSocket must already be instantiated (i.e. `new WebSocket(url, protocols)`).
|
|
47
|
+
* The caller drives this by the time `_install_socket` is called; we just bind.
|
|
48
|
+
*/
|
|
49
|
+
export class WsSocketAdapter extends EventEmitter {
|
|
50
|
+
ws;
|
|
51
|
+
remoteAddress;
|
|
52
|
+
remotePort;
|
|
53
|
+
destroyed = false;
|
|
54
|
+
_timeoutHandle = null;
|
|
55
|
+
_timeoutMs = 0;
|
|
56
|
+
_timeoutCb = null;
|
|
57
|
+
constructor(ws, url) {
|
|
58
|
+
super();
|
|
59
|
+
this.ws = ws;
|
|
60
|
+
if (url) {
|
|
61
|
+
try {
|
|
62
|
+
const u = new URL(url);
|
|
63
|
+
this.remoteAddress = u.hostname;
|
|
64
|
+
this.remotePort = u.port ? Number(u.port) : undefined;
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
/* ignore – URL parse already happened in connect() */
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
ws.binaryType = "arraybuffer";
|
|
71
|
+
const emitError = (err) => {
|
|
72
|
+
this.emit("error", err);
|
|
73
|
+
};
|
|
74
|
+
ws.onopen = () => {
|
|
75
|
+
this.emit("connect");
|
|
76
|
+
};
|
|
77
|
+
ws.onmessage = (ev) => {
|
|
78
|
+
// Reset inactivity timer if any
|
|
79
|
+
this._resetTimeout();
|
|
80
|
+
const buf = toBuffer(ev.data);
|
|
81
|
+
if (!buf) {
|
|
82
|
+
// Text frame or unknown type: ignore with a warning, per spec
|
|
83
|
+
console.warn("[ClientWS_transport] ignoring non-binary WebSocket frame");
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
this.emit("data", buf);
|
|
87
|
+
};
|
|
88
|
+
ws.onerror = () => {
|
|
89
|
+
// Browser WebSocket errors carry no useful detail. Translate into a
|
|
90
|
+
// generic Error so downstream log messages still make sense.
|
|
91
|
+
emitError(new Error("WebSocket error"));
|
|
92
|
+
};
|
|
93
|
+
ws.onclose = (ev) => {
|
|
94
|
+
this._clearTimeout();
|
|
95
|
+
// `hadError` is best-effort: anything other than 1000 (normal) is
|
|
96
|
+
// treated as an error path.
|
|
97
|
+
const hadError = !!ev && typeof ev.code === "number" && ev.code !== 1000;
|
|
98
|
+
this.emit("end");
|
|
99
|
+
this.emit("close", hadError);
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
write(data, callback) {
|
|
103
|
+
if (this.destroyed || this.ws.readyState >= WS_CLOSING) {
|
|
104
|
+
callback?.(new Error("WebSocket is not open"));
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
108
|
+
if (typeof data === "string") {
|
|
109
|
+
// UACP chunks are always binary; if we somehow got a string,
|
|
110
|
+
// encode to UTF-8.
|
|
111
|
+
this.ws.send(new TextEncoder().encode(data));
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
// Send as ArrayBufferView so the WS layer keeps it as one binary frame.
|
|
115
|
+
const u8 = data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
116
|
+
// `send()` accepts ArrayBuffer or ArrayBufferView; use the view so the
|
|
117
|
+
// underlying buffer isn't copied unnecessarily.
|
|
118
|
+
this.ws.send(u8);
|
|
119
|
+
}
|
|
120
|
+
callback?.();
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
callback?.(err);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
end() {
|
|
127
|
+
this._clearTimeout();
|
|
128
|
+
if (this.ws.readyState === WS_OPEN) {
|
|
129
|
+
try {
|
|
130
|
+
this.ws.close(1000, "normal closure");
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
/* swallow */
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
destroy(_err) {
|
|
138
|
+
this.destroyed = true;
|
|
139
|
+
this._clearTimeout();
|
|
140
|
+
if (this.ws.readyState < WS_CLOSED) {
|
|
141
|
+
try {
|
|
142
|
+
this.ws.close(1001, "going away");
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
/* swallow */
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
// Detach handlers so no late events fire into a destroyed transport.
|
|
149
|
+
try {
|
|
150
|
+
this.ws.onopen = null;
|
|
151
|
+
this.ws.onclose = null;
|
|
152
|
+
this.ws.onerror = null;
|
|
153
|
+
this.ws.onmessage = null;
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
/* swallow */
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
// These three are no-ops for WebSocket – keep-alive and nodelay are handled
|
|
160
|
+
// by the browser / underlying TCP stack; we expose them so TCP_transport's
|
|
161
|
+
// setup sequence runs unchanged.
|
|
162
|
+
setKeepAlive(_enable, _initialDelay) {
|
|
163
|
+
return this;
|
|
164
|
+
}
|
|
165
|
+
setNoDelay(_noDelay) {
|
|
166
|
+
return this;
|
|
167
|
+
}
|
|
168
|
+
setTimeout(timeout, callback) {
|
|
169
|
+
this._timeoutMs = timeout;
|
|
170
|
+
this._timeoutCb = callback ?? null;
|
|
171
|
+
this._resetTimeout();
|
|
172
|
+
return this;
|
|
173
|
+
}
|
|
174
|
+
_resetTimeout() {
|
|
175
|
+
this._clearTimeout();
|
|
176
|
+
if (this._timeoutMs > 0 && this._timeoutCb) {
|
|
177
|
+
const cb = this._timeoutCb;
|
|
178
|
+
this._timeoutHandle = setTimeout(() => {
|
|
179
|
+
this.emit("timeout");
|
|
180
|
+
cb();
|
|
181
|
+
}, this._timeoutMs);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
_clearTimeout() {
|
|
185
|
+
if (this._timeoutHandle !== null) {
|
|
186
|
+
clearTimeout(this._timeoutHandle);
|
|
187
|
+
this._timeoutHandle = null;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=ws_socket_adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ws_socket_adapter.js","sourceRoot":"","sources":["../source/ws_socket_adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAoBtC,4FAA4F;AAC5F,MAAM,OAAO,GAAG,CAAC,CAAC;AAClB,MAAM,UAAU,GAAG,CAAC,CAAC;AACrB,MAAM,SAAS,GAAG,CAAC,CAAC;AAEpB,SAAS,QAAQ,CAAC,IAAa;IAC3B,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,IAAc,CAAC;IAClF,IAAI,IAAI,YAAY,WAAW;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1E,IAAI,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,IAAuB,CAAC;QACrC,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IACtE,CAAC;IACD,wEAAwE;I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EAA2E;IAC3E,iCAAiC;IAC1B,YAAY,CAAC,OAAiB,EAAE,aAAsB;QACzD,OAAO,IAAI,CAAC;IAChB,CAAC;IACM,UAAU,CAAC,QAAkB;QAChC,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,UAAU,CAAC,OAAe,EAAE,QAAqB;QACpD,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC;QAC1B,IAAI,CAAC,UAAU,GAAG,QAAQ,IAAI,IAAI,CAAC;QACnC,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,OAAO,IAAI,CAAC;IAChB,CAAC;IAEO,aAAa;QACjB,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,IAAI,IAAI,CAAC,UAAU,GAAG,CAAC,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACzC,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC;YAC3B,IAAI,CAAC,cAAc,GAAG,UAAU,CAAC,GAAG,EAAE;gBAClC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;gBACrB,EAAE,EAAE,CAAC;YACT,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACxB,CAAC;IACL,CAAC;IAEO,aAAa;QACjB,IAAI,IAAI,CAAC,cAAc,KAAK,IAAI,EAAE,CAAC;YAC/B,YAAY,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAClC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC/B,CAAC;IACL,CAAC;CACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-opcua-client-browser",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.181.0",
|
|
4
4
|
"description": "OPC UA SDK - browser WebSocket client (opc.ws / opc.wss)",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -27,20 +27,21 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"node-opcua-assert": "2.179.0",
|
|
30
|
-
"node-opcua-client": "2.
|
|
31
|
-
"node-opcua-common": "2.
|
|
32
|
-
"node-opcua-crypto": "5.
|
|
33
|
-
"node-opcua-debug": "2.
|
|
34
|
-
"node-opcua-status-code": "2.
|
|
35
|
-
"node-opcua-transport": "2.
|
|
30
|
+
"node-opcua-client": "2.181.0",
|
|
31
|
+
"node-opcua-common": "2.181.0",
|
|
32
|
+
"node-opcua-crypto": "5.10.1",
|
|
33
|
+
"node-opcua-debug": "2.181.0",
|
|
34
|
+
"node-opcua-status-code": "2.181.0",
|
|
35
|
+
"node-opcua-transport": "2.181.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@playwright/test": "^1.
|
|
38
|
+
"@playwright/test": "^1.63.0",
|
|
39
39
|
"@types/ws": "^8.18.1",
|
|
40
40
|
"buffer": "^6.0.3",
|
|
41
41
|
"esbuild": "^0.28.2",
|
|
42
42
|
"events": "^3.3.0",
|
|
43
|
-
"node-opcua-leak-detector": "2.
|
|
43
|
+
"node-opcua-leak-detector": "2.181.0",
|
|
44
|
+
"node-opcua-test-helpers": "2.181.0",
|
|
44
45
|
"process": "^0.11.10",
|
|
45
46
|
"util": "^0.12.5",
|
|
46
47
|
"ws": "^8.21.3"
|
|
@@ -66,5 +67,5 @@
|
|
|
66
67
|
"dist-esm",
|
|
67
68
|
"source"
|
|
68
69
|
],
|
|
69
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "f8f472c59e681b2aa18ae1533c3d1e5f17614c5c"
|
|
70
71
|
}
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
type TransportSettingsOptions
|
|
33
33
|
} from "node-opcua-transport";
|
|
34
34
|
|
|
35
|
-
import { type WebSocketLike, WsSocketAdapter } from "./ws_socket_adapter";
|
|
35
|
+
import { type WebSocketLike, WsSocketAdapter } from "./ws_socket_adapter.js";
|
|
36
36
|
|
|
37
37
|
const debugLog = make_debugLog("ClientWS_transport");
|
|
38
38
|
const warningLog = make_warningLog("ClientWS_transport");
|
|
@@ -31,7 +31,7 @@ import { OPCUAClient, type OPCUAClientOptions } from "node-opcua-client";
|
|
|
31
31
|
import { InMemoryCertificateKeyPairProvider, InMemoryCertificateStore } from "node-opcua-common";
|
|
32
32
|
import type { Certificate, PrivateKey } from "node-opcua-crypto/web";
|
|
33
33
|
|
|
34
|
-
import { browserWsTransportFactory } from "./client_ws_transport";
|
|
34
|
+
import { browserWsTransportFactory } from "./client_ws_transport.js";
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* Options accepted by {@link createBrowserClient}. Superset of
|
package/source/index.ts
CHANGED
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
* the plan once Steps 1–4 land.
|
|
43
43
|
*/
|
|
44
44
|
|
|
45
|
-
export * from "./client_ws_transport";
|
|
46
|
-
export * as uacp from "./uacp";
|
|
47
|
-
export { type WebSocketLike, WsSocketAdapter } from "./ws_socket_adapter";
|
|
45
|
+
export * from "./client_ws_transport.js";
|
|
46
|
+
export * as uacp from "./uacp.js";
|
|
47
|
+
export { type WebSocketLike, WsSocketAdapter } from "./ws_socket_adapter.js";
|
|
48
48
|
|
|
49
49
|
export const VERSION = "2.172.0";
|