# jd-h5st-signer

Electron **主进程**用隐藏窗口加载京东 `js_security`，执行 `ParamsSign` / `ParamsSignMain` 生成 `h5st`。

## 线上部署（供 jd_fast_cart 每次启动拉取）

1. 将本目录打包上传到你的 HTTPS 静态服务器/CDN/OSS，对外暴露 **`index.js`** 原始文件（例如 `https://cdn.example.com/vendor/jd-h5st-signer/index.js`）。
2. 客户端设置环境变量 **`JD_H5ST_SIGNER_URL`** 为该 HTTPS URL（jd_fast_cart 启动时会下载到 `userData/vendor/jd-h5st-signer/index.js` 再 `require`）。
3. （可选）设置 **`JD_H5ST_SIGNER_SHA256`** 为文件 UTF-8 内容的 SHA256 小写 hex，校验失败则丢弃下载并回退到内置 npm 包。

本地开发不设 `JD_H5ST_SIGNER_URL` 时，直接使用 npm `file:../jd-h5st-signer` 内置模块。

## API

```js
const { createH5stSigner } = require('jd-h5st-signer');
const signer = createH5stSigner({
  partitionPrefix: 'persist:my-app-h5st',
});
await signer.sign(accountId, 'ParamsSign', '0248a', paramsObject, cookieHeaderString);
```
