@floegence/floe-webapp-boot 0.97.1 → 0.98.1

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.
@@ -9,6 +9,7 @@ export interface AcquisitionConnectionLifecycle {
9
9
  dispose(): void;
10
10
  }
11
11
  export type AcquisitionConnectionLifecycleOptions = Readonly<{
12
+ extraResponseHeaders?: readonly string[];
12
13
  proxyBootstrap?: ProxyBootstrapOwner;
13
14
  onConnected?: (acquisition: ConnectedAcquisition) => void;
14
15
  }>;
@@ -1,21 +1,23 @@
1
- import { createSessionHealthMonitor as u } from "./session-health.js";
2
- import { clearAcquisitionSource as a, AcquisitionError as l, synchronizeAcquisitionSourceSnapshot as f } from "./acquisition.js";
3
- import { createProxyBootstrapOwner as p, closeProxyBootstrap as y, synchronizeProxyBootstrap as d, readProxyBootstrapEvents as h, fetchProxyBootstrap as x } from "./proxy-bootstrap.js";
4
- function w(i, c = {}) {
5
- let n = !1, r = null;
6
- const s = u(), t = c.proxyBootstrap ?? p();
1
+ import { createSessionHealthMonitor as l } from "./session-health.js";
2
+ import { clearAcquisitionSource as u, AcquisitionError as a, synchronizeAcquisitionSourceSnapshot as d } from "./acquisition.js";
3
+ import { createProxyBootstrapOwner as p, closeProxyBootstrap as f, synchronizeProxyBootstrap as y, readProxyBootstrapEvents as x, fetchProxyBootstrap as h } from "./proxy-bootstrap.js";
4
+ function w(s, t = {}) {
5
+ let n = !1, i = null;
6
+ const c = l(), r = t.proxyBootstrap ?? p(
7
+ t.extraResponseHeaders === void 0 ? void 0 : { extraResponseHeaders: t.extraResponseHeaders }
8
+ );
7
9
  return Object.freeze({
8
- fetch: (e, o) => x(t, e, o),
9
- events: (e, o) => h(t, e, o),
10
- synchronize(e) {
11
- if (n) throw new l("acquisition_lifecycle_disposed");
12
- const o = f(i, e);
13
- if (e.state === "connected" && o === null)
14
- throw new l("connected_acquisition_missing");
15
- d(t, o), o !== null && o !== r && c.onConnected?.(o), r = o, s.synchronize(e.state === "connected" ? e.currentSession ?? null : null);
10
+ fetch: (o, e) => h(r, o, e),
11
+ events: (o, e) => x(r, o, e),
12
+ synchronize(o) {
13
+ if (n) throw new a("acquisition_lifecycle_disposed");
14
+ const e = d(s, o);
15
+ if (o.state === "connected" && e === null)
16
+ throw new a("connected_acquisition_missing");
17
+ y(r, e), e !== null && e !== i && t.onConnected?.(e), i = e, c.synchronize(o.state === "connected" ? o.currentSession ?? null : null);
16
18
  },
17
19
  dispose() {
18
- n || (n = !0, r = null, s.dispose(), y(t), a(i));
20
+ n || (n = !0, i = null, c.dispose(), f(r), u(s));
19
21
  }
20
22
  });
21
23
  }
@@ -23,6 +23,7 @@ export type FlowersecConnectionConfig = SharedFlowersecConnectionConfig & (Reado
23
23
  controller?: never;
24
24
  }>);
25
25
  type AcquisitionConnectionOptions = Readonly<{
26
+ extraResponseHeaders?: readonly string[];
26
27
  source: ArtifactSource;
27
28
  controller?: ConnectionControllerOptions;
28
29
  onConnected?: (acquisition: ConnectedAcquisition) => void;
@@ -30,17 +31,19 @@ type AcquisitionConnectionOptions = Readonly<{
30
31
  export type TunnelArtifactConnectionOptions = AcquisitionConnectionOptions;
31
32
  export type DirectArtifactConnectionOptions = AcquisitionConnectionOptions;
32
33
  export type PrivateLoopbackDirectConnectionOptions = Readonly<{
34
+ extraResponseHeaders?: readonly string[];
33
35
  source: PrivateLoopbackArtifactSourceV1;
34
36
  privateLoopback: PrivateLoopbackConnectionControllerOptionsV1;
35
37
  onConnected?: (acquisition: ConnectedAcquisition) => void;
36
38
  }>;
37
39
  export type HTTPDirectConnectionOptions = Readonly<{
40
+ extraResponseHeaders?: readonly string[];
38
41
  source: HTTPDirectArtifactSourceV1;
39
42
  httpDirect: HTTPDirectConnectionControllerOptionsV1;
40
43
  onConnected?: (acquisition: ConnectedAcquisition) => void;
41
44
  }>;
42
45
  export declare function createHTTPDirectConnectionConfig(options: HTTPDirectConnectionOptions): FlowersecConnectionConfig;
43
- export type ProxyRuntimeTunnelConnectionOptions = AcquisitionConnectionOptions & Readonly<{
46
+ export type ProxyRuntimeTunnelConnectionOptions = Omit<AcquisitionConnectionOptions, 'extraResponseHeaders'> & Readonly<{
44
47
  proxyBootstrap: ProxyBootstrapOwner;
45
48
  }>;
46
49
  export declare function createArtifactTunnelConnectionConfig(options: TunnelArtifactConnectionOptions): FlowersecConnectionConfig;
@@ -1,45 +1,48 @@
1
- import { createAcquisitionConnectionLifecycle as c } from "./acquisition-lifecycle.js";
1
+ import { createAcquisitionConnectionLifecycle as n } from "./acquisition-lifecycle.js";
2
2
  function o(e) {
3
3
  return Object.freeze({
4
4
  source: e.source,
5
5
  httpDirect: e.httpDirect,
6
- lifecycle: c(e.source, {
6
+ lifecycle: n(e.source, {
7
+ extraResponseHeaders: e.extraResponseHeaders,
7
8
  ...e.onConnected === void 0 ? {} : { onConnected: e.onConnected }
8
9
  })
9
10
  });
10
11
  }
12
+ function a(e) {
13
+ return c(e);
14
+ }
11
15
  function i(e) {
12
- return n(e);
16
+ return c(e, e.proxyBootstrap);
13
17
  }
14
18
  function u(e) {
15
- return n(e, e.proxyBootstrap);
19
+ return c(e);
16
20
  }
17
21
  function f(e) {
18
- return n(e);
19
- }
20
- function C(e) {
21
22
  return Object.freeze({
22
23
  source: e.source,
23
24
  privateLoopback: e.privateLoopback,
24
- lifecycle: c(e.source, {
25
+ lifecycle: n(e.source, {
26
+ extraResponseHeaders: e.extraResponseHeaders,
25
27
  ...e.onConnected === void 0 ? {} : { onConnected: e.onConnected }
26
28
  })
27
29
  });
28
30
  }
29
- function n(e, r) {
31
+ function c(e, r) {
30
32
  return Object.freeze({
31
33
  source: e.source,
32
34
  ...e.controller === void 0 ? {} : { controller: e.controller },
33
- lifecycle: c(e.source, {
35
+ lifecycle: n(e.source, {
36
+ extraResponseHeaders: e.extraResponseHeaders,
34
37
  ...r === void 0 ? {} : { proxyBootstrap: r },
35
38
  ...e.onConnected === void 0 ? {} : { onConnected: e.onConnected }
36
39
  })
37
40
  });
38
41
  }
39
42
  export {
40
- f as createArtifactDirectConnectionConfig,
41
- i as createArtifactTunnelConnectionConfig,
43
+ u as createArtifactDirectConnectionConfig,
44
+ a as createArtifactTunnelConnectionConfig,
42
45
  o as createHTTPDirectConnectionConfig,
43
- C as createPrivateLoopbackDirectConnectionConfig,
44
- u as createProxyRuntimeTunnelConnectionConfig
46
+ f as createPrivateLoopbackDirectConnectionConfig,
47
+ i as createProxyRuntimeTunnelConnectionConfig
45
48
  };
@@ -21,6 +21,8 @@ export type ControllerBridgeProxyBootstrapContext = Readonly<{
21
21
  capabilityNonce: string;
22
22
  }>;
23
23
  export type ProxyBootstrapOwnerOptions = Readonly<{
24
+ /** Host response fields retained after the server's own header policy. */
25
+ extraResponseHeaders?: readonly string[];
24
26
  serviceWorker?: (context: ServiceWorkerProxyBootstrapContext) => ProxyBootstrapBinding;
25
27
  controllerBridge?: (context: ControllerBridgeProxyBootstrapContext) => ProxyBootstrapBinding;
26
28
  }>;
@@ -1,6 +1,6 @@
1
- import { ServerSentEventStreamError as f, fetchServerSentEvents as b } from "./server-sent-events.js";
2
- import { createProxyRuntime as w } from "@floegence/flowersec-core/proxy";
3
- import { connectedAcquisitionDetails as y, AcquisitionError as a } from "./acquisition.js";
1
+ import { ServerSentEventStreamError as v, fetchServerSentEvents as w } from "./server-sent-events.js";
2
+ import { createProxyRuntime as y } from "@floegence/flowersec-core/proxy";
3
+ import { connectedAcquisitionDetails as g, AcquisitionError as a } from "./acquisition.js";
4
4
  class l {
5
5
  #e = void 0;
6
6
  constructor() {
@@ -13,65 +13,81 @@ class l {
13
13
  t.#e;
14
14
  }
15
15
  }
16
- const v = /* @__PURE__ */ new WeakMap();
17
- function B(r) {
16
+ const b = /* @__PURE__ */ new WeakMap();
17
+ function _(r) {
18
18
  const t = l.create();
19
- return v.set(t, { options: r, generation: 0 }), t;
19
+ return b.set(t, { options: r, generation: 0 }), t;
20
20
  }
21
- function _(r, t) {
21
+ function O(r, t) {
22
22
  const e = h(r);
23
23
  if (t === null)
24
24
  return u(e), null;
25
25
  if (e.acquisition === t && e.snapshot !== void 0) return e.snapshot;
26
- const n = y(t);
26
+ const n = g(t);
27
27
  u(e);
28
28
  const i = e.generation + 1;
29
29
  e.generation = i;
30
- const o = n.scope, c = w({
30
+ const o = n.scope, c = y({
31
31
  session: n.session,
32
32
  externalOrigin: n.appOrigin,
33
33
  ...o.limits ?? {},
34
34
  ...o.http?.extraRequestHeaders === void 0 ? {} : { extraRequestHeaders: o.http.extraRequestHeaders },
35
- ...o.appBasePath === void 0 ? {} : { pathPolicy: {
36
- allowedPathPrefixes: Object.freeze([o.appBasePath, ...o.http?.additionalPathPrefixes ?? []]),
37
- allowedWebSocketPathPrefixes: Object.freeze([o.appBasePath])
38
- } }
35
+ ...e.options?.extraResponseHeaders === void 0 ? {} : { extraResponseHeaders: e.options.extraResponseHeaders },
36
+ ...o.appBasePath === void 0 ? {} : {
37
+ pathPolicy: {
38
+ allowedPathPrefixes: Object.freeze([
39
+ o.appBasePath,
40
+ ...o.http?.additionalPathPrefixes ?? []
41
+ ]),
42
+ allowedWebSocketPathPrefixes: Object.freeze([o.appBasePath])
43
+ }
44
+ }
39
45
  });
40
46
  try {
41
47
  let s;
42
- if (e.options !== void 0)
48
+ const d = e.options !== void 0 && (e.options.extraResponseHeaders === void 0 || e.options.serviceWorker !== void 0 || e.options.controllerBridge !== void 0);
49
+ if (d)
43
50
  if (o.mode === "service_worker") {
44
- const d = e.options.serviceWorker;
45
- if (d === void 0) throw new a("service_worker_bootstrap_unavailable");
46
- s = d(Object.freeze({
47
- runtime: c,
48
- generation: i,
49
- bindingIdentity: n.bindingIdentity,
50
- scriptUrl: o.serviceWorker.scriptUrl,
51
- serviceWorkerScope: o.serviceWorker.scope,
52
- ...o.appBasePath === void 0 ? {} : { appBasePath: o.appBasePath }
53
- }));
51
+ const p = e.options?.serviceWorker;
52
+ if (p === void 0) throw new a("service_worker_bootstrap_unavailable");
53
+ s = p(
54
+ Object.freeze({
55
+ runtime: c,
56
+ generation: i,
57
+ bindingIdentity: n.bindingIdentity,
58
+ scriptUrl: o.serviceWorker.scriptUrl,
59
+ serviceWorkerScope: o.serviceWorker.scope,
60
+ ...o.appBasePath === void 0 ? {} : { appBasePath: o.appBasePath }
61
+ })
62
+ );
54
63
  } else {
55
- const d = e.options.controllerBridge;
56
- if (d === void 0) throw new a("controller_bridge_bootstrap_unavailable");
57
- s = d(Object.freeze({
58
- runtime: c,
59
- generation: i,
60
- bindingIdentity: n.bindingIdentity,
61
- allowedOrigins: o.controllerBridge.allowedOrigins,
62
- ...o.appBasePath === void 0 ? {} : { appBasePath: o.appBasePath },
63
- capabilityNonce: g()
64
- }));
64
+ const p = e.options?.controllerBridge;
65
+ if (p === void 0)
66
+ throw new a("controller_bridge_bootstrap_unavailable");
67
+ s = p(
68
+ Object.freeze({
69
+ runtime: c,
70
+ generation: i,
71
+ bindingIdentity: n.bindingIdentity,
72
+ allowedOrigins: o.controllerBridge.allowedOrigins,
73
+ ...o.appBasePath === void 0 ? {} : { appBasePath: o.appBasePath },
74
+ capabilityNonce: m()
75
+ })
76
+ );
65
77
  }
66
- if (e.options !== void 0 && (s === null || typeof s != "object" || typeof s.dispose != "function"))
78
+ if (d && (s === null || typeof s != "object" || typeof s.dispose != "function"))
67
79
  throw new a("invalid_proxy_bootstrap_binding");
68
- const p = Object.freeze({ generation: i, mode: e.options === void 0 ? "session" : o.mode, bindingIdentity: n.bindingIdentity });
69
- return e.acquisition = t, e.runtime = c, e.binding = s, e.snapshot = p, p;
80
+ const f = Object.freeze({
81
+ generation: i,
82
+ mode: d ? o.mode : "session",
83
+ bindingIdentity: n.bindingIdentity
84
+ });
85
+ return e.acquisition = t, e.runtime = c, e.binding = s, e.snapshot = f, f;
70
86
  } catch (s) {
71
87
  throw c.dispose(), s;
72
88
  }
73
89
  }
74
- async function O(r, t, e) {
90
+ async function R(r, t, e) {
75
91
  const n = h(r), i = n.runtime;
76
92
  if (i === void 0) throw new a("session_http_unavailable");
77
93
  const o = await i.fetch(t, e);
@@ -82,28 +98,32 @@ async function O(r, t, e) {
82
98
  }
83
99
  async function* A(r, t, e = {}) {
84
100
  const n = h(r), i = n.runtime;
85
- if (i === void 0) throw new f("transport", "session HTTP is unavailable");
101
+ if (i === void 0)
102
+ throw new v("transport", "session HTTP is unavailable");
86
103
  e.signal?.throwIfAborted();
87
- const o = new Headers(e.headers ?? (t instanceof Request ? t.headers : void 0));
104
+ const o = new Headers(
105
+ e.headers ?? (t instanceof Request ? t.headers : void 0)
106
+ );
88
107
  o.set("Accept", "text/event-stream");
89
- for await (const c of b(t, {
108
+ for await (const c of w(t, {
90
109
  ...e,
91
110
  headers: o,
92
- fetch: (s, p) => i.fetch(s, p),
111
+ fetch: (s, d) => i.fetch(s, d),
93
112
  onActivity: () => {
94
113
  n.runtime === i && !e.signal?.aborted && e.onActivity?.();
95
114
  }
96
115
  })) {
97
- if (e.signal?.throwIfAborted(), n.runtime !== i) throw new f("transport", "session HTTP was replaced");
116
+ if (e.signal?.throwIfAborted(), n.runtime !== i)
117
+ throw new v("transport", "session HTTP was replaced");
98
118
  yield c;
99
119
  }
100
120
  }
101
- function S(r) {
121
+ function H(r) {
102
122
  u(h(r));
103
123
  }
104
124
  function h(r) {
105
125
  l.assertAuthentic(r);
106
- const t = v.get(r);
126
+ const t = b.get(r);
107
127
  if (t === void 0) throw new a("invalid_proxy_bootstrap_owner");
108
128
  return t;
109
129
  }
@@ -116,8 +136,9 @@ function u(r) {
116
136
  e?.dispose();
117
137
  }
118
138
  }
119
- function g() {
120
- if (globalThis.crypto?.getRandomValues === void 0) throw new a("acquisition_entropy_unavailable");
139
+ function m() {
140
+ if (globalThis.crypto?.getRandomValues === void 0)
141
+ throw new a("acquisition_entropy_unavailable");
121
142
  const r = globalThis.crypto.getRandomValues(new Uint8Array(32));
122
143
  let t = "";
123
144
  for (const e of r) t += String.fromCharCode(e);
@@ -125,9 +146,9 @@ function g() {
125
146
  }
126
147
  export {
127
148
  l as ProxyBootstrapOwner,
128
- S as closeProxyBootstrap,
129
- B as createProxyBootstrapOwner,
130
- O as fetchProxyBootstrap,
149
+ H as closeProxyBootstrap,
150
+ _ as createProxyBootstrapOwner,
151
+ R as fetchProxyBootstrap,
131
152
  A as readProxyBootstrapEvents,
132
- _ as synchronizeProxyBootstrap
153
+ O as synchronizeProxyBootstrap
133
154
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-boot",
3
- "version": "0.97.1",
3
+ "version": "0.98.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",