@readyfor/api-client-base 1.157.0 → 1.158.0-pr1542.3a288f9
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/fetcher.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/index.mjs +17 -1
- package/dist/react/ApiClientConfigProvider.d.ts +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/useApiClientConfig.js +1 -1
- package/dist/requestUrl.js +17 -1
- package/package.json +1 -1
package/dist/fetcher.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_utils_requestInit = require("./utils/requestInit.js");
|
|
3
|
-
const require_apiClientConfigStore = require("./apiClientConfigStore.js");
|
|
4
2
|
const require_apiError = require("./apiError.js");
|
|
3
|
+
const require_apiClientConfigStore = require("./apiClientConfigStore.js");
|
|
4
|
+
const require_utils_requestInit = require("./utils/requestInit.js");
|
|
5
5
|
// src/fetcher.ts
|
|
6
6
|
const defaultRequestInit = { credentials: "include" };
|
|
7
7
|
const fetchWithDefaultRequestInit = (input, customRequestInit, requestInit) => {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Store, createStore } from "./store.js";
|
|
2
1
|
import { Config, RequestConfig, buildRequestInitWithDefaultConfig, setApiClientConfig, store } from "./apiClientConfigStore.js";
|
|
3
2
|
import { ErrorStatusCode, HTTPError, errorStatusCode, errorTitle, getErrorStatus, getHttpErrorBody, getHttpErrorBodyReason, isHttpErrorWithStatus } from "./apiError.js";
|
|
4
3
|
import { BlobFetcherResponse, FetcherOptions, FileOrBlobFetcherResponse, createBlobFetcher, createFileOrBlobFetcher, createJsonFetcher, createTextFetcher, createVoidFetcher } from "./fetcher.js";
|
|
5
4
|
import { __internal__requestUrl } from "./requestUrl.js";
|
|
5
|
+
import { Store, createStore } from "./store.js";
|
|
6
6
|
import { ForceDig, QueryPropsFor } from "./types.js";
|
|
7
7
|
import { isZodError, schemaForType } from "./zod.js";
|
|
8
8
|
import { mergeRequestInit } from "./utils/requestInit.js";
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_store = require("./store.js");
|
|
3
|
-
const require_utils_headersInit = require("./utils/headersInit.js");
|
|
4
|
-
const require_utils_requestInit = require("./utils/requestInit.js");
|
|
5
2
|
const require_apiClientConfigStore = require("./apiClientConfigStore.js");
|
|
6
|
-
const require_zod = require("./zod.js");
|
|
7
3
|
const require_apiError = require("./apiError.js");
|
|
8
4
|
const require_fetcher = require("./fetcher.js");
|
|
9
5
|
const require_requestUrl = require("./requestUrl.js");
|
|
6
|
+
const require_store = require("./store.js");
|
|
7
|
+
const require_zod = require("./zod.js");
|
|
8
|
+
const require_utils_requestInit = require("./utils/requestInit.js");
|
|
9
|
+
const require_utils_headersInit = require("./utils/headersInit.js");
|
|
10
10
|
exports.HTTPError = require_apiError.HTTPError;
|
|
11
11
|
exports.__internal__requestUrl = require_requestUrl.__internal__requestUrl;
|
|
12
12
|
exports.buildRequestInitWithDefaultConfig = require_apiClientConfigStore.buildRequestInitWithDefaultConfig;
|
package/dist/index.mjs
CHANGED
|
@@ -145,9 +145,25 @@ const createVoidFetcher = (customRequestInit = {}, options = {}) => (input, requ
|
|
|
145
145
|
throw error;
|
|
146
146
|
});
|
|
147
147
|
// src/requestUrl.ts
|
|
148
|
+
const UNSAFE_PATH_SEGMENT_CHARS = /[/?#\\\u0000-\u001f\u007f]/;
|
|
149
|
+
const isSafePathSegment = (segment) => {
|
|
150
|
+
let decoded;
|
|
151
|
+
try {
|
|
152
|
+
decoded = decodeURIComponent(segment);
|
|
153
|
+
} catch {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
const trimmed = decoded.replace(/^ +| +$/g, "");
|
|
157
|
+
return trimmed !== "." && trimmed !== ".." && !UNSAFE_PATH_SEGMENT_CHARS.test(decoded);
|
|
158
|
+
};
|
|
148
159
|
const __internal__requestUrl = (rawPath, { path: pathParams = {}, query } = {}) => {
|
|
149
160
|
const config = store.getState();
|
|
150
|
-
const path = (config.hostName ? typeof config.hostName === "string" ? config.hostName : config.hostName(rawPath) : "") +
|
|
161
|
+
const path = (config.hostName ? typeof config.hostName === "string" ? config.hostName : config.hostName(rawPath) : "") + rawPath.replace(/\{([^}]+)\}/g, (placeholder, key) => {
|
|
162
|
+
if (!Object.prototype.hasOwnProperty.call(pathParams, key)) return placeholder;
|
|
163
|
+
const segment = String(pathParams[key]);
|
|
164
|
+
if (!isSafePathSegment(segment)) throw new Error(`Invalid path parameter: ${key}`);
|
|
165
|
+
return segment;
|
|
166
|
+
});
|
|
151
167
|
return query ? `${path}?${qs.stringify(query)}` : path;
|
|
152
168
|
};
|
|
153
169
|
export { HTTPError, __internal__requestUrl, buildRequestInitWithDefaultConfig, createBlobFetcher, createFileOrBlobFetcher, createJsonFetcher, createStore, createTextFetcher, createVoidFetcher, errorStatusCode, errorTitle, getErrorStatus, getHttpErrorBody, getHttpErrorBodyReason, isHttpErrorWithStatus, isZodError, mergeHeadersInit, mergeRequestInit, schemaForType, setApiClientConfig, store, toHeadersInit };
|
package/dist/react/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_react_swr = require("./swr.js");
|
|
3
2
|
const require_react_ApiClientConfigProvider = require("./ApiClientConfigProvider.js");
|
|
3
|
+
const require_react_swr = require("./swr.js");
|
|
4
4
|
const require_react_useApiClientConfig = require("./useApiClientConfig.js");
|
|
5
5
|
exports.ApiClientConfigProvider = require_react_ApiClientConfigProvider.ApiClientConfigProvider;
|
|
6
6
|
exports.createSwrConfig = require_react_swr.createSwrConfig;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_utils_requestInit = require("../utils/requestInit.js");
|
|
3
2
|
const require_react_ApiClientConfigProvider = require("./ApiClientConfigProvider.js");
|
|
3
|
+
const require_utils_requestInit = require("../utils/requestInit.js");
|
|
4
4
|
let react = require("react");
|
|
5
5
|
let use_sync_external_store_shim_index_js = require("use-sync-external-store/shim/index.js");
|
|
6
6
|
let use_sync_external_store_shim_with_selector_js = require("use-sync-external-store/shim/with-selector.js");
|
package/dist/requestUrl.js
CHANGED
|
@@ -4,9 +4,25 @@ const require_apiClientConfigStore = require("./apiClientConfigStore.js");
|
|
|
4
4
|
let qs = require("qs");
|
|
5
5
|
qs = require_runtime.__toESM(qs);
|
|
6
6
|
// src/requestUrl.ts
|
|
7
|
+
const UNSAFE_PATH_SEGMENT_CHARS = /[/?#\\\u0000-\u001f\u007f]/;
|
|
8
|
+
const isSafePathSegment = (segment) => {
|
|
9
|
+
let decoded;
|
|
10
|
+
try {
|
|
11
|
+
decoded = decodeURIComponent(segment);
|
|
12
|
+
} catch {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
const trimmed = decoded.replace(/^ +| +$/g, "");
|
|
16
|
+
return trimmed !== "." && trimmed !== ".." && !UNSAFE_PATH_SEGMENT_CHARS.test(decoded);
|
|
17
|
+
};
|
|
7
18
|
const __internal__requestUrl = (rawPath, { path: pathParams = {}, query } = {}) => {
|
|
8
19
|
const config = require_apiClientConfigStore.store.getState();
|
|
9
|
-
const path = (config.hostName ? typeof config.hostName === "string" ? config.hostName : config.hostName(rawPath) : "") +
|
|
20
|
+
const path = (config.hostName ? typeof config.hostName === "string" ? config.hostName : config.hostName(rawPath) : "") + rawPath.replace(/\{([^}]+)\}/g, (placeholder, key) => {
|
|
21
|
+
if (!Object.prototype.hasOwnProperty.call(pathParams, key)) return placeholder;
|
|
22
|
+
const segment = String(pathParams[key]);
|
|
23
|
+
if (!isSafePathSegment(segment)) throw new Error(`Invalid path parameter: ${key}`);
|
|
24
|
+
return segment;
|
|
25
|
+
});
|
|
10
26
|
return query ? `${path}?${qs.default.stringify(query)}` : path;
|
|
11
27
|
};
|
|
12
28
|
exports.__internal__requestUrl = __internal__requestUrl;
|