cloudcc-ccdk 0.0.9 → 0.1.0

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/lib/ccdk.js CHANGED
@@ -89,6 +89,11 @@ function getDomain() {
89
89
  }
90
90
  }
91
91
 
92
+ var CCUtils = /*#__PURE__*/Object.freeze({
93
+ __proto__: null,
94
+ getDomain: getDomain
95
+ });
96
+
92
97
  // cookie存储标识
93
98
  const USER_INFO = "cc_user_info";
94
99
 
@@ -174,4 +179,33 @@ var CCToken = /*#__PURE__*/Object.freeze({
174
179
  clearToken: clearToken
175
180
  });
176
181
 
177
- export { Crypto as CCCrypto, CCToken, CCUser };
182
+ /**
183
+ * 获取基础url
184
+ * @returns 基础地址
185
+ */
186
+ function getBaseUrl() {
187
+ return window.gw.BASE_URL
188
+ }
189
+ /**
190
+ * 获取网关对象
191
+ * @returns 网关对象
192
+ */
193
+ function getGw() {
194
+ return window.gw;
195
+ }
196
+ /**
197
+ * 获取服务对象
198
+ * @returns 服务对象
199
+ */
200
+ function getSvc() {
201
+ return window.Glod;
202
+ }
203
+
204
+ var CCConfig = /*#__PURE__*/Object.freeze({
205
+ __proto__: null,
206
+ getBaseUrl: getBaseUrl,
207
+ getGw: getGw,
208
+ getSvc: getSvc
209
+ });
210
+
211
+ export { CCConfig, Crypto as CCCrypto, CCToken, CCUser, CCUtils };
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});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};
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(".")}}var CCUtils=Object.freeze({__proto__:null,getDomain:getDomain});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});function getBaseUrl(){return window.gw.BASE_URL}function getGw(){return window.gw}function getSvc(){return window.Glod}var CCConfig=Object.freeze({__proto__:null,getBaseUrl:getBaseUrl,getGw:getGw,getSvc:getSvc});export{CCConfig,Crypto as CCCrypto,CCToken,CCUser,CCUtils};
package/package.json CHANGED
@@ -1,13 +1,10 @@
1
1
  {
2
2
  "name": "cloudcc-ccdk",
3
- "version": "0.0.9",
3
+ "version": "0.1.0",
4
4
  "description": "",
5
5
  "main": "lib/ccdk-min.js",
6
6
  "scripts": {
7
- "docs:markdown": "vuepress-jsdoc --source ./packages",
8
- "docs:dev": "vuepress dev docs",
9
- "docs:build": "vuepress build docs",
10
- "libs:build": "rollup -c && npx uglifyjs lib/ccdk.js -o lib/ccdk.min.js",
7
+ "libs:build": "rollup -c && uglifyjs lib/ccdk.js -o lib/ccdk.min.js",
11
8
  "libs:publish": "npm run libs:build && npm publish --registry https://registry.npmjs.org"
12
9
  },
13
10
  "keywords": [
@@ -20,9 +17,7 @@
20
17
  "author": "294985925@qq.com",
21
18
  "devDependencies": {
22
19
  "rollup": "^2.77.0",
23
- "uglifyjs": "^2.4.11",
24
- "vuepress": "^2.0.0-beta.49",
25
- "vuepress-jsdoc": "^4.3.0"
20
+ "uglify-js": "^3.17.3"
26
21
  },
27
22
  "dependencies": {
28
23
  "crypto-js": "^4.1.1",