cloudcc-ccdk 0.0.8 → 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/README.md +8 -0
- package/lib/ccdk.js +38 -2
- package/lib/ccdk.min.js +1 -1
- package/package.json +3 -8
package/README.md
CHANGED
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
|
|
|
@@ -99,6 +104,7 @@ const USER_INFO = "cc_user_info";
|
|
|
99
104
|
*/
|
|
100
105
|
function setUserInfo(userInfo, domain = getDomain()) {
|
|
101
106
|
Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { domain: domain, expires: 1 / 12 });
|
|
107
|
+
Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { expires: 1 / 12 });
|
|
102
108
|
}
|
|
103
109
|
|
|
104
110
|
/**
|
|
@@ -153,8 +159,8 @@ function getToken(urlName = "binding") {
|
|
|
153
159
|
* @param {String} domain 域名
|
|
154
160
|
*/
|
|
155
161
|
function setToken(token, domain = getDomain()) {
|
|
156
|
-
// 开发模式不设置domain
|
|
157
162
|
Cookies.set(Crypto.encrypt(TOKEN), token, { domain: domain, expires: 1 / 12 });
|
|
163
|
+
Cookies.set(Crypto.encrypt(TOKEN), token, { expires: 1 / 12 });
|
|
158
164
|
}
|
|
159
165
|
|
|
160
166
|
/**
|
|
@@ -163,6 +169,7 @@ function setToken(token, domain = getDomain()) {
|
|
|
163
169
|
*/
|
|
164
170
|
function clearToken(domain = getDomain()) {
|
|
165
171
|
Cookies.remove(Crypto.encrypt(TOKEN), { domain: domain });
|
|
172
|
+
Cookies.remove(Crypto.encrypt(TOKEN));
|
|
166
173
|
}
|
|
167
174
|
|
|
168
175
|
var CCToken = /*#__PURE__*/Object.freeze({
|
|
@@ -172,4 +179,33 @@ var CCToken = /*#__PURE__*/Object.freeze({
|
|
|
172
179
|
clearToken: clearToken
|
|
173
180
|
});
|
|
174
181
|
|
|
175
|
-
|
|
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})}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(".")}}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
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/ccdk-min.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"
|
|
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
|
-
"
|
|
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",
|