@ray-js/lock-sdk 1.2.0-beta.9 → 1.2.1-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/lib/api/fit.d.ts +55 -2
  2. package/lib/api/fit.js +43 -1
  3. package/lib/api/gesture.d.ts +11 -0
  4. package/lib/api/gesture.js +18 -0
  5. package/lib/api/log.d.ts +52 -4
  6. package/lib/api/log.js +22 -0
  7. package/lib/api/temp.d.ts +21 -0
  8. package/lib/api/temp.js +24 -0
  9. package/lib/api/user.d.ts +4 -0
  10. package/lib/api/user.js +8 -0
  11. package/lib/config/dp-code/index.d.ts +1 -1
  12. package/lib/config/dp-code/index.js +1 -0
  13. package/lib/entries/main/bootstrap/bootstrap-lock-instance.d.ts +2 -1
  14. package/lib/entries/main/bootstrap/bootstrap-lock-instance.js +23 -8
  15. package/lib/entries/main/bootstrap/bootstrap.d.ts +3 -2
  16. package/lib/entries/main/bootstrap/bootstrap.js +10 -6
  17. package/lib/entries/main/bootstrap/primary-instance.d.ts +1 -2
  18. package/lib/entries/main/bootstrap/primary-instance.js +1 -1
  19. package/lib/entries/main/bootstrap/resolve-runtime-from-export-this.js +1 -1
  20. package/lib/entries/main/build-instance.d.ts +6 -3
  21. package/lib/entries/main/build-instance.js +13 -1
  22. package/lib/entries/main/exports/capability.d.ts +2 -0
  23. package/lib/entries/main/exports/capability.js +7 -1
  24. package/lib/entries/main/exports/fit-sdk/binding.d.ts +10 -0
  25. package/lib/entries/{fit/exports → main/exports/fit-sdk}/binding.js +6 -3
  26. package/lib/entries/{fit/exports → main/exports/fit-sdk}/device.d.ts +11 -10
  27. package/lib/entries/{fit/exports → main/exports/fit-sdk}/device.js +20 -20
  28. package/lib/entries/{fit/exports → main/exports/fit-sdk}/index.d.ts +1 -0
  29. package/lib/entries/{fit/exports → main/exports/fit-sdk}/index.js +1 -0
  30. package/lib/entries/main/exports/fit-sdk/log.d.ts +3 -0
  31. package/lib/entries/main/exports/fit-sdk/log.js +5 -0
  32. package/lib/entries/main/exports/fit-sdk/temp.d.ts +40 -0
  33. package/lib/entries/main/exports/fit-sdk/temp.js +59 -0
  34. package/lib/entries/main/exports/gesture.d.ts +6 -0
  35. package/lib/entries/main/exports/gesture.js +8 -0
  36. package/lib/entries/main/exports/index.d.ts +5 -0
  37. package/lib/entries/main/exports/index.js +5 -0
  38. package/lib/entries/main/exports/log.d.ts +2 -0
  39. package/lib/entries/main/exports/log.js +7 -1
  40. package/lib/entries/main/exports/misc.d.ts +4 -2
  41. package/lib/entries/main/exports/misc.js +2 -2
  42. package/lib/entries/main/index.d.ts +3 -3
  43. package/lib/entries/main/index.js +11 -5
  44. package/lib/feature/fit/bind-lock-to-fit.d.ts +1 -0
  45. package/lib/feature/fit/bind-lock-to-fit.js +53 -0
  46. package/lib/feature/fit/ble-key.d.ts +10 -4
  47. package/lib/feature/fit/ble-key.js +145 -4
  48. package/lib/feature/fit/device-bv.d.ts +2 -0
  49. package/lib/feature/fit/device-bv.js +15 -0
  50. package/lib/feature/fit/invalid-password.d.ts +10 -0
  51. package/lib/feature/fit/invalid-password.js +43 -0
  52. package/lib/feature/fit/list.d.ts +12 -2
  53. package/lib/feature/fit/list.js +54 -5
  54. package/lib/feature/fit/log.d.ts +7 -0
  55. package/lib/feature/fit/log.js +123 -0
  56. package/lib/feature/fit/method/add-flow.js +2 -2
  57. package/lib/feature/fit/method/add-password.js +2 -2
  58. package/lib/feature/fit/method/internal/base.js +7 -16
  59. package/lib/feature/fit/method/update-remove.js +40 -14
  60. package/lib/feature/fit/password-list.d.ts +37 -0
  61. package/lib/feature/fit/password-list.js +44 -1
  62. package/lib/feature/fit/security-channel.d.ts +3 -0
  63. package/lib/feature/fit/security-channel.js +43 -0
  64. package/lib/feature/fit/shared.d.ts +8 -0
  65. package/lib/feature/fit/shared.js +40 -1
  66. package/lib/feature/fit/sync.d.ts +4 -2
  67. package/lib/feature/fit/sync.js +63 -22
  68. package/lib/feature/fit/temp-password.d.ts +23 -0
  69. package/lib/feature/fit/temp-password.js +95 -3
  70. package/lib/feature/fit/users.d.ts +1 -0
  71. package/lib/feature/fit/users.js +1 -0
  72. package/lib/feature/gesture/gesture.d.ts +6 -0
  73. package/lib/feature/gesture/gesture.js +3 -0
  74. package/lib/feature/log/log.d.ts +5 -1
  75. package/lib/feature/log/log.js +53 -6
  76. package/lib/feature/misc/ble-control.js +2 -2
  77. package/lib/feature/misc/capability.d.ts +2 -0
  78. package/lib/feature/misc/capability.js +33 -31
  79. package/lib/feature/misc/connect-device.d.ts +1 -1
  80. package/lib/feature/misc/connect-device.js +7 -6
  81. package/lib/feature/misc/is-use-near-channel-for-runtime.js +8 -1
  82. package/lib/feature/password/temporary/offline-create.d.ts +14 -0
  83. package/lib/feature/password/temporary/offline-create.js +77 -1
  84. package/lib/feature/service/goto-service.d.ts +1 -1
  85. package/lib/feature/state/clear.js +1 -0
  86. package/lib/feature/state/device-status.js +17 -6
  87. package/lib/feature/state/init-state.js +17 -9
  88. package/lib/feature/state/platform-routing.js +12 -3
  89. package/lib/feature/state/remote-permissions.js +2 -1
  90. package/lib/feature/state/sync/remote-serect-key.js +7 -0
  91. package/lib/feature/storage/swr-cache.d.ts +7 -0
  92. package/lib/feature/storage/swr-cache.js +54 -0
  93. package/lib/feature/unlock/method/add-flow.js +2 -2
  94. package/lib/feature/unlock/method/add-password.js +2 -2
  95. package/lib/feature/unlock/method/internal/base.js +6 -16
  96. package/lib/feature/user/sync-user.js +4 -2
  97. package/lib/feature/user/user.js +25 -18
  98. package/lib/feature/utils/index.d.ts +1 -0
  99. package/lib/feature/utils/index.js +1 -0
  100. package/lib/interface.d.ts +24 -1
  101. package/lib/platform/device.d.ts +4 -3
  102. package/lib/platform/ipc.d.ts +3 -0
  103. package/lib/platform/ipc.js +13 -0
  104. package/lib/platform/storage.d.ts +1 -1
  105. package/lib/runtime/LockDeviceRuntime.js +3 -0
  106. package/lib/runtime/lock-config.d.ts +3 -0
  107. package/lib/runtime/lock-config.js +5 -0
  108. package/lib/runtime/runtime-state-types.d.ts +6 -0
  109. package/lib/utils/constant.d.ts +1 -0
  110. package/lib/utils/constant.js +6 -0
  111. package/lib/utils/errors.js +1 -0
  112. package/lib/utils/index.d.ts +2 -13
  113. package/lib/utils/index.js +1 -14
  114. package/package.json +1 -11
  115. package/lib/bootstrap/bootstrap-lock-instance.d.ts +0 -7
  116. package/lib/bootstrap/bootstrap-lock-instance.js +0 -16
  117. package/lib/bootstrap/bootstrap.d.ts +0 -4
  118. package/lib/bootstrap/bootstrap.js +0 -53
  119. package/lib/bootstrap/lock-instance-runtime-ref.d.ts +0 -3
  120. package/lib/bootstrap/lock-instance-runtime-ref.js +0 -7
  121. package/lib/bootstrap/primary-instance.d.ts +0 -6
  122. package/lib/bootstrap/primary-instance.js +0 -24
  123. package/lib/bootstrap/resolve-runtime-from-export-this.d.ts +0 -5
  124. package/lib/bootstrap/resolve-runtime-from-export-this.js +0 -29
  125. package/lib/bootstrap/top-level-runtime.d.ts +0 -2
  126. package/lib/bootstrap/top-level-runtime.js +0 -9
  127. package/lib/entries/ble/bootstrap/bootstrap-lock-instance.d.ts +0 -7
  128. package/lib/entries/ble/bootstrap/bootstrap-lock-instance.js +0 -12
  129. package/lib/entries/ble/bootstrap/bootstrap.d.ts +0 -4
  130. package/lib/entries/ble/bootstrap/bootstrap.js +0 -53
  131. package/lib/entries/ble/bootstrap/lock-instance-runtime-ref.d.ts +0 -3
  132. package/lib/entries/ble/bootstrap/lock-instance-runtime-ref.js +0 -7
  133. package/lib/entries/ble/bootstrap/primary-instance.d.ts +0 -6
  134. package/lib/entries/ble/bootstrap/primary-instance.js +0 -24
  135. package/lib/entries/ble/bootstrap/resolve-runtime-from-export-this.d.ts +0 -5
  136. package/lib/entries/ble/bootstrap/resolve-runtime-from-export-this.js +0 -29
  137. package/lib/entries/ble/bootstrap/top-level-runtime.d.ts +0 -2
  138. package/lib/entries/ble/bootstrap/top-level-runtime.js +0 -9
  139. package/lib/entries/ble/build-instance.d.ts +0 -9
  140. package/lib/entries/ble/build-instance.js +0 -50
  141. package/lib/entries/ble/exports/capability.d.ts +0 -6
  142. package/lib/entries/ble/exports/capability.js +0 -17
  143. package/lib/entries/ble/exports/config.d.ts +0 -3
  144. package/lib/entries/ble/exports/config.js +0 -5
  145. package/lib/entries/ble/exports/dp.d.ts +0 -9
  146. package/lib/entries/ble/exports/dp.js +0 -13
  147. package/lib/entries/ble/exports/index.d.ts +0 -16
  148. package/lib/entries/ble/exports/index.js +0 -16
  149. package/lib/entries/ble/exports/linkage.d.ts +0 -5
  150. package/lib/entries/ble/exports/linkage.js +0 -15
  151. package/lib/entries/ble/exports/log.d.ts +0 -9
  152. package/lib/entries/ble/exports/log.js +0 -21
  153. package/lib/entries/ble/exports/media.d.ts +0 -4
  154. package/lib/entries/ble/exports/media.js +0 -12
  155. package/lib/entries/ble/exports/misc.d.ts +0 -19
  156. package/lib/entries/ble/exports/misc.js +0 -30
  157. package/lib/entries/ble/exports/offline-dps.d.ts +0 -8
  158. package/lib/entries/ble/exports/offline-dps.js +0 -24
  159. package/lib/entries/ble/exports/open/do-open-close-action.d.ts +0 -2
  160. package/lib/entries/ble/exports/open/do-open-close-action.js +0 -36
  161. package/lib/entries/ble/exports/open/index.d.ts +0 -18
  162. package/lib/entries/ble/exports/open/index.js +0 -45
  163. package/lib/entries/ble/exports/signal.d.ts +0 -6
  164. package/lib/entries/ble/exports/signal.js +0 -14
  165. package/lib/entries/ble/exports/sleep.d.ts +0 -13
  166. package/lib/entries/ble/exports/sleep.js +0 -31
  167. package/lib/entries/ble/exports/state.d.ts +0 -6
  168. package/lib/entries/ble/exports/state.js +0 -19
  169. package/lib/entries/ble/exports/temporary.d.ts +0 -31
  170. package/lib/entries/ble/exports/temporary.js +0 -91
  171. package/lib/entries/ble/exports/unlock/sync.d.ts +0 -1
  172. package/lib/entries/ble/exports/unlock/sync.js +0 -5
  173. package/lib/entries/ble/exports/unlock-method.d.ts +0 -19
  174. package/lib/entries/ble/exports/unlock-method.js +0 -58
  175. package/lib/entries/ble/exports/user/index.d.ts +0 -23
  176. package/lib/entries/ble/exports/user/index.js +0 -22
  177. package/lib/entries/ble/exports/user/sync.d.ts +0 -1
  178. package/lib/entries/ble/exports/user/sync.js +0 -5
  179. package/lib/entries/ble/index.d.ts +0 -8
  180. package/lib/entries/ble/index.js +0 -39
  181. package/lib/entries/fit/bootstrap/bootstrap-lock-instance.d.ts +0 -7
  182. package/lib/entries/fit/bootstrap/bootstrap-lock-instance.js +0 -12
  183. package/lib/entries/fit/bootstrap/bootstrap.d.ts +0 -4
  184. package/lib/entries/fit/bootstrap/bootstrap.js +0 -69
  185. package/lib/entries/fit/bootstrap/lock-instance-runtime-ref.d.ts +0 -3
  186. package/lib/entries/fit/bootstrap/lock-instance-runtime-ref.js +0 -7
  187. package/lib/entries/fit/bootstrap/primary-instance.d.ts +0 -6
  188. package/lib/entries/fit/bootstrap/primary-instance.js +0 -24
  189. package/lib/entries/fit/bootstrap/resolve-runtime-from-export-this.d.ts +0 -5
  190. package/lib/entries/fit/bootstrap/resolve-runtime-from-export-this.js +0 -29
  191. package/lib/entries/fit/bootstrap/top-level-runtime.d.ts +0 -2
  192. package/lib/entries/fit/bootstrap/top-level-runtime.js +0 -9
  193. package/lib/entries/fit/build-instance.d.ts +0 -9
  194. package/lib/entries/fit/build-instance.js +0 -57
  195. package/lib/entries/fit/exports/binding.d.ts +0 -8
  196. package/lib/entries/fit/exports/temp.d.ts +0 -19
  197. package/lib/entries/fit/exports/temp.js +0 -18
  198. package/lib/entries/fit/index.d.ts +0 -8
  199. package/lib/entries/fit/index.js +0 -36
  200. package/lib/entries/main/exports/open.d.ts +0 -16
  201. package/lib/entries/main/exports/open.js +0 -44
  202. package/lib/entries/screen/bootstrap/bootstrap-lock-instance.d.ts +0 -7
  203. package/lib/entries/screen/bootstrap/bootstrap-lock-instance.js +0 -12
  204. package/lib/entries/screen/bootstrap/bootstrap.d.ts +0 -4
  205. package/lib/entries/screen/bootstrap/bootstrap.js +0 -69
  206. package/lib/entries/screen/bootstrap/lock-instance-runtime-ref.d.ts +0 -3
  207. package/lib/entries/screen/bootstrap/lock-instance-runtime-ref.js +0 -7
  208. package/lib/entries/screen/bootstrap/primary-instance.d.ts +0 -6
  209. package/lib/entries/screen/bootstrap/primary-instance.js +0 -24
  210. package/lib/entries/screen/bootstrap/resolve-runtime-from-export-this.d.ts +0 -5
  211. package/lib/entries/screen/bootstrap/resolve-runtime-from-export-this.js +0 -29
  212. package/lib/entries/screen/bootstrap/top-level-runtime.d.ts +0 -2
  213. package/lib/entries/screen/bootstrap/top-level-runtime.js +0 -9
  214. package/lib/entries/screen/build-instance.d.ts +0 -9
  215. package/lib/entries/screen/build-instance.js +0 -57
  216. package/lib/entries/screen/exports/bind-events.d.ts +0 -4
  217. package/lib/entries/screen/exports/bind-events.js +0 -8
  218. package/lib/entries/screen/exports/binding.d.ts +0 -6
  219. package/lib/entries/screen/exports/binding.js +0 -15
  220. package/lib/entries/screen/exports/device.d.ts +0 -16
  221. package/lib/entries/screen/exports/device.js +0 -41
  222. package/lib/entries/screen/exports/event.d.ts +0 -3
  223. package/lib/entries/screen/exports/event.js +0 -5
  224. package/lib/entries/screen/exports/index.d.ts +0 -5
  225. package/lib/entries/screen/exports/index.js +0 -5
  226. package/lib/entries/screen/exports/user.d.ts +0 -2
  227. package/lib/entries/screen/exports/user.js +0 -8
  228. package/lib/entries/screen/index.d.ts +0 -8
  229. package/lib/entries/screen/index.js +0 -36
  230. package/lib/feature/unlock/door/door-action.d.ts +0 -2
  231. package/lib/feature/unlock/door/door-action.js +0 -32
  232. package/lib/fit.d.ts +0 -4
  233. package/lib/fit.js +0 -3
  234. package/lib/runtime/device-status/compute-device-status.d.ts +0 -25
  235. package/lib/runtime/device-status/compute-device-status.js +0 -94
  236. package/lib/screen.d.ts +0 -4
  237. package/lib/screen.js +0 -3
@@ -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: `${dpId}-${res.unlockId}`,
79
+ unlockId: formatCloudUnlockId(dpId, res.unlockId),
80
80
  unlockName: params.name,
81
81
  unlockDetail: aesPwd,
82
82
  ...specialInfo,
@@ -1,11 +1,14 @@
1
+ import DpUtils from "@ray-js/tuya-dp-transform";
1
2
  import { fetchCreatePasswordSN } from "../../../../api/lock";
2
3
  import dpCodes from "../../../../config/dp-code";
3
4
  import { add as addMap, reportAdd as reportAddMap, } from "../../../../config/dp-map/unlock-method";
4
5
  import { add as addBigMap, reportAdd as reportAddBigMap, } from "../../../../config/dp-map/unlock-method-big";
5
6
  import { getUnlockMethodTypeByTypeForRuntime } from "../../../utils";
6
- import { getPermanentSetting, isAdmin } from "../../../../utils";
7
+ import { isAdmin } from "../../../../utils";
7
8
  import { LoopTypes } from "../../../../utils/constant";
8
9
  import { getUserInfoForRuntime } from "../../../user/user";
10
+ import { getError } from "../../../../utils/errors";
11
+ import { validConfigDpMap } from "../../../../config/dp-map/common";
9
12
  export async function getUnlockMethodBase(rt, type, userId) {
10
13
  const { idsByCode, devInfo: { devId }, supportBigData, } = rt.config;
11
14
  const unlockMethodConfig = getUnlockMethodTypeByTypeForRuntime(rt, type);
@@ -27,20 +30,7 @@ export async function getUnlockMethodBase(rt, type, userId) {
27
30
  if (timeScheduleInfo) {
28
31
  const { permanent, effectiveTime, expiredTime, scheduleDetails } = timeScheduleInfo;
29
32
  if (permanent) {
30
- validConfig = {
31
- startTime: effectiveTime
32
- ? Math.floor(effectiveTime / 1000)
33
- : 0x386cd300,
34
- endTime: expiredTime ? Math.floor(expiredTime / 1000) : 0x72bc9b7f,
35
- loop: LoopTypes.NONE,
36
- loopConfig: 0,
37
- weeks: [0, 0, 0, 0, 0, 0, 0],
38
- days: [],
39
- startHour: 0,
40
- startMinute: 0,
41
- endHour: 0,
42
- endMinute: 0,
43
- };
33
+ validConfig = DpUtils.parse(timeScheduleInfo.userTimeSet, validConfigDpMap.childMap);
44
34
  }
45
35
  else {
46
36
  validConfig = {
@@ -60,7 +50,7 @@ export async function getUnlockMethodBase(rt, type, userId) {
60
50
  }
61
51
  }
62
52
  else {
63
- validConfig = getPermanentSetting();
53
+ throw getError(1106);
64
54
  }
65
55
  const dpData = {
66
56
  type: unlockMethodConfig.id,
@@ -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
- if (runtime.config.devInfo.wifiEnableState !== 1) {
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,4 +1,4 @@
1
- import { getCurrentUserInfo, getUserDetailQuery, getUserList, } from "../../api/user";
1
+ import { getCurrentUserInfo, getPermanentValidTime, getUserDetailQuery, getUserList, } from "../../api/user";
2
2
  import { update as updateMap, reportUpdate as reportUpdateMap, } from "../../config/dp-map/unlock-method";
3
3
  import { update as updateMapBig, reportUpdate as reportUpdateMapBig, } from "../../config/dp-map/unlock-method-big";
4
4
  import { publishDpsForRuntime } from "../dp/publish-dps";
@@ -9,7 +9,7 @@ import { updateUserTimeSchedule, addNormalUser, removeNormalUser, } from "../../
9
9
  import { validConfigDpMap } from "../../config/dp-map/common";
10
10
  import { isUseNearChannelForRuntime } from "../misc/is-use-near-channel-for-runtime";
11
11
  import { getUnlockMethodTypeByDpCodeForRuntime } from "../utils";
12
- import { formatTimestampToMilliseconds, formatWeek, getPermanentSetting, isAdmin, parseWeek, validateEffectiveConfig, } from "../../utils";
12
+ import { formatTimestampToMilliseconds, formatWeek, isAdmin, parseWeek, validateEffectiveConfig, } from "../../utils";
13
13
  import { getCurrentHomeInfo, isSupportShortLink } from "../../platform/device";
14
14
  import { LoopTypes } from "../../utils/constant";
15
15
  import { getCurrentUserForRuntime } from "./current-user";
@@ -21,6 +21,7 @@ const handleUserDetail = (rt, user) => {
21
21
  const { timeScheduleInfo, unlockDetail, ...rest } = user;
22
22
  let scheduleInfo = {
23
23
  permanent: true,
24
+ userTimeSet: timeScheduleInfo.userTimeSet,
24
25
  };
25
26
  if (!timeScheduleInfo.permanent &&
26
27
  timeScheduleInfo.scheduleDetails &&
@@ -214,6 +215,27 @@ export async function updateUserLimitTimeForRuntime(rt, params) {
214
215
  ?
215
216
  LoopTypes[repeat.toUpperCase()]
216
217
  : LoopTypes.NONE;
218
+ let validConfig;
219
+ if (permanent) {
220
+ const { timeSetHex } = await getPermanentValidTime(cfg.devInfo.devId);
221
+ validConfig = DpUtils.parse(timeSetHex, validConfigDpMap.childMap);
222
+ }
223
+ else {
224
+ validConfig = {
225
+ startTime: effective.effectiveDate,
226
+ endTime: effective.expiredDate,
227
+ loop: loopType,
228
+ loopConfig: 0,
229
+ weeks: effective?.repeat !== "week" || effective?.weeks === undefined
230
+ ? [0, 0, 0, 0, 0, 0, 0]
231
+ : effective.weeks,
232
+ days: [],
233
+ startHour: Math.floor(effectiveTime / 60),
234
+ startMinute: effectiveTime % 60,
235
+ endHour: Math.floor(expiredTime / 60),
236
+ endMinute: expiredTime % 60,
237
+ };
238
+ }
217
239
  const dpValue = {
218
240
  type: 0,
219
241
  stage: 0,
@@ -223,22 +245,7 @@ export async function updateUserLimitTimeForRuntime(rt, params) {
223
245
  validNum: 0,
224
246
  pwdLength: 0,
225
247
  pwd: [],
226
- validConfig: permanent
227
- ? getPermanentSetting()
228
- : {
229
- startTime: effective.effectiveDate,
230
- endTime: effective.expiredDate,
231
- loop: loopType,
232
- loopConfig: 0,
233
- weeks: effective?.repeat !== "week" || effective?.weeks === undefined
234
- ? [0, 0, 0, 0, 0, 0, 0]
235
- : effective.weeks,
236
- days: [],
237
- startHour: Math.floor(effectiveTime / 60),
238
- startMinute: effectiveTime % 60,
239
- endHour: Math.floor(expiredTime / 60),
240
- endMinute: expiredTime % 60,
241
- },
248
+ validConfig,
242
249
  };
243
250
  const res = (await publishDpsForRuntime(rt, {
244
251
  [dpCode]: DpUtils.format(dpValue, (cfg.supportBigData ? updateMapBig : updateMap)),
@@ -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) {
@@ -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;
@@ -113,6 +116,7 @@ export interface UserInfo {
113
116
  nickName: string;
114
117
  offlineUnlock: boolean;
115
118
  timeScheduleInfo: {
119
+ userTimeSet: string;
116
120
  effectiveTime: number;
117
121
  expiredTime: number;
118
122
  permanent: boolean;
@@ -180,6 +184,16 @@ export interface EffectiveConfig {
180
184
  effectiveTime?: number;
181
185
  expiredTime?: number;
182
186
  }
187
+ export interface FitBleKeyItem {
188
+ id: string;
189
+ unlockBindingId: string;
190
+ name: string;
191
+ opModeSubType?: number;
192
+ effectiveConfig: EffectiveConfig;
193
+ sn?: number;
194
+ userName?: string;
195
+ devNameList?: string[];
196
+ }
183
197
  export interface UnBindUnlockMethod {
184
198
  dpId: number;
185
199
  dpCode: string;
@@ -204,6 +218,8 @@ export interface DeviceStatus {
204
218
  };
205
219
  isWifiActive: boolean;
206
220
  isWifiMatter: boolean;
221
+ isActiveThread: boolean;
222
+ isShareThread: boolean;
207
223
  }
208
224
  export interface UnionUnlockInfo {
209
225
  userId: string;
@@ -254,6 +270,11 @@ export interface MediaInfo {
254
270
  fileUrl: string;
255
271
  mediaBucket: string;
256
272
  mediaKey: string;
273
+ width: number;
274
+ height: number;
275
+ angle: number;
276
+ position: number;
277
+ isVR: boolean;
257
278
  }
258
279
  export type LogType = "alarm_record" | "close_record" | "unlock_record" | "operation" | "local_operation";
259
280
  export type CloseValue = "UNDEFINED" | "VOICE_REMOTE" | "APP_REMOTE" | "AUTO" | "LOCAL_MANUAL" | "FITTINGS" | "APP" | "GEO_FENCE";
@@ -269,6 +290,8 @@ export interface LogData {
269
290
  dpCode: string;
270
291
  data: any;
271
292
  userName: string;
293
+ avatarUrl?: string;
294
+ relateDevName?: string;
272
295
  bindable: boolean;
273
296
  unlockName: string;
274
297
  mediaInfo?: MediaInfo[];
@@ -407,6 +430,6 @@ export interface CameraConfig {
407
430
  width: number;
408
431
  height: number;
409
432
  rotate: number;
410
- localtion: number;
433
+ location: number;
411
434
  }
412
435
  export {};
@@ -52,7 +52,7 @@ export declare const getSystemInfoSync: () => {
52
52
  locationEnabled: boolean;
53
53
  wifiEnabled: boolean;
54
54
  theme?: ty.Themes;
55
- deviceOrientation?: ty.Orientation;
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.GetLogManagerTask;
223
+ export declare const getLogManager: () => ty.LogManager;
223
224
  export declare const getAppUserInfo: () => Promise<{
224
225
  nickName: string;
225
226
  avatarUrl: string;
@@ -10,5 +10,8 @@ declare const _default: {
10
10
  getCurrentSupportedTalkMode: (deviceId: string) => Promise<{
11
11
  talkbackMode: number;
12
12
  }>;
13
+ getTTTAbilityKeyList: (key: string) => Promise<{
14
+ abilityList: string[];
15
+ }>;
13
16
  };
14
17
  export default _default;
@@ -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
  };
@@ -1,3 +1,3 @@
1
- export declare const setStorageSync: (key: string, data: unknown) => void;
1
+ export declare const setStorageSync: (key: string, data: string) => void;
2
2
  export declare const getStorageSync: (key: string) => any;
3
3
  export declare const removeStorageSync: (key: string) => void;
@@ -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,
@@ -21,9 +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;
26
27
  cameraConfig: CameraConfig[];
28
+ notSupportWake: boolean;
29
+ isFitting: boolean;
27
30
  };
28
31
  export declare function createDefaultDeviceStatus(): DeviceStatus;
29
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,8 +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,
36
39
  cameraConfig: [],
40
+ notSupportWake: false,
41
+ isFitting: false
37
42
  };
38
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;
@@ -12,3 +12,4 @@ export declare enum LoopTypes {
12
12
  WEEK = 2,
13
13
  MONTH = 3
14
14
  }
15
+ export declare const cameraPositionMap: Record<number, number>;
@@ -14,3 +14,9 @@ export var LoopTypes;
14
14
  LoopTypes[LoopTypes["WEEK"] = 2] = "WEEK";
15
15
  LoopTypes[LoopTypes["MONTH"] = 3] = "MONTH";
16
16
  })(LoopTypes || (LoopTypes = {}));
17
+ export const cameraPositionMap = {
18
+ 0: 4,
19
+ 1: 3,
20
+ 2: 5,
21
+ 3: 6,
22
+ };
@@ -105,6 +105,7 @@ const errors = {
105
105
  1103: "Binding failed",
106
106
  1104: "Failed to switch cameras",
107
107
  1105: "Camera switching is not supported",
108
+ 1106: "No validity configuration data",
108
109
  };
109
110
  export const getError = (code, ...places) => {
110
111
  if (errors[code]) {
@@ -32,7 +32,7 @@ export declare const getSystemInfo: () => {
32
32
  locationEnabled: boolean;
33
33
  wifiEnabled: boolean;
34
34
  theme?: ty.Themes;
35
- deviceOrientation?: ty.Orientation;
35
+ deviceOrientation?: ty.PhoneOrientation;
36
36
  deviceLevel: string;
37
37
  isSupportPinShortcut?: boolean;
38
38
  deviceType?: string;
@@ -121,19 +121,8 @@ 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
- export declare const getPermanentSetting: () => {
126
- startTime: number;
127
- endTime: number;
128
- loop: LoopTypes;
129
- loopConfig: number;
130
- weeks: number[];
131
- days: never[];
132
- startHour: number;
133
- startMinute: number;
134
- endHour: number;
135
- endMinute: number;
136
- };
137
126
  export declare const isAdmin: (userType: UserType) => boolean;
138
127
  export declare const validateEffectiveConfig: (effective?: EffectiveConfig) => void;
139
128
  export declare const formatTimestampToMilliseconds: (timestamp: number) => number;
@@ -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)
@@ -65,20 +66,6 @@ export const parseWeek = (value) => {
65
66
  .map(Number)
66
67
  .slice(0, 7);
67
68
  };
68
- export const getPermanentSetting = () => {
69
- return {
70
- startTime: 0x386cd300,
71
- endTime: 0x72bc9b7f,
72
- loop: LoopTypes.NONE,
73
- loopConfig: 0,
74
- weeks: [0, 0, 0, 0, 0, 0, 0],
75
- days: [],
76
- startHour: 0,
77
- startMinute: 0,
78
- endHour: 0,
79
- endMinute: 0,
80
- };
81
- };
82
69
  export const isAdmin = (userType) => userType === 10 || userType === 50 ? true : false;
83
70
  export const validateEffectiveConfig = (effective) => {
84
71
  if (!effective) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/lock-sdk",
3
- "version": "1.2.0-beta.9",
3
+ "version": "1.2.1-beta.0",
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;
@@ -1,7 +0,0 @@
1
- const runtimeByInstance = new WeakMap();
2
- export function registerLockSDKInstanceRuntime(instance, runtime) {
3
- runtimeByInstance.set(instance, runtime);
4
- }
5
- export function getRuntimeForLockSDKInstance(instance) {
6
- return runtimeByInstance.get(instance);
7
- }
@@ -1,6 +0,0 @@
1
- import type { LockDeviceRuntime } from "../runtime/LockDeviceRuntime";
2
- import type { LockSDKInstance } from "../entries/main/build-instance";
3
- export declare function setPrimaryLockSDKInstance(instance: LockSDKInstance): void;
4
- export declare function getPrimaryLockSDKRuntime(): LockDeviceRuntime | null;
5
- export declare function clearPrimaryLockSDKInstance(): void;
6
- export declare function clearPrimaryLockSDKInstanceIfDevId(devId: string): void;
@@ -1,24 +0,0 @@
1
- import { getRuntimeForLockSDKInstance } from "./lock-instance-runtime-ref";
2
- let primaryDevId = null;
3
- let primaryRuntime = null;
4
- export function setPrimaryLockSDKInstance(instance) {
5
- const runtime = getRuntimeForLockSDKInstance(instance);
6
- if (!runtime) {
7
- throw new Error("setPrimaryLockSDKInstance: instance must be returned by createLockSDK or init");
8
- }
9
- primaryDevId = runtime.devId;
10
- primaryRuntime = runtime;
11
- }
12
- export function getPrimaryLockSDKRuntime() {
13
- return primaryRuntime;
14
- }
15
- export function clearPrimaryLockSDKInstance() {
16
- primaryDevId = null;
17
- primaryRuntime = null;
18
- }
19
- export function clearPrimaryLockSDKInstanceIfDevId(devId) {
20
- if (primaryDevId === devId) {
21
- primaryDevId = null;
22
- primaryRuntime = null;
23
- }
24
- }
@@ -1,5 +0,0 @@
1
- import type { LockDeviceRuntime } from "../runtime/LockDeviceRuntime";
2
- export type LockSdkBoundExportThis = {
3
- devId: string;
4
- };
5
- export declare function resolveRuntimeFromExportThis(thisArg: unknown): LockDeviceRuntime;