@backstage/plugin-events-backend-module-github 0.2.12-next.0 → 0.2.12-next.1

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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # @backstage/plugin-events-backend-module-github
2
2
 
3
+ ## 0.2.12-next.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/backend-plugin-api@1.0.1-next.1
9
+ - @backstage/config@1.2.0
10
+ - @backstage/plugin-events-node@0.4.1-next.1
11
+
3
12
  ## 0.2.12-next.0
4
13
 
5
14
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-events-backend-module-github__alpha",
3
- "version": "0.2.12-next.0",
3
+ "version": "0.2.12-next.1",
4
4
  "main": "../dist/alpha.cjs.js",
5
5
  "types": "../dist/alpha.d.ts"
6
6
  }
package/dist/alpha.cjs.js CHANGED
@@ -1,46 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var backendPluginApi = require('@backstage/backend-plugin-api');
4
- var pluginEventsNode = require('@backstage/plugin-events-node');
5
- var GithubEventRouter = require('./cjs/GithubEventRouter-DynNUSpO.cjs.js');
6
- var alpha = require('@backstage/plugin-events-node/alpha');
7
- require('@octokit/webhooks-methods');
3
+ var eventsModuleGithubEventRouter = require('./service/eventsModuleGithubEventRouter.cjs.js');
4
+ var eventsModuleGithubWebhook = require('./service/eventsModuleGithubWebhook.cjs.js');
8
5
 
9
- const eventsModuleGithubEventRouter = backendPluginApi.createBackendModule({
10
- pluginId: "events",
11
- moduleId: "github-event-router",
12
- register(env) {
13
- env.registerInit({
14
- deps: {
15
- events: pluginEventsNode.eventsServiceRef
16
- },
17
- async init({ events }) {
18
- const eventRouter = new GithubEventRouter.GithubEventRouter({ events });
19
- await eventRouter.subscribe();
20
- }
21
- });
22
- }
23
- });
24
6
 
25
- const eventsModuleGithubWebhook = backendPluginApi.createBackendModule({
26
- pluginId: "events",
27
- moduleId: "github-webhook",
28
- register(env) {
29
- env.registerInit({
30
- deps: {
31
- config: backendPluginApi.coreServices.rootConfig,
32
- events: alpha.eventsExtensionPoint
33
- },
34
- async init({ config, events }) {
35
- events.addHttpPostIngress({
36
- topic: "github",
37
- validator: GithubEventRouter.createGithubSignatureValidator(config)
38
- });
39
- }
40
- });
41
- }
42
- });
43
7
 
44
- exports.eventsModuleGithubEventRouter = eventsModuleGithubEventRouter;
45
- exports.eventsModuleGithubWebhook = eventsModuleGithubWebhook;
8
+ exports.eventsModuleGithubEventRouter = eventsModuleGithubEventRouter.eventsModuleGithubEventRouter;
9
+ exports.eventsModuleGithubWebhook = eventsModuleGithubWebhook.eventsModuleGithubWebhook;
46
10
  //# sourceMappingURL=alpha.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"alpha.cjs.js","sources":["../src/service/eventsModuleGithubEventRouter.ts","../src/service/eventsModuleGithubWebhook.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 { createBackendModule } from '@backstage/backend-plugin-api';\nimport { eventsServiceRef } from '@backstage/plugin-events-node';\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 eventsModuleGithubEventRouter = createBackendModule({\n pluginId: 'events',\n moduleId: 'github-event-router',\n register(env) {\n env.registerInit({\n deps: {\n events: eventsServiceRef,\n },\n async init({ events }) {\n const eventRouter = new GithubEventRouter({ events });\n await eventRouter.subscribe();\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 eventsModuleGithubWebhook = createBackendModule({\n pluginId: 'events',\n moduleId: 'github-webhook',\n register(env) {\n env.registerInit({\n deps: {\n config: coreServices.rootConfig,\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":["createBackendModule","eventsServiceRef","GithubEventRouter","coreServices","eventsExtensionPoint","createGithubSignatureValidator"],"mappings":";;;;;;;;AA2BO,MAAM,gCAAgCA,oCAAoB,CAAA;AAAA,EAC/D,QAAU,EAAA,QAAA;AAAA,EACV,QAAU,EAAA,qBAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,MAAQ,EAAAC,iCAAA;AAAA,OACV;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,MAAA,EAAU,EAAA;AACrB,QAAA,MAAM,WAAc,GAAA,IAAIC,mCAAkB,CAAA,EAAE,QAAQ,CAAA,CAAA;AACpD,QAAA,MAAM,YAAY,SAAU,EAAA,CAAA;AAAA,OAC9B;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;ACXM,MAAM,4BAA4BF,oCAAoB,CAAA;AAAA,EAC3D,QAAU,EAAA,QAAA;AAAA,EACV,QAAU,EAAA,gBAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,QAAQG,6BAAa,CAAA,UAAA;AAAA,QACrB,MAAQ,EAAAC,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,EAAWC,iDAA+B,MAAM,CAAA;AAAA,SACjD,CAAA,CAAA;AAAA,OACH;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;;"}
1
+ {"version":3,"file":"alpha.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  var webhooksMethods = require('@octokit/webhooks-methods');
4
- var pluginEventsNode = require('@backstage/plugin-events-node');
5
4
 
6
5
  function createGithubSignatureValidator(config) {
7
6
  const secret = config.getString("events.modules.github.webhookSecret");
@@ -16,21 +15,5 @@ function createGithubSignatureValidator(config) {
16
15
  };
17
16
  }
18
17
 
19
- class GithubEventRouter extends pluginEventsNode.SubTopicEventRouter {
20
- constructor(options) {
21
- super({
22
- events: options.events,
23
- topic: "github"
24
- });
25
- }
26
- getSubscriberId() {
27
- return "GithubEventRouter";
28
- }
29
- determineSubTopic(params) {
30
- return params.metadata?.["x-github-event"];
31
- }
32
- }
33
-
34
- exports.GithubEventRouter = GithubEventRouter;
35
18
  exports.createGithubSignatureValidator = createGithubSignatureValidator;
36
- //# sourceMappingURL=GithubEventRouter-DynNUSpO.cjs.js.map
19
+ //# sourceMappingURL=createGithubSignatureValidator.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createGithubSignatureValidator.cjs.js","sources":["../../src/http/createGithubSignatureValidator.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"],"names":["verify"],"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;;;;"}
package/dist/index.cjs.js CHANGED
@@ -1,11 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var GithubEventRouter = require('./cjs/GithubEventRouter-DynNUSpO.cjs.js');
4
- require('@octokit/webhooks-methods');
5
- require('@backstage/plugin-events-node');
3
+ var createGithubSignatureValidator = require('./http/createGithubSignatureValidator.cjs.js');
4
+ var GithubEventRouter = require('./router/GithubEventRouter.cjs.js');
6
5
 
7
6
 
8
7
 
8
+ exports.createGithubSignatureValidator = createGithubSignatureValidator.createGithubSignatureValidator;
9
9
  exports.GithubEventRouter = GithubEventRouter.GithubEventRouter;
10
- exports.createGithubSignatureValidator = GithubEventRouter.createGithubSignatureValidator;
11
10
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ var pluginEventsNode = require('@backstage/plugin-events-node');
4
+
5
+ class GithubEventRouter extends pluginEventsNode.SubTopicEventRouter {
6
+ constructor(options) {
7
+ super({
8
+ events: options.events,
9
+ topic: "github"
10
+ });
11
+ }
12
+ getSubscriberId() {
13
+ return "GithubEventRouter";
14
+ }
15
+ determineSubTopic(params) {
16
+ return params.metadata?.["x-github-event"];
17
+ }
18
+ }
19
+
20
+ exports.GithubEventRouter = GithubEventRouter;
21
+ //# sourceMappingURL=GithubEventRouter.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GithubEventRouter.cjs.js","sources":["../../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 {\n EventParams,\n EventsService,\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(options: { events: EventsService }) {\n super({\n events: options.events,\n topic: 'github',\n });\n }\n\n protected getSubscriberId(): string {\n return 'GithubEventRouter';\n }\n\n protected determineSubTopic(params: EventParams): string | undefined {\n return params.metadata?.['x-github-event'] as string | undefined;\n }\n}\n"],"names":["SubTopicEventRouter"],"mappings":";;;;AA6BO,MAAM,0BAA0BA,oCAAoB,CAAA;AAAA,EACzD,YAAY,OAAoC,EAAA;AAC9C,IAAM,KAAA,CAAA;AAAA,MACJ,QAAQ,OAAQ,CAAA,MAAA;AAAA,MAChB,KAAO,EAAA,QAAA;AAAA,KACR,CAAA,CAAA;AAAA,GACH;AAAA,EAEU,eAA0B,GAAA;AAClC,IAAO,OAAA,mBAAA,CAAA;AAAA,GACT;AAAA,EAEU,kBAAkB,MAAyC,EAAA;AACnE,IAAO,OAAA,MAAA,CAAO,WAAW,gBAAgB,CAAA,CAAA;AAAA,GAC3C;AACF;;;;"}
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ var backendPluginApi = require('@backstage/backend-plugin-api');
4
+ var pluginEventsNode = require('@backstage/plugin-events-node');
5
+ var GithubEventRouter = require('../router/GithubEventRouter.cjs.js');
6
+
7
+ const eventsModuleGithubEventRouter = backendPluginApi.createBackendModule({
8
+ pluginId: "events",
9
+ moduleId: "github-event-router",
10
+ register(env) {
11
+ env.registerInit({
12
+ deps: {
13
+ events: pluginEventsNode.eventsServiceRef
14
+ },
15
+ async init({ events }) {
16
+ const eventRouter = new GithubEventRouter.GithubEventRouter({ events });
17
+ await eventRouter.subscribe();
18
+ }
19
+ });
20
+ }
21
+ });
22
+
23
+ exports.eventsModuleGithubEventRouter = eventsModuleGithubEventRouter;
24
+ //# sourceMappingURL=eventsModuleGithubEventRouter.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eventsModuleGithubEventRouter.cjs.js","sources":["../../src/service/eventsModuleGithubEventRouter.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 { createBackendModule } from '@backstage/backend-plugin-api';\nimport { eventsServiceRef } from '@backstage/plugin-events-node';\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 eventsModuleGithubEventRouter = createBackendModule({\n pluginId: 'events',\n moduleId: 'github-event-router',\n register(env) {\n env.registerInit({\n deps: {\n events: eventsServiceRef,\n },\n async init({ events }) {\n const eventRouter = new GithubEventRouter({ events });\n await eventRouter.subscribe();\n },\n });\n },\n});\n"],"names":["createBackendModule","eventsServiceRef","GithubEventRouter"],"mappings":";;;;;;AA2BO,MAAM,gCAAgCA,oCAAoB,CAAA;AAAA,EAC/D,QAAU,EAAA,QAAA;AAAA,EACV,QAAU,EAAA,qBAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,MAAQ,EAAAC,iCAAA;AAAA,OACV;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,MAAA,EAAU,EAAA;AACrB,QAAA,MAAM,WAAc,GAAA,IAAIC,mCAAkB,CAAA,EAAE,QAAQ,CAAA,CAAA;AACpD,QAAA,MAAM,YAAY,SAAU,EAAA,CAAA;AAAA,OAC9B;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;"}
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ var backendPluginApi = require('@backstage/backend-plugin-api');
4
+ var alpha = require('@backstage/plugin-events-node/alpha');
5
+ var createGithubSignatureValidator = require('../http/createGithubSignatureValidator.cjs.js');
6
+
7
+ const eventsModuleGithubWebhook = backendPluginApi.createBackendModule({
8
+ pluginId: "events",
9
+ moduleId: "github-webhook",
10
+ register(env) {
11
+ env.registerInit({
12
+ deps: {
13
+ config: backendPluginApi.coreServices.rootConfig,
14
+ events: alpha.eventsExtensionPoint
15
+ },
16
+ async init({ config, events }) {
17
+ events.addHttpPostIngress({
18
+ topic: "github",
19
+ validator: createGithubSignatureValidator.createGithubSignatureValidator(config)
20
+ });
21
+ }
22
+ });
23
+ }
24
+ });
25
+
26
+ exports.eventsModuleGithubWebhook = eventsModuleGithubWebhook;
27
+ //# sourceMappingURL=eventsModuleGithubWebhook.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eventsModuleGithubWebhook.cjs.js","sources":["../../src/service/eventsModuleGithubWebhook.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 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 eventsModuleGithubWebhook = createBackendModule({\n pluginId: 'events',\n moduleId: 'github-webhook',\n register(env) {\n env.registerInit({\n deps: {\n config: coreServices.rootConfig,\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":["createBackendModule","coreServices","eventsExtensionPoint","createGithubSignatureValidator"],"mappings":";;;;;;AA8BO,MAAM,4BAA4BA,oCAAoB,CAAA;AAAA,EAC3D,QAAU,EAAA,QAAA;AAAA,EACV,QAAU,EAAA,gBAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,QAAQC,6BAAa,CAAA,UAAA;AAAA,QACrB,MAAQ,EAAAC,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,EAAWC,8DAA+B,MAAM,CAAA;AAAA,SACjD,CAAA,CAAA;AAAA,OACH;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-events-backend-module-github",
3
- "version": "0.2.12-next.0",
3
+ "version": "0.2.12-next.1",
4
4
  "backstage": {
5
5
  "role": "backend-plugin-module",
6
6
  "pluginId": "events",
@@ -46,15 +46,15 @@
46
46
  "test": "backstage-cli package test"
47
47
  },
48
48
  "dependencies": {
49
- "@backstage/backend-plugin-api": "^1.0.1-next.0",
50
- "@backstage/config": "^1.2.0",
51
- "@backstage/plugin-events-node": "^0.4.1-next.0",
49
+ "@backstage/backend-plugin-api": "1.0.1-next.1",
50
+ "@backstage/config": "1.2.0",
51
+ "@backstage/plugin-events-node": "0.4.1-next.1",
52
52
  "@octokit/webhooks-methods": "^3.0.0"
53
53
  },
54
54
  "devDependencies": {
55
- "@backstage/backend-test-utils": "^1.0.1-next.0",
56
- "@backstage/cli": "^0.28.0-next.0",
57
- "@backstage/plugin-events-backend-test-utils": "^0.1.36-next.0"
55
+ "@backstage/backend-test-utils": "1.0.1-next.2",
56
+ "@backstage/cli": "0.28.0-next.2",
57
+ "@backstage/plugin-events-backend-test-utils": "0.1.36-next.1"
58
58
  },
59
59
  "configSchema": "config.d.ts"
60
60
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"GithubEventRouter-DynNUSpO.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 EventsService,\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(options: { events: EventsService }) {\n super({\n events: options.events,\n topic: 'github',\n });\n }\n\n protected getSubscriberId(): string {\n return 'GithubEventRouter';\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;;AC7BO,MAAM,0BAA0BC,oCAAoB,CAAA;AAAA,EACzD,YAAY,OAAoC,EAAA;AAC9C,IAAM,KAAA,CAAA;AAAA,MACJ,QAAQ,OAAQ,CAAA,MAAA;AAAA,MAChB,KAAO,EAAA,QAAA;AAAA,KACR,CAAA,CAAA;AAAA,GACH;AAAA,EAEU,eAA0B,GAAA;AAClC,IAAO,OAAA,mBAAA,CAAA;AAAA,GACT;AAAA,EAEU,kBAAkB,MAAyC,EAAA;AACnE,IAAO,OAAA,MAAA,CAAO,WAAW,gBAAgB,CAAA,CAAA;AAAA,GAC3C;AACF;;;;;"}