ocpp-ws-io 2.1.3 → 2.1.5
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/LICENSE +21 -0
- package/README.md +32 -6
- package/dist/adapters/redis.d.mts +1 -1
- package/dist/adapters/redis.d.ts +1 -1
- package/dist/adapters/redis.js +104 -0
- package/dist/adapters/redis.js.map +1 -1
- package/dist/adapters/redis.mjs +104 -0
- package/dist/adapters/redis.mjs.map +1 -1
- package/dist/browser.d.mts +21 -0
- package/dist/browser.d.ts +21 -0
- package/dist/browser.js.map +1 -1
- package/dist/browser.mjs.map +1 -1
- package/dist/{index-BixJj_yJ.d.mts → index-1QBeqAuc.d.mts} +145 -4
- package/dist/{index-BixJj_yJ.d.ts → index-1QBeqAuc.d.ts} +145 -4
- package/dist/index.d.mts +64 -8
- package/dist/index.d.ts +64 -8
- package/dist/index.js +502 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +500 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +17 -27
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as EventAdapterInterface, A as AuthCallback, L as LoggerLike, a as LoggingConfig, M as MiddlewareFunction, b as MiddlewareContext, C as ConnectionMiddleware, T as TypedEventEmitter, S as ServerEvents, c as CORSOptions, R as RouterConfig, O as OCPPProtocol, d as AllMethodNames, e as RouterHandlerContext, f as OCPPRequestType, g as OCPPResponseType, h as RouterWildcardHandler, i as ServerOptions, j as LoggerLikeNotOptional, k as OCPPServerClient, l as OCPPServerStats, m as ListenOptions, n as
|
|
2
|
-
export {
|
|
1
|
+
import { E as EventAdapterInterface, A as AuthCallback, L as LoggerLike, a as LoggingConfig, M as MiddlewareFunction, b as MiddlewareContext, C as ConnectionMiddleware, T as TypedEventEmitter, S as ServerEvents, c as CORSOptions, R as RouterConfig, O as OCPPProtocol, d as AllMethodNames, e as RouterHandlerContext, f as OCPPRequestType, g as OCPPResponseType, h as RouterWildcardHandler, i as ServerOptions, j as LoggerLikeNotOptional, k as OCPPServerClient, l as OCPPServerStats, m as ListenOptions, n as TLSOptions, o as CloseOptions, p as CallOptions, V as Validator } from './index-1QBeqAuc.js';
|
|
2
|
+
export { q as AnyOCPPProtocol, r as AuthAccept, s as CallHandler, t as ClientEvents, u as ClientOptions, v as ConnectionContext, w as ConnectionState, H as HandlerContext, x as HandshakeInfo, y as MessageType, z as MiddlewareNext, B as MiddlewareStack, N as NOREPLY, D as OCPP16Methods, F as OCPP201Methods, G as OCPP21Methods, I as OCPPCall, J as OCPPCallError, K as OCPPCallResult, P as OCPPClient, Q as OCPPMessage, U as OCPPMethodMap, W as OCPPProtocolKey, X as RedisAdapter, Y as SecurityProfile, Z as SessionData, _ as WildcardHandler, $ as createValidator } from './index-1QBeqAuc.js';
|
|
3
3
|
import { Server, IncomingMessage } from 'node:http';
|
|
4
4
|
import { Duplex } from 'node:stream';
|
|
5
5
|
import 'ws';
|
|
@@ -28,6 +28,11 @@ declare class InMemoryAdapter implements EventAdapterInterface {
|
|
|
28
28
|
getPresence(identity: string): Promise<string | null>;
|
|
29
29
|
getPresenceBatch(identities: string[]): Promise<(string | null)[]>;
|
|
30
30
|
removePresence(identity: string): Promise<void>;
|
|
31
|
+
setPresenceBatch(entries: {
|
|
32
|
+
identity: string;
|
|
33
|
+
nodeId: string;
|
|
34
|
+
ttl?: number;
|
|
35
|
+
}[]): Promise<void>;
|
|
31
36
|
}
|
|
32
37
|
/**
|
|
33
38
|
* Helper function to create a custom EventAdapter without needing to define a rigid Class.
|
|
@@ -160,6 +165,38 @@ declare function combineAuth(...cbs: AuthCallback[]): AuthCallback;
|
|
|
160
165
|
*/
|
|
161
166
|
declare function createLoggingMiddleware(logger: LoggerLike, identity: string, config?: LoggingConfig | boolean): MiddlewareFunction<MiddlewareContext, any>;
|
|
162
167
|
|
|
168
|
+
/**
|
|
169
|
+
* LRUMap — A zero-dependency, drop-in Map replacement with a maximum capacity.
|
|
170
|
+
*
|
|
171
|
+
* Evicts the **least recently used** entry when the capacity is exceeded.
|
|
172
|
+
* Uses native Map insertion-order semantics for O(1) LRU tracking
|
|
173
|
+
* (delete + re-insert moves a key to the "most recent" end).
|
|
174
|
+
*
|
|
175
|
+
* @remarks
|
|
176
|
+
* This is used by OCPPServer to bound the `_sessions` map and prevent OOM under
|
|
177
|
+
* DDoS or reconnection storms with transient identities.
|
|
178
|
+
*/
|
|
179
|
+
declare class LRUMap<K, V> extends Map<K, V> {
|
|
180
|
+
private _maxSize;
|
|
181
|
+
constructor(maxSize: number);
|
|
182
|
+
/**
|
|
183
|
+
* Returns the configured maximum capacity of this LRU cache.
|
|
184
|
+
*/
|
|
185
|
+
get maxSize(): number;
|
|
186
|
+
/**
|
|
187
|
+
* Sets a key-value pair. If the key already exists, it is promoted to the
|
|
188
|
+
* most-recently-used position. If inserting a new key would exceed capacity,
|
|
189
|
+
* the oldest (least-recently-used) entry is evicted.
|
|
190
|
+
*/
|
|
191
|
+
set(key: K, value: V): this;
|
|
192
|
+
/**
|
|
193
|
+
* Gets a value by key and promotes it to the most-recently-used position.
|
|
194
|
+
* Uses `this.has(key)` instead of a value truthiness check to correctly
|
|
195
|
+
* handle stored values of `undefined`, `null`, `0`, `""`, etc.
|
|
196
|
+
*/
|
|
197
|
+
get(key: K): V | undefined;
|
|
198
|
+
}
|
|
199
|
+
|
|
163
200
|
/**
|
|
164
201
|
* Compiled regex pattern for RegExp-based route fallback.
|
|
165
202
|
* Only used when a user registers a RegExp pattern (not string patterns).
|
|
@@ -280,6 +317,7 @@ declare class OCPPServer extends OCPPServer_base {
|
|
|
280
317
|
private _httpServerAbortControllers;
|
|
281
318
|
private _logger;
|
|
282
319
|
private _globalCORS?;
|
|
320
|
+
private _connectionBuckets;
|
|
283
321
|
private readonly _nodeId;
|
|
284
322
|
private _sessions;
|
|
285
323
|
private _gcInterval;
|
|
@@ -361,6 +399,28 @@ declare class OCPPServer extends OCPPServer_base {
|
|
|
361
399
|
*/
|
|
362
400
|
private _registerRouter;
|
|
363
401
|
listen(port?: number, host?: string, options?: ListenOptions): Promise<Server>;
|
|
402
|
+
/**
|
|
403
|
+
* Hot-reloads the TLS certificate on all active HTTPS servers without
|
|
404
|
+
* dropping any existing WebSocket connections.
|
|
405
|
+
*
|
|
406
|
+
* **When to use:** Call this whenever your TLS certificate is renewed —
|
|
407
|
+
* for example, after a Let's Encrypt auto-renewal (every ~90 days).
|
|
408
|
+
* Without this, you would need to restart the Node.js process to pick up
|
|
409
|
+
* the new certificate, disconnecting all connected charging stations.
|
|
410
|
+
*
|
|
411
|
+
* **How to use:**
|
|
412
|
+
* ```ts
|
|
413
|
+
* server.updateTLS({ cert: newCert, key: newKey });
|
|
414
|
+
* ```
|
|
415
|
+
*
|
|
416
|
+
* **Optional:** Only relevant if you are terminating TLS directly in Node.js
|
|
417
|
+
* (i.e. `SecurityProfile.TLS_BASIC_AUTH` or `TLS_CLIENT_CERT`). If you are
|
|
418
|
+
* running behind a reverse proxy (Nginx, AWS ALB, etc.) that handles TLS,
|
|
419
|
+
* you do not need this method — just rotate the cert on the proxy.
|
|
420
|
+
*
|
|
421
|
+
* @throws If the server is not using a TLS Security Profile.
|
|
422
|
+
*/
|
|
423
|
+
updateTLS(tlsOpts: TLSOptions): void;
|
|
364
424
|
get handleUpgrade(): (req: IncomingMessage, socket: Duplex, head: Buffer) => Promise<void>;
|
|
365
425
|
/**
|
|
366
426
|
* Core upgrade handler. Follows a strict pipeline:
|
|
@@ -418,11 +478,7 @@ declare class OCPPServer extends OCPPServer_base {
|
|
|
418
478
|
broadcastBatch<V extends AllMethodNames<any>>(identities: string[], method: V, params: OCPPRequestType<any, V>, options?: CallOptions): Promise<void>;
|
|
419
479
|
}
|
|
420
480
|
|
|
421
|
-
|
|
422
|
-
* Pre-built validators for all supported OCPP protocol versions.
|
|
423
|
-
* These are automatically registered when strict mode is enabled.
|
|
424
|
-
*/
|
|
425
|
-
declare const standardValidators: Validator[];
|
|
481
|
+
declare function getStandardValidators(): Validator[];
|
|
426
482
|
|
|
427
483
|
/**
|
|
428
484
|
* Instantiate a typed RPCError from a string error code.
|
|
@@ -446,4 +502,4 @@ declare function getErrorPlainObject(err: Error): Record<string, unknown>;
|
|
|
446
502
|
*/
|
|
447
503
|
declare function getPackageIdent(): string;
|
|
448
504
|
|
|
449
|
-
export { AllMethodNames, AuthCallback, CORSOptions, CallOptions, CloseOptions, ConnectionMiddleware, EventAdapterInterface, InMemoryAdapter, ListenOptions, LoggerLike, LoggingConfig, MiddlewareFunction, OCPPProtocol, OCPPRequestType, OCPPResponseType, OCPPRouter, OCPPServer, OCPPServerClient, type RPCError, RPCFormatViolationError, RPCFormationViolationError, RPCFrameworkError, RPCGenericError, RPCInternalError, RPCMessageTypeNotSupportedError, RPCNotImplementedError, RPCNotSupportedError, RPCOccurrenceConstraintViolationError, RPCPropertyConstraintViolationError, RPCProtocolError, RPCSecurityError, RPCTypeConstraintViolationError, RouterConfig, ServerEvents, ServerOptions, TimeoutError, TypedEventEmitter, UnexpectedHttpResponse, Validator, WebsocketUpgradeError, combineAuth, createLoggingMiddleware, createRPCError, createRouter, defineAdapter, defineAuth, defineMiddleware, defineRpcMiddleware, getErrorPlainObject, getPackageIdent,
|
|
505
|
+
export { AllMethodNames, AuthCallback, CORSOptions, CallOptions, CloseOptions, ConnectionMiddleware, EventAdapterInterface, InMemoryAdapter, LRUMap, ListenOptions, LoggerLike, LoggingConfig, MiddlewareFunction, OCPPProtocol, OCPPRequestType, OCPPResponseType, OCPPRouter, OCPPServer, OCPPServerClient, type RPCError, RPCFormatViolationError, RPCFormationViolationError, RPCFrameworkError, RPCGenericError, RPCInternalError, RPCMessageTypeNotSupportedError, RPCNotImplementedError, RPCNotSupportedError, RPCOccurrenceConstraintViolationError, RPCPropertyConstraintViolationError, RPCProtocolError, RPCSecurityError, RPCTypeConstraintViolationError, RouterConfig, ServerEvents, ServerOptions, TLSOptions, TimeoutError, TypedEventEmitter, UnexpectedHttpResponse, Validator, WebsocketUpgradeError, combineAuth, createLoggingMiddleware, createRPCError, createRouter, defineAdapter, defineAuth, defineMiddleware, defineRpcMiddleware, getErrorPlainObject, getPackageIdent, getStandardValidators };
|