@floegence/floe-webapp-boot 0.44.0 → 0.44.2
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 +2 -1
- package/dist/acquisition.d.ts +6 -4
- package/dist/acquisition.js +313 -235
- package/dist/artifact-source.d.ts +3 -0
- package/dist/artifact-source.js +95 -60
- package/dist/connection.d.ts +17 -4
- package/dist/connection.js +12 -2
- package/dist/index.d.ts +7 -7
- package/dist/index.js +33 -30
- package/package.json +2 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ArtifactSource, ConnectionSnapshot } from '@floegence/flowersec-core';
|
|
2
|
+
import type { PrivateLoopbackArtifactSourceV1 } from '@floegence/flowersec-core/browser';
|
|
2
3
|
import { ConnectedAcquisition } from './acquisition';
|
|
3
4
|
import { ProxyBootstrapOwner } from './proxy-bootstrap';
|
|
4
5
|
export interface AcquisitionConnectionLifecycle {
|
|
@@ -9,4 +10,4 @@ export type AcquisitionConnectionLifecycleOptions = Readonly<{
|
|
|
9
10
|
proxyBootstrap?: ProxyBootstrapOwner;
|
|
10
11
|
onConnected?: (acquisition: ConnectedAcquisition) => void;
|
|
11
12
|
}>;
|
|
12
|
-
export declare function createAcquisitionConnectionLifecycle(source: ArtifactSource, options?: AcquisitionConnectionLifecycleOptions): AcquisitionConnectionLifecycle;
|
|
13
|
+
export declare function createAcquisitionConnectionLifecycle(source: ArtifactSource | PrivateLoopbackArtifactSourceV1, options?: AcquisitionConnectionLifecycleOptions): AcquisitionConnectionLifecycle;
|
package/dist/acquisition.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ArtifactLease, type ArtifactSource, type ConnectionSnapshot, type JsonValue, type Session } from '@floegence/flowersec-core';
|
|
2
|
-
import type { ConnectionControllerOptions, SessionOptions } from '@floegence/flowersec-core/browser';
|
|
2
|
+
import type { ConnectionControllerOptions, PrivateLoopbackArtifactLeaseV1, PrivateLoopbackArtifactSourceV1, SessionOptions } from '@floegence/flowersec-core/browser';
|
|
3
3
|
import { type ProxyRuntimeScope } from '@floegence/flowersec-core/proxy';
|
|
4
4
|
export type CriticalScopeProjectionV1 = Readonly<{
|
|
5
5
|
scope: 'proxy.runtime';
|
|
@@ -70,6 +70,7 @@ export declare class IsolatedOneShotAcquisition {
|
|
|
70
70
|
static create(): IsolatedOneShotAcquisition;
|
|
71
71
|
static assertAuthentic(value: IsolatedOneShotAcquisition): void;
|
|
72
72
|
}
|
|
73
|
+
type AcquisitionSource = ArtifactSource | PrivateLoopbackArtifactSourceV1;
|
|
73
74
|
export type ConnectedAcquisitionDetails = Readonly<{
|
|
74
75
|
session: Session;
|
|
75
76
|
scope: ProxyRuntimeScope;
|
|
@@ -81,10 +82,11 @@ type MaterializeOptions = Readonly<{
|
|
|
81
82
|
validateSpendBinding: ValidateSpendBinding;
|
|
82
83
|
expectedConsumer: 'trusted' | 'isolated';
|
|
83
84
|
}>;
|
|
84
|
-
export declare function registerAcquisitionSource(source:
|
|
85
|
+
export declare function registerAcquisitionSource(source: AcquisitionSource): void;
|
|
85
86
|
export declare function materializeAcquisitionForSource(source: ArtifactSource, value: unknown, options: MaterializeOptions): Promise<ArtifactLease>;
|
|
86
|
-
export declare function
|
|
87
|
-
export declare function
|
|
87
|
+
export declare function materializePrivateLoopbackAcquisitionForSource(source: PrivateLoopbackArtifactSourceV1, value: unknown, options: MaterializeOptions): Promise<PrivateLoopbackArtifactLeaseV1>;
|
|
88
|
+
export declare function synchronizeAcquisitionSourceSnapshot(source: AcquisitionSource, snapshot: ConnectionSnapshot): ConnectedAcquisition | null;
|
|
89
|
+
export declare function clearAcquisitionSource(source: AcquisitionSource): void;
|
|
88
90
|
export declare function connectedAcquisitionDetails(acquisition: ConnectedAcquisition): ConnectedAcquisitionDetails;
|
|
89
91
|
export type IsolatedHandoffValidationContext = Readonly<{
|
|
90
92
|
envPublicId: string;
|
package/dist/acquisition.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { assertProxyRuntimeScope as
|
|
3
|
-
const j = 32,
|
|
4
|
-
class
|
|
5
|
-
constructor(
|
|
6
|
-
super(`Floe acquisition failed (code=${
|
|
1
|
+
import { createArtifactLease as I, parseArtifact as T } from "@floegence/flowersec-core";
|
|
2
|
+
import { assertProxyRuntimeScope as F } from "@floegence/flowersec-core/proxy";
|
|
3
|
+
const j = 32, C = 16384, P = "#redeven=";
|
|
4
|
+
class r extends Error {
|
|
5
|
+
constructor(t) {
|
|
6
|
+
super(`Floe acquisition failed (code=${t})`), this.code = t, this.name = "AcquisitionError";
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
class h {
|
|
@@ -14,8 +14,8 @@ class h {
|
|
|
14
14
|
static create() {
|
|
15
15
|
return new h();
|
|
16
16
|
}
|
|
17
|
-
static assertAuthentic(
|
|
18
|
-
|
|
17
|
+
static assertAuthentic(t) {
|
|
18
|
+
t.#e;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
class m {
|
|
@@ -26,203 +26,266 @@ class m {
|
|
|
26
26
|
static create() {
|
|
27
27
|
return new m();
|
|
28
28
|
}
|
|
29
|
-
static assertAuthentic(
|
|
30
|
-
|
|
29
|
+
static assertAuthentic(t) {
|
|
30
|
+
t.#e;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
const g = /* @__PURE__ */ new WeakMap(),
|
|
34
|
-
function
|
|
35
|
-
if (g.has(e)) throw new
|
|
33
|
+
const g = /* @__PURE__ */ new WeakMap(), A = /* @__PURE__ */ new WeakMap(), E = /* @__PURE__ */ new WeakMap(), z = /* @__PURE__ */ new Set();
|
|
34
|
+
function Y(e) {
|
|
35
|
+
if (g.has(e)) throw new r("duplicate_acquisition_source");
|
|
36
36
|
g.set(e, { pending: [] });
|
|
37
37
|
}
|
|
38
|
-
async function
|
|
39
|
-
const
|
|
40
|
-
if (
|
|
41
|
-
const
|
|
42
|
-
return
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
38
|
+
async function K(e, t, i) {
|
|
39
|
+
const n = g.get(e);
|
|
40
|
+
if (n === void 0) throw new r("invalid_acquisition_source");
|
|
41
|
+
const o = await S(t, i, T);
|
|
42
|
+
return O(
|
|
43
|
+
o,
|
|
44
|
+
I,
|
|
45
|
+
i.commitSpend,
|
|
46
|
+
(c) => {
|
|
47
|
+
n.pending.push(c);
|
|
48
|
+
},
|
|
49
|
+
(c) => {
|
|
50
|
+
n.pending = n.pending.filter((a) => a !== c);
|
|
51
|
+
}
|
|
52
|
+
);
|
|
47
53
|
}
|
|
48
|
-
function
|
|
49
|
-
const
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
54
|
+
async function Q(e, t, i) {
|
|
55
|
+
const n = g.get(e);
|
|
56
|
+
if (n === void 0) throw new r("invalid_acquisition_source");
|
|
57
|
+
const o = await import("@floegence/flowersec-core/browser"), c = await S(
|
|
58
|
+
t,
|
|
59
|
+
i,
|
|
60
|
+
o.parsePrivateLoopbackArtifactV1
|
|
61
|
+
);
|
|
62
|
+
return O(
|
|
63
|
+
c,
|
|
64
|
+
o.createPrivateLoopbackArtifactLeaseV1,
|
|
65
|
+
i.commitSpend,
|
|
66
|
+
(a) => {
|
|
67
|
+
n.pending.push(a);
|
|
68
|
+
},
|
|
69
|
+
(a) => {
|
|
70
|
+
n.pending = n.pending.filter((d) => d !== a);
|
|
71
|
+
}
|
|
72
|
+
);
|
|
66
73
|
}
|
|
67
|
-
function
|
|
74
|
+
function ee(e, t) {
|
|
68
75
|
const i = g.get(e);
|
|
69
|
-
|
|
76
|
+
if (i === void 0) return null;
|
|
77
|
+
if (t.state !== "connected" || t.currentSession === void 0)
|
|
78
|
+
return (t.state === "idle" || t.state === "waiting" || t.state === "failed" || t.state === "closed") && (i.pending = [], i.connected = void 0, i.connectedSession = void 0), null;
|
|
79
|
+
if (i.connected !== void 0 && i.connectedSession === t.currentSession)
|
|
80
|
+
return i.connected;
|
|
81
|
+
const n = i.pending.filter((a) => a.committed);
|
|
82
|
+
if (n.length !== 1 || i.pending.length !== 1)
|
|
83
|
+
throw i.pending = [], new r("connected_acquisition_mismatch");
|
|
84
|
+
const o = n[0];
|
|
85
|
+
if (o === void 0) throw new r("connected_acquisition_mismatch");
|
|
86
|
+
const c = h.create();
|
|
87
|
+
return A.set(
|
|
88
|
+
c,
|
|
89
|
+
Object.freeze({
|
|
90
|
+
session: t.currentSession,
|
|
91
|
+
scope: o.scope,
|
|
92
|
+
bindingIdentity: o.bindingIdentity,
|
|
93
|
+
attempt: t.attempt
|
|
94
|
+
})
|
|
95
|
+
), i.pending = [], i.connected = c, i.connectedSession = t.currentSession, c;
|
|
70
96
|
}
|
|
71
|
-
function
|
|
97
|
+
function te(e) {
|
|
98
|
+
const t = g.get(e);
|
|
99
|
+
t !== void 0 && (t.pending = [], t.connected = void 0, t.connectedSession = void 0);
|
|
100
|
+
}
|
|
101
|
+
function ie(e) {
|
|
72
102
|
h.assertAuthentic(e);
|
|
73
|
-
const
|
|
74
|
-
if (
|
|
75
|
-
return
|
|
103
|
+
const t = A.get(e);
|
|
104
|
+
if (t === void 0) throw new r("invalid_connected_acquisition");
|
|
105
|
+
return t;
|
|
76
106
|
}
|
|
77
|
-
async function
|
|
78
|
-
const
|
|
79
|
-
let
|
|
107
|
+
async function ne(e) {
|
|
108
|
+
const t = e.rawHandoff, i = typeof t != "string" || W(`${P}${t}`) > C;
|
|
109
|
+
let n = !1;
|
|
80
110
|
try {
|
|
81
|
-
|
|
111
|
+
n = e.clearSensitiveLocation() === !0;
|
|
82
112
|
} catch {
|
|
83
|
-
|
|
113
|
+
n = !1;
|
|
84
114
|
}
|
|
85
|
-
if (!
|
|
86
|
-
throw e.navigateToLauncher(), new
|
|
87
|
-
if (
|
|
88
|
-
const
|
|
89
|
-
if (
|
|
90
|
-
|
|
115
|
+
if (!n)
|
|
116
|
+
throw e.navigateToLauncher(), new r("isolated_location_clear_failed");
|
|
117
|
+
if (i) throw new r("isolated_handoff_too_large");
|
|
118
|
+
const o = y(t, "invalid_isolated_handoff"), c = await J(o);
|
|
119
|
+
if (z.has(c))
|
|
120
|
+
throw new r("isolated_handoff_consumed");
|
|
121
|
+
z.add(c);
|
|
91
122
|
let a;
|
|
92
123
|
try {
|
|
93
|
-
a = JSON.parse(new TextDecoder("utf-8", { fatal: !0 }).decode(
|
|
124
|
+
a = JSON.parse(new TextDecoder("utf-8", { fatal: !0 }).decode(o));
|
|
94
125
|
} catch {
|
|
95
|
-
throw new
|
|
126
|
+
throw new r("invalid_isolated_handoff");
|
|
96
127
|
}
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
128
|
+
const d = V(a, e.validationContext), p = await S(
|
|
129
|
+
d.acquisition,
|
|
130
|
+
{
|
|
131
|
+
commitSpend: e.commitSpend,
|
|
132
|
+
expectedConsumer: "isolated",
|
|
133
|
+
validateSpendBinding: (s) => (N(d, s, e.validationContext), e.validationContext.validateTargetBinding(s.targetBinding), `${s.artifactDigestB64u}.${s.projectionDigestB64u}`)
|
|
134
|
+
},
|
|
135
|
+
T
|
|
136
|
+
);
|
|
137
|
+
if (p.scope.appBasePath !== d.app_path)
|
|
138
|
+
throw new r("isolated_app_path_mismatch");
|
|
139
|
+
if (p.scope.mode === "controller_bridge") {
|
|
140
|
+
const s = p.scope.controllerBridge.allowedOrigins;
|
|
141
|
+
if (s.length !== 1 || s[0] !== d.app_origin)
|
|
142
|
+
throw new r("isolated_allowed_origins_mismatch");
|
|
107
143
|
}
|
|
108
|
-
let
|
|
109
|
-
const l =
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
144
|
+
let u;
|
|
145
|
+
const l = O(
|
|
146
|
+
p,
|
|
147
|
+
I,
|
|
148
|
+
e.commitSpend,
|
|
149
|
+
(s) => {
|
|
150
|
+
u = s;
|
|
151
|
+
},
|
|
152
|
+
() => {
|
|
153
|
+
}
|
|
154
|
+
);
|
|
155
|
+
if (u === void 0 || u.lease !== l)
|
|
156
|
+
throw new r("isolated_materialization_failed");
|
|
157
|
+
const _ = m.create();
|
|
158
|
+
return E.set(_, { pending: u, state: "ready" }), _;
|
|
116
159
|
}
|
|
117
|
-
async function
|
|
160
|
+
async function re(e, t = {}) {
|
|
118
161
|
m.assertAuthentic(e);
|
|
119
|
-
const
|
|
120
|
-
if (
|
|
121
|
-
|
|
162
|
+
const i = E.get(e);
|
|
163
|
+
if (i === void 0 || i.state !== "ready")
|
|
164
|
+
throw new r("isolated_acquisition_consumed");
|
|
165
|
+
i.state = "connecting";
|
|
122
166
|
try {
|
|
123
|
-
const { connect:
|
|
124
|
-
if (!
|
|
125
|
-
throw await
|
|
126
|
-
}), new
|
|
127
|
-
const
|
|
128
|
-
return
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
167
|
+
const { connect: n } = await import("@floegence/flowersec-core/browser"), o = await n(i.pending.lease, t);
|
|
168
|
+
if (!i.pending.committed)
|
|
169
|
+
throw await o.close().catch(() => {
|
|
170
|
+
}), new r("isolated_spend_not_committed");
|
|
171
|
+
const c = h.create();
|
|
172
|
+
return A.set(
|
|
173
|
+
c,
|
|
174
|
+
Object.freeze({
|
|
175
|
+
session: o,
|
|
176
|
+
scope: i.pending.scope,
|
|
177
|
+
bindingIdentity: i.pending.bindingIdentity,
|
|
178
|
+
attempt: 1
|
|
179
|
+
})
|
|
180
|
+
), i.state = "consumed", c;
|
|
181
|
+
} catch (n) {
|
|
182
|
+
throw i.state = "consumed", n;
|
|
136
183
|
}
|
|
137
184
|
}
|
|
138
|
-
async function
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
185
|
+
async function S(e, t, i) {
|
|
186
|
+
const n = w(
|
|
187
|
+
e,
|
|
188
|
+
["v", "connect_artifact", "critical_scope_projection_json", "spend_scope"],
|
|
189
|
+
"invalid_acquisition_envelope"
|
|
190
|
+
);
|
|
191
|
+
if (n.v !== 1 || typeof n.connect_artifact != "string" || n.connect_artifact.length === 0 || typeof n.critical_scope_projection_json != "string" || n.critical_scope_projection_json.length === 0)
|
|
192
|
+
throw new r("invalid_acquisition_envelope");
|
|
193
|
+
const o = k(n.spend_scope, t.expectedConsumer), c = new TextEncoder().encode(n.connect_artifact), a = new TextEncoder().encode(n.critical_scope_projection_json);
|
|
194
|
+
await D(c, o.artifact_digest_b64u, "artifact_digest_mismatch"), await D(
|
|
195
|
+
a,
|
|
196
|
+
o.projection_digest_b64u,
|
|
197
|
+
"projection_digest_mismatch"
|
|
198
|
+
);
|
|
199
|
+
let d;
|
|
145
200
|
try {
|
|
146
|
-
|
|
201
|
+
d = JSON.parse(n.critical_scope_projection_json);
|
|
147
202
|
} catch {
|
|
148
|
-
throw new
|
|
203
|
+
throw new r("invalid_critical_scope_projection");
|
|
149
204
|
}
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
205
|
+
const p = w(
|
|
206
|
+
d,
|
|
207
|
+
["scope", "scope_version", "critical", "payload"],
|
|
208
|
+
"invalid_critical_scope_projection"
|
|
209
|
+
);
|
|
210
|
+
if (p.scope !== "proxy.runtime" || p.scope_version !== 2 || p.critical !== !0)
|
|
211
|
+
throw new r("invalid_critical_scope_projection");
|
|
153
212
|
let u;
|
|
154
213
|
try {
|
|
155
|
-
u =
|
|
214
|
+
u = F(p.payload);
|
|
156
215
|
} catch {
|
|
157
|
-
throw new
|
|
216
|
+
throw new r("invalid_proxy_runtime_scope");
|
|
158
217
|
}
|
|
159
|
-
let
|
|
218
|
+
let l;
|
|
160
219
|
try {
|
|
161
|
-
|
|
220
|
+
l = i(n.connect_artifact);
|
|
162
221
|
} catch {
|
|
163
|
-
throw new
|
|
222
|
+
throw new r("invalid_connect_artifact");
|
|
164
223
|
}
|
|
165
|
-
const
|
|
166
|
-
if (
|
|
167
|
-
throw new
|
|
224
|
+
const _ = U(o), s = t.validateSpendBinding(_);
|
|
225
|
+
if (s !== void 0 && (typeof s != "string" || s.trim() === "" || s !== s.trim()))
|
|
226
|
+
throw new r("invalid_spend_binding_identity");
|
|
168
227
|
return Object.freeze({
|
|
169
|
-
artifact:
|
|
228
|
+
artifact: l,
|
|
170
229
|
scope: u,
|
|
171
|
-
binding:
|
|
172
|
-
bindingIdentity:
|
|
173
|
-
receipt:
|
|
230
|
+
binding: _,
|
|
231
|
+
bindingIdentity: s ?? `${_.artifactDigestB64u}.${_.projectionDigestB64u}`,
|
|
232
|
+
receipt: o.receipt
|
|
174
233
|
});
|
|
175
234
|
}
|
|
176
|
-
function
|
|
177
|
-
const c = e.artifact,
|
|
178
|
-
let u = e.receipt,
|
|
179
|
-
const
|
|
180
|
-
const
|
|
181
|
-
if (u = void 0,
|
|
182
|
-
const
|
|
183
|
-
...
|
|
184
|
-
attemptId:
|
|
185
|
-
receipt:
|
|
235
|
+
function O(e, t, i, n, o) {
|
|
236
|
+
const c = e.artifact, a = e.scope, d = e.binding, p = e.bindingIdentity;
|
|
237
|
+
let u = e.receipt, l;
|
|
238
|
+
const _ = t(c, async (s) => {
|
|
239
|
+
const q = u;
|
|
240
|
+
if (u = void 0, q === void 0) throw new r("spend_binding_consumed");
|
|
241
|
+
const R = Object.freeze({
|
|
242
|
+
...d,
|
|
243
|
+
attemptId: Z(),
|
|
244
|
+
receipt: q
|
|
186
245
|
});
|
|
187
246
|
try {
|
|
188
|
-
await i(
|
|
189
|
-
} catch (
|
|
190
|
-
throw
|
|
247
|
+
await i(R, s), l.committed = !0;
|
|
248
|
+
} catch ($) {
|
|
249
|
+
throw o(l), $;
|
|
191
250
|
}
|
|
192
251
|
});
|
|
193
|
-
return
|
|
252
|
+
return l = { lease: _, scope: a, bindingIdentity: p, committed: !1 }, n(l), _;
|
|
194
253
|
}
|
|
195
|
-
function
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
254
|
+
function k(e, t) {
|
|
255
|
+
const i = w(
|
|
256
|
+
e,
|
|
257
|
+
[
|
|
258
|
+
"v",
|
|
259
|
+
"receipt",
|
|
260
|
+
"artifact_digest_b64u",
|
|
261
|
+
"projection_digest_b64u",
|
|
262
|
+
"launcher_origin",
|
|
263
|
+
"runtime_origin",
|
|
264
|
+
"app_origin",
|
|
265
|
+
"consumer",
|
|
266
|
+
"target_binding",
|
|
267
|
+
"expires_at"
|
|
268
|
+
],
|
|
269
|
+
"invalid_spend_scope"
|
|
270
|
+
);
|
|
271
|
+
if (i.v !== 1 || typeof i.receipt != "string" || !H(i.receipt) || typeof i.artifact_digest_b64u != "string" || !x(i.artifact_digest_b64u) || typeof i.projection_digest_b64u != "string" || !x(i.projection_digest_b64u) || i.consumer !== t || typeof i.expires_at != "string" || !M(i.expires_at) || !b(i.target_binding))
|
|
272
|
+
throw new r("invalid_spend_scope");
|
|
273
|
+
const n = f(i.launcher_origin), o = f(i.runtime_origin), c = f(i.app_origin);
|
|
274
|
+
if (Date.parse(i.expires_at) <= Date.now()) throw new r("expired_spend_scope");
|
|
212
275
|
return Object.freeze({
|
|
213
276
|
v: 1,
|
|
214
|
-
receipt:
|
|
215
|
-
artifact_digest_b64u:
|
|
216
|
-
projection_digest_b64u:
|
|
217
|
-
launcher_origin:
|
|
218
|
-
runtime_origin:
|
|
219
|
-
app_origin:
|
|
220
|
-
consumer:
|
|
221
|
-
target_binding: v(
|
|
222
|
-
expires_at:
|
|
277
|
+
receipt: i.receipt,
|
|
278
|
+
artifact_digest_b64u: i.artifact_digest_b64u,
|
|
279
|
+
projection_digest_b64u: i.projection_digest_b64u,
|
|
280
|
+
launcher_origin: n,
|
|
281
|
+
runtime_origin: o,
|
|
282
|
+
app_origin: c,
|
|
283
|
+
consumer: t,
|
|
284
|
+
target_binding: v(i.target_binding),
|
|
285
|
+
expires_at: i.expires_at
|
|
223
286
|
});
|
|
224
287
|
}
|
|
225
|
-
function
|
|
288
|
+
function U(e) {
|
|
226
289
|
return Object.freeze({
|
|
227
290
|
artifactDigestB64u: e.artifact_digest_b64u,
|
|
228
291
|
projectionDigestB64u: e.projection_digest_b64u,
|
|
@@ -234,56 +297,62 @@ function N(e) {
|
|
|
234
297
|
expiresAt: e.expires_at
|
|
235
298
|
});
|
|
236
299
|
}
|
|
237
|
-
function
|
|
238
|
-
const
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
300
|
+
function V(e, t) {
|
|
301
|
+
const i = w(
|
|
302
|
+
e,
|
|
303
|
+
[
|
|
304
|
+
"v",
|
|
305
|
+
"env_public_id",
|
|
306
|
+
"floe_app",
|
|
307
|
+
"code_space_id",
|
|
308
|
+
"app_path",
|
|
309
|
+
"launcher_kind",
|
|
310
|
+
"launcher_id",
|
|
311
|
+
"launcher_origin",
|
|
312
|
+
"runtime_origin",
|
|
313
|
+
"app_origin",
|
|
314
|
+
"acquisition"
|
|
315
|
+
],
|
|
316
|
+
"invalid_isolated_handoff"
|
|
317
|
+
);
|
|
318
|
+
if (i.v !== 6 || i.env_public_id !== t.envPublicId || i.floe_app !== t.floeApp || i.code_space_id !== t.codeSpaceId || i.app_path !== t.appPath || i.launcher_kind !== t.launcherKind || i.launcher_id !== t.launcherId || i.launcher_origin !== t.launcherOrigin || i.runtime_origin !== t.runtimeOrigin || i.app_origin !== t.appOrigin)
|
|
319
|
+
throw new r("isolated_context_mismatch");
|
|
320
|
+
return f(i.launcher_origin), f(i.runtime_origin), f(i.app_origin), i;
|
|
254
321
|
}
|
|
255
|
-
function
|
|
256
|
-
if (
|
|
257
|
-
throw new
|
|
322
|
+
function N(e, t, i) {
|
|
323
|
+
if (t.consumer !== "isolated" || t.launcherOrigin !== e.launcher_origin || t.runtimeOrigin !== e.runtime_origin || t.appOrigin !== e.app_origin || e.runtime_origin !== i.runtimeOrigin || e.app_origin !== i.appOrigin)
|
|
324
|
+
throw new r("isolated_spend_binding_mismatch");
|
|
258
325
|
}
|
|
259
|
-
function w(e,
|
|
260
|
-
if (e === null || typeof e != "object" || Array.isArray(e))
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
326
|
+
function w(e, t, i) {
|
|
327
|
+
if (e === null || typeof e != "object" || Array.isArray(e))
|
|
328
|
+
throw new r(i);
|
|
329
|
+
const n = e, o = new Set(t), c = Object.keys(n);
|
|
330
|
+
if (c.length !== t.length || c.some((a) => !o.has(a)))
|
|
331
|
+
throw new r(i);
|
|
332
|
+
return n;
|
|
264
333
|
}
|
|
265
334
|
function f(e) {
|
|
266
|
-
if (typeof e != "string") throw new
|
|
267
|
-
let
|
|
335
|
+
if (typeof e != "string") throw new r("invalid_spend_scope");
|
|
336
|
+
let t;
|
|
268
337
|
try {
|
|
269
|
-
|
|
338
|
+
t = new URL(e);
|
|
270
339
|
} catch {
|
|
271
|
-
throw new
|
|
340
|
+
throw new r("invalid_spend_scope");
|
|
272
341
|
}
|
|
273
|
-
if (
|
|
274
|
-
throw new
|
|
342
|
+
if (t.protocol !== "https:" && t.protocol !== "http:" || t.origin !== e || t.username !== "" || t.password !== "")
|
|
343
|
+
throw new r("invalid_spend_scope");
|
|
275
344
|
return e;
|
|
276
345
|
}
|
|
277
346
|
function H(e) {
|
|
278
|
-
const
|
|
279
|
-
if (
|
|
347
|
+
const t = /^r1\.([A-Za-z0-9_-]{1,64})\.([A-Za-z0-9_-]+)$/u.exec(e);
|
|
348
|
+
if (t === null || t[2] === void 0) return !1;
|
|
280
349
|
try {
|
|
281
|
-
return y(
|
|
350
|
+
return y(t[2], "invalid_spend_scope").length === j;
|
|
282
351
|
} catch {
|
|
283
352
|
return !1;
|
|
284
353
|
}
|
|
285
354
|
}
|
|
286
|
-
function
|
|
355
|
+
function x(e) {
|
|
287
356
|
try {
|
|
288
357
|
return y(e, "invalid_spend_scope").length === j;
|
|
289
358
|
} catch {
|
|
@@ -293,69 +362,78 @@ function B(e) {
|
|
|
293
362
|
function M(e) {
|
|
294
363
|
return /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/u.test(e) ? Number.isFinite(Date.parse(e)) : !1;
|
|
295
364
|
}
|
|
296
|
-
function b(e,
|
|
297
|
-
return
|
|
365
|
+
function b(e, t = 0) {
|
|
366
|
+
return t > 32 ? !1 : e === null || typeof e == "string" || typeof e == "boolean" ? !0 : typeof e == "number" ? Number.isFinite(e) : Array.isArray(e) ? e.every((i) => b(i, t + 1)) : typeof e != "object" ? !1 : Object.values(e).every(
|
|
367
|
+
(i) => b(i, t + 1)
|
|
368
|
+
);
|
|
298
369
|
}
|
|
299
370
|
function v(e) {
|
|
300
371
|
if (Array.isArray(e)) {
|
|
301
|
-
for (const
|
|
372
|
+
for (const t of e) v(t);
|
|
302
373
|
return Object.freeze(e);
|
|
303
374
|
}
|
|
304
375
|
if (e !== null && typeof e == "object") {
|
|
305
|
-
for (const
|
|
376
|
+
for (const t of Object.values(e)) v(t);
|
|
306
377
|
return Object.freeze(e);
|
|
307
378
|
}
|
|
308
379
|
return e;
|
|
309
380
|
}
|
|
310
|
-
async function
|
|
311
|
-
const
|
|
312
|
-
if (
|
|
313
|
-
let
|
|
314
|
-
for (let a = 0; a <
|
|
315
|
-
|
|
381
|
+
async function D(e, t, i) {
|
|
382
|
+
const n = await L(e), o = y(t, i);
|
|
383
|
+
if (n.length !== o.length) throw new r(i);
|
|
384
|
+
let c = 0;
|
|
385
|
+
for (let a = 0; a < n.length; a += 1)
|
|
386
|
+
c |= n[a] ^ o[a];
|
|
387
|
+
if (c !== 0) throw new r(i);
|
|
316
388
|
}
|
|
317
|
-
async function
|
|
318
|
-
return
|
|
389
|
+
async function J(e) {
|
|
390
|
+
return B(await L(e));
|
|
319
391
|
}
|
|
320
|
-
async function
|
|
321
|
-
if (globalThis.crypto?.subtle === void 0)
|
|
322
|
-
|
|
323
|
-
|
|
392
|
+
async function L(e) {
|
|
393
|
+
if (globalThis.crypto?.subtle === void 0)
|
|
394
|
+
throw new r("acquisition_crypto_unavailable");
|
|
395
|
+
const t = e.buffer.slice(
|
|
396
|
+
e.byteOffset,
|
|
397
|
+
e.byteOffset + e.byteLength
|
|
398
|
+
), i = await globalThis.crypto.subtle.digest("SHA-256", t);
|
|
399
|
+
return new Uint8Array(i);
|
|
324
400
|
}
|
|
325
|
-
function
|
|
326
|
-
if (globalThis.crypto?.getRandomValues === void 0)
|
|
327
|
-
|
|
401
|
+
function Z() {
|
|
402
|
+
if (globalThis.crypto?.getRandomValues === void 0)
|
|
403
|
+
throw new r("acquisition_entropy_unavailable");
|
|
404
|
+
return B(globalThis.crypto.getRandomValues(new Uint8Array(j)));
|
|
328
405
|
}
|
|
329
|
-
function y(e,
|
|
330
|
-
if (!/^[A-Za-z0-9_-]*$/u.test(e) || e.length % 4 === 1) throw new
|
|
331
|
-
const
|
|
332
|
-
let
|
|
406
|
+
function y(e, t) {
|
|
407
|
+
if (!/^[A-Za-z0-9_-]*$/u.test(e) || e.length % 4 === 1) throw new r(t);
|
|
408
|
+
const i = e.replace(/-/gu, "+").replace(/_/gu, "/") + "=".repeat((4 - e.length % 4) % 4);
|
|
409
|
+
let n;
|
|
333
410
|
try {
|
|
334
|
-
|
|
411
|
+
n = atob(i);
|
|
335
412
|
} catch {
|
|
336
|
-
throw new
|
|
413
|
+
throw new r(t);
|
|
337
414
|
}
|
|
338
|
-
const
|
|
339
|
-
if (
|
|
340
|
-
return
|
|
415
|
+
const o = Uint8Array.from(n, (c) => c.charCodeAt(0));
|
|
416
|
+
if (B(o) !== e) throw new r(t);
|
|
417
|
+
return o;
|
|
341
418
|
}
|
|
342
|
-
function
|
|
343
|
-
let
|
|
344
|
-
for (const
|
|
345
|
-
return btoa(
|
|
419
|
+
function B(e) {
|
|
420
|
+
let t = "";
|
|
421
|
+
for (const i of e) t += String.fromCharCode(i);
|
|
422
|
+
return btoa(t).replace(/\+/gu, "-").replace(/\//gu, "_").replace(/=+$/u, "");
|
|
346
423
|
}
|
|
347
|
-
function
|
|
424
|
+
function W(e) {
|
|
348
425
|
return new TextEncoder().encode(e).length;
|
|
349
426
|
}
|
|
350
427
|
export {
|
|
351
|
-
|
|
428
|
+
r as AcquisitionError,
|
|
352
429
|
h as ConnectedAcquisition,
|
|
353
430
|
m as IsolatedOneShotAcquisition,
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
431
|
+
te as clearAcquisitionSource,
|
|
432
|
+
re as connectIsolatedOneShot,
|
|
433
|
+
ie as connectedAcquisitionDetails,
|
|
434
|
+
K as materializeAcquisitionForSource,
|
|
435
|
+
ne as materializeIsolatedOneShot,
|
|
436
|
+
Q as materializePrivateLoopbackAcquisitionForSource,
|
|
437
|
+
Y as registerAcquisitionSource,
|
|
438
|
+
ee as synchronizeAcquisitionSourceSnapshot
|
|
361
439
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ArtifactSource, JsonObject, RetryDisposition } from '@floegence/flowersec-core';
|
|
2
|
+
import type { PrivateLoopbackArtifactSourceV1 } from '@floegence/flowersec-core/browser';
|
|
2
3
|
import { type CommitSpend, type ValidateSpendBinding } from './acquisition';
|
|
3
4
|
export type ControlplaneArtifactSourceOptions = Readonly<{
|
|
4
5
|
baseUrl: string;
|
|
@@ -14,6 +15,7 @@ export type ControlplaneArtifactSourceOptions = Readonly<{
|
|
|
14
15
|
validateSpendBinding: ValidateSpendBinding;
|
|
15
16
|
retryableBusinessCodes?: readonly string[];
|
|
16
17
|
}>;
|
|
18
|
+
export type PrivateLoopbackControlplaneArtifactSourceOptions = Omit<ControlplaneArtifactSourceOptions, 'allowLoopbackHTTP' | 'entryTicket'>;
|
|
17
19
|
export declare class ControlplaneRequestError extends Error {
|
|
18
20
|
readonly status: number;
|
|
19
21
|
readonly code: string;
|
|
@@ -32,3 +34,4 @@ export type ClassifiedControlplaneFailure = Readonly<{
|
|
|
32
34
|
}>;
|
|
33
35
|
export declare function classifyControlplaneFailure(input: ControlplaneFailureInput): ClassifiedControlplaneFailure;
|
|
34
36
|
export declare function createControlplaneArtifactSource(options: ControlplaneArtifactSourceOptions): ArtifactSource;
|
|
37
|
+
export declare function createPrivateLoopbackControlplaneArtifactSource(options: PrivateLoopbackControlplaneArtifactSourceOptions): PrivateLoopbackArtifactSourceV1;
|
package/dist/artifact-source.js
CHANGED
|
@@ -1,56 +1,71 @@
|
|
|
1
|
-
import { registerAcquisitionSource as b, materializeAcquisitionForSource as
|
|
1
|
+
import { registerAcquisitionSource as b, AcquisitionError as p, materializeAcquisitionForSource as w, materializePrivateLoopbackAcquisitionForSource as k } from "./acquisition.js";
|
|
2
2
|
const y = /^[a-z][a-z0-9_]{0,63}$/u;
|
|
3
|
-
class
|
|
4
|
-
constructor(
|
|
5
|
-
super(`Floe controlplane request failed (code=${
|
|
3
|
+
class a extends Error {
|
|
4
|
+
constructor(r, t) {
|
|
5
|
+
super(`Floe controlplane request failed (code=${t})`), this.status = r, this.code = t, this.name = "ControlplaneRequestError";
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
-
function
|
|
9
|
-
const
|
|
10
|
-
return
|
|
8
|
+
function S(e) {
|
|
9
|
+
const r = e.toLowerCase();
|
|
10
|
+
return r === "localhost" || r === "::1" || r === "127.0.0.1" || r.startsWith("127.");
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
let
|
|
12
|
+
function _(e, r) {
|
|
13
|
+
let t;
|
|
14
14
|
try {
|
|
15
|
-
|
|
15
|
+
t = new URL(e);
|
|
16
16
|
} catch {
|
|
17
|
-
throw new
|
|
17
|
+
throw new a(0, "transport_policy_denied");
|
|
18
18
|
}
|
|
19
|
-
if (
|
|
20
|
-
throw new
|
|
21
|
-
return
|
|
19
|
+
if (t.protocol !== "https:" && !(r && t.protocol === "http:" && S(t.hostname)))
|
|
20
|
+
throw new a(0, "transport_policy_denied");
|
|
21
|
+
return t.pathname = t.pathname.replace(/\/+$/u, ""), t;
|
|
22
22
|
}
|
|
23
|
-
function j(e,
|
|
24
|
-
const
|
|
25
|
-
return new URL(`${e.pathname}${
|
|
23
|
+
function j(e, r) {
|
|
24
|
+
const t = r === void 0 ? "/v1/connect/artifact" : "/v1/connect/artifact/entry";
|
|
25
|
+
return new URL(`${e.pathname}${t}`, e).toString();
|
|
26
26
|
}
|
|
27
27
|
function v(e) {
|
|
28
28
|
if (!y.test(e.code))
|
|
29
|
-
return Object.freeze({
|
|
29
|
+
return Object.freeze({
|
|
30
|
+
code: "invalid_error_code",
|
|
31
|
+
disposition: Object.freeze({ kind: "terminal" })
|
|
32
|
+
});
|
|
30
33
|
if (new Set(e.retryableBusinessCodes ?? []).has(e.code))
|
|
31
34
|
return Object.freeze({ code: e.code, disposition: Object.freeze({ kind: "retryable" }) });
|
|
32
35
|
if (e.status === 429) {
|
|
33
|
-
const
|
|
36
|
+
const t = g(e.retryAfter, e.nowUnixMilliseconds ?? Date.now());
|
|
34
37
|
return Object.freeze({
|
|
35
38
|
code: e.code,
|
|
36
|
-
disposition: Object.freeze(
|
|
39
|
+
disposition: Object.freeze(t === void 0 ? { kind: "retryable" } : { kind: "retry_after", notBeforeUnixMilliseconds: t })
|
|
37
40
|
});
|
|
38
41
|
}
|
|
39
42
|
return e.status === 408 || e.status === 425 || e.status >= 500 ? Object.freeze({ code: e.code, disposition: Object.freeze({ kind: "retryable" }) }) : Object.freeze({ code: e.code, disposition: Object.freeze({ kind: "terminal" }) });
|
|
40
43
|
}
|
|
41
|
-
function
|
|
44
|
+
function B(e) {
|
|
45
|
+
const r = m(e, w);
|
|
46
|
+
return b(r), r;
|
|
47
|
+
}
|
|
48
|
+
function L(e) {
|
|
49
|
+
const r = z(e.baseUrl), t = m(
|
|
50
|
+
{ ...e, baseUrl: r.origin, allowLoopbackHTTP: !0 },
|
|
51
|
+
k
|
|
52
|
+
);
|
|
53
|
+
return b(t), t;
|
|
54
|
+
}
|
|
55
|
+
function m(e, r) {
|
|
42
56
|
if (typeof e.commitSpend != "function") throw new TypeError("commitSpend is required");
|
|
43
|
-
if (typeof e.validateSpendBinding != "function")
|
|
57
|
+
if (typeof e.validateSpendBinding != "function")
|
|
58
|
+
throw new TypeError("validateSpendBinding is required");
|
|
44
59
|
const t = e.fetch ?? globalThis.fetch;
|
|
45
60
|
if (typeof t != "function") throw new TypeError("fetch is required");
|
|
46
|
-
const
|
|
47
|
-
acquire: async ({ signal:
|
|
61
|
+
const n = _(e.baseUrl, e.allowLoopbackHTTP === !0), s = j(n, e.entryTicket), i = {
|
|
62
|
+
acquire: async ({ signal: d }) => {
|
|
48
63
|
try {
|
|
49
64
|
const o = {
|
|
50
65
|
endpoint_id: e.endpointId,
|
|
51
66
|
...e.payload === void 0 ? {} : { payload: e.payload },
|
|
52
67
|
...e.entryTicket === void 0 && e.correlation !== void 0 ? { correlation: { trace_id: e.correlation.traceId } } : {}
|
|
53
|
-
},
|
|
68
|
+
}, c = await t(s, {
|
|
54
69
|
method: "POST",
|
|
55
70
|
headers: {
|
|
56
71
|
accept: "application/json",
|
|
@@ -60,39 +75,39 @@ function _(e) {
|
|
|
60
75
|
body: JSON.stringify(o),
|
|
61
76
|
credentials: "omit",
|
|
62
77
|
redirect: "error",
|
|
63
|
-
signal:
|
|
78
|
+
signal: d
|
|
64
79
|
});
|
|
65
|
-
if (!
|
|
66
|
-
const
|
|
80
|
+
if (!c.ok) {
|
|
81
|
+
const l = await E(c);
|
|
67
82
|
return { kind: "failure", ...v({
|
|
68
|
-
status:
|
|
69
|
-
code:
|
|
70
|
-
retryAfter:
|
|
83
|
+
status: c.status,
|
|
84
|
+
code: l,
|
|
85
|
+
retryAfter: c.headers.get("retry-after"),
|
|
71
86
|
retryableBusinessCodes: e.retryableBusinessCodes
|
|
72
87
|
}) };
|
|
73
88
|
}
|
|
74
|
-
let
|
|
89
|
+
let u;
|
|
75
90
|
try {
|
|
76
|
-
|
|
91
|
+
u = await c.json();
|
|
77
92
|
} catch {
|
|
78
|
-
return
|
|
93
|
+
return f("invalid_controlplane_response");
|
|
79
94
|
}
|
|
80
|
-
const
|
|
95
|
+
const h = await r(i, u, {
|
|
81
96
|
commitSpend: e.commitSpend,
|
|
82
|
-
validateSpendBinding: (
|
|
97
|
+
validateSpendBinding: (l) => {
|
|
83
98
|
try {
|
|
84
|
-
return e.validateSpendBinding(
|
|
99
|
+
return e.validateSpendBinding(l);
|
|
85
100
|
} catch {
|
|
86
|
-
throw new
|
|
101
|
+
throw new p("invalid_spend_binding");
|
|
87
102
|
}
|
|
88
103
|
},
|
|
89
104
|
expectedConsumer: "trusted"
|
|
90
105
|
});
|
|
91
|
-
return Object.freeze({ kind: "lease", lease:
|
|
106
|
+
return Object.freeze({ kind: "lease", lease: h });
|
|
92
107
|
} catch (o) {
|
|
93
|
-
if (
|
|
108
|
+
if (d.aborted) throw d.reason ?? new DOMException("Aborted", "AbortError");
|
|
94
109
|
if (o instanceof DOMException && o.name === "AbortError") throw o;
|
|
95
|
-
return o instanceof
|
|
110
|
+
return o instanceof p || o instanceof a ? f(o.code) : Object.freeze({
|
|
96
111
|
kind: "failure",
|
|
97
112
|
code: "network_error",
|
|
98
113
|
disposition: Object.freeze({ kind: "retryable" })
|
|
@@ -100,15 +115,34 @@ function _(e) {
|
|
|
100
115
|
}
|
|
101
116
|
}
|
|
102
117
|
};
|
|
103
|
-
return
|
|
118
|
+
return i;
|
|
119
|
+
}
|
|
120
|
+
function z(e) {
|
|
121
|
+
let r;
|
|
122
|
+
try {
|
|
123
|
+
r = new URL(e);
|
|
124
|
+
} catch {
|
|
125
|
+
throw new a(0, "transport_policy_denied");
|
|
126
|
+
}
|
|
127
|
+
if (e !== r.origin || r.protocol !== "http:" || r.username !== "" || r.password !== "" || !O(r.port) || !A(r.hostname))
|
|
128
|
+
throw new a(0, "transport_policy_denied");
|
|
129
|
+
return r;
|
|
130
|
+
}
|
|
131
|
+
function O(e) {
|
|
132
|
+
if (!/^[1-9][0-9]*$/u.test(e)) return !1;
|
|
133
|
+
const r = Number(e);
|
|
134
|
+
return Number.isSafeInteger(r) && r >= 1024 && r <= 65535;
|
|
135
|
+
}
|
|
136
|
+
function A(e) {
|
|
137
|
+
return e === "127.0.0.1" || e === "[::1]";
|
|
104
138
|
}
|
|
105
|
-
async function
|
|
139
|
+
async function E(e) {
|
|
106
140
|
try {
|
|
107
|
-
const
|
|
108
|
-
if (
|
|
109
|
-
const
|
|
110
|
-
if (
|
|
111
|
-
const n =
|
|
141
|
+
const r = await e.json();
|
|
142
|
+
if (r !== null && typeof r == "object" && !Array.isArray(r)) {
|
|
143
|
+
const t = r.error;
|
|
144
|
+
if (t !== null && typeof t == "object" && !Array.isArray(t)) {
|
|
145
|
+
const n = t.code;
|
|
112
146
|
if (typeof n == "string") return n;
|
|
113
147
|
}
|
|
114
148
|
}
|
|
@@ -116,19 +150,19 @@ async function z(e) {
|
|
|
116
150
|
}
|
|
117
151
|
return "request_failed";
|
|
118
152
|
}
|
|
119
|
-
function
|
|
153
|
+
function g(e, r) {
|
|
120
154
|
if (e == null) return;
|
|
121
|
-
const
|
|
122
|
-
if (/^\d+$/u.test(
|
|
123
|
-
const
|
|
124
|
-
if (!Number.isSafeInteger(
|
|
125
|
-
const i =
|
|
126
|
-
return Number.isSafeInteger(i) && i >
|
|
155
|
+
const t = e.trim();
|
|
156
|
+
if (/^\d+$/u.test(t)) {
|
|
157
|
+
const s = Number(t);
|
|
158
|
+
if (!Number.isSafeInteger(s)) return;
|
|
159
|
+
const i = r + s * 1e3;
|
|
160
|
+
return Number.isSafeInteger(i) && i > r ? i : void 0;
|
|
127
161
|
}
|
|
128
|
-
const n = Date.parse(
|
|
129
|
-
return Number.isSafeInteger(n) && n >
|
|
162
|
+
const n = Date.parse(t);
|
|
163
|
+
return Number.isSafeInteger(n) && n > r ? n : void 0;
|
|
130
164
|
}
|
|
131
|
-
function
|
|
165
|
+
function f(e) {
|
|
132
166
|
return Object.freeze({
|
|
133
167
|
kind: "failure",
|
|
134
168
|
code: y.test(e) ? e : "invalid_error_code",
|
|
@@ -136,7 +170,8 @@ function d(e) {
|
|
|
136
170
|
});
|
|
137
171
|
}
|
|
138
172
|
export {
|
|
139
|
-
|
|
173
|
+
a as ControlplaneRequestError,
|
|
140
174
|
v as classifyControlplaneFailure,
|
|
141
|
-
|
|
175
|
+
B as createControlplaneArtifactSource,
|
|
176
|
+
L as createPrivateLoopbackControlplaneArtifactSource
|
|
142
177
|
};
|
package/dist/connection.d.ts
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import type { ArtifactSource } from '@floegence/flowersec-core';
|
|
2
|
-
import type { ConnectionControllerOptions } from '@floegence/flowersec-core/browser';
|
|
2
|
+
import type { ConnectionControllerOptions, PrivateLoopbackArtifactSourceV1, PrivateLoopbackConnectionControllerOptionsV1 } from '@floegence/flowersec-core/browser';
|
|
3
3
|
import { type AcquisitionConnectionLifecycle } from './acquisition-lifecycle';
|
|
4
4
|
import type { ConnectedAcquisition } from './acquisition';
|
|
5
5
|
import type { ProxyBootstrapOwner } from './proxy-bootstrap';
|
|
6
|
-
|
|
7
|
-
source: ArtifactSource;
|
|
8
|
-
controller?: ConnectionControllerOptions;
|
|
6
|
+
type SharedFlowersecConnectionConfig = Readonly<{
|
|
9
7
|
lifecycle: AcquisitionConnectionLifecycle;
|
|
10
8
|
}>;
|
|
9
|
+
export type FlowersecConnectionConfig = SharedFlowersecConnectionConfig & (Readonly<{
|
|
10
|
+
source: ArtifactSource;
|
|
11
|
+
controller?: ConnectionControllerOptions;
|
|
12
|
+
privateLoopback?: never;
|
|
13
|
+
}> | Readonly<{
|
|
14
|
+
source: PrivateLoopbackArtifactSourceV1;
|
|
15
|
+
privateLoopback: PrivateLoopbackConnectionControllerOptionsV1;
|
|
16
|
+
controller?: never;
|
|
17
|
+
}>);
|
|
11
18
|
type AcquisitionConnectionOptions = Readonly<{
|
|
12
19
|
source: ArtifactSource;
|
|
13
20
|
controller?: ConnectionControllerOptions;
|
|
@@ -15,10 +22,16 @@ type AcquisitionConnectionOptions = Readonly<{
|
|
|
15
22
|
}>;
|
|
16
23
|
export type TunnelArtifactConnectionOptions = AcquisitionConnectionOptions;
|
|
17
24
|
export type DirectArtifactConnectionOptions = AcquisitionConnectionOptions;
|
|
25
|
+
export type PrivateLoopbackDirectConnectionOptions = Readonly<{
|
|
26
|
+
source: PrivateLoopbackArtifactSourceV1;
|
|
27
|
+
privateLoopback: PrivateLoopbackConnectionControllerOptionsV1;
|
|
28
|
+
onConnected?: (acquisition: ConnectedAcquisition) => void;
|
|
29
|
+
}>;
|
|
18
30
|
export type ProxyRuntimeTunnelConnectionOptions = AcquisitionConnectionOptions & Readonly<{
|
|
19
31
|
proxyBootstrap: ProxyBootstrapOwner;
|
|
20
32
|
}>;
|
|
21
33
|
export declare function createArtifactTunnelConnectionConfig(options: TunnelArtifactConnectionOptions): FlowersecConnectionConfig;
|
|
22
34
|
export declare function createProxyRuntimeTunnelConnectionConfig(options: ProxyRuntimeTunnelConnectionOptions): FlowersecConnectionConfig;
|
|
23
35
|
export declare function createArtifactDirectConnectionConfig(options: DirectArtifactConnectionOptions): FlowersecConnectionConfig;
|
|
36
|
+
export declare function createPrivateLoopbackDirectConnectionConfig(options: PrivateLoopbackDirectConnectionOptions): FlowersecConnectionConfig;
|
|
24
37
|
export {};
|
package/dist/connection.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createAcquisitionConnectionLifecycle as r } from "./acquisition-lifecycle.js";
|
|
2
|
-
function
|
|
2
|
+
function t(e) {
|
|
3
3
|
return n(e);
|
|
4
4
|
}
|
|
5
5
|
function i(e) {
|
|
@@ -8,6 +8,15 @@ function i(e) {
|
|
|
8
8
|
function u(e) {
|
|
9
9
|
return n(e);
|
|
10
10
|
}
|
|
11
|
+
function f(e) {
|
|
12
|
+
return Object.freeze({
|
|
13
|
+
source: e.source,
|
|
14
|
+
privateLoopback: e.privateLoopback,
|
|
15
|
+
lifecycle: r(e.source, {
|
|
16
|
+
...e.onConnected === void 0 ? {} : { onConnected: e.onConnected }
|
|
17
|
+
})
|
|
18
|
+
});
|
|
19
|
+
}
|
|
11
20
|
function n(e, c) {
|
|
12
21
|
return Object.freeze({
|
|
13
22
|
source: e.source,
|
|
@@ -20,6 +29,7 @@ function n(e, c) {
|
|
|
20
29
|
}
|
|
21
30
|
export {
|
|
22
31
|
u as createArtifactDirectConnectionConfig,
|
|
23
|
-
|
|
32
|
+
t as createArtifactTunnelConnectionConfig,
|
|
33
|
+
f as createPrivateLoopbackDirectConnectionConfig,
|
|
24
34
|
i as createProxyRuntimeTunnelConnectionConfig
|
|
25
35
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
export { clearLocationHash, parseHashParam
|
|
1
|
+
export { clearLocationHash, parseHashParam } from './hash';
|
|
2
2
|
export type { WaitForMessageOptions } from './messaging';
|
|
3
3
|
export { postMessageToOrigins, waitForMessage } from './messaging';
|
|
4
4
|
export { getSessionStorage, removeSessionStorage, setSessionStorage } from './storage';
|
|
5
5
|
export type { ArtifactSource, ArtifactSourceResult } from '@floegence/flowersec-core';
|
|
6
|
-
export { createControlplaneArtifactSource, ControlplaneRequestError } from './artifact-source';
|
|
6
|
+
export { createControlplaneArtifactSource, createPrivateLoopbackControlplaneArtifactSource, ControlplaneRequestError, } from './artifact-source';
|
|
7
7
|
export { classifyControlplaneFailure } from './artifact-source';
|
|
8
|
-
export type { ClassifiedControlplaneFailure, ControlplaneArtifactSourceOptions, ControlplaneFailureInput, } from './artifact-source';
|
|
9
|
-
export { AcquisitionError, clearAcquisitionSource, connectIsolatedOneShot, ConnectedAcquisition, IsolatedOneShotAcquisition, materializeIsolatedOneShot, synchronizeAcquisitionSourceSnapshot, } from './acquisition';
|
|
8
|
+
export type { ClassifiedControlplaneFailure, ControlplaneArtifactSourceOptions, ControlplaneFailureInput, PrivateLoopbackControlplaneArtifactSourceOptions, } from './artifact-source';
|
|
9
|
+
export { AcquisitionError, clearAcquisitionSource, connectIsolatedOneShot, ConnectedAcquisition, IsolatedOneShotAcquisition, materializePrivateLoopbackAcquisitionForSource, materializeIsolatedOneShot, synchronizeAcquisitionSourceSnapshot, } from './acquisition';
|
|
10
10
|
export type { CommitSpend, CriticalScopeProjectionV1, IsolatedHandoffValidationContext, MaterializeIsolatedOneShotOptions, RuntimeBootInitPayloadV6, SerializedAcquisitionEnvelopeV1, SpendBindingView, SpendCommitRequest, SpendScopeV1, ValidateSpendBinding, } from './acquisition';
|
|
11
11
|
export { createAcquisitionConnectionLifecycle } from './acquisition-lifecycle';
|
|
12
12
|
export type { AcquisitionConnectionLifecycle, AcquisitionConnectionLifecycleOptions, } from './acquisition-lifecycle';
|
|
13
|
-
export type { DirectArtifactConnectionOptions, FlowersecConnectionConfig, ProxyRuntimeTunnelConnectionOptions, TunnelArtifactConnectionOptions, } from './connection';
|
|
14
|
-
export { createArtifactDirectConnectionConfig, createArtifactTunnelConnectionConfig, createProxyRuntimeTunnelConnectionConfig, } from './connection';
|
|
13
|
+
export type { DirectArtifactConnectionOptions, FlowersecConnectionConfig, PrivateLoopbackDirectConnectionOptions, ProxyRuntimeTunnelConnectionOptions, TunnelArtifactConnectionOptions, } from './connection';
|
|
14
|
+
export { createArtifactDirectConnectionConfig, createArtifactTunnelConnectionConfig, createPrivateLoopbackDirectConnectionConfig, createProxyRuntimeTunnelConnectionConfig, } from './connection';
|
|
15
15
|
export type { FetchServerSentEventsOptions, ServerSentEvent, ServerSentEventStreamErrorCode, } from './server-sent-events';
|
|
16
|
-
export { fetchServerSentEvents, ServerSentEventStreamError
|
|
16
|
+
export { fetchServerSentEvents, ServerSentEventStreamError } from './server-sent-events';
|
|
17
17
|
export { closeProxyBootstrap, createProxyBootstrapOwner, ProxyBootstrapOwner, synchronizeProxyBootstrap, } from './proxy-bootstrap';
|
|
18
18
|
export type { ControllerBridgeProxyBootstrapContext, ProxyBootstrapBinding, ProxyBootstrapOwnerOptions, ProxyBootstrapSnapshot, ServiceWorkerProxyBootstrapContext, } from './proxy-bootstrap';
|
|
19
19
|
export type { ScopeEnvelope, ScopeResolver, ScopeResolverMap, ValidatedCriticalScopeProjection, } from './scope';
|
package/dist/index.js
CHANGED
|
@@ -1,43 +1,46 @@
|
|
|
1
1
|
import { clearLocationHash as r, parseHashParam as t } from "./hash.js";
|
|
2
2
|
import { postMessageToOrigins as i, waitForMessage as a } from "./messaging.js";
|
|
3
|
-
import { getSessionStorage as
|
|
4
|
-
import { ControlplaneRequestError as f, classifyControlplaneFailure as
|
|
5
|
-
import { AcquisitionError as
|
|
6
|
-
import { createAcquisitionConnectionLifecycle as
|
|
7
|
-
import { createArtifactDirectConnectionConfig as
|
|
8
|
-
import { ServerSentEventStreamError as
|
|
9
|
-
import { ProxyBootstrapOwner as
|
|
10
|
-
import { FLOWERSEC_BOOTSTRAP_SCOPE_RESOLVERS as N, PROXY_RUNTIME_SCOPE_NAME as
|
|
3
|
+
import { getSessionStorage as s, removeSessionStorage as S, setSessionStorage as p } from "./storage.js";
|
|
4
|
+
import { ControlplaneRequestError as f, classifyControlplaneFailure as u, createControlplaneArtifactSource as m, createPrivateLoopbackControlplaneArtifactSource as C } from "./artifact-source.js";
|
|
5
|
+
import { AcquisitionError as E, ConnectedAcquisition as P, IsolatedOneShotAcquisition as A, clearAcquisitionSource as O, connectIsolatedOneShot as g, materializeIsolatedOneShot as y, materializePrivateLoopbackAcquisitionForSource as v, synchronizeAcquisitionSourceSnapshot as R } from "./acquisition.js";
|
|
6
|
+
import { createAcquisitionConnectionLifecycle as q } from "./acquisition-lifecycle.js";
|
|
7
|
+
import { createArtifactDirectConnectionConfig as B, createArtifactTunnelConnectionConfig as T, createPrivateLoopbackDirectConnectionConfig as _, createProxyRuntimeTunnelConnectionConfig as d } from "./connection.js";
|
|
8
|
+
import { ServerSentEventStreamError as F, fetchServerSentEvents as I } from "./server-sent-events.js";
|
|
9
|
+
import { ProxyBootstrapOwner as b, closeProxyBootstrap as k, createProxyBootstrapOwner as w, synchronizeProxyBootstrap as D } from "./proxy-bootstrap.js";
|
|
10
|
+
import { FLOWERSEC_BOOTSTRAP_SCOPE_RESOLVERS as N, PROXY_RUNTIME_SCOPE_NAME as U, createBootstrapScopeResolvers as V, validateProxyRuntimeScopeEntry as W } from "./scope.js";
|
|
11
11
|
export {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
E as AcquisitionError,
|
|
13
|
+
P as ConnectedAcquisition,
|
|
14
14
|
f as ControlplaneRequestError,
|
|
15
15
|
N as FLOWERSEC_BOOTSTRAP_SCOPE_RESOLVERS,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
A as IsolatedOneShotAcquisition,
|
|
17
|
+
U as PROXY_RUNTIME_SCOPE_NAME,
|
|
18
|
+
b as ProxyBootstrapOwner,
|
|
19
|
+
F as ServerSentEventStreamError,
|
|
20
|
+
u as classifyControlplaneFailure,
|
|
21
|
+
O as clearAcquisitionSource,
|
|
22
22
|
r as clearLocationHash,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
k as closeProxyBootstrap,
|
|
24
|
+
g as connectIsolatedOneShot,
|
|
25
|
+
q as createAcquisitionConnectionLifecycle,
|
|
26
|
+
B as createArtifactDirectConnectionConfig,
|
|
27
|
+
T as createArtifactTunnelConnectionConfig,
|
|
28
|
+
V as createBootstrapScopeResolvers,
|
|
29
|
+
m as createControlplaneArtifactSource,
|
|
30
|
+
C as createPrivateLoopbackControlplaneArtifactSource,
|
|
31
|
+
_ as createPrivateLoopbackDirectConnectionConfig,
|
|
32
|
+
w as createProxyBootstrapOwner,
|
|
33
|
+
d as createProxyRuntimeTunnelConnectionConfig,
|
|
32
34
|
I as fetchServerSentEvents,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
s as getSessionStorage,
|
|
36
|
+
y as materializeIsolatedOneShot,
|
|
37
|
+
v as materializePrivateLoopbackAcquisitionForSource,
|
|
35
38
|
t as parseHashParam,
|
|
36
39
|
i as postMessageToOrigins,
|
|
37
40
|
S as removeSessionStorage,
|
|
38
41
|
p as setSessionStorage,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
R as synchronizeAcquisitionSourceSnapshot,
|
|
43
|
+
D as synchronizeProxyBootstrap,
|
|
44
|
+
W as validateProxyRuntimeScopeEntry,
|
|
42
45
|
a as waitForMessage
|
|
43
46
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@floegence/floe-webapp-boot",
|
|
3
|
-
"version": "0.44.
|
|
3
|
+
"version": "0.44.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"clean": "rm -rf dist *.tsbuildinfo"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@floegence/flowersec-core": "3.
|
|
38
|
+
"@floegence/flowersec-core": "3.2.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"typescript": "^5.9.3",
|