@ray-js/lock-sdk 1.2.3 → 1.2.4-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.
@@ -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
  };
@@ -17,7 +17,7 @@ import { fetchDeviceProperties } from "./remote-permissions";
17
17
  import { ipc, yuChannelSyncSingleSync } from "../../platform";
18
18
  import { sdkLog } from "../../utils/sdk-log";
19
19
  import { ProductCommunicationType, RotateType } from "../../constant";
20
- import { isHarmony, isVirtualDevice } from "../../utils";
20
+ import { isVirtualDevice } from "../../utils";
21
21
  import { getError } from "../../utils/errors";
22
22
  import { isSupportMediaForRuntime } from "../media/media";
23
23
  export const initState = async (runtime) => {
@@ -130,25 +130,23 @@ export const initState = async (runtime) => {
130
130
  runtime.config.supportTalk = true;
131
131
  runtime.config.isTwoWayTalk =
132
132
  ipcConfig.value?.audioAttributes?.callMode?.[0] === 2;
133
- if (!isHarmony()) {
134
- try {
135
- const modeRes = await ipc.getCurrentSupportedTalkMode(devId);
136
- runtime.config.isTwoWayTalk = modeRes.talkbackMode === 2;
137
- sdkLog("info", "initState", "supportTalk", {
138
- devId,
139
- duration: Date.now() - startedAt,
140
- data: {
141
- mode: modeRes.talkbackMode,
142
- },
143
- });
144
- }
145
- catch (e) {
146
- sdkLog("error", "initState", "supportTalk", {
147
- devId,
148
- duration: Date.now() - startedAt,
149
- error: e,
150
- });
151
- }
133
+ try {
134
+ const modeRes = await ipc.getCurrentSupportedTalkMode(devId);
135
+ runtime.config.isTwoWayTalk = modeRes.talkbackMode === 2;
136
+ sdkLog("info", "initState", "supportTalk", {
137
+ devId,
138
+ duration: Date.now() - startedAt,
139
+ data: {
140
+ mode: modeRes.talkbackMode,
141
+ },
142
+ });
143
+ }
144
+ catch (e) {
145
+ sdkLog("error", "initState", "supportTalk", {
146
+ devId,
147
+ duration: Date.now() - startedAt,
148
+ error: e,
149
+ });
152
150
  }
153
151
  }
154
152
  if (!isSEI &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/lock-sdk",
3
- "version": "1.2.3",
3
+ "version": "1.2.4-beta.1",
4
4
  "files": [
5
5
  "lib",
6
6
  "LICENSE.md"