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 +1 -1
- package/src/ework.ts +1 -1
- package/src/ingest.ts +8 -5
package/package.json
CHANGED
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
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
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) {
|