whyuzeim 1.1.18 → 1.1.19

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.
@@ -18,10 +18,12 @@ var _setInterval = require('@babel/runtime-corejs3/core-js-stable/set-interval')
18
18
  var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
19
19
  var React = require('react');
20
20
  var agoraChatUikit = require('agora-chat-uikit');
21
+ var jsrsasign = require('jsrsasign');
21
22
  var context = require('../IM/context.js');
22
23
  var type = require('../type.js');
23
24
  var tools = require('../tools.js');
24
25
  var avatar_default = require('../Icon/avatar_default.svg.js');
26
+ var encryption = require('../IM/encryption.js');
25
27
 
26
28
  function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
27
29
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context4, _context5; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context4 = ownKeys(Object(t), true)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context5 = ownKeys(Object(t))).call(_context5, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -35,6 +37,7 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
35
37
  onLoginSuccess = props.onLoginSuccess;
36
38
  var _useSDK = agoraChatUikit.useSDK(),
37
39
  MessageSDK = _useSDK.ChatSDK;
40
+ var manulLoginRef = React.useRef(false);
38
41
  var _useContext = React.useContext(context.Context),
39
42
  http = _useContext.http,
40
43
  userInfo = _useContext.userInfo;
@@ -308,6 +311,34 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
308
311
  // 初始检查登录状态
309
312
  var currentLoginState = agoraChatUikit.rootStore.loginState;
310
313
  setLoading(!currentLoginState);
314
+ if (!agoraChatUikit.rootStore.loginState && !manulLoginRef.current && !window.AGAIN_ENTER_IM_INIT) {
315
+ manulLoginRef.current = true;
316
+ http.get("/capi/account/imuser/getkeypair", {
317
+ params: {
318
+ type: 2
319
+ }
320
+ }).then(function (result1) {
321
+ var publickey = result1.data.data.publickey;
322
+ // const rsaStr = encryption.rsaEncrypt(this.aesKey, publickey)
323
+ var publicPemKey = "-----BEGIN PUBLIC KEY-----\n" + publickey + "\n-----END PUBLIC KEY-----";
324
+ var pub = jsrsasign.KEYUTIL.getKey(publicPemKey);
325
+ var enc = jsrsasign.KJUR.crypto.Cipher.encrypt(encryption.aesKey, pub, "RSAOAEP");
326
+ http.get("/capi/account/imuser/getutoken", {
327
+ params: {
328
+ type: 2,
329
+ token: jsrsasign.hextob64(enc)
330
+ }
331
+ }).then(function (result2) {
332
+ var token = encryption.aesDecrypt(result2.data.data.utoken, encryption.aesKey);
333
+ client.open({
334
+ user: userInfo.uid,
335
+ accessToken: token
336
+ });
337
+ })["catch"](function (error) {
338
+ console.log(error, 'rewrew');
339
+ });
340
+ });
341
+ }
311
342
  if (currentLoginState && props.conversationId) {
312
343
  initConversation();
313
344
  getHeaderInfo();
@@ -23,30 +23,31 @@ var useGetAgoraToken = function useGetAgoraToken(http, uid) {
23
23
  }
24
24
  return _context.abrupt("return");
25
25
  case 2:
26
- _context.next = 4;
26
+ window.AGAIN_ENTER_IM_INIT = true;
27
+ _context.next = 5;
27
28
  return http.get("/capi/account/imuser/getkeypair", {
28
29
  params: {
29
30
  type: 2
30
31
  }
31
32
  });
32
- case 4:
33
+ case 5:
33
34
  result1 = _context.sent;
34
35
  publickey = result1.data.data.publickey; // const rsaStr = encryption.rsaEncrypt(this.aesKey, publickey)
35
36
  publicPemKey = "-----BEGIN PUBLIC KEY-----\n" + publickey + "\n-----END PUBLIC KEY-----";
36
37
  pub = jsrsasign.KEYUTIL.getKey(publicPemKey);
37
38
  enc = jsrsasign.KJUR.crypto.Cipher.encrypt(encryption.aesKey, pub, "RSAOAEP");
38
- _context.next = 11;
39
+ _context.next = 12;
39
40
  return http.get("/capi/account/imuser/getutoken", {
40
41
  params: {
41
42
  type: 2,
42
43
  token: jsrsasign.hextob64(enc)
43
44
  }
44
45
  });
45
- case 11:
46
+ case 12:
46
47
  result2 = _context.sent;
47
48
  token = encryption.aesDecrypt(result2.data.data.utoken, encryption.aesKey);
48
49
  setAgoraToken(token);
49
- case 14:
50
+ case 15:
50
51
  case "end":
51
52
  return _context.stop();
52
53
  }
package/cjs/IM/index.js CHANGED
@@ -32,6 +32,7 @@ var IM = function IM(props) {
32
32
  onAdditionalConversationClick = props.onAdditionalConversationClick,
33
33
  onRenderConversationItem = props.onRenderConversationItem,
34
34
  canSidebarExpand = props.canSidebarExpand;
35
+ window.AGAIN_ENTER_IM_INIT = false;
35
36
  console.log("the useinfo is", userInfo);
36
37
  var agoraToken = useGetAgoraToken.useGetAgoraToken(http, userInfo.uid);
37
38
  var _useState = React.useState(),
@@ -14,12 +14,14 @@ import _findInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instanc
14
14
  import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
15
15
  import _setInterval from '@babel/runtime-corejs3/core-js-stable/set-interval';
16
16
  import _trimInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/trim';
17
- import React, { useContext, useState, useCallback, useEffect } from 'react';
17
+ import React, { useRef, useContext, useState, useCallback, useEffect } from 'react';
18
18
  import { useClient, useSDK, rootStore, MessageList, MessageInput, ImageMessage, FileMessage, VideoMessage, BaseMessage } from 'agora-chat-uikit';
19
+ import jsrsasign from 'jsrsasign';
19
20
  import { Context } from '../IM/context.js';
20
21
  import { commonMessageInputConfig, commonMessageProps } from '../type.js';
21
22
  import { reportAgentInUse } from '../tools.js';
22
23
  import img from '../Icon/avatar_default.svg.js';
24
+ import { aesKey, aesDecrypt } from '../IM/encryption.js';
23
25
 
24
26
  function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
25
27
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context4, _context5; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context4 = ownKeys(Object(t), true)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context5 = ownKeys(Object(t))).call(_context5, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -33,6 +35,7 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
33
35
  onLoginSuccess = props.onLoginSuccess;
34
36
  var _useSDK = useSDK(),
35
37
  MessageSDK = _useSDK.ChatSDK;
38
+ var manulLoginRef = useRef(false);
36
39
  var _useContext = useContext(Context),
37
40
  http = _useContext.http,
38
41
  userInfo = _useContext.userInfo;
@@ -306,6 +309,34 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
306
309
  // 初始检查登录状态
307
310
  var currentLoginState = rootStore.loginState;
308
311
  setLoading(!currentLoginState);
312
+ if (!rootStore.loginState && !manulLoginRef.current && !window.AGAIN_ENTER_IM_INIT) {
313
+ manulLoginRef.current = true;
314
+ http.get("/capi/account/imuser/getkeypair", {
315
+ params: {
316
+ type: 2
317
+ }
318
+ }).then(function (result1) {
319
+ var publickey = result1.data.data.publickey;
320
+ // const rsaStr = encryption.rsaEncrypt(this.aesKey, publickey)
321
+ var publicPemKey = "-----BEGIN PUBLIC KEY-----\n" + publickey + "\n-----END PUBLIC KEY-----";
322
+ var pub = jsrsasign.KEYUTIL.getKey(publicPemKey);
323
+ var enc = jsrsasign.KJUR.crypto.Cipher.encrypt(aesKey, pub, "RSAOAEP");
324
+ http.get("/capi/account/imuser/getutoken", {
325
+ params: {
326
+ type: 2,
327
+ token: jsrsasign.hextob64(enc)
328
+ }
329
+ }).then(function (result2) {
330
+ var token = aesDecrypt(result2.data.data.utoken, aesKey);
331
+ client.open({
332
+ user: userInfo.uid,
333
+ accessToken: token
334
+ });
335
+ })["catch"](function (error) {
336
+ console.log(error, 'rewrew');
337
+ });
338
+ });
339
+ }
309
340
  if (currentLoginState && props.conversationId) {
310
341
  initConversation();
311
342
  getHeaderInfo();
@@ -21,30 +21,31 @@ var useGetAgoraToken = function useGetAgoraToken(http, uid) {
21
21
  }
22
22
  return _context.abrupt("return");
23
23
  case 2:
24
- _context.next = 4;
24
+ window.AGAIN_ENTER_IM_INIT = true;
25
+ _context.next = 5;
25
26
  return http.get("/capi/account/imuser/getkeypair", {
26
27
  params: {
27
28
  type: 2
28
29
  }
29
30
  });
30
- case 4:
31
+ case 5:
31
32
  result1 = _context.sent;
32
33
  publickey = result1.data.data.publickey; // const rsaStr = encryption.rsaEncrypt(this.aesKey, publickey)
33
34
  publicPemKey = "-----BEGIN PUBLIC KEY-----\n" + publickey + "\n-----END PUBLIC KEY-----";
34
35
  pub = jsrsasign.KEYUTIL.getKey(publicPemKey);
35
36
  enc = jsrsasign.KJUR.crypto.Cipher.encrypt(aesKey, pub, "RSAOAEP");
36
- _context.next = 11;
37
+ _context.next = 12;
37
38
  return http.get("/capi/account/imuser/getutoken", {
38
39
  params: {
39
40
  type: 2,
40
41
  token: jsrsasign.hextob64(enc)
41
42
  }
42
43
  });
43
- case 11:
44
+ case 12:
44
45
  result2 = _context.sent;
45
46
  token = aesDecrypt(result2.data.data.utoken, aesKey);
46
47
  setAgoraToken(token);
47
- case 14:
48
+ case 15:
48
49
  case "end":
49
50
  return _context.stop();
50
51
  }
package/es/IM/index.js CHANGED
@@ -30,6 +30,7 @@ var IM = function IM(props) {
30
30
  onAdditionalConversationClick = props.onAdditionalConversationClick,
31
31
  onRenderConversationItem = props.onRenderConversationItem,
32
32
  canSidebarExpand = props.canSidebarExpand;
33
+ window.AGAIN_ENTER_IM_INIT = false;
33
34
  console.log("the useinfo is", userInfo);
34
35
  var agoraToken = useGetAgoraToken(http, userInfo.uid);
35
36
  var _useState = useState(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whyuzeim",
3
- "version": "1.1.18",
3
+ "version": "1.1.19",
4
4
  "description": "im componenets",
5
5
  "main": "cjs/index.js",
6
6
  "module": "es/index.js",