From b6590b16c9f5c6042665ff090deafb680e38f0b7 Mon Sep 17 00:00:00 2001 From: wk3368 Date: Thu, 8 Jun 2017 17:04:58 +0800 Subject: [PATCH 01/23] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/javascript/dist/webim.config.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/demo/javascript/dist/webim.config.js b/demo/javascript/dist/webim.config.js index 811e8eb0..2999a774 100755 --- a/demo/javascript/dist/webim.config.js +++ b/demo/javascript/dist/webim.config.js @@ -10,11 +10,13 @@ WebIM.config = { /* * XMPP server */ - xmppURL: 'im-api.easemob.com', + // xmppURL: 'im-api.easemob.com', + xmppURL: 'zy-imapi.easemob.com', /* * Backend REST API URL */ - apiURL: (location.protocol === 'https:' ? 'https:' : 'http:') + '//a1.easemob.com', + // apiURL: (location.protocol === 'https:' ? 'https:' : 'http:') + '//a1.easemob.com', + apiURL: (location.protocol === 'https:' ? 'https:' : 'http:') + '//zy-a1.easemob.com', /* * Application AppKey */ @@ -64,7 +66,7 @@ WebIM.config = { * Whether to console.log in strophe.log() * @parameter {Boolean} true or false */ - isDebug: false, + isDebug: true, /** * will auto connect the xmpp server autoReconnectNumMax times in background when client is offline. * won't auto connect if autoReconnectNumMax=0. @@ -110,6 +112,6 @@ WebIM.config = { * {type:'aes',mode: 'cbc',key: '123456789easemob',iv: '0000000000000000'} encrypt with aes(cbc) */ encrypt: { - type: 'none' + type: 'aes' } }; From 7276ef4ace0f05859435c0153e51618910f31dd1 Mon Sep 17 00:00:00 2001 From: wk3368 Date: Thu, 8 Jun 2017 17:31:31 +0800 Subject: [PATCH 02/23] res get key from ajax --- sdk/src/connection.js | 72 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 58 insertions(+), 14 deletions(-) diff --git a/sdk/src/connection.js b/sdk/src/connection.js index bab99717..95df90f3 100755 --- a/sdk/src/connection.js +++ b/sdk/src/connection.js @@ -297,6 +297,42 @@ var _parseFriend = function (queryTag, conn, from) { return rouster; }; +var _getAESKey = function (options, conn) { + // console.log(options) + // console.log('_getAESKey') + var self = this; + var suc = function (resp, xhr) { + console.log('suc') + console.log(resp) + //{"algorithm": "AES", "mode": "ECB", "padding": "PKCS5Padding", "key": "easemob@@easemob"} + conn.encrypt.mode = resp.data.mode.toLowerCase() + conn.encrypt.key = CryptoJS.enc.Utf8.parse(resp.data.key) + conn.encrypt.iv = CryptoJS.enc.Utf8.parse('0000000000000000') + _login(options, conn) + }; + var error = function (res, xhr, msg) { + console.log('error') + console.log(res) + + }; + + // console.log(conn) + var apiUrl = conn.context.apiUrl; + var appName = conn.context.appName; + var orgName = conn.context.orgName; + var options2 = { + url: apiUrl + '/' + orgName + '/' + appName + '/encrypt_info', + dataType: 'json', + type: 'GET', + headers: {'Authorization': 'Bearer ' + conn.context.accessToken}, + success: suc || _utils.emptyfn, + error: error || _utils.emptyfn + }; + _utils.ajax(options2); + +} + + var _login = function (options, conn) { var accessToken = options.access_token || ''; if (accessToken == '') { @@ -309,6 +345,13 @@ var _login = function (options, conn) { } conn.context.accessToken = options.access_token; conn.context.accessTokenExpires = options.expires_in; + + if (conn.encrypt.type === 'aes' && !conn.encrypt.mode) { + _getAESKey(options, conn) + return + } + + var stropheConn = null; if (conn.isOpening() && conn.context.stropheConn) { stropheConn = conn.context.stropheConn; @@ -670,6 +713,7 @@ var connection = function (options) { this.sendQueue = new Queue(); //instead of sending message immediately,cache them in this queue this.intervalId = null; //clearInterval return value this.apiUrl = options.apiUrl || ''; + this.context.apiUrl = this.apiUrl; this.isWindowSDK = options.isWindowSDK || false; this.encrypt = options.encrypt || {encrypt: {type: 'none'}}; this.delivery = options.delivery || false; @@ -1487,17 +1531,17 @@ connection.prototype.handleMessage = function (msginfo) { if (self.encrypt.type === 'base64') { receiveMsg = atob(receiveMsg); } else if (self.encrypt.type === 'aes') { - var key = CryptoJS.enc.Utf8.parse(self.encrypt.key); - var iv = CryptoJS.enc.Utf8.parse(self.encrypt.iv); - var mode = self.encrypt.mode.toLowerCase(); + var key = self.encrypt.key + var iv = self.encrypt.iv + var mode = self.encrypt.mode var option = {}; if (mode === 'cbc') { option = { iv: iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 - }; - } else if (mode === 'ebc') { + } + } else if (mode === 'ecb') { option = { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 @@ -1842,15 +1886,15 @@ connection.prototype.getUniqueId = function (prefix) { connection.prototype.send = function (messageSource) { var self = this; var message = messageSource; - if (message.type === 'txt') { - if (this.encrypt.type === 'base64') { - message = _.clone(messageSource); + if (message.type === 'txt' && (self.encrypt.type === 'base64' || self.encrypt.type === 'aes')) { + message = _.clone(messageSource); + if (self.encrypt.type === 'base64') { message.msg = btoa(message.msg); - } else if (this.encrypt.type === 'aes') { - message = _.clone(messageSource); - var key = CryptoJS.enc.Utf8.parse(this.encrypt.key); - var iv = CryptoJS.enc.Utf8.parse(this.encrypt.iv); - var mode = this.encrypt.mode.toLowerCase(); + } else if (self.encrypt.type === 'aes') { + console.log(this.encrypt) + var key = self.encrypt.key; + var iv = self.encrypt.iv; + var mode = self.encrypt.mode; var option = {}; if (mode === 'cbc') { option = { @@ -1858,7 +1902,7 @@ connection.prototype.send = function (messageSource) { mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 }; - } else if (mode === 'ebc') { + } else if (mode === 'ecb') { option = { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 From 0dad5b25c7cafdf674392394cd7ae4bed17fd5c1 Mon Sep 17 00:00:00 2001 From: wk3368 Date: Thu, 8 Jun 2017 17:32:30 +0800 Subject: [PATCH 03/23] block some new func relied on xmpp server --- .../src/components/chat/chatWindow.js | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/demo/javascript/src/components/chat/chatWindow.js b/demo/javascript/src/components/chat/chatWindow.js index 59af99ae..f453ec47 100755 --- a/demo/javascript/src/components/chat/chatWindow.js +++ b/demo/javascript/src/components/chat/chatWindow.js @@ -385,17 +385,17 @@ module.exports = React.createClass({
- {isMuted?'e':'f'} -
-
- + {/*{isMuted?'e':'f'}*/} + {/*
*/} + {/*
*/} + {/**/}
); }else{ @@ -413,17 +413,17 @@ module.exports = React.createClass({
- {isMuted?'e':'f'} -
-
- + {/*{isMuted?'e':'f'}*/} + {/*
*/} + {/*
*/} + {/**/}
); } From b7b7c606332605bfdd46cc3448d49eede9ddb8f8 Mon Sep 17 00:00:00 2001 From: wk3368 Date: Thu, 8 Jun 2017 23:57:30 +0800 Subject: [PATCH 04/23] =?UTF-8?q?fix=20bug:=20=E5=AE=A2=E6=88=B7=E7=AB=AF?= =?UTF-8?q?=E5=8F=91=E9=80=81cmd=E6=B6=88=E6=81=AF=E4=B9=8B=E5=90=8E?= =?UTF-8?q?=EF=BC=8Cwebim=E5=B4=A9=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/javascript/src/api.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/demo/javascript/src/api.js b/demo/javascript/src/api.js index 5428dcef..05af8d05 100755 --- a/demo/javascript/src/api.js +++ b/demo/javascript/src/api.js @@ -390,9 +390,12 @@ module.exports = { var brief = '', data = msg.data || msg.msg || '', name = this.sendByMe ? Demo.user : msg.from, - targetId = this.sentByMe || msg.type !== 'chat' ? msg.to : msg.from, - targetNode = document.getElementById('wrapper' + targetId), - isStranger = !document.getElementById(targetId) && !document.getElementById('wrapper' + targetId); + targetId = this.sentByMe || msg.type !== 'chat' ? msg.to : msg.from; + var targetNode = document.getElementById('wrapper' + targetId) + if (targetNode == null) { + return + } + var isStranger = !document.getElementById(targetId) && !document.getElementById('wrapper' + targetId); // TODO: ios/android client doesn't encodeURIComponent yet if (typeof data === "string" && WebIM.config.isWindowSDK) { From c3b6629e474e1e8e74be7e533f2851fdaea51641 Mon Sep 17 00:00:00 2001 From: clock <18209263592@163.com> Date: Fri, 9 Jun 2017 11:48:11 +0800 Subject: [PATCH 05/23] =?UTF-8?q?=E6=8E=A5=E6=94=B6=E6=96=B9=E8=BE=93?= =?UTF-8?q?=E5=87=BA=E7=9A=84log=E4=B8=BA=E6=98=8E=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/javascript/dist/demo-1.4.11.js | 127 ++++++--------- demo/javascript/src/components/chat/chat.js | 1 - sdk/dist/websdk-1.4.11.js | 162 +++++++++++++++++--- sdk/src/connection.js | 71 +++++++-- 4 files changed, 248 insertions(+), 113 deletions(-) diff --git a/demo/javascript/dist/demo-1.4.11.js b/demo/javascript/dist/demo-1.4.11.js index 0ee7e4c7..3cb4fe05 100644 --- a/demo/javascript/dist/demo-1.4.11.js +++ b/demo/javascript/dist/demo-1.4.11.js @@ -235,7 +235,7 @@ // module - exports.push([module.id, "@charset \"UTF-8\";\nhtml, body, section, article, h1, h2, h3, h4, h5, h6, p, div, i, em, span, ul, li, ol {\n font-family: Arial, Helvetica, sans-serif;\n margin: 0;\n padding: 0; }\n\nhtml, body {\n width: 100%;\n height: 100%;\n font-size: 13px;\n overflow-y: hidden;\n overflow-x: hidden;\n background-color: #fafafa;\n border: 1px solid rgba(250, 250, 250, 0);\n -webkit-font-smoothing: antialiased; }\n\ninput, button {\n outline: none; }\n input:focus, button:focus {\n border: 1px solid #4eb1f4;\n box-shadow: rgba(25, 161, 219, 0.247059) 0px 0px 5px 0px; }\n\ntextarea {\n outline: none;\n resize: none; }\n\nul, ol, li {\n list-style: none; }\n\n.pointer {\n cursor: pointer; }\n\n.left {\n float: left; }\n\n.right {\n float: right; }\n\n.w100 {\n width: 100%;\n height: 100%; }\n\n.pad0 {\n padding: 0; }\n\n.top50 {\n margin-top: 50px; }\n\n.rel {\n position: relative; }\n\n.dib {\n display: inline-block; }\n\nobject {\n z-index: 3;\n position: absolute;\n left: 340px;\n bottom: 118px;\n width: 84px; }\n\n@font-face {\n font-family: 'webim';\n src: url("http://github.com/+%20__webpack_require__(5) + ");\n src: url("http://github.com/+%20__webpack_require__(6) + ") format(\"woff\"), url("http://github.com/+%20__webpack_require__(7) + ") format(\"truetype\"), url("http://github.com/+%20__webpack_require__(8) + "#iconfont) format(\"svg\"); }\n\n.font {\n width: 40px;\n height: 40px;\n font-family: 'webim' !important;\n font-size: 40px;\n font-style: normal;\n -webkit-font-smoothing: antialiased;\n -webkit-text-stroke-width: 0.2px;\n -moz-osx-font-smoothing: grayscale; }\n .font.small {\n width: 30px;\n height: 30px;\n font-size: 30px; }\n .font.xsmaller {\n width: 26px;\n height: 26px;\n font-size: 26px; }\n .font.smaller {\n width: 24px;\n height: 24px;\n font-size: 24px; }\n .font.smallest {\n width: 16px;\n height: 16px;\n font-size: 16px; }\n\n.hide {\n display: none; }\n\n.bg-color {\n color: #fff;\n border: 1px solid #4eb1f4;\n -webkit-tap-highlight-color: transparent;\n background-color: #4eb1f4; }\n\n.color {\n color: #4eb1f4; }\n\n.hover-color:hover {\n color: #4eb1f4; }\n\n.webim-logo {\n width: 200px;\n margin: 0 auto; }\n\n.webim {\n position: absolute;\n right: 0;\n left: 0;\n margin: auto;\n top: 10%;\n bottom: 10%; }\n\n.copyright {\n z-index: 3;\n position: absolute;\n width: 100%;\n bottom: 10px;\n text-align: center;\n color: #cccccc; }\n\n.webim-rtc-video {\n z-index: 3;\n cursor: pointer;\n position: fixed;\n margin: auto;\n right: 0;\n left: 0;\n top: 0;\n bottom: 0;\n overflow: hidden;\n border-radius: 4px;\n background-color: #cccccc; }\n .webim-rtc-video video {\n position: absolute; }\n .webim-rtc-video video.full {\n z-index: 1;\n width: 100%;\n height: 100%;\n object-fit: contain; }\n .webim-rtc-video video.corner {\n z-index: 2;\n top: 40px;\n left: auto;\n right: 10px;\n bottom: auto;\n max-height: 17%;\n max-width: 17%;\n object-fit: contain; }\n .webim-rtc-video span {\n z-index: 2;\n position: absolute;\n margin: 0 auto;\n left: 0;\n right: 0;\n top: 6px;\n bottom: 0;\n width: 200px;\n height: 80px;\n text-align: center;\n color: #fff; }\n .webim-rtc-video i {\n z-index: 2;\n position: absolute;\n background-color: rgba(255, 255, 255, 0.2);\n font-style: normal;\n border-radius: 50%;\n text-align: center;\n color: rgba(0, 0, 0, 0.2);\n cursor: pointer; }\n .webim-rtc-video i.close {\n color: #e90101; }\n .webim-rtc-video i.toggle {\n color: #98e024; }\n .webim-rtc-video i.accept {\n color: #98e024; }\n .webim-rtc-video i.mute {\n color: #eeeeee; }\n\n/*\n * loading\n */\n.webim-loading {\n position: fixed;\n z-index: 3;\n background-color: #FAFAFA;\n width: 100%;\n height: 100%;\n top: 0;\n left: 0; }\n .webim-loading img {\n position: absolute;\n margin: auto;\n left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n width: 24px; }\n\n/*\n * button\n */\n.webim-button {\n font-size: 16px;\n box-sizing: border-box;\n display: inline-block;\n margin: 10px auto;\n width: 300px;\n height: 36px;\n cursor: pointer;\n border-radius: 2px; }\n .webim-button.error {\n background-color: #ff3a00;\n border: 1px solid #ff3a00; }\n .webim-button:hover {\n background-color: #1aa1e4; }\n\n/*\n * input\n */\n.webim-input {\n box-sizing: border-box;\n font-size: 14px;\n padding: 0 4px;\n display: inline-block;\n margin: 10px auto 0;\n width: 300px;\n height: 36px;\n line-height: 36px;\n cursor: pointer;\n border-radius: 2px;\n border: 1px solid #e5e5e5;\n -webkit-tap-highlight-color: transparent;\n background-color: white; }\n\n/*\n * checkbox\n */\n.webim-checkbox {\n text-align: left;\n margin: 10px 0 10px 5px;\n padding-left: 50px;\n box-sizing: border-box; }\n .webim-checkbox span {\n height: 30px;\n line-height: 30px; }\n .webim-checkbox > i {\n position: relative;\n margin-right: 6px;\n width: 14px;\n height: 14px;\n border-radius: 2px;\n display: inline-block;\n vertical-align: middle;\n border: 1px solid #cccccc;\n cursor: pointer; }\n .webim-checkbox > i:hover {\n background-color: #fff; }\n .webim-checkbox > i:hover em {\n display: inline-block;\n color: #cccccc; }\n .webim-checkbox > i.checked {\n background-color: #afd7e8; }\n .webim-checkbox > i.checked em {\n display: inline-block;\n color: #000; }\n .webim-checkbox > i em {\n display: none;\n position: absolute;\n left: -6px;\n top: -10px;\n color: #000; }\n\n/*\n * left bar\n */\n.webim-leftbar {\n position: relative;\n float: left;\n width: 50px;\n height: 100%;\n text-align: center;\n border-radius: 2px 0px 0px 2px;\n border: 1px solid #f2f2f2;\n -webkit-tap-highlight-color: transparent;\n background-color: #fcfdfb; }\n\n/*\n * contact list\n */\n.webim-contact-wrapper {\n float: left;\n height: 100%;\n width: 250px;\n overflow-x: hidden;\n overflow-y: auto;\n border-right: 1px solid #f2f2f2;\n -webkit-tap-highlight-color: transparent;\n background-color: white; }\n\n.webim-contact-item {\n cursor: pointer;\n position: relative;\n width: 100%;\n overflow: hidden;\n height: 60px; }\n .webim-contact-item .webim-avatar-icon {\n float: left;\n margin: 10px; }\n .webim-contact-item .webim-contact-info {\n position: relative; }\n .webim-contact-item .webim-contact-handlers {\n text-align: right;\n position: absolute;\n right: 2px;\n top: 0; }\n .webim-contact-item .webim-contact-handlers i {\n font-size: 16px;\n line-height: 36px; }\n .webim-contact-item > span, .webim-contact-item .webim-contact-username {\n color: #1a1a1a;\n font-size: 14px;\n margin: 10px 0;\n display: inline-block;\n width: calc(100% - 70px);\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis; }\n .webim-contact-item > i {\n display: inline-block;\n right: 2px;\n bottom: 10px;\n top: auto; }\n .webim-contact-item > em {\n display: block;\n height: 20px;\n line-height: 20px;\n width: calc(100% - 100px);\n position: absolute;\n margin: auto;\n left: 30px;\n top: 30px;\n right: 10px;\n color: #999999;\n font-style: normal;\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden; }\n .webim-contact-item > em img {\n width: 20px;\n vertical-align: middle; }\n .webim-contact-item.selected {\n background-color: #f3f6f6; }\n\n.webim-profile-avatar {\n display: inline-block;\n margin: 10px auto; }\n\n.webim-avatar-icon {\n width: 40px;\n height: 40px;\n border-radius: 50%;\n overflow: hidden;\n -webkit-filter: contrast(1.2);\n -webkit-tap-highlight-color: transparent; }\n .webim-avatar-icon.small {\n width: 30px;\n height: 30px; }\n\n.webim-operations-icon,\n.webim-leftbar-icon {\n position: relative;\n display: inline-block;\n cursor: pointer;\n margin-bottom: 10px;\n color: #cccccc; }\n .webim-operations-icon .rotate,\n .webim-leftbar-icon .rotate {\n transform: rotate(180deg);\n -webkit-transform: rotate(180deg);\n -moz-transform: rotate(180deg);\n -o-transform: rotate(180deg);\n -ms-transform: rotate(180deg); }\n\n.webim-operations-icon:hover,\n.webim-leftbar-icon:hover,\n.webim-operations-icon.selected,\n.webim-leftbar-icon.selected {\n color: #4eb1f4; }\n\n.webim-operations-icon {\n color: #cccccc;\n position: absolute;\n margin-bottom: 0;\n bottom: 10px;\n left: 10px; }\n .webim-operations-icon:hover {\n color: #4eb1f4; }\n\n/*\n * operations\n */\n.webim-operations {\n z-index: 1;\n position: absolute;\n text-align: left;\n left: 40px;\n bottom: 10px;\n width: 160px;\n box-shadow: rgba(0, 0, 0, 0.298039) 0px 0px 6px 0px;\n background-color: #fff; }\n .webim-operations i {\n margin: 0 10px;\n color: #cccccc; }\n .webim-operations span {\n vertical-align: top;\n word-break: keep-all;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis; }\n .webim-operations li {\n height: 30px;\n line-height: 30px;\n cursor: pointer;\n overflow: hidden; }\n .webim-operations li:hover {\n color: #4eb1f4;\n background-color: #f2f2f2; }\n .webim-operations li:hover i {\n color: #4eb1f4; }\n .webim-operations li:nth-child(2) i {\n display: inline-block;\n margin-top: -4px;\n vertical-align: top; }\n .webim-operations li:last-child:hover {\n color: #e90101; }\n .webim-operations li:last-child:hover i {\n color: #e90101; }\n\n.webim-msg-prompt {\n position: absolute;\n top: -4px;\n right: 0;\n line-height: 16px;\n font-style: normal;\n width: 16px;\n height: 16px;\n font-size: 12px;\n text-align: center;\n color: #fff;\n border-radius: 50%;\n border: 2px solid #fcfdfb;\n -webkit-tap-highlight-color: transparent;\n background-color: #ff3a00; }\n\n.webim-msg-icon-prompt {\n width: 10px;\n height: 10px;\n top: 0px;\n right: 8px; }\n\n.webim-blacklist-wrapper {\n position: relative;\n height: 100%;\n width: 100%;\n overflow-x: hidden;\n overflow-y: auto;\n -webkit-tap-highlight-color: transparent;\n background-color: white; }\n\n.webim-blacklist-item {\n position: relative;\n cursor: pointer;\n display: block;\n width: 100%;\n overflow: hidden;\n height: 30px;\n font-size: 20px;\n line-height: 30px; }\n .webim-blacklist-item i.font {\n line-height: 30px;\n float: right;\n position: static; }\n\n.webim-operation-icon {\n width: 100px;\n float: right;\n margin-right: 10px;\n text-align: right; }\n\n* :focus {\n outline: 0; }\n\n/*\n * notify\n */\n.webim-notify {\n z-index: 3;\n position: fixed;\n top: 10px;\n word-wrap: break-word;\n padding: 4px;\n width: 50%;\n color: #fff;\n left: 0;\n right: 0;\n margin: 0 auto;\n max-width: 90%;\n min-height: 30px;\n border-radius: 2px;\n line-height: 30px;\n text-align: center;\n box-shadow: rgba(0, 0, 0, 0.0980392) 0px 2px 6px 0px;\n -webkit-tap-highlight-color: transparent;\n border: 0px none black; }\n .webim-notify.success {\n background-color: #aeda3e; }\n .webim-notify.error {\n background-color: #ff3a00; }\n .webim-notify i {\n position: absolute;\n right: 10px;\n top: 9px; }\n\n/*\n * signin & signup\n */\n.webim-sign {\n overflow: hidden;\n width: 400px;\n margin: 40px auto;\n text-align: center;\n border-radius: 2px;\n box-shadow: rgba(0, 0, 0, 0.298039) 0px 0px 6px 0px;\n border: 0px none black;\n -webkit-tap-highlight-color: transparent;\n background-color: white; }\n .webim-sign h2 {\n font-size: 24px;\n color: #1a1a1a;\n width: 100%;\n line-height: 84px;\n height: 64px; }\n .webim-sign p {\n margin: 0px auto 40px;\n width: 300px;\n text-align: left; }\n .webim-sign p i {\n font-style: normal;\n color: #4eb1f4;\n cursor: pointer; }\n .webim-sign.webim-signup button {\n margin-top: 30px; }\n\n.webim-chat {\n position: relative;\n max-width: 1024px;\n min-width: 960px;\n max-height: 600px;\n height: 100%;\n margin: auto;\n box-shadow: rgba(0, 0, 0, 0.298039) 0px 0px 6px 0px;\n border: 0px none black;\n -webkit-tap-highlight-color: transparent;\n background-color: white;\n border-radius: 2px;\n overflow: hidden; }\n\n.webim-chatwindow {\n position: relative;\n float: left;\n height: 100%;\n width: calc(100% - 303px); }\n .webim-chatwindow textarea {\n position: absolute;\n bottom: 40px;\n right: 0;\n box-sizing: border-box;\n height: 80px;\n border: none;\n width: 100%;\n padding: 10px 15px; }\n .webim-chatwindow .webim-group-memeber {\n position: absolute;\n left: 0;\n right: 0;\n top: 40px;\n margin: auto;\n padding: 10px 7px;\n border-radius: 2px;\n width: 200px;\n overflow: auto;\n box-shadow: rgba(0, 0, 0, 0.298039) 0px 0px 6px 0px;\n z-index: 2;\n background: #fff;\n max-height: 300px; }\n .webim-chatwindow .webim-group-memeber li {\n height: 30px;\n padding: 0 4px;\n box-sizing: border-box;\n text-align: left; }\n .webim-chatwindow .webim-group-memeber li > div {\n display: inline-block;\n margin-right: 6px;\n width: 20px;\n height: 20px; }\n .webim-chatwindow .webim-group-name {\n max-width: 64px;\n overflow: hidden;\n text-overflow: ellipsis;\n display: inline-block; }\n\n.webim-chatwindow-title {\n position: absolute;\n top: 0;\n width: 100%;\n height: 40px;\n line-height: 40px;\n text-align: center;\n font-size: 14px; }\n .webim-chatwindow-title i {\n color: #cccccc;\n vertical-align: middle;\n cursor: pointer;\n margin-left: 10px;\n padding-bottom: 22px; }\n .webim-chatwindow-title i.webim-up-icon {\n transform: rotate(180deg); }\n .webim-chatwindow-title i.webim-call-icon {\n position: absolute;\n left: 0;\n top: 0; }\n .webim-chatwindow-title i.webim-accept-icon {\n position: absolute;\n left: 40px;\n top: 0; }\n\n.webim-chatwindow-options {\n border-top: 1px solid #f2f2f2;\n width: 100%;\n z-index: 1;\n position: absolute;\n bottom: 120px;\n left: 0;\n height: 30px;\n line-height: 30px; }\n .webim-chatwindow-options > span {\n margin-left: 6px;\n color: #cccccc;\n cursor: pointer; }\n .webim-chatwindow-options > span:hover {\n color: #4eb1f4; }\n\n.webim-send-btn {\n position: absolute;\n bottom: 0;\n right: 10px;\n width: 80px;\n height: 24px;\n font-size: 12px; }\n\n.webim-chatwindow-msg {\n z-index: 1;\n position: absolute;\n top: 40px;\n bottom: 150px;\n overflow-x: hidden;\n overflow-y: auto;\n box-sizing: border-box;\n padding: 20px 10px;\n width: 100%; }\n\n.webim-send-wrapper > ul {\n z-index: 1;\n position: absolute;\n width: 280px;\n height: 194px;\n bottom: 150px;\n left: -140px;\n border-radius: 2px;\n background: #fff;\n box-sizing: border-box;\n padding: 4px;\n box-shadow: rgba(0, 0, 0, 0.298039) 0px 4px 12px 0px; }\n .webim-send-wrapper > ul li {\n cursor: pointer;\n display: inline-block;\n margin: 2px 3px 0 3px; }\n\n#test {\n position: fixed;\n bottom: 0;\n left: 0;\n z-index: 2222; }\n\n.webim-msg-container {\n overflow: hidden;\n margin: 24px 0; }\n .webim-msg-container > div {\n max-width: 60%;\n overflow: hidden; }\n .webim-msg-container .right > p {\n color: #999999;\n letter-spacing: 1px;\n margin-right: 10px; }\n .webim-msg-container .right .webim-msg-icon {\n color: #b4e4fc;\n right: -40px; }\n .webim-msg-container .right .webim-msg-delivered {\n float: left;\n margin: 6px 2px 0 0;\n background-color: #cccccc; }\n .webim-msg-container .right .webim-msg-value {\n float: right;\n margin: 6px 10px 0 0;\n background-color: #b4e4fc; }\n .webim-msg-container .right .webim-msg-error {\n float: right;\n margin: 6px 10px 0 0; }\n .webim-msg-container .right .webim-msg-header {\n text-align: right; }\n .webim-msg-container .left > p {\n color: #999999;\n letter-spacing: 1px;\n margin-left: 10px; }\n .webim-msg-container .left .webim-msg-icon {\n color: #f1f2ec;\n left: -10px; }\n .webim-msg-container .left .webim-msg-value {\n background-color: #f1f2ec;\n float: left;\n margin: 6px 0 0 10px; }\n .webim-msg-container .left .webim-msg-header {\n text-align: left; }\n\n.webim-msg-icon {\n position: absolute;\n top: 4px;\n font-size: 10px; }\n\n.webim-msg-value {\n position: relative;\n min-height: 30px;\n max-width: calc(100% - 80px);\n border-radius: 4px;\n padding: 6px;\n box-sizing: border-box;\n min-width: 60%; }\n .webim-msg-value video {\n width: 100%; }\n .webim-msg-value.webim-img-msg-wrapper {\n padding: 1px; }\n .webim-msg-value > div,\n .webim-msg-value > pre {\n white-space: pre-wrap;\n word-break: break-all;\n color: #1a1a1a;\n font-size: 14px;\n line-height: 20px;\n margin: 0; }\n .webim-msg-value .emoji {\n width: 32px;\n vertical-align: bottom; }\n .webim-msg-value i {\n display: block;\n font-style: normal;\n margin-left: 40px;\n font-size: 12px;\n color: rgba(0, 0, 0, 0.25); }\n .webim-msg-value a {\n display: block;\n margin-left: 30px;\n margin-top: -28px;\n font-size: 12px;\n color: rgba(0, 0, 0, 0.25);\n text-decoration: none; }\n\n.webim-msg-img {\n max-width: 100%;\n vertical-align: middle;\n cursor: pointer;\n border-radius: 4px; }\n\n.webim-msg-header {\n line-height: 30px;\n margin-bottom: 4px;\n border-bottom: 1px solid rgba(0, 0, 0, 0.15); }\n\n.webim-msg-header-icon {\n vertical-align: middle;\n display: inline-block;\n margin: -46px 4px 0 -4px;\n line-height: 40px;\n color: #868683; }\n\n.webim-msg-name {\n width: calc(100% - 80px);\n display: inline-block;\n height: 40px;\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden; }\n\n.webim-msg-fileSize {\n display: inline-block;\n float: right;\n width: 47px;\n overflow: hidden; }\n\n.webim-img-expand {\n position: fixed;\n width: 100%;\n height: 100%;\n left: 0;\n top: 0;\n background: rgba(0, 0, 0, 0.3);\n z-index: 3; }\n .webim-img-expand img {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n max-width: 90%;\n max-height: 90%;\n margin: auto; }\n\n.webim-audio-slash {\n background-color: transparent;\n position: absolute;\n width: 100%;\n height: 100%;\n top: 0;\n left: 0;\n border-radius: 4px; }\n\n.slash {\n animation: slash 1s infinite;\n -moz-animation: slash 1s infinite;\n -webkit-animation: slash 1s infinite; }\n\n@keyframes slash {\n from {\n background-color: transparent; }\n 50% {\n background-color: rgba(0, 0, 0, 0.1); }\n to {\n background-color: transparent; } }\n\n@-moz-keyframes slash {\n from {\n background-color: transparent; }\n 50% {\n background-color: rgba(0, 0, 0, 0.1); }\n to {\n background-color: transparent; } }\n\n@-webkit-keyframes slash {\n from {\n background-color: transparent; }\n 50% {\n background-color: rgba(0, 0, 0, 0.1); }\n to {\n background-color: transparent; } }\n\n.clearfix:after {\n content: ' ';\n display: table;\n clear: both; }\n\n/*\n * dialog\n */\n.webim-dialog {\n z-index: 3;\n position: absolute;\n width: 400px;\n min-height: 168px;\n top: 20%;\n left: 0;\n right: 0;\n margin: auto;\n border-radius: 2px;\n box-shadow: rgba(0, 0, 0, 0.298039) 0px 0px 8px 0px;\n background-color: white; }\n .webim-dialog h3 {\n line-height: 40px;\n box-sizing: border-box;\n padding-left: 10px;\n border-bottom: 1px solid rgba(0, 0, 0, 0.1);\n font-weight: normal; }\n .webim-dialog .font {\n font-size: 20px;\n position: absolute;\n right: 6px;\n top: 6px;\n width: 20px;\n height: 20px;\n color: rgba(0, 0, 0, 0.1);\n cursor: pointer; }\n .webim-dialog > div {\n border-bottom: 1px solid rgba(0, 0, 0, 0.1);\n padding: 10px 10px 10px; }\n .webim-dialog .webim-dialog-button {\n position: absolute;\n right: 8px;\n bottom: 2px;\n width: 80px;\n height: 26px; }\n .webim-dialog .webim-dialog-button-search {\n bottom: 2px;\n width: 80px;\n height: 30px;\n margin-left: 70px; }\n .webim-dialog .webim-dialog-button-left {\n position: absolute;\n right: 100px;\n bottom: 2px;\n width: 80px;\n height: 26px; }\n .webim-dialog .webim-subscribe-button {\n width: 60px;\n height: 30px;\n margin-left: 10px; }\n .webim-dialog input {\n height: 30px;\n width: 220px; }\n .webim-dialog textarea {\n margin-top: 20px;\n right: 0;\n box-sizing: border-box;\n height: 80px;\n border: 1px solid rgba(0, 0, 0, 0.1);\n width: 220px; }\n .webim-dialog-body {\n min-height: 100px;\n max-height: 126px;\n overflow: scroll; }\n .webim-dialog-body-detail {\n width: 100%; }\n .webim-dialog-body-detail span.title {\n font-size: 14px;\n display: block;\n font-weight: 700;\n margin-bottom: 5px; }\n .webim-dialog-body-detail span.content {\n font-size: 12px;\n color: #6a737c; }\n .webim-dialog .webim-dialog-footer {\n padding: 10px;\n position: relative;\n min-height: 20px;\n text-align: right; }\n .webim-dialog .webim-dialog-footer .webim-button {\n position: static;\n margin-right: 10px; }\n .webim-dialog .webim-dialog-footer .webim-group-back {\n position: absolute;\n left: 0;\n height: 67px;\n width: 50px;\n background-color: #f2f2f2;\n top: 0;\n border-radius: 0 2px 2px 0;\n text-align: center;\n cursor: pointer; }\n .webim-dialog .webim-dialog-footer .webim-group-back span {\n line-height: 67px;\n font-size: 30px;\n font-weight: 700;\n color: #868683; }\n\n.webim-dialog-2 {\n height: 450px; }\n\n.webim-friend-requests {\n height: auto; }\n .webim-friend-requests span {\n width: 60%;\n display: inline-block;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap; }\n .webim-friend-requests > div {\n overflow: auto;\n max-height: 400px; }\n\n.webim-body-loading {\n height: 86px;\n width: 400px;\n position: absolute;\n opacity: 0.5;\n z-index: 999;\n margin-top: -10px;\n margin-left: -10px;\n padding-top: 61px; }\n .webim-body-loading img {\n margin: auto;\n display: block;\n width: 30px;\n line-height: inherit; }\n\n/*\n * layer\n */\n.webim-layer {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: 1;\n background-color: rgba(0, 0, 0, 0.25); }\n\n/*\n 说明:\n 下面的css都是为了快速实现功能,覆盖旧有属性的各种trick\n 后期需要找专门的css人员整理一遍,合并入正常的文件,然后删除本文件!\n*/\n/******************* multiple select box ********************/\n.react-multi-select-box-container {\n position: relative;\n width: 240px;\n display: inline-block;\n background-color: #fff;\n border-radius: 4px;\n text-align: left;\n box-shadow: 0 0 2px rgba(0, 0, 0, 0.3); }\n\n.react-multi-select-box {\n padding: 10px 0;\n display: inline-block;\n cursor: pointer;\n border: none;\n width: 100%;\n text-align: left;\n background-color: transparent; }\n .react-multi-select-box::before {\n content: ' ';\n position: absolute;\n z-index: 1;\n height: 20px;\n top: -7px;\n right: 13px;\n border-left: 3px solid transparent;\n border-right: 3px solid transparent;\n border-bottom: 4px solid #a7a8aa; }\n .react-multi-select-box::after {\n content: ' ';\n position: absolute;\n z-index: 1;\n top: 20px;\n right: 13px;\n border-top: 4px solid #a7a8aa;\n border-left: 3px solid transparent;\n border-right: 3px solid transparent; }\n\n.react-multi-select-box-label {\n padding: 0 40px 0 10px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n color: #333;\n line-height: 16px; }\n\n.react-multi-select-box-empty .react-multi-select-box-label {\n color: #c5c5c5; }\n\n.react-multi-select-area {\n position: absolute;\n margin-top: 4px;\n padding: 0 10px;\n height: 225px;\n min-width: 260px;\n border-radius: 4px;\n background-color: #fff;\n z-index: 4;\n box-shadow: 0 0 2px rgba(0, 0, 0, 0.3); }\n\n.react-multi-select-box-hidden {\n display: none; }\n\n.react-multi-select-hide {\n display: none; }\n\n.react-multi-select-panel {\n display: flex;\n height: 185px; }\n\n.react-multi-select-col {\n min-width: 110px;\n overflow-y: auto; }\n .react-multi-select-col .selected-option-row {\n padding: 5px 0;\n cursor: pointer; }\n\n.react-multi-select-sign {\n display: flex;\n flex-direction: column;\n justify-content: center;\n width: 15px; }\n .react-multi-select-sign i {\n width: 6px;\n height: 6px;\n border-top: 2px solid #a9a9a9;\n border-right: 2px solid #a9a9a9;\n -webkit-transform: rotate(45deg);\n -moz-transform: rotate(45deg);\n -o-transform: rotate(45deg);\n transform: rotate(45deg); }\n\n.react-multi-select-area-btn {\n padding: 5px 0;\n height: 40px;\n border-top: 1px solid #eee;\n text-align: center; }\n .react-multi-select-area-btn .eg-btn {\n padding: 4px 20px;\n margin-right: 10px; }\n .react-multi-select-area-btn .eg-btn:last-child {\n margin-right: 0; }\n\n.classification {\n padding: 5px 0;\n cursor: pointer; }\n\n.react-multi-select-list-arrow {\n position: relative;\n display: inline-block;\n vertical-align: middle;\n width: 8px;\n height: 8px; }\n .react-multi-select-list-arrow::before {\n content: ' ';\n position: absolute;\n border-top: 3px solid transparent;\n border-bottom: 3px solid transparent;\n border-left: 4px solid #87c2e5; }\n\n.react-multi-select-list-arrow.expand::before {\n content: ' ';\n position: absolute;\n border-left: 3px solid transparent;\n border-right: 3px solid transparent;\n border-top: 4px solid #87c2e5; }\n\n.react-multi-select-sub-options {\n padding-left: 16px; }\n\n.react-multi-select-list-option:last-child {\n padding-bottom: 0; }\n\n.react-multi-select-list-option .eg-input.checkbox .input-icon {\n margin-right: 2px; }\n\n.react-multi-select-list-option .eg-input.checkbox.active .input-icon {\n fill: #87c2e5; }\n\n.react-multi-select-list-option .react-multi-select-box-option {\n position: relative;\n padding: 5px 0 5px 20px;\n margin: 0;\n cursor: pointer;\n display: block;\n text-decoration: none; }\n .react-multi-select-list-option .react-multi-select-box-option:before {\n content: ' ';\n position: absolute;\n text-align: center;\n line-height: 1.1;\n left: 2px;\n top: 8px;\n height: 12px;\n width: 12px;\n margin-right: 10px;\n border: 1px solid #7B8E9B;\n background: #f9f9f9;\n vertical-align: middle; }\n\n.react-multi-select-list-option .react-multi-select-box-option-selected:before {\n content: '\\2713';\n color: #87c2e5; }\n\n.react-multiple-select-type-name {\n padding: 5px 0 4px 0;\n border-bottom: 1px solid #eee;\n color: #c5c5c5; }\n\n.react-multi-select-btn {\n padding: 4px 20px;\n border-radius: 6px;\n background-color: #307fc8;\n display: inline-block;\n margin-right: 10px;\n margin-bottom: 0;\n text-align: center;\n vertical-align: middle;\n touch-action: manipulation;\n cursor: pointer;\n background-image: none;\n border: 1px solid transparent;\n white-space: nowrap;\n outline: 0;\n text-decoration: none;\n font-weight: normal;\n font-size: 14px;\n line-height: 1.42857143;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n color: #fff;\n border-color: transparent; }\n .react-multi-select-btn:last-child {\n margin-right: 0; }\n\n.react-multi-select-btn-white {\n background-color: #fff;\n color: #333;\n border-color: #d5d5d5; }\n\n/******************* multiple select box ********************/\n.webim-chatwindow .webim-operations-icon {\n top: 5px;\n left: auto;\n right: 10px;\n bottom: 0px; }\n\n.webim-chatwindow .webim-operations {\n left: inherit;\n right: 40px;\n top: 10px;\n bottom: auto;\n z-index: 2; }\n\n.webim-friend-options span.radio_span {\n width: 80px;\n display: inline-block; }\n\n.webim-friend-options input.radio {\n height: 10px;\n width: 20px; }\n\n.webim_isWindowSDK {\n top: 0;\n bottom: 0; }\n\n.webim_isWindowSDK .webim-chat {\n max-width: 100%;\n min-width: 100%;\n max-height: 100%;\n width: 100%; }\n\n.webim-friend-requests-windowSDK {\n width: 500px; }\n\n.webim-friend-requests-windowSDK span {\n width: 100%; }\n\n.webim-msg-value a.dir {\n margin-left: 130px;\n margin-top: -20px; }\n\n.webim-leftbar .username {\n width: 100%;\n overflow: hidden; }\n\n.webim-loading span {\n position: absolute;\n margin: auto;\n left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n width: 200px;\n height: 80px;\n text-align: center; }\n\nspan.red {\n color: #ff2a00; }\n\n.webim-contact-loading {\n width: 24px;\n margin: 0 auto; }\n\n.webim-contact-loading img {\n width: 24px; }\n", ""]); + exports.push([module.id, "@charset \"UTF-8\";\nhtml, body, section, article, h1, h2, h3, h4, h5, h6, p, div, i, em, span, ul, li, ol {\n font-family: Arial, Helvetica, sans-serif;\n margin: 0;\n padding: 0; }\n\nhtml, body {\n width: 100%;\n height: 100%;\n font-size: 13px;\n overflow-y: hidden;\n overflow-x: hidden;\n background-color: #fafafa;\n border: 1px solid rgba(250, 250, 250, 0);\n -webkit-font-smoothing: antialiased; }\n\ninput, button {\n outline: none; }\n input:focus, button:focus {\n border: 1px solid #4eb1f4;\n box-shadow: rgba(25, 161, 219, 0.247059) 0px 0px 5px 0px; }\n\ntextarea {\n outline: none;\n resize: none; }\n\nul, ol, li {\n list-style: none; }\n\n.pointer {\n cursor: pointer; }\n\n.left {\n float: left; }\n\n.right {\n float: right; }\n\n.w100 {\n width: 100%;\n height: 100%; }\n\n.pad0 {\n padding: 0; }\n\n.top50 {\n margin-top: 50px; }\n\n.rel {\n position: relative; }\n\n.dib {\n display: inline-block; }\n\nobject {\n z-index: 3;\n position: absolute;\n left: 340px;\n bottom: 118px;\n width: 84px; }\n\n@font-face {\n font-family: 'webim';\n src: url("http://github.com/+%20__webpack_require__(5) + ");\n src: url("http://github.com/+%20__webpack_require__(6) + ") format(\"woff\"), url("http://github.com/+%20__webpack_require__(7) + ") format(\"truetype\"), url("http://github.com/+%20__webpack_require__(8) + "#iconfont) format(\"svg\"); }\n\n.font {\n width: 40px;\n height: 40px;\n font-family: 'webim' !important;\n font-size: 40px;\n font-style: normal;\n -webkit-font-smoothing: antialiased;\n -webkit-text-stroke-width: 0.2px;\n -moz-osx-font-smoothing: grayscale; }\n .font.small {\n width: 30px;\n height: 30px;\n font-size: 30px; }\n .font.xsmaller {\n width: 26px;\n height: 26px;\n font-size: 26px; }\n .font.smaller {\n width: 24px;\n height: 24px;\n font-size: 24px; }\n .font.smallest {\n width: 16px;\n height: 16px;\n font-size: 16px; }\n\n.hide {\n display: none; }\n\n.bg-color {\n color: #fff;\n border: 1px solid #4eb1f4;\n -webkit-tap-highlight-color: transparent;\n background-color: #4eb1f4; }\n\n.color {\n color: #4eb1f4; }\n\n.hover-color:hover {\n color: #4eb1f4; }\n\n.webim-logo {\n width: 200px;\n margin: 0 auto; }\n\n.webim {\n position: absolute;\n right: 0;\n left: 0;\n margin: auto;\n top: 10%;\n bottom: 10%; }\n\n.copyright {\n z-index: 3;\n position: absolute;\n width: 100%;\n bottom: 10px;\n text-align: center;\n color: #cccccc; }\n\n.webim-rtc-video {\n z-index: 3;\n cursor: pointer;\n position: fixed;\n margin: auto;\n right: 0;\n left: 0;\n top: 0;\n bottom: 0;\n overflow: hidden;\n border-radius: 4px;\n background-color: #cccccc; }\n .webim-rtc-video video {\n position: absolute; }\n .webim-rtc-video video.full {\n z-index: 1;\n width: 100%;\n height: 100%;\n object-fit: contain; }\n .webim-rtc-video video.corner {\n z-index: 2;\n top: 40px;\n left: auto;\n right: 10px;\n bottom: auto;\n max-height: 17%;\n max-width: 17%;\n object-fit: contain; }\n .webim-rtc-video span {\n z-index: 2;\n position: absolute;\n margin: 0 auto;\n left: 0;\n right: 0;\n top: 6px;\n bottom: 0;\n width: 200px;\n height: 80px;\n text-align: center;\n color: #fff; }\n .webim-rtc-video i {\n z-index: 2;\n position: absolute;\n background-color: rgba(255, 255, 255, 0.2);\n font-style: normal;\n border-radius: 50%;\n text-align: center;\n color: rgba(0, 0, 0, 0.2);\n cursor: pointer; }\n .webim-rtc-video i.close {\n color: #e90101; }\n .webim-rtc-video i.toggle {\n color: #98e024; }\n .webim-rtc-video i.accept {\n color: #98e024; }\n .webim-rtc-video i.mute {\n color: #eeeeee; }\n\n/*\n * loading\n */\n.webim-loading {\n position: fixed;\n z-index: 3;\n background-color: #FAFAFA;\n width: 100%;\n height: 100%;\n top: 0;\n left: 0; }\n .webim-loading img {\n position: absolute;\n margin: auto;\n left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n width: 24px; }\n\n/*\n * button\n */\n.webim-button {\n font-size: 16px;\n box-sizing: border-box;\n display: inline-block;\n margin: 10px auto;\n width: 300px;\n height: 36px;\n cursor: pointer;\n border-radius: 2px; }\n .webim-button.error {\n background-color: #ff3a00;\n border: 1px solid #ff3a00; }\n .webim-button:hover {\n background-color: #1aa1e4; }\n\n/*\n * input\n */\n.webim-input {\n box-sizing: border-box;\n font-size: 14px;\n padding: 0 4px;\n display: inline-block;\n margin: 10px auto 0;\n width: 300px;\n height: 36px;\n line-height: 36px;\n cursor: pointer;\n border-radius: 2px;\n border: 1px solid #e5e5e5;\n -webkit-tap-highlight-color: transparent;\n background-color: white; }\n\n/*\n * checkbox\n */\n.webim-checkbox {\n text-align: left;\n margin: 10px 0 10px 5px;\n padding-left: 50px;\n box-sizing: border-box; }\n .webim-checkbox span {\n height: 30px;\n line-height: 30px; }\n .webim-checkbox > i {\n position: relative;\n margin-right: 6px;\n width: 14px;\n height: 14px;\n border-radius: 2px;\n display: inline-block;\n vertical-align: middle;\n border: 1px solid #cccccc;\n cursor: pointer; }\n .webim-checkbox > i:hover {\n background-color: #fff; }\n .webim-checkbox > i:hover em {\n display: inline-block;\n color: #cccccc; }\n .webim-checkbox > i.checked {\n background-color: #afd7e8; }\n .webim-checkbox > i.checked em {\n display: inline-block;\n color: #000; }\n .webim-checkbox > i em {\n display: none;\n position: absolute;\n left: -6px;\n top: -10px;\n color: #000; }\n\n/*\n * left bar\n */\n.webim-leftbar {\n position: relative;\n float: left;\n width: 50px;\n height: 100%;\n text-align: center;\n border-radius: 2px 0px 0px 2px;\n border: 1px solid #f2f2f2;\n -webkit-tap-highlight-color: transparent;\n background-color: #fcfdfb; }\n\n/*\n * contact list\n */\n.webim-contact-wrapper {\n float: left;\n height: 100%;\n width: 250px;\n overflow-x: hidden;\n overflow-y: auto;\n border-right: 1px solid #f2f2f2;\n -webkit-tap-highlight-color: transparent;\n background-color: white; }\n\n.webim-contact-item {\n cursor: pointer;\n position: relative;\n width: 100%;\n overflow: hidden;\n height: 60px; }\n .webim-contact-item .webim-avatar-icon {\n float: left;\n margin: 10px; }\n .webim-contact-item .webim-contact-info {\n position: relative; }\n .webim-contact-item .webim-contact-handlers {\n text-align: right;\n position: absolute;\n right: 2px;\n top: 0; }\n .webim-contact-item .webim-contact-handlers i {\n font-size: 16px;\n line-height: 36px; }\n .webim-contact-item > span, .webim-contact-item .webim-contact-username {\n color: #1a1a1a;\n font-size: 14px;\n margin: 10px 0;\n display: inline-block;\n width: calc(100% - 70px);\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis; }\n .webim-contact-item > i {\n display: inline-block;\n right: 2px;\n bottom: 10px;\n top: auto; }\n .webim-contact-item > em {\n display: block;\n height: 20px;\n line-height: 20px;\n width: calc(100% - 100px);\n position: absolute;\n margin: auto;\n left: 30px;\n top: 30px;\n right: 10px;\n color: #999999;\n font-style: normal;\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden; }\n .webim-contact-item > em img {\n width: 20px;\n vertical-align: middle; }\n .webim-contact-item.selected {\n background-color: #f3f6f6; }\n\n.webim-profile-avatar {\n display: inline-block;\n margin: 10px auto; }\n\n.webim-avatar-icon {\n width: 40px;\n height: 40px;\n border-radius: 50%;\n overflow: hidden;\n -webkit-filter: contrast(1.2);\n -webkit-tap-highlight-color: transparent; }\n .webim-avatar-icon.small {\n width: 30px;\n height: 30px; }\n\n.webim-operations-icon,\n.webim-leftbar-icon {\n position: relative;\n display: inline-block;\n cursor: pointer;\n margin-bottom: 10px;\n color: #cccccc; }\n .webim-operations-icon .rotate,\n .webim-leftbar-icon .rotate {\n transform: rotate(180deg);\n -webkit-transform: rotate(180deg);\n -moz-transform: rotate(180deg);\n -o-transform: rotate(180deg);\n -ms-transform: rotate(180deg); }\n\n.webim-operations-icon:hover,\n.webim-leftbar-icon:hover,\n.webim-operations-icon.selected,\n.webim-leftbar-icon.selected {\n color: #4eb1f4; }\n\n.webim-operations-icon {\n color: #cccccc;\n position: absolute;\n margin-bottom: 0;\n bottom: 10px;\n left: 10px; }\n .webim-operations-icon:hover {\n color: #4eb1f4; }\n\n/*\n * operations\n */\n.webim-operations {\n z-index: 1;\n position: absolute;\n text-align: left;\n left: 40px;\n bottom: 10px;\n width: 160px;\n box-shadow: rgba(0, 0, 0, 0.298039) 0px 0px 6px 0px;\n background-color: #fff; }\n .webim-operations i {\n margin: 0 10px;\n color: #cccccc; }\n .webim-operations span {\n vertical-align: top;\n word-break: keep-all;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis; }\n .webim-operations li {\n height: 30px;\n line-height: 30px;\n cursor: pointer;\n overflow: hidden; }\n .webim-operations li:hover {\n color: #4eb1f4;\n background-color: #f2f2f2; }\n .webim-operations li:hover i {\n color: #4eb1f4; }\n .webim-operations li:nth-child(2) i {\n display: inline-block;\n margin-top: -4px;\n vertical-align: top; }\n .webim-operations li:last-child:hover {\n color: #e90101; }\n .webim-operations li:last-child:hover i {\n color: #e90101; }\n\n.webim-msg-prompt {\n position: absolute;\n top: -4px;\n right: 0;\n line-height: 16px;\n font-style: normal;\n width: 16px;\n height: 16px;\n font-size: 12px;\n text-align: center;\n color: #fff;\n border-radius: 50%;\n border: 2px solid #fcfdfb;\n -webkit-tap-highlight-color: transparent;\n background-color: #ff3a00; }\n\n.webim-msg-icon-prompt {\n width: 10px;\n height: 10px;\n top: 0px;\n right: 8px; }\n\n.webim-blacklist-wrapper {\n position: relative;\n height: 100%;\n width: 100%;\n overflow-x: hidden;\n overflow-y: auto;\n -webkit-tap-highlight-color: transparent;\n background-color: white; }\n\n.webim-blacklist-item {\n position: relative;\n cursor: pointer;\n display: block;\n width: 100%;\n overflow: hidden;\n height: 30px;\n font-size: 20px;\n line-height: 30px; }\n .webim-blacklist-item i.font {\n line-height: 30px;\n float: right;\n position: static; }\n\n.webim-operation-icon {\n width: 100px;\n float: right;\n margin-right: 10px;\n text-align: right; }\n\n* :focus {\n outline: 0; }\n\n/*\n * notify\n */\n.webim-notify {\n z-index: 3;\n position: fixed;\n top: 10px;\n word-wrap: break-word;\n padding: 4px;\n width: 50%;\n color: #fff;\n left: 0;\n right: 0;\n margin: 0 auto;\n max-width: 90%;\n min-height: 30px;\n border-radius: 2px;\n line-height: 30px;\n text-align: center;\n box-shadow: rgba(0, 0, 0, 0.0980392) 0px 2px 6px 0px;\n -webkit-tap-highlight-color: transparent;\n border: 0px none black; }\n .webim-notify.success {\n background-color: #aeda3e; }\n .webim-notify.error {\n background-color: #ff3a00; }\n .webim-notify i {\n position: absolute;\n right: 10px;\n top: 9px; }\n\n/*\n * signin & signup\n */\n.webim-sign {\n overflow: hidden;\n width: 400px;\n margin: 40px auto;\n text-align: center;\n border-radius: 2px;\n box-shadow: rgba(0, 0, 0, 0.298039) 0px 0px 6px 0px;\n border: 0px none black;\n -webkit-tap-highlight-color: transparent;\n background-color: white; }\n .webim-sign h2 {\n font-size: 24px;\n color: #1a1a1a;\n width: 100%;\n line-height: 84px;\n height: 64px; }\n .webim-sign p {\n margin: 0px auto 40px;\n width: 300px;\n text-align: left; }\n .webim-sign p i {\n font-style: normal;\n color: #4eb1f4;\n cursor: pointer; }\n .webim-sign.webim-signup button {\n margin-top: 30px; }\n\n.webim-chat {\n position: relative;\n max-width: 1024px;\n min-width: 960px;\n max-height: 600px;\n height: 100%;\n margin: auto;\n box-shadow: rgba(0, 0, 0, 0.298039) 0px 0px 6px 0px;\n border: 0px none black;\n -webkit-tap-highlight-color: transparent;\n background-color: white;\n border-radius: 2px;\n overflow: hidden; }\n\n.webim-chatwindow {\n position: relative;\n float: left;\n height: 100%;\n width: calc(100% - 303px); }\n .webim-chatwindow textarea {\n position: absolute;\n bottom: 40px;\n right: 0;\n box-sizing: border-box;\n height: 80px;\n border: none;\n width: 100%;\n padding: 10px 15px; }\n .webim-chatwindow .webim-group-memeber {\n position: absolute;\n left: 0;\n right: 0;\n top: 40px;\n margin: auto;\n padding: 10px 7px;\n border-radius: 2px;\n width: 200px;\n overflow: auto;\n box-shadow: rgba(0, 0, 0, 0.298039) 0px 0px 6px 0px;\n z-index: 2;\n background: #fff;\n max-height: 300px; }\n .webim-chatwindow .webim-group-memeber li {\n height: 30px;\n padding: 0 4px;\n box-sizing: border-box;\n text-align: left; }\n .webim-chatwindow .webim-group-memeber li > div {\n display: inline-block;\n margin-right: 6px;\n width: 20px;\n height: 20px; }\n .webim-chatwindow .webim-group-name {\n max-width: 64px;\n overflow: hidden;\n text-overflow: ellipsis;\n display: inline-block; }\n\n.webim-chatwindow-title {\n position: absolute;\n top: 0;\n width: 100%;\n height: 40px;\n line-height: 40px;\n text-align: center;\n font-size: 14px; }\n .webim-chatwindow-title i {\n color: #cccccc;\n vertical-align: middle;\n cursor: pointer;\n margin-left: 10px;\n padding-bottom: 22px; }\n .webim-chatwindow-title i.webim-up-icon {\n transform: rotate(180deg); }\n .webim-chatwindow-title i.webim-call-icon {\n position: absolute;\n left: 0;\n top: 0; }\n .webim-chatwindow-title i.webim-accept-icon {\n position: absolute;\n left: 40px;\n top: 0; }\n\n.webim-chatwindow-options {\n border-top: 1px solid #f2f2f2;\n width: 100%;\n z-index: 1;\n position: absolute;\n bottom: 120px;\n left: 0;\n height: 30px;\n line-height: 30px; }\n .webim-chatwindow-options > span {\n margin-left: 6px;\n color: #cccccc;\n cursor: pointer; }\n .webim-chatwindow-options > span:hover {\n color: #4eb1f4; }\n\n.webim-send-btn {\n position: absolute;\n bottom: 0;\n right: 10px;\n width: 80px;\n height: 24px;\n font-size: 12px; }\n\n.webim-chatwindow-msg {\n z-index: 1;\n position: absolute;\n top: 40px;\n bottom: 150px;\n overflow-x: hidden;\n overflow-y: auto;\n box-sizing: border-box;\n padding: 20px 10px;\n width: 100%; }\n\n.webim-send-wrapper > ul {\n z-index: 1;\n position: absolute;\n width: 280px;\n height: 194px;\n bottom: 150px;\n left: -140px;\n border-radius: 2px;\n background: #fff;\n box-sizing: border-box;\n padding: 4px;\n box-shadow: rgba(0, 0, 0, 0.298039) 0px 4px 12px 0px; }\n .webim-send-wrapper > ul li {\n cursor: pointer;\n display: inline-block;\n margin: 2px 3px 0 3px; }\n\n#test {\n position: fixed;\n bottom: 0;\n left: 0;\n z-index: 2222; }\n\n.webim-msg-container {\n overflow: hidden;\n margin: 24px 0; }\n .webim-msg-container > div {\n max-width: 60%;\n overflow: hidden; }\n .webim-msg-container .right > p {\n color: #999999;\n letter-spacing: 1px;\n margin-right: 10px; }\n .webim-msg-container .right .webim-msg-icon {\n color: #b4e4fc;\n right: -40px; }\n .webim-msg-container .right .webim-msg-delivered {\n float: left;\n margin: 6px 2px 0 0;\n background-color: #cccccc; }\n .webim-msg-container .right .webim-msg-value {\n float: right;\n margin: 6px 10px 0 0;\n background-color: #b4e4fc; }\n .webim-msg-container .right .webim-msg-error {\n float: right;\n margin: 6px 10px 0 0; }\n .webim-msg-container .right .webim-msg-header {\n text-align: right; }\n .webim-msg-container .left > p {\n color: #999999;\n letter-spacing: 1px;\n margin-left: 10px; }\n .webim-msg-container .left .webim-msg-icon {\n color: #f1f2ec;\n left: -10px; }\n .webim-msg-container .left .webim-msg-value {\n background-color: #f1f2ec;\n float: left;\n margin: 6px 0 0 10px; }\n .webim-msg-container .left .webim-msg-header {\n text-align: left; }\n\n.webim-msg-icon {\n position: absolute;\n top: 4px;\n font-size: 10px; }\n\n.webim-msg-value {\n position: relative;\n min-height: 30px;\n max-width: calc(100% - 80px);\n border-radius: 4px;\n padding: 6px;\n box-sizing: border-box;\n min-width: 60%; }\n .webim-msg-value video {\n width: 100%; }\n .webim-msg-value.webim-img-msg-wrapper {\n padding: 1px; }\n .webim-msg-value > div,\n .webim-msg-value > pre {\n white-space: pre-wrap;\n word-break: break-all;\n color: #1a1a1a;\n font-size: 14px;\n line-height: 20px;\n margin: 0; }\n .webim-msg-value .emoji {\n width: 32px;\n vertical-align: bottom; }\n .webim-msg-value i {\n display: block;\n font-style: normal;\n margin-left: 40px;\n font-size: 12px;\n color: rgba(0, 0, 0, 0.25); }\n .webim-msg-value a {\n display: block;\n margin-left: 30px;\n margin-top: -28px;\n font-size: 12px;\n color: rgba(0, 0, 0, 0.25);\n text-decoration: none; }\n\n.webim-msg-img {\n max-width: 100%;\n vertical-align: middle;\n cursor: pointer;\n border-radius: 4px; }\n\n.webim-msg-header {\n line-height: 30px;\n margin-bottom: 4px;\n border-bottom: 1px solid rgba(0, 0, 0, 0.15); }\n\n.webim-msg-header-icon {\n vertical-align: middle;\n display: inline-block;\n margin: -46px 4px 0 -4px;\n line-height: 40px;\n color: #868683; }\n\n.webim-msg-name {\n width: calc(100% - 80px);\n display: inline-block;\n height: 40px;\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden; }\n\n.webim-msg-fileSize {\n display: inline-block;\n float: right;\n width: 47px;\n overflow: hidden; }\n\n.webim-img-expand {\n position: fixed;\n width: 100%;\n height: 100%;\n left: 0;\n top: 0;\n background: rgba(0, 0, 0, 0.3);\n z-index: 3; }\n .webim-img-expand img {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n max-width: 90%;\n max-height: 90%;\n margin: auto; }\n\n.webim-audio-slash {\n background-color: transparent;\n position: absolute;\n width: 100%;\n height: 100%;\n top: 0;\n left: 0;\n border-radius: 4px; }\n\n.slash {\n animation: slash 1s infinite;\n -moz-animation: slash 1s infinite;\n -webkit-animation: slash 1s infinite; }\n\n@keyframes slash {\n from {\n background-color: transparent; }\n 50% {\n background-color: rgba(0, 0, 0, 0.1); }\n to {\n background-color: transparent; } }\n\n@-moz-keyframes slash {\n from {\n background-color: transparent; }\n 50% {\n background-color: rgba(0, 0, 0, 0.1); }\n to {\n background-color: transparent; } }\n\n@-webkit-keyframes slash {\n from {\n background-color: transparent; }\n 50% {\n background-color: rgba(0, 0, 0, 0.1); }\n to {\n background-color: transparent; } }\n\n.clearfix:after {\n content: ' ';\n display: table;\n clear: both; }\n\n/*\n * dialog\n */\n.webim-dialog {\n z-index: 3;\n position: absolute;\n width: 400px;\n min-height: 168px;\n top: 20%;\n left: 0;\n right: 0;\n margin: auto;\n border-radius: 2px;\n box-shadow: rgba(0, 0, 0, 0.298039) 0px 0px 8px 0px;\n background-color: white; }\n .webim-dialog h3 {\n line-height: 40px;\n box-sizing: border-box;\n padding-left: 10px;\n border-bottom: 1px solid rgba(0, 0, 0, 0.1);\n font-weight: normal; }\n .webim-dialog .font {\n font-size: 20px;\n position: absolute;\n right: 6px;\n top: 6px;\n width: 20px;\n height: 20px;\n color: rgba(0, 0, 0, 0.1);\n cursor: pointer; }\n .webim-dialog > div {\n border-bottom: 1px solid rgba(0, 0, 0, 0.1);\n padding: 10px 10px 10px; }\n .webim-dialog .webim-dialog-button {\n position: absolute;\n right: 8px;\n bottom: 2px;\n width: 80px;\n height: 26px; }\n .webim-dialog .webim-dialog-button-search {\n bottom: 2px;\n width: 80px;\n height: 30px;\n margin-left: 70px; }\n .webim-dialog .webim-dialog-button-left {\n position: absolute;\n right: 100px;\n bottom: 2px;\n width: 80px;\n height: 26px; }\n .webim-dialog .webim-subscribe-button {\n width: 60px;\n height: 30px;\n margin-left: 10px; }\n .webim-dialog input {\n height: 30px;\n width: 220px; }\n .webim-dialog textarea {\n margin-top: 20px;\n right: 0;\n box-sizing: border-box;\n height: 80px;\n border: 1px solid rgba(0, 0, 0, 0.1);\n width: 220px; }\n .webim-dialog-body {\n min-height: 100px;\n max-height: 126px;\n overflow-y: scroll;\n overflow-x: hidden; }\n .webim-dialog-body-detail {\n width: 100%; }\n .webim-dialog-body-detail span.title {\n font-size: 14px;\n display: block;\n font-weight: 700;\n margin-bottom: 5px; }\n .webim-dialog-body-detail span.content {\n font-size: 12px;\n color: #6a737c; }\n .webim-dialog .webim-dialog-footer {\n padding: 10px;\n position: relative;\n min-height: 20px;\n text-align: right; }\n .webim-dialog .webim-dialog-footer .webim-button {\n position: static;\n margin-right: 10px; }\n .webim-dialog .webim-dialog-footer .webim-group-back {\n position: absolute;\n left: 0;\n height: 67px;\n width: 50px;\n background-color: #f2f2f2;\n top: 0;\n border-radius: 0 2px 2px 0;\n text-align: center;\n cursor: pointer; }\n .webim-dialog .webim-dialog-footer .webim-group-back span {\n line-height: 67px;\n font-size: 30px;\n font-weight: 700;\n color: #868683; }\n\n.webim-dialog-2 {\n height: 450px; }\n\n.webim-friend-requests {\n height: auto; }\n .webim-friend-requests span {\n width: 60%;\n display: inline-block;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap; }\n .webim-friend-requests > div {\n overflow: auto;\n max-height: 400px; }\n\n.webim-body-loading {\n height: 86px;\n width: 400px;\n position: absolute;\n opacity: 0.5;\n z-index: 999;\n margin-top: -10px;\n margin-left: -10px;\n padding-top: 61px; }\n .webim-body-loading img {\n margin: auto;\n display: block;\n width: 30px;\n line-height: inherit; }\n\n/*\n * layer\n */\n.webim-layer {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: 1;\n background-color: rgba(0, 0, 0, 0.25); }\n\n/*\n 说明:\n 下面的css都是为了快速实现功能,覆盖旧有属性的各种trick\n 后期需要找专门的css人员整理一遍,合并入正常的文件,然后删除本文件!\n*/\n/******************* multiple select box ********************/\n.react-multi-select-box-container {\n position: relative;\n width: 240px;\n display: inline-block;\n background-color: #fff;\n border-radius: 4px;\n text-align: left;\n box-shadow: 0 0 2px rgba(0, 0, 0, 0.3); }\n\n.react-multi-select-box {\n padding: 10px 0;\n display: inline-block;\n cursor: pointer;\n border: none;\n width: 100%;\n text-align: left;\n background-color: transparent; }\n .react-multi-select-box::before {\n content: ' ';\n position: absolute;\n z-index: 1;\n height: 20px;\n top: -7px;\n right: 13px;\n border-left: 3px solid transparent;\n border-right: 3px solid transparent;\n border-bottom: 4px solid #a7a8aa; }\n .react-multi-select-box::after {\n content: ' ';\n position: absolute;\n z-index: 1;\n top: 20px;\n right: 13px;\n border-top: 4px solid #a7a8aa;\n border-left: 3px solid transparent;\n border-right: 3px solid transparent; }\n\n.react-multi-select-box-label {\n padding: 0 40px 0 10px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n color: #333;\n line-height: 16px; }\n\n.react-multi-select-box-empty .react-multi-select-box-label {\n color: #c5c5c5; }\n\n.react-multi-select-area {\n position: absolute;\n margin-top: 4px;\n padding: 0 10px;\n height: 225px;\n min-width: 260px;\n border-radius: 4px;\n background-color: #fff;\n z-index: 4;\n box-shadow: 0 0 2px rgba(0, 0, 0, 0.3); }\n\n.react-multi-select-box-hidden {\n display: none; }\n\n.react-multi-select-hide {\n display: none; }\n\n.react-multi-select-panel {\n display: flex;\n height: 185px; }\n\n.react-multi-select-col {\n min-width: 110px;\n overflow-y: auto; }\n .react-multi-select-col .selected-option-row {\n padding: 5px 0;\n cursor: pointer; }\n\n.react-multi-select-sign {\n display: flex;\n flex-direction: column;\n justify-content: center;\n width: 15px; }\n .react-multi-select-sign i {\n width: 6px;\n height: 6px;\n border-top: 2px solid #a9a9a9;\n border-right: 2px solid #a9a9a9;\n -webkit-transform: rotate(45deg);\n -moz-transform: rotate(45deg);\n -o-transform: rotate(45deg);\n transform: rotate(45deg); }\n\n.react-multi-select-area-btn {\n padding: 5px 0;\n height: 40px;\n border-top: 1px solid #eee;\n text-align: center; }\n .react-multi-select-area-btn .eg-btn {\n padding: 4px 20px;\n margin-right: 10px; }\n .react-multi-select-area-btn .eg-btn:last-child {\n margin-right: 0; }\n\n.classification {\n padding: 5px 0;\n cursor: pointer; }\n\n.react-multi-select-list-arrow {\n position: relative;\n display: inline-block;\n vertical-align: middle;\n width: 8px;\n height: 8px; }\n .react-multi-select-list-arrow::before {\n content: ' ';\n position: absolute;\n border-top: 3px solid transparent;\n border-bottom: 3px solid transparent;\n border-left: 4px solid #87c2e5; }\n\n.react-multi-select-list-arrow.expand::before {\n content: ' ';\n position: absolute;\n border-left: 3px solid transparent;\n border-right: 3px solid transparent;\n border-top: 4px solid #87c2e5; }\n\n.react-multi-select-sub-options {\n padding-left: 16px; }\n\n.react-multi-select-list-option:last-child {\n padding-bottom: 0; }\n\n.react-multi-select-list-option .eg-input.checkbox .input-icon {\n margin-right: 2px; }\n\n.react-multi-select-list-option .eg-input.checkbox.active .input-icon {\n fill: #87c2e5; }\n\n.react-multi-select-list-option .react-multi-select-box-option {\n position: relative;\n padding: 5px 0 5px 20px;\n margin: 0;\n cursor: pointer;\n display: block;\n text-decoration: none; }\n .react-multi-select-list-option .react-multi-select-box-option:before {\n content: ' ';\n position: absolute;\n text-align: center;\n line-height: 1.1;\n left: 2px;\n top: 8px;\n height: 12px;\n width: 12px;\n margin-right: 10px;\n border: 1px solid #7B8E9B;\n background: #f9f9f9;\n vertical-align: middle; }\n\n.react-multi-select-list-option .react-multi-select-box-option-selected:before {\n content: '\\2713';\n color: #87c2e5; }\n\n.react-multiple-select-type-name {\n padding: 5px 0 4px 0;\n border-bottom: 1px solid #eee;\n color: #c5c5c5; }\n\n.react-multi-select-btn {\n padding: 4px 20px;\n border-radius: 6px;\n background-color: #307fc8;\n display: inline-block;\n margin-right: 10px;\n margin-bottom: 0;\n text-align: center;\n vertical-align: middle;\n touch-action: manipulation;\n cursor: pointer;\n background-image: none;\n border: 1px solid transparent;\n white-space: nowrap;\n outline: 0;\n text-decoration: none;\n font-weight: normal;\n font-size: 14px;\n line-height: 1.42857143;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n color: #fff;\n border-color: transparent; }\n .react-multi-select-btn:last-child {\n margin-right: 0; }\n\n.react-multi-select-btn-white {\n background-color: #fff;\n color: #333;\n border-color: #d5d5d5; }\n\n/******************* multiple select box ********************/\n.webim-chatwindow .webim-operations-icon {\n top: 5px;\n left: auto;\n right: 10px;\n bottom: 0px; }\n\n.webim-chatwindow .webim-operations {\n left: inherit;\n right: 40px;\n top: 10px;\n bottom: auto;\n z-index: 2; }\n\n.webim-friend-options span.radio_span {\n width: 80px;\n display: inline-block; }\n\n.webim-friend-options input.radio {\n height: 10px;\n width: 20px; }\n\n.webim_isWindowSDK {\n top: 0;\n bottom: 0; }\n\n.webim_isWindowSDK .webim-chat {\n max-width: 100%;\n min-width: 100%;\n max-height: 100%;\n width: 100%; }\n\n.webim-friend-requests-windowSDK {\n width: 500px; }\n\n.webim-friend-requests-windowSDK span {\n width: 100%; }\n\n.webim-msg-value a.dir {\n margin-left: 130px;\n margin-top: -20px; }\n\n.webim-leftbar .username {\n width: 100%;\n overflow: hidden; }\n\n.webim-loading span {\n position: absolute;\n margin: auto;\n left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n width: 200px;\n height: 80px;\n text-align: center; }\n\nspan.red {\n color: #ff2a00; }\n\n.webim-contact-loading {\n width: 24px;\n margin: 0 auto; }\n\n.webim-contact-loading img {\n width: 24px; }\n", ""]); // exports @@ -1176,9 +1176,12 @@ var brief = '', data = msg.data || msg.msg || '', name = this.sendByMe ? Demo.user : msg.from, - targetId = this.sentByMe || msg.type !== 'chat' ? msg.to : msg.from, - targetNode = document.getElementById('wrapper' + targetId), - isStranger = !document.getElementById(targetId) && !document.getElementById('wrapper' + targetId); + targetId = this.sentByMe || msg.type !== 'chat' ? msg.to : msg.from; + var targetNode = document.getElementById('wrapper' + targetId); + if (targetNode == null) { + return; + } + var isStranger = !document.getElementById(targetId) && !document.getElementById('wrapper' + targetId); // TODO: ios/android client doesn't encodeURIComponent yet if (typeof data === "string" && WebIM.config.isWindowSDK) { @@ -21902,7 +21905,7 @@ var uri = WebIM.utils.parseUri(); var curNode = uri.curNode; - var window = []; + var windows = []; if (curNode) { Demo.selected = curNode; if (Demo.chatState['friends']) { @@ -21923,7 +21926,7 @@ chatType: 'singleChat', updateNode: this.updateNode, className: '' }))); - window = Demo.chatState['friends'].chatWindow; + windows = Demo.chatState['friends'].chatWindow; } Demo.conn.listen({ @@ -21957,7 +21960,6 @@ if (WebIM.config.isWindowSDK) { message = eval('(' + message + ')'); } - // 发送已送达回执 if (Demo.selected == message.from) { // 发送已读回执 Demo.api.sendRead(message); @@ -22124,12 +22126,12 @@ }, onDeliveredMessage: function onDeliveredMessage(message) { var msg = document.getElementsByName(message.mid); - if (msg) { - if (msg[0]) msg[0].innerHTML = '已送达'; - } // 记录消息的状态 for (var targetId in Demo.chatRecord) { - if (Demo.chatRecord[targetId].messages[message.mid]) { + if (Demo.chatRecord[targetId].messages[message.mid] && Demo.chatRecord[targetId].messages[message.mid].status != 'Read') { + if (msg) { + if (msg[0]) msg[0].innerHTML = '已送达'; + } Demo.chatRecord[targetId].messages[message.mid].status = 'Delivered'; } } @@ -22137,7 +22139,9 @@ onReadMessage: function onReadMessage(message) { var msg = document.getElementsByName(message.mid); if (msg) { - if (msg[0]) msg[0].innerHTML = '已读'; + if (msg[0]) { + msg[0].innerHTML = '已读'; + } } // 记录消息的状态 for (var targetId in Demo.chatRecord) { @@ -22175,7 +22179,7 @@ blacklist: {}, chatrooms_totalnum: Demo.api.pagesize, contact_loading_show: false, - window: window + windows: windows }; }, @@ -22535,7 +22539,7 @@ var name = friends[i].name; if (name == me.state.curNode) flag = true; } - if (flag) me.setState({ friends: friends });else me.setState({ friends: friends, window: [] }); + if (flag) me.setState({ friends: friends });else me.setState({ friends: friends, windows: [] }); doNotUpdateGroup || me.getGroup(); } }); @@ -22732,9 +22736,9 @@ setChatWindow: function setChatWindow(show) { var cate = Demo.selectedCate; if (!show) { - this.setState({ window: [] }); + this.setState({ windows: [] }); } else { - this.setState({ window: Demo.chatState[cate].chatWindow }); + this.setState({ windows: Demo.chatState[cate].chatWindow }); } }, @@ -23022,7 +23026,7 @@ strangers: this.state.strangers, getChatroom: this.getChatroom, loading: this.state.contact_loading_show }), - this.state.window, + this.state.windows, React.createElement('input', { ref: 'picture', onChange: this.pictureChange, type: 'file', @@ -26563,7 +26567,7 @@ }.bind(this), error: function error() {} }; - Demo.conn.blockSingle(options); + Demo.conn.groupBlockSingle(options); /* username = []; username['1qaz'] = true; @@ -26582,7 +26586,7 @@ }.bind(this), error: function(){} }; - Demo.conn.blockMulti(options); + Demo.conn.groupBlockMulti(options); */ }, @@ -26803,32 +26807,8 @@ 'n' ) ), - React.createElement( - 'div', - { className: 'webim-operation-icon', - style: { display: affiliation == 'owner' ? 'none' : '' } }, - React.createElement( - 'i', - { className: "webim-leftbar-icon font smaller " + className, - style: { display: this.state.admin != 1 ? 'none' : '' }, - onClick: isMuted ? this.removeMute.bind(this, username) : this.mute.bind(this, username), - title: Demo.lan.mute }, - isMuted ? 'e' : 'f' - ) - ), - React.createElement( - 'div', - { className: 'webim-operation-icon', - style: { display: affiliation == 'owner' ? 'none' : '' } }, - React.createElement( - 'i', - { className: "webim-leftbar-icon font smaller " + className, - style: { display: this.state.admin != 1 ? 'none' : '' }, - onClick: isAdmin ? this.removeAdmin.bind(this, username) : this.setAdmin.bind(this, username), - title: Demo.lan.rmAdministrator }, - '\u2193' - ) - ) + React.createElement('div', { className: 'webim-operation-icon', + style: { display: affiliation == 'owner' ? 'none' : '' } }) )); } else { roomMember.push(React.createElement( @@ -26853,32 +26833,8 @@ 'n' ) ), - React.createElement( - 'div', - { className: 'webim-operation-icon', - style: { display: affiliation == 'owner' ? 'none' : '' } }, - React.createElement( - 'i', - { className: "webim-leftbar-icon font smaller " + className, - style: { display: this.state.admin != 1 ? 'none' : '' }, - onClick: isMuted ? this.removeMute.bind(this, username) : this.mute.bind(this, username), - title: Demo.lan.mute }, - isMuted ? 'e' : 'f' - ) - ), - React.createElement( - 'div', - { className: 'webim-operation-icon', - style: { display: affiliation == 'owner' ? 'none' : '' } }, - React.createElement( - 'i', - { className: "webim-leftbar-icon font smaller " + className, - style: { display: this.state.admin != 1 ? 'none' : '' }, - onClick: isAdmin ? this.removeAdmin.bind(this, username) : this.setAdmin.bind(this, username), - title: Demo.lan.administrator }, - '\u2191' - ) - ) + React.createElement('div', { className: 'webim-operation-icon', + style: { display: affiliation == 'owner' ? 'none' : '' } }) )); } } @@ -27894,19 +27850,28 @@ }, onRemoveFromGroupBlackList: function onRemoveFromGroupBlackList(value) { - var me = this; var list = this.state.list; - // Demo.api.blacklist.removeGroupMemberFromBlacklist({ - // roomId: this.props.roomId, - // to: value, - // success: function () { + var options = { + groupId: Demo.selected, + username: value, + success: function () { + delete list[value]; + this.setState({ list: list }); + }.bind(this) + }; + Demo.conn.removeGroupBlockSingle(options); + + // value = ['zzf2', 'zzf3']; + // var options = { + // groupId: Demo.selected, + // username: value, + // success: function(){ // delete list[value]; - // me.setState({ - // list: list - // }) - // } - // }); + // this.setState({list: list}); + // }.bind(this) + // }; + // Demo.conn.removeGroupBlockMulti(options); }, close: function close() { diff --git a/demo/javascript/src/components/chat/chat.js b/demo/javascript/src/components/chat/chat.js index 46d9c526..4d78d246 100755 --- a/demo/javascript/src/components/chat/chat.js +++ b/demo/javascript/src/components/chat/chat.js @@ -77,7 +77,6 @@ module.exports = React.createClass({ message = eval('(' + message + ')'); } if (Demo.selected == message.from) { - console.log("Read"); // 发送已读回执 Demo.api.sendRead(message); } diff --git a/sdk/dist/websdk-1.4.11.js b/sdk/dist/websdk-1.4.11.js index 6412970a..c7c30a37 100644 --- a/sdk/dist/websdk-1.4.11.js +++ b/sdk/dist/websdk-1.4.11.js @@ -9405,6 +9405,9 @@ var Queue = __webpack_require__(249).Queue; var CryptoJS = __webpack_require__(210); var _ = __webpack_require__(183); + var global_mode = ''; + var global_key = ''; + var global_iv = ''; window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL; @@ -9686,6 +9689,40 @@ return rouster; }; + var _getAESKey = function _getAESKey(options, conn) { + // console.log(options) + // console.log('_getAESKey') + var self = this; + var suc = function suc(resp, xhr) { + //{"algorithm": "AES", "mode": "ECB", "padding": "PKCS5Padding", "key": "easemob@@easemob"} + conn.encrypt.mode = resp.data.mode.toLowerCase(); + conn.encrypt.key = CryptoJS.enc.Utf8.parse(resp.data.key); + conn.encrypt.iv = CryptoJS.enc.Utf8.parse('0000000000000000'); + global_mode = resp.data.mode.toLowerCase(); + global_key = CryptoJS.enc.Utf8.parse(resp.data.key); + global_iv = CryptoJS.enc.Utf8.parse('0000000000000000'); + _login(options, conn); + }; + var error = function error(res, xhr, msg) { + console.log('error'); + console.log(res); + }; + + // console.log(conn) + var apiUrl = conn.context.apiUrl; + var appName = conn.context.appName; + var orgName = conn.context.orgName; + var options2 = { + url: apiUrl + '/' + orgName + '/' + appName + '/encrypt_info', + dataType: 'json', + type: 'GET', + headers: { 'Authorization': 'Bearer ' + conn.context.accessToken }, + success: suc || _utils.emptyfn, + error: error || _utils.emptyfn + }; + _utils.ajax(options2); + }; + var _login = function _login(options, conn) { var accessToken = options.access_token || ''; if (accessToken == '') { @@ -9698,6 +9735,12 @@ } conn.context.accessToken = options.access_token; conn.context.accessTokenExpires = options.expires_in; + + if (conn.encrypt.type === 'aes' && !conn.encrypt.mode) { + _getAESKey(options, conn); + return; + } + var stropheConn = null; if (conn.isOpening() && conn.context.stropheConn) { stropheConn = conn.context.stropheConn; @@ -9761,7 +9804,6 @@ }; var _loginCallback = function _loginCallback(status, msg, conn) { - // console.log('stropheConn.connected status=', status, msg) var conflict, error; if (msg === 'conflict') { @@ -10048,6 +10090,7 @@ this.sendQueue = new Queue(); //instead of sending message immediately,cache them in this queue this.intervalId = null; //clearInterval return value this.apiUrl = options.apiUrl || ''; + this.context.apiUrl = this.apiUrl; this.isWindowSDK = options.isWindowSDK || false; this.encrypt = options.encrypt || { encrypt: { type: 'none' } }; this.delivery = options.delivery || false; @@ -10839,9 +10882,9 @@ if (self.encrypt.type === 'base64') { receiveMsg = atob(receiveMsg); } else if (self.encrypt.type === 'aes') { - var key = CryptoJS.enc.Utf8.parse(self.encrypt.key); - var iv = CryptoJS.enc.Utf8.parse(self.encrypt.iv); - var mode = self.encrypt.mode.toLowerCase(); + var key = self.encrypt.key; + var iv = self.encrypt.iv; + var mode = self.encrypt.mode; var option = {}; if (mode === 'cbc') { option = { @@ -10849,7 +10892,7 @@ mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 }; - } else if (mode === 'ebc') { + } else if (mode === 'ecb') { option = { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 @@ -11033,7 +11076,7 @@ id: bodyId, to: msg.from }); - self.send(deliverMessage); + self.send(deliverMessage.body); } } catch (e) { this.onError({ @@ -11188,15 +11231,15 @@ connection.prototype.send = function (messageSource) { var self = this; var message = messageSource; - if (message.type === 'txt') { - if (this.encrypt.type === 'base64') { - message = _.clone(messageSource); + if (message.type === 'txt' && (self.encrypt.type === 'base64' || self.encrypt.type === 'aes')) { + message = _.clone(messageSource); + if (self.encrypt.type === 'base64') { message.msg = btoa(message.msg); - } else if (this.encrypt.type === 'aes') { - message = _.clone(messageSource); - var key = CryptoJS.enc.Utf8.parse(this.encrypt.key); - var iv = CryptoJS.enc.Utf8.parse(this.encrypt.iv); - var mode = this.encrypt.mode.toLowerCase(); + } else if (self.encrypt.type === 'aes') { + console.log(this.encrypt); + var key = self.encrypt.key; + var iv = self.encrypt.iv; + var mode = self.encrypt.mode; var option = {}; if (mode === 'cbc') { option = { @@ -11204,7 +11247,7 @@ mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 }; - } else if (mode === 'ebc') { + } else if (mode === 'ecb') { option = { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 @@ -12729,7 +12772,7 @@ }; // 通过Rest添加用户至群组黑名单(单个) - connection.prototype.blockSingle = function (opt) { + connection.prototype.groupBlockSingle = function (opt) { var groupId = opt.groupId, username = opt.username, options = { @@ -12747,7 +12790,7 @@ }; // 通过Rest添加用户至群组黑名单(批量) - connection.prototype.blockMulti = function (opt) { + connection.prototype.groupBlockMulti = function (opt) { var groupId = opt.groupId, usernames = opt.usernames, requestData = { @@ -12768,8 +12811,41 @@ WebIM.utils.ajax(options); }; - // 通过Rest将用户从群黑名单移除 - connection.prototype.removeBlock = function (opt) {}; + // 通过Rest将用户从群黑名单移除(单个) + connection.prototype.removeGroupBlockSingle = function (opt) { + var groupId = opt.groupId, + username = opt.username, + options = { + url: this.apiUrl + '/' + this.orgName + '/' + this.appName + '/' + 'chatgroups' + '/' + groupId + '/' + 'blocks' + '/' + 'users' + '/' + username, + type: 'DELETE', + dataType: 'json', + headers: { + 'Authorization': 'Bearer ' + this.token, + 'Content-Type': 'application/json' + } + }; + options.success = opt.success || _utils.emptyfn; + options.error = opt.error || _utils.emptyfn; + WebIM.utils.ajax(options); + }; + + // 通过Rest将用户从群黑名单移除(批量) + connection.prototype.removeGroupBlockMulti = function (opt) { + var groupId = opt.groupId, + username = opt.username.join(','), + options = { + url: this.apiUrl + '/' + this.orgName + '/' + this.appName + '/' + 'chatgroups' + '/' + groupId + '/' + 'blocks' + '/' + 'users' + '/' + username, + type: 'DELETE', + dataType: 'json', + headers: { + 'Authorization': 'Bearer ' + this.token, + 'Content-Type': 'application/json' + } + }; + options.success = opt.success || _utils.emptyfn; + options.error = opt.error || _utils.emptyfn; + WebIM.utils.ajax(options); + }; function _setText(valueDom, v) { if ('textContent' in valueDom) { @@ -12801,7 +12877,53 @@ /**************************** debug ****************************/ function logMessage(message) { - WebIM && WebIM.config.isDebug && console.log(WebIM.utils.ts() + '[recv] ', message.data); + var data = message.data; + if (message.data.indexOf('msg') > 0 && message.data.indexOf('type') > 0) { + + var cloneData = new DOMParser().parseFromString(message.data, 'text/xml'); + var body = cloneData.getElementsByTagName('body')[0]; + if (body && body.innerHTML) { + var objValue = JSON.parse(body.innerHTML); + if (objValue.bodies[0].type === 'txt') { + var text = objValue.bodies[0].msg; + if (WebIM.config.encrypt.type === 'base64') { + text = atob(text); + } else if (WebIM.config.encrypt.type === 'aes') { + var key = global_key; + var iv = global_iv; + var mode = global_mode; + var option = {}; + if (mode === 'cbc') { + option = { + iv: iv, + mode: CryptoJS.mode.CBC, + padding: CryptoJS.pad.Pkcs7 + }; + } else if (mode === 'ecb') { + option = { + mode: CryptoJS.mode.ECB, + padding: CryptoJS.pad.Pkcs7 + }; + } + var encryptedBase64Str = text; + var decryptedData = CryptoJS.AES.decrypt(encryptedBase64Str, key, option); + var decryptedStr = decryptedData.toString(CryptoJS.enc.Utf8); + text = decryptedStr; + + // rebuild message.data; + objValue.bodies[0].msg = text; + var objValue = JSON.stringify(objValue); + body.innerHTML = objValue; + if (window.ActiveXObject) { + data = cloneData.xml; + } else { + data = new XMLSerializer().serializeToString(cloneData); + } + } + } + } + } + WebIM && WebIM.config.isDebug && console.log(WebIM.utils.ts() + '[recv] ', data); } if (WebIM && WebIM.config.isDebug) { diff --git a/sdk/src/connection.js b/sdk/src/connection.js index 95df90f3..a7b5c2fe 100755 --- a/sdk/src/connection.js +++ b/sdk/src/connection.js @@ -7,6 +7,9 @@ var _msgHash = {}; var Queue = require('./queue').Queue; var CryptoJS = require('crypto-js'); var _ = require('underscore'); +var global_mode = ''; +var global_key = ''; +var global_iv = ''; window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL; @@ -302,13 +305,14 @@ var _getAESKey = function (options, conn) { // console.log('_getAESKey') var self = this; var suc = function (resp, xhr) { - console.log('suc') - console.log(resp) //{"algorithm": "AES", "mode": "ECB", "padding": "PKCS5Padding", "key": "easemob@@easemob"} - conn.encrypt.mode = resp.data.mode.toLowerCase() - conn.encrypt.key = CryptoJS.enc.Utf8.parse(resp.data.key) - conn.encrypt.iv = CryptoJS.enc.Utf8.parse('0000000000000000') - _login(options, conn) + conn.encrypt.mode = resp.data.mode.toLowerCase(); + conn.encrypt.key = CryptoJS.enc.Utf8.parse(resp.data.key); + conn.encrypt.iv = CryptoJS.enc.Utf8.parse('0000000000000000'); + global_mode = resp.data.mode.toLowerCase(); + global_key = CryptoJS.enc.Utf8.parse(resp.data.key); + global_iv = CryptoJS.enc.Utf8.parse('0000000000000000'); + _login(options, conn); }; var error = function (res, xhr, msg) { console.log('error') @@ -330,8 +334,7 @@ var _getAESKey = function (options, conn) { }; _utils.ajax(options2); -} - +}; var _login = function (options, conn) { var accessToken = options.access_token || ''; @@ -446,7 +449,6 @@ var _loginCallback = function (status, msg, conn) { conn.handelSendQueue(); }, 200); var handleMessage = function (msginfo) { - console.log("MessageInfo: ", msginfo); var delivery = msginfo.getElementsByTagName('delivery'); var acked = msginfo.getElementsByTagName('acked'); if (delivery.length) { @@ -3612,7 +3614,54 @@ WebIM.doQuery = function (str, suc, fail) { /**************************** debug ****************************/ function logMessage(message) { - WebIM && WebIM.config.isDebug && console.log(WebIM.utils.ts() + '[recv] ', message.data); + var data = message.data; + if(message.data.indexOf('msg') > 0 + && message.data.indexOf('type') > 0){ + + var cloneData = new DOMParser().parseFromString(message.data, 'text/xml'); + var body = cloneData.getElementsByTagName('body')[0]; + if(body && body.innerHTML){ + var objValue = JSON.parse(body.innerHTML) + if(objValue.bodies[0].type === 'txt'){ + var text = objValue.bodies[0].msg; + if (WebIM.config.encrypt.type === 'base64') { + text = atob(text); + } else if (WebIM.config.encrypt.type === 'aes') { + var key = global_key; + var iv = global_iv; + var mode = global_mode; + var option = {}; + if (mode === 'cbc') { + option = { + iv: iv, + mode: CryptoJS.mode.CBC, + padding: CryptoJS.pad.Pkcs7 + } + } else if (mode === 'ecb') { + option = { + mode: CryptoJS.mode.ECB, + padding: CryptoJS.pad.Pkcs7 + } + } + var encryptedBase64Str = text; + var decryptedData = CryptoJS.AES.decrypt(encryptedBase64Str, key, option); + var decryptedStr = decryptedData.toString(CryptoJS.enc.Utf8); + text = decryptedStr; + + // rebuild message.data; + objValue.bodies[0].msg = text; + var objValue = JSON.stringify(objValue); + body.innerHTML = objValue; + if (window.ActiveXObject) { + data = cloneData.xml; + }else{ + data = new XMLSerializer().serializeToString(cloneData); + } + } + } + } + } + WebIM && WebIM.config.isDebug && console.log(WebIM.utils.ts() + '[recv] ', data); } if (WebIM && WebIM.config.isDebug) { @@ -3631,4 +3680,4 @@ module.exports = WebIM; if (module.hot) { module.hot.accept(); -} \ No newline at end of file +} From 8885ee6526e017a1433e7dee4489c293211bb9bd Mon Sep 17 00:00:00 2001 From: clock <18209263592@163.com> Date: Fri, 9 Jun 2017 15:24:11 +0800 Subject: [PATCH 06/23] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=94=B6=E5=88=B0cmd?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=97=B6=E5=B4=A9=E6=BA=83=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/javascript/dist/demo-1.4.11.js | 6 ++++-- demo/javascript/src/api.js | 5 +++-- demo/javascript/src/components/chat/chat.js | 1 + sdk/dist/websdk-1.4.11.js | 8 -------- sdk/src/connection.js | 8 -------- 5 files changed, 8 insertions(+), 20 deletions(-) diff --git a/demo/javascript/dist/demo-1.4.11.js b/demo/javascript/dist/demo-1.4.11.js index 3cb4fe05..dd22db28 100644 --- a/demo/javascript/dist/demo-1.4.11.js +++ b/demo/javascript/dist/demo-1.4.11.js @@ -1165,7 +1165,7 @@ }, appendMsg: function appendMsg(msg, type, status, nid) { - if (!msg) { + if (!msg || type === 'cmd') { return; } msg.from = msg.from || Demo.user; @@ -1179,7 +1179,8 @@ targetId = this.sentByMe || msg.type !== 'chat' ? msg.to : msg.from; var targetNode = document.getElementById('wrapper' + targetId); if (targetNode == null) { - return; + console.log("ScareCrow Return"); + // return } var isStranger = !document.getElementById(targetId) && !document.getElementById('wrapper' + targetId); @@ -21957,6 +21958,7 @@ // Demo.api.logout(); }, onTextMessage: function onTextMessage(message) { + console.log('onTextMessage'); if (WebIM.config.isWindowSDK) { message = eval('(' + message + ')'); } diff --git a/demo/javascript/src/api.js b/demo/javascript/src/api.js index 05af8d05..fc8494d0 100755 --- a/demo/javascript/src/api.js +++ b/demo/javascript/src/api.js @@ -379,7 +379,7 @@ module.exports = { }, appendMsg: function (msg, type, status, nid) { - if (!msg) { + if (!msg || type === 'cmd') { return; } msg.from = msg.from || Demo.user; @@ -393,7 +393,8 @@ module.exports = { targetId = this.sentByMe || msg.type !== 'chat' ? msg.to : msg.from; var targetNode = document.getElementById('wrapper' + targetId) if (targetNode == null) { - return + console.log("ScareCrow Return"); + // return } var isStranger = !document.getElementById(targetId) && !document.getElementById('wrapper' + targetId); diff --git a/demo/javascript/src/components/chat/chat.js b/demo/javascript/src/components/chat/chat.js index 4d78d246..e1dfd837 100755 --- a/demo/javascript/src/components/chat/chat.js +++ b/demo/javascript/src/components/chat/chat.js @@ -73,6 +73,7 @@ module.exports = React.createClass({ // Demo.api.logout(); }, onTextMessage: function (message) { + console.log('onTextMessage'); if (WebIM.config.isWindowSDK) { message = eval('(' + message + ')'); } diff --git a/sdk/dist/websdk-1.4.11.js b/sdk/dist/websdk-1.4.11.js index c7c30a37..bf128cf0 100644 --- a/sdk/dist/websdk-1.4.11.js +++ b/sdk/dist/websdk-1.4.11.js @@ -12215,14 +12215,6 @@ * * @param options */ - // - // - // - // - // - // - // - // connection.prototype.leaveGroup = function (options) { var sucFn = options.success || _utils.emptyfn; var errFn = options.error || _utils.emptyfn; diff --git a/sdk/src/connection.js b/sdk/src/connection.js index a7b5c2fe..d7d908b0 100755 --- a/sdk/src/connection.js +++ b/sdk/src/connection.js @@ -2923,14 +2923,6 @@ connection.prototype.leaveGroupBySelf = function (options) { * * @param options */ -// -// -// -// -// -// -// -// connection.prototype.leaveGroup = function (options) { var sucFn = options.success || _utils.emptyfn; var errFn = options.error || _utils.emptyfn; From 5ac68b06bdf1fb658fc73b4f22729682ca1ad229 Mon Sep 17 00:00:00 2001 From: wk3368 Date: Sat, 10 Jun 2017 00:09:11 +0800 Subject: [PATCH 07/23] =?UTF-8?q?=E6=89=80=E6=9C=89=E4=B8=8B=E8=A1=8C?= =?UTF-8?q?=E5=AD=98=E5=88=B0chrome=E7=9A=84LocalStorage=20=E8=AE=BF?= =?UTF-8?q?=E9=97=AEdownload.html=E4=B8=8B=E8=BD=BD=E5=88=B0=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- download.html | 12 ++++++++++++ publish.sh | 2 +- sdk/src/connection.js | 22 ++++++++++++++++------ 3 files changed, 29 insertions(+), 7 deletions(-) create mode 100755 download.html diff --git a/download.html b/download.html new file mode 100755 index 00000000..dca7f2bc --- /dev/null +++ b/download.html @@ -0,0 +1,12 @@ + diff --git a/publish.sh b/publish.sh index 44d25a69..ad74c828 100755 --- a/publish.sh +++ b/publish.sh @@ -36,7 +36,7 @@ cp favicon.ico publish/ cp index.html publish/ cp CHANGELOG.md publish/ cp package.json publish/ - +cp download.html publish/ cp webpack.config.js publish/ cp README.md publish/ cp .babelrc publish/ diff --git a/sdk/src/connection.js b/sdk/src/connection.js index d7d908b0..d1cf94f2 100755 --- a/sdk/src/connection.js +++ b/sdk/src/connection.js @@ -3605,16 +3605,21 @@ WebIM.doQuery = function (str, suc, fail) { }; /**************************** debug ****************************/ +var recv_num = 0 +if (window.localStorage) { + window.localStorage.clear() +} function logMessage(message) { + var data = message.data; - if(message.data.indexOf('msg') > 0 - && message.data.indexOf('type') > 0){ + if (message.data.indexOf('msg') > 0 + && message.data.indexOf('type') > 0) { var cloneData = new DOMParser().parseFromString(message.data, 'text/xml'); var body = cloneData.getElementsByTagName('body')[0]; - if(body && body.innerHTML){ + if (body && body.innerHTML) { var objValue = JSON.parse(body.innerHTML) - if(objValue.bodies[0].type === 'txt'){ + if (objValue.bodies[0].type === 'txt') { var text = objValue.bodies[0].msg; if (WebIM.config.encrypt.type === 'base64') { text = atob(text); @@ -3646,14 +3651,19 @@ function logMessage(message) { body.innerHTML = objValue; if (window.ActiveXObject) { data = cloneData.xml; - }else{ + } else { data = new XMLSerializer().serializeToString(cloneData); } } } } } - WebIM && WebIM.config.isDebug && console.log(WebIM.utils.ts() + '[recv] ', data); + // WebIM && WebIM.config.isDebug && console.log(WebIM.utils.ts() + '[recv] ', data); + if (WebIM && WebIM.config.isDebug) { + if (window.localStorage) { + window.localStorage.setItem(recv_num++, data) + } + } } if (WebIM && WebIM.config.isDebug) { From 5b53fdb6f4ae245d02a201595b55440f52b5b692 Mon Sep 17 00:00:00 2001 From: clock <18209263592@163.com> Date: Sat, 10 Jun 2017 10:16:18 +0800 Subject: [PATCH 08/23] =?UTF-8?q?Download=E7=9A=84Log=E5=8F=AF=E6=8E=92?= =?UTF-8?q?=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- download.html | 13 +++++++++++-- sdk/dist/websdk-1.4.11.js | 14 +++++++++++++- sdk/src/connection.js | 2 ++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/download.html b/download.html index dca7f2bc..e6da3ae0 100755 --- a/download.html +++ b/download.html @@ -1,9 +1,18 @@ + diff --git a/sdk/dist/jsencrypt.min.js b/sdk/dist/jsencrypt.min.js new file mode 100755 index 00000000..273b8efa --- /dev/null +++ b/sdk/dist/jsencrypt.min.js @@ -0,0 +1,73 @@ +/*! JSEncrypt v2.3.1 | https://npmcdn.com/jsencrypt@2.3.1/LICENSE.txt */ +!function(t,e){"function"==typeof define&&define.amd?define(["exports"],e):e("object"==typeof exports&&"string"!=typeof exports.nodeName?module.exports:t)}(this,function(t){function e(t,e,i){null!=t&&("number"==typeof t?this.fromNumber(t,e,i):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}function i(){return new e(null)}function r(t,e,i,r,s,n){for(;--n>=0;){var o=e*this[t++]+i[r]+s;s=Math.floor(o/67108864),i[r++]=67108863&o}return s}function s(t,e,i,r,s,n){for(var o=32767&e,h=e>>15;--n>=0;){var a=32767&this[t],u=this[t++]>>15,c=h*a+u*o;a=o*a+((32767&c)<<15)+i[r]+(1073741823&s),s=(a>>>30)+(c>>>15)+h*u+(s>>>30),i[r++]=1073741823&a}return s}function n(t,e,i,r,s,n){for(var o=16383&e,h=e>>14;--n>=0;){var a=16383&this[t],u=this[t++]>>14,c=h*a+u*o;a=o*a+((16383&c)<<14)+i[r]+s,s=(a>>28)+(c>>14)+h*u,i[r++]=268435455&a}return s}function o(t){return Be.charAt(t)}function h(t,e){var i=Ke[t.charCodeAt(e)];return null==i?-1:i}function a(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s}function u(t){this.t=1,this.s=0>t?-1:0,t>0?this[0]=t:-1>t?this[0]=t+this.DV:this.t=0}function c(t){var e=i();return e.fromInt(t),e}function f(t,i){var r;if(16==i)r=4;else if(8==i)r=3;else if(256==i)r=8;else if(2==i)r=1;else if(32==i)r=5;else{if(4!=i)return void this.fromRadix(t,i);r=2}this.t=0,this.s=0;for(var s=t.length,n=!1,o=0;--s>=0;){var a=8==r?255&t[s]:h(t,s);0>a?"-"==t.charAt(s)&&(n=!0):(n=!1,0==o?this[this.t++]=a:o+r>this.DB?(this[this.t-1]|=(a&(1<>this.DB-o):this[this.t-1]|=a<=this.DB&&(o-=this.DB))}8==r&&0!=(128&t[0])&&(this.s=-1,o>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t}function l(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var i,r=(1<0)for(a>a)>0&&(s=!0,n=o(i));h>=0;)e>a?(i=(this[h]&(1<>(a+=this.DB-e)):(i=this[h]>>(a-=e)&r,0>=a&&(a+=this.DB,--h)),i>0&&(s=!0),s&&(n+=o(i));return s?n:"0"}function d(){var t=i();return e.ZERO.subTo(this,t),t}function g(){return this.s<0?this.negate():this}function m(t){var e=this.s-t.s;if(0!=e)return e;var i=this.t;if(e=i-t.t,0!=e)return this.s<0?-e:e;for(;--i>=0;)if(0!=(e=this[i]-t[i]))return e;return 0}function y(t){var e,i=1;return 0!=(e=t>>>16)&&(t=e,i+=16),0!=(e=t>>8)&&(t=e,i+=8),0!=(e=t>>4)&&(t=e,i+=4),0!=(e=t>>2)&&(t=e,i+=2),0!=(e=t>>1)&&(t=e,i+=1),i}function b(){return this.t<=0?0:this.DB*(this.t-1)+y(this[this.t-1]^this.s&this.DM)}function T(t,e){var i;for(i=this.t-1;i>=0;--i)e[i+t]=this[i];for(i=t-1;i>=0;--i)e[i]=0;e.t=this.t+t,e.s=this.s}function S(t,e){for(var i=t;i=0;--i)e[i+o+1]=this[i]>>s|h,h=(this[i]&n)<=0;--i)e[i]=0;e[o]=h,e.t=this.t+o+1,e.s=this.s,e.clamp()}function E(t,e){e.s=this.s;var i=Math.floor(t/this.DB);if(i>=this.t)return void(e.t=0);var r=t%this.DB,s=this.DB-r,n=(1<>r;for(var o=i+1;o>r;r>0&&(e[this.t-i-1]|=(this.s&n)<i;)r+=this[i]-t[i],e[i++]=r&this.DM,r>>=this.DB;if(t.t>=this.DB;r+=this.s}else{for(r+=this.s;i>=this.DB;r-=t.s}e.s=0>r?-1:0,-1>r?e[i++]=this.DV+r:r>0&&(e[i++]=r),e.t=i,e.clamp()}function w(t,i){var r=this.abs(),s=t.abs(),n=r.t;for(i.t=n+s.t;--n>=0;)i[n]=0;for(n=0;n=0;)t[i]=0;for(i=0;i=e.DV&&(t[i+e.t]-=e.DV,t[i+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(i,e[i],t,2*i,0,1)),t.s=0,t.clamp()}function B(t,r,s){var n=t.abs();if(!(n.t<=0)){var o=this.abs();if(o.t0?(n.lShiftTo(c,h),o.lShiftTo(c,s)):(n.copyTo(h),o.copyTo(s));var f=h.t,p=h[f-1];if(0!=p){var l=p*(1<1?h[f-2]>>this.F2:0),d=this.FV/l,g=(1<=0&&(s[s.t++]=1,s.subTo(T,s)),e.ONE.dlShiftTo(f,T),T.subTo(h,h);h.t=0;){var S=s[--v]==p?this.DM:Math.floor(s[v]*d+(s[v-1]+m)*g);if((s[v]+=h.am(0,S,s,b,0,f))0&&s.rShiftTo(c,s),0>a&&e.ZERO.subTo(s,s)}}}function K(t){var r=i();return this.abs().divRemTo(t,null,r),this.s<0&&r.compareTo(e.ZERO)>0&&t.subTo(r,r),r}function A(t){this.m=t}function U(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t}function O(t){return t}function V(t){t.divRemTo(this.m,null,t)}function N(t,e,i){t.multiplyTo(e,i),this.reduce(i)}function J(t,e){t.squareTo(e),this.reduce(e)}function I(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return e=e*(2-(15&t)*e)&15,e=e*(2-(255&t)*e)&255,e=e*(2-((65535&t)*e&65535))&65535,e=e*(2-t*e%this.DV)%this.DV,e>0?this.DV-e:-e}function P(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<0&&this.m.subTo(r,r),r}function L(t){var e=i();return t.copyTo(e),this.reduce(e),e}function q(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(i=e+this.m.t,t[i]+=this.m.am(0,r,t,e,0,this.m.t);t[i]>=t.DV;)t[i]-=t.DV,t[++i]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)}function C(t,e){t.squareTo(e),this.reduce(e)}function H(t,e,i){t.multiplyTo(e,i),this.reduce(i)}function j(){return 0==(this.t>0?1&this[0]:this.s)}function k(t,r){if(t>4294967295||1>t)return e.ONE;var s=i(),n=i(),o=r.convert(this),h=y(t)-1;for(o.copyTo(s);--h>=0;)if(r.sqrTo(s,n),(t&1<0)r.mulTo(n,o,s);else{var a=s;s=n,n=a}return r.revert(s)}function F(t,e){var i;return i=256>t||e.isEven()?new A(e):new P(e),this.exp(t,i)} +// Copyright (c) 2005-2009 Tom Wu +// All Rights Reserved. +// See "LICENSE" for details. +function _(){var t=i();return this.copyTo(t),t}function z(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<>24}function G(){return 0==this.t?this.s:this[0]<<16>>16}function $(t){return Math.floor(Math.LN2*this.DB/Math.log(t))}function Y(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1}function W(t){if(null==t&&(t=10),0==this.signum()||2>t||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),s=c(r),n=i(),o=i(),h="";for(this.divRemTo(s,n,o);n.signum()>0;)h=(r+o.intValue()).toString(t).substr(1)+h,n.divRemTo(s,n,o);return o.intValue().toString(t)+h}function Q(t,i){this.fromInt(0),null==i&&(i=10);for(var r=this.chunkSize(i),s=Math.pow(i,r),n=!1,o=0,a=0,u=0;uc?"-"==t.charAt(u)&&0==this.signum()&&(n=!0):(a=i*a+c,++o>=r&&(this.dMultiply(s),this.dAddOffset(a,0),o=0,a=0))}o>0&&(this.dMultiply(Math.pow(i,o)),this.dAddOffset(a,0)),n&&e.ZERO.subTo(this,this)}function X(t,i,r){if("number"==typeof i)if(2>t)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(e.ONE.shiftLeft(t-1),ht,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(i);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(e.ONE.shiftLeft(t-1),this);else{var s=new Array,n=7&t;s.length=(t>>3)+1,i.nextBytes(s),n>0?s[0]&=(1<0)for(r>r)!=(this.s&this.DM)>>r&&(e[s++]=i|this.s<=0;)8>r?(i=(this[t]&(1<>(r+=this.DB-8)):(i=this[t]>>(r-=8)&255,0>=r&&(r+=this.DB,--t)),0!=(128&i)&&(i|=-256),0==s&&(128&this.s)!=(128&i)&&++s,(s>0||i!=this.s)&&(e[s++]=i);return e}function et(t){return 0==this.compareTo(t)}function it(t){return this.compareTo(t)<0?this:t}function rt(t){return this.compareTo(t)>0?this:t}function st(t,e,i){var r,s,n=Math.min(t.t,this.t);for(r=0;n>r;++r)i[r]=e(this[r],t[r]);if(t.tt?this.rShiftTo(-t,e):this.lShiftTo(t,e),e}function gt(t){var e=i();return 0>t?this.lShiftTo(-t,e):this.rShiftTo(t,e),e}function mt(t){if(0==t)return-1;var e=0;return 0==(65535&t)&&(t>>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function yt(){for(var t=0;t=this.t?0!=this.s:0!=(this[e]&1<i;)r+=this[i]+t[i],e[i++]=r&this.DM,r>>=this.DB;if(t.t>=this.DB;r+=this.s}else{for(r+=this.s;i>=this.DB;r+=t.s}e.s=0>r?-1:0,r>0?e[i++]=r:-1>r&&(e[i++]=this.DV+r),e.t=i,e.clamp()}function xt(t){var e=i();return this.addTo(t,e),e}function Bt(t){var e=i();return this.subTo(t,e),e}function Kt(t){var e=i();return this.multiplyTo(t,e),e}function At(){var t=i();return this.squareTo(t),t}function Ut(t){var e=i();return this.divRemTo(t,e,null),e}function Ot(t){var e=i();return this.divRemTo(t,null,e),e}function Vt(t){var e=i(),r=i();return this.divRemTo(t,e,r),new Array(e,r)}function Nt(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()}function Jt(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}}function It(){}function Pt(t){return t}function Mt(t,e,i){t.multiplyTo(e,i)}function Lt(t,e){t.squareTo(e)}function qt(t){return this.exp(t,new It)}function Ct(t,e,i){var r=Math.min(this.t+t.t,e);for(i.s=0,i.t=r;r>0;)i[--r]=0;var s;for(s=i.t-this.t;s>r;++r)i[r+this.t]=this.am(0,t[r],i,r,0,this.t);for(s=Math.min(t.t,e);s>r;++r)this.am(0,t[r],i,r,0,e-r);i.clamp()}function Ht(t,e,i){--e;var r=i.t=this.t+t.t-e;for(i.s=0;--r>=0;)i[r]=0;for(r=Math.max(e-this.t,0);r2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=i();return t.copyTo(e),this.reduce(e),e}function Ft(t){return t}function _t(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)}function zt(t,e){t.squareTo(e),this.reduce(e)}function Zt(t,e,i){t.multiplyTo(e,i),this.reduce(i)}function Gt(t,e){var r,s,n=t.bitLength(),o=c(1);if(0>=n)return o;r=18>n?1:48>n?3:144>n?4:768>n?5:6,s=8>n?new A(e):e.isEven()?new jt(e):new P(e);var h=new Array,a=3,u=r-1,f=(1<1){var p=i();for(s.sqrTo(h[1],p);f>=a;)h[a]=i(),s.mulTo(p,h[a-2],h[a]),a+=2}var l,d,g=t.t-1,m=!0,v=i();for(n=y(t[g])-1;g>=0;){for(n>=u?l=t[g]>>n-u&f:(l=(t[g]&(1<0&&(l|=t[g-1]>>this.DB+n-u)),a=r;0==(1&l);)l>>=1,--a;if((n-=a)<0&&(n+=this.DB,--g),m)h[l].copyTo(o),m=!1;else{for(;a>1;)s.sqrTo(o,v),s.sqrTo(v,o),a-=2;a>0?s.sqrTo(o,v):(d=o,o=v,v=d),s.mulTo(v,h[l],o)}for(;g>=0&&0==(t[g]&1<n)return e;for(n>s&&(n=s),n>0&&(e.rShiftTo(n,e),i.rShiftTo(n,i));e.signum()>0;)(s=e.getLowestSetBit())>0&&e.rShiftTo(s,e),(s=i.getLowestSetBit())>0&&i.rShiftTo(s,i),e.compareTo(i)>=0?(e.subTo(i,e),e.rShiftTo(1,e)):(i.subTo(e,i),i.rShiftTo(1,i));return n>0&&i.lShiftTo(n,i),i}function Yt(t){if(0>=t)return 0;var e=this.DV%t,i=this.s<0?t-1:0;if(this.t>0)if(0==e)i=this[0]%t;else for(var r=this.t-1;r>=0;--r)i=(e*i+this[r])%t;return i}function Wt(t){var i=t.isEven();if(this.isEven()&&i||0==t.signum())return e.ZERO;for(var r=t.clone(),s=this.clone(),n=c(1),o=c(0),h=c(0),a=c(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),i?(n.isEven()&&o.isEven()||(n.addTo(this,n),o.subTo(t,o)),n.rShiftTo(1,n)):o.isEven()||o.subTo(t,o),o.rShiftTo(1,o);for(;s.isEven();)s.rShiftTo(1,s),i?(h.isEven()&&a.isEven()||(h.addTo(this,h),a.subTo(t,a)),h.rShiftTo(1,h)):a.isEven()||a.subTo(t,a),a.rShiftTo(1,a);r.compareTo(s)>=0?(r.subTo(s,r),i&&n.subTo(h,n),o.subTo(a,o)):(s.subTo(r,s),i&&h.subTo(n,h),a.subTo(o,a))}return 0!=s.compareTo(e.ONE)?e.ZERO:a.compareTo(t)>=0?a.subtract(t):a.signum()<0?(a.addTo(t,a),a.signum()<0?a.add(t):a):a}function Qt(t){var e,i=this.abs();if(1==i.t&&i[0]<=Ae[Ae.length-1]){for(e=0;er;)r*=Ae[s++];for(r=i.modInt(r);s>e;)if(r%Ae[e++]==0)return!1}return i.millerRabin(t)}function Xt(t){var r=this.subtract(e.ONE),s=r.getLowestSetBit();if(0>=s)return!1;var n=r.shiftRight(s);t=t+1>>1,t>Ae.length&&(t=Ae.length);for(var o=i(),h=0;t>h;++h){o.fromInt(Ae[Math.floor(Math.random()*Ae.length)]);var a=o.modPow(n,this);if(0!=a.compareTo(e.ONE)&&0!=a.compareTo(r)){for(var u=1;u++e;++e)this.S[e]=e;for(i=0,e=0;256>e;++e)i=i+this.S[e]+t[e%t.length]&255,r=this.S[e],this.S[e]=this.S[i],this.S[i]=r;this.i=0,this.j=0}function ie(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]}function re(){return new te}function se(){if(null==Oe){for(Oe=re();Je>Ne;){var t=Math.floor(65536*Math.random());Ve[Ne++]=255&t}for(Oe.init(Ve),Ne=0;Ne=0&&i>0;){var n=t.charCodeAt(s--);128>n?r[--i]=n:n>127&&2048>n?(r[--i]=63&n|128,r[--i]=n>>6|192):(r[--i]=63&n|128,r[--i]=n>>6&63|128,r[--i]=n>>12|224)}r[--i]=0;for(var o=new oe,h=new Array;i>2;){for(h[0]=0;0==h[0];)o.nextBytes(h);r[--i]=h[0]}return r[--i]=2,r[--i]=0,new e(r)}function ue(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function ce(t,e){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=he(t,16),this.e=parseInt(e,16)):console.error("Invalid RSA public key")}function fe(t){return t.modPowInt(this.e,this.n)}function pe(t){var e=ae(t,this.n.bitLength()+7>>3);if(null==e)return null;var i=this.doPublic(e);if(null==i)return null;var r=i.toString(16);return 0==(1&r.length)?r:"0"+r}function le(t,e){for(var i=t.toByteArray(),r=0;r=i.length)return null;for(var s="";++rn?s+=String.fromCharCode(n):n>191&&224>n?(s+=String.fromCharCode((31&n)<<6|63&i[r+1]),++r):(s+=String.fromCharCode((15&n)<<12|(63&i[r+1])<<6|63&i[r+2]),r+=2)}return s}function de(t,e,i){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=he(t,16),this.e=parseInt(e,16),this.d=he(i,16)):console.error("Invalid RSA private key")}function ge(t,e,i,r,s,n,o,h){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=he(t,16),this.e=parseInt(e,16),this.d=he(i,16),this.p=he(r,16),this.q=he(s,16),this.dmp1=he(n,16),this.dmq1=he(o,16),this.coeff=he(h,16)):console.error("Invalid RSA private key")}function me(t,i){var r=new oe,s=t>>1;this.e=parseInt(i,16);for(var n=new e(i,16);;){for(;this.p=new e(t-s,1,r),0!=this.p.subtract(e.ONE).gcd(n).compareTo(e.ONE)||!this.p.isProbablePrime(10););for(;this.q=new e(s,1,r),0!=this.q.subtract(e.ONE).gcd(n).compareTo(e.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var o=this.p;this.p=this.q,this.q=o}var h=this.p.subtract(e.ONE),a=this.q.subtract(e.ONE),u=h.multiply(a);if(0==u.gcd(n).compareTo(e.ONE)){this.n=this.p.multiply(this.q),this.d=n.modInverse(u),this.dmp1=this.d.mod(h),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}}function ye(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),i=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(i)<0;)e=e.add(this.p);return e.subtract(i).multiply(this.coeff).mod(this.p).multiply(this.q).add(i)}function ve(t){var e=he(t,16),i=this.doPrivate(e);return null==i?null:le(i,this.n.bitLength()+7>>3)}function be(t){var e,i,r="";for(e=0;e+3<=t.length;e+=3)i=parseInt(t.substring(e,e+3),16),r+=Le.charAt(i>>6)+Le.charAt(63&i);for(e+1==t.length?(i=parseInt(t.substring(e,e+1),16),r+=Le.charAt(i<<2)):e+2==t.length&&(i=parseInt(t.substring(e,e+2),16),r+=Le.charAt(i>>2)+Le.charAt((3&i)<<4));(3&r.length)>0;)r+=qe;return r}function Te(t){var e,i,r="",s=0;for(e=0;e>2),i=3&v,s=1):1==s?(r+=o(i<<2|v>>4),i=15&v,s=2):2==s?(r+=o(i),r+=o(v>>2),i=3&v,s=3):(r+=o(i<<2|v>>4),r+=o(15&v),s=0));return 1==s&&(r+=o(i<<2)),r} +// Copyright (c) 2005 Tom Wu +// All Rights Reserved. +// See "LICENSE" for details. +var Se,Re=0xdeadbeefcafe,Ee=15715070==(16777215&Re);Ee&&"Microsoft Internet Explorer"==navigator.appName?(e.prototype.am=s,Se=30):Ee&&"Netscape"!=navigator.appName?(e.prototype.am=r,Se=26):(e.prototype.am=n,Se=28),e.prototype.DB=Se,e.prototype.DM=(1<=xe;++xe)Ke[we++]=xe;for(we="a".charCodeAt(0),xe=10;36>xe;++xe)Ke[we++]=xe;for(we="A".charCodeAt(0),xe=10;36>xe;++xe)Ke[we++]=xe;A.prototype.convert=U,A.prototype.revert=O,A.prototype.reduce=V,A.prototype.mulTo=N,A.prototype.sqrTo=J,P.prototype.convert=M,P.prototype.revert=L,P.prototype.reduce=q,P.prototype.mulTo=H,P.prototype.sqrTo=C,e.prototype.copyTo=a,e.prototype.fromInt=u,e.prototype.fromString=f,e.prototype.clamp=p,e.prototype.dlShiftTo=T,e.prototype.drShiftTo=S,e.prototype.lShiftTo=R,e.prototype.rShiftTo=E,e.prototype.subTo=D,e.prototype.multiplyTo=w,e.prototype.squareTo=x,e.prototype.divRemTo=B,e.prototype.invDigit=I,e.prototype.isEven=j,e.prototype.exp=k,e.prototype.toString=l,e.prototype.negate=d,e.prototype.abs=g,e.prototype.compareTo=m,e.prototype.bitLength=b,e.prototype.mod=K,e.prototype.modPowInt=F,e.ZERO=c(0),e.ONE=c(1),It.prototype.convert=Pt,It.prototype.revert=Pt,It.prototype.mulTo=Mt,It.prototype.sqrTo=Lt,jt.prototype.convert=kt,jt.prototype.revert=Ft,jt.prototype.reduce=_t,jt.prototype.mulTo=Zt,jt.prototype.sqrTo=zt;var Ae=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],Ue=(1<<26)/Ae[Ae.length-1];e.prototype.chunkSize=$,e.prototype.toRadix=W,e.prototype.fromRadix=Q,e.prototype.fromNumber=X,e.prototype.bitwiseTo=st,e.prototype.changeBit=St,e.prototype.addTo=wt,e.prototype.dMultiply=Nt,e.prototype.dAddOffset=Jt,e.prototype.multiplyLowerTo=Ct,e.prototype.multiplyUpperTo=Ht,e.prototype.modInt=Yt,e.prototype.millerRabin=Xt,e.prototype.clone=_,e.prototype.intValue=z,e.prototype.byteValue=Z,e.prototype.shortValue=G,e.prototype.signum=Y,e.prototype.toByteArray=tt,e.prototype.equals=et,e.prototype.min=it,e.prototype.max=rt,e.prototype.and=ot,e.prototype.or=at,e.prototype.xor=ct,e.prototype.andNot=pt,e.prototype.not=lt,e.prototype.shiftLeft=dt,e.prototype.shiftRight=gt,e.prototype.getLowestSetBit=yt,e.prototype.bitCount=bt,e.prototype.testBit=Tt,e.prototype.setBit=Rt,e.prototype.clearBit=Et,e.prototype.flipBit=Dt,e.prototype.add=xt,e.prototype.subtract=Bt,e.prototype.multiply=Kt,e.prototype.divide=Ut,e.prototype.remainder=Ot,e.prototype.divideAndRemainder=Vt,e.prototype.modPow=Gt,e.prototype.modInverse=Wt,e.prototype.pow=qt,e.prototype.gcd=$t,e.prototype.isProbablePrime=Qt,e.prototype.square=At,te.prototype.init=ee,te.prototype.next=ie;var Oe,Ve,Ne,Je=256;if(null==Ve){Ve=new Array,Ne=0;var Ie;if(window.crypto&&window.crypto.getRandomValues){var Pe=new Uint32Array(256);for(window.crypto.getRandomValues(Pe),Ie=0;Ie=256||Ne>=Je)return void(window.removeEventListener?window.removeEventListener("mousemove",Me,!1):window.detachEvent&&window.detachEvent("onmousemove",Me));try{var e=t.x+t.y;Ve[Ne++]=255&e,this.count+=1}catch(i){}};window.addEventListener?window.addEventListener("mousemove",Me,!1):window.attachEvent&&window.attachEvent("onmousemove",Me)}oe.prototype.nextBytes=ne,ue.prototype.doPublic=fe,ue.prototype.setPublic=ce,ue.prototype.encrypt=pe,ue.prototype.doPrivate=ye,ue.prototype.setPrivate=de,ue.prototype.setPrivateEx=ge,ue.prototype.generate=me,ue.prototype.decrypt=ve, +// Copyright (c) 2011 Kevin M Burns Jr. +// All Rights Reserved. +// See "LICENSE" for details. +// +// Extension to jsbn which adds facilities for asynchronous RSA key generation +// Primarily created to avoid execution timeout on mobile devices +// +// http://www-cs-students.stanford.edu/~tjw/jsbn/ +// +// --- +function(){var t=function(t,r,s){var n=new oe,o=t>>1;this.e=parseInt(r,16);var h=new e(r,16),a=this,u=function(){var r=function(){if(a.p.compareTo(a.q)<=0){var t=a.p;a.p=a.q,a.q=t}var i=a.p.subtract(e.ONE),r=a.q.subtract(e.ONE),n=i.multiply(r);0==n.gcd(h).compareTo(e.ONE)?(a.n=a.p.multiply(a.q),a.d=h.modInverse(n),a.dmp1=a.d.mod(i),a.dmq1=a.d.mod(r),a.coeff=a.q.modInverse(a.p),setTimeout(function(){s()},0)):setTimeout(u,0)},c=function(){a.q=i(),a.q.fromNumberAsync(o,1,n,function(){a.q.subtract(e.ONE).gcda(h,function(t){0==t.compareTo(e.ONE)&&a.q.isProbablePrime(10)?setTimeout(r,0):setTimeout(c,0)})})},f=function(){a.p=i(),a.p.fromNumberAsync(t-o,1,n,function(){a.p.subtract(e.ONE).gcda(h,function(t){0==t.compareTo(e.ONE)&&a.p.isProbablePrime(10)?setTimeout(c,0):setTimeout(f,0)})})};setTimeout(f,0)};setTimeout(u,0)};ue.prototype.generateAsync=t;var r=function(t,e){var i=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(i.compareTo(r)<0){var s=i;i=r,r=s}var n=i.getLowestSetBit(),o=r.getLowestSetBit();if(0>o)return void e(i);o>n&&(o=n),o>0&&(i.rShiftTo(o,i),r.rShiftTo(o,r));var h=function(){(n=i.getLowestSetBit())>0&&i.rShiftTo(n,i),(n=r.getLowestSetBit())>0&&r.rShiftTo(n,r),i.compareTo(r)>=0?(i.subTo(r,i),i.rShiftTo(1,i)):(r.subTo(i,r),r.rShiftTo(1,r)),i.signum()>0?setTimeout(h,0):(o>0&&r.lShiftTo(o,r),setTimeout(function(){e(r)},0))};setTimeout(h,10)};e.prototype.gcda=r;var s=function(t,i,r,s){if("number"==typeof i)if(2>t)this.fromInt(1);else{this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(e.ONE.shiftLeft(t-1),ht,this),this.isEven()&&this.dAddOffset(1,0);var n=this,o=function(){n.dAddOffset(2,0),n.bitLength()>t&&n.subTo(e.ONE.shiftLeft(t-1),n),n.isProbablePrime(i)?setTimeout(function(){s()},0):setTimeout(o,0)};setTimeout(o,0)}else{var h=new Array,a=7&t;h.length=(t>>3)+1,i.nextBytes(h),a>0?h[0]&=(1<MIT License + */ +"undefined"!=typeof KJUR&&KJUR||(KJUR={}),"undefined"!=typeof KJUR.asn1&&KJUR.asn1||(KJUR.asn1={}),KJUR.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var i=t.toString(16);if("-"!=i.substr(0,1))i.length%2==1?i="0"+i:i.match(/^[0-7]/)||(i="00"+i);else{var r=i.substr(1),s=r.length;s%2==1?s+=1:i.match(/^[0-7]/)||(s+=2);for(var n="",o=0;s>o;o++)n+="f";var h=new e(n,16),a=h.xor(t).add(e.ONE);i=a.toString(16).replace(/^-/,"")}return i},this.getPEMStringFromHex=function(t,e){var i=CryptoJS.enc.Hex.parse(t),r=CryptoJS.enc.Base64.stringify(i),s=r.replace(/(.{64})/g,"$1\r\n");return s=s.replace(/\r\n$/,""),"-----BEGIN "+e+"-----\r\n"+s+"\r\n-----END "+e+"-----\r\n"}},KJUR.asn1.ASN1Object=function(){var t="";this.getLengthHexFromValue=function(){if("undefined"==typeof this.hV||null==this.hV)throw"this.hV is null or undefined.";if(this.hV.length%2==1)throw"value hex must be even length: n="+t.length+",v="+this.hV;var e=this.hV.length/2,i=e.toString(16);if(i.length%2==1&&(i="0"+i),128>e)return i;var r=i.length/2;if(r>15)throw"ASN.1 length too long to represent by 8x: n = "+e.toString(16);var s=128+r;return s.toString(16)+i},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},KJUR.asn1.DERAbstractString=function(t){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(this.s)},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},"undefined"!=typeof t&&("undefined"!=typeof t.str?this.setString(t.str):"undefined"!=typeof t.hex&&this.setStringHex(t.hex))},Ce.extend(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object),KJUR.asn1.DERAbstractTime=function(t){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);this.localDateToUTC=function(t){utc=t.getTime()+6e4*t.getTimezoneOffset();var e=new Date(utc);return e},this.formatDate=function(t,e){var i=this.zeroPadding,r=this.localDateToUTC(t),s=String(r.getFullYear());"utc"==e&&(s=s.substr(2,2));var n=i(String(r.getMonth()+1),2),o=i(String(r.getDate()),2),h=i(String(r.getHours()),2),a=i(String(r.getMinutes()),2),u=i(String(r.getSeconds()),2);return s+n+o+h+a+u+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(this.s)},this.setByDateValue=function(t,e,i,r,s,n){var o=new Date(Date.UTC(t,e-1,i,r,s,n,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},Ce.extend(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object),KJUR.asn1.DERAbstractStructured=function(t){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,"undefined"!=typeof t&&"undefined"!=typeof t.array&&(this.asn1Array=t.array)},Ce.extend(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object),KJUR.asn1.DERBoolean=function(){KJUR.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},Ce.extend(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object),KJUR.asn1.DERInteger=function(t){KJUR.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var i=new e(String(t),10);this.setByBigInteger(i)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},"undefined"!=typeof t&&("undefined"!=typeof t.bigint?this.setByBigInteger(t.bigint):"undefined"!=typeof t["int"]?this.setByInteger(t["int"]):"undefined"!=typeof t.hex&&this.setValueHex(t.hex))},Ce.extend(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object),KJUR.asn1.DERBitString=function(t){KJUR.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(0>t||t>7)throw"unused bits shall be from 0 to 7: u = "+t;var i="0"+t;this.hTLV=null,this.isModified=!0,this.hV=i+e},this.setByBinaryString=function(t){t=t.replace(/0+$/,"");var e=8-t.length%8;8==e&&(e=0);for(var i=0;e>=i;i++)t+="0";for(var r="",i=0;ii;i++)e[i]=!1;return e},this.getFreshValueHex=function(){return this.hV},"undefined"!=typeof t&&("undefined"!=typeof t.hex?this.setHexValueIncludingUnusedBits(t.hex):"undefined"!=typeof t.bin?this.setByBinaryString(t.bin):"undefined"!=typeof t.array&&this.setByBooleanArray(t.array))},Ce.extend(KJUR.asn1.DERBitString,KJUR.asn1.ASN1Object),KJUR.asn1.DEROctetString=function(t){KJUR.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},Ce.extend(KJUR.asn1.DEROctetString,KJUR.asn1.DERAbstractString),KJUR.asn1.DERNull=function(){KJUR.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},Ce.extend(KJUR.asn1.DERNull,KJUR.asn1.ASN1Object),KJUR.asn1.DERObjectIdentifier=function(t){var i=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},r=function(t){var r="",s=new e(t,10),n=s.toString(2),o=7-n.length%7;7==o&&(o=0);for(var h="",a=0;o>a;a++)h+="0";n=h+n;for(var a=0;a +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +function(t){"use strict";var e,i={};i.decode=function(i){var r;if(e===t){var s="0123456789ABCDEF",n=" \f\n\r  \u2028\u2029";for(e=[],r=0;16>r;++r)e[s.charAt(r)]=r;for(s=s.toLowerCase(),r=10;16>r;++r)e[s.charAt(r)]=r;for(r=0;r=2?(o[o.length]=h,h=0,a=0):h<<=4}}if(a)throw"Hex encoding incomplete: 4 bits missing";return o},window.Hex=i}(), +// Copyright (c) 2008-2013 Lapo Luchini +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +function(t){"use strict";var e,i={};i.decode=function(i){var r;if(e===t){var s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n="= \f\n\r  \u2028\u2029";for(e=[],r=0;64>r;++r)e[s.charAt(r)]=r;for(r=0;r=4?(o[o.length]=h>>16,o[o.length]=h>>8&255,o[o.length]=255&h,h=0,a=0):h<<=6}}switch(a){case 1:throw"Base64 encoding incomplete: at least 2 bits missing";case 2:o[o.length]=h>>10;break;case 3:o[o.length]=h>>16,o[o.length]=h>>8&255}return o},i.re=/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,i.unarmor=function(t){var e=i.re.exec(t);if(e)if(e[1])t=e[1];else{if(!e[2])throw"RegExp out of sync";t=e[2]}return i.decode(t)},window.Base64=i}(), +// Copyright (c) 2008-2013 Lapo Luchini +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +function(t){"use strict";function e(t,i){t instanceof e?(this.enc=t.enc,this.pos=t.pos):(this.enc=t,this.pos=i)}function i(t,e,i,r,s){this.stream=t,this.header=e,this.length=i,this.tag=r,this.sub=s}var r=100,s="…",n={tag:function(t,e){var i=document.createElement(t);return i.className=e,i},text:function(t){return document.createTextNode(t)}};e.prototype.get=function(e){if(e===t&&(e=this.pos++),e>=this.enc.length)throw"Requesting byte offset "+e+" on a stream of length "+this.enc.length;return this.enc[e]},e.prototype.hexDigits="0123456789ABCDEF",e.prototype.hexByte=function(t){return this.hexDigits.charAt(t>>4&15)+this.hexDigits.charAt(15&t)},e.prototype.hexDump=function(t,e,i){for(var r="",s=t;e>s;++s)if(r+=this.hexByte(this.get(s)),i!==!0)switch(15&s){case 7:r+=" ";break;case 15:r+="\n";break;default:r+=" "}return r},e.prototype.parseStringISO=function(t,e){for(var i="",r=t;e>r;++r)i+=String.fromCharCode(this.get(r));return i},e.prototype.parseStringUTF=function(t,e){for(var i="",r=t;e>r;){var s=this.get(r++);i+=128>s?String.fromCharCode(s):s>191&&224>s?String.fromCharCode((31&s)<<6|63&this.get(r++)):String.fromCharCode((15&s)<<12|(63&this.get(r++))<<6|63&this.get(r++))}return i},e.prototype.parseStringBMP=function(t,e){for(var i="",r=t;e>r;r+=2){var s=this.get(r),n=this.get(r+1);i+=String.fromCharCode((s<<8)+n)}return i},e.prototype.reTime=/^((?:1[89]|2\d)?\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/,e.prototype.parseTime=function(t,e){var i=this.parseStringISO(t,e),r=this.reTime.exec(i);return r?(i=r[1]+"-"+r[2]+"-"+r[3]+" "+r[4],r[5]&&(i+=":"+r[5],r[6]&&(i+=":"+r[6],r[7]&&(i+="."+r[7]))),r[8]&&(i+=" UTC","Z"!=r[8]&&(i+=r[8],r[9]&&(i+=":"+r[9]))),i):"Unrecognized time: "+i},e.prototype.parseInteger=function(t,e){var i=e-t;if(i>4){i<<=3;var r=this.get(t);if(0===r)i-=8;else for(;128>r;)r<<=1,--i;return"("+i+" bit)"}for(var s=0,n=t;e>n;++n)s=s<<8|this.get(n);return s},e.prototype.parseBitString=function(t,e){var i=this.get(t),r=(e-t-1<<3)-i,s="("+r+" bit)";if(20>=r){var n=i;s+=" ";for(var o=e-1;o>t;--o){for(var h=this.get(o),a=n;8>a;++a)s+=h>>a&1?"1":"0";n=0}}return s},e.prototype.parseOctetString=function(t,e){var i=e-t,n="("+i+" byte) ";i>r&&(e=t+r);for(var o=t;e>o;++o)n+=this.hexByte(this.get(o));return i>r&&(n+=s),n},e.prototype.parseOID=function(t,e){for(var i="",r=0,s=0,n=t;e>n;++n){var o=this.get(n);if(r=r<<7|127&o,s+=7,!(128&o)){if(""===i){var h=80>r?40>r?0:1:2;i=h+"."+(r-40*h)}else i+="."+(s>=31?"bigint":r);r=s=0}}return i},i.prototype.typeName=function(){if(this.tag===t)return"unknown";var e=this.tag>>6,i=(this.tag>>5&1,31&this.tag);switch(e){case 0:switch(i){case 0:return"EOC";case 1:return"BOOLEAN";case 2:return"INTEGER";case 3:return"BIT_STRING";case 4:return"OCTET_STRING";case 5:return"NULL";case 6:return"OBJECT_IDENTIFIER";case 7:return"ObjectDescriptor";case 8:return"EXTERNAL";case 9:return"REAL";case 10:return"ENUMERATED";case 11:return"EMBEDDED_PDV";case 12:return"UTF8String";case 16:return"SEQUENCE";case 17:return"SET";case 18:return"NumericString";case 19:return"PrintableString";case 20:return"TeletexString";case 21:return"VideotexString";case 22:return"IA5String";case 23:return"UTCTime";case 24:return"GeneralizedTime";case 25:return"GraphicString";case 26:return"VisibleString";case 27:return"GeneralString";case 28:return"UniversalString";case 30:return"BMPString";default:return"Universal_"+i.toString(16)}case 1:return"Application_"+i.toString(16);case 2:return"["+i+"]";case 3:return"Private_"+i.toString(16)}},i.prototype.reSeemsASCII=/^[ -~]+$/,i.prototype.content=function(){if(this.tag===t)return null;var e=this.tag>>6,i=31&this.tag,n=this.posContent(),o=Math.abs(this.length);if(0!==e){if(null!==this.sub)return"("+this.sub.length+" elem)";var h=this.stream.parseStringISO(n,n+Math.min(o,r));return this.reSeemsASCII.test(h)?h.substring(0,2*r)+(h.length>2*r?s:""):this.stream.parseOctetString(n,n+o)}switch(i){case 1:return 0===this.stream.get(n)?"false":"true";case 2:return this.stream.parseInteger(n,n+o);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(n,n+o);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(n,n+o);case 6:return this.stream.parseOID(n,n+o);case 16:case 17:return"("+this.sub.length+" elem)";case 12:return this.stream.parseStringUTF(n,n+o);case 18:case 19:case 20:case 21:case 22:case 26:return this.stream.parseStringISO(n,n+o);case 30:return this.stream.parseStringBMP(n,n+o);case 23:case 24:return this.stream.parseTime(n,n+o)}return null},i.prototype.toString=function(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(null===this.sub?"null":this.sub.length)+"]"},i.prototype.print=function(e){if(e===t&&(e=""),document.writeln(e+this),null!==this.sub){e+=" ";for(var i=0,r=this.sub.length;r>i;++i)this.sub[i].print(e)}},i.prototype.toPrettyString=function(e){e===t&&(e="");var i=e+this.typeName()+" @"+this.stream.pos;if(this.length>=0&&(i+="+"),i+=this.length,32&this.tag?i+=" (constructed)":3!=this.tag&&4!=this.tag||null===this.sub||(i+=" (encapsulates)"),i+="\n",null!==this.sub){e+=" ";for(var r=0,s=this.sub.length;s>r;++r)i+=this.sub[r].toPrettyString(e)}return i},i.prototype.toDOM=function(){var t=n.tag("div","node");t.asn1=this;var e=n.tag("div","head"),i=this.typeName().replace(/_/g," ");e.innerHTML=i;var r=this.content();if(null!==r){r=String(r).replace(/",i+="Length: "+this.header+"+",i+=this.length>=0?this.length:-this.length+" (undefined)",32&this.tag?i+="
(constructed)":3!=this.tag&&4!=this.tag||null===this.sub||(i+="
(encapsulates)"),null!==r&&(i+="
Value:
"+r+"","object"==typeof oids&&6==this.tag)){var h=oids[r];h&&(h.d&&(i+="
"+h.d),h.c&&(i+="
"+h.c),h.w&&(i+="
(warning!)"))}o.innerHTML=i,t.appendChild(o);var a=n.tag("div","sub");if(null!==this.sub)for(var u=0,c=this.sub.length;c>u;++u)a.appendChild(this.sub[u].toDOM());return t.appendChild(a),e.onclick=function(){t.className="node collapsed"==t.className?"node":"node collapsed"},t},i.prototype.posStart=function(){return this.stream.pos},i.prototype.posContent=function(){return this.stream.pos+this.header},i.prototype.posEnd=function(){return this.stream.pos+this.header+Math.abs(this.length)},i.prototype.fakeHover=function(t){this.node.className+=" hover",t&&(this.head.className+=" hover")},i.prototype.fakeOut=function(t){var e=/ ?hover/;this.node.className=this.node.className.replace(e,""),t&&(this.head.className=this.head.className.replace(e,""))},i.prototype.toHexDOM_sub=function(t,e,i,r,s){if(!(r>=s)){var o=n.tag("span",e);o.appendChild(n.text(i.hexDump(r,s))),t.appendChild(o)}},i.prototype.toHexDOM=function(e){var i=n.tag("span","hex");if(e===t&&(e=i),this.head.hexNode=i,this.head.onmouseover=function(){this.hexNode.className="hexCurrent"},this.head.onmouseout=function(){this.hexNode.className="hex"},i.asn1=this,i.onmouseover=function(){var t=!e.selected;t&&(e.selected=this.asn1,this.className="hexCurrent"),this.asn1.fakeHover(t)},i.onmouseout=function(){var t=e.selected==this.asn1;this.asn1.fakeOut(t),t&&(e.selected=null,this.className="hex")},this.toHexDOM_sub(i,"tag",this.stream,this.posStart(),this.posStart()+1),this.toHexDOM_sub(i,this.length>=0?"dlen":"ulen",this.stream,this.posStart()+1,this.posContent()),null===this.sub)i.appendChild(n.text(this.stream.hexDump(this.posContent(),this.posEnd())));else if(this.sub.length>0){var r=this.sub[0],s=this.sub[this.sub.length-1];this.toHexDOM_sub(i,"intro",this.stream,this.posContent(),r.posStart());for(var o=0,h=this.sub.length;h>o;++o)i.appendChild(this.sub[o].toHexDOM(e));this.toHexDOM_sub(i,"outro",this.stream,s.posEnd(),this.posEnd())}return i},i.prototype.toHexString=function(t){return this.stream.hexDump(this.posStart(),this.posEnd(),!0)},i.decodeLength=function(t){var e=t.get(),i=127&e;if(i==e)return i;if(i>3)throw"Length over 24 bits not supported at position "+(t.pos-1);if(0===i)return-1;e=0;for(var r=0;i>r;++r)e=e<<8|t.get();return e},i.hasContent=function(t,r,s){if(32&t)return!0;if(3>t||t>4)return!1;var n=new e(s);3==t&&n.get();var o=n.get();if(o>>6&1)return!1;try{var h=i.decodeLength(n);return n.pos-s.pos+h==r}catch(a){return!1}},i.decode=function(t){t instanceof e||(t=new e(t,0));var r=new e(t),s=t.get(),n=i.decodeLength(t),o=t.pos-r.pos,h=null;if(i.hasContent(s,n,t)){var a=t.pos;if(3==s&&t.get(),h=[],n>=0){for(var u=a+n;t.posr;++r){var n=new e(t[r].value,0),o=i.decodeLength(n);o!=t[r].expected&&document.write("In test["+r+"] expected "+t[r].expected+" got "+o+"\n")}},window.ASN1=i}(),ASN1.prototype.getHexStringValue=function(){var t=this.toHexString(),e=2*this.header,i=2*this.length;return t.substr(e,i)},ue.prototype.parseKey=function(t){try{var e=0,i=0,r=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/,s=r.test(t)?Hex.decode(t):Base64.unarmor(t),n=ASN1.decode(s);if(3===n.sub.length&&(n=n.sub[2].sub[0]),9===n.sub.length){e=n.sub[1].getHexStringValue(),this.n=he(e,16),i=n.sub[2].getHexStringValue(),this.e=parseInt(i,16);var o=n.sub[3].getHexStringValue();this.d=he(o,16);var h=n.sub[4].getHexStringValue();this.p=he(h,16);var a=n.sub[5].getHexStringValue();this.q=he(a,16);var u=n.sub[6].getHexStringValue();this.dmp1=he(u,16);var c=n.sub[7].getHexStringValue();this.dmq1=he(c,16);var f=n.sub[8].getHexStringValue();this.coeff=he(f,16)}else{if(2!==n.sub.length)return!1;var p=n.sub[1],l=p.sub[0];e=l.sub[0].getHexStringValue(),this.n=he(e,16),i=l.sub[1].getHexStringValue(),this.e=parseInt(i,16)}return!0}catch(d){return!1}},ue.prototype.getPrivateBaseKey=function(){var t={array:[new KJUR.asn1.DERInteger({"int":0}),new KJUR.asn1.DERInteger({bigint:this.n}),new KJUR.asn1.DERInteger({"int":this.e}),new KJUR.asn1.DERInteger({bigint:this.d}),new KJUR.asn1.DERInteger({bigint:this.p}),new KJUR.asn1.DERInteger({bigint:this.q}),new KJUR.asn1.DERInteger({bigint:this.dmp1}),new KJUR.asn1.DERInteger({bigint:this.dmq1}),new KJUR.asn1.DERInteger({bigint:this.coeff})]},e=new KJUR.asn1.DERSequence(t);return e.getEncodedHex()},ue.prototype.getPrivateBaseKeyB64=function(){return be(this.getPrivateBaseKey())},ue.prototype.getPublicBaseKey=function(){var t={array:[new KJUR.asn1.DERObjectIdentifier({oid:"1.2.840.113549.1.1.1"}),new KJUR.asn1.DERNull]},e=new KJUR.asn1.DERSequence(t);t={array:[new KJUR.asn1.DERInteger({bigint:this.n}),new KJUR.asn1.DERInteger({"int":this.e})]};var i=new KJUR.asn1.DERSequence(t);t={hex:"00"+i.getEncodedHex()};var r=new KJUR.asn1.DERBitString(t);t={array:[e,r]};var s=new KJUR.asn1.DERSequence(t);return s.getEncodedHex()},ue.prototype.getPublicBaseKeyB64=function(){return be(this.getPublicBaseKey())},ue.prototype.wordwrap=function(t,e){if(e=e||64,!t)return t;var i="(.{1,"+e+"})( +|$\n?)|(.{1,"+e+"})";return t.match(RegExp(i,"g")).join("\n")},ue.prototype.getPrivateKey=function(){var t="-----BEGIN RSA PRIVATE KEY-----\n";return t+=this.wordwrap(this.getPrivateBaseKeyB64())+"\n",t+="-----END RSA PRIVATE KEY-----"},ue.prototype.getPublicKey=function(){var t="-----BEGIN PUBLIC KEY-----\n";return t+=this.wordwrap(this.getPublicBaseKeyB64())+"\n",t+="-----END PUBLIC KEY-----"},ue.prototype.hasPublicKeyProperty=function(t){return t=t||{},t.hasOwnProperty("n")&&t.hasOwnProperty("e")},ue.prototype.hasPrivateKeyProperty=function(t){return t=t||{},t.hasOwnProperty("n")&&t.hasOwnProperty("e")&&t.hasOwnProperty("d")&&t.hasOwnProperty("p")&&t.hasOwnProperty("q")&&t.hasOwnProperty("dmp1")&&t.hasOwnProperty("dmq1")&&t.hasOwnProperty("coeff")},ue.prototype.parsePropertiesFrom=function(t){this.n=t.n,this.e=t.e,t.hasOwnProperty("d")&&(this.d=t.d,this.p=t.p,this.q=t.q,this.dmp1=t.dmp1,this.dmq1=t.dmq1,this.coeff=t.coeff)};var _e=function(t){ue.call(this),t&&("string"==typeof t?this.parseKey(t):(this.hasPrivateKeyProperty(t)||this.hasPublicKeyProperty(t))&&this.parsePropertiesFrom(t))};_e.prototype=new ue,_e.prototype.constructor=_e;var ze=function(t){t=t||{},this.default_key_size=parseInt(t.default_key_size)||1024,this.default_public_exponent=t.default_public_exponent||"010001",this.log=t.log||!1,this.key=null};ze.prototype.setKey=function(t){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new _e(t)},ze.prototype.setPrivateKey=function(t){this.setKey(t)},ze.prototype.setPublicKey=function(t){this.setKey(t)},ze.prototype.decrypt=function(t){try{return this.getKey().decrypt(Te(t))}catch(e){return!1}},ze.prototype.encrypt=function(t){try{return be(this.getKey().encrypt(t))}catch(e){return!1}},ze.prototype.getKey=function(t){if(!this.key){if(this.key=new _e,t&&"[object Function]"==={}.toString.call(t))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,t);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},ze.prototype.getPrivateKey=function(){return this.getKey().getPrivateKey()},ze.prototype.getPrivateKeyB64=function(){return this.getKey().getPrivateBaseKeyB64()},ze.prototype.getPublicKey=function(){return this.getKey().getPublicKey()},ze.prototype.getPublicKeyB64=function(){return this.getKey().getPublicBaseKeyB64()},ze.version="2.3.1",t.JSEncrypt=ze}); \ No newline at end of file diff --git a/sdk/src/connection.js b/sdk/src/connection.js index d15d9cbc..d81af86d 100755 --- a/sdk/src/connection.js +++ b/sdk/src/connection.js @@ -67,6 +67,7 @@ if (window.localStorage) { } Strophe.Websocket.prototype._onMessage = function (message) { + logMessage(message); var elem, data; // check for closing stream // var close = ''; @@ -103,7 +104,7 @@ Strophe.Websocket.prototype._onMessage = function (message) { } else { data = this._streamWrap(message.data); elem = new DOMParser().parseFromString(data, "text/xml").documentElement; - + // console.log(elem) if (this._check_streamerror(elem, Strophe.Status.ERROR)) { return; @@ -366,8 +367,11 @@ var _getAESKey = function (options, conn) { _login(options, conn); }; var error = function (res, xhr, msg) { - console.log('error') + console.log('rest _getAESKey error') console.log(res) + conn.encrypt.mode = "ecb"; + global_mode = "ecb"; + _login(options, conn); }; @@ -387,6 +391,69 @@ var _getAESKey = function (options, conn) { }; + +var rsa_encrypt = function (target, pub_key) { + // 创建 RSA 对象 + var crypt = new JSEncrypt(); + + crypt.setKey(pub_key); + + var encrypted = crypt.encrypt(target); + + return encrypted; + +} + +var aes_encrypt = function (target, pub_key) { + // conn.encrypt.mode = CryptoJS.mode.CBC; + // conn.encrypt.key = CryptoJS.enc.Utf8.parse(pub_key); + // conn.encrypt.iv = CryptoJS.enc.Utf8.parse('0000000000000000'); + // global_mode = resp.data.mode.toLowerCase(); + // global_key = CryptoJS.enc.Utf8.parse(resp.data.key); + // global_iv = CryptoJS.enc.Utf8.parse('0000000000000000'); + + var option = { + iv: CryptoJS.enc.Utf8.parse('0000000000000000'), + mode: CryptoJS.mode.CBC, + padding: CryptoJS.pad.Pkcs7 + }; + var encryptedData = CryptoJS.AES.encrypt(target, CryptoJS.enc.Utf8.parse(pub_key), option); + + return encryptedData.toString(); + +} + +var aes_encrypt = function (target, pub_key) { + // conn.encrypt.mode = CryptoJS.mode.CBC; + // conn.encrypt.key = CryptoJS.enc.Utf8.parse(pub_key); + // conn.encrypt.iv = CryptoJS.enc.Utf8.parse('0000000000000000'); + // global_mode = resp.data.mode.toLowerCase(); + // global_key = CryptoJS.enc.Utf8.parse(resp.data.key); + // global_iv = CryptoJS.enc.Utf8.parse('0000000000000000'); + + var option = { + iv: CryptoJS.enc.Utf8.parse('0000000000000000'), + mode: CryptoJS.mode.CBC, + padding: CryptoJS.pad.Pkcs7 + }; + var encryptedData = CryptoJS.AES.encrypt(target, CryptoJS.enc.Utf8.parse(pub_key), option); + + return encryptedData.toString(); + +} + + +var getRandomKey = function (conn, pub_key) { + var local_private_key = new Array(conn.context.userId, new Date().getTime(), Math.random()).join("_") + //rsa 返回的 已经是base4加密过的字符串了 + var encryped = rsa_encrypt(local_private_key, pub_key) + + // private_key = atob(private_key) + + return encryped +} + + var _login = function (options, conn) { var accessToken = options.access_token || ''; if (accessToken == '') { @@ -3655,11 +3722,149 @@ WebIM.doQuery = function (str, suc, fail) { ); }; +var test_num = 0; +// ENCRYPT_NONE = 0; +// ENCRYPT_AES_128_CBC = 1; //defaule encryption type. +// ENCRYPT_AES_256_CBC = 2; // + +//webim +// ENCRYPT_NONE + + +//webim +// ENCRYPT_128dfgdfg +Strophe.Connection.prototype._sasl_auth1_cb = function (elem) { + // save stream:features for future usage + this.features = elem; + var i, child; + for (i = 0; i < elem.childNodes.length; i++) { + child = elem.childNodes[i]; + if (child.nodeName == 'bind') { + this.do_bind = true; + } + + if (child.nodeName == 'session') { + this.do_session = true; + } + } + + if (!this.do_bind) { + this._changeConnectStatus(Strophe.Status.AUTHFAIL, null); + return false; + } else { + this._addSysHandler(this._sasl_bind_cb.bind(this), null, null, + null, "_bind_auth_2"); + + // let key = getRandomKey(Demo.conn) + // console.log(key) + var resource = Strophe.getResourceFromJid(this.jid); + if (resource) { + this.send($iq({type: "set", id: "_bind_auth_2"}) + .c('bind', {xmlns: Strophe.NS.BIND}) + .c('resource', {}).t(resource) + .up() + .c('encrypt_type', {}).t("ENCRYPT_NONE") + .up() + .c('encrypt_key', {}).t('') + .up() + .tree()); + } else { + this.send($iq({type: "set", id: "_bind_auth_2"}) + .c('bind', {xmlns: Strophe.NS.BIND}) + .tree()); + } + } + return false; +}; + +//webimENCRYPT_NONE-----BEGIN PUBLIC KEY----- +// MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDJPMdGcWfQ4JAY0IWY/Z+umUF7 +// J48Lk0yY/XjTG8d1Pbqio8t/4lGhNem3obefXe4KpRGjNUZ6kVKwebyUmAsdT1iC +// jTI1ZbcUXVPwoE8IiYIP6mGEgdvzDr4ly8yBRHYFn8WMyeP+4KsQHuyQmZ54VToS +// 1G9JW9CECTofxALqrQIDAQAB +// -----END PUBLIC KEY----- +// + +Strophe.Connection.prototype._sasl_bind_cb = function (elem) { + console.log(elem) + if (elem.getAttribute("type") == "error") { + var errors = elem.getElementsByTagName("error"); + console.log(errors, errors[0].getAttribute("code")) + var code = errors[0].getAttribute("code") + if (code == "413" && test_num == 0) { + var texts = elem.getElementsByTagName("text"); + console.log(texts) + var pub_key = Strophe.getText(texts[0]) + console.log('pub_key', pub_key) + this._addSysHandler(this._sasl_bind_cb.bind(this), null, null, + null, "_bind_auth_2"); + + let encrypt_key = getRandomKey(Demo.conn, pub_key) + console.log('encrypt_key', encrypt_key) + var resource = Strophe.getResourceFromJid(this.jid); + if (resource) { + this.send($iq({type: "set", id: "_bind_auth_2"}) + .c('bind', {xmlns: Strophe.NS.BIND}) + .c('resource', {}).t(resource) + .up() + .c('encrypt_type', {}).t("ENCRYPT_AES_128_CBC") + .up() + .c('encrypt_key', {}).t(encrypt_key) + .up() + .tree()); + } else { + this.send($iq({type: "set", id: "_bind_auth_2"}) + .c('bind', {xmlns: Strophe.NS.BIND}) + .tree()); + } + test_num++ + } else { + Strophe.info("SASL binding failed."); + var conflict = elem.getElementsByTagName("conflict"), condition; + if (conflict.length > 0) { + condition = 'conflict'; + } + this._changeConnectStatus(Strophe.Status.AUTHFAIL, condition); + return false; + } + + } + + // TODO - need to grab errors + var bind = elem.getElementsByTagName("bind"); + var jidNode; + if (bind.length > 0) { + // Grab jid + jidNode = bind[0].getElementsByTagName("jid"); + if (jidNode.length > 0) { + this.jid = Strophe.getText(jidNode[0]); + + if (this.do_session) { + this._addSysHandler(this._sasl_session_cb.bind(this), + null, null, null, "_session_auth_2"); + + this.send($iq({type: "set", id: "_session_auth_2"}) + .c('session', {xmlns: Strophe.NS.SESSION}) + .tree()); + } else { + this.authenticated = true; + this._changeConnectStatus(Strophe.Status.CONNECTED, null); + } + } + } else { + Strophe.info("SASL binding failed."); + this._changeConnectStatus(Strophe.Status.AUTHFAIL, null); + return false; + } +}; /**************************** debug ****************************/ +function logMessage(message) { + WebIM && WebIM.config.isDebug && console.log(WebIM.utils.ts() + '[recv] ', message.data); +} if (WebIM && WebIM.config.isDebug) { Strophe.Connection.prototype.rawOutput = function (data) { - // console.log('%c ' + WebIM.utils.ts() + '[send] ' + data, "background-color: #e2f7da"); + console.log('%c ' + WebIM.utils.ts() + '[send] ' + data, "background-color: #e2f7da"); } } @@ -3668,6 +3873,9 @@ if (WebIM && WebIM.config && WebIM.config.isSandBox) { WebIM.config.apiURL = WebIM.config.apiURL.replace('.easemob.', '-sdb.easemob.'); } +WebIM.config.apiURL = '//118.193.28.212:31080'; +WebIM.config.xmppURL = '118.193.28.212:31293'; //加密版本 +// WebIM.config.xmppURL = '118.193.28.212:31093'; //非加密版本 module.exports = WebIM; From 430dbf582e98bc47a55ab0db7ee54041922f1841 Mon Sep 17 00:00:00 2001 From: wk3368 Date: Thu, 17 Aug 2017 11:31:15 +0800 Subject: [PATCH 12/23] =?UTF-8?q?=E5=8F=91=E9=80=81=E5=8A=A0=E5=AF=86=20ok?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/javascript/dist/webim.config.js | 1 + sdk/src/connection.js | 135 +++++++-------------------- 2 files changed, 33 insertions(+), 103 deletions(-) diff --git a/demo/javascript/dist/webim.config.js b/demo/javascript/dist/webim.config.js index 2999a774..32117514 100755 --- a/demo/javascript/dist/webim.config.js +++ b/demo/javascript/dist/webim.config.js @@ -112,6 +112,7 @@ WebIM.config = { * {type:'aes',mode: 'cbc',key: '123456789easemob',iv: '0000000000000000'} encrypt with aes(cbc) */ encrypt: { + enabled: true, type: 'aes' } }; diff --git a/sdk/src/connection.js b/sdk/src/connection.js index d81af86d..a0e50e2e 100755 --- a/sdk/src/connection.js +++ b/sdk/src/connection.js @@ -7,9 +7,10 @@ var _msgHash = {}; var Queue = require('./queue').Queue; var CryptoJS = require('crypto-js'); var _ = require('underscore'); -var global_mode = ''; -var global_key = ''; -var global_iv = ''; + +var aes_key_str = ''; +var aes_key = ''; +var aes_iv = CryptoJS.enc.Utf8.parse('0000000000000000'); window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL; @@ -133,20 +134,13 @@ Strophe.Websocket.prototype._onMessage = function (message) { if (WebIM.config.encrypt.type === 'base64') { text = atob(text); } else if (WebIM.config.encrypt.type === 'aes') { - option = {}; - if (global_mode === 'cbc') { - option = { - iv: global_iv, - mode: CryptoJS.mode.CBC, - padding: CryptoJS.pad.Pkcs7 - } - } else if (global_mode === 'ecb') { - option = { - mode: CryptoJS.mode.ECB, - padding: CryptoJS.pad.Pkcs7 - } + option = { + iv: aes_iv, + mode: CryptoJS.mode.CBC, + padding: CryptoJS.pad.Pkcs7 } - decryptedData = CryptoJS.AES.decrypt(text, global_key, option); + + decryptedData = CryptoJS.AES.decrypt(text, aes_key, option); text = decryptedData.toString(CryptoJS.enc.Utf8); // console.log('text', text) @@ -360,17 +354,12 @@ var _getAESKey = function (options, conn) { //{"algorithm": "AES", "mode": "ECB", "padding": "PKCS5Padding", "key": "easemob@@easemob"} conn.encrypt.mode = resp.data.mode.toLowerCase(); conn.encrypt.key = CryptoJS.enc.Utf8.parse(resp.data.key); - conn.encrypt.iv = CryptoJS.enc.Utf8.parse('0000000000000000'); - global_mode = resp.data.mode.toLowerCase(); - global_key = CryptoJS.enc.Utf8.parse(resp.data.key); - global_iv = CryptoJS.enc.Utf8.parse('0000000000000000'); _login(options, conn); }; var error = function (res, xhr, msg) { console.log('rest _getAESKey error') console.log(res) - conn.encrypt.mode = "ecb"; - global_mode = "ecb"; + conn.encrypt.mode = "cbc"; _login(options, conn); }; @@ -404,51 +393,17 @@ var rsa_encrypt = function (target, pub_key) { } -var aes_encrypt = function (target, pub_key) { - // conn.encrypt.mode = CryptoJS.mode.CBC; - // conn.encrypt.key = CryptoJS.enc.Utf8.parse(pub_key); - // conn.encrypt.iv = CryptoJS.enc.Utf8.parse('0000000000000000'); - // global_mode = resp.data.mode.toLowerCase(); - // global_key = CryptoJS.enc.Utf8.parse(resp.data.key); - // global_iv = CryptoJS.enc.Utf8.parse('0000000000000000'); - - var option = { - iv: CryptoJS.enc.Utf8.parse('0000000000000000'), - mode: CryptoJS.mode.CBC, - padding: CryptoJS.pad.Pkcs7 - }; - var encryptedData = CryptoJS.AES.encrypt(target, CryptoJS.enc.Utf8.parse(pub_key), option); - - return encryptedData.toString(); - -} - -var aes_encrypt = function (target, pub_key) { - // conn.encrypt.mode = CryptoJS.mode.CBC; - // conn.encrypt.key = CryptoJS.enc.Utf8.parse(pub_key); - // conn.encrypt.iv = CryptoJS.enc.Utf8.parse('0000000000000000'); - // global_mode = resp.data.mode.toLowerCase(); - // global_key = CryptoJS.enc.Utf8.parse(resp.data.key); - // global_iv = CryptoJS.enc.Utf8.parse('0000000000000000'); - - var option = { - iv: CryptoJS.enc.Utf8.parse('0000000000000000'), - mode: CryptoJS.mode.CBC, - padding: CryptoJS.pad.Pkcs7 - }; - var encryptedData = CryptoJS.AES.encrypt(target, CryptoJS.enc.Utf8.parse(pub_key), option); - - return encryptedData.toString(); -} +var getRandomKey = function (conn, pub_key) { + aes_key_str = new Array(new Date().getTime(), Math.random().toString().substr(2, 2)).join("_") + console.log('aes_key_str', aes_key_str) + aes_key = CryptoJS.enc.Utf8.parse(aes_key_str); -var getRandomKey = function (conn, pub_key) { - var local_private_key = new Array(conn.context.userId, new Date().getTime(), Math.random()).join("_") //rsa 返回的 已经是base4加密过的字符串了 - var encryped = rsa_encrypt(local_private_key, pub_key) + var encryped = rsa_encrypt(aes_key_str, pub_key) + - // private_key = atob(private_key) return encryped } @@ -467,7 +422,7 @@ var _login = function (options, conn) { conn.context.accessToken = options.access_token; conn.context.accessTokenExpires = options.expires_in; - if (conn.encrypt.type === 'aes' && !conn.encrypt.mode) { + if (WebIM.config.encrypt.enabled && !conn.encrypt.mode) { _getAESKey(options, conn) return } @@ -1648,27 +1603,14 @@ connection.prototype.handleMessage = function (msginfo) { switch (type) { case 'txt': var receiveMsg = msgBody.msg; - if (self.encrypt.type === 'base64') { - receiveMsg = atob(receiveMsg); - } else if (self.encrypt.type === 'aes') { - var key = self.encrypt.key - var iv = self.encrypt.iv - var mode = self.encrypt.mode - var option = {}; - if (mode === 'cbc') { - option = { - iv: iv, - mode: CryptoJS.mode.CBC, - padding: CryptoJS.pad.Pkcs7 - } - } else if (mode === 'ecb') { - option = { - mode: CryptoJS.mode.ECB, - padding: CryptoJS.pad.Pkcs7 - } + if (self.encrypt.enabled) { + var option = { + iv: aes_iv, + mode: CryptoJS.mode.CBC, + padding: CryptoJS.pad.Pkcs7 } var encryptedBase64Str = receiveMsg; - var decryptedData = CryptoJS.AES.decrypt(encryptedBase64Str, key, option); + var decryptedData = CryptoJS.AES.decrypt(encryptedBase64Str, aes_key, option); var decryptedStr = decryptedData.toString(CryptoJS.enc.Utf8); receiveMsg = decryptedStr; } @@ -2008,28 +1950,15 @@ connection.prototype.send = function (messageSource) { var message = messageSource; if (message.type === 'txt' && (self.encrypt.type === 'base64' || self.encrypt.type === 'aes')) { message = _.clone(messageSource); - if (self.encrypt.type === 'base64') { - message.msg = btoa(message.msg); - } else if (self.encrypt.type === 'aes') { - // console.log(this.encrypt) - var key = self.encrypt.key; - var iv = self.encrypt.iv; - var mode = self.encrypt.mode; - var option = {}; - if (mode === 'cbc') { - option = { - iv: iv, - mode: CryptoJS.mode.CBC, - padding: CryptoJS.pad.Pkcs7 - }; - } else if (mode === 'ecb') { - option = { - mode: CryptoJS.mode.ECB, - padding: CryptoJS.pad.Pkcs7 - } - } - var encryptedData = CryptoJS.AES.encrypt(message.msg, key, option); + if (self.encrypt.enabled) { + var option = { + iv: aes_iv, + mode: CryptoJS.mode.CBC, + padding: CryptoJS.pad.Pkcs7 + }; + var encryptedData = CryptoJS.AES.encrypt(message.msg, aes_key, option); + console.log(aes_key_str, message.msg, encryptedData.toString()) message.msg = encryptedData.toString(); } } From 73ef970951befa1646c1bf921506f4ae1b16968f Mon Sep 17 00:00:00 2001 From: wk3368 Date: Thu, 17 Aug 2017 12:30:54 +0800 Subject: [PATCH 13/23] =?UTF-8?q?=E5=8F=91=E9=80=81=E5=8A=A0=E5=AF=86=20?= =?UTF-8?q?=E5=AF=B9=E6=95=B4=E4=B8=AAbody=20=E8=80=8C=E4=B8=8D=E5=8F=AA?= =?UTF-8?q?=E6=98=AFmessage.msg=E5=AD=97=E6=AE=B5=20=E5=8C=85=E6=8B=ACext?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sdk/src/connection.js | 23 +++++------------------ sdk/src/message.js | 10 ++++++++++ 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/sdk/src/connection.js b/sdk/src/connection.js index a0e50e2e..749aaf14 100755 --- a/sdk/src/connection.js +++ b/sdk/src/connection.js @@ -395,14 +395,14 @@ var rsa_encrypt = function (target, pub_key) { var getRandomKey = function (conn, pub_key) { - aes_key_str = new Array(new Date().getTime(), Math.random().toString().substr(2, 2)).join("_") - console.log('aes_key_str', aes_key_str) + conn.context.aes_iv = CryptoJS.enc.Utf8.parse('0000000000000000'); + conn.context.aes_key_str = new Array(new Date().getTime(), Math.random().toString().substr(2, 2)).join("_") + console.log('aes_key_str', conn.context.aes_key_str) - aes_key = CryptoJS.enc.Utf8.parse(aes_key_str); + conn.context.aes_key = CryptoJS.enc.Utf8.parse(conn.context.aes_key_str); //rsa 返回的 已经是base4加密过的字符串了 - var encryped = rsa_encrypt(aes_key_str, pub_key) - + var encryped = rsa_encrypt(conn.context.aes_key_str, pub_key) return encryped @@ -1948,20 +1948,7 @@ connection.prototype.getUniqueId = function (prefix) { connection.prototype.send = function (messageSource) { var self = this; var message = messageSource; - if (message.type === 'txt' && (self.encrypt.type === 'base64' || self.encrypt.type === 'aes')) { - message = _.clone(messageSource); - if (self.encrypt.enabled) { - var option = { - iv: aes_iv, - mode: CryptoJS.mode.CBC, - padding: CryptoJS.pad.Pkcs7 - }; - var encryptedData = CryptoJS.AES.encrypt(message.msg, aes_key, option); - console.log(aes_key_str, message.msg, encryptedData.toString()) - message.msg = encryptedData.toString(); - } - } if (this.isWindowSDK) { WebIM.doQuery('{"type":"sendMessage","to":"' + message.to + '","message_type":"' + message.type + '","msg":"' + encodeURI(message.msg) + '","chatType":"' + message.chatType + '"}', function (response) { diff --git a/sdk/src/message.js b/sdk/src/message.js index 4a746a05..fd3c1035 100755 --- a/sdk/src/message.js +++ b/sdk/src/message.js @@ -258,6 +258,16 @@ var CryptoJS = require('crypto-js'); , ext: message.ext || {} }; var jsonstr = _utils.stringify(json); + if (message.type === 'txt' && conn.encrypt.enabled) { + var option = { + iv: conn.context.aes_iv, + mode: CryptoJS.mode.CBC, + padding: CryptoJS.pad.Pkcs7 + }; + var encryptedData = CryptoJS.AES.encrypt(jsonstr, conn.context.aes_key, option); + console.log(conn.context.aes_key_str, jsonstr, encryptedData.toString()) + jsonstr = encryptedData.toString(); + } dom = $msg({ type: message.group || 'chat' , to: message.toJid From d26f5ed982301c2361fe0b1aa3eab2a0ed70a6d0 Mon Sep 17 00:00:00 2001 From: wk3368 Date: Thu, 17 Aug 2017 16:30:12 +0800 Subject: [PATCH 14/23] =?UTF-8?q?=E5=8F=91=E9=80=81=E5=92=8C=E6=8E=A5?= =?UTF-8?q?=E6=94=B6=E7=9A=84=20=E5=8A=A0=E5=AF=86=E8=A7=A3=E5=AF=86=20?= =?UTF-8?q?=E9=83=BDok=E4=BA=86=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sdk/src/connection.js | 144 +++++++++++++++++++++++++----------------- sdk/src/message.js | 2 +- 2 files changed, 86 insertions(+), 60 deletions(-) diff --git a/sdk/src/connection.js b/sdk/src/connection.js index 749aaf14..9ca7bc1f 100755 --- a/sdk/src/connection.js +++ b/sdk/src/connection.js @@ -8,9 +8,6 @@ var Queue = require('./queue').Queue; var CryptoJS = require('crypto-js'); var _ = require('underscore'); -var aes_key_str = ''; -var aes_key = ''; -var aes_iv = CryptoJS.enc.Utf8.parse('0000000000000000'); window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL; @@ -103,7 +100,37 @@ Strophe.Websocket.prototype._onMessage = function (message) { return; } } else { - data = this._streamWrap(message.data); + var data_decrypted = null + if (WebIM.config.encrypt.enabled) { + // var test = "4hdALtL5l9I93HKQaxaYoTbWXPh8IDCFBRfOHMkGYDQg93YYgzHi3N5zR6tRmoOJsFVzI4n+KYmjMHKKd27La6fL5vzcoVrDSxvVR4HddZgoIOyg61UfdkYiblflqbvGKHN3Y7/KRn9rGPaUQy00LQ==" + // test = "{'from':'zzf1','to':'zzf3','bodies':[{}],'ext':{'weichat':{'originType':'webim'}}}351158306766586140{'xmlns':'urn:xmpp:receipts','id':'351158306766586140'}" + // console.log(message.data) + + let pos1 = message.data.indexOf("") + 6 + let pos2 = message.data.indexOf("") + if (pos1 > 6 && pos2 > 6) { + var body = message.data.substr(pos1, pos2 - pos1) + + var option = { + iv: WebIM.config.encrypt.aes_iv, + mode: CryptoJS.mode.CBC, + padding: CryptoJS.pad.Pkcs7 + } + + var decryptedData = CryptoJS.AES.decrypt(body, WebIM.config.encrypt.aes_key, option); + body = decryptedData.toString(CryptoJS.enc.Utf8); + + // message.data 是只读的 直接修改message.data=temp 会报错: + // Uncaught TypeError: Cannot assign to read only property 'data' of object '#' + data_decrypted = new Array(message.data.substr(0, pos1), body, message.data.substr(pos2)).join("") + console.log(data_decrypted) + } + } + if (data_decrypted) { + data = this._streamWrap(data_decrypted); + } else { + data = this._streamWrap(message.data); + } elem = new DOMParser().parseFromString(data, "text/xml").documentElement; // console.log(elem) @@ -123,40 +150,40 @@ Strophe.Websocket.prototype._onMessage = function (message) { } //log aes message into localstorage - if (message.data.indexOf('msg') > 0 && message.data.indexOf('type') > 0) { - var body, objValue, text, option, decryptedData - body = elem.getElementsByTagName('body')[0]; - if (body && body.innerHTML) { - objValue = JSON.parse(body.innerHTML) - // console.log('objValue', objValue) - if (objValue.bodies[0].type === 'txt') { - text = objValue.bodies[0].msg; - if (WebIM.config.encrypt.type === 'base64') { - text = atob(text); - } else if (WebIM.config.encrypt.type === 'aes') { - option = { - iv: aes_iv, - mode: CryptoJS.mode.CBC, - padding: CryptoJS.pad.Pkcs7 - } - - decryptedData = CryptoJS.AES.decrypt(text, aes_key, option); - text = decryptedData.toString(CryptoJS.enc.Utf8); - - // console.log('text', text) - if (WebIM && WebIM.config.isDebug && window.localStorage) { - window.localStorage.setItem(recv_num++, text) - } - - } - } - } - body = null - objValue = null - text = null - option = null - decryptedData = null - } + // if (message.data.indexOf('msg') > 0 && message.data.indexOf('type') > 0) { + // var body, objValue, text, option, decryptedData + // body = elem.getElementsByTagName('body')[0]; + // if (body && body.innerHTML) { + // objValue = JSON.parse(body.innerHTML) + // // console.log('objValue', objValue) + // if (objValue.bodies[0].type === 'txt') { + // text = objValue.bodies[0].msg; + // if (WebIM.config.encrypt.type === 'base64') { + // text = atob(text); + // } else if (WebIM.config.encrypt.type === 'aes') { + // option = { + // iv: aes_iv, + // mode: CryptoJS.mode.CBC, + // padding: CryptoJS.pad.Pkcs7 + // } + // + // decryptedData = CryptoJS.AES.decrypt(text, aes_key, option); + // text = decryptedData.toString(CryptoJS.enc.Utf8); + // + // // console.log('text', text) + // if (WebIM && WebIM.config.isDebug && window.localStorage) { + // window.localStorage.setItem(recv_num++, text) + // } + // + // } + // } + // } + // body = null + // objValue = null + // text = null + // option = null + // decryptedData = null + // } } this._conn._dataRecv(elem, message.data); @@ -401,6 +428,10 @@ var getRandomKey = function (conn, pub_key) { conn.context.aes_key = CryptoJS.enc.Utf8.parse(conn.context.aes_key_str); + WebIM.config.encrypt.aes_iv = conn.context.aes_iv + WebIM.config.encrypt.aes_key_str = conn.context.aes_key_str + WebIM.config.encrypt.aes_key = conn.context.aes_key + //rsa 返回的 已经是base4加密过的字符串了 var encryped = rsa_encrypt(conn.context.aes_key_str, pub_key) @@ -422,10 +453,10 @@ var _login = function (options, conn) { conn.context.accessToken = options.access_token; conn.context.accessTokenExpires = options.expires_in; - if (WebIM.config.encrypt.enabled && !conn.encrypt.mode) { - _getAESKey(options, conn) - return - } + // if (WebIM.config.encrypt.enabled && !conn.encrypt.mode) { + // _getAESKey(options, conn) + // return + // } var stropheConn = null; @@ -790,7 +821,7 @@ var connection = function (options) { this.apiUrl = options.apiUrl || ''; this.context.apiUrl = this.apiUrl; this.isWindowSDK = options.isWindowSDK || false; - this.encrypt = options.encrypt || {encrypt: {type: 'none'}}; + this.encrypt = options.encrypt; this.delivery = options.delivery || false; this.user = ''; this.orgName = ''; @@ -1603,17 +1634,17 @@ connection.prototype.handleMessage = function (msginfo) { switch (type) { case 'txt': var receiveMsg = msgBody.msg; - if (self.encrypt.enabled) { - var option = { - iv: aes_iv, - mode: CryptoJS.mode.CBC, - padding: CryptoJS.pad.Pkcs7 - } - var encryptedBase64Str = receiveMsg; - var decryptedData = CryptoJS.AES.decrypt(encryptedBase64Str, aes_key, option); - var decryptedStr = decryptedData.toString(CryptoJS.enc.Utf8); - receiveMsg = decryptedStr; - } + // if (self.encrypt.enabled) { + // var option = { + // iv: aes_iv, + // mode: CryptoJS.mode.CBC, + // padding: CryptoJS.pad.Pkcs7 + // } + // var encryptedBase64Str = receiveMsg; + // var decryptedData = CryptoJS.AES.decrypt(encryptedBase64Str, aes_key, option); + // var decryptedStr = decryptedData.toString(CryptoJS.enc.Utf8); + // receiveMsg = decryptedStr; + // } var emojibody = _utils.parseTextMessage(receiveMsg, WebIM.Emoji); if (emojibody.isemoji) { var msg = { @@ -3702,21 +3733,16 @@ Strophe.Connection.prototype._sasl_auth1_cb = function (elem) { // Strophe.Connection.prototype._sasl_bind_cb = function (elem) { - console.log(elem) if (elem.getAttribute("type") == "error") { var errors = elem.getElementsByTagName("error"); - console.log(errors, errors[0].getAttribute("code")) var code = errors[0].getAttribute("code") if (code == "413" && test_num == 0) { var texts = elem.getElementsByTagName("text"); - console.log(texts) var pub_key = Strophe.getText(texts[0]) - console.log('pub_key', pub_key) this._addSysHandler(this._sasl_bind_cb.bind(this), null, null, null, "_bind_auth_2"); let encrypt_key = getRandomKey(Demo.conn, pub_key) - console.log('encrypt_key', encrypt_key) var resource = Strophe.getResourceFromJid(this.jid); if (resource) { this.send($iq({type: "set", id: "_bind_auth_2"}) diff --git a/sdk/src/message.js b/sdk/src/message.js index fd3c1035..e4508ad6 100755 --- a/sdk/src/message.js +++ b/sdk/src/message.js @@ -258,7 +258,7 @@ var CryptoJS = require('crypto-js'); , ext: message.ext || {} }; var jsonstr = _utils.stringify(json); - if (message.type === 'txt' && conn.encrypt.enabled) { + if (conn.encrypt.enabled) { var option = { iv: conn.context.aes_iv, mode: CryptoJS.mode.CBC, From 60b24ec750ee28863b2aebced750b946c0826923 Mon Sep 17 00:00:00 2001 From: wk3368 Date: Fri, 18 Aug 2017 10:54:11 +0800 Subject: [PATCH 15/23] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/javascript/dist/webim.config.js | 11 ++--- sdk/src/connection.js | 69 +++++----------------------- sdk/src/message.js | 4 +- 3 files changed, 16 insertions(+), 68 deletions(-) diff --git a/demo/javascript/dist/webim.config.js b/demo/javascript/dist/webim.config.js index 32117514..e2663e29 100755 --- a/demo/javascript/dist/webim.config.js +++ b/demo/javascript/dist/webim.config.js @@ -61,12 +61,12 @@ WebIM.config = { * isSandBox=false: xmppURL: 'im-api.easemob.com', apiURL: '//a1.easemob.com', * @parameter {Boolean} true or false */ - isSandBox: false, + isSandBox: true, /** * Whether to console.log in strophe.log() * @parameter {Boolean} true or false */ - isDebug: true, + isDebug: false, /** * will auto connect the xmpp server autoReconnectNumMax times in background when client is offline. * won't auto connect if autoReconnectNumMax=0. @@ -105,14 +105,9 @@ WebIM.config = { read: true, /** - * Will encrypt text message and emoji message - * {type:'none'} no encrypt - * {type:'base64'} encrypt with base64 - * {type:'aes',mode: 'ebc',key: '123456789easemob',iv: '0000000000000000'} encrypt with aes(ebc) - * {type:'aes',mode: 'cbc',key: '123456789easemob',iv: '0000000000000000'} encrypt with aes(cbc) + * Whether encrypt/decrypt the message during transfer */ encrypt: { enabled: true, - type: 'aes' } }; diff --git a/sdk/src/connection.js b/sdk/src/connection.js index 9ca7bc1f..ef663536 100755 --- a/sdk/src/connection.js +++ b/sdk/src/connection.js @@ -102,12 +102,9 @@ Strophe.Websocket.prototype._onMessage = function (message) { } else { var data_decrypted = null if (WebIM.config.encrypt.enabled) { - // var test = "4hdALtL5l9I93HKQaxaYoTbWXPh8IDCFBRfOHMkGYDQg93YYgzHi3N5zR6tRmoOJsFVzI4n+KYmjMHKKd27La6fL5vzcoVrDSxvVR4HddZgoIOyg61UfdkYiblflqbvGKHN3Y7/KRn9rGPaUQy00LQ==" - // test = "{'from':'zzf1','to':'zzf3','bodies':[{}],'ext':{'weichat':{'originType':'webim'}}}351158306766586140{'xmlns':'urn:xmpp:receipts','id':'351158306766586140'}" - // console.log(message.data) - let pos1 = message.data.indexOf("") + 6 - let pos2 = message.data.indexOf("") + var pos1 = message.data.indexOf("") + 6 + var pos2 = message.data.indexOf("") if (pos1 > 6 && pos2 > 6) { var body = message.data.substr(pos1, pos2 - pos1) @@ -123,7 +120,7 @@ Strophe.Websocket.prototype._onMessage = function (message) { // message.data 是只读的 直接修改message.data=temp 会报错: // Uncaught TypeError: Cannot assign to read only property 'data' of object '#' data_decrypted = new Array(message.data.substr(0, pos1), body, message.data.substr(pos2)).join("") - console.log(data_decrypted) + body = null } } if (data_decrypted) { @@ -131,7 +128,11 @@ Strophe.Websocket.prototype._onMessage = function (message) { } else { data = this._streamWrap(message.data); } + + elem = new DOMParser().parseFromString(data, "text/xml").documentElement; + data_decrypted = null + data = null // console.log(elem) if (this._check_streamerror(elem, Strophe.Status.ERROR)) { @@ -149,41 +150,6 @@ Strophe.Websocket.prototype._onMessage = function (message) { return; } - //log aes message into localstorage - // if (message.data.indexOf('msg') > 0 && message.data.indexOf('type') > 0) { - // var body, objValue, text, option, decryptedData - // body = elem.getElementsByTagName('body')[0]; - // if (body && body.innerHTML) { - // objValue = JSON.parse(body.innerHTML) - // // console.log('objValue', objValue) - // if (objValue.bodies[0].type === 'txt') { - // text = objValue.bodies[0].msg; - // if (WebIM.config.encrypt.type === 'base64') { - // text = atob(text); - // } else if (WebIM.config.encrypt.type === 'aes') { - // option = { - // iv: aes_iv, - // mode: CryptoJS.mode.CBC, - // padding: CryptoJS.pad.Pkcs7 - // } - // - // decryptedData = CryptoJS.AES.decrypt(text, aes_key, option); - // text = decryptedData.toString(CryptoJS.enc.Utf8); - // - // // console.log('text', text) - // if (WebIM && WebIM.config.isDebug && window.localStorage) { - // window.localStorage.setItem(recv_num++, text) - // } - // - // } - // } - // } - // body = null - // objValue = null - // text = null - // option = null - // decryptedData = null - // } } this._conn._dataRecv(elem, message.data); @@ -424,7 +390,6 @@ var rsa_encrypt = function (target, pub_key) { var getRandomKey = function (conn, pub_key) { conn.context.aes_iv = CryptoJS.enc.Utf8.parse('0000000000000000'); conn.context.aes_key_str = new Array(new Date().getTime(), Math.random().toString().substr(2, 2)).join("_") - console.log('aes_key_str', conn.context.aes_key_str) conn.context.aes_key = CryptoJS.enc.Utf8.parse(conn.context.aes_key_str); @@ -1634,17 +1599,7 @@ connection.prototype.handleMessage = function (msginfo) { switch (type) { case 'txt': var receiveMsg = msgBody.msg; - // if (self.encrypt.enabled) { - // var option = { - // iv: aes_iv, - // mode: CryptoJS.mode.CBC, - // padding: CryptoJS.pad.Pkcs7 - // } - // var encryptedBase64Str = receiveMsg; - // var decryptedData = CryptoJS.AES.decrypt(encryptedBase64Str, aes_key, option); - // var decryptedStr = decryptedData.toString(CryptoJS.enc.Utf8); - // receiveMsg = decryptedStr; - // } + var emojibody = _utils.parseTextMessage(receiveMsg, WebIM.Emoji); if (emojibody.isemoji) { var msg = { @@ -3811,13 +3766,11 @@ if (WebIM && WebIM.config.isDebug) { } if (WebIM && WebIM.config && WebIM.config.isSandBox) { - WebIM.config.xmppURL = WebIM.config.xmppURL.replace('.easemob.', '-sandbox.easemob.'); - WebIM.config.apiURL = WebIM.config.apiURL.replace('.easemob.', '-sdb.easemob.'); + // WebIM.config.xmppURL = '118.193.28.212:31093'; //非加密版本 + WebIM.config.xmppURL = '118.193.28.212:31293'; //加密版本 + WebIM.config.apiURL = '//118.193.28.212:31080'; } -WebIM.config.apiURL = '//118.193.28.212:31080'; -WebIM.config.xmppURL = '118.193.28.212:31293'; //加密版本 -// WebIM.config.xmppURL = '118.193.28.212:31093'; //非加密版本 module.exports = WebIM; diff --git a/sdk/src/message.js b/sdk/src/message.js index e4508ad6..6c30b3e7 100755 --- a/sdk/src/message.js +++ b/sdk/src/message.js @@ -265,8 +265,8 @@ var CryptoJS = require('crypto-js'); padding: CryptoJS.pad.Pkcs7 }; var encryptedData = CryptoJS.AES.encrypt(jsonstr, conn.context.aes_key, option); - console.log(conn.context.aes_key_str, jsonstr, encryptedData.toString()) jsonstr = encryptedData.toString(); + encryptedData = null } dom = $msg({ type: message.group || 'chat' @@ -274,7 +274,7 @@ var CryptoJS = require('crypto-js'); , id: message.id , xmlns: 'jabber:client' }).c('body').t(jsonstr); - + jsonstr = null if (message.roomType) { dom.up().c('roomtype', {xmlns: 'easemob:x:roomtype', type: 'chatroom'}); } From 4b1f5897293b31197921dd2cb0971b8cb3dcbfc2 Mon Sep 17 00:00:00 2001 From: wk3368 Date: Wed, 23 Aug 2017 15:33:07 +0800 Subject: [PATCH 16/23] =?UTF-8?q?aes=E5=88=86=E6=94=AF=E7=9A=84=E6=B2=99?= =?UTF-8?q?=E7=AE=B1=E5=8F=91=E5=B8=83=20http://47.93.126.28:18025?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.drone.yml b/.drone.yml index bee9b3ee..0eb43e89 100644 --- a/.drone.yml +++ b/.drone.yml @@ -39,7 +39,7 @@ pipeline: - cp -rf publish image/docker/webim/webim - echo 'build success' when: - branch: [ dev, online ] + branch: [ aes, online ] dockerize-latest: @@ -48,24 +48,24 @@ pipeline: - DOCKER_LAUNCH_DEBUG=true debug: true repo: docker-registry-cn.easemob.com/kubernetes/im/webim - tags: latest + tags: aes registry: docker-registry-cn.easemob.com secrets: [ docker_username, docker_password ] dockerfile: image/docker/webim/Dockerfile context: image/docker/webim/ when: - branch: dev + branch: aes deploy-latest: image: docker-registry-cn.easemob.com/kubernetes/im/webim-deploy:latest pull: true environment: - DOCKER_LAUNCH_DEBUG=true - - TAG=latest + - TAG=aes secrets: [ ssh_key, jumpserver_host, jumpserver_port, sandbox_host ] debug: true when: - branch: dev + branch: aes dockerize-online: image: plugins/docker From c53d255f4297273d717d81a078688d930af65d4b Mon Sep 17 00:00:00 2001 From: wk3368 Date: Thu, 24 Aug 2017 12:03:35 +0800 Subject: [PATCH 17/23] =?UTF-8?q?=E9=80=9A=E8=BF=87=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E6=8E=A7=E5=88=B6docker=E7=9A=84=E6=B2=99?= =?UTF-8?q?=E7=AE=B1=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/javascript/dist/webim.config.js | 11 +++++++---- sdk/src/connection.js | 10 +++++----- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/demo/javascript/dist/webim.config.js b/demo/javascript/dist/webim.config.js index e2663e29..bc9573a3 100755 --- a/demo/javascript/dist/webim.config.js +++ b/demo/javascript/dist/webim.config.js @@ -10,13 +10,16 @@ WebIM.config = { /* * XMPP server */ - // xmppURL: 'im-api.easemob.com', - xmppURL: 'zy-imapi.easemob.com', + xmppURL: 'im-api.easemob.com', + // xmppURL: '118.193.28.212:31093', //非加密版本 + // xmppURL: '118.193.28.212:31293', //加密版本 + /* * Backend REST API URL */ - // apiURL: (location.protocol === 'https:' ? 'https:' : 'http:') + '//a1.easemob.com', - apiURL: (location.protocol === 'https:' ? 'https:' : 'http:') + '//zy-a1.easemob.com', + apiURL: (location.protocol === 'https:' ? 'https:' : 'http:') + '//a1.easemob.com', + // apiURL: (location.protocol === 'https:' ? 'https:' : 'http:') + '//118.193.28.212:31080', + /* * Application AppKey */ diff --git a/sdk/src/connection.js b/sdk/src/connection.js index ef663536..0da7a3fb 100755 --- a/sdk/src/connection.js +++ b/sdk/src/connection.js @@ -3765,11 +3765,11 @@ if (WebIM && WebIM.config.isDebug) { } } -if (WebIM && WebIM.config && WebIM.config.isSandBox) { - // WebIM.config.xmppURL = '118.193.28.212:31093'; //非加密版本 - WebIM.config.xmppURL = '118.193.28.212:31293'; //加密版本 - WebIM.config.apiURL = '//118.193.28.212:31080'; -} +// if (WebIM && WebIM.config && WebIM.config.isSandBox) { +// // WebIM.config.xmppURL = '118.193.28.212:31093'; //非加密版本 +// WebIM.config.xmppURL = '118.193.28.212:31293'; //加密版本 +// WebIM.config.apiURL = '//118.193.28.212:31080'; +// } module.exports = WebIM; From aec874208646dec48f30c3bfb994ffee48591025 Mon Sep 17 00:00:00 2001 From: wk3368 Date: Thu, 24 Aug 2017 12:24:02 +0800 Subject: [PATCH 18/23] =?UTF-8?q?=E9=9D=9E=E5=8A=A0=E5=AF=86=E7=89=88?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/javascript/dist/webim.config.js | 13 +++--- sdk/src/connection.js | 59 +++++++++++++++++----------- sdk/src/message.js | 2 +- 3 files changed, 42 insertions(+), 32 deletions(-) diff --git a/demo/javascript/dist/webim.config.js b/demo/javascript/dist/webim.config.js index bc9573a3..6186434f 100755 --- a/demo/javascript/dist/webim.config.js +++ b/demo/javascript/dist/webim.config.js @@ -10,15 +10,15 @@ WebIM.config = { /* * XMPP server */ - xmppURL: 'im-api.easemob.com', - // xmppURL: '118.193.28.212:31093', //非加密版本 + // xmppURL: 'im-api.easemob.com', + xmppURL: '118.193.28.212:31093', //非加密版本 // xmppURL: '118.193.28.212:31293', //加密版本 /* * Backend REST API URL */ - apiURL: (location.protocol === 'https:' ? 'https:' : 'http:') + '//a1.easemob.com', - // apiURL: (location.protocol === 'https:' ? 'https:' : 'http:') + '//118.193.28.212:31080', + // apiURL: (location.protocol === 'https:' ? 'https:' : 'http:') + '//a1.easemob.com', + apiURL: (location.protocol === 'https:' ? 'https:' : 'http:') + '//118.193.28.212:31080', /* * Application AppKey @@ -110,7 +110,6 @@ WebIM.config = { /** * Whether encrypt/decrypt the message during transfer */ - encrypt: { - enabled: true, - } + encrypt: false, + }; diff --git a/sdk/src/connection.js b/sdk/src/connection.js index 0da7a3fb..298325a0 100755 --- a/sdk/src/connection.js +++ b/sdk/src/connection.js @@ -101,7 +101,7 @@ Strophe.Websocket.prototype._onMessage = function (message) { } } else { var data_decrypted = null - if (WebIM.config.encrypt.enabled) { + if (WebIM.config.encrypt) { var pos1 = message.data.indexOf("") + 6 var pos2 = message.data.indexOf("") @@ -418,11 +418,6 @@ var _login = function (options, conn) { conn.context.accessToken = options.access_token; conn.context.accessTokenExpires = options.expires_in; - // if (WebIM.config.encrypt.enabled && !conn.encrypt.mode) { - // _getAESKey(options, conn) - // return - // } - var stropheConn = null; if (conn.isOpening() && conn.context.stropheConn) { @@ -3661,15 +3656,23 @@ Strophe.Connection.prototype._sasl_auth1_cb = function (elem) { // console.log(key) var resource = Strophe.getResourceFromJid(this.jid); if (resource) { - this.send($iq({type: "set", id: "_bind_auth_2"}) - .c('bind', {xmlns: Strophe.NS.BIND}) - .c('resource', {}).t(resource) - .up() - .c('encrypt_type', {}).t("ENCRYPT_NONE") - .up() - .c('encrypt_key', {}).t('') - .up() - .tree()); + if (WebIM.config.encrypt) { + this.send($iq({type: "set", id: "_bind_auth_2"}) + .c('bind', {xmlns: Strophe.NS.BIND}) + .c('resource', {}).t(resource) + .up() + .c('encrypt_type', {}).t("ENCRYPT_NONE") + .up() + .c('encrypt_key', {}).t('') + .up() + .tree()); + } else { + this.send($iq({type: "set", id: "_bind_auth_2"}) + .c('bind', {xmlns: Strophe.NS.BIND}) + .c('resource', {}).t(resource) + .up() + .tree()); + } } else { this.send($iq({type: "set", id: "_bind_auth_2"}) .c('bind', {xmlns: Strophe.NS.BIND}) @@ -3700,15 +3703,23 @@ Strophe.Connection.prototype._sasl_bind_cb = function (elem) { let encrypt_key = getRandomKey(Demo.conn, pub_key) var resource = Strophe.getResourceFromJid(this.jid); if (resource) { - this.send($iq({type: "set", id: "_bind_auth_2"}) - .c('bind', {xmlns: Strophe.NS.BIND}) - .c('resource', {}).t(resource) - .up() - .c('encrypt_type', {}).t("ENCRYPT_AES_128_CBC") - .up() - .c('encrypt_key', {}).t(encrypt_key) - .up() - .tree()); + if (WebIM.config.encrypt) { + this.send($iq({type: "set", id: "_bind_auth_2"}) + .c('bind', {xmlns: Strophe.NS.BIND}) + .c('resource', {}).t(resource) + .up() + .c('encrypt_type', {}).t("ENCRYPT_AES_128_CBC") + .up() + .c('encrypt_key', {}).t(encrypt_key) + .up() + .tree()); + } else { + this.send($iq({type: "set", id: "_bind_auth_2"}) + .c('bind', {xmlns: Strophe.NS.BIND}) + .c('resource', {}).t(resource) + .up() + .tree()); + } } else { this.send($iq({type: "set", id: "_bind_auth_2"}) .c('bind', {xmlns: Strophe.NS.BIND}) diff --git a/sdk/src/message.js b/sdk/src/message.js index 6c30b3e7..de5df5df 100755 --- a/sdk/src/message.js +++ b/sdk/src/message.js @@ -258,7 +258,7 @@ var CryptoJS = require('crypto-js'); , ext: message.ext || {} }; var jsonstr = _utils.stringify(json); - if (conn.encrypt.enabled) { + if (conn.encrypt) { var option = { iv: conn.context.aes_iv, mode: CryptoJS.mode.CBC, From 9d50ee95123d24a7f17f309e455233a129f6c243 Mon Sep 17 00:00:00 2001 From: wk3368 Date: Thu, 24 Aug 2017 16:55:03 +0800 Subject: [PATCH 19/23] =?UTF-8?q?=E5=8A=A0=E5=AF=86=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/javascript/dist/webim.config.js | 4 +++- sdk/src/connection.js | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/demo/javascript/dist/webim.config.js b/demo/javascript/dist/webim.config.js index 6186434f..a4aee505 100755 --- a/demo/javascript/dist/webim.config.js +++ b/demo/javascript/dist/webim.config.js @@ -110,6 +110,8 @@ WebIM.config = { /** * Whether encrypt/decrypt the message during transfer */ - encrypt: false, + encrypt: { + enabled: true + } }; diff --git a/sdk/src/connection.js b/sdk/src/connection.js index 298325a0..215fa41b 100755 --- a/sdk/src/connection.js +++ b/sdk/src/connection.js @@ -101,7 +101,7 @@ Strophe.Websocket.prototype._onMessage = function (message) { } } else { var data_decrypted = null - if (WebIM.config.encrypt) { + if (WebIM.config.encrypt.enabled) { var pos1 = message.data.indexOf("") + 6 var pos2 = message.data.indexOf("") @@ -388,6 +388,7 @@ var rsa_encrypt = function (target, pub_key) { var getRandomKey = function (conn, pub_key) { + conn.context.aes_iv = CryptoJS.enc.Utf8.parse('0000000000000000'); conn.context.aes_key_str = new Array(new Date().getTime(), Math.random().toString().substr(2, 2)).join("_") @@ -3656,7 +3657,7 @@ Strophe.Connection.prototype._sasl_auth1_cb = function (elem) { // console.log(key) var resource = Strophe.getResourceFromJid(this.jid); if (resource) { - if (WebIM.config.encrypt) { + if (WebIM.config.encrypt.enabled) { this.send($iq({type: "set", id: "_bind_auth_2"}) .c('bind', {xmlns: Strophe.NS.BIND}) .c('resource', {}).t(resource) @@ -3701,9 +3702,10 @@ Strophe.Connection.prototype._sasl_bind_cb = function (elem) { null, "_bind_auth_2"); let encrypt_key = getRandomKey(Demo.conn, pub_key) + var resource = Strophe.getResourceFromJid(this.jid); if (resource) { - if (WebIM.config.encrypt) { + if (WebIM.config.encrypt.enabled) { this.send($iq({type: "set", id: "_bind_auth_2"}) .c('bind', {xmlns: Strophe.NS.BIND}) .c('resource', {}).t(resource) From a2d6b8cf3dcb9514a23d7def01f4310bf9116dcf Mon Sep 17 00:00:00 2001 From: wk3368 Date: Thu, 24 Aug 2017 17:35:30 +0800 Subject: [PATCH 20/23] =?UTF-8?q?=E5=8A=A0=E5=AF=86=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E6=9D=A1=E4=BB=B6=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sdk/src/connection.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sdk/src/connection.js b/sdk/src/connection.js index 215fa41b..6e5acc24 100755 --- a/sdk/src/connection.js +++ b/sdk/src/connection.js @@ -3620,7 +3620,6 @@ WebIM.doQuery = function (str, suc, fail) { ); }; -var test_num = 0; // ENCRYPT_NONE = 0; // ENCRYPT_AES_128_CBC = 1; //defaule encryption type. // ENCRYPT_AES_256_CBC = 2; // @@ -3695,7 +3694,7 @@ Strophe.Connection.prototype._sasl_bind_cb = function (elem) { if (elem.getAttribute("type") == "error") { var errors = elem.getElementsByTagName("error"); var code = errors[0].getAttribute("code") - if (code == "413" && test_num == 0) { + if (code == "413") { var texts = elem.getElementsByTagName("text"); var pub_key = Strophe.getText(texts[0]) this._addSysHandler(this._sasl_bind_cb.bind(this), null, null, @@ -3727,7 +3726,6 @@ Strophe.Connection.prototype._sasl_bind_cb = function (elem) { .c('bind', {xmlns: Strophe.NS.BIND}) .tree()); } - test_num++ } else { Strophe.info("SASL binding failed."); var conflict = elem.getElementsByTagName("conflict"), condition; From 419bdbc05e6d1fa30a18adc9fa6b9aa5d3899aa9 Mon Sep 17 00:00:00 2001 From: wk3368 Date: Wed, 30 Aug 2017 17:10:48 +0800 Subject: [PATCH 21/23] =?UTF-8?q?=E4=B8=8D=E5=8A=A0=E5=AF=86=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=EF=BC=8C=E6=AD=A3=E5=B8=B8=E8=AE=BF=E9=97=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sdk/src/message.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/src/message.js b/sdk/src/message.js index de5df5df..6c30b3e7 100755 --- a/sdk/src/message.js +++ b/sdk/src/message.js @@ -258,7 +258,7 @@ var CryptoJS = require('crypto-js'); , ext: message.ext || {} }; var jsonstr = _utils.stringify(json); - if (conn.encrypt) { + if (conn.encrypt.enabled) { var option = { iv: conn.context.aes_iv, mode: CryptoJS.mode.CBC, From 93d37a627cf3b06d0218c492e2e9fa705f86723f Mon Sep 17 00:00:00 2001 From: wk3368 Date: Wed, 30 Aug 2017 17:11:31 +0800 Subject: [PATCH 22/23] =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=99=A8=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E9=94=99=E8=AF=AF=E4=BB=A3=E7=A0=81413=EF=BC=88fail?= =?UTF-8?q?=EF=BC=89=E6=94=B9=E6=88=90412(enable)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sdk/src/connection.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/src/connection.js b/sdk/src/connection.js index 6e5acc24..061d072b 100755 --- a/sdk/src/connection.js +++ b/sdk/src/connection.js @@ -3682,7 +3682,7 @@ Strophe.Connection.prototype._sasl_auth1_cb = function (elem) { return false; }; -//webimENCRYPT_NONE-----BEGIN PUBLIC KEY----- +//webimENCRYPT_NONE-----BEGIN PUBLIC KEY----- // MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDJPMdGcWfQ4JAY0IWY/Z+umUF7 // J48Lk0yY/XjTG8d1Pbqio8t/4lGhNem3obefXe4KpRGjNUZ6kVKwebyUmAsdT1iC // jTI1ZbcUXVPwoE8IiYIP6mGEgdvzDr4ly8yBRHYFn8WMyeP+4KsQHuyQmZ54VToS @@ -3694,7 +3694,7 @@ Strophe.Connection.prototype._sasl_bind_cb = function (elem) { if (elem.getAttribute("type") == "error") { var errors = elem.getElementsByTagName("error"); var code = errors[0].getAttribute("code") - if (code == "413") { + if (code == "412") { var texts = elem.getElementsByTagName("text"); var pub_key = Strophe.getText(texts[0]) this._addSysHandler(this._sasl_bind_cb.bind(this), null, null, From 93deeae5ac5b0d566efa9323fddf499178499d94 Mon Sep 17 00:00:00 2001 From: wk3368 Date: Wed, 30 Aug 2017 19:53:34 +0800 Subject: [PATCH 23/23] =?UTF-8?q?connection.encrypt=20=E5=92=8C=20strophe.?= =?UTF-8?q?connection.options.encrypt=E6=98=AF=E5=BC=95=E7=94=A8=E5=85=B3?= =?UTF-8?q?=E7=B3=BB=EF=BC=8C=E4=BA=92=E7=9B=B8=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/javascript/dist/webim.config.js | 9 +---- demo/javascript/src/entry.js | 1 - sdk/src/connection.js | 54 ++++++++++++---------------- sdk/src/message.js | 4 +-- 4 files changed, 26 insertions(+), 42 deletions(-) diff --git a/demo/javascript/dist/webim.config.js b/demo/javascript/dist/webim.config.js index a4aee505..8e62042c 100755 --- a/demo/javascript/dist/webim.config.js +++ b/demo/javascript/dist/webim.config.js @@ -105,13 +105,6 @@ WebIM.config = { * sender, in order to tell the sender the message has been read. * See call back function onReadMessage */ - read: true, - - /** - * Whether encrypt/decrypt the message during transfer - */ - encrypt: { - enabled: true - } + read: true }; diff --git a/demo/javascript/src/entry.js b/demo/javascript/src/entry.js index 64f817d9..9e1ddae9 100755 --- a/demo/javascript/src/entry.js +++ b/demo/javascript/src/entry.js @@ -131,7 +131,6 @@ Demo.conn = new WebIM.connection({ isHttpDNS: WebIM.config.isHttpDNS, isWindowSDK: WebIM.config.isWindowSDK, isAutoLogin: true, - encrypt: WebIM.config.encrypt, delivery: WebIM.config.delivery }); diff --git a/sdk/src/connection.js b/sdk/src/connection.js index 061d072b..8dab1872 100755 --- a/sdk/src/connection.js +++ b/sdk/src/connection.js @@ -101,7 +101,7 @@ Strophe.Websocket.prototype._onMessage = function (message) { } } else { var data_decrypted = null - if (WebIM.config.encrypt.enabled) { + if (this._conn.options.encrypt.enabled) { var pos1 = message.data.indexOf("") + 6 var pos2 = message.data.indexOf("") @@ -109,12 +109,12 @@ Strophe.Websocket.prototype._onMessage = function (message) { var body = message.data.substr(pos1, pos2 - pos1) var option = { - iv: WebIM.config.encrypt.aes_iv, + iv: this._conn.options.encrypt.aes_iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 } - var decryptedData = CryptoJS.AES.decrypt(body, WebIM.config.encrypt.aes_key, option); + var decryptedData = CryptoJS.AES.decrypt(body, this._conn.options.encrypt.aes_key, option); body = decryptedData.toString(CryptoJS.enc.Utf8); // message.data 是只读的 直接修改message.data=temp 会报错: @@ -389,17 +389,13 @@ var rsa_encrypt = function (target, pub_key) { var getRandomKey = function (conn, pub_key) { - conn.context.aes_iv = CryptoJS.enc.Utf8.parse('0000000000000000'); - conn.context.aes_key_str = new Array(new Date().getTime(), Math.random().toString().substr(2, 2)).join("_") + conn.encrypt.aes_iv = CryptoJS.enc.Utf8.parse('0000000000000000'); + conn.encrypt.aes_key_str = new Array(new Date().getTime(), Math.random().toString().substr(2, 2)).join("_") + conn.encrypt.aes_key = CryptoJS.enc.Utf8.parse(conn.encrypt.aes_key_str); - conn.context.aes_key = CryptoJS.enc.Utf8.parse(conn.context.aes_key_str); - - WebIM.config.encrypt.aes_iv = conn.context.aes_iv - WebIM.config.encrypt.aes_key_str = conn.context.aes_key_str - WebIM.config.encrypt.aes_key = conn.context.aes_key //rsa 返回的 已经是base4加密过的字符串了 - var encryped = rsa_encrypt(conn.context.aes_key_str, pub_key) + var encryped = rsa_encrypt(conn.encrypt.aes_key_str, pub_key) return encryped @@ -782,7 +778,6 @@ var connection = function (options) { this.apiUrl = options.apiUrl || ''; this.context.apiUrl = this.apiUrl; this.isWindowSDK = options.isWindowSDK || false; - this.encrypt = options.encrypt; this.delivery = options.delivery || false; this.user = ''; this.orgName = ''; @@ -800,6 +795,7 @@ var connection = function (options) { this.xmppTotal = 0; //max number of creating xmpp server connection(ws/bosh) retries this.groupOption = {}; + this.encrypt = {enabled: false}; }; connection.prototype.registerUser = function (options) { @@ -916,7 +912,8 @@ connection.prototype.getStrophe = function () { var stropheConn = new Strophe.Connection(this.url, { inactivity: this.inactivity, maxRetries: this.maxRetries, - pollingTime: this.pollingTime + pollingTime: this.pollingTime, + encrypt: this.encrypt }); return stropheConn; }; @@ -3656,23 +3653,17 @@ Strophe.Connection.prototype._sasl_auth1_cb = function (elem) { // console.log(key) var resource = Strophe.getResourceFromJid(this.jid); if (resource) { - if (WebIM.config.encrypt.enabled) { - this.send($iq({type: "set", id: "_bind_auth_2"}) - .c('bind', {xmlns: Strophe.NS.BIND}) - .c('resource', {}).t(resource) - .up() - .c('encrypt_type', {}).t("ENCRYPT_NONE") - .up() - .c('encrypt_key', {}).t('') - .up() - .tree()); - } else { - this.send($iq({type: "set", id: "_bind_auth_2"}) - .c('bind', {xmlns: Strophe.NS.BIND}) - .c('resource', {}).t(resource) - .up() - .tree()); - } + this.options.encrypt.enabled = false; + // 新版发ENCRYPT_NONE 旧版不发 以服务器的加密与否为准 + this.send($iq({type: "set", id: "_bind_auth_2"}) + .c('bind', {xmlns: Strophe.NS.BIND}) + .c('resource', {}).t(resource) + .up() + .c('encrypt_type', {}).t("ENCRYPT_NONE") + .up() + .c('encrypt_key', {}).t('') + .up() + .tree()); } else { this.send($iq({type: "set", id: "_bind_auth_2"}) .c('bind', {xmlns: Strophe.NS.BIND}) @@ -3695,6 +3686,7 @@ Strophe.Connection.prototype._sasl_bind_cb = function (elem) { var errors = elem.getElementsByTagName("error"); var code = errors[0].getAttribute("code") if (code == "412") { + this.options.encrypt.enabled = true; var texts = elem.getElementsByTagName("text"); var pub_key = Strophe.getText(texts[0]) this._addSysHandler(this._sasl_bind_cb.bind(this), null, null, @@ -3704,7 +3696,7 @@ Strophe.Connection.prototype._sasl_bind_cb = function (elem) { var resource = Strophe.getResourceFromJid(this.jid); if (resource) { - if (WebIM.config.encrypt.enabled) { + if (this.options.encrypt.enabled) { this.send($iq({type: "set", id: "_bind_auth_2"}) .c('bind', {xmlns: Strophe.NS.BIND}) .c('resource', {}).t(resource) diff --git a/sdk/src/message.js b/sdk/src/message.js index 6c30b3e7..575ddce1 100755 --- a/sdk/src/message.js +++ b/sdk/src/message.js @@ -260,11 +260,11 @@ var CryptoJS = require('crypto-js'); var jsonstr = _utils.stringify(json); if (conn.encrypt.enabled) { var option = { - iv: conn.context.aes_iv, + iv: conn.encrypt.aes_iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 }; - var encryptedData = CryptoJS.AES.encrypt(jsonstr, conn.context.aes_key, option); + var encryptedData = CryptoJS.AES.encrypt(jsonstr, conn.encrypt.aes_key, option); jsonstr = encryptedData.toString(); encryptedData = null }