@floegence/floe-webapp-boot 0.35.58 → 0.35.59
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/artifactSource.d.ts +14 -0
- package/dist/hash.d.ts +4 -0
- package/dist/index.d.ts +10 -15
- package/dist/index.js +26 -87
- package/dist/index10.js +13 -0
- package/dist/index11.js +50 -0
- package/dist/index12.js +6 -0
- package/dist/index13.js +2 -0
- package/dist/index14.js +1 -0
- package/dist/index15.js +7 -0
- package/dist/index16.js +83 -0
- package/dist/index17.js +195 -0
- package/dist/index18.js +148 -0
- package/dist/index19.js +3 -0
- package/dist/index2.js +39 -0
- package/dist/index20.js +6 -0
- package/dist/index21.js +109 -0
- package/dist/index22.js +2 -0
- package/dist/index23.js +1 -0
- package/dist/index24.js +1 -0
- package/dist/index25.js +1 -0
- package/dist/index3.js +30 -0
- package/dist/index4.js +24 -0
- package/dist/index5.js +40 -0
- package/dist/index6.js +37 -0
- package/dist/index7.js +32 -0
- package/dist/index8.js +159 -0
- package/dist/index9.js +6 -0
- package/dist/messaging.d.ts +8 -0
- package/dist/reconnect.d.ts +21 -0
- package/dist/scope.d.ts +12 -0
- package/dist/storage.d.ts +3 -0
- package/package.json +4 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ConnectArtifact, ConnectArtifactRequestConfig, EntryConnectArtifactRequestConfig } from '@floegence/flowersec-core/browser';
|
|
2
|
+
export type ArtifactRequestContext = Readonly<{
|
|
3
|
+
signal?: AbortSignal;
|
|
4
|
+
traceId?: string;
|
|
5
|
+
}>;
|
|
6
|
+
export type ArtifactSourceKind = 'controlplane' | 'entry_controlplane' | 'fixed' | 'factory';
|
|
7
|
+
export type ArtifactSource = Readonly<{
|
|
8
|
+
kind: ArtifactSourceKind;
|
|
9
|
+
getArtifact: (ctx: ArtifactRequestContext) => Promise<ConnectArtifact>;
|
|
10
|
+
}>;
|
|
11
|
+
export declare function createArtifactSourceFromFactory(getArtifact: (ctx: ArtifactRequestContext) => Promise<ConnectArtifact>, kind?: ArtifactSourceKind): ArtifactSource;
|
|
12
|
+
export declare function createFixedArtifactSource(artifact: ConnectArtifact): ArtifactSource;
|
|
13
|
+
export declare function createControlplaneArtifactSource(config: ConnectArtifactRequestConfig): ArtifactSource;
|
|
14
|
+
export declare function createEntryControlplaneArtifactSource(config: EntryConnectArtifactRequestConfig): ArtifactSource;
|
package/dist/hash.d.ts
ADDED
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export declare function getSessionStorage(key: string): string;
|
|
12
|
-
export declare function setSessionStorage(key: string, value: string): void;
|
|
13
|
-
export declare function removeSessionStorage(key: string): void;
|
|
14
|
-
export declare function postMessageToOrigins(target: Window, origins: string[], message: unknown): void;
|
|
15
|
-
export declare function waitForMessage<T>(opts: WaitForMessageOptions<T>): Promise<T>;
|
|
1
|
+
export { base64UrlToBase64, clearLocationHash, parseBase64UrlJsonFromHash, parseHashParam, } from './hash';
|
|
2
|
+
export type { WaitForMessageOptions } from './messaging';
|
|
3
|
+
export { postMessageToOrigins, waitForMessage } from './messaging';
|
|
4
|
+
export { getSessionStorage, removeSessionStorage, setSessionStorage } from './storage';
|
|
5
|
+
export type { ArtifactRequestContext, ArtifactSource, ArtifactSourceKind, } from './artifactSource';
|
|
6
|
+
export { createArtifactSourceFromFactory, createControlplaneArtifactSource, createEntryControlplaneArtifactSource, createFixedArtifactSource, } from './artifactSource';
|
|
7
|
+
export type { DirectArtifactReconnectOptions, TunnelArtifactReconnectOptions, } from './reconnect';
|
|
8
|
+
export { createArtifactDirectReconnectConfig, createArtifactTunnelReconnectConfig, createProxyRuntimeTunnelReconnectConfig, } from './reconnect';
|
|
9
|
+
export type { ScopeEnvelope, ScopeResolver, ScopeResolverMap } from './scope';
|
|
10
|
+
export { createBootstrapScopeResolvers, FLOWERSEC_BOOTSTRAP_SCOPE_RESOLVERS, PROXY_RUNTIME_SCOPE_NAME, validateProxyRuntimeScopeEntry, } from './scope';
|
package/dist/index.js
CHANGED
|
@@ -1,89 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
const t = String(e ?? "").trim();
|
|
8
|
-
if (!t) return null;
|
|
9
|
-
const r = String(window.location.hash ?? "").trim(), n = r.startsWith("#") ? r.slice(1) : r;
|
|
10
|
-
if (!n) return null;
|
|
11
|
-
try {
|
|
12
|
-
const o = new URLSearchParams(n);
|
|
13
|
-
return String(o.get(t) ?? "").trim() || null;
|
|
14
|
-
} catch {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
function g(e) {
|
|
19
|
-
const t = m(e);
|
|
20
|
-
if (!t) return null;
|
|
21
|
-
try {
|
|
22
|
-
const r = atob(l(t));
|
|
23
|
-
return r ? JSON.parse(r) : null;
|
|
24
|
-
} catch {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
function f() {
|
|
29
|
-
try {
|
|
30
|
-
history.replaceState(null, document.title, window.location.pathname + window.location.search);
|
|
31
|
-
} catch {
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
function h(e) {
|
|
35
|
-
try {
|
|
36
|
-
return String(sessionStorage.getItem(e) ?? "").trim();
|
|
37
|
-
} catch {
|
|
38
|
-
return "";
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
function w(e, t) {
|
|
42
|
-
try {
|
|
43
|
-
sessionStorage.setItem(e, t);
|
|
44
|
-
} catch {
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
function S(e) {
|
|
48
|
-
try {
|
|
49
|
-
sessionStorage.removeItem(e);
|
|
50
|
-
} catch {
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function d(e, t, r) {
|
|
54
|
-
const n = Array.from(new Set((t ?? []).map((o) => String(o ?? "").trim()).filter(Boolean)));
|
|
55
|
-
for (const o of n)
|
|
56
|
-
try {
|
|
57
|
-
e.postMessage(r, o);
|
|
58
|
-
} catch {
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
function p(e) {
|
|
62
|
-
const t = Array.from(new Set((e.expectedOrigins ?? []).map((n) => String(n ?? "").trim()).filter(Boolean)));
|
|
63
|
-
if (t.length === 0) return Promise.reject(new Error("expectedOrigins is required"));
|
|
64
|
-
if (!e.expectedSource) return Promise.reject(new Error("expectedSource is required"));
|
|
65
|
-
const r = Math.max(0, Math.floor(e.timeoutMs ?? 8e3));
|
|
66
|
-
return new Promise((n, o) => {
|
|
67
|
-
const s = window.setTimeout(() => {
|
|
68
|
-
c(), o(new Error("Handshake timeout"));
|
|
69
|
-
}, r), a = (i) => {
|
|
70
|
-
if (!t.includes(i.origin) || i.source !== e.expectedSource) return;
|
|
71
|
-
const u = e.accept(i.data);
|
|
72
|
-
u != null && (c(), n(u));
|
|
73
|
-
}, c = () => {
|
|
74
|
-
window.clearTimeout(s), window.removeEventListener("message", a);
|
|
75
|
-
};
|
|
76
|
-
window.addEventListener("message", a);
|
|
77
|
-
});
|
|
78
|
-
}
|
|
1
|
+
import { base64UrlToBase64 as o, clearLocationHash as t, parseBase64UrlJsonFromHash as a, parseHashParam as c } from "./index2.js";
|
|
2
|
+
import { postMessageToOrigins as s, waitForMessage as i } from "./index3.js";
|
|
3
|
+
import { getSessionStorage as f, removeSessionStorage as p, setSessionStorage as m } from "./index4.js";
|
|
4
|
+
import { createArtifactSourceFromFactory as l, createControlplaneArtifactSource as g, createEntryControlplaneArtifactSource as E, createFixedArtifactSource as x } from "./index5.js";
|
|
5
|
+
import { createArtifactDirectReconnectConfig as A, createArtifactTunnelReconnectConfig as C, createProxyRuntimeTunnelReconnectConfig as O } from "./index6.js";
|
|
6
|
+
import { FLOWERSEC_BOOTSTRAP_SCOPE_RESOLVERS as T, PROXY_RUNTIME_SCOPE_NAME as F, createBootstrapScopeResolvers as _, validateProxyRuntimeScopeEntry as y } from "./index7.js";
|
|
79
7
|
export {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
8
|
+
T as FLOWERSEC_BOOTSTRAP_SCOPE_RESOLVERS,
|
|
9
|
+
F as PROXY_RUNTIME_SCOPE_NAME,
|
|
10
|
+
o as base64UrlToBase64,
|
|
11
|
+
t as clearLocationHash,
|
|
12
|
+
A as createArtifactDirectReconnectConfig,
|
|
13
|
+
l as createArtifactSourceFromFactory,
|
|
14
|
+
C as createArtifactTunnelReconnectConfig,
|
|
15
|
+
_ as createBootstrapScopeResolvers,
|
|
16
|
+
g as createControlplaneArtifactSource,
|
|
17
|
+
E as createEntryControlplaneArtifactSource,
|
|
18
|
+
x as createFixedArtifactSource,
|
|
19
|
+
O as createProxyRuntimeTunnelReconnectConfig,
|
|
20
|
+
f as getSessionStorage,
|
|
21
|
+
a as parseBase64UrlJsonFromHash,
|
|
22
|
+
c as parseHashParam,
|
|
23
|
+
s as postMessageToOrigins,
|
|
24
|
+
p as removeSessionStorage,
|
|
25
|
+
m as setSessionStorage,
|
|
26
|
+
y as validateProxyRuntimeScopeEntry,
|
|
27
|
+
i as waitForMessage
|
|
89
28
|
};
|
package/dist/index10.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { resolveProxyPreset as m, DEFAULT_PROXY_PRESET_MANIFEST as _, CODESERVER_PROXY_PRESET_MANIFEST as i } from "./index21.js";
|
|
2
|
+
function t(s) {
|
|
3
|
+
const e = m(s);
|
|
4
|
+
return Object.freeze({
|
|
5
|
+
maxJsonFrameBytes: e.limits.max_json_frame_bytes,
|
|
6
|
+
maxChunkBytes: e.limits.max_chunk_bytes,
|
|
7
|
+
maxBodyBytes: e.limits.max_body_bytes,
|
|
8
|
+
maxWsFrameBytes: e.limits.max_ws_frame_bytes,
|
|
9
|
+
timeoutMs: e.limits.timeout_ms ?? 0
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
t(_);
|
|
13
|
+
t(i);
|
package/dist/index11.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
var i;
|
|
2
|
+
(function(e) {
|
|
3
|
+
e[e.Suite_P256_HKDF_SHA256_AES_256_GCM = 2] = "Suite_P256_HKDF_SHA256_AES_256_GCM", e[e.Suite_X25519_HKDF_SHA256_AES_256_GCM = 1] = "Suite_X25519_HKDF_SHA256_AES_256_GCM";
|
|
4
|
+
})(i || (i = {}));
|
|
5
|
+
function o(e) {
|
|
6
|
+
return typeof e == "object" && e != null && !Array.isArray(e);
|
|
7
|
+
}
|
|
8
|
+
function r(e, n) {
|
|
9
|
+
if (typeof n != "string")
|
|
10
|
+
throw new Error(`bad ${e}`);
|
|
11
|
+
return n;
|
|
12
|
+
}
|
|
13
|
+
function _(e, n) {
|
|
14
|
+
if (typeof n != "number" || !Number.isSafeInteger(n))
|
|
15
|
+
throw new Error(`bad ${e}`);
|
|
16
|
+
return n;
|
|
17
|
+
}
|
|
18
|
+
function u(e, n) {
|
|
19
|
+
return _(e, n);
|
|
20
|
+
}
|
|
21
|
+
const c = /* @__PURE__ */ new Set([
|
|
22
|
+
2,
|
|
23
|
+
1
|
|
24
|
+
]);
|
|
25
|
+
function f(e, n) {
|
|
26
|
+
const t = _(e, n);
|
|
27
|
+
if (!c.has(t))
|
|
28
|
+
throw new Error(`bad ${e}`);
|
|
29
|
+
return t;
|
|
30
|
+
}
|
|
31
|
+
function a(e) {
|
|
32
|
+
if (!o(e))
|
|
33
|
+
throw new Error("bad DirectConnectInfo");
|
|
34
|
+
const n = e;
|
|
35
|
+
if (n.ws_url === void 0)
|
|
36
|
+
throw new Error("bad DirectConnectInfo.ws_url");
|
|
37
|
+
if (r("DirectConnectInfo.ws_url", n.ws_url), n.channel_id === void 0)
|
|
38
|
+
throw new Error("bad DirectConnectInfo.channel_id");
|
|
39
|
+
if (r("DirectConnectInfo.channel_id", n.channel_id), n.e2ee_psk_b64u === void 0)
|
|
40
|
+
throw new Error("bad DirectConnectInfo.e2ee_psk_b64u");
|
|
41
|
+
if (r("DirectConnectInfo.e2ee_psk_b64u", n.e2ee_psk_b64u), n.channel_init_expire_at_unix_s === void 0)
|
|
42
|
+
throw new Error("bad DirectConnectInfo.channel_init_expire_at_unix_s");
|
|
43
|
+
if (u("DirectConnectInfo.channel_init_expire_at_unix_s", n.channel_init_expire_at_unix_s), n.default_suite === void 0)
|
|
44
|
+
throw new Error("bad DirectConnectInfo.default_suite");
|
|
45
|
+
return f("DirectConnectInfo.default_suite", n.default_suite), n;
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
i as Suite,
|
|
49
|
+
a as assertDirectConnectInfo
|
|
50
|
+
};
|
package/dist/index12.js
ADDED
package/dist/index13.js
ADDED
package/dist/index14.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
new TextEncoder();
|
package/dist/index15.js
ADDED
package/dist/index16.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
var a;
|
|
2
|
+
(function(e) {
|
|
3
|
+
e[e.Role_client = 1] = "Role_client", e[e.Role_server = 2] = "Role_server";
|
|
4
|
+
})(a || (a = {}));
|
|
5
|
+
var _;
|
|
6
|
+
(function(e) {
|
|
7
|
+
e[e.Suite_P256_HKDF_SHA256_AES_256_GCM = 2] = "Suite_P256_HKDF_SHA256_AES_256_GCM", e[e.Suite_X25519_HKDF_SHA256_AES_256_GCM = 1] = "Suite_X25519_HKDF_SHA256_AES_256_GCM";
|
|
8
|
+
})(_ || (_ = {}));
|
|
9
|
+
function l(e) {
|
|
10
|
+
return typeof e == "object" && e != null && !Array.isArray(e);
|
|
11
|
+
}
|
|
12
|
+
function r(e, n) {
|
|
13
|
+
if (typeof n != "string")
|
|
14
|
+
throw new Error(`bad ${e}`);
|
|
15
|
+
return n;
|
|
16
|
+
}
|
|
17
|
+
function i(e, n) {
|
|
18
|
+
if (typeof n != "number" || !Number.isSafeInteger(n))
|
|
19
|
+
throw new Error(`bad ${e}`);
|
|
20
|
+
return n;
|
|
21
|
+
}
|
|
22
|
+
function u(e, n) {
|
|
23
|
+
const t = i(e, n);
|
|
24
|
+
if (t < -2147483648 || t > 2147483647)
|
|
25
|
+
throw new Error(`bad ${e}`);
|
|
26
|
+
return t;
|
|
27
|
+
}
|
|
28
|
+
function s(e, n) {
|
|
29
|
+
return i(e, n);
|
|
30
|
+
}
|
|
31
|
+
const d = /* @__PURE__ */ new Set([
|
|
32
|
+
1,
|
|
33
|
+
2
|
|
34
|
+
]);
|
|
35
|
+
function h(e, n) {
|
|
36
|
+
const t = i(e, n);
|
|
37
|
+
if (!d.has(t))
|
|
38
|
+
throw new Error(`bad ${e}`);
|
|
39
|
+
return t;
|
|
40
|
+
}
|
|
41
|
+
const f = /* @__PURE__ */ new Set([
|
|
42
|
+
2,
|
|
43
|
+
1
|
|
44
|
+
]);
|
|
45
|
+
function o(e, n) {
|
|
46
|
+
const t = i(e, n);
|
|
47
|
+
if (!f.has(t))
|
|
48
|
+
throw new Error(`bad ${e}`);
|
|
49
|
+
return t;
|
|
50
|
+
}
|
|
51
|
+
function w(e) {
|
|
52
|
+
if (!l(e))
|
|
53
|
+
throw new Error("bad ChannelInitGrant");
|
|
54
|
+
const n = e;
|
|
55
|
+
if (n.tunnel_url === void 0)
|
|
56
|
+
throw new Error("bad ChannelInitGrant.tunnel_url");
|
|
57
|
+
if (r("ChannelInitGrant.tunnel_url", n.tunnel_url), n.channel_id === void 0)
|
|
58
|
+
throw new Error("bad ChannelInitGrant.channel_id");
|
|
59
|
+
if (r("ChannelInitGrant.channel_id", n.channel_id), n.channel_init_expire_at_unix_s === void 0)
|
|
60
|
+
throw new Error("bad ChannelInitGrant.channel_init_expire_at_unix_s");
|
|
61
|
+
if (s("ChannelInitGrant.channel_init_expire_at_unix_s", n.channel_init_expire_at_unix_s), n.idle_timeout_seconds === void 0)
|
|
62
|
+
throw new Error("bad ChannelInitGrant.idle_timeout_seconds");
|
|
63
|
+
if (u("ChannelInitGrant.idle_timeout_seconds", n.idle_timeout_seconds), n.role === void 0)
|
|
64
|
+
throw new Error("bad ChannelInitGrant.role");
|
|
65
|
+
if (h("ChannelInitGrant.role", n.role), n.token === void 0)
|
|
66
|
+
throw new Error("bad ChannelInitGrant.token");
|
|
67
|
+
if (r("ChannelInitGrant.token", n.token), n.e2ee_psk_b64u === void 0)
|
|
68
|
+
throw new Error("bad ChannelInitGrant.e2ee_psk_b64u");
|
|
69
|
+
if (r("ChannelInitGrant.e2ee_psk_b64u", n.e2ee_psk_b64u), n.allowed_suites === void 0)
|
|
70
|
+
throw new Error("bad ChannelInitGrant.allowed_suites");
|
|
71
|
+
if (!Array.isArray(n.allowed_suites))
|
|
72
|
+
throw new Error("bad ChannelInitGrant.allowed_suites");
|
|
73
|
+
for (let t = 0; t < n.allowed_suites.length; t++)
|
|
74
|
+
o("ChannelInitGrant.allowed_suites[]", n.allowed_suites[t]);
|
|
75
|
+
if (n.default_suite === void 0)
|
|
76
|
+
throw new Error("bad ChannelInitGrant.default_suite");
|
|
77
|
+
return o("ChannelInitGrant.default_suite", n.default_suite), n;
|
|
78
|
+
}
|
|
79
|
+
export {
|
|
80
|
+
a as Role,
|
|
81
|
+
_ as Suite,
|
|
82
|
+
w as assertChannelInitGrant
|
|
83
|
+
};
|
package/dist/index17.js
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { assertChannelInitGrant as b, Role as E } from "./index16.js";
|
|
2
|
+
import { assertDirectConnectInfo as C } from "./index11.js";
|
|
3
|
+
const u = /^[a-z][a-z0-9._-]{0,63}$/, h = /^[a-z][a-z0-9._-]{0,31}$/, l = /^[A-Za-z0-9._~-]{8,128}$/, _ = new TextEncoder(), A = /* @__PURE__ */ new Set(["v", "transport", "tunnel_grant", "scoped", "correlation"]), S = /* @__PURE__ */ new Set(["v", "transport", "direct_info", "scoped", "correlation"]);
|
|
4
|
+
function a(r) {
|
|
5
|
+
return typeof r == "object" && r != null && !Array.isArray(r);
|
|
6
|
+
}
|
|
7
|
+
function p(r, t) {
|
|
8
|
+
return Object.prototype.hasOwnProperty.call(r, t);
|
|
9
|
+
}
|
|
10
|
+
function c(r, t, n) {
|
|
11
|
+
for (const e of Object.keys(t))
|
|
12
|
+
if (!n.has(e))
|
|
13
|
+
throw new Error(`bad ${r}.${e}`);
|
|
14
|
+
}
|
|
15
|
+
function g(r, t, n, e) {
|
|
16
|
+
if (typeof t != "number" || !Number.isSafeInteger(t))
|
|
17
|
+
throw new Error(`bad ${r}`);
|
|
18
|
+
if (t < n || t > e)
|
|
19
|
+
throw new Error(`bad ${r}`);
|
|
20
|
+
return t;
|
|
21
|
+
}
|
|
22
|
+
function f(r) {
|
|
23
|
+
return _.encode(r).length;
|
|
24
|
+
}
|
|
25
|
+
function O(r) {
|
|
26
|
+
return m(d(r));
|
|
27
|
+
}
|
|
28
|
+
function d(r) {
|
|
29
|
+
if (r === null)
|
|
30
|
+
return null;
|
|
31
|
+
switch (typeof r) {
|
|
32
|
+
case "string":
|
|
33
|
+
case "boolean":
|
|
34
|
+
return r;
|
|
35
|
+
case "number":
|
|
36
|
+
if (!Number.isFinite(r))
|
|
37
|
+
throw new Error("bad payload.number");
|
|
38
|
+
return r;
|
|
39
|
+
case "object": {
|
|
40
|
+
if (Array.isArray(r))
|
|
41
|
+
return r.map((n) => d(n));
|
|
42
|
+
if (!a(r))
|
|
43
|
+
throw new Error("bad payload.object");
|
|
44
|
+
const t = {};
|
|
45
|
+
for (const n of Object.keys(r).sort())
|
|
46
|
+
t[n] = d(r[n]);
|
|
47
|
+
return t;
|
|
48
|
+
}
|
|
49
|
+
default:
|
|
50
|
+
throw new Error("bad payload.value");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function m(r) {
|
|
54
|
+
return JSON.stringify(r);
|
|
55
|
+
}
|
|
56
|
+
function w(r) {
|
|
57
|
+
if (Array.isArray(r)) {
|
|
58
|
+
let t = 1;
|
|
59
|
+
for (const n of r)
|
|
60
|
+
t = Math.max(t, 1 + w(n));
|
|
61
|
+
return t;
|
|
62
|
+
}
|
|
63
|
+
if (a(r)) {
|
|
64
|
+
let t = 1;
|
|
65
|
+
for (const n of Object.values(r))
|
|
66
|
+
t = Math.max(t, 1 + w(n));
|
|
67
|
+
return t;
|
|
68
|
+
}
|
|
69
|
+
return 0;
|
|
70
|
+
}
|
|
71
|
+
function y(r) {
|
|
72
|
+
if (typeof r != "string")
|
|
73
|
+
return;
|
|
74
|
+
const t = r.trim();
|
|
75
|
+
if (l.test(t))
|
|
76
|
+
return t;
|
|
77
|
+
}
|
|
78
|
+
function z(r) {
|
|
79
|
+
if (!a(r))
|
|
80
|
+
throw new Error("bad CorrelationKV");
|
|
81
|
+
if (c("CorrelationKV", r, /* @__PURE__ */ new Set(["key", "value"])), typeof r.key != "string" || !h.test(r.key))
|
|
82
|
+
throw new Error("bad CorrelationKV.key");
|
|
83
|
+
if (typeof r.value != "string")
|
|
84
|
+
throw new Error("bad CorrelationKV.value");
|
|
85
|
+
if (f(r.key) > 32)
|
|
86
|
+
throw new Error("bad CorrelationKV.key");
|
|
87
|
+
if (f(r.value) > 128)
|
|
88
|
+
throw new Error("bad CorrelationKV.value");
|
|
89
|
+
return Object.freeze({ key: r.key, value: r.value });
|
|
90
|
+
}
|
|
91
|
+
function j(r) {
|
|
92
|
+
if (!a(r))
|
|
93
|
+
throw new Error("bad CorrelationContext");
|
|
94
|
+
if (c("CorrelationContext", r, /* @__PURE__ */ new Set(["v", "trace_id", "session_id", "tags"])), r.v !== 1)
|
|
95
|
+
throw new Error("bad CorrelationContext.v");
|
|
96
|
+
const t = r.tags;
|
|
97
|
+
if (t !== void 0 && !Array.isArray(t))
|
|
98
|
+
throw new Error("bad CorrelationContext.tags");
|
|
99
|
+
const n = (t ?? []).map((i) => z(i)), e = /* @__PURE__ */ new Set();
|
|
100
|
+
for (const i of n) {
|
|
101
|
+
if (e.has(i.key))
|
|
102
|
+
throw new Error("bad CorrelationContext.tags");
|
|
103
|
+
e.add(i.key);
|
|
104
|
+
}
|
|
105
|
+
if (n.length > 8)
|
|
106
|
+
throw new Error("bad CorrelationContext.tags");
|
|
107
|
+
const o = y(r.trace_id), s = y(r.session_id);
|
|
108
|
+
return Object.freeze({
|
|
109
|
+
v: 1,
|
|
110
|
+
...o === void 0 ? {} : { trace_id: o },
|
|
111
|
+
...s === void 0 ? {} : { session_id: s },
|
|
112
|
+
tags: Object.freeze(n)
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function k(r) {
|
|
116
|
+
if (!a(r))
|
|
117
|
+
throw new Error("bad ScopeMetadataEntry.payload");
|
|
118
|
+
const t = O(r);
|
|
119
|
+
if (f(t) > 8192)
|
|
120
|
+
throw new Error("bad ScopeMetadataEntry.payload");
|
|
121
|
+
if (w(r) > 8)
|
|
122
|
+
throw new Error("bad ScopeMetadataEntry.payload");
|
|
123
|
+
return r;
|
|
124
|
+
}
|
|
125
|
+
function T(r) {
|
|
126
|
+
if (!a(r))
|
|
127
|
+
throw new Error("bad ScopeMetadataEntry");
|
|
128
|
+
if (c("ScopeMetadataEntry", r, /* @__PURE__ */ new Set(["scope", "scope_version", "critical", "payload"])), typeof r.scope != "string" || !u.test(r.scope))
|
|
129
|
+
throw new Error("bad ScopeMetadataEntry.scope");
|
|
130
|
+
if (typeof r.critical != "boolean")
|
|
131
|
+
throw new Error("bad ScopeMetadataEntry.critical");
|
|
132
|
+
const t = g("ScopeMetadataEntry.scope_version", r.scope_version, 1, 65535), n = k(r.payload);
|
|
133
|
+
return Object.freeze({
|
|
134
|
+
scope: r.scope,
|
|
135
|
+
scope_version: t,
|
|
136
|
+
critical: r.critical,
|
|
137
|
+
payload: n
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
function I(r) {
|
|
141
|
+
if (!Array.isArray(r))
|
|
142
|
+
throw new Error("bad ConnectArtifact.scoped");
|
|
143
|
+
if (r.length > 8)
|
|
144
|
+
throw new Error("bad ConnectArtifact.scoped");
|
|
145
|
+
const t = r.map((e) => T(e)), n = /* @__PURE__ */ new Set();
|
|
146
|
+
for (const e of t) {
|
|
147
|
+
if (n.has(e.scope))
|
|
148
|
+
throw new Error("bad ConnectArtifact.scoped");
|
|
149
|
+
n.add(e.scope);
|
|
150
|
+
}
|
|
151
|
+
return Object.freeze(t);
|
|
152
|
+
}
|
|
153
|
+
function x(r) {
|
|
154
|
+
if (!a(r))
|
|
155
|
+
throw new Error("bad ConnectArtifact");
|
|
156
|
+
return r;
|
|
157
|
+
}
|
|
158
|
+
function M(r) {
|
|
159
|
+
if (r !== "tunnel" && r !== "direct")
|
|
160
|
+
throw new Error("bad ConnectArtifact.transport");
|
|
161
|
+
return r;
|
|
162
|
+
}
|
|
163
|
+
function K(r) {
|
|
164
|
+
const t = x(r);
|
|
165
|
+
if (t.v !== 1)
|
|
166
|
+
throw new Error("bad ConnectArtifact.v");
|
|
167
|
+
const n = M(t.transport), e = t.scoped === void 0 ? void 0 : I(t.scoped), o = t.correlation === void 0 ? void 0 : j(t.correlation);
|
|
168
|
+
if (n === "tunnel") {
|
|
169
|
+
if (c("TunnelClientConnectArtifact", t, A), !p(t, "tunnel_grant"))
|
|
170
|
+
throw new Error("bad TunnelClientConnectArtifact.tunnel_grant");
|
|
171
|
+
const i = b(t.tunnel_grant);
|
|
172
|
+
if (i.role !== E.Role_client)
|
|
173
|
+
throw new Error("bad TunnelClientConnectArtifact.tunnel_grant.role");
|
|
174
|
+
return Object.freeze({
|
|
175
|
+
v: 1,
|
|
176
|
+
transport: n,
|
|
177
|
+
tunnel_grant: i,
|
|
178
|
+
...e === void 0 ? {} : { scoped: e },
|
|
179
|
+
...o === void 0 ? {} : { correlation: o }
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
if (c("DirectClientConnectArtifact", t, S), !p(t, "direct_info"))
|
|
183
|
+
throw new Error("bad DirectClientConnectArtifact.direct_info");
|
|
184
|
+
const s = C(t.direct_info);
|
|
185
|
+
return Object.freeze({
|
|
186
|
+
v: 1,
|
|
187
|
+
transport: n,
|
|
188
|
+
direct_info: s,
|
|
189
|
+
...e === void 0 ? {} : { scoped: e },
|
|
190
|
+
...o === void 0 ? {} : { correlation: o }
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
export {
|
|
194
|
+
K as assertConnectArtifact
|
|
195
|
+
};
|
package/dist/index18.js
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { assertProxyPresetManifest as u } from "./index21.js";
|
|
2
|
+
const x = /^[a-z][a-z0-9._-]{0,63}$/, w = 8 * 1024, h = 8, B = 64, b = 4 * 1024;
|
|
3
|
+
function i(r) {
|
|
4
|
+
return typeof r == "object" && r != null && !Array.isArray(r);
|
|
5
|
+
}
|
|
6
|
+
function d(r, e, t) {
|
|
7
|
+
const o = new Set(t);
|
|
8
|
+
for (const n of Object.keys(e))
|
|
9
|
+
if (!o.has(n))
|
|
10
|
+
throw new Error(`bad ${r}.${n}`);
|
|
11
|
+
}
|
|
12
|
+
function s(r, e) {
|
|
13
|
+
if (typeof e != "number" || !Number.isSafeInteger(e) || e <= 0)
|
|
14
|
+
throw new Error(`bad ${r}`);
|
|
15
|
+
return e;
|
|
16
|
+
}
|
|
17
|
+
function a(r) {
|
|
18
|
+
return new TextEncoder().encode(r).length;
|
|
19
|
+
}
|
|
20
|
+
function c(r) {
|
|
21
|
+
if (Array.isArray(r)) {
|
|
22
|
+
let e = 1;
|
|
23
|
+
for (const t of r)
|
|
24
|
+
e = Math.max(e, 1 + c(t));
|
|
25
|
+
return e;
|
|
26
|
+
}
|
|
27
|
+
if (i(r)) {
|
|
28
|
+
let e = 1;
|
|
29
|
+
for (const t of Object.values(r))
|
|
30
|
+
e = Math.max(e, 1 + c(t));
|
|
31
|
+
return e;
|
|
32
|
+
}
|
|
33
|
+
return 0;
|
|
34
|
+
}
|
|
35
|
+
function f(r) {
|
|
36
|
+
return Array.isArray(r) ? r.reduce((e, t) => e + f(t), 0) : i(r) ? Object.entries(r).reduce((e, [, t]) => e + 1 + f(t), 0) : 0;
|
|
37
|
+
}
|
|
38
|
+
function E(r) {
|
|
39
|
+
if (!i(r))
|
|
40
|
+
throw new Error("bad proxy.runtime.payload");
|
|
41
|
+
if (a(JSON.stringify(r)) > w)
|
|
42
|
+
throw new Error("bad proxy.runtime.payload");
|
|
43
|
+
if (c(r) > h)
|
|
44
|
+
throw new Error("bad proxy.runtime.payload");
|
|
45
|
+
if (f(r) > B)
|
|
46
|
+
throw new Error("bad proxy.runtime.payload");
|
|
47
|
+
return r;
|
|
48
|
+
}
|
|
49
|
+
function l(r) {
|
|
50
|
+
if (!i(r))
|
|
51
|
+
throw new Error("bad proxy.runtime.serviceWorker");
|
|
52
|
+
d("proxy.runtime.serviceWorker", r, ["scriptUrl", "scope"]);
|
|
53
|
+
const e = String(r.scriptUrl ?? "").trim(), t = String(r.scope ?? "").trim();
|
|
54
|
+
if (e === "")
|
|
55
|
+
throw new Error("bad proxy.runtime.serviceWorker.scriptUrl");
|
|
56
|
+
if (t === "")
|
|
57
|
+
throw new Error("bad proxy.runtime.serviceWorker.scope");
|
|
58
|
+
return Object.freeze({ scriptUrl: e, scope: t });
|
|
59
|
+
}
|
|
60
|
+
function g(r) {
|
|
61
|
+
if (!Array.isArray(r))
|
|
62
|
+
throw new Error("bad proxy.runtime.controllerBridge.allowedOrigins");
|
|
63
|
+
const e = [], t = /* @__PURE__ */ new Set();
|
|
64
|
+
for (const o of r) {
|
|
65
|
+
const n = String(o ?? "").trim();
|
|
66
|
+
n === "" || t.has(n) || (t.add(n), e.push(n));
|
|
67
|
+
}
|
|
68
|
+
if (e.length === 0)
|
|
69
|
+
throw new Error("bad proxy.runtime.controllerBridge.allowedOrigins");
|
|
70
|
+
return Object.freeze(e);
|
|
71
|
+
}
|
|
72
|
+
function O(r) {
|
|
73
|
+
if (!i(r))
|
|
74
|
+
throw new Error("bad proxy.runtime.controllerBridge");
|
|
75
|
+
return d("proxy.runtime.controllerBridge", r, ["allowedOrigins"]), Object.freeze({
|
|
76
|
+
allowedOrigins: g(r.allowedOrigins)
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function k(r) {
|
|
80
|
+
if (!i(r))
|
|
81
|
+
throw new Error("bad proxy.runtime.limits");
|
|
82
|
+
d("proxy.runtime.limits", r, [
|
|
83
|
+
"timeoutMs",
|
|
84
|
+
"maxJsonFrameBytes",
|
|
85
|
+
"maxChunkBytes",
|
|
86
|
+
"maxBodyBytes",
|
|
87
|
+
"maxWsFrameBytes"
|
|
88
|
+
]);
|
|
89
|
+
const e = {};
|
|
90
|
+
return r.timeoutMs !== void 0 && (e.timeoutMs = s("proxy.runtime.limits.timeoutMs", r.timeoutMs)), r.maxJsonFrameBytes !== void 0 && (e.maxJsonFrameBytes = s("proxy.runtime.limits.maxJsonFrameBytes", r.maxJsonFrameBytes)), r.maxChunkBytes !== void 0 && (e.maxChunkBytes = s("proxy.runtime.limits.maxChunkBytes", r.maxChunkBytes)), r.maxBodyBytes !== void 0 && (e.maxBodyBytes = s("proxy.runtime.limits.maxBodyBytes", r.maxBodyBytes)), r.maxWsFrameBytes !== void 0 && (e.maxWsFrameBytes = s("proxy.runtime.limits.maxWsFrameBytes", r.maxWsFrameBytes)), Object.freeze(e);
|
|
91
|
+
}
|
|
92
|
+
function S(r) {
|
|
93
|
+
if (!i(r))
|
|
94
|
+
throw new Error("bad proxy.runtime.preset");
|
|
95
|
+
d("proxy.runtime.preset", r, ["presetId", "snapshot"]);
|
|
96
|
+
const e = String(r.presetId ?? "").trim();
|
|
97
|
+
if (!x.test(e))
|
|
98
|
+
throw new Error("bad proxy.runtime.preset.presetId");
|
|
99
|
+
if (r.snapshot === void 0)
|
|
100
|
+
return Object.freeze({ presetId: e });
|
|
101
|
+
const t = u(r.snapshot);
|
|
102
|
+
if (a(JSON.stringify(t)) > b)
|
|
103
|
+
throw new Error("bad proxy.runtime.preset.snapshot");
|
|
104
|
+
return Object.freeze({ presetId: e, snapshot: t });
|
|
105
|
+
}
|
|
106
|
+
function M(r) {
|
|
107
|
+
const e = E(r);
|
|
108
|
+
d("proxy.runtime", e, [
|
|
109
|
+
"mode",
|
|
110
|
+
"appBasePath",
|
|
111
|
+
"serviceWorker",
|
|
112
|
+
"controllerBridge",
|
|
113
|
+
"preset",
|
|
114
|
+
"limits"
|
|
115
|
+
]);
|
|
116
|
+
const t = e.mode;
|
|
117
|
+
if (t !== "service_worker" && t !== "controller_bridge")
|
|
118
|
+
throw new Error("bad proxy.runtime.mode");
|
|
119
|
+
const o = e.appBasePath === void 0 ? void 0 : String(e.appBasePath ?? "").trim();
|
|
120
|
+
if (e.appBasePath !== void 0 && o === "")
|
|
121
|
+
throw new Error("bad proxy.runtime.appBasePath");
|
|
122
|
+
const n = S(e.preset), m = e.limits === void 0 ? void 0 : k(e.limits);
|
|
123
|
+
if (t === "service_worker") {
|
|
124
|
+
if (e.controllerBridge !== void 0)
|
|
125
|
+
throw new Error("bad proxy.runtime.controllerBridge");
|
|
126
|
+
const p = l(e.serviceWorker);
|
|
127
|
+
return Object.freeze({
|
|
128
|
+
mode: t,
|
|
129
|
+
...o === void 0 ? {} : { appBasePath: o },
|
|
130
|
+
serviceWorker: p,
|
|
131
|
+
preset: n,
|
|
132
|
+
...m === void 0 ? {} : { limits: m }
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
if (e.serviceWorker !== void 0)
|
|
136
|
+
throw new Error("bad proxy.runtime.serviceWorker");
|
|
137
|
+
const y = O(e.controllerBridge);
|
|
138
|
+
return Object.freeze({
|
|
139
|
+
mode: t,
|
|
140
|
+
...o === void 0 ? {} : { appBasePath: o },
|
|
141
|
+
controllerBridge: y,
|
|
142
|
+
preset: n,
|
|
143
|
+
...m === void 0 ? {} : { limits: m }
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
export {
|
|
147
|
+
M as assertProxyRuntimeScopeV1
|
|
148
|
+
};
|
package/dist/index19.js
ADDED
package/dist/index2.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
function l(r) {
|
|
2
|
+
let t = String(r ?? "").replace(/-/g, "+").replace(/_/g, "/");
|
|
3
|
+
for (; t.length % 4 !== 0; ) t += "=";
|
|
4
|
+
return t;
|
|
5
|
+
}
|
|
6
|
+
function o(r) {
|
|
7
|
+
const t = String(r ?? "").trim();
|
|
8
|
+
if (!t) return null;
|
|
9
|
+
const n = String(window.location.hash ?? "").trim(), e = n.startsWith("#") ? n.slice(1) : n;
|
|
10
|
+
if (!e) return null;
|
|
11
|
+
try {
|
|
12
|
+
const a = new URLSearchParams(e);
|
|
13
|
+
return String(a.get(t) ?? "").trim() || null;
|
|
14
|
+
} catch {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function i(r) {
|
|
19
|
+
const t = o(r);
|
|
20
|
+
if (!t) return null;
|
|
21
|
+
try {
|
|
22
|
+
const n = atob(l(t));
|
|
23
|
+
return n ? JSON.parse(n) : null;
|
|
24
|
+
} catch {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function s() {
|
|
29
|
+
try {
|
|
30
|
+
history.replaceState(null, document.title, window.location.pathname + window.location.search);
|
|
31
|
+
} catch {
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
l as base64UrlToBase64,
|
|
36
|
+
s as clearLocationHash,
|
|
37
|
+
i as parseBase64UrlJsonFromHash,
|
|
38
|
+
o as parseHashParam
|
|
39
|
+
};
|
package/dist/index20.js
ADDED
package/dist/index21.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { DEFAULT_MAX_JSON_FRAME_BYTES as r } from "./index9.js";
|
|
2
|
+
import { DEFAULT_MAX_WS_FRAME_BYTES as b, DEFAULT_MAX_BODY_BYTES as m, DEFAULT_MAX_CHUNK_BYTES as o } from "./index20.js";
|
|
3
|
+
const c = /^[a-z][a-z0-9._-]{0,63}$/, _ = Object.freeze({
|
|
4
|
+
max_json_frame_bytes: r,
|
|
5
|
+
max_chunk_bytes: o,
|
|
6
|
+
max_body_bytes: m,
|
|
7
|
+
max_ws_frame_bytes: b
|
|
8
|
+
}), w = Object.freeze({
|
|
9
|
+
v: 1,
|
|
10
|
+
preset_id: "default",
|
|
11
|
+
limits: {
|
|
12
|
+
max_json_frame_bytes: r,
|
|
13
|
+
max_chunk_bytes: o,
|
|
14
|
+
max_body_bytes: m,
|
|
15
|
+
max_ws_frame_bytes: b
|
|
16
|
+
}
|
|
17
|
+
}), p = Object.freeze({
|
|
18
|
+
v: 1,
|
|
19
|
+
preset_id: "codeserver",
|
|
20
|
+
deprecated: !0,
|
|
21
|
+
limits: {
|
|
22
|
+
max_json_frame_bytes: r,
|
|
23
|
+
max_chunk_bytes: o,
|
|
24
|
+
max_body_bytes: m,
|
|
25
|
+
max_ws_frame_bytes: 32 * 1024 * 1024
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
function i(e) {
|
|
29
|
+
return typeof e == "object" && e != null && !Array.isArray(e);
|
|
30
|
+
}
|
|
31
|
+
function y(e, t, d) {
|
|
32
|
+
const x = new Set(d);
|
|
33
|
+
for (const a of Object.keys(t))
|
|
34
|
+
if (!x.has(a))
|
|
35
|
+
throw new Error(`bad ${e}.${a}`);
|
|
36
|
+
}
|
|
37
|
+
function s(e, t) {
|
|
38
|
+
if (typeof t != "number" || !Number.isSafeInteger(t) || t <= 0)
|
|
39
|
+
throw new Error(`${e} must be a positive safe integer`);
|
|
40
|
+
return t;
|
|
41
|
+
}
|
|
42
|
+
function f(e) {
|
|
43
|
+
if (!i(e))
|
|
44
|
+
throw new Error("bad ProxyPresetManifest.limits");
|
|
45
|
+
y("ProxyPresetManifest.limits", e, [
|
|
46
|
+
"max_json_frame_bytes",
|
|
47
|
+
"max_chunk_bytes",
|
|
48
|
+
"max_body_bytes",
|
|
49
|
+
"max_ws_frame_bytes",
|
|
50
|
+
"timeout_ms"
|
|
51
|
+
]);
|
|
52
|
+
const t = {};
|
|
53
|
+
return e.max_json_frame_bytes !== void 0 && (t.max_json_frame_bytes = s("max_json_frame_bytes", e.max_json_frame_bytes)), e.max_chunk_bytes !== void 0 && (t.max_chunk_bytes = s("max_chunk_bytes", e.max_chunk_bytes)), e.max_body_bytes !== void 0 && (t.max_body_bytes = s("max_body_bytes", e.max_body_bytes)), e.max_ws_frame_bytes !== void 0 && (t.max_ws_frame_bytes = s("max_ws_frame_bytes", e.max_ws_frame_bytes)), e.timeout_ms !== void 0 && (t.timeout_ms = s("timeout_ms", e.timeout_ms)), Object.freeze(t);
|
|
54
|
+
}
|
|
55
|
+
function E(e) {
|
|
56
|
+
if (!i(e))
|
|
57
|
+
throw new Error("bad ProxyPresetManifest");
|
|
58
|
+
if (y("ProxyPresetManifest", e, ["v", "preset_id", "deprecated", "limits"]), e.v !== 1)
|
|
59
|
+
throw new Error("bad ProxyPresetManifest.v");
|
|
60
|
+
if (typeof e.preset_id != "string" || !c.test(e.preset_id))
|
|
61
|
+
throw new Error("bad ProxyPresetManifest.preset_id");
|
|
62
|
+
if (e.deprecated !== void 0 && typeof e.deprecated != "boolean")
|
|
63
|
+
throw new Error("bad ProxyPresetManifest.deprecated");
|
|
64
|
+
return Object.freeze({
|
|
65
|
+
v: 1,
|
|
66
|
+
preset_id: e.preset_id,
|
|
67
|
+
...e.deprecated === void 0 ? {} : { deprecated: e.deprecated },
|
|
68
|
+
limits: f(e.limits)
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function n(e) {
|
|
72
|
+
return Object.freeze({
|
|
73
|
+
v: 1,
|
|
74
|
+
preset_id: e.preset_id,
|
|
75
|
+
deprecated: e.deprecated === !0,
|
|
76
|
+
limits: Object.freeze({
|
|
77
|
+
max_json_frame_bytes: e.limits.max_json_frame_bytes ?? _.max_json_frame_bytes,
|
|
78
|
+
max_chunk_bytes: e.limits.max_chunk_bytes ?? _.max_chunk_bytes,
|
|
79
|
+
max_body_bytes: e.limits.max_body_bytes ?? _.max_body_bytes,
|
|
80
|
+
max_ws_frame_bytes: e.limits.max_ws_frame_bytes ?? _.max_ws_frame_bytes,
|
|
81
|
+
...e.limits.timeout_ms === void 0 ? {} : { timeout_ms: e.limits.timeout_ms }
|
|
82
|
+
})
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function P(e) {
|
|
86
|
+
if (e == null)
|
|
87
|
+
return n(w);
|
|
88
|
+
if (i(e) && ("v" in e || "presetId" in e || "limits" in e))
|
|
89
|
+
return n(E(e));
|
|
90
|
+
const t = f(e);
|
|
91
|
+
return Object.freeze({
|
|
92
|
+
v: 1,
|
|
93
|
+
preset_id: "custom",
|
|
94
|
+
deprecated: !1,
|
|
95
|
+
limits: Object.freeze({
|
|
96
|
+
max_json_frame_bytes: t.max_json_frame_bytes ?? _.max_json_frame_bytes,
|
|
97
|
+
max_chunk_bytes: t.max_chunk_bytes ?? _.max_chunk_bytes,
|
|
98
|
+
max_body_bytes: t.max_body_bytes ?? _.max_body_bytes,
|
|
99
|
+
max_ws_frame_bytes: t.max_ws_frame_bytes ?? _.max_ws_frame_bytes,
|
|
100
|
+
...t.timeout_ms === void 0 ? {} : { timeout_ms: t.timeout_ms }
|
|
101
|
+
})
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
export {
|
|
105
|
+
p as CODESERVER_PROXY_PRESET_MANIFEST,
|
|
106
|
+
w as DEFAULT_PROXY_PRESET_MANIFEST,
|
|
107
|
+
E as assertProxyPresetManifest,
|
|
108
|
+
P as resolveProxyPreset
|
|
109
|
+
};
|
package/dist/index22.js
ADDED
package/dist/index23.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
new TextEncoder();
|
package/dist/index24.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
new TextEncoder();
|
package/dist/index25.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
new TextEncoder();
|
package/dist/index3.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
function m(e, n, i) {
|
|
2
|
+
const r = Array.from(new Set((n ?? []).map((t) => String(t ?? "").trim()).filter(Boolean)));
|
|
3
|
+
for (const t of r)
|
|
4
|
+
try {
|
|
5
|
+
e.postMessage(i, t);
|
|
6
|
+
} catch {
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
function d(e) {
|
|
10
|
+
const n = Array.from(new Set((e.expectedOrigins ?? []).map((r) => String(r ?? "").trim()).filter(Boolean)));
|
|
11
|
+
if (n.length === 0) return Promise.reject(new Error("expectedOrigins is required"));
|
|
12
|
+
if (!e.expectedSource) return Promise.reject(new Error("expectedSource is required"));
|
|
13
|
+
const i = Math.max(0, Math.floor(e.timeoutMs ?? 8e3));
|
|
14
|
+
return new Promise((r, t) => {
|
|
15
|
+
const u = window.setTimeout(() => {
|
|
16
|
+
c(), t(new Error("Handshake timeout"));
|
|
17
|
+
}, i), s = (o) => {
|
|
18
|
+
if (!n.includes(o.origin) || o.source !== e.expectedSource) return;
|
|
19
|
+
const a = e.accept(o.data);
|
|
20
|
+
a != null && (c(), r(a));
|
|
21
|
+
}, c = () => {
|
|
22
|
+
window.clearTimeout(u), window.removeEventListener("message", s);
|
|
23
|
+
};
|
|
24
|
+
window.addEventListener("message", s);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
m as postMessageToOrigins,
|
|
29
|
+
d as waitForMessage
|
|
30
|
+
};
|
package/dist/index4.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
function o(t) {
|
|
2
|
+
try {
|
|
3
|
+
return String(sessionStorage.getItem(t) ?? "").trim();
|
|
4
|
+
} catch {
|
|
5
|
+
return "";
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
function r(t, e) {
|
|
9
|
+
try {
|
|
10
|
+
sessionStorage.setItem(t, e);
|
|
11
|
+
} catch {
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function s(t) {
|
|
15
|
+
try {
|
|
16
|
+
sessionStorage.removeItem(t);
|
|
17
|
+
} catch {
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
o as getSessionStorage,
|
|
22
|
+
s as removeSessionStorage,
|
|
23
|
+
r as setSessionStorage
|
|
24
|
+
};
|
package/dist/index5.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { requestConnectArtifact as c, requestEntryConnectArtifact as a } from "./index8.js";
|
|
2
|
+
function o(r, t) {
|
|
3
|
+
const e = String(t ?? r?.traceId ?? "").trim();
|
|
4
|
+
return e ? { ...r ?? {}, traceId: e } : r;
|
|
5
|
+
}
|
|
6
|
+
function n(r, t = "factory") {
|
|
7
|
+
return {
|
|
8
|
+
kind: t,
|
|
9
|
+
getArtifact: r
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function u(r) {
|
|
13
|
+
return n(async () => r, "fixed");
|
|
14
|
+
}
|
|
15
|
+
function l(r) {
|
|
16
|
+
return n(
|
|
17
|
+
async ({ signal: t, traceId: e }) => c({
|
|
18
|
+
...r,
|
|
19
|
+
...t === void 0 ? {} : { signal: t },
|
|
20
|
+
...o(r.correlation, e) === void 0 ? {} : { correlation: o(r.correlation, e) }
|
|
21
|
+
}),
|
|
22
|
+
"controlplane"
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
function f(r) {
|
|
26
|
+
return n(
|
|
27
|
+
async ({ signal: t, traceId: e }) => a({
|
|
28
|
+
...r,
|
|
29
|
+
...t === void 0 ? {} : { signal: t },
|
|
30
|
+
...o(r.correlation, e) === void 0 ? {} : { correlation: o(r.correlation, e) }
|
|
31
|
+
}),
|
|
32
|
+
"entry_controlplane"
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
n as createArtifactSourceFromFactory,
|
|
37
|
+
l as createControlplaneArtifactSource,
|
|
38
|
+
f as createEntryControlplaneArtifactSource,
|
|
39
|
+
u as createFixedArtifactSource
|
|
40
|
+
};
|
package/dist/index6.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createBootstrapScopeResolvers as n } from "./index7.js";
|
|
2
|
+
function t(e) {
|
|
3
|
+
return async (c) => e.getArtifact(c);
|
|
4
|
+
}
|
|
5
|
+
function r(e) {
|
|
6
|
+
return {
|
|
7
|
+
mode: "tunnel",
|
|
8
|
+
getArtifact: t(e.artifactSource),
|
|
9
|
+
...e.observer === void 0 ? {} : { observer: e.observer },
|
|
10
|
+
...e.autoReconnect === void 0 ? {} : { autoReconnect: e.autoReconnect },
|
|
11
|
+
...e.connect === void 0 ? {} : { connect: e.connect }
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function a(e) {
|
|
15
|
+
const c = e.connect;
|
|
16
|
+
return r({
|
|
17
|
+
...e,
|
|
18
|
+
connect: {
|
|
19
|
+
...c ?? {},
|
|
20
|
+
scopeResolvers: n(c?.scopeResolvers)
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function u(e) {
|
|
25
|
+
return {
|
|
26
|
+
mode: "direct",
|
|
27
|
+
getArtifact: t(e.artifactSource),
|
|
28
|
+
...e.observer === void 0 ? {} : { observer: e.observer },
|
|
29
|
+
...e.autoReconnect === void 0 ? {} : { autoReconnect: e.autoReconnect },
|
|
30
|
+
...e.connect === void 0 ? {} : { connect: e.connect }
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
u as createArtifactDirectReconnectConfig,
|
|
35
|
+
r as createArtifactTunnelReconnectConfig,
|
|
36
|
+
a as createProxyRuntimeTunnelReconnectConfig
|
|
37
|
+
};
|
package/dist/index7.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import "./index9.js";
|
|
2
|
+
import "./index10.js";
|
|
3
|
+
import "./index11.js";
|
|
4
|
+
import "./index12.js";
|
|
5
|
+
import "./index13.js";
|
|
6
|
+
import "./index14.js";
|
|
7
|
+
import "./index15.js";
|
|
8
|
+
import "./index16.js";
|
|
9
|
+
import "./index17.js";
|
|
10
|
+
import { assertProxyRuntimeScopeV1 as t } from "./index18.js";
|
|
11
|
+
import "./index19.js";
|
|
12
|
+
const r = "proxy.runtime";
|
|
13
|
+
function e(o) {
|
|
14
|
+
if (o.scope_version !== 1)
|
|
15
|
+
throw new Error(`unsupported ${r} scope_version: ${o.scope_version}`);
|
|
16
|
+
t(o.payload);
|
|
17
|
+
}
|
|
18
|
+
const p = Object.freeze({
|
|
19
|
+
[r]: e
|
|
20
|
+
});
|
|
21
|
+
function f(o) {
|
|
22
|
+
return o ? Object.freeze({
|
|
23
|
+
...o,
|
|
24
|
+
[r]: e
|
|
25
|
+
}) : p;
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
p as FLOWERSEC_BOOTSTRAP_SCOPE_RESOLVERS,
|
|
29
|
+
r as PROXY_RUNTIME_SCOPE_NAME,
|
|
30
|
+
f as createBootstrapScopeResolvers,
|
|
31
|
+
e as validateProxyRuntimeScopeEntry
|
|
32
|
+
};
|
package/dist/index8.js
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { assertConnectArtifact as l } from "./index17.js";
|
|
2
|
+
class d extends Error {
|
|
3
|
+
status;
|
|
4
|
+
code;
|
|
5
|
+
responseBody;
|
|
6
|
+
constructor(e) {
|
|
7
|
+
super(e.message), this.name = "ControlplaneRequestError", this.status = e.status, this.code = String(e.code ?? "").trim(), this.responseBody = e.responseBody;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
const w = "/v1/connect/artifact", y = "/v1/connect/artifact/entry", T = 1 << 20;
|
|
11
|
+
class c extends Error {
|
|
12
|
+
constructor(e) {
|
|
13
|
+
super(`controlplane response exceeded ${e} bytes`), this.name = "ControlplaneResponseTooLargeError";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function m(t) {
|
|
17
|
+
if (t)
|
|
18
|
+
return t;
|
|
19
|
+
if (typeof globalThis.fetch == "function")
|
|
20
|
+
return globalThis.fetch.bind(globalThis);
|
|
21
|
+
throw new Error("global fetch is not available");
|
|
22
|
+
}
|
|
23
|
+
function u(t, e) {
|
|
24
|
+
const r = String(t ?? "").trim();
|
|
25
|
+
return r === "" ? e : `${r.replace(/\/+$/, "")}${e}`;
|
|
26
|
+
}
|
|
27
|
+
function b(t) {
|
|
28
|
+
const e = String(t ?? "").trim();
|
|
29
|
+
if (e === "")
|
|
30
|
+
return "";
|
|
31
|
+
try {
|
|
32
|
+
return JSON.parse(e);
|
|
33
|
+
} catch {
|
|
34
|
+
return e;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function E(t) {
|
|
38
|
+
const e = String(t ?? "").trim();
|
|
39
|
+
if (e === "" || !/^[0-9]+$/.test(e))
|
|
40
|
+
return null;
|
|
41
|
+
const r = Number(e);
|
|
42
|
+
return !Number.isSafeInteger(r) || r < 0 ? null : r;
|
|
43
|
+
}
|
|
44
|
+
async function S(t, e) {
|
|
45
|
+
const r = E(t.headers.get("Content-Length"));
|
|
46
|
+
if (r !== null && r > e)
|
|
47
|
+
throw new c(e);
|
|
48
|
+
if (!t.body)
|
|
49
|
+
return "";
|
|
50
|
+
const n = t.body.getReader(), a = new TextDecoder();
|
|
51
|
+
let o = 0, s = "";
|
|
52
|
+
for (; ; ) {
|
|
53
|
+
const i = await n.read();
|
|
54
|
+
if (i.done)
|
|
55
|
+
break;
|
|
56
|
+
if (o += i.value.byteLength, o > e) {
|
|
57
|
+
try {
|
|
58
|
+
await n.cancel();
|
|
59
|
+
} catch {
|
|
60
|
+
}
|
|
61
|
+
throw new c(e);
|
|
62
|
+
}
|
|
63
|
+
s += a.decode(i.value, { stream: !0 });
|
|
64
|
+
}
|
|
65
|
+
return s += a.decode(), s;
|
|
66
|
+
}
|
|
67
|
+
function C(t, e) {
|
|
68
|
+
let r = `controlplane request failed: ${t}`, n = "";
|
|
69
|
+
if (e && typeof e == "object") {
|
|
70
|
+
const a = e.error;
|
|
71
|
+
if (a && typeof a == "object") {
|
|
72
|
+
const o = String(a.message ?? "").trim();
|
|
73
|
+
o !== "" && (r = o), n = String(a.code ?? "").trim();
|
|
74
|
+
}
|
|
75
|
+
} else typeof e == "string" && e !== "" && (r = e);
|
|
76
|
+
return { code: n, message: r };
|
|
77
|
+
}
|
|
78
|
+
async function f(t, e) {
|
|
79
|
+
const n = await m(e.fetch)(t, {
|
|
80
|
+
...e,
|
|
81
|
+
cache: "no-store"
|
|
82
|
+
});
|
|
83
|
+
let a = "";
|
|
84
|
+
try {
|
|
85
|
+
a = await S(n, T);
|
|
86
|
+
} catch (s) {
|
|
87
|
+
throw s instanceof c && !n.ok ? new d({
|
|
88
|
+
status: n.status,
|
|
89
|
+
message: s.message
|
|
90
|
+
}) : s;
|
|
91
|
+
}
|
|
92
|
+
const o = b(a);
|
|
93
|
+
if (!n.ok) {
|
|
94
|
+
const s = C(n.status, o);
|
|
95
|
+
throw new d({
|
|
96
|
+
status: n.status,
|
|
97
|
+
message: s.message,
|
|
98
|
+
code: s.code,
|
|
99
|
+
responseBody: o
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
if (typeof o == "string")
|
|
103
|
+
throw o === "" ? new Error("Invalid controlplane response: expected JSON body") : new Error("Invalid controlplane response: expected JSON body");
|
|
104
|
+
return o;
|
|
105
|
+
}
|
|
106
|
+
function h(t) {
|
|
107
|
+
const e = {
|
|
108
|
+
endpoint_id: String(t.endpointId ?? "").trim()
|
|
109
|
+
};
|
|
110
|
+
if (e.endpoint_id === "")
|
|
111
|
+
throw new Error("endpointId is required");
|
|
112
|
+
t.payload !== void 0 && (e.payload = { ...t.payload });
|
|
113
|
+
const r = String(t.correlation?.traceId ?? "").trim();
|
|
114
|
+
return r !== "" && (e.correlation = { trace_id: r }), e;
|
|
115
|
+
}
|
|
116
|
+
function p(t) {
|
|
117
|
+
const e = new Headers(t);
|
|
118
|
+
return e.has("Content-Type") || e.set("Content-Type", "application/json"), e;
|
|
119
|
+
}
|
|
120
|
+
async function _(t) {
|
|
121
|
+
const e = await f(u(t.baseUrl, t.path ?? w), {
|
|
122
|
+
...t.fetch === void 0 ? {} : { fetch: t.fetch },
|
|
123
|
+
method: "POST",
|
|
124
|
+
credentials: t.credentials ?? "omit",
|
|
125
|
+
headers: p(t.headers),
|
|
126
|
+
body: JSON.stringify(h(t)),
|
|
127
|
+
...t.signal === void 0 ? {} : { signal: t.signal }
|
|
128
|
+
});
|
|
129
|
+
if (!e?.connect_artifact)
|
|
130
|
+
throw new Error("Invalid controlplane response: missing `connect_artifact`");
|
|
131
|
+
return l(e.connect_artifact);
|
|
132
|
+
}
|
|
133
|
+
async function N(t) {
|
|
134
|
+
const e = String(t.entryTicket ?? "").trim();
|
|
135
|
+
if (e === "")
|
|
136
|
+
throw new Error("entryTicket is required");
|
|
137
|
+
const r = p(t.headers);
|
|
138
|
+
r.set("Authorization", `Bearer ${e}`);
|
|
139
|
+
const n = await f(u(t.baseUrl, t.path ?? y), {
|
|
140
|
+
...t.fetch === void 0 ? {} : { fetch: t.fetch },
|
|
141
|
+
method: "POST",
|
|
142
|
+
credentials: t.credentials ?? "omit",
|
|
143
|
+
headers: r,
|
|
144
|
+
body: JSON.stringify(h(t)),
|
|
145
|
+
...t.signal === void 0 ? {} : { signal: t.signal }
|
|
146
|
+
});
|
|
147
|
+
if (!n?.connect_artifact)
|
|
148
|
+
throw new Error("Invalid controlplane response: missing `connect_artifact`");
|
|
149
|
+
return l(n.connect_artifact);
|
|
150
|
+
}
|
|
151
|
+
export {
|
|
152
|
+
d as ControlplaneRequestError,
|
|
153
|
+
w as DEFAULT_CONNECT_ARTIFACT_PATH,
|
|
154
|
+
y as DEFAULT_ENTRY_CONNECT_ARTIFACT_PATH,
|
|
155
|
+
u as buildControlplaneURL,
|
|
156
|
+
_ as requestConnectArtifact,
|
|
157
|
+
f as requestControlplaneJSON,
|
|
158
|
+
N as requestEntryConnectArtifact
|
|
159
|
+
};
|
package/dist/index9.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type WaitForMessageOptions<T> = Readonly<{
|
|
2
|
+
expectedOrigins: string[];
|
|
3
|
+
expectedSource: Window;
|
|
4
|
+
timeoutMs?: number;
|
|
5
|
+
accept: (data: unknown) => T | null;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function postMessageToOrigins(target: Window, origins: string[], message: unknown): void;
|
|
8
|
+
export declare function waitForMessage<T>(opts: WaitForMessageOptions<T>): Promise<T>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { DirectBrowserReconnectConfig, DirectConnectBrowserOptions, TunnelBrowserReconnectConfig, TunnelConnectBrowserOptions } from '@floegence/flowersec-core/browser';
|
|
2
|
+
import type { ClientObserverLike } from '@floegence/flowersec-core/observability';
|
|
3
|
+
import type { AutoReconnectConfig } from '@floegence/flowersec-core/reconnect';
|
|
4
|
+
import type { ArtifactSource } from './artifactSource';
|
|
5
|
+
type SharedArtifactReconnectOptions = Readonly<{
|
|
6
|
+
artifactSource: ArtifactSource;
|
|
7
|
+
observer?: ClientObserverLike;
|
|
8
|
+
autoReconnect?: AutoReconnectConfig;
|
|
9
|
+
}>;
|
|
10
|
+
type TunnelArtifactConnectOptions = Omit<TunnelConnectBrowserOptions, 'observer' | 'signal'>;
|
|
11
|
+
type DirectArtifactConnectOptions = Omit<DirectConnectBrowserOptions, 'observer' | 'signal'>;
|
|
12
|
+
export type TunnelArtifactReconnectOptions = SharedArtifactReconnectOptions & Readonly<{
|
|
13
|
+
connect?: TunnelArtifactConnectOptions;
|
|
14
|
+
}>;
|
|
15
|
+
export type DirectArtifactReconnectOptions = SharedArtifactReconnectOptions & Readonly<{
|
|
16
|
+
connect?: DirectArtifactConnectOptions;
|
|
17
|
+
}>;
|
|
18
|
+
export declare function createArtifactTunnelReconnectConfig(options: TunnelArtifactReconnectOptions): TunnelBrowserReconnectConfig;
|
|
19
|
+
export declare function createProxyRuntimeTunnelReconnectConfig(options: TunnelArtifactReconnectOptions): TunnelBrowserReconnectConfig;
|
|
20
|
+
export declare function createArtifactDirectReconnectConfig(options: DirectArtifactReconnectOptions): DirectBrowserReconnectConfig;
|
|
21
|
+
export {};
|
package/dist/scope.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const PROXY_RUNTIME_SCOPE_NAME = "proxy.runtime";
|
|
2
|
+
export type ScopeEnvelope = Readonly<{
|
|
3
|
+
scope_version: number;
|
|
4
|
+
payload: unknown;
|
|
5
|
+
}>;
|
|
6
|
+
export type ScopeResolver = (entry: ScopeEnvelope) => void;
|
|
7
|
+
export type ScopeResolverMap = Readonly<Record<string, ScopeResolver>>;
|
|
8
|
+
export declare function validateProxyRuntimeScopeEntry(entry: ScopeEnvelope): void;
|
|
9
|
+
export declare const FLOWERSEC_BOOTSTRAP_SCOPE_RESOLVERS: Readonly<{
|
|
10
|
+
"proxy.runtime": typeof validateProxyRuntimeScopeEntry;
|
|
11
|
+
}>;
|
|
12
|
+
export declare function createBootstrapScopeResolvers(extra?: ScopeResolverMap): ScopeResolverMap;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@floegence/floe-webapp-boot",
|
|
3
|
-
"version": "0.35.
|
|
3
|
+
"version": "0.35.59",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -26,6 +26,9 @@
|
|
|
26
26
|
"typecheck": "tsc --noEmit",
|
|
27
27
|
"clean": "rm -rf dist *.tsbuildinfo"
|
|
28
28
|
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@floegence/flowersec-core": "^0.19.1"
|
|
31
|
+
},
|
|
29
32
|
"devDependencies": {
|
|
30
33
|
"typescript": "^5.9.3",
|
|
31
34
|
"vite": "^7.3.2"
|