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