@zegocloud/zego-uikit-prebuilt 1.7.3 → 1.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/zego-uikit-prebuilt.js +1 -1
package/package.json
CHANGED
package/zego-uikit-prebuilt.js
CHANGED
|
@@ -2168,7 +2168,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
|
2168
2168
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
2169
2169
|
|
|
2170
2170
|
"use strict";
|
|
2171
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"DateFormat\": function() { return /* binding */ DateFormat; },\n/* harmony export */ \"IsLowVersionSafari\": function() { return /* binding */ IsLowVersionSafari; },\n/* harmony export */ \"chooseFile\": function() { return /* binding */ chooseFile; },\n/* harmony export */ \"generatePrebuiltToken\": function() { return /* binding */ generatePrebuiltToken; },\n/* harmony export */ \"getBrowser\": function() { return /* binding */ getBrowser; },\n/* harmony export */ \"getNameFirstLetter\": function() { return /* binding */ getNameFirstLetter; },\n/* harmony export */ \"getUrlParams\": function() { return /* binding */ getUrlParams; },\n/* harmony export */ \"getVideoResolution\": function() { return /* binding */ getVideoResolution; },\n/* harmony export */ \"isAndroid\": function() { return /* binding */ isAndroid; },\n/* harmony export */ \"isFireFox\": function() { return /* binding */ isFireFox; },\n/* harmony export */ \"isIOS\": function() { return /* binding */ isIOS; },\n/* harmony export */ \"isPc\": function() { return /* binding */ isPc; },\n/* harmony export */ \"isSafari\": function() { return /* binding */ isSafari; },\n/* harmony export */ \"randomNumber\": function() { return /* binding */ randomNumber; },\n/* harmony export */ \"runes\": function() { return /* binding */ runes; },\n/* harmony export */ \"throttle\": function() { return /* binding */ throttle; },\n/* harmony export */ \"userNameColor\": function() { return /* binding */ userNameColor; }\n/* harmony export */ });\n/* harmony import */ var crypto_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! crypto-js */ \"./node_modules/crypto-js/index.js\");\n/* harmony import */ var crypto_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(crypto_js__WEBPACK_IMPORTED_MODULE_0__);\n/* eslint-disable no-cond-assign */\n\nfunction randomNumber(len) {\n var result = \"\";\n var chars = \"123456789\", maxPos = chars.length, i;\n len = len || 5;\n for (i = 0; i < len; i++) {\n result += chars.charAt(Math.floor(Math.random() * maxPos));\n }\n return Number.parseInt(result);\n}\nfunction isPc() {\n var p = navigator.platform;\n var system = { win: p.indexOf(\"Win\") === 0, mac: p.indexOf(\"Mac\") === 0 };\n if (false) {}\n return system.win || system.mac;\n}\nfunction isIOS() {\n var u = navigator.userAgent;\n return !!u.match(/\\(i[^;]+;( U;)? CPU.+Mac OS X/);\n}\nfunction isAndroid() {\n var u = navigator.userAgent;\n return u.indexOf(\"Android\") > -1 || u.indexOf(\"Adr\") > -1;\n}\nfunction isSafari() {\n return (/Safari/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent));\n}\nfunction isFireFox() {\n var u = navigator.userAgent;\n return !!u.match(/firefox|fxios/i);\n}\nfunction IsLowVersionSafari() {\n var is_safari = navigator.userAgent.toLowerCase().indexOf(\"safari/\") > -1;\n var is_chrome = navigator.userAgent.match(\"CriOS\");\n var is_firefox = navigator.userAgent.match(\"FxiOS\");\n // 获取操作系统版本\n var m1 = navigator.userAgent.match(/iPhone OS .*?(?= )/);\n var version = 0;\n if (m1 && m1.length > 0) {\n try {\n var versionWith_ = m1[0].split(\" \")[m1[0].split(\" \").length - 1];\n var mainVersion = versionWith_.split(\"_\")[0];\n version = Number.parseInt(mainVersion);\n }\n catch (error) {\n console.error(\"【ZEGOCLOUD】get safari version failed\", error);\n }\n }\n return is_safari && !is_chrome && !is_firefox && version < 14;\n}\nfunction DateFormat(date, fmt) {\n var myDate = new Date(date);\n var o = {\n \"M+\": myDate.getMonth() + 1 + \"\",\n \"d+\": myDate.getDate() + \"\",\n \"h+\": myDate.getHours() >= 12\n ? myDate.getHours() - 12 + \"\"\n : myDate.getHours() + \"\",\n \"m+\": myDate.getMinutes() + \"\",\n \"s+\": myDate.getSeconds() + \"\",\n \"q+\": Math.floor((myDate.getMonth() + 3) / 3) + \"\",\n S: myDate.getMilliseconds() + \"\", // 毫秒\n };\n Object.entries(o).forEach(function (_a) {\n var k = _a[0], v = _a[1];\n if (new RegExp(\"(\" + k + \")\").test(fmt)) {\n fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? v : (\"00\" + v).substr((\"\" + v).length));\n }\n });\n return fmt;\n}\nvar userColorMap = {};\nfunction userNameColor(userName) {\n var colorArr = [\n \"#557BFF\",\n \"#1FAD40\",\n \"#06A1E5\",\n \"#E9473A\",\n \"#BB9B21\",\n \"#B755FF\",\n \"#10BD8E\",\n \"#FF2F5F\",\n ];\n if (!userColorMap[userName]) {\n userColorMap[userName] =\n colorArr[Object.keys(userColorMap).length % colorArr.length];\n }\n return userColorMap[userName];\n}\nfunction getUrlParams(url) {\n if (url === void 0) { url = window.location.href; }\n var urlStr = url.split(\"?\")[1];\n return new URLSearchParams(urlStr);\n}\nfunction getVideoResolution(level) {\n var _a = {\n width: 640,\n height: 360,\n bitrate: 400,\n frameRate: 15,\n }, width = _a.width, height = _a.height, bitrate = _a.bitrate, frameRate = _a.frameRate;\n if (level === \"180p\") {\n width = 320;\n height = 180;\n bitrate = 140;\n }\n else if (level === \"360p\") {\n width = 640;\n height = 360;\n bitrate = 400;\n }\n else if (level === \"480p\") {\n width = 640;\n height = 480;\n bitrate = 500;\n }\n else if (level === \"720p\") {\n width = 1280;\n height = 720;\n bitrate = 1130;\n }\n return {\n width: width,\n height: height,\n bitrate: bitrate,\n frameRate: frameRate,\n };\n}\nvar throttle = function (fn, wait) {\n var canRun = true;\n return function () {\n var _this = this;\n if (!canRun)\n return;\n canRun = false;\n setTimeout(function () {\n // @ts-ignore\n fn.apply(_this, arguments);\n canRun = true;\n }, wait);\n };\n};\nfunction getBrowser() {\n var sys = {};\n var ua = navigator.userAgent.toLowerCase();\n var s;\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions, no-cond-assign\n (s = ua.match(/edge\\/([\\d.]+)/))\n ? (sys.edge = s[1])\n : (s = ua.match(/rv:([\\d.]+)\\) like gecko/))\n ? (sys.ie = s[1])\n : (s = ua.match(/msie ([\\d.]+)/))\n ? (sys.ie = s[1])\n : (s = ua.match(/firefox\\/([\\d.]+)/))\n ? (sys.firefox = s[1])\n : (s = ua.match(/chrome\\/([\\d.]+)/))\n ? (sys.chrome = s[1])\n : (s = ua.match(/opera.([\\d.]+)/))\n ? (sys.opera = s[1])\n : (s = ua.match(/version\\/([\\d.]+).*safari/))\n ? (sys.safari = s[1])\n : 0;\n if (sys.edge)\n return { browser: \"Edge\", version: sys.edge };\n if (sys.ie)\n return { browser: \"IE\", version: sys.ie };\n if (sys.firefox)\n return { browser: \"Firefox\", version: sys.firefox };\n if (sys.chrome)\n return { browser: \"Chrome\", version: sys.chrome };\n if (sys.opera)\n return { browser: \"Opera\", version: sys.opera };\n if (sys.safari)\n return { browser: \"Safari\", version: sys.safari };\n return { browser: \"\", version: \"0\" };\n}\nfunction runes(string) {\n var HIGH_SURROGATE_START = 0xd800;\n var HIGH_SURROGATE_END = 0xdbff;\n var LOW_SURROGATE_START = 0xdc00;\n var REGIONAL_INDICATOR_START = 0x1f1e6;\n var REGIONAL_INDICATOR_END = 0x1f1ff;\n var FITZPATRICK_MODIFIER_START = 0x1f3fb;\n var FITZPATRICK_MODIFIER_END = 0x1f3ff;\n var VARIATION_MODIFIER_START = 0xfe00;\n var VARIATION_MODIFIER_END = 0xfe0f;\n var DIACRITICAL_MARKS_START = 0x20d0;\n var DIACRITICAL_MARKS_END = 0x20ff;\n var ZWJ = 0x200d;\n var GRAPHEMS = [\n 0x0308, 0x0937, 0x0937, 0x093f, 0x093f, 0x0ba8, 0x0bbf, 0x0bcd, 0x0e31,\n 0x0e33, 0x0e40, 0x0e49, 0x1100, 0x1161, 0x11a8,\n ];\n function nextUnits(i, string) {\n var current = string[i];\n if (!isFirstOfSurrogatePair(current) || i === string.length - 1) {\n return 1;\n }\n var currentPair = current + string[i + 1];\n var nextPair = string.substring(i + 2, i + 5);\n if (isRegionalIndicator(currentPair) && isRegionalIndicator(nextPair)) {\n return 4;\n }\n if (isFitzpatrickModifier(nextPair)) {\n return 4;\n }\n return 2;\n }\n function isFirstOfSurrogatePair(string) {\n return (string &&\n betweenInclusive(string[0].charCodeAt(0), HIGH_SURROGATE_START, HIGH_SURROGATE_END));\n }\n function isRegionalIndicator(string) {\n return betweenInclusive(codePointFromSurrogatePair(string), REGIONAL_INDICATOR_START, REGIONAL_INDICATOR_END);\n }\n function isFitzpatrickModifier(string) {\n return betweenInclusive(codePointFromSurrogatePair(string), FITZPATRICK_MODIFIER_START, FITZPATRICK_MODIFIER_END);\n }\n function isVariationSelector(string) {\n return (typeof string === \"string\" &&\n betweenInclusive(string.charCodeAt(0), VARIATION_MODIFIER_START, VARIATION_MODIFIER_END));\n }\n function isDiacriticalMark(string) {\n return (typeof string === \"string\" &&\n betweenInclusive(string.charCodeAt(0), DIACRITICAL_MARKS_START, DIACRITICAL_MARKS_END));\n }\n function isGraphem(string) {\n return (typeof string === \"string\" &&\n GRAPHEMS.indexOf(string.charCodeAt(0)) !== -1);\n }\n function isZeroWidthJoiner(string) {\n return typeof string === \"string\" && string.charCodeAt(0) === ZWJ;\n }\n function codePointFromSurrogatePair(pair) {\n var highOffset = pair.charCodeAt(0) - HIGH_SURROGATE_START;\n var lowOffset = pair.charCodeAt(1) - LOW_SURROGATE_START;\n return (highOffset << 10) + lowOffset + 0x10000;\n }\n function betweenInclusive(value, lower, upper) {\n return value >= lower && value <= upper;\n }\n if (typeof string !== \"string\") {\n throw new Error(\"string cannot be undefined or null\");\n }\n var result = [];\n var i = 0;\n var increment = 0;\n while (i < string.length) {\n increment += nextUnits(i + increment, string);\n if (isGraphem(string[i + increment])) {\n increment++;\n }\n if (isVariationSelector(string[i + increment])) {\n increment++;\n }\n if (isDiacriticalMark(string[i + increment])) {\n increment++;\n }\n if (isZeroWidthJoiner(string[i + increment])) {\n increment++;\n continue;\n }\n result.push(string.substring(i, i + increment));\n i += increment;\n increment = 0;\n }\n return result;\n}\nfunction getNameFirstLetter(name) {\n return runes(name).shift() || \"\";\n}\nfunction chooseFile(callback) {\n var oldInputDom = document.querySelector(\"#zego_whiteboard_UIKits_file\");\n if (oldInputDom) {\n oldInputDom.remove();\n }\n var inputObj = document.createElement(\"input\");\n inputObj.setAttribute(\"id\", \"zego_whiteboard_UIKits_file\");\n inputObj.setAttribute(\"type\", \"file\");\n inputObj.setAttribute(\"name\", \"file\");\n inputObj.setAttribute(\"style\", \"visibility:hidden\");\n inputObj.setAttribute(\"accept\", \"image/jpeg,image/png\");\n document.body.appendChild(inputObj);\n document.querySelector(\"#zego_whiteboard_UIKits_file\").addEventListener(\"change\", function (ev) {\n var target = ev.target;\n target.files && callback(target.files[0]);\n document.body.removeChild(inputObj);\n });\n inputObj.click();\n}\n/**\n * Generate token\n *\n * Token = \"04\" + Base64.encode(expire_time + IV.length + IV + binary ciphertext.length + binary ciphertext)\n * Algorithm: AES<ServerSecret, IV>(token_json_str), use mode: CBC/PKCS5Padding\n *\n * Only the client-side sample code for generating token is provided here. Be sure to generate tokens in your business background to avoid leaking your ServerSecret\n */\nfunction generatePrebuiltToken(appID, serverSecret, roomID, userID, userName, seconds) {\n // if (!roomID) {\n // console.error(\"【ZEGOCLOUD】:roomID required!!\");\n // return \"\";\n // }\n if (!userID) {\n console.error(\"【ZEGOCLOUD】:userID required!!\");\n return \"\";\n }\n if (!userName) {\n console.error(\"【ZEGOCLOUD】:userName required!!\");\n return \"\";\n }\n if (!appID) {\n console.error(\"【ZEGOCLOUD】:appID required!!\");\n return \"\";\n }\n if (typeof appID != \"number\") {\n console.error(\"【ZEGOCLOUD】:appID must be number!!\");\n return \"\";\n }\n if (!serverSecret) {\n console.error(\"【ZEGOCLOUD】: serverSecret required!!\");\n return \"\";\n }\n // construct encrypted data\n var time = (Date.now() / 1000) | 0;\n var body = {\n app_id: appID,\n user_id: userID,\n nonce: (Math.random() * 2147483647) | 0,\n ctime: time,\n expire: time + (seconds || 7200),\n };\n // encrypt body\n var key = crypto_js__WEBPACK_IMPORTED_MODULE_0___default().enc.Utf8.parse(serverSecret);\n var iv = Math.random().toString().substring(2, 18);\n if (iv.length < 16)\n iv += iv.substring(0, 16 - iv.length);\n var ciphertext = crypto_js__WEBPACK_IMPORTED_MODULE_0___default().AES.encrypt(JSON.stringify(body), key, {\n iv: crypto_js__WEBPACK_IMPORTED_MODULE_0___default().enc.Utf8.parse(iv),\n }).toString();\n var ciphert = Uint8Array.from(Array.from(atob(ciphertext)).map(function (val) { return val.charCodeAt(0); }));\n var len_ciphert = ciphert.length;\n // Assemble token data\n var uint8 = new Uint8Array(8 + 2 + 16 + 2 + len_ciphert);\n // expire: 8\n uint8.set([0, 0, 0, 0]);\n uint8.set(new Uint8Array(Int32Array.from([body.expire]).buffer).reverse(), 4);\n // iv length: 2\n uint8[8] = iv.length >> 8;\n uint8[9] = iv.length - (uint8[8] << 8);\n // iv: 16\n uint8.set(Uint8Array.from(Array.from(iv).map(function (val) { return val.charCodeAt(0); })), 10);\n // ciphertext length: 2\n uint8[26] = len_ciphert >> 8;\n uint8[27] = len_ciphert - (uint8[26] << 8);\n // ciphertext\n uint8.set(ciphert, 28);\n var token = \"04\".concat(btoa(String.fromCharCode.apply(String, Array.from(uint8))));\n return (token +\n \"#\" +\n window.btoa(JSON.stringify({ userID: userID, roomID: roomID, userName: userName, appID: appID })));\n}\n\n\n//# sourceURL=webpack://zegocloud_client_sdk_web/./src/sdk/util.ts?");
|
|
2171
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"DateFormat\": function() { return /* binding */ DateFormat; },\n/* harmony export */ \"IsLowVersionSafari\": function() { return /* binding */ IsLowVersionSafari; },\n/* harmony export */ \"chooseFile\": function() { return /* binding */ chooseFile; },\n/* harmony export */ \"generatePrebuiltToken\": function() { return /* binding */ generatePrebuiltToken; },\n/* harmony export */ \"getBrowser\": function() { return /* binding */ getBrowser; },\n/* harmony export */ \"getNameFirstLetter\": function() { return /* binding */ getNameFirstLetter; },\n/* harmony export */ \"getUrlParams\": function() { return /* binding */ getUrlParams; },\n/* harmony export */ \"getVideoResolution\": function() { return /* binding */ getVideoResolution; },\n/* harmony export */ \"isAndroid\": function() { return /* binding */ isAndroid; },\n/* harmony export */ \"isFireFox\": function() { return /* binding */ isFireFox; },\n/* harmony export */ \"isIOS\": function() { return /* binding */ isIOS; },\n/* harmony export */ \"isPc\": function() { return /* binding */ isPc; },\n/* harmony export */ \"isSafari\": function() { return /* binding */ isSafari; },\n/* harmony export */ \"randomNumber\": function() { return /* binding */ randomNumber; },\n/* harmony export */ \"runes\": function() { return /* binding */ runes; },\n/* harmony export */ \"throttle\": function() { return /* binding */ throttle; },\n/* harmony export */ \"userNameColor\": function() { return /* binding */ userNameColor; }\n/* harmony export */ });\n/* harmony import */ var crypto_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! crypto-js */ \"./node_modules/crypto-js/index.js\");\n/* harmony import */ var crypto_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(crypto_js__WEBPACK_IMPORTED_MODULE_0__);\n/* eslint-disable no-cond-assign */\n\nfunction randomNumber(len) {\n var result = \"\";\n var chars = \"123456789\", maxPos = chars.length, i;\n len = len || 5;\n for (i = 0; i < len; i++) {\n result += chars.charAt(Math.floor(Math.random() * maxPos));\n }\n return Number.parseInt(result);\n}\nfunction isPc() {\n var p = navigator.platform;\n var system = {\n win: p.indexOf(\"Win\") === 0,\n mac: p.indexOf(\"Mac\") === 0,\n linux: p.indexOf(\"Linux\") === 0,\n };\n if (false) {}\n return system.win || system.mac || system.linux;\n}\nfunction isIOS() {\n var u = navigator.userAgent;\n return !!u.match(/\\(i[^;]+;( U;)? CPU.+Mac OS X/);\n}\nfunction isAndroid() {\n var u = navigator.userAgent;\n return u.indexOf(\"Android\") > -1 || u.indexOf(\"Adr\") > -1;\n}\nfunction isSafari() {\n return (/Safari/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent));\n}\nfunction isFireFox() {\n var u = navigator.userAgent;\n return !!u.match(/firefox|fxios/i);\n}\nfunction IsLowVersionSafari() {\n var is_safari = navigator.userAgent.toLowerCase().indexOf(\"safari/\") > -1;\n var is_chrome = navigator.userAgent.match(\"CriOS\");\n var is_firefox = navigator.userAgent.match(\"FxiOS\");\n // 获取操作系统版本\n var m1 = navigator.userAgent.match(/iPhone OS .*?(?= )/);\n var version = 0;\n if (m1 && m1.length > 0) {\n try {\n var versionWith_ = m1[0].split(\" \")[m1[0].split(\" \").length - 1];\n var mainVersion = versionWith_.split(\"_\")[0];\n version = Number.parseInt(mainVersion);\n }\n catch (error) {\n console.error(\"【ZEGOCLOUD】get safari version failed\", error);\n }\n }\n return is_safari && !is_chrome && !is_firefox && version < 14;\n}\nfunction DateFormat(date, fmt) {\n var myDate = new Date(date);\n var o = {\n \"M+\": myDate.getMonth() + 1 + \"\",\n \"d+\": myDate.getDate() + \"\",\n \"h+\": myDate.getHours() >= 12\n ? myDate.getHours() - 12 + \"\"\n : myDate.getHours() + \"\",\n \"m+\": myDate.getMinutes() + \"\",\n \"s+\": myDate.getSeconds() + \"\",\n \"q+\": Math.floor((myDate.getMonth() + 3) / 3) + \"\",\n S: myDate.getMilliseconds() + \"\", // 毫秒\n };\n Object.entries(o).forEach(function (_a) {\n var k = _a[0], v = _a[1];\n if (new RegExp(\"(\" + k + \")\").test(fmt)) {\n fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? v : (\"00\" + v).substr((\"\" + v).length));\n }\n });\n return fmt;\n}\nvar userColorMap = {};\nfunction userNameColor(userName) {\n var colorArr = [\n \"#557BFF\",\n \"#1FAD40\",\n \"#06A1E5\",\n \"#E9473A\",\n \"#BB9B21\",\n \"#B755FF\",\n \"#10BD8E\",\n \"#FF2F5F\",\n ];\n if (!userColorMap[userName]) {\n userColorMap[userName] =\n colorArr[Object.keys(userColorMap).length % colorArr.length];\n }\n return userColorMap[userName];\n}\nfunction getUrlParams(url) {\n if (url === void 0) { url = window.location.href; }\n var urlStr = url.split(\"?\")[1];\n return new URLSearchParams(urlStr);\n}\nfunction getVideoResolution(level) {\n var _a = {\n width: 640,\n height: 360,\n bitrate: 400,\n frameRate: 15,\n }, width = _a.width, height = _a.height, bitrate = _a.bitrate, frameRate = _a.frameRate;\n if (level === \"180p\") {\n width = 320;\n height = 180;\n bitrate = 140;\n }\n else if (level === \"360p\") {\n width = 640;\n height = 360;\n bitrate = 400;\n }\n else if (level === \"480p\") {\n width = 640;\n height = 480;\n bitrate = 500;\n }\n else if (level === \"720p\") {\n width = 1280;\n height = 720;\n bitrate = 1130;\n }\n return {\n width: width,\n height: height,\n bitrate: bitrate,\n frameRate: frameRate,\n };\n}\nvar throttle = function (fn, wait) {\n var canRun = true;\n return function () {\n var _this = this;\n if (!canRun)\n return;\n canRun = false;\n setTimeout(function () {\n // @ts-ignore\n fn.apply(_this, arguments);\n canRun = true;\n }, wait);\n };\n};\nfunction getBrowser() {\n var sys = {};\n var ua = navigator.userAgent.toLowerCase();\n var s;\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions, no-cond-assign\n (s = ua.match(/edge\\/([\\d.]+)/))\n ? (sys.edge = s[1])\n : (s = ua.match(/rv:([\\d.]+)\\) like gecko/))\n ? (sys.ie = s[1])\n : (s = ua.match(/msie ([\\d.]+)/))\n ? (sys.ie = s[1])\n : (s = ua.match(/firefox\\/([\\d.]+)/))\n ? (sys.firefox = s[1])\n : (s = ua.match(/chrome\\/([\\d.]+)/))\n ? (sys.chrome = s[1])\n : (s = ua.match(/opera.([\\d.]+)/))\n ? (sys.opera = s[1])\n : (s = ua.match(/version\\/([\\d.]+).*safari/))\n ? (sys.safari = s[1])\n : 0;\n if (sys.edge)\n return { browser: \"Edge\", version: sys.edge };\n if (sys.ie)\n return { browser: \"IE\", version: sys.ie };\n if (sys.firefox)\n return { browser: \"Firefox\", version: sys.firefox };\n if (sys.chrome)\n return { browser: \"Chrome\", version: sys.chrome };\n if (sys.opera)\n return { browser: \"Opera\", version: sys.opera };\n if (sys.safari)\n return { browser: \"Safari\", version: sys.safari };\n return { browser: \"\", version: \"0\" };\n}\nfunction runes(string) {\n var HIGH_SURROGATE_START = 0xd800;\n var HIGH_SURROGATE_END = 0xdbff;\n var LOW_SURROGATE_START = 0xdc00;\n var REGIONAL_INDICATOR_START = 0x1f1e6;\n var REGIONAL_INDICATOR_END = 0x1f1ff;\n var FITZPATRICK_MODIFIER_START = 0x1f3fb;\n var FITZPATRICK_MODIFIER_END = 0x1f3ff;\n var VARIATION_MODIFIER_START = 0xfe00;\n var VARIATION_MODIFIER_END = 0xfe0f;\n var DIACRITICAL_MARKS_START = 0x20d0;\n var DIACRITICAL_MARKS_END = 0x20ff;\n var ZWJ = 0x200d;\n var GRAPHEMS = [\n 0x0308, 0x0937, 0x0937, 0x093f, 0x093f, 0x0ba8, 0x0bbf, 0x0bcd, 0x0e31,\n 0x0e33, 0x0e40, 0x0e49, 0x1100, 0x1161, 0x11a8,\n ];\n function nextUnits(i, string) {\n var current = string[i];\n if (!isFirstOfSurrogatePair(current) || i === string.length - 1) {\n return 1;\n }\n var currentPair = current + string[i + 1];\n var nextPair = string.substring(i + 2, i + 5);\n if (isRegionalIndicator(currentPair) && isRegionalIndicator(nextPair)) {\n return 4;\n }\n if (isFitzpatrickModifier(nextPair)) {\n return 4;\n }\n return 2;\n }\n function isFirstOfSurrogatePair(string) {\n return (string &&\n betweenInclusive(string[0].charCodeAt(0), HIGH_SURROGATE_START, HIGH_SURROGATE_END));\n }\n function isRegionalIndicator(string) {\n return betweenInclusive(codePointFromSurrogatePair(string), REGIONAL_INDICATOR_START, REGIONAL_INDICATOR_END);\n }\n function isFitzpatrickModifier(string) {\n return betweenInclusive(codePointFromSurrogatePair(string), FITZPATRICK_MODIFIER_START, FITZPATRICK_MODIFIER_END);\n }\n function isVariationSelector(string) {\n return (typeof string === \"string\" &&\n betweenInclusive(string.charCodeAt(0), VARIATION_MODIFIER_START, VARIATION_MODIFIER_END));\n }\n function isDiacriticalMark(string) {\n return (typeof string === \"string\" &&\n betweenInclusive(string.charCodeAt(0), DIACRITICAL_MARKS_START, DIACRITICAL_MARKS_END));\n }\n function isGraphem(string) {\n return (typeof string === \"string\" &&\n GRAPHEMS.indexOf(string.charCodeAt(0)) !== -1);\n }\n function isZeroWidthJoiner(string) {\n return typeof string === \"string\" && string.charCodeAt(0) === ZWJ;\n }\n function codePointFromSurrogatePair(pair) {\n var highOffset = pair.charCodeAt(0) - HIGH_SURROGATE_START;\n var lowOffset = pair.charCodeAt(1) - LOW_SURROGATE_START;\n return (highOffset << 10) + lowOffset + 0x10000;\n }\n function betweenInclusive(value, lower, upper) {\n return value >= lower && value <= upper;\n }\n if (typeof string !== \"string\") {\n throw new Error(\"string cannot be undefined or null\");\n }\n var result = [];\n var i = 0;\n var increment = 0;\n while (i < string.length) {\n increment += nextUnits(i + increment, string);\n if (isGraphem(string[i + increment])) {\n increment++;\n }\n if (isVariationSelector(string[i + increment])) {\n increment++;\n }\n if (isDiacriticalMark(string[i + increment])) {\n increment++;\n }\n if (isZeroWidthJoiner(string[i + increment])) {\n increment++;\n continue;\n }\n result.push(string.substring(i, i + increment));\n i += increment;\n increment = 0;\n }\n return result;\n}\nfunction getNameFirstLetter(name) {\n return runes(name).shift() || \"\";\n}\nfunction chooseFile(callback) {\n var oldInputDom = document.querySelector(\"#zego_whiteboard_UIKits_file\");\n if (oldInputDom) {\n oldInputDom.remove();\n }\n var inputObj = document.createElement(\"input\");\n inputObj.setAttribute(\"id\", \"zego_whiteboard_UIKits_file\");\n inputObj.setAttribute(\"type\", \"file\");\n inputObj.setAttribute(\"name\", \"file\");\n inputObj.setAttribute(\"style\", \"visibility:hidden\");\n inputObj.setAttribute(\"accept\", \"image/jpeg,image/png\");\n document.body.appendChild(inputObj);\n document.querySelector(\"#zego_whiteboard_UIKits_file\").addEventListener(\"change\", function (ev) {\n var target = ev.target;\n target.files && callback(target.files[0]);\n document.body.removeChild(inputObj);\n });\n inputObj.click();\n}\n/**\n * Generate token\n *\n * Token = \"04\" + Base64.encode(expire_time + IV.length + IV + binary ciphertext.length + binary ciphertext)\n * Algorithm: AES<ServerSecret, IV>(token_json_str), use mode: CBC/PKCS5Padding\n *\n * Only the client-side sample code for generating token is provided here. Be sure to generate tokens in your business background to avoid leaking your ServerSecret\n */\nfunction generatePrebuiltToken(appID, serverSecret, roomID, userID, userName, seconds) {\n // if (!roomID) {\n // console.error(\"【ZEGOCLOUD】:roomID required!!\");\n // return \"\";\n // }\n if (!userID) {\n console.error(\"【ZEGOCLOUD】:userID required!!\");\n return \"\";\n }\n if (!userName) {\n console.error(\"【ZEGOCLOUD】:userName required!!\");\n return \"\";\n }\n if (!appID) {\n console.error(\"【ZEGOCLOUD】:appID required!!\");\n return \"\";\n }\n if (typeof appID != \"number\") {\n console.error(\"【ZEGOCLOUD】:appID must be number!!\");\n return \"\";\n }\n if (!serverSecret) {\n console.error(\"【ZEGOCLOUD】: serverSecret required!!\");\n return \"\";\n }\n // construct encrypted data\n var time = (Date.now() / 1000) | 0;\n var body = {\n app_id: appID,\n user_id: userID,\n nonce: (Math.random() * 2147483647) | 0,\n ctime: time,\n expire: time + (seconds || 7200),\n };\n // encrypt body\n var key = crypto_js__WEBPACK_IMPORTED_MODULE_0___default().enc.Utf8.parse(serverSecret);\n var iv = Math.random().toString().substring(2, 18);\n if (iv.length < 16)\n iv += iv.substring(0, 16 - iv.length);\n var ciphertext = crypto_js__WEBPACK_IMPORTED_MODULE_0___default().AES.encrypt(JSON.stringify(body), key, {\n iv: crypto_js__WEBPACK_IMPORTED_MODULE_0___default().enc.Utf8.parse(iv),\n }).toString();\n var ciphert = Uint8Array.from(Array.from(atob(ciphertext)).map(function (val) { return val.charCodeAt(0); }));\n var len_ciphert = ciphert.length;\n // Assemble token data\n var uint8 = new Uint8Array(8 + 2 + 16 + 2 + len_ciphert);\n // expire: 8\n uint8.set([0, 0, 0, 0]);\n uint8.set(new Uint8Array(Int32Array.from([body.expire]).buffer).reverse(), 4);\n // iv length: 2\n uint8[8] = iv.length >> 8;\n uint8[9] = iv.length - (uint8[8] << 8);\n // iv: 16\n uint8.set(Uint8Array.from(Array.from(iv).map(function (val) { return val.charCodeAt(0); })), 10);\n // ciphertext length: 2\n uint8[26] = len_ciphert >> 8;\n uint8[27] = len_ciphert - (uint8[26] << 8);\n // ciphertext\n uint8.set(ciphert, 28);\n var token = \"04\".concat(btoa(String.fromCharCode.apply(String, Array.from(uint8))));\n return (token +\n \"#\" +\n window.btoa(JSON.stringify({ userID: userID, roomID: roomID, userName: userName, appID: appID })));\n}\n\n\n//# sourceURL=webpack://zegocloud_client_sdk_web/./src/sdk/util.ts?");
|
|
2172
2172
|
|
|
2173
2173
|
/***/ }),
|
|
2174
2174
|
|