@deliverart/sdk-js-core 2.35.2 → 2.35.3
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.cjs +11 -2
- package/dist/index.js +11 -2
- package/package.json +7 -5
package/dist/index.cjs
CHANGED
|
@@ -480,6 +480,13 @@ function isFormDataInstance(input2) {
|
|
|
480
480
|
return typeof FormData === "function" && typeof input2 === "object" && input2 !== null && input2 instanceof FormData;
|
|
481
481
|
}
|
|
482
482
|
function createApiClient(config) {
|
|
483
|
+
const baseUrl = new URL(config.baseUrl);
|
|
484
|
+
const assertDestination = (url) => {
|
|
485
|
+
if (!["http:", "https:"].includes(url.protocol) || url.origin !== baseUrl.origin || url.username || url.password) {
|
|
486
|
+
throw new Error("API requests must target the configured origin without URL credentials");
|
|
487
|
+
}
|
|
488
|
+
};
|
|
489
|
+
assertDestination(baseUrl);
|
|
483
490
|
const requestMiddlewares = [];
|
|
484
491
|
const responseMiddlewares = [];
|
|
485
492
|
const base = {
|
|
@@ -494,7 +501,8 @@ function createApiClient(config) {
|
|
|
494
501
|
const input2 = request.validateInput();
|
|
495
502
|
const query = request.validateQuery();
|
|
496
503
|
const headers = request.validateHeaders();
|
|
497
|
-
const url = new URL(request.getPath(),
|
|
504
|
+
const url = new URL(request.getPath(), baseUrl);
|
|
505
|
+
assertDestination(url);
|
|
498
506
|
const queryParams = { ...query || {} };
|
|
499
507
|
if (options?.pagination === false) {
|
|
500
508
|
queryParams.pagination = false;
|
|
@@ -537,7 +545,8 @@ function createApiClient(config) {
|
|
|
537
545
|
for (const middleware of requestMiddlewares) {
|
|
538
546
|
ctx = await middleware(ctx);
|
|
539
547
|
}
|
|
540
|
-
|
|
548
|
+
assertDestination(ctx.url);
|
|
549
|
+
let response = await fetch(ctx.url.toString(), { ...ctx.init, redirect: "error" });
|
|
541
550
|
let contentType = response.headers.get("Content-Type") ?? "";
|
|
542
551
|
let parsedBody;
|
|
543
552
|
if (response.status === 204) {
|
package/dist/index.js
CHANGED
|
@@ -438,6 +438,13 @@ function isFormDataInstance(input2) {
|
|
|
438
438
|
return typeof FormData === "function" && typeof input2 === "object" && input2 !== null && input2 instanceof FormData;
|
|
439
439
|
}
|
|
440
440
|
function createApiClient(config) {
|
|
441
|
+
const baseUrl = new URL(config.baseUrl);
|
|
442
|
+
const assertDestination = (url) => {
|
|
443
|
+
if (!["http:", "https:"].includes(url.protocol) || url.origin !== baseUrl.origin || url.username || url.password) {
|
|
444
|
+
throw new Error("API requests must target the configured origin without URL credentials");
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
assertDestination(baseUrl);
|
|
441
448
|
const requestMiddlewares = [];
|
|
442
449
|
const responseMiddlewares = [];
|
|
443
450
|
const base = {
|
|
@@ -452,7 +459,8 @@ function createApiClient(config) {
|
|
|
452
459
|
const input2 = request.validateInput();
|
|
453
460
|
const query = request.validateQuery();
|
|
454
461
|
const headers = request.validateHeaders();
|
|
455
|
-
const url = new URL(request.getPath(),
|
|
462
|
+
const url = new URL(request.getPath(), baseUrl);
|
|
463
|
+
assertDestination(url);
|
|
456
464
|
const queryParams = { ...query || {} };
|
|
457
465
|
if (options?.pagination === false) {
|
|
458
466
|
queryParams.pagination = false;
|
|
@@ -495,7 +503,8 @@ function createApiClient(config) {
|
|
|
495
503
|
for (const middleware of requestMiddlewares) {
|
|
496
504
|
ctx = await middleware(ctx);
|
|
497
505
|
}
|
|
498
|
-
|
|
506
|
+
assertDestination(ctx.url);
|
|
507
|
+
let response = await fetch(ctx.url.toString(), { ...ctx.init, redirect: "error" });
|
|
499
508
|
let contentType = response.headers.get("Content-Type") ?? "";
|
|
500
509
|
let parsedBody;
|
|
501
510
|
if (response.status === 204) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deliverart/sdk-js-core",
|
|
3
3
|
"description": "Core SDK for DeliverArt, providing essential functionalities and utilities.",
|
|
4
|
-
"version": "2.35.
|
|
4
|
+
"version": "2.35.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -21,15 +21,17 @@
|
|
|
21
21
|
"access": "public"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"qs": "6.
|
|
24
|
+
"qs": "6.16.0",
|
|
25
25
|
"zod": "4.3.5"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@types/qs": "^6.
|
|
29
|
-
"
|
|
28
|
+
"@types/qs": "^6.15.1",
|
|
29
|
+
"vitest": "4.1.11",
|
|
30
|
+
"@deliverart/sdk-js-global-types": "2.35.3"
|
|
30
31
|
},
|
|
31
32
|
"scripts": {
|
|
32
33
|
"build": "tsup src/index.ts --dts --format esm,cjs",
|
|
33
|
-
"dev": "tsup src/index.ts --dts --watch"
|
|
34
|
+
"dev": "tsup src/index.ts --dts --watch",
|
|
35
|
+
"test": "vitest run"
|
|
34
36
|
}
|
|
35
37
|
}
|