@koi-design/callkit 1.0.22 → 1.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -35,20 +35,6 @@ declare class Call {
35
35
  callUnhold(): Promise<void>;
36
36
  }
37
37
 
38
- type LoggerLevel = 'debug' | 'log' | 'warn' | 'error' | 'silent';
39
- declare class Logger {
40
- prefix: string;
41
- level: LoggerLevel;
42
- private callKit;
43
- constructor(callKit: CallKit, level?: LoggerLevel);
44
- setLevel(level: LoggerLevel): void;
45
- debug(msg: any, extra?: Object): void;
46
- log(msg: any, extra?: Object): void;
47
- warn(msg: any, extra?: Object): void;
48
- error(msg: any, extra?: any): void;
49
- output(color: string): (msg: any, extra?: Object) => void;
50
- }
51
-
52
38
  declare const CallStatus: {
53
39
  /**
54
40
  * Initial state/Hang up
@@ -182,7 +168,26 @@ declare const SocketSendEvent: {
182
168
  * End
183
169
  */
184
170
  END: string;
185
- };
171
+ };
172
+ declare const EncryptionMethod: {
173
+ NONE: string;
174
+ INTERNAL: string;
175
+ };
176
+ type EncryptionMethodType = (typeof EncryptionMethod)[keyof typeof EncryptionMethod];
177
+
178
+ type LoggerLevel = 'debug' | 'log' | 'warn' | 'error' | 'silent';
179
+ declare class Logger {
180
+ prefix: string;
181
+ level: LoggerLevel;
182
+ private callKit;
183
+ constructor(callKit: CallKit, level?: LoggerLevel);
184
+ setLevel(level: LoggerLevel): void;
185
+ debug(msg: any, extra?: Object): void;
186
+ log(msg: any, extra?: Object): void;
187
+ warn(msg: any, extra?: Object): void;
188
+ error(msg: any, extra?: any): void;
189
+ output(color: string): (msg: any, extra?: Object) => void;
190
+ }
186
191
 
187
192
  type SocketSendEventType = (typeof SocketSendEvent)[keyof typeof SocketSendEvent];
188
193
  interface SocketConfig {
@@ -249,6 +254,7 @@ interface IConfig {
249
254
  sessionId: string;
250
255
  username: string;
251
256
  password: string;
257
+ encryptionPassword: string;
252
258
  extno: string;
253
259
  userPart: string;
254
260
  agentId: string;
@@ -258,6 +264,7 @@ interface IConfig {
258
264
  fsPort: string;
259
265
  iceInfo: string[];
260
266
  iceGatheringTimeout: number;
267
+ encryptionMethod: EncryptionMethodType;
261
268
  };
262
269
  isAutoUpdateUserStatus: boolean;
263
270
  }
@@ -415,7 +422,9 @@ declare class CallKit {
415
422
  user: User;
416
423
  listener: Listener[];
417
424
  constructor(options: ConfigEntity);
418
- login(username: string, password: string, extra?: object): Promise<void>;
425
+ login(username: string, password: string, extra?: {
426
+ [key: string]: any;
427
+ }): Promise<void>;
419
428
  logout(): Promise<void>;
420
429
  call(extno?: string | number): Promise<void>;
421
430
  register(): Promise<void>;
@@ -3547,6 +3547,10 @@ var WebCall = (() => {
3547
3547
  */
3548
3548
  ERROR: "ERROR"
3549
3549
  };
3550
+ var EncryptionMethod = {
3551
+ NONE: "NONE",
3552
+ INTERNAL: "INTERNAL"
3553
+ };
3550
3554
  var constrainsDefault = {
3551
3555
  audio: {
3552
3556
  autoGainControl: true,
@@ -3638,6 +3642,7 @@ var WebCall = (() => {
3638
3642
  username: "",
3639
3643
  // Password
3640
3644
  password: "",
3645
+ encryptionPassword: EncryptionMethod.INTERNAL,
3641
3646
  // Extension number
3642
3647
  extno: "",
3643
3648
  userPart: "",
@@ -3647,7 +3652,8 @@ var WebCall = (() => {
3647
3652
  fsIp: "",
3648
3653
  fsPort: "",
3649
3654
  iceInfo: [],
3650
- iceGatheringTimeout: 0
3655
+ iceGatheringTimeout: 0,
3656
+ encryptionMethod: EncryptionMethod.INTERNAL
3651
3657
  },
3652
3658
  // EXECUTE setUserStatus
3653
3659
  isAutoUpdateUserStatus: true
@@ -3667,6 +3673,7 @@ var WebCall = (() => {
3667
3673
  sessionId: "",
3668
3674
  username: "",
3669
3675
  password: "",
3676
+ encryptionPassword: "",
3670
3677
  userPart: "",
3671
3678
  extno: "",
3672
3679
  agentId: "",
@@ -3675,7 +3682,8 @@ var WebCall = (() => {
3675
3682
  fsIp: "",
3676
3683
  fsPort: "",
3677
3684
  iceInfo: [],
3678
- iceGatheringTimeout: this.config.userInfo.iceGatheringTimeout
3685
+ iceGatheringTimeout: this.config.userInfo.iceGatheringTimeout,
3686
+ encryptionMethod: EncryptionMethod.INTERNAL
3679
3687
  };
3680
3688
  this.callKit.trigger(KitEvent.KIT_LOGIN_CHANGE, false);
3681
3689
  }
@@ -19040,18 +19048,35 @@ var WebCall = (() => {
19040
19048
  this.socket = new Socket(this);
19041
19049
  this.user = new User(this);
19042
19050
  }
19043
- async login(username, password, extra = {}) {
19051
+ async login(username, password, extra = {
19052
+ encryptionMethod: EncryptionMethod.INTERNAL
19053
+ }) {
19044
19054
  if (this.config.isLogin()) {
19045
19055
  this.logger.warn("already login");
19046
19056
  return;
19047
19057
  }
19058
+ let encryptionPassword = "";
19059
+ const { encryptionMethod = EncryptionMethod.INTERNAL } = extra;
19060
+ switch (encryptionMethod) {
19061
+ case EncryptionMethod.NONE:
19062
+ encryptionPassword = password;
19063
+ break;
19064
+ case EncryptionMethod.INTERNAL:
19065
+ encryptionPassword = (0, import_blueimp_md5.default)(username + (0, import_blueimp_md5.default)(password));
19066
+ break;
19067
+ default:
19068
+ encryptionPassword = (0, import_blueimp_md5.default)(username + (0, import_blueimp_md5.default)(password));
19069
+ break;
19070
+ }
19048
19071
  this.logger.debug("login info:", {
19049
19072
  username,
19050
- password
19073
+ password,
19074
+ encryptionMethod,
19075
+ encryptionPassword
19051
19076
  });
19052
19077
  const user = await this.api.login({
19053
19078
  userName: username,
19054
- password: (0, import_blueimp_md5.default)(username + (0, import_blueimp_md5.default)(password))
19079
+ password: encryptionPassword
19055
19080
  }).catch((err) => {
19056
19081
  this.logger.error(err, { errCode: ErrorCode.API_USER_LOGIN_ERROR });
19057
19082
  });
@@ -19060,7 +19085,8 @@ var WebCall = (() => {
19060
19085
  wsUrl: `wss://${user.wsUrl}`,
19061
19086
  sessionId: user.sessionId,
19062
19087
  username,
19063
- password,
19088
+ password: encryptionPassword,
19089
+ encryptionPassword,
19064
19090
  agentId: user.agentId,
19065
19091
  fsUserId: user.fsUserId,
19066
19092
  userPart: user.userPart,
@@ -19069,6 +19095,7 @@ var WebCall = (() => {
19069
19095
  fsPort: user.fsPort,
19070
19096
  iceInfo: user.iceInfo,
19071
19097
  iceGatheringTimeout: user.iceGatheringTimeout,
19098
+ // encryptionType is in extra
19072
19099
  ...extra
19073
19100
  });
19074
19101
  this.socket.init();