@backstage/plugin-events-backend-module-github 0.1.4-next.2 → 0.1.5-next.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/CHANGELOG.md +19 -0
- package/alpha/package.json +3 -3
- package/dist/alpha.cjs.js +71 -0
- package/dist/alpha.cjs.js.map +1 -0
- package/dist/alpha.d.ts +21 -0
- package/dist/index.cjs.js +0 -39
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +4 -18
- package/package.json +25 -15
- package/dist/index.alpha.d.ts +0 -57
- package/dist/index.beta.d.ts +0 -43
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @backstage/plugin-events-backend-module-github
|
|
2
2
|
|
|
3
|
+
## 0.1.5-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 928a12a9b3: Internal refactor of `/alpha` exports.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/backend-plugin-api@0.4.1-next.0
|
|
10
|
+
- @backstage/plugin-events-node@0.2.4-next.0
|
|
11
|
+
- @backstage/config@1.0.6
|
|
12
|
+
|
|
13
|
+
## 0.1.4
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
- @backstage/backend-plugin-api@0.4.0
|
|
19
|
+
- @backstage/plugin-events-node@0.2.3
|
|
20
|
+
- @backstage/config@1.0.6
|
|
21
|
+
|
|
3
22
|
## 0.1.4-next.2
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/alpha/package.json
CHANGED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
6
|
+
var alpha = require('@backstage/plugin-events-node/alpha');
|
|
7
|
+
var pluginEventsNode = require('@backstage/plugin-events-node');
|
|
8
|
+
var webhooksMethods = require('@octokit/webhooks-methods');
|
|
9
|
+
|
|
10
|
+
class GithubEventRouter extends pluginEventsNode.SubTopicEventRouter {
|
|
11
|
+
constructor() {
|
|
12
|
+
super("github");
|
|
13
|
+
}
|
|
14
|
+
determineSubTopic(params) {
|
|
15
|
+
var _a;
|
|
16
|
+
return (_a = params.metadata) == null ? void 0 : _a["x-github-event"];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const githubEventRouterEventsModule = backendPluginApi.createBackendModule({
|
|
21
|
+
pluginId: "events",
|
|
22
|
+
moduleId: "githubEventRouter",
|
|
23
|
+
register(env) {
|
|
24
|
+
env.registerInit({
|
|
25
|
+
deps: {
|
|
26
|
+
events: alpha.eventsExtensionPoint
|
|
27
|
+
},
|
|
28
|
+
async init({ events }) {
|
|
29
|
+
const eventRouter = new GithubEventRouter();
|
|
30
|
+
events.addPublishers(eventRouter);
|
|
31
|
+
events.addSubscribers(eventRouter);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
function createGithubSignatureValidator(config) {
|
|
38
|
+
const secret = config.getString("events.modules.github.webhookSecret");
|
|
39
|
+
return async (request, context) => {
|
|
40
|
+
const signature = request.headers["x-hub-signature-256"];
|
|
41
|
+
if (!signature || !await webhooksMethods.verify(secret, JSON.stringify(request.body), signature)) {
|
|
42
|
+
context.reject({
|
|
43
|
+
status: 403,
|
|
44
|
+
payload: { message: "invalid signature" }
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const githubWebhookEventsModule = backendPluginApi.createBackendModule({
|
|
51
|
+
pluginId: "events",
|
|
52
|
+
moduleId: "githubWebhook",
|
|
53
|
+
register(env) {
|
|
54
|
+
env.registerInit({
|
|
55
|
+
deps: {
|
|
56
|
+
config: backendPluginApi.coreServices.config,
|
|
57
|
+
events: alpha.eventsExtensionPoint
|
|
58
|
+
},
|
|
59
|
+
async init({ config, events }) {
|
|
60
|
+
events.addHttpPostIngress({
|
|
61
|
+
topic: "github",
|
|
62
|
+
validator: createGithubSignatureValidator(config)
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
exports.githubEventRouterEventsModule = githubEventRouterEventsModule;
|
|
70
|
+
exports.githubWebhookEventsModule = githubWebhookEventsModule;
|
|
71
|
+
//# sourceMappingURL=alpha.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alpha.cjs.js","sources":["../src/router/GithubEventRouter.ts","../src/service/GithubEventRouterEventsModule.ts","../src/http/createGithubSignatureValidator.ts","../src/service/GithubWebhookEventsModule.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n EventParams,\n SubTopicEventRouter,\n} from '@backstage/plugin-events-node';\n\n/**\n * Subscribes to the generic `github` topic\n * and publishes the events under the more concrete sub-topic\n * depending on the `x-github-event` provided.\n *\n * @public\n */\nexport class GithubEventRouter extends SubTopicEventRouter {\n constructor() {\n super('github');\n }\n\n protected determineSubTopic(params: EventParams): string | undefined {\n return params.metadata?.['x-github-event'] as string | undefined;\n }\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createBackendModule } from '@backstage/backend-plugin-api';\nimport { eventsExtensionPoint } from '@backstage/plugin-events-node/alpha';\nimport { GithubEventRouter } from '../router/GithubEventRouter';\n\n/**\n * Module for the events-backend plugin, adding an event router for GitHub.\n *\n * Registers the `GithubEventRouter`.\n *\n * @alpha\n */\nexport const githubEventRouterEventsModule = createBackendModule({\n pluginId: 'events',\n moduleId: 'githubEventRouter',\n register(env) {\n env.registerInit({\n deps: {\n events: eventsExtensionPoint,\n },\n async init({ events }) {\n const eventRouter = new GithubEventRouter();\n\n events.addPublishers(eventRouter);\n events.addSubscribers(eventRouter);\n },\n });\n },\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport {\n RequestDetails,\n RequestValidationContext,\n RequestValidator,\n} from '@backstage/plugin-events-node';\nimport { verify } from '@octokit/webhooks-methods';\n\n/**\n * Validates that the request received is the expected GitHub request\n * using the signature received with the `x-hub-signature-256` header\n * which is based on a secret token configured at GitHub and here.\n *\n * See https://docs.github.com/en/developers/webhooks-and-events/webhooks/securing-your-webhooks\n * for more details.\n *\n * @param config - root config\n * @public\n */\nexport function createGithubSignatureValidator(\n config: Config,\n): RequestValidator {\n const secret = config.getString('events.modules.github.webhookSecret');\n\n return async (\n request: RequestDetails,\n context: RequestValidationContext,\n ): Promise<void> => {\n const signature = request.headers['x-hub-signature-256'] as\n | string\n | undefined;\n\n if (\n !signature ||\n !(await verify(secret, JSON.stringify(request.body), signature))\n ) {\n context.reject({\n status: 403,\n payload: { message: 'invalid signature' },\n });\n }\n };\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport { eventsExtensionPoint } from '@backstage/plugin-events-node/alpha';\nimport { createGithubSignatureValidator } from '../http/createGithubSignatureValidator';\n\n/**\n * Module for the events-backend plugin,\n * registering an HTTP POST ingress with request validator\n * which verifies the webhook signature based on a secret.\n *\n * @alpha\n */\nexport const githubWebhookEventsModule = createBackendModule({\n pluginId: 'events',\n moduleId: 'githubWebhook',\n register(env) {\n env.registerInit({\n deps: {\n config: coreServices.config,\n events: eventsExtensionPoint,\n },\n async init({ config, events }) {\n events.addHttpPostIngress({\n topic: 'github',\n validator: createGithubSignatureValidator(config),\n });\n },\n });\n },\n});\n"],"names":["SubTopicEventRouter","createBackendModule","eventsExtensionPoint","verify","coreServices"],"mappings":";;;;;;;;;AA4BO,MAAM,0BAA0BA,oCAAoB,CAAA;AAAA,EACzD,WAAc,GAAA;AACZ,IAAA,KAAA,CAAM,QAAQ,CAAA,CAAA;AAAA,GAChB;AAAA,EAEU,kBAAkB,MAAyC,EAAA;AAjCvE,IAAA,IAAA,EAAA,CAAA;AAkCI,IAAO,OAAA,CAAA,EAAA,GAAA,MAAA,CAAO,aAAP,IAAkB,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,gBAAA,CAAA,CAAA;AAAA,GAC3B;AACF;;ACTO,MAAM,gCAAgCC,oCAAoB,CAAA;AAAA,EAC/D,QAAU,EAAA,QAAA;AAAA,EACV,QAAU,EAAA,mBAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,MAAQ,EAAAC,0BAAA;AAAA,OACV;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,MAAA,EAAU,EAAA;AACrB,QAAM,MAAA,WAAA,GAAc,IAAI,iBAAkB,EAAA,CAAA;AAE1C,QAAA,MAAA,CAAO,cAAc,WAAW,CAAA,CAAA;AAChC,QAAA,MAAA,CAAO,eAAe,WAAW,CAAA,CAAA;AAAA,OACnC;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;ACRM,SAAS,+BACd,MACkB,EAAA;AAClB,EAAM,MAAA,MAAA,GAAS,MAAO,CAAA,SAAA,CAAU,qCAAqC,CAAA,CAAA;AAErE,EAAO,OAAA,OACL,SACA,OACkB,KAAA;AAClB,IAAM,MAAA,SAAA,GAAY,OAAQ,CAAA,OAAA,CAAQ,qBAAqB,CAAA,CAAA;AAIvD,IAAA,IACE,CAAC,SAAA,IACD,CAAE,MAAMC,sBAAO,CAAA,MAAA,EAAQ,IAAK,CAAA,SAAA,CAAU,OAAQ,CAAA,IAAI,CAAG,EAAA,SAAS,CAC9D,EAAA;AACA,MAAA,OAAA,CAAQ,MAAO,CAAA;AAAA,QACb,MAAQ,EAAA,GAAA;AAAA,QACR,OAAA,EAAS,EAAE,OAAA,EAAS,mBAAoB,EAAA;AAAA,OACzC,CAAA,CAAA;AAAA,KACH;AAAA,GACF,CAAA;AACF;;AC5BO,MAAM,4BAA4BF,oCAAoB,CAAA;AAAA,EAC3D,QAAU,EAAA,QAAA;AAAA,EACV,QAAU,EAAA,eAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,QAAQG,6BAAa,CAAA,MAAA;AAAA,QACrB,MAAQ,EAAAF,0BAAA;AAAA,OACV;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,MAAA,EAAQ,QAAU,EAAA;AAC7B,QAAA,MAAA,CAAO,kBAAmB,CAAA;AAAA,UACxB,KAAO,EAAA,QAAA;AAAA,UACP,SAAA,EAAW,+BAA+B,MAAM,CAAA;AAAA,SACjD,CAAA,CAAA;AAAA,OACH;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;;"}
|
package/dist/alpha.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Module for the events-backend plugin, adding an event router for GitHub.
|
|
5
|
+
*
|
|
6
|
+
* Registers the `GithubEventRouter`.
|
|
7
|
+
*
|
|
8
|
+
* @alpha
|
|
9
|
+
*/
|
|
10
|
+
declare const githubEventRouterEventsModule: () => _backstage_backend_plugin_api.BackendFeature;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Module for the events-backend plugin,
|
|
14
|
+
* registering an HTTP POST ingress with request validator
|
|
15
|
+
* which verifies the webhook signature based on a secret.
|
|
16
|
+
*
|
|
17
|
+
* @alpha
|
|
18
|
+
*/
|
|
19
|
+
declare const githubWebhookEventsModule: () => _backstage_backend_plugin_api.BackendFeature;
|
|
20
|
+
|
|
21
|
+
export { githubEventRouterEventsModule, githubWebhookEventsModule };
|
package/dist/index.cjs.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var webhooksMethods = require('@octokit/webhooks-methods');
|
|
6
6
|
var pluginEventsNode = require('@backstage/plugin-events-node');
|
|
7
|
-
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
8
7
|
|
|
9
8
|
function createGithubSignatureValidator(config) {
|
|
10
9
|
const secret = config.getString("events.modules.github.webhookSecret");
|
|
@@ -29,44 +28,6 @@ class GithubEventRouter extends pluginEventsNode.SubTopicEventRouter {
|
|
|
29
28
|
}
|
|
30
29
|
}
|
|
31
30
|
|
|
32
|
-
const githubEventRouterEventsModule = backendPluginApi.createBackendModule({
|
|
33
|
-
pluginId: "events",
|
|
34
|
-
moduleId: "githubEventRouter",
|
|
35
|
-
register(env) {
|
|
36
|
-
env.registerInit({
|
|
37
|
-
deps: {
|
|
38
|
-
events: pluginEventsNode.eventsExtensionPoint
|
|
39
|
-
},
|
|
40
|
-
async init({ events }) {
|
|
41
|
-
const eventRouter = new GithubEventRouter();
|
|
42
|
-
events.addPublishers(eventRouter);
|
|
43
|
-
events.addSubscribers(eventRouter);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
const githubWebhookEventsModule = backendPluginApi.createBackendModule({
|
|
50
|
-
pluginId: "events",
|
|
51
|
-
moduleId: "githubWebhook",
|
|
52
|
-
register(env) {
|
|
53
|
-
env.registerInit({
|
|
54
|
-
deps: {
|
|
55
|
-
config: backendPluginApi.coreServices.config,
|
|
56
|
-
events: pluginEventsNode.eventsExtensionPoint
|
|
57
|
-
},
|
|
58
|
-
async init({ config, events }) {
|
|
59
|
-
events.addHttpPostIngress({
|
|
60
|
-
topic: "github",
|
|
61
|
-
validator: createGithubSignatureValidator(config)
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
|
|
68
31
|
exports.GithubEventRouter = GithubEventRouter;
|
|
69
32
|
exports.createGithubSignatureValidator = createGithubSignatureValidator;
|
|
70
|
-
exports.githubEventRouterEventsModule = githubEventRouterEventsModule;
|
|
71
|
-
exports.githubWebhookEventsModule = githubWebhookEventsModule;
|
|
72
33
|
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/http/createGithubSignatureValidator.ts","../src/router/GithubEventRouter.ts"
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/http/createGithubSignatureValidator.ts","../src/router/GithubEventRouter.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport {\n RequestDetails,\n RequestValidationContext,\n RequestValidator,\n} from '@backstage/plugin-events-node';\nimport { verify } from '@octokit/webhooks-methods';\n\n/**\n * Validates that the request received is the expected GitHub request\n * using the signature received with the `x-hub-signature-256` header\n * which is based on a secret token configured at GitHub and here.\n *\n * See https://docs.github.com/en/developers/webhooks-and-events/webhooks/securing-your-webhooks\n * for more details.\n *\n * @param config - root config\n * @public\n */\nexport function createGithubSignatureValidator(\n config: Config,\n): RequestValidator {\n const secret = config.getString('events.modules.github.webhookSecret');\n\n return async (\n request: RequestDetails,\n context: RequestValidationContext,\n ): Promise<void> => {\n const signature = request.headers['x-hub-signature-256'] as\n | string\n | undefined;\n\n if (\n !signature ||\n !(await verify(secret, JSON.stringify(request.body), signature))\n ) {\n context.reject({\n status: 403,\n payload: { message: 'invalid signature' },\n });\n }\n };\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n EventParams,\n SubTopicEventRouter,\n} from '@backstage/plugin-events-node';\n\n/**\n * Subscribes to the generic `github` topic\n * and publishes the events under the more concrete sub-topic\n * depending on the `x-github-event` provided.\n *\n * @public\n */\nexport class GithubEventRouter extends SubTopicEventRouter {\n constructor() {\n super('github');\n }\n\n protected determineSubTopic(params: EventParams): string | undefined {\n return params.metadata?.['x-github-event'] as string | undefined;\n }\n}\n"],"names":["verify","SubTopicEventRouter"],"mappings":";;;;;;;AAmCO,SAAS,+BACd,MACkB,EAAA;AAClB,EAAM,MAAA,MAAA,GAAS,MAAO,CAAA,SAAA,CAAU,qCAAqC,CAAA,CAAA;AAErE,EAAO,OAAA,OACL,SACA,OACkB,KAAA;AAClB,IAAM,MAAA,SAAA,GAAY,OAAQ,CAAA,OAAA,CAAQ,qBAAqB,CAAA,CAAA;AAIvD,IAAA,IACE,CAAC,SAAA,IACD,CAAE,MAAMA,sBAAO,CAAA,MAAA,EAAQ,IAAK,CAAA,SAAA,CAAU,OAAQ,CAAA,IAAI,CAAG,EAAA,SAAS,CAC9D,EAAA;AACA,MAAA,OAAA,CAAQ,MAAO,CAAA;AAAA,QACb,MAAQ,EAAA,GAAA;AAAA,QACR,OAAA,EAAS,EAAE,OAAA,EAAS,mBAAoB,EAAA;AAAA,OACzC,CAAA,CAAA;AAAA,KACH;AAAA,GACF,CAAA;AACF;;AC9BO,MAAM,0BAA0BC,oCAAoB,CAAA;AAAA,EACzD,WAAc,GAAA;AACZ,IAAA,KAAA,CAAM,QAAQ,CAAA,CAAA;AAAA,GAChB;AAAA,EAEU,kBAAkB,MAAyC,EAAA;AAjCvE,IAAA,IAAA,EAAA,CAAA;AAkCI,IAAO,OAAA,CAAA,EAAA,GAAA,MAAA,CAAO,aAAP,IAAkB,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,gBAAA,CAAA,CAAA;AAAA,GAC3B;AACF;;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The module `github` for the Backstage backend plugin "events-backend"
|
|
3
|
-
* adding an event router and signature validator for GitHub.
|
|
4
|
-
*
|
|
5
|
-
* @packageDocumentation
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { BackendFeature } from '@backstage/backend-plugin-api';
|
|
9
1
|
import { Config } from '@backstage/config';
|
|
10
|
-
import { EventParams } from '@backstage/plugin-events-node';
|
|
11
|
-
import { RequestValidator } from '@backstage/plugin-events-node';
|
|
12
|
-
import { SubTopicEventRouter } from '@backstage/plugin-events-node';
|
|
2
|
+
import { RequestValidator, SubTopicEventRouter, EventParams } from '@backstage/plugin-events-node';
|
|
13
3
|
|
|
14
4
|
/**
|
|
15
5
|
* Validates that the request received is the expected GitHub request
|
|
@@ -22,7 +12,7 @@ import { SubTopicEventRouter } from '@backstage/plugin-events-node';
|
|
|
22
12
|
* @param config - root config
|
|
23
13
|
* @public
|
|
24
14
|
*/
|
|
25
|
-
|
|
15
|
+
declare function createGithubSignatureValidator(config: Config): RequestValidator;
|
|
26
16
|
|
|
27
17
|
/**
|
|
28
18
|
* Subscribes to the generic `github` topic
|
|
@@ -31,13 +21,9 @@ export declare function createGithubSignatureValidator(config: Config): RequestV
|
|
|
31
21
|
*
|
|
32
22
|
* @public
|
|
33
23
|
*/
|
|
34
|
-
|
|
24
|
+
declare class GithubEventRouter extends SubTopicEventRouter {
|
|
35
25
|
constructor();
|
|
36
26
|
protected determineSubTopic(params: EventParams): string | undefined;
|
|
37
27
|
}
|
|
38
28
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
/* Excluded from this release type: githubWebhookEventsModule */
|
|
42
|
-
|
|
43
|
-
export { }
|
|
29
|
+
export { GithubEventRouter, createGithubSignatureValidator };
|
package/package.json
CHANGED
|
@@ -1,21 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-events-backend-module-github",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"main": "dist/index.cjs.js",
|
|
5
|
-
"types": "dist/index.d.ts",
|
|
3
|
+
"version": "0.1.5-next.0",
|
|
4
|
+
"main": "./dist/index.cjs.js",
|
|
5
|
+
"types": "./dist/index.d.ts",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"publishConfig": {
|
|
8
|
-
"access": "public"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"require": "./dist/index.cjs.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"default": "./dist/index.cjs.js"
|
|
15
|
+
},
|
|
16
|
+
"./alpha": {
|
|
17
|
+
"require": "./dist/alpha.cjs.js",
|
|
18
|
+
"types": "./dist/alpha.d.ts",
|
|
19
|
+
"default": "./dist/alpha.cjs.js"
|
|
20
|
+
},
|
|
21
|
+
"./package.json": "./package.json"
|
|
12
22
|
},
|
|
13
23
|
"backstage": {
|
|
14
24
|
"role": "backend-plugin-module"
|
|
15
25
|
},
|
|
16
26
|
"scripts": {
|
|
17
27
|
"start": "backstage-cli package start",
|
|
18
|
-
"build": "backstage-cli package build
|
|
28
|
+
"build": "backstage-cli package build",
|
|
19
29
|
"lint": "backstage-cli package lint",
|
|
20
30
|
"test": "backstage-cli package test",
|
|
21
31
|
"clean": "backstage-cli package clean",
|
|
@@ -23,22 +33,22 @@
|
|
|
23
33
|
"postpack": "backstage-cli package postpack"
|
|
24
34
|
},
|
|
25
35
|
"dependencies": {
|
|
26
|
-
"@backstage/backend-plugin-api": "^0.4.
|
|
36
|
+
"@backstage/backend-plugin-api": "^0.4.1-next.0",
|
|
27
37
|
"@backstage/config": "^1.0.6",
|
|
28
|
-
"@backstage/plugin-events-node": "^0.2.
|
|
38
|
+
"@backstage/plugin-events-node": "^0.2.4-next.0",
|
|
29
39
|
"@octokit/webhooks-methods": "^3.0.0",
|
|
30
40
|
"winston": "^3.2.1"
|
|
31
41
|
},
|
|
32
42
|
"devDependencies": {
|
|
33
|
-
"@backstage/backend-test-utils": "^0.1.
|
|
34
|
-
"@backstage/cli": "^0.22.
|
|
35
|
-
"@backstage/plugin-events-backend-test-utils": "^0.1.
|
|
43
|
+
"@backstage/backend-test-utils": "^0.1.35-next.0",
|
|
44
|
+
"@backstage/cli": "^0.22.4-next.0",
|
|
45
|
+
"@backstage/plugin-events-backend-test-utils": "^0.1.5-next.0",
|
|
36
46
|
"supertest": "^6.1.3"
|
|
37
47
|
},
|
|
38
48
|
"files": [
|
|
39
|
-
"alpha",
|
|
40
49
|
"config.d.ts",
|
|
41
|
-
"dist"
|
|
50
|
+
"dist",
|
|
51
|
+
"alpha"
|
|
42
52
|
],
|
|
43
53
|
"configSchema": "config.d.ts"
|
|
44
54
|
}
|
package/dist/index.alpha.d.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The module `github` for the Backstage backend plugin "events-backend"
|
|
3
|
-
* adding an event router and signature validator for GitHub.
|
|
4
|
-
*
|
|
5
|
-
* @packageDocumentation
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { BackendFeature } from '@backstage/backend-plugin-api';
|
|
9
|
-
import { Config } from '@backstage/config';
|
|
10
|
-
import { EventParams } from '@backstage/plugin-events-node';
|
|
11
|
-
import { RequestValidator } from '@backstage/plugin-events-node';
|
|
12
|
-
import { SubTopicEventRouter } from '@backstage/plugin-events-node';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Validates that the request received is the expected GitHub request
|
|
16
|
-
* using the signature received with the `x-hub-signature-256` header
|
|
17
|
-
* which is based on a secret token configured at GitHub and here.
|
|
18
|
-
*
|
|
19
|
-
* See https://docs.github.com/en/developers/webhooks-and-events/webhooks/securing-your-webhooks
|
|
20
|
-
* for more details.
|
|
21
|
-
*
|
|
22
|
-
* @param config - root config
|
|
23
|
-
* @public
|
|
24
|
-
*/
|
|
25
|
-
export declare function createGithubSignatureValidator(config: Config): RequestValidator;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Subscribes to the generic `github` topic
|
|
29
|
-
* and publishes the events under the more concrete sub-topic
|
|
30
|
-
* depending on the `x-github-event` provided.
|
|
31
|
-
*
|
|
32
|
-
* @public
|
|
33
|
-
*/
|
|
34
|
-
export declare class GithubEventRouter extends SubTopicEventRouter {
|
|
35
|
-
constructor();
|
|
36
|
-
protected determineSubTopic(params: EventParams): string | undefined;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Module for the events-backend plugin, adding an event router for GitHub.
|
|
41
|
-
*
|
|
42
|
-
* Registers the {@link GithubEventRouter}.
|
|
43
|
-
*
|
|
44
|
-
* @alpha
|
|
45
|
-
*/
|
|
46
|
-
export declare const githubEventRouterEventsModule: () => BackendFeature;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Module for the events-backend plugin,
|
|
50
|
-
* registering an HTTP POST ingress with request validator
|
|
51
|
-
* which verifies the webhook signature based on a secret.
|
|
52
|
-
*
|
|
53
|
-
* @alpha
|
|
54
|
-
*/
|
|
55
|
-
export declare const githubWebhookEventsModule: () => BackendFeature;
|
|
56
|
-
|
|
57
|
-
export { }
|
package/dist/index.beta.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The module `github` for the Backstage backend plugin "events-backend"
|
|
3
|
-
* adding an event router and signature validator for GitHub.
|
|
4
|
-
*
|
|
5
|
-
* @packageDocumentation
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { BackendFeature } from '@backstage/backend-plugin-api';
|
|
9
|
-
import { Config } from '@backstage/config';
|
|
10
|
-
import { EventParams } from '@backstage/plugin-events-node';
|
|
11
|
-
import { RequestValidator } from '@backstage/plugin-events-node';
|
|
12
|
-
import { SubTopicEventRouter } from '@backstage/plugin-events-node';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Validates that the request received is the expected GitHub request
|
|
16
|
-
* using the signature received with the `x-hub-signature-256` header
|
|
17
|
-
* which is based on a secret token configured at GitHub and here.
|
|
18
|
-
*
|
|
19
|
-
* See https://docs.github.com/en/developers/webhooks-and-events/webhooks/securing-your-webhooks
|
|
20
|
-
* for more details.
|
|
21
|
-
*
|
|
22
|
-
* @param config - root config
|
|
23
|
-
* @public
|
|
24
|
-
*/
|
|
25
|
-
export declare function createGithubSignatureValidator(config: Config): RequestValidator;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Subscribes to the generic `github` topic
|
|
29
|
-
* and publishes the events under the more concrete sub-topic
|
|
30
|
-
* depending on the `x-github-event` provided.
|
|
31
|
-
*
|
|
32
|
-
* @public
|
|
33
|
-
*/
|
|
34
|
-
export declare class GithubEventRouter extends SubTopicEventRouter {
|
|
35
|
-
constructor();
|
|
36
|
-
protected determineSubTopic(params: EventParams): string | undefined;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/* Excluded from this release type: githubEventRouterEventsModule */
|
|
40
|
-
|
|
41
|
-
/* Excluded from this release type: githubWebhookEventsModule */
|
|
42
|
-
|
|
43
|
-
export { }
|