@sinch/sdk-client 1.4.2 → 1.6.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/dist/api/api-client-options-helper.d.ts +6 -2
- package/dist/api/api-client-options-helper.js +56 -7
- package/dist/api/api-client-options-helper.js.map +1 -1
- package/dist/api/api-client-options.d.ts +8 -1
- package/dist/api/api-client.d.ts +12 -3
- package/dist/api/api-client.js +8 -1
- package/dist/api/api-client.js.map +1 -1
- package/dist/api/api-errors.d.ts +2 -0
- package/dist/api/api-errors.js +3 -1
- package/dist/api/api-errors.js.map +1 -1
- package/dist/api/api-interface.d.ts +1 -1
- package/dist/api/callback-webhooks-interface.d.ts +1 -0
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.js.map +1 -1
- package/dist/client/api-client-helpers.js.map +1 -1
- package/dist/client/api-client-pagination-helper.js +24 -0
- package/dist/client/api-client-pagination-helper.js.map +1 -1
- package/dist/client/api-fetch-client.d.ts +7 -3
- package/dist/client/api-fetch-client.js +77 -31
- package/dist/client/api-fetch-client.js.map +1 -1
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.js +1 -0
- package/dist/client/index.js.map +1 -1
- package/dist/client/lazy-api-client.d.ts +9 -0
- package/dist/client/lazy-api-client.js +14 -0
- package/dist/client/lazy-api-client.js.map +1 -0
- package/dist/client/retry-policy.d.ts +33 -0
- package/dist/client/retry-policy.js +112 -0
- package/dist/client/retry-policy.js.map +1 -0
- package/dist/domain/domain-helper.d.ts +15 -0
- package/dist/domain/domain-helper.js +16 -1
- package/dist/domain/domain-helper.js.map +1 -1
- package/dist/domain/domain-interface.d.ts +99 -3
- package/dist/domain/domain-interface.js +35 -1
- package/dist/domain/domain-interface.js.map +1 -1
- package/dist/http/fetch/fetch-http-content-parser.d.ts +13 -0
- package/dist/http/fetch/fetch-http-content-parser.js +65 -0
- package/dist/http/fetch/fetch-http-content-parser.js.map +1 -0
- package/dist/http/fetch/fetch-http-headers.d.ts +4 -0
- package/dist/http/fetch/fetch-http-headers.js +37 -0
- package/dist/http/fetch/fetch-http-headers.js.map +1 -0
- package/dist/http/fetch/fetch-http-request-mapper.d.ts +8 -0
- package/dist/http/fetch/fetch-http-request-mapper.js +31 -0
- package/dist/http/fetch/fetch-http-request-mapper.js.map +1 -0
- package/dist/http/fetch/fetch-http-response.d.ts +3 -0
- package/dist/http/fetch/fetch-http-response.js +10 -0
- package/dist/http/fetch/fetch-http-response.js.map +1 -0
- package/dist/http/fetch/fetch-http-transport.d.ts +11 -0
- package/dist/http/fetch/fetch-http-transport.js +44 -0
- package/dist/http/fetch/fetch-http-transport.js.map +1 -0
- package/dist/http/fetch/index.d.ts +5 -0
- package/dist/http/fetch/index.js +15 -0
- package/dist/http/fetch/index.js.map +1 -0
- package/dist/http/http-content-parser.d.ts +13 -0
- package/dist/http/http-content-parser.js +3 -0
- package/dist/http/http-content-parser.js.map +1 -0
- package/dist/http/http-headers.d.ts +16 -0
- package/dist/http/http-headers.js +63 -0
- package/dist/http/http-headers.js.map +1 -0
- package/dist/http/http-method.d.ts +10 -0
- package/dist/http/http-method.js +26 -0
- package/dist/http/http-method.js.map +1 -0
- package/dist/http/http-request.d.ts +27 -0
- package/dist/http/http-request.js +19 -0
- package/dist/http/http-request.js.map +1 -0
- package/dist/http/http-response.d.ts +12 -0
- package/dist/http/http-response.js +16 -0
- package/dist/http/http-response.js.map +1 -0
- package/dist/http/http-transport.d.ts +15 -0
- package/dist/http/http-transport.js +3 -0
- package/dist/http/http-transport.js.map +1 -0
- package/dist/http/index.d.ts +6 -0
- package/dist/http/index.js +13 -0
- package/dist/http/index.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/logger/index.d.ts +2 -0
- package/dist/logger/index.js +9 -0
- package/dist/logger/index.js.map +1 -0
- package/dist/logger/logger-types.d.ts +30 -0
- package/dist/logger/logger-types.js +3 -0
- package/dist/logger/logger-types.js.map +1 -0
- package/dist/logger/logger.d.ts +11 -0
- package/dist/logger/logger.js +56 -0
- package/dist/logger/logger.js.map +1 -0
- package/dist/logger/sinch-logger.d.ts +14 -0
- package/dist/logger/sinch-logger.js +39 -0
- package/dist/logger/sinch-logger.js.map +1 -0
- package/dist/plugins/additional-headers/additional-headers.request.js.map +1 -1
- package/dist/plugins/api-token/api-token.request.d.ts +1 -0
- package/dist/plugins/api-token/api-token.request.js +1 -0
- package/dist/plugins/api-token/api-token.request.js.map +1 -1
- package/dist/plugins/basicAuthentication/basic-authentication.request.d.ts +1 -0
- package/dist/plugins/basicAuthentication/basic-authentication.request.js +1 -0
- package/dist/plugins/basicAuthentication/basic-authentication.request.js.map +1 -1
- package/dist/plugins/core/index.d.ts +1 -1
- package/dist/plugins/core/index.js +1 -0
- package/dist/plugins/core/index.js.map +1 -1
- package/dist/plugins/core/request-plugin.d.ts +2 -1
- package/dist/plugins/core/request-plugin.js.map +1 -1
- package/dist/plugins/exception/exception.response.d.ts +5 -4
- package/dist/plugins/exception/exception.response.js +5 -4
- package/dist/plugins/exception/exception.response.js.map +1 -1
- package/dist/plugins/oauth2/oauth2-api.js.map +1 -1
- package/dist/plugins/oauth2/oauth2-token.request.d.ts +4 -6
- package/dist/plugins/oauth2/oauth2-token.request.js +26 -77
- package/dist/plugins/oauth2/oauth2-token.request.js.map +1 -1
- package/dist/plugins/signing/signing.request.d.ts +1 -0
- package/dist/plugins/signing/signing.request.js +1 -0
- package/dist/plugins/signing/signing.request.js.map +1 -1
- package/dist/plugins/version/version.request.d.ts +1 -0
- package/dist/plugins/version/version.request.js +1 -0
- package/dist/plugins/version/version.request.js.map +1 -1
- package/dist/plugins/x-timestamp/x-timestamp.request.d.ts +1 -0
- package/dist/plugins/x-timestamp/x-timestamp.request.js +1 -0
- package/dist/plugins/x-timestamp/x-timestamp.request.js.map +1 -1
- package/dist/utils/authorization.helper.d.ts +2 -2
- package/dist/utils/authorization.helper.js +7 -16
- package/dist/utils/authorization.helper.js.map +1 -1
- package/dist/utils/date.js.map +1 -1
- package/dist/utils/text-to-hex.js.map +1 -1
- package/package.json +7 -4
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpMethod = void 0;
|
|
4
|
+
exports.resolveHttpMethod = resolveHttpMethod;
|
|
5
|
+
/** @internal */
|
|
6
|
+
var HttpMethod;
|
|
7
|
+
(function (HttpMethod) {
|
|
8
|
+
HttpMethod["GET"] = "GET";
|
|
9
|
+
HttpMethod["POST"] = "POST";
|
|
10
|
+
HttpMethod["PUT"] = "PUT";
|
|
11
|
+
HttpMethod["PATCH"] = "PATCH";
|
|
12
|
+
HttpMethod["DELETE"] = "DELETE";
|
|
13
|
+
})(HttpMethod || (exports.HttpMethod = HttpMethod = {}));
|
|
14
|
+
const HTTP_METHODS = new Set(Object.values(HttpMethod));
|
|
15
|
+
/** @internal */
|
|
16
|
+
function resolveHttpMethod(method) {
|
|
17
|
+
if (!method) {
|
|
18
|
+
throw new Error('HTTP method is required');
|
|
19
|
+
}
|
|
20
|
+
const normalized = method.toUpperCase();
|
|
21
|
+
if (!HTTP_METHODS.has(normalized)) {
|
|
22
|
+
throw new Error(`Unsupported HTTP method: ${method}`);
|
|
23
|
+
}
|
|
24
|
+
return normalized;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=http-method.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-method.js","sourceRoot":"","sources":["../../src/http/http-method.ts"],"names":[],"mappings":";;;;AAAA,gBAAgB;AAChB,IAAY,UAMX;AAND,WAAY,UAAU;IACpB,yBAAW,CAAA;IACX,2BAAa,CAAA;IACb,yBAAW,CAAA;IACX,6BAAe,CAAA;IACf,+BAAiB,CAAA;AACnB,CAAC,EANW,UAAU,aAAV,UAAU,GAAV,UAAU,QAMrB;AAED,MAAM,YAAY,GAAG,IAAI,GAAG,CAAS,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;AAEhE,gBAAgB;AAChB,2BAAkC,MAAe;IAC/C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IACD,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;IACxC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CAAC,4BAA4B,MAAM,EAAE,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,UAAwB,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import FormData = require('form-data');
|
|
2
|
+
import { HttpHeaders } from './http-headers';
|
|
3
|
+
import { HttpMethod } from './http-method';
|
|
4
|
+
/** @internal */
|
|
5
|
+
export type HttpContent = string | FormData | Buffer;
|
|
6
|
+
/** @internal */
|
|
7
|
+
export interface HttpRequestParams {
|
|
8
|
+
method: HttpMethod;
|
|
9
|
+
/** Absolute URL without query parameters */
|
|
10
|
+
url: string;
|
|
11
|
+
/** Pre-serialized query string including the leading `?`, or null */
|
|
12
|
+
queryParameters?: string | null;
|
|
13
|
+
headers?: HttpHeaders;
|
|
14
|
+
content?: HttpContent | null;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Wire-level HTTP request used by the SDK transport.
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export declare class HttpRequest {
|
|
21
|
+
readonly method: HttpMethod;
|
|
22
|
+
readonly url: string;
|
|
23
|
+
readonly queryParameters: string | null;
|
|
24
|
+
readonly headers: HttpHeaders;
|
|
25
|
+
readonly content: HttpContent | null;
|
|
26
|
+
constructor(params: HttpRequestParams);
|
|
27
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpRequest = void 0;
|
|
4
|
+
const http_headers_1 = require("./http-headers");
|
|
5
|
+
/**
|
|
6
|
+
* Wire-level HTTP request used by the SDK transport.
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
class HttpRequest {
|
|
10
|
+
constructor(params) {
|
|
11
|
+
this.method = params.method;
|
|
12
|
+
this.url = params.url;
|
|
13
|
+
this.queryParameters = params.queryParameters ?? null;
|
|
14
|
+
this.headers = params.headers ?? new http_headers_1.HttpHeaders();
|
|
15
|
+
this.content = params.content ?? null;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.HttpRequest = HttpRequest;
|
|
19
|
+
//# sourceMappingURL=http-request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-request.js","sourceRoot":"","sources":["../../src/http/http-request.ts"],"names":[],"mappings":";;;AACA,iDAA6C;AAiB7C;;;GAGG;AACH;IAOE,YAAY,MAAyB;QACnC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC;QACtB,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,eAAe,IAAI,IAAI,CAAC;QACtD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,IAAI,0BAAW,EAAE,CAAC;QACnD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,IAAI,CAAC;IACxC,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HttpContentParser } from './http-content-parser';
|
|
2
|
+
import { HttpHeaders } from './http-headers';
|
|
3
|
+
/**
|
|
4
|
+
* Wire-level HTTP response used by the SDK transport.
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare class HttpResponse {
|
|
8
|
+
readonly status: number;
|
|
9
|
+
readonly headers: HttpHeaders;
|
|
10
|
+
readonly content: HttpContentParser;
|
|
11
|
+
constructor(status: number, headers: HttpHeaders, content: HttpContentParser);
|
|
12
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpResponse = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Wire-level HTTP response used by the SDK transport.
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
class HttpResponse {
|
|
9
|
+
constructor(status, headers, content) {
|
|
10
|
+
this.status = status;
|
|
11
|
+
this.headers = headers;
|
|
12
|
+
this.content = content;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.HttpResponse = HttpResponse;
|
|
16
|
+
//# sourceMappingURL=http-response.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-response.js","sourceRoot":"","sources":["../../src/http/http-response.ts"],"names":[],"mappings":";;;AAGA;;;GAGG;AACH;IACE,YACW,MAAc,EACd,OAAoB,EACpB,OAA0B;sBAF1B,MAAM;uBACN,OAAO;uBACP,OAAO;IACf,CAAC;CACL"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { HttpRequest } from './http-request';
|
|
2
|
+
import { HttpResponse } from './http-response';
|
|
3
|
+
/** @internal */
|
|
4
|
+
export interface HttpTransportSendInit {
|
|
5
|
+
timeout?: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Thin HTTP transport: one round-trip, no auth or retry.
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export interface HttpTransport {
|
|
12
|
+
send(request: HttpRequest, init?: HttpTransportSendInit): Promise<HttpResponse>;
|
|
13
|
+
/** Release unused response resources so sockets can be reused. */
|
|
14
|
+
release(response: HttpResponse): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-transport.js","sourceRoot":"","sources":["../../src/http/http-transport.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { HttpMethod, resolveHttpMethod } from './http-method';
|
|
2
|
+
export { HttpHeaders } from './http-headers';
|
|
3
|
+
export { HttpContent, HttpRequest, HttpRequestParams } from './http-request';
|
|
4
|
+
export { HttpResponse } from './http-response';
|
|
5
|
+
export { HttpContentParser } from './http-content-parser';
|
|
6
|
+
export { HttpTransport, HttpTransportSendInit } from './http-transport';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpResponse = exports.HttpRequest = exports.HttpHeaders = exports.resolveHttpMethod = exports.HttpMethod = void 0;
|
|
4
|
+
var http_method_1 = require("./http-method");
|
|
5
|
+
Object.defineProperty(exports, "HttpMethod", { enumerable: true, get: function () { return http_method_1.HttpMethod; } });
|
|
6
|
+
Object.defineProperty(exports, "resolveHttpMethod", { enumerable: true, get: function () { return http_method_1.resolveHttpMethod; } });
|
|
7
|
+
var http_headers_1 = require("./http-headers");
|
|
8
|
+
Object.defineProperty(exports, "HttpHeaders", { enumerable: true, get: function () { return http_headers_1.HttpHeaders; } });
|
|
9
|
+
var http_request_1 = require("./http-request");
|
|
10
|
+
Object.defineProperty(exports, "HttpRequest", { enumerable: true, get: function () { return http_request_1.HttpRequest; } });
|
|
11
|
+
var http_response_1 = require("./http-response");
|
|
12
|
+
Object.defineProperty(exports, "HttpResponse", { enumerable: true, get: function () { return http_response_1.HttpResponse; } });
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/http/index.ts"],"names":[],"mappings":";;;AAAA,6CAA8D;AAArD,yGAAA,UAAU,OAAA;AAAE,gHAAA,iBAAiB,OAAA;AACtC,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AACpB,+CAA6E;AAAvD,2GAAA,WAAW,OAAA;AACjC,iDAA+C;AAAtC,6GAAA,YAAY,OAAA"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./api"), exports);
|
|
18
18
|
__exportStar(require("./client"), exports);
|
|
19
19
|
__exportStar(require("./domain"), exports);
|
|
20
|
+
__exportStar(require("./logger"), exports);
|
|
20
21
|
__exportStar(require("./model"), exports);
|
|
21
22
|
__exportStar(require("./plugins"), exports);
|
|
22
23
|
__exportStar(require("./utils"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB;AACtB,2CAAyB;AACzB,2CAAyB;AACzB,0CAAwB;AACxB,4CAA0B;AAC1B,0CAAwB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB;AACtB,2CAAyB;AACzB,2CAAyB;AACzB,2CAAyB;AACzB,0CAAwB;AACxB,4CAA0B;AAC1B,0CAAwB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveLogger = exports.resolveClientParameters = exports.NOOP_LOGGER = exports.CONSOLE_LOGGER = void 0;
|
|
4
|
+
var logger_1 = require("./logger");
|
|
5
|
+
Object.defineProperty(exports, "CONSOLE_LOGGER", { enumerable: true, get: function () { return logger_1.CONSOLE_LOGGER; } });
|
|
6
|
+
Object.defineProperty(exports, "NOOP_LOGGER", { enumerable: true, get: function () { return logger_1.NOOP_LOGGER; } });
|
|
7
|
+
Object.defineProperty(exports, "resolveClientParameters", { enumerable: true, get: function () { return logger_1.resolveClientParameters; } });
|
|
8
|
+
Object.defineProperty(exports, "resolveLogger", { enumerable: true, get: function () { return logger_1.resolveLogger; } });
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/logger/index.ts"],"names":[],"mappings":";;;AACA,mCAKkB;AAJhB,wGAAA,cAAc,OAAA;AACd,qGAAA,WAAW,OAAA;AACX,iHAAA,uBAAuB,OAAA;AACvB,uGAAA,aAAa,OAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A log message as a string, or a function that returns one when the logger reads it.
|
|
3
|
+
*
|
|
4
|
+
* Pass a function to defer building the message; level-aware loggers can skip that work
|
|
5
|
+
* when the level is disabled.
|
|
6
|
+
*/
|
|
7
|
+
export type LogMessage = string | (() => string);
|
|
8
|
+
/**
|
|
9
|
+
* Logger interface for SDK log output.
|
|
10
|
+
*
|
|
11
|
+
* Pass any object implementing `debug`, `info`, `warn`, and `error` via the `logger`
|
|
12
|
+
* option when initializing `SinchClient`. Messages use {@link LogMessage}.
|
|
13
|
+
*/
|
|
14
|
+
export interface Logger {
|
|
15
|
+
/**
|
|
16
|
+
* On failed HTTP responses (non-success status), the SDK logs the API name, operation,
|
|
17
|
+
* status code, HTTP method, request URL, and response headers. Enable debug on your
|
|
18
|
+
* logger to troubleshoot authentication issues, expired tokens, and other API errors.
|
|
19
|
+
*/
|
|
20
|
+
debug(message: LogMessage, ...meta: any[]): void;
|
|
21
|
+
/** Informational SDK messages, such as deprecation guidance for specific APIs. */
|
|
22
|
+
info(message: LogMessage, ...meta: any[]): void;
|
|
23
|
+
/**
|
|
24
|
+
* Deprecation notices and configuration warnings (for example conflicting credentials
|
|
25
|
+
* or deprecated region parameters).
|
|
26
|
+
*/
|
|
27
|
+
warn(message: LogMessage, ...meta: any[]): void;
|
|
28
|
+
/** SDK-level errors surfaced during client initialization or configuration. */
|
|
29
|
+
error(message: LogMessage, ...meta: any[]): void;
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger-types.js","sourceRoot":"","sources":["../../src/logger/logger-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ResolvedSinchClientParameters, SinchClientParameters } from '../domain';
|
|
2
|
+
import type { Logger } from './logger-types';
|
|
3
|
+
export type { LogMessage, Logger } from './logger-types';
|
|
4
|
+
/** @internal */
|
|
5
|
+
export declare const CONSOLE_LOGGER: Logger;
|
|
6
|
+
/** @internal */
|
|
7
|
+
export declare const NOOP_LOGGER: Logger;
|
|
8
|
+
/** @internal */
|
|
9
|
+
export declare const resolveLogger: (logger?: Logger | null) => Logger;
|
|
10
|
+
/** @internal */
|
|
11
|
+
export declare const resolveClientParameters: (params: SinchClientParameters | ResolvedSinchClientParameters) => ResolvedSinchClientParameters;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveClientParameters = exports.resolveLogger = exports.NOOP_LOGGER = exports.CONSOLE_LOGGER = void 0;
|
|
4
|
+
const domain_1 = require("../domain");
|
|
5
|
+
const sinch_logger_1 = require("./sinch-logger");
|
|
6
|
+
const evaluateMessage = (message) => typeof message === 'function' ? message() : message;
|
|
7
|
+
/** @internal */
|
|
8
|
+
exports.CONSOLE_LOGGER = {
|
|
9
|
+
debug: (message, ...meta) => console.debug(evaluateMessage(message), ...meta),
|
|
10
|
+
info: (message, ...meta) => console.info(evaluateMessage(message), ...meta),
|
|
11
|
+
warn: (message, ...meta) => console.warn(evaluateMessage(message), ...meta),
|
|
12
|
+
error: (message, ...meta) => console.error(evaluateMessage(message), ...meta),
|
|
13
|
+
};
|
|
14
|
+
/** @internal */
|
|
15
|
+
exports.NOOP_LOGGER = {
|
|
16
|
+
debug: () => { },
|
|
17
|
+
info: () => { },
|
|
18
|
+
warn: () => { },
|
|
19
|
+
error: () => { },
|
|
20
|
+
};
|
|
21
|
+
const resolveBaseLogger = (logger) => {
|
|
22
|
+
if (logger === null) {
|
|
23
|
+
return exports.NOOP_LOGGER;
|
|
24
|
+
}
|
|
25
|
+
if (logger === undefined) {
|
|
26
|
+
return exports.CONSOLE_LOGGER;
|
|
27
|
+
}
|
|
28
|
+
return logger;
|
|
29
|
+
};
|
|
30
|
+
/** @internal */
|
|
31
|
+
const resolveLogger = (logger) => {
|
|
32
|
+
if ((0, sinch_logger_1.isSinchLogger)(logger)) {
|
|
33
|
+
return logger;
|
|
34
|
+
}
|
|
35
|
+
return new sinch_logger_1.SinchLogger(resolveBaseLogger(logger));
|
|
36
|
+
};
|
|
37
|
+
exports.resolveLogger = resolveLogger;
|
|
38
|
+
/** @internal */
|
|
39
|
+
const resolveClientParameters = (params) => {
|
|
40
|
+
const useSinchAuth = params.useSinchAuth ?? true;
|
|
41
|
+
const timeoutSeconds = (0, domain_1.resolveTimeoutSeconds)(params.timeoutSeconds);
|
|
42
|
+
const logger = (0, sinch_logger_1.isSinchLogger)(params.logger) ? params.logger : (0, exports.resolveLogger)(params.logger);
|
|
43
|
+
if (logger === params.logger
|
|
44
|
+
&& params.useSinchAuth === useSinchAuth
|
|
45
|
+
&& params.timeoutSeconds === timeoutSeconds) {
|
|
46
|
+
return params;
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
...params,
|
|
50
|
+
logger,
|
|
51
|
+
useSinchAuth,
|
|
52
|
+
timeoutSeconds,
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
exports.resolveClientParameters = resolveClientParameters;
|
|
56
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger/logger.ts"],"names":[],"mappings":";;;AACA,sCAAkD;AAElD,iDAA4D;AAI5D,MAAM,eAAe,GAAG,CAAC,OAAmB,EAAU,EAAE,CACtD,OAAO,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,EAAE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C;QAC1B,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,OAAO,IAAI,0BAAW,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC;AACpD,CAAC,CAAC;AALW,QAAA,aAAa,GAAb,aAAa,CAKxB;AAEF,gBAAgB;AACT,MAAM,uBAAuB,GAAG,CACrC,MAA6D,EAC9B,EAAE;IACjC,MAAM,YAAY,GAAG,MAAM,CAAC,YAAY,IAAI,IAAI,CAAC;IACjD,MAAM,cAAc,GAAG,IAAA,8BAAqB,EAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IACpE,MAAM,MAAM,GAAG,IAAA,4BAAa,EAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAA,QAAA,aAAa,EAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAE3F,IACE,MAAM,KAAK,MAAM,CAAC,MAAM;WACrB,MAAM,CAAC,YAAY,KAAK,YAAY;WACpC,MAAM,CAAC,cAAc,KAAK,cAAc,EAC3C,CAAC;QACD,OAAO,MAAuC,CAAC;IACjD,CAAC;IAED,OAAO;QACL,GAAG,MAAM;QACT,MAAM;QACN,YAAY;QACZ,cAAc;KACf,CAAC;AACJ,CAAC,CAAC;AArBW,QAAA,uBAAuB,GAAvB,uBAAuB,CAqBlC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Logger, LogMessage } from './logger-types';
|
|
2
|
+
/** @internal */
|
|
3
|
+
export declare const isSinchLogger: (logger?: Logger | null) => logger is SinchLogger;
|
|
4
|
+
/** @internal */
|
|
5
|
+
export declare class SinchLogger implements Logger {
|
|
6
|
+
private baseLogger;
|
|
7
|
+
constructor(baseLogger: Logger);
|
|
8
|
+
private format;
|
|
9
|
+
private log;
|
|
10
|
+
debug(message: LogMessage, ...meta: any[]): void;
|
|
11
|
+
info(message: LogMessage, ...meta: any[]): void;
|
|
12
|
+
warn(message: LogMessage, ...meta: any[]): void;
|
|
13
|
+
error(message: LogMessage, ...meta: any[]): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SinchLogger = exports.isSinchLogger = void 0;
|
|
4
|
+
const sinchLoggers = new WeakSet();
|
|
5
|
+
/** @internal */
|
|
6
|
+
const isSinchLogger = (logger) => logger != null && sinchLoggers.has(logger);
|
|
7
|
+
exports.isSinchLogger = isSinchLogger;
|
|
8
|
+
/** @internal */
|
|
9
|
+
class SinchLogger {
|
|
10
|
+
constructor(baseLogger) {
|
|
11
|
+
this.baseLogger = baseLogger;
|
|
12
|
+
sinchLoggers.add(this);
|
|
13
|
+
}
|
|
14
|
+
format(level, message) {
|
|
15
|
+
return `[Sinch SDK][${level}] ${message}`;
|
|
16
|
+
}
|
|
17
|
+
log(level, method, message, ...meta) {
|
|
18
|
+
if (typeof message === 'function') {
|
|
19
|
+
this.baseLogger[method](() => this.format(level, message()), ...meta);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
this.baseLogger[method](this.format(level, message), ...meta);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
debug(message, ...meta) {
|
|
26
|
+
this.log('Debug', 'debug', message, ...meta);
|
|
27
|
+
}
|
|
28
|
+
info(message, ...meta) {
|
|
29
|
+
this.log('Info', 'info', message, ...meta);
|
|
30
|
+
}
|
|
31
|
+
warn(message, ...meta) {
|
|
32
|
+
this.log('Warn', 'warn', message, ...meta);
|
|
33
|
+
}
|
|
34
|
+
error(message, ...meta) {
|
|
35
|
+
this.log('Error', 'error', message, ...meta);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.SinchLogger = SinchLogger;
|
|
39
|
+
//# sourceMappingURL=sinch-logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sinch-logger.js","sourceRoot":"","sources":["../../src/logger/sinch-logger.ts"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,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IAC7C,CAAC;IACD,KAAK,CAAC,OAAmB,EAAE,GAAG,IAAW;QACvC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IAC/C,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"additional-headers.request.js","sourceRoot":"","sources":["../../../src/plugins/additional-headers/additional-headers.request.ts"],"names":[],"mappings":";;;AACA,2DAA0F;AAM1F;;;;GAIG;AACI,MAAM,WAAW,GAAG,KAAK,EAAE,GAAW,EAAE,KAAa,EAAoC,EAAE,CAAC,CACjG,EAAE,CAAC,GAAG,CAAC,EAAG,KAAK,EAAE,CAClB,CAAC;AAFW,QAAA,WAAW,
|
|
1
|
+
{"version":3,"file":"additional-headers.request.js","sourceRoot":"","sources":["../../../src/plugins/additional-headers/additional-headers.request.ts"],"names":[],"mappings":";;;AACA,2DAA0F;AAM1F;;;;GAIG;AACI,MAAM,WAAW,GAAG,KAAK,EAAE,GAAW,EAAE,KAAa,EAAoC,EAAE,CAAC,CACjG,EAAE,CAAC,GAAG,CAAC,EAAG,KAAK,EAAE,CAClB,CAAC;AAFW,QAAA,WAAW,GAAX,WAAW,CAEtB;AAEF;IAGE,YAAY,iBAAoC;QAC9C,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;IAC7C,CAAC;IAED,OAAO;QACL,OAAO,kCAAiB,CAAC,yBAAyB,CAAC;IACrD,CAAC;IAEM,IAAI;QACT,OAAO;YACL,SAAS,EAAE,KAAK,EAAE,IAAoB,EAAE,EAAE;gBACxC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC;gBACrD,IAAI,OAAO,EAAE,CAAC;oBACZ,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CACnC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CACpC,CAAC;gBACJ,CAAC;gBACD,OAAO,IAAI,CAAC;YACd,CAAC;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-token.request.js","sourceRoot":"","sources":["../../../src/plugins/api-token/api-token.request.ts"],"names":[],"mappings":";;;AACA,2DAA0F;AAE1F,
|
|
1
|
+
{"version":3,"file":"api-token.request.js","sourceRoot":"","sources":["../../../src/plugins/api-token/api-token.request.ts"],"names":[],"mappings":";;;AACA,2DAA0F;AAE1F,gBAAgB;AAChB;IAGE,YAAY,QAAgB;QAC1B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,OAAO;QACL,OAAO,kCAAiB,CAAC,iBAAiB,CAAC;IAC7C,CAAC;IAEM,IAAI;QACT,OAAO;YACL,SAAS,EAAE,CAAC,IAAoB,EAAE,EAAE;gBAClC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,UAAU,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;gBAChE,OAAO,IAAI,CAAC;YACd,CAAC;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BasicAuthenticationRequest = void 0;
|
|
4
4
|
const request_plugin_1 = require("../core/request-plugin");
|
|
5
|
+
/** @internal */
|
|
5
6
|
class BasicAuthenticationRequest {
|
|
6
7
|
constructor(userName, password) {
|
|
7
8
|
this.userName = userName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basic-authentication.request.js","sourceRoot":"","sources":["../../../src/plugins/basicAuthentication/basic-authentication.request.ts"],"names":[],"mappings":";;;AACA,2DAA0F;AAE1F,
|
|
1
|
+
{"version":3,"file":"basic-authentication.request.js","sourceRoot":"","sources":["../../../src/plugins/basicAuthentication/basic-authentication.request.ts"],"names":[],"mappings":";;;AACA,2DAA0F;AAE1F,gBAAgB;AAChB;IAIE,YAAY,QAAgB,EAAE,QAAgB;QAC5C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,OAAO;QACL,OAAO,kCAAiB,CAAC,4BAA4B,CAAC;IACxD,CAAC;IAEM,IAAI;QACT,OAAO;YACL,SAAS,EAAE,CAAC,IAAoB,EAAE,EAAE;gBAClC,MAAM,SAAS,GACX,QAAQ;sBACR,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;gBACxE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;gBAChD,OAAO,IAAI,CAAC;YACd,CAAC;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './plugin';
|
|
2
|
-
export
|
|
2
|
+
export * from './request-plugin';
|
|
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./plugin"), exports);
|
|
18
|
+
__exportStar(require("./request-plugin"), exports);
|
|
18
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/core/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/core/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,mDAAiC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Plugin, PluginRunner } from './plugin';
|
|
2
2
|
import { Headers, RequestInit } from 'node-fetch';
|
|
3
3
|
import FormData = require('form-data');
|
|
4
|
+
import { WithLogger } from '../../domain';
|
|
4
5
|
export type RequestBody = string | FormData;
|
|
5
6
|
export declare enum RequestPluginEnum {
|
|
6
7
|
ADDITIONAL_HEADER_REQUEST = "AdditionalHeadersRequest",
|
|
@@ -11,7 +12,7 @@ export declare enum RequestPluginEnum {
|
|
|
11
12
|
VERSION_REQUEST = "VersionRequest",
|
|
12
13
|
X_TIMESTAMP_REQUEST = "XTimestampRequest"
|
|
13
14
|
}
|
|
14
|
-
export interface RequestOptions extends RequestInit {
|
|
15
|
+
export interface RequestOptions extends RequestInit, WithLogger {
|
|
15
16
|
/** Query Parameters */
|
|
16
17
|
queryParams?: {
|
|
17
18
|
[key: string]: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-plugin.js","sourceRoot":"","sources":["../../../src/plugins/core/request-plugin.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"request-plugin.js","sourceRoot":"","sources":["../../../src/plugins/core/request-plugin.ts"],"names":[],"mappings":";;;AAOA,IAAY,iBAQX;AARD,WAAY,iBAAiB;IAC3B,2EAAsD,CAAA;IACtD,0DAAqC,CAAA;IACrC,gFAA2D,CAAA;IAC3D,gEAA2C,CAAA;IAC3C,uDAAkC,CAAA;IAClC,uDAAkC,CAAA;IAClC,8DAAyC,CAAA;AAC3C,CAAC,EARW,iBAAiB,aAAjB,iBAAiB,GAAjB,iBAAiB,QAQ5B"}
|
|
@@ -3,13 +3,14 @@ import { ResponsePlugin, ResponsePluginContext } from '../core/response-plugin';
|
|
|
3
3
|
/**
|
|
4
4
|
* Plugin to fire an exception on wrong response / data
|
|
5
5
|
*/
|
|
6
|
+
/** @internal */
|
|
6
7
|
export declare class ExceptionResponse<V extends Record<string, any> | undefined = Record<string, any>> implements ResponsePlugin<V | Record<string, unknown>, V> {
|
|
7
8
|
private callback?;
|
|
8
9
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
* Initialize an instance of the class, with an optional callback function for exception handling.
|
|
11
|
+
*
|
|
12
|
+
* @param {Function} [callback] - A function called in case of an exception. If provided, this function is responsible for throwing the exception or not.
|
|
13
|
+
*/
|
|
13
14
|
constructor(callback?: ((res: V, error: Error | undefined) => V) | undefined);
|
|
14
15
|
load(context: ResponsePluginContext): PluginRunner<V | Record<string, unknown>, V>;
|
|
15
16
|
}
|
|
@@ -5,12 +5,13 @@ const api_errors_1 = require("../../api/api-errors");
|
|
|
5
5
|
/**
|
|
6
6
|
* Plugin to fire an exception on wrong response / data
|
|
7
7
|
*/
|
|
8
|
+
/** @internal */
|
|
8
9
|
class ExceptionResponse {
|
|
9
10
|
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
* Initialize an instance of the class, with an optional callback function for exception handling.
|
|
12
|
+
*
|
|
13
|
+
* @param {Function} [callback] - A function called in case of an exception. If provided, this function is responsible for throwing the exception or not.
|
|
14
|
+
*/
|
|
14
15
|
constructor(callback) {
|
|
15
16
|
this.callback = callback;
|
|
16
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exception.response.js","sourceRoot":"","sources":["../../../src/plugins/exception/exception.response.ts"],"names":[],"mappings":";;;AAAA,qDAA8E;AAI9E;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"exception.response.js","sourceRoot":"","sources":["../../../src/plugins/exception/exception.response.ts"],"names":[],"mappings":";;;AAAA,qDAA8E;AAI9E;;GAEG;AACH,gBAAgB;AAChB;IAIE;;;;KAIC;IACD,YACU,QAAkD;wBAAlD,QAAQ;IACf,CAAC;IAEG,IAAI,CACT,OAA8B;QAE9B,OAAO;YACL,SAAS,EAAE,CAA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IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;wBAClB,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;oBACnC,CAAC;yBAAM,CAAC;wBACN,MAAM,KAAK,CAAC;oBACd,CAAC;gBACH,CAAC;gBACD,OAAO,GAAG,CAAC;YACb,CAAC;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth2-api.js","sourceRoot":"","sources":["../../../src/plugins/oauth2/oauth2-api.ts"],"names":[],"mappings":";;;AAUA
|
|
1
|
+
{"version":3,"file":"oauth2-api.js","sourceRoot":"","sources":["../../../src/plugins/oauth2/oauth2-api.ts"],"names":[],"mappings":";;;AAUA;IAOE,YAAY,SAAoB;QANhC,kBAAkB;QACF,YAAO,GAAG,WAAW,CAAC;QAMpC,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;IAC1B,CAAC;IAEM,KAAK,CAAC,eAAe;QAC1B,MAAM,OAAO,GAA8B;YACzC,cAAc,EAAE,mCAAmC;SACpD,CAAC;QACF,MAAM,IAAI,GAAG,GAAG,kBAAkB,CAAC,YAAY,CAAC,IAAI,kBAAkB,CACpE,oBAAoB,CACrB,EAAE,CAAC;QACJ,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,QAAQ,eAAe,CAAC;QACpE,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,cAAc,CACrD,GAAG,EACH,MAAM,EACN,EAAE,EACF,OAAO,EACP,IAAI,CACL,CAAC;QACF,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAW;YACvC,GAAG;YACH,cAAc;YACd,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,WAAW,EAAE,aAAa;SAC3B,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { PluginRunner } from '../core';
|
|
2
2
|
import { RequestOptions, RequestPlugin } from '../core/request-plugin';
|
|
3
|
+
import { WithRetryPolicy } from '../../domain';
|
|
4
|
+
import { Logger } from '../../logger';
|
|
5
|
+
/** @internal */
|
|
3
6
|
export declare class Oauth2TokenRequest implements RequestPlugin {
|
|
4
7
|
private readonly apiClient;
|
|
5
8
|
private token;
|
|
6
9
|
/** Shared promise for concurrent token refresh */
|
|
7
10
|
private pendingTokenRefresh;
|
|
8
11
|
getName(): string;
|
|
9
|
-
constructor(clientId: string, clientSecret: string, authenticationUrl?: string);
|
|
12
|
+
constructor(clientId: string, clientSecret: string, authenticationUrl?: string, logger?: Logger | null, timeoutSeconds?: number, retryPolicy?: WithRetryPolicy);
|
|
10
13
|
private getOAuth2Token;
|
|
11
14
|
private fetchNewToken;
|
|
12
|
-
/**
|
|
13
|
-
* Call the auth endpoint, retrying only on 429 with full-jitter backoff.
|
|
14
|
-
* Other failures (network, 5xx, malformed response) propagate immediately
|
|
15
|
-
*/
|
|
16
|
-
private callAuthWithRateLimitRetry;
|
|
17
15
|
private buildAuthorizationHeader;
|
|
18
16
|
private isTokenValid;
|
|
19
17
|
load(): PluginRunner<RequestOptions, RequestOptions>;
|