yoto-nodejs-client 0.0.1 → 0.0.2
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/bin/lib/cli-helpers.d.ts +32 -0
- package/bin/lib/cli-helpers.d.ts.map +1 -1
- package/bin/lib/token-helpers.d.ts +32 -0
- package/bin/lib/token-helpers.d.ts.map +1 -1
- package/index.d.ts +368 -0
- package/index.d.ts.map +1 -1
- package/lib/api-endpoints/auth.d.ts +85 -0
- package/lib/api-endpoints/auth.d.ts.map +1 -1
- package/lib/api-endpoints/constants.d.ts +22 -0
- package/lib/api-endpoints/constants.d.ts.map +1 -1
- package/lib/api-endpoints/content.d.ts +760 -0
- package/lib/api-endpoints/content.d.ts.map +1 -1
- package/lib/api-endpoints/devices.d.ts +581 -0
- package/lib/api-endpoints/devices.d.ts.map +1 -1
- package/lib/api-endpoints/family-library-groups.d.ts +187 -0
- package/lib/api-endpoints/family-library-groups.d.ts.map +1 -1
- package/lib/api-endpoints/family.d.ts +88 -0
- package/lib/api-endpoints/family.d.ts.map +1 -1
- package/lib/api-endpoints/helpers.d.ts +37 -3
- package/lib/api-endpoints/helpers.d.ts.map +1 -1
- package/lib/api-endpoints/icons.d.ts +196 -0
- package/lib/api-endpoints/icons.d.ts.map +1 -1
- package/lib/api-endpoints/media.d.ts +83 -0
- package/lib/api-endpoints/media.d.ts.map +1 -1
- package/lib/api-endpoints/test-helpers.d.ts +21 -0
- package/lib/api-endpoints/test-helpers.d.ts.map +1 -1
- package/lib/mqtt/client.d.ts +277 -0
- package/lib/mqtt/client.d.ts.map +1 -1
- package/lib/mqtt/commands.d.ts +195 -0
- package/lib/mqtt/commands.d.ts.map +1 -1
- package/lib/mqtt/factory.d.ts +43 -0
- package/lib/mqtt/factory.d.ts.map +1 -1
- package/lib/mqtt/topics.d.ts +157 -0
- package/lib/mqtt/topics.d.ts.map +1 -1
- package/lib/token.d.ts +88 -0
- package/lib/token.d.ts.map +1 -1
- package/package.json +1 -1
package/lib/mqtt/factory.d.ts
CHANGED
|
@@ -1,11 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a configured MQTT client for a Yoto device
|
|
3
|
+
* @param {YotoMqttOptions} options - MQTT connection options
|
|
4
|
+
* @returns {YotoMqttClient} Configured Yoto MQTT client
|
|
5
|
+
* @throws {Error} If required options are missing
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```javascript
|
|
9
|
+
* import { createYotoMqttClient } from 'yoto-nodejs-client/lib/mqtt'
|
|
10
|
+
*
|
|
11
|
+
* const client = createYotoMqttClient({
|
|
12
|
+
* deviceId: 'abc123',
|
|
13
|
+
* accessToken: 'eyJhbGc...'
|
|
14
|
+
* })
|
|
15
|
+
*
|
|
16
|
+
* client.on('events', (message) => {
|
|
17
|
+
* console.log('Playing:', message.trackTitle)
|
|
18
|
+
* })
|
|
19
|
+
*
|
|
20
|
+
* await client.connect()
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
1
23
|
export function createYotoMqttClient(options: YotoMqttOptions): YotoMqttClient;
|
|
2
24
|
export type YotoMqttOptions = {
|
|
25
|
+
/**
|
|
26
|
+
* - Device ID to connect to
|
|
27
|
+
*/
|
|
3
28
|
deviceId: string;
|
|
29
|
+
/**
|
|
30
|
+
* - JWT access token for authentication
|
|
31
|
+
*/
|
|
4
32
|
accessToken: string;
|
|
33
|
+
/**
|
|
34
|
+
* - Prefix for MQTT client ID (default: 'DASH')
|
|
35
|
+
*/
|
|
5
36
|
clientIdPrefix?: string;
|
|
37
|
+
/**
|
|
38
|
+
* - MQTT broker URL
|
|
39
|
+
*/
|
|
6
40
|
brokerUrl?: string;
|
|
41
|
+
/**
|
|
42
|
+
* - Keepalive interval in seconds
|
|
43
|
+
*/
|
|
7
44
|
keepalive?: number;
|
|
45
|
+
/**
|
|
46
|
+
* - MQTT broker port
|
|
47
|
+
*/
|
|
8
48
|
port?: number;
|
|
49
|
+
/**
|
|
50
|
+
* - Auto-subscribe to device topics on connect
|
|
51
|
+
*/
|
|
9
52
|
autoSubscribe?: boolean;
|
|
10
53
|
};
|
|
11
54
|
import { YotoMqttClient } from './client.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["factory.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["factory.js"],"names":[],"mappings":"AAqCA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,8CApBW,eAAe,GACb,cAAc,CAkE1B;;;;;cAzFa,MAAM;;;;iBACN,MAAM;;;;qBACN,MAAM;;;;gBACN,MAAM;;;;gBACN,MAAM;;;;WACN,MAAM;;;;oBACN,OAAO;;+BAIU,aAAa"}
|
package/lib/mqtt/topics.d.ts
CHANGED
|
@@ -1,34 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the events topics for a device (both old and new formats)
|
|
3
|
+
* Devices publish to both paths, so both are returned
|
|
4
|
+
* @param {string} deviceId - Device ID
|
|
5
|
+
* @returns {string[]} Events topics [old format, new format]
|
|
6
|
+
*/
|
|
1
7
|
export function getEventsTopic(deviceId: string): string[];
|
|
8
|
+
/**
|
|
9
|
+
* Get the status topics for a device (both old and new formats)
|
|
10
|
+
* Devices publish to both paths, so both are returned
|
|
11
|
+
* @param {string} deviceId - Device ID
|
|
12
|
+
* @returns {string[]} Status topics [old format, new format]
|
|
13
|
+
*/
|
|
2
14
|
export function getStatusTopic(deviceId: string): string[];
|
|
15
|
+
/**
|
|
16
|
+
* Get the response topic for a device (subscribe)
|
|
17
|
+
* @param {string} deviceId - Device ID
|
|
18
|
+
* @returns {string} Response topic
|
|
19
|
+
*/
|
|
3
20
|
export function getResponseTopic(deviceId: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Get all subscription topics for a device
|
|
23
|
+
*
|
|
24
|
+
* Subscribes to both old and new topic formats because Yoto devices publish to both:
|
|
25
|
+
* - Old format: device/{id}/events, device/{id}/status
|
|
26
|
+
* - New format: device/{id}/data/events, device/{id}/data/status
|
|
27
|
+
*
|
|
28
|
+
* This ensures all messages are received regardless of which path the device uses.
|
|
29
|
+
*
|
|
30
|
+
* @param {string} deviceId - Device ID
|
|
31
|
+
* @returns {string[]} Array of topics to subscribe to (includes both old and new formats)
|
|
32
|
+
*/
|
|
4
33
|
export function getSubscriptionTopics(deviceId: string): string[];
|
|
34
|
+
/**
|
|
35
|
+
* Get a command topic for a device (publish)
|
|
36
|
+
* @param {string} deviceId - Device ID
|
|
37
|
+
* @param {string} resource - Command resource (e.g., 'volume', 'ambients', 'card')
|
|
38
|
+
* @param {string} [action] - Command action (e.g., 'set', 'start', 'stop')
|
|
39
|
+
* @returns {string} Command topic
|
|
40
|
+
*/
|
|
5
41
|
export function getCommandTopic(deviceId: string, resource: string, action?: string): string;
|
|
42
|
+
/**
|
|
43
|
+
* Parse a topic string to extract device ID and message type
|
|
44
|
+
* @param {string} topic - Full MQTT topic string
|
|
45
|
+
* @returns {{ deviceId: string, messageType: YotoMqttTopicType | 'unknown' }} Parsed topic info
|
|
46
|
+
*/
|
|
6
47
|
export function parseTopic(topic: string): {
|
|
7
48
|
deviceId: string;
|
|
8
49
|
messageType: YotoMqttTopicType | "unknown";
|
|
9
50
|
};
|
|
51
|
+
/**
|
|
52
|
+
* Get the events request command topic
|
|
53
|
+
* @param {string} deviceId - Device ID
|
|
54
|
+
* @returns {string} Events request topic
|
|
55
|
+
*/
|
|
10
56
|
export function getEventsRequestTopic(deviceId: string): string;
|
|
57
|
+
/**
|
|
58
|
+
* Get the status request command topic
|
|
59
|
+
* @param {string} deviceId - Device ID
|
|
60
|
+
* @returns {string} Status request topic
|
|
61
|
+
*/
|
|
11
62
|
export function getStatusRequestTopic(deviceId: string): string;
|
|
63
|
+
/**
|
|
64
|
+
* Get the volume set command topic
|
|
65
|
+
* @param {string} deviceId - Device ID
|
|
66
|
+
* @returns {string} Volume set topic
|
|
67
|
+
*/
|
|
12
68
|
export function getVolumeSetTopic(deviceId: string): string;
|
|
69
|
+
/**
|
|
70
|
+
* Get the ambients set command topic
|
|
71
|
+
* @param {string} deviceId - Device ID
|
|
72
|
+
* @returns {string} Ambients set topic
|
|
73
|
+
*/
|
|
13
74
|
export function getAmbientsSetTopic(deviceId: string): string;
|
|
75
|
+
/**
|
|
76
|
+
* Get the sleep timer set command topic
|
|
77
|
+
* @param {string} deviceId - Device ID
|
|
78
|
+
* @returns {string} Sleep timer set topic
|
|
79
|
+
*/
|
|
14
80
|
export function getSleepTimerSetTopic(deviceId: string): string;
|
|
81
|
+
/**
|
|
82
|
+
* Get the reboot command topic
|
|
83
|
+
* @param {string} deviceId - Device ID
|
|
84
|
+
* @returns {string} Reboot topic
|
|
85
|
+
*/
|
|
15
86
|
export function getRebootTopic(deviceId: string): string;
|
|
87
|
+
/**
|
|
88
|
+
* Get the card start command topic
|
|
89
|
+
* @param {string} deviceId - Device ID
|
|
90
|
+
* @returns {string} Card start topic
|
|
91
|
+
*/
|
|
16
92
|
export function getCardStartTopic(deviceId: string): string;
|
|
93
|
+
/**
|
|
94
|
+
* Get the card stop command topic
|
|
95
|
+
* @param {string} deviceId - Device ID
|
|
96
|
+
* @returns {string} Card stop topic
|
|
97
|
+
*/
|
|
17
98
|
export function getCardStopTopic(deviceId: string): string;
|
|
99
|
+
/**
|
|
100
|
+
* Get the card pause command topic
|
|
101
|
+
* @param {string} deviceId - Device ID
|
|
102
|
+
* @returns {string} Card pause topic
|
|
103
|
+
*/
|
|
18
104
|
export function getCardPauseTopic(deviceId: string): string;
|
|
105
|
+
/**
|
|
106
|
+
* Get the card resume command topic
|
|
107
|
+
* @param {string} deviceId - Device ID
|
|
108
|
+
* @returns {string} Card resume topic
|
|
109
|
+
*/
|
|
19
110
|
export function getCardResumeTopic(deviceId: string): string;
|
|
111
|
+
/**
|
|
112
|
+
* Get the bluetooth on command topic
|
|
113
|
+
* @param {string} deviceId - Device ID
|
|
114
|
+
* @returns {string} Bluetooth on topic
|
|
115
|
+
*/
|
|
20
116
|
export function getBluetoothOnTopic(deviceId: string): string;
|
|
117
|
+
/**
|
|
118
|
+
* Get the bluetooth off command topic
|
|
119
|
+
* @param {string} deviceId - Device ID
|
|
120
|
+
* @returns {string} Bluetooth off topic
|
|
121
|
+
*/
|
|
21
122
|
export function getBluetoothOffTopic(deviceId: string): string;
|
|
123
|
+
/**
|
|
124
|
+
* Get the bluetooth delete bonds command topic
|
|
125
|
+
* @param {string} deviceId - Device ID
|
|
126
|
+
* @returns {string} Bluetooth delete bonds topic
|
|
127
|
+
*/
|
|
22
128
|
export function getBluetoothDeleteBondsTopic(deviceId: string): string;
|
|
129
|
+
/**
|
|
130
|
+
* Get the bluetooth connect command topic
|
|
131
|
+
* @param {string} deviceId - Device ID
|
|
132
|
+
* @returns {string} Bluetooth connect topic
|
|
133
|
+
*/
|
|
23
134
|
export function getBluetoothConnectTopic(deviceId: string): string;
|
|
135
|
+
/**
|
|
136
|
+
* Get the bluetooth disconnect command topic
|
|
137
|
+
* @param {string} deviceId - Device ID
|
|
138
|
+
* @returns {string} Bluetooth disconnect topic
|
|
139
|
+
*/
|
|
24
140
|
export function getBluetoothDisconnectTopic(deviceId: string): string;
|
|
141
|
+
/**
|
|
142
|
+
* Get the bluetooth state command topic
|
|
143
|
+
* @param {string} deviceId - Device ID
|
|
144
|
+
* @returns {string} Bluetooth state topic
|
|
145
|
+
*/
|
|
25
146
|
export function getBluetoothStateTopic(deviceId: string): string;
|
|
147
|
+
/**
|
|
148
|
+
* Get the display preview command topic
|
|
149
|
+
* @param {string} deviceId - Device ID
|
|
150
|
+
* @returns {string} Display preview topic
|
|
151
|
+
*/
|
|
26
152
|
export function getDisplayPreviewTopic(deviceId: string): string;
|
|
153
|
+
/**
|
|
154
|
+
* MQTT Topics for Yoto Players
|
|
155
|
+
*
|
|
156
|
+
* Topic builders and constants for Yoto MQTT communication
|
|
157
|
+
* @see https://yoto.dev/players-mqtt/
|
|
158
|
+
*/
|
|
159
|
+
/**
|
|
160
|
+
* MQTT topic type for subscriptions
|
|
161
|
+
* @typedef {'events' | 'status' | 'response'} YotoMqttTopicType
|
|
162
|
+
*/
|
|
163
|
+
/**
|
|
164
|
+
* MQTT broker URL for Yoto devices
|
|
165
|
+
*/
|
|
27
166
|
export const MQTT_BROKER_URL: "wss://aqrphjqbp3u2z-ats.iot.eu-west-2.amazonaws.com";
|
|
167
|
+
/**
|
|
168
|
+
* MQTT authorizer name for Yoto authentication
|
|
169
|
+
*/
|
|
28
170
|
export const MQTT_AUTH_NAME: "PublicJWTAuthorizer";
|
|
171
|
+
/**
|
|
172
|
+
* MQTT connection port
|
|
173
|
+
*/
|
|
29
174
|
export const MQTT_PORT: 443;
|
|
175
|
+
/**
|
|
176
|
+
* MQTT protocol
|
|
177
|
+
*/
|
|
30
178
|
export const MQTT_PROTOCOL: "wss";
|
|
179
|
+
/**
|
|
180
|
+
* MQTT keepalive interval in seconds
|
|
181
|
+
*/
|
|
31
182
|
export const MQTT_KEEPALIVE: 300;
|
|
183
|
+
/**
|
|
184
|
+
* ALPN protocols for AWS IoT
|
|
185
|
+
*/
|
|
32
186
|
export const MQTT_ALPN_PROTOCOLS: string[];
|
|
187
|
+
/**
|
|
188
|
+
* MQTT topic type for subscriptions
|
|
189
|
+
*/
|
|
33
190
|
export type YotoMqttTopicType = "events" | "status" | "response";
|
|
34
191
|
//# sourceMappingURL=topics.d.ts.map
|
package/lib/mqtt/topics.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"topics.d.ts","sourceRoot":"","sources":["topics.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"topics.d.ts","sourceRoot":"","sources":["topics.js"],"names":[],"mappings":"AA8CA;;;;;GAKG;AACH,yCAHW,MAAM,GACJ,MAAM,EAAE,CAOpB;AAED;;;;;GAKG;AACH,yCAHW,MAAM,GACJ,MAAM,EAAE,CAOpB;AAED;;;;GAIG;AACH,2CAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;;;;;;;;;GAWG;AACH,gDAHW,MAAM,GACJ,MAAM,EAAE,CAQpB;AAED;;;;;;GAMG;AACH,0CALW,MAAM,YACN,MAAM,WACN,MAAM,GACJ,MAAM,CAKlB;AAED;;;;GAIG;AACH,kCAHW,MAAM,GACJ;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,iBAAiB,GAAG,SAAS,CAAA;CAAE,CAuB5E;AAID;;;;GAIG;AACH,gDAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;;GAIG;AACH,gDAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;;GAIG;AACH,4CAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;;GAIG;AACH,8CAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;;GAIG;AACH,gDAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;;GAIG;AACH,yCAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;;GAIG;AACH,4CAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;;GAIG;AACH,2CAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;;GAIG;AACH,4CAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;;GAIG;AACH,6CAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;;GAIG;AACH,8CAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;;GAIG;AACH,+CAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;;GAIG;AACH,uDAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;;GAIG;AACH,mDAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;;GAIG;AACH,sDAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;;GAIG;AACH,iDAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;;GAIG;AACH,iDAHW,MAAM,GACJ,MAAM,CAIlB;AAtSD;;;;;GAKG;AAMH;;;GAGG;AAEH;;GAEG;AACH,8BAA+B,qDAAqD,CAAA;AAEpF;;GAEG;AACH,6BAA8B,qBAAqB,CAAA;AAEnD;;GAEG;AACH,wBAAyB,GAAG,CAAA;AAE5B;;GAEG;AACH,4BAA6B,KAAK,CAAA;AAElC;;GAEG;AACH,6BAA8B,GAAG,CAAA;AAEjC;;GAEG;AACH,2CAAqD;;;;gCA/BxC,QAAQ,GAAG,QAAQ,GAAG,UAAU"}
|
package/lib/token.d.ts
CHANGED
|
@@ -1,24 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} RefreshableTokenOpts
|
|
3
|
+
* @property {string} clientId - OAuth client ID
|
|
4
|
+
* @property {string} refreshToken - OAuth refresh token
|
|
5
|
+
* @property {string} accessToken - Initial OAuth access token (JWT)
|
|
6
|
+
* @property {number} [bufferSeconds=30] - Seconds before expiration to consider token expired
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {Object} RefreshSuccessEvent
|
|
10
|
+
* @property {string} clientId - The OAuth client ID
|
|
11
|
+
* @property {string} accessToken - The new access token
|
|
12
|
+
* @property {string} refreshToken - The refresh token (may be updated)
|
|
13
|
+
* @property {number} expiresAt - Unix timestamp in seconds when token expires
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Event map for RefreshableToken
|
|
17
|
+
* @typedef {{
|
|
18
|
+
* 'refresh:start': [],
|
|
19
|
+
* 'refresh:success': [RefreshSuccessEvent],
|
|
20
|
+
* 'refresh:error': [Error],
|
|
21
|
+
* 'invalid': [Error]
|
|
22
|
+
* }} RefreshableTokenEventMap
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* A refreshable OAuth token that automatically refreshes when expired.
|
|
26
|
+
* Handles in-flight refresh deduplication to prevent multiple concurrent refresh requests.
|
|
27
|
+
*
|
|
28
|
+
* Events:
|
|
29
|
+
* - 'refresh:start' - Emitted when token refresh begins
|
|
30
|
+
* - 'refresh:success' - Emitted when token refresh succeeds, passes { clientId, accessToken, refreshToken, expiresAt }
|
|
31
|
+
* - 'refresh:error' - Emitted when token refresh fails (transient errors), passes error
|
|
32
|
+
* - 'invalid' - Emitted when refresh token is permanently invalid, passes error
|
|
33
|
+
*
|
|
34
|
+
* @extends {EventEmitter<RefreshableTokenEventMap>}
|
|
35
|
+
*/
|
|
1
36
|
export class RefreshableToken extends EventEmitter<RefreshableTokenEventMap> {
|
|
37
|
+
/**
|
|
38
|
+
* @param {RefreshableTokenOpts} opts
|
|
39
|
+
*/
|
|
2
40
|
constructor({ clientId, refreshToken, accessToken, bufferSeconds }: RefreshableTokenOpts);
|
|
41
|
+
/**
|
|
42
|
+
* Get a valid access token, refreshing if necessary.
|
|
43
|
+
* @returns {Promise<string>} Valid access token
|
|
44
|
+
* @throws {Error} If token is invalid or refresh fails
|
|
45
|
+
*/
|
|
3
46
|
getAccessToken(): Promise<string>;
|
|
47
|
+
/**
|
|
48
|
+
* Check if the token is currently valid (not expired and not marked invalid).
|
|
49
|
+
* @returns {boolean} True if token is valid
|
|
50
|
+
*/
|
|
4
51
|
isValid(): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Get the expiration timestamp of the current access token.
|
|
54
|
+
* @returns {number} Unix timestamp (seconds since epoch)
|
|
55
|
+
*/
|
|
5
56
|
getExpiresAt(): number;
|
|
57
|
+
/**
|
|
58
|
+
* Get the time remaining until token expiration.
|
|
59
|
+
* @returns {number} Seconds until expiration (may be negative if expired)
|
|
60
|
+
*/
|
|
6
61
|
getTimeRemaining(): number;
|
|
62
|
+
/**
|
|
63
|
+
* Manually trigger a token refresh, regardless of expiration status.
|
|
64
|
+
* Useful for proactive refresh or testing.
|
|
65
|
+
* @returns {Promise<RefreshSuccessEvent>} Token information including clientId, accessToken, refreshToken, and expiresAt
|
|
66
|
+
* @throws {Error} If token is invalid or refresh fails
|
|
67
|
+
*/
|
|
7
68
|
refresh(): Promise<RefreshSuccessEvent>;
|
|
8
69
|
#private;
|
|
9
70
|
}
|
|
10
71
|
export type RefreshableTokenOpts = {
|
|
72
|
+
/**
|
|
73
|
+
* - OAuth client ID
|
|
74
|
+
*/
|
|
11
75
|
clientId: string;
|
|
76
|
+
/**
|
|
77
|
+
* - OAuth refresh token
|
|
78
|
+
*/
|
|
12
79
|
refreshToken: string;
|
|
80
|
+
/**
|
|
81
|
+
* - Initial OAuth access token (JWT)
|
|
82
|
+
*/
|
|
13
83
|
accessToken: string;
|
|
84
|
+
/**
|
|
85
|
+
* - Seconds before expiration to consider token expired
|
|
86
|
+
*/
|
|
14
87
|
bufferSeconds?: number;
|
|
15
88
|
};
|
|
16
89
|
export type RefreshSuccessEvent = {
|
|
90
|
+
/**
|
|
91
|
+
* - The OAuth client ID
|
|
92
|
+
*/
|
|
17
93
|
clientId: string;
|
|
94
|
+
/**
|
|
95
|
+
* - The new access token
|
|
96
|
+
*/
|
|
18
97
|
accessToken: string;
|
|
98
|
+
/**
|
|
99
|
+
* - The refresh token (may be updated)
|
|
100
|
+
*/
|
|
19
101
|
refreshToken: string;
|
|
102
|
+
/**
|
|
103
|
+
* - Unix timestamp in seconds when token expires
|
|
104
|
+
*/
|
|
20
105
|
expiresAt: number;
|
|
21
106
|
};
|
|
107
|
+
/**
|
|
108
|
+
* Event map for RefreshableToken
|
|
109
|
+
*/
|
|
22
110
|
export type RefreshableTokenEventMap = {
|
|
23
111
|
"refresh:start": [];
|
|
24
112
|
"refresh:success": [RefreshSuccessEvent];
|
package/lib/token.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["token.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["token.js"],"names":[],"mappings":"AAIA;;;;;;GAMG;AAEH;;;;;;GAMG;AAEH;;;;;;;;GAQG;AAEH;;;;;;;;;;;GAWG;AACH;IAgBE;;OAEG;IACH,oEAFW,oBAAoB,EAoB9B;IAED;;;;OAIG;IACH,kBAHa,OAAO,CAAC,MAAM,CAAC,CAiB3B;IAwFD;;;OAGG;IACH,WAFa,OAAO,CASnB;IAED;;;OAGG;IACH,gBAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,oBAFa,MAAM,CAKlB;IAED;;;;;OAKG;IACH,WAHa,OAAO,CAAC,mBAAmB,CAAC,CAiBxC;;CACF;;;;;cAzOa,MAAM;;;;kBACN,MAAM;;;;iBACN,MAAM;;;;oBACN,MAAM;;;;;;cAKN,MAAM;;;;iBACN,MAAM;;;;kBACN,MAAM;;;;eACN,MAAM;;;;;uCAKP;IACZ,eAAmB,EAAE,EAAE,CAAC;IACxB,iBAAqB,EAAE,CAAC,mBAAmB,CAAC,CAAC;IAC7C,eAAmB,EAAE,CAAC,KAAK,CAAC,CAAC;IAC7B,SAAa,EAAE,CAAC,KAAK,CAAC,CAAA;CACnB;6BA3ByB,aAAa"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yoto-nodejs-client",
|
|
3
3
|
"description": "(Unofficial) Node.js client for the Yoto API with automatic token refresh, MQTT device communication, and TypeScript support",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.2",
|
|
5
5
|
"author": "Bret Comnes <bcomnes@gmail.com> (https://bret.io)",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/bcomnes/yoto-nodejs-client/issues"
|