@eudiplo/sdk-core 1.14.0-main.070d9f8

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,2185 @@
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 appControllerMain = (options) => (options?.client ?? client).get({ url: "/", ...options });
853
+ var healthControllerCheck = (options) => (options?.client ?? client).get({ url: "/health", ...options });
854
+ var authControllerGetOAuth2Token = (options) => (options.client ?? client).post({
855
+ url: "/oauth2/token",
856
+ ...options,
857
+ headers: {
858
+ "Content-Type": "application/json",
859
+ ...options.headers
860
+ }
861
+ });
862
+ var authControllerGetOidcDiscovery = (options) => (options?.client ?? client).get({ url: "/.well-known/oauth-authorization-server", ...options });
863
+ var authControllerGetGlobalJwks = (options) => (options?.client ?? client).get({ url: "/.well-known/jwks.json", ...options });
864
+ var tenantControllerGetTenants = (options) => (options?.client ?? client).get({
865
+ security: [{ scheme: "bearer", type: "http" }],
866
+ url: "/tenant",
867
+ ...options
868
+ });
869
+ var tenantControllerInitTenant = (options) => (options.client ?? client).post({
870
+ security: [{ scheme: "bearer", type: "http" }],
871
+ url: "/tenant",
872
+ ...options,
873
+ headers: {
874
+ "Content-Type": "application/json",
875
+ ...options.headers
876
+ }
877
+ });
878
+ var tenantControllerDeleteTenant = (options) => (options.client ?? client).delete({
879
+ security: [{ scheme: "bearer", type: "http" }],
880
+ url: "/tenant/{id}",
881
+ ...options
882
+ });
883
+ var tenantControllerGetTenant = (options) => (options.client ?? client).get({
884
+ security: [{ scheme: "bearer", type: "http" }],
885
+ url: "/tenant/{id}",
886
+ ...options
887
+ });
888
+ var tenantControllerUpdateTenant = (options) => (options.client ?? client).patch({
889
+ security: [{ scheme: "bearer", type: "http" }],
890
+ url: "/tenant/{id}",
891
+ ...options,
892
+ headers: {
893
+ "Content-Type": "application/json",
894
+ ...options.headers
895
+ }
896
+ });
897
+ var clientControllerGetClients = (options) => (options?.client ?? client).get({
898
+ security: [{ scheme: "bearer", type: "http" }],
899
+ url: "/client",
900
+ ...options
901
+ });
902
+ var clientControllerCreateClient = (options) => (options.client ?? client).post({
903
+ security: [{ scheme: "bearer", type: "http" }],
904
+ url: "/client",
905
+ ...options,
906
+ headers: {
907
+ "Content-Type": "application/json",
908
+ ...options.headers
909
+ }
910
+ });
911
+ var clientControllerDeleteClient = (options) => (options.client ?? client).delete({
912
+ security: [{ scheme: "bearer", type: "http" }],
913
+ url: "/client/{id}",
914
+ ...options
915
+ });
916
+ var clientControllerGetClient = (options) => (options.client ?? client).get({
917
+ security: [{ scheme: "bearer", type: "http" }],
918
+ url: "/client/{id}",
919
+ ...options
920
+ });
921
+ var clientControllerUpdateClient = (options) => (options.client ?? client).patch({
922
+ security: [{ scheme: "bearer", type: "http" }],
923
+ url: "/client/{id}",
924
+ ...options,
925
+ headers: {
926
+ "Content-Type": "application/json",
927
+ ...options.headers
928
+ }
929
+ });
930
+ var clientControllerGetClientSecret = (options) => (options.client ?? client).get({
931
+ security: [{ scheme: "bearer", type: "http" }],
932
+ url: "/client/{id}/secret",
933
+ ...options
934
+ });
935
+ var clientControllerRotateClientSecret = (options) => (options.client ?? client).post({
936
+ security: [{ scheme: "bearer", type: "http" }],
937
+ url: "/client/{id}/rotate-secret",
938
+ ...options
939
+ });
940
+ var keyControllerGetKeys = (options) => (options?.client ?? client).get({
941
+ security: [{ scheme: "bearer", type: "http" }],
942
+ url: "/key",
943
+ ...options
944
+ });
945
+ var keyControllerAddKey = (options) => (options.client ?? client).post({
946
+ security: [{ scheme: "bearer", type: "http" }],
947
+ url: "/key",
948
+ ...options,
949
+ headers: {
950
+ "Content-Type": "application/json",
951
+ ...options.headers
952
+ }
953
+ });
954
+ var keyControllerDeleteKey = (options) => (options.client ?? client).delete({
955
+ security: [{ scheme: "bearer", type: "http" }],
956
+ url: "/key/{id}",
957
+ ...options
958
+ });
959
+ var keyControllerGetKey = (options) => (options.client ?? client).get({
960
+ security: [{ scheme: "bearer", type: "http" }],
961
+ url: "/key/{id}",
962
+ ...options
963
+ });
964
+ var keyControllerUpdateKey = (options) => (options.client ?? client).put({
965
+ security: [{ scheme: "bearer", type: "http" }],
966
+ url: "/key/{id}",
967
+ ...options,
968
+ headers: {
969
+ "Content-Type": "application/json",
970
+ ...options.headers
971
+ }
972
+ });
973
+ var certControllerGetCertificates = (options) => (options?.client ?? client).get({
974
+ security: [{ scheme: "bearer", type: "http" }],
975
+ url: "/certs",
976
+ ...options
977
+ });
978
+ var certControllerAddCertificate = (options) => (options.client ?? client).post({
979
+ security: [{ scheme: "bearer", type: "http" }],
980
+ url: "/certs",
981
+ ...options,
982
+ headers: {
983
+ "Content-Type": "application/json",
984
+ ...options.headers
985
+ }
986
+ });
987
+ var certControllerDeleteCertificate = (options) => (options.client ?? client).delete({
988
+ security: [{ scheme: "bearer", type: "http" }],
989
+ url: "/certs/{certId}",
990
+ ...options
991
+ });
992
+ var certControllerGetCertificate = (options) => (options.client ?? client).get({
993
+ security: [{ scheme: "bearer", type: "http" }],
994
+ url: "/certs/{certId}",
995
+ ...options
996
+ });
997
+ var certControllerUpdateCertificate = (options) => (options.client ?? client).patch({
998
+ security: [{ scheme: "bearer", type: "http" }],
999
+ url: "/certs/{certId}",
1000
+ ...options,
1001
+ headers: {
1002
+ "Content-Type": "application/json",
1003
+ ...options.headers
1004
+ }
1005
+ });
1006
+ var certControllerExportConfig = (options) => (options.client ?? client).get({
1007
+ security: [{ scheme: "bearer", type: "http" }],
1008
+ url: "/certs/{certId}/config",
1009
+ ...options
1010
+ });
1011
+ var statusListControllerGetList = (options) => (options.client ?? client).get({ url: "/{tenantId}/status-management/status-list/{listId}", ...options });
1012
+ var statusListControllerGetStatusListAggregation = (options) => (options.client ?? client).get({
1013
+ url: "/{tenantId}/status-management/status-list-aggregation",
1014
+ ...options
1015
+ });
1016
+ var statusListConfigControllerResetConfig = (options) => (options?.client ?? client).delete({
1017
+ security: [{ scheme: "bearer", type: "http" }],
1018
+ url: "/status-list-config",
1019
+ ...options
1020
+ });
1021
+ var statusListConfigControllerGetConfig = (options) => (options?.client ?? client).get({
1022
+ security: [{ scheme: "bearer", type: "http" }],
1023
+ url: "/status-list-config",
1024
+ ...options
1025
+ });
1026
+ var statusListConfigControllerUpdateConfig = (options) => (options.client ?? client).put({
1027
+ security: [{ scheme: "bearer", type: "http" }],
1028
+ url: "/status-list-config",
1029
+ ...options,
1030
+ headers: {
1031
+ "Content-Type": "application/json",
1032
+ ...options.headers
1033
+ }
1034
+ });
1035
+ var statusListManagementControllerGetLists = (options) => (options?.client ?? client).get({
1036
+ security: [{ scheme: "bearer", type: "http" }],
1037
+ url: "/status-lists",
1038
+ ...options
1039
+ });
1040
+ var statusListManagementControllerCreateList = (options) => (options.client ?? client).post({
1041
+ security: [{ scheme: "bearer", type: "http" }],
1042
+ url: "/status-lists",
1043
+ ...options,
1044
+ headers: {
1045
+ "Content-Type": "application/json",
1046
+ ...options.headers
1047
+ }
1048
+ });
1049
+ var statusListManagementControllerDeleteList = (options) => (options.client ?? client).delete({
1050
+ security: [{ scheme: "bearer", type: "http" }],
1051
+ url: "/status-lists/{listId}",
1052
+ ...options
1053
+ });
1054
+ var statusListManagementControllerGetList = (options) => (options.client ?? client).get({
1055
+ security: [{ scheme: "bearer", type: "http" }],
1056
+ url: "/status-lists/{listId}",
1057
+ ...options
1058
+ });
1059
+ var statusListManagementControllerUpdateList = (options) => (options.client ?? client).patch({
1060
+ security: [{ scheme: "bearer", type: "http" }],
1061
+ url: "/status-lists/{listId}",
1062
+ ...options,
1063
+ headers: {
1064
+ "Content-Type": "application/json",
1065
+ ...options.headers
1066
+ }
1067
+ });
1068
+ var sessionControllerGetAllSessions = (options) => (options?.client ?? client).get({
1069
+ security: [{ scheme: "bearer", type: "http" }],
1070
+ url: "/session",
1071
+ ...options
1072
+ });
1073
+ var sessionControllerDeleteSession = (options) => (options.client ?? client).delete({
1074
+ security: [{ scheme: "bearer", type: "http" }],
1075
+ url: "/session/{id}",
1076
+ ...options
1077
+ });
1078
+ var sessionControllerGetSession = (options) => (options.client ?? client).get({
1079
+ security: [{ scheme: "bearer", type: "http" }],
1080
+ url: "/session/{id}",
1081
+ ...options
1082
+ });
1083
+ var sessionControllerRevokeAll = (options) => (options.client ?? client).post({
1084
+ security: [{ scheme: "bearer", type: "http" }],
1085
+ url: "/session/revoke",
1086
+ ...options,
1087
+ headers: {
1088
+ "Content-Type": "application/json",
1089
+ ...options.headers
1090
+ }
1091
+ });
1092
+ var sessionConfigControllerResetConfig = (options) => (options?.client ?? client).delete({
1093
+ security: [{ scheme: "bearer", type: "http" }],
1094
+ url: "/session-config",
1095
+ ...options
1096
+ });
1097
+ var sessionConfigControllerGetConfig = (options) => (options?.client ?? client).get({
1098
+ security: [{ scheme: "bearer", type: "http" }],
1099
+ url: "/session-config",
1100
+ ...options
1101
+ });
1102
+ var sessionConfigControllerUpdateConfig = (options) => (options.client ?? client).put({
1103
+ security: [{ scheme: "bearer", type: "http" }],
1104
+ url: "/session-config",
1105
+ ...options,
1106
+ headers: {
1107
+ "Content-Type": "application/json",
1108
+ ...options.headers
1109
+ }
1110
+ });
1111
+ var sessionEventsControllerSubscribeToSessionEvents = (options) => (options.client ?? client).get({ url: "/session/{id}/events", ...options });
1112
+ var issuanceConfigControllerGetIssuanceConfigurations = (options) => (options?.client ?? client).get({
1113
+ security: [{ scheme: "bearer", type: "http" }],
1114
+ url: "/issuer/config",
1115
+ ...options
1116
+ });
1117
+ var issuanceConfigControllerStoreIssuanceConfiguration = (options) => (options.client ?? client).post({
1118
+ security: [{ scheme: "bearer", type: "http" }],
1119
+ url: "/issuer/config",
1120
+ ...options,
1121
+ headers: {
1122
+ "Content-Type": "application/json",
1123
+ ...options.headers
1124
+ }
1125
+ });
1126
+ var credentialConfigControllerGetConfigs = (options) => (options?.client ?? client).get({
1127
+ security: [{ scheme: "bearer", type: "http" }],
1128
+ url: "/issuer/credentials",
1129
+ ...options
1130
+ });
1131
+ var credentialConfigControllerStoreCredentialConfiguration = (options) => (options.client ?? client).post({
1132
+ security: [{ scheme: "bearer", type: "http" }],
1133
+ url: "/issuer/credentials",
1134
+ ...options,
1135
+ headers: {
1136
+ "Content-Type": "application/json",
1137
+ ...options.headers
1138
+ }
1139
+ });
1140
+ var credentialConfigControllerDeleteIssuanceConfiguration = (options) => (options.client ?? client).delete({
1141
+ security: [{ scheme: "bearer", type: "http" }],
1142
+ url: "/issuer/credentials/{id}",
1143
+ ...options
1144
+ });
1145
+ var credentialConfigControllerGetConfigById = (options) => (options.client ?? client).get({
1146
+ security: [{ scheme: "bearer", type: "http" }],
1147
+ url: "/issuer/credentials/{id}",
1148
+ ...options
1149
+ });
1150
+ var credentialConfigControllerUpdateCredentialConfiguration = (options) => (options.client ?? client).patch({
1151
+ security: [{ scheme: "bearer", type: "http" }],
1152
+ url: "/issuer/credentials/{id}",
1153
+ ...options,
1154
+ headers: {
1155
+ "Content-Type": "application/json",
1156
+ ...options.headers
1157
+ }
1158
+ });
1159
+ var presentationManagementControllerConfiguration = (options) => (options?.client ?? client).get({
1160
+ security: [{ scheme: "bearer", type: "http" }],
1161
+ url: "/verifier/config",
1162
+ ...options
1163
+ });
1164
+ var presentationManagementControllerStorePresentationConfig = (options) => (options.client ?? client).post({
1165
+ security: [{ scheme: "bearer", type: "http" }],
1166
+ url: "/verifier/config",
1167
+ ...options,
1168
+ headers: {
1169
+ "Content-Type": "application/json",
1170
+ ...options.headers
1171
+ }
1172
+ });
1173
+ var presentationManagementControllerDeleteConfiguration = (options) => (options.client ?? client).delete({
1174
+ security: [{ scheme: "bearer", type: "http" }],
1175
+ url: "/verifier/config/{id}",
1176
+ ...options
1177
+ });
1178
+ var presentationManagementControllerGetConfiguration = (options) => (options.client ?? client).get({
1179
+ security: [{ scheme: "bearer", type: "http" }],
1180
+ url: "/verifier/config/{id}",
1181
+ ...options
1182
+ });
1183
+ var presentationManagementControllerUpdateConfiguration = (options) => (options.client ?? client).patch({
1184
+ security: [{ scheme: "bearer", type: "http" }],
1185
+ url: "/verifier/config/{id}",
1186
+ ...options,
1187
+ headers: {
1188
+ "Content-Type": "application/json",
1189
+ ...options.headers
1190
+ }
1191
+ });
1192
+ var cacheControllerGetStats = (options) => (options?.client ?? client).get({
1193
+ security: [{ scheme: "bearer", type: "http" }],
1194
+ url: "/cache/stats",
1195
+ ...options
1196
+ });
1197
+ var cacheControllerClearAllCaches = (options) => (options?.client ?? client).delete({
1198
+ security: [{ scheme: "bearer", type: "http" }],
1199
+ url: "/cache",
1200
+ ...options
1201
+ });
1202
+ var cacheControllerClearTrustListCache = (options) => (options?.client ?? client).delete({
1203
+ security: [{ scheme: "bearer", type: "http" }],
1204
+ url: "/cache/trust-list",
1205
+ ...options
1206
+ });
1207
+ var cacheControllerClearStatusListCache = (options) => (options?.client ?? client).delete({
1208
+ security: [{ scheme: "bearer", type: "http" }],
1209
+ url: "/cache/status-list",
1210
+ ...options
1211
+ });
1212
+ var oid4VciControllerCredential = (options) => (options.client ?? client).post({ url: "/{tenantId}/vci/credential", ...options });
1213
+ var oid4VciControllerDeferredCredential = (options) => (options.client ?? client).post({
1214
+ url: "/{tenantId}/vci/deferred_credential",
1215
+ ...options,
1216
+ headers: {
1217
+ "Content-Type": "application/json",
1218
+ ...options.headers
1219
+ }
1220
+ });
1221
+ var oid4VciControllerNotifications = (options) => (options.client ?? client).post({
1222
+ url: "/{tenantId}/vci/notification",
1223
+ ...options,
1224
+ headers: {
1225
+ "Content-Type": "application/json",
1226
+ ...options.headers
1227
+ }
1228
+ });
1229
+ var oid4VciControllerNonce = (options) => (options.client ?? client).post({ url: "/{tenantId}/vci/nonce", ...options });
1230
+ var authorizeControllerAuthorize = (options) => (options.client ?? client).get({ url: "/{tenantId}/authorize", ...options });
1231
+ var authorizeControllerPar = (options) => (options.client ?? client).post({
1232
+ url: "/{tenantId}/authorize/par",
1233
+ ...options,
1234
+ headers: {
1235
+ "Content-Type": "application/json",
1236
+ ...options.headers
1237
+ }
1238
+ });
1239
+ var authorizeControllerToken = (options) => (options.client ?? client).post({ url: "/{tenantId}/authorize/token", ...options });
1240
+ var interactiveAuthorizationControllerInteractiveAuthorization = (options) => (options.client ?? client).post({
1241
+ url: "/{tenantId}/authorize/interactive",
1242
+ ...options,
1243
+ headers: {
1244
+ "Content-Type": "application/json",
1245
+ ...options.headers
1246
+ }
1247
+ });
1248
+ var interactiveAuthorizationControllerCompleteWebAuth = (options) => (options.client ?? client).post({
1249
+ url: "/{tenantId}/authorize/interactive/complete-web-auth/{authSession}",
1250
+ ...options
1251
+ });
1252
+ var chainedAsControllerPar = (options) => (options.client ?? client).post({
1253
+ url: "/{tenant}/chained-as/par",
1254
+ ...options,
1255
+ headers: {
1256
+ "Content-Type": "application/json",
1257
+ ...options.headers
1258
+ }
1259
+ });
1260
+ var chainedAsControllerAuthorize = (options) => (options.client ?? client).get({ url: "/{tenant}/chained-as/authorize", ...options });
1261
+ var chainedAsControllerCallback = (options) => (options.client ?? client).get({ url: "/{tenant}/chained-as/callback", ...options });
1262
+ var chainedAsControllerToken = (options) => (options.client ?? client).post({
1263
+ url: "/{tenant}/chained-as/token",
1264
+ ...options,
1265
+ headers: {
1266
+ "Content-Type": "application/json",
1267
+ ...options.headers
1268
+ }
1269
+ });
1270
+ var chainedAsControllerJwks = (options) => (options.client ?? client).get({ url: "/{tenant}/chained-as/.well-known/jwks.json", ...options });
1271
+ var chainedAsControllerGetMetadata = (options) => (options.client ?? client).get({
1272
+ url: "/{tenant}/chained-as/.well-known/oauth-authorization-server",
1273
+ ...options
1274
+ });
1275
+ var credentialOfferControllerGetOffer = (options) => (options.client ?? client).post({
1276
+ security: [{ scheme: "bearer", type: "http" }],
1277
+ url: "/issuer/offer",
1278
+ ...options,
1279
+ headers: {
1280
+ "Content-Type": "application/json",
1281
+ ...options.headers
1282
+ }
1283
+ });
1284
+ var deferredControllerCompleteDeferred = (options) => (options.client ?? client).post({
1285
+ security: [{ scheme: "bearer", type: "http" }],
1286
+ url: "/issuer/deferred/{transactionId}/complete",
1287
+ ...options,
1288
+ headers: {
1289
+ "Content-Type": "application/json",
1290
+ ...options.headers
1291
+ }
1292
+ });
1293
+ var deferredControllerFailDeferred = (options) => (options.client ?? client).post({
1294
+ security: [{ scheme: "bearer", type: "http" }],
1295
+ url: "/issuer/deferred/{transactionId}/fail",
1296
+ ...options,
1297
+ headers: {
1298
+ "Content-Type": "application/json",
1299
+ ...options.headers
1300
+ }
1301
+ });
1302
+ var oid4VciMetadataControllerVct = (options) => (options.client ?? client).get({ url: "/{tenantId}/credentials-metadata/vct/{id}", ...options });
1303
+ var wellKnownControllerIssuerMetadata0 = (options) => (options.client ?? client).get({ url: "/.well-known/openid-credential-issuer/{tenantId}", ...options });
1304
+ var wellKnownControllerIssuerMetadata1 = (options) => (options.client ?? client).get({ url: "/{tenantId}/.well-known/openid-credential-issuer", ...options });
1305
+ var wellKnownControllerAuthzMetadata0 = (options) => (options.client ?? client).get({ url: "/.well-known/oauth-authorization-server/{tenantId}", ...options });
1306
+ var wellKnownControllerAuthzMetadata1 = (options) => (options.client ?? client).get({ url: "/{tenantId}/.well-known/oauth-authorization-server", ...options });
1307
+ var wellKnownControllerGetJwks0 = (options) => (options.client ?? client).get({ url: "/.well-known/jwks.json/{tenantId}", ...options });
1308
+ var wellKnownControllerGetJwks1 = (options) => (options.client ?? client).get({ url: "/{tenantId}/.well-known/jwks.json", ...options });
1309
+ var oid4VpControllerGetRequestWithSession = (options) => (options.client ?? client).get({ url: "/{session}/oid4vp/request", ...options });
1310
+ var oid4VpControllerGetPostRequestWithSession = (options) => (options.client ?? client).post({ url: "/{session}/oid4vp/request", ...options });
1311
+ var oid4VpControllerGetRequestNoRedirectWithSession = (options) => (options.client ?? client).get({ url: "/{session}/oid4vp/request/no-redirect", ...options });
1312
+ var oid4VpControllerGetResponse = (options) => (options.client ?? client).post({
1313
+ url: "/{session}/oid4vp",
1314
+ ...options,
1315
+ headers: {
1316
+ "Content-Type": "application/json",
1317
+ ...options.headers
1318
+ }
1319
+ });
1320
+ var registrarControllerDeleteConfig = (options) => (options?.client ?? client).delete({
1321
+ security: [{ scheme: "bearer", type: "http" }],
1322
+ url: "/registrar/config",
1323
+ ...options
1324
+ });
1325
+ var registrarControllerGetConfig = (options) => (options?.client ?? client).get({
1326
+ security: [{ scheme: "bearer", type: "http" }],
1327
+ url: "/registrar/config",
1328
+ ...options
1329
+ });
1330
+ var registrarControllerUpdateConfig = (options) => (options.client ?? client).patch({
1331
+ security: [{ scheme: "bearer", type: "http" }],
1332
+ url: "/registrar/config",
1333
+ ...options,
1334
+ headers: {
1335
+ "Content-Type": "application/json",
1336
+ ...options.headers
1337
+ }
1338
+ });
1339
+ var registrarControllerCreateConfig = (options) => (options.client ?? client).post({
1340
+ security: [{ scheme: "bearer", type: "http" }],
1341
+ url: "/registrar/config",
1342
+ ...options,
1343
+ headers: {
1344
+ "Content-Type": "application/json",
1345
+ ...options.headers
1346
+ }
1347
+ });
1348
+ var registrarControllerCreateAccessCertificate = (options) => (options.client ?? client).post({
1349
+ security: [{ scheme: "bearer", type: "http" }],
1350
+ url: "/registrar/access-certificate",
1351
+ ...options,
1352
+ headers: {
1353
+ "Content-Type": "application/json",
1354
+ ...options.headers
1355
+ }
1356
+ });
1357
+ var trustListControllerGetAllTrustLists = (options) => (options?.client ?? client).get({
1358
+ security: [{ scheme: "bearer", type: "http" }],
1359
+ url: "/trust-list",
1360
+ ...options
1361
+ });
1362
+ var trustListControllerCreateTrustList = (options) => (options.client ?? client).post({
1363
+ security: [{ scheme: "bearer", type: "http" }],
1364
+ url: "/trust-list",
1365
+ ...options,
1366
+ headers: {
1367
+ "Content-Type": "application/json",
1368
+ ...options.headers
1369
+ }
1370
+ });
1371
+ var trustListControllerDeleteTrustList = (options) => (options.client ?? client).delete({
1372
+ security: [{ scheme: "bearer", type: "http" }],
1373
+ url: "/trust-list/{id}",
1374
+ ...options
1375
+ });
1376
+ var trustListControllerGetTrustList = (options) => (options.client ?? client).get({
1377
+ security: [{ scheme: "bearer", type: "http" }],
1378
+ url: "/trust-list/{id}",
1379
+ ...options
1380
+ });
1381
+ var trustListControllerUpdateTrustList = (options) => (options.client ?? client).put({
1382
+ security: [{ scheme: "bearer", type: "http" }],
1383
+ url: "/trust-list/{id}",
1384
+ ...options,
1385
+ headers: {
1386
+ "Content-Type": "application/json",
1387
+ ...options.headers
1388
+ }
1389
+ });
1390
+ var trustListControllerExportTrustList = (options) => (options.client ?? client).get({
1391
+ security: [{ scheme: "bearer", type: "http" }],
1392
+ url: "/trust-list/{id}/export",
1393
+ ...options
1394
+ });
1395
+ var trustListControllerGetTrustListVersions = (options) => (options.client ?? client).get({
1396
+ security: [{ scheme: "bearer", type: "http" }],
1397
+ url: "/trust-list/{id}/versions",
1398
+ ...options
1399
+ });
1400
+ var trustListControllerGetTrustListVersion = (options) => (options.client ?? client).get({
1401
+ security: [{ scheme: "bearer", type: "http" }],
1402
+ url: "/trust-list/{id}/versions/{versionId}",
1403
+ ...options
1404
+ });
1405
+ var trustListPublicControllerGetTrustListJwt = (options) => (options.client ?? client).get({ url: "/{tenantId}/trust-list/{id}", ...options });
1406
+ var verifierOfferControllerGetOffer = (options) => (options.client ?? client).post({
1407
+ security: [{ scheme: "bearer", type: "http" }],
1408
+ url: "/verifier/offer",
1409
+ ...options,
1410
+ headers: {
1411
+ "Content-Type": "application/json",
1412
+ ...options.headers
1413
+ }
1414
+ });
1415
+ var storageControllerUpload = (options) => (options.client ?? client).post({
1416
+ ...formDataBodySerializer,
1417
+ security: [{ scheme: "bearer", type: "http" }],
1418
+ url: "/storage",
1419
+ ...options,
1420
+ headers: {
1421
+ "Content-Type": null,
1422
+ ...options.headers
1423
+ }
1424
+ });
1425
+ var storageControllerDownload = (options) => (options.client ?? client).get({ url: "/storage/{key}", ...options });
1426
+
1427
+ // src/client.ts
1428
+ function isDcApiAvailable() {
1429
+ return typeof navigator !== "undefined" && "credentials" in navigator && "get" in navigator.credentials && typeof window !== "undefined" && "DigitalCredential" in window;
1430
+ }
1431
+ function decodeJwtPayload(jwt) {
1432
+ const parts = jwt.split(".");
1433
+ if (parts.length !== 3) {
1434
+ throw new Error("Invalid JWT format");
1435
+ }
1436
+ const payload = parts[1];
1437
+ const base64 = payload.replace(/-/g, "+").replace(/_/g, "/");
1438
+ const jsonPayload = atob(base64);
1439
+ return JSON.parse(jsonPayload);
1440
+ }
1441
+ var EudiploClient = class {
1442
+ config;
1443
+ accessToken;
1444
+ tokenExpiresAt;
1445
+ refreshPromise;
1446
+ constructor(config) {
1447
+ this.config = {
1448
+ autoRefresh: true,
1449
+ ...config
1450
+ };
1451
+ client.setConfig({
1452
+ baseUrl: config.baseUrl,
1453
+ fetch: config.fetch
1454
+ });
1455
+ }
1456
+ /**
1457
+ * Authenticate and obtain an access token.
1458
+ * Called automatically by other methods, but can be called explicitly.
1459
+ */
1460
+ async authenticate() {
1461
+ if (this.refreshPromise) {
1462
+ return this.refreshPromise;
1463
+ }
1464
+ this.refreshPromise = this._doAuthenticate();
1465
+ try {
1466
+ await this.refreshPromise;
1467
+ } finally {
1468
+ this.refreshPromise = void 0;
1469
+ }
1470
+ }
1471
+ async _doAuthenticate() {
1472
+ const res = await authControllerGetOAuth2Token({
1473
+ body: {
1474
+ grant_type: "client_credentials",
1475
+ client_id: this.config.clientId,
1476
+ client_secret: this.config.clientSecret
1477
+ }
1478
+ });
1479
+ if (!res.response.ok) {
1480
+ const error = await res.response.text();
1481
+ throw new Error(`Authentication failed: ${res.response.status} ${error}`);
1482
+ }
1483
+ const data = res.data;
1484
+ this.accessToken = data.access_token;
1485
+ this.tokenExpiresAt = Date.now() + data.expires_in * 1e3;
1486
+ client.setConfig({
1487
+ baseUrl: this.config.baseUrl,
1488
+ fetch: this.config.fetch,
1489
+ headers: {
1490
+ Authorization: `Bearer ${this.accessToken}`
1491
+ }
1492
+ });
1493
+ }
1494
+ /**
1495
+ * Ensure we have a valid access token, refreshing if necessary.
1496
+ */
1497
+ async ensureAuthenticated() {
1498
+ const bufferMs = 6e4;
1499
+ if (!this.accessToken || !this.tokenExpiresAt) {
1500
+ await this.authenticate();
1501
+ return;
1502
+ }
1503
+ if (this.config.autoRefresh && Date.now() > this.tokenExpiresAt - bufferMs) {
1504
+ await this.authenticate();
1505
+ }
1506
+ }
1507
+ /**
1508
+ * Create a credential issuance offer.
1509
+ *
1510
+ * @example
1511
+ * ```typescript
1512
+ * const { uri, sessionId } = await client.createIssuanceOffer({
1513
+ * credentialConfigurationIds: ['PID'],
1514
+ * claims: {
1515
+ * PID: { given_name: 'John', family_name: 'Doe' }
1516
+ * }
1517
+ * });
1518
+ * ```
1519
+ */
1520
+ async createIssuanceOffer(options) {
1521
+ await this.ensureAuthenticated();
1522
+ const body = {
1523
+ response_type: options.responseType ?? "uri",
1524
+ credentialConfigurationIds: options.credentialConfigurationIds,
1525
+ flow: options.flow ?? "pre_authorized_code",
1526
+ tx_code: options.txCode
1527
+ };
1528
+ if (options.claims) {
1529
+ body.credentialClaims = {
1530
+ additionalProperties: void 0
1531
+ };
1532
+ for (const [configId, claims] of Object.entries(options.claims)) {
1533
+ body.credentialClaims[configId] = {
1534
+ type: "inline",
1535
+ claims
1536
+ };
1537
+ }
1538
+ }
1539
+ const response = await credentialOfferControllerGetOffer({
1540
+ body
1541
+ });
1542
+ if (!response.data) {
1543
+ throw new Error("Failed to create issuance offer");
1544
+ }
1545
+ return {
1546
+ uri: response.data.uri,
1547
+ sessionId: response.data.session
1548
+ };
1549
+ }
1550
+ /**
1551
+ * Create a presentation request (for verification).
1552
+ *
1553
+ * Returns two URIs:
1554
+ * - `uri`: For same-device flow (wallet on same device, redirect after completion)
1555
+ * - `crossDeviceUri`: For cross-device flow (QR code, no redirect, poll for status)
1556
+ *
1557
+ * @example Same-device flow (wallet app on user's device)
1558
+ * ```typescript
1559
+ * const { uri, sessionId } = await client.createPresentationRequest({
1560
+ * configId: 'age-over-18',
1561
+ * redirectUri: 'https://example.com/callback'
1562
+ * });
1563
+ * // Redirect user to uri - wallet will redirect back after completion
1564
+ * window.location.href = uri;
1565
+ * ```
1566
+ *
1567
+ * @example Cross-device flow (QR code scanned by separate device)
1568
+ * ```typescript
1569
+ * const { crossDeviceUri, sessionId } = await client.createPresentationRequest({
1570
+ * configId: 'age-over-18'
1571
+ * });
1572
+ * // Display crossDeviceUri as QR code, then poll for completion
1573
+ * const session = await client.waitForSession(sessionId);
1574
+ * ```
1575
+ */
1576
+ async createPresentationRequest(options) {
1577
+ await this.ensureAuthenticated();
1578
+ const body = {
1579
+ response_type: options.responseType ?? "uri",
1580
+ requestId: options.configId,
1581
+ redirectUri: options.redirectUri
1582
+ };
1583
+ const response = await verifierOfferControllerGetOffer({
1584
+ body
1585
+ });
1586
+ if (!response.data) {
1587
+ throw new Error("Failed to create presentation request");
1588
+ }
1589
+ return {
1590
+ uri: response.data.uri,
1591
+ crossDeviceUri: response.data.crossDeviceUri ?? response.data.uri,
1592
+ sessionId: response.data.session
1593
+ };
1594
+ }
1595
+ /**
1596
+ * Get the current health of the EUDIPLO connector.
1597
+ * The status in the response is `ok`/`error`.
1598
+ * The health of the components is listed in the response under `info`/`error`/`details`.
1599
+ * If the EUDIPLO connector itself is unreachable, no components are listed.
1600
+ */
1601
+ async getHealth() {
1602
+ const response = await healthControllerCheck({ throwOnError: false });
1603
+ if (!response.data) {
1604
+ return { status: "error" };
1605
+ }
1606
+ return response.data;
1607
+ }
1608
+ /**
1609
+ * Get the current status of a session.
1610
+ */
1611
+ async getSession(sessionId) {
1612
+ await this.ensureAuthenticated();
1613
+ const response = await sessionControllerGetSession({
1614
+ path: { id: sessionId }
1615
+ });
1616
+ if (!response.data) {
1617
+ throw new Error(`Session not found: ${sessionId}`);
1618
+ }
1619
+ return response.data;
1620
+ }
1621
+ /**
1622
+ * Wait for a session to complete (polling).
1623
+ *
1624
+ * @example
1625
+ * ```typescript
1626
+ * const session = await client.waitForSession(sessionId, {
1627
+ * interval: 1000,
1628
+ * timeout: 60000,
1629
+ * onUpdate: (s) => console.log('Status:', s.status)
1630
+ * });
1631
+ * ```
1632
+ */
1633
+ async waitForSession(sessionId, options = {}) {
1634
+ const {
1635
+ interval = 1e3,
1636
+ timeout = 3e5,
1637
+ onUpdate,
1638
+ signal
1639
+ } = options;
1640
+ const startTime = Date.now();
1641
+ while (true) {
1642
+ if (signal?.aborted) {
1643
+ throw new Error("Session polling aborted");
1644
+ }
1645
+ if (Date.now() - startTime > timeout) {
1646
+ throw new Error(`Session polling timed out after ${timeout}ms`);
1647
+ }
1648
+ const session = await this.getSession(sessionId);
1649
+ if (onUpdate) {
1650
+ onUpdate(session);
1651
+ }
1652
+ if (session.status === "completed") {
1653
+ return session;
1654
+ }
1655
+ if (session.status === "expired" || session.status === "failed") {
1656
+ throw new Error(`Session ${session.status}: ${sessionId}`);
1657
+ }
1658
+ await this.sleep(interval, signal);
1659
+ }
1660
+ }
1661
+ /**
1662
+ * Helper to sleep with abort support
1663
+ */
1664
+ sleep(ms, signal) {
1665
+ return new Promise((resolve, reject) => {
1666
+ const timeoutId = setTimeout(resolve, ms);
1667
+ if (signal) {
1668
+ signal.addEventListener("abort", () => {
1669
+ clearTimeout(timeoutId);
1670
+ reject(new Error("Aborted"));
1671
+ }, { once: true });
1672
+ }
1673
+ });
1674
+ }
1675
+ /**
1676
+ * Subscribe to real-time session status updates via Server-Sent Events.
1677
+ *
1678
+ * This is more efficient than polling and provides instant updates.
1679
+ * The connection remains open until closed or the session reaches a terminal state.
1680
+ *
1681
+ * @example
1682
+ * ```typescript
1683
+ * const subscription = await client.subscribeToSession(sessionId, {
1684
+ * onStatusChange: (event) => {
1685
+ * console.log(`Status: ${event.status}`);
1686
+ * if (['completed', 'expired', 'failed'].includes(event.status)) {
1687
+ * subscription.close();
1688
+ * }
1689
+ * },
1690
+ * onError: (error) => console.error('SSE error:', error)
1691
+ * });
1692
+ *
1693
+ * // Later, to close the connection:
1694
+ * subscription.close();
1695
+ * ```
1696
+ */
1697
+ async subscribeToSession(sessionId, options = {}) {
1698
+ await this.ensureAuthenticated();
1699
+ const token = this.accessToken;
1700
+ if (!token) {
1701
+ throw new Error("No access token available");
1702
+ }
1703
+ if (typeof EventSource === "undefined") {
1704
+ throw new Error(
1705
+ "EventSource is not available in this environment. Use polling with waitForSession() instead, or provide a polyfill."
1706
+ );
1707
+ }
1708
+ const url = `${this.config.baseUrl}/session/${sessionId}/events?token=${encodeURIComponent(token)}`;
1709
+ const eventSource = new EventSource(url);
1710
+ eventSource.onopen = () => {
1711
+ options.onOpen?.();
1712
+ };
1713
+ eventSource.onmessage = (event) => {
1714
+ try {
1715
+ const data = JSON.parse(event.data);
1716
+ options.onStatusChange?.(data);
1717
+ } catch (error) {
1718
+ options.onError?.(new Error(`Failed to parse SSE event: ${error}`));
1719
+ }
1720
+ };
1721
+ eventSource.onerror = () => {
1722
+ options.onError?.(new Error("SSE connection error"));
1723
+ };
1724
+ return {
1725
+ close: () => eventSource.close()
1726
+ };
1727
+ }
1728
+ /**
1729
+ * Subscribe to session and wait for completion via SSE.
1730
+ *
1731
+ * Returns a Promise that resolves when the session completes,
1732
+ * or rejects if it fails/expires.
1733
+ *
1734
+ * @example
1735
+ * ```typescript
1736
+ * try {
1737
+ * const finalStatus = await client.waitForSessionWithSse(sessionId);
1738
+ * console.log('Session completed:', finalStatus);
1739
+ * } catch (error) {
1740
+ * console.error('Session failed:', error);
1741
+ * }
1742
+ * ```
1743
+ */
1744
+ async waitForSessionWithSse(sessionId, options = {}) {
1745
+ return new Promise(async (resolve, reject) => {
1746
+ try {
1747
+ const subscription = await this.subscribeToSession(sessionId, {
1748
+ onStatusChange: (event) => {
1749
+ options.onStatusChange?.(event);
1750
+ if (event.status === "completed") {
1751
+ subscription.close();
1752
+ resolve(event);
1753
+ } else if (event.status === "expired" || event.status === "failed") {
1754
+ subscription.close();
1755
+ reject(new Error(`Session ${event.status}: ${sessionId}`));
1756
+ }
1757
+ },
1758
+ onError: (error) => {
1759
+ console.warn("SSE connection error, reconnecting...", error);
1760
+ }
1761
+ });
1762
+ } catch (error) {
1763
+ reject(error);
1764
+ }
1765
+ });
1766
+ }
1767
+ /**
1768
+ * Get the current access token (for advanced usage)
1769
+ */
1770
+ getAccessToken() {
1771
+ return this.accessToken;
1772
+ }
1773
+ /**
1774
+ * Get the configured base URL
1775
+ */
1776
+ getBaseUrl() {
1777
+ return this.config.baseUrl;
1778
+ }
1779
+ // ==========================================================================
1780
+ // Digital Credentials API Methods
1781
+ // ==========================================================================
1782
+ /**
1783
+ * Create a presentation request configured for DC API usage.
1784
+ * Returns a session with the signed request object needed for DC API.
1785
+ *
1786
+ * @example
1787
+ * ```typescript
1788
+ * const session = await client.createDcApiPresentationRequest({
1789
+ * configId: 'age-over-18'
1790
+ * });
1791
+ *
1792
+ * // Use the requestObject with the DC API
1793
+ * const result = await client.submitDcApiPresentation(session);
1794
+ * ```
1795
+ */
1796
+ async createDcApiPresentationRequest(options) {
1797
+ await this.ensureAuthenticated();
1798
+ const body = {
1799
+ response_type: "dc-api",
1800
+ requestId: options.configId,
1801
+ redirectUri: options.redirectUri
1802
+ };
1803
+ const response = await verifierOfferControllerGetOffer({
1804
+ body
1805
+ });
1806
+ if (!response.data) {
1807
+ throw new Error("Failed to create DC API presentation request");
1808
+ }
1809
+ return this.getSession(response.data.session);
1810
+ }
1811
+ /**
1812
+ * Submit a presentation using the Digital Credentials API.
1813
+ * This method handles the browser DC API call and submits the response to the verifier.
1814
+ *
1815
+ * @example
1816
+ * ```typescript
1817
+ * // Check if DC API is available
1818
+ * if (!isDcApiAvailable()) {
1819
+ * throw new Error('DC API not supported in this browser');
1820
+ * }
1821
+ *
1822
+ * const session = await client.createDcApiPresentationRequest({
1823
+ * configId: 'age-over-18'
1824
+ * });
1825
+ *
1826
+ * const result = await client.submitDcApiPresentation(session);
1827
+ * console.log('Verified credentials:', result.credentials);
1828
+ * ```
1829
+ */
1830
+ async submitDcApiPresentation(session, options = {}) {
1831
+ if (!isDcApiAvailable()) {
1832
+ throw new Error(
1833
+ "Digital Credentials API is not available in this browser. Please use a supported browser or fall back to QR code flow."
1834
+ );
1835
+ }
1836
+ if (!session.requestObject) {
1837
+ throw new Error(
1838
+ 'Session does not contain a requestObject. Make sure to create the session with response_type: "dc-api"'
1839
+ );
1840
+ }
1841
+ const dcResponse = await navigator.credentials.get({
1842
+ mediation: "required",
1843
+ digital: {
1844
+ requests: [
1845
+ {
1846
+ protocol: "openid4vp-v1-signed",
1847
+ data: { request: session.requestObject }
1848
+ }
1849
+ ]
1850
+ }
1851
+ });
1852
+ if (!dcResponse) {
1853
+ throw new Error("No response from Digital Credentials API");
1854
+ }
1855
+ if (dcResponse.data?.error) {
1856
+ throw new Error(
1857
+ `Wallet error: ${dcResponse.data.error}${dcResponse.data.error_description ? ` - ${dcResponse.data.error_description}` : ""}`
1858
+ );
1859
+ }
1860
+ const requestPayload = decodeJwtPayload(
1861
+ session.requestObject
1862
+ );
1863
+ if (!requestPayload.response_uri) {
1864
+ throw new Error("No response_uri found in request object");
1865
+ }
1866
+ const fetchImpl = this.config.fetch ?? fetch;
1867
+ const submitResponse = await fetchImpl(requestPayload.response_uri, {
1868
+ method: "POST",
1869
+ headers: {
1870
+ "Content-Type": "application/json"
1871
+ },
1872
+ body: JSON.stringify({
1873
+ ...dcResponse.data,
1874
+ sendResponse: options.sendResponse ?? true
1875
+ })
1876
+ });
1877
+ if (!submitResponse.ok) {
1878
+ const errorText = await submitResponse.text();
1879
+ throw new Error(
1880
+ `Failed to submit presentation: ${submitResponse.status} ${errorText}`
1881
+ );
1882
+ }
1883
+ const result = await submitResponse.json();
1884
+ return {
1885
+ credentials: result.credentials ?? result,
1886
+ response: result,
1887
+ redirectUri: result.redirect_uri
1888
+ };
1889
+ }
1890
+ /**
1891
+ * Convenience method to create a presentation request and immediately
1892
+ * submit it using the Digital Credentials API.
1893
+ *
1894
+ * @example
1895
+ * ```typescript
1896
+ * const result = await client.verifyWithDcApi({
1897
+ * configId: 'age-over-18'
1898
+ * });
1899
+ * console.log('Verified:', result.credentials);
1900
+ * ```
1901
+ */
1902
+ async verifyWithDcApi(options, dcOptions = {}) {
1903
+ const session = await this.createDcApiPresentationRequest(options);
1904
+ return this.submitDcApiPresentation(session, dcOptions);
1905
+ }
1906
+ };
1907
+ async function verify(options) {
1908
+ const client2 = new EudiploClient({
1909
+ baseUrl: options.baseUrl,
1910
+ clientId: options.clientId,
1911
+ clientSecret: options.clientSecret
1912
+ });
1913
+ const { uri, sessionId } = await client2.createPresentationRequest({
1914
+ configId: options.configId,
1915
+ redirectUri: options.redirectUri
1916
+ });
1917
+ return {
1918
+ uri,
1919
+ sessionId,
1920
+ waitForCompletion: (pollingOptions) => client2.waitForSession(sessionId, { ...options.polling, ...pollingOptions }),
1921
+ getStatus: () => client2.getSession(sessionId)
1922
+ };
1923
+ }
1924
+ async function issue(options) {
1925
+ const client2 = new EudiploClient({
1926
+ baseUrl: options.baseUrl,
1927
+ clientId: options.clientId,
1928
+ clientSecret: options.clientSecret
1929
+ });
1930
+ const { uri, sessionId } = await client2.createIssuanceOffer({
1931
+ credentialConfigurationIds: options.credentialConfigurationIds,
1932
+ claims: options.claims,
1933
+ txCode: options.txCode
1934
+ });
1935
+ return {
1936
+ uri,
1937
+ sessionId,
1938
+ waitForCompletion: (pollingOptions) => client2.waitForSession(sessionId, { ...options.polling, ...pollingOptions }),
1939
+ getStatus: () => client2.getSession(sessionId)
1940
+ };
1941
+ }
1942
+ async function verifyAndWait(options) {
1943
+ const { uri, waitForCompletion } = await verify(options);
1944
+ options.onUri(uri);
1945
+ return waitForCompletion(options.polling);
1946
+ }
1947
+ async function issueAndWait(options) {
1948
+ const { uri, waitForCompletion } = await issue(options);
1949
+ options.onUri(uri);
1950
+ return waitForCompletion(options.polling);
1951
+ }
1952
+ async function verifyWithDcApi(options) {
1953
+ const eudiploClient = new EudiploClient({
1954
+ baseUrl: options.baseUrl,
1955
+ clientId: options.clientId,
1956
+ clientSecret: options.clientSecret
1957
+ });
1958
+ return eudiploClient.verifyWithDcApi(
1959
+ {
1960
+ configId: options.configId,
1961
+ redirectUri: options.redirectUri
1962
+ },
1963
+ {
1964
+ sendResponse: options.sendResponse
1965
+ }
1966
+ );
1967
+ }
1968
+ async function createDcApiRequest(options) {
1969
+ const eudiploClient = new EudiploClient({
1970
+ baseUrl: options.baseUrl,
1971
+ clientId: options.clientId,
1972
+ clientSecret: options.clientSecret
1973
+ });
1974
+ const session = await eudiploClient.createDcApiPresentationRequest({
1975
+ configId: options.configId,
1976
+ redirectUri: options.redirectUri
1977
+ });
1978
+ return {
1979
+ session,
1980
+ submit: (dcOptions) => eudiploClient.submitDcApiPresentation(session, {
1981
+ sendResponse: options.sendResponse,
1982
+ ...dcOptions
1983
+ })
1984
+ };
1985
+ }
1986
+ async function createDcApiRequestForBrowser(options) {
1987
+ const eudiploClient = new EudiploClient({
1988
+ baseUrl: options.baseUrl,
1989
+ clientId: options.clientId,
1990
+ clientSecret: options.clientSecret
1991
+ });
1992
+ const session = await eudiploClient.createDcApiPresentationRequest({
1993
+ configId: options.configId,
1994
+ redirectUri: options.redirectUri
1995
+ });
1996
+ if (!session.requestObject) {
1997
+ throw new Error("Session does not contain a requestObject");
1998
+ }
1999
+ const requestPayload = decodeJwtPayload(
2000
+ session.requestObject
2001
+ );
2002
+ if (!requestPayload.response_uri) {
2003
+ throw new Error("No response_uri found in request object");
2004
+ }
2005
+ return {
2006
+ requestObject: session.requestObject,
2007
+ sessionId: session.id,
2008
+ responseUri: requestPayload.response_uri
2009
+ };
2010
+ }
2011
+ async function callDcApi(requestObject) {
2012
+ if (!isDcApiAvailable()) {
2013
+ throw new Error(
2014
+ "Digital Credentials API is not available in this browser. Please use a supported browser or fall back to QR code flow."
2015
+ );
2016
+ }
2017
+ const dcResponse = await navigator.credentials.get({
2018
+ mediation: "required",
2019
+ digital: {
2020
+ requests: [
2021
+ {
2022
+ protocol: "openid4vp-v1-signed",
2023
+ data: { request: requestObject }
2024
+ }
2025
+ ]
2026
+ }
2027
+ });
2028
+ if (!dcResponse) {
2029
+ throw new Error("No response from Digital Credentials API");
2030
+ }
2031
+ if (dcResponse.data?.error) {
2032
+ throw new Error(
2033
+ `Wallet error: ${dcResponse.data.error}${dcResponse.data.error_description ? ` - ${dcResponse.data.error_description}` : ""}`
2034
+ );
2035
+ }
2036
+ return dcResponse.data;
2037
+ }
2038
+ async function submitDcApiWalletResponse(options) {
2039
+ const fetchImpl = options.fetch ?? fetch;
2040
+ const submitResponse = await fetchImpl(options.responseUri, {
2041
+ method: "POST",
2042
+ headers: {
2043
+ "Content-Type": "application/json"
2044
+ },
2045
+ body: JSON.stringify({
2046
+ ...options.walletResponse,
2047
+ sendResponse: options.sendResponse ?? true
2048
+ })
2049
+ });
2050
+ if (!submitResponse.ok) {
2051
+ const errorText = await submitResponse.text();
2052
+ throw new Error(
2053
+ `Failed to submit presentation: ${submitResponse.status} ${errorText}`
2054
+ );
2055
+ }
2056
+ const result = await submitResponse.json();
2057
+ return {
2058
+ credentials: result.credentials ?? result,
2059
+ response: result,
2060
+ redirectUri: result.redirect_uri
2061
+ };
2062
+ }
2063
+
2064
+ exports.EudiploClient = EudiploClient;
2065
+ exports.appControllerMain = appControllerMain;
2066
+ exports.authControllerGetGlobalJwks = authControllerGetGlobalJwks;
2067
+ exports.authControllerGetOAuth2Token = authControllerGetOAuth2Token;
2068
+ exports.authControllerGetOidcDiscovery = authControllerGetOidcDiscovery;
2069
+ exports.authorizeControllerAuthorize = authorizeControllerAuthorize;
2070
+ exports.authorizeControllerPar = authorizeControllerPar;
2071
+ exports.authorizeControllerToken = authorizeControllerToken;
2072
+ exports.cacheControllerClearAllCaches = cacheControllerClearAllCaches;
2073
+ exports.cacheControllerClearStatusListCache = cacheControllerClearStatusListCache;
2074
+ exports.cacheControllerClearTrustListCache = cacheControllerClearTrustListCache;
2075
+ exports.cacheControllerGetStats = cacheControllerGetStats;
2076
+ exports.callDcApi = callDcApi;
2077
+ exports.certControllerAddCertificate = certControllerAddCertificate;
2078
+ exports.certControllerDeleteCertificate = certControllerDeleteCertificate;
2079
+ exports.certControllerExportConfig = certControllerExportConfig;
2080
+ exports.certControllerGetCertificate = certControllerGetCertificate;
2081
+ exports.certControllerGetCertificates = certControllerGetCertificates;
2082
+ exports.certControllerUpdateCertificate = certControllerUpdateCertificate;
2083
+ exports.chainedAsControllerAuthorize = chainedAsControllerAuthorize;
2084
+ exports.chainedAsControllerCallback = chainedAsControllerCallback;
2085
+ exports.chainedAsControllerGetMetadata = chainedAsControllerGetMetadata;
2086
+ exports.chainedAsControllerJwks = chainedAsControllerJwks;
2087
+ exports.chainedAsControllerPar = chainedAsControllerPar;
2088
+ exports.chainedAsControllerToken = chainedAsControllerToken;
2089
+ exports.client = client;
2090
+ exports.clientControllerCreateClient = clientControllerCreateClient;
2091
+ exports.clientControllerDeleteClient = clientControllerDeleteClient;
2092
+ exports.clientControllerGetClient = clientControllerGetClient;
2093
+ exports.clientControllerGetClientSecret = clientControllerGetClientSecret;
2094
+ exports.clientControllerGetClients = clientControllerGetClients;
2095
+ exports.clientControllerRotateClientSecret = clientControllerRotateClientSecret;
2096
+ exports.clientControllerUpdateClient = clientControllerUpdateClient;
2097
+ exports.createDcApiRequest = createDcApiRequest;
2098
+ exports.createDcApiRequestForBrowser = createDcApiRequestForBrowser;
2099
+ exports.credentialConfigControllerDeleteIssuanceConfiguration = credentialConfigControllerDeleteIssuanceConfiguration;
2100
+ exports.credentialConfigControllerGetConfigById = credentialConfigControllerGetConfigById;
2101
+ exports.credentialConfigControllerGetConfigs = credentialConfigControllerGetConfigs;
2102
+ exports.credentialConfigControllerStoreCredentialConfiguration = credentialConfigControllerStoreCredentialConfiguration;
2103
+ exports.credentialConfigControllerUpdateCredentialConfiguration = credentialConfigControllerUpdateCredentialConfiguration;
2104
+ exports.credentialOfferControllerGetOffer = credentialOfferControllerGetOffer;
2105
+ exports.deferredControllerCompleteDeferred = deferredControllerCompleteDeferred;
2106
+ exports.deferredControllerFailDeferred = deferredControllerFailDeferred;
2107
+ exports.healthControllerCheck = healthControllerCheck;
2108
+ exports.interactiveAuthorizationControllerCompleteWebAuth = interactiveAuthorizationControllerCompleteWebAuth;
2109
+ exports.interactiveAuthorizationControllerInteractiveAuthorization = interactiveAuthorizationControllerInteractiveAuthorization;
2110
+ exports.isDcApiAvailable = isDcApiAvailable;
2111
+ exports.issuanceConfigControllerGetIssuanceConfigurations = issuanceConfigControllerGetIssuanceConfigurations;
2112
+ exports.issuanceConfigControllerStoreIssuanceConfiguration = issuanceConfigControllerStoreIssuanceConfiguration;
2113
+ exports.issue = issue;
2114
+ exports.issueAndWait = issueAndWait;
2115
+ exports.keyControllerAddKey = keyControllerAddKey;
2116
+ exports.keyControllerDeleteKey = keyControllerDeleteKey;
2117
+ exports.keyControllerGetKey = keyControllerGetKey;
2118
+ exports.keyControllerGetKeys = keyControllerGetKeys;
2119
+ exports.keyControllerUpdateKey = keyControllerUpdateKey;
2120
+ exports.oid4VciControllerCredential = oid4VciControllerCredential;
2121
+ exports.oid4VciControllerDeferredCredential = oid4VciControllerDeferredCredential;
2122
+ exports.oid4VciControllerNonce = oid4VciControllerNonce;
2123
+ exports.oid4VciControllerNotifications = oid4VciControllerNotifications;
2124
+ exports.oid4VciMetadataControllerVct = oid4VciMetadataControllerVct;
2125
+ exports.oid4VpControllerGetPostRequestWithSession = oid4VpControllerGetPostRequestWithSession;
2126
+ exports.oid4VpControllerGetRequestNoRedirectWithSession = oid4VpControllerGetRequestNoRedirectWithSession;
2127
+ exports.oid4VpControllerGetRequestWithSession = oid4VpControllerGetRequestWithSession;
2128
+ exports.oid4VpControllerGetResponse = oid4VpControllerGetResponse;
2129
+ exports.presentationManagementControllerConfiguration = presentationManagementControllerConfiguration;
2130
+ exports.presentationManagementControllerDeleteConfiguration = presentationManagementControllerDeleteConfiguration;
2131
+ exports.presentationManagementControllerGetConfiguration = presentationManagementControllerGetConfiguration;
2132
+ exports.presentationManagementControllerStorePresentationConfig = presentationManagementControllerStorePresentationConfig;
2133
+ exports.presentationManagementControllerUpdateConfiguration = presentationManagementControllerUpdateConfiguration;
2134
+ exports.registrarControllerCreateAccessCertificate = registrarControllerCreateAccessCertificate;
2135
+ exports.registrarControllerCreateConfig = registrarControllerCreateConfig;
2136
+ exports.registrarControllerDeleteConfig = registrarControllerDeleteConfig;
2137
+ exports.registrarControllerGetConfig = registrarControllerGetConfig;
2138
+ exports.registrarControllerUpdateConfig = registrarControllerUpdateConfig;
2139
+ exports.sessionConfigControllerGetConfig = sessionConfigControllerGetConfig;
2140
+ exports.sessionConfigControllerResetConfig = sessionConfigControllerResetConfig;
2141
+ exports.sessionConfigControllerUpdateConfig = sessionConfigControllerUpdateConfig;
2142
+ exports.sessionControllerDeleteSession = sessionControllerDeleteSession;
2143
+ exports.sessionControllerGetAllSessions = sessionControllerGetAllSessions;
2144
+ exports.sessionControllerGetSession = sessionControllerGetSession;
2145
+ exports.sessionControllerRevokeAll = sessionControllerRevokeAll;
2146
+ exports.sessionEventsControllerSubscribeToSessionEvents = sessionEventsControllerSubscribeToSessionEvents;
2147
+ exports.statusListConfigControllerGetConfig = statusListConfigControllerGetConfig;
2148
+ exports.statusListConfigControllerResetConfig = statusListConfigControllerResetConfig;
2149
+ exports.statusListConfigControllerUpdateConfig = statusListConfigControllerUpdateConfig;
2150
+ exports.statusListControllerGetList = statusListControllerGetList;
2151
+ exports.statusListControllerGetStatusListAggregation = statusListControllerGetStatusListAggregation;
2152
+ exports.statusListManagementControllerCreateList = statusListManagementControllerCreateList;
2153
+ exports.statusListManagementControllerDeleteList = statusListManagementControllerDeleteList;
2154
+ exports.statusListManagementControllerGetList = statusListManagementControllerGetList;
2155
+ exports.statusListManagementControllerGetLists = statusListManagementControllerGetLists;
2156
+ exports.statusListManagementControllerUpdateList = statusListManagementControllerUpdateList;
2157
+ exports.storageControllerDownload = storageControllerDownload;
2158
+ exports.storageControllerUpload = storageControllerUpload;
2159
+ exports.submitDcApiWalletResponse = submitDcApiWalletResponse;
2160
+ exports.tenantControllerDeleteTenant = tenantControllerDeleteTenant;
2161
+ exports.tenantControllerGetTenant = tenantControllerGetTenant;
2162
+ exports.tenantControllerGetTenants = tenantControllerGetTenants;
2163
+ exports.tenantControllerInitTenant = tenantControllerInitTenant;
2164
+ exports.tenantControllerUpdateTenant = tenantControllerUpdateTenant;
2165
+ exports.trustListControllerCreateTrustList = trustListControllerCreateTrustList;
2166
+ exports.trustListControllerDeleteTrustList = trustListControllerDeleteTrustList;
2167
+ exports.trustListControllerExportTrustList = trustListControllerExportTrustList;
2168
+ exports.trustListControllerGetAllTrustLists = trustListControllerGetAllTrustLists;
2169
+ exports.trustListControllerGetTrustList = trustListControllerGetTrustList;
2170
+ exports.trustListControllerGetTrustListVersion = trustListControllerGetTrustListVersion;
2171
+ exports.trustListControllerGetTrustListVersions = trustListControllerGetTrustListVersions;
2172
+ exports.trustListControllerUpdateTrustList = trustListControllerUpdateTrustList;
2173
+ exports.trustListPublicControllerGetTrustListJwt = trustListPublicControllerGetTrustListJwt;
2174
+ exports.verifierOfferControllerGetOffer = verifierOfferControllerGetOffer;
2175
+ exports.verify = verify;
2176
+ exports.verifyAndWait = verifyAndWait;
2177
+ exports.verifyWithDcApi = verifyWithDcApi;
2178
+ exports.wellKnownControllerAuthzMetadata0 = wellKnownControllerAuthzMetadata0;
2179
+ exports.wellKnownControllerAuthzMetadata1 = wellKnownControllerAuthzMetadata1;
2180
+ exports.wellKnownControllerGetJwks0 = wellKnownControllerGetJwks0;
2181
+ exports.wellKnownControllerGetJwks1 = wellKnownControllerGetJwks1;
2182
+ exports.wellKnownControllerIssuerMetadata0 = wellKnownControllerIssuerMetadata0;
2183
+ exports.wellKnownControllerIssuerMetadata1 = wellKnownControllerIssuerMetadata1;
2184
+ //# sourceMappingURL=index.js.map
2185
+ //# sourceMappingURL=index.js.map