mirror of
https://github.com/bourquep/mysa-js-sdk.git
synced 2026-02-04 09:41:07 +00:00
Compare commits
1 Commits
180-rapid-
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c69b5d324a |
@@ -20,7 +20,6 @@ const rootLogger = pino({
|
||||
/** Main entry point of the example application. */
|
||||
async function main() {
|
||||
let session: MysaSession | undefined;
|
||||
|
||||
try {
|
||||
rootLogger.info('Loading session...');
|
||||
const sessionJson = await readFile('session.json', 'utf8');
|
||||
@@ -28,11 +27,7 @@ async function main() {
|
||||
} catch {
|
||||
rootLogger.info('No valid session file found.');
|
||||
}
|
||||
|
||||
const client = new MysaApiClient(session, {
|
||||
logger: rootLogger.child({ module: 'mysa-js-sdk' }),
|
||||
isAwsCrtDebugLoggingEnabled: process.env.AWS_CRT_DEBUG_LOGGING === '1'
|
||||
});
|
||||
const client = new MysaApiClient(session, { logger: rootLogger.child({ module: 'mysa-js-sdk' }) });
|
||||
|
||||
client.emitter.on('sessionChanged', async (newSession) => {
|
||||
if (newSession) {
|
||||
@@ -101,12 +96,14 @@ async function main() {
|
||||
});
|
||||
}
|
||||
|
||||
for (const [deviceId, device] of Object.entries(devices.DevicesObj)) {
|
||||
const serial = await client.getDeviceSerialNumber(deviceId);
|
||||
rootLogger.info(`Serial number for device '${deviceId}' (${device.Name ?? 'Unknown'}): ${serial}`);
|
||||
await Promise.all(
|
||||
Object.entries(devices.DevicesObj).map(async ([deviceId, device]) => {
|
||||
const serial = await client.getDeviceSerialNumber(deviceId);
|
||||
rootLogger.info(`Serial number for device '${deviceId}' (${device.Name ?? 'Unknown'}): ${serial}`);
|
||||
|
||||
await client.startRealtimeUpdates(deviceId);
|
||||
}
|
||||
await client.startRealtimeUpdates(deviceId);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
|
||||
21
package-lock.json
generated
21
package-lock.json
generated
@@ -2547,7 +2547,6 @@
|
||||
"integrity": "sha512-DhGl4xMVFGVIyMwswXeyzdL4uXD5OGILGX5N8Y+f6W7LhC1Ze2poSNrkF/fedpVDHEEZ+PHFW0vL14I+mm8K3Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@octokit/auth-token": "^6.0.0",
|
||||
"@octokit/graphql": "^9.0.3",
|
||||
@@ -4065,7 +4064,6 @@
|
||||
"integrity": "sha512-BnOroVl1SgrPLywqxyqdJ4l3S2MsKVLDVxZvjI1Eoe8ev2r3kGDo+PcMihNmDE+6/KjkTubSJnmqGZZjQSBq/g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/scope-manager": "8.46.2",
|
||||
"@typescript-eslint/types": "8.46.2",
|
||||
@@ -4274,7 +4272,6 @@
|
||||
"integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"acorn": "bin/acorn"
|
||||
},
|
||||
@@ -4465,7 +4462,6 @@
|
||||
"integrity": "sha512-LPVCX4If8nAy1OERzmFx/pVr4g6olBqbz30SoLTkVJu5m5WH5GkhbIKnucQ1e5ZbpfNh+nrsFM2dolXO8ow4PQ==",
|
||||
"hasInstallScript": true,
|
||||
"license": "Apache-2.0",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@aws-sdk/util-utf8-browser": "^3.259.0",
|
||||
"@httptoolkit/websocket-stream": "^6.0.1",
|
||||
@@ -5889,7 +5885,6 @@
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"esbuild": "bin/esbuild"
|
||||
},
|
||||
@@ -5953,7 +5948,6 @@
|
||||
"integrity": "sha512-BhHmn2yNOFA9H9JmmIVKJmd288g9hrVRDkdoIgRCRuSySRUHH7r/DI6aAXW9T1WwUuY3DFgrcaqB+deURBLR5g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@eslint-community/eslint-utils": "^4.8.0",
|
||||
"@eslint-community/regexpp": "^4.12.1",
|
||||
@@ -7473,9 +7467,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/lodash-es": {
|
||||
"version": "4.17.21",
|
||||
"resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz",
|
||||
"integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==",
|
||||
"version": "4.17.23",
|
||||
"resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.23.tgz",
|
||||
"integrity": "sha512-kVI48u3PZr38HdYz98UmfPnXl2DXrpdctLrFLCd3kOx1xUkOmpFPx7gCWWM5MPkL/fD8zb+Ph0QzjGFs4+hHWg==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
@@ -7576,7 +7570,6 @@
|
||||
"integrity": "sha512-8dD6FusOQSrpv9Z1rdNMdlSgQOIP880DHqnohobOmYLElGEqAL/JvxvuxZO16r4HtjTlfPRDC1hbvxC9dPN2nA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"marked": "bin/marked.js"
|
||||
},
|
||||
@@ -10803,7 +10796,6 @@
|
||||
"dev": true,
|
||||
"inBundle": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
@@ -11651,7 +11643,6 @@
|
||||
"integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"prettier": "bin/prettier.cjs"
|
||||
},
|
||||
@@ -12154,7 +12145,6 @@
|
||||
"integrity": "sha512-6qGjWccl5yoyugHt3jTgztJ9Y0JVzyH8/Voc/D8PlLat9pwxQYXz7W1Dpnq5h0/G5GCYGUaDSlYcyk3AMh5A6g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@semantic-release/commit-analyzer": "^13.0.1",
|
||||
"@semantic-release/error": "^4.0.0",
|
||||
@@ -13116,7 +13106,6 @@
|
||||
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
@@ -13278,7 +13267,6 @@
|
||||
"integrity": "sha512-ytQKuwgmrrkDTFP4LjR0ToE2nqgy886GpvRSpU0JAnrdBYppuY5rLkRUYPU1yCryb24SsKBTL/hlDQAEFVwtZg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"esbuild": "~0.25.0",
|
||||
"get-tsconfig": "^4.7.5"
|
||||
@@ -13408,7 +13396,6 @@
|
||||
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
@@ -13776,7 +13763,6 @@
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.18.2.tgz",
|
||||
"integrity": "sha512-DMricUmwGZUVr++AEAe2uiVM7UoO9MAVZMDu05UQOaUII0lp+zOzLLU4Xqh/JvTqklB1T4uELaaPBKyjE1r4fQ==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
@@ -13824,7 +13810,6 @@
|
||||
"integrity": "sha512-lcYcMxX2PO9XMGvAJkJ3OsNMw+/7FKes7/hgerGUYWIoWu5j/+YQqcZr5JnPZWzOsEBgMbSbiSTn/dv/69Mkpw==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"yaml": "bin.mjs"
|
||||
},
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
CognitoUserPool,
|
||||
CognitoUserSession
|
||||
} from 'amazon-cognito-identity-js';
|
||||
import { io, iot, mqtt } from 'aws-iot-device-sdk-v2';
|
||||
import { iot, mqtt } from 'aws-iot-device-sdk-v2';
|
||||
import { hash } from 'crypto';
|
||||
import dayjs, { Dayjs } from 'dayjs';
|
||||
import duration from 'dayjs/plugin/duration.js';
|
||||
@@ -152,10 +152,6 @@ export class MysaApiClient {
|
||||
this._logger = options?.logger || new VoidLogger();
|
||||
this._fetcher = options?.fetcher || fetch;
|
||||
|
||||
if (options?.isAwsCrtDebugLoggingEnabled) {
|
||||
io.enable_logging(io.LogLevel.DEBUG);
|
||||
}
|
||||
|
||||
if (session) {
|
||||
this._cognitoUser = new CognitoUser({
|
||||
Username: session.username,
|
||||
@@ -745,7 +741,7 @@ export class MysaApiClient {
|
||||
.with_client_id(this._mqttClientId)
|
||||
.with_clean_session(false)
|
||||
.with_keep_alive_seconds(30)
|
||||
.with_ping_timeout_ms(10000)
|
||||
.with_ping_timeout_ms(3000)
|
||||
.with_protocol_operation_timeout_ms(60000)
|
||||
.with_reconnect_min_sec(1)
|
||||
.with_reconnect_max_sec(30);
|
||||
|
||||
@@ -15,11 +15,4 @@ export interface MysaApiClientOptions {
|
||||
* @defaultValue The global `fetch` function.
|
||||
*/
|
||||
fetcher?: typeof fetch;
|
||||
|
||||
/**
|
||||
* Whether to enable debug logging for AWS CRT.
|
||||
*
|
||||
* @defaultValue `false`
|
||||
*/
|
||||
isAwsCrtDebugLoggingEnabled?: boolean;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user