@openape/proxy 0.2.7 → 0.2.9

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/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @openape/proxy
2
2
 
3
+ ## 0.2.9
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`6c0cbad`](https://github.com/openape-ai/openape/commit/6c0cbada5165dc4e45381ffdaca847cd9dfc1d02)]:
8
+ - @openape/grants@0.8.0
9
+
10
+ ## 0.2.8
11
+
12
+ ### Patch Changes
13
+
14
+ - Fix ReDoS-vulnerable regex in proxy auth header parsing. Fix lint violations across packages. Update import paths for CLI permissions moved to @openape/grants.
15
+
16
+ - Updated dependencies []:
17
+ - @openape/core@0.12.0
18
+ - @openape/grants@0.7.0
19
+
3
20
  ## 0.2.7
4
21
 
5
22
  ### Patch Changes
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@openape/proxy",
3
3
  "type": "module",
4
- "version": "0.2.7",
4
+ "version": "0.2.9",
5
5
  "turbo": {
6
6
  "tags": [
7
7
  "publishable"
@@ -16,8 +16,8 @@
16
16
  "dependencies": {
17
17
  "jose": "^5.9.0",
18
18
  "smol-toml": "^1.3.0",
19
- "@openape/core": "0.11.0",
20
- "@openape/grants": "0.6.0"
19
+ "@openape/core": "0.12.0",
20
+ "@openape/grants": "0.8.0"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@types/bun": "^1.3.10",
@@ -43,6 +43,7 @@
43
43
  "build": "tsup",
44
44
  "typecheck": "tsc --noEmit",
45
45
  "lint": "eslint .",
46
- "test": "vitest run --passWithNoTests"
46
+ "test": "vitest run --passWithNoTests",
47
+ "test:coverage": "vitest run --coverage"
47
48
  }
48
49
  }
package/src/audit.ts CHANGED
@@ -15,6 +15,6 @@ export function writeAudit(entry: AuditEntry): void {
15
15
 
16
16
  // Write to file if configured
17
17
  if (auditPath) {
18
- appendFileSync(auditPath, line + '\n')
18
+ appendFileSync(auditPath, `${line}\n`)
19
19
  }
20
20
  }
package/src/auth.ts CHANGED
@@ -27,7 +27,7 @@ export async function verifyAgentAuth(
27
27
  return null
28
28
  }
29
29
 
30
- const match = authHeader.match(/^Bearer\s+(.+)$/i)
30
+ const match = authHeader.match(/^Bearer (.+)$/i)
31
31
  if (!match) {
32
32
  if (mandatory) throw new AuthError('Invalid authorization header')
33
33
  return null
@@ -19,7 +19,7 @@ export class GrantsClient {
19
19
  private headers(): Record<string, string> {
20
20
  const h: Record<string, string> = { 'Content-Type': 'application/json' }
21
21
  if (this.agentToken) {
22
- h['Authorization'] = `Bearer ${this.agentToken}`
22
+ h.Authorization = `Bearer ${this.agentToken}`
23
23
  }
24
24
  return h
25
25
  }
package/src/matcher.ts CHANGED
@@ -7,13 +7,13 @@ import type { ProxyConfig, RuleAction, RuleEntry } from './types.js'
7
7
  function globMatch(pattern: string, value: string): boolean {
8
8
  // Simple glob: convert * to regex
9
9
  const regex = new RegExp(
10
- '^' +
11
- pattern
12
- .replace(/[.+^${}()|[\]\\]/g, '\\$&') // escape regex chars except *
13
- .replace(/\*\*/g, '<<<DOUBLESTAR>>>')
14
- .replace(/\*/g, '[^/]*')
15
- .replace(/<<<DOUBLESTAR>>>/g, '.*')
16
- + '$'
10
+ `^${
11
+ pattern
12
+ .replace(/[.+^${}()|[\]\\]/g, '\\$&') // escape regex chars except *
13
+ .replace(/\*\*/g, '<<<DOUBLESTAR>>>')
14
+ .replace(/\*/g, '[^/]*')
15
+ .replace(/<<<DOUBLESTAR>>>/g, '.*')
16
+ }$`,
17
17
  )
18
18
  return regex.test(value)
19
19
  }
package/src/proxy.ts CHANGED
@@ -393,7 +393,8 @@ async function forwardRequest(originalReq: Request, targetUrl: string, cachedBod
393
393
  statusText: res.statusText,
394
394
  headers: responseHeaders,
395
395
  })
396
- } catch (err) {
396
+ }
397
+ catch (err) {
397
398
  const msg = err instanceof Error ? err.message : 'Upstream error'
398
399
  return new Response(`Proxy error: ${msg}`, { status: 502 })
399
400
  }
package/vitest.config.ts CHANGED
@@ -3,5 +3,16 @@ import { defineConfig } from 'vitest/config'
3
3
  export default defineConfig({
4
4
  test: {
5
5
  environment: 'node',
6
+ coverage: {
7
+ provider: 'istanbul',
8
+ include: ['src/**/*.ts'],
9
+ exclude: ['src/**/*.test.ts', 'src/**/index.ts', 'src/types/**'],
10
+ reporter: ['text', 'lcov'],
11
+ thresholds: {
12
+ statements: 29,
13
+ functions: 29,
14
+ lines: 29,
15
+ },
16
+ },
6
17
  },
7
18
  })