@hlw-uni-mp/request 1.0.9 → 1.0.10
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/dist/index.js +6 -3
- package/dist/index.mjs +6 -3
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -6855,15 +6855,15 @@ function encryptRsa(plaintext, publicKey) {
|
|
|
6855
6855
|
const maxBlockSize = key.keyBytes - 11;
|
|
6856
6856
|
const dataBytes = stringToUtf8(plaintext);
|
|
6857
6857
|
const totalBlocks = Math.ceil(dataBytes.length / maxBlockSize) || 1;
|
|
6858
|
-
const
|
|
6858
|
+
const chunks = [];
|
|
6859
6859
|
for (let i = 0; i < totalBlocks; i++) {
|
|
6860
6860
|
const start = i * maxBlockSize;
|
|
6861
6861
|
const end = Math.min(start + maxBlockSize, dataBytes.length);
|
|
6862
6862
|
const chunk = dataBytes.slice(start, end);
|
|
6863
6863
|
const encryptedChunk = encryptBlock(chunk, key);
|
|
6864
|
-
|
|
6864
|
+
chunks.push(bytesToBase64(encryptedChunk));
|
|
6865
6865
|
}
|
|
6866
|
-
return
|
|
6866
|
+
return chunks.join(".");
|
|
6867
6867
|
}
|
|
6868
6868
|
|
|
6869
6869
|
// src/crypto/sign.ts
|
|
@@ -7037,6 +7037,9 @@ function buildSecurityHeaders(config) {
|
|
|
7037
7037
|
if ("appid" in devInfo && devInfo.appid) {
|
|
7038
7038
|
headers["x-appid"] = String(devInfo.appid);
|
|
7039
7039
|
}
|
|
7040
|
+
if (token) {
|
|
7041
|
+
headers["x-token"] = token;
|
|
7042
|
+
}
|
|
7040
7043
|
return headers;
|
|
7041
7044
|
}
|
|
7042
7045
|
function sendRequest(url, config) {
|
package/dist/index.mjs
CHANGED
|
@@ -6829,15 +6829,15 @@ function encryptRsa(plaintext, publicKey) {
|
|
|
6829
6829
|
const maxBlockSize = key.keyBytes - 11;
|
|
6830
6830
|
const dataBytes = stringToUtf8(plaintext);
|
|
6831
6831
|
const totalBlocks = Math.ceil(dataBytes.length / maxBlockSize) || 1;
|
|
6832
|
-
const
|
|
6832
|
+
const chunks = [];
|
|
6833
6833
|
for (let i = 0; i < totalBlocks; i++) {
|
|
6834
6834
|
const start = i * maxBlockSize;
|
|
6835
6835
|
const end = Math.min(start + maxBlockSize, dataBytes.length);
|
|
6836
6836
|
const chunk = dataBytes.slice(start, end);
|
|
6837
6837
|
const encryptedChunk = encryptBlock(chunk, key);
|
|
6838
|
-
|
|
6838
|
+
chunks.push(bytesToBase64(encryptedChunk));
|
|
6839
6839
|
}
|
|
6840
|
-
return
|
|
6840
|
+
return chunks.join(".");
|
|
6841
6841
|
}
|
|
6842
6842
|
|
|
6843
6843
|
// src/crypto/sign.ts
|
|
@@ -7011,6 +7011,9 @@ function buildSecurityHeaders(config) {
|
|
|
7011
7011
|
if ("appid" in devInfo && devInfo.appid) {
|
|
7012
7012
|
headers["x-appid"] = String(devInfo.appid);
|
|
7013
7013
|
}
|
|
7014
|
+
if (token) {
|
|
7015
|
+
headers["x-token"] = token;
|
|
7016
|
+
}
|
|
7014
7017
|
return headers;
|
|
7015
7018
|
}
|
|
7016
7019
|
function sendRequest(url, config) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hlw-uni-mp/request",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "Universal Uni-App HTTP and upload client with RSA encryption & sign verification",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -16,6 +16,11 @@
|
|
|
16
16
|
"files": [
|
|
17
17
|
"dist"
|
|
18
18
|
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsup",
|
|
21
|
+
"dev": "tsup --watch",
|
|
22
|
+
"publish:npm": "pnpm build && npm publish --access public"
|
|
23
|
+
},
|
|
19
24
|
"publishConfig": {
|
|
20
25
|
"access": "public"
|
|
21
26
|
},
|
|
@@ -37,10 +42,5 @@
|
|
|
37
42
|
"@types/crypto-js": "^4.2.2",
|
|
38
43
|
"tsup": "^8.5.1",
|
|
39
44
|
"typescript": "^5.8.3"
|
|
40
|
-
},
|
|
41
|
-
"scripts": {
|
|
42
|
-
"build": "tsup",
|
|
43
|
-
"dev": "tsup --watch",
|
|
44
|
-
"publish:npm": "pnpm build && npm publish --access public"
|
|
45
45
|
}
|
|
46
|
-
}
|
|
46
|
+
}
|