@lumiblue/secrets 0.1.15

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/index.js ADDED
@@ -0,0 +1,1496 @@
1
+ /*! @lumiblue/secrets v0.1.15 */
2
+ //#region src/backend/core/bodySerializer.gen.ts
3
+ var jsonBodySerializer = { bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value) };
4
+ Object.entries({
5
+ $body_: "body",
6
+ $headers_: "headers",
7
+ $path_: "path",
8
+ $query_: "query"
9
+ });
10
+ //#endregion
11
+ //#region src/backend/core/serverSentEvents.gen.ts
12
+ function createSseClient({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) {
13
+ let lastEventId;
14
+ const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
15
+ const createStream = async function* () {
16
+ let retryDelay = sseDefaultRetryDelay ?? 3e3;
17
+ let attempt = 0;
18
+ const signal = options.signal ?? new AbortController().signal;
19
+ while (true) {
20
+ if (signal.aborted) break;
21
+ attempt++;
22
+ const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
23
+ if (lastEventId !== void 0) headers.set("Last-Event-ID", lastEventId);
24
+ try {
25
+ const requestInit = {
26
+ redirect: "follow",
27
+ ...options,
28
+ body: options.serializedBody,
29
+ headers,
30
+ signal
31
+ };
32
+ let request = new Request(url, requestInit);
33
+ if (onRequest) request = await onRequest(url, requestInit);
34
+ const response = await (options.fetch ?? globalThis.fetch)(request);
35
+ if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
36
+ if (!response.body) throw new Error("No body in SSE response");
37
+ const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
38
+ let buffer = "";
39
+ const abortHandler = () => {
40
+ try {
41
+ reader.cancel();
42
+ } catch {}
43
+ };
44
+ signal.addEventListener("abort", abortHandler);
45
+ try {
46
+ while (true) {
47
+ const { done, value } = await reader.read();
48
+ if (done) break;
49
+ buffer += value;
50
+ buffer = buffer.replace(/\r\n?/g, "\n");
51
+ const chunks = buffer.split("\n\n");
52
+ buffer = chunks.pop() ?? "";
53
+ for (const chunk of chunks) {
54
+ const lines = chunk.split("\n");
55
+ const dataLines = [];
56
+ let eventName;
57
+ for (const line of lines) if (line.startsWith("data:")) dataLines.push(line.replace(/^data:\s*/, ""));
58
+ else if (line.startsWith("event:")) eventName = line.replace(/^event:\s*/, "");
59
+ else if (line.startsWith("id:")) lastEventId = line.replace(/^id:\s*/, "");
60
+ else if (line.startsWith("retry:")) {
61
+ const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
62
+ if (!Number.isNaN(parsed)) retryDelay = parsed;
63
+ }
64
+ let data;
65
+ let parsedJson = false;
66
+ if (dataLines.length) {
67
+ const rawData = dataLines.join("\n");
68
+ try {
69
+ data = JSON.parse(rawData);
70
+ parsedJson = true;
71
+ } catch {
72
+ data = rawData;
73
+ }
74
+ }
75
+ if (parsedJson) {
76
+ if (responseValidator) await responseValidator(data);
77
+ if (responseTransformer) data = await responseTransformer(data);
78
+ }
79
+ onSseEvent?.({
80
+ data,
81
+ event: eventName,
82
+ id: lastEventId,
83
+ retry: retryDelay
84
+ });
85
+ if (dataLines.length) yield data;
86
+ }
87
+ }
88
+ } finally {
89
+ signal.removeEventListener("abort", abortHandler);
90
+ reader.releaseLock();
91
+ }
92
+ break;
93
+ } catch (error) {
94
+ onSseError?.(error);
95
+ if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) break;
96
+ const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
97
+ await sleep(backoff);
98
+ }
99
+ }
100
+ };
101
+ return { stream: createStream() };
102
+ }
103
+ //#endregion
104
+ //#region src/backend/core/pathSerializer.gen.ts
105
+ var separatorArrayExplode = (style) => {
106
+ switch (style) {
107
+ case "label": return ".";
108
+ case "matrix": return ";";
109
+ case "simple": return ",";
110
+ default: return "&";
111
+ }
112
+ };
113
+ var separatorArrayNoExplode = (style) => {
114
+ switch (style) {
115
+ case "form": return ",";
116
+ case "pipeDelimited": return "|";
117
+ case "spaceDelimited": return "%20";
118
+ default: return ",";
119
+ }
120
+ };
121
+ var separatorObjectExplode = (style) => {
122
+ switch (style) {
123
+ case "label": return ".";
124
+ case "matrix": return ";";
125
+ case "simple": return ",";
126
+ default: return "&";
127
+ }
128
+ };
129
+ var serializeArrayParam = ({ allowReserved, explode, name, style, value }) => {
130
+ if (!explode) {
131
+ const joinedValues = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
132
+ switch (style) {
133
+ case "label": return `.${joinedValues}`;
134
+ case "matrix": return `;${name}=${joinedValues}`;
135
+ case "simple": return joinedValues;
136
+ default: return `${name}=${joinedValues}`;
137
+ }
138
+ }
139
+ const separator = separatorArrayExplode(style);
140
+ const joinedValues = value.map((v) => {
141
+ if (style === "label" || style === "simple") return allowReserved ? v : encodeURIComponent(v);
142
+ return serializePrimitiveParam({
143
+ allowReserved,
144
+ name,
145
+ value: v
146
+ });
147
+ }).join(separator);
148
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
149
+ };
150
+ var serializePrimitiveParam = ({ allowReserved, name, value }) => {
151
+ if (value === void 0 || value === null) return "";
152
+ if (typeof value === "object") throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");
153
+ return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
154
+ };
155
+ var serializeObjectParam = ({ allowReserved, explode, name, style, value, valueOnly }) => {
156
+ if (value instanceof Date) return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
157
+ if (style !== "deepObject" && !explode) {
158
+ let values = [];
159
+ Object.entries(value).forEach(([key, v]) => {
160
+ values = [
161
+ ...values,
162
+ key,
163
+ allowReserved ? v : encodeURIComponent(v)
164
+ ];
165
+ });
166
+ const joinedValues = values.join(",");
167
+ switch (style) {
168
+ case "form": return `${name}=${joinedValues}`;
169
+ case "label": return `.${joinedValues}`;
170
+ case "matrix": return `;${name}=${joinedValues}`;
171
+ default: return joinedValues;
172
+ }
173
+ }
174
+ const separator = separatorObjectExplode(style);
175
+ const joinedValues = Object.entries(value).map(([key, v]) => serializePrimitiveParam({
176
+ allowReserved,
177
+ name: style === "deepObject" ? `${name}[${key}]` : key,
178
+ value: v
179
+ })).join(separator);
180
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
181
+ };
182
+ //#endregion
183
+ //#region src/backend/core/utils.gen.ts
184
+ var PATH_PARAM_RE = /\{[^{}]+\}/g;
185
+ var defaultPathSerializer = ({ path, url: _url }) => {
186
+ let url = _url;
187
+ const matches = _url.match(PATH_PARAM_RE);
188
+ if (matches) for (const match of matches) {
189
+ let explode = false;
190
+ let name = match.substring(1, match.length - 1);
191
+ let style = "simple";
192
+ if (name.endsWith("*")) {
193
+ explode = true;
194
+ name = name.substring(0, name.length - 1);
195
+ }
196
+ if (name.startsWith(".")) {
197
+ name = name.substring(1);
198
+ style = "label";
199
+ } else if (name.startsWith(";")) {
200
+ name = name.substring(1);
201
+ style = "matrix";
202
+ }
203
+ const value = path[name];
204
+ if (value === void 0 || value === null) continue;
205
+ if (Array.isArray(value)) {
206
+ url = url.replace(match, serializeArrayParam({
207
+ explode,
208
+ name,
209
+ style,
210
+ value
211
+ }));
212
+ continue;
213
+ }
214
+ if (typeof value === "object") {
215
+ url = url.replace(match, serializeObjectParam({
216
+ explode,
217
+ name,
218
+ style,
219
+ value,
220
+ valueOnly: true
221
+ }));
222
+ continue;
223
+ }
224
+ if (style === "matrix") {
225
+ url = url.replace(match, `;${serializePrimitiveParam({
226
+ name,
227
+ value
228
+ })}`);
229
+ continue;
230
+ }
231
+ const replaceValue = encodeURIComponent(style === "label" ? `.${value}` : value);
232
+ url = url.replace(match, replaceValue);
233
+ }
234
+ return url;
235
+ };
236
+ var getUrl = ({ baseUrl, path, query, querySerializer, url: _url }) => {
237
+ const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
238
+ let url = (baseUrl ?? "") + pathUrl;
239
+ if (path) url = defaultPathSerializer({
240
+ path,
241
+ url
242
+ });
243
+ let search = query ? querySerializer(query) : "";
244
+ if (search.startsWith("?")) search = search.substring(1);
245
+ if (search) url += `?${search}`;
246
+ return url;
247
+ };
248
+ function getValidRequestBody(options) {
249
+ const hasBody = options.body !== void 0;
250
+ if (hasBody && options.bodySerializer) {
251
+ if ("serializedBody" in options) return options.serializedBody !== void 0 && options.serializedBody !== "" ? options.serializedBody : null;
252
+ return options.body !== "" ? options.body : null;
253
+ }
254
+ if (hasBody) return options.body;
255
+ }
256
+ //#endregion
257
+ //#region src/backend/core/auth.gen.ts
258
+ var getAuthToken = async (auth, callback) => {
259
+ const token = typeof callback === "function" ? await callback(auth) : callback;
260
+ if (!token) return;
261
+ if (auth.scheme === "bearer") return `Bearer ${token}`;
262
+ if (auth.scheme === "basic") return `Basic ${btoa(token)}`;
263
+ return token;
264
+ };
265
+ //#endregion
266
+ //#region src/backend/client/utils.gen.ts
267
+ var createQuerySerializer = ({ parameters = {}, ...args } = {}) => {
268
+ const querySerializer = (queryParams) => {
269
+ const search = [];
270
+ if (queryParams && typeof queryParams === "object") for (const name in queryParams) {
271
+ const value = queryParams[name];
272
+ if (value === void 0 || value === null) continue;
273
+ const options = parameters[name] || args;
274
+ if (Array.isArray(value)) {
275
+ const serializedArray = serializeArrayParam({
276
+ allowReserved: options.allowReserved,
277
+ explode: true,
278
+ name,
279
+ style: "form",
280
+ value,
281
+ ...options.array
282
+ });
283
+ if (serializedArray) search.push(serializedArray);
284
+ } else if (typeof value === "object") {
285
+ const serializedObject = serializeObjectParam({
286
+ allowReserved: options.allowReserved,
287
+ explode: true,
288
+ name,
289
+ style: "deepObject",
290
+ value,
291
+ ...options.object
292
+ });
293
+ if (serializedObject) search.push(serializedObject);
294
+ } else {
295
+ const serializedPrimitive = serializePrimitiveParam({
296
+ allowReserved: options.allowReserved,
297
+ name,
298
+ value
299
+ });
300
+ if (serializedPrimitive) search.push(serializedPrimitive);
301
+ }
302
+ }
303
+ return search.join("&");
304
+ };
305
+ return querySerializer;
306
+ };
307
+ /**
308
+ * Infers parseAs value from provided Content-Type header.
309
+ */
310
+ var getParseAs = (contentType) => {
311
+ if (!contentType) return "stream";
312
+ const cleanContent = contentType.split(";")[0]?.trim();
313
+ if (!cleanContent) return;
314
+ if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) return "json";
315
+ if (cleanContent === "multipart/form-data") return "formData";
316
+ if ([
317
+ "application/",
318
+ "audio/",
319
+ "image/",
320
+ "video/"
321
+ ].some((type) => cleanContent.startsWith(type))) return "blob";
322
+ if (cleanContent.startsWith("text/")) return "text";
323
+ };
324
+ var checkForExistence = (options, name) => {
325
+ if (!name) return false;
326
+ if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) return true;
327
+ return false;
328
+ };
329
+ async function setAuthParams(options) {
330
+ for (const auth of options.security ?? []) {
331
+ if (checkForExistence(options, auth.name)) continue;
332
+ const token = await getAuthToken(auth, options.auth);
333
+ if (!token) continue;
334
+ const name = auth.name ?? "Authorization";
335
+ switch (auth.in) {
336
+ case "query":
337
+ if (!options.query) options.query = {};
338
+ options.query[name] = token;
339
+ break;
340
+ case "cookie":
341
+ options.headers.append("Cookie", `${name}=${token}`);
342
+ break;
343
+ default: options.headers.set(name, token);
344
+ }
345
+ }
346
+ }
347
+ var buildUrl = (options) => getUrl({
348
+ baseUrl: options.baseUrl,
349
+ path: options.path,
350
+ query: options.query,
351
+ querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
352
+ url: options.url
353
+ });
354
+ var mergeConfigs = (a, b) => {
355
+ const config = {
356
+ ...a,
357
+ ...b
358
+ };
359
+ if (config.baseUrl?.endsWith("/")) config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
360
+ config.headers = mergeHeaders(a.headers, b.headers);
361
+ return config;
362
+ };
363
+ var headersEntries = (headers) => {
364
+ const entries = [];
365
+ headers.forEach((value, key) => {
366
+ entries.push([key, value]);
367
+ });
368
+ return entries;
369
+ };
370
+ var mergeHeaders = (...headers) => {
371
+ const mergedHeaders = new Headers();
372
+ for (const header of headers) {
373
+ if (!header) continue;
374
+ const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
375
+ for (const [key, value] of iterator) if (value === null) mergedHeaders.delete(key);
376
+ else if (Array.isArray(value)) for (const v of value) mergedHeaders.append(key, v);
377
+ else if (value !== void 0) mergedHeaders.set(key, typeof value === "object" ? JSON.stringify(value) : value);
378
+ }
379
+ return mergedHeaders;
380
+ };
381
+ var Interceptors = class {
382
+ constructor() {
383
+ this.fns = [];
384
+ }
385
+ clear() {
386
+ this.fns = [];
387
+ }
388
+ eject(id) {
389
+ const index = this.getInterceptorIndex(id);
390
+ if (this.fns[index]) this.fns[index] = null;
391
+ }
392
+ exists(id) {
393
+ const index = this.getInterceptorIndex(id);
394
+ return Boolean(this.fns[index]);
395
+ }
396
+ getInterceptorIndex(id) {
397
+ if (typeof id === "number") return this.fns[id] ? id : -1;
398
+ return this.fns.indexOf(id);
399
+ }
400
+ update(id, fn) {
401
+ const index = this.getInterceptorIndex(id);
402
+ if (this.fns[index]) {
403
+ this.fns[index] = fn;
404
+ return id;
405
+ }
406
+ return false;
407
+ }
408
+ use(fn) {
409
+ this.fns.push(fn);
410
+ return this.fns.length - 1;
411
+ }
412
+ };
413
+ var createInterceptors = () => ({
414
+ error: new Interceptors(),
415
+ request: new Interceptors(),
416
+ response: new Interceptors()
417
+ });
418
+ var defaultQuerySerializer = createQuerySerializer({
419
+ allowReserved: false,
420
+ array: {
421
+ explode: true,
422
+ style: "form"
423
+ },
424
+ object: {
425
+ explode: true,
426
+ style: "deepObject"
427
+ }
428
+ });
429
+ var defaultHeaders = { "Content-Type": "application/json" };
430
+ var createConfig = (override = {}) => ({
431
+ ...jsonBodySerializer,
432
+ headers: defaultHeaders,
433
+ parseAs: "auto",
434
+ querySerializer: defaultQuerySerializer,
435
+ ...override
436
+ });
437
+ //#endregion
438
+ //#region src/backend/client/client.gen.ts
439
+ var createClient = (config = {}) => {
440
+ let _config = mergeConfigs(createConfig(), config);
441
+ const getConfig = () => ({ ..._config });
442
+ const setConfig = (config) => {
443
+ _config = mergeConfigs(_config, config);
444
+ return getConfig();
445
+ };
446
+ const interceptors = createInterceptors();
447
+ const beforeRequest = async (options) => {
448
+ const opts = {
449
+ ..._config,
450
+ ...options,
451
+ fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
452
+ headers: mergeHeaders(_config.headers, options.headers),
453
+ serializedBody: void 0
454
+ };
455
+ if (opts.security) await setAuthParams(opts);
456
+ if (opts.requestValidator) await opts.requestValidator(opts);
457
+ if (opts.body !== void 0 && opts.bodySerializer) opts.serializedBody = opts.bodySerializer(opts.body);
458
+ if (opts.body === void 0 || opts.serializedBody === "") opts.headers.delete("Content-Type");
459
+ const resolvedOpts = opts;
460
+ return {
461
+ opts: resolvedOpts,
462
+ url: buildUrl(resolvedOpts)
463
+ };
464
+ };
465
+ const request = async (options) => {
466
+ const throwOnError = options.throwOnError ?? _config.throwOnError;
467
+ const responseStyle = options.responseStyle ?? _config.responseStyle;
468
+ let request;
469
+ let response;
470
+ try {
471
+ const { opts, url } = await beforeRequest(options);
472
+ const requestInit = {
473
+ redirect: "follow",
474
+ ...opts,
475
+ body: getValidRequestBody(opts)
476
+ };
477
+ request = new Request(url, requestInit);
478
+ for (const fn of interceptors.request.fns) if (fn) request = await fn(request, opts);
479
+ const _fetch = opts.fetch;
480
+ response = await _fetch(request);
481
+ for (const fn of interceptors.response.fns) if (fn) response = await fn(response, request, opts);
482
+ const result = {
483
+ request,
484
+ response
485
+ };
486
+ if (response.ok) {
487
+ const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
488
+ if (response.status === 204 || response.headers.get("Content-Length") === "0") {
489
+ let emptyData;
490
+ switch (parseAs) {
491
+ case "arrayBuffer":
492
+ case "blob":
493
+ case "text":
494
+ emptyData = await response[parseAs]();
495
+ break;
496
+ case "formData":
497
+ emptyData = new FormData();
498
+ break;
499
+ case "stream":
500
+ emptyData = response.body;
501
+ break;
502
+ default: emptyData = {};
503
+ }
504
+ return opts.responseStyle === "data" ? emptyData : {
505
+ data: emptyData,
506
+ ...result
507
+ };
508
+ }
509
+ let data;
510
+ switch (parseAs) {
511
+ case "arrayBuffer":
512
+ case "blob":
513
+ case "formData":
514
+ case "text":
515
+ data = await response[parseAs]();
516
+ break;
517
+ case "json": {
518
+ const text = await response.text();
519
+ data = text ? JSON.parse(text) : {};
520
+ break;
521
+ }
522
+ case "stream": return opts.responseStyle === "data" ? response.body : {
523
+ data: response.body,
524
+ ...result
525
+ };
526
+ }
527
+ if (parseAs === "json") {
528
+ if (opts.responseValidator) await opts.responseValidator(data);
529
+ if (opts.responseTransformer) data = await opts.responseTransformer(data);
530
+ }
531
+ return opts.responseStyle === "data" ? data : {
532
+ data,
533
+ ...result
534
+ };
535
+ }
536
+ const textError = await response.text();
537
+ let jsonError;
538
+ try {
539
+ jsonError = JSON.parse(textError);
540
+ } catch {}
541
+ throw jsonError ?? textError;
542
+ } catch (error) {
543
+ let finalError = error;
544
+ for (const fn of interceptors.error.fns) if (fn) finalError = await fn(finalError, response, request, options);
545
+ finalError = finalError || {};
546
+ if (throwOnError) throw finalError;
547
+ return responseStyle === "data" ? void 0 : {
548
+ error: finalError,
549
+ request,
550
+ response
551
+ };
552
+ }
553
+ };
554
+ const makeMethodFn = (method) => (options) => request({
555
+ ...options,
556
+ method
557
+ });
558
+ const makeSseFn = (method) => async (options) => {
559
+ const { opts, url } = await beforeRequest(options);
560
+ return createSseClient({
561
+ ...opts,
562
+ body: opts.body,
563
+ method,
564
+ onRequest: async (url, init) => {
565
+ let request = new Request(url, init);
566
+ for (const fn of interceptors.request.fns) if (fn) request = await fn(request, opts);
567
+ return request;
568
+ },
569
+ serializedBody: getValidRequestBody(opts),
570
+ url
571
+ });
572
+ };
573
+ const _buildUrl = (options) => buildUrl({
574
+ ..._config,
575
+ ...options
576
+ });
577
+ return {
578
+ buildUrl: _buildUrl,
579
+ connect: makeMethodFn("CONNECT"),
580
+ delete: makeMethodFn("DELETE"),
581
+ get: makeMethodFn("GET"),
582
+ getConfig,
583
+ head: makeMethodFn("HEAD"),
584
+ interceptors,
585
+ options: makeMethodFn("OPTIONS"),
586
+ patch: makeMethodFn("PATCH"),
587
+ post: makeMethodFn("POST"),
588
+ put: makeMethodFn("PUT"),
589
+ request,
590
+ setConfig,
591
+ sse: {
592
+ connect: makeSseFn("CONNECT"),
593
+ delete: makeSseFn("DELETE"),
594
+ get: makeSseFn("GET"),
595
+ head: makeSseFn("HEAD"),
596
+ options: makeSseFn("OPTIONS"),
597
+ patch: makeSseFn("PATCH"),
598
+ post: makeSseFn("POST"),
599
+ put: makeSseFn("PUT"),
600
+ trace: makeSseFn("TRACE")
601
+ },
602
+ trace: makeMethodFn("TRACE")
603
+ };
604
+ };
605
+ //#endregion
606
+ //#region src/backend/client.gen.ts
607
+ var DEFAULT_API_SERVERS = ["http://localhost:3001"];
608
+ var SERVER_DOWN_STATUS_CODES = /* @__PURE__ */ new Set([
609
+ 502,
610
+ 503,
611
+ 504
612
+ ]);
613
+ function isServerDownStatus(status) {
614
+ return SERVER_DOWN_STATUS_CODES.has(status);
615
+ }
616
+ /**
617
+ * Identity hosts for JWT minting. Local when DEFAULT_API_SERVERS includes localhost.
618
+ * @returns Ordered Identity base URLs.
619
+ */
620
+ function resolveIdentityServers() {
621
+ return DEFAULT_API_SERVERS.some((url) => url.includes("localhost")) ? ["http://localhost:3000"] : ["https://identity.lumiblue.nl", "https://identity2.lumiblue.nl"];
622
+ }
623
+ /**
624
+ * Creates an Identity HTTP client with multi-server failover, JWT refresh,
625
+ * and optional M2M API-key auth. Each call gets isolated credential state.
626
+ *
627
+ * @param options - Optional servers and apiKey overrides.
628
+ * @returns Augmented client usable with `new Sdk({ client })`.
629
+ */
630
+ function createSdkClient(options) {
631
+ let availableServers = [...options?.servers ?? DEFAULT_API_SERVERS];
632
+ const identityServers = resolveIdentityServers();
633
+ let authToken;
634
+ let apiKey = options?.apiKey;
635
+ let refreshPromise = null;
636
+ function getAvailableServers() {
637
+ return [...availableServers];
638
+ }
639
+ function setApiKey(key) {
640
+ apiKey = key;
641
+ authToken = void 0;
642
+ }
643
+ function setToken(token) {
644
+ authToken = token;
645
+ }
646
+ function promoteServer(server) {
647
+ availableServers = [server, ...availableServers.filter((entry) => entry !== server)];
648
+ }
649
+ async function cloneRequest(baseUrl, input, init, bearer) {
650
+ const isRequestInstance = input instanceof Request;
651
+ const rawUrl = isRequestInstance ? input.url : String(input);
652
+ const reqUrl = URL.canParse(rawUrl) ? new URL(rawUrl) : new URL(rawUrl, baseUrl);
653
+ const recreatedURL = new URL(reqUrl.pathname, baseUrl);
654
+ recreatedURL.search = reqUrl.search;
655
+ recreatedURL.hash = reqUrl.hash;
656
+ const method = isRequestInstance ? input.method : init?.method || "GET";
657
+ const hasBody = ![
658
+ "GET",
659
+ "HEAD",
660
+ "OPTIONS"
661
+ ].includes(method.toUpperCase());
662
+ const headers = new Headers(isRequestInstance ? input.headers : init?.headers);
663
+ if (bearer) headers.set("Authorization", "Bearer " + bearer);
664
+ const attemptInit = isRequestInstance ? {
665
+ method,
666
+ headers,
667
+ credentials: input.credentials,
668
+ mode: input.mode,
669
+ redirect: input.redirect,
670
+ referrer: input.referrer,
671
+ referrerPolicy: input.referrerPolicy,
672
+ cache: input.cache,
673
+ integrity: input.integrity,
674
+ keepalive: input.keepalive,
675
+ signal: input.signal,
676
+ body: hasBody ? await input.clone().arrayBuffer() : void 0
677
+ } : {
678
+ ...init,
679
+ headers
680
+ };
681
+ return new Request(recreatedURL, attemptInit);
682
+ }
683
+ async function refreshWithApiKey() {
684
+ let lastError;
685
+ for (const server of identityServers) try {
686
+ const response = await fetch(server + "/api/lumiblue-token", {
687
+ method: "POST",
688
+ credentials: "omit",
689
+ headers: {
690
+ "content-type": "application/json",
691
+ "x-api-key": apiKey
692
+ },
693
+ body: JSON.stringify({})
694
+ });
695
+ if (isServerDownStatus(response.status)) continue;
696
+ if (response.ok) {
697
+ const data = await response.json();
698
+ authToken = data.token;
699
+ return data.token;
700
+ }
701
+ throw new Error("Identity - API key token mint failed: " + response.status);
702
+ } catch (error) {
703
+ lastError = error;
704
+ console.warn("Identity - Failed contacting ", server, error);
705
+ }
706
+ if (lastError instanceof Error) throw lastError;
707
+ throw new Error("All identity servers unreachable");
708
+ }
709
+ async function refreshWithSessionCookie() {
710
+ let activeServer;
711
+ for (const server of identityServers) try {
712
+ const response = await fetch(server + "/api/lumiblue-token", {
713
+ method: "POST",
714
+ credentials: "include",
715
+ headers: { "content-type": "application/json" },
716
+ body: JSON.stringify({})
717
+ });
718
+ if (isServerDownStatus(response.status)) continue;
719
+ if (response.ok) {
720
+ const data = await response.json();
721
+ authToken = data.token;
722
+ return data.token;
723
+ }
724
+ activeServer = server;
725
+ } catch (error) {
726
+ console.warn("Identity - Failed contacting ", server, error);
727
+ }
728
+ if (activeServer && typeof window !== "undefined") {
729
+ const loginUrl = new URL(activeServer + "/login.html");
730
+ loginUrl.searchParams.set("redirect_uri", window.location.href);
731
+ window.location.assign(loginUrl.toString());
732
+ return;
733
+ }
734
+ throw new Error("All identity servers unreachable");
735
+ }
736
+ async function getAuthToken() {
737
+ if (refreshPromise) return refreshPromise;
738
+ refreshPromise = (async () => {
739
+ try {
740
+ return apiKey ? await refreshWithApiKey() : await refreshWithSessionCookie();
741
+ } finally {
742
+ refreshPromise = null;
743
+ }
744
+ })();
745
+ return refreshPromise;
746
+ }
747
+ async function multiServersRetryWithAuth(input, init) {
748
+ let lastResponse;
749
+ let lastError;
750
+ for (let i = 0; i < availableServers.length; i++) {
751
+ const baseUrl = availableServers[i].replace(/\/$/, "");
752
+ const attempt = await cloneRequest(baseUrl, input, init, authToken);
753
+ try {
754
+ const response = await fetch(attempt);
755
+ if (isServerDownStatus(response.status)) {
756
+ lastResponse = response;
757
+ continue;
758
+ }
759
+ promoteServer(baseUrl);
760
+ if (response.status === 401) {
761
+ authToken = await getAuthToken();
762
+ return await fetch(await cloneRequest(baseUrl, input, init, authToken));
763
+ }
764
+ return response;
765
+ } catch (error) {
766
+ lastError = error;
767
+ continue;
768
+ }
769
+ }
770
+ if (lastResponse) return lastResponse;
771
+ if (lastError instanceof Error) throw lastError;
772
+ throw new Error("All servers unreachable");
773
+ }
774
+ async function logout() {
775
+ if (apiKey) {
776
+ apiKey = void 0;
777
+ authToken = void 0;
778
+ return;
779
+ }
780
+ for (const server of identityServers) try {
781
+ const response = await fetch(server + "/api/auth/sign-out", {
782
+ method: "POST",
783
+ credentials: "include",
784
+ headers: { "content-type": "application/json" },
785
+ body: JSON.stringify({})
786
+ });
787
+ if (isServerDownStatus(response.status)) continue;
788
+ if (!response.ok) console.error("Identity - Failed signing out from " + server);
789
+ else {
790
+ await multiServersRetryWithAuth("http://localhost/api/lumiblue-token", {
791
+ method: "DELETE",
792
+ credentials: "include"
793
+ });
794
+ authToken = void 0;
795
+ }
796
+ } catch (error) {
797
+ console.error("Identity - Failed signing out", error);
798
+ }
799
+ }
800
+ const baseClient = createClient(createConfig({
801
+ auth: () => authToken,
802
+ credentials: "include",
803
+ baseUrl: availableServers[0],
804
+ fetch: multiServersRetryWithAuth
805
+ }));
806
+ return Object.assign(baseClient, {
807
+ logout,
808
+ getAvailableServers,
809
+ setApiKey,
810
+ setToken
811
+ });
812
+ }
813
+ /** Default shared client used by `new Sdk()` when no client is passed. */
814
+ var client = createSdkClient();
815
+ //#endregion
816
+ //#region src/backend/sdk.gen.ts
817
+ var HeyApiClient = class {
818
+ constructor(args) {
819
+ this.client = args?.client ?? client;
820
+ }
821
+ };
822
+ var HeyApiRegistry = class {
823
+ constructor() {
824
+ this.defaultKey = "default";
825
+ this.instances = /* @__PURE__ */ new Map();
826
+ }
827
+ get(key) {
828
+ const instance = this.instances.get(key ?? this.defaultKey);
829
+ if (!instance) throw new Error(`No SDK client found. Create one with "new Sdk()" to fix this error.`);
830
+ return instance;
831
+ }
832
+ set(value, key) {
833
+ this.instances.set(key ?? this.defaultKey, value);
834
+ }
835
+ };
836
+ var Sdk = class Sdk extends HeyApiClient {
837
+ static {
838
+ this.__registry = new HeyApiRegistry();
839
+ }
840
+ constructor(args) {
841
+ super(args);
842
+ Sdk.__registry.set(this, args?.key);
843
+ }
844
+ /**
845
+ * Service health check response
846
+ */
847
+ getApiHealth(options) {
848
+ return (options?.client ?? this.client).get({
849
+ url: "/api/health",
850
+ ...options
851
+ });
852
+ }
853
+ /**
854
+ * Bearer Auth - service health check plus JWT payload
855
+ */
856
+ getApiHealthMe(options) {
857
+ return (options?.client ?? this.client).get({
858
+ security: [{
859
+ scheme: "bearer",
860
+ type: "http"
861
+ }],
862
+ url: "/api/health/me",
863
+ ...options
864
+ });
865
+ }
866
+ /**
867
+ * Bulk delete projects by array of IDs (project-admin only).
868
+ */
869
+ deleteApiVaultProjects(options) {
870
+ return (options.client ?? this.client).delete({
871
+ security: [{
872
+ scheme: "bearer",
873
+ type: "http"
874
+ }],
875
+ url: "/api/vault/projects",
876
+ ...options,
877
+ headers: {
878
+ "Content-Type": "application/json",
879
+ ...options.headers
880
+ }
881
+ });
882
+ }
883
+ /**
884
+ * List all projects accessible to the authenticated user, with per-project secret count.
885
+ */
886
+ getApiVaultProjects(options) {
887
+ return (options?.client ?? this.client).get({
888
+ security: [{
889
+ scheme: "bearer",
890
+ type: "http"
891
+ }],
892
+ url: "/api/vault/projects",
893
+ ...options
894
+ });
895
+ }
896
+ /**
897
+ * Bulk update projects (project-admin only).
898
+ */
899
+ patchApiVaultProjects(options) {
900
+ return (options.client ?? this.client).patch({
901
+ security: [{
902
+ scheme: "bearer",
903
+ type: "http"
904
+ }],
905
+ url: "/api/vault/projects",
906
+ ...options,
907
+ headers: {
908
+ "Content-Type": "application/json",
909
+ ...options.headers
910
+ }
911
+ });
912
+ }
913
+ /**
914
+ * Create one or more projects and auto-assign the creator as admin on each.
915
+ */
916
+ putApiVaultProjects(options) {
917
+ return (options.client ?? this.client).put({
918
+ security: [{
919
+ scheme: "bearer",
920
+ type: "http"
921
+ }],
922
+ url: "/api/vault/projects",
923
+ ...options,
924
+ headers: {
925
+ "Content-Type": "application/json",
926
+ ...options.headers
927
+ }
928
+ });
929
+ }
930
+ /**
931
+ * Get all secrets for a project, pivoted by environment (dev, staging, production).
932
+ */
933
+ getApiVaultProjectsByProjectIdSecrets(options) {
934
+ return (options.client ?? this.client).get({
935
+ security: [{
936
+ scheme: "bearer",
937
+ type: "http"
938
+ }],
939
+ url: "/api/vault/projects/{projectId}/secrets",
940
+ ...options
941
+ });
942
+ }
943
+ /**
944
+ * Reveal the decrypted plaintext value of a single secret. Call on demand when the user chooses to view it.
945
+ */
946
+ getApiVaultSecretsBySecretId(options) {
947
+ return (options.client ?? this.client).get({
948
+ security: [{
949
+ scheme: "bearer",
950
+ type: "http"
951
+ }],
952
+ url: "/api/vault/secrets/{secretId}",
953
+ ...options
954
+ });
955
+ }
956
+ /**
957
+ * Update a single secret value. The plaintext value is encrypted before persisting.
958
+ */
959
+ patchApiVaultSecretsBySecretId(options) {
960
+ return (options.client ?? this.client).patch({
961
+ security: [{
962
+ scheme: "bearer",
963
+ type: "http"
964
+ }],
965
+ url: "/api/vault/secrets/{secretId}",
966
+ ...options,
967
+ headers: {
968
+ "Content-Type": "application/json",
969
+ ...options.headers
970
+ }
971
+ });
972
+ }
973
+ /**
974
+ * Inject secrets for a machine identity. Authenticates via SHA-256 hash of machineId.
975
+ */
976
+ postApiVaultInject(options) {
977
+ return (options.client ?? this.client).post({
978
+ url: "/api/vault/inject",
979
+ ...options,
980
+ headers: {
981
+ "Content-Type": "application/json",
982
+ ...options.headers
983
+ }
984
+ });
985
+ }
986
+ /**
987
+ * Batch query projects by array of IDs (access-scoped).
988
+ */
989
+ postApiVaultProjectsQuery(options) {
990
+ return (options.client ?? this.client).post({
991
+ security: [{
992
+ scheme: "bearer",
993
+ type: "http"
994
+ }],
995
+ url: "/api/vault/projects/query",
996
+ ...options,
997
+ headers: {
998
+ "Content-Type": "application/json",
999
+ ...options.headers
1000
+ }
1001
+ });
1002
+ }
1003
+ /**
1004
+ * Bulk delete secrets by array of IDs (permission-scoped).
1005
+ */
1006
+ deleteApiVaultSecrets(options) {
1007
+ return (options.client ?? this.client).delete({
1008
+ security: [{
1009
+ scheme: "bearer",
1010
+ type: "http"
1011
+ }],
1012
+ url: "/api/vault/secrets",
1013
+ ...options,
1014
+ headers: {
1015
+ "Content-Type": "application/json",
1016
+ ...options.headers
1017
+ }
1018
+ });
1019
+ }
1020
+ /**
1021
+ * Bulk update secrets (permission-scoped).
1022
+ */
1023
+ patchApiVaultSecrets(options) {
1024
+ return (options.client ?? this.client).patch({
1025
+ security: [{
1026
+ scheme: "bearer",
1027
+ type: "http"
1028
+ }],
1029
+ url: "/api/vault/secrets",
1030
+ ...options,
1031
+ headers: {
1032
+ "Content-Type": "application/json",
1033
+ ...options.headers
1034
+ }
1035
+ });
1036
+ }
1037
+ /**
1038
+ * Bulk create secrets (plaintext values are encrypted before persisting).
1039
+ */
1040
+ putApiVaultSecrets(options) {
1041
+ return (options.client ?? this.client).put({
1042
+ security: [{
1043
+ scheme: "bearer",
1044
+ type: "http"
1045
+ }],
1046
+ url: "/api/vault/secrets",
1047
+ ...options,
1048
+ headers: {
1049
+ "Content-Type": "application/json",
1050
+ ...options.headers
1051
+ }
1052
+ });
1053
+ }
1054
+ /**
1055
+ * Batch query secrets by array of IDs (permission-scoped).
1056
+ */
1057
+ postApiVaultSecretsQuery(options) {
1058
+ return (options.client ?? this.client).post({
1059
+ security: [{
1060
+ scheme: "bearer",
1061
+ type: "http"
1062
+ }],
1063
+ url: "/api/vault/secrets/query",
1064
+ ...options,
1065
+ headers: {
1066
+ "Content-Type": "application/json",
1067
+ ...options.headers
1068
+ }
1069
+ });
1070
+ }
1071
+ /**
1072
+ * Turn DMS off by hard-deleting the dms row (owner only). Idempotent when already off.
1073
+ */
1074
+ deleteApiVaultProjectsByProjectIdDms(options) {
1075
+ return (options.client ?? this.client).delete({
1076
+ security: [{
1077
+ scheme: "bearer",
1078
+ type: "http"
1079
+ }],
1080
+ url: "/api/vault/projects/{projectId}/dms",
1081
+ ...options
1082
+ });
1083
+ }
1084
+ /**
1085
+ * Read DMS settings for a vault project (owner only). Missing row returns stable off payload.
1086
+ */
1087
+ getApiVaultProjectsByProjectIdDms(options) {
1088
+ return (options.client ?? this.client).get({
1089
+ security: [{
1090
+ scheme: "bearer",
1091
+ type: "http"
1092
+ }],
1093
+ url: "/api/vault/projects/{projectId}/dms",
1094
+ ...options
1095
+ });
1096
+ }
1097
+ /**
1098
+ * Edit DMS settings (owner only). Emails-only edits preserve delivery/reminder/claim fields.
1099
+ */
1100
+ patchApiVaultProjectsByProjectIdDms(options) {
1101
+ return (options.client ?? this.client).patch({
1102
+ security: [{
1103
+ scheme: "bearer",
1104
+ type: "http"
1105
+ }],
1106
+ url: "/api/vault/projects/{projectId}/dms",
1107
+ ...options,
1108
+ headers: {
1109
+ "Content-Type": "application/json",
1110
+ ...options.headers
1111
+ }
1112
+ });
1113
+ }
1114
+ /**
1115
+ * Arm / create DMS for a project (owner only). Resets reminder, delivery, and claim cursors.
1116
+ */
1117
+ putApiVaultProjectsByProjectIdDms(options) {
1118
+ return (options.client ?? this.client).put({
1119
+ security: [{
1120
+ scheme: "bearer",
1121
+ type: "http"
1122
+ }],
1123
+ url: "/api/vault/projects/{projectId}/dms",
1124
+ ...options,
1125
+ headers: {
1126
+ "Content-Type": "application/json",
1127
+ ...options.headers
1128
+ }
1129
+ });
1130
+ }
1131
+ /**
1132
+ * Public proof-of-life HTML page (signed magic-link token; no JWT).
1133
+ */
1134
+ getApiDmsProofByToken(options) {
1135
+ return (options.client ?? this.client).get({
1136
+ url: "/api/dms/proof/{token}",
1137
+ ...options
1138
+ });
1139
+ }
1140
+ /**
1141
+ * Public proof-of-life update. Omit deliveryDate to extend by DMS_DEFAULT_EXTEND_DAYS.
1142
+ */
1143
+ patchApiDmsProofByToken(options) {
1144
+ return (options.client ?? this.client).patch({
1145
+ url: "/api/dms/proof/{token}",
1146
+ ...options
1147
+ });
1148
+ }
1149
+ /**
1150
+ * Public project wipe via claim token. Confirmation must equal the project name.
1151
+ */
1152
+ deleteApiDmsClaimByToken(options) {
1153
+ return (options.client ?? this.client).delete({
1154
+ url: "/api/dms/claim/{token}",
1155
+ ...options
1156
+ });
1157
+ }
1158
+ /**
1159
+ * Public claim HTML page with project notes and decrypted secrets (token credential).
1160
+ */
1161
+ getApiDmsClaimByToken(options) {
1162
+ return (options.client ?? this.client).get({
1163
+ url: "/api/dms/claim/{token}",
1164
+ ...options
1165
+ });
1166
+ }
1167
+ /**
1168
+ * List audit logs for a project. Only accessible by project admins. Supports date range filtering, pagination, and optional filters.
1169
+ */
1170
+ getApiProjectsByProjectIdAuditLogs(options) {
1171
+ return (options.client ?? this.client).get({
1172
+ security: [{
1173
+ scheme: "bearer",
1174
+ type: "http"
1175
+ }],
1176
+ url: "/api/projects/{projectId}/audit-logs",
1177
+ ...options
1178
+ });
1179
+ }
1180
+ /**
1181
+ * List all admins for a project
1182
+ */
1183
+ getApiProjectsByProjectIdAdmins(options) {
1184
+ return (options.client ?? this.client).get({
1185
+ security: [{
1186
+ scheme: "bearer",
1187
+ type: "http"
1188
+ }],
1189
+ url: "/api/projects/{projectId}/admins",
1190
+ ...options
1191
+ });
1192
+ }
1193
+ /**
1194
+ * Add a new admin to a project
1195
+ */
1196
+ postApiProjectsByProjectIdAdmins(options) {
1197
+ return (options.client ?? this.client).post({
1198
+ security: [{
1199
+ scheme: "bearer",
1200
+ type: "http"
1201
+ }],
1202
+ url: "/api/projects/{projectId}/admins",
1203
+ ...options,
1204
+ headers: {
1205
+ "Content-Type": "application/json",
1206
+ ...options.headers
1207
+ }
1208
+ });
1209
+ }
1210
+ /**
1211
+ * Remove an admin from a project
1212
+ */
1213
+ deleteApiProjectsByProjectIdAdminsBySubjectId(options) {
1214
+ return (options.client ?? this.client).delete({
1215
+ security: [{
1216
+ scheme: "bearer",
1217
+ type: "http"
1218
+ }],
1219
+ url: "/api/projects/{projectId}/admins/{subjectId}",
1220
+ ...options
1221
+ });
1222
+ }
1223
+ /**
1224
+ * List all users with access to a project (admins and/or users with permission grants)
1225
+ */
1226
+ getApiProjectsByProjectIdAccess(options) {
1227
+ return (options.client ?? this.client).get({
1228
+ security: [{
1229
+ scheme: "bearer",
1230
+ type: "http"
1231
+ }],
1232
+ url: "/api/projects/{projectId}/access",
1233
+ ...options
1234
+ });
1235
+ }
1236
+ /**
1237
+ * List or search all subjects in the authenticated tenant (users and machines)
1238
+ */
1239
+ getApiSubjects(options) {
1240
+ return (options?.client ?? this.client).get({
1241
+ security: [{
1242
+ scheme: "bearer",
1243
+ type: "http"
1244
+ }],
1245
+ url: "/api/subjects",
1246
+ ...options
1247
+ });
1248
+ }
1249
+ /**
1250
+ * List all tenant users annotated with admin status and permission-grant count for this project
1251
+ */
1252
+ getApiProjectsByProjectIdSubjects(options) {
1253
+ return (options.client ?? this.client).get({
1254
+ security: [{
1255
+ scheme: "bearer",
1256
+ type: "http"
1257
+ }],
1258
+ url: "/api/projects/{projectId}/subjects",
1259
+ ...options
1260
+ });
1261
+ }
1262
+ /**
1263
+ * Get the permission matrix for a user subject within a project
1264
+ */
1265
+ getApiProjectsByProjectIdPermissionsMatrix(options) {
1266
+ return (options.client ?? this.client).get({
1267
+ security: [{
1268
+ scheme: "bearer",
1269
+ type: "http"
1270
+ }],
1271
+ url: "/api/projects/{projectId}/permissions/matrix",
1272
+ ...options
1273
+ });
1274
+ }
1275
+ /**
1276
+ * Atomically add and remove permissions for a user subject in a project
1277
+ */
1278
+ postApiProjectsByProjectIdPermissionsBatch(options) {
1279
+ return (options.client ?? this.client).post({
1280
+ security: [{
1281
+ scheme: "bearer",
1282
+ type: "http"
1283
+ }],
1284
+ url: "/api/projects/{projectId}/permissions/batch",
1285
+ ...options,
1286
+ headers: {
1287
+ "Content-Type": "application/json",
1288
+ ...options.headers
1289
+ }
1290
+ });
1291
+ }
1292
+ /**
1293
+ * Get permission change audit logs for a project
1294
+ */
1295
+ getApiProjectsByProjectIdPermissionsAuditLogs(options) {
1296
+ return (options.client ?? this.client).get({
1297
+ security: [{
1298
+ scheme: "bearer",
1299
+ type: "http"
1300
+ }],
1301
+ url: "/api/projects/{projectId}/permissions/audit-logs",
1302
+ ...options
1303
+ });
1304
+ }
1305
+ /**
1306
+ * Get a read-only permission summary for a machine
1307
+ */
1308
+ getApiMachinesByIdPermissions(options) {
1309
+ return (options.client ?? this.client).get({
1310
+ security: [{
1311
+ scheme: "bearer",
1312
+ type: "http"
1313
+ }],
1314
+ url: "/api/machines/{id}/permissions",
1315
+ ...options
1316
+ });
1317
+ }
1318
+ /**
1319
+ * Assignable permission matrix for an owned machine (secrets the caller can see)
1320
+ */
1321
+ getApiMachinesByIdPermissionsMatrix(options) {
1322
+ return (options.client ?? this.client).get({
1323
+ security: [{
1324
+ scheme: "bearer",
1325
+ type: "http"
1326
+ }],
1327
+ url: "/api/machines/{id}/permissions/matrix",
1328
+ ...options
1329
+ });
1330
+ }
1331
+ /**
1332
+ * Add/remove permissions on an owned machine, capped by secrets the caller can see
1333
+ */
1334
+ postApiMachinesByIdPermissionsBatch(options) {
1335
+ return (options.client ?? this.client).post({
1336
+ security: [{
1337
+ scheme: "bearer",
1338
+ type: "http"
1339
+ }],
1340
+ url: "/api/machines/{id}/permissions/batch",
1341
+ ...options,
1342
+ headers: {
1343
+ "Content-Type": "application/json",
1344
+ ...options.headers
1345
+ }
1346
+ });
1347
+ }
1348
+ /**
1349
+ * Regenerate a machine ID (old ID invalidated immediately)
1350
+ */
1351
+ postApiMachinesByIdRegenerate(options) {
1352
+ return (options.client ?? this.client).post({
1353
+ security: [{
1354
+ scheme: "bearer",
1355
+ type: "http"
1356
+ }],
1357
+ url: "/api/machines/{id}/regenerate",
1358
+ ...options
1359
+ });
1360
+ }
1361
+ /**
1362
+ * Delete a machine (cascade permissions)
1363
+ */
1364
+ deleteApiMachinesById(options) {
1365
+ return (options.client ?? this.client).delete({
1366
+ security: [{
1367
+ scheme: "bearer",
1368
+ type: "http"
1369
+ }],
1370
+ url: "/api/machines/{id}",
1371
+ ...options
1372
+ });
1373
+ }
1374
+ /**
1375
+ * Get a single machine by ID (masked)
1376
+ */
1377
+ getApiMachinesById(options) {
1378
+ return (options.client ?? this.client).get({
1379
+ security: [{
1380
+ scheme: "bearer",
1381
+ type: "http"
1382
+ }],
1383
+ url: "/api/machines/{id}",
1384
+ ...options
1385
+ });
1386
+ }
1387
+ /**
1388
+ * Rename a machine (name only)
1389
+ */
1390
+ patchApiMachinesById(options) {
1391
+ return (options.client ?? this.client).patch({
1392
+ security: [{
1393
+ scheme: "bearer",
1394
+ type: "http"
1395
+ }],
1396
+ url: "/api/machines/{id}",
1397
+ ...options,
1398
+ headers: {
1399
+ "Content-Type": "application/json",
1400
+ ...options.headers
1401
+ }
1402
+ });
1403
+ }
1404
+ /**
1405
+ * Bulk delete machines (cascade permissions)
1406
+ */
1407
+ deleteApiMachines(options) {
1408
+ return (options.client ?? this.client).delete({
1409
+ security: [{
1410
+ scheme: "bearer",
1411
+ type: "http"
1412
+ }],
1413
+ url: "/api/machines",
1414
+ ...options,
1415
+ headers: {
1416
+ "Content-Type": "application/json",
1417
+ ...options.headers
1418
+ }
1419
+ });
1420
+ }
1421
+ /**
1422
+ * List own machines (creator-scoped, masked IDs)
1423
+ */
1424
+ getApiMachines(options) {
1425
+ return (options?.client ?? this.client).get({
1426
+ security: [{
1427
+ scheme: "bearer",
1428
+ type: "http"
1429
+ }],
1430
+ url: "/api/machines",
1431
+ ...options
1432
+ });
1433
+ }
1434
+ /**
1435
+ * Bulk update machine names
1436
+ */
1437
+ patchApiMachines(options) {
1438
+ return (options.client ?? this.client).patch({
1439
+ security: [{
1440
+ scheme: "bearer",
1441
+ type: "http"
1442
+ }],
1443
+ url: "/api/machines",
1444
+ ...options,
1445
+ headers: {
1446
+ "Content-Type": "application/json",
1447
+ ...options.headers
1448
+ }
1449
+ });
1450
+ }
1451
+ /**
1452
+ * Create a new machine identity (rawId shown once)
1453
+ */
1454
+ postApiMachines(options) {
1455
+ return (options.client ?? this.client).post({
1456
+ security: [{
1457
+ scheme: "bearer",
1458
+ type: "http"
1459
+ }],
1460
+ url: "/api/machines",
1461
+ ...options,
1462
+ headers: {
1463
+ "Content-Type": "application/json",
1464
+ ...options.headers
1465
+ }
1466
+ });
1467
+ }
1468
+ /**
1469
+ * Batch-get machines by IDs
1470
+ */
1471
+ postApiMachinesQuery(options) {
1472
+ return (options.client ?? this.client).post({
1473
+ security: [{
1474
+ scheme: "bearer",
1475
+ type: "http"
1476
+ }],
1477
+ url: "/api/machines/query",
1478
+ ...options,
1479
+ headers: {
1480
+ "Content-Type": "application/json",
1481
+ ...options.headers
1482
+ }
1483
+ });
1484
+ }
1485
+ /**
1486
+ * Clears the lumiblue-token HttpOnly cookie so the browser stops sending it on subsequent requests.
1487
+ */
1488
+ deleteApiLumiblueToken(options) {
1489
+ return (options?.client ?? this.client).delete({
1490
+ url: "/api/lumiblue-token",
1491
+ ...options
1492
+ });
1493
+ }
1494
+ };
1495
+ //#endregion
1496
+ export { Sdk, client, createSdkClient };