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