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

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.31",
3
+ "version": "0.9.0-dev.33",
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.31",
53
- "@fabrika/jwks": "0.9.0-dev.31",
52
+ "@fabrika/auth-core": "0.9.0-dev.33",
53
+ "@fabrika/jwks": "0.9.0-dev.33",
54
54
  "jose": "^5.9.0",
55
- "@fabrika/platform": "0.9.0-dev.31"
55
+ "@fabrika/platform": "0.9.0-dev.33"
56
56
  }
57
57
  }
package/src/authorize.ts CHANGED
@@ -97,6 +97,8 @@ export type DenyReason =
97
97
  | 'delegation_refused'
98
98
  /** The `Host` maps to no app in the manifest. */
99
99
  | 'no_app'
100
+ /** The entry is suspended (`ContractProxyApp.suspended`): its environment is offline, whatever the request. */
101
+ | 'suspended'
100
102
  /** The forwarded-request headers are missing or malformed — we cannot know what was asked for. */
101
103
  | 'bad_forward'
102
104
  /** The forwarded path is not canonical (`isCanonicalPath`); refused before any endpoint is planned. */
package/src/manifest.ts CHANGED
@@ -69,6 +69,11 @@ export interface ContractProxyApp extends ProxyAppBase {
69
69
  audience?: string
70
70
  /** The `Host` the proxy sends upstream in place of the client's; absent, the client's passes. */
71
71
  upstreamHost?: string
72
+ /**
73
+ * The environment is taken offline: every request to its hosts answers 503 and nothing reaches its upstream. Absent on
74
+ * an entry that serves. Older proxies' strict parsers refuse it; a producer sends it only to a proxy that reads it.
75
+ */
76
+ suspended?: true
72
77
  }
73
78
 
74
79
  /** The IAM app id an entry's tokens are minted for and verified against: its `audience`, or else its id. */
@@ -408,6 +413,7 @@ export const contractProxyAppSchema = z.object({
408
413
  crossOrigins: z.array(z.string().refine(isCrossOrigin)).nonempty().max(MAX_CROSS_ORIGINS).optional(),
409
414
  audience: z.string().refine((value) => parseAppEnvironmentId(value) !== null).optional(),
410
415
  upstreamHost: z.string().refine(isProxyHost).optional(),
416
+ suspended: z.literal(true).optional(),
411
417
  }).strict().superRefine((app, ctx) => {
412
418
  checkAudience(app, ctx)
413
419
  checkCrossOrigins(app, ctx)
@@ -558,6 +564,8 @@ export interface ContractEntryPlacement {
558
564
  /** A dev sandbox entry's `<app>@<env>`; see `ContractProxyApp.audience`. */
559
565
  readonly audience?: string
560
566
  readonly upstreamHost?: string
567
+ /** See `ContractProxyApp.suspended`; false or absent serves the entry. */
568
+ readonly suspended?: boolean
561
569
  }
562
570
 
563
571
  /**
@@ -581,7 +589,7 @@ export type OlderProxyReaders = readonly [OlderProxyReader, ...OlderProxyReader[
581
589
  * would refuse it, naming the fields and never their values, because an origin with userinfo may carry a key.
582
590
  */
583
591
  export function contractProxyEntry(placement: ContractEntryPlacement): ContractProxyApp {
584
- const { table, operationsOrigin, crossOrigins = [], audience, upstreamHost } = placement
592
+ const { table, operationsOrigin, crossOrigins = [], audience, upstreamHost, suspended = false } = placement
585
593
  const entry: ContractProxyApp = {
586
594
  id: placement.id,
587
595
  hosts: [...placement.hosts],
@@ -595,6 +603,7 @@ export function contractProxyEntry(placement: ContractEntryPlacement): ContractP
595
603
  ...(crossOrigins.length === 0 ? {} : { crossOrigins: [...crossOrigins] }),
596
604
  ...(audience === undefined ? {} : { audience }),
597
605
  ...(upstreamHost === undefined ? {} : { upstreamHost }),
606
+ ...(suspended ? { suspended: true } : {}),
598
607
  }
599
608
  const parsed = contractProxyAppSchema.safeParse(entry)
600
609
  if (!parsed.success) {
package/src/service.ts CHANGED
@@ -158,6 +158,12 @@ export function createVerifyService(config: VerifyServiceConfig): VerifyService
158
158
  const fields = { requestId, host: forwarded.url.host, path: redactPath(forwarded.url.pathname) }
159
159
  return withPolicy(denied(logger, fields, { outcome: 'deny', status: 403, reason: 'no_app' }, { asPage, brand }), BASE_HEADER_POLICY)
160
160
  }
161
+ // Before anything else of the entry, the callback and the sign-out included: a suspended environment serves nothing.
162
+ if (isApplicationEntry(resolved.app) && resolved.app.suspended === true) {
163
+ const fields = { requestId, app: resolved.app.id, host: forwarded.url.host, path: redactPath(forwarded.url.pathname) }
164
+ const answer = denied(logger, fields, { outcome: 'deny', status: 503, reason: 'suspended' }, { asPage, brand })
165
+ return withPolicy(answer, policies.get(resolved.app.id) ?? BASE_HEADER_POLICY)
166
+ }
161
167
 
162
168
  if (url.pathname === OAUTH_METADATA_VERIFY_PATH) {
163
169
  const metadata = findOAuthMetadata(resolved.app, forwarded.url)
@@ -58,6 +58,8 @@ export type DenyReason =
58
58
  | 'delegation_refused'
59
59
  /** The `Host` maps to no app in the manifest. */
60
60
  | 'no_app'
61
+ /** The entry is suspended (`ContractProxyApp.suspended`): its environment is offline, whatever the request. */
62
+ | 'suspended'
61
63
  /** The forwarded-request headers are missing or malformed — we cannot know what was asked for. */
62
64
  | 'bad_forward'
63
65
  /** The forwarded path is not canonical (`isCanonicalPath`); refused before any endpoint is planned. */
@@ -36,6 +36,11 @@ export interface ContractProxyApp extends ProxyAppBase {
36
36
  audience?: string;
37
37
  /** The `Host` the proxy sends upstream in place of the client's; absent, the client's passes. */
38
38
  upstreamHost?: string;
39
+ /**
40
+ * The environment is taken offline: every request to its hosts answers 503 and nothing reaches its upstream. Absent on
41
+ * an entry that serves. Older proxies' strict parsers refuse it; a producer sends it only to a proxy that reads it.
42
+ */
43
+ suspended?: true;
39
44
  }
40
45
  /** The IAM app id an entry's tokens are minted for and verified against: its `audience`, or else its id. */
41
46
  export declare function audienceOf(entry: Pick<ContractProxyApp, 'id' | 'audience'>): string;
@@ -2961,6 +2966,7 @@ export declare const contractProxyAppSchema: z.ZodEffects<z.ZodObject<{
2961
2966
  crossOrigins: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "atleastone">>;
2962
2967
  audience: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
2963
2968
  upstreamHost: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
2969
+ suspended: z.ZodOptional<z.ZodLiteral<true>>;
2964
2970
  id: z.ZodEffects<z.ZodString, string, string>;
2965
2971
  hosts: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
2966
2972
  upstream: z.ZodString;
@@ -3088,6 +3094,7 @@ export declare const contractProxyAppSchema: z.ZodEffects<z.ZodObject<{
3088
3094
  operationsOrigin?: string | undefined;
3089
3095
  crossOrigins?: [string, ...string[]] | undefined;
3090
3096
  upstreamHost?: string | undefined;
3097
+ suspended?: true | undefined;
3091
3098
  }, {
3092
3099
  csp: {
3093
3100
  connectSrc: string[];
@@ -3212,6 +3219,7 @@ export declare const contractProxyAppSchema: z.ZodEffects<z.ZodObject<{
3212
3219
  operationsOrigin?: string | undefined;
3213
3220
  crossOrigins?: [string, ...string[]] | undefined;
3214
3221
  upstreamHost?: string | undefined;
3222
+ suspended?: true | undefined;
3215
3223
  }>, {
3216
3224
  csp: {
3217
3225
  scriptSrc: string[];
@@ -3336,6 +3344,7 @@ export declare const contractProxyAppSchema: z.ZodEffects<z.ZodObject<{
3336
3344
  operationsOrigin?: string | undefined;
3337
3345
  crossOrigins?: [string, ...string[]] | undefined;
3338
3346
  upstreamHost?: string | undefined;
3347
+ suspended?: true | undefined;
3339
3348
  }, {
3340
3349
  csp: {
3341
3350
  connectSrc: string[];
@@ -3460,6 +3469,7 @@ export declare const contractProxyAppSchema: z.ZodEffects<z.ZodObject<{
3460
3469
  operationsOrigin?: string | undefined;
3461
3470
  crossOrigins?: [string, ...string[]] | undefined;
3462
3471
  upstreamHost?: string | undefined;
3472
+ suspended?: true | undefined;
3463
3473
  }>;
3464
3474
  /** One row of an installation entry: the installation forms, and no application form but `health`. */
3465
3475
  export declare const installationProxyEndpointRowSchema: z.ZodEffects<z.ZodUnion<[z.ZodEffects<z.ZodObject<{
@@ -5579,6 +5589,7 @@ export declare const proxyAppSchema: z.ZodUnion<[z.ZodEffects<z.ZodObject<{
5579
5589
  crossOrigins: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "atleastone">>;
5580
5590
  audience: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
5581
5591
  upstreamHost: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
5592
+ suspended: z.ZodOptional<z.ZodLiteral<true>>;
5582
5593
  id: z.ZodEffects<z.ZodString, string, string>;
5583
5594
  hosts: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
5584
5595
  upstream: z.ZodString;
@@ -5706,6 +5717,7 @@ export declare const proxyAppSchema: z.ZodUnion<[z.ZodEffects<z.ZodObject<{
5706
5717
  operationsOrigin?: string | undefined;
5707
5718
  crossOrigins?: [string, ...string[]] | undefined;
5708
5719
  upstreamHost?: string | undefined;
5720
+ suspended?: true | undefined;
5709
5721
  }, {
5710
5722
  csp: {
5711
5723
  connectSrc: string[];
@@ -5830,6 +5842,7 @@ export declare const proxyAppSchema: z.ZodUnion<[z.ZodEffects<z.ZodObject<{
5830
5842
  operationsOrigin?: string | undefined;
5831
5843
  crossOrigins?: [string, ...string[]] | undefined;
5832
5844
  upstreamHost?: string | undefined;
5845
+ suspended?: true | undefined;
5833
5846
  }>, {
5834
5847
  csp: {
5835
5848
  scriptSrc: string[];
@@ -5954,6 +5967,7 @@ export declare const proxyAppSchema: z.ZodUnion<[z.ZodEffects<z.ZodObject<{
5954
5967
  operationsOrigin?: string | undefined;
5955
5968
  crossOrigins?: [string, ...string[]] | undefined;
5956
5969
  upstreamHost?: string | undefined;
5970
+ suspended?: true | undefined;
5957
5971
  }, {
5958
5972
  csp: {
5959
5973
  connectSrc: string[];
@@ -6078,6 +6092,7 @@ export declare const proxyAppSchema: z.ZodUnion<[z.ZodEffects<z.ZodObject<{
6078
6092
  operationsOrigin?: string | undefined;
6079
6093
  crossOrigins?: [string, ...string[]] | undefined;
6080
6094
  upstreamHost?: string | undefined;
6095
+ suspended?: true | undefined;
6081
6096
  }>, z.ZodEffects<z.ZodObject<{
6082
6097
  scheme: z.ZodEffects<z.ZodDefault<z.ZodEnum<["http", "https"]>>, "http" | "https", unknown>;
6083
6098
  installation: z.ZodLiteral<true>;
@@ -6537,6 +6552,8 @@ export interface ContractEntryPlacement {
6537
6552
  /** A dev sandbox entry's `<app>@<env>`; see `ContractProxyApp.audience`. */
6538
6553
  readonly audience?: string;
6539
6554
  readonly upstreamHost?: string;
6555
+ /** See `ContractProxyApp.suspended`; false or absent serves the entry. */
6556
+ readonly suspended?: boolean;
6540
6557
  }
6541
6558
  /**
6542
6559
  * What the proxy of one older platform release parses of an application's manifest entry: a row, and the entry's CSP
@@ -8029,6 +8046,7 @@ export declare const proxyManifestSchema: z.ZodEffects<z.ZodObject<{
8029
8046
  crossOrigins: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "atleastone">>;
8030
8047
  audience: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
8031
8048
  upstreamHost: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
8049
+ suspended: z.ZodOptional<z.ZodLiteral<true>>;
8032
8050
  id: z.ZodEffects<z.ZodString, string, string>;
8033
8051
  hosts: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
8034
8052
  upstream: z.ZodString;
@@ -8156,6 +8174,7 @@ export declare const proxyManifestSchema: z.ZodEffects<z.ZodObject<{
8156
8174
  operationsOrigin?: string | undefined;
8157
8175
  crossOrigins?: [string, ...string[]] | undefined;
8158
8176
  upstreamHost?: string | undefined;
8177
+ suspended?: true | undefined;
8159
8178
  }, {
8160
8179
  csp: {
8161
8180
  connectSrc: string[];
@@ -8280,6 +8299,7 @@ export declare const proxyManifestSchema: z.ZodEffects<z.ZodObject<{
8280
8299
  operationsOrigin?: string | undefined;
8281
8300
  crossOrigins?: [string, ...string[]] | undefined;
8282
8301
  upstreamHost?: string | undefined;
8302
+ suspended?: true | undefined;
8283
8303
  }>, {
8284
8304
  csp: {
8285
8305
  scriptSrc: string[];
@@ -8404,6 +8424,7 @@ export declare const proxyManifestSchema: z.ZodEffects<z.ZodObject<{
8404
8424
  operationsOrigin?: string | undefined;
8405
8425
  crossOrigins?: [string, ...string[]] | undefined;
8406
8426
  upstreamHost?: string | undefined;
8427
+ suspended?: true | undefined;
8407
8428
  }, {
8408
8429
  csp: {
8409
8430
  connectSrc: string[];
@@ -8528,6 +8549,7 @@ export declare const proxyManifestSchema: z.ZodEffects<z.ZodObject<{
8528
8549
  operationsOrigin?: string | undefined;
8529
8550
  crossOrigins?: [string, ...string[]] | undefined;
8530
8551
  upstreamHost?: string | undefined;
8552
+ suspended?: true | undefined;
8531
8553
  }>, z.ZodEffects<z.ZodObject<{
8532
8554
  scheme: z.ZodEffects<z.ZodDefault<z.ZodEnum<["http", "https"]>>, "http" | "https", unknown>;
8533
8555
  installation: z.ZodLiteral<true>;
@@ -9140,6 +9162,7 @@ export declare const proxyManifestSchema: z.ZodEffects<z.ZodObject<{
9140
9162
  operationsOrigin?: string | undefined;
9141
9163
  crossOrigins?: [string, ...string[]] | undefined;
9142
9164
  upstreamHost?: string | undefined;
9165
+ suspended?: true | undefined;
9143
9166
  } | {
9144
9167
  endpoints: ({
9145
9168
  kind: "service";
@@ -9322,6 +9345,7 @@ export declare const proxyManifestSchema: z.ZodEffects<z.ZodObject<{
9322
9345
  operationsOrigin?: string | undefined;
9323
9346
  crossOrigins?: [string, ...string[]] | undefined;
9324
9347
  upstreamHost?: string | undefined;
9348
+ suspended?: true | undefined;
9325
9349
  } | {
9326
9350
  endpoints: ({
9327
9351
  kind: "service";
@@ -9504,6 +9528,7 @@ export declare const proxyManifestSchema: z.ZodEffects<z.ZodObject<{
9504
9528
  operationsOrigin?: string | undefined;
9505
9529
  crossOrigins?: [string, ...string[]] | undefined;
9506
9530
  upstreamHost?: string | undefined;
9531
+ suspended?: true | undefined;
9507
9532
  } | {
9508
9533
  endpoints: ({
9509
9534
  kind: "service";
@@ -9686,6 +9711,7 @@ export declare const proxyManifestSchema: z.ZodEffects<z.ZodObject<{
9686
9711
  operationsOrigin?: string | undefined;
9687
9712
  crossOrigins?: [string, ...string[]] | undefined;
9688
9713
  upstreamHost?: string | undefined;
9714
+ suspended?: true | undefined;
9689
9715
  } | {
9690
9716
  endpoints: ({
9691
9717
  kind: "service";