cyrus-github-event-transport 0.2.22

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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Service for posting comments back to GitHub PR conversations.
3
+ *
4
+ * Uses the GitHub REST API with an installation access token
5
+ * to post replies on PR issue comments and PR review comments.
6
+ */
7
+ export interface GitHubCommentServiceConfig {
8
+ /** GitHub API base URL (default: https://api.github.com) */
9
+ apiBaseUrl?: string;
10
+ }
11
+ /**
12
+ * Parameters for posting a reply to a GitHub PR comment
13
+ */
14
+ export interface PostCommentParams {
15
+ /** GitHub installation access token */
16
+ token: string;
17
+ /** Repository owner */
18
+ owner: string;
19
+ /** Repository name */
20
+ repo: string;
21
+ /** PR/Issue number */
22
+ issueNumber: number;
23
+ /** Comment body (markdown) */
24
+ body: string;
25
+ }
26
+ /**
27
+ * Parameters for posting a reply to a PR review comment
28
+ */
29
+ export interface PostReviewCommentReplyParams {
30
+ /** GitHub installation access token */
31
+ token: string;
32
+ /** Repository owner */
33
+ owner: string;
34
+ /** Repository name */
35
+ repo: string;
36
+ /** Pull request number */
37
+ pullNumber: number;
38
+ /** The ID of the review comment to reply to */
39
+ commentId: number;
40
+ /** Reply body (markdown) */
41
+ body: string;
42
+ }
43
+ /**
44
+ * Response from GitHub API after creating a comment
45
+ */
46
+ export interface GitHubCommentResponse {
47
+ id: number;
48
+ html_url: string;
49
+ body: string;
50
+ }
51
+ /**
52
+ * Parameters for adding a reaction to a GitHub comment
53
+ */
54
+ export interface AddReactionParams {
55
+ /** GitHub installation access token */
56
+ token: string;
57
+ /** Repository owner */
58
+ owner: string;
59
+ /** Repository name */
60
+ repo: string;
61
+ /** The ID of the comment to react to */
62
+ commentId: number;
63
+ /** Whether this is a PR review comment (vs an issue comment) */
64
+ isPullRequestReviewComment: boolean;
65
+ /** Reaction content (e.g. "eyes", "+1", "heart") */
66
+ content: string;
67
+ }
68
+ export declare class GitHubCommentService {
69
+ private apiBaseUrl;
70
+ constructor(config?: GitHubCommentServiceConfig);
71
+ /**
72
+ * Post a comment on a PR/Issue (top-level comment).
73
+ * Used for replying to issue_comment webhooks.
74
+ *
75
+ * @see https://docs.github.com/en/rest/issues/comments#create-an-issue-comment
76
+ */
77
+ postIssueComment(params: PostCommentParams): Promise<GitHubCommentResponse>;
78
+ /**
79
+ * Post a reply to a PR review comment (inline reply).
80
+ * Used for replying to pull_request_review_comment webhooks.
81
+ *
82
+ * @see https://docs.github.com/en/rest/pulls/comments#create-a-reply-for-a-review-comment
83
+ */
84
+ postReviewCommentReply(params: PostReviewCommentReplyParams): Promise<GitHubCommentResponse>;
85
+ /**
86
+ * Add a reaction to a comment.
87
+ *
88
+ * @see https://docs.github.com/en/rest/reactions/reactions#create-reaction-for-an-issue-comment
89
+ * @see https://docs.github.com/en/rest/reactions/reactions#create-reaction-for-a-pull-request-review-comment
90
+ */
91
+ addReaction(params: AddReactionParams): Promise<void>;
92
+ }
93
+ //# sourceMappingURL=GitHubCommentService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GitHubCommentService.d.ts","sourceRoot":"","sources":["../src/GitHubCommentService.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,0BAA0B;IAC1C,4DAA4D;IAC5D,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,uBAAuB;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,sBAAsB;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,sBAAsB;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC5C,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,uBAAuB;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,sBAAsB;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,0BAA0B;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,+CAA+C;IAC/C,SAAS,EAAE,MAAM,CAAC;IAClB,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,uBAAuB;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,sBAAsB;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,gEAAgE;IAChE,0BAA0B,EAAE,OAAO,CAAC;IACpC,oDAAoD;IACpD,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,oBAAoB;IAChC,OAAO,CAAC,UAAU,CAAS;gBAEf,MAAM,CAAC,EAAE,0BAA0B;IAI/C;;;;;OAKG;IACG,gBAAgB,CACrB,MAAM,EAAE,iBAAiB,GACvB,OAAO,CAAC,qBAAqB,CAAC;IAyBjC;;;;;OAKG;IACG,sBAAsB,CAC3B,MAAM,EAAE,4BAA4B,GAClC,OAAO,CAAC,qBAAqB,CAAC;IAyBjC;;;;;OAKG;IACG,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;CA+B3D"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Service for posting comments back to GitHub PR conversations.
3
+ *
4
+ * Uses the GitHub REST API with an installation access token
5
+ * to post replies on PR issue comments and PR review comments.
6
+ */
7
+ export class GitHubCommentService {
8
+ apiBaseUrl;
9
+ constructor(config) {
10
+ this.apiBaseUrl = config?.apiBaseUrl ?? "https://api.github.com";
11
+ }
12
+ /**
13
+ * Post a comment on a PR/Issue (top-level comment).
14
+ * Used for replying to issue_comment webhooks.
15
+ *
16
+ * @see https://docs.github.com/en/rest/issues/comments#create-an-issue-comment
17
+ */
18
+ async postIssueComment(params) {
19
+ const { token, owner, repo, issueNumber, body } = params;
20
+ const url = `${this.apiBaseUrl}/repos/${owner}/${repo}/issues/${issueNumber}/comments`;
21
+ const response = await fetch(url, {
22
+ method: "POST",
23
+ headers: {
24
+ Authorization: `Bearer ${token}`,
25
+ Accept: "application/vnd.github+json",
26
+ "Content-Type": "application/json",
27
+ "X-GitHub-Api-Version": "2022-11-28",
28
+ },
29
+ body: JSON.stringify({ body }),
30
+ });
31
+ if (!response.ok) {
32
+ const errorBody = await response.text();
33
+ throw new Error(`[GitHubCommentService] Failed to post issue comment: ${response.status} ${response.statusText} - ${errorBody}`);
34
+ }
35
+ return (await response.json());
36
+ }
37
+ /**
38
+ * Post a reply to a PR review comment (inline reply).
39
+ * Used for replying to pull_request_review_comment webhooks.
40
+ *
41
+ * @see https://docs.github.com/en/rest/pulls/comments#create-a-reply-for-a-review-comment
42
+ */
43
+ async postReviewCommentReply(params) {
44
+ const { token, owner, repo, pullNumber, commentId, body } = params;
45
+ const url = `${this.apiBaseUrl}/repos/${owner}/${repo}/pulls/${pullNumber}/comments/${commentId}/replies`;
46
+ const response = await fetch(url, {
47
+ method: "POST",
48
+ headers: {
49
+ Authorization: `Bearer ${token}`,
50
+ Accept: "application/vnd.github+json",
51
+ "Content-Type": "application/json",
52
+ "X-GitHub-Api-Version": "2022-11-28",
53
+ },
54
+ body: JSON.stringify({ body }),
55
+ });
56
+ if (!response.ok) {
57
+ const errorBody = await response.text();
58
+ throw new Error(`[GitHubCommentService] Failed to post review comment reply: ${response.status} ${response.statusText} - ${errorBody}`);
59
+ }
60
+ return (await response.json());
61
+ }
62
+ /**
63
+ * Add a reaction to a comment.
64
+ *
65
+ * @see https://docs.github.com/en/rest/reactions/reactions#create-reaction-for-an-issue-comment
66
+ * @see https://docs.github.com/en/rest/reactions/reactions#create-reaction-for-a-pull-request-review-comment
67
+ */
68
+ async addReaction(params) {
69
+ const { token, owner, repo, commentId, isPullRequestReviewComment, content, } = params;
70
+ const segment = isPullRequestReviewComment ? "pulls" : "issues";
71
+ const url = `${this.apiBaseUrl}/repos/${owner}/${repo}/${segment}/comments/${commentId}/reactions`;
72
+ const response = await fetch(url, {
73
+ method: "POST",
74
+ headers: {
75
+ Authorization: `Bearer ${token}`,
76
+ Accept: "application/vnd.github+json",
77
+ "Content-Type": "application/json",
78
+ "X-GitHub-Api-Version": "2022-11-28",
79
+ },
80
+ body: JSON.stringify({ content }),
81
+ });
82
+ if (!response.ok) {
83
+ const errorBody = await response.text();
84
+ throw new Error(`[GitHubCommentService] Failed to add reaction: ${response.status} ${response.statusText} - ${errorBody}`);
85
+ }
86
+ }
87
+ }
88
+ //# sourceMappingURL=GitHubCommentService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GitHubCommentService.js","sourceRoot":"","sources":["../src/GitHubCommentService.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAoEH,MAAM,OAAO,oBAAoB;IACxB,UAAU,CAAS;IAE3B,YAAY,MAAmC;QAC9C,IAAI,CAAC,UAAU,GAAG,MAAM,EAAE,UAAU,IAAI,wBAAwB,CAAC;IAClE,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,gBAAgB,CACrB,MAAyB;QAEzB,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;QACzD,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,UAAU,UAAU,KAAK,IAAI,IAAI,WAAW,WAAW,WAAW,CAAC;QAEvF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;YACjC,MAAM,EAAE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YACxC,MAAM,IAAI,KAAK,CACd,+DAA+D,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,MAAM,SAAS,EAAE,CACtH,CAAC;QACH,CAAC;QAED,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAA0B,CAAC;IACzD,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,WAAW,CAAC,MAAyB;QAC1C,MAAM,EACL,KAAK,EACL,KAAK,EACL,IAAI,EACJ,SAAS,EACT,0BAA0B,EAC1B,OAAO,GACP,GAAG,MAAM,CAAC;QAEX,MAAM,OAAO,GAAG,0BAA0B,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC;QAChE,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,UAAU,UAAU,KAAK,IAAI,IAAI,IAAI,OAAO,aAAa,SAAS,YAAY,CAAC;QAEnG,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;YACjC,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACR,aAAa,EAAE,UAAU,KAAK,EAAE;gBAChC,MAAM,EAAE,6BAA6B;gBACrC,cAAc,EAAE,kBAAkB;gBAClC,sBAAsB,EAAE,YAAY;aACpC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC;SACjC,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YAClB,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACxC,MAAM,IAAI,KAAK,CACd,kDAAkD,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,MAAM,SAAS,EAAE,CACzG,CAAC;QACH,CAAC;IACF,CAAC;CACD"}
@@ -0,0 +1,60 @@
1
+ import { EventEmitter } from "node:events";
2
+ import type { TranslationContext } from "cyrus-core";
3
+ import { type ILogger } from "cyrus-core";
4
+ import type { GitHubEventTransportConfig, GitHubEventTransportEvents } from "./types.js";
5
+ export declare interface GitHubEventTransport {
6
+ on<K extends keyof GitHubEventTransportEvents>(event: K, listener: GitHubEventTransportEvents[K]): this;
7
+ emit<K extends keyof GitHubEventTransportEvents>(event: K, ...args: Parameters<GitHubEventTransportEvents[K]>): boolean;
8
+ }
9
+ /**
10
+ * GitHubEventTransport - Handles forwarded GitHub webhook event delivery
11
+ *
12
+ * This class provides a typed EventEmitter-based transport
13
+ * for handling GitHub webhooks forwarded from CYHOST.
14
+ *
15
+ * It registers a POST /github-webhook endpoint with a Fastify server
16
+ * and verifies incoming webhooks using either:
17
+ * 1. "proxy" mode: Verifies Bearer token authentication (self-hosted)
18
+ * 2. "signature" mode: Verifies GitHub's HMAC-SHA256 signature (cloud)
19
+ *
20
+ * Supported GitHub event types:
21
+ * - issue_comment: Comments on PR issues (top-level PR comments)
22
+ * - pull_request_review_comment: Inline review comments on PR diffs
23
+ */
24
+ export declare class GitHubEventTransport extends EventEmitter {
25
+ private config;
26
+ private logger;
27
+ private messageTranslator;
28
+ private translationContext;
29
+ constructor(config: GitHubEventTransportConfig, logger?: ILogger, translationContext?: TranslationContext);
30
+ /**
31
+ * Set the translation context for message translation.
32
+ */
33
+ setTranslationContext(context: TranslationContext): void;
34
+ /**
35
+ * Register the /github-webhook endpoint with the Fastify server
36
+ */
37
+ register(): void;
38
+ /**
39
+ * Handle webhook using GitHub's HMAC-SHA256 signature verification
40
+ */
41
+ private handleSignatureWebhook;
42
+ /**
43
+ * Handle webhook using Bearer token authentication (forwarded from CYHOST)
44
+ */
45
+ private handleProxyWebhook;
46
+ /**
47
+ * Process the webhook request and emit the appropriate event
48
+ */
49
+ private processAndEmitEvent;
50
+ /**
51
+ * Translate and emit an internal message from a webhook event.
52
+ * Only emits if translation succeeds; logs debug message on failure.
53
+ */
54
+ private emitMessage;
55
+ /**
56
+ * Verify GitHub webhook signature using HMAC-SHA256
57
+ */
58
+ private verifyGitHubSignature;
59
+ }
60
+ //# sourceMappingURL=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AO,CAAC,qBAAqB;CAgB7B"}
@@ -0,0 +1,181 @@
1
+ import { createHmac, timingSafeEqual } from "node:crypto";
2
+ import { EventEmitter } from "node:events";
3
+ import { createLogger } from "cyrus-core";
4
+ import { GitHubMessageTranslator } from "./GitHubMessageTranslator.js";
5
+ /**
6
+ * GitHubEventTransport - Handles forwarded GitHub webhook event delivery
7
+ *
8
+ * This class provides a typed EventEmitter-based transport
9
+ * for handling GitHub webhooks forwarded from CYHOST.
10
+ *
11
+ * It registers a POST /github-webhook endpoint with a Fastify server
12
+ * and verifies incoming webhooks using either:
13
+ * 1. "proxy" mode: Verifies Bearer token authentication (self-hosted)
14
+ * 2. "signature" mode: Verifies GitHub's HMAC-SHA256 signature (cloud)
15
+ *
16
+ * Supported GitHub event types:
17
+ * - issue_comment: Comments on PR issues (top-level PR comments)
18
+ * - pull_request_review_comment: Inline review comments on PR diffs
19
+ */
20
+ export class GitHubEventTransport extends EventEmitter {
21
+ config;
22
+ logger;
23
+ messageTranslator;
24
+ translationContext;
25
+ constructor(config, logger, translationContext) {
26
+ super();
27
+ this.config = config;
28
+ this.logger = logger ?? createLogger({ component: "GitHubEventTransport" });
29
+ this.messageTranslator = new GitHubMessageTranslator();
30
+ this.translationContext = translationContext ?? {};
31
+ }
32
+ /**
33
+ * Set the translation context for message translation.
34
+ */
35
+ setTranslationContext(context) {
36
+ this.translationContext = { ...this.translationContext, ...context };
37
+ }
38
+ /**
39
+ * Register the /github-webhook endpoint with the Fastify server
40
+ */
41
+ register() {
42
+ this.config.fastifyServer.post("/github-webhook", {
43
+ config: {
44
+ rawBody: true,
45
+ },
46
+ }, async (request, reply) => {
47
+ try {
48
+ if (this.config.verificationMode === "signature") {
49
+ await this.handleSignatureWebhook(request, reply);
50
+ }
51
+ else {
52
+ await this.handleProxyWebhook(request, reply);
53
+ }
54
+ }
55
+ catch (error) {
56
+ const err = new Error("Webhook error");
57
+ if (error instanceof Error) {
58
+ err.cause = error;
59
+ }
60
+ this.logger.error("Webhook error", err);
61
+ this.emit("error", err);
62
+ reply.code(500).send({ error: "Internal server error" });
63
+ }
64
+ });
65
+ this.logger.info(`Registered POST /github-webhook endpoint (${this.config.verificationMode} mode)`);
66
+ }
67
+ /**
68
+ * Handle webhook using GitHub's HMAC-SHA256 signature verification
69
+ */
70
+ async handleSignatureWebhook(request, reply) {
71
+ const signature = request.headers["x-hub-signature-256"];
72
+ if (!signature) {
73
+ reply.code(401).send({ error: "Missing x-hub-signature-256 header" });
74
+ return;
75
+ }
76
+ try {
77
+ const body = request.rawBody;
78
+ const isValid = this.verifyGitHubSignature(body, signature, this.config.secret);
79
+ if (!isValid) {
80
+ reply.code(401).send({ error: "Invalid webhook signature" });
81
+ return;
82
+ }
83
+ this.processAndEmitEvent(request, reply);
84
+ }
85
+ catch (error) {
86
+ const err = new Error("Signature verification failed");
87
+ if (error instanceof Error) {
88
+ err.cause = error;
89
+ }
90
+ this.logger.error("Signature verification failed", err);
91
+ reply.code(401).send({ error: "Invalid webhook signature" });
92
+ }
93
+ }
94
+ /**
95
+ * Handle webhook using Bearer token authentication (forwarded from CYHOST)
96
+ */
97
+ async handleProxyWebhook(request, reply) {
98
+ const authHeader = request.headers.authorization;
99
+ if (!authHeader) {
100
+ reply.code(401).send({ error: "Missing Authorization header" });
101
+ return;
102
+ }
103
+ const expectedAuth = `Bearer ${this.config.secret}`;
104
+ if (authHeader !== expectedAuth) {
105
+ reply.code(401).send({ error: "Invalid authorization token" });
106
+ return;
107
+ }
108
+ try {
109
+ this.processAndEmitEvent(request, reply);
110
+ }
111
+ catch (error) {
112
+ const err = new Error("Proxy webhook processing failed");
113
+ if (error instanceof Error) {
114
+ err.cause = error;
115
+ }
116
+ this.logger.error("Proxy webhook processing failed", err);
117
+ reply.code(500).send({ error: "Failed to process webhook" });
118
+ }
119
+ }
120
+ /**
121
+ * Process the webhook request and emit the appropriate event
122
+ */
123
+ processAndEmitEvent(request, reply) {
124
+ const eventType = request.headers["x-github-event"];
125
+ const deliveryId = request.headers["x-github-delivery"] || "unknown";
126
+ const installationToken = request.headers["x-github-installation-token"];
127
+ if (!eventType) {
128
+ reply.code(400).send({ error: "Missing x-github-event header" });
129
+ return;
130
+ }
131
+ if (eventType !== "issue_comment" &&
132
+ eventType !== "pull_request_review_comment") {
133
+ this.logger.debug(`Ignoring unsupported event type: ${eventType}`);
134
+ reply.code(200).send({ success: true, ignored: true });
135
+ return;
136
+ }
137
+ const payload = request.body;
138
+ // Only handle 'created' actions (new comments, not edits/deletes)
139
+ if (payload.action !== "created") {
140
+ this.logger.debug(`Ignoring ${eventType} with action: ${payload.action}`);
141
+ reply.code(200).send({ success: true, ignored: true });
142
+ return;
143
+ }
144
+ const webhookEvent = {
145
+ eventType: eventType,
146
+ deliveryId,
147
+ payload,
148
+ installationToken,
149
+ };
150
+ this.logger.info(`Received ${eventType} webhook (delivery: ${deliveryId})`);
151
+ // Emit "event" for legacy compatibility
152
+ this.emit("event", webhookEvent);
153
+ // Emit "message" with translated internal message
154
+ this.emitMessage(webhookEvent);
155
+ reply.code(200).send({ success: true });
156
+ }
157
+ /**
158
+ * Translate and emit an internal message from a webhook event.
159
+ * Only emits if translation succeeds; logs debug message on failure.
160
+ */
161
+ emitMessage(event) {
162
+ const result = this.messageTranslator.translate(event, this.translationContext);
163
+ if (result.success) {
164
+ this.emit("message", result.message);
165
+ }
166
+ else {
167
+ this.logger.debug(`Message translation skipped: ${result.reason}`);
168
+ }
169
+ }
170
+ /**
171
+ * Verify GitHub webhook signature using HMAC-SHA256
172
+ */
173
+ verifyGitHubSignature(body, signature, secret) {
174
+ const expectedSignature = `sha256=${createHmac("sha256", secret).update(body).digest("hex")}`;
175
+ if (signature.length !== expectedSignature.length) {
176
+ return false;
177
+ }
178
+ return timingSafeEqual(Buffer.from(signature), Buffer.from(expectedSignature));
179
+ }
180
+ }
181
+ //# sourceMappingURL=GitHubEventTransport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GitHubEventTransport.js","sourceRoot":"","sources":["../src/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