@hlw-uni-mp/request 1.0.14 → 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 CHANGED
@@ -236,8 +236,8 @@ interface UploadFileParams {
236
236
  * 零第三方外部依赖,原生兼容小程序、浏览器与 Node 环境
237
237
  */
238
238
  /**
239
- * RSA-2048 公钥分段加密
240
- * @param plaintext 明文字符串(支持 UTF-8 多字节)
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 明文字符串(支持 UTF-8 多字节)
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 totalBlocks = Math.ceil(dataBytes.length / maxBlockSize) || 1;
6859
- const chunks = [];
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
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 totalBlocks = Math.ceil(dataBytes.length / maxBlockSize) || 1;
6832
- const chunks = [];
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hlw-uni-mp/request",
3
- "version": "1.0.14",
3
+ "version": "1.0.15",
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",