cloudcc-ccdk 0.0.3 → 0.0.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/README.md CHANGED
@@ -1,3 +1,11 @@
1
+ #### 发布版本:0.0.4
2
+ #### 更新日期:2022/8/8
3
+ #### 更新内容:
4
+ * 修复
5
+ * 迭代
6
+ * 优化加密库依赖导入
7
+ * 优化
8
+
1
9
  #### 发布版本:0.0.3
2
10
  #### 更新日期:2022/7/28
3
11
  #### 更新内容:
package/lib/ccdk.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import Cookies from 'js-cookie';
2
- import CryptoJS from 'crypto-js';
2
+ import CryptoJS from 'crypto-js/aes';
3
3
 
4
4
  /**
5
5
  * 加密
@@ -83,7 +83,7 @@ const USER_INFO = "cc_user_info";
83
83
  * @param {String} domain 域名
84
84
  */
85
85
  function setUserInfo(userInfo, domain) {
86
- Cookies.set(Crypto.encrypt(USER_INFO), userInfo, { domain: domain || "." + document.domain.split('.').slice(-2).join('.'), expires: 1 });
86
+ Cookies.set(Crypto.encrypt(USER_INFO), userInfo, { domain: domain || ("." + document.domain.split('.').slice(-2).join('.')), expires: 1 });
87
87
  }
88
88
 
89
89
  /**
@@ -139,7 +139,7 @@ function getToken(urlName = "binding") {
139
139
  */
140
140
  function setToken(token, domain) {
141
141
  // 开发模式不设置domain
142
- Cookies.set(Crypto.encrypt(TOKEN), token, { domain: domain || "." + document.domain.split('.').slice(-2).join('.'), expires: 1 });
142
+ Cookies.set(Crypto.encrypt(TOKEN), token, { domain: domain || ("." + document.domain.split('.').slice(-2).join('.')), expires: 1 });
143
143
  }
144
144
 
145
145
  /**
@@ -147,7 +147,7 @@ function setToken(token, domain) {
147
147
  * @param {String} domain 域名
148
148
  */
149
149
  function clearToken(domain) {
150
- Cookies.remove(Crypto.encrypt(TOKEN), { domain: domain || "." + document.domain.split('.').slice(-2).join('.'), expires: 1 });
150
+ Cookies.remove(Crypto.encrypt(TOKEN), { domain: domain || ("." + document.domain.split('.').slice(-2).join('.')), expires: 1 });
151
151
  }
152
152
 
153
153
  var CCToken = /*#__PURE__*/Object.freeze({
package/lib/ccdk.min.js CHANGED
@@ -1 +1 @@
1
- import Cookies from"js-cookie";import CryptoJS from"crypto-js";function getAesString(data,key,iv){key=CryptoJS.enc.Utf8.parse(key);iv=CryptoJS.enc.Utf8.parse(iv);let encrypted=CryptoJS.AES.encrypt(data,key,{iv:iv,mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7});return encrypted.toString()}function getDAesString(encrypted,key,iv){key=CryptoJS.enc.Utf8.parse(key);iv=CryptoJS.enc.Utf8.parse(iv);let decrypted=CryptoJS.AES.decrypt(encrypted,key,{iv:iv,mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7});return decrypted.toString(CryptoJS.enc.Utf8)}function encrypt(data,key="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",iv=1){data=JSON.stringify(data);var encrypted=getAesString(data,key,iv);return encrypted}function decrypt(data,key="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",iv=1){try{var decryptedStr=getDAesString(data,key,iv);if(!decryptedStr)return null;return JSON.parse(decryptedStr)}catch(error){console.trace("解密密码错误",error);return null}}var Crypto=Object.freeze({__proto__:null,encrypt:encrypt,decrypt:decrypt});const USER_INFO="cc_user_info";function setUserInfo(userInfo,domain){Cookies.set(Crypto.encrypt(USER_INFO),userInfo,{domain:domain||"."+document.domain.split(".").slice(-2).join("."),expires:1})}function getUserInfo(){let encryptUserInfo=Cookies.get(Crypto.encrypt(USER_INFO));if(encryptUserInfo){return Crypto.decrypt(encryptUserInfo)}else{return""}}var CCUser=Object.freeze({__proto__:null,setUserInfo:setUserInfo,getUserInfo:getUserInfo});const TOKEN="cc_token";function getUrlQuery(name){var reg=new RegExp(name+"=([^&]*)(&|$)");var r=window.location.href.match(reg);let res=null;if(r!=null)res=r[1].trim();return res}function getToken(urlName="binding"){let token=getUrlQuery(urlName)||Cookies.get(Crypto.encrypt(TOKEN))||Cookies.get(urlName);if(token){setToken(token)}return token}function setToken(token,domain){Cookies.set(Crypto.encrypt(TOKEN),token,{domain:domain||"."+document.domain.split(".").slice(-2).join("."),expires:1})}function clearToken(domain){Cookies.remove(Crypto.encrypt(TOKEN),{domain:domain||"."+document.domain.split(".").slice(-2).join("."),expires:1})}var CCToken=Object.freeze({__proto__:null,setToken:setToken,getToken:getToken,clearToken:clearToken});export{Crypto as CCCrypto,CCToken,CCUser};
1
+ import Cookies from"js-cookie";import CryptoJS from"crypto-js/aes";function getAesString(data,key,iv){key=CryptoJS.enc.Utf8.parse(key);iv=CryptoJS.enc.Utf8.parse(iv);let encrypted=CryptoJS.AES.encrypt(data,key,{iv:iv,mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7});return encrypted.toString()}function getDAesString(encrypted,key,iv){key=CryptoJS.enc.Utf8.parse(key);iv=CryptoJS.enc.Utf8.parse(iv);let decrypted=CryptoJS.AES.decrypt(encrypted,key,{iv:iv,mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7});return decrypted.toString(CryptoJS.enc.Utf8)}function encrypt(data,key="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",iv=1){data=JSON.stringify(data);var encrypted=getAesString(data,key,iv);return encrypted}function decrypt(data,key="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",iv=1){try{var decryptedStr=getDAesString(data,key,iv);if(!decryptedStr)return null;return JSON.parse(decryptedStr)}catch(error){console.trace("解密密码错误",error);return null}}var Crypto=Object.freeze({__proto__:null,encrypt:encrypt,decrypt:decrypt});const USER_INFO="cc_user_info";function setUserInfo(userInfo,domain){Cookies.set(Crypto.encrypt(USER_INFO),userInfo,{domain:domain||"."+document.domain.split(".").slice(-2).join("."),expires:1})}function getUserInfo(){let encryptUserInfo=Cookies.get(Crypto.encrypt(USER_INFO));if(encryptUserInfo){return Crypto.decrypt(encryptUserInfo)}else{return""}}var CCUser=Object.freeze({__proto__:null,setUserInfo:setUserInfo,getUserInfo:getUserInfo});const TOKEN="cc_token";function getUrlQuery(name){var reg=new RegExp(name+"=([^&]*)(&|$)");var r=window.location.href.match(reg);let res=null;if(r!=null)res=r[1].trim();return res}function getToken(urlName="binding"){let token=getUrlQuery(urlName)||Cookies.get(Crypto.encrypt(TOKEN))||Cookies.get(urlName);if(token){setToken(token)}return token}function setToken(token,domain){Cookies.set(Crypto.encrypt(TOKEN),token,{domain:domain||"."+document.domain.split(".").slice(-2).join("."),expires:1})}function clearToken(domain){Cookies.remove(Crypto.encrypt(TOKEN),{domain:domain||"."+document.domain.split(".").slice(-2).join("."),expires:1})}var CCToken=Object.freeze({__proto__:null,setToken:setToken,getToken:getToken,clearToken:clearToken});export{Crypto as CCCrypto,CCToken,CCUser};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudcc-ccdk",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "",
5
5
  "main": "lib/ccdk-min.js",
6
6
  "scripts": {