@ray-js/lock-sdk 1.1.3-beta.9 → 1.2.0-beta.1

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 (534) hide show
  1. package/lib/api/ble.d.ts +57 -0
  2. package/lib/api/ble.js +46 -0
  3. package/lib/api/fit.d.ts +203 -0
  4. package/lib/api/fit.js +158 -0
  5. package/lib/api/index.d.ts +1 -1
  6. package/lib/api/index.js +10 -0
  7. package/lib/api/linkage.js +6 -0
  8. package/lib/api/lock.d.ts +4 -2
  9. package/lib/api/lock.js +24 -0
  10. package/lib/api/log.d.ts +49 -22
  11. package/lib/api/log.js +21 -0
  12. package/lib/api/request.d.ts +5 -2
  13. package/lib/api/request.js +34 -2
  14. package/lib/api/screen.d.ts +110 -0
  15. package/lib/api/screen.js +52 -0
  16. package/lib/api/setting.js +2 -0
  17. package/lib/api/temp.d.ts +24 -3
  18. package/lib/api/temp.js +27 -0
  19. package/lib/api/user.d.ts +35 -1
  20. package/lib/api/user.js +24 -0
  21. package/lib/api/video.d.ts +27 -0
  22. package/lib/api/video.js +21 -0
  23. package/lib/api/voice-file.d.ts +14 -0
  24. package/lib/api/voice-file.js +18 -0
  25. package/lib/bootstrap/bootstrap-lock-instance.d.ts +7 -0
  26. package/lib/bootstrap/bootstrap-lock-instance.js +16 -0
  27. package/lib/bootstrap/bootstrap.d.ts +4 -0
  28. package/lib/bootstrap/bootstrap.js +53 -0
  29. package/lib/bootstrap/lock-instance-runtime-ref.d.ts +3 -0
  30. package/lib/bootstrap/lock-instance-runtime-ref.js +7 -0
  31. package/lib/bootstrap/primary-instance.d.ts +6 -0
  32. package/lib/bootstrap/primary-instance.js +24 -0
  33. package/lib/bootstrap/resolve-runtime-from-export-this.d.ts +5 -0
  34. package/lib/bootstrap/resolve-runtime-from-export-this.js +29 -0
  35. package/lib/bootstrap/top-level-runtime.d.ts +2 -0
  36. package/lib/bootstrap/top-level-runtime.js +9 -0
  37. package/lib/config/dp-code/index.d.ts +100 -67
  38. package/lib/config/dp-code/index.js +33 -1
  39. package/lib/config/dp-map/ble-check-code.d.ts +41 -0
  40. package/lib/config/dp-map/ble-check-code.js +55 -0
  41. package/lib/config/dp-map/ble-key-fit.d.ts +328 -0
  42. package/lib/config/dp-map/ble-key-fit.js +33 -0
  43. package/lib/config/dp-map/ble-sync.d.ts +2 -2
  44. package/lib/config/dp-map/ble-sync.js +2 -2
  45. package/lib/config/dp-map/ble-unlock-check.d.ts +42 -0
  46. package/lib/config/dp-map/ble-unlock-check.js +59 -0
  47. package/lib/config/dp-map/ble-voice-data.d.ts +16 -0
  48. package/lib/config/dp-map/ble-voice-data.js +7 -0
  49. package/lib/config/dp-map/bluetooth-unlock.d.ts +10 -0
  50. package/lib/config/dp-map/bluetooth-unlock.js +16 -0
  51. package/lib/config/dp-map/registry.d.ts +1137 -0
  52. package/lib/config/dp-map/registry.js +110 -0
  53. package/lib/config/dp-map/sync-method-fit.d.ts +3 -0
  54. package/lib/config/dp-map/sync-method-fit.js +36 -0
  55. package/lib/config/dp-map/temp-pwd-fit.d.ts +441 -0
  56. package/lib/config/dp-map/temp-pwd-fit.js +73 -0
  57. package/lib/config/dp-map/unlock-method-fit.d.ts +302 -0
  58. package/lib/config/dp-map/unlock-method-fit.js +62 -0
  59. package/lib/config/dp-map/unlock-method.d.ts +345 -1
  60. package/lib/config/dp-map/unlock-method.js +37 -1
  61. package/lib/constant.d.ts +5 -0
  62. package/lib/constant.js +6 -0
  63. package/lib/entries/ble/bootstrap/bootstrap-lock-instance.d.ts +7 -0
  64. package/lib/entries/ble/bootstrap/bootstrap-lock-instance.js +12 -0
  65. package/lib/entries/ble/bootstrap/bootstrap.d.ts +4 -0
  66. package/lib/entries/ble/bootstrap/bootstrap.js +53 -0
  67. package/lib/entries/ble/bootstrap/lock-instance-runtime-ref.d.ts +3 -0
  68. package/lib/entries/ble/bootstrap/lock-instance-runtime-ref.js +7 -0
  69. package/lib/entries/ble/bootstrap/primary-instance.d.ts +6 -0
  70. package/lib/entries/ble/bootstrap/primary-instance.js +24 -0
  71. package/lib/entries/ble/bootstrap/resolve-runtime-from-export-this.d.ts +5 -0
  72. package/lib/entries/ble/bootstrap/resolve-runtime-from-export-this.js +29 -0
  73. package/lib/entries/ble/bootstrap/top-level-runtime.d.ts +2 -0
  74. package/lib/entries/ble/bootstrap/top-level-runtime.js +9 -0
  75. package/lib/entries/ble/build-instance.d.ts +9 -0
  76. package/lib/entries/ble/build-instance.js +50 -0
  77. package/lib/entries/ble/exports/capability.d.ts +6 -0
  78. package/lib/entries/ble/exports/capability.js +17 -0
  79. package/lib/entries/ble/exports/config.d.ts +3 -0
  80. package/lib/entries/ble/exports/config.js +5 -0
  81. package/lib/entries/ble/exports/dp.d.ts +9 -0
  82. package/lib/entries/ble/exports/dp.js +13 -0
  83. package/lib/entries/ble/exports/index.d.ts +16 -0
  84. package/lib/entries/ble/exports/index.js +16 -0
  85. package/lib/entries/ble/exports/linkage.d.ts +5 -0
  86. package/lib/entries/ble/exports/linkage.js +15 -0
  87. package/lib/entries/ble/exports/log.d.ts +9 -0
  88. package/lib/entries/ble/exports/log.js +21 -0
  89. package/lib/entries/ble/exports/media.d.ts +4 -0
  90. package/lib/entries/ble/exports/media.js +12 -0
  91. package/lib/entries/ble/exports/misc.d.ts +19 -0
  92. package/lib/entries/ble/exports/misc.js +30 -0
  93. package/lib/entries/ble/exports/offline-dps.d.ts +8 -0
  94. package/lib/entries/ble/exports/offline-dps.js +24 -0
  95. package/lib/entries/ble/exports/open/do-open-close-action.d.ts +2 -0
  96. package/lib/entries/ble/exports/open/do-open-close-action.js +36 -0
  97. package/lib/entries/ble/exports/open/index.d.ts +18 -0
  98. package/lib/entries/ble/exports/open/index.js +45 -0
  99. package/lib/entries/ble/exports/signal.d.ts +6 -0
  100. package/lib/entries/ble/exports/signal.js +14 -0
  101. package/lib/entries/ble/exports/sleep.d.ts +13 -0
  102. package/lib/entries/ble/exports/sleep.js +31 -0
  103. package/lib/entries/ble/exports/state.d.ts +6 -0
  104. package/lib/entries/ble/exports/state.js +19 -0
  105. package/lib/entries/ble/exports/temporary.d.ts +31 -0
  106. package/lib/entries/ble/exports/temporary.js +91 -0
  107. package/lib/entries/ble/exports/unlock/sync.d.ts +1 -0
  108. package/lib/entries/ble/exports/unlock/sync.js +5 -0
  109. package/lib/entries/ble/exports/unlock-method.d.ts +19 -0
  110. package/lib/entries/ble/exports/unlock-method.js +58 -0
  111. package/lib/entries/ble/exports/user/index.d.ts +23 -0
  112. package/lib/entries/ble/exports/user/index.js +22 -0
  113. package/lib/entries/ble/exports/user/sync.d.ts +1 -0
  114. package/lib/entries/ble/exports/user/sync.js +5 -0
  115. package/lib/entries/ble/index.d.ts +8 -0
  116. package/lib/entries/ble/index.js +39 -0
  117. package/lib/entries/fit/bootstrap/bootstrap-lock-instance.d.ts +7 -0
  118. package/lib/entries/fit/bootstrap/bootstrap-lock-instance.js +12 -0
  119. package/lib/entries/fit/bootstrap/bootstrap.d.ts +4 -0
  120. package/lib/entries/fit/bootstrap/bootstrap.js +69 -0
  121. package/lib/entries/fit/bootstrap/lock-instance-runtime-ref.d.ts +3 -0
  122. package/lib/entries/fit/bootstrap/lock-instance-runtime-ref.js +7 -0
  123. package/lib/entries/fit/bootstrap/primary-instance.d.ts +6 -0
  124. package/lib/entries/fit/bootstrap/primary-instance.js +24 -0
  125. package/lib/entries/fit/bootstrap/resolve-runtime-from-export-this.d.ts +5 -0
  126. package/lib/entries/fit/bootstrap/resolve-runtime-from-export-this.js +29 -0
  127. package/lib/entries/fit/bootstrap/top-level-runtime.d.ts +2 -0
  128. package/lib/entries/fit/bootstrap/top-level-runtime.js +9 -0
  129. package/lib/entries/fit/build-instance.d.ts +9 -0
  130. package/lib/entries/fit/build-instance.js +57 -0
  131. package/lib/entries/fit/exports/binding.d.ts +8 -0
  132. package/lib/entries/fit/exports/binding.js +15 -0
  133. package/lib/entries/fit/exports/device.d.ts +26 -0
  134. package/lib/entries/fit/exports/device.js +64 -0
  135. package/lib/entries/fit/exports/index.d.ts +3 -0
  136. package/lib/entries/fit/exports/index.js +3 -0
  137. package/lib/entries/fit/exports/temp.d.ts +19 -0
  138. package/lib/entries/fit/exports/temp.js +18 -0
  139. package/lib/entries/fit/index.d.ts +8 -0
  140. package/lib/entries/fit/index.js +36 -0
  141. package/lib/entries/main/bootstrap/bootstrap-lock-instance.d.ts +7 -0
  142. package/lib/entries/main/bootstrap/bootstrap-lock-instance.js +12 -0
  143. package/lib/entries/main/bootstrap/bootstrap.d.ts +4 -0
  144. package/lib/entries/main/bootstrap/bootstrap.js +69 -0
  145. package/lib/entries/main/bootstrap/lock-instance-runtime-ref.d.ts +3 -0
  146. package/lib/entries/main/bootstrap/lock-instance-runtime-ref.js +7 -0
  147. package/lib/entries/main/bootstrap/primary-instance.d.ts +6 -0
  148. package/lib/entries/main/bootstrap/primary-instance.js +24 -0
  149. package/lib/entries/main/bootstrap/resolve-runtime-from-export-this.d.ts +5 -0
  150. package/lib/entries/main/bootstrap/resolve-runtime-from-export-this.js +29 -0
  151. package/lib/entries/main/bootstrap/top-level-runtime.d.ts +2 -0
  152. package/lib/entries/main/bootstrap/top-level-runtime.js +9 -0
  153. package/lib/entries/main/build-instance.d.ts +7 -0
  154. package/lib/entries/main/build-instance.js +49 -0
  155. package/lib/entries/main/exports/accessory-binding.d.ts +1 -0
  156. package/lib/entries/main/exports/accessory-binding.js +1 -0
  157. package/lib/entries/main/exports/capability.d.ts +6 -0
  158. package/lib/entries/main/exports/capability.js +17 -0
  159. package/lib/entries/main/exports/config.d.ts +3 -0
  160. package/lib/entries/main/exports/config.js +5 -0
  161. package/lib/entries/main/exports/dp.d.ts +11 -0
  162. package/lib/entries/main/exports/dp.js +13 -0
  163. package/lib/entries/main/exports/fit.d.ts +8 -0
  164. package/lib/entries/main/exports/fit.js +14 -0
  165. package/lib/entries/main/exports/index.d.ts +20 -0
  166. package/lib/entries/main/exports/index.js +20 -0
  167. package/lib/entries/main/exports/linkage.d.ts +5 -0
  168. package/lib/entries/main/exports/linkage.js +15 -0
  169. package/lib/entries/main/exports/log.d.ts +10 -0
  170. package/lib/entries/main/exports/log.js +24 -0
  171. package/lib/entries/main/exports/media.d.ts +6 -0
  172. package/lib/entries/main/exports/media.js +18 -0
  173. package/lib/entries/main/exports/misc.d.ts +18 -0
  174. package/lib/entries/main/exports/misc.js +30 -0
  175. package/lib/entries/main/exports/offline-dps.d.ts +8 -0
  176. package/lib/entries/main/exports/offline-dps.js +28 -0
  177. package/lib/entries/main/exports/open/do-open-close-action.d.ts +2 -0
  178. package/lib/entries/main/exports/open/do-open-close-action.js +68 -0
  179. package/lib/entries/main/exports/open/index.d.ts +16 -0
  180. package/lib/entries/main/exports/open/index.js +44 -0
  181. package/lib/entries/main/exports/open.d.ts +16 -0
  182. package/lib/entries/main/exports/open.js +44 -0
  183. package/lib/entries/main/exports/screen/bind.d.ts +4 -0
  184. package/lib/entries/main/exports/screen/bind.js +8 -0
  185. package/lib/entries/main/exports/screen/list.d.ts +5 -0
  186. package/lib/entries/main/exports/screen/list.js +13 -0
  187. package/lib/entries/main/exports/signal.d.ts +6 -0
  188. package/lib/entries/main/exports/signal.js +14 -0
  189. package/lib/entries/main/exports/sleep.d.ts +15 -0
  190. package/lib/entries/main/exports/sleep.js +31 -0
  191. package/lib/entries/main/exports/state.d.ts +6 -0
  192. package/lib/entries/main/exports/state.js +19 -0
  193. package/lib/entries/main/exports/temporary.d.ts +32 -0
  194. package/lib/entries/main/exports/temporary.js +86 -0
  195. package/lib/entries/main/exports/unlock/sync.d.ts +1 -0
  196. package/lib/entries/main/exports/unlock/sync.js +5 -0
  197. package/lib/entries/main/exports/unlock-method.d.ts +19 -0
  198. package/lib/entries/main/exports/unlock-method.js +58 -0
  199. package/lib/entries/main/exports/user/index.d.ts +33 -0
  200. package/lib/entries/main/exports/user/index.js +35 -0
  201. package/lib/entries/main/exports/user/sync.d.ts +1 -0
  202. package/lib/entries/main/exports/user/sync.js +5 -0
  203. package/lib/entries/main/exports/voice-file.d.ts +7 -0
  204. package/lib/entries/main/exports/voice-file.js +17 -0
  205. package/lib/entries/main/exports/yu-channel.d.ts +5 -0
  206. package/lib/entries/main/exports/yu-channel.js +17 -0
  207. package/lib/entries/main/index.d.ts +8 -0
  208. package/lib/entries/main/index.js +36 -0
  209. package/lib/entries/screen/bootstrap/bootstrap-lock-instance.d.ts +7 -0
  210. package/lib/entries/screen/bootstrap/bootstrap-lock-instance.js +12 -0
  211. package/lib/entries/screen/bootstrap/bootstrap.d.ts +4 -0
  212. package/lib/entries/screen/bootstrap/bootstrap.js +69 -0
  213. package/lib/entries/screen/bootstrap/lock-instance-runtime-ref.d.ts +3 -0
  214. package/lib/entries/screen/bootstrap/lock-instance-runtime-ref.js +7 -0
  215. package/lib/entries/screen/bootstrap/primary-instance.d.ts +6 -0
  216. package/lib/entries/screen/bootstrap/primary-instance.js +24 -0
  217. package/lib/entries/screen/bootstrap/resolve-runtime-from-export-this.d.ts +5 -0
  218. package/lib/entries/screen/bootstrap/resolve-runtime-from-export-this.js +29 -0
  219. package/lib/entries/screen/bootstrap/top-level-runtime.d.ts +2 -0
  220. package/lib/entries/screen/bootstrap/top-level-runtime.js +9 -0
  221. package/lib/entries/screen/build-instance.d.ts +9 -0
  222. package/lib/entries/screen/build-instance.js +57 -0
  223. package/lib/entries/screen/exports/binding.d.ts +6 -0
  224. package/lib/entries/screen/exports/binding.js +15 -0
  225. package/lib/entries/screen/exports/device.d.ts +16 -0
  226. package/lib/entries/screen/exports/device.js +41 -0
  227. package/lib/entries/screen/exports/event.d.ts +3 -0
  228. package/lib/entries/screen/exports/event.js +5 -0
  229. package/lib/entries/screen/exports/index.d.ts +4 -0
  230. package/lib/entries/screen/exports/index.js +4 -0
  231. package/lib/entries/screen/exports/user.d.ts +2 -0
  232. package/lib/entries/screen/exports/user.js +8 -0
  233. package/lib/entries/screen/index.d.ts +8 -0
  234. package/lib/entries/screen/index.js +36 -0
  235. package/lib/feature/dp/get-dp-value.d.ts +3 -0
  236. package/lib/feature/dp/get-dp-value.js +3 -0
  237. package/lib/feature/dp/has-dp.d.ts +2 -0
  238. package/lib/feature/dp/has-dp.js +1 -0
  239. package/lib/feature/dp/publish-dps.d.ts +7 -0
  240. package/lib/feature/dp/publish-dps.js +155 -0
  241. package/lib/feature/fit/bind-fit-to-lock.d.ts +6 -0
  242. package/lib/feature/fit/bind-fit-to-lock.js +222 -0
  243. package/lib/feature/fit/bind-lock-to-fit.d.ts +4 -0
  244. package/lib/feature/fit/bind-lock-to-fit.js +167 -0
  245. package/lib/feature/fit/ble-key.d.ts +16 -0
  246. package/lib/feature/fit/ble-key.js +99 -0
  247. package/lib/feature/fit/list.d.ts +3 -0
  248. package/lib/feature/fit/list.js +28 -0
  249. package/lib/feature/fit/method/add-flow.d.ts +7 -0
  250. package/lib/feature/fit/method/add-flow.js +380 -0
  251. package/lib/feature/fit/method/add-method-events.d.ts +5 -0
  252. package/lib/feature/fit/method/add-method-events.js +11 -0
  253. package/lib/feature/fit/method/add-password.d.ts +3 -0
  254. package/lib/feature/fit/method/add-password.js +99 -0
  255. package/lib/feature/fit/method/internal/base.d.ts +19 -0
  256. package/lib/feature/fit/method/internal/base.js +134 -0
  257. package/lib/feature/fit/method/list.d.ts +3 -0
  258. package/lib/feature/fit/method/list.js +64 -0
  259. package/lib/feature/fit/method/types.d.ts +68 -0
  260. package/lib/feature/fit/method/types.js +1 -0
  261. package/lib/feature/fit/method/update-remove.d.ts +4 -0
  262. package/lib/feature/fit/method/update-remove.js +159 -0
  263. package/lib/feature/fit/password-list.d.ts +24 -0
  264. package/lib/feature/fit/password-list.js +31 -0
  265. package/lib/feature/fit/resolve-slave-id.d.ts +2 -0
  266. package/lib/feature/fit/resolve-slave-id.js +38 -0
  267. package/lib/feature/fit/setting.d.ts +2 -0
  268. package/lib/feature/fit/setting.js +27 -0
  269. package/lib/feature/fit/shared.d.ts +27 -0
  270. package/lib/feature/fit/shared.js +118 -0
  271. package/lib/feature/fit/sync.d.ts +4 -0
  272. package/lib/feature/fit/sync.js +85 -0
  273. package/lib/feature/fit/temp-password.d.ts +27 -0
  274. package/lib/feature/fit/temp-password.js +428 -0
  275. package/lib/feature/fit/users.d.ts +12 -0
  276. package/lib/feature/fit/users.js +25 -0
  277. package/lib/feature/linkage/linkage.d.ts +10 -0
  278. package/lib/{linkage.js → feature/linkage/linkage.js} +30 -30
  279. package/lib/feature/log/log.d.ts +63 -0
  280. package/lib/feature/log/log.js +438 -0
  281. package/lib/feature/media/media.d.ts +31 -0
  282. package/lib/feature/media/media.js +66 -0
  283. package/lib/feature/media/rotate.d.ts +6 -0
  284. package/lib/feature/media/rotate.js +6 -0
  285. package/lib/feature/misc/ble-control.d.ts +2 -0
  286. package/lib/feature/misc/ble-control.js +38 -0
  287. package/lib/feature/misc/capability.d.ts +8 -0
  288. package/lib/{capability.js → feature/misc/capability.js} +39 -29
  289. package/lib/feature/misc/connect-device.d.ts +2 -0
  290. package/lib/feature/misc/connect-device.js +206 -0
  291. package/lib/feature/misc/dp-period.d.ts +18 -0
  292. package/lib/feature/misc/dp-period.js +75 -0
  293. package/lib/feature/misc/is-use-near-channel-for-runtime.d.ts +2 -0
  294. package/lib/feature/misc/is-use-near-channel-for-runtime.js +17 -0
  295. package/lib/feature/misc/open-scene.d.ts +3 -0
  296. package/lib/feature/misc/open-scene.js +63 -0
  297. package/lib/feature/misc/signal.d.ts +12 -0
  298. package/lib/feature/misc/signal.js +36 -0
  299. package/lib/feature/misc/sleep.d.ts +14 -0
  300. package/lib/feature/misc/sleep.js +66 -0
  301. package/lib/feature/misc/types.d.ts +7 -0
  302. package/lib/feature/misc/types.js +1 -0
  303. package/lib/feature/misc/update-config.d.ts +4 -0
  304. package/lib/feature/misc/update-config.js +9 -0
  305. package/lib/feature/misc/validate-pwd.d.ts +2 -0
  306. package/lib/feature/misc/validate-pwd.js +10 -0
  307. package/lib/feature/misc/yu-channel.d.ts +6 -0
  308. package/lib/feature/misc/yu-channel.js +26 -0
  309. package/lib/feature/offline-dps/index.d.ts +10 -0
  310. package/lib/feature/offline-dps/index.js +133 -0
  311. package/lib/feature/password/ble-temp-payload.d.ts +3 -0
  312. package/lib/{sync → feature/password}/ble-temp-payload.js +10 -10
  313. package/lib/feature/password/sync-temp.d.ts +4 -0
  314. package/lib/feature/password/sync-temp.js +91 -0
  315. package/lib/feature/password/temporary/custom-dp-ble.d.ts +6 -0
  316. package/lib/feature/password/temporary/custom-dp-ble.js +263 -0
  317. package/lib/feature/password/temporary/custom-dp-create-shared.d.ts +34 -0
  318. package/lib/feature/password/temporary/custom-dp-create-shared.js +64 -0
  319. package/lib/feature/password/temporary/custom-dp.d.ts +6 -0
  320. package/lib/feature/password/temporary/custom-dp.js +241 -0
  321. package/lib/feature/password/temporary/freeze-ble-key.d.ts +4 -0
  322. package/lib/feature/password/temporary/freeze-ble-key.js +7 -0
  323. package/lib/feature/password/temporary/freeze-rename.d.ts +5 -0
  324. package/lib/feature/password/temporary/freeze-rename.js +72 -0
  325. package/lib/feature/password/temporary/internal/change-password-phase.d.ts +2 -0
  326. package/lib/feature/password/temporary/internal/change-password-phase.js +48 -0
  327. package/lib/feature/password/temporary/internal/constants.d.ts +12 -0
  328. package/lib/feature/password/temporary/internal/constants.js +21 -0
  329. package/lib/feature/password/temporary/internal/password-helpers.d.ts +4 -0
  330. package/lib/feature/password/temporary/internal/password-helpers.js +18 -0
  331. package/lib/feature/password/temporary/internal/password-type-map.d.ts +2 -0
  332. package/lib/feature/password/temporary/internal/password-type-map.js +7 -0
  333. package/lib/feature/password/temporary/lists.d.ts +16 -0
  334. package/lib/feature/password/temporary/lists.js +157 -0
  335. package/lib/feature/password/temporary/offline-create.d.ts +7 -0
  336. package/lib/feature/password/temporary/offline-create.js +192 -0
  337. package/lib/feature/password/temporary/types.d.ts +107 -0
  338. package/lib/feature/password/temporary/types.js +1 -0
  339. package/lib/feature/password/temporary/wifi-offline.d.ts +5 -0
  340. package/lib/feature/password/temporary/wifi-offline.js +85 -0
  341. package/lib/feature/password/temporary/wifi-online.d.ts +28 -0
  342. package/lib/feature/password/temporary/wifi-online.js +153 -0
  343. package/lib/feature/screen/bind.d.ts +4 -0
  344. package/lib/feature/screen/bind.js +181 -0
  345. package/lib/feature/screen/error.d.ts +1 -0
  346. package/lib/feature/screen/error.js +34 -0
  347. package/lib/feature/screen/event.d.ts +3 -0
  348. package/lib/feature/screen/event.js +19 -0
  349. package/lib/feature/screen/list.d.ts +13 -0
  350. package/lib/feature/screen/list.js +56 -0
  351. package/lib/feature/service/goto-service.d.ts +5 -0
  352. package/lib/feature/service/goto-service.js +16 -0
  353. package/lib/feature/state/clear.d.ts +2 -0
  354. package/lib/feature/state/clear.js +17 -0
  355. package/lib/feature/state/device-status-events.d.ts +5 -0
  356. package/lib/feature/state/device-status-events.js +11 -0
  357. package/lib/feature/state/device-status.d.ts +5 -0
  358. package/lib/feature/state/device-status.js +130 -0
  359. package/lib/feature/state/dp-change.d.ts +3 -0
  360. package/lib/feature/state/dp-change.js +44 -0
  361. package/lib/feature/state/init-state.d.ts +2 -0
  362. package/lib/feature/state/init-state.js +167 -0
  363. package/lib/feature/state/internal/read-is-sleep.d.ts +2 -0
  364. package/lib/feature/state/internal/read-is-sleep.js +9 -0
  365. package/lib/feature/state/internal/share-thread-local.d.ts +2 -0
  366. package/lib/feature/state/internal/share-thread-local.js +4 -0
  367. package/lib/feature/state/platform-routing.d.ts +3 -0
  368. package/lib/feature/state/platform-routing.js +155 -0
  369. package/lib/feature/state/remote-permissions.d.ts +4 -0
  370. package/lib/feature/state/remote-permissions.js +30 -0
  371. package/lib/feature/state/sync/offline-dps.d.ts +2 -0
  372. package/lib/feature/state/sync/offline-dps.js +71 -0
  373. package/lib/feature/state/sync/remote-serect-key.d.ts +3 -0
  374. package/lib/feature/state/sync/remote-serect-key.js +74 -0
  375. package/lib/feature/state/sync/t0.d.ts +3 -0
  376. package/lib/feature/state/sync/t0.js +64 -0
  377. package/lib/feature/unlock/door/check-remote.d.ts +2 -0
  378. package/lib/feature/unlock/door/check-remote.js +40 -0
  379. package/lib/feature/unlock/door/check-user-valid.d.ts +2 -0
  380. package/lib/feature/unlock/door/check-user-valid.js +21 -0
  381. package/lib/feature/unlock/door/door-action.d.ts +2 -0
  382. package/lib/feature/unlock/door/door-action.js +32 -0
  383. package/lib/feature/unlock/door/door-ble-only.d.ts +2 -0
  384. package/lib/feature/unlock/door/door-ble-only.js +102 -0
  385. package/lib/feature/unlock/door/door-matter-lan.d.ts +2 -0
  386. package/lib/feature/unlock/door/door-matter-lan.js +15 -0
  387. package/lib/feature/unlock/door/door-near-dual-mode.d.ts +2 -0
  388. package/lib/feature/unlock/door/door-near-dual-mode.js +39 -0
  389. package/lib/feature/unlock/door/door-remote-cloud.d.ts +2 -0
  390. package/lib/feature/unlock/door/door-remote-cloud.js +69 -0
  391. package/lib/feature/unlock/door/door-report.d.ts +11 -0
  392. package/lib/feature/unlock/door/door-report.js +96 -0
  393. package/lib/feature/unlock/door/internal/report-error.d.ts +2 -0
  394. package/lib/feature/unlock/door/internal/report-error.js +46 -0
  395. package/lib/feature/unlock/door/open-close-path.d.ts +3 -0
  396. package/lib/feature/unlock/door/open-close-path.js +30 -0
  397. package/lib/feature/unlock/door/remote-permission.d.ts +5 -0
  398. package/lib/feature/unlock/door/remote-permission.js +67 -0
  399. package/lib/feature/unlock/door/remove-share-user-once.d.ts +2 -0
  400. package/lib/feature/unlock/door/remove-share-user-once.js +21 -0
  401. package/lib/feature/unlock/door/types.d.ts +4 -0
  402. package/lib/feature/unlock/door/types.js +1 -0
  403. package/lib/feature/unlock/door/voice-unlock-pwd.d.ts +4 -0
  404. package/lib/feature/unlock/door/voice-unlock-pwd.js +25 -0
  405. package/lib/feature/unlock/door/wifi-pro-confirm.d.ts +2 -0
  406. package/lib/feature/unlock/door/wifi-pro-confirm.js +69 -0
  407. package/lib/feature/unlock/method/add-flow.d.ts +7 -0
  408. package/lib/feature/unlock/method/add-flow.js +403 -0
  409. package/lib/feature/unlock/method/add-method-events.d.ts +5 -0
  410. package/lib/feature/unlock/method/add-method-events.js +11 -0
  411. package/lib/feature/unlock/method/add-password.d.ts +3 -0
  412. package/lib/feature/unlock/method/add-password.js +99 -0
  413. package/lib/feature/unlock/method/bind-unbind.d.ts +8 -0
  414. package/lib/feature/unlock/method/bind-unbind.js +113 -0
  415. package/lib/feature/unlock/method/detail.d.ts +3 -0
  416. package/lib/feature/unlock/method/detail.js +35 -0
  417. package/lib/feature/unlock/method/guide.d.ts +3 -0
  418. package/lib/feature/unlock/method/guide.js +48 -0
  419. package/lib/feature/unlock/method/internal/base.d.ts +109 -0
  420. package/lib/feature/unlock/method/internal/base.js +89 -0
  421. package/lib/feature/unlock/method/internal/errors.d.ts +5 -0
  422. package/lib/feature/unlock/method/internal/errors.js +13 -0
  423. package/lib/feature/unlock/method/internal/special-check.d.ts +13 -0
  424. package/lib/feature/unlock/method/internal/special-check.js +38 -0
  425. package/lib/feature/unlock/method/types.d.ts +70 -0
  426. package/lib/feature/unlock/method/types.js +1 -0
  427. package/lib/feature/unlock/method/update-remove.d.ts +4 -0
  428. package/lib/feature/unlock/method/update-remove.js +138 -0
  429. package/lib/feature/unlock/method/verify-code.d.ts +3 -0
  430. package/lib/feature/unlock/method/verify-code.js +7 -0
  431. package/lib/feature/unlock/sync/unlock-method.d.ts +3 -0
  432. package/lib/feature/unlock/sync/unlock-method.js +79 -0
  433. package/lib/feature/user/current-user.d.ts +3 -0
  434. package/lib/feature/user/current-user.js +33 -0
  435. package/lib/feature/user/delete-user-dp.d.ts +3 -0
  436. package/lib/{utils/user.js → feature/user/delete-user-dp.js} +13 -13
  437. package/lib/feature/user/share-user.d.ts +29 -0
  438. package/lib/feature/user/share-user.js +228 -0
  439. package/lib/feature/user/sync-user.d.ts +2 -0
  440. package/lib/feature/user/sync-user.js +151 -0
  441. package/lib/feature/user/user.d.ts +37 -0
  442. package/lib/feature/user/user.js +484 -0
  443. package/lib/feature/utils/index.d.ts +12 -0
  444. package/lib/feature/utils/index.js +165 -0
  445. package/lib/feature/voice-file/voice-file.d.ts +27 -0
  446. package/lib/feature/voice-file/voice-file.js +203 -0
  447. package/lib/fit.d.ts +4 -0
  448. package/lib/fit.js +3 -0
  449. package/lib/index.d.ts +2 -21
  450. package/lib/index.js +1 -74
  451. package/lib/interface.d.ts +50 -3
  452. package/lib/{utils → platform}/device.d.ts +48 -0
  453. package/lib/{utils → platform}/device.js +153 -2
  454. package/lib/platform/index.d.ts +2 -0
  455. package/lib/platform/index.js +2 -0
  456. package/lib/{utils → platform}/ipc.d.ts +3 -0
  457. package/lib/{utils → platform}/ipc.js +11 -0
  458. package/lib/platform/transport/index.d.ts +1 -0
  459. package/lib/platform/transport/index.js +1 -0
  460. package/lib/runtime/LockDeviceRuntime.d.ts +12 -0
  461. package/lib/runtime/LockDeviceRuntime.js +34 -0
  462. package/lib/runtime/device-status/compute-device-status.d.ts +25 -0
  463. package/lib/runtime/device-status/compute-device-status.js +94 -0
  464. package/lib/runtime/index.d.ts +5 -0
  465. package/lib/runtime/index.js +3 -0
  466. package/lib/runtime/lock-config.d.ts +28 -0
  467. package/lib/runtime/lock-config.js +37 -0
  468. package/lib/runtime/registry.d.ts +7 -0
  469. package/lib/runtime/registry.js +28 -0
  470. package/lib/runtime/runtime-state-types.d.ts +20 -0
  471. package/lib/runtime/runtime-state-types.js +1 -0
  472. package/lib/screen.d.ts +4 -0
  473. package/lib/screen.js +3 -0
  474. package/lib/utils/constant.d.ts +3 -0
  475. package/lib/utils/constant.js +3 -0
  476. package/lib/utils/errors.js +39 -4
  477. package/lib/utils/event.js +2 -1
  478. package/lib/utils/index.d.ts +22 -13
  479. package/lib/utils/index.js +39 -118
  480. package/lib/utils/sdk-log.d.ts +28 -0
  481. package/lib/utils/sdk-log.js +128 -0
  482. package/package.json +26 -7
  483. package/lib/capability.d.ts +0 -4
  484. package/lib/config/index.d.ts +0 -28
  485. package/lib/config/index.js +0 -41
  486. package/lib/event.d.ts +0 -2
  487. package/lib/event.js +0 -2
  488. package/lib/linkage.d.ts +0 -8
  489. package/lib/log.d.ts +0 -41
  490. package/lib/log.js +0 -311
  491. package/lib/media.d.ts +0 -14
  492. package/lib/media.js +0 -27
  493. package/lib/offline-dps.d.ts +0 -9
  494. package/lib/offline-dps.js +0 -76
  495. package/lib/open/ble-dedicated-dp.d.ts +0 -4
  496. package/lib/open/ble-dedicated-dp.js +0 -148
  497. package/lib/open/ble-remote-no-dp-key.d.ts +0 -4
  498. package/lib/open/ble-remote-no-dp-key.js +0 -69
  499. package/lib/open/report-status.d.ts +0 -1
  500. package/lib/open/report-status.js +0 -23
  501. package/lib/open.d.ts +0 -22
  502. package/lib/open.js +0 -262
  503. package/lib/other.d.ts +0 -31
  504. package/lib/other.js +0 -291
  505. package/lib/signal.d.ts +0 -14
  506. package/lib/signal.js +0 -31
  507. package/lib/sleep.d.ts +0 -19
  508. package/lib/sleep.js +0 -79
  509. package/lib/state.d.ts +0 -16
  510. package/lib/state.js +0 -351
  511. package/lib/sync/ble-temp-payload.d.ts +0 -2
  512. package/lib/sync/offline-dps.d.ts +0 -1
  513. package/lib/sync/offline-dps.js +0 -29
  514. package/lib/sync/remote-serect-key.d.ts +0 -2
  515. package/lib/sync/remote-serect-key.js +0 -43
  516. package/lib/sync/t0.d.ts +0 -2
  517. package/lib/sync/t0.js +0 -26
  518. package/lib/sync/temp.d.ts +0 -3
  519. package/lib/sync/temp.js +0 -70
  520. package/lib/sync/unlock-method.d.ts +0 -2
  521. package/lib/sync/unlock-method.js +0 -42
  522. package/lib/sync/user.d.ts +0 -2
  523. package/lib/sync/user.js +0 -68
  524. package/lib/temporary.d.ts +0 -171
  525. package/lib/temporary.js +0 -698
  526. package/lib/unlock-method.d.ts +0 -90
  527. package/lib/unlock-method.js +0 -701
  528. package/lib/user.d.ts +0 -30
  529. package/lib/user.js +0 -298
  530. package/lib/utils/publishDps.d.ts +0 -6
  531. package/lib/utils/publishDps.js +0 -78
  532. package/lib/utils/user.d.ts +0 -2
  533. /package/lib/{parse/index.d.ts → utils/parse.d.ts} +0 -0
  534. /package/lib/{parse/index.js → utils/parse.js} +0 -0
@@ -0,0 +1,30 @@
1
+ import { hasCapabilityForRuntime, isBlePureDeviceForRuntime, } from "../../misc/capability";
2
+ import { isUseNearChannelForRuntime } from "../../misc/is-use-near-channel-for-runtime";
3
+ import { ProductCommunicationType } from "../../../constant";
4
+ import { getDeviceStatusForRuntime } from "../../state/device-status";
5
+ export function resolveOpenClosePath(rt) {
6
+ const deviceStatus = getDeviceStatusForRuntime(rt);
7
+ const hasThread = hasCapabilityForRuntime(rt, ProductCommunicationType.THREAD);
8
+ if ((hasThread || deviceStatus.isWifiMatter) &&
9
+ deviceStatus.onlineTypes.includes("local") &&
10
+ deviceStatus.onlineTypes.length === 1) {
11
+ return "matter_lan";
12
+ }
13
+ const isDeviceOnline = isBlePureDeviceForRuntime(rt);
14
+ const isNear = isUseNearChannelForRuntime(rt);
15
+ if (isNear) {
16
+ if (hasCapabilityForRuntime(rt, ProductCommunicationType.WIFI) ||
17
+ hasCapabilityForRuntime(rt, ProductCommunicationType.THREAD)) {
18
+ return "near_dual_mode";
19
+ }
20
+ if (isDeviceOnline) {
21
+ if (!deviceStatus.onlineTypes.includes("cloud")) {
22
+ return "ble_only";
23
+ }
24
+ }
25
+ }
26
+ if (isDeviceOnline && deviceStatus.onlineTypes.includes("yuChannel")) {
27
+ return "ble_only";
28
+ }
29
+ return "remote_cloud";
30
+ }
@@ -0,0 +1,5 @@
1
+ import type { LockDeviceRuntime } from "../../../runtime/LockDeviceRuntime";
2
+ import { RemotePermissionType } from "../../../constant";
3
+ export declare const remoteEnabledForRuntime: (this: unknown, rt: LockDeviceRuntime, state: boolean) => Promise<void>;
4
+ export declare const getRemotePermissionList: () => RemotePermissionType[];
5
+ export declare function updateRemotePermissionForRuntime(rt: LockDeviceRuntime, permission: RemotePermissionType): Promise<void>;
@@ -0,0 +1,67 @@
1
+ import { parallelMergeForRuntime } from "../../utils";
2
+ import { setDeviceProperties } from "../../../api/setting";
3
+ import syncRemoteSerectKey from "../../state/sync/remote-serect-key";
4
+ import { permissions } from "../../state/remote-permissions";
5
+ import { sdkLog } from "../../../utils/sdk-log";
6
+ export const remoteEnabledForRuntime = parallelMergeForRuntime(async function remoteEnabledForRuntime(rt, state) {
7
+ const startedAt = Date.now();
8
+ sdkLog("info", "remotePermission", "remoteEnabledStart", {
9
+ devId: rt.devId,
10
+ data: { state },
11
+ });
12
+ try {
13
+ await setDeviceProperties(rt.config.devInfo.devId, {
14
+ UNLOCK_PHONE_REMOTE: state,
15
+ });
16
+ rt.config.remoteOpenEnabled = state;
17
+ if (state) {
18
+ void syncRemoteSerectKey(rt);
19
+ }
20
+ sdkLog("info", "remotePermission", "remoteEnabledSuccess", {
21
+ devId: rt.devId,
22
+ duration: Date.now() - startedAt,
23
+ data: { state },
24
+ });
25
+ }
26
+ catch (error) {
27
+ sdkLog("error", "remotePermission", "remoteEnabledFail", {
28
+ devId: rt.devId,
29
+ duration: Date.now() - startedAt,
30
+ data: { state },
31
+ error,
32
+ });
33
+ throw error;
34
+ }
35
+ });
36
+ export const getRemotePermissionList = () => {
37
+ return permissions;
38
+ };
39
+ export async function updateRemotePermissionForRuntime(rt, permission) {
40
+ const startedAt = Date.now();
41
+ const index = permissions.indexOf(permission);
42
+ const permissionIndex = index > 0 ? index : 0;
43
+ sdkLog("info", "remotePermission", "updateStart", {
44
+ devId: rt.devId,
45
+ data: { permission, permissionIndex },
46
+ });
47
+ try {
48
+ await setDeviceProperties(rt.config.devInfo.devId, {
49
+ REMOTE_UNLOCK_AUTH: permissionIndex,
50
+ });
51
+ rt.config.remoteOpenPermission = permission;
52
+ sdkLog("info", "remotePermission", "updateSuccess", {
53
+ devId: rt.devId,
54
+ duration: Date.now() - startedAt,
55
+ data: { permission, permissionIndex },
56
+ });
57
+ }
58
+ catch (error) {
59
+ sdkLog("error", "remotePermission", "updateFail", {
60
+ devId: rt.devId,
61
+ duration: Date.now() - startedAt,
62
+ data: { permission, permissionIndex },
63
+ error,
64
+ });
65
+ throw error;
66
+ }
67
+ }
@@ -0,0 +1,2 @@
1
+ import type { LockDeviceRuntime } from "../../../runtime/LockDeviceRuntime";
2
+ export declare function removeShareUserOnceForRuntime(rt: LockDeviceRuntime): Promise<void>;
@@ -0,0 +1,21 @@
1
+ import { removeLockVirtualKeyBinding } from "../../../api/ble";
2
+ import { getuserAuthList } from "../../../api/user";
3
+ import { UserType } from "../../../constant";
4
+ import { isBlePureDeviceForRuntime } from "../../misc/capability";
5
+ import { getCurrentUserForRuntime } from "../../user/current-user";
6
+ export async function removeShareUserOnceForRuntime(rt) {
7
+ const currentUser = await getCurrentUserForRuntime(rt);
8
+ if (!isBlePureDeviceForRuntime(rt) || currentUser.userType !== UserType.SHARE) {
9
+ return;
10
+ }
11
+ const devId = rt.config.devInfo.devId;
12
+ const list = await getuserAuthList({
13
+ devId,
14
+ authTypes: ["LOCK_BLUE_PASSWORD"],
15
+ });
16
+ const first = list?.[0];
17
+ if (!first?.unlockBindingId || first.availTime !== 1) {
18
+ return;
19
+ }
20
+ await removeLockVirtualKeyBinding(devId, first.unlockBindingId);
21
+ }
@@ -0,0 +1,4 @@
1
+ export declare const OPEN_CLOSE_ACTION_DEFAULT_TIMEOUT_MS = 15000;
2
+ export interface OpenDoorCallOptions {
3
+ timeout?: number;
4
+ }
@@ -0,0 +1 @@
1
+ export const OPEN_CLOSE_ACTION_DEFAULT_TIMEOUT_MS = 15000;
@@ -0,0 +1,4 @@
1
+ import type { LockDeviceRuntime } from "../../../runtime/LockDeviceRuntime";
2
+ export declare function getVoiceUnlockPwdEnabledForRuntime(rt: LockDeviceRuntime): Promise<boolean>;
3
+ export declare function voiceUnlockPwdDisabledForRuntime(rt: LockDeviceRuntime): Promise<boolean>;
4
+ export declare function updateVoiceUnlockPwdForRuntime(rt: LockDeviceRuntime, password: string): Promise<boolean>;
@@ -0,0 +1,25 @@
1
+ import { encrypt } from "../../../platform/device";
2
+ import { getVoicePwdEnabled, setVoicePwd } from "../../../api";
3
+ import { getError } from "../../../utils/errors";
4
+ export async function getVoiceUnlockPwdEnabledForRuntime(rt) {
5
+ const res = await getVoicePwdEnabled(rt.config.devInfo.devId);
6
+ return res === true || res === 1;
7
+ }
8
+ export async function voiceUnlockPwdDisabledForRuntime(rt) {
9
+ return setVoicePwd({
10
+ devId: rt.config.devInfo.devId,
11
+ open: false,
12
+ pwd: "",
13
+ });
14
+ }
15
+ export async function updateVoiceUnlockPwdForRuntime(rt, password) {
16
+ if (!/^\d{4,6}$/.test(password)) {
17
+ throw getError(1063);
18
+ }
19
+ const encryptedPassword = await encrypt(rt.config.devInfo.devId, password);
20
+ return setVoicePwd({
21
+ devId: rt.config.devInfo.devId,
22
+ open: true,
23
+ pwd: encryptedPassword,
24
+ });
25
+ }
@@ -0,0 +1,2 @@
1
+ import type { LockDeviceRuntime } from "../../../runtime/LockDeviceRuntime";
2
+ export declare const handleOpenDoorForRuntime: (this: unknown, rt: LockDeviceRuntime, confirm: boolean, timeout: number) => Promise<void>;
@@ -0,0 +1,69 @@
1
+ import dpUtils from "@ray-js/tuya-dp-transform";
2
+ import { isConfirmOpenDoorByWifiPro } from "../../../api/lock";
3
+ import { parallelOnlyForRuntime } from "../../utils";
4
+ import { reportOpen as reportOpenMap, } from "../../../config/dp-map/open";
5
+ import emitter from "../../../utils/event";
6
+ import { getError } from "../../../utils/errors";
7
+ import { DPCHANGE } from "../../../utils/constant";
8
+ import dpCodes from "../../../config/dp-code";
9
+ import { getReportError } from "./internal/report-error";
10
+ import { sdkLog } from "../../../utils/sdk-log";
11
+ export const handleOpenDoorForRuntime = parallelOnlyForRuntime(function handleOpenDoorForRuntime(rt, confirm, timeout) {
12
+ const { devInfo } = rt.config;
13
+ const startedAt = Date.now();
14
+ sdkLog("info", "unlock", "wifiProConfirmStart", {
15
+ devId: rt.devId,
16
+ data: { confirm, timeout },
17
+ });
18
+ return new Promise((resolve, reject) => {
19
+ const handleReport = (dpData) => {
20
+ if (typeof dpData[dpCodes.remoteNoDpKey] !== "undefined") {
21
+ timeoutTask && clearTimeout(timeoutTask);
22
+ emitter.off(DPCHANGE, handleReport);
23
+ const result = dpUtils.parse(dpData[dpCodes.remoteNoDpKey], reportOpenMap);
24
+ if (result.status !== 0x00) {
25
+ const error = getReportError(result.status);
26
+ sdkLog("warn", "unlock", "wifiProConfirmReportFail", {
27
+ devId: rt.devId,
28
+ duration: Date.now() - startedAt,
29
+ data: { confirm, status: result.status },
30
+ error,
31
+ });
32
+ reject(error);
33
+ }
34
+ else {
35
+ sdkLog("info", "unlock", "wifiProConfirmReportSuccess", {
36
+ devId: rt.devId,
37
+ duration: Date.now() - startedAt,
38
+ data: { confirm, status: result.status },
39
+ });
40
+ resolve();
41
+ }
42
+ }
43
+ };
44
+ const timeoutTask = setTimeout(() => {
45
+ emitter.off(DPCHANGE, handleReport);
46
+ const error = getError(1002);
47
+ sdkLog("warn", "unlock", "wifiProConfirmTimeout", {
48
+ devId: rt.devId,
49
+ duration: Date.now() - startedAt,
50
+ data: { confirm, timeout },
51
+ error,
52
+ });
53
+ reject(error);
54
+ }, timeout);
55
+ emitter.on(DPCHANGE, handleReport);
56
+ isConfirmOpenDoorByWifiPro(devInfo.devId, confirm).catch((e) => {
57
+ timeoutTask && clearTimeout(timeoutTask);
58
+ emitter.off(DPCHANGE, handleReport);
59
+ const error = getError(1003);
60
+ sdkLog("error", "unlock", "wifiProConfirmInvokeFail", {
61
+ devId: rt.devId,
62
+ duration: Date.now() - startedAt,
63
+ data: { confirm },
64
+ error: e || error,
65
+ });
66
+ reject(error);
67
+ });
68
+ });
69
+ });
@@ -0,0 +1,7 @@
1
+ import type { LockDeviceRuntime } from "../../../runtime/LockDeviceRuntime";
2
+ import type { CancelAddUnlockMethodParams, StartAddUnlockMethodParams } from "./types";
3
+ export interface StartAddUnlockMethodResult {
4
+ total: number;
5
+ }
6
+ export declare function startAddUnlockMethodForRuntime(rt: LockDeviceRuntime, params: StartAddUnlockMethodParams): Promise<StartAddUnlockMethodResult>;
7
+ export declare const cancelAddUnlockMethodForRuntime: (this: unknown, rt: LockDeviceRuntime, params: CancelAddUnlockMethodParams) => Promise<void>;
@@ -0,0 +1,403 @@
1
+ import dpUtils from "@ray-js/tuya-dp-transform";
2
+ import { createUnlockMethod } from "../../../api/lock";
3
+ import { parallelOnlyForRuntime } from "../../utils";
4
+ import { sleep } from "../../../utils";
5
+ import { getError } from "../../../utils/errors";
6
+ import { publishDpsForRuntime } from "../../dp/publish-dps";
7
+ import emitter from "../../../utils/event";
8
+ import { DPCHANGE } from "../../../utils/constant";
9
+ import { getUserInfoForRuntime } from "../../user/user";
10
+ import { getUnlockMethodEvent } from "./add-method-events";
11
+ import { getUnlockMethodBase } from "./internal/base";
12
+ import { getAddUnlockError } from "./internal/errors";
13
+ import { sdkLog } from "../../../utils/sdk-log";
14
+ const ADD_UNLOCK_METHOD_EVENT_RELEASE_DELAY = 16;
15
+ const addUnlockMethodData = {
16
+ unlockMethodConfig: {},
17
+ total: 0,
18
+ dpCode: "",
19
+ dpMap: {},
20
+ sn: 0,
21
+ lockUserId: 0,
22
+ timeoutId: 0,
23
+ userId: "",
24
+ unlockDpId: 0,
25
+ timeout: 15000,
26
+ runtime: null,
27
+ canEmitEvents: true,
28
+ pendingEvents: [],
29
+ releaseEmitTimer: 0,
30
+ eventSessionId: 0,
31
+ };
32
+ let isCancelAddUnlockMethod = false;
33
+ const dispatchAddUnlockMethodEvent = (eventKey, eventData) => {
34
+ if (emitter.hasListener(eventKey)) {
35
+ emitter.emit(eventKey, eventData);
36
+ }
37
+ else {
38
+ emitter.cache(eventKey, eventData);
39
+ }
40
+ };
41
+ const emitAddUnlockMethodEvent = (rt, eventData) => {
42
+ const eventKey = getUnlockMethodEvent(rt);
43
+ if (!addUnlockMethodData.canEmitEvents) {
44
+ addUnlockMethodData.pendingEvents.push({ eventKey, eventData });
45
+ return;
46
+ }
47
+ dispatchAddUnlockMethodEvent(eventKey, eventData);
48
+ };
49
+ const releaseAddUnlockMethodEventsAfterStart = (eventSessionId) => {
50
+ clearTimeout(addUnlockMethodData.releaseEmitTimer);
51
+ addUnlockMethodData.releaseEmitTimer = setTimeout(() => {
52
+ if (addUnlockMethodData.eventSessionId !== eventSessionId) {
53
+ return;
54
+ }
55
+ addUnlockMethodData.releaseEmitTimer = setTimeout(() => {
56
+ if (addUnlockMethodData.eventSessionId !== eventSessionId) {
57
+ return;
58
+ }
59
+ addUnlockMethodData.canEmitEvents = true;
60
+ const pendingEvents = addUnlockMethodData.pendingEvents.splice(0);
61
+ pendingEvents.forEach(({ eventKey, eventData }) => {
62
+ dispatchAddUnlockMethodEvent(eventKey, eventData);
63
+ });
64
+ }, ADD_UNLOCK_METHOD_EVENT_RELEASE_DELAY);
65
+ }, 0);
66
+ };
67
+ const handleAddTimeout = (timeout = 15000) => {
68
+ clearTimeout(addUnlockMethodData.timeoutId);
69
+ addUnlockMethodData.timeoutId = setTimeout(() => {
70
+ emitter.off(DPCHANGE, handleAddReport);
71
+ const rt = addUnlockMethodData.runtime;
72
+ if (!rt)
73
+ return;
74
+ emitAddUnlockMethodEvent(rt, {
75
+ type: addUnlockMethodData.unlockMethodConfig.type,
76
+ stage: "fail",
77
+ lockUserId: addUnlockMethodData.lockUserId,
78
+ error: getError(1002),
79
+ });
80
+ }, timeout);
81
+ };
82
+ const handleAddReport = async (dps) => {
83
+ const rt = addUnlockMethodData.runtime;
84
+ if (!rt) {
85
+ return;
86
+ }
87
+ const cfg = rt.config;
88
+ if (dps[addUnlockMethodData.dpCode]) {
89
+ const result = dpUtils.parse(dps[addUnlockMethodData.dpCode], addUnlockMethodData.dpMap);
90
+ let eventData = null;
91
+ if (result.type !== addUnlockMethodData.unlockMethodConfig.id) {
92
+ return;
93
+ }
94
+ if (cfg.strictMode) {
95
+ if (result.sn !== addUnlockMethodData.sn ||
96
+ result.memberId !== addUnlockMethodData.lockUserId) {
97
+ return;
98
+ }
99
+ }
100
+ else {
101
+ if (result.sn !== addUnlockMethodData.sn) {
102
+ sdkLog("warn", "unlockMethod", "addReportSnMismatch", {
103
+ devId: rt.devId,
104
+ data: { type: addUnlockMethodData.unlockMethodConfig.type },
105
+ });
106
+ }
107
+ if (result.memberId !== addUnlockMethodData.lockUserId) {
108
+ sdkLog("warn", "unlockMethod", "addReportMemberMismatch", {
109
+ devId: rt.devId,
110
+ data: { type: addUnlockMethodData.unlockMethodConfig.type },
111
+ });
112
+ }
113
+ }
114
+ const type = addUnlockMethodData.unlockMethodConfig.type;
115
+ switch (result.stage) {
116
+ case 0xfc: {
117
+ handleAddTimeout(addUnlockMethodData.timeout);
118
+ sdkLog("debug", "unlockMethod", "addStep", {
119
+ devId: rt.devId,
120
+ data: {
121
+ type,
122
+ step: result.step,
123
+ total: addUnlockMethodData.total,
124
+ },
125
+ });
126
+ eventData = {
127
+ type,
128
+ stage: "step",
129
+ lockUserId: result.memberId,
130
+ step: result.step,
131
+ total: addUnlockMethodData.total,
132
+ };
133
+ break;
134
+ }
135
+ case 0xfd: {
136
+ clearMonitoringAddReport();
137
+ sdkLog("warn", "unlockMethod", "addReportFail", {
138
+ devId: rt.devId,
139
+ data: { type, status: result.status },
140
+ });
141
+ eventData = {
142
+ stage: "fail",
143
+ type,
144
+ lockUserId: result.memberId,
145
+ error: getAddUnlockError(result.status),
146
+ };
147
+ break;
148
+ }
149
+ case 0xfe: {
150
+ clearMonitoringAddReport();
151
+ if (isCancelAddUnlockMethod) {
152
+ isCancelAddUnlockMethod = false;
153
+ sdkLog("info", "unlockMethod", "addCancelled", {
154
+ devId: rt.devId,
155
+ data: { type },
156
+ });
157
+ return;
158
+ }
159
+ sdkLog("warn", "unlockMethod", "addReportFail", {
160
+ devId: rt.devId,
161
+ data: { type, status: result.status },
162
+ });
163
+ eventData = {
164
+ stage: "fail",
165
+ type,
166
+ lockUserId: result.memberId,
167
+ error: getAddUnlockError(result.status),
168
+ };
169
+ break;
170
+ }
171
+ case 0xff: {
172
+ clearMonitoringAddReport();
173
+ try {
174
+ await sleep(300);
175
+ sdkLog("debug", "unlockMethod", "cloudCreateStart", {
176
+ devId: rt.devId,
177
+ data: { type },
178
+ });
179
+ let isAddEnabled = true;
180
+ if (!cfg.supportMultipleFace && type === "face") {
181
+ const user = await getUserInfoForRuntime(rt, {
182
+ userId: addUnlockMethodData.userId,
183
+ });
184
+ const faceData = user.unlockDetails.find((item) => item.type === "face" && item.unlockList.length > 0);
185
+ if (faceData) {
186
+ const originUnlockId = faceData.unlockList[0].unlockId;
187
+ if (originUnlockId !== result.unlockId) {
188
+ eventData = {
189
+ stage: "fail",
190
+ type,
191
+ lockUserId: result.memberId,
192
+ error: getError(1061),
193
+ };
194
+ }
195
+ else {
196
+ eventData = {
197
+ stage: "success",
198
+ type,
199
+ id: faceData.unlockList[0].id,
200
+ name: faceData.unlockList[0].unlockName,
201
+ };
202
+ }
203
+ isAddEnabled = false;
204
+ }
205
+ }
206
+ if (isAddEnabled) {
207
+ const res = await createUnlockMethod({
208
+ devId: cfg.devInfo.devId,
209
+ userId: addUnlockMethodData.userId,
210
+ unlockId: `${addUnlockMethodData.unlockDpId}-${result.unlockId}`,
211
+ unlockName: "",
212
+ unlockAttr: 0,
213
+ });
214
+ eventData = {
215
+ stage: "success",
216
+ type,
217
+ id: res.opModeId,
218
+ name: res.unlockName,
219
+ };
220
+ sdkLog("info", "unlockMethod", "addSuccess", {
221
+ devId: rt.devId,
222
+ data: { type, opModeId: res.opModeId },
223
+ });
224
+ }
225
+ }
226
+ catch (err) {
227
+ sdkLog("warn", "unlockMethod", "cloudCreateFail", {
228
+ devId: rt.devId,
229
+ data: { type },
230
+ error: err,
231
+ });
232
+ eventData = {
233
+ stage: "fail",
234
+ type,
235
+ lockUserId: result.memberId,
236
+ error: getError(1053),
237
+ };
238
+ }
239
+ break;
240
+ }
241
+ default:
242
+ }
243
+ if (eventData) {
244
+ emitAddUnlockMethodEvent(rt, eventData);
245
+ }
246
+ }
247
+ };
248
+ const clearMonitoringAddReport = () => {
249
+ clearTimeout(addUnlockMethodData.timeoutId);
250
+ emitter.off(DPCHANGE, handleAddReport);
251
+ addUnlockMethodData.runtime = null;
252
+ };
253
+ const monitoringAddReport = (option) => {
254
+ Object.assign(addUnlockMethodData, option);
255
+ clearTimeout(addUnlockMethodData.releaseEmitTimer);
256
+ addUnlockMethodData.canEmitEvents = false;
257
+ addUnlockMethodData.pendingEvents = [];
258
+ addUnlockMethodData.eventSessionId += 1;
259
+ emitter.clearCache(getUnlockMethodEvent(option.runtime));
260
+ emitter.off(DPCHANGE, handleAddReport);
261
+ emitter.on(DPCHANGE, handleAddReport);
262
+ handleAddTimeout(option.timeout);
263
+ return addUnlockMethodData.eventSessionId;
264
+ };
265
+ export async function startAddUnlockMethodForRuntime(rt, params) {
266
+ const startedAt = Date.now();
267
+ const cfg = rt.config;
268
+ const { unlockMethodConfig, lockUserId, dpData, sn, addDpCode, addDpMap, addDpReportMap, dpId, } = await getUnlockMethodBase(rt, params.type, params.userId);
269
+ isCancelAddUnlockMethod = false;
270
+ sdkLog("info", "unlockMethod", "startAdd", {
271
+ devId: rt.devId,
272
+ data: {
273
+ type: params.type,
274
+ userId: params.userId,
275
+ dpCode: addDpCode,
276
+ timeout: params.timeout,
277
+ },
278
+ });
279
+ let addReportMonitoringStarted = false;
280
+ let addReportMonitoringSessionId = 0;
281
+ const startAddReportMonitoring = (total) => {
282
+ if (addReportMonitoringStarted) {
283
+ return addReportMonitoringSessionId;
284
+ }
285
+ addReportMonitoringStarted = true;
286
+ addReportMonitoringSessionId = monitoringAddReport({
287
+ runtime: rt,
288
+ timeout: params.timeout,
289
+ unlockMethodConfig,
290
+ total,
291
+ dpCode: addDpCode,
292
+ dpMap: addDpReportMap,
293
+ sn,
294
+ lockUserId,
295
+ userId: params.userId,
296
+ unlockDpId: dpId,
297
+ });
298
+ return addReportMonitoringSessionId;
299
+ };
300
+ const res = await publishDpsForRuntime(rt, {
301
+ [addDpCode]: dpUtils.format(dpData, addDpMap),
302
+ }, {
303
+ timeout: params.timeout,
304
+ checkReport: (dpDataIn) => {
305
+ if (typeof dpDataIn[addDpCode] !== "undefined") {
306
+ const result = dpUtils.parse(dpDataIn[addDpCode], addDpReportMap);
307
+ let hasReport = result.type === unlockMethodConfig.id;
308
+ if (cfg.strictMode) {
309
+ hasReport =
310
+ hasReport && result.memberId === lockUserId && result.sn === sn;
311
+ }
312
+ if (hasReport) {
313
+ if (result.memberId !== lockUserId) {
314
+ sdkLog("warn", "unlockMethod", "startReportMemberMismatch", {
315
+ devId: rt.devId,
316
+ data: { type: params.type },
317
+ });
318
+ }
319
+ if (result.sn !== sn) {
320
+ sdkLog("warn", "unlockMethod", "startReportSnMismatch", {
321
+ devId: rt.devId,
322
+ data: { type: params.type },
323
+ });
324
+ }
325
+ if (result.stage === 0) {
326
+ startAddReportMonitoring(result.total);
327
+ }
328
+ return result;
329
+ }
330
+ return false;
331
+ }
332
+ sdkLog("warn", "unlockMethod", "startInvalidReport", {
333
+ devId: rt.devId,
334
+ data: { type: params.type, dpCode: addDpCode },
335
+ });
336
+ return false;
337
+ },
338
+ });
339
+ if (res.stage === 0) {
340
+ const eventSessionId = startAddReportMonitoring(res.total);
341
+ sdkLog("info", "unlockMethod", "startAddSuccess", {
342
+ devId: rt.devId,
343
+ duration: Date.now() - startedAt,
344
+ data: { type: params.type, total: res.total },
345
+ });
346
+ releaseAddUnlockMethodEventsAfterStart(eventSessionId);
347
+ return { total: res.total };
348
+ }
349
+ if (res.stage === 0xfd) {
350
+ const error = getAddUnlockError(res.status);
351
+ sdkLog("warn", "unlockMethod", "startAddRejected", {
352
+ devId: rt.devId,
353
+ duration: Date.now() - startedAt,
354
+ data: { type: params.type, status: res.status },
355
+ error,
356
+ });
357
+ throw error;
358
+ }
359
+ const error = getError(1027);
360
+ sdkLog("warn", "unlockMethod", "startAddUnexpectedStage", {
361
+ devId: rt.devId,
362
+ duration: Date.now() - startedAt,
363
+ data: { type: params.type, stage: res.stage },
364
+ error,
365
+ });
366
+ throw error;
367
+ }
368
+ export const cancelAddUnlockMethodForRuntime = parallelOnlyForRuntime(async function cancelAddUnlockMethodForRuntime(rt, params) {
369
+ const cfg = rt.config;
370
+ sdkLog("info", "unlockMethod", "cancelAdd", {
371
+ devId: rt.devId,
372
+ data: { type: params.type, userId: params.userId },
373
+ });
374
+ const { dpData, addDpCode, addDpMap, addDpReportMap, unlockMethodConfig, lockUserId, sn, } = await getUnlockMethodBase(rt, params.type, params.userId);
375
+ dpData.stage = 0xfe;
376
+ isCancelAddUnlockMethod = true;
377
+ await publishDpsForRuntime(rt, {
378
+ [addDpCode]: dpUtils.format(dpData, addDpMap),
379
+ }, {
380
+ checkReport: (dpDataIn) => {
381
+ if (typeof dpDataIn[addDpCode] !== "undefined") {
382
+ const result = dpUtils.parse(dpDataIn[addDpCode], addDpReportMap);
383
+ let hasReport = result.type === unlockMethodConfig.id;
384
+ if (cfg.strictMode) {
385
+ hasReport =
386
+ hasReport &&
387
+ result.stage === 0xfe &&
388
+ result.memberId === lockUserId &&
389
+ result.sn === sn;
390
+ }
391
+ if (hasReport) {
392
+ return result;
393
+ }
394
+ sdkLog("warn", "unlockMethod", "cancelInvalidReport", {
395
+ devId: rt.devId,
396
+ data: { type: params.type },
397
+ });
398
+ }
399
+ return false;
400
+ },
401
+ });
402
+ return;
403
+ });
@@ -0,0 +1,5 @@
1
+ import type { AddUnlockMethodListener } from "./types";
2
+ import type { LockDeviceRuntime } from "../../../runtime/LockDeviceRuntime";
3
+ export declare function getUnlockMethodEvent(runtime: LockDeviceRuntime): string;
4
+ export declare const onAddUnlockMethodForRuntime: (runtime: LockDeviceRuntime, listener: AddUnlockMethodListener) => void;
5
+ export declare const offAddUnlockMethodForRuntime: (runtime: LockDeviceRuntime, listener: AddUnlockMethodListener) => void;
@@ -0,0 +1,11 @@
1
+ import emitter from "../../../utils/event";
2
+ import { UNLOCK_METHOD_EVENT } from "../../../utils/constant";
3
+ export function getUnlockMethodEvent(runtime) {
4
+ return `${UNLOCK_METHOD_EVENT}_${runtime.devId}`;
5
+ }
6
+ export const onAddUnlockMethodForRuntime = (runtime, listener) => {
7
+ emitter.on(getUnlockMethodEvent(runtime), listener);
8
+ };
9
+ export const offAddUnlockMethodForRuntime = (runtime, listener) => {
10
+ emitter.off(getUnlockMethodEvent(runtime), listener);
11
+ };