@hlw-uni-mp/request 1.0.13 → 1.0.15
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.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +7 -16
- package/dist/index.mjs +7 -16
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -236,8 +236,8 @@ interface UploadFileParams {
|
|
|
236
236
|
* 零第三方外部依赖,原生兼容小程序、浏览器与 Node 环境
|
|
237
237
|
*/
|
|
238
238
|
/**
|
|
239
|
-
* RSA-2048
|
|
240
|
-
* @param plaintext
|
|
239
|
+
* RSA-2048 公钥单块加密(PKCS#1 v1.5,用于安全加密对称密钥)
|
|
240
|
+
* @param plaintext 明文字符串
|
|
241
241
|
* @param publicKey PEM 格式或纯 Base64 公钥
|
|
242
242
|
* @returns 密文 Base64 编码
|
|
243
243
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -236,8 +236,8 @@ interface UploadFileParams {
|
|
|
236
236
|
* 零第三方外部依赖,原生兼容小程序、浏览器与 Node 环境
|
|
237
237
|
*/
|
|
238
238
|
/**
|
|
239
|
-
* RSA-2048
|
|
240
|
-
* @param plaintext
|
|
239
|
+
* RSA-2048 公钥单块加密(PKCS#1 v1.5,用于安全加密对称密钥)
|
|
240
|
+
* @param plaintext 明文字符串
|
|
241
241
|
* @param publicKey PEM 格式或纯 Base64 公钥
|
|
242
242
|
* @returns 密文 Base64 编码
|
|
243
243
|
*/
|
package/dist/index.js
CHANGED
|
@@ -6853,18 +6853,9 @@ function encryptBlock(block, key) {
|
|
|
6853
6853
|
function encryptRsa(plaintext, publicKey) {
|
|
6854
6854
|
if (!plaintext || !publicKey) return "";
|
|
6855
6855
|
const key = parsePublicKey(publicKey);
|
|
6856
|
-
const maxBlockSize = key.keyBytes - 11;
|
|
6857
6856
|
const dataBytes = stringToUtf8(plaintext);
|
|
6858
|
-
const
|
|
6859
|
-
|
|
6860
|
-
for (let i = 0; i < totalBlocks; i++) {
|
|
6861
|
-
const start = i * maxBlockSize;
|
|
6862
|
-
const end = Math.min(start + maxBlockSize, dataBytes.length);
|
|
6863
|
-
const chunk = dataBytes.slice(start, end);
|
|
6864
|
-
const encryptedChunk = encryptBlock(chunk, key);
|
|
6865
|
-
chunks.push(bytesToBase64(encryptedChunk));
|
|
6866
|
-
}
|
|
6867
|
-
return chunks.join(".");
|
|
6857
|
+
const encryptedChunk = encryptBlock(dataBytes, key);
|
|
6858
|
+
return bytesToBase64(encryptedChunk);
|
|
6868
6859
|
}
|
|
6869
6860
|
|
|
6870
6861
|
// src/crypto/sign.ts
|
|
@@ -6958,7 +6949,7 @@ function buildHeader(cred, customHeader) {
|
|
|
6958
6949
|
const appid = "appid" in devInfo ? String(devInfo.appid || "") : "";
|
|
6959
6950
|
const headers = { ...customHeader };
|
|
6960
6951
|
if (cred.type === "local") {
|
|
6961
|
-
if (appid) headers["
|
|
6952
|
+
if (appid) headers["x-appid"] = String(appid);
|
|
6962
6953
|
if (token) headers["token"] = String(token);
|
|
6963
6954
|
}
|
|
6964
6955
|
return headers;
|
|
@@ -7055,10 +7046,10 @@ function buildSecurityHeaders(config) {
|
|
|
7055
7046
|
"Content-Type": "application/json",
|
|
7056
7047
|
Accept: "application/json",
|
|
7057
7048
|
...config.headers,
|
|
7058
|
-
"
|
|
7059
|
-
"
|
|
7060
|
-
"
|
|
7061
|
-
"
|
|
7049
|
+
"x-client-timestamp": String(timestamp),
|
|
7050
|
+
"x-client-nonce": nonce,
|
|
7051
|
+
"x-client-sign": sign,
|
|
7052
|
+
"x-client-context": cipher
|
|
7062
7053
|
};
|
|
7063
7054
|
if ("appid" in devInfo && devInfo.appid) {
|
|
7064
7055
|
headers["x-appid"] = String(devInfo.appid);
|
package/dist/index.mjs
CHANGED
|
@@ -6826,18 +6826,9 @@ function encryptBlock(block, key) {
|
|
|
6826
6826
|
function encryptRsa(plaintext, publicKey) {
|
|
6827
6827
|
if (!plaintext || !publicKey) return "";
|
|
6828
6828
|
const key = parsePublicKey(publicKey);
|
|
6829
|
-
const maxBlockSize = key.keyBytes - 11;
|
|
6830
6829
|
const dataBytes = stringToUtf8(plaintext);
|
|
6831
|
-
const
|
|
6832
|
-
|
|
6833
|
-
for (let i = 0; i < totalBlocks; i++) {
|
|
6834
|
-
const start = i * maxBlockSize;
|
|
6835
|
-
const end = Math.min(start + maxBlockSize, dataBytes.length);
|
|
6836
|
-
const chunk = dataBytes.slice(start, end);
|
|
6837
|
-
const encryptedChunk = encryptBlock(chunk, key);
|
|
6838
|
-
chunks.push(bytesToBase64(encryptedChunk));
|
|
6839
|
-
}
|
|
6840
|
-
return chunks.join(".");
|
|
6830
|
+
const encryptedChunk = encryptBlock(dataBytes, key);
|
|
6831
|
+
return bytesToBase64(encryptedChunk);
|
|
6841
6832
|
}
|
|
6842
6833
|
|
|
6843
6834
|
// src/crypto/sign.ts
|
|
@@ -6931,7 +6922,7 @@ function buildHeader(cred, customHeader) {
|
|
|
6931
6922
|
const appid = "appid" in devInfo ? String(devInfo.appid || "") : "";
|
|
6932
6923
|
const headers = { ...customHeader };
|
|
6933
6924
|
if (cred.type === "local") {
|
|
6934
|
-
if (appid) headers["
|
|
6925
|
+
if (appid) headers["x-appid"] = String(appid);
|
|
6935
6926
|
if (token) headers["token"] = String(token);
|
|
6936
6927
|
}
|
|
6937
6928
|
return headers;
|
|
@@ -7028,10 +7019,10 @@ function buildSecurityHeaders(config) {
|
|
|
7028
7019
|
"Content-Type": "application/json",
|
|
7029
7020
|
Accept: "application/json",
|
|
7030
7021
|
...config.headers,
|
|
7031
|
-
"
|
|
7032
|
-
"
|
|
7033
|
-
"
|
|
7034
|
-
"
|
|
7022
|
+
"x-client-timestamp": String(timestamp),
|
|
7023
|
+
"x-client-nonce": nonce,
|
|
7024
|
+
"x-client-sign": sign,
|
|
7025
|
+
"x-client-context": cipher
|
|
7035
7026
|
};
|
|
7036
7027
|
if ("appid" in devInfo && devInfo.appid) {
|
|
7037
7028
|
headers["x-appid"] = String(devInfo.appid);
|
package/package.json
CHANGED