@floegence/floe-webapp-boot 0.56.10 → 0.56.11

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.
@@ -1,22 +1,22 @@
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;
1
+ import { registerAcquisitionSource as d, materializeHTTPDirectAcquisitionForSource as S, materializeNativeIsolatedAcquisitionForSource as _, AcquisitionError as m, materializeAcquisitionForSource as k, materializePrivateLoopbackAcquisitionForSource as z } from "./acquisition.js";
2
+ const v = /^[a-z][a-z0-9_]{0,63}$/u;
3
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
  }
7
7
  }
8
- function v(e) {
8
+ function j(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 j(e, r) {
12
+ function O(e, r) {
13
13
  let t;
14
14
  try {
15
15
  t = new URL(e);
16
16
  } catch {
17
17
  throw new c(0, "transport_policy_denied");
18
18
  }
19
- if (t.protocol !== "https:" && !(r && t.protocol === "http:" && v(t.hostname)))
19
+ if (t.protocol !== "https:" && !(r && t.protocol === "http:" && j(t.hostname)))
20
20
  throw new c(0, "transport_policy_denied");
21
21
  return t.pathname = t.pathname.replace(/\/+$/u, ""), t;
22
22
  }
@@ -24,8 +24,8 @@ 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
- function O(e) {
28
- if (!m.test(e.code))
27
+ function T(e) {
28
+ if (!v.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 = L(e.retryAfter, e.nowUnixMilliseconds ?? Date.now());
36
+ const t = q(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 })
@@ -48,8 +48,8 @@ function U(e) {
48
48
  function I(e) {
49
49
  const r = l(
50
50
  e,
51
- (t, o, i) => _(t, o, {
52
- ...i,
51
+ (t, o, n) => _(t, o, {
52
+ ...n,
53
53
  context: e.isolatedContext
54
54
  }),
55
55
  "isolated"
@@ -57,7 +57,7 @@ function I(e) {
57
57
  return d(r), r;
58
58
  }
59
59
  function N(e) {
60
- const r = T(e.baseUrl), t = l(
60
+ const r = C(e.baseUrl), t = l(
61
61
  { ...e, baseUrl: r.origin, allowLoopbackHTTP: !0 },
62
62
  z
63
63
  );
@@ -80,91 +80,95 @@ function P(e) {
80
80
  );
81
81
  return d(t), t;
82
82
  }
83
- function l(e, r, t = "trusted", o = j(e.baseUrl, e.allowLoopbackHTTP === !0)) {
83
+ function l(e, r, t = "trusted", o = O(e.baseUrl, e.allowLoopbackHTTP === !0)) {
84
84
  if (typeof e.commitSpend != "function") throw new TypeError("commitSpend is required");
85
85
  if (typeof e.validateSpendBinding != "function")
86
86
  throw new TypeError("validateSpendBinding is required");
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 }) => {
87
+ const n = e.fetch ?? globalThis.fetch;
88
+ if (typeof n != "function") throw new TypeError("fetch is required");
89
+ const a = A(o, e.entryTicket), b = {
90
+ acquire: async ({ signal: f }) => {
91
91
  try {
92
- const n = {
92
+ const i = {
93
93
  endpoint_id: e.endpointId,
94
94
  ...e.payload === void 0 ? {} : { payload: e.payload },
95
95
  ...e.entryTicket === void 0 && e.correlation !== void 0 ? { correlation: { trace_id: e.correlation.traceId } } : {}
96
- }, s = await i(a, {
96
+ }, s = await n(a, {
97
97
  method: "POST",
98
98
  headers: {
99
99
  accept: "application/json",
100
100
  "content-type": "application/json",
101
101
  ...e.entryTicket === void 0 ? {} : { authorization: `Bearer ${e.entryTicket}` }
102
102
  },
103
- body: JSON.stringify(n),
103
+ body: JSON.stringify(i),
104
104
  credentials: "omit",
105
105
  redirect: "error",
106
- signal: u
106
+ signal: f
107
107
  });
108
108
  if (!s.ok) {
109
- const f = await E(s);
110
- return { kind: "failure", ...O({
109
+ const u = await L(s), h = T({
111
110
  status: s.status,
112
- code: f,
111
+ code: u,
113
112
  retryAfter: s.headers.get("retry-after"),
114
113
  retryableBusinessCodes: e.retryableBusinessCodes
115
- }) };
114
+ });
115
+ return Object.freeze({
116
+ kind: "failure",
117
+ code: h.code === "invalid_error_code" ? "artifact_invalid" : "connection_failed",
118
+ disposition: h.disposition
119
+ });
116
120
  }
117
- let b;
121
+ let y;
118
122
  try {
119
- b = await s.json();
123
+ y = await s.json();
120
124
  } catch {
121
- return p("invalid_controlplane_response");
125
+ return p();
122
126
  }
123
- const w = await r(y, b, {
127
+ const w = await r(b, y, {
124
128
  commitSpend: e.commitSpend,
125
- validateSpendBinding: (f) => {
129
+ validateSpendBinding: (u) => {
126
130
  try {
127
- return e.validateSpendBinding(f);
131
+ return e.validateSpendBinding(u);
128
132
  } catch {
129
- throw new h("invalid_spend_binding");
133
+ throw new m("invalid_spend_binding");
130
134
  }
131
135
  },
132
136
  expectedConsumer: t
133
137
  });
134
138
  return Object.freeze({ kind: "lease", lease: w });
135
- } catch (n) {
136
- if (u.aborted) throw u.reason ?? new DOMException("Aborted", "AbortError");
137
- if (n instanceof DOMException && n.name === "AbortError") throw n;
138
- return n instanceof h || n instanceof c ? p(n.code) : Object.freeze({
139
+ } catch (i) {
140
+ if (f.aborted) throw f.reason ?? new DOMException("Aborted", "AbortError");
141
+ if (i instanceof DOMException && i.name === "AbortError") throw i;
142
+ return i instanceof m || i instanceof c ? p() : Object.freeze({
139
143
  kind: "failure",
140
- code: "network_error",
144
+ code: "connection_failed",
141
145
  disposition: Object.freeze({ kind: "retryable" })
142
146
  });
143
147
  }
144
148
  }
145
149
  };
146
- return y;
150
+ return b;
147
151
  }
148
- function T(e) {
152
+ function C(e) {
149
153
  let r;
150
154
  try {
151
155
  r = new URL(e);
152
156
  } catch {
153
157
  throw new c(0, "transport_policy_denied");
154
158
  }
155
- if (e !== r.origin || r.protocol !== "http:" || r.username !== "" || r.password !== "" || !C(r.port) || !g(r.hostname))
159
+ if (e !== r.origin || r.protocol !== "http:" || r.username !== "" || r.password !== "" || !g(r.port) || !E(r.hostname))
156
160
  throw new c(0, "transport_policy_denied");
157
161
  return r;
158
162
  }
159
- function C(e) {
163
+ function g(e) {
160
164
  if (!/^[1-9][0-9]*$/u.test(e)) return !1;
161
165
  const r = Number(e);
162
166
  return Number.isSafeInteger(r) && r >= 1024 && r <= 65535;
163
167
  }
164
- function g(e) {
168
+ function E(e) {
165
169
  return e === "127.0.0.1" || e === "[::1]";
166
170
  }
167
- async function E(e) {
171
+ async function L(e) {
168
172
  try {
169
173
  const r = await e.json();
170
174
  if (r !== null && typeof r == "object" && !Array.isArray(r)) {
@@ -178,28 +182,28 @@ async function E(e) {
178
182
  }
179
183
  return "request_failed";
180
184
  }
181
- function L(e, r) {
185
+ function q(e, r) {
182
186
  if (e == null) return;
183
187
  const t = e.trim();
184
188
  if (/^\d+$/u.test(t)) {
185
- const i = Number(t);
186
- if (!Number.isSafeInteger(i)) return;
187
- const a = r + i * 1e3;
189
+ const n = Number(t);
190
+ if (!Number.isSafeInteger(n)) return;
191
+ const a = r + n * 1e3;
188
192
  return Number.isSafeInteger(a) && a > r ? a : void 0;
189
193
  }
190
194
  const o = Date.parse(t);
191
195
  return Number.isSafeInteger(o) && o > r ? o : void 0;
192
196
  }
193
- function p(e) {
197
+ function p() {
194
198
  return Object.freeze({
195
199
  kind: "failure",
196
- code: m.test(e) ? e : "invalid_error_code",
200
+ code: "artifact_invalid",
197
201
  disposition: Object.freeze({ kind: "terminal" })
198
202
  });
199
203
  }
200
204
  export {
201
205
  c as ControlplaneRequestError,
202
- O as classifyControlplaneFailure,
206
+ T as classifyControlplaneFailure,
203
207
  U as createControlplaneArtifactSource,
204
208
  P as createHTTPDirectControlplaneArtifactSource,
205
209
  I as createIsolatedControlplaneArtifactSource,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-boot",
3
- "version": "0.56.10",
3
+ "version": "0.56.11",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",