@eudiplo/sdk-core 4.4.0 → 4.5.0
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/README.md +45 -170
- package/dist/api/client/client.gen.d.mts +1 -1
- package/dist/api/client/client.gen.d.ts +1 -1
- package/dist/api/client/client.gen.js +12 -44
- package/dist/api/client/client.gen.mjs +12 -44
- package/dist/api/client/index.d.mts +4 -4
- package/dist/api/client/index.d.ts +4 -4
- package/dist/api/client/index.js +18 -54
- package/dist/api/client/index.mjs +18 -54
- package/dist/api/client/types.gen.d.mts +1 -1
- package/dist/api/client/types.gen.d.ts +1 -1
- package/dist/api/client.gen.d.mts +2 -2
- package/dist/api/client.gen.d.ts +2 -2
- package/dist/api/client.gen.js +13 -47
- package/dist/api/client.gen.mjs +13 -47
- package/dist/api/index.d.mts +79 -75
- package/dist/api/index.d.ts +79 -75
- package/dist/api/index.js +108 -136
- package/dist/api/index.mjs +106 -135
- package/dist/index.d.mts +56 -295
- package/dist/index.d.ts +56 -295
- package/dist/index.js +389 -308
- package/dist/index.mjs +381 -298
- package/dist/{types.gen-DKrNRB-E.d.mts → types.gen-Cc6DtXw9.d.mts} +23 -23
- package/dist/{types.gen-DKrNRB-E.d.ts → types.gen-Cc6DtXw9.d.ts} +23 -23
- package/dist/{types.gen-DpwDhqbe.d.mts → types.gen-z3We9JHj.d.mts} +898 -787
- package/dist/{types.gen-DpwDhqbe.d.ts → types.gen-z3We9JHj.d.ts} +898 -787
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -12,227 +12,102 @@ pnpm add @eudiplo/sdk-core
|
|
|
12
12
|
yarn add @eudiplo/sdk-core
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
## Quick Start
|
|
16
|
-
|
|
17
|
-
### One-liner for Age Verification
|
|
15
|
+
## Quick Start
|
|
18
16
|
|
|
19
17
|
```typescript
|
|
20
|
-
import {
|
|
18
|
+
import { EudiploClient } from '@eudiplo/sdk-core';
|
|
21
19
|
|
|
22
|
-
const
|
|
20
|
+
const client = new EudiploClient({
|
|
23
21
|
baseUrl: 'https://eudiplo.example.com',
|
|
24
22
|
clientId: 'my-demo',
|
|
25
23
|
clientSecret: 'secret',
|
|
26
|
-
configId: 'age-over-18',
|
|
27
|
-
onUri: (uri) => showQRCode(uri), // Your QR code display function
|
|
28
|
-
onUpdate: (s) => console.log('Status:', s.status),
|
|
29
24
|
});
|
|
30
25
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
### Two-step Flow (More Control)
|
|
35
|
-
|
|
36
|
-
```typescript
|
|
37
|
-
import { verify } from '@eudiplo/sdk-core';
|
|
38
|
-
|
|
39
|
-
// Step 1: Create the request
|
|
40
|
-
const { uri, sessionId, waitForCompletion } = await verify({
|
|
41
|
-
baseUrl: 'https://eudiplo.example.com',
|
|
42
|
-
clientId: 'my-demo',
|
|
43
|
-
clientSecret: 'secret',
|
|
26
|
+
// Verification (QR flow)
|
|
27
|
+
const verifyOffer = await client.createPresentationRequest({
|
|
44
28
|
configId: 'age-over-18',
|
|
45
29
|
});
|
|
30
|
+
showQRCode(verifyOffer.uri);
|
|
31
|
+
const verifiedSession = await client.waitForSession(verifyOffer.sessionId);
|
|
46
32
|
|
|
47
|
-
//
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
// Step 3: Wait for user to scan and respond
|
|
51
|
-
const session = await waitForCompletion();
|
|
52
|
-
console.log('Verified credentials:', session.credentials);
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### Credential Issuance
|
|
56
|
-
|
|
57
|
-
```typescript
|
|
58
|
-
import { issue } from '@eudiplo/sdk-core';
|
|
59
|
-
|
|
60
|
-
const { uri, waitForCompletion } = await issue({
|
|
61
|
-
baseUrl: 'https://eudiplo.example.com',
|
|
62
|
-
clientId: 'my-demo',
|
|
63
|
-
clientSecret: 'secret',
|
|
33
|
+
// Issuance (QR flow)
|
|
34
|
+
const issuanceOffer = await client.createIssuanceOffer({
|
|
64
35
|
credentialConfigurationIds: ['PID'],
|
|
65
36
|
claims: {
|
|
66
37
|
PID: { given_name: 'John', family_name: 'Doe', birthdate: '1990-01-15' },
|
|
67
38
|
},
|
|
68
39
|
});
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
await waitForCompletion();
|
|
40
|
+
showQRCode(issuanceOffer.uri);
|
|
41
|
+
await client.waitForSession(issuanceOffer.sessionId);
|
|
72
42
|
```
|
|
73
43
|
|
|
74
44
|
## Full API
|
|
75
45
|
|
|
76
|
-
###
|
|
46
|
+
### Class API
|
|
77
47
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
|
81
|
-
|
|
|
82
|
-
| `
|
|
83
|
-
| `
|
|
48
|
+
Use `EudiploClient` methods directly:
|
|
49
|
+
|
|
50
|
+
| Method | Description |
|
|
51
|
+
| ----------------------------- | ---------------------------------------------- |
|
|
52
|
+
| `createPresentationRequest()` | Create verification request URI and session ID |
|
|
53
|
+
| `createIssuanceOffer()` | Create issuance offer URI and session ID |
|
|
54
|
+
| `waitForSession()` | Poll session until terminal state |
|
|
55
|
+
| `subscribeToSession()` | Subscribe via SSE |
|
|
56
|
+
| `verifyWithDcApi()` | Browser-native DC API end-to-end flow |
|
|
84
57
|
|
|
85
58
|
### Digital Credentials API (Browser Native)
|
|
86
59
|
|
|
87
60
|
The SDK includes utilities for the [Digital Credentials API](https://wicg.github.io/digital-credentials/), enabling browser-native credential presentation without QR codes.
|
|
88
61
|
|
|
89
62
|
```typescript
|
|
90
|
-
import { isDcApiAvailable,
|
|
63
|
+
import { isDcApiAvailable, EudiploClient } from '@eudiplo/sdk-core';
|
|
64
|
+
|
|
65
|
+
const client = new EudiploClient({
|
|
66
|
+
baseUrl: 'https://eudiplo.example.com',
|
|
67
|
+
clientId: 'my-demo',
|
|
68
|
+
clientSecret: 'secret',
|
|
69
|
+
});
|
|
91
70
|
|
|
92
71
|
// Check if browser supports DC API
|
|
93
72
|
if (isDcApiAvailable()) {
|
|
94
|
-
const result = await verifyWithDcApi({
|
|
95
|
-
baseUrl: 'https://eudiplo.example.com',
|
|
96
|
-
clientId: 'my-demo',
|
|
97
|
-
clientSecret: 'secret',
|
|
73
|
+
const result = await client.verifyWithDcApi({
|
|
98
74
|
configId: 'age-over-18',
|
|
99
75
|
});
|
|
100
76
|
|
|
101
|
-
console.log('Verified!', result.
|
|
77
|
+
console.log('Verified!', result.credentials);
|
|
102
78
|
} else {
|
|
103
|
-
// Fall back to QR code flow
|
|
104
|
-
const session = await verifyAndWait({...});
|
|
79
|
+
// Fall back to QR code flow using EudiploClient methods
|
|
105
80
|
}
|
|
106
81
|
```
|
|
107
82
|
|
|
108
|
-
#### DC API
|
|
83
|
+
#### DC API Methods
|
|
109
84
|
|
|
110
|
-
|
|
|
111
|
-
|
|
|
112
|
-
| `isDcApiAvailable()`
|
|
113
|
-
| `verifyWithDcApi()`
|
|
114
|
-
| `
|
|
85
|
+
| Method | Description |
|
|
86
|
+
| -------------------------------------------- | --------------------------------------------------- |
|
|
87
|
+
| `isDcApiAvailable()` | Check if browser supports Digital Credentials API |
|
|
88
|
+
| `client.verifyWithDcApi()` | Complete verification flow using browser-native API |
|
|
89
|
+
| `client.createDcApiPresentationRequest(...)` | Create DC API session with request object |
|
|
115
90
|
|
|
116
91
|
#### Lower-level DC API Usage
|
|
117
92
|
|
|
118
93
|
```typescript
|
|
119
|
-
import {
|
|
94
|
+
import { EudiploClient } from '@eudiplo/sdk-core';
|
|
120
95
|
|
|
121
96
|
const client = new EudiploClient({...});
|
|
122
97
|
|
|
123
|
-
// Create
|
|
124
|
-
const
|
|
98
|
+
// Create DC API session with request object
|
|
99
|
+
const session = await client.createDcApiPresentationRequest({
|
|
125
100
|
configId: 'age-over-18',
|
|
126
|
-
responseType: 'dc-api',
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
// Create the browser request object
|
|
130
|
-
const request = createDcApiRequest(uri);
|
|
131
|
-
|
|
132
|
-
// Call the browser API directly
|
|
133
|
-
const credential = await navigator.credentials.get(request);
|
|
134
|
-
|
|
135
|
-
// Submit the response and get verified session
|
|
136
|
-
const session = await client.submitDcApiResponse(sessionId, credential);
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
#### Secure Server/Client Deployment (Recommended for Production)
|
|
140
|
-
|
|
141
|
-
When deploying to production, you should **never expose your client credentials to the browser**. The SDK provides helper functions to split the DC API flow between your server (where credentials are safe) and the browser (where the DC API runs).
|
|
142
|
-
|
|
143
|
-
**Server-side Functions:**
|
|
144
|
-
|
|
145
|
-
| Function | Description |
|
|
146
|
-
| -------------------------------- | ------------------------------------------------------ |
|
|
147
|
-
| `createDcApiRequestForBrowser()` | Create request on server, return safe data for browser |
|
|
148
|
-
| `submitDcApiWalletResponse()` | Submit wallet response to EUDIPLO from server |
|
|
149
|
-
|
|
150
|
-
**Browser-side Functions:**
|
|
151
|
-
|
|
152
|
-
| Function | Description |
|
|
153
|
-
| ------------- | ------------------------------------------------------ |
|
|
154
|
-
| `callDcApi()` | Call the native DC API with a request from your server |
|
|
155
|
-
|
|
156
|
-
##### Example: Express.js Backend + Browser Frontend
|
|
157
|
-
|
|
158
|
-
**Server (Express.js / Next.js API route):**
|
|
159
|
-
|
|
160
|
-
```typescript
|
|
161
|
-
import {
|
|
162
|
-
createDcApiRequestForBrowser,
|
|
163
|
-
submitDcApiWalletResponse,
|
|
164
|
-
} from '@eudiplo/sdk-core';
|
|
165
|
-
|
|
166
|
-
// POST /api/start-verification
|
|
167
|
-
app.post('/api/start-verification', async (req, res) => {
|
|
168
|
-
const requestData = await createDcApiRequestForBrowser({
|
|
169
|
-
baseUrl: process.env.EUDIPLO_URL,
|
|
170
|
-
clientId: process.env.EUDIPLO_CLIENT_ID, // ✅ Safe on server
|
|
171
|
-
clientSecret: process.env.EUDIPLO_SECRET, // ✅ Safe on server
|
|
172
|
-
configId: 'age-over-18',
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
// Only safe data is sent to browser (no secrets)
|
|
176
|
-
res.json(requestData);
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
// POST /api/complete-verification
|
|
180
|
-
app.post('/api/complete-verification', async (req, res) => {
|
|
181
|
-
const { responseUri, walletResponse } = req.body;
|
|
182
|
-
|
|
183
|
-
const result = await submitDcApiWalletResponse({
|
|
184
|
-
responseUri,
|
|
185
|
-
walletResponse,
|
|
186
|
-
sendResponse: true, // Get verified claims back
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
// result.credentials contains the verified data
|
|
190
|
-
res.json(result);
|
|
191
101
|
});
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
**Browser (React / vanilla JS):**
|
|
195
102
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
async function verifyAge() {
|
|
200
|
-
// 1. Get the request from your server (credentials stay on server)
|
|
201
|
-
const requestData = await fetch('/api/start-verification', {
|
|
202
|
-
method: 'POST',
|
|
203
|
-
}).then((r) => r.json());
|
|
204
|
-
|
|
205
|
-
// 2. Check DC API support and call it locally
|
|
206
|
-
if (!isDcApiAvailable()) {
|
|
207
|
-
throw new Error('Digital Credentials API not supported');
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
const walletResponse = await callDcApi(requestData.requestObject);
|
|
211
|
-
|
|
212
|
-
// 3. Send the wallet response back to your server for verification
|
|
213
|
-
const result = await fetch('/api/complete-verification', {
|
|
214
|
-
method: 'POST',
|
|
215
|
-
headers: { 'Content-Type': 'application/json' },
|
|
216
|
-
body: JSON.stringify({
|
|
217
|
-
responseUri: requestData.responseUri,
|
|
218
|
-
walletResponse,
|
|
219
|
-
}),
|
|
220
|
-
}).then((r) => r.json());
|
|
221
|
-
|
|
222
|
-
console.log('Verified!', result.credentials);
|
|
223
|
-
return result;
|
|
224
|
-
}
|
|
103
|
+
// Submit using the browser-native DC API end-to-end
|
|
104
|
+
const result = await client.submitDcApiPresentation(session);
|
|
225
105
|
```
|
|
226
106
|
|
|
227
|
-
|
|
107
|
+
#### Secure Deployment Note
|
|
228
108
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
| `clientId` / `clientSecret` | Server only | ❌ Never expose |
|
|
232
|
-
| `requestObject` (signed JWT) | Server → Browser | ✅ Yes |
|
|
233
|
-
| `responseUri` | Server → Browser | ✅ Yes |
|
|
234
|
-
| Wallet response (encrypted VP) | Browser → Server | ✅ Yes |
|
|
235
|
-
| Verified credentials | Server only | Depends on use case |
|
|
109
|
+
For production deployments, keep `clientId` and `clientSecret` on the server.
|
|
110
|
+
Use `EudiploClient` methods to run the full flow (`createDcApiPresentationRequest` + `submitDcApiPresentation`) from trusted backend/application code.
|
|
236
111
|
|
|
237
112
|
### Class-based API (More Control)
|
|
238
113
|
|
|
@@ -41,10 +41,7 @@ function createSseClient({
|
|
|
41
41
|
}
|
|
42
42
|
const _fetch = options.fetch ?? globalThis.fetch;
|
|
43
43
|
const response = await _fetch(request);
|
|
44
|
-
if (!response.ok)
|
|
45
|
-
throw new Error(
|
|
46
|
-
`SSE failed: ${response.status} ${response.statusText}`
|
|
47
|
-
);
|
|
44
|
+
if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
|
|
48
45
|
if (!response.body) throw new Error("No body in SSE response");
|
|
49
46
|
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
|
|
50
47
|
let buffer = "";
|
|
@@ -75,10 +72,7 @@ function createSseClient({
|
|
|
75
72
|
} else if (line.startsWith("id:")) {
|
|
76
73
|
lastEventId = line.replace(/^id:\s*/, "");
|
|
77
74
|
} else if (line.startsWith("retry:")) {
|
|
78
|
-
const parsed = Number.parseInt(
|
|
79
|
-
line.replace(/^retry:\s*/, ""),
|
|
80
|
-
10
|
|
81
|
-
);
|
|
75
|
+
const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
|
|
82
76
|
if (!Number.isNaN(parsed)) {
|
|
83
77
|
retryDelay = parsed;
|
|
84
78
|
}
|
|
@@ -124,10 +118,7 @@ function createSseClient({
|
|
|
124
118
|
if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
|
|
125
119
|
break;
|
|
126
120
|
}
|
|
127
|
-
const backoff = Math.min(
|
|
128
|
-
retryDelay * 2 ** (attempt - 1),
|
|
129
|
-
sseMaxRetryDelay ?? 3e4
|
|
130
|
-
);
|
|
121
|
+
const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
|
|
131
122
|
await sleep(backoff);
|
|
132
123
|
}
|
|
133
124
|
}
|
|
@@ -235,11 +226,7 @@ var serializeObjectParam = ({
|
|
|
235
226
|
if (style !== "deepObject" && !explode) {
|
|
236
227
|
let values = [];
|
|
237
228
|
Object.entries(value).forEach(([key, v]) => {
|
|
238
|
-
values = [
|
|
239
|
-
...values,
|
|
240
|
-
key,
|
|
241
|
-
allowReserved ? v : encodeURIComponent(v)
|
|
242
|
-
];
|
|
229
|
+
values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
|
|
243
230
|
});
|
|
244
231
|
const joinedValues2 = values.join(",");
|
|
245
232
|
switch (style) {
|
|
@@ -290,10 +277,7 @@ var defaultPathSerializer = ({ path, url: _url }) => {
|
|
|
290
277
|
continue;
|
|
291
278
|
}
|
|
292
279
|
if (Array.isArray(value)) {
|
|
293
|
-
url = url.replace(
|
|
294
|
-
match,
|
|
295
|
-
serializeArrayParam({ explode, name, style, value })
|
|
296
|
-
);
|
|
280
|
+
url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
|
|
297
281
|
continue;
|
|
298
282
|
}
|
|
299
283
|
if (typeof value === "object") {
|
|
@@ -381,10 +365,7 @@ var getAuthToken = async (auth, callback) => {
|
|
|
381
365
|
|
|
382
366
|
// src/api/core/bodySerializer.gen.ts
|
|
383
367
|
var jsonBodySerializer = {
|
|
384
|
-
bodySerializer: (body) => JSON.stringify(
|
|
385
|
-
body,
|
|
386
|
-
(_key, value) => typeof value === "bigint" ? value.toString() : value
|
|
387
|
-
)
|
|
368
|
+
bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value)
|
|
388
369
|
};
|
|
389
370
|
|
|
390
371
|
// src/api/client/utils.gen.ts
|
|
@@ -449,9 +430,7 @@ var getParseAs = (contentType) => {
|
|
|
449
430
|
if (cleanContent === "multipart/form-data") {
|
|
450
431
|
return "formData";
|
|
451
432
|
}
|
|
452
|
-
if (["application/", "audio/", "image/", "video/"].some(
|
|
453
|
-
(type) => cleanContent.startsWith(type)
|
|
454
|
-
)) {
|
|
433
|
+
if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
|
|
455
434
|
return "blob";
|
|
456
435
|
}
|
|
457
436
|
if (cleanContent.startsWith("text/")) {
|
|
@@ -468,11 +447,8 @@ var checkForExistence = (options, name) => {
|
|
|
468
447
|
}
|
|
469
448
|
return false;
|
|
470
449
|
};
|
|
471
|
-
|
|
472
|
-
security
|
|
473
|
-
...options
|
|
474
|
-
}) => {
|
|
475
|
-
for (const auth of security) {
|
|
450
|
+
async function setAuthParams(options) {
|
|
451
|
+
for (const auth of options.security ?? []) {
|
|
476
452
|
if (checkForExistence(options, auth.name)) {
|
|
477
453
|
continue;
|
|
478
454
|
}
|
|
@@ -497,7 +473,7 @@ var setAuthParams = async ({
|
|
|
497
473
|
break;
|
|
498
474
|
}
|
|
499
475
|
}
|
|
500
|
-
}
|
|
476
|
+
}
|
|
501
477
|
var buildUrl = (options) => getUrl({
|
|
502
478
|
baseUrl: options.baseUrl,
|
|
503
479
|
path: options.path,
|
|
@@ -623,10 +599,7 @@ var createClient = (config = {}) => {
|
|
|
623
599
|
serializedBody: void 0
|
|
624
600
|
};
|
|
625
601
|
if (opts.security) {
|
|
626
|
-
await setAuthParams(
|
|
627
|
-
...opts,
|
|
628
|
-
security: opts.security
|
|
629
|
-
});
|
|
602
|
+
await setAuthParams(opts);
|
|
630
603
|
}
|
|
631
604
|
if (opts.requestValidator) {
|
|
632
605
|
await opts.requestValidator(opts);
|
|
@@ -739,12 +712,7 @@ var createClient = (config = {}) => {
|
|
|
739
712
|
let finalError = error;
|
|
740
713
|
for (const fn of interceptors.error.fns) {
|
|
741
714
|
if (fn) {
|
|
742
|
-
finalError = await fn(
|
|
743
|
-
finalError,
|
|
744
|
-
response,
|
|
745
|
-
request2,
|
|
746
|
-
options
|
|
747
|
-
);
|
|
715
|
+
finalError = await fn(finalError, response, request2, options);
|
|
748
716
|
}
|
|
749
717
|
}
|
|
750
718
|
finalError = finalError || {};
|
|
@@ -39,10 +39,7 @@ function createSseClient({
|
|
|
39
39
|
}
|
|
40
40
|
const _fetch = options.fetch ?? globalThis.fetch;
|
|
41
41
|
const response = await _fetch(request);
|
|
42
|
-
if (!response.ok)
|
|
43
|
-
throw new Error(
|
|
44
|
-
`SSE failed: ${response.status} ${response.statusText}`
|
|
45
|
-
);
|
|
42
|
+
if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
|
|
46
43
|
if (!response.body) throw new Error("No body in SSE response");
|
|
47
44
|
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
|
|
48
45
|
let buffer = "";
|
|
@@ -73,10 +70,7 @@ function createSseClient({
|
|
|
73
70
|
} else if (line.startsWith("id:")) {
|
|
74
71
|
lastEventId = line.replace(/^id:\s*/, "");
|
|
75
72
|
} else if (line.startsWith("retry:")) {
|
|
76
|
-
const parsed = Number.parseInt(
|
|
77
|
-
line.replace(/^retry:\s*/, ""),
|
|
78
|
-
10
|
|
79
|
-
);
|
|
73
|
+
const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
|
|
80
74
|
if (!Number.isNaN(parsed)) {
|
|
81
75
|
retryDelay = parsed;
|
|
82
76
|
}
|
|
@@ -122,10 +116,7 @@ function createSseClient({
|
|
|
122
116
|
if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
|
|
123
117
|
break;
|
|
124
118
|
}
|
|
125
|
-
const backoff = Math.min(
|
|
126
|
-
retryDelay * 2 ** (attempt - 1),
|
|
127
|
-
sseMaxRetryDelay ?? 3e4
|
|
128
|
-
);
|
|
119
|
+
const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
|
|
129
120
|
await sleep(backoff);
|
|
130
121
|
}
|
|
131
122
|
}
|
|
@@ -233,11 +224,7 @@ var serializeObjectParam = ({
|
|
|
233
224
|
if (style !== "deepObject" && !explode) {
|
|
234
225
|
let values = [];
|
|
235
226
|
Object.entries(value).forEach(([key, v]) => {
|
|
236
|
-
values = [
|
|
237
|
-
...values,
|
|
238
|
-
key,
|
|
239
|
-
allowReserved ? v : encodeURIComponent(v)
|
|
240
|
-
];
|
|
227
|
+
values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
|
|
241
228
|
});
|
|
242
229
|
const joinedValues2 = values.join(",");
|
|
243
230
|
switch (style) {
|
|
@@ -288,10 +275,7 @@ var defaultPathSerializer = ({ path, url: _url }) => {
|
|
|
288
275
|
continue;
|
|
289
276
|
}
|
|
290
277
|
if (Array.isArray(value)) {
|
|
291
|
-
url = url.replace(
|
|
292
|
-
match,
|
|
293
|
-
serializeArrayParam({ explode, name, style, value })
|
|
294
|
-
);
|
|
278
|
+
url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
|
|
295
279
|
continue;
|
|
296
280
|
}
|
|
297
281
|
if (typeof value === "object") {
|
|
@@ -379,10 +363,7 @@ var getAuthToken = async (auth, callback) => {
|
|
|
379
363
|
|
|
380
364
|
// src/api/core/bodySerializer.gen.ts
|
|
381
365
|
var jsonBodySerializer = {
|
|
382
|
-
bodySerializer: (body) => JSON.stringify(
|
|
383
|
-
body,
|
|
384
|
-
(_key, value) => typeof value === "bigint" ? value.toString() : value
|
|
385
|
-
)
|
|
366
|
+
bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value)
|
|
386
367
|
};
|
|
387
368
|
|
|
388
369
|
// src/api/client/utils.gen.ts
|
|
@@ -447,9 +428,7 @@ var getParseAs = (contentType) => {
|
|
|
447
428
|
if (cleanContent === "multipart/form-data") {
|
|
448
429
|
return "formData";
|
|
449
430
|
}
|
|
450
|
-
if (["application/", "audio/", "image/", "video/"].some(
|
|
451
|
-
(type) => cleanContent.startsWith(type)
|
|
452
|
-
)) {
|
|
431
|
+
if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
|
|
453
432
|
return "blob";
|
|
454
433
|
}
|
|
455
434
|
if (cleanContent.startsWith("text/")) {
|
|
@@ -466,11 +445,8 @@ var checkForExistence = (options, name) => {
|
|
|
466
445
|
}
|
|
467
446
|
return false;
|
|
468
447
|
};
|
|
469
|
-
|
|
470
|
-
security
|
|
471
|
-
...options
|
|
472
|
-
}) => {
|
|
473
|
-
for (const auth of security) {
|
|
448
|
+
async function setAuthParams(options) {
|
|
449
|
+
for (const auth of options.security ?? []) {
|
|
474
450
|
if (checkForExistence(options, auth.name)) {
|
|
475
451
|
continue;
|
|
476
452
|
}
|
|
@@ -495,7 +471,7 @@ var setAuthParams = async ({
|
|
|
495
471
|
break;
|
|
496
472
|
}
|
|
497
473
|
}
|
|
498
|
-
}
|
|
474
|
+
}
|
|
499
475
|
var buildUrl = (options) => getUrl({
|
|
500
476
|
baseUrl: options.baseUrl,
|
|
501
477
|
path: options.path,
|
|
@@ -621,10 +597,7 @@ var createClient = (config = {}) => {
|
|
|
621
597
|
serializedBody: void 0
|
|
622
598
|
};
|
|
623
599
|
if (opts.security) {
|
|
624
|
-
await setAuthParams(
|
|
625
|
-
...opts,
|
|
626
|
-
security: opts.security
|
|
627
|
-
});
|
|
600
|
+
await setAuthParams(opts);
|
|
628
601
|
}
|
|
629
602
|
if (opts.requestValidator) {
|
|
630
603
|
await opts.requestValidator(opts);
|
|
@@ -737,12 +710,7 @@ var createClient = (config = {}) => {
|
|
|
737
710
|
let finalError = error;
|
|
738
711
|
for (const fn of interceptors.error.fns) {
|
|
739
712
|
if (fn) {
|
|
740
|
-
finalError = await fn(
|
|
741
|
-
finalError,
|
|
742
|
-
response,
|
|
743
|
-
request2,
|
|
744
|
-
options
|
|
745
|
-
);
|
|
713
|
+
finalError = await fn(finalError, response, request2, options);
|
|
746
714
|
}
|
|
747
715
|
}
|
|
748
716
|
finalError = finalError || {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { A as Auth, C as Client, a as ClientOptions, b as Config, c as CreateClientConfig, O as Options, Q as QuerySerializerOptions, R as RequestOptions, d as RequestResult, e as ResolvedRequestOptions, f as ResponseStyle, T as TDataShape, g as createConfig, h as formDataBodySerializer, j as jsonBodySerializer, m as mergeHeaders, u as urlSearchParamsBodySerializer } from '../../types.gen-
|
|
1
|
+
export { A as Auth, C as Client, a as ClientOptions, b as Config, c as CreateClientConfig, O as Options, Q as QuerySerializerOptions, R as RequestOptions, d as RequestResult, e as ResolvedRequestOptions, f as ResponseStyle, T as TDataShape, g as createConfig, h as formDataBodySerializer, j as jsonBodySerializer, m as mergeHeaders, u as urlSearchParamsBodySerializer } from '../../types.gen-Cc6DtXw9.mjs';
|
|
2
2
|
export { createClient } from './client.gen.mjs';
|
|
3
3
|
|
|
4
|
-
type Slot =
|
|
4
|
+
type Slot = 'body' | 'headers' | 'path' | 'query';
|
|
5
5
|
type Field = {
|
|
6
|
-
in: Exclude<Slot,
|
|
6
|
+
in: Exclude<Slot, 'body'>;
|
|
7
7
|
/**
|
|
8
8
|
* Field name. This is the name we want the user to see and use.
|
|
9
9
|
*/
|
|
@@ -14,7 +14,7 @@ type Field = {
|
|
|
14
14
|
*/
|
|
15
15
|
map?: string;
|
|
16
16
|
} | {
|
|
17
|
-
in: Extract<Slot,
|
|
17
|
+
in: Extract<Slot, 'body'>;
|
|
18
18
|
/**
|
|
19
19
|
* Key isn't required for bodies.
|
|
20
20
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { A as Auth, C as Client, a as ClientOptions, b as Config, c as CreateClientConfig, O as Options, Q as QuerySerializerOptions, R as RequestOptions, d as RequestResult, e as ResolvedRequestOptions, f as ResponseStyle, T as TDataShape, g as createConfig, h as formDataBodySerializer, j as jsonBodySerializer, m as mergeHeaders, u as urlSearchParamsBodySerializer } from '../../types.gen-
|
|
1
|
+
export { A as Auth, C as Client, a as ClientOptions, b as Config, c as CreateClientConfig, O as Options, Q as QuerySerializerOptions, R as RequestOptions, d as RequestResult, e as ResolvedRequestOptions, f as ResponseStyle, T as TDataShape, g as createConfig, h as formDataBodySerializer, j as jsonBodySerializer, m as mergeHeaders, u as urlSearchParamsBodySerializer } from '../../types.gen-Cc6DtXw9.js';
|
|
2
2
|
export { createClient } from './client.gen.js';
|
|
3
3
|
|
|
4
|
-
type Slot =
|
|
4
|
+
type Slot = 'body' | 'headers' | 'path' | 'query';
|
|
5
5
|
type Field = {
|
|
6
|
-
in: Exclude<Slot,
|
|
6
|
+
in: Exclude<Slot, 'body'>;
|
|
7
7
|
/**
|
|
8
8
|
* Field name. This is the name we want the user to see and use.
|
|
9
9
|
*/
|
|
@@ -14,7 +14,7 @@ type Field = {
|
|
|
14
14
|
*/
|
|
15
15
|
map?: string;
|
|
16
16
|
} | {
|
|
17
|
-
in: Extract<Slot,
|
|
17
|
+
in: Extract<Slot, 'body'>;
|
|
18
18
|
/**
|
|
19
19
|
* Key isn't required for bodies.
|
|
20
20
|
*/
|