@dvelop-sdk/app-router 3.1.5 → 3.2.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 +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -2
- package/lib/index.js.map +1 -1
- package/lib/validate-cloud-center-event-signature/validate-cloud-center-event-signature.d.ts +51 -0
- package/lib/validate-cloud-center-event-signature/validate-cloud-center-event-signature.d.ts.map +1 -0
- package/lib/validate-cloud-center-event-signature/validate-cloud-center-event-signature.js +85 -0
- package/lib/validate-cloud-center-event-signature/validate-cloud-center-event-signature.js.map +1 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<a href="https://github.com/d-velop/dvelop-sdk-node">
|
|
10
10
|
<img alt="GitHub" src="https://img.shields.io/badge/GitHub-dvelop--sdk--node-%23ff0844?logo=github&style=for-the-badge">
|
|
11
11
|
</a>
|
|
12
|
-
<a href="https://github.com/d-velop/dvelop-sdk-node/blob/
|
|
12
|
+
<a href="https://github.com/d-velop/dvelop-sdk-node/blob/main/LICENSE">
|
|
13
13
|
<img alt="license" src="https://img.shields.io/github/license/d-velop/dvelop-sdk-node?style=for-the-badge">
|
|
14
14
|
</a>
|
|
15
15
|
|
package/lib/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<a href="https://github.com/d-velop/dvelop-sdk-node">
|
|
11
11
|
<img alt="GitHub" src="https://img.shields.io/badge/GitHub-dvelop--sdk--node-%23ff0844?logo=github&style=for-the-badge">
|
|
12
12
|
</a>
|
|
13
|
-
<a href="https://github.com/d-velop/dvelop-sdk-node/blob/
|
|
13
|
+
<a href="https://github.com/d-velop/dvelop-sdk-node/blob/main/LICENSE">
|
|
14
14
|
<img alt="license" src="https://img.shields.io/github/license/d-velop/dvelop-sdk-node?style=for-the-badge">
|
|
15
15
|
</a>
|
|
16
16
|
</br>
|
|
@@ -25,4 +25,5 @@
|
|
|
25
25
|
*/
|
|
26
26
|
export { DvelopContext } from "@dvelop-sdk/core";
|
|
27
27
|
export { validateRequestSignature, validateDvelopContext, InvalidRequestSignatureError } from "./validate-request-signature/validate-request-signature";
|
|
28
|
+
export { validateCloudCenterEventSignature, InvalidCloudCenterEventSignatureError } from "./validate-cloud-center-event-signature/validate-cloud-center-event-signature";
|
|
28
29
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,4BAA4B,EAAE,MAAM,yDAAyD,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,4BAA4B,EAAE,MAAM,yDAAyD,CAAC;AACxJ,OAAO,EAAE,iCAAiC,EAAE,qCAAqC,EAAE,MAAM,+EAA+E,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
<a href="https://github.com/d-velop/dvelop-sdk-node">
|
|
12
12
|
<img alt="GitHub" src="https://img.shields.io/badge/GitHub-dvelop--sdk--node-%23ff0844?logo=github&style=for-the-badge">
|
|
13
13
|
</a>
|
|
14
|
-
<a href="https://github.com/d-velop/dvelop-sdk-node/blob/
|
|
14
|
+
<a href="https://github.com/d-velop/dvelop-sdk-node/blob/main/LICENSE">
|
|
15
15
|
<img alt="license" src="https://img.shields.io/github/license/d-velop/dvelop-sdk-node?style=for-the-badge">
|
|
16
16
|
</a>
|
|
17
17
|
</br>
|
|
@@ -25,9 +25,12 @@
|
|
|
25
25
|
* @module app-router
|
|
26
26
|
*/
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.InvalidRequestSignatureError = exports.validateDvelopContext = exports.validateRequestSignature = void 0;
|
|
28
|
+
exports.InvalidCloudCenterEventSignatureError = exports.validateCloudCenterEventSignature = exports.InvalidRequestSignatureError = exports.validateDvelopContext = exports.validateRequestSignature = void 0;
|
|
29
29
|
var validate_request_signature_1 = require("./validate-request-signature/validate-request-signature");
|
|
30
30
|
Object.defineProperty(exports, "validateRequestSignature", { enumerable: true, get: function () { return validate_request_signature_1.validateRequestSignature; } });
|
|
31
31
|
Object.defineProperty(exports, "validateDvelopContext", { enumerable: true, get: function () { return validate_request_signature_1.validateDvelopContext; } });
|
|
32
32
|
Object.defineProperty(exports, "InvalidRequestSignatureError", { enumerable: true, get: function () { return validate_request_signature_1.InvalidRequestSignatureError; } });
|
|
33
|
+
var validate_cloud_center_event_signature_1 = require("./validate-cloud-center-event-signature/validate-cloud-center-event-signature");
|
|
34
|
+
Object.defineProperty(exports, "validateCloudCenterEventSignature", { enumerable: true, get: function () { return validate_cloud_center_event_signature_1.validateCloudCenterEventSignature; } });
|
|
35
|
+
Object.defineProperty(exports, "InvalidCloudCenterEventSignatureError", { enumerable: true, get: function () { return validate_cloud_center_event_signature_1.InvalidCloudCenterEventSignatureError; } });
|
|
33
36
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;;;AAGH,sGAAwJ;AAA/I,sIAAA,wBAAwB,OAAA;AAAE,mIAAA,qBAAqB,OAAA;AAAE,0IAAA,4BAA4B,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;;;AAGH,sGAAwJ;AAA/I,sIAAA,wBAAwB,OAAA;AAAE,mIAAA,qBAAqB,OAAA;AAAE,0IAAA,4BAA4B,OAAA;AACtF,uIAAyK;AAAhK,0JAAA,iCAAiC,OAAA;AAAE,8JAAA,qCAAqC,OAAA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { DvelopSdkError } from "@dvelop-sdk/core";
|
|
2
|
+
/**
|
|
3
|
+
* RequestSignature is invalid for given appSecret.
|
|
4
|
+
* @category Error
|
|
5
|
+
*/
|
|
6
|
+
export declare class InvalidCloudCenterEventSignatureError extends DvelopSdkError {
|
|
7
|
+
constructor();
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* RequestSignature is invalid for given appSecret.
|
|
11
|
+
* @category Error
|
|
12
|
+
*/
|
|
13
|
+
export interface ValidateCloudCenterEventSignatureParams {
|
|
14
|
+
httpMethod: string;
|
|
15
|
+
resourcePath: string;
|
|
16
|
+
queryString: string | undefined;
|
|
17
|
+
headers: {
|
|
18
|
+
[key: string]: string | undefined;
|
|
19
|
+
};
|
|
20
|
+
payload: any;
|
|
21
|
+
cloudCenterEventSignature: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Validate a cloud-center-event-signature against your appSecret.
|
|
25
|
+
*
|
|
26
|
+
* **The cloud-center-event-signature should be validated for every cloud-center-event.
|
|
27
|
+
* Refer to the [d.velop cloud center API](https://developer.d-velop.de/documentation/ccapi/en) for more information.**
|
|
28
|
+
*
|
|
29
|
+
* @throws {@link InvalidCloudCenterEventSignatureError} indicates that a cloud-center-event had an invalid signature.
|
|
30
|
+
*
|
|
31
|
+
* ```typescript
|
|
32
|
+
* validateCloudCenterEventSignature(
|
|
33
|
+
* process.env.APP_SECRET,
|
|
34
|
+
* "POST",
|
|
35
|
+
* "/myapp/dvelop-cloud-lifecycle-event",
|
|
36
|
+
* "",
|
|
37
|
+
* {
|
|
38
|
+
* "x-dv-signature-algorithm": "DV1-HMAC-SHA256",
|
|
39
|
+
* "x-dv-signature-headers": "x-dv-signature-algorithm,x-dv-signature-headers,x-dv-signature-timestamp",
|
|
40
|
+
* "x-dv-signature-timestamp": "2019-08-09T08:49:42Z"
|
|
41
|
+
* }, {
|
|
42
|
+
* "type": "subscribe",
|
|
43
|
+
* "tenantId": "id",
|
|
44
|
+
* "baseUri": "https://someone.d-velop.cloud"
|
|
45
|
+
* },
|
|
46
|
+
* "02783453441665bf27aa465cbbac9b98507ae94c54b6be2b1882fe9a05ec104c"
|
|
47
|
+
* );
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function validateCloudCenterEventSignature(appSecret: string, params: ValidateCloudCenterEventSignatureParams): void;
|
|
51
|
+
//# sourceMappingURL=validate-cloud-center-event-signature.d.ts.map
|
package/lib/validate-cloud-center-event-signature/validate-cloud-center-event-signature.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-cloud-center-event-signature.d.ts","sourceRoot":"","sources":["../../src/validate-cloud-center-event-signature/validate-cloud-center-event-signature.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;GAGG;AACH,qBAAa,qCAAsC,SAAQ,cAAc;;CAMxE;AAED;;;GAGG;AACH,MAAM,WAAW,uCAAuC;IACtD,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,OAAO,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;KAAE,CAAC;IAC/C,OAAO,EAAE,GAAG,CAAC;IACb,yBAAyB,EAAE,MAAM,CAAA;CAClC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,iCAAiC,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,uCAAuC,GAAG,IAAI,CAmB1H"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.validateCloudCenterEventSignature = exports.InvalidCloudCenterEventSignatureError = void 0;
|
|
19
|
+
var crypto_1 = require("crypto");
|
|
20
|
+
var core_1 = require("@dvelop-sdk/core");
|
|
21
|
+
/**
|
|
22
|
+
* RequestSignature is invalid for given appSecret.
|
|
23
|
+
* @category Error
|
|
24
|
+
*/
|
|
25
|
+
var InvalidCloudCenterEventSignatureError = /** @class */ (function (_super) {
|
|
26
|
+
__extends(InvalidCloudCenterEventSignatureError, _super);
|
|
27
|
+
// eslint-disable-next-line no-unused-vars
|
|
28
|
+
function InvalidCloudCenterEventSignatureError() {
|
|
29
|
+
var _this = _super.call(this, "Invalid CloudCenterEvent-signature: A cloud center event was recieved but signature was invalid.") || this;
|
|
30
|
+
Object.setPrototypeOf(_this, InvalidCloudCenterEventSignatureError.prototype);
|
|
31
|
+
return _this;
|
|
32
|
+
}
|
|
33
|
+
return InvalidCloudCenterEventSignatureError;
|
|
34
|
+
}(core_1.DvelopSdkError));
|
|
35
|
+
exports.InvalidCloudCenterEventSignatureError = InvalidCloudCenterEventSignatureError;
|
|
36
|
+
/**
|
|
37
|
+
* Validate a cloud-center-event-signature against your appSecret.
|
|
38
|
+
*
|
|
39
|
+
* **The cloud-center-event-signature should be validated for every cloud-center-event.
|
|
40
|
+
* Refer to the [d.velop cloud center API](https://developer.d-velop.de/documentation/ccapi/en) for more information.**
|
|
41
|
+
*
|
|
42
|
+
* @throws {@link InvalidCloudCenterEventSignatureError} indicates that a cloud-center-event had an invalid signature.
|
|
43
|
+
*
|
|
44
|
+
* ```typescript
|
|
45
|
+
* validateCloudCenterEventSignature(
|
|
46
|
+
* process.env.APP_SECRET,
|
|
47
|
+
* "POST",
|
|
48
|
+
* "/myapp/dvelop-cloud-lifecycle-event",
|
|
49
|
+
* "",
|
|
50
|
+
* {
|
|
51
|
+
* "x-dv-signature-algorithm": "DV1-HMAC-SHA256",
|
|
52
|
+
* "x-dv-signature-headers": "x-dv-signature-algorithm,x-dv-signature-headers,x-dv-signature-timestamp",
|
|
53
|
+
* "x-dv-signature-timestamp": "2019-08-09T08:49:42Z"
|
|
54
|
+
* }, {
|
|
55
|
+
* "type": "subscribe",
|
|
56
|
+
* "tenantId": "id",
|
|
57
|
+
* "baseUri": "https://someone.d-velop.cloud"
|
|
58
|
+
* },
|
|
59
|
+
* "02783453441665bf27aa465cbbac9b98507ae94c54b6be2b1882fe9a05ec104c"
|
|
60
|
+
* );
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
function validateCloudCenterEventSignature(appSecret, params) {
|
|
64
|
+
var _a;
|
|
65
|
+
var validSignature = false;
|
|
66
|
+
try {
|
|
67
|
+
var normalizedHeaderString = (_a = params.headers["x-dv-signature-headers"]) === null || _a === void 0 ? void 0 : _a.split(",").reduce(function (headerString, header) {
|
|
68
|
+
var _a;
|
|
69
|
+
return headerString + header.toLowerCase() + ":" + ((_a = params.headers[header]) === null || _a === void 0 ? void 0 : _a.trim()) + "\n";
|
|
70
|
+
}, "");
|
|
71
|
+
var sha256Payload = crypto_1.createHash("sha256").update(JSON.stringify(params.payload) + "\n").digest("hex");
|
|
72
|
+
var normalizedRequestString = params.httpMethod.toUpperCase() + "\n" + params.resourcePath + "\n" + (params.queryString || "") + "\n" + normalizedHeaderString + "\n" + sha256Payload;
|
|
73
|
+
var sha256RequestString = crypto_1.createHash("sha256").update(normalizedRequestString).digest("hex");
|
|
74
|
+
var calculatedSignature = crypto_1.createHmac("sha256", Buffer.from(appSecret, "base64")).update(sha256RequestString).digest("hex");
|
|
75
|
+
validSignature = crypto_1.timingSafeEqual(Buffer.from(params.cloudCenterEventSignature), Buffer.from(calculatedSignature));
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
throw new InvalidCloudCenterEventSignatureError();
|
|
79
|
+
}
|
|
80
|
+
if (!validSignature) {
|
|
81
|
+
throw new InvalidCloudCenterEventSignatureError();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.validateCloudCenterEventSignature = validateCloudCenterEventSignature;
|
|
85
|
+
//# sourceMappingURL=validate-cloud-center-event-signature.js.map
|
package/lib/validate-cloud-center-event-signature/validate-cloud-center-event-signature.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-cloud-center-event-signature.js","sourceRoot":"","sources":["../../src/validate-cloud-center-event-signature/validate-cloud-center-event-signature.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,iCAAiE;AACjE,yCAAkD;AAElD;;;GAGG;AACH;IAA2D,yDAAc;IACvE,0CAA0C;IAC1C;QAAA,YACE,kBAAM,kGAAkG,CAAC,SAE1G;QADC,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,qCAAqC,CAAC,SAAS,CAAC,CAAC;;IAC/E,CAAC;IACH,4CAAC;AAAD,CA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AAC,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC;KACnH;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,qCAAqC,EAAE,CAAC;KACnD;IACD,IAAI,CAAC,cAAc,EAAE;QACnB,MAAM,IAAI,qCAAqC,EAAE,CAAC;KACnD;AACH,CAAC;AAnBD,8EAmBC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dvelop-sdk/app-router",
|
|
3
3
|
"description": "This package contains functionality for the App-Router in the d.velop cloud.",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.2.2",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "lib/index.d.ts",
|
|
@@ -23,6 +23,6 @@
|
|
|
23
23
|
"license": "license-checker --production --onlyAllow Apache-2.0;MIT;ISC;BSD-2-Clause;BSD-3-Clause"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@dvelop-sdk/core": "^2.
|
|
26
|
+
"@dvelop-sdk/core": "^2.1.2"
|
|
27
27
|
}
|
|
28
|
-
}
|
|
28
|
+
}
|