@floegence/floe-webapp-boot 0.41.0 → 0.41.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.js +18 -18
- package/dist/artifact-source.js +33 -27
- package/package.json +2 -2
package/dist/acquisition.js
CHANGED
|
@@ -94,25 +94,25 @@ async function te(e) {
|
|
|
94
94
|
} catch {
|
|
95
95
|
throw new n("invalid_isolated_handoff");
|
|
96
96
|
}
|
|
97
|
-
const _ = P(a, e.validationContext),
|
|
97
|
+
const _ = P(a, e.validationContext), u = await x(_.acquisition, {
|
|
98
98
|
commitSpend: e.commitSpend,
|
|
99
99
|
expectedConsumer: "isolated",
|
|
100
100
|
validateSpendBinding: (d) => (k(_, d, e.validationContext), e.validationContext.validateTargetBinding(d.targetBinding), `${d.artifactDigestB64u}.${d.projectionDigestB64u}`)
|
|
101
101
|
});
|
|
102
|
-
if (
|
|
103
|
-
if (
|
|
104
|
-
const d =
|
|
102
|
+
if (u.scope.appBasePath !== _.app_path) throw new n("isolated_app_path_mismatch");
|
|
103
|
+
if (u.scope.mode === "controller_bridge") {
|
|
104
|
+
const d = u.scope.controllerBridge.allowedOrigins;
|
|
105
105
|
if (d.length !== 1 || d[0] !== _.app_origin)
|
|
106
106
|
throw new n("isolated_allowed_origins_mismatch");
|
|
107
107
|
}
|
|
108
108
|
let s;
|
|
109
|
-
const l = D(
|
|
109
|
+
const l = D(u, e.commitSpend, (d) => {
|
|
110
110
|
s = d;
|
|
111
111
|
}, () => {
|
|
112
112
|
});
|
|
113
113
|
if (s === void 0 || s.lease !== l) throw new n("isolated_materialization_failed");
|
|
114
|
-
const
|
|
115
|
-
return z.set(
|
|
114
|
+
const p = m.create();
|
|
115
|
+
return z.set(p, { pending: s, state: "ready" }), p;
|
|
116
116
|
}
|
|
117
117
|
async function ie(e, i = {}) {
|
|
118
118
|
m.assertAuthentic(e);
|
|
@@ -150,9 +150,9 @@ async function x(e, i) {
|
|
|
150
150
|
const _ = w(a, ["scope", "scope_version", "critical", "payload"], "invalid_critical_scope_projection");
|
|
151
151
|
if (_.scope !== "proxy.runtime" || _.scope_version !== 2 || _.critical !== !0)
|
|
152
152
|
throw new n("invalid_critical_scope_projection");
|
|
153
|
-
let
|
|
153
|
+
let u;
|
|
154
154
|
try {
|
|
155
|
-
|
|
155
|
+
u = C(_.payload);
|
|
156
156
|
} catch {
|
|
157
157
|
throw new n("invalid_proxy_runtime_scope");
|
|
158
158
|
}
|
|
@@ -162,30 +162,30 @@ async function x(e, i) {
|
|
|
162
162
|
} catch {
|
|
163
163
|
throw new n("invalid_connect_artifact");
|
|
164
164
|
}
|
|
165
|
-
const l = N(r),
|
|
166
|
-
if (
|
|
165
|
+
const l = N(r), p = i.validateSpendBinding(l);
|
|
166
|
+
if (p !== void 0 && (typeof p != "string" || p.trim() === "" || p !== p.trim()))
|
|
167
167
|
throw new n("invalid_spend_binding_identity");
|
|
168
168
|
return Object.freeze({
|
|
169
169
|
artifact: s,
|
|
170
|
-
scope:
|
|
170
|
+
scope: u,
|
|
171
171
|
binding: l,
|
|
172
|
-
bindingIdentity:
|
|
172
|
+
bindingIdentity: p ?? `${l.artifactDigestB64u}.${l.projectionDigestB64u}`,
|
|
173
173
|
receipt: r.receipt
|
|
174
174
|
});
|
|
175
175
|
}
|
|
176
176
|
function D(e, i, t, r) {
|
|
177
177
|
const c = e.artifact, o = e.scope, a = e.binding, _ = e.bindingIdentity;
|
|
178
|
-
let
|
|
179
|
-
const l = $(c, async (
|
|
180
|
-
const d =
|
|
181
|
-
if (
|
|
178
|
+
let u = e.receipt, s;
|
|
179
|
+
const l = $(c, async (p) => {
|
|
180
|
+
const d = u;
|
|
181
|
+
if (u = void 0, d === void 0) throw new n("spend_binding_consumed");
|
|
182
182
|
const T = Object.freeze({
|
|
183
183
|
...a,
|
|
184
184
|
attemptId: J(),
|
|
185
185
|
receipt: d
|
|
186
186
|
});
|
|
187
187
|
try {
|
|
188
|
-
await i(T,
|
|
188
|
+
await i(T, p), s.committed = !0;
|
|
189
189
|
} catch (E) {
|
|
190
190
|
throw r(s), E;
|
|
191
191
|
}
|
package/dist/artifact-source.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { registerAcquisitionSource as
|
|
2
|
-
const
|
|
3
|
-
class
|
|
1
|
+
import { registerAcquisitionSource as b, materializeAcquisitionForSource as h, AcquisitionError as u } from "./acquisition.js";
|
|
2
|
+
const y = /^[a-z][a-z0-9_]{0,63}$/u;
|
|
3
|
+
class f extends Error {
|
|
4
4
|
constructor(t, r) {
|
|
5
5
|
super(`Floe controlplane request failed (code=${r})`), this.status = t, this.code = r, this.name = "ControlplaneRequestError";
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
-
function
|
|
8
|
+
function m(e) {
|
|
9
9
|
const t = e.toLowerCase();
|
|
10
10
|
return t === "localhost" || t === "::1" || t === "127.0.0.1" || t.startsWith("127.");
|
|
11
11
|
}
|
|
@@ -14,23 +14,23 @@ function w(e, t) {
|
|
|
14
14
|
try {
|
|
15
15
|
r = new URL(e);
|
|
16
16
|
} catch {
|
|
17
|
-
throw new
|
|
17
|
+
throw new f(0, "transport_policy_denied");
|
|
18
18
|
}
|
|
19
|
-
if (r.protocol !== "https:" && !(t && r.protocol === "http:" &&
|
|
20
|
-
throw new
|
|
19
|
+
if (r.protocol !== "https:" && !(t && r.protocol === "http:" && m(r.hostname)))
|
|
20
|
+
throw new f(0, "transport_policy_denied");
|
|
21
21
|
return r.pathname = r.pathname.replace(/\/+$/u, ""), r;
|
|
22
22
|
}
|
|
23
23
|
function j(e, t) {
|
|
24
24
|
const r = t === void 0 ? "/v1/connect/artifact" : "/v1/connect/artifact/entry";
|
|
25
25
|
return new URL(`${e.pathname}${r}`, e).toString();
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
if (!
|
|
27
|
+
function v(e) {
|
|
28
|
+
if (!y.test(e.code))
|
|
29
29
|
return Object.freeze({ code: "invalid_error_code", disposition: Object.freeze({ kind: "terminal" }) });
|
|
30
30
|
if (new Set(e.retryableBusinessCodes ?? []).has(e.code))
|
|
31
31
|
return Object.freeze({ code: e.code, disposition: Object.freeze({ kind: "retryable" }) });
|
|
32
32
|
if (e.status === 429) {
|
|
33
|
-
const r =
|
|
33
|
+
const r = O(e.retryAfter, e.nowUnixMilliseconds ?? Date.now());
|
|
34
34
|
return Object.freeze({
|
|
35
35
|
code: e.code,
|
|
36
36
|
disposition: Object.freeze(r === void 0 ? { kind: "retryable" } : { kind: "retry_after", notBeforeUnixMilliseconds: r })
|
|
@@ -63,30 +63,36 @@ function _(e) {
|
|
|
63
63
|
signal: i
|
|
64
64
|
});
|
|
65
65
|
if (!a.ok) {
|
|
66
|
-
const
|
|
67
|
-
return { kind: "failure", ...
|
|
66
|
+
const s = await z(a);
|
|
67
|
+
return { kind: "failure", ...v({
|
|
68
68
|
status: a.status,
|
|
69
|
-
code:
|
|
69
|
+
code: s,
|
|
70
70
|
retryAfter: a.headers.get("retry-after"),
|
|
71
71
|
retryableBusinessCodes: e.retryableBusinessCodes
|
|
72
72
|
}) };
|
|
73
73
|
}
|
|
74
|
-
let
|
|
74
|
+
let l;
|
|
75
75
|
try {
|
|
76
|
-
|
|
76
|
+
l = await a.json();
|
|
77
77
|
} catch {
|
|
78
|
-
return
|
|
78
|
+
return d("invalid_controlplane_response");
|
|
79
79
|
}
|
|
80
|
-
const
|
|
80
|
+
const p = await h(c, l, {
|
|
81
81
|
commitSpend: e.commitSpend,
|
|
82
|
-
validateSpendBinding:
|
|
82
|
+
validateSpendBinding: (s) => {
|
|
83
|
+
try {
|
|
84
|
+
return e.validateSpendBinding(s);
|
|
85
|
+
} catch {
|
|
86
|
+
throw new u("invalid_spend_binding");
|
|
87
|
+
}
|
|
88
|
+
},
|
|
83
89
|
expectedConsumer: "trusted"
|
|
84
90
|
});
|
|
85
|
-
return Object.freeze({ kind: "lease", lease:
|
|
91
|
+
return Object.freeze({ kind: "lease", lease: p });
|
|
86
92
|
} catch (o) {
|
|
87
93
|
if (i.aborted) throw i.reason ?? new DOMException("Aborted", "AbortError");
|
|
88
94
|
if (o instanceof DOMException && o.name === "AbortError") throw o;
|
|
89
|
-
return o instanceof
|
|
95
|
+
return o instanceof u || o instanceof f ? d(o.code) : Object.freeze({
|
|
90
96
|
kind: "failure",
|
|
91
97
|
code: "network_error",
|
|
92
98
|
disposition: Object.freeze({ kind: "retryable" })
|
|
@@ -94,9 +100,9 @@ function _(e) {
|
|
|
94
100
|
}
|
|
95
101
|
}
|
|
96
102
|
};
|
|
97
|
-
return
|
|
103
|
+
return b(c), c;
|
|
98
104
|
}
|
|
99
|
-
async function
|
|
105
|
+
async function z(e) {
|
|
100
106
|
try {
|
|
101
107
|
const t = await e.json();
|
|
102
108
|
if (t !== null && typeof t == "object" && !Array.isArray(t)) {
|
|
@@ -110,7 +116,7 @@ async function O(e) {
|
|
|
110
116
|
}
|
|
111
117
|
return "request_failed";
|
|
112
118
|
}
|
|
113
|
-
function
|
|
119
|
+
function O(e, t) {
|
|
114
120
|
if (e == null) return;
|
|
115
121
|
const r = e.trim();
|
|
116
122
|
if (/^\d+$/u.test(r)) {
|
|
@@ -122,15 +128,15 @@ function S(e, t) {
|
|
|
122
128
|
const n = Date.parse(r);
|
|
123
129
|
return Number.isSafeInteger(n) && n > t ? n : void 0;
|
|
124
130
|
}
|
|
125
|
-
function
|
|
131
|
+
function d(e) {
|
|
126
132
|
return Object.freeze({
|
|
127
133
|
kind: "failure",
|
|
128
|
-
code:
|
|
134
|
+
code: y.test(e) ? e : "invalid_error_code",
|
|
129
135
|
disposition: Object.freeze({ kind: "terminal" })
|
|
130
136
|
});
|
|
131
137
|
}
|
|
132
138
|
export {
|
|
133
|
-
|
|
134
|
-
|
|
139
|
+
f as ControlplaneRequestError,
|
|
140
|
+
v as classifyControlplaneFailure,
|
|
135
141
|
_ as createControlplaneArtifactSource
|
|
136
142
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@floegence/floe-webapp-boot",
|
|
3
|
-
"version": "0.41.
|
|
3
|
+
"version": "0.41.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"clean": "rm -rf dist *.tsbuildinfo"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@floegence/flowersec-core": "2.5.
|
|
37
|
+
"@floegence/flowersec-core": "2.5.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"typescript": "^5.9.3",
|