cloud189-sdk 1.0.3 → 1.0.5
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 +2 -3
- package/dist/CloudClient.d.ts +45 -17
- package/dist/CloudClient.js +17 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# cloud189-sdk
|
|
2
2
|
|
|
3
3
|
## 安装依赖
|
|
4
|
-
```
|
|
4
|
+
``` console
|
|
5
5
|
npm i cloud189-sdk
|
|
6
6
|
```
|
|
7
7
|
或者
|
|
8
|
-
```
|
|
8
|
+
``` console
|
|
9
9
|
yarn add cloud189-sdk
|
|
10
10
|
```
|
|
11
11
|
## 测试代码
|
|
@@ -47,5 +47,4 @@ const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
|
47
47
|
const info = await client.getUserSizeInfo();
|
|
48
48
|
console.log(info);
|
|
49
49
|
})();
|
|
50
|
-
``
|
|
51
50
|
```
|
package/dist/CloudClient.d.ts
CHANGED
|
@@ -1,31 +1,40 @@
|
|
|
1
|
+
import { CookieJar } from "tough-cookie";
|
|
1
2
|
interface CacheQuery {
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
appId: string;
|
|
4
|
+
reqId: string;
|
|
5
|
+
lt: string;
|
|
4
6
|
}
|
|
5
7
|
interface FamilyListResponse {
|
|
6
8
|
familyInfoResp: [
|
|
7
9
|
{
|
|
8
|
-
familyId:
|
|
10
|
+
familyId: number;
|
|
11
|
+
remarkName: string;
|
|
12
|
+
type: number;
|
|
13
|
+
userRole: number;
|
|
9
14
|
}
|
|
10
15
|
];
|
|
11
16
|
}
|
|
12
|
-
interface
|
|
13
|
-
result: number;
|
|
14
|
-
msg: string;
|
|
15
|
-
}
|
|
16
|
-
interface UserBriefInfoResponse extends APIResponse {
|
|
17
|
+
interface UserBriefInfoResponse {
|
|
17
18
|
sessionKey: string;
|
|
18
19
|
}
|
|
19
|
-
interface AccessTokenResponse
|
|
20
|
+
interface AccessTokenResponse {
|
|
20
21
|
accessToken: string;
|
|
21
22
|
}
|
|
22
|
-
interface FamilyUserSignResponse
|
|
23
|
+
interface FamilyUserSignResponse {
|
|
23
24
|
bonusSpace: number;
|
|
24
25
|
signFamilyId: number;
|
|
25
26
|
signStatus: number;
|
|
26
27
|
signTime: string;
|
|
27
28
|
userId: string;
|
|
28
29
|
}
|
|
30
|
+
interface UserSizeInfoResponse {
|
|
31
|
+
cloudCapacityInfo: {
|
|
32
|
+
totalSize: number;
|
|
33
|
+
};
|
|
34
|
+
familyCapacityInfo: {
|
|
35
|
+
totalSize: number;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
29
38
|
interface UserSignResponse {
|
|
30
39
|
isSign: boolean;
|
|
31
40
|
netdiskBonus: number;
|
|
@@ -34,15 +43,25 @@ interface TaskResponse {
|
|
|
34
43
|
errorCode: string;
|
|
35
44
|
prizeName: string;
|
|
36
45
|
}
|
|
46
|
+
interface UserSizeInfoResponse {
|
|
47
|
+
account: string;
|
|
48
|
+
cloudCapacityInfo: {
|
|
49
|
+
totalSize: number;
|
|
50
|
+
};
|
|
51
|
+
familyCapacityInfo: {
|
|
52
|
+
totalSize: number;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
37
55
|
declare class CloudClient {
|
|
38
56
|
#private;
|
|
39
57
|
username: string;
|
|
40
58
|
password: string;
|
|
41
59
|
cacheQuery: CacheQuery;
|
|
42
|
-
|
|
60
|
+
cookieJar: CookieJar;
|
|
61
|
+
constructor(username: string, password: string);
|
|
43
62
|
getEncrypt: () => Promise<any>;
|
|
44
63
|
redirectURL: () => Promise<unknown>;
|
|
45
|
-
appConf: (query:
|
|
64
|
+
appConf: (query: CacheQuery) => Promise<any>;
|
|
46
65
|
/**
|
|
47
66
|
* 登录流程
|
|
48
67
|
* 1.获取公钥
|
|
@@ -51,16 +70,25 @@ declare class CloudClient {
|
|
|
51
70
|
* 4.跳转到登录页
|
|
52
71
|
* */
|
|
53
72
|
login: () => Promise<any>;
|
|
54
|
-
fetchAPI: (task:
|
|
55
|
-
getUserSizeInfo: () => Promise<
|
|
73
|
+
fetchAPI: (task: string) => Promise<any>;
|
|
74
|
+
getUserSizeInfo: () => Promise<UserSizeInfoResponse>;
|
|
56
75
|
userSign: () => Promise<UserSignResponse>;
|
|
76
|
+
/**
|
|
77
|
+
* @deprecated 任务无效, 1.0.4版本废弃
|
|
78
|
+
*/
|
|
57
79
|
taskSign: () => Promise<TaskResponse>;
|
|
80
|
+
/**
|
|
81
|
+
* @deprecated 任务无效, 1.0.4版本废弃
|
|
82
|
+
*/
|
|
58
83
|
taskPhoto: () => Promise<TaskResponse>;
|
|
84
|
+
/**
|
|
85
|
+
* @deprecated 任务无效, 1.0.3版本废弃
|
|
86
|
+
*/
|
|
59
87
|
taskKJ: () => Promise<TaskResponse>;
|
|
60
88
|
getUserBriefInfo: () => Promise<UserBriefInfoResponse>;
|
|
61
|
-
getAccessTokenBySsKey: (sessionKey:
|
|
62
|
-
fetchFamilyAPI: (path:
|
|
89
|
+
getAccessTokenBySsKey: (sessionKey: string) => Promise<AccessTokenResponse>;
|
|
90
|
+
fetchFamilyAPI: (path: string) => Promise<any>;
|
|
63
91
|
getFamilyList: () => Promise<FamilyListResponse>;
|
|
64
|
-
familyUserSign: (familyId:
|
|
92
|
+
familyUserSign: (familyId: number) => Promise<FamilyUserSignResponse>;
|
|
65
93
|
}
|
|
66
94
|
export default CloudClient;
|
package/dist/CloudClient.js
CHANGED
|
@@ -20,7 +20,6 @@ const node_jsencrypt_1 = __importDefault(require("node-jsencrypt"));
|
|
|
20
20
|
const crypto_1 = __importDefault(require("crypto"));
|
|
21
21
|
const got_1 = __importDefault(require("got"));
|
|
22
22
|
const tough_cookie_1 = require("tough-cookie");
|
|
23
|
-
const cookieJar = new tough_cookie_1.CookieJar();
|
|
24
23
|
const config = {
|
|
25
24
|
clientId: "538135150693412",
|
|
26
25
|
model: "KB2000",
|
|
@@ -119,7 +118,7 @@ class CloudClient {
|
|
|
119
118
|
headers: {
|
|
120
119
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/76.0",
|
|
121
120
|
Referer: "https://open.e.189.cn/",
|
|
122
|
-
REQID: this.cacheQuery.
|
|
121
|
+
REQID: this.cacheQuery.reqId,
|
|
123
122
|
lt: this.cacheQuery.lt,
|
|
124
123
|
},
|
|
125
124
|
form: data,
|
|
@@ -133,7 +132,7 @@ class CloudClient {
|
|
|
133
132
|
}
|
|
134
133
|
else {
|
|
135
134
|
return got_1.default
|
|
136
|
-
.get(res.toUrl, { headers, cookieJar })
|
|
135
|
+
.get(res.toUrl, { headers, cookieJar: this.cookieJar })
|
|
137
136
|
.then((r) => resolve(r.statusCode));
|
|
138
137
|
}
|
|
139
138
|
})
|
|
@@ -144,7 +143,7 @@ class CloudClient {
|
|
|
144
143
|
return got_1.default
|
|
145
144
|
.get(task, {
|
|
146
145
|
headers: Object.assign(Object.assign({}, headers), { Host: q.host }),
|
|
147
|
-
cookieJar,
|
|
146
|
+
cookieJar: this.cookieJar,
|
|
148
147
|
})
|
|
149
148
|
.json();
|
|
150
149
|
};
|
|
@@ -154,25 +153,34 @@ class CloudClient {
|
|
|
154
153
|
headers: {
|
|
155
154
|
Accept: "application/json;charset=UTF-8",
|
|
156
155
|
},
|
|
157
|
-
cookieJar,
|
|
156
|
+
cookieJar: this.cookieJar,
|
|
158
157
|
})
|
|
159
158
|
.json();
|
|
160
159
|
};
|
|
161
160
|
this.userSign = () => {
|
|
162
161
|
return this.fetchAPI(`https://cloud.189.cn/mkt/userSign.action?rand=${new Date().getTime()}&clientType=TELEANDROID&version=${config.version}&model=${config.model}`);
|
|
163
162
|
};
|
|
163
|
+
/**
|
|
164
|
+
* @deprecated 任务无效, 1.0.4版本废弃
|
|
165
|
+
*/
|
|
164
166
|
this.taskSign = () => {
|
|
165
167
|
return this.fetchAPI("https://m.cloud.189.cn/v2/drawPrizeMarketDetails.action?taskId=TASK_SIGNIN&activityId=ACT_SIGNIN");
|
|
166
168
|
};
|
|
169
|
+
/**
|
|
170
|
+
* @deprecated 任务无效, 1.0.4版本废弃
|
|
171
|
+
*/
|
|
167
172
|
this.taskPhoto = () => {
|
|
168
173
|
return this.fetchAPI("https://m.cloud.189.cn/v2/drawPrizeMarketDetails.action?taskId=TASK_SIGNIN_PHOTOS&activityId=ACT_SIGNIN");
|
|
169
174
|
};
|
|
175
|
+
/**
|
|
176
|
+
* @deprecated 任务无效, 1.0.3版本废弃
|
|
177
|
+
*/
|
|
170
178
|
this.taskKJ = () => {
|
|
171
179
|
return this.fetchAPI("https://m.cloud.189.cn/v2/drawPrizeMarketDetails.action?taskId=TASK_2022_FLDFS_KJ&activityId=ACT_SIGNIN");
|
|
172
180
|
};
|
|
173
181
|
this.getUserBriefInfo = () => got_1.default
|
|
174
182
|
.get("https://cloud.189.cn/api/portal/v2/getUserBriefInfo.action", {
|
|
175
|
-
cookieJar,
|
|
183
|
+
cookieJar: this.cookieJar,
|
|
176
184
|
})
|
|
177
185
|
.json();
|
|
178
186
|
this.getAccessTokenBySsKey = (sessionKey) => {
|
|
@@ -191,7 +199,7 @@ class CloudClient {
|
|
|
191
199
|
Timestamp: time,
|
|
192
200
|
Appkey: appkey,
|
|
193
201
|
},
|
|
194
|
-
cookieJar,
|
|
202
|
+
cookieJar: this.cookieJar,
|
|
195
203
|
})
|
|
196
204
|
.json();
|
|
197
205
|
};
|
|
@@ -213,7 +221,7 @@ class CloudClient {
|
|
|
213
221
|
Accesstoken: __classPrivateFieldGet(this, _CloudClient_accessToken, "f"),
|
|
214
222
|
Accept: "application/json;charset=UTF-8",
|
|
215
223
|
},
|
|
216
|
-
cookieJar,
|
|
224
|
+
cookieJar: this.cookieJar,
|
|
217
225
|
})
|
|
218
226
|
.json();
|
|
219
227
|
};
|
|
@@ -224,6 +232,7 @@ class CloudClient {
|
|
|
224
232
|
};
|
|
225
233
|
this.username = username;
|
|
226
234
|
this.password = password;
|
|
235
|
+
this.cookieJar = new tough_cookie_1.CookieJar();
|
|
227
236
|
}
|
|
228
237
|
}
|
|
229
238
|
_CloudClient_accessToken = new WeakMap(), _CloudClient_builLoginForm = new WeakMap(), _CloudClient_sortParameter = new WeakMap(), _CloudClient_getSignature = new WeakMap();
|