ework-qq-bridge 0.1.2 → 0.1.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ework-qq-bridge",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "QQ group <-> ework issue bridge (OneBot 11 reverse WebSocket)",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
package/src/ework.ts CHANGED
@@ -4,7 +4,7 @@ export interface EworkClient {
4
4
  }
5
5
 
6
6
  export function createEworkClient(baseUrl: string, token: string): EworkClient {
7
- const root = baseUrl.replace(/\/+$/, "");
7
+ const root = baseUrl.replace(/\/+$/, "").replace(/\/api\/v1$/, "") + "/api/v1";
8
8
  const headers = {
9
9
  "Content-Type": "application/json",
10
10
  Authorization: `Bearer ${token}`,
package/src/ingest.ts CHANGED
@@ -22,11 +22,14 @@ interface IngestDeps {
22
22
  export function verifySignature(secret: string, body: string, header: string | null): boolean {
23
23
  if (!secret) return true;
24
24
  if (!header) return false;
25
- const expected = `sha256=${createHmac("sha256", secret).update(body).digest("hex")}`;
26
- const a = Buffer.from(expected);
27
- const b = Buffer.from(header);
28
- if (a.length !== b.length) return false;
29
- return timingSafeEqual(a, b);
25
+ const hex = createHmac("sha256", secret).update(body).digest("hex");
26
+ // Gitea sends bare hex in X-Gitea-Signature; GitHub-style sends "sha256=<hex>".
27
+ const candidates = [hex, `sha256=${hex}`];
28
+ return candidates.some((expected) => {
29
+ const a = Buffer.from(expected);
30
+ const b = Buffer.from(header);
31
+ return a.length === b.length && timingSafeEqual(a, b);
32
+ });
30
33
  }
31
34
 
32
35
  export function createIngest(deps: IngestDeps) {