@ray-js/lock-sdk 1.2.4-beta.0 → 1.2.4-beta.2

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.
@@ -1,11 +1,10 @@
1
1
  export interface GestureStatus {
2
2
  status: boolean;
3
- password: string;
4
- [k: string]: any;
3
+ password?: string;
5
4
  }
6
5
  export declare const getGestureStatusApi: (devId: string) => Promise<GestureStatus>;
7
6
  export interface UpdateGestureStatusParams {
8
- password: string;
7
+ password?: string;
9
8
  open: boolean;
10
9
  }
11
10
  export declare const setGestureStatusApi: (params: UpdateGestureStatusParams & {
@@ -1,9 +1,8 @@
1
- import { THING } from "../utils/constant";
2
1
  import { requestApi } from "./request";
3
2
  export const getGestureStatusApi = (devId) => {
4
3
  return requestApi({
5
4
  logName: "getGestureStatus",
6
- api: `${THING}.m.device.lock.gesturepwd.check`,
5
+ api: "m.lock.device.gesturepwd.check",
7
6
  version: "1.0",
8
7
  data: { devId },
9
8
  });
@@ -11,7 +10,7 @@ export const getGestureStatusApi = (devId) => {
11
10
  export const setGestureStatusApi = (params) => {
12
11
  return requestApi({
13
12
  logName: "setGestureStatus",
14
- api: `${THING}.m.device.lock.gesturepwd.set`,
13
+ api: "m.lock.device.gesturepwd.set",
15
14
  version: "1.0",
16
15
  data: params,
17
16
  });
@@ -1,4 +1,4 @@
1
1
  import type { UpdateGestureStatusParams } from "../../../api/gesture";
2
2
  export type { GestureStatus, UpdateGestureStatusParams, } from "../../../api/gesture";
3
3
  export declare function getGestureStatus(): Promise<import("../../../api/gesture").GestureStatus>;
4
- export declare function updateGestureStatus(params: UpdateGestureStatusParams): Promise<boolean>;
4
+ export declare function updateGestureStatus(params: UpdateGestureStatusParams): Promise<void>;
@@ -1,6 +1,4 @@
1
+ import { UpdateGestureStatusParams } from "../../api/gesture";
1
2
  import type { LockDeviceRuntime } from "../../runtime/LockDeviceRuntime";
2
3
  export declare const getGestureStatusForRuntime: (rt: LockDeviceRuntime) => Promise<import("../../api/gesture").GestureStatus>;
3
- export declare const updateGestureStatusForRuntime: (rt: LockDeviceRuntime, params: {
4
- password: string;
5
- open: boolean;
6
- }) => Promise<boolean>;
4
+ export declare const updateGestureStatusForRuntime: (rt: LockDeviceRuntime, params: UpdateGestureStatusParams) => Promise<void>;
@@ -1,3 +1,24 @@
1
+ import { decrypt, encrypt } from "../../platform";
1
2
  import { getGestureStatusApi, setGestureStatusApi } from "../../api/gesture";
2
- export const getGestureStatusForRuntime = (rt) => getGestureStatusApi(rt.config.devInfo.devId);
3
- export const updateGestureStatusForRuntime = (rt, params) => setGestureStatusApi({ devId: rt.config.devInfo.devId, ...params });
3
+ import { getError } from "../../utils/errors";
4
+ export const getGestureStatusForRuntime = async (rt) => {
5
+ const res = await getGestureStatusApi(rt.config.devInfo.devId);
6
+ if (res.status && res.password) {
7
+ res.password = await decrypt(rt.config.devInfo.devId, res.password);
8
+ }
9
+ return res;
10
+ };
11
+ export const updateGestureStatusForRuntime = async (rt, params) => {
12
+ let encryptedPassword = undefined;
13
+ if (params.open) {
14
+ if (!params.password) {
15
+ throw getError(1009, "password");
16
+ }
17
+ encryptedPassword = await encrypt(rt.config.devInfo.devId, params.password);
18
+ }
19
+ await setGestureStatusApi({
20
+ devId: rt.config.devInfo.devId,
21
+ password: encryptedPassword,
22
+ open: params.open,
23
+ });
24
+ };
@@ -18,7 +18,7 @@ export const isUseNearChannelForRuntime = (rt) => {
18
18
  return isBleOnline;
19
19
  }
20
20
  if (isSupportThread && isSupportBle) {
21
- return isBleOnline && !devInfo.isCloudOnline;
21
+ return isBleOnline;
22
22
  }
23
23
  return isBleOnline;
24
24
  };
@@ -28,6 +28,7 @@ export const createTempCustomForRuntime = parallelOnlyForRuntime(async function
28
28
  });
29
29
  if (!useNear) {
30
30
  try {
31
+ await isValidPassword(baseData);
31
32
  const res = await createTemporaryPassword({
32
33
  ...baseData,
33
34
  sn: 0,
@@ -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, isAdmin, parseWeek, validateEffectiveConfig, } from "../../utils";
12
+ import { formatTimestampToMilliseconds, formatWeek, isAdmin, isHarmony, 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";
@@ -337,8 +337,8 @@ export const openAddFamilyUser = async () => {
337
337
  if (!link) {
338
338
  link = await isSupportShortLink("thingsh_family_add_member_rn");
339
339
  }
340
- if (link) {
341
- const url = `tuyaSmart://${link}?homeId=${homeInfo.homeId}`;
340
+ if (link || isHarmony()) {
341
+ const url = `tuyaSmart://${isHarmony() ? "thingsh_family_add_member_rn" : link}?homeId=${homeInfo.homeId}`;
342
342
  return new Promise((resolve, reject) => {
343
343
  ty.router({
344
344
  url: url,
@@ -369,7 +369,7 @@ export async function openFamilyUserDetailForRuntime(rt, userId) {
369
369
  const { userType: currentUserType } = await getCurrentUserForRuntime(rt);
370
370
  const role = userTypeMap[currentUserType];
371
371
  let link = await isSupportShortLink("member_info");
372
- if (link) {
372
+ if (link || isHarmony()) {
373
373
  const url = `tuyaSmart://member_info?homeId=${homeId}&memberId=${userId}&role=${role}`;
374
374
  ty.router({
375
375
  url: url,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/lock-sdk",
3
- "version": "1.2.4-beta.0",
3
+ "version": "1.2.4-beta.2",
4
4
  "files": [
5
5
  "lib",
6
6
  "LICENSE.md"