@fabrika/proxy-core 0.9.0-dev.33 → 0.9.0-dev.34

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": "@fabrika/proxy-core",
3
- "version": "0.9.0-dev.33",
3
+ "version": "0.9.0-dev.34",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "repository": {
@@ -49,9 +49,9 @@
49
49
  },
50
50
  "dependencies": {
51
51
  "zod": "^3.25.76",
52
- "@fabrika/auth-core": "0.9.0-dev.33",
53
- "@fabrika/jwks": "0.9.0-dev.33",
52
+ "@fabrika/auth-core": "0.9.0-dev.34",
53
+ "@fabrika/jwks": "0.9.0-dev.34",
54
54
  "jose": "^5.9.0",
55
- "@fabrika/platform": "0.9.0-dev.33"
55
+ "@fabrika/platform": "0.9.0-dev.34"
56
56
  }
57
57
  }
package/src/manifest.ts CHANGED
@@ -31,7 +31,7 @@ import {
31
31
  import { z } from 'zod'
32
32
  import { type InstallationBrand, installationBrandSchema } from './brand'
33
33
  import { type CspOrigins, cspOrigins, isCrossOrigin, isPolicyOrigin, MAX_CROSS_ORIGINS, MAX_CSP_ORIGINS, WORKER_BLOB_SOURCE } from './headers'
34
- import { type OAuthProtectedResource, oauthProtectedResourceSchema, oauthScopesSchema } from './oauth-resource'
34
+ import { type OAuthProtectedResource, oauthProtectedResourceSchema, oauthRowScopesSchema } from './oauth-resource'
35
35
 
36
36
  export * from './oauth-resource'
37
37
 
@@ -448,7 +448,7 @@ export const installationProxyEndpointRowSchema = z.union([
448
448
  kind: z.literal('service'),
449
449
  callers: z.array(z.enum(['human', 'machine', 'oauth'])).nonempty(),
450
450
  requirement: z.object({ kind: z.literal('authenticated') }).strict(),
451
- oauth: z.object({ scopes: oauthScopesSchema }).strict().nullable(),
451
+ oauth: z.object({ scopes: oauthRowScopesSchema }).strict().nullable(),
452
452
  }).strict().refine((row) => row.callers.includes('oauth') === (row.oauth !== null), 'oauth scopes belong to a row that admits oauth'),
453
453
  z.object({
454
454
  ...installationRuleFields,
@@ -33,6 +33,15 @@ export const oauthScopesSchema = z.unknown().transform((value, ctx) => {
33
33
  return z.NEVER
34
34
  })
35
35
 
36
+ /** The scopes a row requires of a token: none (the token is bound to the row's resource all the same), or valid ones. */
37
+ export const oauthRowScopesSchema = z.unknown().transform((value, ctx) => {
38
+ if (Array.isArray(value) && value.length === 0) return []
39
+ const scopes = parseOAuthScopes(value)
40
+ if (scopes !== null) return scopes
41
+ ctx.addIssue({ code: 'custom', message: 'invalid OAuth scopes', fatal: true })
42
+ return z.NEVER
43
+ })
44
+
36
45
  const resourceUriSchema = z.string().refine(isOAuthResourceUri)
37
46
  const authorizationServerSchema = z.string().refine((server) => isOAuthResourceUri(`${server}/`) && new URL(server).origin === server)
38
47
 
@@ -20,6 +20,8 @@ export interface OAuthBearerChallenge {
20
20
  scope?: string;
21
21
  }
22
22
  export declare const oauthScopesSchema: z.ZodEffects<z.ZodUnknown, string[], unknown>;
23
+ /** The scopes a row requires of a token: none (the token is bound to the row's resource all the same), or valid ones. */
24
+ export declare const oauthRowScopesSchema: z.ZodEffects<z.ZodUnknown, string[], unknown>;
23
25
  export declare const oauthProtectedResourceSchema: z.ZodEffects<z.ZodObject<{
24
26
  resource: z.ZodEffects<z.ZodString, string, string>;
25
27
  resourceMetadata: z.ZodEffects<z.ZodString, string, string>;