@supaku/agentfactory-server 0.1.2 → 0.3.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.
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Worker Authentication Module
3
+ *
4
+ * Framework-agnostic API key verification for worker endpoints.
5
+ * Workers must include a valid API key in the Authorization header.
6
+ */
7
+ /**
8
+ * Extract a Bearer token from an Authorization header value
9
+ *
10
+ * @param authHeader - The Authorization header value
11
+ * @returns The bearer token or null if not a valid Bearer header
12
+ */
13
+ export declare function extractBearerToken(authHeader: string | null | undefined): string | null;
14
+ /**
15
+ * Verify an API key against the expected key using timing-safe comparison
16
+ *
17
+ * @param providedKey - The API key from the request
18
+ * @param expectedKey - The expected API key (defaults to WORKER_API_KEY env var)
19
+ * @returns true if the key is valid
20
+ */
21
+ export declare function verifyApiKey(providedKey: string, expectedKey?: string): boolean;
22
+ /**
23
+ * Check if worker auth is configured
24
+ * (useful for development/testing where auth might be disabled)
25
+ *
26
+ * @param envVar - Environment variable name to check (default: WORKER_API_KEY)
27
+ */
28
+ export declare function isWorkerAuthConfigured(envVar?: string): boolean;
29
+ //# sourceMappingURL=worker-auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-auth.d.ts","sourceRoot":"","sources":["../../src/worker-auth.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAKvF;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,WAAW,EAAE,MAAM,EACnB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAiBT;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,SAAmB,GAAG,OAAO,CAEzE"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Worker Authentication Module
3
+ *
4
+ * Framework-agnostic API key verification for worker endpoints.
5
+ * Workers must include a valid API key in the Authorization header.
6
+ */
7
+ import crypto from 'crypto';
8
+ /**
9
+ * Extract a Bearer token from an Authorization header value
10
+ *
11
+ * @param authHeader - The Authorization header value
12
+ * @returns The bearer token or null if not a valid Bearer header
13
+ */
14
+ export function extractBearerToken(authHeader) {
15
+ if (!authHeader?.startsWith('Bearer ')) {
16
+ return null;
17
+ }
18
+ return authHeader.slice(7);
19
+ }
20
+ /**
21
+ * Verify an API key against the expected key using timing-safe comparison
22
+ *
23
+ * @param providedKey - The API key from the request
24
+ * @param expectedKey - The expected API key (defaults to WORKER_API_KEY env var)
25
+ * @returns true if the key is valid
26
+ */
27
+ export function verifyApiKey(providedKey, expectedKey) {
28
+ const expected = expectedKey ?? process.env.WORKER_API_KEY;
29
+ if (!expected) {
30
+ return false;
31
+ }
32
+ // Use timing-safe comparison to prevent timing attacks
33
+ try {
34
+ return crypto.timingSafeEqual(Buffer.from(providedKey), Buffer.from(expected));
35
+ }
36
+ catch {
37
+ // Buffers have different lengths
38
+ return false;
39
+ }
40
+ }
41
+ /**
42
+ * Check if worker auth is configured
43
+ * (useful for development/testing where auth might be disabled)
44
+ *
45
+ * @param envVar - Environment variable name to check (default: WORKER_API_KEY)
46
+ */
47
+ export function isWorkerAuthConfigured(envVar = 'WORKER_API_KEY') {
48
+ return !!process.env[envVar];
49
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supaku/agentfactory-server",
3
- "version": "0.1.2",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "description": "Webhook server and distributed worker pool for AgentFactory — Redis queues, issue locks, session management",
6
6
  "author": "Supaku (https://supaku.com)",
@@ -44,8 +44,8 @@
44
44
  ],
45
45
  "dependencies": {
46
46
  "ioredis": "^5.4.2",
47
- "@supaku/agentfactory": "0.1.2",
48
- "@supaku/agentfactory-linear": "0.1.2"
47
+ "@supaku/agentfactory": "0.3.0",
48
+ "@supaku/agentfactory-linear": "0.3.0"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@types/node": "^22.5.4",