failure-lambda
Version:
Failure injection for AWS Lambda - chaos engineering made simple
1,524 lines (1,485 loc) • 180 kB
JavaScript
#!/usr/bin/env node
import {
loadConfig,
memoize,
parseUrl
} from "./chunk-2345QE66.js";
import {
CONFIG_PREFIX_SEPARATOR
} from "./chunk-52D4AVIU.js";
import {
HttpResponse,
escapeUri,
fromBase64,
fromHex,
toBase64,
toHex
} from "./chunk-W3M6RT2M.js";
import {
HttpRequest
} from "./chunk-XDZ73E2B.js";
import {
fromArrayBuffer,
fromString,
fromUtf8,
isArrayBuffer,
toUtf8
} from "./chunk-VACN7GDP.js";
import {
setCredentialFeature
} from "./chunk-S6KKH4HA.js";
// node_modules/@smithy/middleware-stack/dist-es/MiddlewareStack.js
var getAllAliases = (name, aliases) => {
const _aliases = [];
if (name) {
_aliases.push(name);
}
if (aliases) {
for (const alias of aliases) {
_aliases.push(alias);
}
}
return _aliases;
};
var getMiddlewareNameWithAliases = (name, aliases) => {
return `${name || "anonymous"}${aliases && aliases.length > 0 ? ` (a.k.a. ${aliases.join(",")})` : ""}`;
};
var constructStack = () => {
let absoluteEntries = [];
let relativeEntries = [];
let identifyOnResolve = false;
const entriesNameSet = /* @__PURE__ */ new Set();
const sort = (entries) => entries.sort((a, b) => stepWeights[b.step] - stepWeights[a.step] || priorityWeights[b.priority || "normal"] - priorityWeights[a.priority || "normal"]);
const removeByName = (toRemove) => {
let isRemoved = false;
const filterCb = (entry) => {
const aliases = getAllAliases(entry.name, entry.aliases);
if (aliases.includes(toRemove)) {
isRemoved = true;
for (const alias of aliases) {
entriesNameSet.delete(alias);
}
return false;
}
return true;
};
absoluteEntries = absoluteEntries.filter(filterCb);
relativeEntries = relativeEntries.filter(filterCb);
return isRemoved;
};
const removeByReference = (toRemove) => {
let isRemoved = false;
const filterCb = (entry) => {
if (entry.middleware === toRemove) {
isRemoved = true;
for (const alias of getAllAliases(entry.name, entry.aliases)) {
entriesNameSet.delete(alias);
}
return false;
}
return true;
};
absoluteEntries = absoluteEntries.filter(filterCb);
relativeEntries = relativeEntries.filter(filterCb);
return isRemoved;
};
const cloneTo = (toStack) => {
absoluteEntries.forEach((entry) => {
toStack.add(entry.middleware, { ...entry });
});
relativeEntries.forEach((entry) => {
toStack.addRelativeTo(entry.middleware, { ...entry });
});
toStack.identifyOnResolve?.(stack.identifyOnResolve());
return toStack;
};
const expandRelativeMiddlewareList = (from) => {
const expandedMiddlewareList = [];
from.before.forEach((entry) => {
if (entry.before.length === 0 && entry.after.length === 0) {
expandedMiddlewareList.push(entry);
} else {
expandedMiddlewareList.push(...expandRelativeMiddlewareList(entry));
}
});
expandedMiddlewareList.push(from);
from.after.reverse().forEach((entry) => {
if (entry.before.length === 0 && entry.after.length === 0) {
expandedMiddlewareList.push(entry);
} else {
expandedMiddlewareList.push(...expandRelativeMiddlewareList(entry));
}
});
return expandedMiddlewareList;
};
const getMiddlewareList = (debug = false) => {
const normalizedAbsoluteEntries = [];
const normalizedRelativeEntries = [];
const normalizedEntriesNameMap = {};
absoluteEntries.forEach((entry) => {
const normalizedEntry = {
...entry,
before: [],
after: []
};
for (const alias of getAllAliases(normalizedEntry.name, normalizedEntry.aliases)) {
normalizedEntriesNameMap[alias] = normalizedEntry;
}
normalizedAbsoluteEntries.push(normalizedEntry);
});
relativeEntries.forEach((entry) => {
const normalizedEntry = {
...entry,
before: [],
after: []
};
for (const alias of getAllAliases(normalizedEntry.name, normalizedEntry.aliases)) {
normalizedEntriesNameMap[alias] = normalizedEntry;
}
normalizedRelativeEntries.push(normalizedEntry);
});
normalizedRelativeEntries.forEach((entry) => {
if (entry.toMiddleware) {
const toMiddleware = normalizedEntriesNameMap[entry.toMiddleware];
if (toMiddleware === void 0) {
if (debug) {
return;
}
throw new Error(`${entry.toMiddleware} is not found when adding ${getMiddlewareNameWithAliases(entry.name, entry.aliases)} middleware ${entry.relation} ${entry.toMiddleware}`);
}
if (entry.relation === "after") {
toMiddleware.after.push(entry);
}
if (entry.relation === "before") {
toMiddleware.before.push(entry);
}
}
});
const mainChain = sort(normalizedAbsoluteEntries).map(expandRelativeMiddlewareList).reduce((wholeList, expandedMiddlewareList) => {
wholeList.push(...expandedMiddlewareList);
return wholeList;
}, []);
return mainChain;
};
const stack = {
add: (middleware, options = {}) => {
const { name, override, aliases: _aliases } = options;
const entry = {
step: "initialize",
priority: "normal",
middleware,
...options
};
const aliases = getAllAliases(name, _aliases);
if (aliases.length > 0) {
if (aliases.some((alias) => entriesNameSet.has(alias))) {
if (!override)
throw new Error(`Duplicate middleware name '${getMiddlewareNameWithAliases(name, _aliases)}'`);
for (const alias of aliases) {
const toOverrideIndex = absoluteEntries.findIndex((entry2) => entry2.name === alias || entry2.aliases?.some((a) => a === alias));
if (toOverrideIndex === -1) {
continue;
}
const toOverride = absoluteEntries[toOverrideIndex];
if (toOverride.step !== entry.step || entry.priority !== toOverride.priority) {
throw new Error(`"${getMiddlewareNameWithAliases(toOverride.name, toOverride.aliases)}" middleware with ${toOverride.priority} priority in ${toOverride.step} step cannot be overridden by "${getMiddlewareNameWithAliases(name, _aliases)}" middleware with ${entry.priority} priority in ${entry.step} step.`);
}
absoluteEntries.splice(toOverrideIndex, 1);
}
}
for (const alias of aliases) {
entriesNameSet.add(alias);
}
}
absoluteEntries.push(entry);
},
addRelativeTo: (middleware, options) => {
const { name, override, aliases: _aliases } = options;
const entry = {
middleware,
...options
};
const aliases = getAllAliases(name, _aliases);
if (aliases.length > 0) {
if (aliases.some((alias) => entriesNameSet.has(alias))) {
if (!override)
throw new Error(`Duplicate middleware name '${getMiddlewareNameWithAliases(name, _aliases)}'`);
for (const alias of aliases) {
const toOverrideIndex = relativeEntries.findIndex((entry2) => entry2.name === alias || entry2.aliases?.some((a) => a === alias));
if (toOverrideIndex === -1) {
continue;
}
const toOverride = relativeEntries[toOverrideIndex];
if (toOverride.toMiddleware !== entry.toMiddleware || toOverride.relation !== entry.relation) {
throw new Error(`"${getMiddlewareNameWithAliases(toOverride.name, toOverride.aliases)}" middleware ${toOverride.relation} "${toOverride.toMiddleware}" middleware cannot be overridden by "${getMiddlewareNameWithAliases(name, _aliases)}" middleware ${entry.relation} "${entry.toMiddleware}" middleware.`);
}
relativeEntries.splice(toOverrideIndex, 1);
}
}
for (const alias of aliases) {
entriesNameSet.add(alias);
}
}
relativeEntries.push(entry);
},
clone: () => cloneTo(constructStack()),
use: (plugin) => {
plugin.applyToStack(stack);
},
remove: (toRemove) => {
if (typeof toRemove === "string")
return removeByName(toRemove);
else
return removeByReference(toRemove);
},
removeByTag: (toRemove) => {
let isRemoved = false;
const filterCb = (entry) => {
const { tags, name, aliases: _aliases } = entry;
if (tags && tags.includes(toRemove)) {
const aliases = getAllAliases(name, _aliases);
for (const alias of aliases) {
entriesNameSet.delete(alias);
}
isRemoved = true;
return false;
}
return true;
};
absoluteEntries = absoluteEntries.filter(filterCb);
relativeEntries = relativeEntries.filter(filterCb);
return isRemoved;
},
concat: (from) => {
const cloned = cloneTo(constructStack());
cloned.use(from);
cloned.identifyOnResolve(identifyOnResolve || cloned.identifyOnResolve() || (from.identifyOnResolve?.() ?? false));
return cloned;
},
applyToStack: cloneTo,
identify: () => {
return getMiddlewareList(true).map((mw) => {
const step = mw.step ?? mw.relation + " " + mw.toMiddleware;
return getMiddlewareNameWithAliases(mw.name, mw.aliases) + " - " + step;
});
},
identifyOnResolve(toggle) {
if (typeof toggle === "boolean")
identifyOnResolve = toggle;
return identifyOnResolve;
},
resolve: (handler, context) => {
for (const middleware of getMiddlewareList().map((entry) => entry.middleware).reverse()) {
handler = middleware(handler, context);
}
if (identifyOnResolve) {
console.log(stack.identify());
}
return handler;
}
};
return stack;
};
var stepWeights = {
initialize: 5,
serialize: 4,
build: 3,
finalizeRequest: 2,
deserialize: 1
};
var priorityWeights = {
high: 3,
normal: 2,
low: 1
};
// node_modules/@smithy/smithy-client/dist-es/client.js
var Client = class {
config;
middlewareStack = constructStack();
initConfig;
handlers;
constructor(config) {
this.config = config;
const { protocol, protocolSettings } = config;
if (protocolSettings) {
if (typeof protocol === "function") {
config.protocol = new protocol(protocolSettings);
}
}
}
send(command, optionsOrCb, cb) {
const options = typeof optionsOrCb !== "function" ? optionsOrCb : void 0;
const callback = typeof optionsOrCb === "function" ? optionsOrCb : cb;
const useHandlerCache = options === void 0 && this.config.cacheMiddleware === true;
let handler;
if (useHandlerCache) {
if (!this.handlers) {
this.handlers = /* @__PURE__ */ new WeakMap();
}
const handlers = this.handlers;
if (handlers.has(command.constructor)) {
handler = handlers.get(command.constructor);
} else {
handler = command.resolveMiddleware(this.middlewareStack, this.config, options);
handlers.set(command.constructor, handler);
}
} else {
delete this.handlers;
handler = command.resolveMiddleware(this.middlewareStack, this.config, options);
}
if (callback) {
handler(command).then((result) => callback(null, result.output), (err) => callback(err)).catch(() => {
});
} else {
return handler(command).then((result) => result.output);
}
}
destroy() {
this.config?.requestHandler?.destroy?.();
delete this.handlers;
}
};
// node_modules/@smithy/types/dist-es/endpoint.js
var EndpointURLScheme;
(function(EndpointURLScheme2) {
EndpointURLScheme2["HTTP"] = "http";
EndpointURLScheme2["HTTPS"] = "https";
})(EndpointURLScheme || (EndpointURLScheme = {}));
// node_modules/@smithy/types/dist-es/extensions/checksum.js
var AlgorithmId;
(function(AlgorithmId2) {
AlgorithmId2["MD5"] = "md5";
AlgorithmId2["CRC32"] = "crc32";
AlgorithmId2["CRC32C"] = "crc32c";
AlgorithmId2["SHA1"] = "sha1";
AlgorithmId2["SHA256"] = "sha256";
})(AlgorithmId || (AlgorithmId = {}));
// node_modules/@smithy/types/dist-es/middleware.js
var SMITHY_CONTEXT_KEY = "__smithy_context";
// node_modules/@smithy/core/dist-es/submodules/schema/deref.js
var deref = (schemaRef) => {
if (typeof schemaRef === "function") {
return schemaRef();
}
return schemaRef;
};
// node_modules/@smithy/protocol-http/dist-es/extensions/httpExtensionConfiguration.js
var 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();
}
};
};
var resolveHttpHandlerRuntimeConfig = (httpHandlerExtensionConfiguration) => {
return {
httpHandler: httpHandlerExtensionConfiguration.httpHandler()
};
};
// node_modules/@smithy/util-middleware/dist-es/getSmithyContext.js
var getSmithyContext = (context) => context[SMITHY_CONTEXT_KEY] || (context[SMITHY_CONTEXT_KEY] = {});
// node_modules/@smithy/util-middleware/dist-es/normalizeProvider.js
var normalizeProvider = (input) => {
if (typeof input === "function")
return input;
const promisified = Promise.resolve(input);
return () => promisified;
};
// node_modules/@smithy/core/dist-es/submodules/schema/schemas/operation.js
var operation = (namespace, name, traits, input, output) => ({
name,
namespace,
traits,
input,
output
});
// node_modules/@smithy/core/dist-es/submodules/schema/middleware/schemaDeserializationMiddleware.js
var schemaDeserializationMiddleware = (config) => (next, context) => async (args) => {
const { response } = await next(args);
const { operationSchema } = getSmithyContext(context);
const [, ns, n, t, i, o] = operationSchema ?? [];
try {
const parsed = await config.protocol.deserializeResponse(operation(ns, n, t, i, o), {
...config,
...context
}, response);
return {
response,
output: parsed
};
} catch (error) {
Object.defineProperty(error, "$response", {
value: response,
enumerable: false,
writable: false,
configurable: false
});
if (!("$metadata" in error)) {
const hint = `Deserialization error: to see the raw response, inspect the hidden field {error}.$response on this object.`;
try {
error.message += "\n " + hint;
} catch (e) {
if (!context.logger || context.logger?.constructor?.name === "NoOpLogger") {
console.warn(hint);
} else {
context.logger?.warn?.(hint);
}
}
if (typeof error.$responseBodyText !== "undefined") {
if (error.$response) {
error.$response.body = error.$responseBodyText;
}
}
try {
if (HttpResponse.isInstance(response)) {
const { headers = {} } = response;
const headerEntries = Object.entries(headers);
error.$metadata = {
httpStatusCode: response.statusCode,
requestId: findHeader(/^x-[\w-]+-request-?id$/, headerEntries),
extendedRequestId: findHeader(/^x-[\w-]+-id-2$/, headerEntries),
cfId: findHeader(/^x-[\w-]+-cf-id$/, headerEntries)
};
}
} catch (e) {
}
}
throw error;
}
};
var findHeader = (pattern, headers) => {
return (headers.find(([k]) => {
return k.match(pattern);
}) || [void 0, void 0])[1];
};
// node_modules/@smithy/core/dist-es/submodules/schema/middleware/schemaSerializationMiddleware.js
var schemaSerializationMiddleware = (config) => (next, context) => async (args) => {
const { operationSchema } = getSmithyContext(context);
const [, ns, n, t, i, o] = operationSchema ?? [];
const endpoint = context.endpointV2?.url && config.urlParser ? async () => config.urlParser(context.endpointV2.url) : config.endpoint;
const request = await config.protocol.serializeRequest(operation(ns, n, t, i, o), args.input, {
...config,
...context,
endpoint
});
return next({
...args,
request
});
};
// node_modules/@smithy/core/dist-es/submodules/schema/middleware/getSchemaSerdePlugin.js
var deserializerMiddlewareOption = {
name: "deserializerMiddleware",
step: "deserialize",
tags: ["DESERIALIZER"],
override: true
};
var serializerMiddlewareOption = {
name: "serializerMiddleware",
step: "serialize",
tags: ["SERIALIZER"],
override: true
};
function getSchemaSerdePlugin(config) {
return {
applyToStack: (commandStack) => {
commandStack.add(schemaSerializationMiddleware(config), serializerMiddlewareOption);
commandStack.add(schemaDeserializationMiddleware(config), deserializerMiddlewareOption);
config.protocol.setSerdeContext(config);
}
};
}
// node_modules/@smithy/core/dist-es/submodules/schema/schemas/translateTraits.js
function translateTraits(indicator) {
if (typeof indicator === "object") {
return indicator;
}
indicator = indicator | 0;
const traits = {};
let i = 0;
for (const trait of [
"httpLabel",
"idempotent",
"idempotencyToken",
"sensitive",
"httpPayload",
"httpResponseCode",
"httpQueryParams"
]) {
if ((indicator >> i++ & 1) === 1) {
traits[trait] = 1;
}
}
return traits;
}
// node_modules/@smithy/core/dist-es/submodules/schema/schemas/NormalizedSchema.js
var anno = {
it: /* @__PURE__ */ Symbol.for("@smithy/nor-struct-it")
};
var NormalizedSchema = class _NormalizedSchema {
ref;
memberName;
static symbol = /* @__PURE__ */ Symbol.for("@smithy/nor");
symbol = _NormalizedSchema.symbol;
name;
schema;
_isMemberSchema;
traits;
memberTraits;
normalizedTraits;
constructor(ref, memberName) {
this.ref = ref;
this.memberName = memberName;
const traitStack = [];
let _ref = ref;
let schema = ref;
this._isMemberSchema = false;
while (isMemberSchema(_ref)) {
traitStack.push(_ref[1]);
_ref = _ref[0];
schema = deref(_ref);
this._isMemberSchema = true;
}
if (traitStack.length > 0) {
this.memberTraits = {};
for (let i = traitStack.length - 1; i >= 0; --i) {
const traitSet = traitStack[i];
Object.assign(this.memberTraits, translateTraits(traitSet));
}
} else {
this.memberTraits = 0;
}
if (schema instanceof _NormalizedSchema) {
const computedMemberTraits = this.memberTraits;
Object.assign(this, schema);
this.memberTraits = Object.assign({}, computedMemberTraits, schema.getMemberTraits(), this.getMemberTraits());
this.normalizedTraits = void 0;
this.memberName = memberName ?? schema.memberName;
return;
}
this.schema = deref(schema);
if (isStaticSchema(this.schema)) {
this.name = `${this.schema[1]}#${this.schema[2]}`;
this.traits = this.schema[3];
} else {
this.name = this.memberName ?? String(schema);
this.traits = 0;
}
if (this._isMemberSchema && !memberName) {
throw new Error(`@smithy/core/schema - NormalizedSchema member init ${this.getName(true)} missing member name.`);
}
}
static [Symbol.hasInstance](lhs) {
const isPrototype = this.prototype.isPrototypeOf(lhs);
if (!isPrototype && typeof lhs === "object" && lhs !== null) {
const ns = lhs;
return ns.symbol === this.symbol;
}
return isPrototype;
}
static of(ref) {
const sc = deref(ref);
if (sc instanceof _NormalizedSchema) {
return sc;
}
if (isMemberSchema(sc)) {
const [ns, traits] = sc;
if (ns instanceof _NormalizedSchema) {
Object.assign(ns.getMergedTraits(), translateTraits(traits));
return ns;
}
throw new Error(`@smithy/core/schema - may not init unwrapped member schema=${JSON.stringify(ref, null, 2)}.`);
}
return new _NormalizedSchema(sc);
}
getSchema() {
const sc = this.schema;
if (Array.isArray(sc) && sc[0] === 0) {
return sc[4];
}
return sc;
}
getName(withNamespace = false) {
const { name } = this;
const short = !withNamespace && name && name.includes("#");
return short ? name.split("#")[1] : name || void 0;
}
getMemberName() {
return this.memberName;
}
isMemberSchema() {
return this._isMemberSchema;
}
isListSchema() {
const sc = this.getSchema();
return typeof sc === "number" ? sc >= 64 && sc < 128 : sc[0] === 1;
}
isMapSchema() {
const sc = this.getSchema();
return typeof sc === "number" ? sc >= 128 && sc <= 255 : sc[0] === 2;
}
isStructSchema() {
const sc = this.getSchema();
if (typeof sc !== "object") {
return false;
}
const id = sc[0];
return id === 3 || id === -3 || id === 4;
}
isUnionSchema() {
const sc = this.getSchema();
if (typeof sc !== "object") {
return false;
}
return sc[0] === 4;
}
isBlobSchema() {
const sc = this.getSchema();
return sc === 21 || sc === 42;
}
isTimestampSchema() {
const sc = this.getSchema();
return typeof sc === "number" && sc >= 4 && sc <= 7;
}
isUnitSchema() {
return this.getSchema() === "unit";
}
isDocumentSchema() {
return this.getSchema() === 15;
}
isStringSchema() {
return this.getSchema() === 0;
}
isBooleanSchema() {
return this.getSchema() === 2;
}
isNumericSchema() {
return this.getSchema() === 1;
}
isBigIntegerSchema() {
return this.getSchema() === 17;
}
isBigDecimalSchema() {
return this.getSchema() === 19;
}
isStreaming() {
const { streaming } = this.getMergedTraits();
return !!streaming || this.getSchema() === 42;
}
isIdempotencyToken() {
return !!this.getMergedTraits().idempotencyToken;
}
getMergedTraits() {
return this.normalizedTraits ?? (this.normalizedTraits = {
...this.getOwnTraits(),
...this.getMemberTraits()
});
}
getMemberTraits() {
return translateTraits(this.memberTraits);
}
getOwnTraits() {
return translateTraits(this.traits);
}
getKeySchema() {
const [isDoc, isMap] = [this.isDocumentSchema(), this.isMapSchema()];
if (!isDoc && !isMap) {
throw new Error(`@smithy/core/schema - cannot get key for non-map: ${this.getName(true)}`);
}
const schema = this.getSchema();
const memberSchema = isDoc ? 15 : schema[4] ?? 0;
return member([memberSchema, 0], "key");
}
getValueSchema() {
const sc = this.getSchema();
const [isDoc, isMap, isList] = [this.isDocumentSchema(), this.isMapSchema(), this.isListSchema()];
const memberSchema = typeof sc === "number" ? 63 & sc : sc && typeof sc === "object" && (isMap || isList) ? sc[3 + sc[0]] : isDoc ? 15 : void 0;
if (memberSchema != null) {
return member([memberSchema, 0], isMap ? "value" : "member");
}
throw new Error(`@smithy/core/schema - ${this.getName(true)} has no value member.`);
}
getMemberSchema(memberName) {
const struct = this.getSchema();
if (this.isStructSchema() && struct[4].includes(memberName)) {
const i = struct[4].indexOf(memberName);
const memberSchema = struct[5][i];
return member(isMemberSchema(memberSchema) ? memberSchema : [memberSchema, 0], memberName);
}
if (this.isDocumentSchema()) {
return member([15, 0], memberName);
}
throw new Error(`@smithy/core/schema - ${this.getName(true)} has no no member=${memberName}.`);
}
getMemberSchemas() {
const buffer = {};
try {
for (const [k, v] of this.structIterator()) {
buffer[k] = v;
}
} catch (ignored) {
}
return buffer;
}
getEventStreamMember() {
if (this.isStructSchema()) {
for (const [memberName, memberSchema] of this.structIterator()) {
if (memberSchema.isStreaming() && memberSchema.isStructSchema()) {
return memberName;
}
}
}
return "";
}
*structIterator() {
if (this.isUnitSchema()) {
return;
}
if (!this.isStructSchema()) {
throw new Error("@smithy/core/schema - cannot iterate non-struct schema.");
}
const struct = this.getSchema();
const z = struct[4].length;
let it = struct[anno.it];
if (it && z === it.length) {
yield* it;
return;
}
it = Array(z);
for (let i = 0; i < z; ++i) {
const k = struct[4][i];
const v = member([struct[5][i], 0], k);
yield it[i] = [k, v];
}
struct[anno.it] = it;
}
};
function member(memberSchema, memberName) {
if (memberSchema instanceof NormalizedSchema) {
return Object.assign(memberSchema, {
memberName,
_isMemberSchema: true
});
}
const internalCtorAccess = NormalizedSchema;
return new internalCtorAccess(memberSchema, memberName);
}
var isMemberSchema = (sc) => Array.isArray(sc) && sc.length === 2;
var isStaticSchema = (sc) => Array.isArray(sc) && sc.length >= 5;
// node_modules/@smithy/core/dist-es/submodules/schema/TypeRegistry.js
var TypeRegistry = class _TypeRegistry {
namespace;
schemas;
exceptions;
static registries = /* @__PURE__ */ new Map();
constructor(namespace, schemas = /* @__PURE__ */ new Map(), exceptions = /* @__PURE__ */ new Map()) {
this.namespace = namespace;
this.schemas = schemas;
this.exceptions = exceptions;
}
static for(namespace) {
if (!_TypeRegistry.registries.has(namespace)) {
_TypeRegistry.registries.set(namespace, new _TypeRegistry(namespace));
}
return _TypeRegistry.registries.get(namespace);
}
copyFrom(other) {
const { schemas, exceptions } = this;
for (const [k, v] of other.schemas) {
if (!schemas.has(k)) {
schemas.set(k, v);
}
}
for (const [k, v] of other.exceptions) {
if (!exceptions.has(k)) {
exceptions.set(k, v);
}
}
}
register(shapeId, schema) {
const qualifiedName = this.normalizeShapeId(shapeId);
for (const r of [this, _TypeRegistry.for(qualifiedName.split("#")[0])]) {
r.schemas.set(qualifiedName, schema);
}
}
getSchema(shapeId) {
const id = this.normalizeShapeId(shapeId);
if (!this.schemas.has(id)) {
throw new Error(`@smithy/core/schema - schema not found for ${id}`);
}
return this.schemas.get(id);
}
registerError(es, ctor) {
const $error = es;
const ns = $error[1];
for (const r of [this, _TypeRegistry.for(ns)]) {
r.schemas.set(ns + "#" + $error[2], $error);
r.exceptions.set($error, ctor);
}
}
getErrorCtor(es) {
const $error = es;
if (this.exceptions.has($error)) {
return this.exceptions.get($error);
}
const registry = _TypeRegistry.for($error[1]);
return registry.exceptions.get($error);
}
getBaseException() {
for (const exceptionKey of this.exceptions.keys()) {
if (Array.isArray(exceptionKey)) {
const [, ns, name] = exceptionKey;
const id = ns + "#" + name;
if (id.startsWith("smithy.ts.sdk.synthetic.") && id.endsWith("ServiceException")) {
return exceptionKey;
}
}
}
return void 0;
}
find(predicate) {
return [...this.schemas.values()].find(predicate);
}
clear() {
this.schemas.clear();
this.exceptions.clear();
}
normalizeShapeId(shapeId) {
if (shapeId.includes("#")) {
return shapeId;
}
return this.namespace + "#" + shapeId;
}
};
// node_modules/@smithy/smithy-client/dist-es/schemaLogFilter.js
var SENSITIVE_STRING = "***SensitiveInformation***";
function schemaLogFilter(schema, data) {
if (data == null) {
return data;
}
const ns = NormalizedSchema.of(schema);
if (ns.getMergedTraits().sensitive) {
return SENSITIVE_STRING;
}
if (ns.isListSchema()) {
const isSensitive = !!ns.getValueSchema().getMergedTraits().sensitive;
if (isSensitive) {
return SENSITIVE_STRING;
}
} else if (ns.isMapSchema()) {
const isSensitive = !!ns.getKeySchema().getMergedTraits().sensitive || !!ns.getValueSchema().getMergedTraits().sensitive;
if (isSensitive) {
return SENSITIVE_STRING;
}
} else if (ns.isStructSchema() && typeof data === "object") {
const object = data;
const newObject = {};
for (const [member2, memberNs] of ns.structIterator()) {
if (object[member2] != null) {
newObject[member2] = schemaLogFilter(memberNs, object[member2]);
}
}
return newObject;
}
return data;
}
// node_modules/@smithy/smithy-client/dist-es/command.js
var Command = class {
middlewareStack = constructStack();
schema;
static classBuilder() {
return new ClassBuilder();
}
resolveMiddlewareWithContext(clientStack, configuration, options, { middlewareFn, clientName, commandName, inputFilterSensitiveLog, outputFilterSensitiveLog, smithyContext, additionalContext, CommandCtor }) {
for (const mw of middlewareFn.bind(this)(CommandCtor, clientStack, configuration, options)) {
this.middlewareStack.use(mw);
}
const stack = clientStack.concat(this.middlewareStack);
const { logger } = configuration;
const handlerExecutionContext = {
logger,
clientName,
commandName,
inputFilterSensitiveLog,
outputFilterSensitiveLog,
[SMITHY_CONTEXT_KEY]: {
commandInstance: this,
...smithyContext
},
...additionalContext
};
const { requestHandler } = configuration;
return stack.resolve((request) => requestHandler.handle(request.request, options || {}), handlerExecutionContext);
}
};
var ClassBuilder = class {
_init = () => {
};
_ep = {};
_middlewareFn = () => [];
_commandName = "";
_clientName = "";
_additionalContext = {};
_smithyContext = {};
_inputFilterSensitiveLog = void 0;
_outputFilterSensitiveLog = void 0;
_serializer = null;
_deserializer = null;
_operationSchema;
init(cb) {
this._init = cb;
}
ep(endpointParameterInstructions) {
this._ep = endpointParameterInstructions;
return this;
}
m(middlewareSupplier) {
this._middlewareFn = middlewareSupplier;
return this;
}
s(service, operation2, smithyContext = {}) {
this._smithyContext = {
service,
operation: operation2,
...smithyContext
};
return this;
}
c(additionalContext = {}) {
this._additionalContext = additionalContext;
return this;
}
n(clientName, commandName) {
this._clientName = clientName;
this._commandName = commandName;
return this;
}
f(inputFilter = (_) => _, outputFilter = (_) => _) {
this._inputFilterSensitiveLog = inputFilter;
this._outputFilterSensitiveLog = outputFilter;
return this;
}
ser(serializer) {
this._serializer = serializer;
return this;
}
de(deserializer) {
this._deserializer = deserializer;
return this;
}
sc(operation2) {
this._operationSchema = operation2;
this._smithyContext.operationSchema = operation2;
return this;
}
build() {
const closure = this;
let CommandRef;
return CommandRef = class extends Command {
input;
static getEndpointParameterInstructions() {
return closure._ep;
}
constructor(...[input]) {
super();
this.input = input ?? {};
closure._init(this);
this.schema = closure._operationSchema;
}
resolveMiddleware(stack, configuration, options) {
const op = closure._operationSchema;
const input = op?.[4] ?? op?.input;
const output = op?.[5] ?? op?.output;
return this.resolveMiddlewareWithContext(stack, configuration, options, {
CommandCtor: CommandRef,
middlewareFn: closure._middlewareFn,
clientName: closure._clientName,
commandName: closure._commandName,
inputFilterSensitiveLog: closure._inputFilterSensitiveLog ?? (op ? schemaLogFilter.bind(null, input) : (_) => _),
outputFilterSensitiveLog: closure._outputFilterSensitiveLog ?? (op ? schemaLogFilter.bind(null, output) : (_) => _),
smithyContext: closure._smithyContext,
additionalContext: closure._additionalContext
});
}
serialize = closure._serializer;
deserialize = closure._deserializer;
};
}
};
// node_modules/@aws-sdk/middleware-host-header/dist-es/index.js
function resolveHostHeaderConfig(input) {
return input;
}
var hostHeaderMiddleware = (options) => (next) => async (args) => {
if (!HttpRequest.isInstance(args.request))
return next(args);
const { request } = args;
const { handlerProtocol = "" } = options.requestHandler.metadata || {};
if (handlerProtocol.indexOf("h2") >= 0 && !request.headers[":authority"]) {
delete request.headers["host"];
request.headers[":authority"] = request.hostname + (request.port ? ":" + request.port : "");
} else if (!request.headers["host"]) {
let host = request.hostname;
if (request.port != null)
host += `:${request.port}`;
request.headers["host"] = host;
}
return next(args);
};
var hostHeaderMiddlewareOptions = {
name: "hostHeaderMiddleware",
step: "build",
priority: "low",
tags: ["HOST"],
override: true
};
var getHostHeaderPlugin = (options) => ({
applyToStack: (clientStack) => {
clientStack.add(hostHeaderMiddleware(options), hostHeaderMiddlewareOptions);
}
});
// node_modules/@aws-sdk/middleware-logger/dist-es/loggerMiddleware.js
var loggerMiddleware = () => (next, context) => async (args) => {
try {
const response = await next(args);
const { clientName, commandName, logger, dynamoDbDocumentClientOptions = {} } = context;
const { overrideInputFilterSensitiveLog, overrideOutputFilterSensitiveLog } = dynamoDbDocumentClientOptions;
const inputFilterSensitiveLog = overrideInputFilterSensitiveLog ?? context.inputFilterSensitiveLog;
const outputFilterSensitiveLog = overrideOutputFilterSensitiveLog ?? context.outputFilterSensitiveLog;
const { $metadata, ...outputWithoutMetadata } = response.output;
logger?.info?.({
clientName,
commandName,
input: inputFilterSensitiveLog(args.input),
output: outputFilterSensitiveLog(outputWithoutMetadata),
metadata: $metadata
});
return response;
} catch (error) {
const { clientName, commandName, logger, dynamoDbDocumentClientOptions = {} } = context;
const { overrideInputFilterSensitiveLog } = dynamoDbDocumentClientOptions;
const inputFilterSensitiveLog = overrideInputFilterSensitiveLog ?? context.inputFilterSensitiveLog;
logger?.error?.({
clientName,
commandName,
input: inputFilterSensitiveLog(args.input),
error,
metadata: error.$metadata
});
throw error;
}
};
var loggerMiddlewareOptions = {
name: "loggerMiddleware",
tags: ["LOGGER"],
step: "initialize",
override: true
};
var getLoggerPlugin = (options) => ({
applyToStack: (clientStack) => {
clientStack.add(loggerMiddleware(), loggerMiddlewareOptions);
}
});
// node_modules/@aws-sdk/middleware-recursion-detection/dist-es/configuration.js
var recursionDetectionMiddlewareOptions = {
step: "build",
tags: ["RECURSION_DETECTION"],
name: "recursionDetectionMiddleware",
override: true,
priority: "low"
};
// node_modules/@aws/lambda-invoke-store/dist-es/invoke-store.js
var PROTECTED_KEYS = {
REQUEST_ID: /* @__PURE__ */ Symbol.for("_AWS_LAMBDA_REQUEST_ID"),
X_RAY_TRACE_ID: /* @__PURE__ */ Symbol.for("_AWS_LAMBDA_X_RAY_TRACE_ID"),
TENANT_ID: /* @__PURE__ */ Symbol.for("_AWS_LAMBDA_TENANT_ID")
};
var NO_GLOBAL_AWS_LAMBDA = ["true", "1"].includes(process.env?.AWS_LAMBDA_NODEJS_NO_GLOBAL_AWSLAMBDA ?? "");
if (!NO_GLOBAL_AWS_LAMBDA) {
globalThis.awslambda = globalThis.awslambda || {};
}
var InvokeStoreBase = class {
static PROTECTED_KEYS = PROTECTED_KEYS;
isProtectedKey(key) {
return Object.values(PROTECTED_KEYS).includes(key);
}
getRequestId() {
return this.get(PROTECTED_KEYS.REQUEST_ID) ?? "-";
}
getXRayTraceId() {
return this.get(PROTECTED_KEYS.X_RAY_TRACE_ID);
}
getTenantId() {
return this.get(PROTECTED_KEYS.TENANT_ID);
}
};
var InvokeStoreSingle = class extends InvokeStoreBase {
currentContext;
getContext() {
return this.currentContext;
}
hasContext() {
return this.currentContext !== void 0;
}
get(key) {
return this.currentContext?.[key];
}
set(key, value) {
if (this.isProtectedKey(key)) {
throw new Error(`Cannot modify protected Lambda context field: ${String(key)}`);
}
this.currentContext = this.currentContext || {};
this.currentContext[key] = value;
}
run(context, fn) {
this.currentContext = context;
return fn();
}
};
var InvokeStoreMulti = class _InvokeStoreMulti extends InvokeStoreBase {
als;
static async create() {
const instance = new _InvokeStoreMulti();
const asyncHooks = await import("async_hooks");
instance.als = new asyncHooks.AsyncLocalStorage();
return instance;
}
getContext() {
return this.als.getStore();
}
hasContext() {
return this.als.getStore() !== void 0;
}
get(key) {
return this.als.getStore()?.[key];
}
set(key, value) {
if (this.isProtectedKey(key)) {
throw new Error(`Cannot modify protected Lambda context field: ${String(key)}`);
}
const store = this.als.getStore();
if (!store) {
throw new Error("No context available");
}
store[key] = value;
}
run(context, fn) {
return this.als.run(context, fn);
}
};
var InvokeStore;
(function(InvokeStore2) {
let instance = null;
async function getInstanceAsync() {
if (!instance) {
instance = (async () => {
const isMulti = "AWS_LAMBDA_MAX_CONCURRENCY" in process.env;
const newInstance = isMulti ? await InvokeStoreMulti.create() : new InvokeStoreSingle();
if (!NO_GLOBAL_AWS_LAMBDA && globalThis.awslambda?.InvokeStore) {
return globalThis.awslambda.InvokeStore;
} else if (!NO_GLOBAL_AWS_LAMBDA && globalThis.awslambda) {
globalThis.awslambda.InvokeStore = newInstance;
return newInstance;
} else {
return newInstance;
}
})();
}
return instance;
}
InvokeStore2.getInstanceAsync = getInstanceAsync;
InvokeStore2._testing = process.env.AWS_LAMBDA_BENCHMARK_MODE === "1" ? {
reset: () => {
instance = null;
if (globalThis.awslambda?.InvokeStore) {
delete globalThis.awslambda.InvokeStore;
}
globalThis.awslambda = { InvokeStore: void 0 };
}
} : void 0;
})(InvokeStore || (InvokeStore = {}));
// node_modules/@aws-sdk/middleware-recursion-detection/dist-es/recursionDetectionMiddleware.js
var TRACE_ID_HEADER_NAME = "X-Amzn-Trace-Id";
var ENV_LAMBDA_FUNCTION_NAME = "AWS_LAMBDA_FUNCTION_NAME";
var ENV_TRACE_ID = "_X_AMZN_TRACE_ID";
var recursionDetectionMiddleware = () => (next) => async (args) => {
const { request } = args;
if (!HttpRequest.isInstance(request)) {
return next(args);
}
const traceIdHeader = Object.keys(request.headers ?? {}).find((h) => h.toLowerCase() === TRACE_ID_HEADER_NAME.toLowerCase()) ?? TRACE_ID_HEADER_NAME;
if (request.headers.hasOwnProperty(traceIdHeader)) {
return next(args);
}
const functionName = process.env[ENV_LAMBDA_FUNCTION_NAME];
const traceIdFromEnv = process.env[ENV_TRACE_ID];
const invokeStore = await InvokeStore.getInstanceAsync();
const traceIdFromInvokeStore = invokeStore?.getXRayTraceId();
const traceId = traceIdFromInvokeStore ?? traceIdFromEnv;
const nonEmptyString = (str) => typeof str === "string" && str.length > 0;
if (nonEmptyString(functionName) && nonEmptyString(traceId)) {
request.headers[TRACE_ID_HEADER_NAME] = traceId;
}
return next({
...args,
request
});
};
// node_modules/@aws-sdk/middleware-recursion-detection/dist-es/getRecursionDetectionPlugin.js
var getRecursionDetectionPlugin = (options) => ({
applyToStack: (clientStack) => {
clientStack.add(recursionDetectionMiddleware(), recursionDetectionMiddlewareOptions);
}
});
// node_modules/@smithy/core/dist-es/middleware-http-auth-scheme/resolveAuthOptions.js
var 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;
};
// node_modules/@smithy/core/dist-es/middleware-http-auth-scheme/httpAuthSchemeMiddleware.js
function convertHttpAuthSchemesToMap(httpAuthSchemes) {
const map = /* @__PURE__ */ new Map();
for (const scheme of httpAuthSchemes) {
map.set(scheme.schemeId, scheme);
}
return map;
}
var 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);
};
// node_modules/@smithy/core/dist-es/middleware-http-auth-scheme/getHttpAuthSchemeEndpointRuleSetPlugin.js
var httpAuthSchemeEndpointRuleSetMiddlewareOptions = {
step: "serialize",
tags: ["HTTP_AUTH_SCHEME"],
name: "httpAuthSchemeMiddleware",
override: true,
relation: "before",
toMiddleware: "endpointV2Middleware"
};
var getHttpAuthSchemeEndpointRuleSetPlugin = (config, { httpAuthSchemeParametersProvider, identityProviderConfigProvider }) => ({
applyToStack: (clientStack) => {
clientStack.addRelativeTo(httpAuthSchemeMiddleware(config, {
httpAuthSchemeParametersProvider,
identityProviderConfigProvider
}), httpAuthSchemeEndpointRuleSetMiddlewareOptions);
}
});
// node_modules/@smithy/core/dist-es/middleware-http-signing/httpSigningMiddleware.js
var defaultErrorHandler = (signingProperties) => (error) => {
throw error;
};
var defaultSuccessHandler = (httpResponse, signingProperties) => {
};
var 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;
};
// node_modules/@smithy/core/dist-es/middleware-http-signing/getHttpSigningMiddleware.js
var httpSigningMiddlewareOptions = {
step: "finalizeRequest",
tags: ["HTTP_SIGNING"],
name: "httpSigningMiddleware",
aliases: ["apiKeyMiddleware", "tokenMiddleware", "awsAuthMiddleware"],
override: true,
relation: "after",
toMiddleware: "retryMiddleware"
};
var getHttpSigningPlugin = (config) => ({
applyToStack: (clientStack) => {
clientStack.addRelativeTo(httpSigningMiddleware(config), httpSigningMiddlewareOptions);
}
});
// node_modules/@smithy/core/dist-es/pagination/createPaginator.js
var 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 void 0;
};
}
var get = (fromObject, path) => {
let cursor = fromObject;
const pathComponents = path.split(".");
for (const step of pathComponents) {
if (!cursor || typeof cursor !== "object") {
return void 0;
}
cursor = cursor[step];
}
return cursor;
};
// node_modules/@smithy/core/dist-es/util-identity-and-auth/DefaultIdentityProviderConfig.js
var DefaultIdentityProviderConfig = class {
authSchemes = /* @__PURE__ */ new Map();
constructor(config) {
for (const [key, value] of Object.entries(config)) {
if (value !== void 0) {
this.authSchemes.set(key, value);
}
}
}
getIdentityProvider(schemeId) {
return this.authSchemes.get(schemeId);
}
};
// node_modules/@smithy/middleware-serde/dist-es/serdePlugin.js
var serializerMiddlewareOption2 = {
name: "serializerMiddleware",
step: "serialize",
tags: ["SERIALIZER"],
override: true
};
// node_modules/@smithy/core/dist-es/normalizeProvider.js
var normalizeProvider2 = (input) => {
if (typeof input === "function")
return input;
const promisified = Promise.resolve(input);
return () => promisified;
};
// node_modules/@smithy/util-utf8/dist-es/toUint8Array.js
var toUint8Array = (data) => {
if (typeof data === "string") {
return fromUtf8(data);
}
if (ArrayBuffer.isView(data)) {
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength / Uint8Array.BYTES_PER_ELEMENT);
}
return new Uint8Array(data);
};
// node_modules/@smithy/util-stream/dist-es/blob/Uint8ArrayBlobAdapter.js
var Uint8ArrayBlobAdapter = class _Uint8ArrayBlobAdapter extends Uint8Array {
static fromString(source, encoding = "utf-8") {
if (typeof source === "string") {
if (encoding === "base64") {
return _Uint8ArrayBlobAdapter.mutate(fromBase64(source));
}
return _Uint8ArrayBlobAdapter.mutate(fromUtf8(source));
}
throw new Error(`Unsupported conversion from ${typeof source} to Uint8ArrayBlobAdapter.`);
}
static mutate(source) {
Object.setPrototypeOf(source, _Uint8ArrayBlobAdapter.prototype);
return source;
}
transformToString(encoding = "utf-8") {
if (encoding === "base64") {
return toBase64(this);
}
return toUtf8(this);
}
};
// node_modules/@smithy/core/dist-es/submodules/protocols/collect-stream-body.js
var collectBody = async (streamBody = new Uint8Array(), context) => {
if (streamBody instanceof Uint8Array) {
return Uint8ArrayBlobAdapter.mutate(streamBody);
}
if (!streamBody) {
return Uint8ArrayBlobAdapter.mutate(new Uint8Array());
}
const fromContext = context.streamCollector(streamBody);
return Uint8ArrayBlobAdapter.mutate(await fromContext);
};
// node_modules/@smithy/core/dist-es/submodules/protocols/extended-encode-uri-component.js
function extendedEncodeURIComponent(str) {
return encodeURIComponent(str).replace(/[!'()*]/g, function(c) {
return "%" + c.charCodeAt(0).toString(16).toUpperCase();
});
}
// node_modules/@smithy/uuid/dist-es/randomUUID.js
import crypto2 from "crypto";
var randomUUID = crypto2.randomUUID.bind(crypto2);
// node_modules/@smithy/uuid/dist-es/v4.js
var decimalToHex = Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
var v4 = () => {
if (randomUUID) {
return ran