@eudiplo/sdk-core 1.14.0-main.0002da5

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.mjs ADDED
@@ -0,0 +1,2030 @@
1
+ // src/api/core/bodySerializer.gen.ts
2
+ var serializeFormDataPair = (data, key, value) => {
3
+ if (typeof value === "string" || value instanceof Blob) {
4
+ data.append(key, value);
5
+ } else if (value instanceof Date) {
6
+ data.append(key, value.toISOString());
7
+ } else {
8
+ data.append(key, JSON.stringify(value));
9
+ }
10
+ };
11
+ var formDataBodySerializer = {
12
+ bodySerializer: (body) => {
13
+ const data = new FormData();
14
+ Object.entries(body).forEach(([key, value]) => {
15
+ if (value === void 0 || value === null) {
16
+ return;
17
+ }
18
+ if (Array.isArray(value)) {
19
+ value.forEach((v) => serializeFormDataPair(data, key, v));
20
+ } else {
21
+ serializeFormDataPair(data, key, value);
22
+ }
23
+ });
24
+ return data;
25
+ }
26
+ };
27
+ var jsonBodySerializer = {
28
+ bodySerializer: (body) => JSON.stringify(
29
+ body,
30
+ (_key, value) => typeof value === "bigint" ? value.toString() : value
31
+ )
32
+ };
33
+
34
+ // src/api/core/serverSentEvents.gen.ts
35
+ var createSseClient = ({
36
+ onRequest,
37
+ onSseError,
38
+ onSseEvent,
39
+ responseTransformer,
40
+ responseValidator,
41
+ sseDefaultRetryDelay,
42
+ sseMaxRetryAttempts,
43
+ sseMaxRetryDelay,
44
+ sseSleepFn,
45
+ url,
46
+ ...options
47
+ }) => {
48
+ let lastEventId;
49
+ const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
50
+ const createStream = async function* () {
51
+ let retryDelay = sseDefaultRetryDelay ?? 3e3;
52
+ let attempt = 0;
53
+ const signal = options.signal ?? new AbortController().signal;
54
+ while (true) {
55
+ if (signal.aborted) break;
56
+ attempt++;
57
+ const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
58
+ if (lastEventId !== void 0) {
59
+ headers.set("Last-Event-ID", lastEventId);
60
+ }
61
+ try {
62
+ const requestInit = {
63
+ redirect: "follow",
64
+ ...options,
65
+ body: options.serializedBody,
66
+ headers,
67
+ signal
68
+ };
69
+ let request = new Request(url, requestInit);
70
+ if (onRequest) {
71
+ request = await onRequest(url, requestInit);
72
+ }
73
+ const _fetch = options.fetch ?? globalThis.fetch;
74
+ const response = await _fetch(request);
75
+ if (!response.ok)
76
+ throw new Error(
77
+ `SSE failed: ${response.status} ${response.statusText}`
78
+ );
79
+ if (!response.body) throw new Error("No body in SSE response");
80
+ const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
81
+ let buffer = "";
82
+ const abortHandler = () => {
83
+ try {
84
+ reader.cancel();
85
+ } catch {
86
+ }
87
+ };
88
+ signal.addEventListener("abort", abortHandler);
89
+ try {
90
+ while (true) {
91
+ const { done, value } = await reader.read();
92
+ if (done) break;
93
+ buffer += value;
94
+ buffer = buffer.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
95
+ const chunks = buffer.split("\n\n");
96
+ buffer = chunks.pop() ?? "";
97
+ for (const chunk of chunks) {
98
+ const lines = chunk.split("\n");
99
+ const dataLines = [];
100
+ let eventName;
101
+ for (const line of lines) {
102
+ if (line.startsWith("data:")) {
103
+ dataLines.push(line.replace(/^data:\s*/, ""));
104
+ } else if (line.startsWith("event:")) {
105
+ eventName = line.replace(/^event:\s*/, "");
106
+ } else if (line.startsWith("id:")) {
107
+ lastEventId = line.replace(/^id:\s*/, "");
108
+ } else if (line.startsWith("retry:")) {
109
+ const parsed = Number.parseInt(
110
+ line.replace(/^retry:\s*/, ""),
111
+ 10
112
+ );
113
+ if (!Number.isNaN(parsed)) {
114
+ retryDelay = parsed;
115
+ }
116
+ }
117
+ }
118
+ let data;
119
+ let parsedJson = false;
120
+ if (dataLines.length) {
121
+ const rawData = dataLines.join("\n");
122
+ try {
123
+ data = JSON.parse(rawData);
124
+ parsedJson = true;
125
+ } catch {
126
+ data = rawData;
127
+ }
128
+ }
129
+ if (parsedJson) {
130
+ if (responseValidator) {
131
+ await responseValidator(data);
132
+ }
133
+ if (responseTransformer) {
134
+ data = await responseTransformer(data);
135
+ }
136
+ }
137
+ onSseEvent?.({
138
+ data,
139
+ event: eventName,
140
+ id: lastEventId,
141
+ retry: retryDelay
142
+ });
143
+ if (dataLines.length) {
144
+ yield data;
145
+ }
146
+ }
147
+ }
148
+ } finally {
149
+ signal.removeEventListener("abort", abortHandler);
150
+ reader.releaseLock();
151
+ }
152
+ break;
153
+ } catch (error) {
154
+ onSseError?.(error);
155
+ if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
156
+ break;
157
+ }
158
+ const backoff = Math.min(
159
+ retryDelay * 2 ** (attempt - 1),
160
+ sseMaxRetryDelay ?? 3e4
161
+ );
162
+ await sleep(backoff);
163
+ }
164
+ }
165
+ };
166
+ const stream = createStream();
167
+ return { stream };
168
+ };
169
+
170
+ // src/api/core/pathSerializer.gen.ts
171
+ var separatorArrayExplode = (style) => {
172
+ switch (style) {
173
+ case "label":
174
+ return ".";
175
+ case "matrix":
176
+ return ";";
177
+ case "simple":
178
+ return ",";
179
+ default:
180
+ return "&";
181
+ }
182
+ };
183
+ var separatorArrayNoExplode = (style) => {
184
+ switch (style) {
185
+ case "form":
186
+ return ",";
187
+ case "pipeDelimited":
188
+ return "|";
189
+ case "spaceDelimited":
190
+ return "%20";
191
+ default:
192
+ return ",";
193
+ }
194
+ };
195
+ var separatorObjectExplode = (style) => {
196
+ switch (style) {
197
+ case "label":
198
+ return ".";
199
+ case "matrix":
200
+ return ";";
201
+ case "simple":
202
+ return ",";
203
+ default:
204
+ return "&";
205
+ }
206
+ };
207
+ var serializeArrayParam = ({
208
+ allowReserved,
209
+ explode,
210
+ name,
211
+ style,
212
+ value
213
+ }) => {
214
+ if (!explode) {
215
+ const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
216
+ switch (style) {
217
+ case "label":
218
+ return `.${joinedValues2}`;
219
+ case "matrix":
220
+ return `;${name}=${joinedValues2}`;
221
+ case "simple":
222
+ return joinedValues2;
223
+ default:
224
+ return `${name}=${joinedValues2}`;
225
+ }
226
+ }
227
+ const separator = separatorArrayExplode(style);
228
+ const joinedValues = value.map((v) => {
229
+ if (style === "label" || style === "simple") {
230
+ return allowReserved ? v : encodeURIComponent(v);
231
+ }
232
+ return serializePrimitiveParam({
233
+ allowReserved,
234
+ name,
235
+ value: v
236
+ });
237
+ }).join(separator);
238
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
239
+ };
240
+ var serializePrimitiveParam = ({
241
+ allowReserved,
242
+ name,
243
+ value
244
+ }) => {
245
+ if (value === void 0 || value === null) {
246
+ return "";
247
+ }
248
+ if (typeof value === "object") {
249
+ throw new Error(
250
+ "Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
251
+ );
252
+ }
253
+ return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
254
+ };
255
+ var serializeObjectParam = ({
256
+ allowReserved,
257
+ explode,
258
+ name,
259
+ style,
260
+ value,
261
+ valueOnly
262
+ }) => {
263
+ if (value instanceof Date) {
264
+ return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
265
+ }
266
+ if (style !== "deepObject" && !explode) {
267
+ let values = [];
268
+ Object.entries(value).forEach(([key, v]) => {
269
+ values = [
270
+ ...values,
271
+ key,
272
+ allowReserved ? v : encodeURIComponent(v)
273
+ ];
274
+ });
275
+ const joinedValues2 = values.join(",");
276
+ switch (style) {
277
+ case "form":
278
+ return `${name}=${joinedValues2}`;
279
+ case "label":
280
+ return `.${joinedValues2}`;
281
+ case "matrix":
282
+ return `;${name}=${joinedValues2}`;
283
+ default:
284
+ return joinedValues2;
285
+ }
286
+ }
287
+ const separator = separatorObjectExplode(style);
288
+ const joinedValues = Object.entries(value).map(
289
+ ([key, v]) => serializePrimitiveParam({
290
+ allowReserved,
291
+ name: style === "deepObject" ? `${name}[${key}]` : key,
292
+ value: v
293
+ })
294
+ ).join(separator);
295
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
296
+ };
297
+
298
+ // src/api/core/utils.gen.ts
299
+ var PATH_PARAM_RE = /\{[^{}]+\}/g;
300
+ var defaultPathSerializer = ({ path, url: _url }) => {
301
+ let url = _url;
302
+ const matches = _url.match(PATH_PARAM_RE);
303
+ if (matches) {
304
+ for (const match of matches) {
305
+ let explode = false;
306
+ let name = match.substring(1, match.length - 1);
307
+ let style = "simple";
308
+ if (name.endsWith("*")) {
309
+ explode = true;
310
+ name = name.substring(0, name.length - 1);
311
+ }
312
+ if (name.startsWith(".")) {
313
+ name = name.substring(1);
314
+ style = "label";
315
+ } else if (name.startsWith(";")) {
316
+ name = name.substring(1);
317
+ style = "matrix";
318
+ }
319
+ const value = path[name];
320
+ if (value === void 0 || value === null) {
321
+ continue;
322
+ }
323
+ if (Array.isArray(value)) {
324
+ url = url.replace(
325
+ match,
326
+ serializeArrayParam({ explode, name, style, value })
327
+ );
328
+ continue;
329
+ }
330
+ if (typeof value === "object") {
331
+ url = url.replace(
332
+ match,
333
+ serializeObjectParam({
334
+ explode,
335
+ name,
336
+ style,
337
+ value,
338
+ valueOnly: true
339
+ })
340
+ );
341
+ continue;
342
+ }
343
+ if (style === "matrix") {
344
+ url = url.replace(
345
+ match,
346
+ `;${serializePrimitiveParam({
347
+ name,
348
+ value
349
+ })}`
350
+ );
351
+ continue;
352
+ }
353
+ const replaceValue = encodeURIComponent(
354
+ style === "label" ? `.${value}` : value
355
+ );
356
+ url = url.replace(match, replaceValue);
357
+ }
358
+ }
359
+ return url;
360
+ };
361
+ var getUrl = ({
362
+ baseUrl,
363
+ path,
364
+ query,
365
+ querySerializer,
366
+ url: _url
367
+ }) => {
368
+ const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
369
+ let url = (baseUrl ?? "") + pathUrl;
370
+ if (path) {
371
+ url = defaultPathSerializer({ path, url });
372
+ }
373
+ let search = query ? querySerializer(query) : "";
374
+ if (search.startsWith("?")) {
375
+ search = search.substring(1);
376
+ }
377
+ if (search) {
378
+ url += `?${search}`;
379
+ }
380
+ return url;
381
+ };
382
+ function getValidRequestBody(options) {
383
+ const hasBody = options.body !== void 0;
384
+ const isSerializedBody = hasBody && options.bodySerializer;
385
+ if (isSerializedBody) {
386
+ if ("serializedBody" in options) {
387
+ const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
388
+ return hasSerializedBody ? options.serializedBody : null;
389
+ }
390
+ return options.body !== "" ? options.body : null;
391
+ }
392
+ if (hasBody) {
393
+ return options.body;
394
+ }
395
+ return void 0;
396
+ }
397
+
398
+ // src/api/core/auth.gen.ts
399
+ var getAuthToken = async (auth, callback) => {
400
+ const token = typeof callback === "function" ? await callback(auth) : callback;
401
+ if (!token) {
402
+ return;
403
+ }
404
+ if (auth.scheme === "bearer") {
405
+ return `Bearer ${token}`;
406
+ }
407
+ if (auth.scheme === "basic") {
408
+ return `Basic ${btoa(token)}`;
409
+ }
410
+ return token;
411
+ };
412
+
413
+ // src/api/client/utils.gen.ts
414
+ var createQuerySerializer = ({
415
+ parameters = {},
416
+ ...args
417
+ } = {}) => {
418
+ const querySerializer = (queryParams) => {
419
+ const search = [];
420
+ if (queryParams && typeof queryParams === "object") {
421
+ for (const name in queryParams) {
422
+ const value = queryParams[name];
423
+ if (value === void 0 || value === null) {
424
+ continue;
425
+ }
426
+ const options = parameters[name] || args;
427
+ if (Array.isArray(value)) {
428
+ const serializedArray = serializeArrayParam({
429
+ allowReserved: options.allowReserved,
430
+ explode: true,
431
+ name,
432
+ style: "form",
433
+ value,
434
+ ...options.array
435
+ });
436
+ if (serializedArray) search.push(serializedArray);
437
+ } else if (typeof value === "object") {
438
+ const serializedObject = serializeObjectParam({
439
+ allowReserved: options.allowReserved,
440
+ explode: true,
441
+ name,
442
+ style: "deepObject",
443
+ value,
444
+ ...options.object
445
+ });
446
+ if (serializedObject) search.push(serializedObject);
447
+ } else {
448
+ const serializedPrimitive = serializePrimitiveParam({
449
+ allowReserved: options.allowReserved,
450
+ name,
451
+ value
452
+ });
453
+ if (serializedPrimitive) search.push(serializedPrimitive);
454
+ }
455
+ }
456
+ }
457
+ return search.join("&");
458
+ };
459
+ return querySerializer;
460
+ };
461
+ var getParseAs = (contentType) => {
462
+ if (!contentType) {
463
+ return "stream";
464
+ }
465
+ const cleanContent = contentType.split(";")[0]?.trim();
466
+ if (!cleanContent) {
467
+ return;
468
+ }
469
+ if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
470
+ return "json";
471
+ }
472
+ if (cleanContent === "multipart/form-data") {
473
+ return "formData";
474
+ }
475
+ if (["application/", "audio/", "image/", "video/"].some(
476
+ (type) => cleanContent.startsWith(type)
477
+ )) {
478
+ return "blob";
479
+ }
480
+ if (cleanContent.startsWith("text/")) {
481
+ return "text";
482
+ }
483
+ return;
484
+ };
485
+ var checkForExistence = (options, name) => {
486
+ if (!name) {
487
+ return false;
488
+ }
489
+ if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
490
+ return true;
491
+ }
492
+ return false;
493
+ };
494
+ var setAuthParams = async ({
495
+ security,
496
+ ...options
497
+ }) => {
498
+ for (const auth of security) {
499
+ if (checkForExistence(options, auth.name)) {
500
+ continue;
501
+ }
502
+ const token = await getAuthToken(auth, options.auth);
503
+ if (!token) {
504
+ continue;
505
+ }
506
+ const name = auth.name ?? "Authorization";
507
+ switch (auth.in) {
508
+ case "query":
509
+ if (!options.query) {
510
+ options.query = {};
511
+ }
512
+ options.query[name] = token;
513
+ break;
514
+ case "cookie":
515
+ options.headers.append("Cookie", `${name}=${token}`);
516
+ break;
517
+ case "header":
518
+ default:
519
+ options.headers.set(name, token);
520
+ break;
521
+ }
522
+ }
523
+ };
524
+ var buildUrl = (options) => getUrl({
525
+ baseUrl: options.baseUrl,
526
+ path: options.path,
527
+ query: options.query,
528
+ querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
529
+ url: options.url
530
+ });
531
+ var mergeConfigs = (a, b) => {
532
+ const config = { ...a, ...b };
533
+ if (config.baseUrl?.endsWith("/")) {
534
+ config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
535
+ }
536
+ config.headers = mergeHeaders(a.headers, b.headers);
537
+ return config;
538
+ };
539
+ var headersEntries = (headers) => {
540
+ const entries = [];
541
+ headers.forEach((value, key) => {
542
+ entries.push([key, value]);
543
+ });
544
+ return entries;
545
+ };
546
+ var mergeHeaders = (...headers) => {
547
+ const mergedHeaders = new Headers();
548
+ for (const header of headers) {
549
+ if (!header) {
550
+ continue;
551
+ }
552
+ const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
553
+ for (const [key, value] of iterator) {
554
+ if (value === null) {
555
+ mergedHeaders.delete(key);
556
+ } else if (Array.isArray(value)) {
557
+ for (const v of value) {
558
+ mergedHeaders.append(key, v);
559
+ }
560
+ } else if (value !== void 0) {
561
+ mergedHeaders.set(
562
+ key,
563
+ typeof value === "object" ? JSON.stringify(value) : value
564
+ );
565
+ }
566
+ }
567
+ }
568
+ return mergedHeaders;
569
+ };
570
+ var Interceptors = class {
571
+ fns = [];
572
+ clear() {
573
+ this.fns = [];
574
+ }
575
+ eject(id) {
576
+ const index = this.getInterceptorIndex(id);
577
+ if (this.fns[index]) {
578
+ this.fns[index] = null;
579
+ }
580
+ }
581
+ exists(id) {
582
+ const index = this.getInterceptorIndex(id);
583
+ return Boolean(this.fns[index]);
584
+ }
585
+ getInterceptorIndex(id) {
586
+ if (typeof id === "number") {
587
+ return this.fns[id] ? id : -1;
588
+ }
589
+ return this.fns.indexOf(id);
590
+ }
591
+ update(id, fn) {
592
+ const index = this.getInterceptorIndex(id);
593
+ if (this.fns[index]) {
594
+ this.fns[index] = fn;
595
+ return id;
596
+ }
597
+ return false;
598
+ }
599
+ use(fn) {
600
+ this.fns.push(fn);
601
+ return this.fns.length - 1;
602
+ }
603
+ };
604
+ var createInterceptors = () => ({
605
+ error: new Interceptors(),
606
+ request: new Interceptors(),
607
+ response: new Interceptors()
608
+ });
609
+ var defaultQuerySerializer = createQuerySerializer({
610
+ allowReserved: false,
611
+ array: {
612
+ explode: true,
613
+ style: "form"
614
+ },
615
+ object: {
616
+ explode: true,
617
+ style: "deepObject"
618
+ }
619
+ });
620
+ var defaultHeaders = {
621
+ "Content-Type": "application/json"
622
+ };
623
+ var createConfig = (override = {}) => ({
624
+ ...jsonBodySerializer,
625
+ headers: defaultHeaders,
626
+ parseAs: "auto",
627
+ querySerializer: defaultQuerySerializer,
628
+ ...override
629
+ });
630
+
631
+ // src/api/client/client.gen.ts
632
+ var createClient = (config = {}) => {
633
+ let _config = mergeConfigs(createConfig(), config);
634
+ const getConfig = () => ({ ..._config });
635
+ const setConfig = (config2) => {
636
+ _config = mergeConfigs(_config, config2);
637
+ return getConfig();
638
+ };
639
+ const interceptors = createInterceptors();
640
+ const beforeRequest = async (options) => {
641
+ const opts = {
642
+ ..._config,
643
+ ...options,
644
+ fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
645
+ headers: mergeHeaders(_config.headers, options.headers),
646
+ serializedBody: void 0
647
+ };
648
+ if (opts.security) {
649
+ await setAuthParams({
650
+ ...opts,
651
+ security: opts.security
652
+ });
653
+ }
654
+ if (opts.requestValidator) {
655
+ await opts.requestValidator(opts);
656
+ }
657
+ if (opts.body !== void 0 && opts.bodySerializer) {
658
+ opts.serializedBody = opts.bodySerializer(opts.body);
659
+ }
660
+ if (opts.body === void 0 || opts.serializedBody === "") {
661
+ opts.headers.delete("Content-Type");
662
+ }
663
+ const url = buildUrl(opts);
664
+ return { opts, url };
665
+ };
666
+ const request = async (options) => {
667
+ const { opts, url } = await beforeRequest(options);
668
+ const requestInit = {
669
+ redirect: "follow",
670
+ ...opts,
671
+ body: getValidRequestBody(opts)
672
+ };
673
+ let request2 = new Request(url, requestInit);
674
+ for (const fn of interceptors.request.fns) {
675
+ if (fn) {
676
+ request2 = await fn(request2, opts);
677
+ }
678
+ }
679
+ const _fetch = opts.fetch;
680
+ let response;
681
+ try {
682
+ response = await _fetch(request2);
683
+ } catch (error2) {
684
+ let finalError2 = error2;
685
+ for (const fn of interceptors.error.fns) {
686
+ if (fn) {
687
+ finalError2 = await fn(
688
+ error2,
689
+ void 0,
690
+ request2,
691
+ opts
692
+ );
693
+ }
694
+ }
695
+ finalError2 = finalError2 || {};
696
+ if (opts.throwOnError) {
697
+ throw finalError2;
698
+ }
699
+ return opts.responseStyle === "data" ? void 0 : {
700
+ error: finalError2,
701
+ request: request2,
702
+ response: void 0
703
+ };
704
+ }
705
+ for (const fn of interceptors.response.fns) {
706
+ if (fn) {
707
+ response = await fn(response, request2, opts);
708
+ }
709
+ }
710
+ const result = {
711
+ request: request2,
712
+ response
713
+ };
714
+ if (response.ok) {
715
+ const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
716
+ if (response.status === 204 || response.headers.get("Content-Length") === "0") {
717
+ let emptyData;
718
+ switch (parseAs) {
719
+ case "arrayBuffer":
720
+ case "blob":
721
+ case "text":
722
+ emptyData = await response[parseAs]();
723
+ break;
724
+ case "formData":
725
+ emptyData = new FormData();
726
+ break;
727
+ case "stream":
728
+ emptyData = response.body;
729
+ break;
730
+ case "json":
731
+ default:
732
+ emptyData = {};
733
+ break;
734
+ }
735
+ return opts.responseStyle === "data" ? emptyData : {
736
+ data: emptyData,
737
+ ...result
738
+ };
739
+ }
740
+ let data;
741
+ switch (parseAs) {
742
+ case "arrayBuffer":
743
+ case "blob":
744
+ case "formData":
745
+ case "text":
746
+ data = await response[parseAs]();
747
+ break;
748
+ case "json": {
749
+ const text = await response.text();
750
+ data = text ? JSON.parse(text) : {};
751
+ break;
752
+ }
753
+ case "stream":
754
+ return opts.responseStyle === "data" ? response.body : {
755
+ data: response.body,
756
+ ...result
757
+ };
758
+ }
759
+ if (parseAs === "json") {
760
+ if (opts.responseValidator) {
761
+ await opts.responseValidator(data);
762
+ }
763
+ if (opts.responseTransformer) {
764
+ data = await opts.responseTransformer(data);
765
+ }
766
+ }
767
+ return opts.responseStyle === "data" ? data : {
768
+ data,
769
+ ...result
770
+ };
771
+ }
772
+ const textError = await response.text();
773
+ let jsonError;
774
+ try {
775
+ jsonError = JSON.parse(textError);
776
+ } catch {
777
+ }
778
+ const error = jsonError ?? textError;
779
+ let finalError = error;
780
+ for (const fn of interceptors.error.fns) {
781
+ if (fn) {
782
+ finalError = await fn(error, response, request2, opts);
783
+ }
784
+ }
785
+ finalError = finalError || {};
786
+ if (opts.throwOnError) {
787
+ throw finalError;
788
+ }
789
+ return opts.responseStyle === "data" ? void 0 : {
790
+ error: finalError,
791
+ ...result
792
+ };
793
+ };
794
+ const makeMethodFn = (method) => (options) => request({ ...options, method });
795
+ const makeSseFn = (method) => async (options) => {
796
+ const { opts, url } = await beforeRequest(options);
797
+ return createSseClient({
798
+ ...opts,
799
+ body: opts.body,
800
+ headers: opts.headers,
801
+ method,
802
+ onRequest: async (url2, init) => {
803
+ let request2 = new Request(url2, init);
804
+ for (const fn of interceptors.request.fns) {
805
+ if (fn) {
806
+ request2 = await fn(request2, opts);
807
+ }
808
+ }
809
+ return request2;
810
+ },
811
+ serializedBody: getValidRequestBody(opts),
812
+ url
813
+ });
814
+ };
815
+ return {
816
+ buildUrl,
817
+ connect: makeMethodFn("CONNECT"),
818
+ delete: makeMethodFn("DELETE"),
819
+ get: makeMethodFn("GET"),
820
+ getConfig,
821
+ head: makeMethodFn("HEAD"),
822
+ interceptors,
823
+ options: makeMethodFn("OPTIONS"),
824
+ patch: makeMethodFn("PATCH"),
825
+ post: makeMethodFn("POST"),
826
+ put: makeMethodFn("PUT"),
827
+ request,
828
+ setConfig,
829
+ sse: {
830
+ connect: makeSseFn("CONNECT"),
831
+ delete: makeSseFn("DELETE"),
832
+ get: makeSseFn("GET"),
833
+ head: makeSseFn("HEAD"),
834
+ options: makeSseFn("OPTIONS"),
835
+ patch: makeSseFn("PATCH"),
836
+ post: makeSseFn("POST"),
837
+ put: makeSseFn("PUT"),
838
+ trace: makeSseFn("TRACE")
839
+ },
840
+ trace: makeMethodFn("TRACE")
841
+ };
842
+ };
843
+
844
+ // src/api/client.gen.ts
845
+ var client = createClient(
846
+ createConfig({ throwOnError: true })
847
+ );
848
+
849
+ // src/api/sdk.gen.ts
850
+ var appControllerGetVersion = (options) => (options?.client ?? client).get({
851
+ security: [{ scheme: "bearer", type: "http" }],
852
+ url: "/api/version",
853
+ ...options
854
+ });
855
+ var tenantControllerGetTenants = (options) => (options?.client ?? client).get({
856
+ security: [{ scheme: "bearer", type: "http" }],
857
+ url: "/api/tenant",
858
+ ...options
859
+ });
860
+ var tenantControllerInitTenant = (options) => (options.client ?? client).post({
861
+ security: [{ scheme: "bearer", type: "http" }],
862
+ url: "/api/tenant",
863
+ ...options,
864
+ headers: {
865
+ "Content-Type": "application/json",
866
+ ...options.headers
867
+ }
868
+ });
869
+ var tenantControllerDeleteTenant = (options) => (options.client ?? client).delete({
870
+ security: [{ scheme: "bearer", type: "http" }],
871
+ url: "/api/tenant/{id}",
872
+ ...options
873
+ });
874
+ var tenantControllerGetTenant = (options) => (options.client ?? client).get({
875
+ security: [{ scheme: "bearer", type: "http" }],
876
+ url: "/api/tenant/{id}",
877
+ ...options
878
+ });
879
+ var tenantControllerUpdateTenant = (options) => (options.client ?? client).patch({
880
+ security: [{ scheme: "bearer", type: "http" }],
881
+ url: "/api/tenant/{id}",
882
+ ...options,
883
+ headers: {
884
+ "Content-Type": "application/json",
885
+ ...options.headers
886
+ }
887
+ });
888
+ var clientControllerGetClients = (options) => (options?.client ?? client).get({
889
+ security: [{ scheme: "bearer", type: "http" }],
890
+ url: "/api/client",
891
+ ...options
892
+ });
893
+ var clientControllerCreateClient = (options) => (options.client ?? client).post({
894
+ security: [{ scheme: "bearer", type: "http" }],
895
+ url: "/api/client",
896
+ ...options,
897
+ headers: {
898
+ "Content-Type": "application/json",
899
+ ...options.headers
900
+ }
901
+ });
902
+ var clientControllerDeleteClient = (options) => (options.client ?? client).delete({
903
+ security: [{ scheme: "bearer", type: "http" }],
904
+ url: "/api/client/{id}",
905
+ ...options
906
+ });
907
+ var clientControllerGetClient = (options) => (options.client ?? client).get({
908
+ security: [{ scheme: "bearer", type: "http" }],
909
+ url: "/api/client/{id}",
910
+ ...options
911
+ });
912
+ var clientControllerUpdateClient = (options) => (options.client ?? client).patch({
913
+ security: [{ scheme: "bearer", type: "http" }],
914
+ url: "/api/client/{id}",
915
+ ...options,
916
+ headers: {
917
+ "Content-Type": "application/json",
918
+ ...options.headers
919
+ }
920
+ });
921
+ var clientControllerGetClientSecret = (options) => (options.client ?? client).get({
922
+ security: [{ scheme: "bearer", type: "http" }],
923
+ url: "/api/client/{id}/secret",
924
+ ...options
925
+ });
926
+ var clientControllerRotateClientSecret = (options) => (options.client ?? client).post({
927
+ security: [{ scheme: "bearer", type: "http" }],
928
+ url: "/api/client/{id}/rotate-secret",
929
+ ...options
930
+ });
931
+ var statusListConfigControllerResetConfig = (options) => (options?.client ?? client).delete({
932
+ security: [{ scheme: "bearer", type: "http" }],
933
+ url: "/api/status-list-config",
934
+ ...options
935
+ });
936
+ var statusListConfigControllerGetConfig = (options) => (options?.client ?? client).get({
937
+ security: [{ scheme: "bearer", type: "http" }],
938
+ url: "/api/status-list-config",
939
+ ...options
940
+ });
941
+ var statusListConfigControllerUpdateConfig = (options) => (options.client ?? client).put({
942
+ security: [{ scheme: "bearer", type: "http" }],
943
+ url: "/api/status-list-config",
944
+ ...options,
945
+ headers: {
946
+ "Content-Type": "application/json",
947
+ ...options.headers
948
+ }
949
+ });
950
+ var statusListManagementControllerGetLists = (options) => (options?.client ?? client).get({
951
+ security: [{ scheme: "bearer", type: "http" }],
952
+ url: "/api/status-lists",
953
+ ...options
954
+ });
955
+ var statusListManagementControllerCreateList = (options) => (options.client ?? client).post({
956
+ security: [{ scheme: "bearer", type: "http" }],
957
+ url: "/api/status-lists",
958
+ ...options,
959
+ headers: {
960
+ "Content-Type": "application/json",
961
+ ...options.headers
962
+ }
963
+ });
964
+ var statusListManagementControllerDeleteList = (options) => (options.client ?? client).delete({
965
+ security: [{ scheme: "bearer", type: "http" }],
966
+ url: "/api/status-lists/{listId}",
967
+ ...options
968
+ });
969
+ var statusListManagementControllerGetList = (options) => (options.client ?? client).get({
970
+ security: [{ scheme: "bearer", type: "http" }],
971
+ url: "/api/status-lists/{listId}",
972
+ ...options
973
+ });
974
+ var statusListManagementControllerUpdateList = (options) => (options.client ?? client).patch({
975
+ security: [{ scheme: "bearer", type: "http" }],
976
+ url: "/api/status-lists/{listId}",
977
+ ...options,
978
+ headers: {
979
+ "Content-Type": "application/json",
980
+ ...options.headers
981
+ }
982
+ });
983
+ var sessionControllerGetAllSessions = (options) => (options?.client ?? client).get({
984
+ security: [{ scheme: "bearer", type: "http" }],
985
+ url: "/api/session",
986
+ ...options
987
+ });
988
+ var sessionControllerDeleteSession = (options) => (options.client ?? client).delete({
989
+ security: [{ scheme: "bearer", type: "http" }],
990
+ url: "/api/session/{id}",
991
+ ...options
992
+ });
993
+ var sessionControllerGetSession = (options) => (options.client ?? client).get({
994
+ security: [{ scheme: "bearer", type: "http" }],
995
+ url: "/api/session/{id}",
996
+ ...options
997
+ });
998
+ var sessionControllerGetSessionLogs = (options) => (options.client ?? client).get({
999
+ security: [{ scheme: "bearer", type: "http" }],
1000
+ url: "/api/session/{id}/logs",
1001
+ ...options
1002
+ });
1003
+ var sessionControllerRevokeAll = (options) => (options.client ?? client).post({
1004
+ security: [{ scheme: "bearer", type: "http" }],
1005
+ url: "/api/session/revoke",
1006
+ ...options,
1007
+ headers: {
1008
+ "Content-Type": "application/json",
1009
+ ...options.headers
1010
+ }
1011
+ });
1012
+ var sessionConfigControllerResetConfig = (options) => (options?.client ?? client).delete({
1013
+ security: [{ scheme: "bearer", type: "http" }],
1014
+ url: "/api/session-config",
1015
+ ...options
1016
+ });
1017
+ var sessionConfigControllerGetConfig = (options) => (options?.client ?? client).get({
1018
+ security: [{ scheme: "bearer", type: "http" }],
1019
+ url: "/api/session-config",
1020
+ ...options
1021
+ });
1022
+ var sessionConfigControllerUpdateConfig = (options) => (options.client ?? client).put({
1023
+ security: [{ scheme: "bearer", type: "http" }],
1024
+ url: "/api/session-config",
1025
+ ...options,
1026
+ headers: {
1027
+ "Content-Type": "application/json",
1028
+ ...options.headers
1029
+ }
1030
+ });
1031
+ var sessionEventsControllerSubscribeToSessionEvents = (options) => (options.client ?? client).get({ url: "/api/session/{id}/events", ...options });
1032
+ var issuanceConfigControllerGetIssuanceConfigurations = (options) => (options?.client ?? client).get({
1033
+ security: [{ scheme: "bearer", type: "http" }],
1034
+ url: "/api/issuer/config",
1035
+ ...options
1036
+ });
1037
+ var issuanceConfigControllerStoreIssuanceConfiguration = (options) => (options.client ?? client).post({
1038
+ security: [{ scheme: "bearer", type: "http" }],
1039
+ url: "/api/issuer/config",
1040
+ ...options,
1041
+ headers: {
1042
+ "Content-Type": "application/json",
1043
+ ...options.headers
1044
+ }
1045
+ });
1046
+ var credentialConfigControllerGetConfigs = (options) => (options?.client ?? client).get({
1047
+ security: [{ scheme: "bearer", type: "http" }],
1048
+ url: "/api/issuer/credentials",
1049
+ ...options
1050
+ });
1051
+ var credentialConfigControllerStoreCredentialConfiguration = (options) => (options.client ?? client).post({
1052
+ security: [{ scheme: "bearer", type: "http" }],
1053
+ url: "/api/issuer/credentials",
1054
+ ...options,
1055
+ headers: {
1056
+ "Content-Type": "application/json",
1057
+ ...options.headers
1058
+ }
1059
+ });
1060
+ var credentialConfigControllerDeleteIssuanceConfiguration = (options) => (options.client ?? client).delete({
1061
+ security: [{ scheme: "bearer", type: "http" }],
1062
+ url: "/api/issuer/credentials/{id}",
1063
+ ...options
1064
+ });
1065
+ var credentialConfigControllerGetConfigById = (options) => (options.client ?? client).get({
1066
+ security: [{ scheme: "bearer", type: "http" }],
1067
+ url: "/api/issuer/credentials/{id}",
1068
+ ...options
1069
+ });
1070
+ var credentialConfigControllerUpdateCredentialConfiguration = (options) => (options.client ?? client).patch({
1071
+ security: [{ scheme: "bearer", type: "http" }],
1072
+ url: "/api/issuer/credentials/{id}",
1073
+ ...options,
1074
+ headers: {
1075
+ "Content-Type": "application/json",
1076
+ ...options.headers
1077
+ }
1078
+ });
1079
+ var attributeProviderControllerGetAll = (options) => (options?.client ?? client).get({
1080
+ security: [{ scheme: "bearer", type: "http" }],
1081
+ url: "/api/issuer/attribute-providers",
1082
+ ...options
1083
+ });
1084
+ var attributeProviderControllerCreate = (options) => (options.client ?? client).post({
1085
+ security: [{ scheme: "bearer", type: "http" }],
1086
+ url: "/api/issuer/attribute-providers",
1087
+ ...options,
1088
+ headers: {
1089
+ "Content-Type": "application/json",
1090
+ ...options.headers
1091
+ }
1092
+ });
1093
+ var attributeProviderControllerDelete = (options) => (options.client ?? client).delete({
1094
+ security: [{ scheme: "bearer", type: "http" }],
1095
+ url: "/api/issuer/attribute-providers/{id}",
1096
+ ...options
1097
+ });
1098
+ var attributeProviderControllerGetById = (options) => (options.client ?? client).get({
1099
+ security: [{ scheme: "bearer", type: "http" }],
1100
+ url: "/api/issuer/attribute-providers/{id}",
1101
+ ...options
1102
+ });
1103
+ var attributeProviderControllerUpdate = (options) => (options.client ?? client).patch({
1104
+ security: [{ scheme: "bearer", type: "http" }],
1105
+ url: "/api/issuer/attribute-providers/{id}",
1106
+ ...options,
1107
+ headers: {
1108
+ "Content-Type": "application/json",
1109
+ ...options.headers
1110
+ }
1111
+ });
1112
+ var webhookEndpointControllerGetAll = (options) => (options?.client ?? client).get({
1113
+ security: [{ scheme: "bearer", type: "http" }],
1114
+ url: "/api/issuer/webhook-endpoints",
1115
+ ...options
1116
+ });
1117
+ var webhookEndpointControllerCreate = (options) => (options.client ?? client).post({
1118
+ security: [{ scheme: "bearer", type: "http" }],
1119
+ url: "/api/issuer/webhook-endpoints",
1120
+ ...options,
1121
+ headers: {
1122
+ "Content-Type": "application/json",
1123
+ ...options.headers
1124
+ }
1125
+ });
1126
+ var webhookEndpointControllerDelete = (options) => (options.client ?? client).delete({
1127
+ security: [{ scheme: "bearer", type: "http" }],
1128
+ url: "/api/issuer/webhook-endpoints/{id}",
1129
+ ...options
1130
+ });
1131
+ var webhookEndpointControllerGetById = (options) => (options.client ?? client).get({
1132
+ security: [{ scheme: "bearer", type: "http" }],
1133
+ url: "/api/issuer/webhook-endpoints/{id}",
1134
+ ...options
1135
+ });
1136
+ var webhookEndpointControllerUpdate = (options) => (options.client ?? client).patch({
1137
+ security: [{ scheme: "bearer", type: "http" }],
1138
+ url: "/api/issuer/webhook-endpoints/{id}",
1139
+ ...options,
1140
+ headers: {
1141
+ "Content-Type": "application/json",
1142
+ ...options.headers
1143
+ }
1144
+ });
1145
+ var presentationManagementControllerConfiguration = (options) => (options?.client ?? client).get({
1146
+ security: [{ scheme: "bearer", type: "http" }],
1147
+ url: "/api/verifier/config",
1148
+ ...options
1149
+ });
1150
+ var presentationManagementControllerStorePresentationConfig = (options) => (options.client ?? client).post({
1151
+ security: [{ scheme: "bearer", type: "http" }],
1152
+ url: "/api/verifier/config",
1153
+ ...options,
1154
+ headers: {
1155
+ "Content-Type": "application/json",
1156
+ ...options.headers
1157
+ }
1158
+ });
1159
+ var presentationManagementControllerDeleteConfiguration = (options) => (options.client ?? client).delete({
1160
+ security: [{ scheme: "bearer", type: "http" }],
1161
+ url: "/api/verifier/config/{id}",
1162
+ ...options
1163
+ });
1164
+ var presentationManagementControllerGetConfiguration = (options) => (options.client ?? client).get({
1165
+ security: [{ scheme: "bearer", type: "http" }],
1166
+ url: "/api/verifier/config/{id}",
1167
+ ...options
1168
+ });
1169
+ var presentationManagementControllerUpdateConfiguration = (options) => (options.client ?? client).patch({
1170
+ security: [{ scheme: "bearer", type: "http" }],
1171
+ url: "/api/verifier/config/{id}",
1172
+ ...options,
1173
+ headers: {
1174
+ "Content-Type": "application/json",
1175
+ ...options.headers
1176
+ }
1177
+ });
1178
+ var cacheControllerGetStats = (options) => (options?.client ?? client).get({
1179
+ security: [{ scheme: "bearer", type: "http" }],
1180
+ url: "/api/cache/stats",
1181
+ ...options
1182
+ });
1183
+ var cacheControllerClearAllCaches = (options) => (options?.client ?? client).delete({
1184
+ security: [{ scheme: "bearer", type: "http" }],
1185
+ url: "/api/cache",
1186
+ ...options
1187
+ });
1188
+ var cacheControllerClearTrustListCache = (options) => (options?.client ?? client).delete({
1189
+ security: [{ scheme: "bearer", type: "http" }],
1190
+ url: "/api/cache/trust-list",
1191
+ ...options
1192
+ });
1193
+ var cacheControllerClearStatusListCache = (options) => (options?.client ?? client).delete({
1194
+ security: [{ scheme: "bearer", type: "http" }],
1195
+ url: "/api/cache/status-list",
1196
+ ...options
1197
+ });
1198
+ var credentialOfferControllerGetOffer = (options) => (options.client ?? client).post({
1199
+ security: [{ scheme: "bearer", type: "http" }],
1200
+ url: "/api/issuer/offer",
1201
+ ...options,
1202
+ headers: {
1203
+ "Content-Type": "application/json",
1204
+ ...options.headers
1205
+ }
1206
+ });
1207
+ var deferredControllerCompleteDeferred = (options) => (options.client ?? client).post({
1208
+ security: [{ scheme: "bearer", type: "http" }],
1209
+ url: "/api/issuer/deferred/{transactionId}/complete",
1210
+ ...options,
1211
+ headers: {
1212
+ "Content-Type": "application/json",
1213
+ ...options.headers
1214
+ }
1215
+ });
1216
+ var deferredControllerFailDeferred = (options) => (options.client ?? client).post({
1217
+ security: [{ scheme: "bearer", type: "http" }],
1218
+ url: "/api/issuer/deferred/{transactionId}/fail",
1219
+ ...options,
1220
+ headers: {
1221
+ "Content-Type": "application/json",
1222
+ ...options.headers
1223
+ }
1224
+ });
1225
+ var registrarControllerDeleteConfig = (options) => (options?.client ?? client).delete({
1226
+ security: [{ scheme: "bearer", type: "http" }],
1227
+ url: "/api/registrar/config",
1228
+ ...options
1229
+ });
1230
+ var registrarControllerGetConfig = (options) => (options?.client ?? client).get({
1231
+ security: [{ scheme: "bearer", type: "http" }],
1232
+ url: "/api/registrar/config",
1233
+ ...options
1234
+ });
1235
+ var registrarControllerUpdateConfig = (options) => (options.client ?? client).patch({
1236
+ security: [{ scheme: "bearer", type: "http" }],
1237
+ url: "/api/registrar/config",
1238
+ ...options,
1239
+ headers: {
1240
+ "Content-Type": "application/json",
1241
+ ...options.headers
1242
+ }
1243
+ });
1244
+ var registrarControllerCreateConfig = (options) => (options.client ?? client).post({
1245
+ security: [{ scheme: "bearer", type: "http" }],
1246
+ url: "/api/registrar/config",
1247
+ ...options,
1248
+ headers: {
1249
+ "Content-Type": "application/json",
1250
+ ...options.headers
1251
+ }
1252
+ });
1253
+ var registrarControllerCreateAccessCertificate = (options) => (options.client ?? client).post({
1254
+ security: [{ scheme: "bearer", type: "http" }],
1255
+ url: "/api/registrar/access-certificate",
1256
+ ...options,
1257
+ headers: {
1258
+ "Content-Type": "application/json",
1259
+ ...options.headers
1260
+ }
1261
+ });
1262
+ var trustListControllerGetAllTrustLists = (options) => (options?.client ?? client).get({
1263
+ security: [{ scheme: "bearer", type: "http" }],
1264
+ url: "/api/trust-list",
1265
+ ...options
1266
+ });
1267
+ var trustListControllerCreateTrustList = (options) => (options.client ?? client).post({
1268
+ security: [{ scheme: "bearer", type: "http" }],
1269
+ url: "/api/trust-list",
1270
+ ...options,
1271
+ headers: {
1272
+ "Content-Type": "application/json",
1273
+ ...options.headers
1274
+ }
1275
+ });
1276
+ var trustListControllerDeleteTrustList = (options) => (options.client ?? client).delete({
1277
+ security: [{ scheme: "bearer", type: "http" }],
1278
+ url: "/api/trust-list/{id}",
1279
+ ...options
1280
+ });
1281
+ var trustListControllerGetTrustList = (options) => (options.client ?? client).get({
1282
+ security: [{ scheme: "bearer", type: "http" }],
1283
+ url: "/api/trust-list/{id}",
1284
+ ...options
1285
+ });
1286
+ var trustListControllerUpdateTrustList = (options) => (options.client ?? client).put({
1287
+ security: [{ scheme: "bearer", type: "http" }],
1288
+ url: "/api/trust-list/{id}",
1289
+ ...options,
1290
+ headers: {
1291
+ "Content-Type": "application/json",
1292
+ ...options.headers
1293
+ }
1294
+ });
1295
+ var trustListControllerExportTrustList = (options) => (options.client ?? client).get({
1296
+ security: [{ scheme: "bearer", type: "http" }],
1297
+ url: "/api/trust-list/{id}/export",
1298
+ ...options
1299
+ });
1300
+ var trustListControllerGetTrustListVersions = (options) => (options.client ?? client).get({
1301
+ security: [{ scheme: "bearer", type: "http" }],
1302
+ url: "/api/trust-list/{id}/versions",
1303
+ ...options
1304
+ });
1305
+ var trustListControllerGetTrustListVersion = (options) => (options.client ?? client).get({
1306
+ security: [{ scheme: "bearer", type: "http" }],
1307
+ url: "/api/trust-list/{id}/versions/{versionId}",
1308
+ ...options
1309
+ });
1310
+ var keyChainControllerGetProviders = (options) => (options?.client ?? client).get({
1311
+ security: [{ scheme: "bearer", type: "http" }],
1312
+ url: "/api/key-chain/providers",
1313
+ ...options
1314
+ });
1315
+ var keyChainControllerGetAll = (options) => (options?.client ?? client).get({
1316
+ security: [{ scheme: "bearer", type: "http" }],
1317
+ url: "/api/key-chain",
1318
+ ...options
1319
+ });
1320
+ var keyChainControllerCreate = (options) => (options.client ?? client).post({
1321
+ security: [{ scheme: "bearer", type: "http" }],
1322
+ url: "/api/key-chain",
1323
+ ...options,
1324
+ headers: {
1325
+ "Content-Type": "application/json",
1326
+ ...options.headers
1327
+ }
1328
+ });
1329
+ var keyChainControllerDelete = (options) => (options.client ?? client).delete({
1330
+ security: [{ scheme: "bearer", type: "http" }],
1331
+ url: "/api/key-chain/{id}",
1332
+ ...options
1333
+ });
1334
+ var keyChainControllerGetById = (options) => (options.client ?? client).get({
1335
+ security: [{ scheme: "bearer", type: "http" }],
1336
+ url: "/api/key-chain/{id}",
1337
+ ...options
1338
+ });
1339
+ var keyChainControllerUpdate = (options) => (options.client ?? client).put({
1340
+ security: [{ scheme: "bearer", type: "http" }],
1341
+ url: "/api/key-chain/{id}",
1342
+ ...options,
1343
+ headers: {
1344
+ "Content-Type": "application/json",
1345
+ ...options.headers
1346
+ }
1347
+ });
1348
+ var keyChainControllerExport = (options) => (options.client ?? client).get({
1349
+ security: [{ scheme: "bearer", type: "http" }],
1350
+ url: "/api/key-chain/{id}/export",
1351
+ ...options
1352
+ });
1353
+ var keyChainControllerImport = (options) => (options.client ?? client).post({
1354
+ security: [{ scheme: "bearer", type: "http" }],
1355
+ url: "/api/key-chain/import",
1356
+ ...options,
1357
+ headers: {
1358
+ "Content-Type": "application/json",
1359
+ ...options.headers
1360
+ }
1361
+ });
1362
+ var keyChainControllerRotate = (options) => (options.client ?? client).post({
1363
+ security: [{ scheme: "bearer", type: "http" }],
1364
+ url: "/api/key-chain/{id}/rotate",
1365
+ ...options
1366
+ });
1367
+ var verifierOfferControllerGetOffer = (options) => (options.client ?? client).post({
1368
+ security: [{ scheme: "bearer", type: "http" }],
1369
+ url: "/api/verifier/offer",
1370
+ ...options,
1371
+ headers: {
1372
+ "Content-Type": "application/json",
1373
+ ...options.headers
1374
+ }
1375
+ });
1376
+ var storageControllerUpload = (options) => (options.client ?? client).post({
1377
+ ...formDataBodySerializer,
1378
+ security: [{ scheme: "bearer", type: "http" }],
1379
+ url: "/api/storage",
1380
+ ...options,
1381
+ headers: {
1382
+ "Content-Type": null,
1383
+ ...options.headers
1384
+ }
1385
+ });
1386
+
1387
+ // src/client.ts
1388
+ function isDcApiAvailable() {
1389
+ return typeof navigator !== "undefined" && "credentials" in navigator && "get" in navigator.credentials && typeof window !== "undefined" && "DigitalCredential" in window;
1390
+ }
1391
+ function decodeJwtPayload(jwt) {
1392
+ const parts = jwt.split(".");
1393
+ if (parts.length !== 3) {
1394
+ throw new Error("Invalid JWT format");
1395
+ }
1396
+ const payload = parts[1];
1397
+ const base64 = payload.replace(/-/g, "+").replace(/_/g, "/");
1398
+ const jsonPayload = atob(base64);
1399
+ return JSON.parse(jsonPayload);
1400
+ }
1401
+ var EudiploClient = class {
1402
+ config;
1403
+ accessToken;
1404
+ tokenExpiresAt;
1405
+ refreshPromise;
1406
+ constructor(config) {
1407
+ this.config = {
1408
+ autoRefresh: true,
1409
+ ...config
1410
+ };
1411
+ client.setConfig({
1412
+ baseUrl: config.baseUrl,
1413
+ fetch: config.fetch
1414
+ });
1415
+ }
1416
+ /**
1417
+ * Authenticate and obtain an access token.
1418
+ * Called automatically by other methods, but can be called explicitly.
1419
+ */
1420
+ async authenticate() {
1421
+ if (this.refreshPromise) {
1422
+ return this.refreshPromise;
1423
+ }
1424
+ this.refreshPromise = this._doAuthenticate();
1425
+ try {
1426
+ await this.refreshPromise;
1427
+ } finally {
1428
+ this.refreshPromise = void 0;
1429
+ }
1430
+ }
1431
+ async _doAuthenticate() {
1432
+ const fetchFn = this.config.fetch ?? globalThis.fetch;
1433
+ const res = await fetchFn(`${this.config.baseUrl}/oauth2/token`, {
1434
+ method: "POST",
1435
+ headers: { "Content-Type": "application/json" },
1436
+ body: JSON.stringify({
1437
+ grant_type: "client_credentials",
1438
+ client_id: this.config.clientId,
1439
+ client_secret: this.config.clientSecret
1440
+ })
1441
+ });
1442
+ if (!res.ok) {
1443
+ const error = await res.text();
1444
+ throw new Error(`Authentication failed: ${res.status} ${error}`);
1445
+ }
1446
+ const data = await res.json();
1447
+ this.accessToken = data.access_token;
1448
+ this.tokenExpiresAt = Date.now() + data.expires_in * 1e3;
1449
+ client.setConfig({
1450
+ baseUrl: this.config.baseUrl,
1451
+ fetch: this.config.fetch,
1452
+ headers: {
1453
+ Authorization: `Bearer ${this.accessToken}`
1454
+ }
1455
+ });
1456
+ }
1457
+ /**
1458
+ * Ensure we have a valid access token, refreshing if necessary.
1459
+ */
1460
+ async ensureAuthenticated() {
1461
+ const bufferMs = 6e4;
1462
+ if (!this.accessToken || !this.tokenExpiresAt) {
1463
+ await this.authenticate();
1464
+ return;
1465
+ }
1466
+ if (this.config.autoRefresh && Date.now() > this.tokenExpiresAt - bufferMs) {
1467
+ await this.authenticate();
1468
+ }
1469
+ }
1470
+ /**
1471
+ * Create a credential issuance offer.
1472
+ *
1473
+ * @example
1474
+ * ```typescript
1475
+ * const { uri, sessionId } = await client.createIssuanceOffer({
1476
+ * credentialConfigurationIds: ['PID'],
1477
+ * claims: {
1478
+ * PID: { given_name: 'John', family_name: 'Doe' }
1479
+ * }
1480
+ * });
1481
+ * ```
1482
+ */
1483
+ async createIssuanceOffer(options) {
1484
+ await this.ensureAuthenticated();
1485
+ const body = {
1486
+ response_type: options.responseType ?? "uri",
1487
+ credentialConfigurationIds: options.credentialConfigurationIds,
1488
+ flow: options.flow ?? "pre_authorized_code",
1489
+ tx_code: options.txCode
1490
+ };
1491
+ if (options.claims) {
1492
+ body.credentialClaims = {
1493
+ additionalProperties: void 0
1494
+ };
1495
+ for (const [configId, claims] of Object.entries(options.claims)) {
1496
+ body.credentialClaims[configId] = {
1497
+ type: "inline",
1498
+ claims
1499
+ };
1500
+ }
1501
+ }
1502
+ const response = await credentialOfferControllerGetOffer({
1503
+ body
1504
+ });
1505
+ if (!response.data) {
1506
+ throw new Error("Failed to create issuance offer");
1507
+ }
1508
+ return {
1509
+ uri: response.data.uri,
1510
+ sessionId: response.data.session
1511
+ };
1512
+ }
1513
+ /**
1514
+ * Create a presentation request (for verification).
1515
+ *
1516
+ * Returns two URIs:
1517
+ * - `uri`: For same-device flow (wallet on same device, redirect after completion)
1518
+ * - `crossDeviceUri`: For cross-device flow (QR code, no redirect, poll for status)
1519
+ *
1520
+ * @example Same-device flow (wallet app on user's device)
1521
+ * ```typescript
1522
+ * const { uri, sessionId } = await client.createPresentationRequest({
1523
+ * configId: 'age-over-18',
1524
+ * redirectUri: 'https://example.com/callback'
1525
+ * });
1526
+ * // Redirect user to uri - wallet will redirect back after completion
1527
+ * window.location.href = uri;
1528
+ * ```
1529
+ *
1530
+ * @example Cross-device flow (QR code scanned by separate device)
1531
+ * ```typescript
1532
+ * const { crossDeviceUri, sessionId } = await client.createPresentationRequest({
1533
+ * configId: 'age-over-18'
1534
+ * });
1535
+ * // Display crossDeviceUri as QR code, then poll for completion
1536
+ * const session = await client.waitForSession(sessionId);
1537
+ * ```
1538
+ */
1539
+ async createPresentationRequest(options) {
1540
+ await this.ensureAuthenticated();
1541
+ const body = {
1542
+ response_type: options.responseType ?? "uri",
1543
+ requestId: options.configId,
1544
+ redirectUri: options.redirectUri
1545
+ };
1546
+ const response = await verifierOfferControllerGetOffer({
1547
+ body
1548
+ });
1549
+ if (!response.data) {
1550
+ throw new Error("Failed to create presentation request");
1551
+ }
1552
+ return {
1553
+ uri: response.data.uri,
1554
+ crossDeviceUri: response.data.crossDeviceUri ?? response.data.uri,
1555
+ sessionId: response.data.session
1556
+ };
1557
+ }
1558
+ /**
1559
+ * Get the current health of the EUDIPLO connector.
1560
+ * The status in the response is `ok`/`error`.
1561
+ * The health of the components is listed in the response under `info`/`error`/`details`.
1562
+ * If the EUDIPLO connector itself is unreachable, no components are listed.
1563
+ */
1564
+ async getHealth() {
1565
+ const fetchFn = this.config.fetch ?? globalThis.fetch;
1566
+ const res = await fetchFn(`${this.config.baseUrl}/health`);
1567
+ if (!res.ok) {
1568
+ return { status: "error" };
1569
+ }
1570
+ return res.json();
1571
+ }
1572
+ /**
1573
+ * Get the current status of a session.
1574
+ */
1575
+ async getSession(sessionId) {
1576
+ await this.ensureAuthenticated();
1577
+ const response = await sessionControllerGetSession({
1578
+ path: { id: sessionId }
1579
+ });
1580
+ if (!response.data) {
1581
+ throw new Error(`Session not found: ${sessionId}`);
1582
+ }
1583
+ return response.data;
1584
+ }
1585
+ /**
1586
+ * Wait for a session to complete (polling).
1587
+ *
1588
+ * @example
1589
+ * ```typescript
1590
+ * const session = await client.waitForSession(sessionId, {
1591
+ * interval: 1000,
1592
+ * timeout: 60000,
1593
+ * onUpdate: (s) => console.log('Status:', s.status)
1594
+ * });
1595
+ * ```
1596
+ */
1597
+ async waitForSession(sessionId, options = {}) {
1598
+ const {
1599
+ interval = 1e3,
1600
+ timeout = 3e5,
1601
+ onUpdate,
1602
+ signal
1603
+ } = options;
1604
+ const startTime = Date.now();
1605
+ while (true) {
1606
+ if (signal?.aborted) {
1607
+ throw new Error("Session polling aborted");
1608
+ }
1609
+ if (Date.now() - startTime > timeout) {
1610
+ throw new Error(`Session polling timed out after ${timeout}ms`);
1611
+ }
1612
+ const session = await this.getSession(sessionId);
1613
+ if (onUpdate) {
1614
+ onUpdate(session);
1615
+ }
1616
+ if (session.status === "completed") {
1617
+ return session;
1618
+ }
1619
+ if (session.status === "expired" || session.status === "failed") {
1620
+ throw new Error(`Session ${session.status}: ${sessionId}`);
1621
+ }
1622
+ await this.sleep(interval, signal);
1623
+ }
1624
+ }
1625
+ /**
1626
+ * Helper to sleep with abort support
1627
+ */
1628
+ sleep(ms, signal) {
1629
+ return new Promise((resolve, reject) => {
1630
+ const timeoutId = setTimeout(resolve, ms);
1631
+ if (signal) {
1632
+ signal.addEventListener("abort", () => {
1633
+ clearTimeout(timeoutId);
1634
+ reject(new Error("Aborted"));
1635
+ }, { once: true });
1636
+ }
1637
+ });
1638
+ }
1639
+ /**
1640
+ * Subscribe to real-time session status updates via Server-Sent Events.
1641
+ *
1642
+ * This is more efficient than polling and provides instant updates.
1643
+ * The connection remains open until closed or the session reaches a terminal state.
1644
+ *
1645
+ * @example
1646
+ * ```typescript
1647
+ * const subscription = await client.subscribeToSession(sessionId, {
1648
+ * onStatusChange: (event) => {
1649
+ * console.log(`Status: ${event.status}`);
1650
+ * if (['completed', 'expired', 'failed'].includes(event.status)) {
1651
+ * subscription.close();
1652
+ * }
1653
+ * },
1654
+ * onError: (error) => console.error('SSE error:', error)
1655
+ * });
1656
+ *
1657
+ * // Later, to close the connection:
1658
+ * subscription.close();
1659
+ * ```
1660
+ */
1661
+ async subscribeToSession(sessionId, options = {}) {
1662
+ await this.ensureAuthenticated();
1663
+ const token = this.accessToken;
1664
+ if (!token) {
1665
+ throw new Error("No access token available");
1666
+ }
1667
+ if (typeof EventSource === "undefined") {
1668
+ throw new Error(
1669
+ "EventSource is not available in this environment. Use polling with waitForSession() instead, or provide a polyfill."
1670
+ );
1671
+ }
1672
+ const url = `${this.config.baseUrl}/session/${sessionId}/events?token=${encodeURIComponent(token)}`;
1673
+ const eventSource = new EventSource(url);
1674
+ eventSource.onopen = () => {
1675
+ options.onOpen?.();
1676
+ };
1677
+ eventSource.onmessage = (event) => {
1678
+ try {
1679
+ const data = JSON.parse(event.data);
1680
+ options.onStatusChange?.(data);
1681
+ } catch (error) {
1682
+ options.onError?.(new Error(`Failed to parse SSE event: ${error}`));
1683
+ }
1684
+ };
1685
+ eventSource.onerror = () => {
1686
+ options.onError?.(new Error("SSE connection error"));
1687
+ };
1688
+ return {
1689
+ close: () => eventSource.close()
1690
+ };
1691
+ }
1692
+ /**
1693
+ * Subscribe to session and wait for completion via SSE.
1694
+ *
1695
+ * Returns a Promise that resolves when the session completes,
1696
+ * or rejects if it fails/expires.
1697
+ *
1698
+ * @example
1699
+ * ```typescript
1700
+ * try {
1701
+ * const finalStatus = await client.waitForSessionWithSse(sessionId);
1702
+ * console.log('Session completed:', finalStatus);
1703
+ * } catch (error) {
1704
+ * console.error('Session failed:', error);
1705
+ * }
1706
+ * ```
1707
+ */
1708
+ async waitForSessionWithSse(sessionId, options = {}) {
1709
+ return new Promise(async (resolve, reject) => {
1710
+ try {
1711
+ const subscription = await this.subscribeToSession(sessionId, {
1712
+ onStatusChange: (event) => {
1713
+ options.onStatusChange?.(event);
1714
+ if (event.status === "completed") {
1715
+ subscription.close();
1716
+ resolve(event);
1717
+ } else if (event.status === "expired" || event.status === "failed") {
1718
+ subscription.close();
1719
+ reject(new Error(`Session ${event.status}: ${sessionId}`));
1720
+ }
1721
+ },
1722
+ onError: (error) => {
1723
+ console.warn("SSE connection error, reconnecting...", error);
1724
+ }
1725
+ });
1726
+ } catch (error) {
1727
+ reject(error);
1728
+ }
1729
+ });
1730
+ }
1731
+ /**
1732
+ * Get the current access token (for advanced usage)
1733
+ */
1734
+ getAccessToken() {
1735
+ return this.accessToken;
1736
+ }
1737
+ /**
1738
+ * Get the configured base URL
1739
+ */
1740
+ getBaseUrl() {
1741
+ return this.config.baseUrl;
1742
+ }
1743
+ // ==========================================================================
1744
+ // Digital Credentials API Methods
1745
+ // ==========================================================================
1746
+ /**
1747
+ * Create a presentation request configured for DC API usage.
1748
+ * Returns a session with the signed request object needed for DC API.
1749
+ *
1750
+ * @example
1751
+ * ```typescript
1752
+ * const session = await client.createDcApiPresentationRequest({
1753
+ * configId: 'age-over-18'
1754
+ * });
1755
+ *
1756
+ * // Use the requestObject with the DC API
1757
+ * const result = await client.submitDcApiPresentation(session);
1758
+ * ```
1759
+ */
1760
+ async createDcApiPresentationRequest(options) {
1761
+ await this.ensureAuthenticated();
1762
+ const body = {
1763
+ response_type: "dc-api",
1764
+ requestId: options.configId,
1765
+ redirectUri: options.redirectUri
1766
+ };
1767
+ const response = await verifierOfferControllerGetOffer({
1768
+ body
1769
+ });
1770
+ if (!response.data) {
1771
+ throw new Error("Failed to create DC API presentation request");
1772
+ }
1773
+ return this.getSession(response.data.session);
1774
+ }
1775
+ /**
1776
+ * Submit a presentation using the Digital Credentials API.
1777
+ * This method handles the browser DC API call and submits the response to the verifier.
1778
+ *
1779
+ * @example
1780
+ * ```typescript
1781
+ * // Check if DC API is available
1782
+ * if (!isDcApiAvailable()) {
1783
+ * throw new Error('DC API not supported in this browser');
1784
+ * }
1785
+ *
1786
+ * const session = await client.createDcApiPresentationRequest({
1787
+ * configId: 'age-over-18'
1788
+ * });
1789
+ *
1790
+ * const result = await client.submitDcApiPresentation(session);
1791
+ * console.log('Verified credentials:', result.credentials);
1792
+ * ```
1793
+ */
1794
+ async submitDcApiPresentation(session, options = {}) {
1795
+ if (!isDcApiAvailable()) {
1796
+ throw new Error(
1797
+ "Digital Credentials API is not available in this browser. Please use a supported browser or fall back to QR code flow."
1798
+ );
1799
+ }
1800
+ if (!session.requestObject) {
1801
+ throw new Error(
1802
+ 'Session does not contain a requestObject. Make sure to create the session with response_type: "dc-api"'
1803
+ );
1804
+ }
1805
+ const dcResponse = await navigator.credentials.get({
1806
+ mediation: "required",
1807
+ digital: {
1808
+ requests: [
1809
+ {
1810
+ protocol: "openid4vp-v1-signed",
1811
+ data: { request: session.requestObject }
1812
+ }
1813
+ ]
1814
+ }
1815
+ });
1816
+ if (!dcResponse) {
1817
+ throw new Error("No response from Digital Credentials API");
1818
+ }
1819
+ if (dcResponse.data?.error) {
1820
+ throw new Error(
1821
+ `Wallet error: ${dcResponse.data.error}${dcResponse.data.error_description ? ` - ${dcResponse.data.error_description}` : ""}`
1822
+ );
1823
+ }
1824
+ const requestPayload = decodeJwtPayload(
1825
+ session.requestObject
1826
+ );
1827
+ if (!requestPayload.response_uri) {
1828
+ throw new Error("No response_uri found in request object");
1829
+ }
1830
+ const fetchImpl = this.config.fetch ?? fetch;
1831
+ const submitResponse = await fetchImpl(requestPayload.response_uri, {
1832
+ method: "POST",
1833
+ headers: {
1834
+ "Content-Type": "application/json"
1835
+ },
1836
+ body: JSON.stringify({
1837
+ ...dcResponse.data,
1838
+ sendResponse: options.sendResponse ?? true
1839
+ })
1840
+ });
1841
+ if (!submitResponse.ok) {
1842
+ const errorText = await submitResponse.text();
1843
+ throw new Error(
1844
+ `Failed to submit presentation: ${submitResponse.status} ${errorText}`
1845
+ );
1846
+ }
1847
+ const result = await submitResponse.json();
1848
+ return {
1849
+ credentials: result.credentials ?? result,
1850
+ response: result,
1851
+ redirectUri: result.redirect_uri
1852
+ };
1853
+ }
1854
+ /**
1855
+ * Convenience method to create a presentation request and immediately
1856
+ * submit it using the Digital Credentials API.
1857
+ *
1858
+ * @example
1859
+ * ```typescript
1860
+ * const result = await client.verifyWithDcApi({
1861
+ * configId: 'age-over-18'
1862
+ * });
1863
+ * console.log('Verified:', result.credentials);
1864
+ * ```
1865
+ */
1866
+ async verifyWithDcApi(options, dcOptions = {}) {
1867
+ const session = await this.createDcApiPresentationRequest(options);
1868
+ return this.submitDcApiPresentation(session, dcOptions);
1869
+ }
1870
+ };
1871
+ async function verify(options) {
1872
+ const client2 = new EudiploClient({
1873
+ baseUrl: options.baseUrl,
1874
+ clientId: options.clientId,
1875
+ clientSecret: options.clientSecret
1876
+ });
1877
+ const { uri, sessionId } = await client2.createPresentationRequest({
1878
+ configId: options.configId,
1879
+ redirectUri: options.redirectUri
1880
+ });
1881
+ return {
1882
+ uri,
1883
+ sessionId,
1884
+ waitForCompletion: (pollingOptions) => client2.waitForSession(sessionId, { ...options.polling, ...pollingOptions }),
1885
+ getStatus: () => client2.getSession(sessionId)
1886
+ };
1887
+ }
1888
+ async function issue(options) {
1889
+ const client2 = new EudiploClient({
1890
+ baseUrl: options.baseUrl,
1891
+ clientId: options.clientId,
1892
+ clientSecret: options.clientSecret
1893
+ });
1894
+ const { uri, sessionId } = await client2.createIssuanceOffer({
1895
+ credentialConfigurationIds: options.credentialConfigurationIds,
1896
+ claims: options.claims,
1897
+ txCode: options.txCode
1898
+ });
1899
+ return {
1900
+ uri,
1901
+ sessionId,
1902
+ waitForCompletion: (pollingOptions) => client2.waitForSession(sessionId, { ...options.polling, ...pollingOptions }),
1903
+ getStatus: () => client2.getSession(sessionId)
1904
+ };
1905
+ }
1906
+ async function verifyAndWait(options) {
1907
+ const { uri, waitForCompletion } = await verify(options);
1908
+ options.onUri(uri);
1909
+ return waitForCompletion(options.polling);
1910
+ }
1911
+ async function issueAndWait(options) {
1912
+ const { uri, waitForCompletion } = await issue(options);
1913
+ options.onUri(uri);
1914
+ return waitForCompletion(options.polling);
1915
+ }
1916
+ async function verifyWithDcApi(options) {
1917
+ const eudiploClient = new EudiploClient({
1918
+ baseUrl: options.baseUrl,
1919
+ clientId: options.clientId,
1920
+ clientSecret: options.clientSecret
1921
+ });
1922
+ return eudiploClient.verifyWithDcApi(
1923
+ {
1924
+ configId: options.configId,
1925
+ redirectUri: options.redirectUri
1926
+ },
1927
+ {
1928
+ sendResponse: options.sendResponse
1929
+ }
1930
+ );
1931
+ }
1932
+ async function createDcApiRequest(options) {
1933
+ const eudiploClient = new EudiploClient({
1934
+ baseUrl: options.baseUrl,
1935
+ clientId: options.clientId,
1936
+ clientSecret: options.clientSecret
1937
+ });
1938
+ const session = await eudiploClient.createDcApiPresentationRequest({
1939
+ configId: options.configId,
1940
+ redirectUri: options.redirectUri
1941
+ });
1942
+ return {
1943
+ session,
1944
+ submit: (dcOptions) => eudiploClient.submitDcApiPresentation(session, {
1945
+ sendResponse: options.sendResponse,
1946
+ ...dcOptions
1947
+ })
1948
+ };
1949
+ }
1950
+ async function createDcApiRequestForBrowser(options) {
1951
+ const eudiploClient = new EudiploClient({
1952
+ baseUrl: options.baseUrl,
1953
+ clientId: options.clientId,
1954
+ clientSecret: options.clientSecret
1955
+ });
1956
+ const session = await eudiploClient.createDcApiPresentationRequest({
1957
+ configId: options.configId,
1958
+ redirectUri: options.redirectUri
1959
+ });
1960
+ if (!session.requestObject) {
1961
+ throw new Error("Session does not contain a requestObject");
1962
+ }
1963
+ const requestPayload = decodeJwtPayload(
1964
+ session.requestObject
1965
+ );
1966
+ if (!requestPayload.response_uri) {
1967
+ throw new Error("No response_uri found in request object");
1968
+ }
1969
+ return {
1970
+ requestObject: session.requestObject,
1971
+ sessionId: session.id,
1972
+ responseUri: requestPayload.response_uri
1973
+ };
1974
+ }
1975
+ async function callDcApi(requestObject) {
1976
+ if (!isDcApiAvailable()) {
1977
+ throw new Error(
1978
+ "Digital Credentials API is not available in this browser. Please use a supported browser or fall back to QR code flow."
1979
+ );
1980
+ }
1981
+ const dcResponse = await navigator.credentials.get({
1982
+ mediation: "required",
1983
+ digital: {
1984
+ requests: [
1985
+ {
1986
+ protocol: "openid4vp-v1-signed",
1987
+ data: { request: requestObject }
1988
+ }
1989
+ ]
1990
+ }
1991
+ });
1992
+ if (!dcResponse) {
1993
+ throw new Error("No response from Digital Credentials API");
1994
+ }
1995
+ if (dcResponse.data?.error) {
1996
+ throw new Error(
1997
+ `Wallet error: ${dcResponse.data.error}${dcResponse.data.error_description ? ` - ${dcResponse.data.error_description}` : ""}`
1998
+ );
1999
+ }
2000
+ return dcResponse.data;
2001
+ }
2002
+ async function submitDcApiWalletResponse(options) {
2003
+ const fetchImpl = options.fetch ?? fetch;
2004
+ const submitResponse = await fetchImpl(options.responseUri, {
2005
+ method: "POST",
2006
+ headers: {
2007
+ "Content-Type": "application/json"
2008
+ },
2009
+ body: JSON.stringify({
2010
+ ...options.walletResponse,
2011
+ sendResponse: options.sendResponse ?? true
2012
+ })
2013
+ });
2014
+ if (!submitResponse.ok) {
2015
+ const errorText = await submitResponse.text();
2016
+ throw new Error(
2017
+ `Failed to submit presentation: ${submitResponse.status} ${errorText}`
2018
+ );
2019
+ }
2020
+ const result = await submitResponse.json();
2021
+ return {
2022
+ credentials: result.credentials ?? result,
2023
+ response: result,
2024
+ redirectUri: result.redirect_uri
2025
+ };
2026
+ }
2027
+
2028
+ export { EudiploClient, appControllerGetVersion, attributeProviderControllerCreate, attributeProviderControllerDelete, attributeProviderControllerGetAll, attributeProviderControllerGetById, attributeProviderControllerUpdate, cacheControllerClearAllCaches, cacheControllerClearStatusListCache, cacheControllerClearTrustListCache, cacheControllerGetStats, callDcApi, client, clientControllerCreateClient, clientControllerDeleteClient, clientControllerGetClient, clientControllerGetClientSecret, clientControllerGetClients, clientControllerRotateClientSecret, clientControllerUpdateClient, createDcApiRequest, createDcApiRequestForBrowser, credentialConfigControllerDeleteIssuanceConfiguration, credentialConfigControllerGetConfigById, credentialConfigControllerGetConfigs, credentialConfigControllerStoreCredentialConfiguration, credentialConfigControllerUpdateCredentialConfiguration, credentialOfferControllerGetOffer, deferredControllerCompleteDeferred, deferredControllerFailDeferred, isDcApiAvailable, issuanceConfigControllerGetIssuanceConfigurations, issuanceConfigControllerStoreIssuanceConfiguration, issue, issueAndWait, keyChainControllerCreate, keyChainControllerDelete, keyChainControllerExport, keyChainControllerGetAll, keyChainControllerGetById, keyChainControllerGetProviders, keyChainControllerImport, keyChainControllerRotate, keyChainControllerUpdate, presentationManagementControllerConfiguration, presentationManagementControllerDeleteConfiguration, presentationManagementControllerGetConfiguration, presentationManagementControllerStorePresentationConfig, presentationManagementControllerUpdateConfiguration, registrarControllerCreateAccessCertificate, registrarControllerCreateConfig, registrarControllerDeleteConfig, registrarControllerGetConfig, registrarControllerUpdateConfig, sessionConfigControllerGetConfig, sessionConfigControllerResetConfig, sessionConfigControllerUpdateConfig, sessionControllerDeleteSession, sessionControllerGetAllSessions, sessionControllerGetSession, sessionControllerGetSessionLogs, sessionControllerRevokeAll, sessionEventsControllerSubscribeToSessionEvents, statusListConfigControllerGetConfig, statusListConfigControllerResetConfig, statusListConfigControllerUpdateConfig, statusListManagementControllerCreateList, statusListManagementControllerDeleteList, statusListManagementControllerGetList, statusListManagementControllerGetLists, statusListManagementControllerUpdateList, storageControllerUpload, submitDcApiWalletResponse, tenantControllerDeleteTenant, tenantControllerGetTenant, tenantControllerGetTenants, tenantControllerInitTenant, tenantControllerUpdateTenant, trustListControllerCreateTrustList, trustListControllerDeleteTrustList, trustListControllerExportTrustList, trustListControllerGetAllTrustLists, trustListControllerGetTrustList, trustListControllerGetTrustListVersion, trustListControllerGetTrustListVersions, trustListControllerUpdateTrustList, verifierOfferControllerGetOffer, verify, verifyAndWait, verifyWithDcApi, webhookEndpointControllerCreate, webhookEndpointControllerDelete, webhookEndpointControllerGetAll, webhookEndpointControllerGetById, webhookEndpointControllerUpdate };
2029
+ //# sourceMappingURL=index.mjs.map
2030
+ //# sourceMappingURL=index.mjs.map