@detectant-api/sdk 0.0.1 → 0.0.2
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 +111 -0
- package/dist/cjs/BaseClient.d.ts +54 -0
- package/dist/cjs/BaseClient.js +77 -0
- package/dist/cjs/Client.d.ts +86 -0
- package/dist/cjs/Client.js +255 -0
- package/dist/cjs/api/client/index.d.ts +1 -0
- package/dist/cjs/api/client/index.js +17 -0
- package/dist/cjs/api/client/requests/CreateScanBatchRequest.d.ts +5 -0
- package/dist/cjs/api/client/requests/CreateScanBatchRequest.js +3 -0
- package/dist/cjs/api/client/requests/CreateScanRequest.d.ts +5 -0
- package/dist/cjs/api/client/requests/CreateScanRequest.js +3 -0
- package/dist/cjs/api/client/requests/index.d.ts +2 -0
- package/dist/cjs/api/client/requests/index.js +2 -0
- package/dist/cjs/api/errors/BadRequestError.d.ts +7 -0
- package/dist/cjs/api/errors/BadRequestError.js +54 -0
- package/dist/cjs/api/errors/ContentTooLargeError.d.ts +7 -0
- package/dist/cjs/api/errors/ContentTooLargeError.js +54 -0
- package/dist/cjs/api/errors/ForbiddenError.d.ts +7 -0
- package/dist/cjs/api/errors/ForbiddenError.js +54 -0
- package/dist/cjs/api/errors/InternalServerError.d.ts +7 -0
- package/dist/cjs/api/errors/InternalServerError.js +54 -0
- package/dist/cjs/api/errors/NotFoundError.d.ts +7 -0
- package/dist/cjs/api/errors/NotFoundError.js +54 -0
- package/dist/cjs/api/errors/ServiceUnavailableError.d.ts +5 -0
- package/dist/cjs/api/errors/ServiceUnavailableError.js +54 -0
- package/dist/cjs/api/errors/TooManyRequestsError.d.ts +7 -0
- package/dist/cjs/api/errors/TooManyRequestsError.js +54 -0
- package/dist/cjs/api/errors/UnauthorizedError.d.ts +7 -0
- package/dist/cjs/api/errors/UnauthorizedError.js +54 -0
- package/dist/cjs/api/errors/index.d.ts +8 -0
- package/dist/cjs/api/errors/index.js +24 -0
- package/dist/cjs/api/index.d.ts +4 -0
- package/dist/cjs/api/index.js +20 -0
- package/dist/cjs/api/resources/health/client/Client.d.ts +43 -0
- package/dist/cjs/api/resources/health/client/Client.js +152 -0
- package/dist/cjs/api/resources/health/client/index.d.ts +1 -0
- package/dist/cjs/api/resources/health/client/index.js +2 -0
- package/dist/cjs/api/resources/health/exports.d.ts +2 -0
- package/dist/cjs/api/resources/health/exports.js +21 -0
- package/dist/cjs/api/resources/health/index.d.ts +1 -0
- package/dist/cjs/api/resources/health/index.js +17 -0
- package/dist/cjs/api/resources/index.d.ts +3 -0
- package/dist/cjs/api/resources/index.js +42 -0
- package/dist/cjs/api/resources/scans/client/Client.d.ts +54 -0
- package/dist/cjs/api/resources/scans/client/Client.js +196 -0
- package/dist/cjs/api/resources/scans/client/index.d.ts +1 -0
- package/dist/cjs/api/resources/scans/client/index.js +17 -0
- package/dist/cjs/api/resources/scans/client/requests/GetScanRequest.d.ts +10 -0
- package/dist/cjs/api/resources/scans/client/requests/GetScanRequest.js +3 -0
- package/dist/cjs/api/resources/scans/client/requests/ListScansRequest.d.ts +18 -0
- package/dist/cjs/api/resources/scans/client/requests/ListScansRequest.js +3 -0
- package/dist/cjs/api/resources/scans/client/requests/index.d.ts +2 -0
- package/dist/cjs/api/resources/scans/client/requests/index.js +2 -0
- package/dist/cjs/api/resources/scans/exports.d.ts +2 -0
- package/dist/cjs/api/resources/scans/exports.js +21 -0
- package/dist/cjs/api/resources/scans/index.d.ts +1 -0
- package/dist/cjs/api/resources/scans/index.js +17 -0
- package/dist/cjs/api/types/ApiError.d.ts +8 -0
- package/dist/cjs/api/types/ApiError.js +3 -0
- package/dist/cjs/api/types/ErrorResponse.d.ts +4 -0
- package/dist/cjs/api/types/ErrorResponse.js +3 -0
- package/dist/cjs/api/types/HealthResponse.d.ts +10 -0
- package/dist/cjs/api/types/HealthResponse.js +11 -0
- package/dist/cjs/api/types/Scan.d.ts +32 -0
- package/dist/cjs/api/types/Scan.js +17 -0
- package/dist/cjs/api/types/ScanBatchResponse.d.ts +5 -0
- package/dist/cjs/api/types/ScanBatchResponse.js +3 -0
- package/dist/cjs/api/types/ScanBatchResult.d.ts +13 -0
- package/dist/cjs/api/types/ScanBatchResult.js +3 -0
- package/dist/cjs/api/types/ScanFailure.d.ts +11 -0
- package/dist/cjs/api/types/ScanFailure.js +11 -0
- package/dist/cjs/api/types/ScanList.d.ts +7 -0
- package/dist/cjs/api/types/ScanList.js +3 -0
- package/dist/cjs/api/types/TypeAnalysis.d.ts +26 -0
- package/dist/cjs/api/types/TypeAnalysis.js +20 -0
- package/dist/cjs/api/types/TypeAnalysisReason.d.ts +13 -0
- package/dist/cjs/api/types/TypeAnalysisReason.js +12 -0
- package/dist/cjs/api/types/TypeDeclaration.d.ts +6 -0
- package/dist/cjs/api/types/TypeDeclaration.js +3 -0
- package/dist/cjs/api/types/TypeIdentification.d.ts +6 -0
- package/dist/cjs/api/types/TypeIdentification.js +3 -0
- package/dist/cjs/api/types/index.d.ts +12 -0
- package/dist/cjs/api/types/index.js +28 -0
- package/dist/cjs/auth/HeaderAuthProvider.d.ts +20 -0
- package/dist/cjs/auth/HeaderAuthProvider.js +80 -0
- package/dist/cjs/auth/index.d.ts +1 -0
- package/dist/cjs/auth/index.js +5 -0
- package/dist/cjs/core/auth/AuthProvider.d.ts +8 -0
- package/dist/cjs/core/auth/AuthProvider.js +9 -0
- package/dist/cjs/core/auth/AuthRequest.d.ts +9 -0
- package/dist/cjs/core/auth/AuthRequest.js +2 -0
- package/dist/cjs/core/auth/BasicAuth.d.ts +8 -0
- package/dist/cjs/core/auth/BasicAuth.js +33 -0
- package/dist/cjs/core/auth/BearerToken.d.ts +7 -0
- package/dist/cjs/core/auth/BearerToken.js +16 -0
- package/dist/cjs/core/auth/NoOpAuthProvider.d.ts +5 -0
- package/dist/cjs/core/auth/NoOpAuthProvider.js +9 -0
- package/dist/cjs/core/auth/index.d.ts +5 -0
- package/dist/cjs/core/auth/index.js +11 -0
- package/dist/cjs/core/base64.d.ts +2 -0
- package/dist/cjs/core/base64.js +26 -0
- package/dist/cjs/core/exports.d.ts +2 -0
- package/dist/cjs/core/exports.js +18 -0
- package/dist/cjs/core/fetcher/APIResponse.d.ts +20 -0
- package/dist/cjs/core/fetcher/APIResponse.js +2 -0
- package/dist/cjs/core/fetcher/BinaryResponse.d.ts +19 -0
- package/dist/cjs/core/fetcher/BinaryResponse.js +17 -0
- package/dist/cjs/core/fetcher/EndpointMetadata.d.ts +13 -0
- package/dist/cjs/core/fetcher/EndpointMetadata.js +2 -0
- package/dist/cjs/core/fetcher/EndpointSupplier.d.ts +12 -0
- package/dist/cjs/core/fetcher/EndpointSupplier.js +22 -0
- package/dist/cjs/core/fetcher/Fetcher.d.ts +56 -0
- package/dist/cjs/core/fetcher/Fetcher.js +244 -0
- package/dist/cjs/core/fetcher/Headers.d.ts +2 -0
- package/dist/cjs/core/fetcher/Headers.js +84 -0
- package/dist/cjs/core/fetcher/HttpResponsePromise.d.ts +58 -0
- package/dist/cjs/core/fetcher/HttpResponsePromise.js +103 -0
- package/dist/cjs/core/fetcher/RawResponse.d.ts +29 -0
- package/dist/cjs/core/fetcher/RawResponse.js +44 -0
- package/dist/cjs/core/fetcher/Supplier.d.ts +4 -0
- package/dist/cjs/core/fetcher/Supplier.js +22 -0
- package/dist/cjs/core/fetcher/createRequestUrl.d.ts +1 -0
- package/dist/cjs/core/fetcher/createRequestUrl.js +8 -0
- package/dist/cjs/core/fetcher/getErrorResponseBody.d.ts +1 -0
- package/dist/cjs/core/fetcher/getErrorResponseBody.js +45 -0
- package/dist/cjs/core/fetcher/getFetchFn.d.ts +1 -0
- package/dist/cjs/core/fetcher/getFetchFn.js +17 -0
- package/dist/cjs/core/fetcher/getHeader.d.ts +1 -0
- package/dist/cjs/core/fetcher/getHeader.js +11 -0
- package/dist/cjs/core/fetcher/getRequestBody.d.ts +7 -0
- package/dist/cjs/core/fetcher/getRequestBody.js +27 -0
- package/dist/cjs/core/fetcher/getResponseBody.d.ts +1 -0
- package/dist/cjs/core/fetcher/getResponseBody.js +80 -0
- package/dist/cjs/core/fetcher/index.d.ts +13 -0
- package/dist/cjs/core/fetcher/index.js +19 -0
- package/dist/cjs/core/fetcher/makePassthroughRequest.d.ts +49 -0
- package/dist/cjs/core/fetcher/makePassthroughRequest.js +157 -0
- package/dist/cjs/core/fetcher/makeRequest.d.ts +6 -0
- package/dist/cjs/core/fetcher/makeRequest.js +61 -0
- package/dist/cjs/core/fetcher/redactUrl.d.ts +2 -0
- package/dist/cjs/core/fetcher/redactUrl.js +88 -0
- package/dist/cjs/core/fetcher/requestWithRetries.d.ts +1 -0
- package/dist/cjs/core/fetcher/requestWithRetries.js +70 -0
- package/dist/cjs/core/fetcher/signals.d.ts +5 -0
- package/dist/cjs/core/fetcher/signals.js +32 -0
- package/dist/cjs/core/file/exports.d.ts +1 -0
- package/dist/cjs/core/file/exports.js +2 -0
- package/dist/cjs/core/file/file.d.ts +10 -0
- package/dist/cjs/core/file/file.js +225 -0
- package/dist/cjs/core/file/index.d.ts +2 -0
- package/dist/cjs/core/file/index.js +18 -0
- package/dist/cjs/core/file/types.d.ts +66 -0
- package/dist/cjs/core/file/types.js +2 -0
- package/dist/cjs/core/form-data-utils/FormDataWrapper.d.ts +15 -0
- package/dist/cjs/core/form-data-utils/FormDataWrapper.js +188 -0
- package/dist/cjs/core/form-data-utils/encodeAsFormParameter.d.ts +1 -0
- package/dist/cjs/core/form-data-utils/encodeAsFormParameter.js +12 -0
- package/dist/cjs/core/form-data-utils/index.d.ts +2 -0
- package/dist/cjs/core/form-data-utils/index.js +20 -0
- package/dist/cjs/core/headers.d.ts +2 -0
- package/dist/cjs/core/headers.js +31 -0
- package/dist/cjs/core/index.d.ts +8 -0
- package/dist/cjs/core/index.js +47 -0
- package/dist/cjs/core/json.d.ts +15 -0
- package/dist/cjs/core/json.js +24 -0
- package/dist/cjs/core/logging/exports.d.ts +18 -0
- package/dist/cjs/core/logging/exports.js +45 -0
- package/dist/cjs/core/logging/index.d.ts +1 -0
- package/dist/cjs/core/logging/index.js +17 -0
- package/dist/cjs/core/logging/logger.d.ts +126 -0
- package/dist/cjs/core/logging/logger.js +144 -0
- package/dist/cjs/core/requestBody.d.ts +12 -0
- package/dist/cjs/core/requestBody.js +26 -0
- package/dist/cjs/core/runtime/index.d.ts +1 -0
- package/dist/cjs/core/runtime/index.js +6 -0
- package/dist/cjs/core/runtime/runtime.d.ts +28 -0
- package/dist/cjs/core/runtime/runtime.js +176 -0
- package/dist/cjs/core/url/QueryStringBuilder.d.ts +47 -0
- package/dist/cjs/core/url/QueryStringBuilder.js +83 -0
- package/dist/cjs/core/url/encodePathParam.d.ts +1 -0
- package/dist/cjs/core/url/encodePathParam.js +21 -0
- package/dist/cjs/core/url/index.d.ts +4 -0
- package/dist/cjs/core/url/index.js +11 -0
- package/dist/cjs/core/url/join.d.ts +1 -0
- package/dist/cjs/core/url/join.js +68 -0
- package/dist/cjs/core/url/qs.d.ts +7 -0
- package/dist/cjs/core/url/qs.js +76 -0
- package/dist/cjs/environments.d.ts +4 -0
- package/dist/cjs/environments.js +7 -0
- package/dist/cjs/errors/DetectantApiError.d.ts +15 -0
- package/dist/cjs/errors/DetectantApiError.js +39 -0
- package/dist/cjs/errors/DetectantApiTimeoutError.d.ts +6 -0
- package/dist/cjs/errors/DetectantApiTimeoutError.js +52 -0
- package/dist/cjs/errors/handleNonStatusCodeError.d.ts +2 -0
- package/dist/cjs/errors/handleNonStatusCodeError.js +68 -0
- package/dist/cjs/errors/index.d.ts +2 -0
- package/dist/cjs/errors/index.js +7 -0
- package/dist/cjs/exports.d.ts +1 -0
- package/dist/cjs/exports.js +17 -0
- package/dist/cjs/index.d.ts +6 -0
- package/dist/cjs/index.js +48 -0
- package/dist/cjs/version.d.ts +1 -0
- package/dist/cjs/version.js +4 -0
- package/dist/esm/BaseClient.d.mts +54 -0
- package/dist/esm/BaseClient.mjs +40 -0
- package/dist/esm/Client.d.mts +86 -0
- package/dist/esm/Client.mjs +218 -0
- package/dist/esm/api/client/index.d.mts +1 -0
- package/dist/esm/api/client/index.mjs +1 -0
- package/dist/esm/api/client/requests/CreateScanBatchRequest.d.mts +5 -0
- package/dist/esm/api/client/requests/CreateScanBatchRequest.mjs +2 -0
- package/dist/esm/api/client/requests/CreateScanRequest.d.mts +5 -0
- package/dist/esm/api/client/requests/CreateScanRequest.mjs +2 -0
- package/dist/esm/api/client/requests/index.d.mts +2 -0
- package/dist/esm/api/client/requests/index.mjs +1 -0
- package/dist/esm/api/errors/BadRequestError.d.mts +7 -0
- package/dist/esm/api/errors/BadRequestError.mjs +17 -0
- package/dist/esm/api/errors/ContentTooLargeError.d.mts +7 -0
- package/dist/esm/api/errors/ContentTooLargeError.mjs +17 -0
- package/dist/esm/api/errors/ForbiddenError.d.mts +7 -0
- package/dist/esm/api/errors/ForbiddenError.mjs +17 -0
- package/dist/esm/api/errors/InternalServerError.d.mts +7 -0
- package/dist/esm/api/errors/InternalServerError.mjs +17 -0
- package/dist/esm/api/errors/NotFoundError.d.mts +7 -0
- package/dist/esm/api/errors/NotFoundError.mjs +17 -0
- package/dist/esm/api/errors/ServiceUnavailableError.d.mts +5 -0
- package/dist/esm/api/errors/ServiceUnavailableError.mjs +17 -0
- package/dist/esm/api/errors/TooManyRequestsError.d.mts +7 -0
- package/dist/esm/api/errors/TooManyRequestsError.mjs +17 -0
- package/dist/esm/api/errors/UnauthorizedError.d.mts +7 -0
- package/dist/esm/api/errors/UnauthorizedError.mjs +17 -0
- package/dist/esm/api/errors/index.d.mts +8 -0
- package/dist/esm/api/errors/index.mjs +8 -0
- package/dist/esm/api/index.d.mts +4 -0
- package/dist/esm/api/index.mjs +4 -0
- package/dist/esm/api/resources/health/client/Client.d.mts +43 -0
- package/dist/esm/api/resources/health/client/Client.mjs +115 -0
- package/dist/esm/api/resources/health/client/index.d.mts +1 -0
- package/dist/esm/api/resources/health/client/index.mjs +1 -0
- package/dist/esm/api/resources/health/exports.d.mts +2 -0
- package/dist/esm/api/resources/health/exports.mjs +3 -0
- package/dist/esm/api/resources/health/index.d.mts +1 -0
- package/dist/esm/api/resources/health/index.mjs +1 -0
- package/dist/esm/api/resources/index.d.mts +3 -0
- package/dist/esm/api/resources/index.mjs +3 -0
- package/dist/esm/api/resources/scans/client/Client.d.mts +54 -0
- package/dist/esm/api/resources/scans/client/Client.mjs +159 -0
- package/dist/esm/api/resources/scans/client/index.d.mts +1 -0
- package/dist/esm/api/resources/scans/client/index.mjs +1 -0
- package/dist/esm/api/resources/scans/client/requests/GetScanRequest.d.mts +10 -0
- package/dist/esm/api/resources/scans/client/requests/GetScanRequest.mjs +2 -0
- package/dist/esm/api/resources/scans/client/requests/ListScansRequest.d.mts +18 -0
- package/dist/esm/api/resources/scans/client/requests/ListScansRequest.mjs +2 -0
- package/dist/esm/api/resources/scans/client/requests/index.d.mts +2 -0
- package/dist/esm/api/resources/scans/client/requests/index.mjs +1 -0
- package/dist/esm/api/resources/scans/exports.d.mts +2 -0
- package/dist/esm/api/resources/scans/exports.mjs +3 -0
- package/dist/esm/api/resources/scans/index.d.mts +1 -0
- package/dist/esm/api/resources/scans/index.mjs +1 -0
- package/dist/esm/api/types/ApiError.d.mts +8 -0
- package/dist/esm/api/types/ApiError.mjs +2 -0
- package/dist/esm/api/types/ErrorResponse.d.mts +4 -0
- package/dist/esm/api/types/ErrorResponse.mjs +2 -0
- package/dist/esm/api/types/HealthResponse.d.mts +10 -0
- package/dist/esm/api/types/HealthResponse.mjs +8 -0
- package/dist/esm/api/types/Scan.d.mts +32 -0
- package/dist/esm/api/types/Scan.mjs +14 -0
- package/dist/esm/api/types/ScanBatchResponse.d.mts +5 -0
- package/dist/esm/api/types/ScanBatchResponse.mjs +2 -0
- package/dist/esm/api/types/ScanBatchResult.d.mts +13 -0
- package/dist/esm/api/types/ScanBatchResult.mjs +2 -0
- package/dist/esm/api/types/ScanFailure.d.mts +11 -0
- package/dist/esm/api/types/ScanFailure.mjs +8 -0
- package/dist/esm/api/types/ScanList.d.mts +7 -0
- package/dist/esm/api/types/ScanList.mjs +2 -0
- package/dist/esm/api/types/TypeAnalysis.d.mts +26 -0
- package/dist/esm/api/types/TypeAnalysis.mjs +17 -0
- package/dist/esm/api/types/TypeAnalysisReason.d.mts +13 -0
- package/dist/esm/api/types/TypeAnalysisReason.mjs +9 -0
- package/dist/esm/api/types/TypeDeclaration.d.mts +6 -0
- package/dist/esm/api/types/TypeDeclaration.mjs +2 -0
- package/dist/esm/api/types/TypeIdentification.d.mts +6 -0
- package/dist/esm/api/types/TypeIdentification.mjs +2 -0
- package/dist/esm/api/types/index.d.mts +12 -0
- package/dist/esm/api/types/index.mjs +12 -0
- package/dist/esm/auth/HeaderAuthProvider.d.mts +20 -0
- package/dist/esm/auth/HeaderAuthProvider.mjs +43 -0
- package/dist/esm/auth/index.d.mts +1 -0
- package/dist/esm/auth/index.mjs +1 -0
- package/dist/esm/core/auth/AuthProvider.d.mts +8 -0
- package/dist/esm/core/auth/AuthProvider.mjs +6 -0
- package/dist/esm/core/auth/AuthRequest.d.mts +9 -0
- package/dist/esm/core/auth/AuthRequest.mjs +1 -0
- package/dist/esm/core/auth/BasicAuth.d.mts +8 -0
- package/dist/esm/core/auth/BasicAuth.mjs +30 -0
- package/dist/esm/core/auth/BearerToken.d.mts +7 -0
- package/dist/esm/core/auth/BearerToken.mjs +13 -0
- package/dist/esm/core/auth/NoOpAuthProvider.d.mts +5 -0
- package/dist/esm/core/auth/NoOpAuthProvider.mjs +5 -0
- package/dist/esm/core/auth/index.d.mts +5 -0
- package/dist/esm/core/auth/index.mjs +4 -0
- package/dist/esm/core/base64.d.mts +2 -0
- package/dist/esm/core/base64.mjs +22 -0
- package/dist/esm/core/exports.d.mts +2 -0
- package/dist/esm/core/exports.mjs +2 -0
- package/dist/esm/core/fetcher/APIResponse.d.mts +20 -0
- package/dist/esm/core/fetcher/APIResponse.mjs +1 -0
- package/dist/esm/core/fetcher/BinaryResponse.d.mts +19 -0
- package/dist/esm/core/fetcher/BinaryResponse.mjs +14 -0
- package/dist/esm/core/fetcher/EndpointMetadata.d.mts +13 -0
- package/dist/esm/core/fetcher/EndpointMetadata.mjs +1 -0
- package/dist/esm/core/fetcher/EndpointSupplier.d.mts +12 -0
- package/dist/esm/core/fetcher/EndpointSupplier.mjs +19 -0
- package/dist/esm/core/fetcher/Fetcher.d.mts +56 -0
- package/dist/esm/core/fetcher/Fetcher.mjs +240 -0
- package/dist/esm/core/fetcher/Headers.d.mts +2 -0
- package/dist/esm/core/fetcher/Headers.mjs +82 -0
- package/dist/esm/core/fetcher/HttpResponsePromise.d.mts +58 -0
- package/dist/esm/core/fetcher/HttpResponsePromise.mjs +99 -0
- package/dist/esm/core/fetcher/RawResponse.d.mts +29 -0
- package/dist/esm/core/fetcher/RawResponse.mjs +40 -0
- package/dist/esm/core/fetcher/Supplier.d.mts +4 -0
- package/dist/esm/core/fetcher/Supplier.mjs +19 -0
- package/dist/esm/core/fetcher/createRequestUrl.d.mts +1 -0
- package/dist/esm/core/fetcher/createRequestUrl.mjs +5 -0
- package/dist/esm/core/fetcher/getErrorResponseBody.d.mts +1 -0
- package/dist/esm/core/fetcher/getErrorResponseBody.mjs +42 -0
- package/dist/esm/core/fetcher/getFetchFn.d.mts +1 -0
- package/dist/esm/core/fetcher/getFetchFn.mjs +14 -0
- package/dist/esm/core/fetcher/getHeader.d.mts +1 -0
- package/dist/esm/core/fetcher/getHeader.mjs +8 -0
- package/dist/esm/core/fetcher/getRequestBody.d.mts +7 -0
- package/dist/esm/core/fetcher/getRequestBody.mjs +24 -0
- package/dist/esm/core/fetcher/getResponseBody.d.mts +1 -0
- package/dist/esm/core/fetcher/getResponseBody.mjs +77 -0
- package/dist/esm/core/fetcher/index.d.mts +13 -0
- package/dist/esm/core/fetcher/index.mjs +7 -0
- package/dist/esm/core/fetcher/makePassthroughRequest.d.mts +49 -0
- package/dist/esm/core/fetcher/makePassthroughRequest.mjs +154 -0
- package/dist/esm/core/fetcher/makeRequest.d.mts +6 -0
- package/dist/esm/core/fetcher/makeRequest.mjs +55 -0
- package/dist/esm/core/fetcher/redactUrl.d.mts +2 -0
- package/dist/esm/core/fetcher/redactUrl.mjs +84 -0
- package/dist/esm/core/fetcher/requestWithRetries.d.mts +1 -0
- package/dist/esm/core/fetcher/requestWithRetries.mjs +67 -0
- package/dist/esm/core/fetcher/signals.d.mts +5 -0
- package/dist/esm/core/fetcher/signals.mjs +28 -0
- package/dist/esm/core/file/exports.d.mts +1 -0
- package/dist/esm/core/file/exports.mjs +1 -0
- package/dist/esm/core/file/file.d.mts +10 -0
- package/dist/esm/core/file/file.mjs +188 -0
- package/dist/esm/core/file/index.d.mts +2 -0
- package/dist/esm/core/file/index.mjs +2 -0
- package/dist/esm/core/file/types.d.mts +66 -0
- package/dist/esm/core/file/types.mjs +1 -0
- package/dist/esm/core/form-data-utils/FormDataWrapper.d.mts +15 -0
- package/dist/esm/core/form-data-utils/FormDataWrapper.mjs +150 -0
- package/dist/esm/core/form-data-utils/encodeAsFormParameter.d.mts +1 -0
- package/dist/esm/core/form-data-utils/encodeAsFormParameter.mjs +9 -0
- package/dist/esm/core/form-data-utils/index.d.mts +2 -0
- package/dist/esm/core/form-data-utils/index.mjs +2 -0
- package/dist/esm/core/headers.d.mts +2 -0
- package/dist/esm/core/headers.mjs +27 -0
- package/dist/esm/core/index.d.mts +8 -0
- package/dist/esm/core/index.mjs +8 -0
- package/dist/esm/core/json.d.mts +15 -0
- package/dist/esm/core/json.mjs +19 -0
- package/dist/esm/core/logging/exports.d.mts +18 -0
- package/dist/esm/core/logging/exports.mjs +9 -0
- package/dist/esm/core/logging/index.d.mts +1 -0
- package/dist/esm/core/logging/index.mjs +1 -0
- package/dist/esm/core/logging/logger.d.mts +126 -0
- package/dist/esm/core/logging/logger.mjs +138 -0
- package/dist/esm/core/requestBody.d.mts +12 -0
- package/dist/esm/core/requestBody.mjs +23 -0
- package/dist/esm/core/runtime/index.d.mts +1 -0
- package/dist/esm/core/runtime/index.mjs +1 -0
- package/dist/esm/core/runtime/runtime.d.mts +28 -0
- package/dist/esm/core/runtime/runtime.mjs +172 -0
- package/dist/esm/core/url/QueryStringBuilder.d.mts +47 -0
- package/dist/esm/core/url/QueryStringBuilder.mjs +80 -0
- package/dist/esm/core/url/encodePathParam.d.mts +1 -0
- package/dist/esm/core/url/encodePathParam.mjs +18 -0
- package/dist/esm/core/url/index.d.mts +4 -0
- package/dist/esm/core/url/index.mjs +4 -0
- package/dist/esm/core/url/join.d.mts +1 -0
- package/dist/esm/core/url/join.mjs +65 -0
- package/dist/esm/core/url/qs.d.mts +7 -0
- package/dist/esm/core/url/qs.mjs +73 -0
- package/dist/esm/environments.d.mts +4 -0
- package/dist/esm/environments.mjs +4 -0
- package/dist/esm/errors/DetectantApiError.d.mts +15 -0
- package/dist/esm/errors/DetectantApiError.mjs +35 -0
- package/dist/esm/errors/DetectantApiTimeoutError.d.mts +6 -0
- package/dist/esm/errors/DetectantApiTimeoutError.mjs +15 -0
- package/dist/esm/errors/handleNonStatusCodeError.d.mts +2 -0
- package/dist/esm/errors/handleNonStatusCodeError.mjs +32 -0
- package/dist/esm/errors/index.d.mts +2 -0
- package/dist/esm/errors/index.mjs +2 -0
- package/dist/esm/exports.d.mts +1 -0
- package/dist/esm/exports.mjs +1 -0
- package/dist/esm/index.d.mts +6 -0
- package/dist/esm/index.mjs +5 -0
- package/dist/esm/version.d.mts +1 -0
- package/dist/esm/version.mjs +1 -0
- package/package.json +91 -1
- package/reference.md +380 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { toJson } from "../json.mjs";
|
|
11
|
+
import { toQueryString } from "../url/qs.mjs";
|
|
12
|
+
export function getRequestBody(_a) {
|
|
13
|
+
return __awaiter(this, arguments, void 0, function* ({ body, type }) {
|
|
14
|
+
if (type === "form") {
|
|
15
|
+
return toQueryString(body, { arrayFormat: "repeat", encode: true });
|
|
16
|
+
}
|
|
17
|
+
if (type.includes("json")) {
|
|
18
|
+
return toJson(body);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
return body;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getResponseBody(response: Response, responseType?: string): Promise<unknown>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { fromJson } from "../json.mjs";
|
|
11
|
+
import { getBinaryResponse } from "./BinaryResponse.mjs";
|
|
12
|
+
// Pins the upstream Response so undici's FinalizationRegistry can't GC it and cancel the body stream.
|
|
13
|
+
function retainResponse(target, response) {
|
|
14
|
+
Object.defineProperty(target, "__fern_response_ref", {
|
|
15
|
+
value: response,
|
|
16
|
+
enumerable: false,
|
|
17
|
+
configurable: true,
|
|
18
|
+
writable: false,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export function getResponseBody(response, responseType) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
switch (responseType) {
|
|
24
|
+
case "binary-response":
|
|
25
|
+
return getBinaryResponse(response);
|
|
26
|
+
case "blob":
|
|
27
|
+
return yield response.blob();
|
|
28
|
+
case "arrayBuffer":
|
|
29
|
+
return yield response.arrayBuffer();
|
|
30
|
+
case "sse":
|
|
31
|
+
if (response.body == null) {
|
|
32
|
+
return {
|
|
33
|
+
ok: false,
|
|
34
|
+
error: {
|
|
35
|
+
reason: "body-is-null",
|
|
36
|
+
statusCode: response.status,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
retainResponse(response.body, response);
|
|
41
|
+
return response.body;
|
|
42
|
+
case "streaming":
|
|
43
|
+
if (response.body == null) {
|
|
44
|
+
return {
|
|
45
|
+
ok: false,
|
|
46
|
+
error: {
|
|
47
|
+
reason: "body-is-null",
|
|
48
|
+
statusCode: response.status,
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
retainResponse(response.body, response);
|
|
53
|
+
return response.body;
|
|
54
|
+
case "text":
|
|
55
|
+
return yield response.text();
|
|
56
|
+
}
|
|
57
|
+
// if responseType is "json" or not specified, try to parse as JSON
|
|
58
|
+
const text = yield response.text();
|
|
59
|
+
if (text.length > 0) {
|
|
60
|
+
try {
|
|
61
|
+
const responseBody = fromJson(text);
|
|
62
|
+
return responseBody;
|
|
63
|
+
}
|
|
64
|
+
catch (_err) {
|
|
65
|
+
return {
|
|
66
|
+
ok: false,
|
|
67
|
+
error: {
|
|
68
|
+
reason: "non-json",
|
|
69
|
+
statusCode: response.status,
|
|
70
|
+
rawBody: text,
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return undefined;
|
|
76
|
+
});
|
|
77
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type { APIResponse } from "./APIResponse.mjs";
|
|
2
|
+
export type { BinaryResponse } from "./BinaryResponse.mjs";
|
|
3
|
+
export type { EndpointMetadata } from "./EndpointMetadata.mjs";
|
|
4
|
+
export { EndpointSupplier } from "./EndpointSupplier.mjs";
|
|
5
|
+
export type { Fetcher, FetchFunction } from "./Fetcher.mjs";
|
|
6
|
+
export { fetcher } from "./Fetcher.mjs";
|
|
7
|
+
export { getHeader } from "./getHeader.mjs";
|
|
8
|
+
export { HttpResponsePromise } from "./HttpResponsePromise.mjs";
|
|
9
|
+
export type { PassthroughRequest } from "./makePassthroughRequest.mjs";
|
|
10
|
+
export { makePassthroughRequest } from "./makePassthroughRequest.mjs";
|
|
11
|
+
export type { RawResponse, WithRawResponse } from "./RawResponse.mjs";
|
|
12
|
+
export { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse.mjs";
|
|
13
|
+
export { Supplier } from "./Supplier.mjs";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { EndpointSupplier } from "./EndpointSupplier.mjs";
|
|
2
|
+
export { fetcher } from "./Fetcher.mjs";
|
|
3
|
+
export { getHeader } from "./getHeader.mjs";
|
|
4
|
+
export { HttpResponsePromise } from "./HttpResponsePromise.mjs";
|
|
5
|
+
export { makePassthroughRequest } from "./makePassthroughRequest.mjs";
|
|
6
|
+
export { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse.mjs";
|
|
7
|
+
export { Supplier } from "./Supplier.mjs";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type LogConfig, type Logger } from "../logging/logger.mjs";
|
|
2
|
+
import { Supplier } from "./Supplier.mjs";
|
|
3
|
+
export declare namespace PassthroughRequest {
|
|
4
|
+
/**
|
|
5
|
+
* Per-request options that can override the SDK client defaults.
|
|
6
|
+
*/
|
|
7
|
+
interface RequestOptions {
|
|
8
|
+
/** Override the default timeout for this request (in seconds). */
|
|
9
|
+
timeoutInSeconds?: number;
|
|
10
|
+
/** Override the default number of retries for this request. */
|
|
11
|
+
maxRetries?: number;
|
|
12
|
+
/** Additional headers to include in this request. */
|
|
13
|
+
headers?: Record<string, string>;
|
|
14
|
+
/** Abort signal for this request. */
|
|
15
|
+
abortSignal?: AbortSignal;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* SDK client configuration used by the passthrough fetch method.
|
|
19
|
+
*/
|
|
20
|
+
interface ClientOptions {
|
|
21
|
+
/** The base URL or environment for the client. */
|
|
22
|
+
environment?: Supplier<string>;
|
|
23
|
+
/** Override the base URL. */
|
|
24
|
+
baseUrl?: Supplier<string>;
|
|
25
|
+
/** Default headers to include in requests. */
|
|
26
|
+
headers?: Record<string, unknown>;
|
|
27
|
+
/** Default maximum time to wait for a response in seconds. */
|
|
28
|
+
timeoutInSeconds?: number;
|
|
29
|
+
/** Default number of times to retry the request. Defaults to 2. */
|
|
30
|
+
maxRetries?: number;
|
|
31
|
+
/** A custom fetch function. */
|
|
32
|
+
fetch?: typeof fetch;
|
|
33
|
+
/** Logging configuration. */
|
|
34
|
+
logging?: LogConfig | Logger;
|
|
35
|
+
/** A function that returns auth headers. */
|
|
36
|
+
getAuthHeaders?: () => Promise<Record<string, string>>;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Makes a passthrough HTTP request using the SDK's configuration (auth, retry, logging, etc.)
|
|
41
|
+
* while mimicking the standard `fetch` API.
|
|
42
|
+
*
|
|
43
|
+
* @param input - The URL, path, or Request object. If a relative path, it will be resolved against the configured base URL.
|
|
44
|
+
* @param init - Standard RequestInit options (method, headers, body, signal, etc.)
|
|
45
|
+
* @param clientOptions - SDK client options (auth, default headers, logging, etc.)
|
|
46
|
+
* @param requestOptions - Per-request overrides (timeout, retries, extra headers, abort signal).
|
|
47
|
+
* @returns A standard Response object.
|
|
48
|
+
*/
|
|
49
|
+
export declare function makePassthroughRequest(input: Request | string | URL, init: RequestInit | undefined, clientOptions: PassthroughRequest.ClientOptions, requestOptions?: PassthroughRequest.RequestOptions): Promise<Response>;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { createLogger } from "../logging/logger.mjs";
|
|
11
|
+
import { join } from "../url/join.mjs";
|
|
12
|
+
import { EndpointSupplier } from "./EndpointSupplier.mjs";
|
|
13
|
+
import { getFetchFn } from "./getFetchFn.mjs";
|
|
14
|
+
import { makeRequest } from "./makeRequest.mjs";
|
|
15
|
+
import { redactUrl } from "./redactUrl.mjs";
|
|
16
|
+
import { requestWithRetries } from "./requestWithRetries.mjs";
|
|
17
|
+
import { Supplier } from "./Supplier.mjs";
|
|
18
|
+
/**
|
|
19
|
+
* Makes a passthrough HTTP request using the SDK's configuration (auth, retry, logging, etc.)
|
|
20
|
+
* while mimicking the standard `fetch` API.
|
|
21
|
+
*
|
|
22
|
+
* @param input - The URL, path, or Request object. If a relative path, it will be resolved against the configured base URL.
|
|
23
|
+
* @param init - Standard RequestInit options (method, headers, body, signal, etc.)
|
|
24
|
+
* @param clientOptions - SDK client options (auth, default headers, logging, etc.)
|
|
25
|
+
* @param requestOptions - Per-request overrides (timeout, retries, extra headers, abort signal).
|
|
26
|
+
* @returns A standard Response object.
|
|
27
|
+
*/
|
|
28
|
+
export function makePassthroughRequest(input, init, clientOptions, requestOptions) {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
31
|
+
const logger = createLogger(clientOptions.logging);
|
|
32
|
+
// Extract URL and default init properties from Request object if provided
|
|
33
|
+
let url;
|
|
34
|
+
let effectiveInit = init;
|
|
35
|
+
if (input instanceof Request) {
|
|
36
|
+
url = input.url;
|
|
37
|
+
// If no explicit init provided, extract properties from the Request object
|
|
38
|
+
if (init == null) {
|
|
39
|
+
effectiveInit = {
|
|
40
|
+
method: input.method,
|
|
41
|
+
headers: Object.fromEntries(input.headers.entries()),
|
|
42
|
+
body: input.body,
|
|
43
|
+
signal: input.signal,
|
|
44
|
+
credentials: input.credentials,
|
|
45
|
+
cache: input.cache,
|
|
46
|
+
redirect: input.redirect,
|
|
47
|
+
referrer: input.referrer,
|
|
48
|
+
integrity: input.integrity,
|
|
49
|
+
mode: input.mode,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
url = input instanceof URL ? input.toString() : input;
|
|
55
|
+
}
|
|
56
|
+
// Resolve the base URL
|
|
57
|
+
const baseUrl = (_a = (clientOptions.baseUrl != null ? yield Supplier.get(clientOptions.baseUrl) : undefined)) !== null && _a !== void 0 ? _a : (clientOptions.environment != null ? yield Supplier.get(clientOptions.environment) : undefined);
|
|
58
|
+
// Determine the full URL
|
|
59
|
+
let fullUrl;
|
|
60
|
+
if (url.startsWith("http://") || url.startsWith("https://")) {
|
|
61
|
+
fullUrl = url;
|
|
62
|
+
}
|
|
63
|
+
else if (baseUrl != null) {
|
|
64
|
+
fullUrl = join(baseUrl, url);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
fullUrl = url;
|
|
68
|
+
}
|
|
69
|
+
// Merge headers: SDK default headers -> auth headers -> user-provided headers
|
|
70
|
+
const mergedHeaders = {};
|
|
71
|
+
// Apply SDK default headers (resolve suppliers)
|
|
72
|
+
if (clientOptions.headers != null) {
|
|
73
|
+
for (const [key, value] of Object.entries(clientOptions.headers)) {
|
|
74
|
+
const resolved = yield EndpointSupplier.get(value, { endpointMetadata: {} });
|
|
75
|
+
if (resolved != null) {
|
|
76
|
+
mergedHeaders[key.toLowerCase()] = `${resolved}`;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// Apply auth headers, but only when the resolved URL targets the configured base URL.
|
|
81
|
+
// This prevents the SDK's credentials from leaking to an unrelated host when a caller
|
|
82
|
+
// passes an absolute cross-origin URL into the passthrough fetch escape hatch.
|
|
83
|
+
if (clientOptions.getAuthHeaders != null && targetsBaseUrl(fullUrl, baseUrl)) {
|
|
84
|
+
const authHeaders = yield clientOptions.getAuthHeaders();
|
|
85
|
+
for (const [key, value] of Object.entries(authHeaders)) {
|
|
86
|
+
mergedHeaders[key.toLowerCase()] = value;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// Apply user-provided headers from init
|
|
90
|
+
if ((effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.headers) != null) {
|
|
91
|
+
const initHeaders = effectiveInit.headers instanceof Headers
|
|
92
|
+
? Object.fromEntries(effectiveInit.headers.entries())
|
|
93
|
+
: Array.isArray(effectiveInit.headers)
|
|
94
|
+
? Object.fromEntries(effectiveInit.headers)
|
|
95
|
+
: effectiveInit.headers;
|
|
96
|
+
for (const [key, value] of Object.entries(initHeaders)) {
|
|
97
|
+
if (value != null) {
|
|
98
|
+
mergedHeaders[key.toLowerCase()] = value;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// Apply per-request option headers (highest priority)
|
|
103
|
+
if ((requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers) != null) {
|
|
104
|
+
for (const [key, value] of Object.entries(requestOptions.headers)) {
|
|
105
|
+
mergedHeaders[key.toLowerCase()] = value;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const method = (_b = effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.method) !== null && _b !== void 0 ? _b : "GET";
|
|
109
|
+
const body = effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.body;
|
|
110
|
+
const timeoutInSeconds = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _c !== void 0 ? _c : clientOptions.timeoutInSeconds;
|
|
111
|
+
const timeoutMs = timeoutInSeconds != null ? timeoutInSeconds * 1000 : undefined;
|
|
112
|
+
const maxRetries = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _d !== void 0 ? _d : clientOptions.maxRetries;
|
|
113
|
+
const abortSignal = (_f = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal) !== null && _e !== void 0 ? _e : effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.signal) !== null && _f !== void 0 ? _f : undefined;
|
|
114
|
+
const fetchFn = (_g = clientOptions.fetch) !== null && _g !== void 0 ? _g : (yield getFetchFn());
|
|
115
|
+
if (logger.isDebug()) {
|
|
116
|
+
logger.debug("Making passthrough HTTP request", {
|
|
117
|
+
method,
|
|
118
|
+
url: redactUrl(fullUrl),
|
|
119
|
+
hasBody: body != null,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
const response = yield requestWithRetries(() => __awaiter(this, void 0, void 0, function* () {
|
|
123
|
+
return makeRequest(fetchFn, fullUrl, method, mergedHeaders, body !== null && body !== void 0 ? body : undefined, timeoutMs, abortSignal, (effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.credentials) === "include", undefined, // duplex
|
|
124
|
+
false);
|
|
125
|
+
}), maxRetries);
|
|
126
|
+
if (logger.isDebug()) {
|
|
127
|
+
logger.debug("Passthrough HTTP request completed", {
|
|
128
|
+
method,
|
|
129
|
+
url: redactUrl(fullUrl),
|
|
130
|
+
statusCode: response.status,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
return response;
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Returns true when the resolved request URL points at the same origin as the
|
|
138
|
+
* configured base URL. Relative paths are always joined onto the base URL, so
|
|
139
|
+
* they resolve to the base origin and return true. Absolute URLs only match when
|
|
140
|
+
* their origin equals the base origin. When there is no base URL to compare
|
|
141
|
+
* against, or either value is not a parseable absolute URL, this returns false so
|
|
142
|
+
* auth headers are not attached.
|
|
143
|
+
*/
|
|
144
|
+
function targetsBaseUrl(fullUrl, baseUrl) {
|
|
145
|
+
if (baseUrl == null) {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
try {
|
|
149
|
+
return new URL(fullUrl).origin === new URL(baseUrl).origin;
|
|
150
|
+
}
|
|
151
|
+
catch (_a) {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function isCacheNoStoreSupported(): boolean;
|
|
2
|
+
/**
|
|
3
|
+
* Reset the cached result of `isCacheNoStoreSupported`. Exposed for testing only.
|
|
4
|
+
*/
|
|
5
|
+
export declare function resetCacheNoStoreSupported(): void;
|
|
6
|
+
export declare const makeRequest: (fetchFn: (url: string, init: RequestInit) => Promise<Response>, url: string, method: string, headers: Headers | Record<string, string>, requestBody: BodyInit | undefined, timeoutMs?: number, abortSignal?: AbortSignal, withCredentials?: boolean, duplex?: "half", disableCache?: boolean) => Promise<Response>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { anySignal, getTimeoutSignal } from "./signals.mjs";
|
|
11
|
+
/**
|
|
12
|
+
* Cached result of checking whether the current runtime supports
|
|
13
|
+
* the `cache` option in `Request`. Some runtimes (e.g. Cloudflare Workers)
|
|
14
|
+
* throw a TypeError when this option is used.
|
|
15
|
+
*/
|
|
16
|
+
let _cacheNoStoreSupported;
|
|
17
|
+
export function isCacheNoStoreSupported() {
|
|
18
|
+
if (_cacheNoStoreSupported != null) {
|
|
19
|
+
return _cacheNoStoreSupported;
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
new Request("http://localhost", { cache: "no-store" });
|
|
23
|
+
_cacheNoStoreSupported = true;
|
|
24
|
+
}
|
|
25
|
+
catch (_a) {
|
|
26
|
+
_cacheNoStoreSupported = false;
|
|
27
|
+
}
|
|
28
|
+
return _cacheNoStoreSupported;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Reset the cached result of `isCacheNoStoreSupported`. Exposed for testing only.
|
|
32
|
+
*/
|
|
33
|
+
export function resetCacheNoStoreSupported() {
|
|
34
|
+
_cacheNoStoreSupported = undefined;
|
|
35
|
+
}
|
|
36
|
+
export const makeRequest = (fetchFn, url, method, headers, requestBody, timeoutMs, abortSignal, withCredentials, duplex, disableCache) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
+
const signals = [];
|
|
38
|
+
let timeoutAbortId;
|
|
39
|
+
if (timeoutMs != null) {
|
|
40
|
+
const { signal, abortId } = getTimeoutSignal(timeoutMs);
|
|
41
|
+
timeoutAbortId = abortId;
|
|
42
|
+
signals.push(signal);
|
|
43
|
+
}
|
|
44
|
+
if (abortSignal != null) {
|
|
45
|
+
signals.push(abortSignal);
|
|
46
|
+
}
|
|
47
|
+
const newSignals = anySignal(signals);
|
|
48
|
+
const response = yield fetchFn(url, Object.assign({ method: method, headers, body: requestBody, signal: newSignals, credentials: withCredentials ? "include" : undefined,
|
|
49
|
+
// @ts-ignore
|
|
50
|
+
duplex }, (disableCache && isCacheNoStoreSupported() ? { cache: "no-store" } : {})));
|
|
51
|
+
if (timeoutAbortId != null) {
|
|
52
|
+
clearTimeout(timeoutAbortId);
|
|
53
|
+
}
|
|
54
|
+
return response;
|
|
55
|
+
});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export const SENSITIVE_QUERY_PARAMS = new Set([
|
|
2
|
+
"api_key",
|
|
3
|
+
"api-key",
|
|
4
|
+
"apikey",
|
|
5
|
+
"token",
|
|
6
|
+
"access_token",
|
|
7
|
+
"access-token",
|
|
8
|
+
"auth_token",
|
|
9
|
+
"auth-token",
|
|
10
|
+
"password",
|
|
11
|
+
"passwd",
|
|
12
|
+
"secret",
|
|
13
|
+
"api_secret",
|
|
14
|
+
"api-secret",
|
|
15
|
+
"apisecret",
|
|
16
|
+
"key",
|
|
17
|
+
"session",
|
|
18
|
+
"session_id",
|
|
19
|
+
"session-id",
|
|
20
|
+
]);
|
|
21
|
+
export function redactUrl(url) {
|
|
22
|
+
const protocolIndex = url.indexOf("://");
|
|
23
|
+
if (protocolIndex === -1)
|
|
24
|
+
return url;
|
|
25
|
+
const afterProtocol = protocolIndex + 3;
|
|
26
|
+
// Find the first delimiter that marks the end of the authority section
|
|
27
|
+
const pathStart = url.indexOf("/", afterProtocol);
|
|
28
|
+
let queryStart = url.indexOf("?", afterProtocol);
|
|
29
|
+
let fragmentStart = url.indexOf("#", afterProtocol);
|
|
30
|
+
const firstDelimiter = Math.min(pathStart === -1 ? url.length : pathStart, queryStart === -1 ? url.length : queryStart, fragmentStart === -1 ? url.length : fragmentStart);
|
|
31
|
+
// Find the LAST @ before the delimiter (handles multiple @ in credentials)
|
|
32
|
+
let atIndex = -1;
|
|
33
|
+
for (let i = afterProtocol; i < firstDelimiter; i++) {
|
|
34
|
+
if (url[i] === "@") {
|
|
35
|
+
atIndex = i;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (atIndex !== -1) {
|
|
39
|
+
url = `${url.slice(0, afterProtocol)}[REDACTED]@${url.slice(atIndex + 1)}`;
|
|
40
|
+
}
|
|
41
|
+
// Recalculate queryStart since url might have changed
|
|
42
|
+
queryStart = url.indexOf("?");
|
|
43
|
+
if (queryStart === -1)
|
|
44
|
+
return url;
|
|
45
|
+
fragmentStart = url.indexOf("#", queryStart);
|
|
46
|
+
const queryEnd = fragmentStart !== -1 ? fragmentStart : url.length;
|
|
47
|
+
const queryString = url.slice(queryStart + 1, queryEnd);
|
|
48
|
+
if (queryString.length === 0)
|
|
49
|
+
return url;
|
|
50
|
+
// FAST PATH: Quick check if any sensitive keywords present
|
|
51
|
+
// Using indexOf is faster than regex for simple substring matching
|
|
52
|
+
const lower = queryString.toLowerCase();
|
|
53
|
+
const hasSensitive = lower.includes("token") ||
|
|
54
|
+
lower.includes("key") ||
|
|
55
|
+
lower.includes("password") ||
|
|
56
|
+
lower.includes("passwd") ||
|
|
57
|
+
lower.includes("secret") ||
|
|
58
|
+
lower.includes("session") ||
|
|
59
|
+
lower.includes("auth");
|
|
60
|
+
if (!hasSensitive) {
|
|
61
|
+
return url;
|
|
62
|
+
}
|
|
63
|
+
// SLOW PATH: Parse and redact
|
|
64
|
+
const redactedParams = [];
|
|
65
|
+
const params = queryString.split("&");
|
|
66
|
+
for (const param of params) {
|
|
67
|
+
const equalIndex = param.indexOf("=");
|
|
68
|
+
if (equalIndex === -1) {
|
|
69
|
+
redactedParams.push(param);
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
const key = param.slice(0, equalIndex);
|
|
73
|
+
let shouldRedact = SENSITIVE_QUERY_PARAMS.has(key.toLowerCase());
|
|
74
|
+
if (!shouldRedact && key.includes("%")) {
|
|
75
|
+
try {
|
|
76
|
+
const decodedKey = decodeURIComponent(key);
|
|
77
|
+
shouldRedact = SENSITIVE_QUERY_PARAMS.has(decodedKey.toLowerCase());
|
|
78
|
+
}
|
|
79
|
+
catch (_a) { }
|
|
80
|
+
}
|
|
81
|
+
redactedParams.push(shouldRedact ? `${key}=[REDACTED]` : param);
|
|
82
|
+
}
|
|
83
|
+
return url.slice(0, queryStart + 1) + redactedParams.join("&") + url.slice(queryEnd);
|
|
84
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function requestWithRetries(requestFn: () => Promise<Response>, maxRetries?: number): Promise<Response>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
const INITIAL_RETRY_DELAY = 1000; // in milliseconds
|
|
11
|
+
const MAX_RETRY_DELAY = 60000; // in milliseconds
|
|
12
|
+
const DEFAULT_MAX_RETRIES = 2;
|
|
13
|
+
const JITTER_FACTOR = 0.2; // 20% random jitter
|
|
14
|
+
function isRetryableStatusCode(statusCode) {
|
|
15
|
+
return [408, 429].includes(statusCode) || statusCode >= 500;
|
|
16
|
+
}
|
|
17
|
+
function addPositiveJitter(delay) {
|
|
18
|
+
const jitterMultiplier = 1 + Math.random() * JITTER_FACTOR;
|
|
19
|
+
return delay * jitterMultiplier;
|
|
20
|
+
}
|
|
21
|
+
function addSymmetricJitter(delay) {
|
|
22
|
+
const jitterMultiplier = 1 + (Math.random() - 0.5) * JITTER_FACTOR;
|
|
23
|
+
return delay * jitterMultiplier;
|
|
24
|
+
}
|
|
25
|
+
function getRetryDelayFromHeaders(response, retryAttempt) {
|
|
26
|
+
const retryAfter = response.headers.get("Retry-After");
|
|
27
|
+
if (retryAfter) {
|
|
28
|
+
const retryAfterSeconds = parseInt(retryAfter, 10);
|
|
29
|
+
if (!Number.isNaN(retryAfterSeconds) && retryAfterSeconds > 0) {
|
|
30
|
+
return Math.min(retryAfterSeconds * 1000, MAX_RETRY_DELAY);
|
|
31
|
+
}
|
|
32
|
+
const retryAfterDate = new Date(retryAfter);
|
|
33
|
+
if (!Number.isNaN(retryAfterDate.getTime())) {
|
|
34
|
+
const delay = retryAfterDate.getTime() - Date.now();
|
|
35
|
+
if (delay > 0) {
|
|
36
|
+
return Math.min(Math.max(delay, 0), MAX_RETRY_DELAY);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const rateLimitReset = response.headers.get("X-RateLimit-Reset");
|
|
41
|
+
if (rateLimitReset) {
|
|
42
|
+
const resetTime = parseInt(rateLimitReset, 10);
|
|
43
|
+
if (!Number.isNaN(resetTime)) {
|
|
44
|
+
const delay = resetTime * 1000 - Date.now();
|
|
45
|
+
if (delay > 0) {
|
|
46
|
+
return addPositiveJitter(Math.min(delay, MAX_RETRY_DELAY));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return addSymmetricJitter(Math.min(INITIAL_RETRY_DELAY * Math.pow(2, retryAttempt), MAX_RETRY_DELAY));
|
|
51
|
+
}
|
|
52
|
+
export function requestWithRetries(requestFn_1) {
|
|
53
|
+
return __awaiter(this, arguments, void 0, function* (requestFn, maxRetries = DEFAULT_MAX_RETRIES) {
|
|
54
|
+
let response = yield requestFn();
|
|
55
|
+
for (let i = 0; i < maxRetries; ++i) {
|
|
56
|
+
if (isRetryableStatusCode(response.status)) {
|
|
57
|
+
const delay = getRetryDelayFromHeaders(response, i);
|
|
58
|
+
yield new Promise((resolve) => setTimeout(resolve, delay));
|
|
59
|
+
response = yield requestFn();
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return response;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const TIMEOUT = "timeout";
|
|
2
|
+
export function getTimeoutSignal(timeoutMs) {
|
|
3
|
+
const controller = new AbortController();
|
|
4
|
+
const abortId = setTimeout(() => controller.abort(TIMEOUT), timeoutMs);
|
|
5
|
+
return { signal: controller.signal, abortId };
|
|
6
|
+
}
|
|
7
|
+
export function anySignal(...args) {
|
|
8
|
+
const signals = (args.length === 1 && Array.isArray(args[0]) ? args[0] : args);
|
|
9
|
+
const controller = new AbortController();
|
|
10
|
+
for (const signal of signals) {
|
|
11
|
+
if (signal.aborted) {
|
|
12
|
+
controller.abort(signal === null || signal === void 0 ? void 0 : signal.reason);
|
|
13
|
+
return controller.signal;
|
|
14
|
+
}
|
|
15
|
+
signal.addEventListener("abort", () => controller.abort(signal === null || signal === void 0 ? void 0 : signal.reason), {
|
|
16
|
+
signal: controller.signal,
|
|
17
|
+
});
|
|
18
|
+
// Re-check after adding listener: the signal may have aborted
|
|
19
|
+
// between the initial `signal.aborted` check and the `addEventListener`
|
|
20
|
+
// call above. If it did, the abort event was already dispatched and
|
|
21
|
+
// the listener will never fire — we must manually abort.
|
|
22
|
+
if (signal.aborted) {
|
|
23
|
+
controller.abort(signal === null || signal === void 0 ? void 0 : signal.reason);
|
|
24
|
+
return controller.signal;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return controller.signal;
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { Uploadable } from "./types.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Uploadable } from "./types.mjs";
|
|
2
|
+
export declare function toBinaryUploadRequest(file: Uploadable): Promise<{
|
|
3
|
+
body: Uploadable.FileLike;
|
|
4
|
+
headers?: Record<string, string>;
|
|
5
|
+
}>;
|
|
6
|
+
export declare function toMultipartDataPart(file: Uploadable): Promise<{
|
|
7
|
+
data: Uploadable.FileLike;
|
|
8
|
+
filename?: string;
|
|
9
|
+
contentType?: string;
|
|
10
|
+
}>;
|