@ray-js/lock-sdk 1.2.0-beta.24 → 1.2.0-beta.26
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/lib/api/fit.d.ts +55 -2
- package/lib/api/fit.js +43 -1
- package/lib/api/log.d.ts +31 -0
- package/lib/api/log.js +22 -0
- package/lib/api/product.d.ts +8 -0
- package/lib/api/product.js +10 -0
- package/lib/api/temp.d.ts +21 -0
- package/lib/api/temp.js +24 -0
- package/lib/entries/fit/bootstrap/bootstrap-lock-instance.js +2 -0
- package/lib/entries/fit/bootstrap/bootstrap.js +1 -0
- package/lib/entries/fit/build-instance.js +2 -0
- package/lib/entries/fit/exports/binding.d.ts +5 -3
- package/lib/entries/fit/exports/binding.js +4 -1
- package/lib/entries/fit/exports/device.d.ts +8 -7
- package/lib/entries/fit/exports/device.js +12 -12
- package/lib/entries/fit/exports/index.d.ts +3 -0
- package/lib/entries/fit/exports/index.js +3 -0
- package/lib/entries/fit/exports/log.d.ts +7 -0
- package/lib/entries/fit/exports/log.js +15 -0
- package/lib/entries/fit/exports/misc.d.ts +5 -0
- package/lib/entries/fit/exports/misc.js +9 -0
- package/lib/entries/fit/exports/setting.d.ts +4 -0
- package/lib/entries/fit/exports/setting.js +8 -0
- package/lib/entries/fit/exports/state.d.ts +4 -0
- package/lib/entries/fit/exports/state.js +12 -0
- package/lib/entries/fit/exports/temp.d.ts +24 -3
- package/lib/entries/fit/exports/temp.js +43 -2
- package/lib/entries/fit/index.js +2 -0
- package/lib/entries/main/exports/log.d.ts +2 -0
- package/lib/entries/main/exports/log.js +7 -1
- package/lib/entries/main/exports/misc.d.ts +3 -1
- package/lib/entries/main/exports/misc.js +2 -2
- package/lib/feature/fit/bind-lock-to-fit.d.ts +1 -0
- package/lib/feature/fit/bind-lock-to-fit.js +53 -0
- package/lib/feature/fit/ble-key.d.ts +10 -4
- package/lib/feature/fit/ble-key.js +145 -4
- package/lib/feature/fit/device-bv.d.ts +2 -0
- package/lib/feature/fit/device-bv.js +15 -0
- package/lib/feature/fit/invalid-password.d.ts +10 -0
- package/lib/feature/fit/invalid-password.js +43 -0
- package/lib/feature/fit/list.d.ts +12 -2
- package/lib/feature/fit/list.js +54 -5
- package/lib/feature/fit/log.d.ts +7 -0
- package/lib/feature/fit/log.js +123 -0
- package/lib/feature/fit/method/add-flow.js +2 -2
- package/lib/feature/fit/method/add-password.js +2 -2
- package/lib/feature/fit/method/update-remove.js +40 -14
- package/lib/feature/fit/password-list.d.ts +37 -0
- package/lib/feature/fit/password-list.js +44 -1
- package/lib/feature/fit/product.d.ts +5 -0
- package/lib/feature/fit/product.js +11 -0
- package/lib/feature/fit/security-channel.d.ts +3 -0
- package/lib/feature/fit/security-channel.js +43 -0
- package/lib/feature/fit/shared.d.ts +8 -0
- package/lib/feature/fit/shared.js +40 -1
- package/lib/feature/fit/sync.d.ts +4 -2
- package/lib/feature/fit/sync.js +63 -22
- package/lib/feature/fit/temp-password.d.ts +23 -0
- package/lib/feature/fit/temp-password.js +95 -3
- package/lib/feature/fit/users.d.ts +1 -0
- package/lib/feature/fit/users.js +1 -0
- package/lib/feature/log/log.d.ts +5 -1
- package/lib/feature/log/log.js +6 -4
- package/lib/feature/misc/connect-device.d.ts +1 -1
- package/lib/feature/misc/connect-device.js +5 -5
- package/lib/feature/password/temporary/offline-create.d.ts +14 -0
- package/lib/feature/password/temporary/offline-create.js +77 -1
- package/lib/feature/state/clear.js +1 -0
- package/lib/feature/state/platform-routing.js +4 -0
- package/lib/feature/state/sync/remote-serect-key.js +7 -0
- package/lib/feature/unlock/method/add-flow.js +2 -2
- package/lib/feature/unlock/method/add-password.js +2 -2
- package/lib/feature/utils/index.d.ts +1 -0
- package/lib/feature/utils/index.js +1 -0
- package/lib/interface.d.ts +12 -0
- package/lib/runtime/LockDeviceRuntime.js +3 -0
- package/lib/runtime/lock-config.d.ts +1 -0
- package/lib/runtime/lock-config.js +2 -1
- package/lib/runtime/runtime-state-types.d.ts +6 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +1 -0
- package/package.json +1 -1
|
@@ -3,11 +3,13 @@ import dpCodes from "../../config/dp-code";
|
|
|
3
3
|
import { fitAddTempPwd, fitReportAddTempPwd, fitRemoveTempPwd, fitReportRemoveTempPwd, fitUpdateTempPwd, fitReportUpdateTempPwd, fitBlePswCreate, fitBlePswDelete, fitBlePswCreateReport, fitBlePswDeleteReport, fitBlePswUpdate, fitBlePswUpdateReport, } from "../../config/dp-map/temp-pwd-fit";
|
|
4
4
|
import { publishDpsForRuntime } from "../dp/publish-dps";
|
|
5
5
|
import { resolveSlaveId } from "./resolve-slave-id";
|
|
6
|
-
import { getError } from "../../utils/errors";
|
|
6
|
+
import { getError, handleCloudError } from "../../utils/errors";
|
|
7
7
|
import { sdkLog } from "../../utils/sdk-log";
|
|
8
|
-
import { addFitOnlineTempPwd, addFitOnlineTempPwdCloud, getFitPasswordList, removeFitOnlineTempPwd, renameFitOnlineTempPwd, updateFitOnlineTempPwd, } from "../../api/fit";
|
|
8
|
+
import { addFitOnlineTempPwd, addFitOnlineTempPwdCloud, getFitPasswordList, removeFitOnlineTempPwd, renameFitOnlineTempPwd, resendFitOnlineTempPwd, updateFitOnlineTempPwd, } from "../../api/fit";
|
|
9
|
+
import { reNameOfflineByPwdId, revokeOfflinePasswordByPwdId } from "../../api/temp";
|
|
9
10
|
import { decrypt, encrypt } from "../../platform";
|
|
10
11
|
import { formatPasswordToList, formatWeek, getAppUser, parseWeek, sleep, transformEffectiveConfigToValidConfig, validateEffectiveConfig, } from "../../utils";
|
|
12
|
+
import { parseOfflinePasswordForRuntime } from "../utils";
|
|
11
13
|
import { hasDpForRuntime } from "../dp/has-dp";
|
|
12
14
|
export async function fitAddTempPwdForRuntime(runtime, params) {
|
|
13
15
|
const startedAt = Date.now();
|
|
@@ -180,7 +182,7 @@ export async function fitRemoveTempPwdForRuntime(runtime, params) {
|
|
|
180
182
|
data: { id: params.id, status: res.status, strategy: "device_first" },
|
|
181
183
|
});
|
|
182
184
|
if (res.status === 0x00 || res.status === 0x02) {
|
|
183
|
-
await removeFitOnlineTempPwd(runtime.devId, exist.
|
|
185
|
+
await removeFitOnlineTempPwd(runtime.devId, exist.unlockBindingId);
|
|
184
186
|
}
|
|
185
187
|
else {
|
|
186
188
|
throw getError(1028);
|
|
@@ -426,3 +428,93 @@ export const fitRenameTempPwdForRuntime = async (runtime, params) => {
|
|
|
426
428
|
throw error;
|
|
427
429
|
}
|
|
428
430
|
};
|
|
431
|
+
export const fitRenameOfflineTempPwdForRuntime = async (runtime, params) => {
|
|
432
|
+
const startedAt = Date.now();
|
|
433
|
+
sdkLog("info", "fitTempPassword", "renameOfflineStart", {
|
|
434
|
+
devId: runtime.devId,
|
|
435
|
+
data: { pwdId: params.pwdId, hasName: typeof params.name === "string" },
|
|
436
|
+
});
|
|
437
|
+
try {
|
|
438
|
+
await reNameOfflineByPwdId({
|
|
439
|
+
devId: runtime.devId,
|
|
440
|
+
pwdName: params.name,
|
|
441
|
+
pwdId: params.pwdId,
|
|
442
|
+
});
|
|
443
|
+
sdkLog("info", "fitTempPassword", "renameOfflineSuccess", {
|
|
444
|
+
devId: runtime.devId,
|
|
445
|
+
duration: Date.now() - startedAt,
|
|
446
|
+
data: { pwdId: params.pwdId },
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
catch (error) {
|
|
450
|
+
sdkLog("error", "fitTempPassword", "renameOfflineFail", {
|
|
451
|
+
devId: runtime.devId,
|
|
452
|
+
duration: Date.now() - startedAt,
|
|
453
|
+
data: { pwdId: params.pwdId },
|
|
454
|
+
error,
|
|
455
|
+
});
|
|
456
|
+
throw error;
|
|
457
|
+
}
|
|
458
|
+
};
|
|
459
|
+
export const fitRevokeOfflineTempPwdForRuntime = async (runtime, params) => {
|
|
460
|
+
const startedAt = Date.now();
|
|
461
|
+
sdkLog("info", "fitTempPassword", "revokeOfflineStart", {
|
|
462
|
+
devId: runtime.devId,
|
|
463
|
+
data: { pwdId: params.pwdId, hasName: typeof params.name === "string" },
|
|
464
|
+
});
|
|
465
|
+
try {
|
|
466
|
+
const res = await revokeOfflinePasswordByPwdId({
|
|
467
|
+
devId: runtime.devId,
|
|
468
|
+
pwdId: params.pwdId,
|
|
469
|
+
name: params.name,
|
|
470
|
+
});
|
|
471
|
+
sdkLog("info", "fitTempPassword", "revokeOfflineSuccess", {
|
|
472
|
+
devId: runtime.devId,
|
|
473
|
+
duration: Date.now() - startedAt,
|
|
474
|
+
data: { pwdId: params.pwdId },
|
|
475
|
+
});
|
|
476
|
+
return {
|
|
477
|
+
password: parseOfflinePasswordForRuntime(runtime, res.pwd),
|
|
478
|
+
pwdId: res.pwdId,
|
|
479
|
+
name: res.pwdName,
|
|
480
|
+
effectiveConfig: {
|
|
481
|
+
effectiveDate: res.gmtStart,
|
|
482
|
+
expiredDate: res.gmtExpired,
|
|
483
|
+
},
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
catch (error) {
|
|
487
|
+
sdkLog("error", "fitTempPassword", "revokeOfflineFail", {
|
|
488
|
+
devId: runtime.devId,
|
|
489
|
+
duration: Date.now() - startedAt,
|
|
490
|
+
data: { pwdId: params.pwdId },
|
|
491
|
+
error,
|
|
492
|
+
});
|
|
493
|
+
throw handleCloudError(error);
|
|
494
|
+
}
|
|
495
|
+
};
|
|
496
|
+
export const fitResendTempPwdForRuntime = async (runtime, params) => {
|
|
497
|
+
const startedAt = Date.now();
|
|
498
|
+
sdkLog("info", "fitTempPassword", "resendStart", {
|
|
499
|
+
devId: runtime.devId,
|
|
500
|
+
data: { id: params.id },
|
|
501
|
+
});
|
|
502
|
+
try {
|
|
503
|
+
const result = await resendFitOnlineTempPwd(runtime.devId, params.id);
|
|
504
|
+
sdkLog("info", "fitTempPassword", "resendSuccess", {
|
|
505
|
+
devId: runtime.devId,
|
|
506
|
+
duration: Date.now() - startedAt,
|
|
507
|
+
data: { id: params.id },
|
|
508
|
+
});
|
|
509
|
+
return result;
|
|
510
|
+
}
|
|
511
|
+
catch (error) {
|
|
512
|
+
sdkLog("error", "fitTempPassword", "resendFail", {
|
|
513
|
+
devId: runtime.devId,
|
|
514
|
+
duration: Date.now() - startedAt,
|
|
515
|
+
data: { id: params.id },
|
|
516
|
+
error,
|
|
517
|
+
});
|
|
518
|
+
throw error;
|
|
519
|
+
}
|
|
520
|
+
};
|
package/lib/feature/fit/users.js
CHANGED
package/lib/feature/log/log.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LockLogCategory } from "../../api/log";
|
|
2
|
-
import { AlbumMessage, LogData, UnlockMethodType } from "../../interface";
|
|
2
|
+
import { AlbumMessage, CloseValue, LogData, UnlockMethodType } from "../../interface";
|
|
3
3
|
import type { LockDeviceRuntime } from "../../runtime/LockDeviceRuntime";
|
|
4
4
|
export type LogsRefreshListener = () => void;
|
|
5
5
|
export declare function getLogsRefreshEvent(runtime: LockDeviceRuntime): string;
|
|
@@ -16,11 +16,13 @@ export interface GetLogsParams {
|
|
|
16
16
|
pageSize?: number;
|
|
17
17
|
}
|
|
18
18
|
export declare const openDps: ("unlock_matter_kw" | "unlock_password" | "unlock_fingerprint" | "unlock_finger_vein" | "unlock_hand" | "unlock_dynamic" | "unlock_key" | "unlock_card" | "unlock_face" | "unlock_temporary" | "unlock_offline_pd" | "unlock_phone_remote" | "unlock_voice_remote" | "lock_record" | "unlock_ble" | "unlock_eye" | "unlock_double_kit" | "unlock_double_kit_w" | "open_inside" | "lock_local_record" | "unlock_inside" | "door_opened" | "unlock_app")[];
|
|
19
|
+
export declare const closeTypes: CloseValue[];
|
|
19
20
|
export interface GetLogsResult {
|
|
20
21
|
list: LogData[];
|
|
21
22
|
hasMore: boolean;
|
|
22
23
|
total: number;
|
|
23
24
|
}
|
|
25
|
+
export declare const dpIdsForUsernameToUnlockName: number[];
|
|
24
26
|
export declare function getLogsForRuntime(rt: LockDeviceRuntime, params?: GetLogsParams): Promise<GetLogsResult>;
|
|
25
27
|
export interface GetAlarmsParams {
|
|
26
28
|
page?: number;
|
|
@@ -61,3 +63,5 @@ export interface GetLockLogListResult {
|
|
|
61
63
|
lastRowKey: string;
|
|
62
64
|
}
|
|
63
65
|
export declare const getLockLogListForRuntime: (rt: LockDeviceRuntime, params: GetLockLogListParams) => Promise<GetLockLogListResult>;
|
|
66
|
+
export declare const getAlarmUnreadCountForRuntime: (rt: LockDeviceRuntime) => Promise<number>;
|
|
67
|
+
export declare const getActivePeriodForRuntime: (rt: LockDeviceRuntime) => Promise<number>;
|
package/lib/feature/log/log.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getAlarmList, getAlbumMessages, getLatest2Log, getLockLogList, getRecordList, } from "../../api/log";
|
|
1
|
+
import { getAlarmList, getAlbumMessages, getLatest2Log, getLockLogList, getRecordList, getAlarmUnreadCountApi, getActivePeriodApi, } from "../../api/log";
|
|
2
2
|
import dpCodes from "../../config/dp-code";
|
|
3
3
|
import { getCurrentUserForRuntime } from "../user/current-user";
|
|
4
4
|
import base64ToHex from "../../utils/base64-to-hex";
|
|
@@ -153,7 +153,7 @@ function handleLockLogs(list, cfg) {
|
|
|
153
153
|
userId: item.userId,
|
|
154
154
|
userName: userName || "",
|
|
155
155
|
unlockName: unlockName || "",
|
|
156
|
-
mediaInfo: item.mediaInfoList?.map?.(item => {
|
|
156
|
+
mediaInfo: item.mediaInfoList?.map?.((item) => {
|
|
157
157
|
return {
|
|
158
158
|
mediaPath: item.mediaPath,
|
|
159
159
|
fileKey: item.fileKey,
|
|
@@ -241,7 +241,7 @@ export const openDps = [
|
|
|
241
241
|
dpCodes.unlockApp,
|
|
242
242
|
dpCodes.unlockMatterKw,
|
|
243
243
|
];
|
|
244
|
-
const closeTypes = [
|
|
244
|
+
export const closeTypes = [
|
|
245
245
|
"UNDEFINED",
|
|
246
246
|
"APP_REMOTE",
|
|
247
247
|
"VOICE_REMOTE",
|
|
@@ -251,7 +251,7 @@ const closeTypes = [
|
|
|
251
251
|
"AUTO",
|
|
252
252
|
"LOCAL_MANUAL",
|
|
253
253
|
];
|
|
254
|
-
const dpIdsForUsernameToUnlockName = [89, 69, 55, 67, 3, 32];
|
|
254
|
+
export const dpIdsForUsernameToUnlockName = [89, 69, 55, 67, 3, 32];
|
|
255
255
|
export async function getLogsForRuntime(rt, params) {
|
|
256
256
|
const cfg = rt.config;
|
|
257
257
|
const { page = 1, pageSize = 50 } = params || {};
|
|
@@ -468,3 +468,5 @@ export const getLockLogListForRuntime = async (rt, params) => {
|
|
|
468
468
|
lastRowKey: data?.lastRowKey ?? "",
|
|
469
469
|
};
|
|
470
470
|
};
|
|
471
|
+
export const getAlarmUnreadCountForRuntime = (rt) => getAlarmUnreadCountApi(rt.config.devInfo.devId);
|
|
472
|
+
export const getActivePeriodForRuntime = (rt) => getActivePeriodApi(rt.config.devInfo.devId);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { LockDeviceRuntime } from "../../runtime/LockDeviceRuntime";
|
|
2
|
-
export declare function connectDeviceForRuntime(rt: LockDeviceRuntime): Promise<true>;
|
|
2
|
+
export declare function connectDeviceForRuntime(rt: LockDeviceRuntime, timeout?: number): Promise<true>;
|
|
@@ -72,7 +72,7 @@ const awakeDevice = async (devId, timeout) => {
|
|
|
72
72
|
run();
|
|
73
73
|
});
|
|
74
74
|
};
|
|
75
|
-
const connectBle = async (devId) => {
|
|
75
|
+
const connectBle = async (devId, timeout) => {
|
|
76
76
|
const startedAt = Date.now();
|
|
77
77
|
sdkLog("info", "connectDevice", "bleConnectStart", { devId });
|
|
78
78
|
return new Promise((resolve, reject) => {
|
|
@@ -109,7 +109,7 @@ const connectBle = async (devId) => {
|
|
|
109
109
|
error,
|
|
110
110
|
});
|
|
111
111
|
reject(error);
|
|
112
|
-
}, 15000);
|
|
112
|
+
}, timeout ?? 15000);
|
|
113
113
|
const clearTimer = () => {
|
|
114
114
|
clearTimeout(timer);
|
|
115
115
|
offBleChange(handleStatusChange);
|
|
@@ -143,7 +143,7 @@ const connectBle = async (devId) => {
|
|
|
143
143
|
});
|
|
144
144
|
});
|
|
145
145
|
};
|
|
146
|
-
export async function connectDeviceForRuntime(rt) {
|
|
146
|
+
export async function connectDeviceForRuntime(rt, timeout) {
|
|
147
147
|
const cfg = rt.config;
|
|
148
148
|
const devId = cfg.devInfo.devId;
|
|
149
149
|
const deviceStatus = getDeviceStatusForRuntime(rt);
|
|
@@ -160,7 +160,7 @@ export async function connectDeviceForRuntime(rt) {
|
|
|
160
160
|
});
|
|
161
161
|
if (deviceStatus.connectEnable && hasWirelessAwakeDp) {
|
|
162
162
|
if (cfg.devInfo.isCloudOnline && !getDpValueForRuntime(rt, wirelessAwake)) {
|
|
163
|
-
const result = await awakeDevice(devId);
|
|
163
|
+
const result = await awakeDevice(devId, timeout);
|
|
164
164
|
sdkLog("info", "connectDevice", "success", {
|
|
165
165
|
devId,
|
|
166
166
|
duration: Date.now() - startedAt,
|
|
@@ -179,7 +179,7 @@ export async function connectDeviceForRuntime(rt) {
|
|
|
179
179
|
});
|
|
180
180
|
return true;
|
|
181
181
|
}
|
|
182
|
-
await connectBle(devId);
|
|
182
|
+
await connectBle(devId, timeout);
|
|
183
183
|
if (rt.cache.deviceAdvanceAbilityCache?.yuChannel.support) {
|
|
184
184
|
if (rt.cache.deviceAdvanceAbilityCache?.yuChannel.value === 1) {
|
|
185
185
|
yuChannelSyncSingleSync(devId);
|
|
@@ -1,7 +1,21 @@
|
|
|
1
|
+
import { type LimitOfflinePwdItem, type OfflinePwdAvailableResult } from "../../../api/temp";
|
|
1
2
|
import type { TempPasswordResult } from "../../../interface";
|
|
2
3
|
import type { LockDeviceRuntime } from "../../../runtime/LockDeviceRuntime";
|
|
3
4
|
import type { CreateClearParams, CreateLimitParams, CreateOnceParams } from "./types";
|
|
4
5
|
export declare function createTempLimitForRuntime(rt: LockDeviceRuntime, params: CreateLimitParams): Promise<TempPasswordResult>;
|
|
5
6
|
export declare function createTempOnceForRuntime(rt: LockDeviceRuntime, params: CreateOnceParams): Promise<TempPasswordResult>;
|
|
7
|
+
export interface FitOfflineOnceResult {
|
|
8
|
+
password: string;
|
|
9
|
+
pwdId: string;
|
|
10
|
+
gmtExpired: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function createFitOfflineOnceForRuntime(rt: LockDeviceRuntime): Promise<FitOfflineOnceResult>;
|
|
13
|
+
export declare function createFitOfflineLimitForRuntime(rt: LockDeviceRuntime, params: {
|
|
14
|
+
effectiveTime: number;
|
|
15
|
+
invalidTime: number;
|
|
16
|
+
}): Promise<FitOfflineOnceResult>;
|
|
17
|
+
export declare function createFitOfflineClearAllForRuntime(rt: LockDeviceRuntime): Promise<FitOfflineOnceResult>;
|
|
18
|
+
export declare function getFitOfflineRevocableListForRuntime(rt: LockDeviceRuntime): Promise<LimitOfflinePwdItem[]>;
|
|
19
|
+
export declare function getFitOfflinePwdAvailableForRuntime(rt: LockDeviceRuntime, pwdType: string): Promise<OfflinePwdAvailableResult>;
|
|
6
20
|
export declare function createTempDynamicForRuntime(rt: LockDeviceRuntime): Promise<TempPasswordResult>;
|
|
7
21
|
export declare function createTempClearForRuntime(rt: LockDeviceRuntime, params: CreateClearParams): Promise<TempPasswordResult>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getDynamicPassword, revokeOfflinePassword, } from "../../../api/temp";
|
|
1
|
+
import { createOfflineOnceAPI, getDynamicPassword, getLimitOfflinePwdListForClear, getOfflinePwdAvailable, revokeOfflinePassword, } from "../../../api/temp";
|
|
2
2
|
import { parseOfflinePasswordForRuntime } from "../../utils";
|
|
3
3
|
import { getError, handleCloudError } from "../../../utils/errors";
|
|
4
4
|
import { getOfflinePassword } from "./internal/password-helpers";
|
|
@@ -87,6 +87,82 @@ export async function createTempOnceForRuntime(rt, params) {
|
|
|
87
87
|
},
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
|
+
async function createFitOfflinePwdForRuntime(rt, params) {
|
|
91
|
+
const startedAt = Date.now();
|
|
92
|
+
sdkLog("info", "tempPassword", "createFitOfflinePwdStart", {
|
|
93
|
+
devId: rt.devId,
|
|
94
|
+
data: { pwdType: params.pwdType },
|
|
95
|
+
});
|
|
96
|
+
try {
|
|
97
|
+
const res = await createOfflineOnceAPI({
|
|
98
|
+
devId: rt.devId,
|
|
99
|
+
...params,
|
|
100
|
+
});
|
|
101
|
+
sdkLog("info", "tempPassword", "createFitOfflinePwdSuccess", {
|
|
102
|
+
devId: rt.devId,
|
|
103
|
+
duration: Date.now() - startedAt,
|
|
104
|
+
data: { pwdType: params.pwdType },
|
|
105
|
+
});
|
|
106
|
+
return {
|
|
107
|
+
password: parseOfflinePasswordForRuntime(rt, res.pwd),
|
|
108
|
+
pwdId: res.pwdId,
|
|
109
|
+
gmtExpired: res.gmtExpired,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
sdkLog("error", "tempPassword", "createFitOfflinePwdFail", {
|
|
114
|
+
devId: rt.devId,
|
|
115
|
+
duration: Date.now() - startedAt,
|
|
116
|
+
data: { pwdType: params.pwdType },
|
|
117
|
+
error,
|
|
118
|
+
});
|
|
119
|
+
throw handleCloudError(error);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
export function createFitOfflineOnceForRuntime(rt) {
|
|
123
|
+
return createFitOfflinePwdForRuntime(rt, {
|
|
124
|
+
pwdType: "1",
|
|
125
|
+
gmtStart: "0",
|
|
126
|
+
gmtExpired: "0",
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
export function createFitOfflineLimitForRuntime(rt, params) {
|
|
130
|
+
const { effectiveTime, invalidTime } = params;
|
|
131
|
+
if (effectiveTime >= invalidTime) {
|
|
132
|
+
throw getError(1010);
|
|
133
|
+
}
|
|
134
|
+
return createFitOfflinePwdForRuntime(rt, {
|
|
135
|
+
pwdType: "0",
|
|
136
|
+
gmtStart: String(effectiveTime),
|
|
137
|
+
gmtExpired: String(invalidTime),
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
export function createFitOfflineClearAllForRuntime(rt) {
|
|
141
|
+
return createFitOfflinePwdForRuntime(rt, {
|
|
142
|
+
pwdType: "9",
|
|
143
|
+
gmtStart: "0",
|
|
144
|
+
gmtExpired: "0",
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
export async function getFitOfflineRevocableListForRuntime(rt) {
|
|
148
|
+
try {
|
|
149
|
+
return (await getLimitOfflinePwdListForClear({ devId: rt.devId })) || [];
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
throw handleCloudError(error);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
export async function getFitOfflinePwdAvailableForRuntime(rt, pwdType) {
|
|
156
|
+
try {
|
|
157
|
+
return await getOfflinePwdAvailable({
|
|
158
|
+
devId: rt.config.devInfo.devId,
|
|
159
|
+
pwdType,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
throw handleCloudError(error);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
90
166
|
export async function createTempDynamicForRuntime(rt) {
|
|
91
167
|
const startedAt = Date.now();
|
|
92
168
|
sdkLog("info", "tempPassword", "createDynamicStart", {
|
|
@@ -8,6 +8,7 @@ export function clearStateForRuntime(runtime) {
|
|
|
8
8
|
runtime.cache.currentUser = null;
|
|
9
9
|
runtime.cache.offlineDpCache = undefined;
|
|
10
10
|
runtime.cache.deviceAdvanceAbilityCache = undefined;
|
|
11
|
+
runtime.cache.fitDeviceBvCache = undefined;
|
|
11
12
|
runtime.cache.isActiveThreadCache = false;
|
|
12
13
|
runtime.sync.hasSyncedT0 = false;
|
|
13
14
|
runtime.sync.syncDeleteUsersBusy = false;
|
|
@@ -3,6 +3,7 @@ import { getRuntimeByDevId, listRegisteredRuntimes, } from "../../runtime/regist
|
|
|
3
3
|
import emitter from "../../utils/event";
|
|
4
4
|
import { getWiFiSignalChangeEvent } from "../misc/signal";
|
|
5
5
|
import { autoSyncTemp } from "../password/sync-temp";
|
|
6
|
+
import { syncFitBindingsForRuntime } from "../fit/sync";
|
|
6
7
|
import syncT0 from "./sync/t0";
|
|
7
8
|
import syncRemoteSerectKey from "./sync/remote-serect-key";
|
|
8
9
|
import { syncOfflineDps } from "./sync/offline-dps";
|
|
@@ -93,6 +94,9 @@ const globalHandleBleChange = ({ deviceId, status }) => {
|
|
|
93
94
|
if (rt) {
|
|
94
95
|
updateOnlineType(rt);
|
|
95
96
|
if (status === "CONNECTED") {
|
|
97
|
+
if (rt.config.isFitting) {
|
|
98
|
+
syncFitBindingsForRuntime(rt).catch(() => { });
|
|
99
|
+
}
|
|
96
100
|
void syncRemoteSerectKey(rt);
|
|
97
101
|
autoSyncTemp(rt);
|
|
98
102
|
void syncT0(rt);
|
|
@@ -11,6 +11,13 @@ import { reportSetKey as reportSetKeyMap, setKey as setKeyMap, } from "../../../
|
|
|
11
11
|
import { sdkLog } from "../../../utils/sdk-log";
|
|
12
12
|
const syncRemoteSerectKey = async (runtime, force) => {
|
|
13
13
|
const rt = runtime;
|
|
14
|
+
if (rt.config.isFitting || !rt.config.idsByCode[dpCodes.remoteNoPdSetkey]) {
|
|
15
|
+
sdkLog("debug", "syncKey", "skipped", {
|
|
16
|
+
devId: rt.devId,
|
|
17
|
+
data: { reason: "unsupported", force: !!force },
|
|
18
|
+
});
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
14
21
|
const useNear = isUseNearChannelForRuntime(rt);
|
|
15
22
|
if (!useNear) {
|
|
16
23
|
sdkLog("debug", "syncKey", "skipped", {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import dpUtils from "@ray-js/tuya-dp-transform";
|
|
2
2
|
import { createUnlockMethod } from "../../../api/lock";
|
|
3
3
|
import { parallelOnlyForRuntime } from "../../utils";
|
|
4
|
-
import { sleep } from "../../../utils";
|
|
4
|
+
import { formatCloudUnlockId, sleep } from "../../../utils";
|
|
5
5
|
import { getError } from "../../../utils/errors";
|
|
6
6
|
import { publishDpsForRuntime } from "../../dp/publish-dps";
|
|
7
7
|
import emitter from "../../../utils/event";
|
|
@@ -207,7 +207,7 @@ const handleAddReport = async (dps) => {
|
|
|
207
207
|
const res = await createUnlockMethod({
|
|
208
208
|
devId: cfg.devInfo.devId,
|
|
209
209
|
userId: addUnlockMethodData.userId,
|
|
210
|
-
unlockId:
|
|
210
|
+
unlockId: formatCloudUnlockId(addUnlockMethodData.unlockDpId, result.unlockId),
|
|
211
211
|
unlockName: "",
|
|
212
212
|
unlockAttr: 0,
|
|
213
213
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import dpUtils from "@ray-js/tuya-dp-transform";
|
|
2
2
|
import { createUnlockMethod } from "../../../api/lock";
|
|
3
3
|
import { encrypt } from "../../../platform/device";
|
|
4
|
-
import { sleep } from "../../../utils";
|
|
4
|
+
import { formatCloudUnlockId, sleep } from "../../../utils";
|
|
5
5
|
import { getError, handleCloudError } from "../../../utils/errors";
|
|
6
6
|
import { publishDpsForRuntime } from "../../dp/publish-dps";
|
|
7
7
|
import { getUnlockMethodBase } from "./internal/base";
|
|
@@ -76,7 +76,7 @@ export async function addPasswordForRuntime(rt, params) {
|
|
|
76
76
|
const result = await createUnlockMethod({
|
|
77
77
|
devId: devId,
|
|
78
78
|
userId: params.userId,
|
|
79
|
-
unlockId:
|
|
79
|
+
unlockId: formatCloudUnlockId(dpId, res.unlockId),
|
|
80
80
|
unlockName: params.name,
|
|
81
81
|
unlockDetail: aesPwd,
|
|
82
82
|
...specialInfo,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { UnlockMethodConfig } from "../../interface";
|
|
2
2
|
import type { LockDeviceRuntime } from "../../runtime/LockDeviceRuntime";
|
|
3
|
+
export declare const unlockMethodDpCodes: string[];
|
|
3
4
|
export declare const getUnlockMethodTypeByDpCodeForRuntime: (rt: LockDeviceRuntime, dpCode: string) => UnlockMethodConfig;
|
|
4
5
|
export declare const getUnlockMethodTypeByIdForRuntime: (rt: LockDeviceRuntime, id: number | string) => UnlockMethodConfig;
|
|
5
6
|
export declare const getUnlockMethodTypeByTypeForRuntime: (rt: LockDeviceRuntime, type: string) => UnlockMethodConfig;
|
|
@@ -33,6 +33,7 @@ const unlockMethodConfigs = [
|
|
|
33
33
|
id: 6,
|
|
34
34
|
},
|
|
35
35
|
];
|
|
36
|
+
export const unlockMethodDpCodes = unlockMethodConfigs.reduce((res, item) => res.concat(item.codes), []);
|
|
36
37
|
const getUnlockMethodTypeForRuntime = (rt, cb) => {
|
|
37
38
|
const result = unlockMethodConfigs.find(cb);
|
|
38
39
|
if (result) {
|
package/lib/interface.d.ts
CHANGED
|
@@ -182,6 +182,16 @@ export interface EffectiveConfig {
|
|
|
182
182
|
effectiveTime?: number;
|
|
183
183
|
expiredTime?: number;
|
|
184
184
|
}
|
|
185
|
+
export interface FitBleKeyItem {
|
|
186
|
+
id: string;
|
|
187
|
+
unlockBindingId: string;
|
|
188
|
+
name: string;
|
|
189
|
+
opModeSubType?: number;
|
|
190
|
+
effectiveConfig: EffectiveConfig;
|
|
191
|
+
sn?: number;
|
|
192
|
+
userName?: string;
|
|
193
|
+
devNameList?: string[];
|
|
194
|
+
}
|
|
185
195
|
export interface UnBindUnlockMethod {
|
|
186
196
|
dpId: number;
|
|
187
197
|
dpCode: string;
|
|
@@ -276,6 +286,8 @@ export interface LogData {
|
|
|
276
286
|
dpCode: string;
|
|
277
287
|
data: any;
|
|
278
288
|
userName: string;
|
|
289
|
+
avatarUrl?: string;
|
|
290
|
+
relateDevName?: string;
|
|
279
291
|
bindable: boolean;
|
|
280
292
|
unlockName: string;
|
|
281
293
|
mediaInfo?: MediaInfo[];
|
|
@@ -14,6 +14,7 @@ export class LockDeviceRuntime {
|
|
|
14
14
|
offlineDpCache: undefined,
|
|
15
15
|
isActiveThreadCache: false,
|
|
16
16
|
deviceAdvanceAbilityCache: undefined,
|
|
17
|
+
fitDeviceBvCache: undefined,
|
|
17
18
|
};
|
|
18
19
|
this.sync = {
|
|
19
20
|
hasSyncedT0: false,
|
|
@@ -21,6 +22,8 @@ export class LockDeviceRuntime {
|
|
|
21
22
|
unlockMethodAutoSyncEnabled: true,
|
|
22
23
|
tempAutoSyncEnabled: true,
|
|
23
24
|
tempPayloadSyncing: false,
|
|
25
|
+
fitSyncReportHandler: null,
|
|
26
|
+
fitBindingsSyncStarted: false,
|
|
24
27
|
};
|
|
25
28
|
this.infra = {
|
|
26
29
|
eventsRegistered: false,
|
|
@@ -26,6 +26,7 @@ export type LockConfigState = {
|
|
|
26
26
|
isTwoWayTalk: boolean;
|
|
27
27
|
cameraConfig: CameraConfig[];
|
|
28
28
|
notSupportWake: boolean;
|
|
29
|
+
isFitting: boolean;
|
|
29
30
|
};
|
|
30
31
|
export declare function createDefaultDeviceStatus(): DeviceStatus;
|
|
31
32
|
export declare function createLockConfigState(): LockConfigState;
|
|
@@ -5,6 +5,7 @@ export interface LockRuntimeCacheFields {
|
|
|
5
5
|
offlineDpCache: OfflineDps | undefined;
|
|
6
6
|
isActiveThreadCache: boolean;
|
|
7
7
|
deviceAdvanceAbilityCache: DeviceAdvancedAbility | undefined;
|
|
8
|
+
fitDeviceBvCache: Promise<number> | undefined;
|
|
8
9
|
}
|
|
9
10
|
export interface LockRuntimeSyncFlags {
|
|
10
11
|
hasSyncedT0: boolean;
|
|
@@ -12,6 +13,11 @@ export interface LockRuntimeSyncFlags {
|
|
|
12
13
|
unlockMethodAutoSyncEnabled: boolean;
|
|
13
14
|
tempAutoSyncEnabled: boolean;
|
|
14
15
|
tempPayloadSyncing: boolean;
|
|
16
|
+
fitSyncReportHandler: ((data: {
|
|
17
|
+
deviceId?: string;
|
|
18
|
+
data?: string;
|
|
19
|
+
}) => void) | null;
|
|
20
|
+
fitBindingsSyncStarted: boolean;
|
|
15
21
|
}
|
|
16
22
|
export interface LockRuntimeInfraFields {
|
|
17
23
|
eventsRegistered: boolean;
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -121,6 +121,7 @@ export declare function getCapabilities(capability: number): ({
|
|
|
121
121
|
readonly short: "thread";
|
|
122
122
|
})[];
|
|
123
123
|
export declare const formatWeek: (value: number[]) => number;
|
|
124
|
+
export declare const formatCloudUnlockId: (dpId: number | string, sn: number) => string;
|
|
124
125
|
export declare const parseWeek: (value: number) => Week;
|
|
125
126
|
export declare const getPermanentSetting: () => {
|
|
126
127
|
startTime: number;
|
package/lib/utils/index.js
CHANGED
|
@@ -56,6 +56,7 @@ export const formatWeek = (value) => {
|
|
|
56
56
|
const temp = value.slice(0, 7);
|
|
57
57
|
return parseInt(temp.reverse().join(""), 2);
|
|
58
58
|
};
|
|
59
|
+
export const formatCloudUnlockId = (dpId, sn) => `${dpId}-${sn.toString(16).padStart(2, "0")}`;
|
|
59
60
|
export const parseWeek = (value) => {
|
|
60
61
|
return Number(value)
|
|
61
62
|
.toString(2)
|