@soga/part-uploader 0.2.22 → 0.2.23
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.AliHelper=void 0;const axios_1=__importDefault(require("axios")),base_uploader_1=require("./base-uploader"),crypto_1=require("crypto"),utils_1=require("@soga/utils"),types_1=require("@soga/types");class AliHelper extends base_uploader_1.BaseUploader{params;drive_id;axios;domain="https://openapi.alipan.com";chunk_size=4194304;group_list=[];constructor(t){super(t,types_1.HostType.ALI),this.params=t,this.initAxios()}getExpiredAt(){return Date.now()+348e4}initAxios(){this.axios=axios_1.default.create({baseURL:this.domain}),this.axios.interceptors.request.use((async t=>{const{access_token:
|
|
1
|
+
"use strict";var __importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.AliHelper=void 0;const axios_1=__importDefault(require("axios")),base_uploader_1=require("./base-uploader"),crypto_1=require("crypto"),utils_1=require("@soga/utils"),types_1=require("@soga/types");class AliHelper extends base_uploader_1.BaseUploader{params;drive_id;axios;domain="https://openapi.alipan.com";chunk_size=4194304;group_list=[];constructor(t){super(t,types_1.HostType.ALI),this.params=t,this.initAxios()}getExpiredAt(){return Date.now()+348e4}initAxios(){this.axios=axios_1.default.create({baseURL:this.domain}),this.axios.interceptors.request.use((async t=>{const{access_token:a}=await this.sdk.getAliHostAuthData({host_id:this.params.host_id,refresh:!1});return t.headers.Authorization=`Bearer ${a}`,t}),(t=>Promise.reject(t)))}async init(){await super.init();const{drive_id:t}=await this.sdk.getAliHostAuthData({host_id:this.params.host_id,refresh:!1});this.drive_id=t}async getUploadId(){return this.db.data.ali_upload_id}async cacheUploadId(t){this.db.data.ali_upload_id=t,await this.db.write()}async clearCache(){this.db.data={},await this.db.write()}async getFileId(){return this.db.data.ali_file_id}async cacheFileId(t){this.db.data.ali_file_id=t,await this.db.write()}async getPartInfoList(){const t=this.db.data.ali_part_info_list;if(t){const{expired_at:a,data:e}=t;return Date.now()<a?{state:!0,expired_at:a,data:e}:{state:!1,expired_at:a,data:e}}}async cachePartInfoList(t){this.db.data.ali_part_info_list={expired_at:this.getExpiredAt(),data:t},await this.db.write()}async getProofCode(){const{access_token:t}=await this.sdk.getAliHostAuthData({host_id:this.params.host_id,refresh:!1}),{part:a}=this.params,e=a.size,i=(0,crypto_1.createHash)("md5").update(t).digest("hex").slice(0,16),s=BigInt(`0x${i}`),r=Number(s%BigInt(e)),d=r,o=Math.min(e,r+8),_=a.start+d,h=a.start+o;return(await(0,utils_1.getFileBufferSlice)(a.path,_,h-1)).toString("base64")}}exports.AliHelper=AliHelper;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soga/part-uploader",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.23",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"form-data": "^4.0.2",
|
|
54
54
|
"fs-extra": "^11.2.0"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "f232aca1cb2b1e9c86d3142c2845d11c87b065ba"
|
|
57
57
|
}
|