cloudcc-ccdk 0.0.8 → 0.0.9

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.9
2
+ #### 更新日期:2022/8/12
3
+ #### 更新内容:
4
+ * 修复
5
+ * 迭代
6
+ * cookies存储到域名中一份
7
+ * 优化
8
+
1
9
  #### 发布版本:0.0.8
2
10
  #### 更新日期:2022/8/12
3
11
  #### 更新内容:
package/lib/ccdk.js CHANGED
@@ -99,6 +99,7 @@ const USER_INFO = "cc_user_info";
99
99
  */
100
100
  function setUserInfo(userInfo, domain = getDomain()) {
101
101
  Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { domain: domain, expires: 1 / 12 });
102
+ Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { expires: 1 / 12 });
102
103
  }
103
104
 
104
105
  /**
@@ -153,8 +154,8 @@ function getToken(urlName = "binding") {
153
154
  * @param {String} domain 域名
154
155
  */
155
156
  function setToken(token, domain = getDomain()) {
156
- // 开发模式不设置domain
157
157
  Cookies.set(Crypto.encrypt(TOKEN), token, { domain: domain, expires: 1 / 12 });
158
+ Cookies.set(Crypto.encrypt(TOKEN), token, { expires: 1 / 12 });
158
159
  }
159
160
 
160
161
  /**
@@ -163,6 +164,7 @@ function setToken(token, domain = getDomain()) {
163
164
  */
164
165
  function clearToken(domain = getDomain()) {
165
166
  Cookies.remove(Crypto.encrypt(TOKEN), { domain: domain });
167
+ Cookies.remove(Crypto.encrypt(TOKEN));
166
168
  }
167
169
 
168
170
  var CCToken = /*#__PURE__*/Object.freeze({
package/lib/ccdk.min.js CHANGED
@@ -1 +1 @@
1
- import Cookies from"js-cookie";import CryptoJS from"crypto-js/aes";import UTF8 from"crypto-js/enc-utf8";import PAD from"crypto-js/pad-pkcs7";function getAesString(data,key,iv){key=UTF8.parse(key);iv=UTF8.parse(iv);let encrypted=CryptoJS.encrypt(data,key,{iv:iv,padding:PAD});return encrypted.toString()}function getDAesString(encrypted,key,iv){key=UTF8.parse(key);iv=UTF8.parse(iv);let decrypted=CryptoJS.decrypt(encrypted,key,{iv:iv,padding:PAD});return decrypted.toString(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});function getDomain(){let lastTow=document.domain.split(".").slice(-2,-1)[0];if(lastTow=="com"||lastTow=="org"||lastTow=="net"){return"."+document.domain.split(".").slice(-3).join(".")}else{return"."+document.domain.split(".").slice(-2).join(".")}}const USER_INFO="cc_user_info";function setUserInfo(userInfo,domain=getDomain()){Cookies.set(Crypto.encrypt(USER_INFO),Crypto.encrypt(userInfo),{domain:domain,expires:1/12})}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=getDomain()){Cookies.set(Crypto.encrypt(TOKEN),token,{domain:domain,expires:1/12})}function clearToken(domain=getDomain()){Cookies.remove(Crypto.encrypt(TOKEN),{domain:domain})}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";import UTF8 from"crypto-js/enc-utf8";import PAD from"crypto-js/pad-pkcs7";function getAesString(data,key,iv){key=UTF8.parse(key);iv=UTF8.parse(iv);let encrypted=CryptoJS.encrypt(data,key,{iv:iv,padding:PAD});return encrypted.toString()}function getDAesString(encrypted,key,iv){key=UTF8.parse(key);iv=UTF8.parse(iv);let decrypted=CryptoJS.decrypt(encrypted,key,{iv:iv,padding:PAD});return decrypted.toString(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});function getDomain(){let lastTow=document.domain.split(".").slice(-2,-1)[0];if(lastTow=="com"||lastTow=="org"||lastTow=="net"){return"."+document.domain.split(".").slice(-3).join(".")}else{return"."+document.domain.split(".").slice(-2).join(".")}}const USER_INFO="cc_user_info";function setUserInfo(userInfo,domain=getDomain()){Cookies.set(Crypto.encrypt(USER_INFO),Crypto.encrypt(userInfo),{domain:domain,expires:1/12});Cookies.set(Crypto.encrypt(USER_INFO),Crypto.encrypt(userInfo),{expires:1/12})}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=getDomain()){Cookies.set(Crypto.encrypt(TOKEN),token,{domain:domain,expires:1/12});Cookies.set(Crypto.encrypt(TOKEN),token,{expires:1/12})}function clearToken(domain=getDomain()){Cookies.remove(Crypto.encrypt(TOKEN),{domain:domain});Cookies.remove(Crypto.encrypt(TOKEN))}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.8",
3
+ "version": "0.0.9",
4
4
  "description": "",
5
5
  "main": "lib/ccdk-min.js",
6
6
  "scripts": {