@espressif/rainmaker-neo-base-sdk 1.1.0 → 1.2.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.
Files changed (55) hide show
  1. package/dist/cjs/ESPRMNeoBase.js +1 -1
  2. package/dist/cjs/index.js +11 -0
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/cjs/proto/rmaker_local_ctrl.js +273 -0
  5. package/dist/cjs/proto/rmaker_local_ctrl.js.map +1 -0
  6. package/dist/cjs/services/ESPTransport/ESPDiscovery/ESPDiscoveryManager.js +5 -4
  7. package/dist/cjs/services/ESPTransport/ESPDiscovery/ESPDiscoveryManager.js.map +1 -1
  8. package/dist/cjs/services/ESPTransport/ESPLocalControlTransport.js +183 -116
  9. package/dist/cjs/services/ESPTransport/ESPLocalControlTransport.js.map +1 -1
  10. package/dist/cjs/services/ESPTransport/LocalControlSession.js +62 -0
  11. package/dist/cjs/services/ESPTransport/LocalControlSession.js.map +1 -0
  12. package/dist/cjs/types/transport.js +24 -0
  13. package/dist/cjs/types/transport.js.map +1 -1
  14. package/dist/cjs/utils/constants.js +70 -4
  15. package/dist/cjs/utils/constants.js.map +1 -1
  16. package/dist/cjs/utils/eventSubscriptionUtils.js +48 -4
  17. package/dist/cjs/utils/eventSubscriptionUtils.js.map +1 -1
  18. package/dist/esm/ESPRMNeoBase.js +1 -1
  19. package/dist/esm/index.js +2 -2
  20. package/dist/esm/proto/rmaker_local_ctrl.js +271 -0
  21. package/dist/esm/proto/rmaker_local_ctrl.js.map +1 -0
  22. package/dist/esm/services/ESPTransport/ESPDiscovery/ESPDiscoveryManager.js +5 -4
  23. package/dist/esm/services/ESPTransport/ESPDiscovery/ESPDiscoveryManager.js.map +1 -1
  24. package/dist/esm/services/ESPTransport/ESPLocalControlTransport.js +184 -117
  25. package/dist/esm/services/ESPTransport/ESPLocalControlTransport.js.map +1 -1
  26. package/dist/esm/services/ESPTransport/LocalControlSession.js +59 -0
  27. package/dist/esm/services/ESPTransport/LocalControlSession.js.map +1 -0
  28. package/dist/esm/types/transport.js +24 -1
  29. package/dist/esm/types/transport.js.map +1 -1
  30. package/dist/esm/utils/constants.js +65 -5
  31. package/dist/esm/utils/constants.js.map +1 -1
  32. package/dist/esm/utils/eventSubscriptionUtils.js +49 -5
  33. package/dist/esm/utils/eventSubscriptionUtils.js.map +1 -1
  34. package/dist/types/ESPRMNeoBase.d.ts +1 -1
  35. package/dist/types/proto/rmaker_local_ctrl.d.ts +137 -0
  36. package/dist/types/services/ESPTransport/ESPDiscovery/ESPDiscoveryManager.d.ts +4 -3
  37. package/dist/types/services/ESPTransport/ESPLocalControlTransport.d.ts +70 -23
  38. package/dist/types/services/ESPTransport/LocalControlSession.d.ts +24 -0
  39. package/dist/types/types/discovery.d.ts +1 -1
  40. package/dist/types/types/localControl.d.ts +26 -1
  41. package/dist/types/types/transport.d.ts +24 -2
  42. package/dist/types/utils/baseUtils.d.ts +1 -1
  43. package/dist/types/utils/constants.d.ts +65 -5
  44. package/dist/types/utils/eventSubscriptionUtils.d.ts +19 -3
  45. package/package.json +1 -1
  46. package/dist/cjs/proto/constants.js +0 -24
  47. package/dist/cjs/proto/constants.js.map +0 -1
  48. package/dist/cjs/proto/esp_local_ctrl.js +0 -787
  49. package/dist/cjs/proto/esp_local_ctrl.js.map +0 -1
  50. package/dist/esm/proto/constants.js +0 -24
  51. package/dist/esm/proto/constants.js.map +0 -1
  52. package/dist/esm/proto/esp_local_ctrl.js +0 -758
  53. package/dist/esm/proto/esp_local_ctrl.js.map +0 -1
  54. package/dist/types/proto/constants.d.ts +0 -15
  55. package/dist/types/proto/esp_local_ctrl.d.ts +0 -283
@@ -13,11 +13,33 @@ declare enum ESPTransportMode {
13
13
  /** Communication is routed through MQTT (RainMaker Neo cloud: AWS shadow). */
14
14
  mqtt = "mqtt"
15
15
  }
16
+ /**
17
+ * Wire protocol spoken by the `local` transport. Both protocols run over a
18
+ * protocomm session on the node's LAN HTTP server; they differ in endpoint
19
+ * names and message encoding.
20
+ *
21
+ * Carried on the local transport config's `metadata.protocol`, set by local
22
+ * discovery from the mDNS service type that produced the hit.
23
+ */
24
+ declare enum ESPLocalControlProtocol {
25
+ /**
26
+ * RainMaker Neo protocol (`rmaker_local_ctrl/*` session plus
27
+ * `get_params`/`set_params`/`get_config`), advertised as
28
+ * `_esp_rmaker_ctrl._tcp`. Default for this SDK.
29
+ */
30
+ rmakerLocalCtrl = "rmaker_local_ctrl"
31
+ }
32
+ /**
33
+ * Protocol assumed when a local transport config carries no explicit
34
+ * `metadata.protocol` — for example a LAN transport restored from a client-side
35
+ * registry rather than a fresh discovery hit.
36
+ */
37
+ declare const DEFAULT_LOCAL_CONTROL_PROTOCOL = ESPLocalControlProtocol.rmakerLocalCtrl;
16
38
  /**
17
39
  * Configuration options for the transport mechanism for ESP communication.
18
40
  *
19
41
  * Includes the transport type and any additional metadata for the chosen mode
20
- * (e.g. `baseUrl`, `securityType`, `pop` for the local transport).
42
+ * (e.g. `baseUrl`, `securityType`, `pop`, `protocol` for the local transport).
21
43
  */
22
44
  interface ESPTransportConfig {
23
45
  /**
@@ -62,4 +84,4 @@ interface ESPTransportInterface {
62
84
  * has an explicit order configured: local control first, MQTT (cloud) fallback.
63
85
  */
64
86
  declare const DEFAULT_TRANSPORT_ORDER: (ESPTransportMode | string)[];
65
- export { ESPTransportMode, ESPTransportConfig, ESPTransportInterface, DEFAULT_TRANSPORT_ORDER, };
87
+ export { ESPTransportMode, ESPLocalControlProtocol, ESPTransportConfig, ESPTransportInterface, DEFAULT_TRANSPORT_ORDER, DEFAULT_LOCAL_CONTROL_PROTOCOL, };
@@ -25,7 +25,7 @@ export interface ESPRMNeoBaseAdapters {
25
25
  storage?: ESPStorageAdapter;
26
26
  /** SoftAP / BLE provisioning implementation supplied by the host app. */
27
27
  provision?: ESPProvisionAdapterInterface;
28
- /** LAN `esp_local_ctrl` transport implementation. */
28
+ /** LAN local-control transport implementation. */
29
29
  localControl?: ESPLocalControlAdapterInterface;
30
30
  /** LAN / mDNS discovery implementation. */
31
31
  localDiscovery?: ESPLocalDiscoveryAdapterInterface;
@@ -468,8 +468,6 @@ declare const ProvisionType: {
468
468
  * An object containing endpoint paths.
469
469
  */
470
470
  declare const Endpoint: {
471
- /** The endpoint for local control. */
472
- LOCAL_CTRL: string;
473
471
  /** The endpoint for cloud user association. */
474
472
  CLOUD_USER_ASSOCIATION: string;
475
473
  /** The endpoint for challenge-response and get-node-id protocol with the device. */
@@ -477,6 +475,64 @@ declare const Endpoint: {
477
475
  /** The endpoint for assisted claiming. */
478
476
  RM_CLAIM: string;
479
477
  };
478
+ /**
479
+ * Endpoint paths of the `rmaker_local_ctrl` protocol served by RainMaker Neo
480
+ * firmware (see the firmware's local-control endpoint protocol spec).
481
+ *
482
+ * All data endpoints inherit the security of the session established on
483
+ * {@link RMakerLocalCtrlEndpoint.SESSION}.
484
+ */
485
+ declare const RMakerLocalCtrlEndpoint: {
486
+ /** Protocomm session-security endpoint (SEC1 with/without PoP, or SEC2). */
487
+ readonly SESSION: "rmaker_local_ctrl/session";
488
+ /** POST any payload; responds with the service info JSON (`sec_ver`, `cap`, …). */
489
+ readonly VERSION: "rmaker_local_ctrl/version";
490
+ /** Reads the params JSON — protobuf `CmdGetData`, fragmented response. */
491
+ readonly GET_PARAMS: "get_params";
492
+ /** Reads the node config JSON — protobuf `CmdGetData`, fragmented response. */
493
+ readonly GET_CONFIG: "get_config";
494
+ /** Writes params — raw JSON request and response (no protobuf). */
495
+ readonly SET_PARAMS: "set_params";
496
+ };
497
+ /**
498
+ * Root key of the JSON served by {@link RMakerLocalCtrlEndpoint.VERSION}, i.e.
499
+ * `{"rmaker_local_ctrl": {"ver": …, "sec_ver": …, "cap": [...]}}`. Passed to the
500
+ * local-control adapter so the native layer probes the right scheme version.
501
+ */
502
+ declare const RMAKER_LOCAL_CTRL_VERSION_KEY = "rmaker_local_ctrl";
503
+ /**
504
+ * Maximum fragment size (bytes) the firmware serves per `RespGetData`. Reads
505
+ * loop with `Offset += Payload.length` until `TotalLen` is reached; this value
506
+ * is informational (the device dictates the actual fragment length).
507
+ */
508
+ declare const RMAKER_LOCAL_CTRL_FRAGMENT_SIZE = 200;
509
+ /**
510
+ * `status` values in a `set_params` raw-JSON response.
511
+ */
512
+ declare const RMakerLocalCtrlSetParamsStatus: {
513
+ readonly SUCCESS: "success";
514
+ readonly FAIL: "fail";
515
+ };
516
+ /**
517
+ * mDNS TXT record keys advertised by the `_esp_rmaker_ctrl._tcp` service.
518
+ */
519
+ declare const RMakerLocalCtrlTxtKey: {
520
+ /** Node ID (also the service instance name and hostname). */
521
+ readonly NODE_ID: "node_id";
522
+ /** Comma-separated active capabilities — see {@link RMakerLocalCtrlCapability}. */
523
+ readonly CAP: "cap";
524
+ };
525
+ /**
526
+ * Capability tokens found in the `cap` TXT record. A node advertising only
527
+ * `ch_resp` is reachable for on-network user-node association but *not* for
528
+ * param control, so it must not be registered as a local control transport.
529
+ */
530
+ declare const RMakerLocalCtrlCapability: {
531
+ /** Params/config endpoints are registered. */
532
+ readonly LOCAL_CTRL: "local_ctrl";
533
+ /** Challenge-response (on-network user-node association) is registered. */
534
+ readonly CH_RESP: "ch_resp";
535
+ };
480
536
  /**
481
537
  * Assisted-claiming REST paths, on the deployment's main API and SigV4-signed
482
538
  * like every other `/v1/*` route.
@@ -627,8 +683,12 @@ declare const ProvErrorCodes: {
627
683
  * @enum {string}
628
684
  */
629
685
  declare const ServiceType: {
630
- /** Represents the ESP local control TCP service type. */
631
- ESP_LOCAL_CTRL_TCP: string;
686
+ /**
687
+ * Service type advertised by RainMaker Neo firmware. A single instance serves
688
+ * the `rmaker_local_ctrl` endpoints; the `cap` TXT record says which endpoint
689
+ * sets are active. This is the default for local discovery in this SDK.
690
+ */
691
+ ESP_RMAKER_LOCAL_CTRL_TCP: string;
632
692
  };
633
693
  /**
634
694
  * An object containing protocol types.
@@ -809,7 +869,7 @@ declare const APIPathV1: {
809
869
  /** POST /v1/groups/{groupId}/node-assoc-requests/{requestId}/verify - Verifies user node mapping */
810
870
  readonly USER_NODE_MAPPING_VERIFY: (groupId: string, requestId: string) => string;
811
871
  };
812
- export { HTTPMethods, APIEndpoints, APIPathV1, StorageKeys, ValidationErrorCodes, StorageAdapterErrorCodes, ConfigErrorCodes, APICallValidationErrorCodes, APIOperations, TokenErrorCodes, AuthErrorCodes, AuthSuccessMessages, AutomationSuccessMessages, AutomationStatusValues, GroupSuccessMessages, NodeSuccessMessages, NodeWarnMessages, ScheduleSuccessMessages, ScheduleErrorMessages, TriggerErrorMessages, TriggerSuccessMessages, SharingSuccessMessages, IntegrationSuccessMessages, AssumeRoleErrorMessages, AWSCredentialsErrorMessages, GroupUserAliases, Endpoint, ProvisionType, ProvErrorCodes, ServiceType, ProtocolType, StatusMessage, DEFAULT_REST_API_VERSION, ESPServiceType, ESPServiceParamType, ESPProvProgressMessages, ErrorLabels, SDK_VERSION, ClaimEndpoints, ClaimCapabilities, ClaimCapabilityPolicies, ClaimErrorCodes, ClaimProgressMessages, CLAIM_CSR_MAX_CHUNKS, CLAIM_MAX_FRAGMENT_SIZE, CLAIM_MAC_SEPARATORS, CLAIM_MAC_HEX_LENGTHS, CLAIM_DEVICE_MAC_KEYS, CLAIM_DEVICE_CSR_KEYS, };
872
+ export { HTTPMethods, APIEndpoints, APIPathV1, StorageKeys, ValidationErrorCodes, StorageAdapterErrorCodes, ConfigErrorCodes, APICallValidationErrorCodes, APIOperations, TokenErrorCodes, AuthErrorCodes, AuthSuccessMessages, AutomationSuccessMessages, AutomationStatusValues, GroupSuccessMessages, NodeSuccessMessages, NodeWarnMessages, ScheduleSuccessMessages, ScheduleErrorMessages, TriggerErrorMessages, TriggerSuccessMessages, SharingSuccessMessages, IntegrationSuccessMessages, AssumeRoleErrorMessages, AWSCredentialsErrorMessages, GroupUserAliases, Endpoint, RMakerLocalCtrlEndpoint, RMAKER_LOCAL_CTRL_VERSION_KEY, RMAKER_LOCAL_CTRL_FRAGMENT_SIZE, RMakerLocalCtrlSetParamsStatus, RMakerLocalCtrlTxtKey, RMakerLocalCtrlCapability, ProvisionType, ProvErrorCodes, ServiceType, ProtocolType, StatusMessage, DEFAULT_REST_API_VERSION, ESPServiceType, ESPServiceParamType, ESPProvProgressMessages, ErrorLabels, SDK_VERSION, ClaimEndpoints, ClaimCapabilities, ClaimCapabilityPolicies, ClaimErrorCodes, ClaimProgressMessages, CLAIM_CSR_MAX_CHUNKS, CLAIM_MAX_FRAGMENT_SIZE, CLAIM_MAC_SEPARATORS, CLAIM_MAC_HEX_LENGTHS, CLAIM_DEVICE_MAC_KEYS, CLAIM_DEVICE_CSR_KEYS, };
813
873
  export declare enum ESPRMNeoErrorCodes {
814
874
  SDK_NOT_CONFIGURED = "SDK_NOT_CONFIGURED",
815
875
  INVALID_CREDENTIALS = "INVALID_CREDENTIALS",
@@ -4,9 +4,25 @@ import { ESPNodeUpdateData } from "../types/subscription";
4
4
  export type EventTeardown = {
5
5
  stop(): void;
6
6
  };
7
- /** Maps a default local-discovery hit into the client-facing payload shape. */
8
- export declare function toDiscoveredNodeData(info: Record<string, any>): ESPDiscoveredNodeData;
9
- /** Starts LAN discovery; each hit is mapped then passed to `onDiscovered`. */
7
+ /**
8
+ * Maps a default local-discovery hit into the client-facing payload shape.
9
+ *
10
+ * The `_esp_rmaker_ctrl._tcp` instance is also advertised by nodes that
11
+ * only serve challenge-response (on-network user-node association). Those are
12
+ * not reachable for param control, so a hit whose `cap` TXT record excludes
13
+ * `local_ctrl` maps to `undefined` and is dropped rather than registered as a
14
+ * local transport. A hit with no `cap` record is treated as control-capable.
15
+ *
16
+ * @param info - Raw adapter result (`nodeId`, `baseUrl`, and `txt` when the
17
+ * platform resolved TXT records).
18
+ * @returns The payload to deliver, or `undefined` to skip this hit.
19
+ */
20
+ export declare function toDiscoveredNodeData(info: Record<string, any>): ESPDiscoveredNodeData | undefined;
21
+ /**
22
+ * Starts LAN discovery; each hit is mapped then passed to `onDiscovered`.
23
+ * Hits that are not control-capable (see {@link toDiscoveredNodeData}) are
24
+ * skipped.
25
+ */
10
26
  export declare function startLocalDiscovery(onDiscovered: (data: ESPDiscoveredNodeData) => void): EventTeardown;
11
27
  /** Forwards process-wide node param updates to `onUpdate`. */
12
28
  export declare function startNodeUpdates(onUpdate: (update: ESPNodeUpdateData) => void): EventTeardown;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@espressif/rainmaker-neo-base-sdk",
3
3
  "description": "ESP RainMaker Neo TypeScript SDK for JS-based apps — Cognito auth, MQTT control, device provisioning, groups, and real-time node updates.",
4
- "version": "1.1.0",
4
+ "version": "1.2.0",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
7
  "main": "dist/cjs/index.js",
@@ -1,24 +0,0 @@
1
- 'use strict';
2
-
3
- /*
4
- * SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
5
- *
6
- * SPDX-License-Identifier: Apache-2.0
7
- */
8
- /**
9
- * Generated by the protoc-gen-ts. DO NOT EDIT!
10
- * compiler version: 5.28.2
11
- * source: constants.proto
12
- * git: https://github.com/thesayyn/protoc-gen-ts */
13
- exports.Status = void 0;
14
- (function (Status) {
15
- Status[Status["Success"] = 0] = "Success";
16
- Status[Status["InvalidSecScheme"] = 1] = "InvalidSecScheme";
17
- Status[Status["InvalidProto"] = 2] = "InvalidProto";
18
- Status[Status["TooManySessions"] = 3] = "TooManySessions";
19
- Status[Status["InvalidArgument"] = 4] = "InvalidArgument";
20
- Status[Status["InternalError"] = 5] = "InternalError";
21
- Status[Status["CryptoError"] = 6] = "CryptoError";
22
- Status[Status["InvalidSession"] = 7] = "InvalidSession";
23
- })(exports.Status || (exports.Status = {}));
24
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;"}