@floegence/floe-webapp-boot 0.97.1 → 0.97.3
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/dist/acquisition-lifecycle.d.ts +1 -0
- package/dist/acquisition-lifecycle.js +17 -15
- package/dist/connection.d.ts +4 -1
- package/dist/connection.js +17 -14
- package/dist/proxy-bootstrap.d.ts +2 -0
- package/dist/proxy-bootstrap.js +72 -51
- package/package.json +1 -1
|
@@ -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
|
|
2
|
-
import { clearAcquisitionSource as
|
|
3
|
-
import { createProxyBootstrapOwner as p, closeProxyBootstrap as
|
|
4
|
-
function w(
|
|
5
|
-
let n = !1,
|
|
6
|
-
const
|
|
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: (
|
|
9
|
-
events: (
|
|
10
|
-
synchronize(
|
|
11
|
-
if (n) throw new
|
|
12
|
-
const
|
|
13
|
-
if (
|
|
14
|
-
throw new
|
|
15
|
-
|
|
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,
|
|
20
|
+
n || (n = !0, i = null, c.dispose(), f(r), u(s));
|
|
19
21
|
}
|
|
20
22
|
});
|
|
21
23
|
}
|
package/dist/connection.d.ts
CHANGED
|
@@ -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;
|
package/dist/connection.js
CHANGED
|
@@ -1,45 +1,48 @@
|
|
|
1
|
-
import { createAcquisitionConnectionLifecycle as
|
|
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:
|
|
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
|
|
16
|
+
return c(e, e.proxyBootstrap);
|
|
13
17
|
}
|
|
14
18
|
function u(e) {
|
|
15
|
-
return
|
|
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:
|
|
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
|
|
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:
|
|
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
|
-
|
|
41
|
-
|
|
43
|
+
u as createArtifactDirectConnectionConfig,
|
|
44
|
+
a as createArtifactTunnelConnectionConfig,
|
|
42
45
|
o as createHTTPDirectConnectionConfig,
|
|
43
|
-
|
|
44
|
-
|
|
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
|
}>;
|
package/dist/proxy-bootstrap.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ServerSentEventStreamError as
|
|
2
|
-
import { createProxyRuntime as
|
|
3
|
-
import { connectedAcquisitionDetails as
|
|
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
|
|
17
|
-
function
|
|
16
|
+
const b = /* @__PURE__ */ new WeakMap();
|
|
17
|
+
function _(r) {
|
|
18
18
|
const t = l.create();
|
|
19
|
-
return
|
|
19
|
+
return b.set(t, { options: r, generation: 0 }), t;
|
|
20
20
|
}
|
|
21
|
-
function
|
|
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 =
|
|
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 =
|
|
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
|
-
...
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
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
|
|
45
|
-
if (
|
|
46
|
-
s =
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
|
56
|
-
if (
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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 (
|
|
78
|
+
if (d && (s === null || typeof s != "object" || typeof s.dispose != "function"))
|
|
67
79
|
throw new a("invalid_proxy_bootstrap_binding");
|
|
68
|
-
const
|
|
69
|
-
|
|
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
|
|
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)
|
|
101
|
+
if (i === void 0)
|
|
102
|
+
throw new v("transport", "session HTTP is unavailable");
|
|
86
103
|
e.signal?.throwIfAborted();
|
|
87
|
-
const o = new Headers(
|
|
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
|
|
108
|
+
for await (const c of w(t, {
|
|
90
109
|
...e,
|
|
91
110
|
headers: o,
|
|
92
|
-
fetch: (s,
|
|
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)
|
|
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
|
|
121
|
+
function H(r) {
|
|
102
122
|
u(h(r));
|
|
103
123
|
}
|
|
104
124
|
function h(r) {
|
|
105
125
|
l.assertAuthentic(r);
|
|
106
|
-
const t =
|
|
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
|
|
120
|
-
if (globalThis.crypto?.getRandomValues === void 0)
|
|
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
|
-
|
|
129
|
-
|
|
130
|
-
|
|
149
|
+
H as closeProxyBootstrap,
|
|
150
|
+
_ as createProxyBootstrapOwner,
|
|
151
|
+
R as fetchProxyBootstrap,
|
|
131
152
|
A as readProxyBootstrapEvents,
|
|
132
|
-
|
|
153
|
+
O as synchronizeProxyBootstrap
|
|
133
154
|
};
|