@bedelightful/upload-sdk 0.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.
- package/LICENSE +8 -0
- package/README.md +132 -0
- package/dist/es/Exception/BaseException.js +14 -0
- package/dist/es/Exception/BaseException.js.map +1 -0
- package/dist/es/Exception/DownloadException.js +40 -0
- package/dist/es/Exception/DownloadException.js.map +1 -0
- package/dist/es/Exception/HttpException.js +50 -0
- package/dist/es/Exception/HttpException.js.map +1 -0
- package/dist/es/Exception/InitException.js +49 -0
- package/dist/es/Exception/InitException.js.map +1 -0
- package/dist/es/Exception/UploadException.js +50 -0
- package/dist/es/Exception/UploadException.js.map +1 -0
- package/dist/es/index.d.ts +867 -0
- package/dist/es/index.js +162 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/modules/Kodo/defaultUpload.js +38 -0
- package/dist/es/modules/Kodo/defaultUpload.js.map +1 -0
- package/dist/es/modules/Kodo/index.js +8 -0
- package/dist/es/modules/Kodo/index.js.map +1 -0
- package/dist/es/modules/Local/index.js +31 -0
- package/dist/es/modules/Local/index.js.map +1 -0
- package/dist/es/modules/MinIO/MultipartUpload.js +335 -0
- package/dist/es/modules/MinIO/MultipartUpload.js.map +1 -0
- package/dist/es/modules/MinIO/STSUpload.js +10 -0
- package/dist/es/modules/MinIO/STSUpload.js.map +1 -0
- package/dist/es/modules/MinIO/defaultUpload.js +124 -0
- package/dist/es/modules/MinIO/defaultUpload.js.map +1 -0
- package/dist/es/modules/MinIO/index.js +16 -0
- package/dist/es/modules/MinIO/index.js.map +1 -0
- package/dist/es/modules/OBS/MultipartUpload.js +269 -0
- package/dist/es/modules/OBS/MultipartUpload.js.map +1 -0
- package/dist/es/modules/OBS/STSUpload.js +71 -0
- package/dist/es/modules/OBS/STSUpload.js.map +1 -0
- package/dist/es/modules/OBS/defaultUpload.js +59 -0
- package/dist/es/modules/OBS/defaultUpload.js.map +1 -0
- package/dist/es/modules/OBS/index.js +16 -0
- package/dist/es/modules/OBS/index.js.map +1 -0
- package/dist/es/modules/OBS/utils/index.js +25 -0
- package/dist/es/modules/OBS/utils/index.js.map +1 -0
- package/dist/es/modules/OSS/MultipartUpload.js +232 -0
- package/dist/es/modules/OSS/MultipartUpload.js.map +1 -0
- package/dist/es/modules/OSS/STSUpload.js +48 -0
- package/dist/es/modules/OSS/STSUpload.js.map +1 -0
- package/dist/es/modules/OSS/defaultUpload.js +53 -0
- package/dist/es/modules/OSS/defaultUpload.js.map +1 -0
- package/dist/es/modules/OSS/index.js +16 -0
- package/dist/es/modules/OSS/index.js.map +1 -0
- package/dist/es/modules/OSS/utils/helper.js +137 -0
- package/dist/es/modules/OSS/utils/helper.js.map +1 -0
- package/dist/es/modules/OSS/utils/signature.js +96 -0
- package/dist/es/modules/OSS/utils/signature.js.map +1 -0
- package/dist/es/modules/TOS/MultipartUpload.js +288 -0
- package/dist/es/modules/TOS/MultipartUpload.js.map +1 -0
- package/dist/es/modules/TOS/STSUpload.js +92 -0
- package/dist/es/modules/TOS/STSUpload.js.map +1 -0
- package/dist/es/modules/TOS/defaultUpload.js +65 -0
- package/dist/es/modules/TOS/defaultUpload.js.map +1 -0
- package/dist/es/modules/TOS/index.js +16 -0
- package/dist/es/modules/TOS/index.js.map +1 -0
- package/dist/es/modules/TOS/utils/TosClientError.js +15 -0
- package/dist/es/modules/TOS/utils/TosClientError.js.map +1 -0
- package/dist/es/modules/TOS/utils/index.js +38 -0
- package/dist/es/modules/TOS/utils/index.js.map +1 -0
- package/dist/es/modules/TOS/utils/signatureV4.js +269 -0
- package/dist/es/modules/TOS/utils/signatureV4.js.map +1 -0
- package/dist/es/modules/TOS/utils/signatureV4Credentials.js +21 -0
- package/dist/es/modules/TOS/utils/signatureV4Credentials.js.map +1 -0
- package/dist/es/modules/TOS/utils/universal/crypto.browser.js +56 -0
- package/dist/es/modules/TOS/utils/universal/crypto.browser.js.map +1 -0
- package/dist/es/modules/TOS/utils/utils.js +18 -0
- package/dist/es/modules/TOS/utils/utils.js.map +1 -0
- package/dist/es/modules/index.js +20 -0
- package/dist/es/modules/index.js.map +1 -0
- package/dist/es/types/Kodo.js +1 -0
- package/dist/es/types/Kodo.js.map +1 -0
- package/dist/es/types/Local.js +1 -0
- package/dist/es/types/Local.js.map +1 -0
- package/dist/es/types/MinIO.js +1 -0
- package/dist/es/types/MinIO.js.map +1 -0
- package/dist/es/types/OBS.js +8 -0
- package/dist/es/types/OBS.js.map +1 -0
- package/dist/es/types/OSS.js +1 -0
- package/dist/es/types/OSS.js.map +1 -0
- package/dist/es/types/TOS.js +1 -0
- package/dist/es/types/TOS.js.map +1 -0
- package/dist/es/types/error.js +1 -0
- package/dist/es/types/error.js.map +1 -0
- package/dist/es/types/index.js +13 -0
- package/dist/es/types/index.js.map +1 -0
- package/dist/es/types/log.js +1 -0
- package/dist/es/types/log.js.map +1 -0
- package/dist/es/types/request.js +1 -0
- package/dist/es/types/request.js.map +1 -0
- package/dist/es/utils/EventEmitter.js +32 -0
- package/dist/es/utils/EventEmitter.js.map +1 -0
- package/dist/es/utils/UploadManger.js +276 -0
- package/dist/es/utils/UploadManger.js.map +1 -0
- package/dist/es/utils/UploadTask.js +13 -0
- package/dist/es/utils/UploadTask.js.map +1 -0
- package/dist/es/utils/checkDataFormat.js +41 -0
- package/dist/es/utils/checkDataFormat.js.map +1 -0
- package/dist/es/utils/global.js +83 -0
- package/dist/es/utils/global.js.map +1 -0
- package/dist/es/utils/index.js +20 -0
- package/dist/es/utils/index.js.map +1 -0
- package/dist/es/utils/logPubSub.js +59 -0
- package/dist/es/utils/logPubSub.js.map +1 -0
- package/dist/es/utils/multipart.js +159 -0
- package/dist/es/utils/multipart.js.map +1 -0
- package/dist/es/utils/nanoid.js +10 -0
- package/dist/es/utils/nanoid.js.map +1 -0
- package/dist/es/utils/regExpUtil.js +21 -0
- package/dist/es/utils/regExpUtil.js.map +1 -0
- package/dist/es/utils/request.js +234 -0
- package/dist/es/utils/request.js.map +1 -0
- package/dist/es/utils/response.js +20 -0
- package/dist/es/utils/response.js.map +1 -0
- package/dist/index.d.ts +867 -0
- package/dist/index.js +60913 -0
- package/dist/index.js.map +1 -0
- package/dist/index.min.js +130 -0
- package/dist/index.min.js.map +1 -0
- package/dist/lib/Exception/BaseException.js +37 -0
- package/dist/lib/Exception/BaseException.js.map +1 -0
- package/dist/lib/Exception/DownloadException.js +65 -0
- package/dist/lib/Exception/DownloadException.js.map +1 -0
- package/dist/lib/Exception/HttpException.js +75 -0
- package/dist/lib/Exception/HttpException.js.map +1 -0
- package/dist/lib/Exception/InitException.js +73 -0
- package/dist/lib/Exception/InitException.js.map +1 -0
- package/dist/lib/Exception/UploadException.js +75 -0
- package/dist/lib/Exception/UploadException.js.map +1 -0
- package/dist/lib/index.d.cts +867 -0
- package/dist/lib/index.js +203 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/modules/Kodo/defaultUpload.js +61 -0
- package/dist/lib/modules/Kodo/defaultUpload.js.map +1 -0
- package/dist/lib/modules/Kodo/index.js +28 -0
- package/dist/lib/modules/Kodo/index.js.map +1 -0
- package/dist/lib/modules/Local/index.js +50 -0
- package/dist/lib/modules/Local/index.js.map +1 -0
- package/dist/lib/modules/MinIO/MultipartUpload.js +357 -0
- package/dist/lib/modules/MinIO/MultipartUpload.js.map +1 -0
- package/dist/lib/modules/MinIO/STSUpload.js +33 -0
- package/dist/lib/modules/MinIO/STSUpload.js.map +1 -0
- package/dist/lib/modules/MinIO/defaultUpload.js +158 -0
- package/dist/lib/modules/MinIO/defaultUpload.js.map +1 -0
- package/dist/lib/modules/MinIO/index.js +35 -0
- package/dist/lib/modules/MinIO/index.js.map +1 -0
- package/dist/lib/modules/OBS/MultipartUpload.js +296 -0
- package/dist/lib/modules/OBS/MultipartUpload.js.map +1 -0
- package/dist/lib/modules/OBS/STSUpload.js +104 -0
- package/dist/lib/modules/OBS/STSUpload.js.map +1 -0
- package/dist/lib/modules/OBS/defaultUpload.js +88 -0
- package/dist/lib/modules/OBS/defaultUpload.js.map +1 -0
- package/dist/lib/modules/OBS/index.js +45 -0
- package/dist/lib/modules/OBS/index.js.map +1 -0
- package/dist/lib/modules/OBS/utils/index.js +49 -0
- package/dist/lib/modules/OBS/utils/index.js.map +1 -0
- package/dist/lib/modules/OSS/MultipartUpload.js +259 -0
- package/dist/lib/modules/OSS/MultipartUpload.js.map +1 -0
- package/dist/lib/modules/OSS/STSUpload.js +71 -0
- package/dist/lib/modules/OSS/STSUpload.js.map +1 -0
- package/dist/lib/modules/OSS/defaultUpload.js +76 -0
- package/dist/lib/modules/OSS/defaultUpload.js.map +1 -0
- package/dist/lib/modules/OSS/index.js +35 -0
- package/dist/lib/modules/OSS/index.js.map +1 -0
- package/dist/lib/modules/OSS/utils/helper.js +173 -0
- package/dist/lib/modules/OSS/utils/helper.js.map +1 -0
- package/dist/lib/modules/OSS/utils/signature.js +132 -0
- package/dist/lib/modules/OSS/utils/signature.js.map +1 -0
- package/dist/lib/modules/TOS/MultipartUpload.js +315 -0
- package/dist/lib/modules/TOS/MultipartUpload.js.map +1 -0
- package/dist/lib/modules/TOS/STSUpload.js +125 -0
- package/dist/lib/modules/TOS/STSUpload.js.map +1 -0
- package/dist/lib/modules/TOS/defaultUpload.js +94 -0
- package/dist/lib/modules/TOS/defaultUpload.js.map +1 -0
- package/dist/lib/modules/TOS/index.js +45 -0
- package/dist/lib/modules/TOS/index.js.map +1 -0
- package/dist/lib/modules/TOS/utils/TosClientError.js +34 -0
- package/dist/lib/modules/TOS/utils/TosClientError.js.map +1 -0
- package/dist/lib/modules/TOS/utils/index.js +64 -0
- package/dist/lib/modules/TOS/utils/index.js.map +1 -0
- package/dist/lib/modules/TOS/utils/signatureV4.js +294 -0
- package/dist/lib/modules/TOS/utils/signatureV4.js.map +1 -0
- package/dist/lib/modules/TOS/utils/signatureV4Credentials.js +44 -0
- package/dist/lib/modules/TOS/utils/signatureV4Credentials.js.map +1 -0
- package/dist/lib/modules/TOS/utils/universal/crypto.browser.js +93 -0
- package/dist/lib/modules/TOS/utils/universal/crypto.browser.js.map +1 -0
- package/dist/lib/modules/TOS/utils/utils.js +42 -0
- package/dist/lib/modules/TOS/utils/utils.js.map +1 -0
- package/dist/lib/modules/index.js +50 -0
- package/dist/lib/modules/index.js.map +1 -0
- package/dist/lib/types/Kodo.js +17 -0
- package/dist/lib/types/Kodo.js.map +1 -0
- package/dist/lib/types/Local.js +17 -0
- package/dist/lib/types/Local.js.map +1 -0
- package/dist/lib/types/MinIO.js +17 -0
- package/dist/lib/types/MinIO.js.map +1 -0
- package/dist/lib/types/OBS.js +32 -0
- package/dist/lib/types/OBS.js.map +1 -0
- package/dist/lib/types/OSS.js +17 -0
- package/dist/lib/types/OSS.js.map +1 -0
- package/dist/lib/types/TOS.js +17 -0
- package/dist/lib/types/TOS.js.map +1 -0
- package/dist/lib/types/error.js +17 -0
- package/dist/lib/types/error.js.map +1 -0
- package/dist/lib/types/index.js +37 -0
- package/dist/lib/types/index.js.map +1 -0
- package/dist/lib/types/log.js +17 -0
- package/dist/lib/types/log.js.map +1 -0
- package/dist/lib/types/request.js +17 -0
- package/dist/lib/types/request.js.map +1 -0
- package/dist/lib/utils/EventEmitter.js +51 -0
- package/dist/lib/utils/EventEmitter.js.map +1 -0
- package/dist/lib/utils/UploadManger.js +309 -0
- package/dist/lib/utils/UploadManger.js.map +1 -0
- package/dist/lib/utils/UploadTask.js +32 -0
- package/dist/lib/utils/UploadTask.js.map +1 -0
- package/dist/lib/utils/checkDataFormat.js +70 -0
- package/dist/lib/utils/checkDataFormat.js.map +1 -0
- package/dist/lib/utils/global.js +106 -0
- package/dist/lib/utils/global.js.map +1 -0
- package/dist/lib/utils/index.js +44 -0
- package/dist/lib/utils/index.js.map +1 -0
- package/dist/lib/utils/logPubSub.js +78 -0
- package/dist/lib/utils/logPubSub.js.map +1 -0
- package/dist/lib/utils/multipart.js +197 -0
- package/dist/lib/utils/multipart.js.map +1 -0
- package/dist/lib/utils/nanoid.js +33 -0
- package/dist/lib/utils/nanoid.js.map +1 -0
- package/dist/lib/utils/regExpUtil.js +44 -0
- package/dist/lib/utils/regExpUtil.js.map +1 -0
- package/dist/lib/utils/request.js +264 -0
- package/dist/lib/utils/request.js.map +1 -0
- package/dist/lib/utils/response.js +43 -0
- package/dist/lib/utils/response.js.map +1 -0
- package/dist/package.json +120 -0
- package/package.json +120 -0
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var signatureV4_exports = {};
|
|
21
|
+
__export(signatureV4_exports, {
|
|
22
|
+
SIG_QUERY: () => SIG_QUERY,
|
|
23
|
+
SignersV4: () => SignersV4,
|
|
24
|
+
isDefaultPort: () => isDefaultPort
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(signatureV4_exports);
|
|
27
|
+
var import_crypto = require("./universal/crypto.browser");
|
|
28
|
+
var import_utils = require("./utils");
|
|
29
|
+
const SIG_QUERY = {
|
|
30
|
+
algorithm: "tos-algorithm",
|
|
31
|
+
expiration: "tos-expiration",
|
|
32
|
+
signame: "tos-signame",
|
|
33
|
+
signature: "tos-signature",
|
|
34
|
+
v4_algorithm: "X-Tos-Algorithm",
|
|
35
|
+
v4_credential: "X-Tos-Credential",
|
|
36
|
+
v4_date: "X-Tos-Date",
|
|
37
|
+
v4_expires: "X-Tos-Expires",
|
|
38
|
+
v4_signedHeaders: "X-Tos-SignedHeaders",
|
|
39
|
+
v4_security_token: "X-Tos-Security-Token",
|
|
40
|
+
v4_signature: "X-Tos-Signature",
|
|
41
|
+
v4_content_sha: "X-Tos-Content-Sha256",
|
|
42
|
+
v4_policy: "X-Tos-Policy"
|
|
43
|
+
};
|
|
44
|
+
function isDefaultPort(port) {
|
|
45
|
+
if (port && port !== 80 && port !== 443) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
__name(isDefaultPort, "isDefaultPort");
|
|
51
|
+
const v4Identifier = "request";
|
|
52
|
+
function getNeedSignedHeaders(headers) {
|
|
53
|
+
const needSignHeaders = [];
|
|
54
|
+
if (headers) {
|
|
55
|
+
Object.keys(headers).forEach((key) => {
|
|
56
|
+
if (key === "host" || key.startsWith("x-tos-")) {
|
|
57
|
+
if (headers[key] != null) {
|
|
58
|
+
needSignHeaders.push(key);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return needSignHeaders.sort();
|
|
64
|
+
}
|
|
65
|
+
__name(getNeedSignedHeaders, "getNeedSignedHeaders");
|
|
66
|
+
const _SignersV4 = class _SignersV4 {
|
|
67
|
+
constructor(opt, credentials) {
|
|
68
|
+
/**
|
|
69
|
+
* normal v4 signature
|
|
70
|
+
* */
|
|
71
|
+
// @ts-ignore
|
|
72
|
+
this.signature = /* @__PURE__ */ __name((opt, expiredAt, credentials) => {
|
|
73
|
+
if (!credentials) {
|
|
74
|
+
credentials = this.credentials;
|
|
75
|
+
}
|
|
76
|
+
const parts = [];
|
|
77
|
+
const datatime = opt.datetime;
|
|
78
|
+
const credString = this.credentialString(datatime);
|
|
79
|
+
parts.push(
|
|
80
|
+
`${this.options.algorithm} Credential=${credentials.GetAccessKey()}/${credString}`
|
|
81
|
+
);
|
|
82
|
+
parts.push(`SignedHeaders=${_SignersV4.signedHeaders(opt)}`);
|
|
83
|
+
parts.push(`Signature=${this.authorization(opt, credentials, 0)}`);
|
|
84
|
+
return parts.join(", ");
|
|
85
|
+
}, "signature");
|
|
86
|
+
this.signatureHeader = /* @__PURE__ */ __name((opt, expiredAt, credentials) => {
|
|
87
|
+
opt.datetime = _SignersV4.getDateTime();
|
|
88
|
+
const header = /* @__PURE__ */ new Map();
|
|
89
|
+
if (!opt.headers) {
|
|
90
|
+
const h = {};
|
|
91
|
+
opt.headers = h;
|
|
92
|
+
}
|
|
93
|
+
opt.headers.host = `${opt.host}`;
|
|
94
|
+
if (!isDefaultPort(opt.port)) {
|
|
95
|
+
opt.headers.host += `:${opt.port}`;
|
|
96
|
+
}
|
|
97
|
+
if (opt.endpoints) {
|
|
98
|
+
opt.headers.host = `${this.options.bucket}.${opt.endpoints}`;
|
|
99
|
+
}
|
|
100
|
+
header.set("host", opt.headers.host);
|
|
101
|
+
header.set("x-tos-date", opt.datetime);
|
|
102
|
+
header.set("x-tos-content-sha256", _SignersV4.hexEncodedBodyHash());
|
|
103
|
+
if (this.options.securityToken) {
|
|
104
|
+
header.set("x-tos-security-token", this.options.securityToken);
|
|
105
|
+
}
|
|
106
|
+
header.forEach((value, key) => {
|
|
107
|
+
if (key.startsWith("x-tos") && opt.headers) {
|
|
108
|
+
opt.headers[key] = value;
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
opt.path = _SignersV4.getEncodePath(opt.path);
|
|
112
|
+
const sign = this.signature(opt, 0, credentials);
|
|
113
|
+
header.set("authorization", sign);
|
|
114
|
+
return header;
|
|
115
|
+
}, "signatureHeader");
|
|
116
|
+
this.getSignatureQuery = /* @__PURE__ */ __name((opt, expiredAt) => {
|
|
117
|
+
const queryOpt = {
|
|
118
|
+
...opt,
|
|
119
|
+
query: typeof opt.query === "string" ? {} : opt.query
|
|
120
|
+
};
|
|
121
|
+
queryOpt.datetime = _SignersV4.getDateTime();
|
|
122
|
+
if (!queryOpt.headers) {
|
|
123
|
+
queryOpt.headers = {};
|
|
124
|
+
}
|
|
125
|
+
queryOpt.headers.host = `${queryOpt.host}`;
|
|
126
|
+
if (!isDefaultPort(queryOpt.port)) {
|
|
127
|
+
queryOpt.headers.host += `:${queryOpt.port}`;
|
|
128
|
+
}
|
|
129
|
+
queryOpt.path = _SignersV4.getEncodePath(queryOpt.path);
|
|
130
|
+
if (queryOpt.endpoints) {
|
|
131
|
+
queryOpt.headers.host = `${this.options.bucket}.${queryOpt.endpoints}`;
|
|
132
|
+
}
|
|
133
|
+
queryOpt.headers[SIG_QUERY.v4_date] = queryOpt.datetime;
|
|
134
|
+
const credString = this.credentialString(queryOpt.datetime);
|
|
135
|
+
const res = {
|
|
136
|
+
...queryOpt.query || {},
|
|
137
|
+
[SIG_QUERY.v4_algorithm]: this.options.algorithm,
|
|
138
|
+
[SIG_QUERY.v4_content_sha]: _SignersV4.hexEncodedBodyHash(),
|
|
139
|
+
[SIG_QUERY.v4_credential]: `${this.credentials.GetAccessKey()}/${credString}`,
|
|
140
|
+
[SIG_QUERY.v4_date]: queryOpt.datetime,
|
|
141
|
+
[SIG_QUERY.v4_expires]: `${expiredAt}`,
|
|
142
|
+
[SIG_QUERY.v4_signedHeaders]: _SignersV4.signedHeaders(queryOpt)
|
|
143
|
+
};
|
|
144
|
+
if (this.options.securityToken) {
|
|
145
|
+
res[SIG_QUERY.v4_security_token] = this.options.securityToken;
|
|
146
|
+
}
|
|
147
|
+
const queryString = (0, import_utils.getSortedQueryString)(res);
|
|
148
|
+
if (typeof opt.query === "string") {
|
|
149
|
+
opt.query = queryString;
|
|
150
|
+
} else {
|
|
151
|
+
opt.query = res;
|
|
152
|
+
}
|
|
153
|
+
res[SIG_QUERY.v4_signature] = this.authorization(queryOpt, this.credentials, expiredAt);
|
|
154
|
+
return res;
|
|
155
|
+
}, "getSignatureQuery");
|
|
156
|
+
this.getSignaturePolicyQuery = /* @__PURE__ */ __name((opt, expiredAt) => {
|
|
157
|
+
const policyOpt = {
|
|
158
|
+
...opt,
|
|
159
|
+
path: opt.path || "/",
|
|
160
|
+
method: opt.method || "POST",
|
|
161
|
+
datetime: _SignersV4.getDateTime()
|
|
162
|
+
};
|
|
163
|
+
const credString = this.credentialString(policyOpt.datetime);
|
|
164
|
+
const res = {
|
|
165
|
+
[SIG_QUERY.v4_algorithm]: this.options.algorithm,
|
|
166
|
+
[SIG_QUERY.v4_credential]: `${this.credentials.GetAccessKey()}/${credString}`,
|
|
167
|
+
[SIG_QUERY.v4_date]: policyOpt.datetime,
|
|
168
|
+
[SIG_QUERY.v4_expires]: `${expiredAt}`,
|
|
169
|
+
[SIG_QUERY.v4_policy]: (0, import_crypto.stringify)((0, import_crypto.parse)(JSON.stringify(opt.policy), "utf-8"), "base64")
|
|
170
|
+
};
|
|
171
|
+
if (this.options.securityToken) {
|
|
172
|
+
res[SIG_QUERY.v4_security_token] = this.options.securityToken;
|
|
173
|
+
}
|
|
174
|
+
opt.query = (0, import_utils.getSortedQueryString)(res);
|
|
175
|
+
res[SIG_QUERY.v4_signature] = this.authorization(policyOpt, this.credentials, expiredAt);
|
|
176
|
+
return res;
|
|
177
|
+
}, "getSignaturePolicyQuery");
|
|
178
|
+
// @ts-ignore
|
|
179
|
+
this.authorization = /* @__PURE__ */ __name((opt, credentials, expiredAt) => {
|
|
180
|
+
if (!opt.datetime) {
|
|
181
|
+
return "";
|
|
182
|
+
}
|
|
183
|
+
const signingKey = this.getSigningKey(credentials, opt.datetime.substr(0, 8));
|
|
184
|
+
return (0, import_crypto.hmacSha256)(signingKey, this.stringToSign(opt.datetime, opt), "hex");
|
|
185
|
+
}, "authorization");
|
|
186
|
+
this.credentialString = /* @__PURE__ */ __name((datetime) => {
|
|
187
|
+
return _SignersV4.createScope(
|
|
188
|
+
datetime.substr(0, 8),
|
|
189
|
+
this.options.region,
|
|
190
|
+
this.options.serviceName
|
|
191
|
+
);
|
|
192
|
+
}, "credentialString");
|
|
193
|
+
this.getSigningKey = /* @__PURE__ */ __name((credentials, date) => {
|
|
194
|
+
const kDate = (0, import_crypto.hmacSha256)(credentials.GetSecretKey(), date);
|
|
195
|
+
const kRegion = (0, import_crypto.hmacSha256)(kDate, this.options.region);
|
|
196
|
+
const kService = (0, import_crypto.hmacSha256)(kRegion, this.options.serviceName);
|
|
197
|
+
const signingKey = (0, import_crypto.hmacSha256)(kService, v4Identifier);
|
|
198
|
+
return signingKey;
|
|
199
|
+
}, "getSigningKey");
|
|
200
|
+
this.stringToSign = /* @__PURE__ */ __name((datetime, opt) => {
|
|
201
|
+
if (!this.options.algorithm) {
|
|
202
|
+
return "";
|
|
203
|
+
}
|
|
204
|
+
const parts = [];
|
|
205
|
+
parts.push(this.options.algorithm);
|
|
206
|
+
parts.push(datetime);
|
|
207
|
+
parts.push(this.credentialString(datetime));
|
|
208
|
+
const canonicalString = "policy" in opt ? _SignersV4.canonicalStringPolicy(opt) : _SignersV4.canonicalString(opt);
|
|
209
|
+
parts.push(_SignersV4.hexEncodedHash(canonicalString));
|
|
210
|
+
return parts.join("\n");
|
|
211
|
+
}, "stringToSign");
|
|
212
|
+
this.options = opt;
|
|
213
|
+
this.credentials = credentials;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* ! * ' () aren't transformed by encodeUrl, so they need be handled
|
|
217
|
+
*/
|
|
218
|
+
static getEncodePath(path, encodeAll = true) {
|
|
219
|
+
if (!path) {
|
|
220
|
+
return "";
|
|
221
|
+
}
|
|
222
|
+
let tmpPath = path;
|
|
223
|
+
if (encodeAll) {
|
|
224
|
+
tmpPath = path.replace(/%2F/g, "/");
|
|
225
|
+
}
|
|
226
|
+
tmpPath = tmpPath.replace(/\(/g, "%28");
|
|
227
|
+
tmpPath = tmpPath.replace(/\)/g, "%29");
|
|
228
|
+
tmpPath = tmpPath.replace(/!/g, "%21");
|
|
229
|
+
tmpPath = tmpPath.replace(/\*/g, "%2A");
|
|
230
|
+
tmpPath = tmpPath.replace(/'/g, "%27");
|
|
231
|
+
return tmpPath;
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
__name(_SignersV4, "SignersV4");
|
|
235
|
+
_SignersV4.hexEncodedBodyHash = /* @__PURE__ */ __name(() => {
|
|
236
|
+
return "UNSIGNED-PAYLOAD";
|
|
237
|
+
}, "hexEncodedBodyHash");
|
|
238
|
+
_SignersV4.getDateTime = /* @__PURE__ */ __name(() => {
|
|
239
|
+
const date = new Date((/* @__PURE__ */ new Date()).toUTCString());
|
|
240
|
+
return `${date.toISOString().replace(/\..+/, "").replace(/-/g, "").replace(/:/g, "")}Z`;
|
|
241
|
+
}, "getDateTime");
|
|
242
|
+
_SignersV4.createScope = /* @__PURE__ */ __name((date, region, serviceName) => {
|
|
243
|
+
return [date.substr(0, 8), region, serviceName, v4Identifier].join("/");
|
|
244
|
+
}, "createScope");
|
|
245
|
+
_SignersV4.hexEncodedHash = /* @__PURE__ */ __name((string) => {
|
|
246
|
+
return (0, import_crypto.hashSha256)(string, "hex");
|
|
247
|
+
}, "hexEncodedHash");
|
|
248
|
+
_SignersV4.canonicalString = /* @__PURE__ */ __name((opt) => {
|
|
249
|
+
const parts = [];
|
|
250
|
+
parts.push(opt.method);
|
|
251
|
+
parts.push(opt.path);
|
|
252
|
+
parts.push(_SignersV4.getEncodePath(opt.query, false));
|
|
253
|
+
parts.push(`${_SignersV4.canonicalHeaders(opt)}
|
|
254
|
+
`);
|
|
255
|
+
parts.push(_SignersV4.signedHeaders(opt));
|
|
256
|
+
parts.push(_SignersV4.hexEncodedBodyHash());
|
|
257
|
+
return parts.join("\n");
|
|
258
|
+
}, "canonicalString");
|
|
259
|
+
_SignersV4.canonicalStringPolicy = /* @__PURE__ */ __name((opt) => {
|
|
260
|
+
const parts = [];
|
|
261
|
+
parts.push(_SignersV4.getEncodePath(opt.query, false));
|
|
262
|
+
parts.push(_SignersV4.hexEncodedBodyHash());
|
|
263
|
+
return parts.join("\n");
|
|
264
|
+
}, "canonicalStringPolicy");
|
|
265
|
+
_SignersV4.canonicalHeaders = /* @__PURE__ */ __name((opt) => {
|
|
266
|
+
const parts = [];
|
|
267
|
+
const needSignHeaders = getNeedSignedHeaders(opt.headers);
|
|
268
|
+
for (const key of needSignHeaders) {
|
|
269
|
+
const value = opt.headers?.[key];
|
|
270
|
+
parts.push(
|
|
271
|
+
`${key.toLowerCase()}:${_SignersV4.canonicalHeaderValues(value?.toString() || "")}`
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
return parts.join("\n");
|
|
275
|
+
}, "canonicalHeaders");
|
|
276
|
+
_SignersV4.canonicalHeaderValues = /* @__PURE__ */ __name((values) => {
|
|
277
|
+
return values.replace(/\s+/g, " ").replace(/^\s+|\s+$/g, "");
|
|
278
|
+
}, "canonicalHeaderValues");
|
|
279
|
+
_SignersV4.signedHeaders = /* @__PURE__ */ __name((opt) => {
|
|
280
|
+
const keys = [];
|
|
281
|
+
const needSignHeaders = getNeedSignedHeaders(opt.headers);
|
|
282
|
+
for (const key of needSignHeaders) {
|
|
283
|
+
keys.push(key.toLowerCase());
|
|
284
|
+
}
|
|
285
|
+
return keys.sort().join(";");
|
|
286
|
+
}, "signedHeaders");
|
|
287
|
+
let SignersV4 = _SignersV4;
|
|
288
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
289
|
+
0 && (module.exports = {
|
|
290
|
+
SIG_QUERY,
|
|
291
|
+
SignersV4,
|
|
292
|
+
isDefaultPort
|
|
293
|
+
});
|
|
294
|
+
//# sourceMappingURL=signatureV4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/modules/TOS/utils/signatureV4.ts"],"sourcesContent":["import { hashSha256, hmacSha256, parse, stringify } from \"./universal/crypto.browser\"\nimport { getSortedQueryString } from \"./utils\"\n\nexport interface ISign {\n\tsignature(opt: ISigOptions, expiredAt: number, credentials?: ISigCredentials): string\n\n\tsignatureHeader(\n\t\topt: ISigOptions,\n\t\texpiredAt?: number,\n\t\tcredentials?: ISigCredentials,\n\t): Map<string, string>\n\n\tgetSignatureQuery(opt: ISigOptions, expiredAt: number): { [key: string]: any }\n}\n\nexport interface ISigCredentials {\n\tGetSecretKey(): string\n\n\tGetAccessKey(): string\n}\n\nexport interface ISigPolicyQuery {\n\tpolicy: {\n\t\tconditions: (string[] | { bucket: string } | { key: string })[]\n\t}\n\tdatetime?: string\n\tquery?: string\n\tpath?: string\n\tmethod?: string\n\theaders?: { [key: string]: string | undefined }\n}\n\nexport interface ISigOptions {\n\tsigName?: string\n\tendpoints?: string\n\tbucket?: string\n\theaders?: { [key: string]: string | undefined }\n\tregion?: string\n\tserviceName?: string\n\talgorithm?: string\n\tpath: string\n\tmethod: string\n\tquery?: string | Record<string, any>\n\tdatetime?: string\n\thost?: string\n\tport?: number\n}\n\nexport interface ISigQueryOptions extends Omit<ISigOptions, \"query\"> {\n\tquery?: Record<string, any>\n}\n\nexport const SIG_QUERY = {\n\talgorithm: \"tos-algorithm\",\n\texpiration: \"tos-expiration\",\n\tsigname: \"tos-signame\",\n\tsignature: \"tos-signature\",\n\n\tv4_algorithm: \"X-Tos-Algorithm\",\n\tv4_credential: \"X-Tos-Credential\",\n\tv4_date: \"X-Tos-Date\",\n\tv4_expires: \"X-Tos-Expires\",\n\tv4_signedHeaders: \"X-Tos-SignedHeaders\",\n\tv4_security_token: \"X-Tos-Security-Token\",\n\tv4_signature: \"X-Tos-Signature\",\n\tv4_content_sha: \"X-Tos-Content-Sha256\",\n\tv4_policy: \"X-Tos-Policy\",\n}\n\nexport function isDefaultPort(port?: number) {\n\tif (port && port !== 80 && port !== 443) {\n\t\treturn false\n\t}\n\treturn true\n}\n\n/**\n * @api private\n */\nconst v4Identifier = \"request\"\n\ninterface ISignV4Opt {\n\talgorithm?: string\n\tregion?: string\n\tserviceName?: string\n\tsecurityToken?: string\n\tbucket: string\n}\n\nfunction getNeedSignedHeaders(headers: Record<string, unknown> | undefined) {\n\tconst needSignHeaders: string[] = []\n\tif (headers) {\n\t\tObject.keys(headers).forEach((key: string) => {\n\t\t\tif (key === \"host\" || key.startsWith(\"x-tos-\")) {\n\t\t\t\tif (headers[key] != null) {\n\t\t\t\t\tneedSignHeaders.push(key)\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n\treturn needSignHeaders.sort()\n}\n\n/**\n * @api private\n */\nexport class SignersV4 implements ISign {\n\tprivate options: ISignV4Opt\n\n\tprivate credentials: ISigCredentials\n\n\tconstructor(opt: ISignV4Opt, credentials: ISigCredentials) {\n\t\tthis.options = opt\n\t\tthis.credentials = credentials\n\t}\n\n\t/**\n\t * normal v4 signature\n\t * */\n\t// @ts-ignore\n\tpublic signature = (opt: ISigOptions, expiredAt: number, credentials?: ISigCredentials) => {\n\t\tif (!credentials) {\n\t\t\tcredentials = this.credentials\n\t\t}\n\t\tconst parts: string[] = []\n\t\tconst datatime = opt.datetime as string\n\t\tconst credString = this.credentialString(datatime)\n\t\tparts.push(\n\t\t\t`${this.options.algorithm} Credential=${credentials.GetAccessKey()}/${credString}`,\n\t\t)\n\n\t\tparts.push(`SignedHeaders=${SignersV4.signedHeaders(opt)}`)\n\t\tparts.push(`Signature=${this.authorization(opt, credentials, 0)}`)\n\t\treturn parts.join(\", \")\n\t}\n\n\tpublic signatureHeader = (\n\t\topt: ISigOptions,\n\t\t// @ts-ignore\n\t\texpiredAt?: number,\n\t\tcredentials?: ISigCredentials,\n\t): Map<string, string> => {\n\t\t// const datetime = (new Date(new Date().toUTCString())).Format(\"yyyyMMddTHHmmssZ\")\n\t\topt.datetime = SignersV4.getDateTime()\n\t\tconst header = new Map<string, string>()\n\t\t/* istanbul ignore if */\n\t\tif (!opt.headers) {\n\t\t\tconst h: { [key: string]: string } = {}\n\t\t\topt.headers = h\n\t\t}\n\n\t\topt.headers.host = `${opt.host}`\n\t\t/* istanbul ignore if */\n\t\tif (!isDefaultPort(opt.port)) {\n\t\t\topt.headers.host += `:${opt.port}`\n\t\t}\n\t\t/* istanbul ignore if */\n\t\tif (opt.endpoints) {\n\t\t\topt.headers.host = `${this.options.bucket}.${opt.endpoints}`\n\t\t}\n\n\t\theader.set(\"host\", opt.headers.host)\n\t\theader.set(\"x-tos-date\", opt.datetime)\n\t\theader.set(\"x-tos-content-sha256\", SignersV4.hexEncodedBodyHash())\n\t\tif (this.options.securityToken) {\n\t\t\theader.set(\"x-tos-security-token\", this.options.securityToken)\n\t\t}\n\t\t// x-tos- must to be signatured\n\t\theader.forEach((value, key) => {\n\t\t\tif (key.startsWith(\"x-tos\") && opt.headers) {\n\t\t\t\topt.headers[key] = value\n\t\t\t}\n\t\t})\n\t\topt.path = SignersV4.getEncodePath(opt.path)\n\t\tconst sign = this.signature(opt, 0, credentials)\n\t\theader.set(\"authorization\", sign)\n\n\t\treturn header\n\t}\n\n\tpublic getSignatureQuery = (opt: ISigOptions, expiredAt: number): { [key: string]: any } => {\n\t\tconst queryOpt: ISigQueryOptions = {\n\t\t\t...opt,\n\t\t\tquery: typeof opt.query === \"string\" ? {} : (opt.query as Record<string, any>),\n\t\t}\n\t\tqueryOpt.datetime = SignersV4.getDateTime()\n\t\tif (!queryOpt.headers) {\n\t\t\tqueryOpt.headers = {}\n\t\t}\n\n\t\tqueryOpt.headers.host = `${queryOpt.host}`\n\t\tif (!isDefaultPort(queryOpt.port)) {\n\t\t\tqueryOpt.headers.host += `:${queryOpt.port}`\n\t\t}\n\n\t\tqueryOpt.path = SignersV4.getEncodePath(queryOpt.path)\n\t\tif (queryOpt.endpoints) {\n\t\t\tqueryOpt.headers.host = `${this.options.bucket}.${queryOpt.endpoints}`\n\t\t\t// opt.path = `${opt.path}`;\n\t\t}\n\n\t\tqueryOpt.headers[SIG_QUERY.v4_date] = queryOpt.datetime\n\t\tconst credString = this.credentialString(queryOpt.datetime as string)\n\t\tconst res = {\n\t\t\t...(queryOpt.query || {}),\n\t\t\t[SIG_QUERY.v4_algorithm]: this.options.algorithm,\n\t\t\t[SIG_QUERY.v4_content_sha]: SignersV4.hexEncodedBodyHash(),\n\t\t\t[SIG_QUERY.v4_credential]: `${this.credentials.GetAccessKey()}/${credString}`,\n\t\t\t[SIG_QUERY.v4_date]: queryOpt.datetime,\n\t\t\t[SIG_QUERY.v4_expires]: `${expiredAt}`,\n\t\t\t[SIG_QUERY.v4_signedHeaders]: SignersV4.signedHeaders(queryOpt),\n\t\t}\n\t\tif (this.options.securityToken) {\n\t\t\tres[SIG_QUERY.v4_security_token] = this.options.securityToken\n\t\t}\n\n\t\tconst queryString = getSortedQueryString(res)\n\t\t// Keep the original opt query type\n\t\tif (typeof opt.query === \"string\") {\n\t\t\topt.query = queryString\n\t\t} else {\n\t\t\topt.query = res\n\t\t}\n\n\t\tres[SIG_QUERY.v4_signature] = this.authorization(queryOpt, this.credentials, expiredAt)\n\t\treturn res\n\t}\n\n\tpublic getSignaturePolicyQuery = (\n\t\topt: ISigPolicyQuery,\n\t\texpiredAt: number,\n\t): { [key: string]: any } => {\n\t\t// Add required ISigOptions properties\n\t\tconst policyOpt: ISigOptions = {\n\t\t\t...(opt as any),\n\t\t\tpath: opt.path || \"/\",\n\t\t\tmethod: opt.method || \"POST\",\n\t\t\tdatetime: SignersV4.getDateTime(),\n\t\t}\n\n\t\tconst credString = this.credentialString(policyOpt.datetime as string)\n\t\tconst res = {\n\t\t\t[SIG_QUERY.v4_algorithm]: this.options.algorithm,\n\t\t\t[SIG_QUERY.v4_credential]: `${this.credentials.GetAccessKey()}/${credString}`,\n\t\t\t[SIG_QUERY.v4_date]: policyOpt.datetime,\n\t\t\t[SIG_QUERY.v4_expires]: `${expiredAt}`,\n\t\t\t[SIG_QUERY.v4_policy]: stringify(parse(JSON.stringify(opt.policy), \"utf-8\"), \"base64\"),\n\t\t}\n\t\tif (this.options.securityToken) {\n\t\t\tres[SIG_QUERY.v4_security_token] = this.options.securityToken\n\t\t}\n\n\t\t// Ensure opt has a query property\n\t\topt.query = getSortedQueryString(res)\n\n\t\tres[SIG_QUERY.v4_signature] = this.authorization(policyOpt, this.credentials, expiredAt)\n\t\treturn res\n\t}\n\n\tstatic hexEncodedBodyHash = () => {\n\t\treturn \"UNSIGNED-PAYLOAD\"\n\t}\n\n\t// @ts-ignore\n\tprivate authorization = (opt: ISigOptions, credentials: ISigCredentials, expiredAt: number) => {\n\t\t/* istanbul ignore if */\n\t\tif (!opt.datetime) {\n\t\t\treturn \"\"\n\t\t}\n\n\t\tconst signingKey = this.getSigningKey(credentials, opt.datetime.substr(0, 8))\n\t\t// console.log(\n\t\t// 'signingKey:',\n\t\t// signingKey,\n\t\t// 'sign:',\n\t\t// this.stringToSign(opt.datetime, opt)\n\t\t// );\n\t\treturn hmacSha256(signingKey, this.stringToSign(opt.datetime, opt), \"hex\")\n\t}\n\n\tstatic getDateTime = () => {\n\t\tconst date = new Date(new Date().toUTCString())\n\t\treturn `${date.toISOString().replace(/\\..+/, \"\").replace(/-/g, \"\").replace(/:/g, \"\")}Z`\n\t}\n\n\tprivate credentialString = (datetime: string) => {\n\t\treturn SignersV4.createScope(\n\t\t\tdatetime.substr(0, 8),\n\t\t\tthis.options.region,\n\t\t\tthis.options.serviceName,\n\t\t)\n\t}\n\n\tstatic createScope = (date: string, region?: string, serviceName?: string) => {\n\t\treturn [date.substr(0, 8), region, serviceName, v4Identifier].join(\"/\")\n\t}\n\n\tprivate getSigningKey = (credentials: ISigCredentials, date: string) => {\n\t\tconst kDate = hmacSha256(credentials.GetSecretKey(), date)\n\t\tconst kRegion = hmacSha256(kDate, this.options.region as string)\n\t\tconst kService = hmacSha256(kRegion, this.options.serviceName as string)\n\t\tconst signingKey = hmacSha256(kService, v4Identifier)\n\n\t\treturn signingKey\n\t}\n\n\tprivate stringToSign = (datetime: string, opt: ISigOptions) => {\n\t\t/* istanbul ignore if */\n\t\tif (!this.options.algorithm) {\n\t\t\treturn \"\"\n\t\t}\n\n\t\tconst parts: string[] = []\n\t\tparts.push(this.options.algorithm)\n\t\tparts.push(datetime)\n\t\tparts.push(this.credentialString(datetime))\n\t\tconst canonicalString =\n\t\t\t\"policy\" in opt ? SignersV4.canonicalStringPolicy(opt) : SignersV4.canonicalString(opt)\n\t\tparts.push(SignersV4.hexEncodedHash(canonicalString))\n\t\treturn parts.join(\"\\n\")\n\t}\n\n\tstatic hexEncodedHash = (string: string) => {\n\t\treturn hashSha256(string, \"hex\")\n\t}\n\n\tstatic canonicalString = (opt: ISigOptions) => {\n\t\tconst parts: any[] = []\n\t\tparts.push(opt.method)\n\t\tparts.push(opt.path)\n\t\tparts.push(SignersV4.getEncodePath(opt.query as string, false))\n\t\tparts.push(`${SignersV4.canonicalHeaders(opt)}\\n`)\n\t\tparts.push(SignersV4.signedHeaders(opt))\n\t\tparts.push(SignersV4.hexEncodedBodyHash())\n\t\treturn parts.join(\"\\n\")\n\t}\n\n\tstatic canonicalStringPolicy = (opt: ISigOptions) => {\n\t\tconst parts: any[] = []\n\t\tparts.push(SignersV4.getEncodePath(opt.query as string, false))\n\t\tparts.push(SignersV4.hexEncodedBodyHash())\n\t\treturn parts.join(\"\\n\")\n\t}\n\n\tstatic canonicalHeaders = (opt: ISigOptions) => {\n\t\tconst parts: string[] = []\n\t\tconst needSignHeaders = getNeedSignedHeaders(opt.headers)\n\n\t\t// eslint-disable-next-line no-restricted-syntax\n\t\tfor (const key of needSignHeaders) {\n\t\t\tconst value = opt.headers?.[key]\n\t\t\tparts.push(\n\t\t\t\t`${key.toLowerCase()}:${SignersV4.canonicalHeaderValues(value?.toString() || \"\")}`,\n\t\t\t)\n\t\t}\n\n\t\treturn parts.join(\"\\n\")\n\t}\n\n\tstatic canonicalHeaderValues = (values: string) => {\n\t\treturn values.replace(/\\s+/g, \" \").replace(/^\\s+|\\s+$/g, \"\")\n\t}\n\n\tstatic signedHeaders = (opt: ISigOptions) => {\n\t\tconst keys: string[] = []\n\t\tconst needSignHeaders = getNeedSignedHeaders(opt.headers)\n\n\t\t// eslint-disable-next-line no-restricted-syntax\n\t\tfor (const key of needSignHeaders) {\n\t\t\tkeys.push(key.toLowerCase())\n\t\t}\n\n\t\treturn keys.sort().join(\";\")\n\t}\n\n\t/**\n\t * ! * ' () aren't transformed by encodeUrl, so they need be handled\n\t */\n\tstatic getEncodePath(path: string, encodeAll: boolean = true): string {\n\t\tif (!path) {\n\t\t\treturn \"\"\n\t\t}\n\n\t\tlet tmpPath = path\n\t\tif (encodeAll) {\n\t\t\ttmpPath = path.replace(/%2F/g, \"/\")\n\t\t}\n\t\ttmpPath = tmpPath.replace(/\\(/g, \"%28\")\n\t\ttmpPath = tmpPath.replace(/\\)/g, \"%29\")\n\t\ttmpPath = tmpPath.replace(/!/g, \"%21\")\n\t\ttmpPath = tmpPath.replace(/\\*/g, \"%2A\")\n\t\ttmpPath = tmpPath.replace(/'/g, \"%27\")\n\t\treturn tmpPath\n\t}\n}\n\n\n\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAC,oBAAyD;AAC1D,mBAAqC;AAmD9B,MAAM,YAAY;AAAA,EACxB,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,WAAW;AAAA,EAEX,cAAc;AAAA,EACd,eAAe;AAAA,EACf,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,kBAAkB;AAAA,EAClB,mBAAmB;AAAA,EACnB,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB,WAAW;AACZ;AAEO,SAAS,cAAc,MAAe;AAC5C,MAAI,QAAQ,SAAS,MAAM,SAAS,KAAK;AACxC,WAAO;AAAA,EACR;AACA,SAAO;AACR;AALgB;AAUhB,MAAM,eAAe;AAUrB,SAAS,qBAAqB,SAA8C;AAC3E,QAAM,kBAA4B,CAAC;AACnC,MAAI,SAAS;AACZ,WAAO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3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var signatureV4Credentials_exports = {};
|
|
21
|
+
__export(signatureV4Credentials_exports, {
|
|
22
|
+
SignatureV4Credentials: () => SignatureV4Credentials
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(signatureV4Credentials_exports);
|
|
25
|
+
const _SignatureV4Credentials = class _SignatureV4Credentials {
|
|
26
|
+
constructor(securityToken, secretAccessKey, accessKeyId) {
|
|
27
|
+
this.accessKeyId = accessKeyId;
|
|
28
|
+
this.secretAccessKey = secretAccessKey;
|
|
29
|
+
this.securityToken = securityToken;
|
|
30
|
+
}
|
|
31
|
+
GetAccessKey() {
|
|
32
|
+
return this.accessKeyId;
|
|
33
|
+
}
|
|
34
|
+
GetSecretKey() {
|
|
35
|
+
return this.secretAccessKey;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
__name(_SignatureV4Credentials, "SignatureV4Credentials");
|
|
39
|
+
let SignatureV4Credentials = _SignatureV4Credentials;
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
SignatureV4Credentials
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=signatureV4Credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/modules/TOS/utils/signatureV4Credentials.ts"],"sourcesContent":["import type { ISigCredentials } from \"./signatureV4\"\n\nexport class SignatureV4Credentials implements ISigCredentials {\n\tpublic securityToken: string\n\n\tpublic secretAccessKey: string\n\n\tpublic accessKeyId: string\n\n\tconstructor(securityToken?: string, secretAccessKey?: string, accessKeyId?: string) {\n\t\tthis.accessKeyId = accessKeyId as string\n\t\tthis.secretAccessKey = secretAccessKey as string\n\t\tthis.securityToken = securityToken as string\n\t}\n\n\tpublic GetAccessKey(): string {\n\t\treturn this.accessKeyId\n\t}\n\n\tpublic GetSecretKey(): string {\n\t\treturn this.secretAccessKey\n\t}\n}\n\n\n\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,MAAM,0BAAN,MAAM,wBAAkD;AAAA,EAO9D,YAAY,eAAwB,iBAA0B,aAAsB;AACnF,SAAK,cAAc;AACnB,SAAK,kBAAkB;AACvB,SAAK,gBAAgB;AAAA,EACtB;AAAA,EAEO,eAAuB;AAC7B,WAAO,KAAK;AAAA,EACb;AAAA,EAEO,eAAuB;AAC7B,WAAO,KAAK;AAAA,EACb;AACD;AApB+D;AAAxD,IAAM,yBAAN;","names":[]}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var crypto_browser_exports = {};
|
|
31
|
+
__export(crypto_browser_exports, {
|
|
32
|
+
hashMd5: () => hashMd5,
|
|
33
|
+
hashSha256: () => hashSha256,
|
|
34
|
+
hmacSha256: () => hmacSha256,
|
|
35
|
+
parse: () => parse,
|
|
36
|
+
stringify: () => stringify
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(crypto_browser_exports);
|
|
39
|
+
var import_enc_base64 = __toESM(require("crypto-js/enc-base64"), 1);
|
|
40
|
+
var import_enc_hex = __toESM(require("crypto-js/enc-hex"), 1);
|
|
41
|
+
var import_enc_utf8 = __toESM(require("crypto-js/enc-utf8"), 1);
|
|
42
|
+
var import_hmac_sha256 = __toESM(require("crypto-js/hmac-sha256"), 1);
|
|
43
|
+
var import_md5 = __toESM(require("crypto-js/md5"), 1);
|
|
44
|
+
var import_sha256 = __toESM(require("crypto-js/sha256"), 1);
|
|
45
|
+
var import_TosClientError = __toESM(require("../TosClientError"), 1);
|
|
46
|
+
var import_utils = require("../utils");
|
|
47
|
+
function getEnc(coding) {
|
|
48
|
+
switch (coding) {
|
|
49
|
+
case "utf-8":
|
|
50
|
+
return import_enc_utf8.default;
|
|
51
|
+
case "base64":
|
|
52
|
+
return import_enc_base64.default;
|
|
53
|
+
case "hex":
|
|
54
|
+
return import_enc_hex.default;
|
|
55
|
+
default:
|
|
56
|
+
throw new import_TosClientError.default("The coding is not supported");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
__name(getEnc, "getEnc");
|
|
60
|
+
function decode(v, decoding) {
|
|
61
|
+
if (!decoding) {
|
|
62
|
+
return v;
|
|
63
|
+
}
|
|
64
|
+
return v.toString(getEnc(decoding));
|
|
65
|
+
}
|
|
66
|
+
__name(decode, "decode");
|
|
67
|
+
const hmacSha256 = /* @__PURE__ */ __name(function hmacSha2562(key, message, decoding) {
|
|
68
|
+
return decode((0, import_hmac_sha256.default)(message, key), decoding);
|
|
69
|
+
}, "hmacSha256");
|
|
70
|
+
const hashSha256 = /* @__PURE__ */ __name(function hashSha2562(message, decoding) {
|
|
71
|
+
return decode((0, import_sha256.default)(message), decoding);
|
|
72
|
+
}, "hashSha256");
|
|
73
|
+
const hashMd5 = /* @__PURE__ */ __name(function hashMd52(message, decoding) {
|
|
74
|
+
if ((0, import_utils.isBuffer)(message)) {
|
|
75
|
+
throw new import_TosClientError.default("not support buffer in browser environment");
|
|
76
|
+
}
|
|
77
|
+
return decode((0, import_md5.default)(message), decoding);
|
|
78
|
+
}, "hashMd5");
|
|
79
|
+
const parse = /* @__PURE__ */ __name(function parse2(str, encoding) {
|
|
80
|
+
return getEnc(encoding).parse(str);
|
|
81
|
+
}, "parse");
|
|
82
|
+
const stringify = /* @__PURE__ */ __name(function stringify2(str, decoding) {
|
|
83
|
+
return getEnc(decoding).stringify(str);
|
|
84
|
+
}, "stringify");
|
|
85
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
86
|
+
0 && (module.exports = {
|
|
87
|
+
hashMd5,
|
|
88
|
+
hashSha256,
|
|
89
|
+
hmacSha256,
|
|
90
|
+
parse,
|
|
91
|
+
stringify
|
|
92
|
+
});
|
|
93
|
+
//# sourceMappingURL=crypto.browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/modules/TOS/utils/universal/crypto.browser.ts"],"sourcesContent":["import cryptoEncBase64 from \"crypto-js/enc-base64\"\nimport cryptoEncHex from \"crypto-js/enc-hex\"\nimport cryptoEncUtf8 from \"crypto-js/enc-utf8\"\nimport cryptoHmacSha256 from \"crypto-js/hmac-sha256\"\nimport cryptoHashMd5 from \"crypto-js/md5\"\nimport cryptoHashSha256 from \"crypto-js/sha256\"\nimport TosClientError from \"../TosClientError\"\nimport { isBuffer } from \"../utils\"\n\nfunction getEnc(coding: \"utf-8\" | \"base64\" | \"hex\") {\n\tswitch (coding) {\n\t\tcase \"utf-8\":\n\t\t\treturn cryptoEncUtf8\n\t\tcase \"base64\":\n\t\t\treturn cryptoEncBase64\n\t\tcase \"hex\":\n\t\t\treturn cryptoEncHex\n\t\tdefault:\n\t\t\tthrow new TosClientError(\"The coding is not supported\")\n\t}\n}\n\nfunction decode(v: any, decoding?: \"base64\" | \"hex\"): string {\n\tif (!decoding) {\n\t\treturn v\n\t}\n\n\treturn v.toString(getEnc(decoding))\n}\n\nexport const hmacSha256 = function hmacSha256(\n\tkey: string,\n\tmessage: string,\n\tdecoding?: \"base64\" | \"hex\",\n) {\n\treturn decode(cryptoHmacSha256(message, key), decoding)\n}\n\nexport const hashSha256 = function hashSha256(message: string, decoding?: \"base64\" | \"hex\") {\n\treturn decode(cryptoHashSha256(message), decoding)\n}\n\nexport const hashMd5 = function hashMd5(message: string | Buffer, decoding?: \"base64\" | \"hex\") {\n\tif (isBuffer(message)) {\n\t\tthrow new TosClientError(\"not support buffer in browser environment\")\n\t}\n\n\treturn decode(cryptoHashMd5(message), decoding)\n}\n\nexport const parse = function parse(str: string, encoding: \"utf-8\" | \"base64\" | \"hex\") {\n\treturn getEnc(encoding).parse(str)\n}\n\nexport const stringify = function stringify(\n\tstr: CryptoJS.lib.WordArray,\n\tdecoding: \"utf-8\" | \"base64\" | \"hex\",\n) {\n\treturn getEnc(decoding).stringify(str)\n}\n\n\n\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAC,wBAA4B;AAC7B,qBAAyB;AACzB,sBAA0B;AAC1B,yBAA6B;AAC7B,iBAA0B;AAC1B,oBAA6B;AAC7B,4BAA2B;AAC3B,mBAAyB;AAEzB,SAAS,OAAO,QAAoC;AACnD,UAAQ,QAAQ;AAAA,IACf,KAAK;AACJ,aAAO,gBAAAA;AAAA,IACR,KAAK;AACJ,aAAO,kBAAAC;AAAA,IACR,KAAK;AACJ,aAAO,eAAAC;AAAA,IACR;AACC,YAAM,IAAI,sBAAAC,QAAe,6BAA6B;AAAA,EACxD;AACD;AAXS;AAaT,SAAS,OAAO,GAAQ,UAAqC;AAC5D,MAAI,CAAC,UAAU;AACd,WAAO;AAAA,EACR;AAEA,SAAO,EAAE,SAAS,OAAO,QAAQ,CAAC;AACnC;AANS;AAQF,MAAM,aAAa,gCAASC,YAClC,KACA,SACA,UACC;AACD,SAAO,WAAO,mBAAAC,SAAiB,SAAS,GAAG,GAAG,QAAQ;AACvD,GAN0B;AAQnB,MAAM,aAAa,gCAASC,YAAW,SAAiB,UAA6B;AAC3F,SAAO,WAAO,cAAAC,SAAiB,OAAO,GAAG,QAAQ;AAClD,GAF0B;AAInB,MAAM,UAAU,gCAASC,SAAQ,SAA0B,UAA6B;AAC9F,UAAI,uBAAS,OAAO,GAAG;AACtB,UAAM,IAAI,sBAAAL,QAAe,2CAA2C;AAAA,EACrE;AAEA,SAAO,WAAO,WAAAM,SAAc,OAAO,GAAG,QAAQ;AAC/C,GANuB;AAQhB,MAAM,QAAQ,gCAASC,OAAM,KAAa,UAAsC;AACtF,SAAO,OAAO,QAAQ,EAAE,MAAM,GAAG;AAClC,GAFqB;AAId,MAAM,YAAY,gCAASC,WACjC,KACA,UACC;AACD,SAAO,OAAO,QAAQ,EAAE,UAAU,GAAG;AACtC,GALyB;","names":["cryptoEncUtf8","cryptoEncBase64","cryptoEncHex","TosClientError","hmacSha256","cryptoHmacSha256","hashSha256","cryptoHashSha256","hashMd5","cryptoHashMd5","parse","stringify"]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var utils_exports = {};
|
|
21
|
+
__export(utils_exports, {
|
|
22
|
+
getSortedQueryString: () => getSortedQueryString,
|
|
23
|
+
isBuffer: () => isBuffer
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(utils_exports);
|
|
26
|
+
const getSortedQueryString = /* @__PURE__ */ __name((query) => {
|
|
27
|
+
const searchParts = [];
|
|
28
|
+
Object.keys(query).sort().forEach((key) => {
|
|
29
|
+
searchParts.push(`${encodeURIComponent(key)}=${encodeURIComponent(query[key])}`);
|
|
30
|
+
});
|
|
31
|
+
return searchParts.join("&");
|
|
32
|
+
}, "getSortedQueryString");
|
|
33
|
+
function isBuffer(obj) {
|
|
34
|
+
return typeof Buffer !== "undefined" && obj instanceof Buffer;
|
|
35
|
+
}
|
|
36
|
+
__name(isBuffer, "isBuffer");
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 && (module.exports = {
|
|
39
|
+
getSortedQueryString,
|
|
40
|
+
isBuffer
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/modules/TOS/utils/utils.ts"],"sourcesContent":["export const getSortedQueryString = (query: Record<string, any>) => {\n\tconst searchParts: string[] = []\n\tObject.keys(query)\n\t\t.sort()\n\t\t.forEach((key) => {\n\t\t\tsearchParts.push(`${encodeURIComponent(key)}=${encodeURIComponent(query[key])}`)\n\t\t})\n\treturn searchParts.join(\"&\")\n}\n\nexport function isBuffer(obj: unknown): obj is Buffer {\n\treturn typeof Buffer !== \"undefined\" && obj instanceof Buffer\n}\n\n\n\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAQ,MAAM,uBAAuB,wBAAC,UAA+B;AACpE,QAAM,cAAwB,CAAC;AAC/B,SAAO,KAAK,KAAK,EACf,KAAK,EACL,QAAQ,CAAC,QAAQ;AACjB,gBAAY,KAAK,GAAG,mBAAmB,GAAG,CAAC,IAAI,mBAAmB,MAAM,GAAG,CAAC,CAAC,EAAE;AAAA,EAChF,CAAC;AACF,SAAO,YAAY,KAAK,GAAG;AAC5B,GARqC;AAU9B,SAAS,SAAS,KAA6B;AACrD,SAAO,OAAO,WAAW,eAAe,eAAe;AACxD;AAFgB;","names":[]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var modules_exports = {};
|
|
30
|
+
__export(modules_exports, {
|
|
31
|
+
default: () => modules_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(modules_exports);
|
|
34
|
+
var import_types = require("../types");
|
|
35
|
+
var import_OSS = __toESM(require("./OSS"), 1);
|
|
36
|
+
var import_OBS = __toESM(require("./OBS"), 1);
|
|
37
|
+
var import_Kodo = __toESM(require("./Kodo"), 1);
|
|
38
|
+
var import_TOS = __toESM(require("./TOS"), 1);
|
|
39
|
+
var import_Local = __toESM(require("./Local"), 1);
|
|
40
|
+
var import_MinIO = __toESM(require("./MinIO"), 1);
|
|
41
|
+
const PlatformModules = {
|
|
42
|
+
[import_types.PlatformType.OSS]: import_OSS.default,
|
|
43
|
+
[import_types.PlatformType.Kodo]: import_Kodo.default,
|
|
44
|
+
[import_types.PlatformType.TOS]: import_TOS.default,
|
|
45
|
+
[import_types.PlatformType.OBS]: import_OBS.default,
|
|
46
|
+
[import_types.PlatformType.Local]: import_Local.default,
|
|
47
|
+
[import_types.PlatformType.Minio]: import_MinIO.default
|
|
48
|
+
};
|
|
49
|
+
var modules_default = PlatformModules;
|
|
50
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/modules/index.ts"],"sourcesContent":["import type {\n\tPlatformMultipartUploadOption,\n\tPlatformRequest,\n\tPlatformSimpleUploadOption,\n} from \"../types\"\nimport { PlatformType } from \"../types\"\nimport type { OSS } from \"../types/OSS\"\nimport type { OBS } from \"../types/OBS\"\nimport type { Kodo } from \"../types/Kodo\"\nimport type { TOS } from \"../types/TOS\"\nimport type { Local } from \"../types/Local\"\nimport type { MinIO } from \"../types/MinIO\"\nimport OSSUpload from \"./OSS\"\nimport OBSUpload from \"./OBS\"\nimport KodoUpload from \"./Kodo\"\nimport TOSUpload from \"./TOS\"\nimport LocalUpload from \"./Local\"\nimport MinIOUpload from \"./MinIO\"\n\nconst PlatformModules: Record<\n\tPlatformType,\n\tRecord<\n\t\tstring,\n\t\t| PlatformRequest<OSS.AuthParams, PlatformSimpleUploadOption>\n\t\t| PlatformRequest<OSS.STSAuthParams, PlatformMultipartUploadOption>\n\t\t| PlatformRequest<Kodo.AuthParams, PlatformSimpleUploadOption>\n\t\t| PlatformRequest<TOS.AuthParams, PlatformMultipartUploadOption>\n\t\t| PlatformRequest<TOS.STSAuthParams, PlatformMultipartUploadOption>\n\t\t| PlatformRequest<OBS.STSAuthParams, PlatformMultipartUploadOption>\n\t\t| PlatformRequest<OBS.AuthParams, PlatformMultipartUploadOption>\n\t\t| PlatformRequest<Local.AuthParams, PlatformSimpleUploadOption>\n\t\t| PlatformRequest<MinIO.AuthParams, PlatformSimpleUploadOption>\n\t\t| PlatformRequest<MinIO.STSAuthParams, PlatformMultipartUploadOption>\n\t>\n> = {\n\t[PlatformType.OSS]: OSSUpload,\n\t[PlatformType.Kodo]: KodoUpload,\n\t[PlatformType.TOS]: TOSUpload,\n\t[PlatformType.OBS]: OBSUpload,\n\t[PlatformType.Local]: LocalUpload,\n\t[PlatformType.Minio]: MinIOUpload,\n}\n\nexport default PlatformModules\n\n\n\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,mBAA6B;AAO7B,iBAAsB;AACtB,iBAAsB;AACtB,kBAAuB;AACvB,iBAAsB;AACtB,mBAAwB;AACxB,mBAAwB;AAExB,MAAM,kBAeF;AAAA,EACH,CAAC,0BAAa,GAAG,GAAG,WAAAA;AAAA,EACpB,CAAC,0BAAa,IAAI,GAAG,YAAAC;AAAA,EACrB,CAAC,0BAAa,GAAG,GAAG,WAAAC;AAAA,EACpB,CAAC,0BAAa,GAAG,GAAG,WAAAC;AAAA,EACpB,CAAC,0BAAa,KAAK,GAAG,aAAAC;AAAA,EACtB,CAAC,0BAAa,KAAK,GAAG,aAAAC;AACvB;AAEA,IAAO,kBAAQ;","names":["OSSUpload","KodoUpload","TOSUpload","OBSUpload","LocalUpload","MinIOUpload"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var Kodo_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(Kodo_exports);
|
|
17
|
+
//# sourceMappingURL=Kodo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/types/Kodo.ts"],"sourcesContent":["/**\n * Qiniu cloud namespace\n */\nexport namespace Kodo {\n\t/** Backend return - Qiniu cloud credential fields */\n\texport type AuthParams = {\n\t\ttoken: string\n\t\tdir: string\n\t}\n}\n\n\n\n\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var Local_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(Local_exports);
|
|
17
|
+
//# sourceMappingURL=Local.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/types/Local.ts"],"sourcesContent":["/**\n * Internal network upload\n */\nexport namespace Local {\n\texport interface AuthParams {\n\t\tdir: string\n\t\thost: string\n\t\tcredential: string\n\t}\n}\n\n\n\n\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|