@crylabsorg/suward-sdk 0.0.20
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 +308 -0
- package/dist/cjs/BaseClient.d.ts +42 -0
- package/dist/cjs/BaseClient.js +77 -0
- package/dist/cjs/Client.d.ts +29 -0
- package/dist/cjs/Client.js +88 -0
- package/dist/cjs/api/errors/BadRequestError.d.ts +6 -0
- package/dist/cjs/api/errors/BadRequestError.js +54 -0
- package/dist/cjs/api/errors/InternalServerError.d.ts +6 -0
- package/dist/cjs/api/errors/InternalServerError.js +54 -0
- package/dist/cjs/api/errors/NotFoundError.d.ts +6 -0
- package/dist/cjs/api/errors/NotFoundError.js +54 -0
- package/dist/cjs/api/errors/UnauthorizedError.d.ts +6 -0
- package/dist/cjs/api/errors/UnauthorizedError.js +54 -0
- package/dist/cjs/api/errors/index.d.ts +4 -0
- package/dist/cjs/api/errors/index.js +20 -0
- package/dist/cjs/api/index.d.ts +3 -0
- package/dist/cjs/api/index.js +19 -0
- package/dist/cjs/api/resources/index.d.ts +6 -0
- package/dist/cjs/api/resources/index.js +45 -0
- package/dist/cjs/api/resources/payments/client/Client.d.ts +107 -0
- package/dist/cjs/api/resources/payments/client/Client.js +416 -0
- package/dist/cjs/api/resources/payments/client/index.d.ts +1 -0
- package/dist/cjs/api/resources/payments/client/index.js +17 -0
- package/dist/cjs/api/resources/payments/client/requests/CryptopayCreatePaymentRequest.d.ts +17 -0
- package/dist/cjs/api/resources/payments/client/requests/CryptopayCreatePaymentRequest.js +3 -0
- package/dist/cjs/api/resources/payments/client/requests/CryptopaySimulatePaymentRequest.d.ts +13 -0
- package/dist/cjs/api/resources/payments/client/requests/CryptopaySimulatePaymentRequest.js +3 -0
- package/dist/cjs/api/resources/payments/client/requests/GetV1PaymentsPaymentIdRequest.d.ts +10 -0
- package/dist/cjs/api/resources/payments/client/requests/GetV1PaymentsPaymentIdRequest.js +3 -0
- package/dist/cjs/api/resources/payments/client/requests/GetV1PaymentsRequest.d.ts +13 -0
- package/dist/cjs/api/resources/payments/client/requests/GetV1PaymentsRequest.js +3 -0
- package/dist/cjs/api/resources/payments/client/requests/PostV1PaymentsPaymentIdActivateRequest.d.ts +10 -0
- package/dist/cjs/api/resources/payments/client/requests/PostV1PaymentsPaymentIdActivateRequest.js +3 -0
- package/dist/cjs/api/resources/payments/client/requests/PostV1PaymentsPaymentIdCancelRequest.d.ts +10 -0
- package/dist/cjs/api/resources/payments/client/requests/PostV1PaymentsPaymentIdCancelRequest.js +3 -0
- package/dist/cjs/api/resources/payments/client/requests/index.d.ts +6 -0
- package/dist/cjs/api/resources/payments/client/requests/index.js +2 -0
- package/dist/cjs/api/resources/payments/exports.d.ts +2 -0
- package/dist/cjs/api/resources/payments/exports.js +21 -0
- package/dist/cjs/api/resources/payments/index.d.ts +2 -0
- package/dist/cjs/api/resources/payments/index.js +18 -0
- package/dist/cjs/api/resources/payments/types/GetV1PaymentsPaymentIdResponse.d.ts +2 -0
- package/dist/cjs/api/resources/payments/types/GetV1PaymentsPaymentIdResponse.js +3 -0
- package/dist/cjs/api/resources/payments/types/GetV1PaymentsRequestOrder.d.ts +5 -0
- package/dist/cjs/api/resources/payments/types/GetV1PaymentsRequestOrder.js +8 -0
- package/dist/cjs/api/resources/payments/types/index.d.ts +2 -0
- package/dist/cjs/api/resources/payments/types/index.js +18 -0
- package/dist/cjs/api/resources/staticWallets/client/Client.d.ts +106 -0
- package/dist/cjs/api/resources/staticWallets/client/Client.js +463 -0
- package/dist/cjs/api/resources/staticWallets/client/index.d.ts +1 -0
- package/dist/cjs/api/resources/staticWallets/client/index.js +17 -0
- package/dist/cjs/api/resources/staticWallets/client/requests/CryptopayCreateStaticWalletRequest.d.ts +12 -0
- package/dist/cjs/api/resources/staticWallets/client/requests/CryptopayCreateStaticWalletRequest.js +3 -0
- package/dist/cjs/api/resources/staticWallets/client/requests/CryptopaySimulateStaticDepositRequest.d.ts +25 -0
- package/dist/cjs/api/resources/staticWallets/client/requests/CryptopaySimulateStaticDepositRequest.js +13 -0
- package/dist/cjs/api/resources/staticWallets/client/requests/CryptopayUpdateStaticWalletRequest.d.ts +14 -0
- package/dist/cjs/api/resources/staticWallets/client/requests/CryptopayUpdateStaticWalletRequest.js +3 -0
- package/dist/cjs/api/resources/staticWallets/client/requests/DeleteV1StaticWalletsStaticWalletIdRequest.d.ts +10 -0
- package/dist/cjs/api/resources/staticWallets/client/requests/DeleteV1StaticWalletsStaticWalletIdRequest.js +3 -0
- package/dist/cjs/api/resources/staticWallets/client/requests/GetV1StaticWalletsRequest.d.ts +13 -0
- package/dist/cjs/api/resources/staticWallets/client/requests/GetV1StaticWalletsRequest.js +3 -0
- package/dist/cjs/api/resources/staticWallets/client/requests/GetV1StaticWalletsStaticWalletIdDepositsRequest.d.ts +17 -0
- package/dist/cjs/api/resources/staticWallets/client/requests/GetV1StaticWalletsStaticWalletIdDepositsRequest.js +3 -0
- package/dist/cjs/api/resources/staticWallets/client/requests/GetV1StaticWalletsStaticWalletIdRequest.d.ts +10 -0
- package/dist/cjs/api/resources/staticWallets/client/requests/GetV1StaticWalletsStaticWalletIdRequest.js +3 -0
- package/dist/cjs/api/resources/staticWallets/client/requests/index.d.ts +7 -0
- package/dist/cjs/api/resources/staticWallets/client/requests/index.js +5 -0
- package/dist/cjs/api/resources/staticWallets/exports.d.ts +2 -0
- package/dist/cjs/api/resources/staticWallets/exports.js +21 -0
- package/dist/cjs/api/resources/staticWallets/index.d.ts +2 -0
- package/dist/cjs/api/resources/staticWallets/index.js +18 -0
- package/dist/cjs/api/resources/staticWallets/types/GetV1StaticWalletsRequestOrder.d.ts +5 -0
- package/dist/cjs/api/resources/staticWallets/types/GetV1StaticWalletsRequestOrder.js +8 -0
- package/dist/cjs/api/resources/staticWallets/types/GetV1StaticWalletsStaticWalletIdDepositsRequestOrder.d.ts +5 -0
- package/dist/cjs/api/resources/staticWallets/types/GetV1StaticWalletsStaticWalletIdDepositsRequestOrder.js +8 -0
- package/dist/cjs/api/resources/staticWallets/types/index.d.ts +2 -0
- package/dist/cjs/api/resources/staticWallets/types/index.js +18 -0
- package/dist/cjs/api/types/ControllerErrorResponse.d.ts +5 -0
- package/dist/cjs/api/types/ControllerErrorResponse.js +3 -0
- package/dist/cjs/api/types/CryptopayAssetId.d.ts +32 -0
- package/dist/cjs/api/types/CryptopayAssetId.js +35 -0
- package/dist/cjs/api/types/CryptopayListPaymentsResponse.d.ts +6 -0
- package/dist/cjs/api/types/CryptopayListPaymentsResponse.js +3 -0
- package/dist/cjs/api/types/CryptopayListStaticDepositsResponse.d.ts +6 -0
- package/dist/cjs/api/types/CryptopayListStaticDepositsResponse.js +3 -0
- package/dist/cjs/api/types/CryptopayListStaticWalletsResponse.d.ts +6 -0
- package/dist/cjs/api/types/CryptopayListStaticWalletsResponse.js +3 -0
- package/dist/cjs/api/types/CryptopayPaymentResponse.d.ts +28 -0
- package/dist/cjs/api/types/CryptopayPaymentResponse.js +3 -0
- package/dist/cjs/api/types/CryptopayPaymentStatusEnum.d.ts +7 -0
- package/dist/cjs/api/types/CryptopayPaymentStatusEnum.js +10 -0
- package/dist/cjs/api/types/CryptopayPaymentSubStatusEnum.d.ts +16 -0
- package/dist/cjs/api/types/CryptopayPaymentSubStatusEnum.js +19 -0
- package/dist/cjs/api/types/CryptopayPublicPaymentResponse.d.ts +18 -0
- package/dist/cjs/api/types/CryptopayPublicPaymentResponse.js +3 -0
- package/dist/cjs/api/types/CryptopayPublicRedirect.d.ts +4 -0
- package/dist/cjs/api/types/CryptopayPublicRedirect.js +3 -0
- package/dist/cjs/api/types/CryptopayRedirectConfigDto.d.ts +15 -0
- package/dist/cjs/api/types/CryptopayRedirectConfigDto.js +14 -0
- package/dist/cjs/api/types/CryptopayStaticDepositResponse.d.ts +31 -0
- package/dist/cjs/api/types/CryptopayStaticDepositResponse.js +14 -0
- package/dist/cjs/api/types/CryptopayStaticWalletResponse.d.ts +13 -0
- package/dist/cjs/api/types/CryptopayStaticWalletResponse.js +3 -0
- package/dist/cjs/api/types/CryptopayTransactionResponse.d.ts +6 -0
- package/dist/cjs/api/types/CryptopayTransactionResponse.js +3 -0
- package/dist/cjs/api/types/WebhookPaymentEvent.d.ts +26 -0
- package/dist/cjs/api/types/WebhookPaymentEvent.js +12 -0
- package/dist/cjs/api/types/WebhookStaticDepositEvent.d.ts +29 -0
- package/dist/cjs/api/types/WebhookStaticDepositEvent.js +11 -0
- package/dist/cjs/api/types/index.d.ts +16 -0
- package/dist/cjs/api/types/index.js +32 -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 +1 -0
- package/dist/cjs/core/exports.js +17 -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 +327 -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 +135 -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/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/headers.d.ts +2 -0
- package/dist/cjs/core/headers.js +31 -0
- package/dist/cjs/core/index.d.ts +7 -0
- package/dist/cjs/core/index.js +46 -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/runtime/index.d.ts +1 -0
- package/dist/cjs/core/runtime/index.js +5 -0
- package/dist/cjs/core/runtime/runtime.d.ts +9 -0
- package/dist/cjs/core/runtime/runtime.js +104 -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/core/webhooks/computeHmacSignature.d.ts +9 -0
- package/dist/cjs/core/webhooks/computeHmacSignature.js +84 -0
- package/dist/cjs/core/webhooks/fetchJwks.d.ts +15 -0
- package/dist/cjs/core/webhooks/fetchJwks.js +156 -0
- package/dist/cjs/core/webhooks/index.d.ts +8 -0
- package/dist/cjs/core/webhooks/index.js +11 -0
- package/dist/cjs/core/webhooks/timingSafeEqual.d.ts +1 -0
- package/dist/cjs/core/webhooks/timingSafeEqual.js +85 -0
- package/dist/cjs/core/webhooks/types.d.ts +1 -0
- package/dist/cjs/core/webhooks/types.js +2 -0
- package/dist/cjs/core/webhooks/verifyAsymmetricSignature.d.ts +10 -0
- package/dist/cjs/core/webhooks/verifyAsymmetricSignature.js +210 -0
- package/dist/cjs/environments.d.ts +4 -0
- package/dist/cjs/environments.js +7 -0
- package/dist/cjs/errors/SuwardSDKError.d.ts +14 -0
- package/dist/cjs/errors/SuwardSDKError.js +35 -0
- package/dist/cjs/errors/SuwardSDKTimeoutError.d.ts +6 -0
- package/dist/cjs/errors/SuwardSDKTimeoutError.js +18 -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 +7 -0
- package/dist/cjs/index.js +49 -0
- package/dist/cjs/version.d.ts +1 -0
- package/dist/cjs/version.js +4 -0
- package/dist/cjs/webhooks/WebhooksHelper.d.ts +9 -0
- package/dist/cjs/webhooks/WebhooksHelper.js +87 -0
- package/dist/cjs/webhooks/index.d.ts +1 -0
- package/dist/cjs/webhooks/index.js +5 -0
- package/dist/esm/BaseClient.d.mts +42 -0
- package/dist/esm/BaseClient.mjs +40 -0
- package/dist/esm/Client.d.mts +29 -0
- package/dist/esm/Client.mjs +51 -0
- package/dist/esm/api/errors/BadRequestError.d.mts +6 -0
- package/dist/esm/api/errors/BadRequestError.mjs +17 -0
- package/dist/esm/api/errors/InternalServerError.d.mts +6 -0
- package/dist/esm/api/errors/InternalServerError.mjs +17 -0
- package/dist/esm/api/errors/NotFoundError.d.mts +6 -0
- package/dist/esm/api/errors/NotFoundError.mjs +17 -0
- package/dist/esm/api/errors/UnauthorizedError.d.mts +6 -0
- package/dist/esm/api/errors/UnauthorizedError.mjs +17 -0
- package/dist/esm/api/errors/index.d.mts +4 -0
- package/dist/esm/api/errors/index.mjs +4 -0
- package/dist/esm/api/index.d.mts +3 -0
- package/dist/esm/api/index.mjs +3 -0
- package/dist/esm/api/resources/index.d.mts +6 -0
- package/dist/esm/api/resources/index.mjs +6 -0
- package/dist/esm/api/resources/payments/client/Client.d.mts +107 -0
- package/dist/esm/api/resources/payments/client/Client.mjs +379 -0
- package/dist/esm/api/resources/payments/client/index.d.mts +1 -0
- package/dist/esm/api/resources/payments/client/index.mjs +1 -0
- package/dist/esm/api/resources/payments/client/requests/CryptopayCreatePaymentRequest.d.mts +17 -0
- package/dist/esm/api/resources/payments/client/requests/CryptopayCreatePaymentRequest.mjs +2 -0
- package/dist/esm/api/resources/payments/client/requests/CryptopaySimulatePaymentRequest.d.mts +13 -0
- package/dist/esm/api/resources/payments/client/requests/CryptopaySimulatePaymentRequest.mjs +2 -0
- package/dist/esm/api/resources/payments/client/requests/GetV1PaymentsPaymentIdRequest.d.mts +10 -0
- package/dist/esm/api/resources/payments/client/requests/GetV1PaymentsPaymentIdRequest.mjs +2 -0
- package/dist/esm/api/resources/payments/client/requests/GetV1PaymentsRequest.d.mts +13 -0
- package/dist/esm/api/resources/payments/client/requests/GetV1PaymentsRequest.mjs +2 -0
- package/dist/esm/api/resources/payments/client/requests/PostV1PaymentsPaymentIdActivateRequest.d.mts +10 -0
- package/dist/esm/api/resources/payments/client/requests/PostV1PaymentsPaymentIdActivateRequest.mjs +2 -0
- package/dist/esm/api/resources/payments/client/requests/PostV1PaymentsPaymentIdCancelRequest.d.mts +10 -0
- package/dist/esm/api/resources/payments/client/requests/PostV1PaymentsPaymentIdCancelRequest.mjs +2 -0
- package/dist/esm/api/resources/payments/client/requests/index.d.mts +6 -0
- package/dist/esm/api/resources/payments/client/requests/index.mjs +1 -0
- package/dist/esm/api/resources/payments/exports.d.mts +2 -0
- package/dist/esm/api/resources/payments/exports.mjs +3 -0
- package/dist/esm/api/resources/payments/index.d.mts +2 -0
- package/dist/esm/api/resources/payments/index.mjs +2 -0
- package/dist/esm/api/resources/payments/types/GetV1PaymentsPaymentIdResponse.d.mts +2 -0
- package/dist/esm/api/resources/payments/types/GetV1PaymentsPaymentIdResponse.mjs +2 -0
- package/dist/esm/api/resources/payments/types/GetV1PaymentsRequestOrder.d.mts +5 -0
- package/dist/esm/api/resources/payments/types/GetV1PaymentsRequestOrder.mjs +5 -0
- package/dist/esm/api/resources/payments/types/index.d.mts +2 -0
- package/dist/esm/api/resources/payments/types/index.mjs +2 -0
- package/dist/esm/api/resources/staticWallets/client/Client.d.mts +106 -0
- package/dist/esm/api/resources/staticWallets/client/Client.mjs +426 -0
- package/dist/esm/api/resources/staticWallets/client/index.d.mts +1 -0
- package/dist/esm/api/resources/staticWallets/client/index.mjs +1 -0
- package/dist/esm/api/resources/staticWallets/client/requests/CryptopayCreateStaticWalletRequest.d.mts +12 -0
- package/dist/esm/api/resources/staticWallets/client/requests/CryptopayCreateStaticWalletRequest.mjs +2 -0
- package/dist/esm/api/resources/staticWallets/client/requests/CryptopaySimulateStaticDepositRequest.d.mts +25 -0
- package/dist/esm/api/resources/staticWallets/client/requests/CryptopaySimulateStaticDepositRequest.mjs +10 -0
- package/dist/esm/api/resources/staticWallets/client/requests/CryptopayUpdateStaticWalletRequest.d.mts +14 -0
- package/dist/esm/api/resources/staticWallets/client/requests/CryptopayUpdateStaticWalletRequest.mjs +2 -0
- package/dist/esm/api/resources/staticWallets/client/requests/DeleteV1StaticWalletsStaticWalletIdRequest.d.mts +10 -0
- package/dist/esm/api/resources/staticWallets/client/requests/DeleteV1StaticWalletsStaticWalletIdRequest.mjs +2 -0
- package/dist/esm/api/resources/staticWallets/client/requests/GetV1StaticWalletsRequest.d.mts +13 -0
- package/dist/esm/api/resources/staticWallets/client/requests/GetV1StaticWalletsRequest.mjs +2 -0
- package/dist/esm/api/resources/staticWallets/client/requests/GetV1StaticWalletsStaticWalletIdDepositsRequest.d.mts +17 -0
- package/dist/esm/api/resources/staticWallets/client/requests/GetV1StaticWalletsStaticWalletIdDepositsRequest.mjs +2 -0
- package/dist/esm/api/resources/staticWallets/client/requests/GetV1StaticWalletsStaticWalletIdRequest.d.mts +10 -0
- package/dist/esm/api/resources/staticWallets/client/requests/GetV1StaticWalletsStaticWalletIdRequest.mjs +2 -0
- package/dist/esm/api/resources/staticWallets/client/requests/index.d.mts +7 -0
- package/dist/esm/api/resources/staticWallets/client/requests/index.mjs +1 -0
- package/dist/esm/api/resources/staticWallets/exports.d.mts +2 -0
- package/dist/esm/api/resources/staticWallets/exports.mjs +3 -0
- package/dist/esm/api/resources/staticWallets/index.d.mts +2 -0
- package/dist/esm/api/resources/staticWallets/index.mjs +2 -0
- package/dist/esm/api/resources/staticWallets/types/GetV1StaticWalletsRequestOrder.d.mts +5 -0
- package/dist/esm/api/resources/staticWallets/types/GetV1StaticWalletsRequestOrder.mjs +5 -0
- package/dist/esm/api/resources/staticWallets/types/GetV1StaticWalletsStaticWalletIdDepositsRequestOrder.d.mts +5 -0
- package/dist/esm/api/resources/staticWallets/types/GetV1StaticWalletsStaticWalletIdDepositsRequestOrder.mjs +5 -0
- package/dist/esm/api/resources/staticWallets/types/index.d.mts +2 -0
- package/dist/esm/api/resources/staticWallets/types/index.mjs +2 -0
- package/dist/esm/api/types/ControllerErrorResponse.d.mts +5 -0
- package/dist/esm/api/types/ControllerErrorResponse.mjs +2 -0
- package/dist/esm/api/types/CryptopayAssetId.d.mts +32 -0
- package/dist/esm/api/types/CryptopayAssetId.mjs +32 -0
- package/dist/esm/api/types/CryptopayListPaymentsResponse.d.mts +6 -0
- package/dist/esm/api/types/CryptopayListPaymentsResponse.mjs +2 -0
- package/dist/esm/api/types/CryptopayListStaticDepositsResponse.d.mts +6 -0
- package/dist/esm/api/types/CryptopayListStaticDepositsResponse.mjs +2 -0
- package/dist/esm/api/types/CryptopayListStaticWalletsResponse.d.mts +6 -0
- package/dist/esm/api/types/CryptopayListStaticWalletsResponse.mjs +2 -0
- package/dist/esm/api/types/CryptopayPaymentResponse.d.mts +28 -0
- package/dist/esm/api/types/CryptopayPaymentResponse.mjs +2 -0
- package/dist/esm/api/types/CryptopayPaymentStatusEnum.d.mts +7 -0
- package/dist/esm/api/types/CryptopayPaymentStatusEnum.mjs +7 -0
- package/dist/esm/api/types/CryptopayPaymentSubStatusEnum.d.mts +16 -0
- package/dist/esm/api/types/CryptopayPaymentSubStatusEnum.mjs +16 -0
- package/dist/esm/api/types/CryptopayPublicPaymentResponse.d.mts +18 -0
- package/dist/esm/api/types/CryptopayPublicPaymentResponse.mjs +2 -0
- package/dist/esm/api/types/CryptopayPublicRedirect.d.mts +4 -0
- package/dist/esm/api/types/CryptopayPublicRedirect.mjs +2 -0
- package/dist/esm/api/types/CryptopayRedirectConfigDto.d.mts +15 -0
- package/dist/esm/api/types/CryptopayRedirectConfigDto.mjs +11 -0
- package/dist/esm/api/types/CryptopayStaticDepositResponse.d.mts +31 -0
- package/dist/esm/api/types/CryptopayStaticDepositResponse.mjs +11 -0
- package/dist/esm/api/types/CryptopayStaticWalletResponse.d.mts +13 -0
- package/dist/esm/api/types/CryptopayStaticWalletResponse.mjs +2 -0
- package/dist/esm/api/types/CryptopayTransactionResponse.d.mts +6 -0
- package/dist/esm/api/types/CryptopayTransactionResponse.mjs +2 -0
- package/dist/esm/api/types/WebhookPaymentEvent.d.mts +26 -0
- package/dist/esm/api/types/WebhookPaymentEvent.mjs +9 -0
- package/dist/esm/api/types/WebhookStaticDepositEvent.d.mts +29 -0
- package/dist/esm/api/types/WebhookStaticDepositEvent.mjs +8 -0
- package/dist/esm/api/types/index.d.mts +16 -0
- package/dist/esm/api/types/index.mjs +16 -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 +1 -0
- package/dist/esm/core/exports.mjs +1 -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 +323 -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 +132 -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/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/headers.d.mts +2 -0
- package/dist/esm/core/headers.mjs +27 -0
- package/dist/esm/core/index.d.mts +7 -0
- package/dist/esm/core/index.mjs +7 -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/runtime/index.d.mts +1 -0
- package/dist/esm/core/runtime/index.mjs +1 -0
- package/dist/esm/core/runtime/runtime.d.mts +9 -0
- package/dist/esm/core/runtime/runtime.mjs +101 -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/core/webhooks/computeHmacSignature.d.mts +9 -0
- package/dist/esm/core/webhooks/computeHmacSignature.mjs +48 -0
- package/dist/esm/core/webhooks/fetchJwks.d.mts +15 -0
- package/dist/esm/core/webhooks/fetchJwks.mjs +153 -0
- package/dist/esm/core/webhooks/index.d.mts +8 -0
- package/dist/esm/core/webhooks/index.mjs +4 -0
- package/dist/esm/core/webhooks/timingSafeEqual.d.mts +1 -0
- package/dist/esm/core/webhooks/timingSafeEqual.mjs +49 -0
- package/dist/esm/core/webhooks/types.d.mts +1 -0
- package/dist/esm/core/webhooks/types.mjs +1 -0
- package/dist/esm/core/webhooks/verifyAsymmetricSignature.d.mts +10 -0
- package/dist/esm/core/webhooks/verifyAsymmetricSignature.mjs +174 -0
- package/dist/esm/environments.d.mts +4 -0
- package/dist/esm/environments.mjs +4 -0
- package/dist/esm/errors/SuwardSDKError.d.mts +14 -0
- package/dist/esm/errors/SuwardSDKError.mjs +31 -0
- package/dist/esm/errors/SuwardSDKTimeoutError.d.mts +6 -0
- package/dist/esm/errors/SuwardSDKTimeoutError.mjs +14 -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 +7 -0
- package/dist/esm/index.mjs +6 -0
- package/dist/esm/version.d.mts +1 -0
- package/dist/esm/version.mjs +1 -0
- package/dist/esm/webhooks/WebhooksHelper.d.mts +9 -0
- package/dist/esm/webhooks/WebhooksHelper.mjs +50 -0
- package/dist/esm/webhooks/index.d.mts +1 -0
- package/dist/esm/webhooks/index.mjs +1 -0
- package/package.json +90 -0
- package/reference.md +771 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { EndpointMetadata } from "../fetcher/EndpointMetadata.mjs";
|
|
2
|
+
import type { AuthRequest } from "./AuthRequest.mjs";
|
|
3
|
+
export interface AuthProvider {
|
|
4
|
+
getAuthRequest(arg?: {
|
|
5
|
+
endpointMetadata?: EndpointMetadata;
|
|
6
|
+
}): Promise<AuthRequest>;
|
|
7
|
+
}
|
|
8
|
+
export declare function isAuthProvider(value: unknown): value is AuthProvider;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { base64Decode, base64Encode } from "../base64.mjs";
|
|
2
|
+
const BASIC_AUTH_HEADER_PREFIX = /^Basic /i;
|
|
3
|
+
export const BasicAuth = {
|
|
4
|
+
toAuthorizationHeader: (basicAuth) => {
|
|
5
|
+
var _a, _b;
|
|
6
|
+
if (basicAuth == null) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
const username = (_a = basicAuth.username) !== null && _a !== void 0 ? _a : "";
|
|
10
|
+
const password = (_b = basicAuth.password) !== null && _b !== void 0 ? _b : "";
|
|
11
|
+
if (username === "" && password === "") {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
const token = base64Encode(`${username}:${password}`);
|
|
15
|
+
return `Basic ${token}`;
|
|
16
|
+
},
|
|
17
|
+
fromAuthorizationHeader: (header) => {
|
|
18
|
+
const credentials = header.replace(BASIC_AUTH_HEADER_PREFIX, "");
|
|
19
|
+
const decoded = base64Decode(credentials);
|
|
20
|
+
const [username, ...passwordParts] = decoded.split(":");
|
|
21
|
+
const password = passwordParts.length > 0 ? passwordParts.join(":") : undefined;
|
|
22
|
+
if (username == null || password == null) {
|
|
23
|
+
throw new Error("Invalid basic auth");
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
username,
|
|
27
|
+
password,
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type BearerToken = string;
|
|
2
|
+
declare function toAuthorizationHeader(token: string | undefined): string | undefined;
|
|
3
|
+
export declare const BearerToken: {
|
|
4
|
+
toAuthorizationHeader: typeof toAuthorizationHeader;
|
|
5
|
+
fromAuthorizationHeader: (header: string) => BearerToken;
|
|
6
|
+
};
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const BEARER_AUTH_HEADER_PREFIX = /^Bearer /i;
|
|
2
|
+
function toAuthorizationHeader(token) {
|
|
3
|
+
if (token == null) {
|
|
4
|
+
return undefined;
|
|
5
|
+
}
|
|
6
|
+
return `Bearer ${token}`;
|
|
7
|
+
}
|
|
8
|
+
export const BearerToken = {
|
|
9
|
+
toAuthorizationHeader: toAuthorizationHeader,
|
|
10
|
+
fromAuthorizationHeader: (header) => {
|
|
11
|
+
return header.replace(BEARER_AUTH_HEADER_PREFIX, "").trim();
|
|
12
|
+
},
|
|
13
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { type AuthProvider, isAuthProvider } from "./AuthProvider.mjs";
|
|
2
|
+
export type { AuthRequest } from "./AuthRequest.mjs";
|
|
3
|
+
export { BasicAuth } from "./BasicAuth.mjs";
|
|
4
|
+
export { BearerToken } from "./BearerToken.mjs";
|
|
5
|
+
export { NoOpAuthProvider } from "./NoOpAuthProvider.mjs";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
function base64ToBytes(base64) {
|
|
2
|
+
const binString = atob(base64);
|
|
3
|
+
return Uint8Array.from(binString, (m) => m.codePointAt(0));
|
|
4
|
+
}
|
|
5
|
+
function bytesToBase64(bytes) {
|
|
6
|
+
const binString = String.fromCodePoint(...bytes);
|
|
7
|
+
return btoa(binString);
|
|
8
|
+
}
|
|
9
|
+
export function base64Encode(input) {
|
|
10
|
+
if (typeof Buffer !== "undefined") {
|
|
11
|
+
return Buffer.from(input, "utf8").toString("base64");
|
|
12
|
+
}
|
|
13
|
+
const bytes = new TextEncoder().encode(input);
|
|
14
|
+
return bytesToBase64(bytes);
|
|
15
|
+
}
|
|
16
|
+
export function base64Decode(input) {
|
|
17
|
+
if (typeof Buffer !== "undefined") {
|
|
18
|
+
return Buffer.from(input, "base64").toString("utf8");
|
|
19
|
+
}
|
|
20
|
+
const bytes = base64ToBytes(input);
|
|
21
|
+
return new TextDecoder().decode(bytes);
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./logging/exports.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./logging/exports.mjs";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { RawResponse } from "./RawResponse.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* The response of an API call.
|
|
4
|
+
* It is a successful response or a failed response.
|
|
5
|
+
*/
|
|
6
|
+
export type APIResponse<Success, Failure> = SuccessfulResponse<Success> | FailedResponse<Failure>;
|
|
7
|
+
export interface SuccessfulResponse<T> {
|
|
8
|
+
ok: true;
|
|
9
|
+
body: T;
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated Use `rawResponse` instead
|
|
12
|
+
*/
|
|
13
|
+
headers?: Record<string, any>;
|
|
14
|
+
rawResponse: RawResponse;
|
|
15
|
+
}
|
|
16
|
+
export interface FailedResponse<T> {
|
|
17
|
+
ok: false;
|
|
18
|
+
error: T;
|
|
19
|
+
rawResponse: RawResponse;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type BinaryResponse = {
|
|
2
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bodyUsed) */
|
|
3
|
+
bodyUsed: Response["bodyUsed"];
|
|
4
|
+
/**
|
|
5
|
+
* Returns a ReadableStream of the response body.
|
|
6
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/body)
|
|
7
|
+
*/
|
|
8
|
+
stream: () => Response["body"];
|
|
9
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/arrayBuffer) */
|
|
10
|
+
arrayBuffer: () => ReturnType<Response["arrayBuffer"]>;
|
|
11
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/blob) */
|
|
12
|
+
blob: () => ReturnType<Response["blob"]>;
|
|
13
|
+
/**
|
|
14
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes)
|
|
15
|
+
* Some versions of the Fetch API may not support this method.
|
|
16
|
+
*/
|
|
17
|
+
bytes?(): Promise<Uint8Array>;
|
|
18
|
+
};
|
|
19
|
+
export declare function getBinaryResponse(response: Response): BinaryResponse;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function getBinaryResponse(response) {
|
|
2
|
+
const binaryResponse = {
|
|
3
|
+
get bodyUsed() {
|
|
4
|
+
return response.bodyUsed;
|
|
5
|
+
},
|
|
6
|
+
stream: () => response.body,
|
|
7
|
+
arrayBuffer: response.arrayBuffer.bind(response),
|
|
8
|
+
blob: response.blob.bind(response),
|
|
9
|
+
};
|
|
10
|
+
if ("bytes" in response && typeof response.bytes === "function") {
|
|
11
|
+
binaryResponse.bytes = response.bytes.bind(response);
|
|
12
|
+
}
|
|
13
|
+
return binaryResponse;
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type SecuritySchemeKey = string;
|
|
2
|
+
/**
|
|
3
|
+
* A collection of security schemes, where the key is the name of the security scheme and the value is the list of scopes required for that scheme.
|
|
4
|
+
* All schemes in the collection must be satisfied for authentication to be successful.
|
|
5
|
+
*/
|
|
6
|
+
export type SecuritySchemeCollection = Record<SecuritySchemeKey, AuthScope[]>;
|
|
7
|
+
export type AuthScope = string;
|
|
8
|
+
export type EndpointMetadata = {
|
|
9
|
+
/**
|
|
10
|
+
* An array of security scheme collections. Each collection represents an alternative way to authenticate.
|
|
11
|
+
*/
|
|
12
|
+
security?: SecuritySchemeCollection[];
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { EndpointMetadata } from "./EndpointMetadata.mjs";
|
|
2
|
+
import type { Supplier } from "./Supplier.mjs";
|
|
3
|
+
type EndpointSupplierFn<T> = (arg: {
|
|
4
|
+
endpointMetadata?: EndpointMetadata;
|
|
5
|
+
}) => T | Promise<T>;
|
|
6
|
+
export type EndpointSupplier<T> = Supplier<T> | EndpointSupplierFn<T>;
|
|
7
|
+
export declare const EndpointSupplier: {
|
|
8
|
+
get: <T>(supplier: EndpointSupplier<T>, arg: {
|
|
9
|
+
endpointMetadata?: EndpointMetadata;
|
|
10
|
+
}) => Promise<T>;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
export const EndpointSupplier = {
|
|
11
|
+
get: (supplier, arg) => __awaiter(void 0, void 0, void 0, function* () {
|
|
12
|
+
if (typeof supplier === "function") {
|
|
13
|
+
return supplier(arg);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
return supplier;
|
|
17
|
+
}
|
|
18
|
+
}),
|
|
19
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type LogConfig, type Logger } from "../logging/logger.mjs";
|
|
2
|
+
import type { APIResponse } from "./APIResponse.mjs";
|
|
3
|
+
import type { EndpointMetadata } from "./EndpointMetadata.mjs";
|
|
4
|
+
export type FetchFunction = <R = unknown>(args: Fetcher.Args) => Promise<APIResponse<R, Fetcher.Error>>;
|
|
5
|
+
export declare namespace Fetcher {
|
|
6
|
+
interface Args {
|
|
7
|
+
url: string;
|
|
8
|
+
method: string;
|
|
9
|
+
contentType?: string;
|
|
10
|
+
headers?: Record<string, unknown>;
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Prefer `queryString` (produced by `core.url.queryBuilder()`).
|
|
13
|
+
* Retained for backwards compatibility with custom fetchers and callers that
|
|
14
|
+
* still construct request args with a query-parameter object.
|
|
15
|
+
*/
|
|
16
|
+
queryParameters?: Record<string, unknown>;
|
|
17
|
+
queryString?: string;
|
|
18
|
+
body?: unknown;
|
|
19
|
+
timeoutMs?: number;
|
|
20
|
+
maxRetries?: number;
|
|
21
|
+
withCredentials?: boolean;
|
|
22
|
+
abortSignal?: AbortSignal;
|
|
23
|
+
requestType?: "json" | "file" | "bytes" | "form" | "other";
|
|
24
|
+
responseType?: "json" | "blob" | "sse" | "streaming" | "text" | "arrayBuffer" | "binary-response";
|
|
25
|
+
duplex?: "half";
|
|
26
|
+
endpointMetadata?: EndpointMetadata;
|
|
27
|
+
fetchFn?: typeof fetch;
|
|
28
|
+
logging?: LogConfig | Logger;
|
|
29
|
+
}
|
|
30
|
+
type Error = FailedStatusCodeError | NonJsonError | BodyIsNullError | TimeoutError | UnknownError;
|
|
31
|
+
interface FailedStatusCodeError {
|
|
32
|
+
reason: "status-code";
|
|
33
|
+
statusCode: number;
|
|
34
|
+
body: unknown;
|
|
35
|
+
}
|
|
36
|
+
interface NonJsonError {
|
|
37
|
+
reason: "non-json";
|
|
38
|
+
statusCode: number;
|
|
39
|
+
rawBody: string;
|
|
40
|
+
}
|
|
41
|
+
interface BodyIsNullError {
|
|
42
|
+
reason: "body-is-null";
|
|
43
|
+
statusCode: number;
|
|
44
|
+
}
|
|
45
|
+
interface TimeoutError {
|
|
46
|
+
reason: "timeout";
|
|
47
|
+
cause?: unknown;
|
|
48
|
+
}
|
|
49
|
+
interface UnknownError {
|
|
50
|
+
reason: "unknown";
|
|
51
|
+
errorMessage: string;
|
|
52
|
+
cause?: unknown;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export declare function fetcherImpl<R = unknown>(args: Fetcher.Args): Promise<APIResponse<R, Fetcher.Error>>;
|
|
56
|
+
export declare const fetcher: FetchFunction;
|
|
@@ -0,0 +1,323 @@
|
|
|
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 { createLogger } from "../logging/logger.mjs";
|
|
12
|
+
import { createRequestUrl } from "./createRequestUrl.mjs";
|
|
13
|
+
import { EndpointSupplier } from "./EndpointSupplier.mjs";
|
|
14
|
+
import { getErrorResponseBody } from "./getErrorResponseBody.mjs";
|
|
15
|
+
import { getFetchFn } from "./getFetchFn.mjs";
|
|
16
|
+
import { getRequestBody } from "./getRequestBody.mjs";
|
|
17
|
+
import { getResponseBody } from "./getResponseBody.mjs";
|
|
18
|
+
import { Headers } from "./Headers.mjs";
|
|
19
|
+
import { makeRequest } from "./makeRequest.mjs";
|
|
20
|
+
import { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse.mjs";
|
|
21
|
+
import { requestWithRetries } from "./requestWithRetries.mjs";
|
|
22
|
+
const SENSITIVE_HEADERS = new Set([
|
|
23
|
+
"authorization",
|
|
24
|
+
"www-authenticate",
|
|
25
|
+
"x-api-key",
|
|
26
|
+
"api-key",
|
|
27
|
+
"apikey",
|
|
28
|
+
"x-api-token",
|
|
29
|
+
"x-auth-token",
|
|
30
|
+
"auth-token",
|
|
31
|
+
"cookie",
|
|
32
|
+
"set-cookie",
|
|
33
|
+
"proxy-authorization",
|
|
34
|
+
"proxy-authenticate",
|
|
35
|
+
"x-csrf-token",
|
|
36
|
+
"x-xsrf-token",
|
|
37
|
+
"x-session-token",
|
|
38
|
+
"x-access-token",
|
|
39
|
+
]);
|
|
40
|
+
function redactHeaders(headers) {
|
|
41
|
+
const filtered = {};
|
|
42
|
+
for (const [key, value] of headers instanceof Headers ? headers.entries() : Object.entries(headers)) {
|
|
43
|
+
if (SENSITIVE_HEADERS.has(key.toLowerCase())) {
|
|
44
|
+
filtered[key] = "[REDACTED]";
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
filtered[key] = value;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return filtered;
|
|
51
|
+
}
|
|
52
|
+
const SENSITIVE_QUERY_PARAMS = new Set([
|
|
53
|
+
"api_key",
|
|
54
|
+
"api-key",
|
|
55
|
+
"apikey",
|
|
56
|
+
"token",
|
|
57
|
+
"access_token",
|
|
58
|
+
"access-token",
|
|
59
|
+
"auth_token",
|
|
60
|
+
"auth-token",
|
|
61
|
+
"password",
|
|
62
|
+
"passwd",
|
|
63
|
+
"secret",
|
|
64
|
+
"api_secret",
|
|
65
|
+
"api-secret",
|
|
66
|
+
"apisecret",
|
|
67
|
+
"key",
|
|
68
|
+
"session",
|
|
69
|
+
"session_id",
|
|
70
|
+
"session-id",
|
|
71
|
+
]);
|
|
72
|
+
function redactQueryParameters(queryParameters) {
|
|
73
|
+
if (queryParameters == null) {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
const redacted = {};
|
|
77
|
+
for (const [key, value] of Object.entries(queryParameters)) {
|
|
78
|
+
redacted[key] = SENSITIVE_QUERY_PARAMS.has(key.toLowerCase()) ? "[REDACTED]" : value;
|
|
79
|
+
}
|
|
80
|
+
return redacted;
|
|
81
|
+
}
|
|
82
|
+
function redactUrl(url) {
|
|
83
|
+
const protocolIndex = url.indexOf("://");
|
|
84
|
+
if (protocolIndex === -1)
|
|
85
|
+
return url;
|
|
86
|
+
const afterProtocol = protocolIndex + 3;
|
|
87
|
+
// Find the first delimiter that marks the end of the authority section
|
|
88
|
+
const pathStart = url.indexOf("/", afterProtocol);
|
|
89
|
+
let queryStart = url.indexOf("?", afterProtocol);
|
|
90
|
+
let fragmentStart = url.indexOf("#", afterProtocol);
|
|
91
|
+
const firstDelimiter = Math.min(pathStart === -1 ? url.length : pathStart, queryStart === -1 ? url.length : queryStart, fragmentStart === -1 ? url.length : fragmentStart);
|
|
92
|
+
// Find the LAST @ before the delimiter (handles multiple @ in credentials)
|
|
93
|
+
let atIndex = -1;
|
|
94
|
+
for (let i = afterProtocol; i < firstDelimiter; i++) {
|
|
95
|
+
if (url[i] === "@") {
|
|
96
|
+
atIndex = i;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (atIndex !== -1) {
|
|
100
|
+
url = `${url.slice(0, afterProtocol)}[REDACTED]@${url.slice(atIndex + 1)}`;
|
|
101
|
+
}
|
|
102
|
+
// Recalculate queryStart since url might have changed
|
|
103
|
+
queryStart = url.indexOf("?");
|
|
104
|
+
if (queryStart === -1)
|
|
105
|
+
return url;
|
|
106
|
+
fragmentStart = url.indexOf("#", queryStart);
|
|
107
|
+
const queryEnd = fragmentStart !== -1 ? fragmentStart : url.length;
|
|
108
|
+
const queryString = url.slice(queryStart + 1, queryEnd);
|
|
109
|
+
if (queryString.length === 0)
|
|
110
|
+
return url;
|
|
111
|
+
// FAST PATH: Quick check if any sensitive keywords present
|
|
112
|
+
// Using indexOf is faster than regex for simple substring matching
|
|
113
|
+
const lower = queryString.toLowerCase();
|
|
114
|
+
const hasSensitive = lower.includes("token") ||
|
|
115
|
+
lower.includes("key") ||
|
|
116
|
+
lower.includes("password") ||
|
|
117
|
+
lower.includes("passwd") ||
|
|
118
|
+
lower.includes("secret") ||
|
|
119
|
+
lower.includes("session") ||
|
|
120
|
+
lower.includes("auth");
|
|
121
|
+
if (!hasSensitive) {
|
|
122
|
+
return url;
|
|
123
|
+
}
|
|
124
|
+
// SLOW PATH: Parse and redact
|
|
125
|
+
const redactedParams = [];
|
|
126
|
+
const params = queryString.split("&");
|
|
127
|
+
for (const param of params) {
|
|
128
|
+
const equalIndex = param.indexOf("=");
|
|
129
|
+
if (equalIndex === -1) {
|
|
130
|
+
redactedParams.push(param);
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
const key = param.slice(0, equalIndex);
|
|
134
|
+
let shouldRedact = SENSITIVE_QUERY_PARAMS.has(key.toLowerCase());
|
|
135
|
+
if (!shouldRedact && key.includes("%")) {
|
|
136
|
+
try {
|
|
137
|
+
const decodedKey = decodeURIComponent(key);
|
|
138
|
+
shouldRedact = SENSITIVE_QUERY_PARAMS.has(decodedKey.toLowerCase());
|
|
139
|
+
}
|
|
140
|
+
catch (_a) { }
|
|
141
|
+
}
|
|
142
|
+
redactedParams.push(shouldRedact ? `${key}=[REDACTED]` : param);
|
|
143
|
+
}
|
|
144
|
+
return url.slice(0, queryStart + 1) + redactedParams.join("&") + url.slice(queryEnd);
|
|
145
|
+
}
|
|
146
|
+
function getHeaders(args) {
|
|
147
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
148
|
+
var _a;
|
|
149
|
+
const newHeaders = new Headers();
|
|
150
|
+
newHeaders.set("Accept", args.responseType === "json"
|
|
151
|
+
? "application/json"
|
|
152
|
+
: args.responseType === "text"
|
|
153
|
+
? "text/plain"
|
|
154
|
+
: args.responseType === "sse"
|
|
155
|
+
? "text/event-stream"
|
|
156
|
+
: "*/*");
|
|
157
|
+
if (args.body !== undefined && args.contentType != null) {
|
|
158
|
+
newHeaders.set("Content-Type", args.contentType);
|
|
159
|
+
}
|
|
160
|
+
if (args.headers == null) {
|
|
161
|
+
return newHeaders;
|
|
162
|
+
}
|
|
163
|
+
for (const [key, value] of Object.entries(args.headers)) {
|
|
164
|
+
const result = yield EndpointSupplier.get(value, { endpointMetadata: (_a = args.endpointMetadata) !== null && _a !== void 0 ? _a : {} });
|
|
165
|
+
if (typeof result === "string") {
|
|
166
|
+
newHeaders.set(key, result);
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
if (result == null) {
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
newHeaders.set(key, `${result}`);
|
|
173
|
+
}
|
|
174
|
+
return newHeaders;
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
export function fetcherImpl(args) {
|
|
178
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
179
|
+
var _a, _b, _c;
|
|
180
|
+
let url = args.url;
|
|
181
|
+
if (args.queryString != null && args.queryString.length > 0) {
|
|
182
|
+
url = `${url}?${args.queryString}`;
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
url = createRequestUrl(args.url, args.queryParameters);
|
|
186
|
+
}
|
|
187
|
+
const requestBody = yield getRequestBody({
|
|
188
|
+
body: args.body,
|
|
189
|
+
type: (_a = args.requestType) !== null && _a !== void 0 ? _a : "other",
|
|
190
|
+
});
|
|
191
|
+
const fetchFn = (_b = args.fetchFn) !== null && _b !== void 0 ? _b : (yield getFetchFn());
|
|
192
|
+
const headers = yield getHeaders(args);
|
|
193
|
+
const logger = createLogger(args.logging);
|
|
194
|
+
if (logger.isDebug()) {
|
|
195
|
+
const metadata = {
|
|
196
|
+
method: args.method,
|
|
197
|
+
url: redactUrl(url),
|
|
198
|
+
headers: redactHeaders(headers),
|
|
199
|
+
queryParameters: redactQueryParameters(args.queryParameters),
|
|
200
|
+
hasBody: requestBody != null,
|
|
201
|
+
};
|
|
202
|
+
logger.debug("Making HTTP request", metadata);
|
|
203
|
+
}
|
|
204
|
+
try {
|
|
205
|
+
const response = yield requestWithRetries(() => __awaiter(this, void 0, void 0, function* () {
|
|
206
|
+
return makeRequest(fetchFn, url, args.method, headers, requestBody, args.timeoutMs, args.abortSignal, args.withCredentials, args.duplex, args.responseType === "streaming" || args.responseType === "sse");
|
|
207
|
+
}), args.maxRetries);
|
|
208
|
+
if (response.status >= 200 && response.status < 400) {
|
|
209
|
+
if (logger.isDebug()) {
|
|
210
|
+
const metadata = {
|
|
211
|
+
method: args.method,
|
|
212
|
+
url: redactUrl(url),
|
|
213
|
+
statusCode: response.status,
|
|
214
|
+
responseHeaders: redactHeaders(response.headers),
|
|
215
|
+
};
|
|
216
|
+
logger.debug("HTTP request succeeded", metadata);
|
|
217
|
+
}
|
|
218
|
+
const body = yield getResponseBody(response, args.responseType);
|
|
219
|
+
return {
|
|
220
|
+
ok: true,
|
|
221
|
+
body: body,
|
|
222
|
+
headers: response.headers,
|
|
223
|
+
rawResponse: toRawResponse(response),
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
if (logger.isError()) {
|
|
228
|
+
const metadata = {
|
|
229
|
+
method: args.method,
|
|
230
|
+
url: redactUrl(url),
|
|
231
|
+
statusCode: response.status,
|
|
232
|
+
responseHeaders: redactHeaders(Object.fromEntries(response.headers.entries())),
|
|
233
|
+
};
|
|
234
|
+
logger.error("HTTP request failed with error status", metadata);
|
|
235
|
+
}
|
|
236
|
+
return {
|
|
237
|
+
ok: false,
|
|
238
|
+
error: {
|
|
239
|
+
reason: "status-code",
|
|
240
|
+
statusCode: response.status,
|
|
241
|
+
body: yield getErrorResponseBody(response),
|
|
242
|
+
},
|
|
243
|
+
rawResponse: toRawResponse(response),
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
catch (error) {
|
|
248
|
+
if ((_c = args.abortSignal) === null || _c === void 0 ? void 0 : _c.aborted) {
|
|
249
|
+
if (logger.isError()) {
|
|
250
|
+
const metadata = {
|
|
251
|
+
method: args.method,
|
|
252
|
+
url: redactUrl(url),
|
|
253
|
+
};
|
|
254
|
+
logger.error("HTTP request was aborted", metadata);
|
|
255
|
+
}
|
|
256
|
+
return {
|
|
257
|
+
ok: false,
|
|
258
|
+
error: {
|
|
259
|
+
reason: "unknown",
|
|
260
|
+
errorMessage: "The user aborted a request",
|
|
261
|
+
cause: error,
|
|
262
|
+
},
|
|
263
|
+
rawResponse: abortRawResponse,
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
else if (error instanceof Error && error.name === "AbortError") {
|
|
267
|
+
if (logger.isError()) {
|
|
268
|
+
const metadata = {
|
|
269
|
+
method: args.method,
|
|
270
|
+
url: redactUrl(url),
|
|
271
|
+
timeoutMs: args.timeoutMs,
|
|
272
|
+
};
|
|
273
|
+
logger.error("HTTP request timed out", metadata);
|
|
274
|
+
}
|
|
275
|
+
return {
|
|
276
|
+
ok: false,
|
|
277
|
+
error: {
|
|
278
|
+
reason: "timeout",
|
|
279
|
+
cause: error,
|
|
280
|
+
},
|
|
281
|
+
rawResponse: abortRawResponse,
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
else if (error instanceof Error) {
|
|
285
|
+
if (logger.isError()) {
|
|
286
|
+
const metadata = {
|
|
287
|
+
method: args.method,
|
|
288
|
+
url: redactUrl(url),
|
|
289
|
+
errorMessage: error.message,
|
|
290
|
+
};
|
|
291
|
+
logger.error("HTTP request failed with error", metadata);
|
|
292
|
+
}
|
|
293
|
+
return {
|
|
294
|
+
ok: false,
|
|
295
|
+
error: {
|
|
296
|
+
reason: "unknown",
|
|
297
|
+
errorMessage: error.message,
|
|
298
|
+
cause: error,
|
|
299
|
+
},
|
|
300
|
+
rawResponse: unknownRawResponse,
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
if (logger.isError()) {
|
|
304
|
+
const metadata = {
|
|
305
|
+
method: args.method,
|
|
306
|
+
url: redactUrl(url),
|
|
307
|
+
error: toJson(error),
|
|
308
|
+
};
|
|
309
|
+
logger.error("HTTP request failed with unknown error", metadata);
|
|
310
|
+
}
|
|
311
|
+
return {
|
|
312
|
+
ok: false,
|
|
313
|
+
error: {
|
|
314
|
+
reason: "unknown",
|
|
315
|
+
errorMessage: toJson(error),
|
|
316
|
+
cause: error,
|
|
317
|
+
},
|
|
318
|
+
rawResponse: unknownRawResponse,
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
export const fetcher = fetcherImpl;
|