mirror of
https://github.com/tvytlx/ai-agent-deep-dive.git
synced 2026-04-07 09:34:49 +08:00
Add extracted source directory and README navigation
This commit is contained in:
194
extracted-source/node_modules/@aws-sdk/middleware-user-agent/dist-cjs/index.js
generated
vendored
Normal file
194
extracted-source/node_modules/@aws-sdk/middleware-user-agent/dist-cjs/index.js
generated
vendored
Normal file
@@ -0,0 +1,194 @@
|
||||
'use strict';
|
||||
|
||||
var core = require('@smithy/core');
|
||||
var utilEndpoints = require('@aws-sdk/util-endpoints');
|
||||
var protocolHttp = require('@smithy/protocol-http');
|
||||
var core$1 = require('@aws-sdk/core');
|
||||
|
||||
const DEFAULT_UA_APP_ID = undefined;
|
||||
function isValidUserAgentAppId(appId) {
|
||||
if (appId === undefined) {
|
||||
return true;
|
||||
}
|
||||
return typeof appId === "string" && appId.length <= 50;
|
||||
}
|
||||
function resolveUserAgentConfig(input) {
|
||||
const normalizedAppIdProvider = core.normalizeProvider(input.userAgentAppId ?? DEFAULT_UA_APP_ID);
|
||||
const { customUserAgent } = input;
|
||||
return Object.assign(input, {
|
||||
customUserAgent: typeof customUserAgent === "string" ? [[customUserAgent]] : customUserAgent,
|
||||
userAgentAppId: async () => {
|
||||
const appId = await normalizedAppIdProvider();
|
||||
if (!isValidUserAgentAppId(appId)) {
|
||||
const logger = input.logger?.constructor?.name === "NoOpLogger" || !input.logger ? console : input.logger;
|
||||
if (typeof appId !== "string") {
|
||||
logger?.warn("userAgentAppId must be a string or undefined.");
|
||||
}
|
||||
else if (appId.length > 50) {
|
||||
logger?.warn("The provided userAgentAppId exceeds the maximum length of 50 characters.");
|
||||
}
|
||||
}
|
||||
return appId;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const ACCOUNT_ID_ENDPOINT_REGEX = /\d{12}\.ddb/;
|
||||
async function checkFeatures(context, config, args) {
|
||||
const request = args.request;
|
||||
if (request?.headers?.["smithy-protocol"] === "rpc-v2-cbor") {
|
||||
core$1.setFeature(context, "PROTOCOL_RPC_V2_CBOR", "M");
|
||||
}
|
||||
if (typeof config.retryStrategy === "function") {
|
||||
const retryStrategy = await config.retryStrategy();
|
||||
if (typeof retryStrategy.acquireInitialRetryToken === "function") {
|
||||
if (retryStrategy.constructor?.name?.includes("Adaptive")) {
|
||||
core$1.setFeature(context, "RETRY_MODE_ADAPTIVE", "F");
|
||||
}
|
||||
else {
|
||||
core$1.setFeature(context, "RETRY_MODE_STANDARD", "E");
|
||||
}
|
||||
}
|
||||
else {
|
||||
core$1.setFeature(context, "RETRY_MODE_LEGACY", "D");
|
||||
}
|
||||
}
|
||||
if (typeof config.accountIdEndpointMode === "function") {
|
||||
const endpointV2 = context.endpointV2;
|
||||
if (String(endpointV2?.url?.hostname).match(ACCOUNT_ID_ENDPOINT_REGEX)) {
|
||||
core$1.setFeature(context, "ACCOUNT_ID_ENDPOINT", "O");
|
||||
}
|
||||
switch (await config.accountIdEndpointMode?.()) {
|
||||
case "disabled":
|
||||
core$1.setFeature(context, "ACCOUNT_ID_MODE_DISABLED", "Q");
|
||||
break;
|
||||
case "preferred":
|
||||
core$1.setFeature(context, "ACCOUNT_ID_MODE_PREFERRED", "P");
|
||||
break;
|
||||
case "required":
|
||||
core$1.setFeature(context, "ACCOUNT_ID_MODE_REQUIRED", "R");
|
||||
break;
|
||||
}
|
||||
}
|
||||
const identity = context.__smithy_context?.selectedHttpAuthScheme?.identity;
|
||||
if (identity?.$source) {
|
||||
const credentials = identity;
|
||||
if (credentials.accountId) {
|
||||
core$1.setFeature(context, "RESOLVED_ACCOUNT_ID", "T");
|
||||
}
|
||||
for (const [key, value] of Object.entries(credentials.$source ?? {})) {
|
||||
core$1.setFeature(context, key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const USER_AGENT = "user-agent";
|
||||
const X_AMZ_USER_AGENT = "x-amz-user-agent";
|
||||
const SPACE = " ";
|
||||
const UA_NAME_SEPARATOR = "/";
|
||||
const UA_NAME_ESCAPE_REGEX = /[^!$%&'*+\-.^_`|~\w]/g;
|
||||
const UA_VALUE_ESCAPE_REGEX = /[^!$%&'*+\-.^_`|~\w#]/g;
|
||||
const UA_ESCAPE_CHAR = "-";
|
||||
|
||||
const BYTE_LIMIT = 1024;
|
||||
function encodeFeatures(features) {
|
||||
let buffer = "";
|
||||
for (const key in features) {
|
||||
const val = features[key];
|
||||
if (buffer.length + val.length + 1 <= BYTE_LIMIT) {
|
||||
if (buffer.length) {
|
||||
buffer += "," + val;
|
||||
}
|
||||
else {
|
||||
buffer += val;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
const userAgentMiddleware = (options) => (next, context) => async (args) => {
|
||||
const { request } = args;
|
||||
if (!protocolHttp.HttpRequest.isInstance(request)) {
|
||||
return next(args);
|
||||
}
|
||||
const { headers } = request;
|
||||
const userAgent = context?.userAgent?.map(escapeUserAgent) || [];
|
||||
const defaultUserAgent = (await options.defaultUserAgentProvider()).map(escapeUserAgent);
|
||||
await checkFeatures(context, options, args);
|
||||
const awsContext = context;
|
||||
defaultUserAgent.push(`m/${encodeFeatures(Object.assign({}, context.__smithy_context?.features, awsContext.__aws_sdk_context?.features))}`);
|
||||
const customUserAgent = options?.customUserAgent?.map(escapeUserAgent) || [];
|
||||
const appId = await options.userAgentAppId();
|
||||
if (appId) {
|
||||
defaultUserAgent.push(escapeUserAgent([`app`, `${appId}`]));
|
||||
}
|
||||
const prefix = utilEndpoints.getUserAgentPrefix();
|
||||
const sdkUserAgentValue = (prefix ? [prefix] : [])
|
||||
.concat([...defaultUserAgent, ...userAgent, ...customUserAgent])
|
||||
.join(SPACE);
|
||||
const normalUAValue = [
|
||||
...defaultUserAgent.filter((section) => section.startsWith("aws-sdk-")),
|
||||
...customUserAgent,
|
||||
].join(SPACE);
|
||||
if (options.runtime !== "browser") {
|
||||
if (normalUAValue) {
|
||||
headers[X_AMZ_USER_AGENT] = headers[X_AMZ_USER_AGENT]
|
||||
? `${headers[USER_AGENT]} ${normalUAValue}`
|
||||
: normalUAValue;
|
||||
}
|
||||
headers[USER_AGENT] = sdkUserAgentValue;
|
||||
}
|
||||
else {
|
||||
headers[X_AMZ_USER_AGENT] = sdkUserAgentValue;
|
||||
}
|
||||
return next({
|
||||
...args,
|
||||
request,
|
||||
});
|
||||
};
|
||||
const escapeUserAgent = (userAgentPair) => {
|
||||
const name = userAgentPair[0]
|
||||
.split(UA_NAME_SEPARATOR)
|
||||
.map((part) => part.replace(UA_NAME_ESCAPE_REGEX, UA_ESCAPE_CHAR))
|
||||
.join(UA_NAME_SEPARATOR);
|
||||
const version = userAgentPair[1]?.replace(UA_VALUE_ESCAPE_REGEX, UA_ESCAPE_CHAR);
|
||||
const prefixSeparatorIndex = name.indexOf(UA_NAME_SEPARATOR);
|
||||
const prefix = name.substring(0, prefixSeparatorIndex);
|
||||
let uaName = name.substring(prefixSeparatorIndex + 1);
|
||||
if (prefix === "api") {
|
||||
uaName = uaName.toLowerCase();
|
||||
}
|
||||
return [prefix, uaName, version]
|
||||
.filter((item) => item && item.length > 0)
|
||||
.reduce((acc, item, index) => {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return item;
|
||||
case 1:
|
||||
return `${acc}/${item}`;
|
||||
default:
|
||||
return `${acc}#${item}`;
|
||||
}
|
||||
}, "");
|
||||
};
|
||||
const getUserAgentMiddlewareOptions = {
|
||||
name: "getUserAgentMiddleware",
|
||||
step: "build",
|
||||
priority: "low",
|
||||
tags: ["SET_USER_AGENT", "USER_AGENT"],
|
||||
override: true,
|
||||
};
|
||||
const getUserAgentPlugin = (config) => ({
|
||||
applyToStack: (clientStack) => {
|
||||
clientStack.add(userAgentMiddleware(config), getUserAgentMiddlewareOptions);
|
||||
},
|
||||
});
|
||||
|
||||
exports.DEFAULT_UA_APP_ID = DEFAULT_UA_APP_ID;
|
||||
exports.getUserAgentMiddlewareOptions = getUserAgentMiddlewareOptions;
|
||||
exports.getUserAgentPlugin = getUserAgentPlugin;
|
||||
exports.resolveUserAgentConfig = resolveUserAgentConfig;
|
||||
exports.userAgentMiddleware = userAgentMiddleware;
|
||||
169
extracted-source/node_modules/@aws-sdk/middleware-user-agent/node_modules/@smithy/protocol-http/dist-cjs/index.js
generated
vendored
Normal file
169
extracted-source/node_modules/@aws-sdk/middleware-user-agent/node_modules/@smithy/protocol-http/dist-cjs/index.js
generated
vendored
Normal file
@@ -0,0 +1,169 @@
|
||||
'use strict';
|
||||
|
||||
var types = require('@smithy/types');
|
||||
|
||||
const getHttpHandlerExtensionConfiguration = (runtimeConfig) => {
|
||||
return {
|
||||
setHttpHandler(handler) {
|
||||
runtimeConfig.httpHandler = handler;
|
||||
},
|
||||
httpHandler() {
|
||||
return runtimeConfig.httpHandler;
|
||||
},
|
||||
updateHttpClientConfig(key, value) {
|
||||
runtimeConfig.httpHandler?.updateHttpClientConfig(key, value);
|
||||
},
|
||||
httpHandlerConfigs() {
|
||||
return runtimeConfig.httpHandler.httpHandlerConfigs();
|
||||
},
|
||||
};
|
||||
};
|
||||
const resolveHttpHandlerRuntimeConfig = (httpHandlerExtensionConfiguration) => {
|
||||
return {
|
||||
httpHandler: httpHandlerExtensionConfiguration.httpHandler(),
|
||||
};
|
||||
};
|
||||
|
||||
class Field {
|
||||
name;
|
||||
kind;
|
||||
values;
|
||||
constructor({ name, kind = types.FieldPosition.HEADER, values = [] }) {
|
||||
this.name = name;
|
||||
this.kind = kind;
|
||||
this.values = values;
|
||||
}
|
||||
add(value) {
|
||||
this.values.push(value);
|
||||
}
|
||||
set(values) {
|
||||
this.values = values;
|
||||
}
|
||||
remove(value) {
|
||||
this.values = this.values.filter((v) => v !== value);
|
||||
}
|
||||
toString() {
|
||||
return this.values.map((v) => (v.includes(",") || v.includes(" ") ? `"${v}"` : v)).join(", ");
|
||||
}
|
||||
get() {
|
||||
return this.values;
|
||||
}
|
||||
}
|
||||
|
||||
class Fields {
|
||||
entries = {};
|
||||
encoding;
|
||||
constructor({ fields = [], encoding = "utf-8" }) {
|
||||
fields.forEach(this.setField.bind(this));
|
||||
this.encoding = encoding;
|
||||
}
|
||||
setField(field) {
|
||||
this.entries[field.name.toLowerCase()] = field;
|
||||
}
|
||||
getField(name) {
|
||||
return this.entries[name.toLowerCase()];
|
||||
}
|
||||
removeField(name) {
|
||||
delete this.entries[name.toLowerCase()];
|
||||
}
|
||||
getByType(kind) {
|
||||
return Object.values(this.entries).filter((field) => field.kind === kind);
|
||||
}
|
||||
}
|
||||
|
||||
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";
|
||||
}
|
||||
}
|
||||
|
||||
function isValidHostname(hostname) {
|
||||
const hostPattern = /^[a-z0-9][a-z0-9\.\-]*[a-z0-9]$/;
|
||||
return hostPattern.test(hostname);
|
||||
}
|
||||
|
||||
exports.Field = Field;
|
||||
exports.Fields = Fields;
|
||||
exports.HttpRequest = HttpRequest;
|
||||
exports.HttpResponse = HttpResponse;
|
||||
exports.getHttpHandlerExtensionConfiguration = getHttpHandlerExtensionConfiguration;
|
||||
exports.isValidHostname = isValidHostname;
|
||||
exports.resolveHttpHandlerRuntimeConfig = resolveHttpHandlerRuntimeConfig;
|
||||
91
extracted-source/node_modules/@aws-sdk/middleware-user-agent/node_modules/@smithy/types/dist-cjs/index.js
generated
vendored
Normal file
91
extracted-source/node_modules/@aws-sdk/middleware-user-agent/node_modules/@smithy/types/dist-cjs/index.js
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
'use strict';
|
||||
|
||||
exports.HttpAuthLocation = void 0;
|
||||
(function (HttpAuthLocation) {
|
||||
HttpAuthLocation["HEADER"] = "header";
|
||||
HttpAuthLocation["QUERY"] = "query";
|
||||
})(exports.HttpAuthLocation || (exports.HttpAuthLocation = {}));
|
||||
|
||||
exports.HttpApiKeyAuthLocation = void 0;
|
||||
(function (HttpApiKeyAuthLocation) {
|
||||
HttpApiKeyAuthLocation["HEADER"] = "header";
|
||||
HttpApiKeyAuthLocation["QUERY"] = "query";
|
||||
})(exports.HttpApiKeyAuthLocation || (exports.HttpApiKeyAuthLocation = {}));
|
||||
|
||||
exports.EndpointURLScheme = void 0;
|
||||
(function (EndpointURLScheme) {
|
||||
EndpointURLScheme["HTTP"] = "http";
|
||||
EndpointURLScheme["HTTPS"] = "https";
|
||||
})(exports.EndpointURLScheme || (exports.EndpointURLScheme = {}));
|
||||
|
||||
exports.AlgorithmId = void 0;
|
||||
(function (AlgorithmId) {
|
||||
AlgorithmId["MD5"] = "md5";
|
||||
AlgorithmId["CRC32"] = "crc32";
|
||||
AlgorithmId["CRC32C"] = "crc32c";
|
||||
AlgorithmId["SHA1"] = "sha1";
|
||||
AlgorithmId["SHA256"] = "sha256";
|
||||
})(exports.AlgorithmId || (exports.AlgorithmId = {}));
|
||||
const getChecksumConfiguration = (runtimeConfig) => {
|
||||
const checksumAlgorithms = [];
|
||||
if (runtimeConfig.sha256 !== undefined) {
|
||||
checksumAlgorithms.push({
|
||||
algorithmId: () => exports.AlgorithmId.SHA256,
|
||||
checksumConstructor: () => runtimeConfig.sha256,
|
||||
});
|
||||
}
|
||||
if (runtimeConfig.md5 != undefined) {
|
||||
checksumAlgorithms.push({
|
||||
algorithmId: () => exports.AlgorithmId.MD5,
|
||||
checksumConstructor: () => runtimeConfig.md5,
|
||||
});
|
||||
}
|
||||
return {
|
||||
addChecksumAlgorithm(algo) {
|
||||
checksumAlgorithms.push(algo);
|
||||
},
|
||||
checksumAlgorithms() {
|
||||
return checksumAlgorithms;
|
||||
},
|
||||
};
|
||||
};
|
||||
const resolveChecksumRuntimeConfig = (clientConfig) => {
|
||||
const runtimeConfig = {};
|
||||
clientConfig.checksumAlgorithms().forEach((checksumAlgorithm) => {
|
||||
runtimeConfig[checksumAlgorithm.algorithmId()] = checksumAlgorithm.checksumConstructor();
|
||||
});
|
||||
return runtimeConfig;
|
||||
};
|
||||
|
||||
const getDefaultClientConfiguration = (runtimeConfig) => {
|
||||
return getChecksumConfiguration(runtimeConfig);
|
||||
};
|
||||
const resolveDefaultRuntimeConfig = (config) => {
|
||||
return resolveChecksumRuntimeConfig(config);
|
||||
};
|
||||
|
||||
exports.FieldPosition = void 0;
|
||||
(function (FieldPosition) {
|
||||
FieldPosition[FieldPosition["HEADER"] = 0] = "HEADER";
|
||||
FieldPosition[FieldPosition["TRAILER"] = 1] = "TRAILER";
|
||||
})(exports.FieldPosition || (exports.FieldPosition = {}));
|
||||
|
||||
const SMITHY_CONTEXT_KEY = "__smithy_context";
|
||||
|
||||
exports.IniSectionType = void 0;
|
||||
(function (IniSectionType) {
|
||||
IniSectionType["PROFILE"] = "profile";
|
||||
IniSectionType["SSO_SESSION"] = "sso-session";
|
||||
IniSectionType["SERVICES"] = "services";
|
||||
})(exports.IniSectionType || (exports.IniSectionType = {}));
|
||||
|
||||
exports.RequestHandlerProtocol = void 0;
|
||||
(function (RequestHandlerProtocol) {
|
||||
RequestHandlerProtocol["HTTP_0_9"] = "http/0.9";
|
||||
RequestHandlerProtocol["HTTP_1_0"] = "http/1.0";
|
||||
RequestHandlerProtocol["TDS_8_0"] = "tds/8.0";
|
||||
})(exports.RequestHandlerProtocol || (exports.RequestHandlerProtocol = {}));
|
||||
|
||||
exports.SMITHY_CONTEXT_KEY = SMITHY_CONTEXT_KEY;
|
||||
exports.getDefaultClientConfiguration = getDefaultClientConfiguration;
|
||||
exports.resolveDefaultRuntimeConfig = resolveDefaultRuntimeConfig;
|
||||
Reference in New Issue
Block a user