@nocobase/plugin-verification 1.5.0-alpha.1 → 1.5.0-alpha.4

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 (18) hide show
  1. package/dist/externalVersion.js +6 -6
  2. package/dist/node_modules/@alicloud/dysmsapi20170525/dist/client.js +2 -2
  3. package/dist/node_modules/@alicloud/dysmsapi20170525/package.json +1 -1
  4. package/dist/node_modules/@alicloud/openapi-client/dist/client.d.ts +44 -0
  5. package/dist/node_modules/@alicloud/openapi-client/dist/client.js +2 -1
  6. package/dist/node_modules/@alicloud/openapi-client/package.json +1 -1
  7. package/dist/node_modules/@alicloud/openapi-client/src/client.ts +429 -51
  8. package/dist/node_modules/@alicloud/tea-util/package.json +1 -1
  9. package/dist/node_modules/tencentcloud-sdk-nodejs/package.json +1 -1
  10. package/package.json +3 -3
  11. package/dist/node_modules/@alicloud/dysmsapi20170525/node_modules/@alicloud/openapi-client/dist/client.d.ts +0 -291
  12. package/dist/node_modules/@alicloud/dysmsapi20170525/node_modules/@alicloud/openapi-client/dist/client.js +0 -1192
  13. package/dist/node_modules/@alicloud/dysmsapi20170525/node_modules/@alicloud/openapi-client/package.json +0 -37
  14. package/dist/node_modules/@alicloud/dysmsapi20170525/node_modules/@alicloud/openapi-client/src/client.ts +0 -1389
  15. /package/dist/node_modules/@alicloud/{dysmsapi20170525/node_modules/@alicloud/openapi-client → openapi-client}/node_modules/@alicloud/openapi-util/dist/client.d.ts +0 -0
  16. /package/dist/node_modules/@alicloud/{dysmsapi20170525/node_modules/@alicloud/openapi-client → openapi-client}/node_modules/@alicloud/openapi-util/dist/client.js +0 -0
  17. /package/dist/node_modules/@alicloud/{dysmsapi20170525/node_modules/@alicloud/openapi-client → openapi-client}/node_modules/@alicloud/openapi-util/package.json +0 -0
  18. /package/dist/node_modules/@alicloud/{dysmsapi20170525/node_modules/@alicloud/openapi-client → openapi-client}/node_modules/@alicloud/openapi-util/src/client.ts +0 -0
@@ -1,1192 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- var __importDefault = (this && this.__importDefault) || function (mod) {
22
- return (mod && mod.__esModule) ? mod : { "default": mod };
23
- };
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.Params = exports.OpenApiRequest = exports.Config = exports.GlobalParameters = void 0;
26
- // This file is auto-generated, don't edit it
27
- /**
28
- * This is for OpenApi SDK
29
- */
30
- const tea_util_1 = __importDefault(require("@alicloud/tea-util"));
31
- const credentials_1 = __importStar(require("@alicloud/credentials")), $Credential = credentials_1;
32
- const openapi_util_1 = __importDefault(require("@alicloud/openapi-util"));
33
- const $SPI = __importStar(require("@alicloud/gateway-spi"));
34
- const tea_xml_1 = __importDefault(require("@alicloud/tea-xml"));
35
- const $tea = __importStar(require("@alicloud/tea-typescript"));
36
- class GlobalParameters extends $tea.Model {
37
- constructor(map) {
38
- super(map);
39
- }
40
- static names() {
41
- return {
42
- headers: 'headers',
43
- queries: 'queries',
44
- };
45
- }
46
- static types() {
47
- return {
48
- headers: { 'type': 'map', 'keyType': 'string', 'valueType': 'string' },
49
- queries: { 'type': 'map', 'keyType': 'string', 'valueType': 'string' },
50
- };
51
- }
52
- }
53
- exports.GlobalParameters = GlobalParameters;
54
- /**
55
- * Model for initing client
56
- */
57
- class Config extends $tea.Model {
58
- constructor(map) {
59
- super(map);
60
- }
61
- static names() {
62
- return {
63
- accessKeyId: 'accessKeyId',
64
- accessKeySecret: 'accessKeySecret',
65
- securityToken: 'securityToken',
66
- protocol: 'protocol',
67
- method: 'method',
68
- regionId: 'regionId',
69
- readTimeout: 'readTimeout',
70
- connectTimeout: 'connectTimeout',
71
- httpProxy: 'httpProxy',
72
- httpsProxy: 'httpsProxy',
73
- credential: 'credential',
74
- endpoint: 'endpoint',
75
- noProxy: 'noProxy',
76
- maxIdleConns: 'maxIdleConns',
77
- network: 'network',
78
- userAgent: 'userAgent',
79
- suffix: 'suffix',
80
- socks5Proxy: 'socks5Proxy',
81
- socks5NetWork: 'socks5NetWork',
82
- endpointType: 'endpointType',
83
- openPlatformEndpoint: 'openPlatformEndpoint',
84
- type: 'type',
85
- signatureVersion: 'signatureVersion',
86
- signatureAlgorithm: 'signatureAlgorithm',
87
- globalParameters: 'globalParameters',
88
- key: 'key',
89
- cert: 'cert',
90
- ca: 'ca',
91
- };
92
- }
93
- static types() {
94
- return {
95
- accessKeyId: 'string',
96
- accessKeySecret: 'string',
97
- securityToken: 'string',
98
- protocol: 'string',
99
- method: 'string',
100
- regionId: 'string',
101
- readTimeout: 'number',
102
- connectTimeout: 'number',
103
- httpProxy: 'string',
104
- httpsProxy: 'string',
105
- credential: credentials_1.default,
106
- endpoint: 'string',
107
- noProxy: 'string',
108
- maxIdleConns: 'number',
109
- network: 'string',
110
- userAgent: 'string',
111
- suffix: 'string',
112
- socks5Proxy: 'string',
113
- socks5NetWork: 'string',
114
- endpointType: 'string',
115
- openPlatformEndpoint: 'string',
116
- type: 'string',
117
- signatureVersion: 'string',
118
- signatureAlgorithm: 'string',
119
- globalParameters: GlobalParameters,
120
- key: 'string',
121
- cert: 'string',
122
- ca: 'string',
123
- };
124
- }
125
- }
126
- exports.Config = Config;
127
- class OpenApiRequest extends $tea.Model {
128
- constructor(map) {
129
- super(map);
130
- }
131
- static names() {
132
- return {
133
- headers: 'headers',
134
- query: 'query',
135
- body: 'body',
136
- stream: 'stream',
137
- hostMap: 'hostMap',
138
- endpointOverride: 'endpointOverride',
139
- };
140
- }
141
- static types() {
142
- return {
143
- headers: { 'type': 'map', 'keyType': 'string', 'valueType': 'string' },
144
- query: { 'type': 'map', 'keyType': 'string', 'valueType': 'string' },
145
- body: 'any',
146
- stream: 'Readable',
147
- hostMap: { 'type': 'map', 'keyType': 'string', 'valueType': 'string' },
148
- endpointOverride: 'string',
149
- };
150
- }
151
- }
152
- exports.OpenApiRequest = OpenApiRequest;
153
- class Params extends $tea.Model {
154
- constructor(map) {
155
- super(map);
156
- }
157
- static names() {
158
- return {
159
- action: 'action',
160
- version: 'version',
161
- protocol: 'protocol',
162
- pathname: 'pathname',
163
- method: 'method',
164
- authType: 'authType',
165
- bodyType: 'bodyType',
166
- reqBodyType: 'reqBodyType',
167
- style: 'style',
168
- };
169
- }
170
- static types() {
171
- return {
172
- action: 'string',
173
- version: 'string',
174
- protocol: 'string',
175
- pathname: 'string',
176
- method: 'string',
177
- authType: 'string',
178
- bodyType: 'string',
179
- reqBodyType: 'string',
180
- style: 'string',
181
- };
182
- }
183
- }
184
- exports.Params = Params;
185
- class Client {
186
- /**
187
- * Init client with Config
188
- * @param config config contains the necessary information to create a client
189
- */
190
- constructor(config) {
191
- if (tea_util_1.default.isUnset(config)) {
192
- throw $tea.newError({
193
- code: "ParameterMissing",
194
- message: "'config' can not be unset",
195
- });
196
- }
197
- if (!tea_util_1.default.empty(config.accessKeyId) && !tea_util_1.default.empty(config.accessKeySecret)) {
198
- if (!tea_util_1.default.empty(config.securityToken)) {
199
- config.type = "sts";
200
- }
201
- else {
202
- config.type = "access_key";
203
- }
204
- let credentialConfig = new $Credential.Config({
205
- accessKeyId: config.accessKeyId,
206
- type: config.type,
207
- accessKeySecret: config.accessKeySecret,
208
- });
209
- credentialConfig.securityToken = config.securityToken;
210
- this._credential = new credentials_1.default(credentialConfig);
211
- }
212
- else if (!tea_util_1.default.isUnset(config.credential)) {
213
- this._credential = config.credential;
214
- }
215
- this._endpoint = config.endpoint;
216
- this._endpointType = config.endpointType;
217
- this._network = config.network;
218
- this._suffix = config.suffix;
219
- this._protocol = config.protocol;
220
- this._method = config.method;
221
- this._regionId = config.regionId;
222
- this._userAgent = config.userAgent;
223
- this._readTimeout = config.readTimeout;
224
- this._connectTimeout = config.connectTimeout;
225
- this._httpProxy = config.httpProxy;
226
- this._httpsProxy = config.httpsProxy;
227
- this._noProxy = config.noProxy;
228
- this._socks5Proxy = config.socks5Proxy;
229
- this._socks5NetWork = config.socks5NetWork;
230
- this._maxIdleConns = config.maxIdleConns;
231
- this._signatureVersion = config.signatureVersion;
232
- this._signatureAlgorithm = config.signatureAlgorithm;
233
- this._globalParameters = config.globalParameters;
234
- this._key = config.key;
235
- this._cert = config.cert;
236
- this._ca = config.ca;
237
- }
238
- /**
239
- * Encapsulate the request and invoke the network
240
- * @param action api name
241
- * @param version product version
242
- * @param protocol http or https
243
- * @param method e.g. GET
244
- * @param authType authorization type e.g. AK
245
- * @param bodyType response body type e.g. String
246
- * @param request object of OpenApiRequest
247
- * @param runtime which controls some details of call api, such as retry times
248
- * @return the response
249
- */
250
- async doRPCRequest(action, version, protocol, method, authType, bodyType, request, runtime) {
251
- let _runtime = {
252
- timeouted: "retry",
253
- key: tea_util_1.default.defaultString(runtime.key, this._key),
254
- cert: tea_util_1.default.defaultString(runtime.cert, this._cert),
255
- ca: tea_util_1.default.defaultString(runtime.ca, this._ca),
256
- readTimeout: tea_util_1.default.defaultNumber(runtime.readTimeout, this._readTimeout),
257
- connectTimeout: tea_util_1.default.defaultNumber(runtime.connectTimeout, this._connectTimeout),
258
- httpProxy: tea_util_1.default.defaultString(runtime.httpProxy, this._httpProxy),
259
- httpsProxy: tea_util_1.default.defaultString(runtime.httpsProxy, this._httpsProxy),
260
- noProxy: tea_util_1.default.defaultString(runtime.noProxy, this._noProxy),
261
- socks5Proxy: tea_util_1.default.defaultString(runtime.socks5Proxy, this._socks5Proxy),
262
- socks5NetWork: tea_util_1.default.defaultString(runtime.socks5NetWork, this._socks5NetWork),
263
- maxIdleConns: tea_util_1.default.defaultNumber(runtime.maxIdleConns, this._maxIdleConns),
264
- retry: {
265
- retryable: runtime.autoretry,
266
- maxAttempts: tea_util_1.default.defaultNumber(runtime.maxAttempts, 3),
267
- },
268
- backoff: {
269
- policy: tea_util_1.default.defaultString(runtime.backoffPolicy, "no"),
270
- period: tea_util_1.default.defaultNumber(runtime.backoffPeriod, 1),
271
- },
272
- ignoreSSL: runtime.ignoreSSL,
273
- };
274
- let _lastRequest = null;
275
- let _now = Date.now();
276
- let _retryTimes = 0;
277
- while ($tea.allowRetry(_runtime['retry'], _retryTimes, _now)) {
278
- if (_retryTimes > 0) {
279
- let _backoffTime = $tea.getBackoffTime(_runtime['backoff'], _retryTimes);
280
- if (_backoffTime > 0) {
281
- await $tea.sleep(_backoffTime);
282
- }
283
- }
284
- _retryTimes = _retryTimes + 1;
285
- try {
286
- let request_ = new $tea.Request();
287
- request_.protocol = tea_util_1.default.defaultString(this._protocol, protocol);
288
- request_.method = method;
289
- request_.pathname = "/";
290
- let globalQueries = {};
291
- let globalHeaders = {};
292
- if (!tea_util_1.default.isUnset(this._globalParameters)) {
293
- let globalParams = this._globalParameters;
294
- if (!tea_util_1.default.isUnset(globalParams.queries)) {
295
- globalQueries = globalParams.queries;
296
- }
297
- if (!tea_util_1.default.isUnset(globalParams.headers)) {
298
- globalHeaders = globalParams.headers;
299
- }
300
- }
301
- request_.query = Object.assign(Object.assign({ Action: action, Format: "json", Version: version, Timestamp: openapi_util_1.default.getTimestamp(), SignatureNonce: tea_util_1.default.getNonce() }, globalQueries), request.query);
302
- let headers = this.getRpcHeaders();
303
- if (tea_util_1.default.isUnset(headers)) {
304
- // endpoint is setted in product client
305
- request_.headers = Object.assign({ host: this._endpoint, 'x-acs-version': version, 'x-acs-action': action, 'user-agent': this.getUserAgent() }, globalHeaders);
306
- }
307
- else {
308
- request_.headers = Object.assign(Object.assign({ host: this._endpoint, 'x-acs-version': version, 'x-acs-action': action, 'user-agent': this.getUserAgent() }, globalHeaders), headers);
309
- }
310
- if (!tea_util_1.default.isUnset(request.body)) {
311
- let m = tea_util_1.default.assertAsMap(request.body);
312
- let tmp = tea_util_1.default.anyifyMapValue(openapi_util_1.default.query(m));
313
- request_.body = new $tea.BytesReadable(tea_util_1.default.toFormString(tmp));
314
- request_.headers["content-type"] = "application/x-www-form-urlencoded";
315
- }
316
- if (!tea_util_1.default.equalString(authType, "Anonymous")) {
317
- let accessKeyId = await this.getAccessKeyId();
318
- let accessKeySecret = await this.getAccessKeySecret();
319
- let securityToken = await this.getSecurityToken();
320
- if (!tea_util_1.default.empty(securityToken)) {
321
- request_.query["SecurityToken"] = securityToken;
322
- }
323
- request_.query["SignatureMethod"] = "HMAC-SHA1";
324
- request_.query["SignatureVersion"] = "1.0";
325
- request_.query["AccessKeyId"] = accessKeyId;
326
- let t = null;
327
- if (!tea_util_1.default.isUnset(request.body)) {
328
- t = tea_util_1.default.assertAsMap(request.body);
329
- }
330
- let signedParam = Object.assign(Object.assign({}, request_.query), openapi_util_1.default.query(t));
331
- request_.query["Signature"] = openapi_util_1.default.getRPCSignature(signedParam, request_.method, accessKeySecret);
332
- }
333
- _lastRequest = request_;
334
- let response_ = await $tea.doAction(request_, _runtime);
335
- if (tea_util_1.default.is4xx(response_.statusCode) || tea_util_1.default.is5xx(response_.statusCode)) {
336
- let _res = await tea_util_1.default.readAsJSON(response_.body);
337
- let err = tea_util_1.default.assertAsMap(_res);
338
- let requestId = Client.defaultAny(err["RequestId"], err["requestId"]);
339
- err["statusCode"] = response_.statusCode;
340
- throw $tea.newError({
341
- code: `${Client.defaultAny(err["Code"], err["code"])}`,
342
- message: `code: ${response_.statusCode}, ${Client.defaultAny(err["Message"], err["message"])} request id: ${requestId}`,
343
- data: err,
344
- description: `${Client.defaultAny(err["Description"], err["description"])}`,
345
- accessDeniedDetail: Client.defaultAny(err["AccessDeniedDetail"], err["accessDeniedDetail"]),
346
- });
347
- }
348
- if (tea_util_1.default.equalString(bodyType, "binary")) {
349
- let resp = {
350
- body: response_.body,
351
- headers: response_.headers,
352
- statusCode: response_.statusCode,
353
- };
354
- return resp;
355
- }
356
- else if (tea_util_1.default.equalString(bodyType, "byte")) {
357
- let byt = await tea_util_1.default.readAsBytes(response_.body);
358
- return {
359
- body: byt,
360
- headers: response_.headers,
361
- statusCode: response_.statusCode,
362
- };
363
- }
364
- else if (tea_util_1.default.equalString(bodyType, "string")) {
365
- let str = await tea_util_1.default.readAsString(response_.body);
366
- return {
367
- body: str,
368
- headers: response_.headers,
369
- statusCode: response_.statusCode,
370
- };
371
- }
372
- else if (tea_util_1.default.equalString(bodyType, "json")) {
373
- let obj = await tea_util_1.default.readAsJSON(response_.body);
374
- let res = tea_util_1.default.assertAsMap(obj);
375
- return {
376
- body: res,
377
- headers: response_.headers,
378
- statusCode: response_.statusCode,
379
- };
380
- }
381
- else if (tea_util_1.default.equalString(bodyType, "array")) {
382
- let arr = await tea_util_1.default.readAsJSON(response_.body);
383
- return {
384
- body: arr,
385
- headers: response_.headers,
386
- statusCode: response_.statusCode,
387
- };
388
- }
389
- else {
390
- return {
391
- headers: response_.headers,
392
- statusCode: response_.statusCode,
393
- };
394
- }
395
- }
396
- catch (ex) {
397
- if ($tea.isRetryable(ex)) {
398
- continue;
399
- }
400
- throw ex;
401
- }
402
- }
403
- throw $tea.newUnretryableError(_lastRequest);
404
- }
405
- /**
406
- * Encapsulate the request and invoke the network
407
- * @param action api name
408
- * @param version product version
409
- * @param protocol http or https
410
- * @param method e.g. GET
411
- * @param authType authorization type e.g. AK
412
- * @param pathname pathname of every api
413
- * @param bodyType response body type e.g. String
414
- * @param request object of OpenApiRequest
415
- * @param runtime which controls some details of call api, such as retry times
416
- * @return the response
417
- */
418
- async doROARequest(action, version, protocol, method, authType, pathname, bodyType, request, runtime) {
419
- let _runtime = {
420
- timeouted: "retry",
421
- key: tea_util_1.default.defaultString(runtime.key, this._key),
422
- cert: tea_util_1.default.defaultString(runtime.cert, this._cert),
423
- ca: tea_util_1.default.defaultString(runtime.ca, this._ca),
424
- readTimeout: tea_util_1.default.defaultNumber(runtime.readTimeout, this._readTimeout),
425
- connectTimeout: tea_util_1.default.defaultNumber(runtime.connectTimeout, this._connectTimeout),
426
- httpProxy: tea_util_1.default.defaultString(runtime.httpProxy, this._httpProxy),
427
- httpsProxy: tea_util_1.default.defaultString(runtime.httpsProxy, this._httpsProxy),
428
- noProxy: tea_util_1.default.defaultString(runtime.noProxy, this._noProxy),
429
- socks5Proxy: tea_util_1.default.defaultString(runtime.socks5Proxy, this._socks5Proxy),
430
- socks5NetWork: tea_util_1.default.defaultString(runtime.socks5NetWork, this._socks5NetWork),
431
- maxIdleConns: tea_util_1.default.defaultNumber(runtime.maxIdleConns, this._maxIdleConns),
432
- retry: {
433
- retryable: runtime.autoretry,
434
- maxAttempts: tea_util_1.default.defaultNumber(runtime.maxAttempts, 3),
435
- },
436
- backoff: {
437
- policy: tea_util_1.default.defaultString(runtime.backoffPolicy, "no"),
438
- period: tea_util_1.default.defaultNumber(runtime.backoffPeriod, 1),
439
- },
440
- ignoreSSL: runtime.ignoreSSL,
441
- };
442
- let _lastRequest = null;
443
- let _now = Date.now();
444
- let _retryTimes = 0;
445
- while ($tea.allowRetry(_runtime['retry'], _retryTimes, _now)) {
446
- if (_retryTimes > 0) {
447
- let _backoffTime = $tea.getBackoffTime(_runtime['backoff'], _retryTimes);
448
- if (_backoffTime > 0) {
449
- await $tea.sleep(_backoffTime);
450
- }
451
- }
452
- _retryTimes = _retryTimes + 1;
453
- try {
454
- let request_ = new $tea.Request();
455
- request_.protocol = tea_util_1.default.defaultString(this._protocol, protocol);
456
- request_.method = method;
457
- request_.pathname = pathname;
458
- let globalQueries = {};
459
- let globalHeaders = {};
460
- if (!tea_util_1.default.isUnset(this._globalParameters)) {
461
- let globalParams = this._globalParameters;
462
- if (!tea_util_1.default.isUnset(globalParams.queries)) {
463
- globalQueries = globalParams.queries;
464
- }
465
- if (!tea_util_1.default.isUnset(globalParams.headers)) {
466
- globalHeaders = globalParams.headers;
467
- }
468
- }
469
- request_.headers = Object.assign(Object.assign({ date: tea_util_1.default.getDateUTCString(), host: this._endpoint, accept: "application/json", 'x-acs-signature-nonce': tea_util_1.default.getNonce(), 'x-acs-signature-method': "HMAC-SHA1", 'x-acs-signature-version': "1.0", 'x-acs-version': version, 'x-acs-action': action, 'user-agent': tea_util_1.default.getUserAgent(this._userAgent) }, globalHeaders), request.headers);
470
- if (!tea_util_1.default.isUnset(request.body)) {
471
- request_.body = new $tea.BytesReadable(tea_util_1.default.toJSONString(request.body));
472
- request_.headers["content-type"] = "application/json; charset=utf-8";
473
- }
474
- request_.query = globalQueries;
475
- if (!tea_util_1.default.isUnset(request.query)) {
476
- request_.query = Object.assign(Object.assign({}, request_.query), request.query);
477
- }
478
- if (!tea_util_1.default.equalString(authType, "Anonymous")) {
479
- let accessKeyId = await this.getAccessKeyId();
480
- let accessKeySecret = await this.getAccessKeySecret();
481
- let securityToken = await this.getSecurityToken();
482
- if (!tea_util_1.default.empty(securityToken)) {
483
- request_.headers["x-acs-accesskey-id"] = accessKeyId;
484
- request_.headers["x-acs-security-token"] = securityToken;
485
- }
486
- let stringToSign = openapi_util_1.default.getStringToSign(request_);
487
- request_.headers["authorization"] = `acs ${accessKeyId}:${openapi_util_1.default.getROASignature(stringToSign, accessKeySecret)}`;
488
- }
489
- _lastRequest = request_;
490
- let response_ = await $tea.doAction(request_, _runtime);
491
- if (tea_util_1.default.equalNumber(response_.statusCode, 204)) {
492
- return {
493
- headers: response_.headers,
494
- };
495
- }
496
- if (tea_util_1.default.is4xx(response_.statusCode) || tea_util_1.default.is5xx(response_.statusCode)) {
497
- let _res = await tea_util_1.default.readAsJSON(response_.body);
498
- let err = tea_util_1.default.assertAsMap(_res);
499
- let requestId = Client.defaultAny(err["RequestId"], err["requestId"]);
500
- requestId = Client.defaultAny(requestId, err["requestid"]);
501
- err["statusCode"] = response_.statusCode;
502
- throw $tea.newError({
503
- code: `${Client.defaultAny(err["Code"], err["code"])}`,
504
- message: `code: ${response_.statusCode}, ${Client.defaultAny(err["Message"], err["message"])} request id: ${requestId}`,
505
- data: err,
506
- description: `${Client.defaultAny(err["Description"], err["description"])}`,
507
- accessDeniedDetail: Client.defaultAny(err["AccessDeniedDetail"], err["accessDeniedDetail"]),
508
- });
509
- }
510
- if (tea_util_1.default.equalString(bodyType, "binary")) {
511
- let resp = {
512
- body: response_.body,
513
- headers: response_.headers,
514
- statusCode: response_.statusCode,
515
- };
516
- return resp;
517
- }
518
- else if (tea_util_1.default.equalString(bodyType, "byte")) {
519
- let byt = await tea_util_1.default.readAsBytes(response_.body);
520
- return {
521
- body: byt,
522
- headers: response_.headers,
523
- statusCode: response_.statusCode,
524
- };
525
- }
526
- else if (tea_util_1.default.equalString(bodyType, "string")) {
527
- let str = await tea_util_1.default.readAsString(response_.body);
528
- return {
529
- body: str,
530
- headers: response_.headers,
531
- statusCode: response_.statusCode,
532
- };
533
- }
534
- else if (tea_util_1.default.equalString(bodyType, "json")) {
535
- let obj = await tea_util_1.default.readAsJSON(response_.body);
536
- let res = tea_util_1.default.assertAsMap(obj);
537
- return {
538
- body: res,
539
- headers: response_.headers,
540
- statusCode: response_.statusCode,
541
- };
542
- }
543
- else if (tea_util_1.default.equalString(bodyType, "array")) {
544
- let arr = await tea_util_1.default.readAsJSON(response_.body);
545
- return {
546
- body: arr,
547
- headers: response_.headers,
548
- statusCode: response_.statusCode,
549
- };
550
- }
551
- else {
552
- return {
553
- headers: response_.headers,
554
- statusCode: response_.statusCode,
555
- };
556
- }
557
- }
558
- catch (ex) {
559
- if ($tea.isRetryable(ex)) {
560
- continue;
561
- }
562
- throw ex;
563
- }
564
- }
565
- throw $tea.newUnretryableError(_lastRequest);
566
- }
567
- /**
568
- * Encapsulate the request and invoke the network with form body
569
- * @param action api name
570
- * @param version product version
571
- * @param protocol http or https
572
- * @param method e.g. GET
573
- * @param authType authorization type e.g. AK
574
- * @param pathname pathname of every api
575
- * @param bodyType response body type e.g. String
576
- * @param request object of OpenApiRequest
577
- * @param runtime which controls some details of call api, such as retry times
578
- * @return the response
579
- */
580
- async doROARequestWithForm(action, version, protocol, method, authType, pathname, bodyType, request, runtime) {
581
- let _runtime = {
582
- timeouted: "retry",
583
- key: tea_util_1.default.defaultString(runtime.key, this._key),
584
- cert: tea_util_1.default.defaultString(runtime.cert, this._cert),
585
- ca: tea_util_1.default.defaultString(runtime.ca, this._ca),
586
- readTimeout: tea_util_1.default.defaultNumber(runtime.readTimeout, this._readTimeout),
587
- connectTimeout: tea_util_1.default.defaultNumber(runtime.connectTimeout, this._connectTimeout),
588
- httpProxy: tea_util_1.default.defaultString(runtime.httpProxy, this._httpProxy),
589
- httpsProxy: tea_util_1.default.defaultString(runtime.httpsProxy, this._httpsProxy),
590
- noProxy: tea_util_1.default.defaultString(runtime.noProxy, this._noProxy),
591
- socks5Proxy: tea_util_1.default.defaultString(runtime.socks5Proxy, this._socks5Proxy),
592
- socks5NetWork: tea_util_1.default.defaultString(runtime.socks5NetWork, this._socks5NetWork),
593
- maxIdleConns: tea_util_1.default.defaultNumber(runtime.maxIdleConns, this._maxIdleConns),
594
- retry: {
595
- retryable: runtime.autoretry,
596
- maxAttempts: tea_util_1.default.defaultNumber(runtime.maxAttempts, 3),
597
- },
598
- backoff: {
599
- policy: tea_util_1.default.defaultString(runtime.backoffPolicy, "no"),
600
- period: tea_util_1.default.defaultNumber(runtime.backoffPeriod, 1),
601
- },
602
- ignoreSSL: runtime.ignoreSSL,
603
- };
604
- let _lastRequest = null;
605
- let _now = Date.now();
606
- let _retryTimes = 0;
607
- while ($tea.allowRetry(_runtime['retry'], _retryTimes, _now)) {
608
- if (_retryTimes > 0) {
609
- let _backoffTime = $tea.getBackoffTime(_runtime['backoff'], _retryTimes);
610
- if (_backoffTime > 0) {
611
- await $tea.sleep(_backoffTime);
612
- }
613
- }
614
- _retryTimes = _retryTimes + 1;
615
- try {
616
- let request_ = new $tea.Request();
617
- request_.protocol = tea_util_1.default.defaultString(this._protocol, protocol);
618
- request_.method = method;
619
- request_.pathname = pathname;
620
- let globalQueries = {};
621
- let globalHeaders = {};
622
- if (!tea_util_1.default.isUnset(this._globalParameters)) {
623
- let globalParams = this._globalParameters;
624
- if (!tea_util_1.default.isUnset(globalParams.queries)) {
625
- globalQueries = globalParams.queries;
626
- }
627
- if (!tea_util_1.default.isUnset(globalParams.headers)) {
628
- globalHeaders = globalParams.headers;
629
- }
630
- }
631
- request_.headers = Object.assign(Object.assign({ date: tea_util_1.default.getDateUTCString(), host: this._endpoint, accept: "application/json", 'x-acs-signature-nonce': tea_util_1.default.getNonce(), 'x-acs-signature-method': "HMAC-SHA1", 'x-acs-signature-version': "1.0", 'x-acs-version': version, 'x-acs-action': action, 'user-agent': tea_util_1.default.getUserAgent(this._userAgent) }, globalHeaders), request.headers);
632
- if (!tea_util_1.default.isUnset(request.body)) {
633
- let m = tea_util_1.default.assertAsMap(request.body);
634
- request_.body = new $tea.BytesReadable(openapi_util_1.default.toForm(m));
635
- request_.headers["content-type"] = "application/x-www-form-urlencoded";
636
- }
637
- request_.query = globalQueries;
638
- if (!tea_util_1.default.isUnset(request.query)) {
639
- request_.query = Object.assign(Object.assign({}, request_.query), request.query);
640
- }
641
- if (!tea_util_1.default.equalString(authType, "Anonymous")) {
642
- let accessKeyId = await this.getAccessKeyId();
643
- let accessKeySecret = await this.getAccessKeySecret();
644
- let securityToken = await this.getSecurityToken();
645
- if (!tea_util_1.default.empty(securityToken)) {
646
- request_.headers["x-acs-accesskey-id"] = accessKeyId;
647
- request_.headers["x-acs-security-token"] = securityToken;
648
- }
649
- let stringToSign = openapi_util_1.default.getStringToSign(request_);
650
- request_.headers["authorization"] = `acs ${accessKeyId}:${openapi_util_1.default.getROASignature(stringToSign, accessKeySecret)}`;
651
- }
652
- _lastRequest = request_;
653
- let response_ = await $tea.doAction(request_, _runtime);
654
- if (tea_util_1.default.equalNumber(response_.statusCode, 204)) {
655
- return {
656
- headers: response_.headers,
657
- };
658
- }
659
- if (tea_util_1.default.is4xx(response_.statusCode) || tea_util_1.default.is5xx(response_.statusCode)) {
660
- let _res = await tea_util_1.default.readAsJSON(response_.body);
661
- let err = tea_util_1.default.assertAsMap(_res);
662
- err["statusCode"] = response_.statusCode;
663
- throw $tea.newError({
664
- code: `${Client.defaultAny(err["Code"], err["code"])}`,
665
- message: `code: ${response_.statusCode}, ${Client.defaultAny(err["Message"], err["message"])} request id: ${Client.defaultAny(err["RequestId"], err["requestId"])}`,
666
- data: err,
667
- description: `${Client.defaultAny(err["Description"], err["description"])}`,
668
- accessDeniedDetail: Client.defaultAny(err["AccessDeniedDetail"], err["accessDeniedDetail"]),
669
- });
670
- }
671
- if (tea_util_1.default.equalString(bodyType, "binary")) {
672
- let resp = {
673
- body: response_.body,
674
- headers: response_.headers,
675
- statusCode: response_.statusCode,
676
- };
677
- return resp;
678
- }
679
- else if (tea_util_1.default.equalString(bodyType, "byte")) {
680
- let byt = await tea_util_1.default.readAsBytes(response_.body);
681
- return {
682
- body: byt,
683
- headers: response_.headers,
684
- statusCode: response_.statusCode,
685
- };
686
- }
687
- else if (tea_util_1.default.equalString(bodyType, "string")) {
688
- let str = await tea_util_1.default.readAsString(response_.body);
689
- return {
690
- body: str,
691
- headers: response_.headers,
692
- statusCode: response_.statusCode,
693
- };
694
- }
695
- else if (tea_util_1.default.equalString(bodyType, "json")) {
696
- let obj = await tea_util_1.default.readAsJSON(response_.body);
697
- let res = tea_util_1.default.assertAsMap(obj);
698
- return {
699
- body: res,
700
- headers: response_.headers,
701
- statusCode: response_.statusCode,
702
- };
703
- }
704
- else if (tea_util_1.default.equalString(bodyType, "array")) {
705
- let arr = await tea_util_1.default.readAsJSON(response_.body);
706
- return {
707
- body: arr,
708
- headers: response_.headers,
709
- statusCode: response_.statusCode,
710
- };
711
- }
712
- else {
713
- return {
714
- headers: response_.headers,
715
- statusCode: response_.statusCode,
716
- };
717
- }
718
- }
719
- catch (ex) {
720
- if ($tea.isRetryable(ex)) {
721
- continue;
722
- }
723
- throw ex;
724
- }
725
- }
726
- throw $tea.newUnretryableError(_lastRequest);
727
- }
728
- /**
729
- * Encapsulate the request and invoke the network
730
- * @param action api name
731
- * @param version product version
732
- * @param protocol http or https
733
- * @param method e.g. GET
734
- * @param authType authorization type e.g. AK
735
- * @param bodyType response body type e.g. String
736
- * @param request object of OpenApiRequest
737
- * @param runtime which controls some details of call api, such as retry times
738
- * @return the response
739
- */
740
- async doRequest(params, request, runtime) {
741
- let _runtime = {
742
- timeouted: "retry",
743
- key: tea_util_1.default.defaultString(runtime.key, this._key),
744
- cert: tea_util_1.default.defaultString(runtime.cert, this._cert),
745
- ca: tea_util_1.default.defaultString(runtime.ca, this._ca),
746
- readTimeout: tea_util_1.default.defaultNumber(runtime.readTimeout, this._readTimeout),
747
- connectTimeout: tea_util_1.default.defaultNumber(runtime.connectTimeout, this._connectTimeout),
748
- httpProxy: tea_util_1.default.defaultString(runtime.httpProxy, this._httpProxy),
749
- httpsProxy: tea_util_1.default.defaultString(runtime.httpsProxy, this._httpsProxy),
750
- noProxy: tea_util_1.default.defaultString(runtime.noProxy, this._noProxy),
751
- socks5Proxy: tea_util_1.default.defaultString(runtime.socks5Proxy, this._socks5Proxy),
752
- socks5NetWork: tea_util_1.default.defaultString(runtime.socks5NetWork, this._socks5NetWork),
753
- maxIdleConns: tea_util_1.default.defaultNumber(runtime.maxIdleConns, this._maxIdleConns),
754
- retry: {
755
- retryable: runtime.autoretry,
756
- maxAttempts: tea_util_1.default.defaultNumber(runtime.maxAttempts, 3),
757
- },
758
- backoff: {
759
- policy: tea_util_1.default.defaultString(runtime.backoffPolicy, "no"),
760
- period: tea_util_1.default.defaultNumber(runtime.backoffPeriod, 1),
761
- },
762
- ignoreSSL: runtime.ignoreSSL,
763
- };
764
- let _lastRequest = null;
765
- let _now = Date.now();
766
- let _retryTimes = 0;
767
- while ($tea.allowRetry(_runtime['retry'], _retryTimes, _now)) {
768
- if (_retryTimes > 0) {
769
- let _backoffTime = $tea.getBackoffTime(_runtime['backoff'], _retryTimes);
770
- if (_backoffTime > 0) {
771
- await $tea.sleep(_backoffTime);
772
- }
773
- }
774
- _retryTimes = _retryTimes + 1;
775
- try {
776
- let request_ = new $tea.Request();
777
- request_.protocol = tea_util_1.default.defaultString(this._protocol, params.protocol);
778
- request_.method = params.method;
779
- request_.pathname = params.pathname;
780
- let globalQueries = {};
781
- let globalHeaders = {};
782
- if (!tea_util_1.default.isUnset(this._globalParameters)) {
783
- let globalParams = this._globalParameters;
784
- if (!tea_util_1.default.isUnset(globalParams.queries)) {
785
- globalQueries = globalParams.queries;
786
- }
787
- if (!tea_util_1.default.isUnset(globalParams.headers)) {
788
- globalHeaders = globalParams.headers;
789
- }
790
- }
791
- request_.query = Object.assign(Object.assign({}, globalQueries), request.query);
792
- // endpoint is setted in product client
793
- request_.headers = Object.assign(Object.assign({ host: this._endpoint, 'x-acs-version': params.version, 'x-acs-action': params.action, 'user-agent': this.getUserAgent(), 'x-acs-date': openapi_util_1.default.getTimestamp(), 'x-acs-signature-nonce': tea_util_1.default.getNonce(), accept: "application/json" }, globalHeaders), request.headers);
794
- if (tea_util_1.default.equalString(params.style, "RPC")) {
795
- let headers = this.getRpcHeaders();
796
- if (!tea_util_1.default.isUnset(headers)) {
797
- request_.headers = Object.assign(Object.assign({}, request_.headers), headers);
798
- }
799
- }
800
- let signatureAlgorithm = tea_util_1.default.defaultString(this._signatureAlgorithm, "ACS3-HMAC-SHA256");
801
- let hashedRequestPayload = openapi_util_1.default.hexEncode(openapi_util_1.default.hash(tea_util_1.default.toBytes(""), signatureAlgorithm));
802
- if (!tea_util_1.default.isUnset(request.stream)) {
803
- let tmp = await tea_util_1.default.readAsBytes(request.stream);
804
- hashedRequestPayload = openapi_util_1.default.hexEncode(openapi_util_1.default.hash(tmp, signatureAlgorithm));
805
- request_.body = new $tea.BytesReadable(tmp);
806
- request_.headers["content-type"] = "application/octet-stream";
807
- }
808
- else {
809
- if (!tea_util_1.default.isUnset(request.body)) {
810
- if (tea_util_1.default.equalString(params.reqBodyType, "byte")) {
811
- let byteObj = tea_util_1.default.assertAsBytes(request.body);
812
- hashedRequestPayload = openapi_util_1.default.hexEncode(openapi_util_1.default.hash(byteObj, signatureAlgorithm));
813
- request_.body = new $tea.BytesReadable(byteObj);
814
- }
815
- else if (tea_util_1.default.equalString(params.reqBodyType, "json")) {
816
- let jsonObj = tea_util_1.default.toJSONString(request.body);
817
- hashedRequestPayload = openapi_util_1.default.hexEncode(openapi_util_1.default.hash(tea_util_1.default.toBytes(jsonObj), signatureAlgorithm));
818
- request_.body = new $tea.BytesReadable(jsonObj);
819
- request_.headers["content-type"] = "application/json; charset=utf-8";
820
- }
821
- else {
822
- let m = tea_util_1.default.assertAsMap(request.body);
823
- let formObj = openapi_util_1.default.toForm(m);
824
- hashedRequestPayload = openapi_util_1.default.hexEncode(openapi_util_1.default.hash(tea_util_1.default.toBytes(formObj), signatureAlgorithm));
825
- request_.body = new $tea.BytesReadable(formObj);
826
- request_.headers["content-type"] = "application/x-www-form-urlencoded";
827
- }
828
- }
829
- }
830
- request_.headers["x-acs-content-sha256"] = hashedRequestPayload;
831
- if (!tea_util_1.default.equalString(params.authType, "Anonymous")) {
832
- let authType = await this.getType();
833
- if (tea_util_1.default.equalString(authType, "bearer")) {
834
- let bearerToken = await this.getBearerToken();
835
- request_.headers["x-acs-bearer-token"] = bearerToken;
836
- }
837
- else {
838
- let accessKeyId = await this.getAccessKeyId();
839
- let accessKeySecret = await this.getAccessKeySecret();
840
- let securityToken = await this.getSecurityToken();
841
- if (!tea_util_1.default.empty(securityToken)) {
842
- request_.headers["x-acs-accesskey-id"] = accessKeyId;
843
- request_.headers["x-acs-security-token"] = securityToken;
844
- }
845
- request_.headers["Authorization"] = openapi_util_1.default.getAuthorization(request_, signatureAlgorithm, hashedRequestPayload, accessKeyId, accessKeySecret);
846
- }
847
- }
848
- _lastRequest = request_;
849
- let response_ = await $tea.doAction(request_, _runtime);
850
- if (tea_util_1.default.is4xx(response_.statusCode) || tea_util_1.default.is5xx(response_.statusCode)) {
851
- let err = {};
852
- if (!tea_util_1.default.isUnset(response_.headers["content-type"]) && tea_util_1.default.equalString(response_.headers["content-type"], "text/xml;charset=utf-8")) {
853
- let _str = await tea_util_1.default.readAsString(response_.body);
854
- let respMap = tea_xml_1.default.parseXml(_str, null);
855
- err = tea_util_1.default.assertAsMap(respMap["Error"]);
856
- }
857
- else {
858
- let _res = await tea_util_1.default.readAsJSON(response_.body);
859
- err = tea_util_1.default.assertAsMap(_res);
860
- }
861
- err["statusCode"] = response_.statusCode;
862
- throw $tea.newError({
863
- code: `${Client.defaultAny(err["Code"], err["code"])}`,
864
- message: `code: ${response_.statusCode}, ${Client.defaultAny(err["Message"], err["message"])} request id: ${Client.defaultAny(err["RequestId"], err["requestId"])}`,
865
- data: err,
866
- description: `${Client.defaultAny(err["Description"], err["description"])}`,
867
- accessDeniedDetail: Client.defaultAny(err["AccessDeniedDetail"], err["accessDeniedDetail"]),
868
- });
869
- }
870
- if (tea_util_1.default.equalString(params.bodyType, "binary")) {
871
- let resp = {
872
- body: response_.body,
873
- headers: response_.headers,
874
- statusCode: response_.statusCode,
875
- };
876
- return resp;
877
- }
878
- else if (tea_util_1.default.equalString(params.bodyType, "byte")) {
879
- let byt = await tea_util_1.default.readAsBytes(response_.body);
880
- return {
881
- body: byt,
882
- headers: response_.headers,
883
- statusCode: response_.statusCode,
884
- };
885
- }
886
- else if (tea_util_1.default.equalString(params.bodyType, "string")) {
887
- let str = await tea_util_1.default.readAsString(response_.body);
888
- return {
889
- body: str,
890
- headers: response_.headers,
891
- statusCode: response_.statusCode,
892
- };
893
- }
894
- else if (tea_util_1.default.equalString(params.bodyType, "json")) {
895
- let obj = await tea_util_1.default.readAsJSON(response_.body);
896
- let res = tea_util_1.default.assertAsMap(obj);
897
- return {
898
- body: res,
899
- headers: response_.headers,
900
- statusCode: response_.statusCode,
901
- };
902
- }
903
- else if (tea_util_1.default.equalString(params.bodyType, "array")) {
904
- let arr = await tea_util_1.default.readAsJSON(response_.body);
905
- return {
906
- body: arr,
907
- headers: response_.headers,
908
- statusCode: response_.statusCode,
909
- };
910
- }
911
- else {
912
- let anything = await tea_util_1.default.readAsString(response_.body);
913
- return {
914
- body: anything,
915
- headers: response_.headers,
916
- statusCode: response_.statusCode,
917
- };
918
- }
919
- }
920
- catch (ex) {
921
- if ($tea.isRetryable(ex)) {
922
- continue;
923
- }
924
- throw ex;
925
- }
926
- }
927
- throw $tea.newUnretryableError(_lastRequest);
928
- }
929
- /**
930
- * Encapsulate the request and invoke the network
931
- * @param action api name
932
- * @param version product version
933
- * @param protocol http or https
934
- * @param method e.g. GET
935
- * @param authType authorization type e.g. AK
936
- * @param bodyType response body type e.g. String
937
- * @param request object of OpenApiRequest
938
- * @param runtime which controls some details of call api, such as retry times
939
- * @return the response
940
- */
941
- async execute(params, request, runtime) {
942
- let _runtime = {
943
- timeouted: "retry",
944
- key: tea_util_1.default.defaultString(runtime.key, this._key),
945
- cert: tea_util_1.default.defaultString(runtime.cert, this._cert),
946
- ca: tea_util_1.default.defaultString(runtime.ca, this._ca),
947
- readTimeout: tea_util_1.default.defaultNumber(runtime.readTimeout, this._readTimeout),
948
- connectTimeout: tea_util_1.default.defaultNumber(runtime.connectTimeout, this._connectTimeout),
949
- httpProxy: tea_util_1.default.defaultString(runtime.httpProxy, this._httpProxy),
950
- httpsProxy: tea_util_1.default.defaultString(runtime.httpsProxy, this._httpsProxy),
951
- noProxy: tea_util_1.default.defaultString(runtime.noProxy, this._noProxy),
952
- socks5Proxy: tea_util_1.default.defaultString(runtime.socks5Proxy, this._socks5Proxy),
953
- socks5NetWork: tea_util_1.default.defaultString(runtime.socks5NetWork, this._socks5NetWork),
954
- maxIdleConns: tea_util_1.default.defaultNumber(runtime.maxIdleConns, this._maxIdleConns),
955
- retry: {
956
- retryable: runtime.autoretry,
957
- maxAttempts: tea_util_1.default.defaultNumber(runtime.maxAttempts, 3),
958
- },
959
- backoff: {
960
- policy: tea_util_1.default.defaultString(runtime.backoffPolicy, "no"),
961
- period: tea_util_1.default.defaultNumber(runtime.backoffPeriod, 1),
962
- },
963
- ignoreSSL: runtime.ignoreSSL,
964
- };
965
- let _lastRequest = null;
966
- let _now = Date.now();
967
- let _retryTimes = 0;
968
- while ($tea.allowRetry(_runtime['retry'], _retryTimes, _now)) {
969
- if (_retryTimes > 0) {
970
- let _backoffTime = $tea.getBackoffTime(_runtime['backoff'], _retryTimes);
971
- if (_backoffTime > 0) {
972
- await $tea.sleep(_backoffTime);
973
- }
974
- }
975
- _retryTimes = _retryTimes + 1;
976
- try {
977
- let request_ = new $tea.Request();
978
- // spi = new Gateway();//Gateway implements SPI,这一步在产品 SDK 中实例化
979
- let headers = this.getRpcHeaders();
980
- let globalQueries = {};
981
- let globalHeaders = {};
982
- if (!tea_util_1.default.isUnset(this._globalParameters)) {
983
- let globalParams = this._globalParameters;
984
- if (!tea_util_1.default.isUnset(globalParams.queries)) {
985
- globalQueries = globalParams.queries;
986
- }
987
- if (!tea_util_1.default.isUnset(globalParams.headers)) {
988
- globalHeaders = globalParams.headers;
989
- }
990
- }
991
- let requestContext = new $SPI.InterceptorContextRequest({
992
- headers: Object.assign(Object.assign(Object.assign({}, globalHeaders), request.headers), headers),
993
- query: Object.assign(Object.assign({}, globalQueries), request.query),
994
- body: request.body,
995
- stream: request.stream,
996
- hostMap: request.hostMap,
997
- pathname: params.pathname,
998
- productId: this._productId,
999
- action: params.action,
1000
- version: params.version,
1001
- protocol: tea_util_1.default.defaultString(this._protocol, params.protocol),
1002
- method: tea_util_1.default.defaultString(this._method, params.method),
1003
- authType: params.authType,
1004
- bodyType: params.bodyType,
1005
- reqBodyType: params.reqBodyType,
1006
- style: params.style,
1007
- credential: this._credential,
1008
- signatureVersion: this._signatureVersion,
1009
- signatureAlgorithm: this._signatureAlgorithm,
1010
- userAgent: this.getUserAgent(),
1011
- });
1012
- let configurationContext = new $SPI.InterceptorContextConfiguration({
1013
- regionId: this._regionId,
1014
- endpoint: tea_util_1.default.defaultString(request.endpointOverride, this._endpoint),
1015
- endpointRule: this._endpointRule,
1016
- endpointMap: this._endpointMap,
1017
- endpointType: this._endpointType,
1018
- network: this._network,
1019
- suffix: this._suffix,
1020
- });
1021
- let interceptorContext = new $SPI.InterceptorContext({
1022
- request: requestContext,
1023
- configuration: configurationContext,
1024
- });
1025
- let attributeMap = new $SPI.AttributeMap({});
1026
- // 1. spi.modifyConfiguration(context: SPI.InterceptorContext, attributeMap: SPI.AttributeMap);
1027
- await this._spi.modifyConfiguration(interceptorContext, attributeMap);
1028
- // 2. spi.modifyRequest(context: SPI.InterceptorContext, attributeMap: SPI.AttributeMap);
1029
- await this._spi.modifyRequest(interceptorContext, attributeMap);
1030
- request_.protocol = interceptorContext.request.protocol;
1031
- request_.method = interceptorContext.request.method;
1032
- request_.pathname = interceptorContext.request.pathname;
1033
- request_.query = interceptorContext.request.query;
1034
- request_.body = interceptorContext.request.stream;
1035
- request_.headers = interceptorContext.request.headers;
1036
- _lastRequest = request_;
1037
- let response_ = await $tea.doAction(request_, _runtime);
1038
- let responseContext = new $SPI.InterceptorContextResponse({
1039
- statusCode: response_.statusCode,
1040
- headers: response_.headers,
1041
- body: response_.body,
1042
- });
1043
- interceptorContext.response = responseContext;
1044
- // 3. spi.modifyResponse(context: SPI.InterceptorContext, attributeMap: SPI.AttributeMap);
1045
- await this._spi.modifyResponse(interceptorContext, attributeMap);
1046
- return {
1047
- headers: interceptorContext.response.headers,
1048
- statusCode: interceptorContext.response.statusCode,
1049
- body: interceptorContext.response.deserializedBody,
1050
- };
1051
- }
1052
- catch (ex) {
1053
- if ($tea.isRetryable(ex)) {
1054
- continue;
1055
- }
1056
- throw ex;
1057
- }
1058
- }
1059
- throw $tea.newUnretryableError(_lastRequest);
1060
- }
1061
- async callApi(params, request, runtime) {
1062
- if (tea_util_1.default.isUnset(params)) {
1063
- throw $tea.newError({
1064
- code: "ParameterMissing",
1065
- message: "'params' can not be unset",
1066
- });
1067
- }
1068
- if (tea_util_1.default.isUnset(this._signatureAlgorithm) || !tea_util_1.default.equalString(this._signatureAlgorithm, "v2")) {
1069
- return await this.doRequest(params, request, runtime);
1070
- }
1071
- else if (tea_util_1.default.equalString(params.style, "ROA") && tea_util_1.default.equalString(params.reqBodyType, "json")) {
1072
- return await this.doROARequest(params.action, params.version, params.protocol, params.method, params.authType, params.pathname, params.bodyType, request, runtime);
1073
- }
1074
- else if (tea_util_1.default.equalString(params.style, "ROA")) {
1075
- return await this.doROARequestWithForm(params.action, params.version, params.protocol, params.method, params.authType, params.pathname, params.bodyType, request, runtime);
1076
- }
1077
- else {
1078
- return await this.doRPCRequest(params.action, params.version, params.protocol, params.method, params.authType, params.bodyType, request, runtime);
1079
- }
1080
- }
1081
- /**
1082
- * Get user agent
1083
- * @return user agent
1084
- */
1085
- getUserAgent() {
1086
- let userAgent = tea_util_1.default.getUserAgent(this._userAgent);
1087
- return userAgent;
1088
- }
1089
- /**
1090
- * Get accesskey id by using credential
1091
- * @return accesskey id
1092
- */
1093
- async getAccessKeyId() {
1094
- if (tea_util_1.default.isUnset(this._credential)) {
1095
- return "";
1096
- }
1097
- let accessKeyId = await this._credential.getAccessKeyId();
1098
- return accessKeyId;
1099
- }
1100
- /**
1101
- * Get accesskey secret by using credential
1102
- * @return accesskey secret
1103
- */
1104
- async getAccessKeySecret() {
1105
- if (tea_util_1.default.isUnset(this._credential)) {
1106
- return "";
1107
- }
1108
- let secret = await this._credential.getAccessKeySecret();
1109
- return secret;
1110
- }
1111
- /**
1112
- * Get security token by using credential
1113
- * @return security token
1114
- */
1115
- async getSecurityToken() {
1116
- if (tea_util_1.default.isUnset(this._credential)) {
1117
- return "";
1118
- }
1119
- let token = await this._credential.getSecurityToken();
1120
- return token;
1121
- }
1122
- /**
1123
- * Get bearer token by credential
1124
- * @return bearer token
1125
- */
1126
- async getBearerToken() {
1127
- if (tea_util_1.default.isUnset(this._credential)) {
1128
- return "";
1129
- }
1130
- let token = this._credential.getBearerToken();
1131
- return token;
1132
- }
1133
- /**
1134
- * Get credential type by credential
1135
- * @return credential type e.g. access_key
1136
- */
1137
- async getType() {
1138
- if (tea_util_1.default.isUnset(this._credential)) {
1139
- return "";
1140
- }
1141
- let authType = this._credential.getType();
1142
- return authType;
1143
- }
1144
- /**
1145
- * If inputValue is not null, return it or return defaultValue
1146
- * @param inputValue users input value
1147
- * @param defaultValue default value
1148
- * @return the final result
1149
- */
1150
- static defaultAny(inputValue, defaultValue) {
1151
- if (tea_util_1.default.isUnset(inputValue)) {
1152
- return defaultValue;
1153
- }
1154
- return inputValue;
1155
- }
1156
- /**
1157
- * If the endpointRule and config.endpoint are empty, throw error
1158
- * @param config config contains the necessary information to create a client
1159
- */
1160
- checkConfig(config) {
1161
- if (tea_util_1.default.empty(this._endpointRule) && tea_util_1.default.empty(config.endpoint)) {
1162
- throw $tea.newError({
1163
- code: "ParameterMissing",
1164
- message: "'config.endpoint' can not be empty",
1165
- });
1166
- }
1167
- }
1168
- /**
1169
- * set gateway client
1170
- * @param spi.
1171
- */
1172
- setGatewayClient(spi) {
1173
- this._spi = spi;
1174
- }
1175
- /**
1176
- * set RPC header for debug
1177
- * @param headers headers for debug, this header can be used only once.
1178
- */
1179
- setRpcHeaders(headers) {
1180
- this._headers = headers;
1181
- }
1182
- /**
1183
- * get RPC header for debug
1184
- */
1185
- getRpcHeaders() {
1186
- let headers = this._headers;
1187
- this._headers = null;
1188
- return headers;
1189
- }
1190
- }
1191
- exports.default = Client;
1192
- //# sourceMappingURL=client.js.map