@yunzhanghu/sdk-nodejs 0.0.1-beta.1

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.
Files changed (66) hide show
  1. package/.eslintignore +4 -0
  2. package/.eslintrc.json +19 -0
  3. package/.husky/pre-commit +7 -0
  4. package/LICENSE +201 -0
  5. package/README.md +114 -0
  6. package/example/apiUserSign.js +70 -0
  7. package/example/authentication.js +142 -0
  8. package/example/bizlicXjjH5.js +46 -0
  9. package/example/bizlicXjjH5Api.js +65 -0
  10. package/example/conf/config.js +30 -0
  11. package/example/dataService.js +98 -0
  12. package/example/h5UserSign.js +68 -0
  13. package/example/invoice.js +91 -0
  14. package/example/notify.js +36 -0
  15. package/example/package.json +12 -0
  16. package/example/payment.js +186 -0
  17. package/example/tax.js +34 -0
  18. package/package.json +47 -0
  19. package/prettier.config.js +32 -0
  20. package/src/common/client.ts +367 -0
  21. package/src/common/exception/yzhSDKHttpException.ts +32 -0
  22. package/src/common/http/index.ts +57 -0
  23. package/src/common/utils/index.ts +18 -0
  24. package/src/index.ts +1 -0
  25. package/src/services/apiusersign/index.ts +125 -0
  26. package/src/services/authentication/index.ts +247 -0
  27. package/src/services/bizlicxjjh5/index.ts +129 -0
  28. package/src/services/bizlicxjjh5api/index.ts +169 -0
  29. package/src/services/dataservice/index.ts +315 -0
  30. package/src/services/h5usersign/index.ts +145 -0
  31. package/src/services/index.ts +10 -0
  32. package/src/services/invoice/index.ts +257 -0
  33. package/src/services/payment/index.ts +523 -0
  34. package/src/services/tax/index.ts +77 -0
  35. package/src/typings.d.ts +1 -0
  36. package/tsconfig.json +25 -0
  37. package/yzh/common/client.d.ts +119 -0
  38. package/yzh/common/client.js +314 -0
  39. package/yzh/common/exception/yzhSDKHttpException.d.ts +10 -0
  40. package/yzh/common/exception/yzhSDKHttpException.js +21 -0
  41. package/yzh/common/http/index.d.ts +6 -0
  42. package/yzh/common/http/index.js +51 -0
  43. package/yzh/common/utils/index.d.ts +14 -0
  44. package/yzh/common/utils/index.js +11 -0
  45. package/yzh/index.d.ts +1 -0
  46. package/yzh/index.js +4 -0
  47. package/yzh/services/apiusersign/index.d.ts +86 -0
  48. package/yzh/services/apiusersign/index.js +26 -0
  49. package/yzh/services/authentication/index.d.ts +153 -0
  50. package/yzh/services/authentication/index.js +42 -0
  51. package/yzh/services/bizlicxjjh5/index.d.ts +76 -0
  52. package/yzh/services/bizlicxjjh5/index.js +18 -0
  53. package/yzh/services/bizlicxjjh5api/index.d.ts +107 -0
  54. package/yzh/services/bizlicxjjh5api/index.js +22 -0
  55. package/yzh/services/dataservice/index.d.ts +243 -0
  56. package/yzh/services/dataservice/index.js +38 -0
  57. package/yzh/services/h5usersign/index.d.ts +90 -0
  58. package/yzh/services/h5usersign/index.js +26 -0
  59. package/yzh/services/index.d.ts +10 -0
  60. package/yzh/services/index.js +23 -0
  61. package/yzh/services/invoice/index.d.ts +158 -0
  62. package/yzh/services/invoice/index.js +34 -0
  63. package/yzh/services/payment/index.d.ts +358 -0
  64. package/yzh/services/payment/index.js +50 -0
  65. package/yzh/services/tax/index.d.ts +55 -0
  66. package/yzh/services/tax/index.js +18 -0
@@ -0,0 +1,367 @@
1
+ import getInstance from "../common/http"
2
+ import * as crypto from "crypto"
3
+ import YZHSDKHttpException from "./exception/yzhSDKHttpException"
4
+ const clearEncoding = "utf8"
5
+ const cipherEncoding = "base64"
6
+
7
+ export type ResponseCallback<TReuslt = any> = (error: null | string, rep: TReuslt) => void
8
+
9
+ type ResponseData = any
10
+
11
+ export class YZHClient {
12
+ public dealer_id: string
13
+ public broker_id: string
14
+ public app_key: string
15
+ public des3_key: string
16
+ public private_key: string
17
+ public yzh_public_key: string
18
+ public sign_type: "rsa" | "sha256"
19
+ public base_url?: string
20
+
21
+ /**
22
+ * 构造函数参数
23
+ * @param {string} dealer_id 平台企业 ID
24
+ * @param {string} broker_id 综合服务主体 ID
25
+ * @param {string} app_key App Key
26
+ * @param {string} des3_key 3DES Key
27
+ * @param {string} private_key 平台企业私钥
28
+ * @param {string} yzh_public_key 云账户公钥
29
+ * @param {string} sign_type 签名方式"rsa" | "sha256"
30
+ * @param {string} base_url 可选,默认为 https://api-service.yunzhanghu.com/
31
+ */
32
+ constructor(conf: {
33
+ dealer_id: string
34
+ broker_id: string
35
+ app_key: string
36
+ des3_key: string
37
+ private_key: string
38
+ yzh_public_key: string
39
+ sign_type: "rsa" | "sha256"
40
+ base_url?: string
41
+ }) {
42
+ const { dealer_id, broker_id, app_key, des3_key, private_key, yzh_public_key, sign_type } =
43
+ conf || {}
44
+ if (
45
+ conf &&
46
+ dealer_id &&
47
+ broker_id &&
48
+ app_key &&
49
+ des3_key &&
50
+ private_key &&
51
+ yzh_public_key &&
52
+ sign_type
53
+ ) {
54
+ this.dealer_id = conf.dealer_id
55
+ this.broker_id = conf.broker_id
56
+ this.app_key = conf.app_key
57
+ this.des3_key = conf.des3_key
58
+ this.private_key = conf.private_key
59
+ this.yzh_public_key = conf.yzh_public_key
60
+ this.sign_type = conf.sign_type
61
+ this.base_url = conf?.base_url
62
+ } else {
63
+ throw new YZHSDKHttpException(
64
+ `实例初始化失败,请检查以下配置是否缺失:\ndealer_id、broker_id、app_key、des3_key、private_key、yzh_public_key、sign_type`
65
+ )
66
+ }
67
+ }
68
+
69
+ // 基础请求:进行请求实例生成 Header,动态设置、请求体包装等偏底层操作
70
+ private doRequest(method: string, action: string, req: any): Promise<ResponseData> {
71
+ // 请求参数加密
72
+ const encryptParams = this.generatorResquestParams(req)
73
+ // 生成请求实例,配置 Header
74
+ const instance = getInstance({
75
+ request_id: req?.request_id ?? this.mess(),
76
+ dealer_id: this.dealer_id,
77
+ base_url: this.base_url,
78
+ })
79
+ // 返回请求实例
80
+ const baseInstanceConf = { method: method, url: action }
81
+ let instanceConf
82
+ if (method === "get") {
83
+ instanceConf = { ...baseInstanceConf, params: encryptParams }
84
+ } else {
85
+ instanceConf = { ...baseInstanceConf, data: encryptParams }
86
+ }
87
+ return instance(instanceConf)
88
+ }
89
+
90
+ // 公共请求:调用封装好的基础请求方法 doRequest,进行发送请求与响应内容处理
91
+ async request(
92
+ method: string,
93
+ action: string,
94
+ req?: any,
95
+ options?: { encryption: boolean },
96
+ cb?: ResponseCallback
97
+ ): Promise<ResponseData> {
98
+ if (typeof options === "function") {
99
+ cb = options
100
+ options = {} as any
101
+ }
102
+ try {
103
+ const result = await this.doRequest(method, action, req ?? {})
104
+ // 错误码处理 > 验签 > 解密
105
+ const responseData = await this.parseResponse(result, options?.encryption)
106
+ cb && cb(null, responseData)
107
+
108
+ return responseData
109
+ } catch (e) {
110
+ if (cb) {
111
+ cb(e as any, null)
112
+ } else {
113
+ throw e
114
+ }
115
+ }
116
+ }
117
+
118
+ /**
119
+ * 请求参数加密
120
+ * @param {object} params
121
+ * @returns {*} object
122
+ */
123
+ private generatorResquestParams(params: string) {
124
+ try {
125
+ const t = Date.now().toString()
126
+ const m = this.mess()
127
+
128
+ const plaintext = JSON.stringify(params)
129
+
130
+ const data = this.encrypt(plaintext)
131
+
132
+ const signStr = this.generatorSign(data, m, t)
133
+ return {
134
+ data,
135
+ mess: m,
136
+ timestamp: t,
137
+ sign: signStr,
138
+ sign_type: this.sign_type,
139
+ }
140
+ } catch (err) {
141
+ throw new YZHSDKHttpException(`${err}`)
142
+ }
143
+ }
144
+
145
+ /**
146
+ * 生成签名(RSA-SHA256)
147
+ * @param {string} data 经过加密后的具体数据
148
+ * @param {string} mess 自定义随机字符串,用于签名
149
+ * @param {string} timestamp 时间戳,精确到秒
150
+ * @returns {string} 签名内容
151
+ */
152
+ private generatorSignRSASHA256 = (data: string, mess: string, timestamp: string) => {
153
+ try {
154
+ const plaintext = `data=${data}&mess=${mess}&timestamp=${timestamp}&key=${this.app_key}`
155
+ const sign = crypto.createSign("RSA-SHA256")
156
+ sign.update(plaintext)
157
+ sign.end()
158
+ return sign.sign(this.private_key, cipherEncoding)
159
+ } catch (err) {
160
+ throw new YZHSDKHttpException(`${err}`)
161
+ }
162
+ }
163
+
164
+ /**
165
+ * 生成签名(HmacSHA256)
166
+ * @param {string} data 经过加密后的具体数据
167
+ * @param {string} mess 自定义随机字符串,用于签名
168
+ * @param {string} timestamp 时间戳,精确到秒
169
+ * @returns {string} 签名内容
170
+ */
171
+ private generatorSignHmacSHA256 = (data: string, mess: string, timestamp: string) => {
172
+ try {
173
+ const plaintext = `data=${data}&mess=${mess}&timestamp=${timestamp}&key=${this.app_key}`
174
+ const hmac = crypto.createHmac("sha256", this.app_key)
175
+ hmac.update(plaintext)
176
+ return hmac.digest("hex")
177
+ } catch (err) {
178
+ throw new YZHSDKHttpException(`${err}`)
179
+ }
180
+ }
181
+
182
+ /**
183
+ * 生成签名
184
+ * @param {string} data 经过加密后的具体数据
185
+ * @param {string} mess 自定义随机字符串,用于签名
186
+ * @param {string} timestamp 时间戳,精确到秒
187
+ * @param {string} sign_type 签名方式
188
+ * @returns {string} 签名内容
189
+ */
190
+ private generatorSign = (data: string, mess: string, timestamp: string) => {
191
+ try {
192
+ switch (this.sign_type) {
193
+ case "rsa": {
194
+ return this.generatorSignRSASHA256(data, mess, timestamp)
195
+ }
196
+ case "sha256": {
197
+ return this.generatorSignHmacSHA256(data, mess, timestamp)
198
+ }
199
+ default:
200
+ throw new YZHSDKHttpException(`sign_type类型不存在`)
201
+ }
202
+ } catch (err) {
203
+ throw new YZHSDKHttpException(`${err}`)
204
+ }
205
+ }
206
+
207
+ // 自定义随机字符串
208
+ private mess = () => {
209
+ const buf = crypto.randomBytes(16)
210
+ const token = buf.toString("hex")
211
+ return token.toString()
212
+ }
213
+
214
+ /**
215
+ * 3DES 加密数据
216
+ * @param plaintext
217
+ * @returns 字符串加密数据
218
+ */
219
+ private encrypt = (plaintext: string) => {
220
+ try {
221
+ const iv = this.des3_key.slice(0, 8)
222
+ const cipherChunks = []
223
+ const cipher = crypto.createCipheriv("des-ede3-cbc", this.des3_key, iv)
224
+ cipher.setAutoPadding(true)
225
+ cipherChunks.push(cipher.update(plaintext, clearEncoding, cipherEncoding))
226
+ cipherChunks.push(cipher.final(cipherEncoding))
227
+
228
+ return cipherChunks.join("")
229
+ } catch (err) {
230
+ throw new YZHSDKHttpException(`${err}`)
231
+ }
232
+ }
233
+
234
+ // 返回处理结果
235
+ private async parseResponse(result: ResponseData, encryption?: boolean) {
236
+ if (result.status !== 200) {
237
+ const yzhError = new YZHSDKHttpException(result.statusText)
238
+ yzhError.httpCode = result.status
239
+ throw yzhError
240
+ } else {
241
+ // httpcode 200
242
+ const { data: axiosData } = result
243
+ let response = axiosData
244
+ // 需解密
245
+ if (encryption) {
246
+ response = { ...response, data: this.decryption(response.data) }
247
+ }
248
+ return response
249
+ }
250
+ }
251
+
252
+ /**
253
+ * 3DES 解密数据
254
+ * @param ciphertext
255
+ * @returns 明文数据
256
+ */
257
+ decryption = (ciphertext: string) => {
258
+ try {
259
+ const iv = this.des3_key.slice(0, 8)
260
+ const cipherChunks = []
261
+ const decipher = crypto.createDecipheriv("des-ede3-cbc", this.des3_key, iv)
262
+ decipher.setAutoPadding(true)
263
+ cipherChunks.push(decipher.update(ciphertext, cipherEncoding, clearEncoding))
264
+ cipherChunks.push(decipher.final(clearEncoding))
265
+ return JSON.parse(cipherChunks.join(""))
266
+ } catch (err) {
267
+ throw new YZHSDKHttpException(`${err}`)
268
+ }
269
+ }
270
+
271
+ /**
272
+ * 验签
273
+ * @param {string} data 返回的数据
274
+ * @param {string} mess 返回的随机字符串
275
+ * @param {string} timestamp 返回的时间戳
276
+ * @param {string} sign 返回的签名
277
+ * @returns {boolean} true:验签成功;false:验签失败
278
+ */
279
+ verifyRSASHA256 = (data: string, mess: string, timestamp: string, sign: string) => {
280
+ try {
281
+ const plaintext = `data=${data}&mess=${mess}&timestamp=${timestamp}&key=${this.app_key}`
282
+ const verify = crypto.createVerify("RSA-SHA256")
283
+ verify.update(plaintext)
284
+ return verify.verify(this.yzh_public_key, sign, cipherEncoding)
285
+ } catch (err) {
286
+ throw new YZHSDKHttpException(`${err}`)
287
+ }
288
+ }
289
+
290
+ verifyHmacSHA256 = (data: string, mess: string, timestamp: string, sign: string) => {
291
+ try {
292
+ const plaintext = `data=${data}&mess=${mess}&timestamp=${timestamp}&key=${this.app_key}`
293
+ const hmac = crypto.createHmac("sha256", this.app_key)
294
+ hmac.update(plaintext)
295
+ return hmac.digest("hex") === sign
296
+ } catch (err) {
297
+ throw new YZHSDKHttpException(`${err}`)
298
+ }
299
+ }
300
+
301
+ /**
302
+ * 文件密码解密
303
+ * @param ciphertextbase64
304
+ * @returns 解密后的密码
305
+ */
306
+ filePassWordDecryption = (ciphertextbase64: string) => {
307
+ try {
308
+ const buff = Buffer.from(ciphertextbase64, "base64")
309
+
310
+ const decrypted = crypto.privateDecrypt(
311
+ {
312
+ key: this.private_key,
313
+ padding: crypto.constants.RSA_PKCS1_PADDING,
314
+ },
315
+ buff
316
+ )
317
+ return decrypted.toString("utf8")
318
+ } catch (err) {
319
+ throw new YZHSDKHttpException(`${err}`)
320
+ }
321
+ }
322
+
323
+ /**
324
+ * 验签+解密
325
+ * @param responseData 回调返回对象
326
+ * @returns
327
+ */
328
+ notifyDecoder: (params: {
329
+ /** 返回的数据 */
330
+ data: string
331
+ /** 返回的随机字符串 */
332
+ mess: string
333
+ /** 返回的时间戳 */
334
+ timestamp: string
335
+ /** 返回的签名 */
336
+ sign: string
337
+ }) => {
338
+ /** 验签结果 */
339
+ result: boolean
340
+ /** 解密结果 */
341
+ plaintext: object
342
+ } = (responseData) => {
343
+ const notifyDecoderResult = (data: string, mess: string, timestamp: string, sign: string) => {
344
+ const verifyMap = {
345
+ rsa: this.verifyRSASHA256,
346
+ sha256: this.verifyHmacSHA256,
347
+ }
348
+ // 验签结果 boolean
349
+ const verifyResult = verifyMap[this.sign_type](data, mess, timestamp, sign)
350
+ let plaintext = {}
351
+ if (verifyResult) {
352
+ plaintext = this.decryption(data)
353
+ }
354
+ return {
355
+ result: verifyResult,
356
+ plaintext,
357
+ }
358
+ }
359
+ const { data, mess, timestamp, sign } = responseData ?? {}
360
+ if (data && mess && timestamp && sign) {
361
+ return notifyDecoderResult(data, mess, timestamp, sign)
362
+ }
363
+ return { result: false, plaintext: "" }
364
+ }
365
+ }
366
+
367
+ export default YZHClient
@@ -0,0 +1,32 @@
1
+ export default class YZHSDKHttpException extends Error {
2
+ // 请求 ID
3
+ request_id: string
4
+ // HTTP 状态码
5
+ httpCode?: number
6
+ // 接口返回状态码
7
+ code?: string
8
+
9
+ constructor(error: string, request_id = "") {
10
+ super(error)
11
+ this.request_id = request_id || ""
12
+ }
13
+
14
+ getMessage(): string {
15
+ return this.message
16
+ }
17
+
18
+ getRequestId(): string {
19
+ return this.request_id
20
+ }
21
+
22
+ toString(): string {
23
+ return `[yzh_sdk_exception] ${
24
+ this.code && `code:${this.code}`
25
+ } requestId:${this.getRequestId()} message:${this.getMessage()}`
26
+ }
27
+ toLocaleString(): string {
28
+ return `[yzh_sdk_exception] ${
29
+ this.code && `code:${this.code}`
30
+ } requestId:${this.getRequestId()} message:${this.getMessage()}`
31
+ }
32
+ }
@@ -0,0 +1,57 @@
1
+ import axios from "axios"
2
+ import * as urlencode from "urlencode"
3
+ import * as pkg from "../../../package.json"
4
+ import * as child_process from "child_process"
5
+ const BASE_URL = "https://api-service.yunzhanghu.com/"
6
+
7
+ const getInstance = (
8
+ config: { request_id?: string; dealer_id?: string; base_url?: string } = {}
9
+ ) => {
10
+ const instance = axios.create({
11
+ baseURL: config.base_url || BASE_URL,
12
+ headers: {
13
+ "request-id": config?.request_id,
14
+ "dealer-id": config?.dealer_id,
15
+ "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
16
+ "User-Agent": `yunzhanghu-sdk-nodejs/${pkg.version}/${child_process
17
+ .execSync("uname -m -r -s")
18
+ .toString("utf-8")
19
+ .replace("\n", "")}/${process.version}`,
20
+ },
21
+ timeout: 30 * 1000,
22
+ })
23
+
24
+ // 拦截器
25
+ instance.interceptors.request.use(function (config) {
26
+ // URL Encode
27
+ if (config.method === "get") {
28
+ const { params: urlData } = config
29
+ const { data, sign, ...resData } = urlData
30
+ config.data = {
31
+ data: urlencode(data),
32
+ sign: urlencode(sign),
33
+ ...resData,
34
+ }
35
+ }
36
+ return config
37
+ })
38
+
39
+ instance.interceptors.response.use(function (response) {
40
+ const { data } = response
41
+ if (data) {
42
+ const { request_id, requestID, ...resResponse } = data
43
+ if (request_id || requestID) {
44
+ response.data = {
45
+ ...resResponse,
46
+ request_id: request_id || requestID,
47
+ }
48
+ }
49
+ }
50
+
51
+ return response
52
+ })
53
+
54
+ return instance
55
+ }
56
+
57
+ export default getInstance
@@ -0,0 +1,18 @@
1
+ import YZHclient from "../client"
2
+
3
+ export class Util extends YZHclient {
4
+ constructor(conf: {
5
+ dealer_id: string
6
+ broker_id: string
7
+ app_key: string
8
+ des3_key: string
9
+ private_key: string
10
+ yzh_public_key: string
11
+ sign_type: "rsa" | "sha256"
12
+ base_url?: string
13
+ }) {
14
+ super(conf)
15
+ }
16
+ }
17
+
18
+ export default Util
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./services"
@@ -0,0 +1,125 @@
1
+ import YZHclient from "../../common/client";
2
+
3
+ /** ApiUseSignContractRequest 获取协议预览 URL 请求 */
4
+ interface ApiUseSignContractRequest {
5
+ /** 平台企业 ID */
6
+ dealer_id: string
7
+ /** 综合服务主体 ID */
8
+ broker_id: string
9
+ }
10
+
11
+ /** ApiUseSignContractResponse 获取协议预览 URL 返回 */
12
+ interface ApiUseSignContractResponse {
13
+ /** 预览跳转 URL */
14
+ url: string
15
+ /** 协议名称 */
16
+ title: string
17
+ }
18
+
19
+ /** ApiUserSignRequest 用户签约请求 */
20
+ interface ApiUserSignRequest {
21
+ /** 综合服务主体 ID */
22
+ broker_id: string
23
+ /** 平台企业 ID */
24
+ dealer_id: string
25
+ /** 姓名 */
26
+ real_name: string
27
+ /** 证件号码 */
28
+ id_card: string
29
+ /** 证件类型 idcard:身份证 passport:护照 mtphkm:港澳居民来往内地通行证 mtpt:台湾居民往来大陆通行证 rphkm:中华人民共和国港澳居民居住证 rpt:中华人民共和国台湾居民居住证 fpr:外国人永久居留身份证 ffwp:中华人民共和国外国人就业许可证书 */
30
+ card_type: string
31
+ }
32
+
33
+ /** ApiUserSignResponse 用户签约返回 */
34
+ interface ApiUserSignResponse {
35
+ /** 是否签约成功 */
36
+ status: string
37
+ }
38
+
39
+ /** GetApiUserSignStatusRequest 获取用户签约状态请求 */
40
+ interface GetApiUserSignStatusRequest {
41
+ /** 平台企业 ID */
42
+ dealer_id: string
43
+ /** 综合服务主体 ID */
44
+ broker_id: string
45
+ /** 姓名 */
46
+ real_name: string
47
+ /** 证件号码 */
48
+ id_card: string
49
+ }
50
+
51
+ /** GetApiUserSignStatusResponse 获取用户签约状态返回 */
52
+ interface GetApiUserSignStatusResponse {
53
+ /** 签约时间 */
54
+ signed_at: string
55
+ /** 用户签约状态 */
56
+ status: string
57
+ }
58
+
59
+ /** ApiUserSignReleaseRequest 用户解约(测试账号专用接口)请求 */
60
+ interface ApiUserSignReleaseRequest {
61
+ /** 综合服务主体 ID */
62
+ broker_id: string
63
+ /** 平台企业 ID */
64
+ dealer_id: string
65
+ /** 姓名 */
66
+ real_name: string
67
+ /** 证件号码 */
68
+ id_card: string
69
+ /** 证件类型 idcard:身份证 passport:护照 mtphkm:港澳居民来往内地通行证 mtpt:台湾居民往来大陆通行证 rphkm:中华人民共和国港澳居民居住证 rpt:中华人民共和国台湾居民居住证 fpr:外国人永久居留身份证 ffwp:中华人民共和国外国人就业许可证书 */
70
+ card_type: string
71
+ }
72
+
73
+ /** ApiUserSignReleaseResponse 用户解约(测试账号专用接口)返回 */
74
+ interface ApiUserSignReleaseResponse {
75
+ /** 是否解约成功 */
76
+ status: string
77
+ }
78
+
79
+ export class Apiusersign extends YZHclient {
80
+ constructor(conf: {
81
+ dealer_id: string
82
+ broker_id: string
83
+ app_key: string
84
+ des3_key: string
85
+ private_key: string
86
+ yzh_public_key: string
87
+ sign_type: "rsa" | "sha256"
88
+ base_url?: string
89
+ }) {
90
+ super(conf)
91
+ }
92
+
93
+ // ApiUseSignContract 获取协议预览 URL
94
+ async ApiUseSignContract(
95
+ req: ApiUseSignContractRequest,
96
+ cb?: (error: null | string, rep: ApiUseSignContractResponse) => void
97
+ ): Promise<ApiUseSignContractResponse> {
98
+ return this.request("get", "/api/sign/v1/user/contract", req, { encryption: false }, cb)
99
+ }
100
+
101
+ // ApiUserSign 用户签约
102
+ async ApiUserSign(
103
+ req: ApiUserSignRequest,
104
+ cb?: (error: null | string, rep: ApiUserSignResponse) => void
105
+ ): Promise<ApiUserSignResponse> {
106
+ return this.request("post", "/api/sign/v1/user/sign", req, { encryption: false }, cb)
107
+ }
108
+
109
+ // GetApiUserSignStatus 获取用户签约状态
110
+ async GetApiUserSignStatus(
111
+ req: GetApiUserSignStatusRequest,
112
+ cb?: (error: null | string, rep: GetApiUserSignStatusResponse) => void
113
+ ): Promise<GetApiUserSignStatusResponse> {
114
+ return this.request("get", "/api/sign/v1/user/status", req, { encryption: false }, cb)
115
+ }
116
+
117
+ // ApiUserSignRelease 用户解约(测试账号专用接口)
118
+ async ApiUserSignRelease(
119
+ req: ApiUserSignReleaseRequest,
120
+ cb?: (error: null | string, rep: ApiUserSignReleaseResponse) => void
121
+ ): Promise<ApiUserSignReleaseResponse> {
122
+ return this.request("post", "/api/sign/v1/user/release", req, { encryption: false }, cb)
123
+ }
124
+
125
+ }