@yingzhixiaoyi/crypto-http
v0.0.1
Published
Explicit legacy request and response crypto adapter
Readme
@yingzhixiaoyi/crypto-http
不绑定 Axios 的 legacy 请求/响应加密适配器,连接 @yingzhixiaoyi/crypto-core 与 @yingzhixiaoyi/crypto-keyring。应用只需配置 namespace、私钥来源和旧协议模式,不应在业务项目重复实现 AES/RSA 解密或 keyring 轮换。
能力边界
- AES-CBC JSON body 加密;
- RSA SHA-256
signbodyheader; - response body 解密与 JSON object 解析;
aeskey、Token、公钥从响应 header/body 更新到显式 keyring。
调用方必须显式提供 IV 和 RSA 私钥;本包不生成密钥/IV、不创建 HTTP interceptor、不决定明文 fallback,也不处理 Wujie。
import { encryptLegacyRequest } from '@yingzhixiaoyi/crypto-http'
const encrypted = encryptLegacyRequest({ data: { ok: true }, aesKey, iv, privateKeyPem })业务应用可使用统一适配器集中处理 keyring、请求加密、响应解密和密钥轮换:
import { createLegacyCryptoAdapter } from '@yingzhixiaoyi/crypto-http'
const legacyCrypto = createLegacyCryptoAdapter({
namespace: 'ue_mint',
privateKeyPem,
aesKeyEncoding: 'rsa-encrypted',
})
legacyCrypto.encryptionRequest(config)
legacyCrypto.decryptResponse(response)这是 legacy 兼容层,AES-CBC 不提供认证完整性;新服务协议应另行设计和版本化。
