@smithy/core
Advanced tools
| 'use strict'; | ||
| var types = require('@smithy/types'); | ||
| const getSmithyContext = (context) => context[types.SMITHY_CONTEXT_KEY] || (context[types.SMITHY_CONTEXT_KEY] = {}); | ||
| class HttpRequest { | ||
| method; | ||
| protocol; | ||
| hostname; | ||
| port; | ||
| path; | ||
| query; | ||
| headers; | ||
| username; | ||
| password; | ||
| fragment; | ||
| body; | ||
| constructor(options) { | ||
| this.method = options.method || "GET"; | ||
| this.hostname = options.hostname || "localhost"; | ||
| this.port = options.port; | ||
| this.query = options.query || {}; | ||
| this.headers = options.headers || {}; | ||
| this.body = options.body; | ||
| this.protocol = options.protocol | ||
| ? options.protocol.slice(-1) !== ":" | ||
| ? `${options.protocol}:` | ||
| : options.protocol | ||
| : "https:"; | ||
| this.path = options.path ? (options.path.charAt(0) !== "/" ? `/${options.path}` : options.path) : "/"; | ||
| this.username = options.username; | ||
| this.password = options.password; | ||
| this.fragment = options.fragment; | ||
| } | ||
| static clone(request) { | ||
| const cloned = new HttpRequest({ | ||
| ...request, | ||
| headers: { ...request.headers }, | ||
| }); | ||
| if (cloned.query) { | ||
| cloned.query = cloneQuery(cloned.query); | ||
| } | ||
| return cloned; | ||
| } | ||
| static isInstance(request) { | ||
| if (!request) { | ||
| return false; | ||
| } | ||
| const req = request; | ||
| return ("method" in req && | ||
| "protocol" in req && | ||
| "hostname" in req && | ||
| "path" in req && | ||
| typeof req["query"] === "object" && | ||
| typeof req["headers"] === "object"); | ||
| } | ||
| clone() { | ||
| return HttpRequest.clone(this); | ||
| } | ||
| } | ||
| function cloneQuery(query) { | ||
| return Object.keys(query).reduce((carry, paramName) => { | ||
| const param = query[paramName]; | ||
| return { | ||
| ...carry, | ||
| [paramName]: Array.isArray(param) ? [...param] : param, | ||
| }; | ||
| }, {}); | ||
| } | ||
| class HttpResponse { | ||
| statusCode; | ||
| reason; | ||
| headers; | ||
| body; | ||
| constructor(options) { | ||
| this.statusCode = options.statusCode; | ||
| this.reason = options.reason; | ||
| this.headers = options.headers || {}; | ||
| this.body = options.body; | ||
| } | ||
| static isInstance(response) { | ||
| if (!response) | ||
| return false; | ||
| const resp = response; | ||
| return typeof resp.statusCode === "number" && typeof resp.headers === "object"; | ||
| } | ||
| } | ||
| const VALID_HOST_LABEL_REGEX = new RegExp(`^(?!.*-$)(?!-)[a-zA-Z0-9-]{1,63}$`); | ||
| const isValidHostLabel = (value, allowSubDomains = false) => { | ||
| if (!allowSubDomains) { | ||
| return VALID_HOST_LABEL_REGEX.test(value); | ||
| } | ||
| const labels = value.split("."); | ||
| for (const label of labels) { | ||
| if (!isValidHostLabel(label)) { | ||
| return false; | ||
| } | ||
| } | ||
| return true; | ||
| }; | ||
| function isValidHostname(hostname) { | ||
| const hostPattern = /^[a-z0-9][a-z0-9\.\-]*[a-z0-9]$/; | ||
| return hostPattern.test(hostname); | ||
| } | ||
| const normalizeProvider = (input) => { | ||
| if (typeof input === "function") | ||
| return input; | ||
| const promisified = Promise.resolve(input); | ||
| return () => promisified; | ||
| }; | ||
| function parseQueryString(querystring) { | ||
| const query = {}; | ||
| querystring = querystring.replace(/^\?/, ""); | ||
| if (querystring) { | ||
| for (const pair of querystring.split("&")) { | ||
| let [key, value = null] = pair.split("="); | ||
| key = decodeURIComponent(key); | ||
| if (value) { | ||
| value = decodeURIComponent(value); | ||
| } | ||
| if (!(key in query)) { | ||
| query[key] = value; | ||
| } | ||
| else if (Array.isArray(query[key])) { | ||
| query[key].push(value); | ||
| } | ||
| else { | ||
| query[key] = [query[key], value]; | ||
| } | ||
| } | ||
| } | ||
| return query; | ||
| } | ||
| const parseUrl = (url) => { | ||
| if (typeof url === "string") { | ||
| return parseUrl(new URL(url)); | ||
| } | ||
| const { hostname, pathname, port, protocol, search } = url; | ||
| let query; | ||
| if (search) { | ||
| query = parseQueryString(search); | ||
| } | ||
| return { | ||
| hostname, | ||
| port: port ? parseInt(port) : undefined, | ||
| protocol, | ||
| path: pathname, | ||
| query, | ||
| }; | ||
| }; | ||
| const toEndpointV1 = (endpoint) => { | ||
| if (typeof endpoint === "object") { | ||
| if ("url" in endpoint) { | ||
| const v1Endpoint = parseUrl(endpoint.url); | ||
| if (endpoint.headers) { | ||
| v1Endpoint.headers = {}; | ||
| for (const name in endpoint.headers) { | ||
| v1Endpoint.headers[name.toLowerCase()] = endpoint.headers[name].join(", "); | ||
| } | ||
| } | ||
| return v1Endpoint; | ||
| } | ||
| return endpoint; | ||
| } | ||
| return parseUrl(endpoint); | ||
| }; | ||
| exports.HttpRequest = HttpRequest; | ||
| exports.HttpResponse = HttpResponse; | ||
| exports.getSmithyContext = getSmithyContext; | ||
| exports.isValidHostLabel = isValidHostLabel; | ||
| exports.isValidHostname = isValidHostname; | ||
| exports.normalizeProvider = normalizeProvider; | ||
| exports.parseQueryString = parseQueryString; | ||
| exports.parseUrl = parseUrl; | ||
| exports.toEndpointV1 = toEndpointV1; |
| import { httpAuthSchemeMiddleware } from "./httpAuthSchemeMiddleware"; | ||
| export const httpAuthSchemeEndpointRuleSetMiddlewareOptions = { | ||
| step: "serialize", | ||
| tags: ["HTTP_AUTH_SCHEME"], | ||
| name: "httpAuthSchemeMiddleware", | ||
| override: true, | ||
| relation: "before", | ||
| toMiddleware: "endpointV2Middleware", | ||
| }; | ||
| export const getHttpAuthSchemeEndpointRuleSetPlugin = (config, { httpAuthSchemeParametersProvider, identityProviderConfigProvider, }) => ({ | ||
| applyToStack: (clientStack) => { | ||
| clientStack.addRelativeTo(httpAuthSchemeMiddleware(config, { | ||
| httpAuthSchemeParametersProvider, | ||
| identityProviderConfigProvider, | ||
| }), httpAuthSchemeEndpointRuleSetMiddlewareOptions); | ||
| }, | ||
| }); |
| import { httpAuthSchemeMiddleware } from "./httpAuthSchemeMiddleware"; | ||
| export const httpAuthSchemeMiddlewareOptions = { | ||
| step: "serialize", | ||
| tags: ["HTTP_AUTH_SCHEME"], | ||
| name: "httpAuthSchemeMiddleware", | ||
| override: true, | ||
| relation: "before", | ||
| toMiddleware: "serializerMiddleware", | ||
| }; | ||
| export const getHttpAuthSchemePlugin = (config, { httpAuthSchemeParametersProvider, identityProviderConfigProvider, }) => ({ | ||
| applyToStack: (clientStack) => { | ||
| clientStack.addRelativeTo(httpAuthSchemeMiddleware(config, { | ||
| httpAuthSchemeParametersProvider, | ||
| identityProviderConfigProvider, | ||
| }), httpAuthSchemeMiddlewareOptions); | ||
| }, | ||
| }); |
| import { getSmithyContext } from "@smithy/core/client"; | ||
| import { resolveAuthOptions } from "./resolveAuthOptions"; | ||
| function convertHttpAuthSchemesToMap(httpAuthSchemes) { | ||
| const map = new Map(); | ||
| for (const scheme of httpAuthSchemes) { | ||
| map.set(scheme.schemeId, scheme); | ||
| } | ||
| return map; | ||
| } | ||
| export const httpAuthSchemeMiddleware = (config, mwOptions) => (next, context) => async (args) => { | ||
| const options = config.httpAuthSchemeProvider(await mwOptions.httpAuthSchemeParametersProvider(config, context, args.input)); | ||
| const authSchemePreference = config.authSchemePreference ? await config.authSchemePreference() : []; | ||
| const resolvedOptions = resolveAuthOptions(options, authSchemePreference); | ||
| const authSchemes = convertHttpAuthSchemesToMap(config.httpAuthSchemes); | ||
| const smithyContext = getSmithyContext(context); | ||
| const failureReasons = []; | ||
| for (const option of resolvedOptions) { | ||
| const scheme = authSchemes.get(option.schemeId); | ||
| if (!scheme) { | ||
| failureReasons.push(`HttpAuthScheme \`${option.schemeId}\` was not enabled for this service.`); | ||
| continue; | ||
| } | ||
| const identityProvider = scheme.identityProvider(await mwOptions.identityProviderConfigProvider(config)); | ||
| if (!identityProvider) { | ||
| failureReasons.push(`HttpAuthScheme \`${option.schemeId}\` did not have an IdentityProvider configured.`); | ||
| continue; | ||
| } | ||
| const { identityProperties = {}, signingProperties = {} } = option.propertiesExtractor?.(config, context) || {}; | ||
| option.identityProperties = Object.assign(option.identityProperties || {}, identityProperties); | ||
| option.signingProperties = Object.assign(option.signingProperties || {}, signingProperties); | ||
| smithyContext.selectedHttpAuthScheme = { | ||
| httpAuthOption: option, | ||
| identity: await identityProvider(option.identityProperties), | ||
| signer: scheme.signer, | ||
| }; | ||
| break; | ||
| } | ||
| if (!smithyContext.selectedHttpAuthScheme) { | ||
| throw new Error(failureReasons.join("\n")); | ||
| } | ||
| return next(args); | ||
| }; |
| export * from "./httpAuthSchemeMiddleware"; | ||
| export * from "./getHttpAuthSchemeEndpointRuleSetPlugin"; | ||
| export * from "./getHttpAuthSchemePlugin"; |
| export const resolveAuthOptions = (candidateAuthOptions, authSchemePreference) => { | ||
| if (!authSchemePreference || authSchemePreference.length === 0) { | ||
| return candidateAuthOptions; | ||
| } | ||
| const preferredAuthOptions = []; | ||
| for (const preferredSchemeName of authSchemePreference) { | ||
| for (const candidateAuthOption of candidateAuthOptions) { | ||
| const candidateAuthSchemeName = candidateAuthOption.schemeId.split("#")[1]; | ||
| if (candidateAuthSchemeName === preferredSchemeName) { | ||
| preferredAuthOptions.push(candidateAuthOption); | ||
| } | ||
| } | ||
| } | ||
| for (const candidateAuthOption of candidateAuthOptions) { | ||
| if (!preferredAuthOptions.find(({ schemeId }) => schemeId === candidateAuthOption.schemeId)) { | ||
| preferredAuthOptions.push(candidateAuthOption); | ||
| } | ||
| } | ||
| return preferredAuthOptions; | ||
| }; |
| import { httpSigningMiddleware } from "./httpSigningMiddleware"; | ||
| export const httpSigningMiddlewareOptions = { | ||
| step: "finalizeRequest", | ||
| tags: ["HTTP_SIGNING"], | ||
| name: "httpSigningMiddleware", | ||
| aliases: ["apiKeyMiddleware", "tokenMiddleware", "awsAuthMiddleware"], | ||
| override: true, | ||
| relation: "after", | ||
| toMiddleware: "retryMiddleware", | ||
| }; | ||
| export const getHttpSigningPlugin = (config) => ({ | ||
| applyToStack: (clientStack) => { | ||
| clientStack.addRelativeTo(httpSigningMiddleware(config), httpSigningMiddlewareOptions); | ||
| }, | ||
| }); |
| import { getSmithyContext } from "@smithy/core/client"; | ||
| import { HttpRequest } from "@smithy/core/protocols"; | ||
| const defaultErrorHandler = (signingProperties) => (error) => { | ||
| throw error; | ||
| }; | ||
| const defaultSuccessHandler = (httpResponse, signingProperties) => { }; | ||
| export const httpSigningMiddleware = (config) => (next, context) => async (args) => { | ||
| if (!HttpRequest.isInstance(args.request)) { | ||
| return next(args); | ||
| } | ||
| const smithyContext = getSmithyContext(context); | ||
| const scheme = smithyContext.selectedHttpAuthScheme; | ||
| if (!scheme) { | ||
| throw new Error(`No HttpAuthScheme was selected: unable to sign request`); | ||
| } | ||
| const { httpAuthOption: { signingProperties = {} }, identity, signer, } = scheme; | ||
| const output = await next({ | ||
| ...args, | ||
| request: await signer.sign(args.request, identity, signingProperties), | ||
| }).catch((signer.errorHandler || defaultErrorHandler)(signingProperties)); | ||
| (signer.successHandler || defaultSuccessHandler)(output.response, signingProperties); | ||
| return output; | ||
| }; |
| export * from "./httpSigningMiddleware"; | ||
| export * from "./getHttpSigningMiddleware"; |
| const makePagedClientRequest = async (CommandCtor, client, input, withCommand = (_) => _, ...args) => { | ||
| let command = new CommandCtor(input); | ||
| command = withCommand(command) ?? command; | ||
| return await client.send(command, ...args); | ||
| }; | ||
| export function createPaginator(ClientCtor, CommandCtor, inputTokenName, outputTokenName, pageSizeTokenName) { | ||
| return async function* paginateOperation(config, input, ...additionalArguments) { | ||
| const _input = input; | ||
| let token = config.startingToken ?? _input[inputTokenName]; | ||
| let hasNext = true; | ||
| let page; | ||
| while (hasNext) { | ||
| _input[inputTokenName] = token; | ||
| if (pageSizeTokenName) { | ||
| _input[pageSizeTokenName] = _input[pageSizeTokenName] ?? config.pageSize; | ||
| } | ||
| if (config.client instanceof ClientCtor) { | ||
| page = await makePagedClientRequest(CommandCtor, config.client, input, config.withCommand, ...additionalArguments); | ||
| } | ||
| else { | ||
| throw new Error(`Invalid client, expected instance of ${ClientCtor.name}`); | ||
| } | ||
| yield page; | ||
| const prevToken = token; | ||
| token = get(page, outputTokenName); | ||
| hasNext = !!(token && (!config.stopOnSameToken || token !== prevToken)); | ||
| } | ||
| return undefined; | ||
| }; | ||
| } | ||
| const get = (fromObject, path) => { | ||
| let cursor = fromObject; | ||
| const pathComponents = path.split("."); | ||
| for (const step of pathComponents) { | ||
| if (!cursor || typeof cursor !== "object") { | ||
| return undefined; | ||
| } | ||
| cursor = cursor[step]; | ||
| } | ||
| return cursor; | ||
| }; |
| export class DefaultIdentityProviderConfig { | ||
| authSchemes = new Map(); | ||
| constructor(config) { | ||
| for (const key in config) { | ||
| const value = config[key]; | ||
| if (value !== undefined) { | ||
| this.authSchemes.set(key, value); | ||
| } | ||
| } | ||
| } | ||
| getIdentityProvider(schemeId) { | ||
| return this.authSchemes.get(schemeId); | ||
| } | ||
| } |
| import { HttpRequest } from "@smithy/core/protocols"; | ||
| import { HttpApiKeyAuthLocation, } from "@smithy/types"; | ||
| export class HttpApiKeyAuthSigner { | ||
| async sign(httpRequest, identity, signingProperties) { | ||
| if (!signingProperties) { | ||
| throw new Error("request could not be signed with `apiKey` since the `name` and `in` signer properties are missing"); | ||
| } | ||
| if (!signingProperties.name) { | ||
| throw new Error("request could not be signed with `apiKey` since the `name` signer property is missing"); | ||
| } | ||
| if (!signingProperties.in) { | ||
| throw new Error("request could not be signed with `apiKey` since the `in` signer property is missing"); | ||
| } | ||
| if (!identity.apiKey) { | ||
| throw new Error("request could not be signed with `apiKey` since the `apiKey` is not defined"); | ||
| } | ||
| const clonedRequest = HttpRequest.clone(httpRequest); | ||
| if (signingProperties.in === HttpApiKeyAuthLocation.QUERY) { | ||
| clonedRequest.query[signingProperties.name] = identity.apiKey; | ||
| } | ||
| else if (signingProperties.in === HttpApiKeyAuthLocation.HEADER) { | ||
| clonedRequest.headers[signingProperties.name] = signingProperties.scheme | ||
| ? `${signingProperties.scheme} ${identity.apiKey}` | ||
| : identity.apiKey; | ||
| } | ||
| else { | ||
| throw new Error("request can only be signed with `apiKey` locations `query` or `header`, " + | ||
| "but found: `" + | ||
| signingProperties.in + | ||
| "`"); | ||
| } | ||
| return clonedRequest; | ||
| } | ||
| } |
| import { HttpRequest } from "@smithy/core/protocols"; | ||
| export class HttpBearerAuthSigner { | ||
| async sign(httpRequest, identity, signingProperties) { | ||
| const clonedRequest = HttpRequest.clone(httpRequest); | ||
| if (!identity.token) { | ||
| throw new Error("request could not be signed with `token` since the `token` is not defined"); | ||
| } | ||
| clonedRequest.headers["Authorization"] = `Bearer ${identity.token}`; | ||
| return clonedRequest; | ||
| } | ||
| } |
| export * from "./httpApiKeyAuth"; | ||
| export * from "./httpBearerAuth"; | ||
| export * from "./noAuth"; |
| export class NoAuthSigner { | ||
| async sign(httpRequest, identity, signingProperties) { | ||
| return httpRequest; | ||
| } | ||
| } |
| export * from "./DefaultIdentityProviderConfig"; | ||
| export * from "./httpAuthSchemes"; | ||
| export * from "./memoizeIdentityProvider"; |
| export const createIsIdentityExpiredFunction = (expirationMs) => function isIdentityExpired(identity) { | ||
| return doesIdentityRequireRefresh(identity) && identity.expiration.getTime() - Date.now() < expirationMs; | ||
| }; | ||
| export const EXPIRATION_MS = 300_000; | ||
| export const isIdentityExpired = createIsIdentityExpiredFunction(EXPIRATION_MS); | ||
| export const doesIdentityRequireRefresh = (identity) => identity.expiration !== undefined; | ||
| export const memoizeIdentityProvider = (provider, isExpired, requiresRefresh) => { | ||
| if (provider === undefined) { | ||
| return undefined; | ||
| } | ||
| const normalizedProvider = typeof provider !== "function" ? async () => Promise.resolve(provider) : provider; | ||
| let resolved; | ||
| let pending; | ||
| let hasResult; | ||
| let isConstant = false; | ||
| const coalesceProvider = async (options) => { | ||
| if (!pending) { | ||
| pending = normalizedProvider(options); | ||
| } | ||
| try { | ||
| resolved = await pending; | ||
| hasResult = true; | ||
| isConstant = false; | ||
| } | ||
| finally { | ||
| pending = undefined; | ||
| } | ||
| return resolved; | ||
| }; | ||
| if (isExpired === undefined) { | ||
| return async (options) => { | ||
| if (!hasResult || options?.forceRefresh) { | ||
| resolved = await coalesceProvider(options); | ||
| } | ||
| return resolved; | ||
| }; | ||
| } | ||
| return async (options) => { | ||
| if (!hasResult || options?.forceRefresh) { | ||
| resolved = await coalesceProvider(options); | ||
| } | ||
| if (isConstant) { | ||
| return resolved; | ||
| } | ||
| if (!requiresRefresh(resolved)) { | ||
| isConstant = true; | ||
| return resolved; | ||
| } | ||
| if (isExpired(resolved)) { | ||
| await coalesceProvider(options); | ||
| return resolved; | ||
| } | ||
| return resolved; | ||
| }; | ||
| }; |
| import { SMITHY_CONTEXT_KEY } from "@smithy/types"; | ||
| export const getSmithyContext = (context) => context[SMITHY_CONTEXT_KEY] || (context[SMITHY_CONTEXT_KEY] = {}); |
| export class HttpRequest { | ||
| method; | ||
| protocol; | ||
| hostname; | ||
| port; | ||
| path; | ||
| query; | ||
| headers; | ||
| username; | ||
| password; | ||
| fragment; | ||
| body; | ||
| constructor(options) { | ||
| this.method = options.method || "GET"; | ||
| this.hostname = options.hostname || "localhost"; | ||
| this.port = options.port; | ||
| this.query = options.query || {}; | ||
| this.headers = options.headers || {}; | ||
| this.body = options.body; | ||
| this.protocol = options.protocol | ||
| ? options.protocol.slice(-1) !== ":" | ||
| ? `${options.protocol}:` | ||
| : options.protocol | ||
| : "https:"; | ||
| this.path = options.path ? (options.path.charAt(0) !== "/" ? `/${options.path}` : options.path) : "/"; | ||
| this.username = options.username; | ||
| this.password = options.password; | ||
| this.fragment = options.fragment; | ||
| } | ||
| static clone(request) { | ||
| const cloned = new HttpRequest({ | ||
| ...request, | ||
| headers: { ...request.headers }, | ||
| }); | ||
| if (cloned.query) { | ||
| cloned.query = cloneQuery(cloned.query); | ||
| } | ||
| return cloned; | ||
| } | ||
| static isInstance(request) { | ||
| if (!request) { | ||
| return false; | ||
| } | ||
| const req = request; | ||
| return ("method" in req && | ||
| "protocol" in req && | ||
| "hostname" in req && | ||
| "path" in req && | ||
| typeof req["query"] === "object" && | ||
| typeof req["headers"] === "object"); | ||
| } | ||
| clone() { | ||
| return HttpRequest.clone(this); | ||
| } | ||
| } | ||
| function cloneQuery(query) { | ||
| return Object.keys(query).reduce((carry, paramName) => { | ||
| const param = query[paramName]; | ||
| return { | ||
| ...carry, | ||
| [paramName]: Array.isArray(param) ? [...param] : param, | ||
| }; | ||
| }, {}); | ||
| } |
| export class HttpResponse { | ||
| statusCode; | ||
| reason; | ||
| headers; | ||
| body; | ||
| constructor(options) { | ||
| this.statusCode = options.statusCode; | ||
| this.reason = options.reason; | ||
| this.headers = options.headers || {}; | ||
| this.body = options.body; | ||
| } | ||
| static isInstance(response) { | ||
| if (!response) | ||
| return false; | ||
| const resp = response; | ||
| return typeof resp.statusCode === "number" && typeof resp.headers === "object"; | ||
| } | ||
| } |
| export { getSmithyContext } from "./getSmithyContext"; | ||
| export { HttpRequest } from "./httpRequest"; | ||
| export { HttpResponse } from "./httpResponse"; | ||
| export { isValidHostLabel } from "./isValidHostLabel"; | ||
| export { isValidHostname } from "./isValidHostname"; | ||
| export { normalizeProvider } from "./normalizeProvider"; | ||
| export { parseQueryString } from "./parseQueryString"; | ||
| export { parseUrl } from "./parseUrl"; | ||
| export { toEndpointV1 } from "./toEndpointV1"; |
| const VALID_HOST_LABEL_REGEX = new RegExp(`^(?!.*-$)(?!-)[a-zA-Z0-9-]{1,63}$`); | ||
| export const isValidHostLabel = (value, allowSubDomains = false) => { | ||
| if (!allowSubDomains) { | ||
| return VALID_HOST_LABEL_REGEX.test(value); | ||
| } | ||
| const labels = value.split("."); | ||
| for (const label of labels) { | ||
| if (!isValidHostLabel(label)) { | ||
| return false; | ||
| } | ||
| } | ||
| return true; | ||
| }; |
| export function isValidHostname(hostname) { | ||
| const hostPattern = /^[a-z0-9][a-z0-9\.\-]*[a-z0-9]$/; | ||
| return hostPattern.test(hostname); | ||
| } |
| export const normalizeProvider = (input) => { | ||
| if (typeof input === "function") | ||
| return input; | ||
| const promisified = Promise.resolve(input); | ||
| return () => promisified; | ||
| }; |
| export function parseQueryString(querystring) { | ||
| const query = {}; | ||
| querystring = querystring.replace(/^\?/, ""); | ||
| if (querystring) { | ||
| for (const pair of querystring.split("&")) { | ||
| let [key, value = null] = pair.split("="); | ||
| key = decodeURIComponent(key); | ||
| if (value) { | ||
| value = decodeURIComponent(value); | ||
| } | ||
| if (!(key in query)) { | ||
| query[key] = value; | ||
| } | ||
| else if (Array.isArray(query[key])) { | ||
| query[key].push(value); | ||
| } | ||
| else { | ||
| query[key] = [query[key], value]; | ||
| } | ||
| } | ||
| } | ||
| return query; | ||
| } |
| import { parseQueryString } from "./parseQueryString"; | ||
| export const parseUrl = (url) => { | ||
| if (typeof url === "string") { | ||
| return parseUrl(new URL(url)); | ||
| } | ||
| const { hostname, pathname, port, protocol, search } = url; | ||
| let query; | ||
| if (search) { | ||
| query = parseQueryString(search); | ||
| } | ||
| return { | ||
| hostname, | ||
| port: port ? parseInt(port) : undefined, | ||
| protocol, | ||
| path: pathname, | ||
| query, | ||
| }; | ||
| }; |
| import { parseUrl } from "./parseUrl"; | ||
| export const toEndpointV1 = (endpoint) => { | ||
| if (typeof endpoint === "object") { | ||
| if ("url" in endpoint) { | ||
| const v1Endpoint = parseUrl(endpoint.url); | ||
| if (endpoint.headers) { | ||
| v1Endpoint.headers = {}; | ||
| for (const name in endpoint.headers) { | ||
| v1Endpoint.headers[name.toLowerCase()] = endpoint.headers[name].join(", "); | ||
| } | ||
| } | ||
| return v1Endpoint; | ||
| } | ||
| return endpoint; | ||
| } | ||
| return parseUrl(endpoint); | ||
| }; |
| import type { HandlerExecutionContext, HttpAuthSchemeParameters, HttpAuthSchemeParametersProvider, IdentityProviderConfig, Pluggable, RelativeMiddlewareOptions, SerializeHandlerOptions } from "@smithy/types"; | ||
| import { type PreviouslyResolved } from "./httpAuthSchemeMiddleware"; | ||
| /** | ||
| * @internal | ||
| */ | ||
| export declare const httpAuthSchemeEndpointRuleSetMiddlewareOptions: SerializeHandlerOptions & RelativeMiddlewareOptions; | ||
| /** | ||
| * @internal | ||
| */ | ||
| interface HttpAuthSchemeEndpointRuleSetPluginOptions<TConfig extends object, TContext extends HandlerExecutionContext, TParameters extends HttpAuthSchemeParameters, TInput extends object> { | ||
| httpAuthSchemeParametersProvider: HttpAuthSchemeParametersProvider<TConfig, TContext, TParameters, TInput>; | ||
| identityProviderConfigProvider: (config: TConfig) => Promise<IdentityProviderConfig>; | ||
| } | ||
| /** | ||
| * @internal | ||
| */ | ||
| export declare const getHttpAuthSchemeEndpointRuleSetPlugin: <TConfig extends object, TContext extends HandlerExecutionContext, TParameters extends HttpAuthSchemeParameters, TInput extends object>(config: TConfig & PreviouslyResolved<TParameters>, { httpAuthSchemeParametersProvider, identityProviderConfigProvider, }: HttpAuthSchemeEndpointRuleSetPluginOptions<TConfig, TContext, TParameters, TInput>) => Pluggable<any, any>; | ||
| export {}; |
| import type { HandlerExecutionContext, HttpAuthSchemeParameters, HttpAuthSchemeParametersProvider, IdentityProviderConfig, Pluggable, RelativeMiddlewareOptions, SerializeHandlerOptions } from "@smithy/types"; | ||
| import { type PreviouslyResolved } from "./httpAuthSchemeMiddleware"; | ||
| /** | ||
| * @internal | ||
| */ | ||
| export declare const httpAuthSchemeMiddlewareOptions: SerializeHandlerOptions & RelativeMiddlewareOptions; | ||
| /** | ||
| * @internal | ||
| */ | ||
| interface HttpAuthSchemePluginOptions<TConfig extends object, TContext extends HandlerExecutionContext, TParameters extends HttpAuthSchemeParameters, TInput extends object> { | ||
| httpAuthSchemeParametersProvider: HttpAuthSchemeParametersProvider<TConfig, TContext, TParameters, TInput>; | ||
| identityProviderConfigProvider: (config: TConfig) => Promise<IdentityProviderConfig>; | ||
| } | ||
| /** | ||
| * @internal | ||
| */ | ||
| export declare const getHttpAuthSchemePlugin: <TConfig extends object, TContext extends HandlerExecutionContext, TParameters extends HttpAuthSchemeParameters, TInput extends object>(config: TConfig & PreviouslyResolved<TParameters>, { httpAuthSchemeParametersProvider, identityProviderConfigProvider, }: HttpAuthSchemePluginOptions<TConfig, TContext, TParameters, TInput>) => Pluggable<any, any>; | ||
| export {}; |
| import type { HandlerExecutionContext, HttpAuthScheme, HttpAuthSchemeParameters, HttpAuthSchemeParametersProvider, HttpAuthSchemeProvider, IdentityProviderConfig, Provider, SMITHY_CONTEXT_KEY, SelectedHttpAuthScheme, SerializeMiddleware } from "@smithy/types"; | ||
| /** | ||
| * @internal | ||
| */ | ||
| export interface PreviouslyResolved<TParameters extends HttpAuthSchemeParameters> { | ||
| authSchemePreference?: Provider<string[]>; | ||
| httpAuthSchemes: HttpAuthScheme[]; | ||
| httpAuthSchemeProvider: HttpAuthSchemeProvider<TParameters>; | ||
| } | ||
| /** | ||
| * @internal | ||
| */ | ||
| interface HttpAuthSchemeMiddlewareOptions<TConfig extends object, TContext extends HandlerExecutionContext, TParameters extends HttpAuthSchemeParameters, TInput extends object> { | ||
| httpAuthSchemeParametersProvider: HttpAuthSchemeParametersProvider<TConfig, TContext, TParameters, TInput>; | ||
| identityProviderConfigProvider: (config: TConfig) => Promise<IdentityProviderConfig>; | ||
| } | ||
| /** | ||
| * @internal | ||
| */ | ||
| interface HttpAuthSchemeMiddlewareSmithyContext extends Record<string, unknown> { | ||
| selectedHttpAuthScheme?: SelectedHttpAuthScheme; | ||
| } | ||
| /** | ||
| * @internal | ||
| */ | ||
| interface HttpAuthSchemeMiddlewareHandlerExecutionContext extends HandlerExecutionContext { | ||
| [SMITHY_CONTEXT_KEY]?: HttpAuthSchemeMiddlewareSmithyContext; | ||
| } | ||
| /** | ||
| * @internal | ||
| */ | ||
| export declare const httpAuthSchemeMiddleware: <TInput extends object, Output extends object, TConfig extends object, TContext extends HttpAuthSchemeMiddlewareHandlerExecutionContext, TParameters extends HttpAuthSchemeParameters>(config: TConfig & PreviouslyResolved<TParameters>, mwOptions: HttpAuthSchemeMiddlewareOptions<TConfig, TContext, TParameters, TInput>) => SerializeMiddleware<TInput, Output>; | ||
| export {}; |
| export * from "./httpAuthSchemeMiddleware"; | ||
| export * from "./getHttpAuthSchemeEndpointRuleSetPlugin"; | ||
| export * from "./getHttpAuthSchemePlugin"; |
| import type { HttpAuthOption } from "@smithy/types"; | ||
| /** | ||
| * Resolves list of auth options based on the supported ones, vs the preference list. | ||
| * | ||
| * @param candidateAuthOptions list of supported auth options selected by the standard | ||
| * resolution process (model-based, endpoints 2.0, etc.) | ||
| * @param authSchemePreference list of auth schemes preferred by user. | ||
| * @returns | ||
| */ | ||
| export declare const resolveAuthOptions: (candidateAuthOptions: HttpAuthOption[], authSchemePreference: string[]) => HttpAuthOption[]; |
| import type { FinalizeRequestHandlerOptions, Pluggable, RelativeMiddlewareOptions } from "@smithy/types"; | ||
| /** | ||
| * @internal | ||
| */ | ||
| export declare const httpSigningMiddlewareOptions: FinalizeRequestHandlerOptions & RelativeMiddlewareOptions; | ||
| /** | ||
| * @internal | ||
| */ | ||
| export declare const getHttpSigningPlugin: <Input extends object, Output extends object>(config: object) => Pluggable<Input, Output>; |
| import type { FinalizeRequestMiddleware } from "@smithy/types"; | ||
| /** | ||
| * @internal | ||
| */ | ||
| export declare const httpSigningMiddleware: <Input extends object, Output extends object>(config: object) => FinalizeRequestMiddleware<Input, Output>; |
| export * from "./httpSigningMiddleware"; | ||
| export * from "./getHttpSigningMiddleware"; |
| import type { PaginationConfiguration, Paginator } from "@smithy/types"; | ||
| /** | ||
| * Creates a paginator. | ||
| * | ||
| * @internal | ||
| */ | ||
| export declare function createPaginator<PaginationConfigType extends PaginationConfiguration, InputType extends object, OutputType extends object>(ClientCtor: any, CommandCtor: any, inputTokenName: string, outputTokenName: string, pageSizeTokenName?: string): (config: PaginationConfigType, input: InputType, ...additionalArguments: any[]) => Paginator<OutputType>; |
| import type { HttpAuthSchemeId, Identity, IdentityProvider, IdentityProviderConfig } from "@smithy/types"; | ||
| /** | ||
| * Default implementation of IdentityProviderConfig | ||
| * @internal | ||
| */ | ||
| export declare class DefaultIdentityProviderConfig implements IdentityProviderConfig { | ||
| private authSchemes; | ||
| /** | ||
| * Creates an IdentityProviderConfig with a record of scheme IDs to identity providers. | ||
| * | ||
| * @param config scheme IDs and identity providers to configure | ||
| */ | ||
| constructor(config: Record<HttpAuthSchemeId, IdentityProvider<Identity> | undefined>); | ||
| getIdentityProvider(schemeId: HttpAuthSchemeId): IdentityProvider<Identity> | undefined; | ||
| } |
| import { HttpRequest } from "@smithy/core/protocols"; | ||
| import { type ApiKeyIdentity, type HttpSigner, type HttpRequest as IHttpRequest } from "@smithy/types"; | ||
| /** | ||
| * @internal | ||
| */ | ||
| export declare class HttpApiKeyAuthSigner implements HttpSigner { | ||
| sign(httpRequest: HttpRequest, identity: ApiKeyIdentity, signingProperties: Record<string, any>): Promise<IHttpRequest>; | ||
| } |
| import { HttpRequest } from "@smithy/core/protocols"; | ||
| import type { HttpSigner, HttpRequest as IHttpRequest, TokenIdentity } from "@smithy/types"; | ||
| /** | ||
| * @internal | ||
| */ | ||
| export declare class HttpBearerAuthSigner implements HttpSigner { | ||
| sign(httpRequest: HttpRequest, identity: TokenIdentity, signingProperties: Record<string, any>): Promise<IHttpRequest>; | ||
| } |
| export * from "./httpApiKeyAuth"; | ||
| export * from "./httpBearerAuth"; | ||
| export * from "./noAuth"; |
| import type { HttpRequest, HttpSigner, Identity } from "@smithy/types"; | ||
| /** | ||
| * Signer for the synthetic @smithy.api#noAuth auth scheme. | ||
| * @internal | ||
| */ | ||
| export declare class NoAuthSigner implements HttpSigner { | ||
| sign(httpRequest: HttpRequest, identity: Identity, signingProperties: Record<string, unknown>): Promise<HttpRequest>; | ||
| } |
| export * from "./DefaultIdentityProviderConfig"; | ||
| export * from "./httpAuthSchemes"; | ||
| export * from "./memoizeIdentityProvider"; |
| import type { Identity, IdentityProvider } from "@smithy/types"; | ||
| /** | ||
| * @internal | ||
| */ | ||
| export declare const createIsIdentityExpiredFunction: (expirationMs: number) => (identity: Identity) => boolean; | ||
| /** | ||
| * This may need to be configurable in the future, but for now it is defaulted to 5min. | ||
| * | ||
| * @internal | ||
| */ | ||
| export declare const EXPIRATION_MS = 300000; | ||
| /** | ||
| * @internal | ||
| */ | ||
| export declare const isIdentityExpired: (identity: Identity) => boolean; | ||
| /** | ||
| * @internal | ||
| */ | ||
| export declare const doesIdentityRequireRefresh: (identity: Identity) => boolean; | ||
| /** | ||
| * @internal | ||
| */ | ||
| export interface MemoizedIdentityProvider<IdentityT extends Identity> { | ||
| (options?: Record<string, any> & { | ||
| forceRefresh?: boolean; | ||
| }): Promise<IdentityT>; | ||
| } | ||
| /** | ||
| * @internal | ||
| */ | ||
| export declare const memoizeIdentityProvider: <IdentityT extends Identity>(provider: IdentityT | IdentityProvider<IdentityT> | undefined, isExpired: (resolved: Identity) => boolean, requiresRefresh: (resolved: Identity) => boolean) => MemoizedIdentityProvider<IdentityT> | undefined; |
| import { type HandlerExecutionContext } from "@smithy/types"; | ||
| /** | ||
| * @internal | ||
| */ | ||
| export declare const getSmithyContext: (context: HandlerExecutionContext) => Record<string, unknown>; |
| import { HttpRequest as IHttpRequest, type HeaderBag, type HttpMessage, type QueryParameterBag, type URI } from "@smithy/types"; | ||
| type HttpRequestOptions = Partial<HttpMessage> & Partial<URI> & { | ||
| method?: string; | ||
| }; | ||
| /** | ||
| * Use the distinct IHttpRequest interface from \@smithy/types instead. | ||
| * This should not be used due to | ||
| * overlapping with the concrete class' name. | ||
| * | ||
| * This is not marked deprecated since that would mark the concrete class | ||
| * deprecated as well. | ||
| * | ||
| * @internal | ||
| */ | ||
| export interface HttpRequest extends IHttpRequest { | ||
| } | ||
| /** | ||
| * @public | ||
| */ | ||
| export { IHttpRequest }; | ||
| /** | ||
| * @public | ||
| */ | ||
| export declare class HttpRequest implements HttpMessage, URI { | ||
| method: string; | ||
| protocol: string; | ||
| hostname: string; | ||
| port?: number; | ||
| path: string; | ||
| query: QueryParameterBag; | ||
| headers: HeaderBag; | ||
| username?: string; | ||
| password?: string; | ||
| fragment?: string; | ||
| body?: any; | ||
| constructor(options: HttpRequestOptions); | ||
| /** | ||
| * Note: this does not deep-clone the body. | ||
| */ | ||
| static clone(request: IHttpRequest): HttpRequest; | ||
| /** | ||
| * This method only actually asserts that request is the interface {@link IHttpRequest}, | ||
| * and not necessarily this concrete class. Left in place for API stability. | ||
| * | ||
| * Do not call instance methods on the input of this function, and | ||
| * do not assume it has the HttpRequest prototype. | ||
| */ | ||
| static isInstance(request: unknown): request is HttpRequest; | ||
| /** | ||
| * @deprecated use static HttpRequest.clone(request) instead. It's not safe to call | ||
| * this method because {@link HttpRequest.isInstance} incorrectly | ||
| * asserts that IHttpRequest (interface) objects are of type HttpRequest (class). | ||
| */ | ||
| clone(): HttpRequest; | ||
| } |
| import type { HeaderBag, HttpMessage, HttpResponse as IHttpResponse } from "@smithy/types"; | ||
| type HttpResponseOptions = Partial<HttpMessage> & { | ||
| statusCode: number; | ||
| reason?: string; | ||
| }; | ||
| /** | ||
| * Use the distinct IHttpResponse interface from \@smithy/types instead. | ||
| * This should not be used due to | ||
| * overlapping with the concrete class' name. | ||
| * | ||
| * This is not marked deprecated since that would mark the concrete class | ||
| * deprecated as well. | ||
| * | ||
| * @internal | ||
| */ | ||
| export interface HttpResponse extends IHttpResponse { | ||
| } | ||
| /** | ||
| * @public | ||
| */ | ||
| export declare class HttpResponse { | ||
| statusCode: number; | ||
| reason?: string; | ||
| headers: HeaderBag; | ||
| body?: any; | ||
| constructor(options: HttpResponseOptions); | ||
| static isInstance(response: unknown): response is HttpResponse; | ||
| } | ||
| export {}; |
| export { getSmithyContext } from "./getSmithyContext"; | ||
| export { HttpRequest, IHttpRequest } from "./httpRequest"; | ||
| export { HttpResponse } from "./httpResponse"; | ||
| export { isValidHostLabel } from "./isValidHostLabel"; | ||
| export { isValidHostname } from "./isValidHostname"; | ||
| export { normalizeProvider } from "./normalizeProvider"; | ||
| export { parseQueryString } from "./parseQueryString"; | ||
| export { parseUrl } from "./parseUrl"; | ||
| export { toEndpointV1 } from "./toEndpointV1"; |
| /** | ||
| * Evaluates whether one or more string values are valid host labels per RFC 1123. | ||
| * | ||
| * If allowSubDomains is true, then the provided value may be zero or more dotted | ||
| * subdomains which are each validated per RFC 1123. | ||
| */ | ||
| export declare const isValidHostLabel: (value: string, allowSubDomains?: boolean) => boolean; |
| export declare function isValidHostname(hostname: string): boolean; |
| import type { Provider } from "@smithy/types"; | ||
| /** | ||
| * @internal | ||
| * | ||
| * @returns a provider function for the input value if it isn't already one. | ||
| */ | ||
| export declare const normalizeProvider: <T>(input: T | Provider<T>) => Provider<T>; |
| import type { QueryParameterBag } from "@smithy/types"; | ||
| /** | ||
| * @internal | ||
| */ | ||
| export declare function parseQueryString(querystring: string): QueryParameterBag; |
| import type { UrlParser } from "@smithy/types"; | ||
| /** | ||
| * @internal | ||
| */ | ||
| export declare const parseUrl: UrlParser; |
| import type { Endpoint, EndpointV2 } from "@smithy/types"; | ||
| /** | ||
| * Converts an endpoint to EndpointV1 format. | ||
| * @internal | ||
| */ | ||
| export declare const toEndpointV1: (endpoint: string | Endpoint | EndpointV2) => Endpoint; |
| /** | ||
| * Do not edit: | ||
| * This is a compatibility redirect for contexts that do not understand package.json exports field. | ||
| */ | ||
| export * from "./dist-types/submodules/transport/index"; |
| /** | ||
| * Do not edit: | ||
| * This is a compatibility redirect for contexts that do not understand package.json exports field. | ||
| */ | ||
| module.exports = require("./dist-cjs/submodules/transport/index.js"); |
| 'use strict'; | ||
| var transport = require('@smithy/core/transport'); | ||
| var protocols = require('@smithy/core/protocols'); | ||
| var types = require('@smithy/types'); | ||
| var protocols = require('@smithy/core/protocols'); | ||
| var client = require('@smithy/core/client'); | ||
| const getSmithyContext = (context) => context[types.SMITHY_CONTEXT_KEY] || (context[types.SMITHY_CONTEXT_KEY] = {}); | ||
| const resolveAuthOptions = (candidateAuthOptions, authSchemePreference) => { | ||
@@ -324,2 +323,3 @@ if (!authSchemePreference || authSchemePreference.length === 0) { | ||
| exports.getSmithyContext = transport.getSmithyContext; | ||
| exports.requestBuilder = protocols.requestBuilder; | ||
@@ -337,3 +337,2 @@ exports.DefaultIdentityProviderConfig = DefaultIdentityProviderConfig; | ||
| exports.getHttpSigningPlugin = getHttpSigningPlugin; | ||
| exports.getSmithyContext = getSmithyContext; | ||
| exports.httpAuthSchemeEndpointRuleSetMiddlewareOptions = httpAuthSchemeEndpointRuleSetMiddlewareOptions; | ||
@@ -340,0 +339,0 @@ exports.httpAuthSchemeMiddleware = httpAuthSchemeMiddleware; |
| 'use strict'; | ||
| var transport = require('@smithy/core/transport'); | ||
| var types = require('@smithy/types'); | ||
@@ -288,11 +289,2 @@ var schema = require('@smithy/core/schema'); | ||
| const getSmithyContext = (context) => context[types.SMITHY_CONTEXT_KEY] || (context[types.SMITHY_CONTEXT_KEY] = {}); | ||
| const normalizeProvider = (input) => { | ||
| if (typeof input === "function") | ||
| return input; | ||
| const promisified = Promise.resolve(input); | ||
| return () => promisified; | ||
| }; | ||
| const invalidFunction = (message) => () => { | ||
@@ -1101,2 +1093,4 @@ throw new Error(message); | ||
| exports.getSmithyContext = transport.getSmithyContext; | ||
| exports.normalizeProvider = transport.normalizeProvider; | ||
| exports.AlgorithmId = types.AlgorithmId; | ||
@@ -1121,3 +1115,2 @@ exports.Client = Client; | ||
| exports.getRetryConfiguration = getRetryConfiguration; | ||
| exports.getSmithyContext = getSmithyContext; | ||
| exports.getValueFromTextNode = getValueFromTextNode; | ||
@@ -1129,3 +1122,2 @@ exports.invalidFunction = invalidFunction; | ||
| exports.map = map; | ||
| exports.normalizeProvider = normalizeProvider; | ||
| exports.resolveChecksumRuntimeConfig = resolveChecksumRuntimeConfig; | ||
@@ -1132,0 +1124,0 @@ exports.resolveDefaultRuntimeConfig = resolveDefaultRuntimeConfig; |
| 'use strict'; | ||
| var client = require('@smithy/core/client'); | ||
| var endpoints = require('@smithy/core/endpoints'); | ||
| var transport = require('@smithy/core/transport'); | ||
@@ -181,3 +181,3 @@ class ProviderError extends Error { | ||
| const validRegions = new Set(); | ||
| const checkRegion = (region, check = endpoints.isValidHostLabel) => { | ||
| const checkRegion = (region, check = transport.isValidHostLabel) => { | ||
| if (!validRegions.has(region) && !check(region)) { | ||
@@ -184,0 +184,0 @@ if (region === "*") { |
@@ -9,3 +9,3 @@ 'use strict'; | ||
| var client = require('@smithy/core/client'); | ||
| var endpoints = require('@smithy/core/endpoints'); | ||
| var transport = require('@smithy/core/transport'); | ||
@@ -490,3 +490,3 @@ class ProviderError extends Error { | ||
| const validRegions = new Set(); | ||
| const checkRegion = (region, check = endpoints.isValidHostLabel) => { | ||
| const checkRegion = (region, check = transport.isValidHostLabel) => { | ||
| if (!validRegions.has(region) && !check(region)) { | ||
@@ -493,0 +493,0 @@ if (region === "*") { |
| 'use strict'; | ||
| var client = require('@smithy/core/client'); | ||
| var endpoints = require('@smithy/core/endpoints'); | ||
| var transport = require('@smithy/core/transport'); | ||
@@ -181,3 +181,3 @@ class ProviderError extends Error { | ||
| const validRegions = new Set(); | ||
| const checkRegion = (region, check = endpoints.isValidHostLabel) => { | ||
| const checkRegion = (region, check = transport.isValidHostLabel) => { | ||
| if (!validRegions.has(region) && !check(region)) { | ||
@@ -184,0 +184,0 @@ if (region === "*") { |
| 'use strict'; | ||
| var protocols = require('@smithy/core/protocols'); | ||
| var transport = require('@smithy/core/transport'); | ||
| var client = require('@smithy/core/client'); | ||
@@ -96,19 +96,2 @@ var types = require('@smithy/types'); | ||
| const toEndpointV1 = (endpoint) => { | ||
| if (typeof endpoint === "object") { | ||
| if ("url" in endpoint) { | ||
| const v1Endpoint = protocols.parseUrl(endpoint.url); | ||
| if (endpoint.headers) { | ||
| v1Endpoint.headers = {}; | ||
| for (const name in endpoint.headers) { | ||
| v1Endpoint.headers[name.toLowerCase()] = endpoint.headers[name].join(", "); | ||
| } | ||
| } | ||
| return v1Endpoint; | ||
| } | ||
| return endpoint; | ||
| } | ||
| return protocols.parseUrl(endpoint); | ||
| }; | ||
| function bindGetEndpointFromInstructions(getEndpointFromConfig) { | ||
@@ -125,3 +108,3 @@ return async (commandInput, instructionsSupplier, clientConfig, context) => { | ||
| if (endpointFromConfig) { | ||
| clientConfig.endpoint = () => Promise.resolve(toEndpointV1(endpointFromConfig)); | ||
| clientConfig.endpoint = () => Promise.resolve(transport.toEndpointV1(endpointFromConfig)); | ||
| clientConfig.isCustomEndpoint = true; | ||
@@ -250,3 +233,3 @@ } | ||
| const { endpoint, useDualstackEndpoint, useFipsEndpoint } = input; | ||
| const customEndpointProvider = endpoint != null ? async () => toEndpointV1(await client.normalizeProvider(endpoint)()) : undefined; | ||
| const customEndpointProvider = endpoint != null ? async () => transport.toEndpointV1(await transport.normalizeProvider(endpoint)()) : undefined; | ||
| const isCustomEndpoint = !!endpoint; | ||
@@ -257,4 +240,4 @@ const resolvedConfig = Object.assign(input, { | ||
| isCustomEndpoint, | ||
| useDualstackEndpoint: client.normalizeProvider(useDualstackEndpoint ?? false), | ||
| useFipsEndpoint: client.normalizeProvider(useFipsEndpoint ?? false), | ||
| useDualstackEndpoint: transport.normalizeProvider(useDualstackEndpoint ?? false), | ||
| useFipsEndpoint: transport.normalizeProvider(useFipsEndpoint ?? false), | ||
| }); | ||
@@ -412,16 +395,2 @@ let configuredEndpointPromise = undefined; | ||
| const VALID_HOST_LABEL_REGEX = new RegExp(`^(?!.*-$)(?!-)[a-zA-Z0-9-]{1,63}$`); | ||
| const isValidHostLabel = (value, allowSubDomains = false) => { | ||
| if (!allowSubDomains) { | ||
| return VALID_HOST_LABEL_REGEX.test(value); | ||
| } | ||
| const labels = value.split("."); | ||
| for (const label of labels) { | ||
| if (!isValidHostLabel(label)) { | ||
| return false; | ||
| } | ||
| } | ||
| return true; | ||
| }; | ||
| function ite(condition, trueValue, falseValue) { | ||
@@ -519,3 +488,3 @@ return condition ? trueValue : falseValue; | ||
| isSet, | ||
| isValidHostLabel, | ||
| isValidHostLabel: transport.isValidHostLabel, | ||
| ite, | ||
@@ -850,2 +819,5 @@ not, | ||
| exports.isValidHostLabel = transport.isValidHostLabel; | ||
| exports.middlewareEndpointToEndpointV1 = transport.toEndpointV1; | ||
| exports.toEndpointV1 = transport.toEndpointV1; | ||
| exports.BinaryDecisionDiagram = BinaryDecisionDiagram; | ||
@@ -861,4 +833,2 @@ exports.EndpointCache = EndpointCache; | ||
| exports.isIpAddress = isIpAddress; | ||
| exports.isValidHostLabel = isValidHostLabel; | ||
| exports.middlewareEndpointToEndpointV1 = toEndpointV1; | ||
| exports.resolveEndpoint = resolveEndpoint; | ||
@@ -868,2 +838,1 @@ exports.resolveEndpointConfig = resolveEndpointConfig; | ||
| exports.resolveParams = resolveParams; | ||
| exports.toEndpointV1 = toEndpointV1; |
| 'use strict'; | ||
| var config = require('@smithy/core/config'); | ||
| var protocols = require('@smithy/core/protocols'); | ||
| var transport = require('@smithy/core/transport'); | ||
| var client = require('@smithy/core/client'); | ||
@@ -128,19 +128,2 @@ var types = require('@smithy/types'); | ||
| const toEndpointV1 = (endpoint) => { | ||
| if (typeof endpoint === "object") { | ||
| if ("url" in endpoint) { | ||
| const v1Endpoint = protocols.parseUrl(endpoint.url); | ||
| if (endpoint.headers) { | ||
| v1Endpoint.headers = {}; | ||
| for (const name in endpoint.headers) { | ||
| v1Endpoint.headers[name.toLowerCase()] = endpoint.headers[name].join(", "); | ||
| } | ||
| } | ||
| return v1Endpoint; | ||
| } | ||
| return endpoint; | ||
| } | ||
| return protocols.parseUrl(endpoint); | ||
| }; | ||
| function bindGetEndpointFromInstructions(getEndpointFromConfig) { | ||
@@ -157,3 +140,3 @@ return async (commandInput, instructionsSupplier, clientConfig, context) => { | ||
| if (endpointFromConfig) { | ||
| clientConfig.endpoint = () => Promise.resolve(toEndpointV1(endpointFromConfig)); | ||
| clientConfig.endpoint = () => Promise.resolve(transport.toEndpointV1(endpointFromConfig)); | ||
| clientConfig.isCustomEndpoint = true; | ||
@@ -282,3 +265,3 @@ } | ||
| const { endpoint, useDualstackEndpoint, useFipsEndpoint } = input; | ||
| const customEndpointProvider = endpoint != null ? async () => toEndpointV1(await client.normalizeProvider(endpoint)()) : undefined; | ||
| const customEndpointProvider = endpoint != null ? async () => transport.toEndpointV1(await transport.normalizeProvider(endpoint)()) : undefined; | ||
| const isCustomEndpoint = !!endpoint; | ||
@@ -289,4 +272,4 @@ const resolvedConfig = Object.assign(input, { | ||
| isCustomEndpoint, | ||
| useDualstackEndpoint: client.normalizeProvider(useDualstackEndpoint ?? false), | ||
| useFipsEndpoint: client.normalizeProvider(useFipsEndpoint ?? false), | ||
| useDualstackEndpoint: transport.normalizeProvider(useDualstackEndpoint ?? false), | ||
| useFipsEndpoint: transport.normalizeProvider(useFipsEndpoint ?? false), | ||
| }); | ||
@@ -444,16 +427,2 @@ let configuredEndpointPromise = undefined; | ||
| const VALID_HOST_LABEL_REGEX = new RegExp(`^(?!.*-$)(?!-)[a-zA-Z0-9-]{1,63}$`); | ||
| const isValidHostLabel = (value, allowSubDomains = false) => { | ||
| if (!allowSubDomains) { | ||
| return VALID_HOST_LABEL_REGEX.test(value); | ||
| } | ||
| const labels = value.split("."); | ||
| for (const label of labels) { | ||
| if (!isValidHostLabel(label)) { | ||
| return false; | ||
| } | ||
| } | ||
| return true; | ||
| }; | ||
| function ite(condition, trueValue, falseValue) { | ||
@@ -551,3 +520,3 @@ return condition ? trueValue : falseValue; | ||
| isSet, | ||
| isValidHostLabel, | ||
| isValidHostLabel: transport.isValidHostLabel, | ||
| ite, | ||
@@ -882,2 +851,5 @@ not, | ||
| exports.isValidHostLabel = transport.isValidHostLabel; | ||
| exports.middlewareEndpointToEndpointV1 = transport.toEndpointV1; | ||
| exports.toEndpointV1 = transport.toEndpointV1; | ||
| exports.BinaryDecisionDiagram = BinaryDecisionDiagram; | ||
@@ -893,4 +865,2 @@ exports.EndpointCache = EndpointCache; | ||
| exports.isIpAddress = isIpAddress; | ||
| exports.isValidHostLabel = isValidHostLabel; | ||
| exports.middlewareEndpointToEndpointV1 = toEndpointV1; | ||
| exports.resolveEndpoint = resolveEndpoint; | ||
@@ -900,2 +870,1 @@ exports.resolveEndpointConfig = resolveEndpointConfig; | ||
| exports.resolveParams = resolveParams; | ||
| exports.toEndpointV1 = toEndpointV1; |
@@ -5,2 +5,3 @@ 'use strict'; | ||
| var schema = require('@smithy/core/schema'); | ||
| var transport = require('@smithy/core/transport'); | ||
| var types = require('@smithy/types'); | ||
@@ -32,86 +33,2 @@ | ||
| class HttpRequest { | ||
| method; | ||
| protocol; | ||
| hostname; | ||
| port; | ||
| path; | ||
| query; | ||
| headers; | ||
| username; | ||
| password; | ||
| fragment; | ||
| body; | ||
| constructor(options) { | ||
| this.method = options.method || "GET"; | ||
| this.hostname = options.hostname || "localhost"; | ||
| this.port = options.port; | ||
| this.query = options.query || {}; | ||
| this.headers = options.headers || {}; | ||
| this.body = options.body; | ||
| this.protocol = options.protocol | ||
| ? options.protocol.slice(-1) !== ":" | ||
| ? `${options.protocol}:` | ||
| : options.protocol | ||
| : "https:"; | ||
| this.path = options.path ? (options.path.charAt(0) !== "/" ? `/${options.path}` : options.path) : "/"; | ||
| this.username = options.username; | ||
| this.password = options.password; | ||
| this.fragment = options.fragment; | ||
| } | ||
| static clone(request) { | ||
| const cloned = new HttpRequest({ | ||
| ...request, | ||
| headers: { ...request.headers }, | ||
| }); | ||
| if (cloned.query) { | ||
| cloned.query = cloneQuery(cloned.query); | ||
| } | ||
| return cloned; | ||
| } | ||
| static isInstance(request) { | ||
| if (!request) { | ||
| return false; | ||
| } | ||
| const req = request; | ||
| return ("method" in req && | ||
| "protocol" in req && | ||
| "hostname" in req && | ||
| "path" in req && | ||
| typeof req["query"] === "object" && | ||
| typeof req["headers"] === "object"); | ||
| } | ||
| clone() { | ||
| return HttpRequest.clone(this); | ||
| } | ||
| } | ||
| function cloneQuery(query) { | ||
| return Object.keys(query).reduce((carry, paramName) => { | ||
| const param = query[paramName]; | ||
| return { | ||
| ...carry, | ||
| [paramName]: Array.isArray(param) ? [...param] : param, | ||
| }; | ||
| }, {}); | ||
| } | ||
| class HttpResponse { | ||
| statusCode; | ||
| reason; | ||
| headers; | ||
| body; | ||
| constructor(options) { | ||
| this.statusCode = options.statusCode; | ||
| this.reason = options.reason; | ||
| this.headers = options.headers || {}; | ||
| this.body = options.body; | ||
| } | ||
| static isInstance(response) { | ||
| if (!response) | ||
| return false; | ||
| const resp = response; | ||
| return typeof resp.statusCode === "number" && typeof resp.headers === "object"; | ||
| } | ||
| } | ||
| class HttpProtocol extends SerdeContext { | ||
@@ -129,6 +46,6 @@ options; | ||
| getRequestType() { | ||
| return HttpRequest; | ||
| return transport.HttpRequest; | ||
| } | ||
| getResponseType() { | ||
| return HttpResponse; | ||
| return transport.HttpResponse; | ||
| } | ||
@@ -265,3 +182,3 @@ setSerdeContext(serdeContext) { | ||
| let payload; | ||
| const request = new HttpRequest({ | ||
| const request = new transport.HttpRequest({ | ||
| protocol: "", | ||
@@ -549,3 +466,3 @@ hostname: "", | ||
| const input = _input && typeof _input === "object" ? _input : {}; | ||
| const request = new HttpRequest({ | ||
| const request = new transport.HttpRequest({ | ||
| protocol: "", | ||
@@ -671,3 +588,3 @@ hostname: "", | ||
| } | ||
| return new HttpRequest({ | ||
| return new transport.HttpRequest({ | ||
| protocol, | ||
@@ -1003,7 +920,2 @@ hostname: this.hostname || hostname, | ||
| function isValidHostname(hostname) { | ||
| const hostPattern = /^[a-z0-9][a-z0-9\.\-]*[a-z0-9]$/; | ||
| return hostPattern.test(hostname); | ||
| } | ||
| const getHttpHandlerExtensionConfiguration = (runtimeConfig) => { | ||
@@ -1035,3 +947,3 @@ return { | ||
| const request = args.request; | ||
| if (HttpRequest.isInstance(request)) { | ||
| if (transport.HttpRequest.isInstance(request)) { | ||
| const { body, headers } = request; | ||
@@ -1097,44 +1009,7 @@ if (body && | ||
| function parseQueryString(querystring) { | ||
| const query = {}; | ||
| querystring = querystring.replace(/^\?/, ""); | ||
| if (querystring) { | ||
| for (const pair of querystring.split("&")) { | ||
| let [key, value = null] = pair.split("="); | ||
| key = decodeURIComponent(key); | ||
| if (value) { | ||
| value = decodeURIComponent(value); | ||
| } | ||
| if (!(key in query)) { | ||
| query[key] = value; | ||
| } | ||
| else if (Array.isArray(query[key])) { | ||
| query[key].push(value); | ||
| } | ||
| else { | ||
| query[key] = [query[key], value]; | ||
| } | ||
| } | ||
| } | ||
| return query; | ||
| } | ||
| const parseUrl = (url) => { | ||
| if (typeof url === "string") { | ||
| return parseUrl(new URL(url)); | ||
| } | ||
| const { hostname, pathname, port, protocol, search } = url; | ||
| let query; | ||
| if (search) { | ||
| query = parseQueryString(search); | ||
| } | ||
| return { | ||
| hostname, | ||
| port: port ? parseInt(port) : undefined, | ||
| protocol, | ||
| path: pathname, | ||
| query, | ||
| }; | ||
| }; | ||
| exports.HttpRequest = transport.HttpRequest; | ||
| exports.HttpResponse = transport.HttpResponse; | ||
| exports.isValidHostname = transport.isValidHostname; | ||
| exports.parseQueryString = transport.parseQueryString; | ||
| exports.parseUrl = transport.parseUrl; | ||
| exports.Field = Field; | ||
@@ -1147,4 +1022,2 @@ exports.Fields = Fields; | ||
| exports.HttpProtocol = HttpProtocol; | ||
| exports.HttpRequest = HttpRequest; | ||
| exports.HttpResponse = HttpResponse; | ||
| exports.RequestBuilder = RequestBuilder; | ||
@@ -1164,7 +1037,4 @@ exports.RpcProtocol = RpcProtocol; | ||
| exports.getHttpHandlerExtensionConfiguration = getHttpHandlerExtensionConfiguration; | ||
| exports.isValidHostname = isValidHostname; | ||
| exports.parseQueryString = parseQueryString; | ||
| exports.parseUrl = parseUrl; | ||
| exports.requestBuilder = requestBuilder; | ||
| exports.resolveHttpHandlerRuntimeConfig = resolveHttpHandlerRuntimeConfig; | ||
| exports.resolvedPath = resolvedPath; |
| 'use strict'; | ||
| var client = require('@smithy/core/client'); | ||
| var protocols = require('@smithy/core/protocols'); | ||
| var endpoints = require('@smithy/core/endpoints'); | ||
| var transport = require('@smithy/core/transport'); | ||
@@ -24,3 +22,3 @@ const deref = (schemaRef) => { | ||
| const { response } = await next(args); | ||
| const { operationSchema } = client.getSmithyContext(context); | ||
| const { operationSchema } = transport.getSmithyContext(context); | ||
| const [, ns, n, t, i, o] = operationSchema ?? []; | ||
@@ -63,7 +61,7 @@ try { | ||
| try { | ||
| if (protocols.HttpResponse.isInstance(response)) { | ||
| const { headers = {} } = response; | ||
| if (transport.HttpResponse.isInstance(response)) { | ||
| const { headers = {}, statusCode } = response; | ||
| const headerEntries = Object.entries(headers); | ||
| error.$metadata = { | ||
| httpStatusCode: response.statusCode, | ||
| httpStatusCode: statusCode, | ||
| requestId: findHeader(/^x-[\w-]+-request-?id$/, headerEntries), | ||
@@ -88,6 +86,6 @@ extendedRequestId: findHeader(/^x-[\w-]+-id-2$/, headerEntries), | ||
| const schemaSerializationMiddleware = (config) => (next, context) => async (args) => { | ||
| const { operationSchema } = client.getSmithyContext(context); | ||
| const { operationSchema } = transport.getSmithyContext(context); | ||
| const [, ns, n, t, i, o] = operationSchema ?? []; | ||
| const endpoint = context.endpointV2 | ||
| ? async () => endpoints.toEndpointV1(context.endpointV2) | ||
| ? async () => transport.toEndpointV1(context.endpointV2) | ||
| : config.endpoint; | ||
@@ -94,0 +92,0 @@ const request = await config.protocol.serializeRequest(operation(ns, n, t, i, o), args.input, { |
| 'use strict'; | ||
| var protocols = require('@smithy/core/protocols'); | ||
| var transport = require('@smithy/core/transport'); | ||
| var endpoints = require('@smithy/core/endpoints'); | ||
@@ -915,3 +915,3 @@ | ||
| try { | ||
| if (protocols.HttpResponse.isInstance(response)) { | ||
| if (transport.HttpResponse.isInstance(response)) { | ||
| const { headers = {} } = response; | ||
@@ -918,0 +918,0 @@ const headerEntries = Object.entries(headers); |
@@ -5,3 +5,3 @@ 'use strict'; | ||
| var node_fs = require('node:fs'); | ||
| var protocols = require('@smithy/core/protocols'); | ||
| var transport = require('@smithy/core/transport'); | ||
| var endpoints = require('@smithy/core/endpoints'); | ||
@@ -881,3 +881,3 @@ var node_stream = require('node:stream'); | ||
| try { | ||
| if (protocols.HttpResponse.isInstance(response)) { | ||
| if (transport.HttpResponse.isInstance(response)) { | ||
| const { headers = {} } = response; | ||
@@ -884,0 +884,0 @@ const headerEntries = Object.entries(headers); |
| 'use strict'; | ||
| var protocols = require('@smithy/core/protocols'); | ||
| var transport = require('@smithy/core/transport'); | ||
| var endpoints = require('@smithy/core/endpoints'); | ||
@@ -915,3 +915,3 @@ | ||
| try { | ||
| if (protocols.HttpResponse.isInstance(response)) { | ||
| if (transport.HttpResponse.isInstance(response)) { | ||
| const { headers = {} } = response; | ||
@@ -918,0 +918,0 @@ const headerEntries = Object.entries(headers); |
+6
-6
@@ -1,8 +0,8 @@ | ||
| export * from "./getSmithyContext"; | ||
| export * from "./middleware-http-auth-scheme"; | ||
| export * from "./middleware-http-signing"; | ||
| export { getSmithyContext } from "@smithy/core/transport"; | ||
| export * from "./legacy-root-exports/middleware-http-auth-scheme"; | ||
| export * from "./legacy-root-exports/middleware-http-signing"; | ||
| export * from "./normalizeProvider"; | ||
| export { createPaginator } from "./pagination/createPaginator"; | ||
| export * from "./request-builder/requestBuilder"; | ||
| export { createPaginator } from "./legacy-root-exports/pagination/createPaginator"; | ||
| export { requestBuilder } from "@smithy/core/protocols"; | ||
| export * from "./setFeature"; | ||
| export * from "./util-identity-and-auth"; | ||
| export * from "./legacy-root-exports/util-identity-and-auth"; |
| export { constructStack } from "./middleware-stack/MiddlewareStack"; | ||
| export { getSmithyContext } from "./util-middleware/getSmithyContext"; | ||
| export { normalizeProvider } from "./util-middleware/normalizeProvider"; | ||
| export { getSmithyContext } from "@smithy/core/transport"; | ||
| export { normalizeProvider } from "@smithy/core/transport"; | ||
| export { invalidFunction } from "./invalid-dependency/invalidFunction"; | ||
@@ -5,0 +5,0 @@ export { invalidProvider } from "./invalid-dependency/invalidProvider"; |
@@ -1,2 +0,2 @@ | ||
| import { isValidHostLabel } from "@smithy/core/endpoints"; | ||
| import { isValidHostLabel } from "@smithy/core/transport"; | ||
| const validRegions = new Set(); | ||
@@ -3,0 +3,0 @@ export const checkRegion = (region, check = isValidHostLabel) => { |
@@ -6,3 +6,3 @@ import { getEndpointFromConfig } from "./middleware-endpoint/adaptors/getEndpointFromConfig.browser"; | ||
| import { bindResolveEndpointConfig } from "./middleware-endpoint/resolveEndpointConfig"; | ||
| export * from "./toEndpointV1"; | ||
| export { toEndpointV1 } from "@smithy/core/transport"; | ||
| export { BinaryDecisionDiagram } from "./util-endpoints/bdd/BinaryDecisionDiagram"; | ||
@@ -12,3 +12,3 @@ export { EndpointCache } from "./util-endpoints/cache/EndpointCache"; | ||
| export { isIpAddress } from "./util-endpoints/lib/isIpAddress"; | ||
| export { isValidHostLabel } from "./util-endpoints/lib/isValidHostLabel"; | ||
| export { isValidHostLabel } from "@smithy/core/transport"; | ||
| export { customEndpointFunctions } from "./util-endpoints/utils/customEndpointFunctions"; | ||
@@ -15,0 +15,0 @@ export { resolveEndpoint } from "./util-endpoints/resolveEndpoint"; |
@@ -6,3 +6,3 @@ import { getEndpointFromConfig } from "./middleware-endpoint/adaptors/getEndpointFromConfig"; | ||
| import { bindResolveEndpointConfig } from "./middleware-endpoint/resolveEndpointConfig"; | ||
| export * from "./toEndpointV1"; | ||
| export { toEndpointV1 } from "@smithy/core/transport"; | ||
| export { BinaryDecisionDiagram } from "./util-endpoints/bdd/BinaryDecisionDiagram"; | ||
@@ -12,3 +12,3 @@ export { EndpointCache } from "./util-endpoints/cache/EndpointCache"; | ||
| export { isIpAddress } from "./util-endpoints/lib/isIpAddress"; | ||
| export { isValidHostLabel } from "./util-endpoints/lib/isValidHostLabel"; | ||
| export { isValidHostLabel } from "@smithy/core/transport"; | ||
| export { customEndpointFunctions } from "./util-endpoints/utils/customEndpointFunctions"; | ||
@@ -15,0 +15,0 @@ export { resolveEndpoint } from "./util-endpoints/resolveEndpoint"; |
@@ -1,1 +0,1 @@ | ||
| export { toEndpointV1 } from "../../toEndpointV1"; | ||
| export { toEndpointV1 } from "@smithy/core/transport"; |
@@ -1,2 +0,2 @@ | ||
| import { normalizeProvider } from "@smithy/core/client"; | ||
| import { normalizeProvider } from "@smithy/core/transport"; | ||
| import { toEndpointV1 } from "./adaptors/toEndpointV1"; | ||
@@ -3,0 +3,0 @@ export function bindResolveEndpointConfig(getEndpointFromConfig) { |
@@ -5,3 +5,3 @@ export * from "./booleanEquals"; | ||
| export * from "./isSet"; | ||
| export * from "./isValidHostLabel"; | ||
| export { isValidHostLabel } from "@smithy/core/transport"; | ||
| export * from "./ite"; | ||
@@ -8,0 +8,0 @@ export * from "./not"; |
| import { NormalizedSchema, translateTraits } from "@smithy/core/schema"; | ||
| import { sdkStreamMixin, splitEvery, splitHeader } from "@smithy/core/serde"; | ||
| import { HttpRequest } from "@smithy/core/transport"; | ||
| import { HttpProtocol } from "./HttpProtocol"; | ||
| import { collectBody } from "./collect-stream-body"; | ||
| import { extendedEncodeURIComponent } from "./extended-encode-uri-component"; | ||
| import { HttpRequest } from "./protocol-http/httpRequest"; | ||
| export class HttpBindingProtocol extends HttpProtocol { | ||
@@ -8,0 +8,0 @@ async serializeRequest(operationSchema, _input, context) { |
| import { NormalizedSchema, TypeRegistry, translateTraits } from "@smithy/core/schema"; | ||
| import { HttpRequest, HttpResponse } from "@smithy/core/transport"; | ||
| import { SerdeContext } from "./SerdeContext"; | ||
| import { HttpRequest } from "./protocol-http/httpRequest"; | ||
| import { HttpResponse } from "./protocol-http/httpResponse"; | ||
| export class HttpProtocol extends SerdeContext { | ||
@@ -6,0 +5,0 @@ options; |
@@ -16,5 +16,5 @@ export * from "./collect-stream-body"; | ||
| export { Fields } from "./protocol-http/Fields"; | ||
| export { HttpRequest } from "./protocol-http/httpRequest"; | ||
| export { HttpResponse } from "./protocol-http/httpResponse"; | ||
| export { isValidHostname } from "./protocol-http/isValidHostname"; | ||
| export { HttpRequest } from "@smithy/core/transport"; | ||
| export { HttpResponse } from "@smithy/core/transport"; | ||
| export { isValidHostname } from "@smithy/core/transport"; | ||
| export { getHttpHandlerExtensionConfiguration, resolveHttpHandlerRuntimeConfig, } from "./protocol-http/extensions/httpExtensionConfiguration"; | ||
@@ -25,3 +25,3 @@ export { contentLengthMiddleware, contentLengthMiddlewareOptions, getContentLengthPlugin, } from "./middleware-content-length/contentLengthMiddleware"; | ||
| export { buildQueryString } from "./querystring-builder/buildQueryString"; | ||
| export { parseQueryString } from "./querystring-parser/parseQueryString"; | ||
| export { parseUrl } from "./url-parser/parseUrl"; | ||
| export { parseQueryString } from "@smithy/core/transport"; | ||
| export { parseUrl } from "@smithy/core/transport"; |
@@ -1,2 +0,2 @@ | ||
| import { HttpRequest } from "../protocol-http/httpRequest"; | ||
| import { HttpRequest } from "@smithy/core/transport"; | ||
| const CONTENT_LENGTH_HEADER = "content-length"; | ||
@@ -3,0 +3,0 @@ export function contentLengthMiddleware(bodyLengthChecker) { |
@@ -1,2 +0,2 @@ | ||
| import { HttpRequest } from "./protocol-http/httpRequest"; | ||
| import { HttpRequest } from "@smithy/core/transport"; | ||
| import { resolvedPath } from "./resolve-path"; | ||
@@ -3,0 +3,0 @@ export function requestBuilder(input, context) { |
| import { NormalizedSchema } from "@smithy/core/schema"; | ||
| import { HttpRequest } from "@smithy/core/transport"; | ||
| import { HttpProtocol } from "./HttpProtocol"; | ||
| import { collectBody } from "./collect-stream-body"; | ||
| import { HttpRequest } from "./protocol-http/httpRequest"; | ||
| export class RpcProtocol extends HttpProtocol { | ||
@@ -6,0 +6,0 @@ async serializeRequest(operationSchema, _input, context) { |
@@ -1,3 +0,2 @@ | ||
| import { getSmithyContext } from "@smithy/core/client"; | ||
| import { HttpResponse } from "@smithy/core/protocols"; | ||
| import { HttpResponse, getSmithyContext } from "@smithy/core/transport"; | ||
| import { operation } from "../schemas/operation"; | ||
@@ -45,6 +44,6 @@ export const schemaDeserializationMiddleware = (config) => (next, context) => async (args) => { | ||
| if (HttpResponse.isInstance(response)) { | ||
| const { headers = {} } = response; | ||
| const { headers = {}, statusCode } = response; | ||
| const headerEntries = Object.entries(headers); | ||
| error.$metadata = { | ||
| httpStatusCode: response.statusCode, | ||
| httpStatusCode: statusCode, | ||
| requestId: findHeader(/^x-[\w-]+-request-?id$/, headerEntries), | ||
@@ -51,0 +50,0 @@ extendedRequestId: findHeader(/^x-[\w-]+-id-2$/, headerEntries), |
@@ -1,3 +0,2 @@ | ||
| import { getSmithyContext } from "@smithy/core/client"; | ||
| import { toEndpointV1 } from "@smithy/core/endpoints"; | ||
| import { getSmithyContext, toEndpointV1 } from "@smithy/core/transport"; | ||
| import { operation } from "../schemas/operation"; | ||
@@ -4,0 +3,0 @@ export const schemaSerializationMiddleware = (config) => (next, context) => async (args) => { |
@@ -1,2 +0,2 @@ | ||
| import { HttpResponse } from "@smithy/core/protocols"; | ||
| import { HttpResponse } from "@smithy/core/transport"; | ||
| export const deserializerMiddleware = (options, deserializer) => (next, context) => async (args) => { | ||
@@ -3,0 +3,0 @@ const { response } = await next(args); |
@@ -1,8 +0,12 @@ | ||
| export * from "./getSmithyContext"; | ||
| export * from "./middleware-http-auth-scheme"; | ||
| export * from "./middleware-http-signing"; | ||
| export { getSmithyContext } from "@smithy/core/transport"; | ||
| export * from "./legacy-root-exports/middleware-http-auth-scheme"; | ||
| export * from "./legacy-root-exports/middleware-http-signing"; | ||
| export * from "./normalizeProvider"; | ||
| export { createPaginator } from "./pagination/createPaginator"; | ||
| export * from "./request-builder/requestBuilder"; | ||
| export { createPaginator } from "./legacy-root-exports/pagination/createPaginator"; | ||
| /** | ||
| * Backwards compatibility re-export. | ||
| * @internal | ||
| */ | ||
| export { requestBuilder } from "@smithy/core/protocols"; | ||
| export * from "./setFeature"; | ||
| export * from "./util-identity-and-auth"; | ||
| export * from "./legacy-root-exports/util-identity-and-auth"; |
| export { constructStack } from "./middleware-stack/MiddlewareStack"; | ||
| export { getSmithyContext } from "./util-middleware/getSmithyContext"; | ||
| export { normalizeProvider } from "./util-middleware/normalizeProvider"; | ||
| export { getSmithyContext } from "@smithy/core/transport"; | ||
| export { normalizeProvider } from "@smithy/core/transport"; | ||
| export { invalidFunction } from "./invalid-dependency/invalidFunction"; | ||
@@ -5,0 +5,0 @@ export { invalidProvider } from "./invalid-dependency/invalidProvider"; |
@@ -1,2 +0,2 @@ | ||
| export * from "./toEndpointV1"; | ||
| export { toEndpointV1 } from "@smithy/core/transport"; | ||
| export { BinaryDecisionDiagram } from "./util-endpoints/bdd/BinaryDecisionDiagram"; | ||
@@ -6,3 +6,3 @@ export { EndpointCache } from "./util-endpoints/cache/EndpointCache"; | ||
| export { isIpAddress } from "./util-endpoints/lib/isIpAddress"; | ||
| export { isValidHostLabel } from "./util-endpoints/lib/isValidHostLabel"; | ||
| export { isValidHostLabel } from "@smithy/core/transport"; | ||
| export { customEndpointFunctions } from "./util-endpoints/utils/customEndpointFunctions"; | ||
@@ -9,0 +9,0 @@ export { resolveEndpoint } from "./util-endpoints/resolveEndpoint"; |
@@ -1,2 +0,2 @@ | ||
| export * from "./toEndpointV1"; | ||
| export { toEndpointV1 } from "@smithy/core/transport"; | ||
| export { BinaryDecisionDiagram } from "./util-endpoints/bdd/BinaryDecisionDiagram"; | ||
@@ -6,3 +6,3 @@ export { EndpointCache } from "./util-endpoints/cache/EndpointCache"; | ||
| export { isIpAddress } from "./util-endpoints/lib/isIpAddress"; | ||
| export { isValidHostLabel } from "./util-endpoints/lib/isValidHostLabel"; | ||
| export { isValidHostLabel } from "@smithy/core/transport"; | ||
| export { customEndpointFunctions } from "./util-endpoints/utils/customEndpointFunctions"; | ||
@@ -9,0 +9,0 @@ export { resolveEndpoint } from "./util-endpoints/resolveEndpoint"; |
| /** | ||
| * @deprecated Use `toEndpointV1` from `@smithy/core/endpoints` instead. | ||
| * @deprecated Use `toEndpointV1` from `@smithy/core/transport` instead. | ||
| * @internal | ||
| */ | ||
| export { toEndpointV1 } from "../../toEndpointV1"; | ||
| export { toEndpointV1 } from "@smithy/core/transport"; |
@@ -5,3 +5,3 @@ export * from "./booleanEquals"; | ||
| export * from "./isSet"; | ||
| export * from "./isValidHostLabel"; | ||
| export { isValidHostLabel } from "@smithy/core/transport"; | ||
| export * from "./ite"; | ||
@@ -8,0 +8,0 @@ export * from "./not"; |
| import { NormalizedSchema, type TypeRegistry } from "@smithy/core/schema"; | ||
| import { HttpRequest } from "@smithy/core/transport"; | ||
| import type { EndpointBearer, HandlerExecutionContext, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, MetadataBearer, OperationSchema, Schema, SerdeFunctions } from "@smithy/types"; | ||
| import { HttpProtocol } from "./HttpProtocol"; | ||
| import { HttpRequest } from "./protocol-http/httpRequest"; | ||
| /** | ||
@@ -6,0 +6,0 @@ * Base for HTTP-binding protocols. Downstream examples |
@@ -17,5 +17,5 @@ export * from "./collect-stream-body"; | ||
| export { type HttpHandler, type HttpHandlerUserInput } from "./protocol-http/httpHandler"; | ||
| export { HttpRequest, type IHttpRequest } from "./protocol-http/httpRequest"; | ||
| export { HttpResponse } from "./protocol-http/httpResponse"; | ||
| export { isValidHostname } from "./protocol-http/isValidHostname"; | ||
| export { HttpRequest, type IHttpRequest } from "@smithy/core/transport"; | ||
| export { HttpResponse } from "@smithy/core/transport"; | ||
| export { isValidHostname } from "@smithy/core/transport"; | ||
| export { getHttpHandlerExtensionConfiguration, resolveHttpHandlerRuntimeConfig, type HttpHandlerExtensionConfiguration, type HttpHandlerExtensionConfigType, } from "./protocol-http/extensions/httpExtensionConfiguration"; | ||
@@ -27,3 +27,3 @@ export { type FieldOptions, type FieldPosition, type HeaderBag, type HttpMessage, type HttpHandlerOptions, } from "./protocol-http/types"; | ||
| export { buildQueryString } from "./querystring-builder/buildQueryString"; | ||
| export { parseQueryString } from "./querystring-parser/parseQueryString"; | ||
| export { parseUrl } from "./url-parser/parseUrl"; | ||
| export { parseQueryString } from "@smithy/core/transport"; | ||
| export { parseUrl } from "@smithy/core/transport"; |
@@ -0,4 +1,3 @@ | ||
| import type { HttpRequest, HttpResponse } from "@smithy/core/transport"; | ||
| import type { FetchHttpHandlerOptions, HttpHandlerOptions, NodeHttpHandlerOptions, RequestHandler } from "@smithy/types"; | ||
| import type { HttpRequest } from "./httpRequest"; | ||
| import type { HttpResponse } from "./httpResponse"; | ||
| /** | ||
@@ -5,0 +4,0 @@ * @internal |
@@ -0,3 +1,3 @@ | ||
| import { HttpRequest } from "@smithy/core/transport"; | ||
| import type { SerdeContext } from "@smithy/types"; | ||
| import { HttpRequest } from "./protocol-http/httpRequest"; | ||
| /** | ||
@@ -4,0 +4,0 @@ * used in code-generated serde. |
+19
-10
| { | ||
| "name": "@smithy/core", | ||
| "version": "3.24.4", | ||
| "version": "3.24.5", | ||
| "scripts": { | ||
@@ -154,2 +154,9 @@ "build": "concurrently 'yarn:build:types' 'yarn:build:es:cjs'", | ||
| "require": "./dist-cjs/submodules/retry/index.js" | ||
| }, | ||
| "./transport": { | ||
| "types": "./dist-types/submodules/transport/index.d.ts", | ||
| "module": "./dist-es/submodules/transport/index.js", | ||
| "node": "./dist-cjs/submodules/transport/index.js", | ||
| "import": "./dist-es/submodules/transport/index.js", | ||
| "require": "./dist-cjs/submodules/transport/index.js" | ||
| } | ||
@@ -182,2 +189,8 @@ }, | ||
| "./cbor.js", | ||
| "./checksum.d.ts", | ||
| "./checksum.js", | ||
| "./client.d.ts", | ||
| "./client.js", | ||
| "./config.d.ts", | ||
| "./config.js", | ||
| "./endpoints.d.ts", | ||
@@ -189,2 +202,4 @@ "./endpoints.js", | ||
| "./protocols.js", | ||
| "./retry.d.ts", | ||
| "./retry.js", | ||
| "./schema.d.ts", | ||
@@ -194,11 +209,5 @@ "./schema.js", | ||
| "./serde.js", | ||
| "dist-*/**", | ||
| "./client.d.ts", | ||
| "./client.js", | ||
| "./config.d.ts", | ||
| "./config.js", | ||
| "./checksum.d.ts", | ||
| "./checksum.js", | ||
| "./retry.d.ts", | ||
| "./retry.js" | ||
| "./transport.d.ts", | ||
| "./transport.js", | ||
| "dist-*/**" | ||
| ], | ||
@@ -205,0 +214,0 @@ "homepage": "https://github.com/smithy-lang/smithy-typescript/tree/main/packages/core", |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.getSmithyContext = void 0; | ||
| const types_1 = require("@smithy/types"); | ||
| const getSmithyContext = (context) => context[types_1.SMITHY_CONTEXT_KEY] || (context[types_1.SMITHY_CONTEXT_KEY] = {}); | ||
| exports.getSmithyContext = getSmithyContext; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.getHttpAuthSchemeEndpointRuleSetPlugin = exports.httpAuthSchemeEndpointRuleSetMiddlewareOptions = void 0; | ||
| const httpAuthSchemeMiddleware_1 = require("./httpAuthSchemeMiddleware"); | ||
| exports.httpAuthSchemeEndpointRuleSetMiddlewareOptions = { | ||
| step: "serialize", | ||
| tags: ["HTTP_AUTH_SCHEME"], | ||
| name: "httpAuthSchemeMiddleware", | ||
| override: true, | ||
| relation: "before", | ||
| toMiddleware: "endpointV2Middleware", | ||
| }; | ||
| const getHttpAuthSchemeEndpointRuleSetPlugin = (config, { httpAuthSchemeParametersProvider, identityProviderConfigProvider, }) => ({ | ||
| applyToStack: (clientStack) => { | ||
| clientStack.addRelativeTo((0, httpAuthSchemeMiddleware_1.httpAuthSchemeMiddleware)(config, { | ||
| httpAuthSchemeParametersProvider, | ||
| identityProviderConfigProvider, | ||
| }), exports.httpAuthSchemeEndpointRuleSetMiddlewareOptions); | ||
| }, | ||
| }); | ||
| exports.getHttpAuthSchemeEndpointRuleSetPlugin = getHttpAuthSchemeEndpointRuleSetPlugin; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.getHttpAuthSchemePlugin = exports.httpAuthSchemeMiddlewareOptions = void 0; | ||
| const httpAuthSchemeMiddleware_1 = require("./httpAuthSchemeMiddleware"); | ||
| exports.httpAuthSchemeMiddlewareOptions = { | ||
| step: "serialize", | ||
| tags: ["HTTP_AUTH_SCHEME"], | ||
| name: "httpAuthSchemeMiddleware", | ||
| override: true, | ||
| relation: "before", | ||
| toMiddleware: "serializerMiddleware", | ||
| }; | ||
| const getHttpAuthSchemePlugin = (config, { httpAuthSchemeParametersProvider, identityProviderConfigProvider, }) => ({ | ||
| applyToStack: (clientStack) => { | ||
| clientStack.addRelativeTo((0, httpAuthSchemeMiddleware_1.httpAuthSchemeMiddleware)(config, { | ||
| httpAuthSchemeParametersProvider, | ||
| identityProviderConfigProvider, | ||
| }), exports.httpAuthSchemeMiddlewareOptions); | ||
| }, | ||
| }); | ||
| exports.getHttpAuthSchemePlugin = getHttpAuthSchemePlugin; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.httpAuthSchemeMiddleware = void 0; | ||
| const client_1 = require("@smithy/core/client"); | ||
| const resolveAuthOptions_1 = require("./resolveAuthOptions"); | ||
| function convertHttpAuthSchemesToMap(httpAuthSchemes) { | ||
| const map = new Map(); | ||
| for (const scheme of httpAuthSchemes) { | ||
| map.set(scheme.schemeId, scheme); | ||
| } | ||
| return map; | ||
| } | ||
| const httpAuthSchemeMiddleware = (config, mwOptions) => (next, context) => async (args) => { | ||
| const options = config.httpAuthSchemeProvider(await mwOptions.httpAuthSchemeParametersProvider(config, context, args.input)); | ||
| const authSchemePreference = config.authSchemePreference ? await config.authSchemePreference() : []; | ||
| const resolvedOptions = (0, resolveAuthOptions_1.resolveAuthOptions)(options, authSchemePreference); | ||
| const authSchemes = convertHttpAuthSchemesToMap(config.httpAuthSchemes); | ||
| const smithyContext = (0, client_1.getSmithyContext)(context); | ||
| const failureReasons = []; | ||
| for (const option of resolvedOptions) { | ||
| const scheme = authSchemes.get(option.schemeId); | ||
| if (!scheme) { | ||
| failureReasons.push(`HttpAuthScheme \`${option.schemeId}\` was not enabled for this service.`); | ||
| continue; | ||
| } | ||
| const identityProvider = scheme.identityProvider(await mwOptions.identityProviderConfigProvider(config)); | ||
| if (!identityProvider) { | ||
| failureReasons.push(`HttpAuthScheme \`${option.schemeId}\` did not have an IdentityProvider configured.`); | ||
| continue; | ||
| } | ||
| const { identityProperties = {}, signingProperties = {} } = option.propertiesExtractor?.(config, context) || {}; | ||
| option.identityProperties = Object.assign(option.identityProperties || {}, identityProperties); | ||
| option.signingProperties = Object.assign(option.signingProperties || {}, signingProperties); | ||
| smithyContext.selectedHttpAuthScheme = { | ||
| httpAuthOption: option, | ||
| identity: await identityProvider(option.identityProperties), | ||
| signer: scheme.signer, | ||
| }; | ||
| break; | ||
| } | ||
| if (!smithyContext.selectedHttpAuthScheme) { | ||
| throw new Error(failureReasons.join("\n")); | ||
| } | ||
| return next(args); | ||
| }; | ||
| exports.httpAuthSchemeMiddleware = httpAuthSchemeMiddleware; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const tslib_1 = require("tslib"); | ||
| tslib_1.__exportStar(require("./httpAuthSchemeMiddleware"), exports); | ||
| tslib_1.__exportStar(require("./getHttpAuthSchemeEndpointRuleSetPlugin"), exports); | ||
| tslib_1.__exportStar(require("./getHttpAuthSchemePlugin"), exports); |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.resolveAuthOptions = void 0; | ||
| const resolveAuthOptions = (candidateAuthOptions, authSchemePreference) => { | ||
| if (!authSchemePreference || authSchemePreference.length === 0) { | ||
| return candidateAuthOptions; | ||
| } | ||
| const preferredAuthOptions = []; | ||
| for (const preferredSchemeName of authSchemePreference) { | ||
| for (const candidateAuthOption of candidateAuthOptions) { | ||
| const candidateAuthSchemeName = candidateAuthOption.schemeId.split("#")[1]; | ||
| if (candidateAuthSchemeName === preferredSchemeName) { | ||
| preferredAuthOptions.push(candidateAuthOption); | ||
| } | ||
| } | ||
| } | ||
| for (const candidateAuthOption of candidateAuthOptions) { | ||
| if (!preferredAuthOptions.find(({ schemeId }) => schemeId === candidateAuthOption.schemeId)) { | ||
| preferredAuthOptions.push(candidateAuthOption); | ||
| } | ||
| } | ||
| return preferredAuthOptions; | ||
| }; | ||
| exports.resolveAuthOptions = resolveAuthOptions; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.getHttpSigningPlugin = exports.httpSigningMiddlewareOptions = void 0; | ||
| const httpSigningMiddleware_1 = require("./httpSigningMiddleware"); | ||
| exports.httpSigningMiddlewareOptions = { | ||
| step: "finalizeRequest", | ||
| tags: ["HTTP_SIGNING"], | ||
| name: "httpSigningMiddleware", | ||
| aliases: ["apiKeyMiddleware", "tokenMiddleware", "awsAuthMiddleware"], | ||
| override: true, | ||
| relation: "after", | ||
| toMiddleware: "retryMiddleware", | ||
| }; | ||
| const getHttpSigningPlugin = (config) => ({ | ||
| applyToStack: (clientStack) => { | ||
| clientStack.addRelativeTo((0, httpSigningMiddleware_1.httpSigningMiddleware)(config), exports.httpSigningMiddlewareOptions); | ||
| }, | ||
| }); | ||
| exports.getHttpSigningPlugin = getHttpSigningPlugin; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.httpSigningMiddleware = void 0; | ||
| const client_1 = require("@smithy/core/client"); | ||
| const protocols_1 = require("@smithy/core/protocols"); | ||
| const defaultErrorHandler = (signingProperties) => (error) => { | ||
| throw error; | ||
| }; | ||
| const defaultSuccessHandler = (httpResponse, signingProperties) => { }; | ||
| const httpSigningMiddleware = (config) => (next, context) => async (args) => { | ||
| if (!protocols_1.HttpRequest.isInstance(args.request)) { | ||
| return next(args); | ||
| } | ||
| const smithyContext = (0, client_1.getSmithyContext)(context); | ||
| const scheme = smithyContext.selectedHttpAuthScheme; | ||
| if (!scheme) { | ||
| throw new Error(`No HttpAuthScheme was selected: unable to sign request`); | ||
| } | ||
| const { httpAuthOption: { signingProperties = {} }, identity, signer, } = scheme; | ||
| const output = await next({ | ||
| ...args, | ||
| request: await signer.sign(args.request, identity, signingProperties), | ||
| }).catch((signer.errorHandler || defaultErrorHandler)(signingProperties)); | ||
| (signer.successHandler || defaultSuccessHandler)(output.response, signingProperties); | ||
| return output; | ||
| }; | ||
| exports.httpSigningMiddleware = httpSigningMiddleware; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const tslib_1 = require("tslib"); | ||
| tslib_1.__exportStar(require("./httpSigningMiddleware"), exports); | ||
| tslib_1.__exportStar(require("./getHttpSigningMiddleware"), exports); |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.normalizeProvider = void 0; | ||
| const normalizeProvider = (input) => { | ||
| if (typeof input === "function") | ||
| return input; | ||
| const promisified = Promise.resolve(input); | ||
| return () => promisified; | ||
| }; | ||
| exports.normalizeProvider = normalizeProvider; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.createPaginator = createPaginator; | ||
| const makePagedClientRequest = async (CommandCtor, client, input, withCommand = (_) => _, ...args) => { | ||
| let command = new CommandCtor(input); | ||
| command = withCommand(command) ?? command; | ||
| return await client.send(command, ...args); | ||
| }; | ||
| function createPaginator(ClientCtor, CommandCtor, inputTokenName, outputTokenName, pageSizeTokenName) { | ||
| return async function* paginateOperation(config, input, ...additionalArguments) { | ||
| const _input = input; | ||
| let token = config.startingToken ?? _input[inputTokenName]; | ||
| let hasNext = true; | ||
| let page; | ||
| while (hasNext) { | ||
| _input[inputTokenName] = token; | ||
| if (pageSizeTokenName) { | ||
| _input[pageSizeTokenName] = _input[pageSizeTokenName] ?? config.pageSize; | ||
| } | ||
| if (config.client instanceof ClientCtor) { | ||
| page = await makePagedClientRequest(CommandCtor, config.client, input, config.withCommand, ...additionalArguments); | ||
| } | ||
| else { | ||
| throw new Error(`Invalid client, expected instance of ${ClientCtor.name}`); | ||
| } | ||
| yield page; | ||
| const prevToken = token; | ||
| token = get(page, outputTokenName); | ||
| hasNext = !!(token && (!config.stopOnSameToken || token !== prevToken)); | ||
| } | ||
| return undefined; | ||
| }; | ||
| } | ||
| const get = (fromObject, path) => { | ||
| let cursor = fromObject; | ||
| const pathComponents = path.split("."); | ||
| for (const step of pathComponents) { | ||
| if (!cursor || typeof cursor !== "object") { | ||
| return undefined; | ||
| } | ||
| cursor = cursor[step]; | ||
| } | ||
| return cursor; | ||
| }; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.requestBuilder = void 0; | ||
| var protocols_1 = require("@smithy/core/protocols"); | ||
| Object.defineProperty(exports, "requestBuilder", { enumerable: true, get: function () { return protocols_1.requestBuilder; } }); |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.setFeature = setFeature; | ||
| function setFeature(context, feature, value) { | ||
| if (!context.__smithy_context) { | ||
| context.__smithy_context = { | ||
| features: {}, | ||
| }; | ||
| } | ||
| else if (!context.__smithy_context.features) { | ||
| context.__smithy_context.features = {}; | ||
| } | ||
| context.__smithy_context.features[feature] = value; | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.DefaultIdentityProviderConfig = void 0; | ||
| class DefaultIdentityProviderConfig { | ||
| authSchemes = new Map(); | ||
| constructor(config) { | ||
| for (const key in config) { | ||
| const value = config[key]; | ||
| if (value !== undefined) { | ||
| this.authSchemes.set(key, value); | ||
| } | ||
| } | ||
| } | ||
| getIdentityProvider(schemeId) { | ||
| return this.authSchemes.get(schemeId); | ||
| } | ||
| } | ||
| exports.DefaultIdentityProviderConfig = DefaultIdentityProviderConfig; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.HttpApiKeyAuthSigner = void 0; | ||
| const protocols_1 = require("@smithy/core/protocols"); | ||
| const types_1 = require("@smithy/types"); | ||
| class HttpApiKeyAuthSigner { | ||
| async sign(httpRequest, identity, signingProperties) { | ||
| if (!signingProperties) { | ||
| throw new Error("request could not be signed with `apiKey` since the `name` and `in` signer properties are missing"); | ||
| } | ||
| if (!signingProperties.name) { | ||
| throw new Error("request could not be signed with `apiKey` since the `name` signer property is missing"); | ||
| } | ||
| if (!signingProperties.in) { | ||
| throw new Error("request could not be signed with `apiKey` since the `in` signer property is missing"); | ||
| } | ||
| if (!identity.apiKey) { | ||
| throw new Error("request could not be signed with `apiKey` since the `apiKey` is not defined"); | ||
| } | ||
| const clonedRequest = protocols_1.HttpRequest.clone(httpRequest); | ||
| if (signingProperties.in === types_1.HttpApiKeyAuthLocation.QUERY) { | ||
| clonedRequest.query[signingProperties.name] = identity.apiKey; | ||
| } | ||
| else if (signingProperties.in === types_1.HttpApiKeyAuthLocation.HEADER) { | ||
| clonedRequest.headers[signingProperties.name] = signingProperties.scheme | ||
| ? `${signingProperties.scheme} ${identity.apiKey}` | ||
| : identity.apiKey; | ||
| } | ||
| else { | ||
| throw new Error("request can only be signed with `apiKey` locations `query` or `header`, " + | ||
| "but found: `" + | ||
| signingProperties.in + | ||
| "`"); | ||
| } | ||
| return clonedRequest; | ||
| } | ||
| } | ||
| exports.HttpApiKeyAuthSigner = HttpApiKeyAuthSigner; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.HttpBearerAuthSigner = void 0; | ||
| const protocols_1 = require("@smithy/core/protocols"); | ||
| class HttpBearerAuthSigner { | ||
| async sign(httpRequest, identity, signingProperties) { | ||
| const clonedRequest = protocols_1.HttpRequest.clone(httpRequest); | ||
| if (!identity.token) { | ||
| throw new Error("request could not be signed with `token` since the `token` is not defined"); | ||
| } | ||
| clonedRequest.headers["Authorization"] = `Bearer ${identity.token}`; | ||
| return clonedRequest; | ||
| } | ||
| } | ||
| exports.HttpBearerAuthSigner = HttpBearerAuthSigner; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const tslib_1 = require("tslib"); | ||
| tslib_1.__exportStar(require("./httpApiKeyAuth"), exports); | ||
| tslib_1.__exportStar(require("./httpBearerAuth"), exports); | ||
| tslib_1.__exportStar(require("./noAuth"), exports); |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.NoAuthSigner = void 0; | ||
| class NoAuthSigner { | ||
| async sign(httpRequest, identity, signingProperties) { | ||
| return httpRequest; | ||
| } | ||
| } | ||
| exports.NoAuthSigner = NoAuthSigner; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const tslib_1 = require("tslib"); | ||
| tslib_1.__exportStar(require("./DefaultIdentityProviderConfig"), exports); | ||
| tslib_1.__exportStar(require("./httpAuthSchemes"), exports); | ||
| tslib_1.__exportStar(require("./memoizeIdentityProvider"), exports); |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.memoizeIdentityProvider = exports.doesIdentityRequireRefresh = exports.isIdentityExpired = exports.EXPIRATION_MS = exports.createIsIdentityExpiredFunction = void 0; | ||
| const createIsIdentityExpiredFunction = (expirationMs) => function isIdentityExpired(identity) { | ||
| return (0, exports.doesIdentityRequireRefresh)(identity) && identity.expiration.getTime() - Date.now() < expirationMs; | ||
| }; | ||
| exports.createIsIdentityExpiredFunction = createIsIdentityExpiredFunction; | ||
| exports.EXPIRATION_MS = 300_000; | ||
| exports.isIdentityExpired = (0, exports.createIsIdentityExpiredFunction)(exports.EXPIRATION_MS); | ||
| const doesIdentityRequireRefresh = (identity) => identity.expiration !== undefined; | ||
| exports.doesIdentityRequireRefresh = doesIdentityRequireRefresh; | ||
| const memoizeIdentityProvider = (provider, isExpired, requiresRefresh) => { | ||
| if (provider === undefined) { | ||
| return undefined; | ||
| } | ||
| const normalizedProvider = typeof provider !== "function" ? async () => Promise.resolve(provider) : provider; | ||
| let resolved; | ||
| let pending; | ||
| let hasResult; | ||
| let isConstant = false; | ||
| const coalesceProvider = async (options) => { | ||
| if (!pending) { | ||
| pending = normalizedProvider(options); | ||
| } | ||
| try { | ||
| resolved = await pending; | ||
| hasResult = true; | ||
| isConstant = false; | ||
| } | ||
| finally { | ||
| pending = undefined; | ||
| } | ||
| return resolved; | ||
| }; | ||
| if (isExpired === undefined) { | ||
| return async (options) => { | ||
| if (!hasResult || options?.forceRefresh) { | ||
| resolved = await coalesceProvider(options); | ||
| } | ||
| return resolved; | ||
| }; | ||
| } | ||
| return async (options) => { | ||
| if (!hasResult || options?.forceRefresh) { | ||
| resolved = await coalesceProvider(options); | ||
| } | ||
| if (isConstant) { | ||
| return resolved; | ||
| } | ||
| if (!requiresRefresh(resolved)) { | ||
| isConstant = true; | ||
| return resolved; | ||
| } | ||
| if (isExpired(resolved)) { | ||
| await coalesceProvider(options); | ||
| return resolved; | ||
| } | ||
| return resolved; | ||
| }; | ||
| }; | ||
| exports.memoizeIdentityProvider = memoizeIdentityProvider; |
| import { SMITHY_CONTEXT_KEY } from "@smithy/types"; | ||
| export const getSmithyContext = (context) => context[SMITHY_CONTEXT_KEY] || (context[SMITHY_CONTEXT_KEY] = {}); |
| import { httpAuthSchemeMiddleware } from "./httpAuthSchemeMiddleware"; | ||
| export const httpAuthSchemeEndpointRuleSetMiddlewareOptions = { | ||
| step: "serialize", | ||
| tags: ["HTTP_AUTH_SCHEME"], | ||
| name: "httpAuthSchemeMiddleware", | ||
| override: true, | ||
| relation: "before", | ||
| toMiddleware: "endpointV2Middleware", | ||
| }; | ||
| export const getHttpAuthSchemeEndpointRuleSetPlugin = (config, { httpAuthSchemeParametersProvider, identityProviderConfigProvider, }) => ({ | ||
| applyToStack: (clientStack) => { | ||
| clientStack.addRelativeTo(httpAuthSchemeMiddleware(config, { | ||
| httpAuthSchemeParametersProvider, | ||
| identityProviderConfigProvider, | ||
| }), httpAuthSchemeEndpointRuleSetMiddlewareOptions); | ||
| }, | ||
| }); |
| import { httpAuthSchemeMiddleware } from "./httpAuthSchemeMiddleware"; | ||
| export const httpAuthSchemeMiddlewareOptions = { | ||
| step: "serialize", | ||
| tags: ["HTTP_AUTH_SCHEME"], | ||
| name: "httpAuthSchemeMiddleware", | ||
| override: true, | ||
| relation: "before", | ||
| toMiddleware: "serializerMiddleware", | ||
| }; | ||
| export const getHttpAuthSchemePlugin = (config, { httpAuthSchemeParametersProvider, identityProviderConfigProvider, }) => ({ | ||
| applyToStack: (clientStack) => { | ||
| clientStack.addRelativeTo(httpAuthSchemeMiddleware(config, { | ||
| httpAuthSchemeParametersProvider, | ||
| identityProviderConfigProvider, | ||
| }), httpAuthSchemeMiddlewareOptions); | ||
| }, | ||
| }); |
| import { getSmithyContext } from "@smithy/core/client"; | ||
| import { resolveAuthOptions } from "./resolveAuthOptions"; | ||
| function convertHttpAuthSchemesToMap(httpAuthSchemes) { | ||
| const map = new Map(); | ||
| for (const scheme of httpAuthSchemes) { | ||
| map.set(scheme.schemeId, scheme); | ||
| } | ||
| return map; | ||
| } | ||
| export const httpAuthSchemeMiddleware = (config, mwOptions) => (next, context) => async (args) => { | ||
| const options = config.httpAuthSchemeProvider(await mwOptions.httpAuthSchemeParametersProvider(config, context, args.input)); | ||
| const authSchemePreference = config.authSchemePreference ? await config.authSchemePreference() : []; | ||
| const resolvedOptions = resolveAuthOptions(options, authSchemePreference); | ||
| const authSchemes = convertHttpAuthSchemesToMap(config.httpAuthSchemes); | ||
| const smithyContext = getSmithyContext(context); | ||
| const failureReasons = []; | ||
| for (const option of resolvedOptions) { | ||
| const scheme = authSchemes.get(option.schemeId); | ||
| if (!scheme) { | ||
| failureReasons.push(`HttpAuthScheme \`${option.schemeId}\` was not enabled for this service.`); | ||
| continue; | ||
| } | ||
| const identityProvider = scheme.identityProvider(await mwOptions.identityProviderConfigProvider(config)); | ||
| if (!identityProvider) { | ||
| failureReasons.push(`HttpAuthScheme \`${option.schemeId}\` did not have an IdentityProvider configured.`); | ||
| continue; | ||
| } | ||
| const { identityProperties = {}, signingProperties = {} } = option.propertiesExtractor?.(config, context) || {}; | ||
| option.identityProperties = Object.assign(option.identityProperties || {}, identityProperties); | ||
| option.signingProperties = Object.assign(option.signingProperties || {}, signingProperties); | ||
| smithyContext.selectedHttpAuthScheme = { | ||
| httpAuthOption: option, | ||
| identity: await identityProvider(option.identityProperties), | ||
| signer: scheme.signer, | ||
| }; | ||
| break; | ||
| } | ||
| if (!smithyContext.selectedHttpAuthScheme) { | ||
| throw new Error(failureReasons.join("\n")); | ||
| } | ||
| return next(args); | ||
| }; |
| export * from "./httpAuthSchemeMiddleware"; | ||
| export * from "./getHttpAuthSchemeEndpointRuleSetPlugin"; | ||
| export * from "./getHttpAuthSchemePlugin"; |
| export const resolveAuthOptions = (candidateAuthOptions, authSchemePreference) => { | ||
| if (!authSchemePreference || authSchemePreference.length === 0) { | ||
| return candidateAuthOptions; | ||
| } | ||
| const preferredAuthOptions = []; | ||
| for (const preferredSchemeName of authSchemePreference) { | ||
| for (const candidateAuthOption of candidateAuthOptions) { | ||
| const candidateAuthSchemeName = candidateAuthOption.schemeId.split("#")[1]; | ||
| if (candidateAuthSchemeName === preferredSchemeName) { | ||
| preferredAuthOptions.push(candidateAuthOption); | ||
| } | ||
| } | ||
| } | ||
| for (const candidateAuthOption of candidateAuthOptions) { | ||
| if (!preferredAuthOptions.find(({ schemeId }) => schemeId === candidateAuthOption.schemeId)) { | ||
| preferredAuthOptions.push(candidateAuthOption); | ||
| } | ||
| } | ||
| return preferredAuthOptions; | ||
| }; |
| import { httpSigningMiddleware } from "./httpSigningMiddleware"; | ||
| export const httpSigningMiddlewareOptions = { | ||
| step: "finalizeRequest", | ||
| tags: ["HTTP_SIGNING"], | ||
| name: "httpSigningMiddleware", | ||
| aliases: ["apiKeyMiddleware", "tokenMiddleware", "awsAuthMiddleware"], | ||
| override: true, | ||
| relation: "after", | ||
| toMiddleware: "retryMiddleware", | ||
| }; | ||
| export const getHttpSigningPlugin = (config) => ({ | ||
| applyToStack: (clientStack) => { | ||
| clientStack.addRelativeTo(httpSigningMiddleware(config), httpSigningMiddlewareOptions); | ||
| }, | ||
| }); |
| import { getSmithyContext } from "@smithy/core/client"; | ||
| import { HttpRequest } from "@smithy/core/protocols"; | ||
| const defaultErrorHandler = (signingProperties) => (error) => { | ||
| throw error; | ||
| }; | ||
| const defaultSuccessHandler = (httpResponse, signingProperties) => { }; | ||
| export const httpSigningMiddleware = (config) => (next, context) => async (args) => { | ||
| if (!HttpRequest.isInstance(args.request)) { | ||
| return next(args); | ||
| } | ||
| const smithyContext = getSmithyContext(context); | ||
| const scheme = smithyContext.selectedHttpAuthScheme; | ||
| if (!scheme) { | ||
| throw new Error(`No HttpAuthScheme was selected: unable to sign request`); | ||
| } | ||
| const { httpAuthOption: { signingProperties = {} }, identity, signer, } = scheme; | ||
| const output = await next({ | ||
| ...args, | ||
| request: await signer.sign(args.request, identity, signingProperties), | ||
| }).catch((signer.errorHandler || defaultErrorHandler)(signingProperties)); | ||
| (signer.successHandler || defaultSuccessHandler)(output.response, signingProperties); | ||
| return output; | ||
| }; |
| export * from "./httpSigningMiddleware"; | ||
| export * from "./getHttpSigningMiddleware"; |
| const makePagedClientRequest = async (CommandCtor, client, input, withCommand = (_) => _, ...args) => { | ||
| let command = new CommandCtor(input); | ||
| command = withCommand(command) ?? command; | ||
| return await client.send(command, ...args); | ||
| }; | ||
| export function createPaginator(ClientCtor, CommandCtor, inputTokenName, outputTokenName, pageSizeTokenName) { | ||
| return async function* paginateOperation(config, input, ...additionalArguments) { | ||
| const _input = input; | ||
| let token = config.startingToken ?? _input[inputTokenName]; | ||
| let hasNext = true; | ||
| let page; | ||
| while (hasNext) { | ||
| _input[inputTokenName] = token; | ||
| if (pageSizeTokenName) { | ||
| _input[pageSizeTokenName] = _input[pageSizeTokenName] ?? config.pageSize; | ||
| } | ||
| if (config.client instanceof ClientCtor) { | ||
| page = await makePagedClientRequest(CommandCtor, config.client, input, config.withCommand, ...additionalArguments); | ||
| } | ||
| else { | ||
| throw new Error(`Invalid client, expected instance of ${ClientCtor.name}`); | ||
| } | ||
| yield page; | ||
| const prevToken = token; | ||
| token = get(page, outputTokenName); | ||
| hasNext = !!(token && (!config.stopOnSameToken || token !== prevToken)); | ||
| } | ||
| return undefined; | ||
| }; | ||
| } | ||
| const get = (fromObject, path) => { | ||
| let cursor = fromObject; | ||
| const pathComponents = path.split("."); | ||
| for (const step of pathComponents) { | ||
| if (!cursor || typeof cursor !== "object") { | ||
| return undefined; | ||
| } | ||
| cursor = cursor[step]; | ||
| } | ||
| return cursor; | ||
| }; |
| export { requestBuilder } from "@smithy/core/protocols"; |
| import { SMITHY_CONTEXT_KEY } from "@smithy/types"; | ||
| export const getSmithyContext = (context) => context[SMITHY_CONTEXT_KEY] || (context[SMITHY_CONTEXT_KEY] = {}); |
| export const normalizeProvider = (input) => { | ||
| if (typeof input === "function") | ||
| return input; | ||
| const promisified = Promise.resolve(input); | ||
| return () => promisified; | ||
| }; |
| import { parseUrl } from "@smithy/core/protocols"; | ||
| export const toEndpointV1 = (endpoint) => { | ||
| if (typeof endpoint === "object") { | ||
| if ("url" in endpoint) { | ||
| const v1Endpoint = parseUrl(endpoint.url); | ||
| if (endpoint.headers) { | ||
| v1Endpoint.headers = {}; | ||
| for (const name in endpoint.headers) { | ||
| v1Endpoint.headers[name.toLowerCase()] = endpoint.headers[name].join(", "); | ||
| } | ||
| } | ||
| return v1Endpoint; | ||
| } | ||
| return endpoint; | ||
| } | ||
| return parseUrl(endpoint); | ||
| }; |
| const VALID_HOST_LABEL_REGEX = new RegExp(`^(?!.*-$)(?!-)[a-zA-Z0-9-]{1,63}$`); | ||
| export const isValidHostLabel = (value, allowSubDomains = false) => { | ||
| if (!allowSubDomains) { | ||
| return VALID_HOST_LABEL_REGEX.test(value); | ||
| } | ||
| const labels = value.split("."); | ||
| for (const label of labels) { | ||
| if (!isValidHostLabel(label)) { | ||
| return false; | ||
| } | ||
| } | ||
| return true; | ||
| }; |
| import { Int64 } from "./Int64"; | ||
| export const vectors = { | ||
| all_headers: { | ||
| expectation: "success", | ||
| encoded: Uint8Array.from([ | ||
| 0, 0, 0, 204, 0, 0, 0, 175, 15, 174, 100, 202, 10, 101, 118, 101, 110, 116, 45, 116, 121, 112, 101, 4, 0, 0, 160, | ||
| 12, 12, 99, 111, 110, 116, 101, 110, 116, 45, 116, 121, 112, 101, 7, 0, 16, 97, 112, 112, 108, 105, 99, 97, 116, | ||
| 105, 111, 110, 47, 106, 115, 111, 110, 10, 98, 111, 111, 108, 32, 102, 97, 108, 115, 101, 1, 9, 98, 111, 111, 108, | ||
| 32, 116, 114, 117, 101, 0, 4, 98, 121, 116, 101, 2, 207, 8, 98, 121, 116, 101, 32, 98, 117, 102, 6, 0, 20, 73, 39, | ||
| 109, 32, 97, 32, 108, 105, 116, 116, 108, 101, 32, 116, 101, 97, 112, 111, 116, 33, 9, 116, 105, 109, 101, 115, | ||
| 116, 97, 109, 112, 8, 0, 0, 0, 0, 0, 132, 95, 237, 5, 105, 110, 116, 49, 54, 3, 0, 42, 5, 105, 110, 116, 54, 52, | ||
| 5, 0, 0, 0, 0, 2, 135, 87, 178, 4, 117, 117, 105, 100, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, | ||
| 123, 39, 102, 111, 111, 39, 58, 39, 98, 97, 114, 39, 125, 171, 165, 241, 12, | ||
| ]), | ||
| decoded: { | ||
| headers: { | ||
| "event-type": { | ||
| type: "integer", | ||
| value: 40972, | ||
| }, | ||
| "content-type": { | ||
| type: "string", | ||
| value: "application/json", | ||
| }, | ||
| "bool false": { | ||
| type: "boolean", | ||
| value: false, | ||
| }, | ||
| "bool true": { | ||
| type: "boolean", | ||
| value: true, | ||
| }, | ||
| byte: { | ||
| type: "byte", | ||
| value: -49, | ||
| }, | ||
| "byte buf": { | ||
| type: "binary", | ||
| value: Uint8Array.from([ | ||
| 73, 39, 109, 32, 97, 32, 108, 105, 116, 116, 108, 101, 32, 116, 101, 97, 112, 111, 116, 33, | ||
| ]), | ||
| }, | ||
| timestamp: { | ||
| type: "timestamp", | ||
| value: new Date(8675309), | ||
| }, | ||
| int16: { | ||
| type: "short", | ||
| value: 42, | ||
| }, | ||
| int64: { | ||
| type: "long", | ||
| value: Int64.fromNumber(42424242), | ||
| }, | ||
| uuid: { | ||
| type: "uuid", | ||
| value: "01020304-0506-0708-090a-0b0c0d0e0f10", | ||
| }, | ||
| }, | ||
| body: Uint8Array.from([123, 39, 102, 111, 111, 39, 58, 39, 98, 97, 114, 39, 125]), | ||
| }, | ||
| }, | ||
| empty_message: { | ||
| expectation: "success", | ||
| encoded: Uint8Array.from([0, 0, 0, 16, 0, 0, 0, 0, 5, 194, 72, 235, 125, 152, 200, 255]), | ||
| decoded: { | ||
| headers: {}, | ||
| body: Uint8Array.from([]), | ||
| }, | ||
| }, | ||
| int32_header: { | ||
| expectation: "success", | ||
| encoded: Uint8Array.from([ | ||
| 0, 0, 0, 45, 0, 0, 0, 16, 65, 196, 36, 184, 10, 101, 118, 101, 110, 116, 45, 116, 121, 112, 101, 4, 0, 0, 160, 12, | ||
| 123, 39, 102, 111, 111, 39, 58, 39, 98, 97, 114, 39, 125, 54, 244, 128, 160, | ||
| ]), | ||
| decoded: { | ||
| headers: { | ||
| "event-type": { | ||
| type: "integer", | ||
| value: 40972, | ||
| }, | ||
| }, | ||
| body: Uint8Array.from([123, 39, 102, 111, 111, 39, 58, 39, 98, 97, 114, 39, 125]), | ||
| }, | ||
| }, | ||
| payload_no_headers: { | ||
| expectation: "success", | ||
| encoded: Uint8Array.from([ | ||
| 0, 0, 0, 29, 0, 0, 0, 0, 253, 82, 140, 90, 123, 39, 102, 111, 111, 39, 58, 39, 98, 97, 114, 39, 125, 195, 101, 57, | ||
| 54, | ||
| ]), | ||
| decoded: { | ||
| headers: {}, | ||
| body: Uint8Array.from([123, 39, 102, 111, 111, 39, 58, 39, 98, 97, 114, 39, 125]), | ||
| }, | ||
| }, | ||
| payload_one_str_header: { | ||
| expectation: "success", | ||
| encoded: Uint8Array.from([ | ||
| 0, 0, 0, 61, 0, 0, 0, 32, 7, 253, 131, 150, 12, 99, 111, 110, 116, 101, 110, 116, 45, 116, 121, 112, 101, 7, 0, | ||
| 16, 97, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 47, 106, 115, 111, 110, 123, 39, 102, 111, 111, 39, 58, | ||
| 39, 98, 97, 114, 39, 125, 141, 156, 8, 177, | ||
| ]), | ||
| decoded: { | ||
| headers: { | ||
| "content-type": { | ||
| type: "string", | ||
| value: "application/json", | ||
| }, | ||
| }, | ||
| body: Uint8Array.from([123, 39, 102, 111, 111, 39, 58, 39, 98, 97, 114, 39, 125]), | ||
| }, | ||
| }, | ||
| corrupted_headers: { | ||
| expectation: "failure", | ||
| encoded: Uint8Array.from([ | ||
| 0, 0, 0, 61, 0, 0, 0, 32, 7, 253, 131, 150, 12, 99, 111, 110, 116, 101, 110, 116, 45, 116, 121, 112, 101, 7, 0, | ||
| 16, 97, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 47, 106, 115, 111, 110, 123, 97, 102, 111, 111, 39, 58, | ||
| 39, 98, 97, 114, 39, 125, 141, 156, 8, 177, | ||
| ]), | ||
| }, | ||
| corrupted_header_len: { | ||
| expectation: "failure", | ||
| encoded: Uint8Array.from([ | ||
| 0, 0, 0, 61, 0, 0, 0, 33, 7, 253, 131, 150, 12, 99, 111, 110, 116, 101, 110, 116, 45, 116, 121, 112, 101, 7, 0, | ||
| 16, 97, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 47, 106, 115, 111, 110, 123, 39, 102, 111, 111, 39, 58, | ||
| 39, 98, 97, 114, 39, 125, 141, 156, 8, 177, | ||
| ]), | ||
| }, | ||
| corrupted_length: { | ||
| expectation: "failure", | ||
| encoded: Uint8Array.from([ | ||
| 0, 0, 0, 62, 0, 0, 0, 32, 7, 253, 131, 150, 12, 99, 111, 110, 116, 101, 110, 116, 45, 116, 121, 112, 101, 7, 0, | ||
| 16, 97, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 47, 106, 115, 111, 110, 123, 39, 102, 111, 111, 39, 58, | ||
| 39, 98, 97, 114, 39, 125, 141, 156, 8, 177, | ||
| ]), | ||
| }, | ||
| corrupted_payload: { | ||
| expectation: "failure", | ||
| encoded: Uint8Array.from([ | ||
| 0, 0, 0, 29, 0, 0, 0, 0, 253, 82, 140, 90, 91, 39, 102, 111, 111, 39, 58, 39, 98, 97, 114, 39, 125, 195, 101, 57, | ||
| 54, | ||
| ]), | ||
| }, | ||
| }; |
| export class HttpRequest { | ||
| method; | ||
| protocol; | ||
| hostname; | ||
| port; | ||
| path; | ||
| query; | ||
| headers; | ||
| username; | ||
| password; | ||
| fragment; | ||
| body; | ||
| constructor(options) { | ||
| this.method = options.method || "GET"; | ||
| this.hostname = options.hostname || "localhost"; | ||
| this.port = options.port; | ||
| this.query = options.query || {}; | ||
| this.headers = options.headers || {}; | ||
| this.body = options.body; | ||
| this.protocol = options.protocol | ||
| ? options.protocol.slice(-1) !== ":" | ||
| ? `${options.protocol}:` | ||
| : options.protocol | ||
| : "https:"; | ||
| this.path = options.path ? (options.path.charAt(0) !== "/" ? `/${options.path}` : options.path) : "/"; | ||
| this.username = options.username; | ||
| this.password = options.password; | ||
| this.fragment = options.fragment; | ||
| } | ||
| static clone(request) { | ||
| const cloned = new HttpRequest({ | ||
| ...request, | ||
| headers: { ...request.headers }, | ||
| }); | ||
| if (cloned.query) { | ||
| cloned.query = cloneQuery(cloned.query); | ||
| } | ||
| return cloned; | ||
| } | ||
| static isInstance(request) { | ||
| if (!request) { | ||
| return false; | ||
| } | ||
| const req = request; | ||
| return ("method" in req && | ||
| "protocol" in req && | ||
| "hostname" in req && | ||
| "path" in req && | ||
| typeof req["query"] === "object" && | ||
| typeof req["headers"] === "object"); | ||
| } | ||
| clone() { | ||
| return HttpRequest.clone(this); | ||
| } | ||
| } | ||
| function cloneQuery(query) { | ||
| return Object.keys(query).reduce((carry, paramName) => { | ||
| const param = query[paramName]; | ||
| return { | ||
| ...carry, | ||
| [paramName]: Array.isArray(param) ? [...param] : param, | ||
| }; | ||
| }, {}); | ||
| } |
| export class HttpResponse { | ||
| statusCode; | ||
| reason; | ||
| headers; | ||
| body; | ||
| constructor(options) { | ||
| this.statusCode = options.statusCode; | ||
| this.reason = options.reason; | ||
| this.headers = options.headers || {}; | ||
| this.body = options.body; | ||
| } | ||
| static isInstance(response) { | ||
| if (!response) | ||
| return false; | ||
| const resp = response; | ||
| return typeof resp.statusCode === "number" && typeof resp.headers === "object"; | ||
| } | ||
| } |
| export function isValidHostname(hostname) { | ||
| const hostPattern = /^[a-z0-9][a-z0-9\.\-]*[a-z0-9]$/; | ||
| return hostPattern.test(hostname); | ||
| } |
| export function parseQueryString(querystring) { | ||
| const query = {}; | ||
| querystring = querystring.replace(/^\?/, ""); | ||
| if (querystring) { | ||
| for (const pair of querystring.split("&")) { | ||
| let [key, value = null] = pair.split("="); | ||
| key = decodeURIComponent(key); | ||
| if (value) { | ||
| value = decodeURIComponent(value); | ||
| } | ||
| if (!(key in query)) { | ||
| query[key] = value; | ||
| } | ||
| else if (Array.isArray(query[key])) { | ||
| query[key].push(value); | ||
| } | ||
| else { | ||
| query[key] = [query[key], value]; | ||
| } | ||
| } | ||
| } | ||
| return query; | ||
| } |
| import { parseQueryString } from "../querystring-parser/parseQueryString"; | ||
| export const parseUrl = (url) => { | ||
| if (typeof url === "string") { | ||
| return parseUrl(new URL(url)); | ||
| } | ||
| const { hostname, pathname, port, protocol, search } = url; | ||
| let query; | ||
| if (search) { | ||
| query = parseQueryString(search); | ||
| } | ||
| return { | ||
| hostname, | ||
| port: port ? parseInt(port) : undefined, | ||
| protocol, | ||
| path: pathname, | ||
| query, | ||
| }; | ||
| }; |
| export class DefaultIdentityProviderConfig { | ||
| authSchemes = new Map(); | ||
| constructor(config) { | ||
| for (const key in config) { | ||
| const value = config[key]; | ||
| if (value !== undefined) { | ||
| this.authSchemes.set(key, value); | ||
| } | ||
| } | ||
| } | ||
| getIdentityProvider(schemeId) { | ||
| return this.authSchemes.get(schemeId); | ||
| } | ||
| } |
| import { HttpRequest } from "@smithy/core/protocols"; | ||
| import { HttpApiKeyAuthLocation, } from "@smithy/types"; | ||
| export class HttpApiKeyAuthSigner { | ||
| async sign(httpRequest, identity, signingProperties) { | ||
| if (!signingProperties) { | ||
| throw new Error("request could not be signed with `apiKey` since the `name` and `in` signer properties are missing"); | ||
| } | ||
| if (!signingProperties.name) { | ||
| throw new Error("request could not be signed with `apiKey` since the `name` signer property is missing"); | ||
| } | ||
| if (!signingProperties.in) { | ||
| throw new Error("request could not be signed with `apiKey` since the `in` signer property is missing"); | ||
| } | ||
| if (!identity.apiKey) { | ||
| throw new Error("request could not be signed with `apiKey` since the `apiKey` is not defined"); | ||
| } | ||
| const clonedRequest = HttpRequest.clone(httpRequest); | ||
| if (signingProperties.in === HttpApiKeyAuthLocation.QUERY) { | ||
| clonedRequest.query[signingProperties.name] = identity.apiKey; | ||
| } | ||
| else if (signingProperties.in === HttpApiKeyAuthLocation.HEADER) { | ||
| clonedRequest.headers[signingProperties.name] = signingProperties.scheme | ||
| ? `${signingProperties.scheme} ${identity.apiKey}` | ||
| : identity.apiKey; | ||
| } | ||
| else { | ||
| throw new Error("request can only be signed with `apiKey` locations `query` or `header`, " + | ||
| "but found: `" + | ||
| signingProperties.in + | ||
| "`"); | ||
| } | ||
| return clonedRequest; | ||
| } | ||
| } |
| import { HttpRequest } from "@smithy/core/protocols"; | ||
| export class HttpBearerAuthSigner { | ||
| async sign(httpRequest, identity, signingProperties) { | ||
| const clonedRequest = HttpRequest.clone(httpRequest); | ||
| if (!identity.token) { | ||
| throw new Error("request could not be signed with `token` since the `token` is not defined"); | ||
| } | ||
| clonedRequest.headers["Authorization"] = `Bearer ${identity.token}`; | ||
| return clonedRequest; | ||
| } | ||
| } |
| export * from "./httpApiKeyAuth"; | ||
| export * from "./httpBearerAuth"; | ||
| export * from "./noAuth"; |
| export class NoAuthSigner { | ||
| async sign(httpRequest, identity, signingProperties) { | ||
| return httpRequest; | ||
| } | ||
| } |
| export * from "./DefaultIdentityProviderConfig"; | ||
| export * from "./httpAuthSchemes"; | ||
| export * from "./memoizeIdentityProvider"; |
| export const createIsIdentityExpiredFunction = (expirationMs) => function isIdentityExpired(identity) { | ||
| return doesIdentityRequireRefresh(identity) && identity.expiration.getTime() - Date.now() < expirationMs; | ||
| }; | ||
| export const EXPIRATION_MS = 300_000; | ||
| export const isIdentityExpired = createIsIdentityExpiredFunction(EXPIRATION_MS); | ||
| export const doesIdentityRequireRefresh = (identity) => identity.expiration !== undefined; | ||
| export const memoizeIdentityProvider = (provider, isExpired, requiresRefresh) => { | ||
| if (provider === undefined) { | ||
| return undefined; | ||
| } | ||
| const normalizedProvider = typeof provider !== "function" ? async () => Promise.resolve(provider) : provider; | ||
| let resolved; | ||
| let pending; | ||
| let hasResult; | ||
| let isConstant = false; | ||
| const coalesceProvider = async (options) => { | ||
| if (!pending) { | ||
| pending = normalizedProvider(options); | ||
| } | ||
| try { | ||
| resolved = await pending; | ||
| hasResult = true; | ||
| isConstant = false; | ||
| } | ||
| finally { | ||
| pending = undefined; | ||
| } | ||
| return resolved; | ||
| }; | ||
| if (isExpired === undefined) { | ||
| return async (options) => { | ||
| if (!hasResult || options?.forceRefresh) { | ||
| resolved = await coalesceProvider(options); | ||
| } | ||
| return resolved; | ||
| }; | ||
| } | ||
| return async (options) => { | ||
| if (!hasResult || options?.forceRefresh) { | ||
| resolved = await coalesceProvider(options); | ||
| } | ||
| if (isConstant) { | ||
| return resolved; | ||
| } | ||
| if (!requiresRefresh(resolved)) { | ||
| isConstant = true; | ||
| return resolved; | ||
| } | ||
| if (isExpired(resolved)) { | ||
| await coalesceProvider(options); | ||
| return resolved; | ||
| } | ||
| return resolved; | ||
| }; | ||
| }; |
| import { type HandlerExecutionContext } from "@smithy/types"; | ||
| /** | ||
| * @internal | ||
| */ | ||
| export declare const getSmithyContext: (context: HandlerExecutionContext) => Record<string, unknown>; |
| import type { HandlerExecutionContext, HttpAuthSchemeParameters, HttpAuthSchemeParametersProvider, IdentityProviderConfig, Pluggable, RelativeMiddlewareOptions, SerializeHandlerOptions } from "@smithy/types"; | ||
| import { type PreviouslyResolved } from "./httpAuthSchemeMiddleware"; | ||
| /** | ||
| * @internal | ||
| */ | ||
| export declare const httpAuthSchemeEndpointRuleSetMiddlewareOptions: SerializeHandlerOptions & RelativeMiddlewareOptions; | ||
| /** | ||
| * @internal | ||
| */ | ||
| interface HttpAuthSchemeEndpointRuleSetPluginOptions<TConfig extends object, TContext extends HandlerExecutionContext, TParameters extends HttpAuthSchemeParameters, TInput extends object> { | ||
| httpAuthSchemeParametersProvider: HttpAuthSchemeParametersProvider<TConfig, TContext, TParameters, TInput>; | ||
| identityProviderConfigProvider: (config: TConfig) => Promise<IdentityProviderConfig>; | ||
| } | ||
| /** | ||
| * @internal | ||
| */ | ||
| export declare const getHttpAuthSchemeEndpointRuleSetPlugin: <TConfig extends object, TContext extends HandlerExecutionContext, TParameters extends HttpAuthSchemeParameters, TInput extends object>(config: TConfig & PreviouslyResolved<TParameters>, { httpAuthSchemeParametersProvider, identityProviderConfigProvider, }: HttpAuthSchemeEndpointRuleSetPluginOptions<TConfig, TContext, TParameters, TInput>) => Pluggable<any, any>; | ||
| export {}; |
| import type { HandlerExecutionContext, HttpAuthSchemeParameters, HttpAuthSchemeParametersProvider, IdentityProviderConfig, Pluggable, RelativeMiddlewareOptions, SerializeHandlerOptions } from "@smithy/types"; | ||
| import { type PreviouslyResolved } from "./httpAuthSchemeMiddleware"; | ||
| /** | ||
| * @internal | ||
| */ | ||
| export declare const httpAuthSchemeMiddlewareOptions: SerializeHandlerOptions & RelativeMiddlewareOptions; | ||
| /** | ||
| * @internal | ||
| */ | ||
| interface HttpAuthSchemePluginOptions<TConfig extends object, TContext extends HandlerExecutionContext, TParameters extends HttpAuthSchemeParameters, TInput extends object> { | ||
| httpAuthSchemeParametersProvider: HttpAuthSchemeParametersProvider<TConfig, TContext, TParameters, TInput>; | ||
| identityProviderConfigProvider: (config: TConfig) => Promise<IdentityProviderConfig>; | ||
| } | ||
| /** | ||
| * @internal | ||
| */ | ||
| export declare const getHttpAuthSchemePlugin: <TConfig extends object, TContext extends HandlerExecutionContext, TParameters extends HttpAuthSchemeParameters, TInput extends object>(config: TConfig & PreviouslyResolved<TParameters>, { httpAuthSchemeParametersProvider, identityProviderConfigProvider, }: HttpAuthSchemePluginOptions<TConfig, TContext, TParameters, TInput>) => Pluggable<any, any>; | ||
| export {}; |
| import type { HandlerExecutionContext, HttpAuthScheme, HttpAuthSchemeParameters, HttpAuthSchemeParametersProvider, HttpAuthSchemeProvider, IdentityProviderConfig, Provider, SMITHY_CONTEXT_KEY, SelectedHttpAuthScheme, SerializeMiddleware } from "@smithy/types"; | ||
| /** | ||
| * @internal | ||
| */ | ||
| export interface PreviouslyResolved<TParameters extends HttpAuthSchemeParameters> { | ||
| authSchemePreference?: Provider<string[]>; | ||
| httpAuthSchemes: HttpAuthScheme[]; | ||
| httpAuthSchemeProvider: HttpAuthSchemeProvider<TParameters>; | ||
| } | ||
| /** | ||
| * @internal | ||
| */ | ||
| interface HttpAuthSchemeMiddlewareOptions<TConfig extends object, TContext extends HandlerExecutionContext, TParameters extends HttpAuthSchemeParameters, TInput extends object> { | ||
| httpAuthSchemeParametersProvider: HttpAuthSchemeParametersProvider<TConfig, TContext, TParameters, TInput>; | ||
| identityProviderConfigProvider: (config: TConfig) => Promise<IdentityProviderConfig>; | ||
| } | ||
| /** | ||
| * @internal | ||
| */ | ||
| interface HttpAuthSchemeMiddlewareSmithyContext extends Record<string, unknown> { | ||
| selectedHttpAuthScheme?: SelectedHttpAuthScheme; | ||
| } | ||
| /** | ||
| * @internal | ||
| */ | ||
| interface HttpAuthSchemeMiddlewareHandlerExecutionContext extends HandlerExecutionContext { | ||
| [SMITHY_CONTEXT_KEY]?: HttpAuthSchemeMiddlewareSmithyContext; | ||
| } | ||
| /** | ||
| * @internal | ||
| */ | ||
| export declare const httpAuthSchemeMiddleware: <TInput extends object, Output extends object, TConfig extends object, TContext extends HttpAuthSchemeMiddlewareHandlerExecutionContext, TParameters extends HttpAuthSchemeParameters>(config: TConfig & PreviouslyResolved<TParameters>, mwOptions: HttpAuthSchemeMiddlewareOptions<TConfig, TContext, TParameters, TInput>) => SerializeMiddleware<TInput, Output>; | ||
| export {}; |
| export * from "./httpAuthSchemeMiddleware"; | ||
| export * from "./getHttpAuthSchemeEndpointRuleSetPlugin"; | ||
| export * from "./getHttpAuthSchemePlugin"; |
| import type { HttpAuthOption } from "@smithy/types"; | ||
| /** | ||
| * Resolves list of auth options based on the supported ones, vs the preference list. | ||
| * | ||
| * @param candidateAuthOptions list of supported auth options selected by the standard | ||
| * resolution process (model-based, endpoints 2.0, etc.) | ||
| * @param authSchemePreference list of auth schemes preferred by user. | ||
| * @returns | ||
| */ | ||
| export declare const resolveAuthOptions: (candidateAuthOptions: HttpAuthOption[], authSchemePreference: string[]) => HttpAuthOption[]; |
| import type { FinalizeRequestHandlerOptions, Pluggable, RelativeMiddlewareOptions } from "@smithy/types"; | ||
| /** | ||
| * @internal | ||
| */ | ||
| export declare const httpSigningMiddlewareOptions: FinalizeRequestHandlerOptions & RelativeMiddlewareOptions; | ||
| /** | ||
| * @internal | ||
| */ | ||
| export declare const getHttpSigningPlugin: <Input extends object, Output extends object>(config: object) => Pluggable<Input, Output>; |
| import type { FinalizeRequestMiddleware } from "@smithy/types"; | ||
| /** | ||
| * @internal | ||
| */ | ||
| export declare const httpSigningMiddleware: <Input extends object, Output extends object>(config: object) => FinalizeRequestMiddleware<Input, Output>; |
| export * from "./httpSigningMiddleware"; | ||
| export * from "./getHttpSigningMiddleware"; |
| import type { PaginationConfiguration, Paginator } from "@smithy/types"; | ||
| /** | ||
| * Creates a paginator. | ||
| * | ||
| * @internal | ||
| */ | ||
| export declare function createPaginator<PaginationConfigType extends PaginationConfiguration, InputType extends object, OutputType extends object>(ClientCtor: any, CommandCtor: any, inputTokenName: string, outputTokenName: string, pageSizeTokenName?: string): (config: PaginationConfigType, input: InputType, ...additionalArguments: any[]) => Paginator<OutputType>; |
| /** | ||
| * Backwards compatibility re-export. | ||
| * | ||
| * @internal | ||
| */ | ||
| export { requestBuilder } from "@smithy/core/protocols"; |
| import { type HandlerExecutionContext } from "@smithy/types"; | ||
| /** | ||
| * @internal | ||
| */ | ||
| export declare const getSmithyContext: (context: HandlerExecutionContext) => Record<string, unknown>; |
| import type { Provider } from "@smithy/types"; | ||
| /** | ||
| * @internal | ||
| * | ||
| * @returns a provider function for the input value if it isn't already one. | ||
| */ | ||
| export declare const normalizeProvider: <T>(input: T | Provider<T>) => Provider<T>; |
| import type { Endpoint, EndpointV2 } from "@smithy/types"; | ||
| /** | ||
| * Converts an endpoint to EndpointV1 format. | ||
| * @internal | ||
| */ | ||
| export declare const toEndpointV1: (endpoint: string | Endpoint | EndpointV2) => Endpoint; |
| /** | ||
| * Evaluates whether one or more string values are valid host labels per RFC 1123. | ||
| * | ||
| * If allowSubDomains is true, then the provided value may be zero or more dotted | ||
| * subdomains which are each validated per RFC 1123. | ||
| */ | ||
| export declare const isValidHostLabel: (value: string, allowSubDomains?: boolean) => boolean; |
| import type { TestVectors } from "./vectorTypes.fixture"; | ||
| export declare const vectors: TestVectors; |
| import type { Message } from "./Message"; | ||
| export interface NegativeTestVector { | ||
| expectation: "failure"; | ||
| encoded: Uint8Array; | ||
| } | ||
| export interface PositiveTestVector { | ||
| expectation: "success"; | ||
| encoded: Uint8Array; | ||
| decoded: Message; | ||
| } | ||
| export type TestVector = NegativeTestVector | PositiveTestVector; | ||
| export type TestVectors = Record<string, TestVector>; |
| import { HttpRequest as IHttpRequest, type HeaderBag, type HttpMessage, type QueryParameterBag, type URI } from "@smithy/types"; | ||
| type HttpRequestOptions = Partial<HttpMessage> & Partial<URI> & { | ||
| method?: string; | ||
| }; | ||
| /** | ||
| * Use the distinct IHttpRequest interface from \@smithy/types instead. | ||
| * This should not be used due to | ||
| * overlapping with the concrete class' name. | ||
| * | ||
| * This is not marked deprecated since that would mark the concrete class | ||
| * deprecated as well. | ||
| * | ||
| * @internal | ||
| */ | ||
| export interface HttpRequest extends IHttpRequest { | ||
| } | ||
| /** | ||
| * @public | ||
| */ | ||
| export { IHttpRequest }; | ||
| /** | ||
| * @public | ||
| */ | ||
| export declare class HttpRequest implements HttpMessage, URI { | ||
| method: string; | ||
| protocol: string; | ||
| hostname: string; | ||
| port?: number; | ||
| path: string; | ||
| query: QueryParameterBag; | ||
| headers: HeaderBag; | ||
| username?: string; | ||
| password?: string; | ||
| fragment?: string; | ||
| body?: any; | ||
| constructor(options: HttpRequestOptions); | ||
| /** | ||
| * Note: this does not deep-clone the body. | ||
| */ | ||
| static clone(request: IHttpRequest): HttpRequest; | ||
| /** | ||
| * This method only actually asserts that request is the interface {@link IHttpRequest}, | ||
| * and not necessarily this concrete class. Left in place for API stability. | ||
| * | ||
| * Do not call instance methods on the input of this function, and | ||
| * do not assume it has the HttpRequest prototype. | ||
| */ | ||
| static isInstance(request: unknown): request is HttpRequest; | ||
| /** | ||
| * @deprecated use static HttpRequest.clone(request) instead. It's not safe to call | ||
| * this method because {@link HttpRequest.isInstance} incorrectly | ||
| * asserts that IHttpRequest (interface) objects are of type HttpRequest (class). | ||
| */ | ||
| clone(): HttpRequest; | ||
| } |
| import type { HeaderBag, HttpMessage, HttpResponse as IHttpResponse } from "@smithy/types"; | ||
| type HttpResponseOptions = Partial<HttpMessage> & { | ||
| statusCode: number; | ||
| reason?: string; | ||
| }; | ||
| /** | ||
| * Use the distinct IHttpResponse interface from \@smithy/types instead. | ||
| * This should not be used due to | ||
| * overlapping with the concrete class' name. | ||
| * | ||
| * This is not marked deprecated since that would mark the concrete class | ||
| * deprecated as well. | ||
| * | ||
| * @internal | ||
| */ | ||
| export interface HttpResponse extends IHttpResponse { | ||
| } | ||
| /** | ||
| * @public | ||
| */ | ||
| export declare class HttpResponse { | ||
| statusCode: number; | ||
| reason?: string; | ||
| headers: HeaderBag; | ||
| body?: any; | ||
| constructor(options: HttpResponseOptions); | ||
| static isInstance(response: unknown): response is HttpResponse; | ||
| } | ||
| export {}; |
| export declare function isValidHostname(hostname: string): boolean; |
| import type { QueryParameterBag } from "@smithy/types"; | ||
| /** | ||
| * @internal | ||
| */ | ||
| export declare function parseQueryString(querystring: string): QueryParameterBag; |
| import type { UrlParser } from "@smithy/types"; | ||
| /** | ||
| * @internal | ||
| */ | ||
| export declare const parseUrl: UrlParser; |
| import type { HttpAuthSchemeId, Identity, IdentityProvider, IdentityProviderConfig } from "@smithy/types"; | ||
| /** | ||
| * Default implementation of IdentityProviderConfig | ||
| * @internal | ||
| */ | ||
| export declare class DefaultIdentityProviderConfig implements IdentityProviderConfig { | ||
| private authSchemes; | ||
| /** | ||
| * Creates an IdentityProviderConfig with a record of scheme IDs to identity providers. | ||
| * | ||
| * @param config scheme IDs and identity providers to configure | ||
| */ | ||
| constructor(config: Record<HttpAuthSchemeId, IdentityProvider<Identity> | undefined>); | ||
| getIdentityProvider(schemeId: HttpAuthSchemeId): IdentityProvider<Identity> | undefined; | ||
| } |
| import { HttpRequest } from "@smithy/core/protocols"; | ||
| import { type ApiKeyIdentity, type HttpSigner, type HttpRequest as IHttpRequest } from "@smithy/types"; | ||
| /** | ||
| * @internal | ||
| */ | ||
| export declare class HttpApiKeyAuthSigner implements HttpSigner { | ||
| sign(httpRequest: HttpRequest, identity: ApiKeyIdentity, signingProperties: Record<string, any>): Promise<IHttpRequest>; | ||
| } |
| import { HttpRequest } from "@smithy/core/protocols"; | ||
| import type { HttpSigner, HttpRequest as IHttpRequest, TokenIdentity } from "@smithy/types"; | ||
| /** | ||
| * @internal | ||
| */ | ||
| export declare class HttpBearerAuthSigner implements HttpSigner { | ||
| sign(httpRequest: HttpRequest, identity: TokenIdentity, signingProperties: Record<string, any>): Promise<IHttpRequest>; | ||
| } |
| export * from "./httpApiKeyAuth"; | ||
| export * from "./httpBearerAuth"; | ||
| export * from "./noAuth"; |
| import type { HttpRequest, HttpSigner, Identity } from "@smithy/types"; | ||
| /** | ||
| * Signer for the synthetic @smithy.api#noAuth auth scheme. | ||
| * @internal | ||
| */ | ||
| export declare class NoAuthSigner implements HttpSigner { | ||
| sign(httpRequest: HttpRequest, identity: Identity, signingProperties: Record<string, unknown>): Promise<HttpRequest>; | ||
| } |
| export * from "./DefaultIdentityProviderConfig"; | ||
| export * from "./httpAuthSchemes"; | ||
| export * from "./memoizeIdentityProvider"; |
| import type { Identity, IdentityProvider } from "@smithy/types"; | ||
| /** | ||
| * @internal | ||
| */ | ||
| export declare const createIsIdentityExpiredFunction: (expirationMs: number) => (identity: Identity) => boolean; | ||
| /** | ||
| * This may need to be configurable in the future, but for now it is defaulted to 5min. | ||
| * | ||
| * @internal | ||
| */ | ||
| export declare const EXPIRATION_MS = 300000; | ||
| /** | ||
| * @internal | ||
| */ | ||
| export declare const isIdentityExpired: (identity: Identity) => boolean; | ||
| /** | ||
| * @internal | ||
| */ | ||
| export declare const doesIdentityRequireRefresh: (identity: Identity) => boolean; | ||
| /** | ||
| * @internal | ||
| */ | ||
| export interface MemoizedIdentityProvider<IdentityT extends Identity> { | ||
| (options?: Record<string, any> & { | ||
| forceRefresh?: boolean; | ||
| }): Promise<IdentityT>; | ||
| } | ||
| /** | ||
| * @internal | ||
| */ | ||
| export declare const memoizeIdentityProvider: <IdentityT extends Identity>(provider: IdentityT | IdentityProvider<IdentityT> | undefined, isExpired: (resolved: Identity) => boolean, requiresRefresh: (resolved: Identity) => boolean) => MemoizedIdentityProvider<IdentityT> | undefined; |
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
1315325
-1.72%724
-3.08%32605
-1.71%