Skip to content

Commit

Permalink
bump to v0.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
TheNorthMemory committed Jan 2, 2022
1 parent 2e4e333 commit 8f604bc
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# 变更历史

## v0.8.0 (2022-01-02)
- 优化,严格限定初始化参数`mchid`为字符串,避免带参请求远端接口时,被校验不通过情况;
- 优化,`Aes`, `Rsa`, `Hash` 等类实现,支持通过`解构`语法仅获取封装的静态方法,例如 `{ sign } = require('./lib/rsa')`

## v0.7.13 (2021-09-20)
- 增加V2版合单支付中的`combine_mch_id`校验能力支持;

Expand Down
18 changes: 9 additions & 9 deletions lib/aes.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,56 +71,56 @@ const PKCS7 = {
class Aes {
/**
* @property {string} hex - Alias of `hex` string
* @deprecated v1.0.0 - Only for compatible, use the literal `hex` string instead
* @deprecated v0.8.0 - Only for compatible, use the literal `hex` string instead
*/
static get hex() { return hex; }

/**
* @property {string} utf8 - Alias of `utf8` string
* @deprecated v1.0.0 - Only for compatible, use the literal `utf8` string instead
* @deprecated v0.8.0 - Only for compatible, use the literal `utf8` string instead
*/
static get utf8() { return utf8; }

/**
* @property {string} base64 - Alias of `base64` string
* @deprecated v1.0.0 - Only for compatible, use the literal `base64` string instead
* @deprecated v0.8.0 - Only for compatible, use the literal `base64` string instead
*/
static get base64() { return base64; }

/**
* @property {integer} BLOCK_SIZE - The `aes` block size
* @deprecated v1.0.0 - Only for compatible, use the literal `16` number instead
* @deprecated v0.8.0 - Only for compatible, use the literal `16` number instead
*/
static get BLOCK_SIZE() { return BLOCK_SIZE; }

/**
* @property {string} ALGO_AES_256_GCM - The `aes-256-gcm` algorithm
* @deprecated v1.0.0 - Only for compatible, use the literal `aes-256-gcm` string instead
* @deprecated v0.8.0 - Only for compatible, use the literal `aes-256-gcm` string instead
*/
static get ALGO_AES_256_GCM() { return ALGO_AES_256_GCM; }

/**
* @property {string} ALGO_AES_256_ECB - The `aes-256-ecb` algorithm
* @deprecated v1.0.0 - Only for compatible, use the literal `aes-256-ecb` string instead
* @deprecated v0.8.0 - Only for compatible, use the literal `aes-256-ecb` string instead
*/
static get ALGO_AES_256_ECB() { return ALGO_AES_256_ECB; }

/**
* @property {string} ALGO_AES_128_CBC - The `aes-128-cbc` algorithm
* @deprecated v1.0.0 - Only for compatible, use the literal `aes-128-cbc` string instead
* @deprecated v0.8.0 - Only for compatible, use the literal `aes-128-cbc` string instead
*/
static get ALGO_AES_128_CBC() { return ALGO_AES_128_CBC; }

/**
* Back compatible {@link AesGcm.encrypt}, shall removed future
* @deprecated v1.0.0 - Only for compatible, use the `AesGcm.encrypt` method instead
* @deprecated v0.8.0 - Only for compatible, use the `AesGcm.encrypt` method instead
* @returns {string} Base64-encoded ciphertext.
*/
static encrypt(...arg) { return AesGcm.encrypt(...arg); }

/**
* Back compatible {@link AesGcm.decrypt}, shall removed future
* @deprecated v1.0.0 - Only for compatible, use the `AesGcm.decrypt` method instead
* @deprecated v0.8.0 - Only for compatible, use the `AesGcm.decrypt` method instead
* @returns {string} Utf-8 plaintext.
*/
static decrypt(...arg) { return AesGcm.decrypt(...arg); }
Expand Down
4 changes: 2 additions & 2 deletions lib/decorator.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const WechatpaySerial = 'Wechatpay-Serial';
const WechatpaySignature = 'Wechatpay-Signature';
const WechatpayTimestamp = 'Wechatpay-Timestamp';

const ERR_INIT_MCHID_IS_MANDATORY = 'The merchant\' ID aka `mchid` is required, usually numerical.';
const ERR_INIT_MCHID_IS_MANDATORY = 'The merchant\' ID aka `mchid` is required, usually is numerical string.';
const ERR_INIT_SERIAL_IS_MANDATORY = 'The serial number of the merchant\'s certificate aka `serial` is required, usually hexadecial.';
const ERR_INIT_PRIVATEKEY_IS_MANDATORY = 'The merchant\'s private key aka `privateKey` is required, usual as pem format.';
const ERR_INIT_CERTS_IS_MANDATORY = 'The platform certificate(s) aka `certs` is required, paired as of `{$serial: $certificate}`.';
Expand Down Expand Up @@ -191,7 +191,7 @@ class Decorator {
} = config;

assert(
utils.isString(mchid) || utils.isNumber(mchid),
utils.isString(mchid),
ERR_INIT_MCHID_IS_MANDATORY,
);
assert(
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wechatpay-axios-plugin",
"version": "0.7.13",
"version": "0.8.0",
"description": "微信支付APIv2及v3 NodeJS SDK,支持CLI模式请求OpenAPI,支持v3证书下载,v2付款码支付、企业付款、退款,企业微信-企业支付-企业红包/向员工付款,v2&v3 Native支付、扫码支付、H5支付、JSAPI/小程序支付、合单支付...",
"main": "index.js",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion tests/openapi/101.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('OpenAPI Kick Start 101', () => {
const publicCert = readFileSync(join(__dirname, '../fixtures/apiserver_cert.pem'));

instance = new Wechatpay({
mchid: 101,
mchid: '101',
serial: '898DBAD30F416EC7',
privateKey,
certs: { BE2A2344B984167B: publicCert },
Expand Down
2 changes: 1 addition & 1 deletion tests/openapi/issue-28-ERR_ASSERTION-SYSTEM_ERROR.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('Issue #28 jsapi 请求路径有误', () => {
const publicCert = readFileSync(join(__dirname, '../fixtures/apiserver_cert.pem'));

instance = new Wechatpay({
mchid: 101,
mchid: '101',
serial: '898DBAD30F416EC7',
privateKey,
certs: { BE2A2344B984167B: publicCert },
Expand Down
4 changes: 2 additions & 2 deletions tests/openapi/issue-30-ERR_ASSERTION-bad_phrases.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('Issue #30 v3/pay/transcations/h5', () => {
const publicCert = readFileSync(join(__dirname, '../fixtures/apiserver_cert.pem'));

instance = new Wechatpay({
mchid: 101,
mchid: '101',
serial: '898DBAD30F416EC7',
privateKey,
certs: { BE2A2344B984167B: publicCert },
Expand All @@ -47,7 +47,7 @@ describe('Issue #30 v3/pay/transcations/h5', () => {
const privateKey = readFileSync(join(__dirname, '../fixtures/apiclient_key.pem'));
const publicCert = readFileSync(join(__dirname, '../fixtures/apiserver_cert.pem'));
await (new Wechatpay({
mchid: 101,
mchid: '101',
serial: '898DBAD30F416EC7',
privateKey,
certs: { BE2A2344B984167B: publicCert },
Expand Down

0 comments on commit 8f604bc

Please sign in to comment.