@floegence/floe-webapp-boot 0.40.4 → 0.40.6
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/artifact-source.d.ts +18 -0
- package/dist/connection.d.ts +10 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.js +22 -21
- package/dist/index5.js +68 -27
- package/dist/index6.js +8 -144
- package/dist/index7.js +146 -18
- package/dist/index8.js +22 -0
- package/package.json +2 -2
- package/dist/reconnect.d.ts +0 -20
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ArtifactSource, type JsonObject } from '@floegence/flowersec-core';
|
|
2
|
+
export type ControlplaneArtifactSourceOptions = Readonly<{
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
endpointId: string;
|
|
5
|
+
payload?: JsonObject;
|
|
6
|
+
correlation?: Readonly<{
|
|
7
|
+
traceId?: string;
|
|
8
|
+
}>;
|
|
9
|
+
entryTicket?: string;
|
|
10
|
+
allowLoopbackHTTP?: boolean;
|
|
11
|
+
fetch?: typeof globalThis.fetch;
|
|
12
|
+
}>;
|
|
13
|
+
export declare class ControlplaneRequestError extends Error {
|
|
14
|
+
readonly status: number;
|
|
15
|
+
readonly code: string;
|
|
16
|
+
constructor(status: number, code: string, message: string);
|
|
17
|
+
}
|
|
18
|
+
export declare function createControlplaneArtifactSource(options: ControlplaneArtifactSourceOptions): ArtifactSource;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ArtifactSource, ConnectionControllerOptions } from '@floegence/flowersec-core';
|
|
2
|
+
export type FlowersecConnectionConfig = Readonly<{
|
|
3
|
+
source: ArtifactSource;
|
|
4
|
+
controller?: ConnectionControllerOptions;
|
|
5
|
+
}>;
|
|
6
|
+
export type TunnelArtifactConnectionOptions = FlowersecConnectionConfig;
|
|
7
|
+
export type DirectArtifactConnectionOptions = FlowersecConnectionConfig;
|
|
8
|
+
export declare function createArtifactTunnelConnectionConfig(options: TunnelArtifactConnectionOptions): FlowersecConnectionConfig;
|
|
9
|
+
export declare function createProxyRuntimeTunnelConnectionConfig(options: TunnelArtifactConnectionOptions): FlowersecConnectionConfig;
|
|
10
|
+
export declare function createArtifactDirectConnectionConfig(options: DirectArtifactConnectionOptions): FlowersecConnectionConfig;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,10 +2,11 @@ export { base64UrlToBase64, clearLocationHash, parseBase64UrlJsonFromHash, parse
|
|
|
2
2
|
export type { WaitForMessageOptions } from './messaging';
|
|
3
3
|
export { postMessageToOrigins, waitForMessage } from './messaging';
|
|
4
4
|
export { getSessionStorage, removeSessionStorage, setSessionStorage } from './storage';
|
|
5
|
-
export type {
|
|
6
|
-
export { createControlplaneArtifactSource } from '
|
|
7
|
-
export type {
|
|
8
|
-
export {
|
|
5
|
+
export type { ArtifactSource, ArtifactSourceResult } from '@floegence/flowersec-core';
|
|
6
|
+
export { createControlplaneArtifactSource, ControlplaneRequestError } from './artifact-source';
|
|
7
|
+
export type { ControlplaneArtifactSourceOptions } from './artifact-source';
|
|
8
|
+
export type { DirectArtifactConnectionOptions, TunnelArtifactConnectionOptions, FlowersecConnectionConfig } from './connection';
|
|
9
|
+
export { createArtifactDirectConnectionConfig, createArtifactTunnelConnectionConfig, createProxyRuntimeTunnelConnectionConfig, } from './connection';
|
|
9
10
|
export type { FetchServerSentEventsOptions, ServerSentEvent, ServerSentEventStreamErrorCode, } from './server-sent-events';
|
|
10
11
|
export { fetchServerSentEvents, ServerSentEventStreamError, } from './server-sent-events';
|
|
11
12
|
export type { ScopeEnvelope, ScopeResolver, ScopeResolverMap } from './scope';
|
package/dist/index.js
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
import { base64UrlToBase64 as o, clearLocationHash as t, parseBase64UrlJsonFromHash as
|
|
2
|
-
import { postMessageToOrigins as
|
|
3
|
-
import { getSessionStorage as
|
|
4
|
-
import { createControlplaneArtifactSource as
|
|
5
|
-
import {
|
|
6
|
-
import { ServerSentEventStreamError as
|
|
7
|
-
import { FLOWERSEC_BOOTSTRAP_SCOPE_RESOLVERS as _, PROXY_RUNTIME_SCOPE_NAME as
|
|
1
|
+
import { base64UrlToBase64 as o, clearLocationHash as t, parseBase64UrlJsonFromHash as n, parseHashParam as a } from "./index2.js";
|
|
2
|
+
import { postMessageToOrigins as i, waitForMessage as S } from "./index3.js";
|
|
3
|
+
import { getSessionStorage as p, removeSessionStorage as f, setSessionStorage as m } from "./index4.js";
|
|
4
|
+
import { ControlplaneRequestError as l, createControlplaneArtifactSource as C } from "./index5.js";
|
|
5
|
+
import { createArtifactDirectConnectionConfig as R, createArtifactTunnelConnectionConfig as x, createProxyRuntimeTunnelConnectionConfig as O } from "./index6.js";
|
|
6
|
+
import { ServerSentEventStreamError as P, fetchServerSentEvents as T } from "./index7.js";
|
|
7
|
+
import { FLOWERSEC_BOOTSTRAP_SCOPE_RESOLVERS as _, PROXY_RUNTIME_SCOPE_NAME as A, createBootstrapScopeResolvers as h, validateProxyRuntimeScopeEntry as B } from "./index8.js";
|
|
8
8
|
export {
|
|
9
|
+
l as ControlplaneRequestError,
|
|
9
10
|
_ as FLOWERSEC_BOOTSTRAP_SCOPE_RESOLVERS,
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
A as PROXY_RUNTIME_SCOPE_NAME,
|
|
12
|
+
P as ServerSentEventStreamError,
|
|
12
13
|
o as base64UrlToBase64,
|
|
13
14
|
t as clearLocationHash,
|
|
14
|
-
|
|
15
|
-
x as
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
O as
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
R as createArtifactDirectConnectionConfig,
|
|
16
|
+
x as createArtifactTunnelConnectionConfig,
|
|
17
|
+
h as createBootstrapScopeResolvers,
|
|
18
|
+
C as createControlplaneArtifactSource,
|
|
19
|
+
O as createProxyRuntimeTunnelConnectionConfig,
|
|
20
|
+
T as fetchServerSentEvents,
|
|
21
|
+
p as getSessionStorage,
|
|
22
|
+
n as parseBase64UrlJsonFromHash,
|
|
23
|
+
a as parseHashParam,
|
|
24
|
+
i as postMessageToOrigins,
|
|
25
|
+
f as removeSessionStorage,
|
|
25
26
|
m as setSessionStorage,
|
|
26
|
-
|
|
27
|
+
B as validateProxyRuntimeScopeEntry,
|
|
27
28
|
S as waitForMessage
|
|
28
29
|
};
|
package/dist/index5.js
CHANGED
|
@@ -1,34 +1,75 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
1
|
+
import { parseArtifact as d, createArtifactLease as f } from "@floegence/flowersec-core";
|
|
2
|
+
class a extends Error {
|
|
3
|
+
status;
|
|
4
|
+
code;
|
|
5
|
+
constructor(e, r, c) {
|
|
6
|
+
super(c), this.name = "ControlplaneRequestError", this.status = e, this.code = r;
|
|
7
|
+
}
|
|
9
8
|
}
|
|
10
|
-
function t
|
|
11
|
-
const
|
|
12
|
-
return
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
});
|
|
9
|
+
function p(t) {
|
|
10
|
+
const e = t.toLowerCase();
|
|
11
|
+
return e === "localhost" || e === "::1" || e === "127.0.0.1" || e.startsWith("127.");
|
|
12
|
+
}
|
|
13
|
+
function u(t, e) {
|
|
14
|
+
const r = new URL(t);
|
|
15
|
+
if (r.protocol !== "https:" && !(e && r.protocol === "http:" && p(r.hostname)))
|
|
16
|
+
throw new a(0, "transport_policy_denied", "controlplane transport policy denied");
|
|
17
|
+
return r.pathname = r.pathname.replace(/\/+$/u, ""), r;
|
|
21
18
|
}
|
|
22
|
-
function
|
|
19
|
+
function h(t, e) {
|
|
20
|
+
const r = e === void 0 ? "/v1/connect/artifact" : "/v1/connect/artifact/entry";
|
|
21
|
+
return new URL(`${t.pathname}${r}`, t).toString();
|
|
22
|
+
}
|
|
23
|
+
function y(t) {
|
|
24
|
+
if (!t || typeof t != "object" || !("connect_artifact" in t))
|
|
25
|
+
throw new a(200, "invalid_request", "Invalid controlplane response: missing `connect_artifact`");
|
|
26
|
+
return JSON.stringify(t.connect_artifact);
|
|
27
|
+
}
|
|
28
|
+
function k(t) {
|
|
29
|
+
const e = t.fetch ?? globalThis.fetch, r = u(t.baseUrl, t.allowLoopbackHTTP === !0), c = h(r, t.entryTicket);
|
|
23
30
|
return {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
acquire: async ({ signal: s }) => {
|
|
32
|
+
try {
|
|
33
|
+
const o = {
|
|
34
|
+
endpoint_id: t.endpointId,
|
|
35
|
+
...t.payload === void 0 ? {} : { payload: t.payload },
|
|
36
|
+
...t.entryTicket === void 0 && t.correlation !== void 0 ? { correlation: { trace_id: t.correlation.traceId } } : {}
|
|
37
|
+
}, n = await e(c, {
|
|
38
|
+
method: "POST",
|
|
39
|
+
headers: {
|
|
40
|
+
accept: "application/json",
|
|
41
|
+
"content-type": "application/json",
|
|
42
|
+
...t.entryTicket === void 0 ? {} : { authorization: `Bearer ${t.entryTicket}` }
|
|
43
|
+
},
|
|
44
|
+
body: JSON.stringify(o),
|
|
45
|
+
credentials: "omit",
|
|
46
|
+
redirect: "error",
|
|
47
|
+
signal: s
|
|
48
|
+
});
|
|
49
|
+
if (!n.ok) {
|
|
50
|
+
let i = "request_failed";
|
|
51
|
+
try {
|
|
52
|
+
i = (await n.json()).error?.code ?? i;
|
|
53
|
+
} catch {
|
|
54
|
+
}
|
|
55
|
+
throw new a(n.status, i, `controlplane request failed: ${n.status}`);
|
|
56
|
+
}
|
|
57
|
+
const l = d(y(await n.json()));
|
|
58
|
+
return {
|
|
59
|
+
kind: "lease",
|
|
60
|
+
lease: f(l, async () => {
|
|
61
|
+
})
|
|
62
|
+
};
|
|
63
|
+
} catch (o) {
|
|
64
|
+
if (o instanceof DOMException && o.name === "AbortError") throw o;
|
|
65
|
+
if (o instanceof a)
|
|
66
|
+
return { kind: "failure", code: o.code, disposition: { kind: "retryable" } };
|
|
67
|
+
throw o;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
28
70
|
};
|
|
29
71
|
}
|
|
30
72
|
export {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
t as createProxyRuntimeTunnelReconnectConfig
|
|
73
|
+
a as ControlplaneRequestError,
|
|
74
|
+
k as createControlplaneArtifactSource
|
|
34
75
|
};
|
package/dist/index6.js
CHANGED
|
@@ -1,150 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
code;
|
|
3
|
-
status;
|
|
4
|
-
retryAfter;
|
|
5
|
-
constructor(d, m, c = {}) {
|
|
6
|
-
super(m, c), this.name = "ServerSentEventStreamError", this.code = d, c.status !== void 0 && (this.status = c.status), c.retryAfter !== void 0 && (this.retryAfter = c.retryAfter);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
const U = 1024 * 1024, N = 2 * 1024 * 1024;
|
|
10
|
-
function T(n, d) {
|
|
11
|
-
if (n === void 0) return d;
|
|
12
|
-
if (!Number.isSafeInteger(n) || n <= 0)
|
|
13
|
-
throw new TypeError("server-sent event byte limits must be positive safe integers");
|
|
1
|
+
function t(n) {
|
|
14
2
|
return n;
|
|
15
3
|
}
|
|
16
|
-
function
|
|
17
|
-
return n
|
|
18
|
-
}
|
|
19
|
-
async function A(n) {
|
|
20
|
-
try {
|
|
21
|
-
await n.body?.cancel();
|
|
22
|
-
} catch {
|
|
23
|
-
}
|
|
4
|
+
function e(n) {
|
|
5
|
+
return n;
|
|
24
6
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
fetch: m = globalThis.fetch,
|
|
28
|
-
maxFrameBytes: c,
|
|
29
|
-
maxBufferBytes: F,
|
|
30
|
-
onActivity: x,
|
|
31
|
-
signal: L,
|
|
32
|
-
...k
|
|
33
|
-
} = d, M = T(c, U), D = T(F, N);
|
|
34
|
-
let a;
|
|
35
|
-
try {
|
|
36
|
-
a = await m(n, { ...k, signal: L });
|
|
37
|
-
} catch (e) {
|
|
38
|
-
throw new i("transport", "failed to open server-sent event stream", { cause: e });
|
|
39
|
-
}
|
|
40
|
-
if (!a.ok) {
|
|
41
|
-
const e = a.headers.get("retry-after") ?? void 0;
|
|
42
|
-
throw await A(a), new i(
|
|
43
|
-
"unexpected_status",
|
|
44
|
-
`server-sent event request returned HTTP ${a.status}`,
|
|
45
|
-
{ status: a.status, retryAfter: e }
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
if (!R(a))
|
|
49
|
-
throw await A(a), new i(
|
|
50
|
-
"unsupported_content_type",
|
|
51
|
-
"server-sent event response must use text/event-stream"
|
|
52
|
-
);
|
|
53
|
-
if (a.body === null)
|
|
54
|
-
throw new i("malformed_frame", "server-sent event response has no body");
|
|
55
|
-
const y = a.body.getReader(), B = new TextDecoder("utf-8", { fatal: !0 }), E = new TextEncoder();
|
|
56
|
-
let s = "", h = 0, w = [], l, b, u, p = !1, g = !1;
|
|
57
|
-
const _ = () => {
|
|
58
|
-
h = 0, w = [], l = void 0, u = void 0, p = !1;
|
|
59
|
-
}, I = (e, o) => {
|
|
60
|
-
if (h += E.encode(e).byteLength + o, h > M)
|
|
61
|
-
throw new i("oversized_frame", "server-sent event frame exceeds its byte limit");
|
|
62
|
-
if (e === "") {
|
|
63
|
-
if (!p) {
|
|
64
|
-
_();
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
const f = {
|
|
68
|
-
data: w.join(`
|
|
69
|
-
`),
|
|
70
|
-
...l === void 0 ? {} : { event: l },
|
|
71
|
-
...b === void 0 ? {} : { id: b },
|
|
72
|
-
...u === void 0 ? {} : { retry: u }
|
|
73
|
-
};
|
|
74
|
-
return _(), f;
|
|
75
|
-
}
|
|
76
|
-
if (e.startsWith(":")) {
|
|
77
|
-
x?.();
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
const r = e.indexOf(":"), v = r < 0 ? e : e.slice(0, r);
|
|
81
|
-
let t = r < 0 ? "" : e.slice(r + 1);
|
|
82
|
-
switch (t.startsWith(" ") && (t = t.slice(1)), v) {
|
|
83
|
-
case "data":
|
|
84
|
-
p = !0, w.push(t);
|
|
85
|
-
break;
|
|
86
|
-
case "event":
|
|
87
|
-
l = t;
|
|
88
|
-
break;
|
|
89
|
-
case "id":
|
|
90
|
-
t.includes("\0") || (b = t);
|
|
91
|
-
break;
|
|
92
|
-
case "retry":
|
|
93
|
-
if (/^[0-9]+$/u.test(t)) {
|
|
94
|
-
const f = Number(t);
|
|
95
|
-
Number.isSafeInteger(f) && (u = f);
|
|
96
|
-
}
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
try {
|
|
101
|
-
for (; ; ) {
|
|
102
|
-
let e;
|
|
103
|
-
try {
|
|
104
|
-
e = await y.read();
|
|
105
|
-
} catch (r) {
|
|
106
|
-
throw new i("transport", "failed while reading server-sent event stream", { cause: r });
|
|
107
|
-
}
|
|
108
|
-
if (e.value !== void 0) {
|
|
109
|
-
x?.();
|
|
110
|
-
try {
|
|
111
|
-
s += B.decode(e.value, { stream: !e.done });
|
|
112
|
-
} catch (r) {
|
|
113
|
-
throw new i("malformed_frame", "server-sent event stream is not valid UTF-8", { cause: r });
|
|
114
|
-
}
|
|
115
|
-
} else if (e.done)
|
|
116
|
-
try {
|
|
117
|
-
s += B.decode();
|
|
118
|
-
} catch (r) {
|
|
119
|
-
throw new i("malformed_frame", "server-sent event stream ends with invalid UTF-8", { cause: r });
|
|
120
|
-
}
|
|
121
|
-
let o = 0;
|
|
122
|
-
for (; o < s.length; ) {
|
|
123
|
-
const r = s.indexOf(`
|
|
124
|
-
`, o), v = s.indexOf("\r", o);
|
|
125
|
-
let t = -1;
|
|
126
|
-
if (r >= 0 && v >= 0 ? t = Math.min(r, v) : t = Math.max(r, v), t < 0 || s[t] === "\r" && t + 1 === s.length && !e.done) break;
|
|
127
|
-
const f = s[t] === "\r" && s[t + 1] === `
|
|
128
|
-
` ? 2 : 1, S = I(s.slice(o, t), f);
|
|
129
|
-
o = t + f, S !== void 0 && (yield S);
|
|
130
|
-
}
|
|
131
|
-
if (s = s.slice(o), E.encode(s).byteLength > D)
|
|
132
|
-
throw new i("oversized_buffer", "server-sent event pending buffer exceeds its byte limit");
|
|
133
|
-
if (e.done) {
|
|
134
|
-
g = !0;
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
} finally {
|
|
139
|
-
if (!g)
|
|
140
|
-
try {
|
|
141
|
-
await y.cancel();
|
|
142
|
-
} catch {
|
|
143
|
-
}
|
|
144
|
-
y.releaseLock();
|
|
145
|
-
}
|
|
7
|
+
function o(n) {
|
|
8
|
+
return n;
|
|
146
9
|
}
|
|
147
10
|
export {
|
|
148
|
-
|
|
149
|
-
|
|
11
|
+
o as createArtifactDirectConnectionConfig,
|
|
12
|
+
t as createArtifactTunnelConnectionConfig,
|
|
13
|
+
e as createProxyRuntimeTunnelConnectionConfig
|
|
150
14
|
};
|
package/dist/index7.js
CHANGED
|
@@ -1,22 +1,150 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
class i extends Error {
|
|
2
|
+
code;
|
|
3
|
+
status;
|
|
4
|
+
retryAfter;
|
|
5
|
+
constructor(d, m, c = {}) {
|
|
6
|
+
super(m, c), this.name = "ServerSentEventStreamError", this.code = d, c.status !== void 0 && (this.status = c.status), c.retryAfter !== void 0 && (this.retryAfter = c.retryAfter);
|
|
7
|
+
}
|
|
7
8
|
}
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
const U = 1024 * 1024, N = 2 * 1024 * 1024;
|
|
10
|
+
function T(n, d) {
|
|
11
|
+
if (n === void 0) return d;
|
|
12
|
+
if (!Number.isSafeInteger(n) || n <= 0)
|
|
13
|
+
throw new TypeError("server-sent event byte limits must be positive safe integers");
|
|
14
|
+
return n;
|
|
15
|
+
}
|
|
16
|
+
function R(n) {
|
|
17
|
+
return n.headers.get("content-type")?.split(";", 1)[0]?.trim().toLowerCase() === "text/event-stream";
|
|
18
|
+
}
|
|
19
|
+
async function A(n) {
|
|
20
|
+
try {
|
|
21
|
+
await n.body?.cancel();
|
|
22
|
+
} catch {
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async function* O(n, d = {}) {
|
|
26
|
+
const {
|
|
27
|
+
fetch: m = globalThis.fetch,
|
|
28
|
+
maxFrameBytes: c,
|
|
29
|
+
maxBufferBytes: F,
|
|
30
|
+
onActivity: x,
|
|
31
|
+
signal: L,
|
|
32
|
+
...k
|
|
33
|
+
} = d, M = T(c, U), D = T(F, N);
|
|
34
|
+
let a;
|
|
35
|
+
try {
|
|
36
|
+
a = await m(n, { ...k, signal: L });
|
|
37
|
+
} catch (e) {
|
|
38
|
+
throw new i("transport", "failed to open server-sent event stream", { cause: e });
|
|
39
|
+
}
|
|
40
|
+
if (!a.ok) {
|
|
41
|
+
const e = a.headers.get("retry-after") ?? void 0;
|
|
42
|
+
throw await A(a), new i(
|
|
43
|
+
"unexpected_status",
|
|
44
|
+
`server-sent event request returned HTTP ${a.status}`,
|
|
45
|
+
{ status: a.status, retryAfter: e }
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
if (!R(a))
|
|
49
|
+
throw await A(a), new i(
|
|
50
|
+
"unsupported_content_type",
|
|
51
|
+
"server-sent event response must use text/event-stream"
|
|
52
|
+
);
|
|
53
|
+
if (a.body === null)
|
|
54
|
+
throw new i("malformed_frame", "server-sent event response has no body");
|
|
55
|
+
const y = a.body.getReader(), B = new TextDecoder("utf-8", { fatal: !0 }), E = new TextEncoder();
|
|
56
|
+
let s = "", h = 0, w = [], l, b, u, p = !1, g = !1;
|
|
57
|
+
const _ = () => {
|
|
58
|
+
h = 0, w = [], l = void 0, u = void 0, p = !1;
|
|
59
|
+
}, I = (e, o) => {
|
|
60
|
+
if (h += E.encode(e).byteLength + o, h > M)
|
|
61
|
+
throw new i("oversized_frame", "server-sent event frame exceeds its byte limit");
|
|
62
|
+
if (e === "") {
|
|
63
|
+
if (!p) {
|
|
64
|
+
_();
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const f = {
|
|
68
|
+
data: w.join(`
|
|
69
|
+
`),
|
|
70
|
+
...l === void 0 ? {} : { event: l },
|
|
71
|
+
...b === void 0 ? {} : { id: b },
|
|
72
|
+
...u === void 0 ? {} : { retry: u }
|
|
73
|
+
};
|
|
74
|
+
return _(), f;
|
|
75
|
+
}
|
|
76
|
+
if (e.startsWith(":")) {
|
|
77
|
+
x?.();
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const r = e.indexOf(":"), v = r < 0 ? e : e.slice(0, r);
|
|
81
|
+
let t = r < 0 ? "" : e.slice(r + 1);
|
|
82
|
+
switch (t.startsWith(" ") && (t = t.slice(1)), v) {
|
|
83
|
+
case "data":
|
|
84
|
+
p = !0, w.push(t);
|
|
85
|
+
break;
|
|
86
|
+
case "event":
|
|
87
|
+
l = t;
|
|
88
|
+
break;
|
|
89
|
+
case "id":
|
|
90
|
+
t.includes("\0") || (b = t);
|
|
91
|
+
break;
|
|
92
|
+
case "retry":
|
|
93
|
+
if (/^[0-9]+$/u.test(t)) {
|
|
94
|
+
const f = Number(t);
|
|
95
|
+
Number.isSafeInteger(f) && (u = f);
|
|
96
|
+
}
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
try {
|
|
101
|
+
for (; ; ) {
|
|
102
|
+
let e;
|
|
103
|
+
try {
|
|
104
|
+
e = await y.read();
|
|
105
|
+
} catch (r) {
|
|
106
|
+
throw new i("transport", "failed while reading server-sent event stream", { cause: r });
|
|
107
|
+
}
|
|
108
|
+
if (e.value !== void 0) {
|
|
109
|
+
x?.();
|
|
110
|
+
try {
|
|
111
|
+
s += B.decode(e.value, { stream: !e.done });
|
|
112
|
+
} catch (r) {
|
|
113
|
+
throw new i("malformed_frame", "server-sent event stream is not valid UTF-8", { cause: r });
|
|
114
|
+
}
|
|
115
|
+
} else if (e.done)
|
|
116
|
+
try {
|
|
117
|
+
s += B.decode();
|
|
118
|
+
} catch (r) {
|
|
119
|
+
throw new i("malformed_frame", "server-sent event stream ends with invalid UTF-8", { cause: r });
|
|
120
|
+
}
|
|
121
|
+
let o = 0;
|
|
122
|
+
for (; o < s.length; ) {
|
|
123
|
+
const r = s.indexOf(`
|
|
124
|
+
`, o), v = s.indexOf("\r", o);
|
|
125
|
+
let t = -1;
|
|
126
|
+
if (r >= 0 && v >= 0 ? t = Math.min(r, v) : t = Math.max(r, v), t < 0 || s[t] === "\r" && t + 1 === s.length && !e.done) break;
|
|
127
|
+
const f = s[t] === "\r" && s[t + 1] === `
|
|
128
|
+
` ? 2 : 1, S = I(s.slice(o, t), f);
|
|
129
|
+
o = t + f, S !== void 0 && (yield S);
|
|
130
|
+
}
|
|
131
|
+
if (s = s.slice(o), E.encode(s).byteLength > D)
|
|
132
|
+
throw new i("oversized_buffer", "server-sent event pending buffer exceeds its byte limit");
|
|
133
|
+
if (e.done) {
|
|
134
|
+
g = !0;
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
} finally {
|
|
139
|
+
if (!g)
|
|
140
|
+
try {
|
|
141
|
+
await y.cancel();
|
|
142
|
+
} catch {
|
|
143
|
+
}
|
|
144
|
+
y.releaseLock();
|
|
145
|
+
}
|
|
16
146
|
}
|
|
17
147
|
export {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
c as createBootstrapScopeResolvers,
|
|
21
|
-
r as validateProxyRuntimeScopeEntry
|
|
148
|
+
i as ServerSentEventStreamError,
|
|
149
|
+
O as fetchServerSentEvents
|
|
22
150
|
};
|
package/dist/index8.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { PROXY_RUNTIME_SCOPE as t, assertProxyRuntimeScope as n } from "@floegence/flowersec-core/proxy";
|
|
2
|
+
const o = "proxy.runtime";
|
|
3
|
+
function r(e) {
|
|
4
|
+
if (e.scope_version !== t.version)
|
|
5
|
+
throw new Error(`unsupported ${o} scope_version: ${e.scope_version}`);
|
|
6
|
+
n(e.payload);
|
|
7
|
+
}
|
|
8
|
+
const s = Object.freeze({
|
|
9
|
+
[o]: r
|
|
10
|
+
});
|
|
11
|
+
function i(e) {
|
|
12
|
+
return e ? Object.freeze({
|
|
13
|
+
...e,
|
|
14
|
+
[o]: r
|
|
15
|
+
}) : s;
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
s as FLOWERSEC_BOOTSTRAP_SCOPE_RESOLVERS,
|
|
19
|
+
o as PROXY_RUNTIME_SCOPE_NAME,
|
|
20
|
+
i as createBootstrapScopeResolvers,
|
|
21
|
+
r as validateProxyRuntimeScopeEntry
|
|
22
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@floegence/floe-webapp-boot",
|
|
3
|
-
"version": "0.40.
|
|
3
|
+
"version": "0.40.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"clean": "rm -rf dist *.tsbuildinfo"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@floegence/flowersec-core": "
|
|
33
|
+
"@floegence/flowersec-core": "2.0.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"typescript": "^5.9.3",
|
package/dist/reconnect.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { DirectBrowserReconnectConfig, DirectConnectBrowserOptions, TunnelBrowserReconnectConfig, TunnelConnectBrowserOptions } from '@floegence/flowersec-core/browser';
|
|
2
|
-
import type { ClientObserverLike } from '@floegence/flowersec-core/observability';
|
|
3
|
-
import type { ArtifactSource, AutoReconnectConfig } from '@floegence/flowersec-core/reconnect';
|
|
4
|
-
type SharedArtifactReconnectOptions = Readonly<{
|
|
5
|
-
source: ArtifactSource;
|
|
6
|
-
observer?: ClientObserverLike;
|
|
7
|
-
autoReconnect?: AutoReconnectConfig;
|
|
8
|
-
}>;
|
|
9
|
-
type TunnelArtifactConnectOptions = Omit<TunnelConnectBrowserOptions, 'observer' | 'signal'>;
|
|
10
|
-
type DirectArtifactConnectOptions = Omit<DirectConnectBrowserOptions, 'observer' | 'signal'>;
|
|
11
|
-
export type TunnelArtifactReconnectOptions = SharedArtifactReconnectOptions & Readonly<{
|
|
12
|
-
connect?: TunnelArtifactConnectOptions;
|
|
13
|
-
}>;
|
|
14
|
-
export type DirectArtifactReconnectOptions = SharedArtifactReconnectOptions & Readonly<{
|
|
15
|
-
connect?: DirectArtifactConnectOptions;
|
|
16
|
-
}>;
|
|
17
|
-
export declare function createArtifactTunnelReconnectConfig(options: TunnelArtifactReconnectOptions): TunnelBrowserReconnectConfig;
|
|
18
|
-
export declare function createProxyRuntimeTunnelReconnectConfig(options: TunnelArtifactReconnectOptions): TunnelBrowserReconnectConfig;
|
|
19
|
-
export declare function createArtifactDirectReconnectConfig(options: DirectArtifactReconnectOptions): DirectBrowserReconnectConfig;
|
|
20
|
-
export {};
|