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.
@@ -0,0 +1,171 @@
1
+ /**
2
+ * Types for GitHub event transport
3
+ */
4
+ import type { InternalMessage } from "cyrus-core";
5
+ import type { FastifyInstance } from "fastify";
6
+ /**
7
+ * Verification mode for GitHub webhooks forwarded from CYHOST
8
+ * - 'proxy': Use CYRUS_API_KEY Bearer token for authentication (self-hosted)
9
+ * - 'signature': Use x-hub-signature-256 GitHub HMAC-SHA256 signature verification (cloud)
10
+ */
11
+ export type GitHubVerificationMode = "proxy" | "signature";
12
+ /**
13
+ * Configuration for GitHubEventTransport
14
+ */
15
+ export interface GitHubEventTransportConfig {
16
+ /** Fastify server instance to mount routes on */
17
+ fastifyServer: FastifyInstance;
18
+ /** Verification mode: 'proxy' or 'signature' */
19
+ verificationMode: GitHubVerificationMode;
20
+ /** Secret for verification (CYRUS_API_KEY for proxy, GITHUB_WEBHOOK_SECRET for signature) */
21
+ secret: string;
22
+ }
23
+ /**
24
+ * Events emitted by GitHubEventTransport
25
+ */
26
+ export interface GitHubEventTransportEvents {
27
+ /** Emitted when a GitHub webhook is received and verified (legacy) */
28
+ event: (event: GitHubWebhookEvent) => void;
29
+ /** Emitted when a unified internal message is received */
30
+ message: (message: InternalMessage) => void;
31
+ /** Emitted when an error occurs */
32
+ error: (error: Error) => void;
33
+ }
34
+ /**
35
+ * Processed GitHub webhook event that is emitted to listeners
36
+ */
37
+ export interface GitHubWebhookEvent {
38
+ /** The GitHub event type (e.g., 'issue_comment', 'pull_request_review_comment') */
39
+ eventType: GitHubEventType;
40
+ /** Unique webhook delivery ID */
41
+ deliveryId: string;
42
+ /** The full GitHub webhook payload */
43
+ payload: GitHubIssueCommentPayload | GitHubPullRequestReviewCommentPayload;
44
+ /** GitHub installation token forwarded from CYHOST (1-hour expiry) */
45
+ installationToken?: string;
46
+ }
47
+ /**
48
+ * Supported GitHub webhook event types
49
+ */
50
+ export type GitHubEventType = "issue_comment" | "pull_request_review_comment";
51
+ /**
52
+ * GitHub user object (minimal)
53
+ */
54
+ export interface GitHubUser {
55
+ login: string;
56
+ id: number;
57
+ avatar_url: string;
58
+ html_url: string;
59
+ type: string;
60
+ }
61
+ /**
62
+ * GitHub repository object (minimal)
63
+ */
64
+ export interface GitHubRepository {
65
+ id: number;
66
+ name: string;
67
+ full_name: string;
68
+ html_url: string;
69
+ clone_url: string;
70
+ ssh_url: string;
71
+ default_branch: string;
72
+ owner: GitHubUser;
73
+ }
74
+ /**
75
+ * GitHub PR reference (head/base)
76
+ */
77
+ export interface GitHubPullRequestRef {
78
+ label: string;
79
+ ref: string;
80
+ sha: string;
81
+ repo: GitHubRepository;
82
+ }
83
+ /**
84
+ * GitHub Pull Request object (minimal, used in issue_comment context)
85
+ */
86
+ export interface GitHubPullRequestMinimal {
87
+ url: string;
88
+ html_url: string;
89
+ diff_url: string;
90
+ patch_url: string;
91
+ }
92
+ /**
93
+ * GitHub Pull Request object (full, used in pull_request_review_comment context)
94
+ */
95
+ export interface GitHubPullRequest {
96
+ id: number;
97
+ number: number;
98
+ title: string;
99
+ body: string | null;
100
+ state: string;
101
+ html_url: string;
102
+ url: string;
103
+ head: GitHubPullRequestRef;
104
+ base: GitHubPullRequestRef;
105
+ user: GitHubUser;
106
+ }
107
+ /**
108
+ * GitHub Issue object (used in issue_comment webhook)
109
+ */
110
+ export interface GitHubIssue {
111
+ id: number;
112
+ number: number;
113
+ title: string;
114
+ body: string | null;
115
+ state: string;
116
+ html_url: string;
117
+ url: string;
118
+ user: GitHubUser;
119
+ /** Present when the issue is a PR */
120
+ pull_request?: GitHubPullRequestMinimal;
121
+ }
122
+ /**
123
+ * GitHub comment object
124
+ */
125
+ export interface GitHubComment {
126
+ id: number;
127
+ body: string;
128
+ html_url: string;
129
+ url: string;
130
+ user: GitHubUser;
131
+ created_at: string;
132
+ updated_at: string;
133
+ /** For PR review comments: the file path being commented on */
134
+ path?: string;
135
+ /** For PR review comments: the diff hunk */
136
+ diff_hunk?: string;
137
+ /** For PR review comments: the commit being commented on */
138
+ commit_id?: string;
139
+ }
140
+ /**
141
+ * GitHub installation object (for GitHub App)
142
+ */
143
+ export interface GitHubInstallation {
144
+ id: number;
145
+ node_id: string;
146
+ }
147
+ /**
148
+ * Payload for issue_comment webhook events
149
+ * @see https://docs.github.com/en/webhooks/webhook-events-and-payloads#issue_comment
150
+ */
151
+ export interface GitHubIssueCommentPayload {
152
+ action: "created" | "edited" | "deleted";
153
+ issue: GitHubIssue;
154
+ comment: GitHubComment;
155
+ repository: GitHubRepository;
156
+ sender: GitHubUser;
157
+ installation?: GitHubInstallation;
158
+ }
159
+ /**
160
+ * Payload for pull_request_review_comment webhook events
161
+ * @see https://docs.github.com/en/webhooks/webhook-events-and-payloads#pull_request_review_comment
162
+ */
163
+ export interface GitHubPullRequestReviewCommentPayload {
164
+ action: "created" | "edited" | "deleted";
165
+ comment: GitHubComment;
166
+ pull_request: GitHubPullRequest;
167
+ repository: GitHubRepository;
168
+ sender: GitHubUser;
169
+ installation?: GitHubInstallation;
170
+ }
171
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG,OAAO,GAAG,WAAW,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,0BAA0B;IAC1C,iDAAiD;IACjD,aAAa,EAAE,eAAe,CAAC;IAC/B,gDAAgD;IAChD,gBAAgB,EAAE,sBAAsB,CAAC;IACzC,6FAA6F;IAC7F,MAAM,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IAC1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B;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACzC,MAAM,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;IACzC,KAAK,EAAE,WAAW,CAAC;IACnB,OAAO,EAAE,aAAa,CAAC;IACvB,UAAU,EAAE,gBAAgB,CAAC;IAC7B,MAAM,EAAE,UAAU,CAAC;IACnB,YAAY,CAAC,EAAE,kBAAkB,CAAC;CAClC;AAED;;;GAGG;AACH,MAAM,WAAW,qCAAqC;IACrD,MAAM,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;IACzC,OAAO,EAAE,aAAa,CAAC;IACvB,YAAY,EAAE,iBAAiB,CAAC;IAChC,UAAU,EAAE,gBAAgB,CAAC;IAC7B,MAAM,EAAE,UAAU,CAAC;IACnB,YAAY,CAAC,EAAE,kBAAkB,CAAC;CAClC"}
package/dist/types.js ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Types for GitHub event transport
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "cyrus-github-event-transport",
3
+ "version": "0.2.22",
4
+ "description": "GitHub event transport for receiving and verifying forwarded GitHub webhooks",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "dependencies": {
12
+ "fastify": "^5.2.0",
13
+ "cyrus-core": "0.2.22"
14
+ },
15
+ "devDependencies": {
16
+ "@types/node": "^20.0.0",
17
+ "typescript": "^5.3.3",
18
+ "vitest": "^3.1.4"
19
+ },
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
23
+ "scripts": {
24
+ "build": "tsc",
25
+ "dev": "tsc --watch",
26
+ "typecheck": "tsc --noEmit",
27
+ "test": "vitest",
28
+ "test:run": "vitest run"
29
+ }
30
+ }