@qzsy/ums-core 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +64 -2
- package/dist/cjs/client.js +286 -0
- package/dist/cjs/client.js.map +1 -0
- package/dist/cjs/crypto.js +63 -0
- package/dist/cjs/crypto.js.map +1 -0
- package/dist/cjs/errors.js +136 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/index.js +42 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/notify.js +88 -0
- package/dist/cjs/notify.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/sign.js +70 -0
- package/dist/cjs/sign.js.map +1 -0
- package/dist/cjs/time.js +41 -0
- package/dist/cjs/time.js.map +1 -0
- package/dist/cjs/token.js +117 -0
- package/dist/cjs/token.js.map +1 -0
- package/dist/cjs/types.js +31 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/util.js +54 -0
- package/dist/cjs/util.js.map +1 -0
- package/dist/esm/client.d.ts +100 -0
- package/dist/esm/client.d.ts.map +1 -0
- package/dist/esm/client.js +282 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/esm/crypto.d.ts +23 -0
- package/dist/esm/crypto.d.ts.map +1 -0
- package/dist/esm/crypto.js +53 -0
- package/dist/esm/crypto.js.map +1 -0
- package/dist/esm/errors.d.ts +106 -0
- package/dist/esm/errors.d.ts.map +1 -0
- package/dist/esm/errors.js +123 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/index.d.ts +17 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +17 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/notify.d.ts +44 -0
- package/dist/esm/notify.d.ts.map +1 -0
- package/dist/esm/notify.js +78 -0
- package/dist/esm/notify.js.map +1 -0
- package/dist/esm/sign.d.ts +58 -0
- package/dist/esm/sign.d.ts.map +1 -0
- package/dist/esm/sign.js +61 -0
- package/dist/esm/sign.js.map +1 -0
- package/dist/esm/time.d.ts +17 -0
- package/dist/esm/time.d.ts.map +1 -0
- package/dist/esm/time.js +34 -0
- package/dist/esm/time.js.map +1 -0
- package/dist/esm/token.d.ts +42 -0
- package/dist/esm/token.d.ts.map +1 -0
- package/dist/esm/token.js +113 -0
- package/dist/esm/token.js.map +1 -0
- package/dist/esm/types.d.ts +57 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +27 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/util.d.ts +25 -0
- package/dist/esm/util.d.ts.map +1 -0
- package/dist/esm/util.js +49 -0
- package/dist/esm/util.js.map +1 -0
- package/package.json +44 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 qunxing-payment contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,65 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @qzsy/ums-core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
银联商务 BC 分账 SDK 的核心包:HTTP 客户端、`OPEN-BODY-SIG` 签名、AccessToken、回调验签与错误体系。
|
|
4
|
+
|
|
5
|
+
- 零运行时依赖(Node.js >= 18 全局 `fetch`)
|
|
6
|
+
- ESM + CJS 双产物,完整 TypeScript 类型
|
|
7
|
+
- 所有业务模块(`@qzsy/ums-miniapp` / `@qzsy/ums-pos` / `@qzsy/ums-mis`)共享同一个 `UmsClient`
|
|
8
|
+
|
|
9
|
+
## 安装
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @qzsy/ums-core
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## 使用
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { UmsClient, createMerOrderId } from '@qzsy/ums-core';
|
|
19
|
+
|
|
20
|
+
const client = new UmsClient({
|
|
21
|
+
appId: process.env.UMS_APP_ID!,
|
|
22
|
+
appKey: process.env.UMS_APP_KEY!,
|
|
23
|
+
env: 'test', // 'test' | 'production' | 'dedicated'
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// 直接调用任意开放平台接口
|
|
27
|
+
const result = await client.request('/v1/netpay/query', {
|
|
28
|
+
instMid: 'MINIDEFAULT',
|
|
29
|
+
merOrderId: createMerOrderId('0001'),
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 主要导出
|
|
34
|
+
|
|
35
|
+
| 导出 | 说明 |
|
|
36
|
+
| --- | --- |
|
|
37
|
+
| `UmsClient` | 支持签名、重试、超时、AccessToken、自定义 `fetch` |
|
|
38
|
+
| `UmsClientOptions` | `appId` / `appKey` / `env` / `baseUrl` / `auth` / `timeoutMs` / `maxRetries` / `logger` / `fetch` |
|
|
39
|
+
| `signBody` / `buildBodyAuthorization` | `OPEN-BODY-SIG` 签名与请求头 |
|
|
40
|
+
| `AccessTokenManager` | token 缓存、并发单飞、提前刷新 |
|
|
41
|
+
| `verifyNotifyParams` / `signNotifyParams` / `parseFormUrlencoded` | 支付结果通知验签与解析 |
|
|
42
|
+
| `NOTIFY_RESPONSE` | 回调应答常量 `SUCCESS` / `FAILED` |
|
|
43
|
+
| `createMerOrderId` / `formatTimestamp` / `randomHex` | 工具函数 |
|
|
44
|
+
| `UmsApiError` / `UmsValidationError` / `UmsTimeoutError` 等 | 错误类型 |
|
|
45
|
+
|
|
46
|
+
## 错误处理
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import { UmsApiError } from '@qzsy/ums-core';
|
|
50
|
+
|
|
51
|
+
try {
|
|
52
|
+
await client.request('/v1/netpay/query', payload, { idempotent: true });
|
|
53
|
+
} catch (error) {
|
|
54
|
+
if (error instanceof UmsApiError) {
|
|
55
|
+
console.error(error.errCode, error.errMsg);
|
|
56
|
+
if (error.isRetryableByApi) {
|
|
57
|
+
// 稍后重试
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## License
|
|
64
|
+
|
|
65
|
+
MIT
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UmsClient = void 0;
|
|
4
|
+
const errors_js_1 = require("./errors.js");
|
|
5
|
+
const sign_js_1 = require("./sign.js");
|
|
6
|
+
const token_js_1 = require("./token.js");
|
|
7
|
+
const types_js_1 = require("./types.js");
|
|
8
|
+
const util_js_1 = require("./util.js");
|
|
9
|
+
const DEFAULT_SUCCESS_CODES = ['SUCCESS', '0000', '000000', '00'];
|
|
10
|
+
const DEFAULT_TIMEOUT_MS = 15_000;
|
|
11
|
+
const DEFAULT_MAX_RETRIES = 2;
|
|
12
|
+
const DEFAULT_RETRY_DELAY_MS = 500;
|
|
13
|
+
const MAX_RETRY_DELAY_MS = 30_000;
|
|
14
|
+
/**
|
|
15
|
+
* 银联商务开放平台 HTTP 客户端。
|
|
16
|
+
*
|
|
17
|
+
* 负责:URL 拼接、认证头生成、超时/重试、JSON 解析、业务错误识别。
|
|
18
|
+
* 各业务模块(小程序支付、POS 通分账、云 MIS)在此之上提供强类型方法。
|
|
19
|
+
*/
|
|
20
|
+
class UmsClient {
|
|
21
|
+
appId;
|
|
22
|
+
env;
|
|
23
|
+
baseUrl;
|
|
24
|
+
auth;
|
|
25
|
+
timeoutMs;
|
|
26
|
+
maxRetries;
|
|
27
|
+
retryDelayMs;
|
|
28
|
+
appKey;
|
|
29
|
+
headers;
|
|
30
|
+
fetchImpl;
|
|
31
|
+
logger;
|
|
32
|
+
successCodes;
|
|
33
|
+
throwOnApiError;
|
|
34
|
+
now;
|
|
35
|
+
tokenProvider;
|
|
36
|
+
tokenManager;
|
|
37
|
+
constructor(options) {
|
|
38
|
+
if (!options.appId)
|
|
39
|
+
throw new errors_js_1.UmsConfigError('appId 不能为空');
|
|
40
|
+
this.appId = options.appId;
|
|
41
|
+
this.appKey = options.appKey;
|
|
42
|
+
this.env = options.env ?? 'production';
|
|
43
|
+
this.baseUrl = (options.baseUrl ?? types_js_1.UMS_HOSTS[this.env]).replace(/\/+$/, '');
|
|
44
|
+
this.auth = options.auth ?? 'body-sig';
|
|
45
|
+
this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
46
|
+
this.maxRetries = Math.max(0, options.maxRetries ?? DEFAULT_MAX_RETRIES);
|
|
47
|
+
this.retryDelayMs = Math.max(0, options.retryDelayMs ?? DEFAULT_RETRY_DELAY_MS);
|
|
48
|
+
this.headers = { ...options.headers };
|
|
49
|
+
this.fetchImpl = options.fetch;
|
|
50
|
+
this.logger = options.logger;
|
|
51
|
+
this.successCodes = new Set(options.successCodes ?? DEFAULT_SUCCESS_CODES);
|
|
52
|
+
this.throwOnApiError = options.throwOnApiError ?? true;
|
|
53
|
+
this.now = options.now ?? (() => new Date());
|
|
54
|
+
if (this.auth !== 'none' && !this.appKey) {
|
|
55
|
+
throw new errors_js_1.UmsConfigError(`认证方式 ${this.auth} 需要 appKey`);
|
|
56
|
+
}
|
|
57
|
+
if (this.auth === 'access-token') {
|
|
58
|
+
const token = options.token;
|
|
59
|
+
if (token && typeof token.getToken === 'function') {
|
|
60
|
+
this.tokenProvider = token;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
if (!this.appKey)
|
|
64
|
+
throw new errors_js_1.UmsConfigError('access-token 模式需要 appKey');
|
|
65
|
+
this.tokenManager = new token_js_1.AccessTokenManager({
|
|
66
|
+
...token,
|
|
67
|
+
appId: this.appId,
|
|
68
|
+
appKey: this.appKey,
|
|
69
|
+
baseUrl: this.baseUrl,
|
|
70
|
+
fetchImpl: this.fetchImpl,
|
|
71
|
+
now: this.now,
|
|
72
|
+
logger: this.logger,
|
|
73
|
+
});
|
|
74
|
+
this.tokenProvider = this.tokenManager;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/** 清除内置的 AccessToken 缓存。 */
|
|
79
|
+
invalidateAccessToken() {
|
|
80
|
+
this.tokenManager?.invalidate();
|
|
81
|
+
}
|
|
82
|
+
/** 发送 POST JSON 请求并返回业务响应。 */
|
|
83
|
+
async request(path, payload, options = {}) {
|
|
84
|
+
const result = await this.requestWithMeta(path, payload, options);
|
|
85
|
+
return result.data;
|
|
86
|
+
}
|
|
87
|
+
/** 发送请求并返回业务响应 + HTTP 元信息。 */
|
|
88
|
+
async requestWithMeta(path, payload, options = {}) {
|
|
89
|
+
const bodyText = serializePayload(payload);
|
|
90
|
+
const url = this.resolveUrl(path);
|
|
91
|
+
const timeoutMs = options.timeoutMs ?? this.timeoutMs;
|
|
92
|
+
const authMode = options.auth ?? this.auth;
|
|
93
|
+
const attempts = 1 + (options.idempotent ? this.maxRetries : 0);
|
|
94
|
+
const successCodes = options.successCodes ? new Set(options.successCodes) : this.successCodes;
|
|
95
|
+
let attempt = 0;
|
|
96
|
+
let tokenRetried = false;
|
|
97
|
+
for (;;) {
|
|
98
|
+
const authorization = await this.buildAuthorization(authMode, bodyText, options);
|
|
99
|
+
let response;
|
|
100
|
+
try {
|
|
101
|
+
response = await this.postOnce(url, bodyText, authorization, timeoutMs, options);
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
if (!(error instanceof errors_js_1.UmsError))
|
|
105
|
+
throw error;
|
|
106
|
+
if ((error instanceof errors_js_1.UmsTimeoutError || error instanceof errors_js_1.UmsNetworkError) && attempt < attempts - 1) {
|
|
107
|
+
attempt += 1;
|
|
108
|
+
await this.backoff(attempt, options.signal);
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
throw error;
|
|
112
|
+
}
|
|
113
|
+
// AccessToken 过期/被踢:失效重取,并重放一次。
|
|
114
|
+
if (response.status === 401 &&
|
|
115
|
+
authMode === 'access-token' &&
|
|
116
|
+
!tokenRetried &&
|
|
117
|
+
!options.authorization) {
|
|
118
|
+
tokenRetried = true;
|
|
119
|
+
this.tokenProvider?.invalidate?.();
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
if ((response.status >= 500 || response.status === 429) && attempt < attempts - 1) {
|
|
123
|
+
attempt += 1;
|
|
124
|
+
this.logger?.warn?.('[ums] retrying request', {
|
|
125
|
+
path,
|
|
126
|
+
status: response.status,
|
|
127
|
+
attempt,
|
|
128
|
+
});
|
|
129
|
+
await this.backoff(attempt, options.signal);
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
return this.parseResponse(path, response, successCodes, options.raw === true);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
resolveUrl(path) {
|
|
136
|
+
if (/^https?:\/\//i.test(path))
|
|
137
|
+
return path;
|
|
138
|
+
return `${this.baseUrl}${path.startsWith('/') ? path : `/${path}`}`;
|
|
139
|
+
}
|
|
140
|
+
async buildAuthorization(authMode, bodyText, options) {
|
|
141
|
+
if (options.authorization)
|
|
142
|
+
return options.authorization;
|
|
143
|
+
if (authMode === 'none')
|
|
144
|
+
return undefined;
|
|
145
|
+
if (authMode === 'access-token') {
|
|
146
|
+
if (!this.tokenProvider)
|
|
147
|
+
throw new errors_js_1.UmsConfigError('access-token 模式未配置 tokenProvider');
|
|
148
|
+
return (0, sign_js_1.buildAccessTokenAuthorization)(await this.tokenProvider.getToken());
|
|
149
|
+
}
|
|
150
|
+
if (!this.appKey)
|
|
151
|
+
throw new errors_js_1.UmsConfigError('OPEN-BODY-SIG 需要 appKey');
|
|
152
|
+
const timestamp = (0, sign_js_1.createTimestamp)(this.now);
|
|
153
|
+
const nonce = (0, sign_js_1.createNonce)();
|
|
154
|
+
return (0, sign_js_1.buildBodyAuthorization)({
|
|
155
|
+
appId: this.appId,
|
|
156
|
+
appKey: this.appKey,
|
|
157
|
+
timestamp,
|
|
158
|
+
nonce,
|
|
159
|
+
body: bodyText,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
async postOnce(url, bodyText, authorization, timeoutMs, options) {
|
|
163
|
+
const fetchFn = this.fetchImpl ?? globalThis.fetch;
|
|
164
|
+
if (typeof fetchFn !== 'function') {
|
|
165
|
+
throw new errors_js_1.UmsConfigError('当前运行环境没有全局 fetch,请通过 options.fetch 注入');
|
|
166
|
+
}
|
|
167
|
+
const controller = new AbortController();
|
|
168
|
+
let timedOut = false;
|
|
169
|
+
const timer = setTimeout(() => {
|
|
170
|
+
timedOut = true;
|
|
171
|
+
controller.abort();
|
|
172
|
+
}, timeoutMs);
|
|
173
|
+
const external = options.signal;
|
|
174
|
+
const onAbort = () => controller.abort();
|
|
175
|
+
if (external) {
|
|
176
|
+
if (external.aborted)
|
|
177
|
+
controller.abort();
|
|
178
|
+
else
|
|
179
|
+
external.addEventListener('abort', onAbort, { once: true });
|
|
180
|
+
}
|
|
181
|
+
const headers = {
|
|
182
|
+
accept: 'application/json',
|
|
183
|
+
'content-type': 'application/json; charset=utf-8',
|
|
184
|
+
...(this.headers.userAgent || this.headers['user-agent']
|
|
185
|
+
? {}
|
|
186
|
+
: { 'user-agent': 'qzsy-ums-sdk/0.1' }),
|
|
187
|
+
...this.headers,
|
|
188
|
+
...options.headers,
|
|
189
|
+
};
|
|
190
|
+
if (authorization)
|
|
191
|
+
headers.authorization = authorization;
|
|
192
|
+
this.logger?.debug?.('[ums] request', { url, bytes: bodyText.length });
|
|
193
|
+
try {
|
|
194
|
+
const response = await fetchFn(url, {
|
|
195
|
+
method: 'POST',
|
|
196
|
+
headers,
|
|
197
|
+
body: bodyText,
|
|
198
|
+
signal: controller.signal,
|
|
199
|
+
});
|
|
200
|
+
const text = await response.text();
|
|
201
|
+
return {
|
|
202
|
+
ok: response.ok,
|
|
203
|
+
status: response.status,
|
|
204
|
+
statusText: response.statusText,
|
|
205
|
+
headers: response.headers,
|
|
206
|
+
text,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
catch (error) {
|
|
210
|
+
if (timedOut)
|
|
211
|
+
throw new errors_js_1.UmsTimeoutError(timeoutMs, { cause: error });
|
|
212
|
+
if (external?.aborted)
|
|
213
|
+
throw new errors_js_1.UmsAbortError('请求已被调用方取消', { cause: error });
|
|
214
|
+
throw new errors_js_1.UmsNetworkError(`请求失败:${String(error?.message ?? error)}`, {
|
|
215
|
+
cause: error,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
finally {
|
|
219
|
+
clearTimeout(timer);
|
|
220
|
+
external?.removeEventListener('abort', onAbort);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
parseResponse(path, response, successCodes, raw) {
|
|
224
|
+
let data;
|
|
225
|
+
try {
|
|
226
|
+
data = response.text ? JSON.parse(response.text) : {};
|
|
227
|
+
}
|
|
228
|
+
catch (error) {
|
|
229
|
+
throw new errors_js_1.UmsResponseParseError({
|
|
230
|
+
status: response.status,
|
|
231
|
+
bodyText: response.text,
|
|
232
|
+
cause: error,
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
const envelope = (data ?? {});
|
|
236
|
+
if (!response.ok) {
|
|
237
|
+
throw new errors_js_1.UmsHttpError({
|
|
238
|
+
status: response.status,
|
|
239
|
+
statusText: response.statusText,
|
|
240
|
+
body: response.text,
|
|
241
|
+
path,
|
|
242
|
+
message: `HTTP ${response.status} ${response.statusText}${path ? ` (${path})` : ''}${envelope.errCode ? ` [${envelope.errCode}]` : ''}`,
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
const errCode = envelope.errCode;
|
|
246
|
+
if (this.throwOnApiError &&
|
|
247
|
+
!raw &&
|
|
248
|
+
typeof errCode === 'string' &&
|
|
249
|
+
errCode.length > 0 &&
|
|
250
|
+
!successCodes.has(errCode)) {
|
|
251
|
+
throw new errors_js_1.UmsApiError({
|
|
252
|
+
errCode,
|
|
253
|
+
errMsg: envelope.errMsg ?? envelope.errInfo,
|
|
254
|
+
data,
|
|
255
|
+
path,
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
this.logger?.debug?.('[ums] response', {
|
|
259
|
+
path,
|
|
260
|
+
status: response.status,
|
|
261
|
+
errCode: envelope.errCode,
|
|
262
|
+
});
|
|
263
|
+
return {
|
|
264
|
+
data: data,
|
|
265
|
+
meta: {
|
|
266
|
+
status: response.status,
|
|
267
|
+
statusText: response.statusText,
|
|
268
|
+
headers: response.headers,
|
|
269
|
+
rawText: response.text,
|
|
270
|
+
},
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
backoff(attempt, signal) {
|
|
274
|
+
const delay = Math.min(this.retryDelayMs * 2 ** Math.max(0, attempt - 1), MAX_RETRY_DELAY_MS);
|
|
275
|
+
return (0, util_js_1.sleep)(delay, signal);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
exports.UmsClient = UmsClient;
|
|
279
|
+
function serializePayload(payload) {
|
|
280
|
+
if (payload === undefined)
|
|
281
|
+
return '{}';
|
|
282
|
+
if (typeof payload === 'string')
|
|
283
|
+
return payload;
|
|
284
|
+
return JSON.stringify(payload);
|
|
285
|
+
}
|
|
286
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":";;;AAAA,2CASqB;AACrB,uCAAgH;AAChH,yCAAmG;AAEnG,yCAAuC;AACvC,uCAAkC;AA2ElC,MAAM,qBAAqB,GAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;AACrF,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAClC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAC9B,MAAM,sBAAsB,GAAG,GAAG,CAAC;AACnC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAElC;;;;;GAKG;AACH,MAAa,SAAS;IACX,KAAK,CAAS;IACd,GAAG,CAAiB;IACpB,OAAO,CAAS;IAChB,IAAI,CAAc;IAClB,SAAS,CAAS;IAClB,UAAU,CAAS;IACnB,YAAY,CAAS;IAEb,MAAM,CAAqB;IAC3B,OAAO,CAAyB;IAChC,SAAS,CAA2B;IACpC,MAAM,CAAwB;IAC9B,YAAY,CAAsB;IAClC,eAAe,CAAU;IACzB,GAAG,CAAa;IAChB,aAAa,CAAkC;IAC/C,YAAY,CAAiC;IAE9D,YAAY,OAAyB;QACnC,IAAI,CAAC,OAAO,CAAC,KAAK;YAAE,MAAM,IAAI,0BAAc,CAAC,YAAY,CAAC,CAAC;QAE3D,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,YAAY,CAA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AK,EAAE,MAAM,CAAC,CAAC;IAC9B,CAAC;CACF;AAvSD,8BAuSC;AAED,SAAS,gBAAgB,CAAC,OAAgB;IACxC,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACvC,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,OAAO,CAAC;IAChD,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sha256Hex = sha256Hex;
|
|
4
|
+
exports.md5Hex = md5Hex;
|
|
5
|
+
exports.hmacSha256Base64 = hmacSha256Base64;
|
|
6
|
+
exports.hmacSha256Hex = hmacSha256Hex;
|
|
7
|
+
exports.base64Encode = base64Encode;
|
|
8
|
+
exports.randomHex = randomHex;
|
|
9
|
+
exports.randomDigits = randomDigits;
|
|
10
|
+
exports.safeEqual = safeEqual;
|
|
11
|
+
const node_crypto_1 = require("node:crypto");
|
|
12
|
+
/**
|
|
13
|
+
* 加密原语封装。
|
|
14
|
+
*
|
|
15
|
+
* 全部基于 `node:crypto`,因此 SDK 仅支持 Node.js >= 18 / Bun。
|
|
16
|
+
* Edge Runtime 可注入自定义实现(见 `UmsClientOptions.crypto`,预留)。
|
|
17
|
+
*/
|
|
18
|
+
/** SHA-256 小写十六进制摘要。 */
|
|
19
|
+
function sha256Hex(input) {
|
|
20
|
+
return (0, node_crypto_1.createHash)('sha256').update(input).digest('hex');
|
|
21
|
+
}
|
|
22
|
+
/** MD5 小写十六进制摘要。 */
|
|
23
|
+
function md5Hex(input) {
|
|
24
|
+
return (0, node_crypto_1.createHash)('md5').update(input).digest('hex');
|
|
25
|
+
}
|
|
26
|
+
/** HMAC-SHA256 后 Base64 编码(OPEN-BODY-SIG 的签名值)。 */
|
|
27
|
+
function hmacSha256Base64(content, key) {
|
|
28
|
+
return (0, node_crypto_1.createHmac)('sha256', key).update(content).digest('base64');
|
|
29
|
+
}
|
|
30
|
+
/** HMAC-SHA256 后小写十六进制字符串。 */
|
|
31
|
+
function hmacSha256Hex(content, key) {
|
|
32
|
+
return (0, node_crypto_1.createHmac)('sha256', key).update(content).digest('hex');
|
|
33
|
+
}
|
|
34
|
+
/** UTF-8 字符串的 Base64 编码。 */
|
|
35
|
+
function base64Encode(input) {
|
|
36
|
+
return Buffer.from(input, 'utf8').toString('base64');
|
|
37
|
+
}
|
|
38
|
+
/** 生成随机十六进制串(默认 16 字节 → 32 字符),用于 nonce。 */
|
|
39
|
+
function randomHex(byteLength = 16) {
|
|
40
|
+
return (0, node_crypto_1.randomBytes)(byteLength).toString('hex');
|
|
41
|
+
}
|
|
42
|
+
/** 生成指定长度的随机纯数字串。 */
|
|
43
|
+
function randomDigits(length) {
|
|
44
|
+
let out = '';
|
|
45
|
+
while (out.length < length) {
|
|
46
|
+
const bytes = (0, node_crypto_1.randomBytes)(length - out.length + 8);
|
|
47
|
+
for (const byte of bytes) {
|
|
48
|
+
out += String(byte % 10);
|
|
49
|
+
if (out.length === length)
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return out;
|
|
54
|
+
}
|
|
55
|
+
/** 定长字符串比较,避免时序侧信道。 */
|
|
56
|
+
function safeEqual(left, right) {
|
|
57
|
+
const a = Buffer.from(left, 'utf8');
|
|
58
|
+
const b = Buffer.from(right, 'utf8');
|
|
59
|
+
if (a.length !== b.length)
|
|
60
|
+
return false;
|
|
61
|
+
return (0, node_crypto_1.timingSafeEqual)(a, b);
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=crypto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../src/crypto.ts"],"names":[],"mappings":";;AAUA,8BAEC;AAGD,wBAEC;AAGD,4CAKC;AAGD,sCAEC;AAGD,oCAEC;AAGD,8BAEC;AAGD,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3B,MAAM,KAAK,GAAG,IAAA,yBAAW,EAAC,MAAM,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACnD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,GAAG,IAAI,MAAM,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;YACzB,IAAI,GAAG,CAAC,MAAM,KAAK,MAAM;gBAAE,MAAM;QACnC,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,uBAAuB;AACvB,SAAgB,SAAS,CAAC,IAAY,EAAE,KAAa;IACnD,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACpC,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACrC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IACxC,OAAO,IAAA,6BAAe,EAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* SDK 错误模型。
|
|
4
|
+
*
|
|
5
|
+
* 设计原则:
|
|
6
|
+
* - 网络层失败(超时、连接中断)与业务层失败(errCode 非成功码)使用不同错误类型;
|
|
7
|
+
* - 所有错误都保留原始响应/报文,便于排查与重放;
|
|
8
|
+
* - `UmsApiError` 携带 `errCode`,调用方可用 `isRetryableByApi()` 判断是否值得重试。
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.UmsSignatureError = exports.UmsResponseParseError = exports.UmsNetworkError = exports.UmsAbortError = exports.UmsTimeoutError = exports.UmsHttpError = exports.RETRYABLE_API_CODES = exports.UmsApiError = exports.UmsValidationError = exports.UmsConfigError = exports.UmsError = void 0;
|
|
12
|
+
/** 所有 SDK 错误的基类。 */
|
|
13
|
+
class UmsError extends Error {
|
|
14
|
+
name = 'UmsError';
|
|
15
|
+
cause;
|
|
16
|
+
constructor(message, options) {
|
|
17
|
+
super(message);
|
|
18
|
+
this.cause = options?.cause;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.UmsError = UmsError;
|
|
22
|
+
/** 配置错误:缺少 appId/appKey、环境非法等。 */
|
|
23
|
+
class UmsConfigError extends UmsError {
|
|
24
|
+
name = 'UmsConfigError';
|
|
25
|
+
}
|
|
26
|
+
exports.UmsConfigError = UmsConfigError;
|
|
27
|
+
/** 本地参数校验错误。 */
|
|
28
|
+
class UmsValidationError extends UmsError {
|
|
29
|
+
name = 'UmsValidationError';
|
|
30
|
+
}
|
|
31
|
+
exports.UmsValidationError = UmsValidationError;
|
|
32
|
+
/** 业务错误:HTTP 200 且 `errCode` 非成功码。 */
|
|
33
|
+
class UmsApiError extends UmsError {
|
|
34
|
+
name = 'UmsApiError';
|
|
35
|
+
errCode;
|
|
36
|
+
errMsg;
|
|
37
|
+
data;
|
|
38
|
+
path;
|
|
39
|
+
constructor(input) {
|
|
40
|
+
const detail = input.errMsg ? `: ${input.errMsg}` : '';
|
|
41
|
+
super(input.message ?? `[${input.errCode}]${detail}`);
|
|
42
|
+
this.errCode = input.errCode;
|
|
43
|
+
this.errMsg = input.errMsg ?? '';
|
|
44
|
+
this.data = input.data;
|
|
45
|
+
this.path = input.path ?? '';
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* 平台侧「系统失败」类错误码(《02-小程序支付》2.1 标注“系统失败=是”)通常可重试;
|
|
49
|
+
* 业务失败(如 NO_ORDER)重试无意义。
|
|
50
|
+
*/
|
|
51
|
+
get isRetryableByApi() {
|
|
52
|
+
return exports.RETRYABLE_API_CODES.has(this.errCode);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.UmsApiError = UmsApiError;
|
|
56
|
+
/** 平台返回“系统失败”语义的错误码集合。 */
|
|
57
|
+
exports.RETRYABLE_API_CODES = new Set([
|
|
58
|
+
'INTERNAL_ERROR',
|
|
59
|
+
'TIMEOUT',
|
|
60
|
+
'NET_ERROR',
|
|
61
|
+
'TXN_DISCARDED',
|
|
62
|
+
'BAD_REQUEST',
|
|
63
|
+
'INVALID_RESPONSE',
|
|
64
|
+
'9999',
|
|
65
|
+
'999999',
|
|
66
|
+
'902021',
|
|
67
|
+
]);
|
|
68
|
+
/** HTTP 层错误:非 2xx 响应。 */
|
|
69
|
+
class UmsHttpError extends UmsError {
|
|
70
|
+
name = 'UmsHttpError';
|
|
71
|
+
status;
|
|
72
|
+
statusText;
|
|
73
|
+
body;
|
|
74
|
+
path;
|
|
75
|
+
constructor(input) {
|
|
76
|
+
super(input.message ??
|
|
77
|
+
`HTTP ${input.status}${input.statusText ? ` ${input.statusText}` : ''}${input.path ? ` (${input.path})` : ''}`);
|
|
78
|
+
this.status = input.status;
|
|
79
|
+
this.statusText = input.statusText ?? '';
|
|
80
|
+
this.body = input.body ?? '';
|
|
81
|
+
this.path = input.path ?? '';
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.UmsHttpError = UmsHttpError;
|
|
85
|
+
/** 请求超时。 */
|
|
86
|
+
class UmsTimeoutError extends UmsError {
|
|
87
|
+
name = 'UmsTimeoutError';
|
|
88
|
+
timeoutMs;
|
|
89
|
+
constructor(timeoutMs, options) {
|
|
90
|
+
super(`请求超时(${timeoutMs}ms)`, options);
|
|
91
|
+
this.timeoutMs = timeoutMs;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.UmsTimeoutError = UmsTimeoutError;
|
|
95
|
+
/** 调用方主动取消。 */
|
|
96
|
+
class UmsAbortError extends UmsError {
|
|
97
|
+
name = 'UmsAbortError';
|
|
98
|
+
constructor(message = '请求已被取消', options) {
|
|
99
|
+
super(message, options);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.UmsAbortError = UmsAbortError;
|
|
103
|
+
/** 网络异常(DNS、TLS、连接重置等)。 */
|
|
104
|
+
class UmsNetworkError extends UmsError {
|
|
105
|
+
name = 'UmsNetworkError';
|
|
106
|
+
constructor(message = '网络请求失败', options) {
|
|
107
|
+
super(message, options);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
exports.UmsNetworkError = UmsNetworkError;
|
|
111
|
+
/** 响应不是合法 JSON。 */
|
|
112
|
+
class UmsResponseParseError extends UmsError {
|
|
113
|
+
name = 'UmsResponseParseError';
|
|
114
|
+
status;
|
|
115
|
+
bodyText;
|
|
116
|
+
constructor(input) {
|
|
117
|
+
const preview = input.bodyText.slice(0, 200);
|
|
118
|
+
super(`响应不是合法 JSON(HTTP ${input.status}):${preview}`, { cause: input.cause });
|
|
119
|
+
this.status = input.status;
|
|
120
|
+
this.bodyText = input.bodyText;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
exports.UmsResponseParseError = UmsResponseParseError;
|
|
124
|
+
/** 通知验签失败。 */
|
|
125
|
+
class UmsSignatureError extends UmsError {
|
|
126
|
+
name = 'UmsSignatureError';
|
|
127
|
+
expected;
|
|
128
|
+
actual;
|
|
129
|
+
constructor(input) {
|
|
130
|
+
super(input.message ?? '签名校验失败');
|
|
131
|
+
this.expected = input.expected;
|
|
132
|
+
this.actual = input.actual;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
exports.UmsSignatureError = UmsSignatureError;
|
|
136
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAEH,oBAAoB;AACpB,MAAa,QAAS,SAAQ,KAAK;IACf,IAAI,GAAW,UAAU,CAAC;IAC1B,KAAK,CAAW;IAElC,YAAY,OAAe,EAAE,OAA6B;QACxD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,OAAO,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iB,CAAC;IAE3C,YAAY,OAAO,GAAG,QAAQ,EAAE,OAA6B;QAC3D,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;CACF;AAND,0CAMC;AAED,mBAAmB;AACnB,MAAa,qBAAsB,SAAQ,QAAQ;IAC/B,IAAI,GAAG,uBAAuB,CAAC;IACxC,MAAM,CAAS;IACf,QAAQ,CAAS;IAE1B,YAAY,KAA4D;QACtE,MAAM,OAAO,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QAC7C,KAAK,CAAC,oBAAoB,KAAK,CAAC,MAAM,KAAK,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;QAC9E,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;IACjC,CAAC;CACF;AAXD,sDAWC;AAED,cAAc;AACd,MAAa,iBAAkB,SAAQ,QAAQ;IAC3B,IAAI,GAAG,mBAAmB,CAAC;IACpC,QAAQ,CAAU;IAClB,MAAM,CAAU;IAEzB,YAAY,KAA+D;QACzE,KAAK,CAAC,KAAK,CAAC,OAAO,IAAI,QAAQ,CAAC,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAC7B,CAAC;CACF;AAVD,8CAUC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @qzsy/ums-core —— 银联商务开放平台核心客户端。
|
|
4
|
+
*
|
|
5
|
+
* 提供:环境与公共类型、OPEN-BODY-SIG / OPEN-ACCESS-TOKEN 认证、HTTP 客户端、
|
|
6
|
+
* 统一错误模型、支付结果通知验签。
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.sha256Hex = exports.safeEqual = exports.randomHex = exports.randomDigits = exports.md5Hex = exports.hmacSha256Hex = exports.hmacSha256Base64 = exports.base64Encode = exports.VERSION = void 0;
|
|
24
|
+
exports.VERSION = '0.1.0';
|
|
25
|
+
__exportStar(require("./types.js"), exports);
|
|
26
|
+
__exportStar(require("./errors.js"), exports);
|
|
27
|
+
__exportStar(require("./client.js"), exports);
|
|
28
|
+
__exportStar(require("./sign.js"), exports);
|
|
29
|
+
__exportStar(require("./token.js"), exports);
|
|
30
|
+
__exportStar(require("./time.js"), exports);
|
|
31
|
+
__exportStar(require("./util.js"), exports);
|
|
32
|
+
__exportStar(require("./notify.js"), exports);
|
|
33
|
+
var crypto_js_1 = require("./crypto.js");
|
|
34
|
+
Object.defineProperty(exports, "base64Encode", { enumerable: true, get: function () { return crypto_js_1.base64Encode; } });
|
|
35
|
+
Object.defineProperty(exports, "hmacSha256Base64", { enumerable: true, get: function () { return crypto_js_1.hmacSha256Base64; } });
|
|
36
|
+
Object.defineProperty(exports, "hmacSha256Hex", { enumerable: true, get: function () { return crypto_js_1.hmacSha256Hex; } });
|
|
37
|
+
Object.defineProperty(exports, "md5Hex", { enumerable: true, get: function () { return crypto_js_1.md5Hex; } });
|
|
38
|
+
Object.defineProperty(exports, "randomDigits", { enumerable: true, get: function () { return crypto_js_1.randomDigits; } });
|
|
39
|
+
Object.defineProperty(exports, "randomHex", { enumerable: true, get: function () { return crypto_js_1.randomHex; } });
|
|
40
|
+
Object.defineProperty(exports, "safeEqual", { enumerable: true, get: function () { return crypto_js_1.safeEqual; } });
|
|
41
|
+
Object.defineProperty(exports, "sha256Hex", { enumerable: true, get: function () { return crypto_js_1.sha256Hex; } });
|
|
42
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;AAEU,QAAA,OAAO,GAAG,OAAO,CAAC;AAE/B,6CAA2B;AAC3B,8CAA4B;AAC5B,8CAA4B;AAC5B,4CAA0B;AAC1B,6CAA2B;AAC3B,4CAA0B;AAC1B,4CAA0B;AAC1B,8CAA4B;AAC5B,yCASqB;AARnB,yGAAA,YAAY,OAAA;AACZ,6GAAA,gBAAgB,OAAA;AAChB,0GAAA,aAAa,OAAA;AACb,mGAAA,MAAM,OAAA;AACN,yGAAA,YAAY,OAAA;AACZ,sGAAA,SAAS,OAAA;AACT,sGAAA,SAAS,OAAA;AACT,sGAAA,SAAS,OAAA"}
|