@ray-js/lock-sdk 1.2.0-beta.3 → 1.2.0-beta.30
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/gesture.d.ts +11 -0
- package/lib/api/gesture.js +18 -0
- package/lib/api/log.d.ts +52 -4
- package/lib/api/log.js +22 -0
- package/lib/api/notify.d.ts +28 -0
- package/lib/api/notify.js +17 -0
- package/lib/api/service.d.ts +26 -0
- package/lib/api/service.js +25 -0
- package/lib/api/temp.d.ts +21 -0
- package/lib/api/temp.js +24 -0
- package/lib/api/video.d.ts +9 -0
- package/lib/api/video.js +30 -0
- package/lib/api/voip.d.ts +10 -0
- package/lib/api/voip.js +17 -0
- package/lib/config/dp-code/index.d.ts +2 -1
- package/lib/config/dp-code/index.js +2 -0
- package/lib/config/dp-map/media.d.ts +13 -0
- package/lib/config/dp-map/media.js +19 -0
- package/lib/entries/main/bootstrap/bootstrap-lock-instance.d.ts +2 -1
- package/lib/entries/main/bootstrap/bootstrap-lock-instance.js +23 -8
- package/lib/entries/main/bootstrap/bootstrap.d.ts +3 -2
- package/lib/entries/main/bootstrap/bootstrap.js +10 -6
- package/lib/entries/main/bootstrap/primary-instance.d.ts +1 -2
- package/lib/entries/main/bootstrap/primary-instance.js +1 -1
- package/lib/entries/main/bootstrap/resolve-runtime-from-export-this.js +1 -1
- package/lib/entries/main/build-instance.d.ts +6 -3
- package/lib/entries/main/build-instance.js +13 -1
- package/lib/entries/main/exports/capability.d.ts +2 -0
- package/lib/entries/main/exports/capability.js +7 -1
- package/lib/entries/main/exports/fit-sdk/binding.d.ts +10 -0
- package/lib/entries/{fit/exports → main/exports/fit-sdk}/binding.js +6 -3
- package/lib/entries/{fit/exports → main/exports/fit-sdk}/device.d.ts +11 -10
- package/lib/entries/{fit/exports → main/exports/fit-sdk}/device.js +20 -20
- package/lib/entries/{fit/exports → main/exports/fit-sdk}/index.d.ts +1 -0
- package/lib/entries/{fit/exports → main/exports/fit-sdk}/index.js +1 -0
- package/lib/entries/main/exports/fit-sdk/log.d.ts +3 -0
- package/lib/entries/main/exports/fit-sdk/log.js +5 -0
- package/lib/entries/main/exports/fit-sdk/temp.d.ts +40 -0
- package/lib/entries/main/exports/fit-sdk/temp.js +59 -0
- package/lib/entries/main/exports/gesture.d.ts +6 -0
- package/lib/entries/main/exports/gesture.js +8 -0
- package/lib/entries/main/exports/index.d.ts +8 -0
- package/lib/entries/main/exports/index.js +8 -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/media.d.ts +10 -1
- package/lib/entries/main/exports/media.js +29 -1
- package/lib/entries/main/exports/misc.d.ts +4 -2
- package/lib/entries/main/exports/misc.js +2 -2
- package/lib/entries/main/exports/notify.d.ts +7 -0
- package/lib/entries/main/exports/notify.js +8 -0
- package/lib/entries/main/exports/service.d.ts +4 -0
- package/lib/entries/main/exports/service.js +11 -0
- package/lib/entries/main/exports/voip.d.ts +3 -0
- package/lib/entries/main/exports/voip.js +8 -0
- package/lib/entries/main/index.d.ts +3 -3
- package/lib/entries/main/index.js +11 -5
- 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/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/gesture/gesture.d.ts +6 -0
- package/lib/feature/gesture/gesture.js +3 -0
- package/lib/feature/log/log.d.ts +5 -1
- package/lib/feature/log/log.js +53 -6
- package/lib/feature/media/camera.d.ts +18 -0
- package/lib/feature/media/camera.js +36 -0
- package/lib/feature/media/media.d.ts +10 -0
- package/lib/feature/media/media.js +31 -0
- package/lib/feature/misc/ble-control.js +2 -2
- package/lib/feature/misc/capability.d.ts +2 -0
- package/lib/feature/misc/capability.js +84 -11
- package/lib/feature/misc/connect-device.d.ts +1 -1
- package/lib/feature/misc/connect-device.js +7 -6
- package/lib/feature/misc/is-use-near-channel-for-runtime.js +8 -1
- package/lib/feature/notify/notify.d.ts +4 -0
- package/lib/feature/notify/notify.js +3 -0
- package/lib/feature/password/temporary/custom-dp.js +59 -54
- package/lib/feature/password/temporary/offline-create.d.ts +14 -0
- package/lib/feature/password/temporary/offline-create.js +77 -1
- package/lib/feature/service/goto-service.d.ts +3 -2
- package/lib/feature/service/goto-service.js +7 -1
- package/lib/feature/service/value-added.d.ts +4 -0
- package/lib/feature/service/value-added.js +4 -0
- package/lib/feature/state/clear.js +1 -0
- package/lib/feature/state/device-status.js +17 -6
- package/lib/feature/state/init-state.js +20 -12
- package/lib/feature/state/platform-routing.js +12 -3
- package/lib/feature/state/remote-permissions.js +17 -0
- package/lib/feature/state/sync/remote-serect-key.js +7 -0
- package/lib/feature/storage/index.d.ts +5 -0
- package/lib/feature/storage/index.js +32 -0
- package/lib/feature/storage/swr-cache.d.ts +7 -0
- package/lib/feature/storage/swr-cache.js +54 -0
- package/lib/feature/unlock/method/add-flow.js +2 -2
- package/lib/feature/unlock/method/add-password.js +2 -2
- package/lib/feature/unlock/sync/unlock-method.js +3 -0
- package/lib/feature/user/sync-user.js +4 -2
- package/lib/feature/utils/index.d.ts +1 -0
- package/lib/feature/utils/index.js +1 -0
- package/lib/feature/voip/voip.d.ts +3 -0
- package/lib/feature/voip/voip.js +3 -0
- package/lib/interface.d.ts +42 -1
- package/lib/platform/device.d.ts +4 -3
- package/lib/platform/index.d.ts +1 -0
- package/lib/platform/index.js +1 -0
- package/lib/platform/ipc.d.ts +3 -0
- package/lib/platform/ipc.js +13 -0
- package/lib/platform/storage.d.ts +3 -0
- package/lib/platform/storage.js +9 -0
- package/lib/runtime/LockDeviceRuntime.js +3 -0
- package/lib/runtime/lock-config.d.ts +5 -1
- package/lib/runtime/lock-config.js +6 -0
- package/lib/runtime/runtime-state-types.d.ts +6 -0
- package/lib/utils/constant.d.ts +1 -0
- package/lib/utils/constant.js +6 -0
- package/lib/utils/errors.js +3 -1
- package/lib/utils/index.d.ts +2 -1
- package/lib/utils/index.js +1 -0
- package/lib/utils/parse.js +1 -1
- package/package.json +1 -11
- package/lib/bootstrap/bootstrap-lock-instance.d.ts +0 -7
- package/lib/bootstrap/bootstrap-lock-instance.js +0 -16
- package/lib/bootstrap/bootstrap.d.ts +0 -4
- package/lib/bootstrap/bootstrap.js +0 -53
- package/lib/bootstrap/lock-instance-runtime-ref.d.ts +0 -3
- package/lib/bootstrap/lock-instance-runtime-ref.js +0 -7
- package/lib/bootstrap/primary-instance.d.ts +0 -6
- package/lib/bootstrap/primary-instance.js +0 -24
- package/lib/bootstrap/resolve-runtime-from-export-this.d.ts +0 -5
- package/lib/bootstrap/resolve-runtime-from-export-this.js +0 -29
- package/lib/bootstrap/top-level-runtime.d.ts +0 -2
- package/lib/bootstrap/top-level-runtime.js +0 -9
- package/lib/entries/ble/bootstrap/bootstrap-lock-instance.d.ts +0 -7
- package/lib/entries/ble/bootstrap/bootstrap-lock-instance.js +0 -12
- package/lib/entries/ble/bootstrap/bootstrap.d.ts +0 -4
- package/lib/entries/ble/bootstrap/bootstrap.js +0 -53
- package/lib/entries/ble/bootstrap/lock-instance-runtime-ref.d.ts +0 -3
- package/lib/entries/ble/bootstrap/lock-instance-runtime-ref.js +0 -7
- package/lib/entries/ble/bootstrap/primary-instance.d.ts +0 -6
- package/lib/entries/ble/bootstrap/primary-instance.js +0 -24
- package/lib/entries/ble/bootstrap/resolve-runtime-from-export-this.d.ts +0 -5
- package/lib/entries/ble/bootstrap/resolve-runtime-from-export-this.js +0 -29
- package/lib/entries/ble/bootstrap/top-level-runtime.d.ts +0 -2
- package/lib/entries/ble/bootstrap/top-level-runtime.js +0 -9
- package/lib/entries/ble/build-instance.d.ts +0 -9
- package/lib/entries/ble/build-instance.js +0 -50
- package/lib/entries/ble/exports/capability.d.ts +0 -6
- package/lib/entries/ble/exports/capability.js +0 -17
- package/lib/entries/ble/exports/config.d.ts +0 -3
- package/lib/entries/ble/exports/config.js +0 -5
- package/lib/entries/ble/exports/dp.d.ts +0 -9
- package/lib/entries/ble/exports/dp.js +0 -13
- package/lib/entries/ble/exports/index.d.ts +0 -16
- package/lib/entries/ble/exports/index.js +0 -16
- package/lib/entries/ble/exports/linkage.d.ts +0 -5
- package/lib/entries/ble/exports/linkage.js +0 -15
- package/lib/entries/ble/exports/log.d.ts +0 -9
- package/lib/entries/ble/exports/log.js +0 -21
- package/lib/entries/ble/exports/media.d.ts +0 -4
- package/lib/entries/ble/exports/media.js +0 -12
- package/lib/entries/ble/exports/misc.d.ts +0 -19
- package/lib/entries/ble/exports/misc.js +0 -30
- package/lib/entries/ble/exports/offline-dps.d.ts +0 -8
- package/lib/entries/ble/exports/offline-dps.js +0 -24
- package/lib/entries/ble/exports/open/do-open-close-action.d.ts +0 -2
- package/lib/entries/ble/exports/open/do-open-close-action.js +0 -36
- package/lib/entries/ble/exports/open/index.d.ts +0 -18
- package/lib/entries/ble/exports/open/index.js +0 -45
- package/lib/entries/ble/exports/signal.d.ts +0 -6
- package/lib/entries/ble/exports/signal.js +0 -14
- package/lib/entries/ble/exports/sleep.d.ts +0 -13
- package/lib/entries/ble/exports/sleep.js +0 -31
- package/lib/entries/ble/exports/state.d.ts +0 -6
- package/lib/entries/ble/exports/state.js +0 -19
- package/lib/entries/ble/exports/temporary.d.ts +0 -31
- package/lib/entries/ble/exports/temporary.js +0 -91
- package/lib/entries/ble/exports/unlock/sync.d.ts +0 -1
- package/lib/entries/ble/exports/unlock/sync.js +0 -5
- package/lib/entries/ble/exports/unlock-method.d.ts +0 -19
- package/lib/entries/ble/exports/unlock-method.js +0 -58
- package/lib/entries/ble/exports/user/index.d.ts +0 -23
- package/lib/entries/ble/exports/user/index.js +0 -22
- package/lib/entries/ble/exports/user/sync.d.ts +0 -1
- package/lib/entries/ble/exports/user/sync.js +0 -5
- package/lib/entries/ble/index.d.ts +0 -8
- package/lib/entries/ble/index.js +0 -39
- package/lib/entries/fit/bootstrap/bootstrap-lock-instance.d.ts +0 -7
- package/lib/entries/fit/bootstrap/bootstrap-lock-instance.js +0 -12
- package/lib/entries/fit/bootstrap/bootstrap.d.ts +0 -4
- package/lib/entries/fit/bootstrap/bootstrap.js +0 -69
- package/lib/entries/fit/bootstrap/lock-instance-runtime-ref.d.ts +0 -3
- package/lib/entries/fit/bootstrap/lock-instance-runtime-ref.js +0 -7
- package/lib/entries/fit/bootstrap/primary-instance.d.ts +0 -6
- package/lib/entries/fit/bootstrap/primary-instance.js +0 -24
- package/lib/entries/fit/bootstrap/resolve-runtime-from-export-this.d.ts +0 -5
- package/lib/entries/fit/bootstrap/resolve-runtime-from-export-this.js +0 -29
- package/lib/entries/fit/bootstrap/top-level-runtime.d.ts +0 -2
- package/lib/entries/fit/bootstrap/top-level-runtime.js +0 -9
- package/lib/entries/fit/build-instance.d.ts +0 -9
- package/lib/entries/fit/build-instance.js +0 -57
- package/lib/entries/fit/exports/binding.d.ts +0 -8
- package/lib/entries/fit/exports/temp.d.ts +0 -19
- package/lib/entries/fit/exports/temp.js +0 -18
- package/lib/entries/fit/index.d.ts +0 -8
- package/lib/entries/fit/index.js +0 -36
- package/lib/entries/main/exports/open.d.ts +0 -16
- package/lib/entries/main/exports/open.js +0 -44
- package/lib/entries/screen/bootstrap/bootstrap-lock-instance.d.ts +0 -7
- package/lib/entries/screen/bootstrap/bootstrap-lock-instance.js +0 -12
- package/lib/entries/screen/bootstrap/bootstrap.d.ts +0 -4
- package/lib/entries/screen/bootstrap/bootstrap.js +0 -69
- package/lib/entries/screen/bootstrap/lock-instance-runtime-ref.d.ts +0 -3
- package/lib/entries/screen/bootstrap/lock-instance-runtime-ref.js +0 -7
- package/lib/entries/screen/bootstrap/primary-instance.d.ts +0 -6
- package/lib/entries/screen/bootstrap/primary-instance.js +0 -24
- package/lib/entries/screen/bootstrap/resolve-runtime-from-export-this.d.ts +0 -5
- package/lib/entries/screen/bootstrap/resolve-runtime-from-export-this.js +0 -29
- package/lib/entries/screen/bootstrap/top-level-runtime.d.ts +0 -2
- package/lib/entries/screen/bootstrap/top-level-runtime.js +0 -9
- package/lib/entries/screen/build-instance.d.ts +0 -9
- package/lib/entries/screen/build-instance.js +0 -57
- package/lib/entries/screen/exports/bind-events.d.ts +0 -4
- package/lib/entries/screen/exports/bind-events.js +0 -8
- package/lib/entries/screen/exports/binding.d.ts +0 -6
- package/lib/entries/screen/exports/binding.js +0 -15
- package/lib/entries/screen/exports/device.d.ts +0 -16
- package/lib/entries/screen/exports/device.js +0 -41
- package/lib/entries/screen/exports/event.d.ts +0 -3
- package/lib/entries/screen/exports/event.js +0 -5
- package/lib/entries/screen/exports/index.d.ts +0 -5
- package/lib/entries/screen/exports/index.js +0 -5
- package/lib/entries/screen/exports/user.d.ts +0 -2
- package/lib/entries/screen/exports/user.js +0 -8
- package/lib/entries/screen/index.d.ts +0 -8
- package/lib/entries/screen/index.js +0 -36
- package/lib/feature/unlock/door/door-action.d.ts +0 -2
- package/lib/feature/unlock/door/door-action.js +0 -32
- package/lib/fit.d.ts +0 -4
- package/lib/fit.js +0 -3
- package/lib/runtime/device-status/compute-device-status.d.ts +0 -25
- package/lib/runtime/device-status/compute-device-status.js +0 -94
- package/lib/screen.d.ts +0 -4
- package/lib/screen.js +0 -3
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { getStorageSync, removeStorageSync, setStorageSync, } from "../../platform";
|
|
2
|
+
const buildStorageKey = (rt, key) => {
|
|
3
|
+
const { devId, activeTime } = rt.config.devInfo;
|
|
4
|
+
return `${devId}_${activeTime}_${key}`;
|
|
5
|
+
};
|
|
6
|
+
export const setStorageForRuntime = (rt, key, data) => {
|
|
7
|
+
const value = typeof data === "string" ? data : JSON.stringify(data);
|
|
8
|
+
setStorageSync(buildStorageKey(rt, key), value);
|
|
9
|
+
};
|
|
10
|
+
export const getStorageForRuntime = (rt, key) => {
|
|
11
|
+
const raw = getStorageSync(buildStorageKey(rt, key));
|
|
12
|
+
if (raw == null || raw === "") {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
if (typeof raw === "string") {
|
|
16
|
+
try {
|
|
17
|
+
return JSON.parse(raw);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return raw;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return raw;
|
|
24
|
+
};
|
|
25
|
+
export const removeStorageForRuntime = (rt, key) => {
|
|
26
|
+
removeStorageSync(buildStorageKey(rt, key));
|
|
27
|
+
};
|
|
28
|
+
export const clearStorageForRuntime = (rt, keys) => {
|
|
29
|
+
keys.forEach((key) => {
|
|
30
|
+
removeStorageSync(buildStorageKey(rt, key));
|
|
31
|
+
});
|
|
32
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { LockDeviceRuntime } from "../../runtime/LockDeviceRuntime";
|
|
2
|
+
export interface SwrOptions<T> {
|
|
3
|
+
version?: number;
|
|
4
|
+
maxAge?: number;
|
|
5
|
+
applyToSession?: (rt: LockDeviceRuntime, fresh: T) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function getWithLocalCache<T>(rt: LockDeviceRuntime, key: string, fetcher: () => Promise<T>, options?: SwrOptions<T>): Promise<T>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { getRuntimeByDevId } from "../../runtime/registry";
|
|
2
|
+
import { sdkLog } from "../../utils/sdk-log";
|
|
3
|
+
import { getStorageForRuntime, setStorageForRuntime } from "./index";
|
|
4
|
+
const CACHE_KEY_PREFIX = "swr_";
|
|
5
|
+
const buildKey = (key) => `${CACHE_KEY_PREFIX}${key}`;
|
|
6
|
+
function readValidCache(rt, storageKey, version, maxAge) {
|
|
7
|
+
const envelope = getStorageForRuntime(rt, storageKey);
|
|
8
|
+
if (!envelope ||
|
|
9
|
+
typeof envelope !== "object" ||
|
|
10
|
+
envelope.v !== version ||
|
|
11
|
+
!("data" in envelope)) {
|
|
12
|
+
return { hit: false };
|
|
13
|
+
}
|
|
14
|
+
if (typeof maxAge === "number" && maxAge >= 0 && Date.now() - envelope.t > maxAge) {
|
|
15
|
+
return { hit: false };
|
|
16
|
+
}
|
|
17
|
+
return { hit: true, data: envelope.data };
|
|
18
|
+
}
|
|
19
|
+
export async function getWithLocalCache(rt, key, fetcher, options) {
|
|
20
|
+
if (!rt.config.localCache) {
|
|
21
|
+
return fetcher();
|
|
22
|
+
}
|
|
23
|
+
const version = options?.version ?? 1;
|
|
24
|
+
const storageKey = buildKey(key);
|
|
25
|
+
const devId = rt.devId;
|
|
26
|
+
const writeCache = (data) => {
|
|
27
|
+
if (getRuntimeByDevId(devId) !== rt) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const envelope = { v: version, t: Date.now(), data };
|
|
31
|
+
setStorageForRuntime(rt, storageKey, envelope);
|
|
32
|
+
};
|
|
33
|
+
const cached = readValidCache(rt, storageKey, version, options?.maxAge);
|
|
34
|
+
if (cached.hit) {
|
|
35
|
+
void (async () => {
|
|
36
|
+
try {
|
|
37
|
+
const fresh = await fetcher();
|
|
38
|
+
writeCache(fresh);
|
|
39
|
+
options?.applyToSession?.(rt, fresh);
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
sdkLog("warn", "swrCache", "revalidateFailed", {
|
|
43
|
+
devId,
|
|
44
|
+
data: { key },
|
|
45
|
+
error,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
})();
|
|
49
|
+
return cached.data;
|
|
50
|
+
}
|
|
51
|
+
const fresh = await fetcher();
|
|
52
|
+
writeCache(fresh);
|
|
53
|
+
return fresh;
|
|
54
|
+
}
|
|
@@ -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,
|
|
@@ -19,6 +19,9 @@ export const syncUnlockMethodWithRuntime = async (runtime) => {
|
|
|
19
19
|
});
|
|
20
20
|
rt.sync.unlockMethodAutoSyncEnabled = false;
|
|
21
21
|
const { allOpenDps = "" } = await getCurrentUserForRuntime(rt);
|
|
22
|
+
if (!allOpenDps) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
22
25
|
const { ins = "", distributed = false } = await fetchSyncUnlockMethodInfo({
|
|
23
26
|
devId: rt.config.devInfo.devId,
|
|
24
27
|
dpIds: allOpenDps.split(","),
|
|
@@ -3,10 +3,12 @@ import { deleteUserForRuntime } from "./delete-user-dp";
|
|
|
3
3
|
import { isUseNearChannelForRuntime } from "../misc/is-use-near-channel-for-runtime";
|
|
4
4
|
import { publishDpsOnlyWithRuntime, } from "../dp/publish-dps";
|
|
5
5
|
import dpCodes from "../../config/dp-code";
|
|
6
|
-
import { isBlePureDeviceForRuntime } from "../misc/capability";
|
|
6
|
+
import { hasCapabilityForRuntime, isBlePureDeviceForRuntime } from "../misc/capability";
|
|
7
7
|
import { sdkLog } from "../../utils/sdk-log";
|
|
8
|
+
import { ProductCommunicationType } from "../../constant";
|
|
8
9
|
export async function syncDeleteUsersWithRuntime(runtime) {
|
|
9
|
-
|
|
10
|
+
const hasWifi = hasCapabilityForRuntime(runtime, ProductCommunicationType.WIFI);
|
|
11
|
+
if (hasWifi && runtime.config.devInfo.wifiEnableState !== 1) {
|
|
10
12
|
sdkLog("debug", "syncUser", "deleteUsersSkipped", {
|
|
11
13
|
devId: runtime.devId,
|
|
12
14
|
data: { reason: "wifiActive" },
|
|
@@ -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) {
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { LockDeviceRuntime } from "../../runtime/LockDeviceRuntime";
|
|
2
|
+
export declare const getVoipAuthForRuntime: (rt: LockDeviceRuntime) => Promise<import("../../api/voip").VoipAuth>;
|
|
3
|
+
export declare const saveVoipAuthForRuntime: (rt: LockDeviceRuntime, userId: string) => Promise<boolean>;
|
package/lib/interface.d.ts
CHANGED
|
@@ -12,9 +12,12 @@ export interface LockSDKOption {
|
|
|
12
12
|
supportMultipleFace?: boolean;
|
|
13
13
|
supportOfflineDps?: boolean;
|
|
14
14
|
preFetch?: boolean;
|
|
15
|
+
localCache?: boolean;
|
|
16
|
+
notSupportWake?: boolean;
|
|
15
17
|
logLevel?: SDKLogLevel;
|
|
16
18
|
logger?: SDKLogSink;
|
|
17
19
|
logToConsole?: boolean;
|
|
20
|
+
kind?: "lock" | "fit" | "screen";
|
|
18
21
|
}
|
|
19
22
|
export interface ErrorData {
|
|
20
23
|
errorCode: number;
|
|
@@ -180,6 +183,16 @@ export interface EffectiveConfig {
|
|
|
180
183
|
effectiveTime?: number;
|
|
181
184
|
expiredTime?: number;
|
|
182
185
|
}
|
|
186
|
+
export interface FitBleKeyItem {
|
|
187
|
+
id: string;
|
|
188
|
+
unlockBindingId: string;
|
|
189
|
+
name: string;
|
|
190
|
+
opModeSubType?: number;
|
|
191
|
+
effectiveConfig: EffectiveConfig;
|
|
192
|
+
sn?: number;
|
|
193
|
+
userName?: string;
|
|
194
|
+
devNameList?: string[];
|
|
195
|
+
}
|
|
183
196
|
export interface UnBindUnlockMethod {
|
|
184
197
|
dpId: number;
|
|
185
198
|
dpCode: string;
|
|
@@ -204,6 +217,8 @@ export interface DeviceStatus {
|
|
|
204
217
|
};
|
|
205
218
|
isWifiActive: boolean;
|
|
206
219
|
isWifiMatter: boolean;
|
|
220
|
+
isActiveThread: boolean;
|
|
221
|
+
isShareThread: boolean;
|
|
207
222
|
}
|
|
208
223
|
export interface UnionUnlockInfo {
|
|
209
224
|
userId: string;
|
|
@@ -254,6 +269,11 @@ export interface MediaInfo {
|
|
|
254
269
|
fileUrl: string;
|
|
255
270
|
mediaBucket: string;
|
|
256
271
|
mediaKey: string;
|
|
272
|
+
width: number;
|
|
273
|
+
height: number;
|
|
274
|
+
angle: number;
|
|
275
|
+
position: number;
|
|
276
|
+
isVR: boolean;
|
|
257
277
|
}
|
|
258
278
|
export type LogType = "alarm_record" | "close_record" | "unlock_record" | "operation" | "local_operation";
|
|
259
279
|
export type CloseValue = "UNDEFINED" | "VOICE_REMOTE" | "APP_REMOTE" | "AUTO" | "LOCAL_MANUAL" | "FITTINGS" | "APP" | "GEO_FENCE";
|
|
@@ -269,6 +289,8 @@ export interface LogData {
|
|
|
269
289
|
dpCode: string;
|
|
270
290
|
data: any;
|
|
271
291
|
userName: string;
|
|
292
|
+
avatarUrl?: string;
|
|
293
|
+
relateDevName?: string;
|
|
272
294
|
bindable: boolean;
|
|
273
295
|
unlockName: string;
|
|
274
296
|
mediaInfo?: MediaInfo[];
|
|
@@ -334,10 +356,20 @@ export interface AlbumMessage extends MediaInfo {
|
|
|
334
356
|
type: number;
|
|
335
357
|
createTime: number;
|
|
336
358
|
}
|
|
359
|
+
export type VRModeType = "original" | "VR" | "horizontal" | "vertical";
|
|
337
360
|
export interface DeviceAdvancedAbility {
|
|
338
361
|
cloudStorage: {
|
|
339
362
|
support: boolean;
|
|
340
363
|
};
|
|
364
|
+
vr: {
|
|
365
|
+
support: boolean;
|
|
366
|
+
coverMode: VRModeType;
|
|
367
|
+
modes: Array<{
|
|
368
|
+
mode: VRModeType;
|
|
369
|
+
value: number;
|
|
370
|
+
}>;
|
|
371
|
+
defaultMode: VRModeType;
|
|
372
|
+
};
|
|
341
373
|
ai: {
|
|
342
374
|
support: boolean;
|
|
343
375
|
config: Record<string, any>;
|
|
@@ -348,7 +380,9 @@ export interface DeviceAdvancedAbility {
|
|
|
348
380
|
};
|
|
349
381
|
wechatVoip: {
|
|
350
382
|
support: boolean;
|
|
351
|
-
|
|
383
|
+
isPublice: boolean;
|
|
384
|
+
appId?: string;
|
|
385
|
+
modeId?: string;
|
|
352
386
|
};
|
|
353
387
|
voip: {
|
|
354
388
|
support: boolean;
|
|
@@ -390,4 +424,11 @@ export interface AIReportPopup {
|
|
|
390
424
|
reportId: string;
|
|
391
425
|
yearMonth: number;
|
|
392
426
|
}
|
|
427
|
+
export interface CameraConfig {
|
|
428
|
+
isVR: boolean;
|
|
429
|
+
width: number;
|
|
430
|
+
height: number;
|
|
431
|
+
rotate: number;
|
|
432
|
+
location: number;
|
|
433
|
+
}
|
|
393
434
|
export {};
|
package/lib/platform/device.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ export declare const getSystemInfoSync: () => {
|
|
|
52
52
|
locationEnabled: boolean;
|
|
53
53
|
wifiEnabled: boolean;
|
|
54
54
|
theme?: ty.Themes;
|
|
55
|
-
deviceOrientation?: ty.
|
|
55
|
+
deviceOrientation?: ty.PhoneOrientation;
|
|
56
56
|
deviceLevel: string;
|
|
57
57
|
isSupportPinShortcut?: boolean;
|
|
58
58
|
deviceType?: string;
|
|
@@ -74,9 +74,10 @@ export declare const requestCloud: <T>(options: {
|
|
|
74
74
|
export declare const getLaunchOptionsSync: () => {
|
|
75
75
|
path: string;
|
|
76
76
|
scene?: ty.MiniAppScene;
|
|
77
|
-
query: any
|
|
77
|
+
query: Record<string, any>;
|
|
78
78
|
referrerInfo: ty.ReferrerInfo;
|
|
79
79
|
apiCategory?: string;
|
|
80
|
+
extraQuery?: Record<string, any>;
|
|
80
81
|
};
|
|
81
82
|
export declare function encrypt(deviceId: string, plaintext: string): Promise<string>;
|
|
82
83
|
export declare function decrypt(deviceId: string, plaintext: string): Promise<string>;
|
|
@@ -219,7 +220,7 @@ export declare const onResetMemberName: (cb: HomeMemberListener) => void;
|
|
|
219
220
|
export declare const offResetMemberName: (cb: HomeMemberListener) => void;
|
|
220
221
|
export declare const onResetMemberRole: (cb: HomeMemberListener) => void;
|
|
221
222
|
export declare const offResetMemberRole: (cb: HomeMemberListener) => void;
|
|
222
|
-
export declare const getLogManager: () => ty.
|
|
223
|
+
export declare const getLogManager: () => ty.LogManager;
|
|
223
224
|
export declare const getAppUserInfo: () => Promise<{
|
|
224
225
|
nickName: string;
|
|
225
226
|
avatarUrl: string;
|
package/lib/platform/index.d.ts
CHANGED
package/lib/platform/index.js
CHANGED
package/lib/platform/ipc.d.ts
CHANGED
package/lib/platform/ipc.js
CHANGED
|
@@ -31,10 +31,23 @@ const getCurrentSupportedTalkMode = (deviceId) => {
|
|
|
31
31
|
}
|
|
32
32
|
return Promise.reject(new Error("not support"));
|
|
33
33
|
};
|
|
34
|
+
const getTTTAbilityKeyList = (key) => {
|
|
35
|
+
if (ty.ipc.getTTTAbilityKeyList) {
|
|
36
|
+
return new Promise((resolve, reject) => {
|
|
37
|
+
ty.ipc.getTTTAbilityKeyList({
|
|
38
|
+
key,
|
|
39
|
+
success: resolve,
|
|
40
|
+
fail: reject,
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return Promise.resolve({ abilityList: [] });
|
|
45
|
+
};
|
|
34
46
|
export default {
|
|
35
47
|
wakeUpDoorBell,
|
|
36
48
|
isConnected,
|
|
37
49
|
isConnecting,
|
|
38
50
|
connect,
|
|
39
51
|
getCurrentSupportedTalkMode,
|
|
52
|
+
getTTTAbilityKeyList,
|
|
40
53
|
};
|
|
@@ -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,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ProductCommunicationType, RemotePermissionType } from "../constant";
|
|
2
|
-
import { CapabilityInfo, DeviceInfo, DeviceStatus, DpSchema } from "../interface";
|
|
2
|
+
import { CameraConfig, CapabilityInfo, DeviceInfo, DeviceStatus, DpSchema } from "../interface";
|
|
3
3
|
export type LockConfigState = {
|
|
4
4
|
devInfo: DeviceInfo;
|
|
5
5
|
dpSchema: Record<string, DpSchema>;
|
|
@@ -21,8 +21,12 @@ export type LockConfigState = {
|
|
|
21
21
|
supportMultipleFace: boolean;
|
|
22
22
|
supportOfflineDps: boolean;
|
|
23
23
|
preFetch: boolean;
|
|
24
|
+
localCache: boolean;
|
|
24
25
|
supportTalk: boolean;
|
|
25
26
|
isTwoWayTalk: boolean;
|
|
27
|
+
cameraConfig: CameraConfig[];
|
|
28
|
+
notSupportWake: boolean;
|
|
29
|
+
isFitting: boolean;
|
|
26
30
|
};
|
|
27
31
|
export declare function createDefaultDeviceStatus(): DeviceStatus;
|
|
28
32
|
export declare function createLockConfigState(): LockConfigState;
|
|
@@ -7,6 +7,8 @@ export function createDefaultDeviceStatus() {
|
|
|
7
7
|
onlineTypes: [],
|
|
8
8
|
isWifiActive: false,
|
|
9
9
|
isWifiMatter: false,
|
|
10
|
+
isActiveThread: false,
|
|
11
|
+
isShareThread: false,
|
|
10
12
|
};
|
|
11
13
|
}
|
|
12
14
|
export function createLockConfigState() {
|
|
@@ -31,7 +33,11 @@ export function createLockConfigState() {
|
|
|
31
33
|
supportMultipleFace: false,
|
|
32
34
|
supportOfflineDps: false,
|
|
33
35
|
preFetch: false,
|
|
36
|
+
localCache: true,
|
|
34
37
|
supportTalk: false,
|
|
35
38
|
isTwoWayTalk: false,
|
|
39
|
+
cameraConfig: [],
|
|
40
|
+
notSupportWake: false,
|
|
41
|
+
isFitting: false
|
|
36
42
|
};
|
|
37
43
|
}
|
|
@@ -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/constant.d.ts
CHANGED
package/lib/utils/constant.js
CHANGED
package/lib/utils/errors.js
CHANGED
|
@@ -102,7 +102,9 @@ const errors = {
|
|
|
102
102
|
1100: "Binding limit reached",
|
|
103
103
|
1101: "The lock has already been bound, please do not bind it again",
|
|
104
104
|
1102: "Lock is binding",
|
|
105
|
-
1103: "Binding failed"
|
|
105
|
+
1103: "Binding failed",
|
|
106
|
+
1104: "Failed to switch cameras",
|
|
107
|
+
1105: "Camera switching is not supported",
|
|
106
108
|
};
|
|
107
109
|
export const getError = (code, ...places) => {
|
|
108
110
|
if (errors[code]) {
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export declare const getSystemInfo: () => {
|
|
|
32
32
|
locationEnabled: boolean;
|
|
33
33
|
wifiEnabled: boolean;
|
|
34
34
|
theme?: ty.Themes;
|
|
35
|
-
deviceOrientation?: ty.
|
|
35
|
+
deviceOrientation?: ty.PhoneOrientation;
|
|
36
36
|
deviceLevel: string;
|
|
37
37
|
isSupportPinShortcut?: boolean;
|
|
38
38
|
deviceType?: string;
|
|
@@ -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)
|
package/lib/utils/parse.js
CHANGED
|
@@ -6,7 +6,7 @@ export const parseCapabilities = (dpValue) => {
|
|
|
6
6
|
return null;
|
|
7
7
|
}
|
|
8
8
|
const data = dpUtils.parse(dpValue, capabilitiesMap);
|
|
9
|
-
if (data.
|
|
9
|
+
if (data.type === ModuleType.M7258) {
|
|
10
10
|
return {
|
|
11
11
|
...data,
|
|
12
12
|
rotateType: data.rotateType === 1 ? 0 : data.rotateType === 0 ? 1 : data.rotateType,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ray-js/lock-sdk",
|
|
3
|
-
"version": "1.2.0-beta.
|
|
3
|
+
"version": "1.2.0-beta.30",
|
|
4
4
|
"files": [
|
|
5
5
|
"lib",
|
|
6
6
|
"LICENSE.md"
|
|
@@ -12,16 +12,6 @@
|
|
|
12
12
|
"types": "./lib/index.d.ts",
|
|
13
13
|
"import": "./lib/index.js",
|
|
14
14
|
"default": "./lib/index.js"
|
|
15
|
-
},
|
|
16
|
-
"./fit": {
|
|
17
|
-
"types": "./lib/fit.d.ts",
|
|
18
|
-
"import": "./lib/fit.js",
|
|
19
|
-
"default": "./lib/fit.js"
|
|
20
|
-
},
|
|
21
|
-
"./screen": {
|
|
22
|
-
"types": "./lib/screen.d.ts",
|
|
23
|
-
"import": "./lib/screen.js",
|
|
24
|
-
"default": "./lib/screen.js"
|
|
25
15
|
}
|
|
26
16
|
},
|
|
27
17
|
"scripts": {
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { LockSDKOption } from "../interface";
|
|
2
|
-
import type { LockDeviceRuntime } from "../runtime/LockDeviceRuntime";
|
|
3
|
-
import { type LockSDKInstance } from "../entries/main/build-instance";
|
|
4
|
-
export declare function bootstrapRegisteredLockInstance(options?: LockSDKOption): Promise<{
|
|
5
|
-
runtime: LockDeviceRuntime;
|
|
6
|
-
instance: LockSDKInstance;
|
|
7
|
-
}>;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { addEvents } from "../feature/state/platform-routing";
|
|
2
|
-
import { initState } from "../feature/state/init-state";
|
|
3
|
-
import { registerRuntime } from "../runtime/registry";
|
|
4
|
-
import { buildLockSDKInstance, } from "../entries/main/build-instance";
|
|
5
|
-
import * as MainDeviceExports from "../entries/main/exports";
|
|
6
|
-
import { createBootstrappedRuntime } from "./bootstrap";
|
|
7
|
-
export async function bootstrapRegisteredLockInstance(options) {
|
|
8
|
-
const runtime = await createBootstrappedRuntime(options);
|
|
9
|
-
registerRuntime(runtime);
|
|
10
|
-
addEvents(runtime);
|
|
11
|
-
await initState(runtime);
|
|
12
|
-
return {
|
|
13
|
-
runtime,
|
|
14
|
-
instance: buildLockSDKInstance(runtime, MainDeviceExports),
|
|
15
|
-
};
|
|
16
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { LockSDKOption } from "../interface";
|
|
2
|
-
import { LockDeviceRuntime } from "../runtime/LockDeviceRuntime";
|
|
3
|
-
export declare function applyLockOptionsToRuntime(runtime: LockDeviceRuntime, options?: LockSDKOption): Promise<void>;
|
|
4
|
-
export declare function createBootstrappedRuntime(options?: LockSDKOption): Promise<LockDeviceRuntime>;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import dpCodes from "../config/dp-code";
|
|
2
|
-
import { getCapabilities } from "../utils";
|
|
3
|
-
import { getDeviceInfo, trackEvent } from "../platform/device";
|
|
4
|
-
import { LockDeviceRuntime } from "../runtime/LockDeviceRuntime";
|
|
5
|
-
export async function applyLockOptionsToRuntime(runtime, options) {
|
|
6
|
-
const { config } = runtime;
|
|
7
|
-
let { devInfo, deviceId } = options || {};
|
|
8
|
-
if (!devInfo && !deviceId) {
|
|
9
|
-
throw new Error("deviceId is required in lock sdk");
|
|
10
|
-
}
|
|
11
|
-
if (deviceId && (!devInfo || devInfo.devId !== deviceId)) {
|
|
12
|
-
devInfo = await getDeviceInfo(deviceId);
|
|
13
|
-
}
|
|
14
|
-
let dpSchema = {};
|
|
15
|
-
const codesById = {};
|
|
16
|
-
const idsByCode = {};
|
|
17
|
-
if (devInfo.schema) {
|
|
18
|
-
dpSchema = devInfo.schema.reduce((acc, cur) => {
|
|
19
|
-
acc[cur.code] = cur;
|
|
20
|
-
codesById[cur.id] = cur.code;
|
|
21
|
-
idsByCode[cur.code] = cur.id;
|
|
22
|
-
return acc;
|
|
23
|
-
}, {});
|
|
24
|
-
}
|
|
25
|
-
else if (devInfo.dpSchema) {
|
|
26
|
-
dpSchema = devInfo.dpSchema;
|
|
27
|
-
Object.keys(dpSchema).forEach((key) => {
|
|
28
|
-
const item = dpSchema[key];
|
|
29
|
-
codesById[item.id] = item.code;
|
|
30
|
-
idsByCode[item.code] = item.id;
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
config.strictMode = options?.strictMode ?? true;
|
|
34
|
-
config.passwordDigitalBase = options?.passwordDigitalBase ?? 10;
|
|
35
|
-
config.passwordSupportZero = options?.passwordSupportZero ?? true;
|
|
36
|
-
config.supportMultipleFace = options?.supportMultipleFace ?? false;
|
|
37
|
-
config.supportOfflineDps = options?.supportOfflineDps ?? false;
|
|
38
|
-
config.devInfo = devInfo;
|
|
39
|
-
config.dpSchema = dpSchema;
|
|
40
|
-
config.codesById = codesById;
|
|
41
|
-
config.idsByCode = idsByCode;
|
|
42
|
-
config.supportBigData = !!dpSchema[dpCodes.synchMethodW];
|
|
43
|
-
config.preFetch = options?.preFetch ?? false;
|
|
44
|
-
config.communication = getCapabilities(devInfo.capability).map((item) => item.id);
|
|
45
|
-
trackEvent("t$y_UztB3Lj9Qns375R0r7dA0L5Kr2VytH3J".replace("$", ""), {
|
|
46
|
-
pid: devInfo.productId,
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
export async function createBootstrappedRuntime(options) {
|
|
50
|
-
const runtime = new LockDeviceRuntime();
|
|
51
|
-
await applyLockOptionsToRuntime(runtime, options);
|
|
52
|
-
return runtime;
|
|
53
|
-
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { LockDeviceRuntime } from "../runtime/LockDeviceRuntime";
|
|
2
|
-
export declare function registerLockSDKInstanceRuntime(instance: object, runtime: LockDeviceRuntime): void;
|
|
3
|
-
export declare function getRuntimeForLockSDKInstance(instance: object): LockDeviceRuntime | undefined;
|