@jayfong/x-server 2.78.1 → 2.78.3

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.
@@ -118,7 +118,7 @@ class Handler {
118
118
  url: err.options.url.toString(),
119
119
  headers: JSON.stringify(err.options.headers || {}),
120
120
  query: (err.options.search ?? err.options.searchParams?.toString()) || '',
121
- body: err.options.body?.toString() ?? (err.options.form ? JSON.stringify(err.options.form) : '')
121
+ body: (err.options.json ? JSON.stringify(err.options.json) : err.options.form ? new URLSearchParams(err.options.form).toString() : err.options.body?.toString()) || ''
122
122
  });
123
123
  }
124
124
  // 服务器错误
@@ -120,7 +120,7 @@ class CryptoService {
120
120
  * @param key - 用于加密的密钥(仅支持16字节的密钥)。
121
121
  */
122
122
  aesEncrypt(text, key) {
123
- const cipher = _nodeCrypto.default.createCipheriv('aes-128-ecb', key, null);
123
+ const cipher = _nodeCrypto.default.createCipheriv('aes-128-ecb', key.substring(0, 16), null);
124
124
  let encrypted = cipher.update(text, 'utf8', 'base64');
125
125
  encrypted += cipher.final('base64');
126
126
  return encrypted;
@@ -133,7 +133,7 @@ class CryptoService {
133
133
  * @param key - 用于解密的密钥(仅支持16字节的密钥)。
134
134
  */
135
135
  aesDecrypt(text, key) {
136
- const decipher = _nodeCrypto.default.createDecipheriv('aes-128-ecb', key, null);
136
+ const decipher = _nodeCrypto.default.createDecipheriv('aes-128-ecb', key.substring(0, 16), null);
137
137
  let decrypted = decipher.update(text, 'base64', 'utf8');
138
138
  decrypted += decipher.final('utf8');
139
139
  return decrypted;
@@ -112,7 +112,7 @@ export class Handler {
112
112
  url: err.options.url.toString(),
113
113
  headers: JSON.stringify(err.options.headers || {}),
114
114
  query: (err.options.search ?? err.options.searchParams?.toString()) || '',
115
- body: err.options.body?.toString() ?? (err.options.form ? JSON.stringify(err.options.form) : '')
115
+ body: (err.options.json ? JSON.stringify(err.options.json) : err.options.form ? new URLSearchParams(err.options.form).toString() : err.options.body?.toString()) || ''
116
116
  });
117
117
  }
118
118
  // 服务器错误
@@ -115,7 +115,7 @@ export class CryptoService {
115
115
  * @param key - 用于加密的密钥(仅支持16字节的密钥)。
116
116
  */
117
117
  aesEncrypt(text, key) {
118
- const cipher = crypto.createCipheriv('aes-128-ecb', key, null);
118
+ const cipher = crypto.createCipheriv('aes-128-ecb', key.substring(0, 16), null);
119
119
  let encrypted = cipher.update(text, 'utf8', 'base64');
120
120
  encrypted += cipher.final('base64');
121
121
  return encrypted;
@@ -128,7 +128,7 @@ export class CryptoService {
128
128
  * @param key - 用于解密的密钥(仅支持16字节的密钥)。
129
129
  */
130
130
  aesDecrypt(text, key) {
131
- const decipher = crypto.createDecipheriv('aes-128-ecb', key, null);
131
+ const decipher = crypto.createDecipheriv('aes-128-ecb', key.substring(0, 16), null);
132
132
  let decrypted = decipher.update(text, 'base64', 'utf8');
133
133
  decrypted += decipher.final('utf8');
134
134
  return decrypted;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jayfong/x-server",
3
- "version": "2.78.1",
3
+ "version": "2.78.3",
4
4
  "license": "ISC",
5
5
  "sideEffects": false,
6
6
  "main": "lib/_cjs/index.js",