@backstage/plugin-events-backend-module-gitlab 0.1.4 → 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 +10 -0
- package/alpha/package.json +3 -3
- package/dist/alpha.cjs.js +73 -0
- package/dist/alpha.cjs.js.map +1 -0
- package/dist/alpha.d.ts +23 -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 -41
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @backstage/plugin-events-backend-module-gitlab
|
|
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
|
+
|
|
3
13
|
## 0.1.4
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/alpha/package.json
CHANGED
|
@@ -0,0 +1,73 @@
|
|
|
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
|
+
|
|
9
|
+
class GitlabEventRouter extends pluginEventsNode.SubTopicEventRouter {
|
|
10
|
+
constructor() {
|
|
11
|
+
super("gitlab");
|
|
12
|
+
}
|
|
13
|
+
determineSubTopic(params) {
|
|
14
|
+
if ("event_name" in params.eventPayload) {
|
|
15
|
+
const payload = params.eventPayload;
|
|
16
|
+
return payload.event_name;
|
|
17
|
+
}
|
|
18
|
+
return void 0;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const gitlabEventRouterEventsModule = backendPluginApi.createBackendModule({
|
|
23
|
+
pluginId: "events",
|
|
24
|
+
moduleId: "gitlabEventRouter",
|
|
25
|
+
register(env) {
|
|
26
|
+
env.registerInit({
|
|
27
|
+
deps: {
|
|
28
|
+
events: alpha.eventsExtensionPoint
|
|
29
|
+
},
|
|
30
|
+
async init({ events }) {
|
|
31
|
+
const eventRouter = new GitlabEventRouter();
|
|
32
|
+
events.addPublishers(eventRouter);
|
|
33
|
+
events.addSubscribers(eventRouter);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
function createGitlabTokenValidator(config) {
|
|
40
|
+
const secret = config.getString("events.modules.gitlab.webhookSecret");
|
|
41
|
+
return async (request, context) => {
|
|
42
|
+
const token = request.headers["x-gitlab-token"];
|
|
43
|
+
if (secret !== token) {
|
|
44
|
+
context.reject({
|
|
45
|
+
status: 403,
|
|
46
|
+
payload: { message: "invalid token" }
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const gitlabWebhookEventsModule = backendPluginApi.createBackendModule({
|
|
53
|
+
pluginId: "events",
|
|
54
|
+
moduleId: "gitlabWebhook",
|
|
55
|
+
register(env) {
|
|
56
|
+
env.registerInit({
|
|
57
|
+
deps: {
|
|
58
|
+
config: backendPluginApi.coreServices.config,
|
|
59
|
+
events: alpha.eventsExtensionPoint
|
|
60
|
+
},
|
|
61
|
+
async init({ config, events }) {
|
|
62
|
+
events.addHttpPostIngress({
|
|
63
|
+
topic: "gitlab",
|
|
64
|
+
validator: createGitlabTokenValidator(config)
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
exports.gitlabEventRouterEventsModule = gitlabEventRouterEventsModule;
|
|
72
|
+
exports.gitlabWebhookEventsModule = gitlabWebhookEventsModule;
|
|
73
|
+
//# sourceMappingURL=alpha.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alpha.cjs.js","sources":["../src/router/GitlabEventRouter.ts","../src/service/GitlabEventRouterEventsModule.ts","../src/http/createGitlabTokenValidator.ts","../src/service/GitlabWebhookEventsModule.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 `gitlab` topic\n * and publishes the events under the more concrete sub-topic\n * depending on the `$.event_name` field provided.\n *\n * @public\n */\nexport class GitlabEventRouter extends SubTopicEventRouter {\n constructor() {\n super('gitlab');\n }\n\n protected determineSubTopic(params: EventParams): string | undefined {\n if ('event_name' in (params.eventPayload as object)) {\n const payload = params.eventPayload as { event_name: string };\n return payload.event_name;\n }\n\n return 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 { GitlabEventRouter } from '../router/GitlabEventRouter';\n\n/**\n * Module for the events-backend plugin, adding an event router for GitLab.\n *\n * Registers the `GitlabEventRouter`.\n *\n * @alpha\n */\nexport const gitlabEventRouterEventsModule = createBackendModule({\n pluginId: 'events',\n moduleId: 'gitlabEventRouter',\n register(env) {\n env.registerInit({\n deps: {\n events: eventsExtensionPoint,\n },\n async init({ events }) {\n const eventRouter = new GitlabEventRouter();\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';\n\n/**\n * Validates a configured secret token against the token received with the `x-gitlab-token` header.\n *\n * See https://docs.gitlab.com/ee/user/project/integrations/webhooks.html#validate-payloads-by-using-a-secret-token\n * for more details.\n *\n * @param config - root config\n * @public\n */\nexport function createGitlabTokenValidator(config: Config): RequestValidator {\n const secret = config.getString('events.modules.gitlab.webhookSecret');\n\n return async (\n request: RequestDetails,\n context: RequestValidationContext,\n ): Promise<void> => {\n const token = request.headers['x-gitlab-token'] as string | undefined;\n\n if (secret !== token) {\n context.reject({\n status: 403,\n payload: { message: 'invalid token' },\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 { createGitlabTokenValidator } from '../http/createGitlabTokenValidator';\n\n/**\n * Module for the events-backend plugin,\n * registering an HTTP POST ingress with request validator\n * which verifies the webhook token based on a secret.\n *\n * Registers the `GitlabEventRouter`.\n *\n * @alpha\n */\nexport const gitlabWebhookEventsModule = createBackendModule({\n pluginId: 'events',\n moduleId: 'gitlabWebhook',\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: 'gitlab',\n validator: createGitlabTokenValidator(config),\n });\n },\n });\n },\n});\n"],"names":["SubTopicEventRouter","createBackendModule","eventsExtensionPoint","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;AACnE,IAAI,IAAA,YAAA,IAAiB,OAAO,YAAyB,EAAA;AACnD,MAAA,MAAM,UAAU,MAAO,CAAA,YAAA,CAAA;AACvB,MAAA,OAAO,OAAQ,CAAA,UAAA,CAAA;AAAA,KACjB;AAEA,IAAO,OAAA,KAAA,CAAA,CAAA;AAAA,GACT;AACF;;ACdO,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;;ACXM,SAAS,2BAA2B,MAAkC,EAAA;AAC3E,EAAM,MAAA,MAAA,GAAS,MAAO,CAAA,SAAA,CAAU,qCAAqC,CAAA,CAAA;AAErE,EAAO,OAAA,OACL,SACA,OACkB,KAAA;AAClB,IAAM,MAAA,KAAA,GAAQ,OAAQ,CAAA,OAAA,CAAQ,gBAAgB,CAAA,CAAA;AAE9C,IAAA,IAAI,WAAW,KAAO,EAAA;AACpB,MAAA,OAAA,CAAQ,MAAO,CAAA;AAAA,QACb,MAAQ,EAAA,GAAA;AAAA,QACR,OAAA,EAAS,EAAE,OAAA,EAAS,eAAgB,EAAA;AAAA,OACrC,CAAA,CAAA;AAAA,KACH;AAAA,GACF,CAAA;AACF;;AChBO,MAAM,4BAA4BD,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,QAAQE,6BAAa,CAAA,MAAA;AAAA,QACrB,MAAQ,EAAAD,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,2BAA2B,MAAM,CAAA;AAAA,SAC7C,CAAA,CAAA;AAAA,OACH;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;;"}
|
package/dist/alpha.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
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 GitLab.
|
|
5
|
+
*
|
|
6
|
+
* Registers the `GitlabEventRouter`.
|
|
7
|
+
*
|
|
8
|
+
* @alpha
|
|
9
|
+
*/
|
|
10
|
+
declare const gitlabEventRouterEventsModule: () => _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 token based on a secret.
|
|
16
|
+
*
|
|
17
|
+
* Registers the `GitlabEventRouter`.
|
|
18
|
+
*
|
|
19
|
+
* @alpha
|
|
20
|
+
*/
|
|
21
|
+
declare const gitlabWebhookEventsModule: () => _backstage_backend_plugin_api.BackendFeature;
|
|
22
|
+
|
|
23
|
+
export { gitlabEventRouterEventsModule, gitlabWebhookEventsModule };
|
package/dist/index.cjs.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var pluginEventsNode = require('@backstage/plugin-events-node');
|
|
6
|
-
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
7
6
|
|
|
8
7
|
function createGitlabTokenValidator(config) {
|
|
9
8
|
const secret = config.getString("events.modules.gitlab.webhookSecret");
|
|
@@ -31,44 +30,6 @@ class GitlabEventRouter extends pluginEventsNode.SubTopicEventRouter {
|
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
const gitlabEventRouterEventsModule = backendPluginApi.createBackendModule({
|
|
35
|
-
pluginId: "events",
|
|
36
|
-
moduleId: "gitlabEventRouter",
|
|
37
|
-
register(env) {
|
|
38
|
-
env.registerInit({
|
|
39
|
-
deps: {
|
|
40
|
-
events: pluginEventsNode.eventsExtensionPoint
|
|
41
|
-
},
|
|
42
|
-
async init({ events }) {
|
|
43
|
-
const eventRouter = new GitlabEventRouter();
|
|
44
|
-
events.addPublishers(eventRouter);
|
|
45
|
-
events.addSubscribers(eventRouter);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
const gitlabWebhookEventsModule = backendPluginApi.createBackendModule({
|
|
52
|
-
pluginId: "events",
|
|
53
|
-
moduleId: "gitlabWebhook",
|
|
54
|
-
register(env) {
|
|
55
|
-
env.registerInit({
|
|
56
|
-
deps: {
|
|
57
|
-
config: backendPluginApi.coreServices.config,
|
|
58
|
-
events: pluginEventsNode.eventsExtensionPoint
|
|
59
|
-
},
|
|
60
|
-
async init({ config, events }) {
|
|
61
|
-
events.addHttpPostIngress({
|
|
62
|
-
topic: "gitlab",
|
|
63
|
-
validator: createGitlabTokenValidator(config)
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
|
|
70
33
|
exports.GitlabEventRouter = GitlabEventRouter;
|
|
71
34
|
exports.createGitlabTokenValidator = createGitlabTokenValidator;
|
|
72
|
-
exports.gitlabEventRouterEventsModule = gitlabEventRouterEventsModule;
|
|
73
|
-
exports.gitlabWebhookEventsModule = gitlabWebhookEventsModule;
|
|
74
35
|
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/http/createGitlabTokenValidator.ts","../src/router/GitlabEventRouter.ts"
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/http/createGitlabTokenValidator.ts","../src/router/GitlabEventRouter.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';\n\n/**\n * Validates a configured secret token against the token received with the `x-gitlab-token` header.\n *\n * See https://docs.gitlab.com/ee/user/project/integrations/webhooks.html#validate-payloads-by-using-a-secret-token\n * for more details.\n *\n * @param config - root config\n * @public\n */\nexport function createGitlabTokenValidator(config: Config): RequestValidator {\n const secret = config.getString('events.modules.gitlab.webhookSecret');\n\n return async (\n request: RequestDetails,\n context: RequestValidationContext,\n ): Promise<void> => {\n const token = request.headers['x-gitlab-token'] as string | undefined;\n\n if (secret !== token) {\n context.reject({\n status: 403,\n payload: { message: 'invalid token' },\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 `gitlab` topic\n * and publishes the events under the more concrete sub-topic\n * depending on the `$.event_name` field provided.\n *\n * @public\n */\nexport class GitlabEventRouter extends SubTopicEventRouter {\n constructor() {\n super('gitlab');\n }\n\n protected determineSubTopic(params: EventParams): string | undefined {\n if ('event_name' in (params.eventPayload as object)) {\n const payload = params.eventPayload as { event_name: string };\n return payload.event_name;\n }\n\n return undefined;\n }\n}\n"],"names":["SubTopicEventRouter"],"mappings":";;;;;;AAgCO,SAAS,2BAA2B,MAAkC,EAAA;AAC3E,EAAM,MAAA,MAAA,GAAS,MAAO,CAAA,SAAA,CAAU,qCAAqC,CAAA,CAAA;AAErE,EAAO,OAAA,OACL,SACA,OACkB,KAAA;AAClB,IAAM,MAAA,KAAA,GAAQ,OAAQ,CAAA,OAAA,CAAQ,gBAAgB,CAAA,CAAA;AAE9C,IAAA,IAAI,WAAW,KAAO,EAAA;AACpB,MAAA,OAAA,CAAQ,MAAO,CAAA;AAAA,QACb,MAAQ,EAAA,GAAA;AAAA,QACR,OAAA,EAAS,EAAE,OAAA,EAAS,eAAgB,EAAA;AAAA,OACrC,CAAA,CAAA;AAAA,KACH;AAAA,GACF,CAAA;AACF;;ACpBO,MAAM,0BAA0BA,oCAAoB,CAAA;AAAA,EACzD,WAAc,GAAA;AACZ,IAAA,KAAA,CAAM,QAAQ,CAAA,CAAA;AAAA,GAChB;AAAA,EAEU,kBAAkB,MAAyC,EAAA;AACnE,IAAI,IAAA,YAAA,IAAiB,OAAO,YAAyB,EAAA;AACnD,MAAA,MAAM,UAAU,MAAO,CAAA,YAAA,CAAA;AACvB,MAAA,OAAO,OAAQ,CAAA,UAAA,CAAA;AAAA,KACjB;AAEA,IAAO,OAAA,KAAA,CAAA,CAAA;AAAA,GACT;AACF;;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The module "gitlab" for the Backstage backend plugin "events-backend"
|
|
3
|
-
* adding an event router and token validator for GitLab.
|
|
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 a configured secret token against the token received with the `x-gitlab-token` header.
|
|
@@ -20,7 +10,7 @@ import { SubTopicEventRouter } from '@backstage/plugin-events-node';
|
|
|
20
10
|
* @param config - root config
|
|
21
11
|
* @public
|
|
22
12
|
*/
|
|
23
|
-
|
|
13
|
+
declare function createGitlabTokenValidator(config: Config): RequestValidator;
|
|
24
14
|
|
|
25
15
|
/**
|
|
26
16
|
* Subscribes to the generic `gitlab` topic
|
|
@@ -29,13 +19,9 @@ export declare function createGitlabTokenValidator(config: Config): RequestValid
|
|
|
29
19
|
*
|
|
30
20
|
* @public
|
|
31
21
|
*/
|
|
32
|
-
|
|
22
|
+
declare class GitlabEventRouter extends SubTopicEventRouter {
|
|
33
23
|
constructor();
|
|
34
24
|
protected determineSubTopic(params: EventParams): string | undefined;
|
|
35
25
|
}
|
|
36
26
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
/* Excluded from this release type: gitlabWebhookEventsModule */
|
|
40
|
-
|
|
41
|
-
export { }
|
|
27
|
+
export { GitlabEventRouter, createGitlabTokenValidator };
|
package/package.json
CHANGED
|
@@ -1,21 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-events-backend-module-gitlab",
|
|
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,21 +33,21 @@
|
|
|
23
33
|
"postpack": "backstage-cli package postpack"
|
|
24
34
|
},
|
|
25
35
|
"dependencies": {
|
|
26
|
-
"@backstage/backend-plugin-api": "^0.4.0",
|
|
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
|
"winston": "^3.2.1"
|
|
30
40
|
},
|
|
31
41
|
"devDependencies": {
|
|
32
|
-
"@backstage/backend-test-utils": "^0.1.
|
|
33
|
-
"@backstage/cli": "^0.22.
|
|
34
|
-
"@backstage/plugin-events-backend-test-utils": "^0.1.
|
|
42
|
+
"@backstage/backend-test-utils": "^0.1.35-next.0",
|
|
43
|
+
"@backstage/cli": "^0.22.4-next.0",
|
|
44
|
+
"@backstage/plugin-events-backend-test-utils": "^0.1.5-next.0",
|
|
35
45
|
"supertest": "^6.1.3"
|
|
36
46
|
},
|
|
37
47
|
"files": [
|
|
38
|
-
"alpha",
|
|
39
48
|
"config.d.ts",
|
|
40
|
-
"dist"
|
|
49
|
+
"dist",
|
|
50
|
+
"alpha"
|
|
41
51
|
],
|
|
42
52
|
"configSchema": "config.d.ts"
|
|
43
53
|
}
|
package/dist/index.alpha.d.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The module "gitlab" for the Backstage backend plugin "events-backend"
|
|
3
|
-
* adding an event router and token validator for GitLab.
|
|
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 a configured secret token against the token received with the `x-gitlab-token` header.
|
|
16
|
-
*
|
|
17
|
-
* See https://docs.gitlab.com/ee/user/project/integrations/webhooks.html#validate-payloads-by-using-a-secret-token
|
|
18
|
-
* for more details.
|
|
19
|
-
*
|
|
20
|
-
* @param config - root config
|
|
21
|
-
* @public
|
|
22
|
-
*/
|
|
23
|
-
export declare function createGitlabTokenValidator(config: Config): RequestValidator;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Subscribes to the generic `gitlab` topic
|
|
27
|
-
* and publishes the events under the more concrete sub-topic
|
|
28
|
-
* depending on the `$.event_name` field provided.
|
|
29
|
-
*
|
|
30
|
-
* @public
|
|
31
|
-
*/
|
|
32
|
-
export declare class GitlabEventRouter extends SubTopicEventRouter {
|
|
33
|
-
constructor();
|
|
34
|
-
protected determineSubTopic(params: EventParams): string | undefined;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Module for the events-backend plugin, adding an event router for GitLab.
|
|
39
|
-
*
|
|
40
|
-
* Registers the {@link GitlabEventRouter}.
|
|
41
|
-
*
|
|
42
|
-
* @alpha
|
|
43
|
-
*/
|
|
44
|
-
export declare const gitlabEventRouterEventsModule: () => BackendFeature;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Module for the events-backend plugin,
|
|
48
|
-
* registering an HTTP POST ingress with request validator
|
|
49
|
-
* which verifies the webhook token based on a secret.
|
|
50
|
-
*
|
|
51
|
-
* Registers the {@link GitlabEventRouter}.
|
|
52
|
-
*
|
|
53
|
-
* @alpha
|
|
54
|
-
*/
|
|
55
|
-
export declare const gitlabWebhookEventsModule: () => BackendFeature;
|
|
56
|
-
|
|
57
|
-
export { }
|
package/dist/index.beta.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The module "gitlab" for the Backstage backend plugin "events-backend"
|
|
3
|
-
* adding an event router and token validator for GitLab.
|
|
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 a configured secret token against the token received with the `x-gitlab-token` header.
|
|
16
|
-
*
|
|
17
|
-
* See https://docs.gitlab.com/ee/user/project/integrations/webhooks.html#validate-payloads-by-using-a-secret-token
|
|
18
|
-
* for more details.
|
|
19
|
-
*
|
|
20
|
-
* @param config - root config
|
|
21
|
-
* @public
|
|
22
|
-
*/
|
|
23
|
-
export declare function createGitlabTokenValidator(config: Config): RequestValidator;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Subscribes to the generic `gitlab` topic
|
|
27
|
-
* and publishes the events under the more concrete sub-topic
|
|
28
|
-
* depending on the `$.event_name` field provided.
|
|
29
|
-
*
|
|
30
|
-
* @public
|
|
31
|
-
*/
|
|
32
|
-
export declare class GitlabEventRouter extends SubTopicEventRouter {
|
|
33
|
-
constructor();
|
|
34
|
-
protected determineSubTopic(params: EventParams): string | undefined;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/* Excluded from this release type: gitlabEventRouterEventsModule */
|
|
38
|
-
|
|
39
|
-
/* Excluded from this release type: gitlabWebhookEventsModule */
|
|
40
|
-
|
|
41
|
-
export { }
|