@sinch/sdk-client 0.0.0 → 0.0.2
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/README.md +2 -2
- package/dist/api/api-client-options.d.ts +2 -1
- package/dist/api/api-client.d.ts +11 -2
- package/dist/api/api-client.js +27 -5
- package/dist/api/api-client.js.map +1 -1
- package/dist/api/api-errors.d.ts +2 -2
- package/dist/api/api-errors.js +2 -2
- package/dist/api/api-errors.js.map +1 -1
- package/dist/api/callback-webhooks-interface.d.ts +6 -0
- package/dist/api/callback-webhooks-interface.js +3 -0
- package/dist/api/callback-webhooks-interface.js.map +1 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +1 -0
- package/dist/api/index.js.map +1 -1
- package/dist/client/api-client-helpers.d.ts +7 -1
- package/dist/client/api-client-helpers.js +36 -3
- package/dist/client/api-client-helpers.js.map +1 -1
- package/dist/client/api-client-pagination-helper.d.ts +2 -2
- package/dist/client/api-client-pagination-helper.js +5 -5
- package/dist/client/api-client-pagination-helper.js.map +1 -1
- package/dist/client/api-fetch-client.js +35 -12
- package/dist/client/api-fetch-client.js.map +1 -1
- package/dist/domain/domain-interface.d.ts +16 -0
- package/dist/domain/domain-interface.js +29 -1
- package/dist/domain/domain-interface.js.map +1 -1
- package/dist/plugins/additional-headers/additional-headers.request.d.ts +3 -1
- package/dist/plugins/additional-headers/additional-headers.request.js +4 -0
- package/dist/plugins/additional-headers/additional-headers.request.js.map +1 -1
- package/dist/plugins/api-token/api-token.request.d.ts +3 -1
- package/dist/plugins/api-token/api-token.request.js +4 -0
- package/dist/plugins/api-token/api-token.request.js.map +1 -1
- package/dist/plugins/basicAuthentication/basic-authentication.request.d.ts +3 -1
- package/dist/plugins/basicAuthentication/basic-authentication.request.js +4 -0
- package/dist/plugins/basicAuthentication/basic-authentication.request.js.map +1 -1
- package/dist/plugins/core/index.d.ts +1 -2
- package/dist/plugins/core/index.js +0 -2
- package/dist/plugins/core/index.js.map +1 -1
- package/dist/plugins/core/request-plugin.d.ts +11 -0
- package/dist/plugins/core/request-plugin.js +11 -0
- package/dist/plugins/core/request-plugin.js.map +1 -1
- package/dist/plugins/exception/exception.response.d.ts +2 -1
- package/dist/plugins/exception/exception.response.js.map +1 -1
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.js +1 -0
- package/dist/plugins/index.js.map +1 -1
- package/dist/plugins/oauth2/index.d.ts +0 -1
- package/dist/plugins/oauth2/index.js +0 -1
- package/dist/plugins/oauth2/index.js.map +1 -1
- package/dist/plugins/oauth2/oauth2-token.request.d.ts +3 -5
- package/dist/plugins/oauth2/oauth2-token.request.js +6 -2
- package/dist/plugins/oauth2/oauth2-token.request.js.map +1 -1
- package/dist/plugins/signing/signing.request.d.ts +3 -4
- package/dist/plugins/signing/signing.request.js +7 -46
- package/dist/plugins/signing/signing.request.js.map +1 -1
- package/dist/plugins/timezone/index.d.ts +1 -0
- package/dist/plugins/timezone/index.js +18 -0
- package/dist/plugins/timezone/index.js.map +1 -0
- package/dist/plugins/timezone/timezone.response.d.ts +5 -0
- package/dist/plugins/timezone/timezone.response.js +50 -0
- package/dist/plugins/timezone/timezone.response.js.map +1 -0
- package/dist/plugins/version/version.request.d.ts +3 -1
- package/dist/plugins/version/version.request.js +4 -1
- package/dist/plugins/version/version.request.js.map +1 -1
- package/dist/plugins/x-timestamp/x-timestamp.request.d.ts +3 -1
- package/dist/plugins/x-timestamp/x-timestamp.request.js +4 -0
- package/dist/plugins/x-timestamp/x-timestamp.request.js.map +1 -1
- package/dist/utils/authorization.helper.d.ts +46 -0
- package/dist/utils/authorization.helper.js +202 -0
- package/dist/utils/authorization.helper.js.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ApiTokenRequest = void 0;
|
|
4
|
+
const request_plugin_1 = require("../core/request-plugin");
|
|
4
5
|
class ApiTokenRequest {
|
|
5
6
|
constructor(apiToken) {
|
|
6
7
|
this.apiToken = apiToken;
|
|
7
8
|
}
|
|
9
|
+
getName() {
|
|
10
|
+
return request_plugin_1.RequestPluginEnum.API_TOKEN_REQUEST;
|
|
11
|
+
}
|
|
8
12
|
load() {
|
|
9
13
|
return {
|
|
10
14
|
transform: (data) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-token.request.js","sourceRoot":"","sources":["../../../src/plugins/api-token/api-token.request.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"api-token.request.js","sourceRoot":"","sources":["../../../src/plugins/api-token/api-token.request.ts"],"names":[],"mappings":";;;AACA,2DAA0F;AAE1F,MAAa,eAAe;IAG1B,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;AAnBD,0CAmBC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { PluginRunner
|
|
1
|
+
import { PluginRunner } from '../core';
|
|
2
|
+
import { RequestOptions, RequestPlugin } from '../core/request-plugin';
|
|
2
3
|
export declare class BasicAuthenticationRequest implements RequestPlugin {
|
|
3
4
|
private readonly userName;
|
|
4
5
|
private readonly password;
|
|
5
6
|
constructor(userName: string, password: string);
|
|
7
|
+
getName(): string;
|
|
6
8
|
load(): PluginRunner<RequestOptions, RequestOptions>;
|
|
7
9
|
}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BasicAuthenticationRequest = void 0;
|
|
4
|
+
const request_plugin_1 = require("../core/request-plugin");
|
|
4
5
|
class BasicAuthenticationRequest {
|
|
5
6
|
constructor(userName, password) {
|
|
6
7
|
this.userName = userName;
|
|
7
8
|
this.password = password;
|
|
8
9
|
}
|
|
10
|
+
getName() {
|
|
11
|
+
return request_plugin_1.RequestPluginEnum.BASIC_AUTHENTICATION_REQUEST;
|
|
12
|
+
}
|
|
9
13
|
load() {
|
|
10
14
|
return {
|
|
11
15
|
transform: (data) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basic-authentication.request.js","sourceRoot":"","sources":["../../../src/plugins/basicAuthentication/basic-authentication.request.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"basic-authentication.request.js","sourceRoot":"","sources":["../../../src/plugins/basicAuthentication/basic-authentication.request.ts"],"names":[],"mappings":";;;AACA,2DAA0F;AAE1F,MAAa,0BAA0B;IAIrC,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;AAxBD,gEAwBC"}
|
|
@@ -15,6 +15,4 @@ 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);
|
|
19
|
-
__exportStar(require("./response-plugin"), exports);
|
|
20
18
|
//# 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"}
|
|
@@ -2,6 +2,15 @@ import { Plugin, PluginRunner } from './plugin';
|
|
|
2
2
|
import { Headers, RequestInit } from 'node-fetch';
|
|
3
3
|
import FormData = require('form-data');
|
|
4
4
|
export type RequestBody = string | FormData;
|
|
5
|
+
export declare enum RequestPluginEnum {
|
|
6
|
+
ADDITIONAL_HEADER_REQUEST = "AdditionalHeadersRequest",
|
|
7
|
+
API_TOKEN_REQUEST = "ApiTokenRequest",
|
|
8
|
+
BASIC_AUTHENTICATION_REQUEST = "BasicAuthenticationRequest",
|
|
9
|
+
OAUTH2_TOKEN_REQUEST = "Oauth2TokenRequest",
|
|
10
|
+
SIGNING_REQUEST = "SigningRequest",
|
|
11
|
+
VERSION_REQUEST = "VersionRequest",
|
|
12
|
+
X_TIMESTAMP_REQUEST = "XTimestampRequest"
|
|
13
|
+
}
|
|
5
14
|
export interface RequestOptions extends RequestInit {
|
|
6
15
|
/** Query Parameters */
|
|
7
16
|
queryParams?: {
|
|
@@ -21,6 +30,8 @@ export interface RequestOptions extends RequestInit {
|
|
|
21
30
|
* The plugin will be run on the request of a call
|
|
22
31
|
*/
|
|
23
32
|
export interface RequestPlugin extends Plugin<RequestOptions, RequestOptions> {
|
|
33
|
+
/** Unique identifier of the plugin */
|
|
34
|
+
getName(): string;
|
|
24
35
|
/** Load the plugin with the context */
|
|
25
36
|
load(): PluginRunner<RequestOptions, RequestOptions>;
|
|
26
37
|
}
|
|
@@ -1,3 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RequestPluginEnum = void 0;
|
|
4
|
+
var RequestPluginEnum;
|
|
5
|
+
(function (RequestPluginEnum) {
|
|
6
|
+
RequestPluginEnum["ADDITIONAL_HEADER_REQUEST"] = "AdditionalHeadersRequest";
|
|
7
|
+
RequestPluginEnum["API_TOKEN_REQUEST"] = "ApiTokenRequest";
|
|
8
|
+
RequestPluginEnum["BASIC_AUTHENTICATION_REQUEST"] = "BasicAuthenticationRequest";
|
|
9
|
+
RequestPluginEnum["OAUTH2_TOKEN_REQUEST"] = "Oauth2TokenRequest";
|
|
10
|
+
RequestPluginEnum["SIGNING_REQUEST"] = "SigningRequest";
|
|
11
|
+
RequestPluginEnum["VERSION_REQUEST"] = "VersionRequest";
|
|
12
|
+
RequestPluginEnum["X_TIMESTAMP_REQUEST"] = "XTimestampRequest";
|
|
13
|
+
})(RequestPluginEnum || (exports.RequestPluginEnum = RequestPluginEnum = {}));
|
|
3
14
|
//# sourceMappingURL=request-plugin.js.map
|
|
@@ -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":";;;AAMA,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,iCAAjB,iBAAiB,QAQ5B"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { PluginRunner
|
|
1
|
+
import { PluginRunner } from '../core';
|
|
2
|
+
import { ResponsePlugin, ResponsePluginContext } from '../core/response-plugin';
|
|
2
3
|
/**
|
|
3
4
|
* Plugin to fire an exception on wrong response / data
|
|
4
5
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exception.response.js","sourceRoot":"","sources":["../../../src/plugins/exception/exception.response.ts"],"names":[],"mappings":";;;AAAA,mCAAmE;
|
|
1
|
+
{"version":3,"file":"exception.response.js","sourceRoot":"","sources":["../../../src/plugins/exception/exception.response.ts"],"names":[],"mappings":";;;AAAA,mCAAmE;AAInE;;GAEG;AACH,MAAa,iBAAiB;IAI9B;;;;OAIG;IACD,YAAoB,QAAkD;QAAlD,aAAQ,GAAR,QAAQ,CAA0C;IAAG,CAAC;IAEnE,IAAI,CACT,OAA8B;QAE9B,OAAO;YACL,SAAS,EAAE,CAAC,GAAM,EAAE,EAAE;gBACpB,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;oBACtB,OAAO,GAAG,CAAC;gBACb,CAAC;gBAED,MAAM,YAAY,GAAG;oBACnB,OAAO,EAAE,OAAO,CAAC,OAAO;oBACxB,WAAW,EAAE,OAAO,CAAC,WAAW;oBAChC,GAAG,EAAE,OAAO,CAAC,GAAG;oBAChB,MAAM,EAAE,OAAO,CAAC,MAAM;iBACvB,CAAC;gBACF,IAAI,KAAwB,CAAC;gBAE7B,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;oBACtB,KAAK,GAAG,IAAI,wBAAkB,CAC5B,eAAe,EACf,YAAY,EACZ,SAAS,CACV,CAAC;gBACJ,CAAC;qBAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;oBAChC,KAAK,GAAG,IAAI,wBAAkB,CAC5B,OAAO,CAAC,QAAQ,CAAC,UAAU,EAC3B,OAAO,CAAC,QAAQ,CAAC,MAAM,EACvB,YAAY,EACZ,GAAG,CACJ,CAAC;gBACJ,CAAC;qBAAM,IAAI,CAAC,GAAG,EAAE,CAAC;oBAChB,GAAG,GAAG,EAAO,CAAC;oBACd,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;wBACvE,GAAG,GAAG,EAAO,CAAC;wBACd,KAAK,GAAG,IAAI,wBAAkB,CAC5B,OAAO,CAAC,QAAQ,CAAC,UAAU,EAC3B,YAAY,EACZ,GAAG,CACJ,CAAC;oBACJ,CAAC;gBACH,CAAC;gBAED,IAAI,KAAK,EAAE,CAAC;oBACV,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;AAhED,8CAgEC"}
|
package/dist/plugins/index.d.ts
CHANGED
package/dist/plugins/index.js
CHANGED
|
@@ -20,6 +20,7 @@ __exportStar(require("./basicAuthentication"), exports);
|
|
|
20
20
|
__exportStar(require("./exception"), exports);
|
|
21
21
|
__exportStar(require("./oauth2"), exports);
|
|
22
22
|
__exportStar(require("./signing"), exports);
|
|
23
|
+
__exportStar(require("./timezone"), exports);
|
|
23
24
|
__exportStar(require("./version"), exports);
|
|
24
25
|
__exportStar(require("./x-timestamp"), exports);
|
|
25
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,8CAA4B;AAC5B,wDAAsC;AACtC,8CAA4B;AAC5B,2CAAyB;AACzB,4CAA0B;AAC1B,4CAA0B;AAC1B,gDAA8B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,8CAA4B;AAC5B,wDAAsC;AACtC,8CAA4B;AAC5B,2CAAyB;AACzB,4CAA0B;AAC1B,6CAA2B;AAC3B,4CAA0B;AAC1B,gDAA8B"}
|
|
@@ -14,6 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./oauth2-api"), exports);
|
|
18
17
|
__exportStar(require("./oauth2-token.request"), exports);
|
|
19
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/oauth2/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/oauth2/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { PluginRunner
|
|
1
|
+
import { PluginRunner } from '../core';
|
|
2
|
+
import { RequestOptions, RequestPlugin } from '../core/request-plugin';
|
|
2
3
|
export declare class Oauth2TokenRequest implements RequestPlugin {
|
|
3
4
|
private readonly apiClient;
|
|
4
5
|
private token;
|
|
6
|
+
getName(): string;
|
|
5
7
|
constructor(clientId: string, clientSecret: string, authenticationUrl?: string);
|
|
6
8
|
private getOAuth2Token;
|
|
7
9
|
private buildAuthorizationHeader;
|
|
@@ -9,7 +11,3 @@ export declare class Oauth2TokenRequest implements RequestPlugin {
|
|
|
9
11
|
load(): PluginRunner<RequestOptions, RequestOptions>;
|
|
10
12
|
invalidateToken(): void;
|
|
11
13
|
}
|
|
12
|
-
export declare enum TokenStatus {
|
|
13
|
-
INVALID = 0,
|
|
14
|
-
VALID = 1
|
|
15
|
-
}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.Oauth2TokenRequest = void 0;
|
|
4
|
+
const request_plugin_1 = require("../core/request-plugin");
|
|
4
5
|
const additional_headers_1 = require("../additional-headers");
|
|
5
6
|
const oauth2_api_1 = require("./oauth2-api");
|
|
6
7
|
const basicAuthentication_1 = require("../basicAuthentication");
|
|
7
8
|
const client_1 = require("../../client");
|
|
8
9
|
class Oauth2TokenRequest {
|
|
10
|
+
getName() {
|
|
11
|
+
return request_plugin_1.RequestPluginEnum.OAUTH2_TOKEN_REQUEST;
|
|
12
|
+
}
|
|
9
13
|
constructor(clientId, clientSecret, authenticationUrl) {
|
|
10
14
|
const basicAuthenticationPlugin = new basicAuthentication_1.BasicAuthenticationRequest(clientId, clientSecret);
|
|
11
15
|
if (!authenticationUrl) {
|
|
@@ -72,5 +76,5 @@ var TokenStatus;
|
|
|
72
76
|
(function (TokenStatus) {
|
|
73
77
|
TokenStatus[TokenStatus["INVALID"] = 0] = "INVALID";
|
|
74
78
|
TokenStatus[TokenStatus["VALID"] = 1] = "VALID";
|
|
75
|
-
})(TokenStatus || (
|
|
79
|
+
})(TokenStatus || (TokenStatus = {}));
|
|
76
80
|
//# sourceMappingURL=oauth2-token.request.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth2-token.request.js","sourceRoot":"","sources":["../../../src/plugins/oauth2/oauth2-token.request.ts"],"names":[],"mappings":";;;AACA,8DAAiE;AAEjE,6CAAyC;AACzC,gEAAoE;AACpE,yCAA8C;AAE9C,MAAa,kBAAkB;IAK7B,YACE,QAAgB,EAChB,YAAoB,EACpB,iBAA0B;QAE1B,MAAM,yBAAyB,GAAG,IAAI,gDAA0B,CAC9D,QAAQ,EACR,YAAY,CACb,CAAC;QACF,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACvB,iBAAiB,GAAG,wBAAwB,CAAC;QAC/C,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,uBAAc,CAAC;YAClC,QAAQ,EAAE,iBAAiB;YAC3B,cAAc,EAAE,CAAC,yBAAyB,CAAC;SAC5C,CAAC,CAAC;IACL,CAAC;IAEO,KAAK,CAAC,cAAc;QAC1B,IAAI,IAAI,CAAC,YAAY,EAAE,EAAE,CAAC;YACxB,OAAO,IAAI,CAAC,wBAAwB,EAAE,CAAC;QACzC,CAAC;QACD,MAAM,SAAS,GAAG,IAAI,sBAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAChD,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,eAAe,EAAE,CAAC;YACnD,IAAI,QAAQ,CAAC,YAAY,EAAE,CAAC;gBAC1B,IAAI,CAAC,KAAK,GAAG;oBACX,KAAK,EAAE,QAAQ,CAAC,YAAY;oBAC5B,MAAM,EAAE,WAAW,CAAC,KAAK;iBAC1B,CAAC;gBACF,OAAO,IAAI,CAAC,wBAAwB,EAAE,CAAC;YACzC,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,KAAK,GAAG;oBACX,KAAK,EAAE,EAAE;oBACT,MAAM,EAAE,WAAW,CAAC,OAAO;iBAC5B,CAAC;gBACF,OAAO,CAAC,KAAK,CAAC,gDAAgD,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAC3F,OAAO,EAAE,CAAC;YACZ,CAAC;QACH,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,CAAC,KAAK,GAAG;gBACX,KAAK,EAAE,EAAE;gBACT,MAAM,EAAE,WAAW,CAAC,OAAO;aAC5B,CAAC;YACF,OAAO,CAAC,KAAK,CAAC,kEAAkE,GAAG,CAAC,CAAC,CAAC;YACtF,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;IAGO,wBAAwB;QAC9B,OAAO,EAAE,aAAa,EAAE,UAAU,IAAI,CAAC,KAAM,CAAC,KAAK,EAAE,EAAE,CAAC;IAC1D,CAAC;IAEO,YAAY;QAClB,OAAO,CACL,IAAI,CAAC,KAAK;eACP,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,WAAW,CAAC,KAAK;eACvC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CACtC,CAAC;IACJ,CAAC;IAEM,IAAI;QACT,OAAO;YACL,SAAS,EAAE,IAAI,6CAAwB,CAAC;gBACtC,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE;aAC/B,CAAC,CAAC,IAAI,EAAE,CAAC,SAAS;SACpB,CAAC;IACJ,CAAC;IAEM,eAAe;QACpB,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;IACzB,CAAC;CACF;
|
|
1
|
+
{"version":3,"file":"oauth2-token.request.js","sourceRoot":"","sources":["../../../src/plugins/oauth2/oauth2-token.request.ts"],"names":[],"mappings":";;;AACA,2DAA0F;AAC1F,8DAAiE;AAEjE,6CAAyC;AACzC,gEAAoE;AACpE,yCAA8C;AAE9C,MAAa,kBAAkB;IAK7B,OAAO;QACL,OAAO,kCAAiB,CAAC,oBAAoB,CAAC;IAChD,CAAC;IAED,YACE,QAAgB,EAChB,YAAoB,EACpB,iBAA0B;QAE1B,MAAM,yBAAyB,GAAG,IAAI,gDAA0B,CAC9D,QAAQ,EACR,YAAY,CACb,CAAC;QACF,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACvB,iBAAiB,GAAG,wBAAwB,CAAC;QAC/C,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,uBAAc,CAAC;YAClC,QAAQ,EAAE,iBAAiB;YAC3B,cAAc,EAAE,CAAC,yBAAyB,CAAC;SAC5C,CAAC,CAAC;IACL,CAAC;IAEO,KAAK,CAAC,cAAc;QAC1B,IAAI,IAAI,CAAC,YAAY,EAAE,EAAE,CAAC;YACxB,OAAO,IAAI,CAAC,wBAAwB,EAAE,CAAC;QACzC,CAAC;QACD,MAAM,SAAS,GAAG,IAAI,sBAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAChD,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,eAAe,EAAE,CAAC;YACnD,IAAI,QAAQ,CAAC,YAAY,EAAE,CAAC;gBAC1B,IAAI,CAAC,KAAK,GAAG;oBACX,KAAK,EAAE,QAAQ,CAAC,YAAY;oBAC5B,MAAM,EAAE,WAAW,CAAC,KAAK;iBAC1B,CAAC;gBACF,OAAO,IAAI,CAAC,wBAAwB,EAAE,CAAC;YACzC,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,KAAK,GAAG;oBACX,KAAK,EAAE,EAAE;oBACT,MAAM,EAAE,WAAW,CAAC,OAAO;iBAC5B,CAAC;gBACF,OAAO,CAAC,KAAK,CAAC,gDAAgD,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAC3F,OAAO,EAAE,CAAC;YACZ,CAAC;QACH,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,CAAC,KAAK,GAAG;gBACX,KAAK,EAAE,EAAE;gBACT,MAAM,EAAE,WAAW,CAAC,OAAO;aAC5B,CAAC;YACF,OAAO,CAAC,KAAK,CAAC,kEAAkE,GAAG,CAAC,CAAC,CAAC;YACtF,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;IAGO,wBAAwB;QAC9B,OAAO,EAAE,aAAa,EAAE,UAAU,IAAI,CAAC,KAAM,CAAC,KAAK,EAAE,EAAE,CAAC;IAC1D,CAAC;IAEO,YAAY;QAClB,OAAO,CACL,IAAI,CAAC,KAAK;eACP,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,WAAW,CAAC,KAAK;eACvC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CACtC,CAAC;IACJ,CAAC;IAEM,IAAI;QACT,OAAO;YACL,SAAS,EAAE,IAAI,6CAAwB,CAAC;gBACtC,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE;aAC/B,CAAC,CAAC,IAAI,EAAE,CAAC,SAAS;SACpB,CAAC;IACJ,CAAC;IAEM,eAAe;QACpB,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;IACzB,CAAC;CACF;AAlFD,gDAkFC;AAOD,IAAK,WAGJ;AAHD,WAAK,WAAW;IACd,mDAAO,CAAA;IACP,+CAAK,CAAA;AACP,CAAC,EAHI,WAAW,KAAX,WAAW,QAGf"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { PluginRunner
|
|
2
|
-
|
|
3
|
-
export declare const calculateHMACSHA256: (secret: string, stringToSign: string) => string;
|
|
4
|
-
export declare const generateAuthorizationHeader: (httpVerb: string, contentMD5: string, contentType: string, canonicalizedHeaders: string, canonicalizedResource: string, applicationKey: string, applicationSecret: string) => string;
|
|
1
|
+
import { PluginRunner } from '../core';
|
|
2
|
+
import { RequestOptions, RequestPlugin } from '../core/request-plugin';
|
|
5
3
|
export declare class SigningRequest implements RequestPlugin {
|
|
6
4
|
private readonly applicationId;
|
|
7
5
|
private readonly applicationSecret;
|
|
8
6
|
constructor(applicationId: string, applicationSecret: string);
|
|
7
|
+
getName(): string;
|
|
9
8
|
load(): PluginRunner<RequestOptions, RequestOptions>;
|
|
10
9
|
}
|
|
@@ -1,53 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.SigningRequest =
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
// Content-MD5 = Base64 ( MD5 ( UTF8 ( [BODY] ) ) )
|
|
30
|
-
return crypto.createHash('md5').update(Buffer.from(body, 'utf-8')).digest('base64');
|
|
31
|
-
};
|
|
32
|
-
exports.calculateMD5 = calculateMD5;
|
|
33
|
-
const calculateHMACSHA256 = (secret, stringToSign) => {
|
|
34
|
-
// Signature = Base64 ( HMAC-SHA256 ( Base64-Decode ( ApplicationSecret ), UTF8 ( StringToSign ) ) );
|
|
35
|
-
return crypto.createHmac('sha256', Buffer.from(secret, 'base64'))
|
|
36
|
-
.update(Buffer.from(stringToSign, 'utf-8'))
|
|
37
|
-
.digest('base64');
|
|
38
|
-
};
|
|
39
|
-
exports.calculateHMACSHA256 = calculateHMACSHA256;
|
|
40
|
-
const generateAuthorizationHeader = (httpVerb, contentMD5, contentType, canonicalizedHeaders, canonicalizedResource, applicationKey, applicationSecret) => {
|
|
41
|
-
const stringToSign = `${httpVerb}\n${contentMD5}\n${contentType}\n${canonicalizedHeaders}\n${canonicalizedResource}`;
|
|
42
|
-
const signature = (0, exports.calculateHMACSHA256)(applicationSecret, stringToSign);
|
|
43
|
-
return `Application ${applicationKey}:${signature}`;
|
|
44
|
-
};
|
|
45
|
-
exports.generateAuthorizationHeader = generateAuthorizationHeader;
|
|
3
|
+
exports.SigningRequest = void 0;
|
|
4
|
+
const request_plugin_1 = require("../core/request-plugin");
|
|
5
|
+
const authorization_helper_1 = require("../../utils/authorization.helper");
|
|
46
6
|
class SigningRequest {
|
|
47
7
|
constructor(applicationId, applicationSecret) {
|
|
48
8
|
this.applicationId = applicationId;
|
|
49
9
|
this.applicationSecret = applicationSecret;
|
|
50
10
|
}
|
|
11
|
+
getName() {
|
|
12
|
+
return request_plugin_1.RequestPluginEnum.SIGNING_REQUEST;
|
|
13
|
+
}
|
|
51
14
|
load() {
|
|
52
15
|
return {
|
|
53
16
|
transform: (data) => {
|
|
@@ -57,9 +20,7 @@ class SigningRequest {
|
|
|
57
20
|
if (!data.path) {
|
|
58
21
|
throw new Error('The URL path must be defined.');
|
|
59
22
|
}
|
|
60
|
-
const
|
|
61
|
-
const contentMD5 = hasBody ? (0, exports.calculateMD5)(data.body) : '';
|
|
62
|
-
const authorizationHeader = (0, exports.generateAuthorizationHeader)(data.method.toUpperCase(), contentMD5, data.headers.get('Content-Type'), `x-timestamp:${data.headers.get('x-timestamp')}`, data.path, this.applicationId, this.applicationSecret);
|
|
23
|
+
const authorizationHeader = (0, authorization_helper_1.generateAuthorizationHeader)(data.method.toUpperCase(), data.body, data.headers.get('Content-Type'), `x-timestamp:${data.headers.get('x-timestamp')}`, data.path, this.applicationId, this.applicationSecret);
|
|
63
24
|
data.headers.append('Authorization', authorizationHeader);
|
|
64
25
|
return data;
|
|
65
26
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signing.request.js","sourceRoot":"","sources":["../../../src/plugins/signing/signing.request.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"signing.request.js","sourceRoot":"","sources":["../../../src/plugins/signing/signing.request.ts"],"names":[],"mappings":";;;AACA,2DAA0F;AAC1F,2EAA+E;AAE/E,MAAa,cAAc;IAIzB,YAAY,aAAqB,EAAE,iBAAyB;QAC1D,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;IAC7C,CAAC;IAED,OAAO;QACL,OAAO,kCAAiB,CAAC,eAAe,CAAC;IAC3C,CAAC;IAEM,IAAI;QACT,OAAO;YACL,SAAS,EAAE,CAAC,IAAoB,EAAE,EAAE;gBAClC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;oBACjB,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;gBACtD,CAAC;gBACD,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;oBACf,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;gBACnD,CAAC;gBACD,MAAM,mBAAmB,GAAG,IAAA,kDAA2B,EACrD,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,EACzB,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAE,EACjC,eAAe,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,EAChD,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,aAAa,EAClB,IAAI,CAAC,iBAAiB,CACvB,CAAC;gBACF,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,mBAAmB,CAAC,CAAC;gBAC1D,OAAO,IAAI,CAAC;YACd,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AApCD,wCAoCC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './timezone.response';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./timezone.response"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/timezone/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ResponsePlugin, ResponsePluginContext } from '../core/response-plugin';
|
|
2
|
+
import { PluginRunner } from '../core';
|
|
3
|
+
export declare class TimezoneResponse<V extends Record<string, any> | undefined = Record<string, any>> implements ResponsePlugin<V | Record<string, any>> {
|
|
4
|
+
load(context: ResponsePluginContext): PluginRunner<V | Record<string, unknown>, V>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TimezoneResponse = void 0;
|
|
4
|
+
const buggyOperationIds = [
|
|
5
|
+
'GetCallResult',
|
|
6
|
+
'VerificationStatusById',
|
|
7
|
+
'VerificationStatusByIdentity',
|
|
8
|
+
'VerificationStatusByReference',
|
|
9
|
+
];
|
|
10
|
+
const buggyFields = {
|
|
11
|
+
'GetCallResult': 'timestamp',
|
|
12
|
+
'VerificationStatusById': 'verificationTimestamp',
|
|
13
|
+
'VerificationStatusByIdentity': 'verificationTimestamp',
|
|
14
|
+
'VerificationStatusByReference': 'verificationTimestamp',
|
|
15
|
+
};
|
|
16
|
+
class TimezoneResponse {
|
|
17
|
+
load(context) {
|
|
18
|
+
return {
|
|
19
|
+
transform(res) {
|
|
20
|
+
// HACK to fix a server-side bug: the timestamp is returned without the timezone
|
|
21
|
+
if (res && buggyOperationIds.includes(context.operationId)) {
|
|
22
|
+
for (const key in res) {
|
|
23
|
+
if (Object.prototype.hasOwnProperty.call(res, key)) {
|
|
24
|
+
const buggyKey = buggyFields[context.operationId];
|
|
25
|
+
if (key === buggyKey && typeof res[buggyKey] === 'string') {
|
|
26
|
+
let timestampValue = res[key];
|
|
27
|
+
// Check the formats +XX:XX, +XX and Z
|
|
28
|
+
const timeZoneRegex = /([+-]\d{2}(:\d{2})|Z)$/;
|
|
29
|
+
if (!timeZoneRegex.test(timestampValue)) {
|
|
30
|
+
const hourMinutesTimezoneRegex = /([+-]\d{2})$/;
|
|
31
|
+
// A timestamp with no minutes in the timezone cannot be converted into a Date => assume it's :00
|
|
32
|
+
if (hourMinutesTimezoneRegex.test(timestampValue)) {
|
|
33
|
+
timestampValue = timestampValue + ':00';
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
timestampValue = timestampValue + 'Z';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
res[key] = new Date(timestampValue);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return res;
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.TimezoneResponse = TimezoneResponse;
|
|
50
|
+
//# sourceMappingURL=timezone.response.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timezone.response.js","sourceRoot":"","sources":["../../../src/plugins/timezone/timezone.response.ts"],"names":[],"mappings":";;;AAGA,MAAM,iBAAiB,GAAa;IAClC,eAAe;IACf,wBAAwB;IACxB,8BAA8B;IAC9B,+BAA+B;CAChC,CAAC;AAEF,MAAM,WAAW,GAA4B;IAC3C,eAAe,EAAE,WAAW;IAC5B,wBAAwB,EAAE,uBAAuB;IACjD,8BAA8B,EAAE,uBAAuB;IACvD,+BAA+B,EAAE,uBAAuB;CACzD,CAAC;AAEF,MAAa,gBAAgB;IAGpB,IAAI,CACT,OAA8B;QAE9B,OAAO;YACL,SAAS,CAAC,GAAM;gBACd,gFAAgF;gBAChF,IAAI,GAAG,IAAI,iBAAiB,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,EAAG,CAAC;oBAC5D,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;wBACtB,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;4BACnD,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;4BAClD,IAAI,GAAG,KAAK,QAAQ,IAAI,OAAO,GAAG,CAAC,QAAQ,CAAC,KAAK,QAAQ,EAAE,CAAC;gCAC1D,IAAI,cAAc,GAAG,GAAG,CAAC,GAAG,CAAW,CAAC;gCACxC,sCAAsC;gCACtC,MAAM,aAAa,GAAG,wBAAwB,CAAC;gCAC/C,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC;oCACxC,MAAM,wBAAwB,GAAG,cAAc,CAAC;oCAChD,iGAAiG;oCACjG,IAAI,wBAAwB,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC;wCAClD,cAAc,GAAG,cAAc,GAAG,KAAK,CAAC;oCAC1C,CAAC;yCAAM,CAAC;wCACN,cAAc,GAAG,cAAc,GAAG,GAAG,CAAC;oCACxC,CAAC;gCACH,CAAC;gCACD,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,CAAC;4BACtC,CAAC;wBACH,CAAC;oBACH,CAAC;gBACH,CAAC;gBACD,OAAO,GAAG,CAAC;YACb,CAAC;SACF,CAAC;IACJ,CAAC;CAEF;AApCD,4CAoCC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { PluginRunner
|
|
1
|
+
import { PluginRunner } from '../core';
|
|
2
|
+
import { RequestOptions, RequestPlugin } from '../core/request-plugin';
|
|
2
3
|
export declare class VersionRequest implements RequestPlugin {
|
|
4
|
+
getName(): string;
|
|
3
5
|
load(): PluginRunner<RequestOptions, RequestOptions>;
|
|
4
6
|
}
|
|
@@ -24,10 +24,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.VersionRequest = void 0;
|
|
27
|
+
const request_plugin_1 = require("../core/request-plugin");
|
|
27
28
|
const process = __importStar(require("process"));
|
|
28
|
-
// import version from '../../getVersion';
|
|
29
29
|
const getVersion_1 = require("../../getVersion");
|
|
30
30
|
class VersionRequest {
|
|
31
|
+
getName() {
|
|
32
|
+
return request_plugin_1.RequestPluginEnum.VERSION_REQUEST;
|
|
33
|
+
}
|
|
31
34
|
load() {
|
|
32
35
|
const sdkVersion = getVersion_1.sdkCoreVersion;
|
|
33
36
|
const languageVersion = process.version;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.request.js","sourceRoot":"","sources":["../../../src/plugins/version/version.request.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,iDAAmC;AACnC,
|
|
1
|
+
{"version":3,"file":"version.request.js","sourceRoot":"","sources":["../../../src/plugins/version/version.request.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2DAA0F;AAC1F,iDAAmC;AACnC,iDAAkD;AAElD,MAAa,cAAc;IAEzB,OAAO;QACL,OAAO,kCAAiB,CAAC,eAAe,CAAC;IAC3C,CAAC;IACM,IAAI;QACT,MAAM,UAAU,GAAG,2BAAc,CAAC;QAClC,MAAM,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC;QACxC,MAAM,kBAAkB,GAAG,SAAS,CAAC;QACrC,MAAM,aAAa,GAAG,MAAM,CAAC;QAC7B,OAAO;YACL,SAAS,EAAE,CAAC,IAAoB,EAAE,EAAE;gBAClC,IAAI,CAAC,OAAO,CAAC,MAAM,CACjB,YAAY,EACZ,aAAa,UAAU,gBAAgB,eAAe,KAAK,kBAAkB,KAAK,aAAa,GAAG,CACnG,CAAC;gBACF,OAAO,IAAI,CAAC;YACd,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AApBD,wCAoBC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { PluginRunner
|
|
1
|
+
import { PluginRunner } from '../core';
|
|
2
|
+
import { RequestOptions, RequestPlugin } from '../core/request-plugin';
|
|
2
3
|
export declare class XTimestampRequest implements RequestPlugin {
|
|
4
|
+
getName(): string;
|
|
3
5
|
load(): PluginRunner<RequestOptions, RequestOptions>;
|
|
4
6
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.XTimestampRequest = void 0;
|
|
4
|
+
const request_plugin_1 = require("../core/request-plugin");
|
|
4
5
|
class XTimestampRequest {
|
|
6
|
+
getName() {
|
|
7
|
+
return request_plugin_1.RequestPluginEnum.X_TIMESTAMP_REQUEST;
|
|
8
|
+
}
|
|
5
9
|
load() {
|
|
6
10
|
return {
|
|
7
11
|
transform: (data) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"x-timestamp.request.js","sourceRoot":"","sources":["../../../src/plugins/x-timestamp/x-timestamp.request.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"x-timestamp.request.js","sourceRoot":"","sources":["../../../src/plugins/x-timestamp/x-timestamp.request.ts"],"names":[],"mappings":";;;AACA,2DAA0F;AAE1F,MAAa,iBAAiB;IAE5B,OAAO;QACL,OAAO,kCAAiB,CAAC,mBAAmB,CAAC;IAC/C,CAAC;IAEM,IAAI;QACT,OAAO;YACL,SAAS,EAAE,CAAC,IAAoB,EAAE,EAAE;gBAClC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;gBAC7D,OAAO,IAAI,CAAC;YACd,CAAC;SACF,CAAC;IACJ,CAAC;CAEF;AAfD,8CAeC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { IncomingHttpHeaders } from 'http';
|
|
3
|
+
import { RequestBody } from '../plugins';
|
|
4
|
+
/**
|
|
5
|
+
* Generate authorization header for application-signed requests (Verification and Voice)
|
|
6
|
+
* @param {string} httpVerb - request's HTTP method
|
|
7
|
+
* @param {RequestBody | undefined} body - request's body (undefined in case of GET request)
|
|
8
|
+
* @param {string} contentType - content-type header value
|
|
9
|
+
* @param {string} canonicalizedHeaders - x-timestamp header
|
|
10
|
+
* @param {string} canonicalizedResource - request's path
|
|
11
|
+
* @param {string} applicationKey - application key (from dashboard)
|
|
12
|
+
* @param {string} applicationSecret - application secret (from dashboard)
|
|
13
|
+
* @return {string} - Application signed header value for HTTP authorization header
|
|
14
|
+
*/
|
|
15
|
+
export declare const generateAuthorizationHeader: (httpVerb: string, body: RequestBody | undefined, contentType: string, canonicalizedHeaders: string, canonicalizedResource: string, applicationKey: string, applicationSecret: string) => string;
|
|
16
|
+
/**
|
|
17
|
+
* Validate webhook signature headers for Conversation callback.
|
|
18
|
+
* @param {string} secret - secret associated to the Conversation app
|
|
19
|
+
* @param {IncomingHttpHeaders} headers - Incoming request's headers
|
|
20
|
+
* @param {any} body - Incoming request's body
|
|
21
|
+
* @return {boolean} - true if the signature header is valid
|
|
22
|
+
*/
|
|
23
|
+
export declare const validateWebhookSignature: (secret: string, headers: IncomingHttpHeaders, body: any) => boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Validate authorization header for callback request on application-signed protected endpoints (Verification and Voice webhooks)
|
|
26
|
+
* @param {string} applicationKey - application key (from dashboard) related to the event
|
|
27
|
+
* @param {string} applicationSecret - application secret (from dashboard) related to the event
|
|
28
|
+
* @param {IncomingHttpHeaders} headers - Incoming request's headers
|
|
29
|
+
* @param {any} body - Incoming request's body
|
|
30
|
+
* @param {string} path - Incoming request's path
|
|
31
|
+
* @param {string} method - Incoming request's HTTP method
|
|
32
|
+
* @return {boolean} - true if the authorization header is valid
|
|
33
|
+
*/
|
|
34
|
+
export declare const validateAuthenticationHeader: (applicationKey: string, applicationSecret: string, headers: IncomingHttpHeaders, body: any, path: string, method: string) => boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Validate signature headers for Numbers callback. Note: a callbackURL must be associated to the number
|
|
37
|
+
* @param {string} callbackSecret - secret associated to the rented number
|
|
38
|
+
* @param {IncomingHttpHeaders} headers - Incoming request's headers
|
|
39
|
+
* @param {any} body - Incoming request's body
|
|
40
|
+
* @return {boolean} - true if the signature header is valid
|
|
41
|
+
*/
|
|
42
|
+
export declare const validateSignatureHeader: (callbackSecret: string, headers: IncomingHttpHeaders, body: any) => boolean;
|
|
43
|
+
export declare const computeSignedData: (body: string, nonce: string, timestamp: string) => string;
|
|
44
|
+
export declare const calculateWebhookSignature: (signedData: string, secret: string) => string;
|
|
45
|
+
export declare const calculateMD5: (body: string) => string;
|
|
46
|
+
export declare const calculateSignature: (secret: string, stringToSign: string) => string;
|