@espressif/rainmaker-neo-base-sdk 1.0.0 → 1.1.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/LICENSE +1 -1
- package/README.md +40 -4
- package/dist/cjs/ESPDevice.js +6 -0
- package/dist/cjs/ESPDevice.js.map +1 -1
- package/dist/cjs/ESPRMNeoNode.js +33 -14
- package/dist/cjs/ESPRMNeoNode.js.map +1 -1
- package/dist/cjs/index.js +3 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/methods/ESPDevice/Provision.js +7 -0
- package/dist/cjs/methods/ESPDevice/Provision.js.map +1 -1
- package/dist/cjs/methods/ESPDevice/ResetWifiStatus.js +26 -0
- package/dist/cjs/methods/ESPDevice/ResetWifiStatus.js.map +1 -0
- package/dist/cjs/methods/ESPDevice/RetryNetworkCredentials.js +46 -0
- package/dist/cjs/methods/ESPDevice/RetryNetworkCredentials.js.map +1 -0
- package/dist/cjs/methods/ESPRMNeoNode/Sync.js +4 -1
- package/dist/cjs/methods/ESPRMNeoNode/Sync.js.map +1 -1
- package/dist/cjs/methods/ESPRMNeoUser/MQTT/AssumeRole.js +8 -9
- package/dist/cjs/methods/ESPRMNeoUser/MQTT/AssumeRole.js.map +1 -1
- package/dist/cjs/proto/esp_rmaker_chal_resp.js +5 -0
- package/dist/cjs/proto/esp_rmaker_chal_resp.js.map +1 -1
- package/dist/cjs/services/ESPRMNeoMqtt/ESPRMNeoMqtt.js +13 -0
- package/dist/cjs/services/ESPRMNeoMqtt/ESPRMNeoMqtt.js.map +1 -1
- package/dist/cjs/services/NodeMQTTOrchestrator.js +2 -5
- package/dist/cjs/services/NodeMQTTOrchestrator.js.map +1 -1
- package/dist/cjs/utils/constants.js +10 -0
- package/dist/cjs/utils/constants.js.map +1 -1
- package/dist/cjs/utils/nodeUtils.js +12 -1
- package/dist/cjs/utils/nodeUtils.js.map +1 -1
- package/dist/cjs/utils/waitForNodeOnline.js +7 -6
- package/dist/cjs/utils/waitForNodeOnline.js.map +1 -1
- package/dist/esm/ESPDevice.js +6 -0
- package/dist/esm/ESPDevice.js.map +1 -1
- package/dist/esm/ESPRMNeoNode.js +33 -14
- package/dist/esm/ESPRMNeoNode.js.map +1 -1
- package/dist/esm/index.js +3 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/methods/ESPDevice/Provision.js +7 -0
- package/dist/esm/methods/ESPDevice/Provision.js.map +1 -1
- package/dist/esm/methods/ESPDevice/ResetWifiStatus.js +24 -0
- package/dist/esm/methods/ESPDevice/ResetWifiStatus.js.map +1 -0
- package/dist/esm/methods/ESPDevice/RetryNetworkCredentials.js +44 -0
- package/dist/esm/methods/ESPDevice/RetryNetworkCredentials.js.map +1 -0
- package/dist/esm/methods/ESPRMNeoNode/Sync.js +4 -1
- package/dist/esm/methods/ESPRMNeoNode/Sync.js.map +1 -1
- package/dist/esm/methods/ESPRMNeoUser/MQTT/AssumeRole.js +9 -10
- package/dist/esm/methods/ESPRMNeoUser/MQTT/AssumeRole.js.map +1 -1
- package/dist/esm/proto/esp_rmaker_chal_resp.js +5 -0
- package/dist/esm/proto/esp_rmaker_chal_resp.js.map +1 -1
- package/dist/esm/services/ESPRMNeoMqtt/ESPRMNeoMqtt.js +13 -0
- package/dist/esm/services/ESPRMNeoMqtt/ESPRMNeoMqtt.js.map +1 -1
- package/dist/esm/services/NodeMQTTOrchestrator.js +2 -5
- package/dist/esm/services/NodeMQTTOrchestrator.js.map +1 -1
- package/dist/esm/utils/constants.js +10 -1
- package/dist/esm/utils/constants.js.map +1 -1
- package/dist/esm/utils/nodeUtils.js +12 -1
- package/dist/esm/utils/nodeUtils.js.map +1 -1
- package/dist/esm/utils/waitForNodeOnline.js +7 -6
- package/dist/esm/utils/waitForNodeOnline.js.map +1 -1
- package/dist/types/ESPDevice.d.ts +10 -0
- package/dist/types/ESPRMNeoNode.d.ts +17 -5
- package/dist/types/methods/ESPDevice/ResetWifiStatus.d.ts +18 -0
- package/dist/types/methods/ESPDevice/RetryNetworkCredentials.d.ts +22 -0
- package/dist/types/methods/ESPDevice/index.d.ts +2 -0
- package/dist/types/methods/ESPRMNeoUser/MQTT/AssumeRole.d.ts +25 -15
- package/dist/types/services/ESPRMNeoMqtt/ESPRMNeoMqtt.d.ts +10 -0
- package/dist/types/services/NodeMQTTOrchestrator.d.ts +2 -2
- package/dist/types/services/interfaces/MQTTTransport.d.ts +10 -0
- package/dist/types/types/provision.d.ts +10 -0
- package/dist/types/utils/constants.d.ts +10 -1
- package/dist/types/utils/waitForNodeOnline.d.ts +9 -3
- package/package.json +1 -1
|
@@ -5,29 +5,39 @@ import { AWSCredentials } from "../../../types/input";
|
|
|
5
5
|
declare module "../../../ESPRMNeoUser" {
|
|
6
6
|
interface ESPRMNeoUser {
|
|
7
7
|
/**
|
|
8
|
-
* Exchanges identity (temporary) credentials for role-based
|
|
8
|
+
* Exchanges identity (temporary) credentials for role-based credentials.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
* (
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* Two modes — chosen by whether `options.services` is set:
|
|
11
|
+
* 1. Default (no `options.services`): POST /v1/assumed-roles. Returns
|
|
12
|
+
* IoT/MQTT credentials scoped to the user's group/subgroup membership.
|
|
13
|
+
* Used for MQTT WebSocket auth.
|
|
14
|
+
* 2. Per-node services (`options.services` with `nodeId`):
|
|
15
|
+
* Same route, with `services` and `node_id` in the body. Returns
|
|
16
|
+
* credentials scoped to that single node for the listed services
|
|
17
|
+
* (currently `s3` and/or `kvs`). The response contains only the
|
|
18
|
+
* requested service permissions — no IoT/MQTT statements.
|
|
14
19
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* @param accessKey - AWS access key from getTemporaryAWSCredentials (identity credentials).
|
|
20
|
+
* @param accessKey - AWS access key from getTemporaryAWSCredentials.
|
|
18
21
|
* @param secretKey - AWS secret key from getTemporaryAWSCredentials.
|
|
19
22
|
* @param sessionToken - AWS session token from getTemporaryAWSCredentials.
|
|
20
|
-
* @param options - Optional
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* @
|
|
24
|
-
* @throws Error if the API call fails or if the response is invalid.
|
|
23
|
+
* @param options - Optional. To request per-node service credentials, pass
|
|
24
|
+
* `services` and `nodeId`.
|
|
25
|
+
* @returns A promise that resolves to AWSCredentials.
|
|
26
|
+
* @throws Error if `services` is set without `nodeId`, or if the API call fails.
|
|
25
27
|
*/
|
|
26
28
|
assumeRole(accessKey: string, secretKey: string, sessionToken: string, options?: AssumeRoleOptions): Promise<AWSCredentials>;
|
|
27
29
|
}
|
|
28
30
|
}
|
|
31
|
+
/** Per-node service credentials supported by the backend. */
|
|
32
|
+
export type AssumeRoleService = "s3" | "kvs";
|
|
29
33
|
/** Options for the assumeRole method. */
|
|
30
34
|
export interface AssumeRoleOptions {
|
|
31
|
-
/**
|
|
32
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Services to scope credentials to (e.g., `["s3"]`, `["kvs"]`, `["s3", "kvs"]`).
|
|
37
|
+
* When set, `nodeId` is required and the returned credentials contain only the
|
|
38
|
+
* listed service permissions for that single node.
|
|
39
|
+
*/
|
|
40
|
+
services?: AssumeRoleService[];
|
|
41
|
+
/** Required when `services` is set. The node these credentials apply to. */
|
|
42
|
+
nodeId?: string;
|
|
33
43
|
}
|
|
@@ -58,6 +58,16 @@ export declare class ESPRMNeoMqtt implements MQTTTransport {
|
|
|
58
58
|
* Returns whether the underlying MQTT client is connected.
|
|
59
59
|
*/
|
|
60
60
|
isConnected(): Promise<boolean>;
|
|
61
|
+
/**
|
|
62
|
+
* Registers a transport connection-status listener when the underlying
|
|
63
|
+
* adapter supports it; otherwise returns a no-op unsubscribe.
|
|
64
|
+
*
|
|
65
|
+
* @param callback - Invoked with `{ connected }` on status changes
|
|
66
|
+
* @returns Unsubscribe function
|
|
67
|
+
*/
|
|
68
|
+
onConnectionStatusChange(callback: (status: {
|
|
69
|
+
connected: boolean;
|
|
70
|
+
}) => void): () => void;
|
|
61
71
|
/**
|
|
62
72
|
* Publish a message to a topic.
|
|
63
73
|
*
|
|
@@ -76,8 +76,8 @@ export declare class NodeMQTTOrchestrator {
|
|
|
76
76
|
/**
|
|
77
77
|
* Registers a node with the orchestrator.
|
|
78
78
|
* Must be called before subscribeToNode, getParams, getShadow, etc.
|
|
79
|
-
* On shadow rename: clears the old binding
|
|
80
|
-
*
|
|
79
|
+
* On shadow rename: clears the old binding, then installs the new name
|
|
80
|
+
* (including shrinks to a shorter membership shadow).
|
|
81
81
|
*
|
|
82
82
|
* @param nodeId - The device/node identifier.
|
|
83
83
|
* @param shadowName - The named shadow (e.g. `params-groupId-subgroupId`).
|
|
@@ -18,6 +18,16 @@ export interface MQTTTransport {
|
|
|
18
18
|
* Check if the MQTT client is connected.
|
|
19
19
|
*/
|
|
20
20
|
isConnected(): Promise<boolean>;
|
|
21
|
+
/**
|
|
22
|
+
* Optional push notification when the transport connects or drops.
|
|
23
|
+
* Returns an unsubscribe function. Not required by NodeMQTTOrchestrator;
|
|
24
|
+
* adapters that omit it simply do not surface async status changes.
|
|
25
|
+
*
|
|
26
|
+
* @param callback - Invoked with `{ connected }` on status changes
|
|
27
|
+
*/
|
|
28
|
+
onConnectionStatusChange?(callback: (status: {
|
|
29
|
+
connected: boolean;
|
|
30
|
+
}) => void): () => void;
|
|
21
31
|
/**
|
|
22
32
|
* Publish a message to a topic.
|
|
23
33
|
*
|
|
@@ -73,6 +73,16 @@ interface ESPProvisionAdapterInterface {
|
|
|
73
73
|
scanWifiList(deviceName: string): Promise<ESPWifiList[]>;
|
|
74
74
|
sendData(deviceName: string, endPoint: string, data: string): Promise<string>;
|
|
75
75
|
provision(deviceName: string, ssid: string, passphrase: string): Promise<ESPProvisionStatus>;
|
|
76
|
+
/**
|
|
77
|
+
* Clears the device's Wi-Fi state over the open provisioning session.
|
|
78
|
+
* Requires an established session; the user-node association is left intact.
|
|
79
|
+
*
|
|
80
|
+
* Optional so that adapters written against an earlier SDK keep compiling;
|
|
81
|
+
* `ESPDevice.resetWifiStatus` resolves `false` when it is absent.
|
|
82
|
+
* @param deviceName - Name of the connected provisioning device.
|
|
83
|
+
* @returns Promise resolving to `true` when the device acknowledged the reset.
|
|
84
|
+
*/
|
|
85
|
+
resetWifiStatus?(deviceName: string): Promise<boolean>;
|
|
76
86
|
disconnect(deviceName: string): Promise<void>;
|
|
77
87
|
}
|
|
78
88
|
/**
|
|
@@ -386,6 +386,15 @@ declare const TriggerErrorMessages: {
|
|
|
386
386
|
/** Logged when retrieving triggers for a node fails. */
|
|
387
387
|
readonly GET_FAILED: "getTriggers failed";
|
|
388
388
|
};
|
|
389
|
+
/**
|
|
390
|
+
* Error messages for assumeRole (POST /v1/assumed-roles).
|
|
391
|
+
*/
|
|
392
|
+
declare const AssumeRoleErrorMessages: {
|
|
393
|
+
/** Thrown when `services` is provided without a `nodeId`. */
|
|
394
|
+
readonly NODE_ID_REQUIRED: "assumeRole: nodeId is required when services is provided";
|
|
395
|
+
/** Thrown when the assume-role response is missing required credential fields. */
|
|
396
|
+
readonly INVALID_RESPONSE: "Invalid assume role response: missing required credential fields";
|
|
397
|
+
};
|
|
389
398
|
/**
|
|
390
399
|
* Error / log messages for temporary AWS credentials (POST /v1/user/credentials).
|
|
391
400
|
*/
|
|
@@ -800,7 +809,7 @@ declare const APIPathV1: {
|
|
|
800
809
|
/** POST /v1/groups/{groupId}/node-assoc-requests/{requestId}/verify - Verifies user node mapping */
|
|
801
810
|
readonly USER_NODE_MAPPING_VERIFY: (groupId: string, requestId: string) => string;
|
|
802
811
|
};
|
|
803
|
-
export { HTTPMethods, APIEndpoints, APIPathV1, StorageKeys, ValidationErrorCodes, StorageAdapterErrorCodes, ConfigErrorCodes, APICallValidationErrorCodes, APIOperations, TokenErrorCodes, AuthErrorCodes, AuthSuccessMessages, AutomationSuccessMessages, AutomationStatusValues, GroupSuccessMessages, NodeSuccessMessages, NodeWarnMessages, ScheduleSuccessMessages, ScheduleErrorMessages, TriggerErrorMessages, TriggerSuccessMessages, SharingSuccessMessages, IntegrationSuccessMessages, 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, };
|
|
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, };
|
|
804
813
|
export declare enum ESPRMNeoErrorCodes {
|
|
805
814
|
SDK_NOT_CONFIGURED = "SDK_NOT_CONFIGURED",
|
|
806
815
|
INVALID_CREDENTIALS = "INVALID_CREDENTIALS",
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Typical use: after provisioning WiFi credentials, the device joins the network and
|
|
5
5
|
* connects to the cloud. There is no dedicated "online" MQTT topic — connectivity is
|
|
6
6
|
* published as `state.reported.online` inside shadow update messages on the named
|
|
7
|
-
* shadow `params-{groupId}` (firmware writes this
|
|
8
|
-
* only clears online on disconnect).
|
|
7
|
+
* shadow `params-{groupId}` or `params-{groupId}-{subgroupIds}` (firmware writes this
|
|
8
|
+
* after getGroupInfo; cloud presence only clears online on disconnect).
|
|
9
9
|
*
|
|
10
10
|
* Matches app_sim `_wait_node_online`: subscribe first, then poll shadow GET on an
|
|
11
11
|
* interval until `reported.online === true` (or a live MQTT update arrives). GET may
|
|
@@ -24,6 +24,12 @@ export interface WaitForNodeOnlineParams {
|
|
|
24
24
|
nodeId: string;
|
|
25
25
|
/** Group the node was associated with during provisioning (drives shadow name). */
|
|
26
26
|
groupId: string;
|
|
27
|
+
/**
|
|
28
|
+
* Subgroup (room/CG) ids that currently contain the node.
|
|
29
|
+
* Omitted or empty ⇒ home-only shadow `params-{groupId}` (legacy callers).
|
|
30
|
+
* When set, shadow is `params-{groupId}-{sortedSubgroupIds}`.
|
|
31
|
+
*/
|
|
32
|
+
subgroupIds?: string[];
|
|
27
33
|
/** Logged-in user; used to connect MQTT if not already connected. */
|
|
28
34
|
user: ESPRMNeoUser;
|
|
29
35
|
timeoutMs?: number;
|
|
@@ -45,4 +51,4 @@ export declare function isNodeOnlineFromShadowPayload(payload: unknown): boolean
|
|
|
45
51
|
* @throws {ESPProvError} If `timeoutMs` elapses without the node reporting online.
|
|
46
52
|
* @throws {Error} If MQTT connection or subscription fails.
|
|
47
53
|
*/
|
|
48
|
-
export declare function waitForNodeOnline({ nodeId, groupId, user, timeoutMs, pollIntervalMs, }: WaitForNodeOnlineParams): Promise<void>;
|
|
54
|
+
export declare function waitForNodeOnline({ nodeId, groupId, subgroupIds, user, timeoutMs, pollIntervalMs, }: WaitForNodeOnlineParams): Promise<void>;
|
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.
|
|
4
|
+
"version": "1.1.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/cjs/index.js",
|