@nger/fk-upload 1.0.4 → 1.0.7

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.
Files changed (62) hide show
  1. package/dist/core.d.ts +1 -0
  2. package/dist/entities/fk-download-task.entity.d.ts +12 -0
  3. package/dist/entities/fk-download-task.entity.js +83 -0
  4. package/dist/entities/fk-login-account.entity.d.ts +5 -0
  5. package/dist/entities/fk-login-account.entity.js +38 -0
  6. package/dist/entities/fk-login-cookie.entity.d.ts +7 -0
  7. package/dist/entities/fk-login-cookie.entity.js +54 -0
  8. package/dist/entities/fk-login.entity.d.ts +12 -0
  9. package/dist/entities/fk-login.entity.js +88 -0
  10. package/dist/entities/index.d.ts +3 -0
  11. package/dist/entities/index.js +19 -0
  12. package/dist/fk-upload.controller.d.ts +28 -0
  13. package/dist/fk-upload.controller.js +271 -0
  14. package/dist/fk-upload.module.d.ts +2 -0
  15. package/dist/fk-upload.module.js +66 -0
  16. package/dist/fk-v2.service.d.ts +29 -0
  17. package/dist/fk-v2.service.js +153 -0
  18. package/dist/fk.service.d.ts +18 -0
  19. package/dist/fk.service.js +89 -0
  20. package/dist/login.controller.d.ts +14 -0
  21. package/dist/login.controller.js +211 -0
  22. package/dist/main.d.ts +3 -0
  23. package/dist/main.js +36 -0
  24. package/dist/templates/account-manage.d.ts +3 -0
  25. package/dist/templates/account-manage.js +27 -0
  26. package/dist/templates/add-account.d.ts +0 -0
  27. package/dist/templates/add-account.js +1 -0
  28. package/dist/templates/add-fk-login.d.ts +10 -0
  29. package/dist/templates/add-fk-login.js +96 -0
  30. package/dist/templates/add-task.d.ts +10 -0
  31. package/dist/templates/add-task.js +76 -0
  32. package/dist/templates/code.d.ts +3 -0
  33. package/dist/templates/code.js +51 -0
  34. package/dist/templates/component.d.ts +9 -0
  35. package/dist/templates/component.js +34 -0
  36. package/dist/templates/download-task.d.ts +12 -0
  37. package/dist/templates/download-task.js +103 -0
  38. package/dist/templates/error.d.ts +3 -0
  39. package/dist/templates/error.js +41 -0
  40. package/dist/templates/help.d.ts +6 -0
  41. package/dist/templates/help.js +67 -0
  42. package/dist/templates/login.service.d.ts +2 -0
  43. package/dist/templates/login.service.js +16 -0
  44. package/dist/templates/relogin.d.ts +5 -0
  45. package/dist/templates/relogin.js +25 -0
  46. package/dist/templates/task-manage.d.ts +6 -0
  47. package/dist/templates/task-manage.js +76 -0
  48. package/dist/templates/upload-task.d.ts +9 -0
  49. package/dist/templates/upload-task.js +155 -0
  50. package/dist/templates/upload.d.ts +15 -0
  51. package/dist/templates/upload.js +248 -0
  52. package/dist/templates/upload.service.d.ts +18 -0
  53. package/dist/templates/upload.service.js +293 -0
  54. package/dist/templates/verify.d.ts +15 -0
  55. package/dist/templates/verify.js +75 -0
  56. package/dist/tests/test.d.ts +3 -0
  57. package/dist/tests/test.js +101 -0
  58. package/dist/urlSafeBase64Decode.d.ts +3 -0
  59. package/dist/urlSafeBase64Decode.js +37 -0
  60. package/package.json +6 -5
  61. package/pnpm-lock.yaml +1172 -0
  62. package/tsconfig.json +12 -0
@@ -0,0 +1,293 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.UploadService = void 0;
16
+ const path_1 = require("path");
17
+ const entities_1 = require("../entities");
18
+ const cids_1 = __importDefault(require("cids"));
19
+ const multihashing_async_1 = __importDefault(require("multihashing-async"));
20
+ const typeorm_1 = require("@nger/typeorm");
21
+ const rxjs_1 = require("rxjs");
22
+ const request_1 = require("request");
23
+ const fs_1 = require("fs");
24
+ const md5_file_1 = __importDefault(require("md5-file"));
25
+ const core_1 = require("@nger/core");
26
+ const axios_1 = __importDefault(require("axios"));
27
+ const form_data_1 = __importDefault(require("form-data"));
28
+ let UploadService = class UploadService {
29
+ db;
30
+ constructor(db) {
31
+ this.db = db;
32
+ }
33
+ async createDownLoadTask(url, fkLoginId) {
34
+ const observable = await this.createObservable(url);
35
+ return observable.listen.pipe((0, rxjs_1.throttleTime)(1000), (0, rxjs_1.switchMap)(async (res) => {
36
+ const exist = await this.db.manager.findOne(entities_1.FkDownloadTaskEntity, { where: { filename: observable.filename } });
37
+ if (exist) {
38
+ const size = res.size;
39
+ const total = res.totalSize;
40
+ const num = Math.floor((size / total) * 100);
41
+ await this.db.manager.update(entities_1.FkDownloadTaskEntity, exist.filename, { size: num });
42
+ }
43
+ else {
44
+ await this.db.manager.save(entities_1.FkDownloadTaskEntity, res);
45
+ }
46
+ return res;
47
+ })).subscribe({
48
+ next: () => { },
49
+ complete: async () => {
50
+ const exist = await this.db.manager.findOne(entities_1.FkDownloadTaskEntity, { where: { filename: observable.filename } });
51
+ const md5 = await (0, md5_file_1.default)(exist.path);
52
+ await this.db.manager.update(entities_1.FkDownloadTaskEntity, observable.filename, { status: 1, size: 100, fileMd5: md5, loginId: fkLoginId });
53
+ // upload
54
+ return await this.createUplaodTask(exist.filename);
55
+ }
56
+ });
57
+ }
58
+ getUploadUrl(token, forceDirect = true) {
59
+ if (forceDirect) {
60
+ return `https://${token.url}/${token.visitType}/${token.app}/upload?cmd=${token.cmd}&token=${token.token}`;
61
+ }
62
+ else {
63
+ return `https://${token.url}/${token.visitType}/${token.app}/advance?cmd=${token.cmd}&token=${token.token}`;
64
+ }
65
+ }
66
+ getUploadInfourl(token) {
67
+ return `https://${token.url}/${token.visitType}/${token.app}/advance/info?cmd=${token.cmd}&token=${token.token}`;
68
+ }
69
+ encodeURIComponent(data) {
70
+ return Object.keys(data).map(key => {
71
+ const value = Reflect.get(data, key);
72
+ return `${key}=${encodeURIComponent(value)}`;
73
+ }).join('&');
74
+ }
75
+ async createUplaodTask(filename) {
76
+ //
77
+ const task = await this.db.manager.findOne(entities_1.FkDownloadTaskEntity, { where: { filename } });
78
+ if (task) {
79
+ if (task.status === 0) {
80
+ return {
81
+ msg: 'downloading'
82
+ };
83
+ }
84
+ if (task.status === 2) {
85
+ return {
86
+ msg: 'uploaded'
87
+ };
88
+ }
89
+ const loginEntity = await this.db.manager.findOne(entities_1.FkLoginEntity, { where: { fkLoginId: task.loginId } });
90
+ const cookies = await this.db.manager.find(entities_1.FkLoginCookieEntity, { where: { fkLoginId: task.loginId } });
91
+ const cookie = cookies.map(cookie => `${cookie.key}=${cookie.value}`).join(';');
92
+ // 00 take token
93
+ const url = `https://i.vip.webportal.top/`;
94
+ const iVipWebPortal = await axios_1.default.get(url, {
95
+ headers: {
96
+ Cookie: cookie
97
+ }
98
+ }).then(res => res.data);
99
+ const items = iVipWebPortal.match(/<meta id='_TOKEN' value='(.*?)'\/>/);
100
+ let token = ``;
101
+ if (items && items.length === 2) {
102
+ token = items[1];
103
+ }
104
+ if (token.length > 0) {
105
+ // 01
106
+ const url = `https://smr00.vip.webportal.top/cn/api/manage/advanceUpload/genAccessKey?_v=1651232099799&_TOKEN=${token}`;
107
+ const accessKey = await axios_1.default.get(url).then(res => res.data);
108
+ if (accessKey.success) {
109
+ const accessTokenString = decode(accessKey.accessKey);
110
+ if (accessTokenString) {
111
+ const accessToken = JSON.parse(accessTokenString);
112
+ const uploadInfoUrl = this.getUploadInfourl(accessToken);
113
+ const bssInfo = {
114
+ fromSite: true, siteId: 0, groupId: 0, fileSizeLimit: 1024
115
+ };
116
+ const info = await axios_1.default.post(uploadInfoUrl, this.encodeURIComponent({
117
+ fileMd5: task.fileMd5,
118
+ fileSize: task.totalSize,
119
+ isFreeVer: false,
120
+ aid: loginEntity.aid,
121
+ folderId: loginEntity.uploadGroupId,
122
+ bssInfo: JSON.stringify(bssInfo),
123
+ fileName: task.filename
124
+ }), { headers: { cookie: cookie } }).then(res => res.data);
125
+ if (info.code === 200) {
126
+ const data = info.data;
127
+ const { delayTime, splitSize, uploadedSize } = data;
128
+ const uploadUrl = this.getUploadUrl(accessToken, false);
129
+ const totalChunks = Math.ceil((task.totalSize - uploadedSize) / splitSize);
130
+ let start = uploadedSize;
131
+ let index = Math.ceil(uploadedSize / splitSize);
132
+ let complete = false;
133
+ do {
134
+ if (index >= totalChunks - 1) {
135
+ complete = true;
136
+ }
137
+ const fileStream = (0, fs_1.createReadStream)(task.path, { start: start, end: start + splitSize });
138
+ const formdata = new form_data_1.default();
139
+ formdata.append('ctrl', fileStream);
140
+ formdata.append('isFreeVer', 'false');
141
+ formdata.append('aid', `${loginEntity.aid || 0}`);
142
+ formdata.append('folderId', `${loginEntity.uploadGroupId || 0}`);
143
+ formdata.append('fileName', task.filename);
144
+ formdata.append(`totalSize`, `${task.totalSize}`);
145
+ formdata.append(`fileMd5`, task.fileMd5);
146
+ formdata.append('index', `${index}`);
147
+ formdata.append('chunkSize', `${splitSize}`);
148
+ formdata.append('totalChunks', `${totalChunks}`);
149
+ formdata.append(`complete`, `${complete}`);
150
+ formdata.append('bssInfo', JSON.stringify(bssInfo));
151
+ const headers = formdata.getHeaders();
152
+ const uploadResult = await axios_1.default.post(uploadUrl, formdata, {
153
+ headers: {
154
+ ...headers,
155
+ Cookie: cookie
156
+ }
157
+ }).then(res => {
158
+ const data = res.data;
159
+ return data;
160
+ });
161
+ if (uploadResult.code === 200) {
162
+ const data = uploadResult.data;
163
+ if (data) {
164
+ const downUrl = data.downUrl;
165
+ if (downUrl) {
166
+ await this.db.manager.update(entities_1.FkDownloadTaskEntity, task.filename, {
167
+ status: 2,
168
+ uploadUrl: `https://` + downUrl,
169
+ uploadSize: 100
170
+ });
171
+ }
172
+ else {
173
+ await this.db.manager.update(entities_1.FkDownloadTaskEntity, task.filename, {
174
+ uploadSize: Math.floor(((index + 1) / totalChunks) * 100)
175
+ });
176
+ }
177
+ }
178
+ index = index + 1;
179
+ start = start + splitSize;
180
+ }
181
+ } while (!complete);
182
+ }
183
+ }
184
+ }
185
+ }
186
+ }
187
+ }
188
+ async createObservable(url) {
189
+ const hash = await (0, multihashing_async_1.default)(Buffer.from(url), 'sha1', 16);
190
+ const cid = new cids_1.default(1, 'raw', hash, 'base64');
191
+ // const _url = new URL(url);
192
+ // const pathname = _url.pathname;
193
+ // const ext = extname(pathname)
194
+ const filename = cid.toString('base64');
195
+ let item = await this.db.manager.findOne(entities_1.FkDownloadTaskEntity, { where: { filename } });
196
+ if (item) {
197
+ let task = item;
198
+ if (task.status) {
199
+ return {
200
+ listen: (0, rxjs_1.of)(task),
201
+ filename
202
+ };
203
+ }
204
+ const observable = new rxjs_1.Observable((sub) => {
205
+ // go on
206
+ const writeStream = (0, fs_1.createWriteStream)(task.path, { start: task.size });
207
+ const req = (0, request_1.get)(url, {
208
+ headers: {
209
+ 'Content-Type': 'application/octet-stream'
210
+ }
211
+ });
212
+ let length = 0;
213
+ req.on('data', (buf) => {
214
+ length += buf.length;
215
+ if (length >= task.size) {
216
+ task.size = length;
217
+ writeStream.write(buf, (err) => {
218
+ if (err)
219
+ sub.error(err);
220
+ });
221
+ sub.next(task);
222
+ }
223
+ });
224
+ req.on('end', () => {
225
+ sub.complete();
226
+ writeStream.end();
227
+ });
228
+ });
229
+ return { listen: observable, filename };
230
+ }
231
+ ;
232
+ const observable = new rxjs_1.Observable((sub) => {
233
+ let task = new entities_1.FkDownloadTaskEntity();
234
+ task.url = url;
235
+ const req = (0, request_1.get)(url);
236
+ const path = (0, path_1.join)(__dirname, 'dist', encodeURIComponent(filename));
237
+ const writeStream = (0, fs_1.createWriteStream)(path);
238
+ task.path = path;
239
+ let total = 0;
240
+ let length = 0;
241
+ task.filename = filename;
242
+ task.uploadSize = 0;
243
+ req.on('data', (buf) => {
244
+ length += buf.length;
245
+ task.size = length;
246
+ writeStream.write(buf, (err) => {
247
+ if (err)
248
+ sub.error(err);
249
+ });
250
+ sub.next(task);
251
+ });
252
+ req.on('end', () => {
253
+ sub.complete();
254
+ writeStream.end();
255
+ });
256
+ req.on('response', (resp) => {
257
+ const headers = resp.headers;
258
+ total = Number(Reflect.get(headers, 'content-length'));
259
+ task.totalSize = total;
260
+ task.size = 0;
261
+ task.status = 0;
262
+ sub.next(task);
263
+ });
264
+ });
265
+ return { listen: observable, filename };
266
+ }
267
+ };
268
+ UploadService = __decorate([
269
+ (0, core_1.Injectable)(),
270
+ __metadata("design:paramtypes", [typeorm_1.Db])
271
+ ], UploadService);
272
+ exports.UploadService = UploadService;
273
+ function decode(base64Str) {
274
+ if (!base64Str)
275
+ return;
276
+ const t = base64Str.replace(/_/g, "/").replace(/-/g, "+");
277
+ const f = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
278
+ let l = 0;
279
+ let p = 0;
280
+ let h = [];
281
+ do {
282
+ const o = f.indexOf(t.charAt(l++));
283
+ const u = f.indexOf(t.charAt(l++));
284
+ const a = f.indexOf(t.charAt(l++));
285
+ const c = f.indexOf(t.charAt(l++));
286
+ const s = o << 18 | u << 12 | a << 6 | c;
287
+ const e = s >> 16 & 255;
288
+ const r = s >> 8 & 255;
289
+ const n = 255 & s;
290
+ h[p++] = 64 === a ? String.fromCharCode(e) : 64 === c ? String.fromCharCode(e, r) : String.fromCharCode(e, r, n);
291
+ } while (l < t.length);
292
+ return h.join('');
293
+ }
@@ -0,0 +1,15 @@
1
+ export declare class VerifyController {
2
+ monitor(monitorId: string): Promise<any>;
3
+ get(body: VerifyBody): Promise<any>;
4
+ validate(body: ValidateBody): Promise<any>;
5
+ }
6
+ export interface VerifyBody {
7
+ appKey: number;
8
+ bss: number;
9
+ bssKey: string;
10
+ version: string;
11
+ }
12
+ export interface ValidateBody extends VerifyBody {
13
+ et: number;
14
+ vi: string;
15
+ }
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var __importDefault = (this && this.__importDefault) || function (mod) {
15
+ return (mod && mod.__esModule) ? mod : { "default": mod };
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.VerifyController = void 0;
19
+ const axios_1 = __importDefault(require("axios"));
20
+ const core_1 = require("@nger/core");
21
+ const http_1 = require("@nger/http");
22
+ let VerifyController = class VerifyController {
23
+ monitor(monitorId) {
24
+ return axios_1.default.get(`https://cv.webportal.top/verify/monitor?monitorId=${monitorId}`, {
25
+ headers: {
26
+ [`Content-Type`]: `text/plain`
27
+ }
28
+ }).then(res => {
29
+ return res.data;
30
+ });
31
+ }
32
+ get(body) {
33
+ return axios_1.default.post(`https://cv.webportal.top/verify/get`, body, {
34
+ headers: {
35
+ [`Content-Type`]: `text/plain`
36
+ }
37
+ }).then(res => {
38
+ return res.data;
39
+ });
40
+ }
41
+ validate(body) {
42
+ return axios_1.default.post(`https://cv.webportal.top/verify/validate`, body, {
43
+ headers: {
44
+ [`Content-Type`]: `text/plain`
45
+ }
46
+ }).then(res => {
47
+ return res.data;
48
+ });
49
+ }
50
+ };
51
+ __decorate([
52
+ (0, http_1.Get)('monitor'),
53
+ __param(0, (0, http_1.Query)('monitorId')),
54
+ __metadata("design:type", Function),
55
+ __metadata("design:paramtypes", [String]),
56
+ __metadata("design:returntype", void 0)
57
+ ], VerifyController.prototype, "monitor", null);
58
+ __decorate([
59
+ (0, http_1.Post)('get'),
60
+ __param(0, (0, http_1.Body)()),
61
+ __metadata("design:type", Function),
62
+ __metadata("design:paramtypes", [Object]),
63
+ __metadata("design:returntype", void 0)
64
+ ], VerifyController.prototype, "get", null);
65
+ __decorate([
66
+ (0, http_1.Post)('validate'),
67
+ __param(0, (0, http_1.Body)()),
68
+ __metadata("design:type", Function),
69
+ __metadata("design:paramtypes", [Object]),
70
+ __metadata("design:returntype", void 0)
71
+ ], VerifyController.prototype, "validate", null);
72
+ VerifyController = __decorate([
73
+ (0, core_1.Controller)(`verify`)
74
+ ], VerifyController);
75
+ exports.VerifyController = VerifyController;
@@ -0,0 +1,3 @@
1
+ import "reflect-metadata";
2
+ export declare class AppModule {
3
+ }
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.AppModule = void 0;
13
+ require("reflect-metadata");
14
+ require('dotenv').config();
15
+ const core_1 = require("@nger/core");
16
+ const core_2 = require("@nger/core");
17
+ const fk_upload_module_1 = require("../fk-upload.module");
18
+ const typeorm_1 = require("@nger/typeorm");
19
+ const fk_service_1 = require("../fk.service");
20
+ const fk_v2_service_1 = require("../fk-v2.service");
21
+ const fs_1 = require("fs");
22
+ const path_1 = require("path");
23
+ let AppModule = class AppModule {
24
+ };
25
+ AppModule = __decorate([
26
+ (0, core_2.Module)({
27
+ providers: [{
28
+ provide: core_1.APP_ROOT,
29
+ useValue: process.cwd()
30
+ }],
31
+ imports: [
32
+ fk_upload_module_1.FkUploadModule,
33
+ typeorm_1.TypeormModule.forEnv()
34
+ ],
35
+ controllers: []
36
+ })
37
+ ], AppModule);
38
+ exports.AppModule = AppModule;
39
+ const axios_1 = __importDefault(require("axios"));
40
+ const form_data_1 = __importDefault(require("form-data"));
41
+ (0, core_1.platformCore)().bootstrap(AppModule).then(async (res) => {
42
+ const db = res.get(typeorm_1.Db);
43
+ const fk = res.get(fk_service_1.FkService);
44
+ const smr00 = await fk.getFkLogin(`smr00`);
45
+ if (smr00) {
46
+ const fkv2 = new fk_v2_service_1.FkV2Service(smr00, db, res);
47
+ await fkv2.init();
48
+ const token = await fkv2.genAccessKey();
49
+ const watermark = await fkv2.getWatermark();
50
+ const file = (0, fs_1.createReadStream)((0, path_1.join)(__dirname, './2.jpeg'));
51
+ if (token) {
52
+ const uploadUrl = fkv2.getUploadUrl(token);
53
+ const formdata = new form_data_1.default();
54
+ formdata.append('ctrl', file);
55
+ formdata.append('fileName', `2.jpeg`);
56
+ formdata.append('isFreeVer', `false`);
57
+ formdata.append('aid', fkv2.aid || 0);
58
+ formdata.append('folderId', fkv2.siteId || 0);
59
+ const bssInfo = {
60
+ // 是否上传到资源库
61
+ fromSite: true,
62
+ // 站点
63
+ siteId: fkv2.aid || 0,
64
+ // 文件夹
65
+ groupId: fkv2.siteId || 0,
66
+ // 文件大小限制
67
+ fileSizeLimit: fkv2.fileSizeLimit * 1024 * 1024
68
+ // waterMark
69
+ };
70
+ formdata.append('bssInfo', JSON.stringify(bssInfo));
71
+ const headers = formdata.getHeaders();
72
+ const res = await axios_1.default.put(uploadUrl, formdata, {
73
+ headers: {
74
+ ...headers,
75
+ 'Cookie': await fkv2.getCookies()
76
+ }
77
+ });
78
+ debugger;
79
+ // const req = Request.post(uploadUrl, {
80
+ // body: formdata,
81
+ // headers: {
82
+ // ...headers,
83
+ // 'Cookie': await fkv2.getCookies()
84
+ // }
85
+ // });
86
+ // req.on('data', (chunk) => {
87
+ // const str = chunk.toString('utf-8')
88
+ // debugger;
89
+ // })
90
+ // // const url = new URL(uploadUrl)
91
+ // formdata.submit(uploadUrl, (err, res) => {
92
+ // res.on('data', (buf: Buffer) => {
93
+ // const d = buf.toString('utf8');
94
+ // debugger;
95
+ // });
96
+ // });
97
+ // let token: any = JSON.parse(res)
98
+ // console.log({ data: res.data, watermark })
99
+ }
100
+ }
101
+ });
@@ -0,0 +1,3 @@
1
+ export declare class UrlSafeBase64 {
2
+ decode(base64Str: string): string | void;
3
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.UrlSafeBase64 = void 0;
10
+ const core_1 = require("@nger/core");
11
+ let UrlSafeBase64 = class UrlSafeBase64 {
12
+ decode(base64Str) {
13
+ if (!base64Str)
14
+ return;
15
+ const t = base64Str.replace(/_/g, "/").replace(/-/g, "+");
16
+ const f = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
17
+ let l = 0;
18
+ let p = 0;
19
+ let h = [];
20
+ do {
21
+ const o = f.indexOf(t.charAt(l++));
22
+ const u = f.indexOf(t.charAt(l++));
23
+ const a = f.indexOf(t.charAt(l++));
24
+ const c = f.indexOf(t.charAt(l++));
25
+ const s = o << 18 | u << 12 | a << 6 | c;
26
+ const e = s >> 16 & 255;
27
+ const r = s >> 8 & 255;
28
+ const n = 255 & s;
29
+ h[p++] = 64 === a ? String.fromCharCode(e) : 64 === c ? String.fromCharCode(e, r) : String.fromCharCode(e, r, n);
30
+ } while (l < t.length);
31
+ return h.join('');
32
+ }
33
+ };
34
+ UrlSafeBase64 = __decorate([
35
+ (0, core_1.Injectable)()
36
+ ], UrlSafeBase64);
37
+ exports.UrlSafeBase64 = UrlSafeBase64;
package/package.json CHANGED
@@ -1,28 +1,29 @@
1
1
  {
2
2
  "name": "@nger/fk-upload",
3
- "version": "1.0.4",
3
+ "version": "1.0.7",
4
4
  "description": "",
5
5
  "main": "dist/core.js",
6
6
  "types": "dist/core.d.ts",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
10
- "files": [
11
- "./dist",
12
- "./readme.md"
13
- ],
14
10
  "author": "",
15
11
  "license": "ISC",
16
12
  "dependencies": {
17
13
  "@nger/core": "^1.0.0",
14
+ "@nger/api": "^1.0.0",
18
15
  "@nger/http": "^4.0.0",
16
+ "@nger/typeorm": "^1.0.0",
19
17
  "@nger/ws": "^1.0.0",
20
18
  "@types/download": "^8.0.1",
21
19
  "@types/request": "^2.48.8",
22
20
  "axios": "^0.26.1",
21
+ "cids": "^1.1.9",
23
22
  "download": "^8.0.0",
24
23
  "form-data": "^4.0.0",
24
+ "fs-extra": "^10.1.0",
25
25
  "md5-file": "^5.0.0",
26
+ "multihashing-async": "^2.1.4",
26
27
  "request": "^2.88.2"
27
28
  },
28
29
  "scripts": {