@aws-cdk/integ-runner 2.204.1 → 2.204.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4766,7 +4766,7 @@ var require_semver2 = __commonJS({
4766
4766
  // ../cloud-assembly-schema/cli-version.json
4767
4767
  var require_cli_version = __commonJS({
4768
4768
  "../cloud-assembly-schema/cli-version.json"(exports2, module2) {
4769
- module2.exports = { version: "2.1135.0" };
4769
+ module2.exports = { version: "2.1136.0" };
4770
4770
  }
4771
4771
  });
4772
4772
 
@@ -39029,7 +39029,7 @@ var init_package = __esm({
39029
39029
  "../../../node_modules/@aws-sdk/nested-clients/package.json"() {
39030
39030
  package_default = {
39031
39031
  name: "@aws-sdk/nested-clients",
39032
- version: "3.997.38",
39032
+ version: "3.997.41",
39033
39033
  description: "Nested clients for AWS SDK packages.",
39034
39034
  homepage: "https://github.com/aws/aws-sdk-js-v3/tree/main/packages/nested-clients",
39035
39035
  license: "Apache-2.0",
@@ -39129,7 +39129,7 @@ var init_package = __esm({
39129
39129
  "test:watch": "yarn g:vitest watch"
39130
39130
  },
39131
39131
  dependencies: {
39132
- "@aws-sdk/core": "^3.977.3",
39132
+ "@aws-sdk/core": "^3.977.6",
39133
39133
  "@aws-sdk/signature-v4-multi-region": "^3.996.43",
39134
39134
  "@aws-sdk/types": "^3.974.2",
39135
39135
  "@smithy/core": "^3.31.1",
@@ -40848,30 +40848,54 @@ var init_UnionSerde = __esm({
40848
40848
  }
40849
40849
  });
40850
40850
 
40851
+ // ../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/detectBufferParsing.js
40852
+ function detectBufferParsing() {
40853
+ if (canParseBuffer === void 0) {
40854
+ try {
40855
+ if (typeof Buffer !== "function") {
40856
+ canParseBuffer = false;
40857
+ } else {
40858
+ const result2 = JSON.parse(Buffer.from([123, 125]));
40859
+ canParseBuffer = result2 !== null && typeof result2 === "object";
40860
+ }
40861
+ } catch {
40862
+ canParseBuffer = false;
40863
+ }
40864
+ }
40865
+ return canParseBuffer;
40866
+ }
40867
+ var canParseBuffer;
40868
+ var init_detectBufferParsing = __esm({
40869
+ "../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/detectBufferParsing.js"() {
40870
+ __name(detectBufferParsing, "detectBufferParsing");
40871
+ }
40872
+ });
40873
+
40851
40874
  // ../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/jsonReviver.js
40852
40875
  function jsonReviver(key, value, context) {
40853
40876
  if (context?.source) {
40854
40877
  const numericString = context.source;
40855
40878
  if (typeof value === "number") {
40856
40879
  const inSafeRange = value <= Number.MAX_SAFE_INTEGER && value >= Number.MIN_SAFE_INTEGER;
40857
- if (!inSafeRange || numericString !== String(value)) {
40858
- if (inSafeRange && /[eE]/.test(numericString) && String(Number(numericString)) === String(value)) {
40880
+ if (inSafeRange) {
40881
+ if (isRepresentable(numericString, value)) {
40859
40882
  return value;
40860
40883
  }
40861
- if (isFractionalNumeric(numericString)) {
40884
+ return new NumericValue(numericString, "bigDecimal");
40885
+ } else {
40886
+ if (isFractionalBigNumeric(numericString)) {
40862
40887
  return new NumericValue(numericString, "bigDecimal");
40863
- } else {
40864
- if (/[eE]/.test(numericString)) {
40865
- return BigInt(Number(numericString));
40866
- }
40867
- return BigInt(numericString);
40868
40888
  }
40889
+ if (/[eE]/.test(numericString)) {
40890
+ return expandExponentToBigInt(numericString);
40891
+ }
40892
+ return BigInt(numericString);
40869
40893
  }
40870
40894
  }
40871
40895
  }
40872
40896
  return value;
40873
40897
  }
40874
- function isFractionalNumeric(s2) {
40898
+ function isFractionalBigNumeric(s2) {
40875
40899
  const dotIndex = s2.indexOf(".");
40876
40900
  if (dotIndex === -1) {
40877
40901
  return false;
@@ -40884,11 +40908,91 @@ function isFractionalNumeric(s2) {
40884
40908
  const exp = parseInt(s2.slice(eIndex + 1), 10);
40885
40909
  return exp < fracDigits;
40886
40910
  }
40911
+ function isRepresentable(numericString, value) {
40912
+ if (numericString === String(value)) {
40913
+ return true;
40914
+ }
40915
+ if (Object.is(value, -0)) {
40916
+ return true;
40917
+ }
40918
+ if (/[eE]/.test(numericString)) {
40919
+ return expandToDecimal(numericString) === expandToDecimal(String(value));
40920
+ }
40921
+ const normalized = numericString.replace(/(\.\d*?)0+$/, "$1").replace(/\.$/, "");
40922
+ const canonical = String(value);
40923
+ if (normalized === canonical) {
40924
+ return true;
40925
+ }
40926
+ if (/[eE]/.test(canonical)) {
40927
+ return normalized === expandToDecimal(canonical);
40928
+ }
40929
+ return false;
40930
+ }
40931
+ function expandToDecimal(s2) {
40932
+ const negative = s2.startsWith("-");
40933
+ const abs = negative ? s2.slice(1) : s2;
40934
+ const eIndex = abs.search(/[eE]/);
40935
+ let result2;
40936
+ if (eIndex === -1) {
40937
+ result2 = abs;
40938
+ } else {
40939
+ const exp = parseInt(abs.slice(eIndex + 1), 10);
40940
+ const mantissa = abs.slice(0, eIndex);
40941
+ const dotIndex = mantissa.indexOf(".");
40942
+ let digits;
40943
+ let intLen;
40944
+ if (dotIndex === -1) {
40945
+ digits = mantissa;
40946
+ intLen = mantissa.length;
40947
+ } else {
40948
+ digits = mantissa.slice(0, dotIndex) + mantissa.slice(dotIndex + 1);
40949
+ intLen = dotIndex;
40950
+ }
40951
+ digits = digits.replace(/0+$/, "") || "0";
40952
+ const newDotPos = intLen + exp;
40953
+ if (digits === "0") {
40954
+ result2 = "0";
40955
+ } else if (newDotPos <= 0) {
40956
+ result2 = "0." + "0".repeat(-newDotPos) + digits;
40957
+ } else if (newDotPos >= digits.length) {
40958
+ result2 = digits + "0".repeat(newDotPos - digits.length);
40959
+ } else {
40960
+ result2 = digits.slice(0, newDotPos) + "." + digits.slice(newDotPos);
40961
+ }
40962
+ }
40963
+ if (result2.includes(".")) {
40964
+ result2 = result2.replace(/(\.\d*?)0+$/, "$1").replace(/\.$/, "");
40965
+ }
40966
+ return (negative ? "-" : "") + result2;
40967
+ }
40968
+ function expandExponentToBigInt(s2) {
40969
+ const eIndex = s2.search(/[eE]/);
40970
+ const exp = parseInt(s2.slice(eIndex + 1), 10);
40971
+ const negative = s2.startsWith("-");
40972
+ const mantissa = s2.slice(negative ? 1 : 0, eIndex);
40973
+ const dotIndex = mantissa.indexOf(".");
40974
+ let digits;
40975
+ let shift;
40976
+ if (dotIndex === -1) {
40977
+ digits = mantissa;
40978
+ shift = exp;
40979
+ } else {
40980
+ digits = mantissa.slice(0, dotIndex) + mantissa.slice(dotIndex + 1);
40981
+ const fracDigits = mantissa.length - dotIndex - 1;
40982
+ shift = exp - fracDigits;
40983
+ }
40984
+ digits = digits.replace(/0+$/, "") || "0";
40985
+ const result2 = BigInt(digits) * 10n ** BigInt(shift + (mantissa.replace(".", "").length - digits.length));
40986
+ return negative ? -result2 : result2;
40987
+ }
40887
40988
  var init_jsonReviver = __esm({
40888
40989
  "../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/jsonReviver.js"() {
40889
40990
  init_serde();
40890
40991
  __name(jsonReviver, "jsonReviver");
40891
- __name(isFractionalNumeric, "isFractionalNumeric");
40992
+ __name(isFractionalBigNumeric, "isFractionalBigNumeric");
40993
+ __name(isRepresentable, "isRepresentable");
40994
+ __name(expandToDecimal, "expandToDecimal");
40995
+ __name(expandExponentToBigInt, "expandExponentToBigInt");
40892
40996
  }
40893
40997
  });
40894
40998
 
@@ -40950,29 +41054,6 @@ var init_common2 = __esm({
40950
41054
  }
40951
41055
  });
40952
41056
 
40953
- // ../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/detectBufferParsing.js
40954
- function detectBufferParsing() {
40955
- if (canParseBuffer === void 0) {
40956
- try {
40957
- if (typeof Buffer !== "function") {
40958
- canParseBuffer = false;
40959
- } else {
40960
- const result2 = JSON.parse(Buffer.from([123, 125]));
40961
- canParseBuffer = result2 !== null && typeof result2 === "object";
40962
- }
40963
- } catch {
40964
- canParseBuffer = false;
40965
- }
40966
- }
40967
- return canParseBuffer;
40968
- }
40969
- var canParseBuffer;
40970
- var init_detectBufferParsing = __esm({
40971
- "../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/detectBufferParsing.js"() {
40972
- __name(detectBufferParsing, "detectBufferParsing");
40973
- }
40974
- });
40975
-
40976
41057
  // ../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/parseJsonBody.js
40977
41058
  async function parseJsonBody(streamBody, context, schema) {
40978
41059
  let parsingInput;
@@ -41078,23 +41159,23 @@ var init_writeKey = __esm({
41078
41159
  }
41079
41160
  });
41080
41161
 
41081
- // ../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v1/JsonShapeDeserializer.js
41082
- var JsonShapeDeserializer;
41083
- var init_JsonShapeDeserializer = __esm({
41084
- "../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v1/JsonShapeDeserializer.js"() {
41162
+ // ../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v2/JsonShapeDeserializer2.js
41163
+ var JsonShapeDeserializer2;
41164
+ var init_JsonShapeDeserializer2 = __esm({
41165
+ "../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v2/JsonShapeDeserializer2.js"() {
41085
41166
  init_protocols();
41086
41167
  init_schema4();
41087
41168
  init_serde();
41088
- init_serde();
41089
41169
  init_ConfigurableSerdeContext();
41090
41170
  init_UnionSerde();
41171
+ init_detectBufferParsing();
41091
41172
  init_jsonReviver();
41092
41173
  init_needsReviver();
41093
41174
  init_parseJsonBody();
41094
41175
  init_writeKey();
41095
- JsonShapeDeserializer = class extends SerdeContextConfig {
41176
+ JsonShapeDeserializer2 = class extends SerdeContextConfig {
41096
41177
  static {
41097
- __name(this, "JsonShapeDeserializer");
41178
+ __name(this, "JsonShapeDeserializer2");
41098
41179
  }
41099
41180
  settings;
41100
41181
  constructor(settings) {
@@ -41103,7 +41184,22 @@ var init_JsonShapeDeserializer = __esm({
41103
41184
  }
41104
41185
  async read(schema, data) {
41105
41186
  const reviver = needsReviver(schema) ? jsonReviver : void 0;
41106
- return this._read(schema, typeof data === "string" ? JSON.parse(data, reviver) : await parseJsonBody(data, this.serdeContext, schema));
41187
+ let parsed;
41188
+ if (typeof data === "string") {
41189
+ if (data.length === 0) {
41190
+ return {};
41191
+ }
41192
+ parsed = JSON.parse(data, reviver);
41193
+ } else if (data instanceof Uint8Array && detectBufferParsing()) {
41194
+ if (data.byteLength === 0) {
41195
+ return {};
41196
+ }
41197
+ const buf2 = Buffer.isBuffer(data) ? data : Buffer.from(data.buffer, data.byteOffset, data.byteLength);
41198
+ parsed = JSON.parse(buf2, reviver);
41199
+ } else {
41200
+ parsed = await parseJsonBody(data, this.serdeContext, schema);
41201
+ }
41202
+ return this._read(schema, parsed);
41107
41203
  }
41108
41204
  readObject(schema, data) {
41109
41205
  return this._read(schema, data);
@@ -41113,62 +41209,29 @@ var init_JsonShapeDeserializer = __esm({
41113
41209
  const ns = NormalizedSchema.of(schema);
41114
41210
  if (isObject3) {
41115
41211
  if (ns.isStructSchema()) {
41116
- const record = value;
41117
- const union = ns.isUnionSchema();
41118
- const out = {};
41119
- let nameMap = void 0;
41120
- const { jsonName } = this.settings;
41121
- if (jsonName) {
41122
- nameMap = {};
41123
- }
41124
- let unionSerde;
41125
- if (union) {
41126
- unionSerde = new UnionSerde(record, out);
41127
- }
41128
- for (const [memberName, memberSchema] of ns.structIterator()) {
41129
- let fromKey = memberName;
41130
- if (jsonName) {
41131
- fromKey = memberSchema.getMergedTraits().jsonName ?? fromKey;
41132
- nameMap[fromKey] = memberName;
41133
- }
41134
- if (union) {
41135
- unionSerde.mark(fromKey);
41136
- }
41137
- if (record[fromKey] != null) {
41138
- out[memberName] = this._read(memberSchema, record[fromKey]);
41139
- }
41140
- }
41141
- if (union) {
41142
- unionSerde.writeUnknown();
41143
- } else if (typeof record.__type === "string") {
41144
- for (const k6 in record) {
41145
- const v = record[k6];
41146
- const t = jsonName ? nameMap[k6] ?? k6 : k6;
41147
- if (!(t in out)) {
41148
- out[t] = v;
41149
- }
41150
- }
41151
- }
41152
- return out;
41212
+ return this._readStruct(ns, value);
41153
41213
  }
41154
41214
  if (Array.isArray(value) && ns.isListSchema()) {
41155
41215
  const listMember = ns.getValueSchema();
41156
- const out = [];
41157
- for (const item of value) {
41158
- out.push(this._read(listMember, item));
41216
+ if (this.needsTransform(listMember)) {
41217
+ for (let i6 = 0; i6 < value.length; ++i6) {
41218
+ value[i6] = this._read(listMember, value[i6]);
41219
+ }
41159
41220
  }
41160
- return out;
41221
+ return value;
41161
41222
  }
41162
41223
  if (ns.isMapSchema()) {
41163
41224
  const mapMember = ns.getValueSchema();
41164
- const out = {};
41165
- for (const _k in value) {
41166
- if (_k === "__proto__") {
41167
- writeKey(out);
41225
+ const map3 = value;
41226
+ if (this.needsTransform(mapMember)) {
41227
+ for (const k6 in map3) {
41228
+ if (k6 === "__proto__") {
41229
+ writeKey(map3);
41230
+ }
41231
+ map3[k6] = this._read(mapMember, map3[k6]);
41168
41232
  }
41169
- out[_k] = this._read(mapMember, value[_k]);
41170
41233
  }
41171
- return out;
41234
+ return map3;
41172
41235
  }
41173
41236
  }
41174
41237
  if (ns.isBlobSchema() && typeof value === "string") {
@@ -41222,292 +41285,723 @@ var init_JsonShapeDeserializer = __esm({
41222
41285
  }
41223
41286
  if (ns.isDocumentSchema()) {
41224
41287
  if (isObject3) {
41225
- const out = Array.isArray(value) ? [] : {};
41226
- for (const k6 in value) {
41227
- if (k6 === "__proto__") {
41228
- writeKey(out);
41288
+ if (Array.isArray(value)) {
41289
+ for (let i6 = 0; i6 < value.length; ++i6) {
41290
+ const v = value[i6];
41291
+ if (!(v instanceof NumericValue)) {
41292
+ value[i6] = this._read(ns, v);
41293
+ }
41229
41294
  }
41230
- const v = value[k6];
41231
- if (v instanceof NumericValue) {
41232
- out[k6] = v;
41233
- } else {
41234
- out[k6] = this._read(ns, v);
41295
+ } else {
41296
+ const doc = value;
41297
+ for (const k6 in doc) {
41298
+ if (k6 === "__proto__") {
41299
+ writeKey(doc);
41300
+ }
41301
+ const v = doc[k6];
41302
+ if (!(v instanceof NumericValue)) {
41303
+ doc[k6] = this._read(ns, v);
41304
+ }
41235
41305
  }
41236
41306
  }
41237
- return out;
41238
- } else {
41239
- return structuredClone(value);
41240
41307
  }
41241
41308
  }
41242
41309
  return value;
41243
41310
  }
41311
+ _readStruct(ns, record) {
41312
+ const union = ns.isUnionSchema();
41313
+ const out = {};
41314
+ let nameMap;
41315
+ const hasType = typeof record.__type === "string";
41316
+ const { jsonName } = this.settings;
41317
+ if (jsonName && hasType) {
41318
+ nameMap = {};
41319
+ }
41320
+ let unionSerde;
41321
+ if (union) {
41322
+ unionSerde = new UnionSerde(record, out);
41323
+ }
41324
+ for (const [memberName, memberSchema] of ns.structIterator()) {
41325
+ let fromKey = memberName;
41326
+ if (jsonName) {
41327
+ fromKey = memberSchema.getMergedTraits().jsonName ?? fromKey;
41328
+ if (hasType) {
41329
+ nameMap[fromKey] = memberName;
41330
+ }
41331
+ }
41332
+ if (union) {
41333
+ unionSerde.mark(fromKey);
41334
+ }
41335
+ if (record[fromKey] != null) {
41336
+ out[memberName] = this._read(memberSchema, record[fromKey]);
41337
+ }
41338
+ }
41339
+ if (union) {
41340
+ unionSerde.writeUnknown();
41341
+ } else if (hasType) {
41342
+ for (const k6 in record) {
41343
+ const v = record[k6];
41344
+ const t = jsonName ? nameMap[k6] ?? k6 : k6;
41345
+ if (!(t in out)) {
41346
+ out[t] = v;
41347
+ }
41348
+ }
41349
+ }
41350
+ return out;
41351
+ }
41352
+ needsTransform(ns) {
41353
+ if (ns.isBlobSchema() || ns.isTimestampSchema() || ns.isBigIntegerSchema() || ns.isBigDecimalSchema()) {
41354
+ return true;
41355
+ }
41356
+ if (ns.isDocumentSchema() || ns.isStructSchema() || ns.isListSchema() || ns.isMapSchema()) {
41357
+ return true;
41358
+ }
41359
+ if (ns.isStringSchema() && ns.getMergedTraits().mediaType) {
41360
+ return true;
41361
+ }
41362
+ return false;
41363
+ }
41244
41364
  };
41245
41365
  }
41246
41366
  });
41247
41367
 
41248
- // ../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/jsonReplacer.js
41249
- var NUMERIC_CONTROL_CHAR, JsonReplacer;
41250
- var init_jsonReplacer = __esm({
41251
- "../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/jsonReplacer.js"() {
41368
+ // ../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v2/JsonBytesStringAdapter.js
41369
+ var JsonBytesStringAdapter, warned;
41370
+ var init_JsonBytesStringAdapter = __esm({
41371
+ "../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v2/JsonBytesStringAdapter.js"() {
41252
41372
  init_serde();
41253
- NUMERIC_CONTROL_CHAR = String.fromCharCode(925);
41254
- JsonReplacer = class {
41373
+ JsonBytesStringAdapter = class _JsonBytesStringAdapter extends Uint8Array {
41255
41374
  static {
41256
- __name(this, "JsonReplacer");
41375
+ __name(this, "JsonBytesStringAdapter");
41257
41376
  }
41258
- values = /* @__PURE__ */ new Map();
41259
- counter = 0;
41260
- stage = 0;
41261
- createReplacer() {
41262
- if (this.stage === 1) {
41263
- throw new Error("@aws-sdk/core/protocols - JsonReplacer already created.");
41377
+ string = null;
41378
+ static allocUnsafe(bytes) {
41379
+ if (typeof Buffer === "function") {
41380
+ const buffer = Buffer.allocUnsafe(bytes);
41381
+ return new _JsonBytesStringAdapter(buffer.buffer, buffer.byteOffset, buffer.byteLength);
41264
41382
  }
41265
- if (this.stage === 2) {
41266
- throw new Error("@aws-sdk/core/protocols - JsonReplacer exhausted.");
41383
+ return new _JsonBytesStringAdapter(bytes);
41384
+ }
41385
+ toString() {
41386
+ return this.s();
41387
+ }
41388
+ valueOf() {
41389
+ return this.s();
41390
+ }
41391
+ includes(searchString, position) {
41392
+ if (typeof searchString === "string") {
41393
+ return this.s().includes(searchString, position);
41267
41394
  }
41268
- this.stage = 1;
41269
- return (key, value) => {
41270
- if (value instanceof NumericValue) {
41271
- const v = `${NUMERIC_CONTROL_CHAR + "nv" + this.counter++}_` + value.string;
41272
- this.values.set(`"${v}"`, value.string);
41273
- return v;
41274
- }
41275
- if (typeof value === "bigint") {
41276
- const s2 = value.toString();
41277
- const v = `${NUMERIC_CONTROL_CHAR + "b" + this.counter++}_` + s2;
41278
- this.values.set(`"${v}"`, s2);
41279
- return v;
41280
- }
41281
- return value;
41282
- };
41395
+ return Uint8Array.prototype.includes.call(this, searchString, position);
41283
41396
  }
41284
- replaceInJson(json) {
41285
- if (this.stage === 0) {
41286
- throw new Error("@aws-sdk/core/protocols - JsonReplacer not created yet.");
41397
+ indexOf(searchString, position) {
41398
+ if (typeof searchString === "string") {
41399
+ return this.s().indexOf(searchString, position);
41287
41400
  }
41288
- if (this.stage === 2) {
41289
- throw new Error("@aws-sdk/core/protocols - JsonReplacer exhausted.");
41401
+ return Uint8Array.prototype.indexOf.call(this, searchString, position);
41402
+ }
41403
+ lastIndexOf(searchString, position) {
41404
+ if (typeof searchString === "string") {
41405
+ return this.s().lastIndexOf(searchString, position);
41290
41406
  }
41291
- this.stage = 2;
41292
- if (this.counter === 0) {
41293
- return json;
41407
+ const fn = Uint8Array.prototype.lastIndexOf;
41408
+ if (position !== void 0) {
41409
+ return fn.call(this, searchString, position);
41294
41410
  }
41295
- for (const [key, value] of this.values) {
41296
- json = json.replace(key, value);
41411
+ return fn.call(this, searchString);
41412
+ }
41413
+ startsWith(searchString, position) {
41414
+ return this.s().startsWith(searchString, position);
41415
+ }
41416
+ endsWith(searchString, endPosition) {
41417
+ return this.s().endsWith(searchString, endPosition);
41418
+ }
41419
+ match(regexp) {
41420
+ return this.s().match(regexp);
41421
+ }
41422
+ replace(searchValue, replaceValue) {
41423
+ return this.s().replace(searchValue, replaceValue);
41424
+ }
41425
+ search(regexp) {
41426
+ return this.s().search(regexp);
41427
+ }
41428
+ split(separator, limit) {
41429
+ return this.s().split(separator, limit);
41430
+ }
41431
+ substring(start, end2) {
41432
+ return this.s().substring(start, end2);
41433
+ }
41434
+ trim() {
41435
+ return this.s().trim();
41436
+ }
41437
+ trimStart() {
41438
+ return this.s().trimStart();
41439
+ }
41440
+ trimEnd() {
41441
+ return this.s().trimEnd();
41442
+ }
41443
+ charAt(pos2) {
41444
+ return this.s().charAt(pos2);
41445
+ }
41446
+ charCodeAt(index) {
41447
+ return this.s().charCodeAt(index);
41448
+ }
41449
+ padStart(maxLength, fillString) {
41450
+ return this.s().padStart(maxLength, fillString);
41451
+ }
41452
+ padEnd(maxLength, fillString) {
41453
+ return this.s().padEnd(maxLength, fillString);
41454
+ }
41455
+ repeat(count) {
41456
+ return this.s().repeat(count);
41457
+ }
41458
+ toUpperCase() {
41459
+ return this.s().toUpperCase();
41460
+ }
41461
+ toLowerCase() {
41462
+ return this.s().toLowerCase();
41463
+ }
41464
+ s() {
41465
+ if (this.string == null) {
41466
+ const n3 = Date.now();
41467
+ if (n3 > warned + 6e4) {
41468
+ console.warn("@aws-sdk/core/protocols - WARN - JsonCodec2: you have called a string method on a Uint8Array request body. It has been automatically converted to string. In a future version this will throw an error.");
41469
+ warned = n3;
41470
+ }
41471
+ this.string = toUtf8(this);
41297
41472
  }
41298
- return json;
41473
+ return this.string;
41299
41474
  }
41300
41475
  };
41476
+ warned = 0;
41301
41477
  }
41302
41478
  });
41303
41479
 
41304
- // ../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v1/JsonShapeSerializer.js
41305
- var JsonShapeSerializer;
41306
- var init_JsonShapeSerializer = __esm({
41307
- "../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v1/JsonShapeSerializer.js"() {
41480
+ // ../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v2/JsonShapeSerializer2.js
41481
+ function alloc(size) {
41482
+ return JsonBytesStringAdapter.allocUnsafe(size);
41483
+ }
41484
+ var encoder, OPEN_BRACE, CLOSE_BRACE, OPEN_BRACKET, CLOSE_BRACKET, QUOTE, COLON, COMMA, BACKSLASH, TRUE, FALSE, NULL, ESCAPE_TABLE, INITIAL_BUFFER_SIZE2, JsonShapeSerializer2;
41485
+ var init_JsonShapeSerializer2 = __esm({
41486
+ "../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v2/JsonShapeSerializer2.js"() {
41308
41487
  init_protocols();
41309
41488
  init_schema4();
41310
41489
  init_serde();
41311
41490
  init_ConfigurableSerdeContext();
41312
- init_jsonReplacer();
41313
- init_writeKey();
41314
- JsonShapeSerializer = class extends SerdeContextConfig {
41491
+ init_JsonBytesStringAdapter();
41492
+ encoder = new TextEncoder();
41493
+ OPEN_BRACE = 123;
41494
+ CLOSE_BRACE = 125;
41495
+ OPEN_BRACKET = 91;
41496
+ CLOSE_BRACKET = 93;
41497
+ QUOTE = 34;
41498
+ COLON = 58;
41499
+ COMMA = 44;
41500
+ BACKSLASH = 92;
41501
+ TRUE = new Uint8Array([116, 114, 117, 101]);
41502
+ FALSE = new Uint8Array([102, 97, 108, 115, 101]);
41503
+ NULL = new Uint8Array([110, 117, 108, 108]);
41504
+ ESCAPE_TABLE = new Array(128).fill(null);
41505
+ ESCAPE_TABLE[8] = "b";
41506
+ ESCAPE_TABLE[9] = "t";
41507
+ ESCAPE_TABLE[10] = "n";
41508
+ ESCAPE_TABLE[12] = "f";
41509
+ ESCAPE_TABLE[13] = "r";
41510
+ ESCAPE_TABLE[34] = '"';
41511
+ ESCAPE_TABLE[92] = "\\";
41512
+ for (let i6 = 0; i6 < 32; i6++) {
41513
+ if (ESCAPE_TABLE[i6] === null) {
41514
+ ESCAPE_TABLE[i6] = "u00" + i6.toString(16).padStart(2, "0");
41515
+ }
41516
+ }
41517
+ INITIAL_BUFFER_SIZE2 = 2048;
41518
+ __name(alloc, "alloc");
41519
+ JsonShapeSerializer2 = class _JsonShapeSerializer2 extends SerdeContextConfig {
41315
41520
  static {
41316
- __name(this, "JsonShapeSerializer");
41521
+ __name(this, "JsonShapeSerializer2");
41317
41522
  }
41318
41523
  settings;
41319
- buffer;
41320
- useReplacer = false;
41524
+ json;
41525
+ i = 0;
41321
41526
  rootSchema;
41527
+ rawValue;
41528
+ passthrough = false;
41322
41529
  constructor(settings) {
41323
41530
  super();
41324
41531
  this.settings = settings;
41532
+ this.json = alloc(INITIAL_BUFFER_SIZE2);
41325
41533
  }
41326
41534
  write(schema, value) {
41535
+ this.i = 0;
41536
+ this.rawValue = value;
41327
41537
  this.rootSchema = NormalizedSchema.of(schema);
41328
- this.buffer = this._write(this.rootSchema, value);
41538
+ this.passthrough = this.rootSchema.isBlobSchema() || this.rootSchema.isStringSchema();
41539
+ if (!this.passthrough) {
41540
+ this.writeValue(this.rootSchema, value, void 0);
41541
+ }
41542
+ }
41543
+ writeDiscriminatedDocument(schema, value) {
41544
+ this.i = 0;
41545
+ this.rootSchema = NormalizedSchema.of(schema);
41546
+ const ns = this.rootSchema;
41547
+ if (ns.isStructSchema() && value != null && typeof value === "object") {
41548
+ this.writeValue(ns, value, void 0);
41549
+ const prefix = `"__type":"${ns.getName(true) ?? "Unknown"}",`;
41550
+ const z = prefix.length;
41551
+ this.ensure(z);
41552
+ this.json.copyWithin(1 + z, 1, this.i);
41553
+ encoder.encodeInto(prefix, this.json.subarray(1));
41554
+ this.i += z;
41555
+ } else {
41556
+ this.writeValue(ns, value, void 0);
41557
+ }
41329
41558
  }
41330
41559
  flush() {
41331
- const { rootSchema, useReplacer } = this;
41332
41560
  this.rootSchema = void 0;
41333
- this.useReplacer = false;
41334
- if (rootSchema?.isStructSchema() || rootSchema?.isDocumentSchema()) {
41335
- if (!useReplacer) {
41336
- return JSON.stringify(this.buffer);
41561
+ const finalPosition = this.i;
41562
+ this.i = 0;
41563
+ const raw = this.rawValue;
41564
+ this.rawValue = void 0;
41565
+ if (finalPosition === 0) {
41566
+ return raw;
41567
+ }
41568
+ const result2 = this.json.subarray(0, finalPosition);
41569
+ this.json = alloc(INITIAL_BUFFER_SIZE2);
41570
+ return result2;
41571
+ }
41572
+ ensure(byteCount) {
41573
+ const { i: i6, json } = this;
41574
+ if (i6 + byteCount > json.length) {
41575
+ let newSize = json.length * 2;
41576
+ while (newSize < i6 + byteCount) {
41577
+ newSize *= 2;
41337
41578
  }
41338
- const replacer = new JsonReplacer();
41339
- return replacer.replaceInJson(JSON.stringify(this.buffer, replacer.createReplacer(), 0));
41579
+ const next = alloc(newSize);
41580
+ next.set(this.json);
41581
+ this.json = next;
41340
41582
  }
41341
- return this.buffer;
41342
41583
  }
41343
- writeDiscriminatedDocument(schema, value) {
41344
- this.write(schema, value);
41345
- if (typeof this.buffer === "object") {
41346
- this.buffer.__type = NormalizedSchema.of(schema).getName(true);
41584
+ writeAscii(s2) {
41585
+ const z = s2.length;
41586
+ this.ensure(z);
41587
+ let { i: i6, json } = this;
41588
+ for (let j6 = 0; j6 < z; ++j6) {
41589
+ json[i6] = s2.charCodeAt(j6);
41590
+ i6 += 1;
41347
41591
  }
41592
+ this.i = i6;
41348
41593
  }
41349
- _write(schema, value, container) {
41350
- const isObject3 = value !== null && typeof value === "object";
41351
- const ns = NormalizedSchema.of(schema);
41352
- if (isObject3) {
41353
- if (ns.isStructSchema()) {
41354
- const record = value;
41355
- const out = {};
41356
- const { jsonName } = this.settings;
41357
- let nameMap = void 0;
41358
- if (jsonName) {
41359
- nameMap = {};
41360
- }
41361
- let outCount = 0;
41362
- for (const [memberName, memberSchema] of ns.structIterator()) {
41363
- const serializableValue = this._write(memberSchema, record[memberName], ns);
41364
- if (serializableValue !== void 0) {
41365
- let targetKey = memberName;
41366
- if (jsonName) {
41367
- targetKey = memberSchema.getMergedTraits().jsonName ?? memberName;
41368
- nameMap[memberName] = targetKey;
41369
- }
41370
- out[targetKey] = serializableValue;
41371
- outCount++;
41594
+ writeAsciiQuoted(s2) {
41595
+ const z = s2.length;
41596
+ this.ensure(z + 4);
41597
+ let { json, i: i6 } = this;
41598
+ json[i6++] = QUOTE;
41599
+ for (let j6 = 0; j6 < z; ++j6) {
41600
+ json[i6++] = s2.charCodeAt(j6);
41601
+ }
41602
+ json[i6++] = QUOTE;
41603
+ this.i = i6;
41604
+ }
41605
+ writeJsonString(s2) {
41606
+ this.ensure(s2.length * 3 + 2);
41607
+ this.json[this.i++] = QUOTE;
41608
+ const z = s2.length;
41609
+ for (let j6 = 0; j6 < z; ++j6) {
41610
+ const c6 = s2.charCodeAt(j6);
41611
+ if (c6 > 34 && c6 < 92) {
41612
+ this.json[this.i++] = c6;
41613
+ } else if (c6 < 128) {
41614
+ const esc = ESCAPE_TABLE[c6];
41615
+ if (esc !== null) {
41616
+ this.ensure(esc.length + 1);
41617
+ this.json[this.i++] = BACKSLASH;
41618
+ for (let k6 = 0; k6 < esc.length; k6++) {
41619
+ this.json[this.i++] = esc.charCodeAt(k6);
41372
41620
  }
41621
+ } else {
41622
+ this.json[this.i++] = c6;
41373
41623
  }
41374
- if (ns.isUnionSchema() && outCount === 0) {
41375
- const { $unknown } = record;
41376
- if (Array.isArray($unknown)) {
41377
- const [k6, v] = $unknown;
41378
- if (k6 === "__proto__") {
41379
- writeKey(out);
41380
- }
41381
- out[k6] = this._write(15, v);
41382
- }
41383
- } else if (typeof record.__type === "string") {
41384
- for (const k6 in record) {
41385
- const v = record[k6];
41386
- const targetKey = jsonName ? nameMap[k6] ?? k6 : k6;
41387
- if (!(targetKey in out)) {
41388
- out[targetKey] = this._write(15, v);
41389
- }
41390
- }
41624
+ } else if (c6 >= 55296 && c6 <= 56319) {
41625
+ const next = j6 + 1 < z ? s2.charCodeAt(j6 + 1) : 0;
41626
+ if (next >= 56320 && next <= 57343) {
41627
+ this.ensure(4);
41628
+ const { written } = encoder.encodeInto(s2.substring(j6, j6 + 2), this.json.subarray(this.i));
41629
+ this.i += written;
41630
+ ++j6;
41631
+ } else {
41632
+ this.ensure(6);
41633
+ this.writeUnicodeEscape(c6);
41391
41634
  }
41392
- return out;
41635
+ } else if (c6 >= 56320 && c6 <= 57343) {
41636
+ this.ensure(6);
41637
+ this.writeUnicodeEscape(c6);
41638
+ } else {
41639
+ let { i: i6, json } = this;
41640
+ if (c6 < 2048) {
41641
+ json[i6++] = 192 | c6 >> 6;
41642
+ json[i6++] = 128 | c6 & 63;
41643
+ } else {
41644
+ json[i6++] = 224 | c6 >> 12;
41645
+ json[i6++] = 128 | c6 >> 6 & 63;
41646
+ json[i6++] = 128 | c6 & 63;
41647
+ }
41648
+ this.i = i6;
41393
41649
  }
41394
- if (Array.isArray(value) && ns.isListSchema()) {
41395
- const listMember = ns.getValueSchema();
41396
- const out = [];
41397
- const sparse = !!ns.getMergedTraits().sparse;
41398
- for (const item of value) {
41399
- if (sparse || item != null) {
41400
- out.push(this._write(listMember, item));
41650
+ }
41651
+ this.json[this.i++] = QUOTE;
41652
+ }
41653
+ writeUnicodeEscape(code) {
41654
+ let { json, i: i6 } = this;
41655
+ json[i6++] = BACKSLASH;
41656
+ json[i6++] = 117;
41657
+ const hex = code.toString(16).padStart(4, "0");
41658
+ for (let j6 = 0; j6 < 4; ++j6) {
41659
+ json[i6++] = hex.charCodeAt(j6);
41660
+ }
41661
+ this.i = i6;
41662
+ }
41663
+ static B64 = (() => {
41664
+ const chars2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
41665
+ const table3 = new Uint8Array(64);
41666
+ for (let i6 = 0; i6 < 64; ++i6) {
41667
+ table3[i6] = chars2.charCodeAt(i6);
41668
+ }
41669
+ return table3;
41670
+ })();
41671
+ writeBase64(data) {
41672
+ const b64Len = Math.ceil(data.length / 3) * 4;
41673
+ this.ensure(b64Len + 2);
41674
+ const json = this.json;
41675
+ const B64 = _JsonShapeSerializer2.B64;
41676
+ let i6 = this.i;
41677
+ json[i6++] = QUOTE;
41678
+ const len = data.length;
41679
+ const remainder = len % 3;
41680
+ const mainLen = len - remainder;
41681
+ for (let j6 = 0; j6 < mainLen; j6 += 3) {
41682
+ const a6 = data[j6];
41683
+ const b6 = data[j6 + 1];
41684
+ const c6 = data[j6 + 2];
41685
+ json[i6++] = B64[a6 >> 2];
41686
+ json[i6++] = B64[(a6 & 3) << 4 | b6 >> 4];
41687
+ json[i6++] = B64[(b6 & 15) << 2 | c6 >> 6];
41688
+ json[i6++] = B64[c6 & 63];
41689
+ }
41690
+ if (remainder === 2) {
41691
+ const a6 = data[mainLen];
41692
+ const b6 = data[mainLen + 1];
41693
+ json[i6++] = B64[a6 >> 2];
41694
+ json[i6++] = B64[(a6 & 3) << 4 | b6 >> 4];
41695
+ json[i6++] = B64[(b6 & 15) << 2];
41696
+ json[i6++] = 61;
41697
+ } else if (remainder === 1) {
41698
+ const a6 = data[mainLen];
41699
+ json[i6++] = B64[a6 >> 2];
41700
+ json[i6++] = B64[(a6 & 3) << 4];
41701
+ json[i6++] = 61;
41702
+ json[i6++] = 61;
41703
+ }
41704
+ json[i6++] = QUOTE;
41705
+ this.i = i6;
41706
+ }
41707
+ writeValue(schema, value, container) {
41708
+ if (value == null) {
41709
+ if (container?.isStructSchema()) {
41710
+ if (value === void 0) {
41711
+ const ns2 = NormalizedSchema.of(schema);
41712
+ if (ns2.isIdempotencyToken()) {
41713
+ this.writeAsciiQuoted(generateIdempotencyToken());
41714
+ return;
41401
41715
  }
41402
41716
  }
41403
- return out;
41717
+ return;
41404
41718
  }
41405
- if (ns.isMapSchema()) {
41406
- const mapMember = ns.getValueSchema();
41407
- const out = {};
41408
- const sparse = !!ns.getMergedTraits().sparse;
41409
- for (const _k in value) {
41410
- const _v = value[_k];
41411
- if (sparse || _v != null) {
41412
- if (_k === "__proto__") {
41413
- writeKey(out);
41414
- }
41415
- out[_k] = this._write(mapMember, _v);
41416
- }
41719
+ this.ensure(4);
41720
+ this.json.set(NULL, this.i);
41721
+ this.i += 4;
41722
+ return;
41723
+ }
41724
+ const ns = NormalizedSchema.of(schema);
41725
+ const isObject3 = typeof value === "object";
41726
+ if (ns.isStringSchema()) {
41727
+ const mediaType = ns.getMergedTraits().mediaType;
41728
+ if (mediaType) {
41729
+ const isJson = mediaType === "application/json" || mediaType.endsWith("+json");
41730
+ if (isJson) {
41731
+ this.writeJsonString(LazyJsonString.from(value).toString());
41732
+ return;
41417
41733
  }
41418
- return out;
41734
+ }
41735
+ }
41736
+ if (isObject3) {
41737
+ if (ns.isStructSchema()) {
41738
+ this.writeStruct(ns, value);
41739
+ return;
41740
+ }
41741
+ if (Array.isArray(value) && (ns.isListSchema() || ns.isDocumentSchema())) {
41742
+ this.writeList(ns, value, ns.isDocumentSchema());
41743
+ return;
41744
+ }
41745
+ if (ns.isMapSchema()) {
41746
+ this.writeMap(ns, value, false);
41747
+ return;
41419
41748
  }
41420
41749
  if (value instanceof Uint8Array && (ns.isBlobSchema() || ns.isDocumentSchema())) {
41421
- if (ns === this.rootSchema) {
41422
- return value;
41423
- }
41424
- return (this.serdeContext?.base64Encoder ?? toBase64)(value);
41750
+ this.writeBase64(value);
41751
+ return;
41425
41752
  }
41426
41753
  if (value instanceof Date && (ns.isTimestampSchema() || ns.isDocumentSchema())) {
41427
- const format28 = determineTimestampFormat(ns, this.settings);
41428
- switch (format28) {
41429
- case 5:
41430
- return value.toISOString().replace(".000Z", "Z");
41431
- case 6:
41432
- return dateToUtcString(value);
41433
- case 7:
41434
- return value.getTime() / 1e3;
41435
- default:
41436
- console.warn("Missing timestamp format, using epoch seconds", value);
41437
- return value.getTime() / 1e3;
41438
- }
41754
+ this.writeTimestamp(ns, value);
41755
+ return;
41439
41756
  }
41440
41757
  if (value instanceof NumericValue) {
41441
- this.useReplacer = true;
41758
+ this.writeAscii(value.string);
41759
+ return;
41442
41760
  }
41761
+ if (ns.isDocumentSchema()) {
41762
+ if (Array.isArray(value)) {
41763
+ this.writeList(ns, value, true);
41764
+ } else {
41765
+ this.writeMap(ns, value, true);
41766
+ }
41767
+ return;
41768
+ }
41769
+ const json = JSON.stringify(value);
41770
+ this.writeAscii(json);
41771
+ return;
41443
41772
  }
41444
- if (value === null && container?.isStructSchema()) {
41445
- return void 0;
41773
+ if (typeof value === "string") {
41774
+ if (ns.isBlobSchema()) {
41775
+ const b64 = (this.serdeContext?.base64Encoder ?? toBase64)(value);
41776
+ this.writeAsciiQuoted(b64);
41777
+ return;
41778
+ }
41779
+ this.writeJsonString(value);
41780
+ return;
41446
41781
  }
41447
- if (ns.isStringSchema()) {
41448
- if (typeof value === "undefined" && ns.isIdempotencyToken()) {
41449
- return generateIdempotencyToken();
41782
+ if (typeof value === "number") {
41783
+ if (Math.abs(value) === Infinity || Number.isNaN(value)) {
41784
+ this.writeAsciiQuoted(String(value));
41785
+ return;
41450
41786
  }
41451
- const mediaType = ns.getMergedTraits().mediaType;
41452
- if (value != null && mediaType) {
41453
- const isJson = mediaType === "application/json" || mediaType.endsWith("+json");
41454
- if (isJson) {
41455
- return LazyJsonString.from(value);
41456
- }
41787
+ const numStr = String(value);
41788
+ this.writeAscii(numStr);
41789
+ return;
41790
+ }
41791
+ if (typeof value === "boolean") {
41792
+ this.ensure(5);
41793
+ let { i: i6, json } = this;
41794
+ if (value) {
41795
+ json.set(TRUE, i6);
41796
+ i6 += 4;
41797
+ } else {
41798
+ json.set(FALSE, i6);
41799
+ i6 += 5;
41457
41800
  }
41458
- return value;
41801
+ this.i = i6;
41802
+ return;
41459
41803
  }
41460
- if (typeof value === "number" && ns.isNumericSchema()) {
41461
- if (Math.abs(value) === Infinity || isNaN(value)) {
41462
- return String(value);
41804
+ if (typeof value === "bigint") {
41805
+ this.writeAscii(value.toString());
41806
+ return;
41807
+ }
41808
+ this.writeAscii(String(value));
41809
+ }
41810
+ writeStruct(ns, value) {
41811
+ this.ensure(2);
41812
+ this.json[this.i++] = OPEN_BRACE;
41813
+ let wroteAny = false;
41814
+ const hasType = typeof value.__type === "string";
41815
+ let writtenKeys;
41816
+ if (hasType) {
41817
+ writtenKeys = /* @__PURE__ */ new Set();
41818
+ }
41819
+ for (const [memberName, memberSchema] of ns.structIterator()) {
41820
+ const item = value[memberName];
41821
+ if (item == null && !memberSchema.isIdempotencyToken()) {
41822
+ continue;
41463
41823
  }
41464
- return value;
41824
+ if (wroteAny) {
41825
+ this.ensure(1);
41826
+ this.json[this.i++] = COMMA;
41827
+ }
41828
+ wroteAny = true;
41829
+ const targetKey = this.settings.jsonName ? memberSchema.getMergedTraits().jsonName ?? memberName : memberName;
41830
+ if (writtenKeys) {
41831
+ writtenKeys.add(memberName);
41832
+ writtenKeys.add(targetKey);
41833
+ }
41834
+ this.writeAsciiQuoted(targetKey);
41835
+ this.json[this.i++] = COLON;
41836
+ this.writeValue(memberSchema, item, ns);
41465
41837
  }
41466
- if (typeof value === "string" && ns.isBlobSchema()) {
41467
- if (ns === this.rootSchema) {
41468
- return value;
41838
+ if (!wroteAny && ns.isUnionSchema()) {
41839
+ const { $unknown } = value;
41840
+ if (Array.isArray($unknown)) {
41841
+ const [k6, v] = $unknown;
41842
+ this.writeAsciiQuoted(k6);
41843
+ this.ensure(1);
41844
+ this.json[this.i++] = COLON;
41845
+ this.writeValue(15, v, ns);
41846
+ }
41847
+ } else if (hasType) {
41848
+ for (const k6 in value) {
41849
+ if (writtenKeys.has(k6)) {
41850
+ continue;
41851
+ }
41852
+ writtenKeys.add(k6);
41853
+ const v = value[k6];
41854
+ if (wroteAny) {
41855
+ this.ensure(1);
41856
+ this.json[this.i++] = COMMA;
41857
+ }
41858
+ wroteAny = true;
41859
+ this.writeAsciiQuoted(k6);
41860
+ this.ensure(1);
41861
+ this.json[this.i++] = COLON;
41862
+ this.writeValue(15, v, void 0);
41469
41863
  }
41470
- return (this.serdeContext?.base64Encoder ?? toBase64)(value);
41471
41864
  }
41472
- if (typeof value === "bigint") {
41473
- this.useReplacer = true;
41865
+ this.ensure(1);
41866
+ this.json[this.i++] = CLOSE_BRACE;
41867
+ }
41868
+ writeList(ns, value, isDocument) {
41869
+ const sparse = !!ns.getMergedTraits().sparse;
41870
+ const valueSchema = ns.getValueSchema();
41871
+ if (!isDocument) {
41872
+ if (valueSchema.isStringSchema() || valueSchema.isNumericSchema() || valueSchema.isBooleanSchema()) {
41873
+ let hasSpecials = false;
41874
+ for (let i6 = 0; i6 < value.length; ++i6) {
41875
+ const v = value[i6];
41876
+ if (Number.isNaN(v) || v === Infinity || v === -Infinity || v == null && !sparse) {
41877
+ hasSpecials = true;
41878
+ break;
41879
+ }
41880
+ }
41881
+ let json;
41882
+ if (!hasSpecials) {
41883
+ json = JSON.stringify(value);
41884
+ } else {
41885
+ const out = [];
41886
+ for (let i6 = 0; i6 < value.length; ++i6) {
41887
+ const v = value[i6];
41888
+ if (v == null && !sparse)
41889
+ continue;
41890
+ if (Number.isNaN(v) || v === Infinity || v === -Infinity) {
41891
+ out.push(String(v));
41892
+ } else {
41893
+ out.push(v);
41894
+ }
41895
+ }
41896
+ json = JSON.stringify(out);
41897
+ }
41898
+ this.ensure(json.length * 3);
41899
+ this.i += encoder.encodeInto(json, this.json.subarray(this.i)).written;
41900
+ return;
41901
+ }
41474
41902
  }
41475
- if (ns.isDocumentSchema()) {
41476
- if (isObject3) {
41477
- const out = Array.isArray(value) ? [] : {};
41903
+ this.ensure(2);
41904
+ this.json[this.i++] = OPEN_BRACKET;
41905
+ let wroteFirstItem = false;
41906
+ for (let i6 = 0; i6 < value.length; ++i6) {
41907
+ const item = value[i6];
41908
+ if (isDocument ? item === void 0 : item == null && !sparse) {
41909
+ continue;
41910
+ }
41911
+ if (wroteFirstItem) {
41912
+ this.ensure(1);
41913
+ this.json[this.i++] = COMMA;
41914
+ }
41915
+ this.writeValue(valueSchema, item, void 0);
41916
+ wroteFirstItem = true;
41917
+ }
41918
+ this.ensure(1);
41919
+ this.json[this.i++] = CLOSE_BRACKET;
41920
+ }
41921
+ writeMap(ns, value, isDocument) {
41922
+ const sparse = !!ns.getMergedTraits().sparse;
41923
+ const valueSchema = ns.getValueSchema();
41924
+ if (!isDocument) {
41925
+ if (valueSchema.isStringSchema() || valueSchema.isNumericSchema() || valueSchema.isBooleanSchema()) {
41926
+ let modifications;
41478
41927
  for (const k6 in value) {
41479
41928
  const v = value[k6];
41480
- if (k6 === "__proto__") {
41481
- writeKey(out);
41482
- }
41483
- if (v instanceof NumericValue) {
41484
- this.useReplacer = true;
41485
- out[k6] = v;
41486
- } else {
41487
- out[k6] = this._write(ns, v);
41929
+ if (Number.isNaN(v) || v === Infinity || v === -Infinity) {
41930
+ (modifications ??= {})[k6] = v;
41931
+ value[k6] = String(v);
41932
+ } else if (v === null && !sparse) {
41933
+ (modifications ??= {})[k6] = null;
41934
+ value[k6] = void 0;
41488
41935
  }
41489
41936
  }
41490
- return out;
41491
- } else {
41492
- return structuredClone(value);
41937
+ const json = JSON.stringify(value);
41938
+ if (modifications) {
41939
+ Object.assign(value, modifications);
41940
+ }
41941
+ this.ensure(json.length * 3);
41942
+ this.i += encoder.encodeInto(json, this.json.subarray(this.i)).written;
41943
+ return;
41944
+ }
41945
+ }
41946
+ this.ensure(2);
41947
+ this.json[this.i++] = OPEN_BRACE;
41948
+ let first = true;
41949
+ for (const k6 in value) {
41950
+ const v = value[k6];
41951
+ if (isDocument ? v === void 0 : v == null && !sparse) {
41952
+ continue;
41953
+ }
41954
+ if (!first) {
41955
+ this.ensure(1);
41956
+ this.json[this.i++] = COMMA;
41957
+ }
41958
+ first = false;
41959
+ this.writeJsonString(k6);
41960
+ this.ensure(1);
41961
+ this.json[this.i++] = COLON;
41962
+ this.writeValue(valueSchema, v, void 0);
41963
+ }
41964
+ this.ensure(1);
41965
+ this.json[this.i++] = CLOSE_BRACE;
41966
+ }
41967
+ writeTimestamp(ns, value) {
41968
+ const format28 = determineTimestampFormat(ns, this.settings);
41969
+ switch (format28) {
41970
+ case 5: {
41971
+ const iso = value.toISOString().replace(".000Z", "Z");
41972
+ this.writeAsciiQuoted(iso);
41973
+ return;
41974
+ }
41975
+ case 6: {
41976
+ this.writeAsciiQuoted(dateToUtcString(value));
41977
+ return;
41978
+ }
41979
+ case 7: {
41980
+ const epochSecs = String(value.getTime() / 1e3);
41981
+ this.writeAscii(epochSecs);
41982
+ return;
41983
+ }
41984
+ default: {
41985
+ const epochSecs = String(value.getTime() / 1e3);
41986
+ this.writeAscii(epochSecs);
41987
+ return;
41493
41988
  }
41494
41989
  }
41495
- return value;
41496
41990
  }
41497
41991
  };
41498
41992
  }
41499
41993
  });
41500
41994
 
41501
- // ../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v1/JsonCodec.js
41502
- var JsonCodec;
41503
- var init_JsonCodec = __esm({
41504
- "../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v1/JsonCodec.js"() {
41995
+ // ../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v2/JsonCodec2.js
41996
+ var JsonCodec2;
41997
+ var init_JsonCodec2 = __esm({
41998
+ "../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v2/JsonCodec2.js"() {
41505
41999
  init_ConfigurableSerdeContext();
41506
- init_JsonShapeDeserializer();
41507
- init_JsonShapeSerializer();
41508
- JsonCodec = class extends SerdeContextConfig {
42000
+ init_JsonShapeDeserializer2();
42001
+ init_JsonShapeSerializer2();
42002
+ JsonCodec2 = class extends SerdeContextConfig {
41509
42003
  static {
41510
- __name(this, "JsonCodec");
42004
+ __name(this, "JsonCodec2");
41511
42005
  }
41512
42006
  settings;
41513
42007
  constructor(settings) {
@@ -41515,12 +42009,12 @@ var init_JsonCodec = __esm({
41515
42009
  this.settings = settings;
41516
42010
  }
41517
42011
  createSerializer() {
41518
- const serializer = new JsonShapeSerializer(this.settings);
42012
+ const serializer = new JsonShapeSerializer2(this.settings);
41519
42013
  serializer.setSerdeContext(this.serdeContext);
41520
42014
  return serializer;
41521
42015
  }
41522
42016
  createDeserializer() {
41523
- const deserializer = new JsonShapeDeserializer(this.settings);
42017
+ const deserializer = new JsonShapeDeserializer2(this.settings);
41524
42018
  deserializer.setSerdeContext(this.serdeContext);
41525
42019
  return deserializer;
41526
42020
  }
@@ -41535,7 +42029,7 @@ var init_AwsJsonRpcProtocol = __esm({
41535
42029
  init_protocols();
41536
42030
  init_schema4();
41537
42031
  init_ProtocolLib();
41538
- init_JsonCodec();
42032
+ init_JsonCodec2();
41539
42033
  init_parseJsonBody();
41540
42034
  AwsJsonRpcProtocol = class extends RpcProtocol {
41541
42035
  static {
@@ -41553,7 +42047,7 @@ var init_AwsJsonRpcProtocol = __esm({
41553
42047
  errorTypeRegistries: errorTypeRegistries6
41554
42048
  });
41555
42049
  this.serviceTarget = serviceTarget;
41556
- this.codec = jsonCodec ?? new JsonCodec({
42050
+ this.codec = jsonCodec ?? new JsonCodec2({
41557
42051
  timestampFormat: {
41558
42052
  useTrait: true,
41559
42053
  default: 7
@@ -41683,7 +42177,7 @@ var init_AwsRestJsonProtocol = __esm({
41683
42177
  init_protocols();
41684
42178
  init_schema4();
41685
42179
  init_ProtocolLib();
41686
- init_JsonCodec();
42180
+ init_JsonCodec2();
41687
42181
  init_parseJsonBody();
41688
42182
  AwsRestJsonProtocol = class extends HttpBindingProtocol {
41689
42183
  static {
@@ -41693,7 +42187,7 @@ var init_AwsRestJsonProtocol = __esm({
41693
42187
  deserializer;
41694
42188
  codec;
41695
42189
  mixin = new ProtocolLib();
41696
- constructor({ defaultNamespace, errorTypeRegistries: errorTypeRegistries6 }) {
42190
+ constructor({ defaultNamespace, errorTypeRegistries: errorTypeRegistries6, jsonCodec }) {
41697
42191
  super({
41698
42192
  defaultNamespace,
41699
42193
  errorTypeRegistries: errorTypeRegistries6
@@ -41706,7 +42200,7 @@ var init_AwsRestJsonProtocol = __esm({
41706
42200
  httpBindings: true,
41707
42201
  jsonName: true
41708
42202
  };
41709
- this.codec = new JsonCodec(settings);
42203
+ this.codec = jsonCodec ?? new JsonCodec2(settings);
41710
42204
  this.serializer = new HttpInterceptingShapeSerializer(this.codec.createSerializer(), settings);
41711
42205
  this.deserializer = new HttpInterceptingShapeDeserializer(this.codec.createDeserializer(), settings);
41712
42206
  }
@@ -41771,24 +42265,23 @@ var init_AwsRestJsonProtocol = __esm({
41771
42265
  }
41772
42266
  });
41773
42267
 
41774
- // ../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v2/JsonShapeDeserializer2.js
41775
- var JsonShapeDeserializer2;
41776
- var init_JsonShapeDeserializer2 = __esm({
41777
- "../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v2/JsonShapeDeserializer2.js"() {
42268
+ // ../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v1/JsonShapeDeserializer.js
42269
+ var JsonShapeDeserializer;
42270
+ var init_JsonShapeDeserializer = __esm({
42271
+ "../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v1/JsonShapeDeserializer.js"() {
41778
42272
  init_protocols();
41779
42273
  init_schema4();
41780
42274
  init_serde();
41781
42275
  init_serde();
41782
42276
  init_ConfigurableSerdeContext();
41783
42277
  init_UnionSerde();
41784
- init_detectBufferParsing();
41785
42278
  init_jsonReviver();
41786
42279
  init_needsReviver();
41787
42280
  init_parseJsonBody();
41788
42281
  init_writeKey();
41789
- JsonShapeDeserializer2 = class extends SerdeContextConfig {
42282
+ JsonShapeDeserializer = class extends SerdeContextConfig {
41790
42283
  static {
41791
- __name(this, "JsonShapeDeserializer2");
42284
+ __name(this, "JsonShapeDeserializer");
41792
42285
  }
41793
42286
  settings;
41794
42287
  constructor(settings) {
@@ -41797,16 +42290,7 @@ var init_JsonShapeDeserializer2 = __esm({
41797
42290
  }
41798
42291
  async read(schema, data) {
41799
42292
  const reviver = needsReviver(schema) ? jsonReviver : void 0;
41800
- let parsed;
41801
- if (typeof data === "string") {
41802
- parsed = JSON.parse(data, reviver);
41803
- } else if (data instanceof Uint8Array && detectBufferParsing()) {
41804
- const buf2 = Buffer.isBuffer(data) ? data : Buffer.from(data.buffer, data.byteOffset, data.byteLength);
41805
- parsed = JSON.parse(buf2, reviver);
41806
- } else {
41807
- parsed = await parseJsonBody(data, this.serdeContext);
41808
- }
41809
- return this._read(schema, parsed);
42293
+ return this._read(schema, typeof data === "string" ? JSON.parse(data, reviver) : await parseJsonBody(data, this.serdeContext, schema));
41810
42294
  }
41811
42295
  readObject(schema, data) {
41812
42296
  return this._read(schema, data);
@@ -41816,25 +42300,62 @@ var init_JsonShapeDeserializer2 = __esm({
41816
42300
  const ns = NormalizedSchema.of(schema);
41817
42301
  if (isObject3) {
41818
42302
  if (ns.isStructSchema()) {
41819
- return this._readStruct(ns, value);
42303
+ const record = value;
42304
+ const union = ns.isUnionSchema();
42305
+ const out = {};
42306
+ let nameMap = void 0;
42307
+ const { jsonName } = this.settings;
42308
+ if (jsonName) {
42309
+ nameMap = {};
42310
+ }
42311
+ let unionSerde;
42312
+ if (union) {
42313
+ unionSerde = new UnionSerde(record, out);
42314
+ }
42315
+ for (const [memberName, memberSchema] of ns.structIterator()) {
42316
+ let fromKey = memberName;
42317
+ if (jsonName) {
42318
+ fromKey = memberSchema.getMergedTraits().jsonName ?? fromKey;
42319
+ nameMap[fromKey] = memberName;
42320
+ }
42321
+ if (union) {
42322
+ unionSerde.mark(fromKey);
42323
+ }
42324
+ if (record[fromKey] != null) {
42325
+ out[memberName] = this._read(memberSchema, record[fromKey]);
42326
+ }
42327
+ }
42328
+ if (union) {
42329
+ unionSerde.writeUnknown();
42330
+ } else if (typeof record.__type === "string") {
42331
+ for (const k6 in record) {
42332
+ const v = record[k6];
42333
+ const t = jsonName ? nameMap[k6] ?? k6 : k6;
42334
+ if (!(t in out)) {
42335
+ out[t] = v;
42336
+ }
42337
+ }
42338
+ }
42339
+ return out;
41820
42340
  }
41821
42341
  if (Array.isArray(value) && ns.isListSchema()) {
41822
42342
  const listMember = ns.getValueSchema();
41823
- for (let i6 = 0; i6 < value.length; ++i6) {
41824
- value[i6] = this._read(listMember, value[i6]);
42343
+ const out = [];
42344
+ for (const item of value) {
42345
+ out.push(this._read(listMember, item));
41825
42346
  }
41826
- return value;
42347
+ return out;
41827
42348
  }
41828
42349
  if (ns.isMapSchema()) {
41829
42350
  const mapMember = ns.getValueSchema();
41830
- const map3 = value;
41831
- for (const k6 in map3) {
41832
- if (k6 === "__proto__") {
41833
- writeKey(map3);
42351
+ const out = {};
42352
+ for (const _k in value) {
42353
+ if (_k === "__proto__") {
42354
+ writeKey(out);
41834
42355
  }
41835
- map3[k6] = this._read(mapMember, map3[k6]);
42356
+ out[_k] = this._read(mapMember, value[_k]);
41836
42357
  }
41837
- return map3;
42358
+ return out;
41838
42359
  }
41839
42360
  }
41840
42361
  if (ns.isBlobSchema() && typeof value === "string") {
@@ -41888,577 +42409,295 @@ var init_JsonShapeDeserializer2 = __esm({
41888
42409
  }
41889
42410
  if (ns.isDocumentSchema()) {
41890
42411
  if (isObject3) {
41891
- if (Array.isArray(value)) {
41892
- for (let i6 = 0; i6 < value.length; ++i6) {
41893
- const v = value[i6];
41894
- if (!(v instanceof NumericValue)) {
41895
- value[i6] = this._read(ns, v);
41896
- }
42412
+ const out = Array.isArray(value) ? [] : {};
42413
+ for (const k6 in value) {
42414
+ if (k6 === "__proto__") {
42415
+ writeKey(out);
41897
42416
  }
41898
- } else {
41899
- const doc = value;
41900
- for (const k6 in doc) {
41901
- if (k6 === "__proto__") {
41902
- writeKey(doc);
41903
- }
41904
- const v = doc[k6];
41905
- if (!(v instanceof NumericValue)) {
41906
- doc[k6] = this._read(ns, v);
41907
- }
42417
+ const v = value[k6];
42418
+ if (v instanceof NumericValue) {
42419
+ out[k6] = v;
42420
+ } else {
42421
+ out[k6] = this._read(ns, v);
41908
42422
  }
41909
42423
  }
41910
- return value;
42424
+ return out;
41911
42425
  } else {
41912
- return value;
42426
+ return structuredClone(value);
41913
42427
  }
41914
42428
  }
41915
42429
  return value;
41916
42430
  }
41917
- _readStruct(ns, record) {
41918
- const union = ns.isUnionSchema();
41919
- const out = {};
41920
- let nameMap = void 0;
41921
- const { jsonName } = this.settings;
41922
- if (jsonName) {
41923
- nameMap = {};
42431
+ };
42432
+ }
42433
+ });
42434
+
42435
+ // ../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/jsonReplacer.js
42436
+ var NUMERIC_CONTROL_CHAR, JsonReplacer;
42437
+ var init_jsonReplacer = __esm({
42438
+ "../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/jsonReplacer.js"() {
42439
+ init_serde();
42440
+ NUMERIC_CONTROL_CHAR = String.fromCharCode(925);
42441
+ JsonReplacer = class {
42442
+ static {
42443
+ __name(this, "JsonReplacer");
42444
+ }
42445
+ values = /* @__PURE__ */ new Map();
42446
+ counter = 0;
42447
+ stage = 0;
42448
+ createReplacer() {
42449
+ if (this.stage === 1) {
42450
+ throw new Error("@aws-sdk/core/protocols - JsonReplacer already created.");
41924
42451
  }
41925
- let unionSerde;
41926
- if (union) {
41927
- unionSerde = new UnionSerde(record, out);
42452
+ if (this.stage === 2) {
42453
+ throw new Error("@aws-sdk/core/protocols - JsonReplacer exhausted.");
41928
42454
  }
41929
- for (const [memberName, memberSchema] of ns.structIterator()) {
41930
- let fromKey = memberName;
41931
- if (jsonName) {
41932
- fromKey = memberSchema.getMergedTraits().jsonName ?? fromKey;
41933
- nameMap[fromKey] = memberName;
41934
- }
41935
- if (union) {
41936
- unionSerde.mark(fromKey);
42455
+ this.stage = 1;
42456
+ return (key, value) => {
42457
+ if (value instanceof NumericValue) {
42458
+ const v = `${NUMERIC_CONTROL_CHAR + "nv" + this.counter++}_` + value.string;
42459
+ this.values.set(`"${v}"`, value.string);
42460
+ return v;
41937
42461
  }
41938
- if (record[fromKey] != null) {
41939
- out[memberName] = this._read(memberSchema, record[fromKey]);
42462
+ if (typeof value === "bigint") {
42463
+ const s2 = value.toString();
42464
+ const v = `${NUMERIC_CONTROL_CHAR + "b" + this.counter++}_` + s2;
42465
+ this.values.set(`"${v}"`, s2);
42466
+ return v;
41940
42467
  }
42468
+ return value;
42469
+ };
42470
+ }
42471
+ replaceInJson(json) {
42472
+ if (this.stage === 0) {
42473
+ throw new Error("@aws-sdk/core/protocols - JsonReplacer not created yet.");
41941
42474
  }
41942
- if (union) {
41943
- unionSerde.writeUnknown();
41944
- } else if (typeof record.__type === "string") {
41945
- for (const k6 in record) {
41946
- const v = record[k6];
41947
- const t = jsonName ? nameMap[k6] ?? k6 : k6;
41948
- if (!(t in out)) {
41949
- out[t] = v;
41950
- }
41951
- }
42475
+ if (this.stage === 2) {
42476
+ throw new Error("@aws-sdk/core/protocols - JsonReplacer exhausted.");
41952
42477
  }
41953
- return out;
42478
+ this.stage = 2;
42479
+ if (this.counter === 0) {
42480
+ return json;
42481
+ }
42482
+ for (const [key, value] of this.values) {
42483
+ json = json.replace(key, value);
42484
+ }
42485
+ return json;
41954
42486
  }
41955
42487
  };
41956
42488
  }
41957
42489
  });
41958
42490
 
41959
- // ../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v2/JsonShapeSerializer2.js
41960
- function alloc(size) {
41961
- return typeof Buffer !== "undefined" ? Buffer.allocUnsafe(size) : new Uint8Array(size);
41962
- }
41963
- var encoder, OPEN_BRACE, CLOSE_BRACE, OPEN_BRACKET, CLOSE_BRACKET, QUOTE, COLON, COMMA, BACKSLASH, TRUE, FALSE, NULL, ESCAPE_TABLE, INITIAL_BUFFER_SIZE2, JsonShapeSerializer2;
41964
- var init_JsonShapeSerializer2 = __esm({
41965
- "../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v2/JsonShapeSerializer2.js"() {
42491
+ // ../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v1/JsonShapeSerializer.js
42492
+ var JsonShapeSerializer;
42493
+ var init_JsonShapeSerializer = __esm({
42494
+ "../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v1/JsonShapeSerializer.js"() {
41966
42495
  init_protocols();
41967
42496
  init_schema4();
41968
42497
  init_serde();
41969
42498
  init_ConfigurableSerdeContext();
42499
+ init_jsonReplacer();
41970
42500
  init_writeKey();
41971
- encoder = new TextEncoder();
41972
- OPEN_BRACE = 123;
41973
- CLOSE_BRACE = 125;
41974
- OPEN_BRACKET = 91;
41975
- CLOSE_BRACKET = 93;
41976
- QUOTE = 34;
41977
- COLON = 58;
41978
- COMMA = 44;
41979
- BACKSLASH = 92;
41980
- TRUE = new Uint8Array([116, 114, 117, 101]);
41981
- FALSE = new Uint8Array([102, 97, 108, 115, 101]);
41982
- NULL = new Uint8Array([110, 117, 108, 108]);
41983
- ESCAPE_TABLE = new Array(128).fill(null);
41984
- ESCAPE_TABLE[8] = "b";
41985
- ESCAPE_TABLE[9] = "t";
41986
- ESCAPE_TABLE[10] = "n";
41987
- ESCAPE_TABLE[12] = "f";
41988
- ESCAPE_TABLE[13] = "r";
41989
- ESCAPE_TABLE[34] = '"';
41990
- ESCAPE_TABLE[92] = "\\";
41991
- for (let i6 = 0; i6 < 32; i6++) {
41992
- if (ESCAPE_TABLE[i6] === null) {
41993
- ESCAPE_TABLE[i6] = "u00" + i6.toString(16).padStart(2, "0");
41994
- }
41995
- }
41996
- INITIAL_BUFFER_SIZE2 = 2048;
41997
- __name(alloc, "alloc");
41998
- JsonShapeSerializer2 = class _JsonShapeSerializer2 extends SerdeContextConfig {
42501
+ JsonShapeSerializer = class extends SerdeContextConfig {
41999
42502
  static {
42000
- __name(this, "JsonShapeSerializer2");
42503
+ __name(this, "JsonShapeSerializer");
42001
42504
  }
42002
42505
  settings;
42003
- json;
42004
- i = 0;
42506
+ buffer;
42507
+ useReplacer = false;
42005
42508
  rootSchema;
42006
- rawValue;
42007
- passthrough = false;
42008
42509
  constructor(settings) {
42009
42510
  super();
42010
42511
  this.settings = settings;
42011
- this.json = alloc(INITIAL_BUFFER_SIZE2);
42012
42512
  }
42013
42513
  write(schema, value) {
42014
- this.i = 0;
42015
- this.rawValue = value;
42016
- this.rootSchema = NormalizedSchema.of(schema);
42017
- this.passthrough = !this.rootSchema.isStructSchema() && !this.rootSchema.isDocumentSchema() && (this.rootSchema.isBlobSchema() || this.rootSchema.isStringSchema());
42018
- if (!this.passthrough) {
42019
- this.writeValue(this.rootSchema, value, void 0);
42020
- }
42021
- }
42022
- writeDiscriminatedDocument(schema, value) {
42023
- this.i = 0;
42024
42514
  this.rootSchema = NormalizedSchema.of(schema);
42025
- const ns = this.rootSchema;
42026
- if (ns.isStructSchema() && value != null && typeof value === "object") {
42027
- this.ensure(2);
42028
- this.json[this.i++] = OPEN_BRACE;
42029
- this.writeAsciiQuoted("__type");
42030
- this.json[this.i++] = COLON;
42031
- this.writeAsciiQuoted(ns.getName(true) ?? "Unknown");
42032
- let wroteAny = true;
42033
- const { jsonName } = this.settings;
42034
- for (const [memberName, memberSchema] of ns.structIterator()) {
42035
- const item = value[memberName];
42036
- if (item == null && !memberSchema.isIdempotencyToken()) {
42037
- continue;
42038
- }
42039
- if (wroteAny) {
42040
- this.ensure(1);
42041
- this.json[this.i++] = COMMA;
42042
- }
42043
- const targetKey = jsonName ? memberSchema.getMergedTraits().jsonName ?? memberName : memberName;
42044
- this.writeAsciiQuoted(targetKey);
42045
- this.json[this.i++] = COLON;
42046
- this.writeValue(memberSchema, item, ns);
42047
- wroteAny = true;
42048
- }
42049
- this.ensure(1);
42050
- this.json[this.i++] = CLOSE_BRACE;
42051
- } else {
42052
- this.writeValue(ns, value, void 0);
42053
- }
42515
+ this.buffer = this._write(this.rootSchema, value);
42054
42516
  }
42055
42517
  flush() {
42518
+ const { rootSchema, useReplacer } = this;
42056
42519
  this.rootSchema = void 0;
42057
- const finalPosition = this.i;
42058
- this.i = 0;
42059
- const raw = this.rawValue;
42060
- this.rawValue = void 0;
42061
- if (finalPosition === 0) {
42062
- return raw;
42063
- }
42064
- const result2 = this.json.subarray(0, finalPosition);
42065
- this.json = alloc(INITIAL_BUFFER_SIZE2);
42066
- return result2;
42067
- }
42068
- ensure(byteCount) {
42069
- const { i: i6, json } = this;
42070
- if (i6 + byteCount > json.length) {
42071
- let newSize = json.length * 2;
42072
- while (newSize < i6 + byteCount) {
42073
- newSize *= 2;
42520
+ this.useReplacer = false;
42521
+ if (rootSchema?.isStructSchema() || rootSchema?.isDocumentSchema()) {
42522
+ if (!useReplacer) {
42523
+ return JSON.stringify(this.buffer);
42074
42524
  }
42075
- const next = alloc(newSize);
42076
- next.set(this.json);
42077
- this.json = next;
42078
- }
42079
- }
42080
- writeAscii(s2) {
42081
- const z = s2.length;
42082
- this.ensure(z);
42083
- let { i: i6, json } = this;
42084
- for (let j6 = 0; j6 < z; ++j6) {
42085
- json[i6] = s2.charCodeAt(j6);
42086
- i6 += 1;
42525
+ const replacer = new JsonReplacer();
42526
+ return replacer.replaceInJson(JSON.stringify(this.buffer, replacer.createReplacer(), 0));
42087
42527
  }
42088
- this.i = i6;
42528
+ return this.buffer;
42089
42529
  }
42090
- writeAsciiQuoted(s2) {
42091
- const z = s2.length;
42092
- this.ensure(z + 4);
42093
- let { json, i: i6 } = this;
42094
- json[i6++] = QUOTE;
42095
- for (let j6 = 0; j6 < z; ++j6) {
42096
- json[i6++] = s2.charCodeAt(j6);
42530
+ writeDiscriminatedDocument(schema, value) {
42531
+ this.write(schema, value);
42532
+ if (typeof this.buffer === "object") {
42533
+ this.buffer.__type = NormalizedSchema.of(schema).getName(true);
42097
42534
  }
42098
- json[i6++] = QUOTE;
42099
- this.i = i6;
42100
42535
  }
42101
- writeJsonString(s2) {
42102
- this.ensure(s2.length * 2 + 2);
42103
- this.json[this.i++] = QUOTE;
42104
- const z = s2.length;
42105
- for (let j6 = 0; j6 < z; ++j6) {
42106
- const c6 = s2.charCodeAt(j6);
42107
- if (c6 > 34 && c6 < 92) {
42108
- this.json[this.i++] = c6;
42109
- } else if (c6 < 128) {
42110
- const esc = ESCAPE_TABLE[c6];
42111
- if (esc !== null) {
42112
- this.ensure(esc.length + 1);
42113
- this.json[this.i++] = BACKSLASH;
42114
- for (let k6 = 0; k6 < esc.length; k6++) {
42115
- this.json[this.i++] = esc.charCodeAt(k6);
42116
- }
42117
- } else {
42118
- this.json[this.i++] = c6;
42119
- }
42120
- } else if (c6 >= 55296 && c6 <= 56319) {
42121
- const next = j6 + 1 < z ? s2.charCodeAt(j6 + 1) : 0;
42122
- if (next >= 56320 && next <= 57343) {
42123
- this.ensure(4);
42124
- const { written } = encoder.encodeInto(s2.substring(j6, j6 + 2), this.json.subarray(this.i));
42125
- this.i += written;
42126
- j6++;
42127
- } else {
42128
- this.ensure(6);
42129
- this.writeUnicodeEscape(c6);
42536
+ _write(schema, value, container) {
42537
+ const isObject3 = value !== null && typeof value === "object";
42538
+ const ns = NormalizedSchema.of(schema);
42539
+ if (isObject3) {
42540
+ if (ns.isStructSchema()) {
42541
+ const record = value;
42542
+ const out = {};
42543
+ const { jsonName } = this.settings;
42544
+ let nameMap = void 0;
42545
+ if (jsonName) {
42546
+ nameMap = {};
42130
42547
  }
42131
- } else if (c6 >= 56320 && c6 <= 57343) {
42132
- this.ensure(6);
42133
- this.writeUnicodeEscape(c6);
42134
- } else {
42135
- let { i: i6, json } = this;
42136
- if (c6 < 2048) {
42137
- json[i6++] = 192 | c6 >> 6;
42138
- json[i6++] = 128 | c6 & 63;
42139
- } else {
42140
- json[i6++] = 224 | c6 >> 12;
42141
- json[i6++] = 128 | c6 >> 6 & 63;
42142
- json[i6++] = 128 | c6 & 63;
42548
+ let outCount = 0;
42549
+ for (const [memberName, memberSchema] of ns.structIterator()) {
42550
+ const serializableValue = this._write(memberSchema, record[memberName], ns);
42551
+ if (serializableValue !== void 0) {
42552
+ let targetKey = memberName;
42553
+ if (jsonName) {
42554
+ targetKey = memberSchema.getMergedTraits().jsonName ?? memberName;
42555
+ nameMap[memberName] = targetKey;
42556
+ }
42557
+ out[targetKey] = serializableValue;
42558
+ outCount++;
42559
+ }
42143
42560
  }
42144
- this.i = i6;
42145
- }
42146
- }
42147
- this.json[this.i++] = QUOTE;
42148
- }
42149
- writeUnicodeEscape(code) {
42150
- let { json, i: i6 } = this;
42151
- json[i6++] = BACKSLASH;
42152
- json[i6++] = 117;
42153
- const hex = code.toString(16).padStart(4, "0");
42154
- for (let j6 = 0; j6 < 4; ++j6) {
42155
- json[i6++] = hex.charCodeAt(j6);
42156
- }
42157
- this.i = i6;
42158
- }
42159
- static B64 = (() => {
42160
- const chars2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
42161
- const table3 = new Uint8Array(64);
42162
- for (let i6 = 0; i6 < 64; i6++)
42163
- table3[i6] = chars2.charCodeAt(i6);
42164
- return table3;
42165
- })();
42166
- writeBase64(data) {
42167
- const b64Len = Math.ceil(data.length / 3) * 4;
42168
- this.ensure(b64Len + 2);
42169
- const json = this.json;
42170
- const B64 = _JsonShapeSerializer2.B64;
42171
- let i6 = this.i;
42172
- json[i6++] = QUOTE;
42173
- const len = data.length;
42174
- const remainder = len % 3;
42175
- const mainLen = len - remainder;
42176
- for (let j6 = 0; j6 < mainLen; j6 += 3) {
42177
- const a6 = data[j6];
42178
- const b6 = data[j6 + 1];
42179
- const c6 = data[j6 + 2];
42180
- json[i6++] = B64[a6 >> 2];
42181
- json[i6++] = B64[(a6 & 3) << 4 | b6 >> 4];
42182
- json[i6++] = B64[(b6 & 15) << 2 | c6 >> 6];
42183
- json[i6++] = B64[c6 & 63];
42184
- }
42185
- if (remainder === 2) {
42186
- const a6 = data[mainLen];
42187
- const b6 = data[mainLen + 1];
42188
- json[i6++] = B64[a6 >> 2];
42189
- json[i6++] = B64[(a6 & 3) << 4 | b6 >> 4];
42190
- json[i6++] = B64[(b6 & 15) << 2];
42191
- json[i6++] = 61;
42192
- } else if (remainder === 1) {
42193
- const a6 = data[mainLen];
42194
- json[i6++] = B64[a6 >> 2];
42195
- json[i6++] = B64[(a6 & 3) << 4];
42196
- json[i6++] = 61;
42197
- json[i6++] = 61;
42198
- }
42199
- json[i6++] = QUOTE;
42200
- this.i = i6;
42201
- }
42202
- writeValue(schema, value, container) {
42203
- if (value == null) {
42204
- if (container?.isStructSchema()) {
42205
- if (value === void 0) {
42206
- const ns2 = NormalizedSchema.of(schema);
42207
- if (ns2.isIdempotencyToken()) {
42208
- this.writeAsciiQuoted(generateIdempotencyToken());
42209
- return;
42561
+ if (ns.isUnionSchema() && outCount === 0) {
42562
+ const { $unknown } = record;
42563
+ if (Array.isArray($unknown)) {
42564
+ const [k6, v] = $unknown;
42565
+ if (k6 === "__proto__") {
42566
+ writeKey(out);
42567
+ }
42568
+ out[k6] = this._write(15, v);
42569
+ }
42570
+ } else if (typeof record.__type === "string") {
42571
+ for (const k6 in record) {
42572
+ const v = record[k6];
42573
+ const targetKey = jsonName ? nameMap[k6] ?? k6 : k6;
42574
+ if (!(targetKey in out)) {
42575
+ out[targetKey] = this._write(15, v);
42576
+ }
42210
42577
  }
42211
42578
  }
42212
- return;
42579
+ return out;
42213
42580
  }
42214
- this.ensure(4);
42215
- this.json.set(NULL, this.i);
42216
- this.i += 4;
42217
- return;
42218
- }
42219
- const ns = NormalizedSchema.of(schema);
42220
- const isObject3 = typeof value === "object";
42221
- if (ns.isStringSchema()) {
42222
- const mediaType = ns.getMergedTraits().mediaType;
42223
- if (mediaType) {
42224
- const isJson = mediaType === "application/json" || mediaType.endsWith("+json");
42225
- if (isJson) {
42226
- this.writeJsonString(LazyJsonString.from(value).toString());
42227
- return;
42581
+ if (Array.isArray(value) && ns.isListSchema()) {
42582
+ const listMember = ns.getValueSchema();
42583
+ const out = [];
42584
+ const sparse = !!ns.getMergedTraits().sparse;
42585
+ for (const item of value) {
42586
+ if (sparse || item != null) {
42587
+ out.push(this._write(listMember, item));
42588
+ }
42228
42589
  }
42229
- }
42230
- }
42231
- if (isObject3) {
42232
- if (ns.isStructSchema()) {
42233
- this.writeStruct(ns, value);
42234
- return;
42235
- }
42236
- if (Array.isArray(value) && (ns.isListSchema() || ns.isDocumentSchema())) {
42237
- this.writeList(ns, value, ns.isDocumentSchema());
42238
- return;
42590
+ return out;
42239
42591
  }
42240
42592
  if (ns.isMapSchema()) {
42241
- this.writeMap(ns, value, false);
42242
- return;
42593
+ const mapMember = ns.getValueSchema();
42594
+ const out = {};
42595
+ const sparse = !!ns.getMergedTraits().sparse;
42596
+ for (const _k in value) {
42597
+ const _v = value[_k];
42598
+ if (sparse || _v != null) {
42599
+ if (_k === "__proto__") {
42600
+ writeKey(out);
42601
+ }
42602
+ out[_k] = this._write(mapMember, _v);
42603
+ }
42604
+ }
42605
+ return out;
42243
42606
  }
42244
- if (value instanceof Uint8Array && (ns.isBlobSchema() || ns.isDocumentSchema())) {
42245
- this.writeBase64(value);
42246
- return;
42607
+ if (value instanceof Uint8Array && ns.isBlobSchema()) {
42608
+ if (ns === this.rootSchema) {
42609
+ return value;
42610
+ }
42611
+ return (this.serdeContext?.base64Encoder ?? toBase64)(value);
42247
42612
  }
42248
42613
  if (value instanceof Date && (ns.isTimestampSchema() || ns.isDocumentSchema())) {
42249
- this.writeTimestamp(ns, value);
42250
- return;
42614
+ const format28 = determineTimestampFormat(ns, this.settings);
42615
+ switch (format28) {
42616
+ case 5:
42617
+ return value.toISOString().replace(".000Z", "Z");
42618
+ case 6:
42619
+ return dateToUtcString(value);
42620
+ case 7:
42621
+ return value.getTime() / 1e3;
42622
+ default:
42623
+ console.warn("Missing timestamp format, using epoch seconds", value);
42624
+ return value.getTime() / 1e3;
42625
+ }
42251
42626
  }
42252
42627
  if (value instanceof NumericValue) {
42253
- this.writeAscii(value.string);
42254
- return;
42255
- }
42256
- if (ns.isDocumentSchema()) {
42257
- if (Array.isArray(value)) {
42258
- this.writeList(ns, value, true);
42259
- } else {
42260
- this.writeMap(ns, value, true);
42261
- }
42262
- return;
42628
+ this.useReplacer = true;
42263
42629
  }
42264
- const json = JSON.stringify(value);
42265
- this.writeAscii(json);
42266
- return;
42267
42630
  }
42268
- if (typeof value === "string") {
42269
- if (ns.isBlobSchema()) {
42270
- const b64 = (this.serdeContext?.base64Encoder ?? toBase64)(value);
42271
- this.writeAsciiQuoted(b64);
42272
- return;
42631
+ if (value === null && container?.isStructSchema()) {
42632
+ return void 0;
42633
+ }
42634
+ if (ns.isStringSchema()) {
42635
+ if (typeof value === "undefined" && ns.isIdempotencyToken()) {
42636
+ return generateIdempotencyToken();
42273
42637
  }
42274
- this.writeJsonString(value);
42275
- return;
42638
+ const mediaType = ns.getMergedTraits().mediaType;
42639
+ if (value != null && mediaType) {
42640
+ const isJson = mediaType === "application/json" || mediaType.endsWith("+json");
42641
+ if (isJson) {
42642
+ return LazyJsonString.from(value);
42643
+ }
42644
+ }
42645
+ return value;
42276
42646
  }
42277
42647
  if (typeof value === "number") {
42278
- if (ns.isNumericSchema() && (Math.abs(value) === Infinity || isNaN(value))) {
42279
- this.writeAsciiQuoted(String(value));
42280
- return;
42648
+ if (Math.abs(value) === Infinity || isNaN(value)) {
42649
+ return String(value);
42281
42650
  }
42282
- const numStr = String(value);
42283
- this.writeAscii(numStr);
42284
- return;
42651
+ return value;
42285
42652
  }
42286
- if (typeof value === "boolean") {
42287
- this.ensure(5);
42288
- if (value) {
42289
- this.json.set(TRUE, this.i);
42290
- this.i += 4;
42291
- } else {
42292
- this.json.set(FALSE, this.i);
42293
- this.i += 5;
42653
+ if (typeof value === "string" && ns.isBlobSchema()) {
42654
+ if (ns === this.rootSchema) {
42655
+ return value;
42294
42656
  }
42295
- return;
42657
+ return (this.serdeContext?.base64Encoder ?? toBase64)(value);
42296
42658
  }
42297
42659
  if (typeof value === "bigint") {
42298
- this.writeAscii(value.toString());
42299
- return;
42300
- }
42301
- this.writeAscii(String(value));
42302
- }
42303
- writeStruct(ns, value) {
42304
- this.ensure(2);
42305
- this.json[this.i++] = OPEN_BRACE;
42306
- let first = true;
42307
- let wroteAny = false;
42308
- const hasType = typeof value.__type === "string";
42309
- let writtenKeys;
42310
- if (hasType) {
42311
- writtenKeys = /* @__PURE__ */ new Set();
42312
- }
42313
- for (const [memberName, memberSchema] of ns.structIterator()) {
42314
- const item = value[memberName];
42315
- if (item == null && !memberSchema.isIdempotencyToken())
42316
- continue;
42317
- if (!first) {
42318
- this.ensure(1);
42319
- this.json[this.i++] = COMMA;
42320
- }
42321
- first = false;
42322
- wroteAny = true;
42323
- const targetKey = this.settings.jsonName ? memberSchema.getMergedTraits().jsonName ?? memberName : memberName;
42324
- if (writtenKeys) {
42325
- writtenKeys.add(memberName);
42326
- writtenKeys.add(targetKey);
42327
- }
42328
- this.writeAsciiQuoted(targetKey);
42329
- this.json[this.i++] = COLON;
42330
- this.writeValue(memberSchema, item, ns);
42660
+ this.useReplacer = true;
42331
42661
  }
42332
- if (!wroteAny && ns.isUnionSchema()) {
42333
- const { $unknown } = value;
42334
- if (Array.isArray($unknown)) {
42335
- const [k6, v] = $unknown;
42336
- this.writeAsciiQuoted(k6);
42337
- this.ensure(1);
42338
- this.json[this.i++] = COLON;
42339
- this.writeValue(15, v, ns);
42340
- }
42341
- } else if (hasType) {
42342
- for (const k6 in value) {
42343
- const targetKey = this.settings.jsonName ? writtenKeys.has(k6) ? k6 : k6 : k6;
42344
- if (writtenKeys.has(targetKey))
42345
- continue;
42346
- writtenKeys.add(targetKey);
42347
- const v = value[k6];
42348
- if (!first) {
42349
- this.ensure(1);
42350
- this.json[this.i++] = COMMA;
42662
+ if (ns.isDocumentSchema()) {
42663
+ if (isObject3) {
42664
+ if (value instanceof Uint8Array) {
42665
+ return (this.serdeContext?.base64Encoder ?? toBase64)(value);
42351
42666
  }
42352
- first = false;
42353
- this.writeAsciiQuoted(targetKey);
42354
- this.ensure(1);
42355
- this.json[this.i++] = COLON;
42356
- this.writeValue(15, v, void 0);
42357
- }
42358
- }
42359
- this.ensure(1);
42360
- this.json[this.i++] = CLOSE_BRACE;
42361
- }
42362
- writeList(ns, value, isDocument) {
42363
- this.ensure(2);
42364
- this.json[this.i++] = OPEN_BRACKET;
42365
- const sparse = !!ns.getMergedTraits().sparse;
42366
- const valueSchema = ns.getValueSchema();
42367
- for (let i6 = 0; i6 < value.length; ++i6) {
42368
- const item = value[i6];
42369
- if (isDocument ? item === void 0 : item == null && !sparse) {
42370
- continue;
42371
- }
42372
- if (i6 !== 0) {
42373
- this.ensure(1);
42374
- this.json[this.i++] = COMMA;
42375
- }
42376
- this.writeValue(valueSchema, item, void 0);
42377
- }
42378
- this.ensure(1);
42379
- this.json[this.i++] = CLOSE_BRACKET;
42380
- }
42381
- writeMap(ns, value, isDocument) {
42382
- const sparse = !!ns.getMergedTraits().sparse;
42383
- const valueSchema = ns.getValueSchema();
42384
- if (!isDocument) {
42385
- if (valueSchema.isStringSchema() || valueSchema.isNumericSchema() || valueSchema.isBooleanSchema()) {
42386
- let input = value;
42387
- if (sparse) {
42388
- input = {};
42389
- for (const k6 in value) {
42390
- if (k6 === "__proto__") {
42391
- writeKey(input);
42392
- }
42393
- input[k6] = value[k6] ?? null;
42667
+ const out = Array.isArray(value) ? [] : {};
42668
+ for (const k6 in value) {
42669
+ const v = value[k6];
42670
+ if (k6 === "__proto__") {
42671
+ writeKey(out);
42672
+ }
42673
+ if (v instanceof NumericValue) {
42674
+ this.useReplacer = true;
42675
+ out[k6] = v;
42676
+ } else {
42677
+ out[k6] = this._write(ns, v);
42394
42678
  }
42395
42679
  }
42396
- const json = JSON.stringify(input);
42397
- this.ensure(json.length * 3);
42398
- const { written } = encoder.encodeInto(json, this.json.subarray(this.i));
42399
- this.i += written;
42400
- return;
42401
- }
42402
- }
42403
- this.ensure(2);
42404
- this.json[this.i++] = OPEN_BRACE;
42405
- let first = true;
42406
- for (const k6 in value) {
42407
- const v = value[k6];
42408
- if (isDocument ? v === void 0 : v == null && !sparse) {
42409
- continue;
42410
- }
42411
- if (!first) {
42412
- this.ensure(1);
42413
- this.json[this.i++] = COMMA;
42414
- }
42415
- first = false;
42416
- this.writeJsonString(k6);
42417
- this.ensure(1);
42418
- this.json[this.i++] = COLON;
42419
- this.writeValue(valueSchema, v, void 0);
42420
- }
42421
- this.ensure(1);
42422
- this.json[this.i++] = CLOSE_BRACE;
42423
- }
42424
- writeTimestamp(ns, value) {
42425
- const format28 = determineTimestampFormat(ns, this.settings);
42426
- switch (format28) {
42427
- case 5: {
42428
- const iso = value.toISOString().replace(".000Z", "Z");
42429
- this.writeAsciiQuoted(iso);
42430
- return;
42431
- }
42432
- case 6: {
42433
- this.writeAsciiQuoted(dateToUtcString(value));
42434
- return;
42435
- }
42436
- case 7: {
42437
- const epochSecs = String(value.getTime() / 1e3);
42438
- this.writeAscii(epochSecs);
42439
- return;
42440
- }
42441
- default: {
42442
- const epochSecs = String(value.getTime() / 1e3);
42443
- this.writeAscii(epochSecs);
42444
- return;
42680
+ return out;
42681
+ } else {
42682
+ return structuredClone(value);
42445
42683
  }
42446
42684
  }
42685
+ return value;
42447
42686
  }
42448
42687
  };
42449
42688
  }
42450
42689
  });
42451
42690
 
42452
- // ../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v2/JsonCodec2.js
42453
- var JsonCodec2;
42454
- var init_JsonCodec2 = __esm({
42455
- "../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v2/JsonCodec2.js"() {
42691
+ // ../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v1/JsonCodec.js
42692
+ var JsonCodec;
42693
+ var init_JsonCodec = __esm({
42694
+ "../../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v1/JsonCodec.js"() {
42456
42695
  init_ConfigurableSerdeContext();
42457
- init_JsonShapeDeserializer2();
42458
- init_JsonShapeSerializer2();
42459
- JsonCodec2 = class extends SerdeContextConfig {
42696
+ init_JsonShapeDeserializer();
42697
+ init_JsonShapeSerializer();
42698
+ JsonCodec = class extends SerdeContextConfig {
42460
42699
  static {
42461
- __name(this, "JsonCodec2");
42700
+ __name(this, "JsonCodec");
42462
42701
  }
42463
42702
  settings;
42464
42703
  constructor(settings) {
@@ -42466,12 +42705,12 @@ var init_JsonCodec2 = __esm({
42466
42705
  this.settings = settings;
42467
42706
  }
42468
42707
  createSerializer() {
42469
- const serializer = new JsonShapeSerializer2(this.settings);
42708
+ const serializer = new JsonShapeSerializer(this.settings);
42470
42709
  serializer.setSerdeContext(this.serdeContext);
42471
42710
  return serializer;
42472
42711
  }
42473
42712
  createDeserializer() {
42474
- const deserializer = new JsonShapeDeserializer2(this.settings);
42713
+ const deserializer = new JsonShapeDeserializer(this.settings);
42475
42714
  deserializer.setSerdeContext(this.serdeContext);
42476
42715
  return deserializer;
42477
42716
  }
@@ -48241,7 +48480,7 @@ var init_signin = __esm({
48241
48480
  var require_dist_cjs11 = __commonJS({
48242
48481
  "../../../node_modules/@aws-sdk/credential-provider-login/dist-cjs/index.js"(exports2) {
48243
48482
  var { setCredentialFeature: setCredentialFeature2 } = (init_client3(), __toCommonJS(client_exports2));
48244
- var { CredentialsProviderError: CredentialsProviderError2, readFile: readFile5, parseKnownFiles: parseKnownFiles2, getProfileName: getProfileName2 } = (init_config2(), __toCommonJS(config_exports));
48483
+ var { CredentialsProviderError: CredentialsProviderError2, parseKnownFiles: parseKnownFiles2, getProfileName: getProfileName2 } = (init_config2(), __toCommonJS(config_exports));
48245
48484
  var { HttpRequest: HttpRequest2 } = (init_protocols(), __toCommonJS(protocols_exports));
48246
48485
  var { createHash: createHash8, createPrivateKey, createPublicKey, sign: sign3 } = require("node:crypto");
48247
48486
  var { promises: promises3 } = require("node:fs");
@@ -48272,13 +48511,7 @@ var require_dist_cjs11 = __commonJS({
48272
48511
  if (timeUntilExpiry <= _LoginCredentialsFetcher.REFRESH_THRESHOLD) {
48273
48512
  return this.refresh(token);
48274
48513
  }
48275
- return {
48276
- accessKeyId: accessToken.accessKeyId,
48277
- secretAccessKey: accessToken.secretAccessKey,
48278
- sessionToken: accessToken.sessionToken,
48279
- accountId: accessToken.accountId,
48280
- expiration: new Date(accessToken.expiresAt)
48281
- };
48514
+ return this.toCredentials(token.accessToken);
48282
48515
  }
48283
48516
  get logger() {
48284
48517
  return this.init?.logger;
@@ -48286,7 +48519,25 @@ var require_dist_cjs11 = __commonJS({
48286
48519
  get loginSession() {
48287
48520
  return this.profileData.login_session;
48288
48521
  }
48522
+ toCredentials(token) {
48523
+ return {
48524
+ accessKeyId: token.accessKeyId,
48525
+ secretAccessKey: token.secretAccessKey,
48526
+ sessionToken: token.sessionToken,
48527
+ accountId: token.accountId,
48528
+ expiration: new Date(token.expiresAt)
48529
+ };
48530
+ }
48289
48531
  async refresh(token) {
48532
+ const diskToken = await this.loadToken().catch(() => token);
48533
+ const now = Date.now();
48534
+ const diskExpiry = new Date(diskToken.accessToken.expiresAt).getTime();
48535
+ const tokenExpiry = new Date(token.accessToken.expiresAt).getTime();
48536
+ const freshToken = diskExpiry <= now && tokenExpiry > now ? token : diskToken;
48537
+ const freshExpiry = new Date(freshToken.accessToken.expiresAt).getTime();
48538
+ if (freshExpiry - Date.now() > _LoginCredentialsFetcher.REFRESH_THRESHOLD) {
48539
+ return this.toCredentials(freshToken.accessToken);
48540
+ }
48290
48541
  const { SigninClient: SigninClient2, CreateOAuth2TokenCommand: CreateOAuth2TokenCommand2 } = (init_signin(), __toCommonJS(signin_exports));
48291
48542
  const { logger: logger3, userAgentAppId } = this.callerClientConfig ?? {};
48292
48543
  const isH22 = /* @__PURE__ */ __name((requestHandler2) => {
@@ -48308,8 +48559,8 @@ var require_dist_cjs11 = __commonJS({
48308
48559
  this.createDPoPInterceptor(client.middlewareStack);
48309
48560
  const commandInput = {
48310
48561
  tokenInput: {
48311
- clientId: token.clientId,
48312
- refreshToken: token.refreshToken,
48562
+ clientId: freshToken.clientId,
48563
+ refreshToken: freshToken.refreshToken,
48313
48564
  grantType: "refresh_token"
48314
48565
  }
48315
48566
  };
@@ -48326,9 +48577,9 @@ var require_dist_cjs11 = __commonJS({
48326
48577
  const expiresInMs = (expiresIn ?? 900) * 1e3;
48327
48578
  const expiration = new Date(Date.now() + expiresInMs);
48328
48579
  const updatedToken = {
48329
- ...token,
48580
+ ...freshToken,
48330
48581
  accessToken: {
48331
- ...token.accessToken,
48582
+ ...freshToken.accessToken,
48332
48583
  accessKeyId,
48333
48584
  secretAccessKey,
48334
48585
  sessionToken,
@@ -48337,14 +48588,7 @@ var require_dist_cjs11 = __commonJS({
48337
48588
  refreshToken
48338
48589
  };
48339
48590
  await this.saveToken(updatedToken);
48340
- const newAccessToken = updatedToken.accessToken;
48341
- return {
48342
- accessKeyId: newAccessToken.accessKeyId,
48343
- secretAccessKey: newAccessToken.secretAccessKey,
48344
- sessionToken: newAccessToken.sessionToken,
48345
- accountId: newAccessToken.accountId,
48346
- expiration
48347
- };
48591
+ return this.toCredentials(updatedToken.accessToken);
48348
48592
  } catch (error4) {
48349
48593
  if (error4.name === "AccessDeniedException") {
48350
48594
  const errorType = error4.error;
@@ -48362,7 +48606,15 @@ var require_dist_cjs11 = __commonJS({
48362
48606
  default:
48363
48607
  message2 = `Failed to refresh token: ${String(error4)}. Please re-authenticate using \`aws login\``;
48364
48608
  }
48365
- throw new CredentialsProviderError2(message2, { logger: this.logger, tryNextLink: false });
48609
+ throw new CredentialsProviderError2(message2, {
48610
+ logger: this.logger,
48611
+ tryNextLink: false
48612
+ });
48613
+ }
48614
+ const tokenExpiry2 = new Date(freshToken.accessToken.expiresAt).getTime();
48615
+ if (tokenExpiry2 > Date.now()) {
48616
+ this.logger?.warn?.(`Failed to refresh token: ${String(error4)}. Using existing token until expiry.`);
48617
+ return this.toCredentials(freshToken.accessToken);
48366
48618
  }
48367
48619
  throw new CredentialsProviderError2(`Failed to refresh token: ${String(error4)}. Please re-authenticate using aws login`, { logger: this.logger });
48368
48620
  }
@@ -48370,12 +48622,7 @@ var require_dist_cjs11 = __commonJS({
48370
48622
  async loadToken() {
48371
48623
  const tokenFilePath = this.getTokenFilePath();
48372
48624
  try {
48373
- let tokenData;
48374
- try {
48375
- tokenData = await readFile5(tokenFilePath, { ignoreCache: this.init?.ignoreCache });
48376
- } catch {
48377
- tokenData = await promises3.readFile(tokenFilePath, "utf8");
48378
- }
48625
+ const tokenData = await promises3.readFile(tokenFilePath, "utf8");
48379
48626
  const token = JSON.parse(tokenData);
48380
48627
  const missingFields = ["accessToken", "clientId", "refreshToken", "dpopKey"].filter((k6) => !token[k6]);
48381
48628
  if (!token.accessToken?.accountId) {
@@ -81683,10 +81930,10 @@ ${pair.comment}` : item.comment;
81683
81930
  }
81684
81931
  }
81685
81932
  __name(warnFileDeprecation, "warnFileDeprecation");
81686
- var warned = {};
81933
+ var warned2 = {};
81687
81934
  function warnOptionDeprecation(name, alternative) {
81688
- if (!warned[name] && shouldWarn(true)) {
81689
- warned[name] = true;
81935
+ if (!warned2[name] && shouldWarn(true)) {
81936
+ warned2[name] = true;
81690
81937
  let msg = `The option '${name}' will be removed in a future release`;
81691
81938
  msg += alternative ? `, use '${alternative}' instead.` : ".";
81692
81939
  warn2(msg, "DeprecationWarning");
@@ -293503,7 +293750,6 @@ async function deployStack(options, ioHelper) {
293503
293750
  await ioHelper.defaults.info("Falling back to doing a full deployment");
293504
293751
  options.sdk.appendCustomUserAgent("cdk-hotswap/fallback");
293505
293752
  deploymentMethod = deploymentMethod.fallback;
293506
- options = { ...options, express: true };
293507
293753
  } else {
293508
293754
  return {
293509
293755
  type: "did-deploy-stack",
@@ -295429,9 +295675,6 @@ function stripReferences(value, exports2) {
295429
295675
  if ("Fn::GetAtt" in value) {
295430
295676
  return { __cloud_ref__: "Fn::GetAtt" };
295431
295677
  }
295432
- if ("DependsOn" in value) {
295433
- return { __cloud_ref__: "DependsOn" };
295434
- }
295435
295678
  if ("Fn::ImportValue" in value) {
295436
295679
  const exp = exports2[value["Fn::ImportValue"]];
295437
295680
  if (exp != null) {
@@ -295449,6 +295692,9 @@ function stripReferences(value, exports2) {
295449
295692
  }
295450
295693
  const result2 = {};
295451
295694
  for (const [k6, v] of Object.entries(value)) {
295695
+ if (k6 === "DependsOn") {
295696
+ continue;
295697
+ }
295452
295698
  result2[k6] = stripReferences(v, exports2);
295453
295699
  }
295454
295700
  return result2;
@@ -300773,7 +301019,7 @@ var require_lru_cache = __commonJS({
300773
301019
  }
300774
301020
  }
300775
301021
  };
300776
- var warned = /* @__PURE__ */ new Set();
301022
+ var warned2 = /* @__PURE__ */ new Set();
300777
301023
  var deprecatedOption = /* @__PURE__ */ __name((opt, instead) => {
300778
301024
  const code = `LRU_CACHE_OPTION_${opt}`;
300779
301025
  if (shouldWarn(code)) {
@@ -300799,9 +301045,9 @@ var require_lru_cache = __commonJS({
300799
301045
  var emitWarning = /* @__PURE__ */ __name((...a6) => {
300800
301046
  typeof process === "object" && process && typeof process.emitWarning === "function" ? process.emitWarning(...a6) : console.error(...a6);
300801
301047
  }, "emitWarning");
300802
- var shouldWarn = /* @__PURE__ */ __name((code) => !warned.has(code), "shouldWarn");
301048
+ var shouldWarn = /* @__PURE__ */ __name((code) => !warned2.has(code), "shouldWarn");
300803
301049
  var warn2 = /* @__PURE__ */ __name((code, what, instead, fn) => {
300804
- warned.add(code);
301050
+ warned2.add(code);
300805
301051
  const msg = `The ${what} is deprecated. Please use ${instead} instead.`;
300806
301052
  emitWarning(msg, "DeprecationWarning", code, fn);
300807
301053
  }, "warn");
@@ -300961,7 +301207,7 @@ var require_lru_cache = __commonJS({
300961
301207
  if (!this.ttlAutopurge && !this.max && !this.maxSize) {
300962
301208
  const code = "LRU_CACHE_UNBOUNDED";
300963
301209
  if (shouldWarn(code)) {
300964
- warned.add(code);
301210
+ warned2.add(code);
300965
301211
  const msg = "TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.";
300966
301212
  emitWarning(msg, "UnboundedCacheWarning", code, _LRUCache);
300967
301213
  }
@@ -302285,10 +302531,10 @@ var require_browser = __commonJS({
302285
302531
  exports2.useColors = useColors;
302286
302532
  exports2.storage = localstorage();
302287
302533
  exports2.destroy = /* @__PURE__ */ (() => {
302288
- let warned = false;
302534
+ let warned2 = false;
302289
302535
  return () => {
302290
- if (!warned) {
302291
- warned = true;
302536
+ if (!warned2) {
302537
+ warned2 = true;
302292
302538
  console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
302293
302539
  }
302294
302540
  };
@@ -304515,8 +304761,10 @@ var require_common5 = __commonJS({
304515
304761
  "use strict";
304516
304762
  Object.defineProperty(exports2, "__esModule", { value: true });
304517
304763
  exports2.isInSubnet = isInSubnet;
304764
+ exports2.isHostInSubnet = isHostInSubnet;
304518
304765
  exports2.isCorrect = isCorrect;
304519
304766
  exports2.prefixLengthFromMask = prefixLengthFromMask;
304767
+ exports2.assertByteArray = assertByteArray;
304520
304768
  exports2.numberToPaddedHex = numberToPaddedHex;
304521
304769
  exports2.stringToPaddedHex = stringToPaddedHex;
304522
304770
  exports2.testBit = testBit;
@@ -304525,14 +304773,15 @@ var require_common5 = __commonJS({
304525
304773
  if (this.subnetMask < address.subnetMask) {
304526
304774
  return false;
304527
304775
  }
304528
- if (this.mask(address.subnetMask) === address.mask()) {
304529
- return true;
304530
- }
304531
- return false;
304776
+ return isHostInSubnet.call(this, address);
304532
304777
  }
304533
304778
  __name(isInSubnet, "isInSubnet");
304779
+ function isHostInSubnet(address) {
304780
+ return this.mask(address.subnetMask) === address.mask();
304781
+ }
304782
+ __name(isHostInSubnet, "isHostInSubnet");
304534
304783
  function isCorrect(defaultBits) {
304535
- return function() {
304784
+ return /* @__PURE__ */ __name(function isCorrectForm() {
304536
304785
  if (this.addressMinusSuffix !== this.correctForm()) {
304537
304786
  return false;
304538
304787
  }
@@ -304540,7 +304789,7 @@ var require_common5 = __commonJS({
304540
304789
  return true;
304541
304790
  }
304542
304791
  return this.parsedSubnet === String(this.subnetMask);
304543
- };
304792
+ }, "isCorrectForm");
304544
304793
  }
304545
304794
  __name(isCorrect, "isCorrect");
304546
304795
  function prefixLengthFromMask(value, totalBits) {
@@ -304558,6 +304807,17 @@ var require_common5 = __commonJS({
304558
304807
  return firstZero;
304559
304808
  }
304560
304809
  __name(prefixLengthFromMask, "prefixLengthFromMask");
304810
+ function assertByteArray(bytes, byteCount, family, minimum) {
304811
+ if (bytes.length !== byteCount) {
304812
+ throw new address_error_1.AddressError(`${family} addresses require exactly ${byteCount} bytes`);
304813
+ }
304814
+ for (let i6 = 0; i6 < bytes.length; i6++) {
304815
+ if (!Number.isInteger(bytes[i6]) || bytes[i6] < minimum || bytes[i6] > 255) {
304816
+ throw new address_error_1.AddressError(`All bytes must be integers between ${minimum} and 255`);
304817
+ }
304818
+ }
304819
+ }
304820
+ __name(assertByteArray, "assertByteArray");
304561
304821
  function numberToPaddedHex(number) {
304562
304822
  return number.toString(16).padStart(2, "0");
304563
304823
  }
@@ -304586,7 +304846,7 @@ var require_constants8 = __commonJS({
304586
304846
  exports2.RE_SUBNET_STRING = exports2.RE_ADDRESS = exports2.GROUPS = exports2.BITS = void 0;
304587
304847
  exports2.BITS = 32;
304588
304848
  exports2.GROUPS = 4;
304589
- exports2.RE_ADDRESS = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/g;
304849
+ exports2.RE_ADDRESS = /^(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])$/g;
304590
304850
  exports2.RE_SUBNET_STRING = /\/\d{1,2}$/;
304591
304851
  }
304592
304852
  });
@@ -304633,6 +304893,7 @@ var require_ipv4 = __commonJS({
304633
304893
  __name(this, "Address4");
304634
304894
  }
304635
304895
  constructor(address) {
304896
+ this.addressMinusSuffix = "";
304636
304897
  this.groups = constants2.GROUPS;
304637
304898
  this.parsedAddress = [];
304638
304899
  this.parsedSubnet = "";
@@ -304641,6 +304902,7 @@ var require_ipv4 = __commonJS({
304641
304902
  this.v4 = true;
304642
304903
  this.isCorrect = isCorrect4;
304643
304904
  this.isInSubnet = common.isInSubnet;
304905
+ this.isHostInSubnet = common.isHostInSubnet;
304644
304906
  this.address = address;
304645
304907
  const subnet = constants2.RE_SUBNET_STRING.exec(address);
304646
304908
  if (subnet) {
@@ -304666,7 +304928,7 @@ var require_ipv4 = __commonJS({
304666
304928
  try {
304667
304929
  new _Address4(address);
304668
304930
  return true;
304669
- } catch (e6) {
304931
+ } catch {
304670
304932
  return false;
304671
304933
  }
304672
304934
  }
@@ -304678,6 +304940,9 @@ var require_ipv4 = __commonJS({
304678
304940
  */
304679
304941
  parse(address) {
304680
304942
  const groups = address.split(".");
304943
+ if (groups.some((group4) => /^0\d/.test(group4))) {
304944
+ throw new address_error_1.AddressError("IPv4 addresses can't have leading zeroes.");
304945
+ }
304681
304946
  if (!address.match(constants2.RE_ADDRESS)) {
304682
304947
  throw new address_error_1.AddressError("Invalid IPv4 address.");
304683
304948
  }
@@ -304913,7 +305178,7 @@ var require_ipv4 = __commonJS({
304913
305178
  * @returns {Address4}
304914
305179
  */
304915
305180
  static fromBigInt(bigInt) {
304916
- if (bigInt < 0n || bigInt > 0xffffffffn) {
305181
+ if (bigInt < BigInt(0) || bigInt > BigInt(4294967295)) {
304917
305182
  throw new address_error_1.AddressError("IPv4 BigInt must be in the range 0 to 2**32 - 1");
304918
305183
  }
304919
305184
  return _Address4.fromHex(bigInt.toString(16).padStart(8, "0"));
@@ -304926,14 +305191,7 @@ var require_ipv4 = __commonJS({
304926
305191
  * @returns {Address4}
304927
305192
  */
304928
305193
  static fromByteArray(bytes) {
304929
- if (bytes.length !== 4) {
304930
- throw new address_error_1.AddressError("IPv4 addresses require exactly 4 bytes");
304931
- }
304932
- for (let i6 = 0; i6 < bytes.length; i6++) {
304933
- if (!Number.isInteger(bytes[i6]) || bytes[i6] < 0 || bytes[i6] > 255) {
304934
- throw new address_error_1.AddressError("All bytes must be integers between 0 and 255");
304935
- }
304936
- }
305194
+ common.assertByteArray(bytes, 4, "IPv4", 0);
304937
305195
  return this.fromUnsignedByteArray(bytes);
304938
305196
  }
304939
305197
  /**
@@ -304987,49 +305245,49 @@ var require_ipv4 = __commonJS({
304987
305245
  * @returns {boolean}
304988
305246
  */
304989
305247
  isMulticast() {
304990
- return this.isInSubnet(MULTICAST_V4);
305248
+ return this.isHostInSubnet(MULTICAST_V4);
304991
305249
  }
304992
305250
  /**
304993
305251
  * Returns true if the address is in one of the [RFC 1918](https://datatracker.ietf.org/doc/html/rfc1918) private address ranges (`10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`).
304994
305252
  * @returns {boolean}
304995
305253
  */
304996
305254
  isPrivate() {
304997
- return PRIVATE_V4.some((subnet) => this.isInSubnet(subnet));
305255
+ return PRIVATE_V4.some((subnet) => this.isHostInSubnet(subnet));
304998
305256
  }
304999
305257
  /**
305000
305258
  * Returns true if the address is in the loopback range `127.0.0.0/8` ([RFC 1122](https://datatracker.ietf.org/doc/html/rfc1122)).
305001
305259
  * @returns {boolean}
305002
305260
  */
305003
305261
  isLoopback() {
305004
- return this.isInSubnet(LOOPBACK_V4);
305262
+ return this.isHostInSubnet(LOOPBACK_V4);
305005
305263
  }
305006
305264
  /**
305007
305265
  * Returns true if the address is in the link-local range `169.254.0.0/16` ([RFC 3927](https://datatracker.ietf.org/doc/html/rfc3927)).
305008
305266
  * @returns {boolean}
305009
305267
  */
305010
305268
  isLinkLocal() {
305011
- return this.isInSubnet(LINK_LOCAL_V4);
305269
+ return this.isHostInSubnet(LINK_LOCAL_V4);
305012
305270
  }
305013
305271
  /**
305014
305272
  * Returns true if the address is the unspecified address `0.0.0.0`.
305015
305273
  * @returns {boolean}
305016
305274
  */
305017
305275
  isUnspecified() {
305018
- return this.isInSubnet(UNSPECIFIED_V4);
305276
+ return this.isHostInSubnet(UNSPECIFIED_V4);
305019
305277
  }
305020
305278
  /**
305021
305279
  * Returns true if the address is the limited broadcast address `255.255.255.255` ([RFC 919](https://datatracker.ietf.org/doc/html/rfc919)).
305022
305280
  * @returns {boolean}
305023
305281
  */
305024
305282
  isBroadcast() {
305025
- return this.isInSubnet(BROADCAST_V4);
305283
+ return this.isHostInSubnet(BROADCAST_V4);
305026
305284
  }
305027
305285
  /**
305028
305286
  * Returns true if the address is in the carrier-grade NAT range `100.64.0.0/10` ([RFC 6598](https://datatracker.ietf.org/doc/html/rfc6598)).
305029
305287
  * @returns {boolean}
305030
305288
  */
305031
305289
  isCGNAT() {
305032
- return this.isInSubnet(CGNAT_V4);
305290
+ return this.isHostInSubnet(CGNAT_V4);
305033
305291
  }
305034
305292
  /**
305035
305293
  * Returns a zero-padded base-2 string representation of the address
@@ -305047,7 +305305,7 @@ var require_ipv4 = __commonJS({
305047
305305
  */
305048
305306
  groupForV6() {
305049
305307
  const segments = this.parsedAddress;
305050
- return this.address.replace(constants2.RE_ADDRESS, `<span class="hover-group group-v4 group-6">${segments.slice(0, 2).join(".")}</span>.<span class="hover-group group-v4 group-7">${segments.slice(2, 4).join(".")}</span>`);
305308
+ return this.correctForm().replace(constants2.RE_ADDRESS, `<span class="hover-group group-v4 group-6">${segments.slice(0, 2).join(".")}</span>.<span class="hover-group group-v4 group-7">${segments.slice(2, 4).join(".")}</span>`);
305051
305309
  }
305052
305310
  };
305053
305311
  exports2.Address4 = Address4;
@@ -305104,6 +305362,7 @@ var require_constants9 = __commonJS({
305104
305362
  "ff05::1:3/128": "Multicast (All DHCP servers in this site)",
305105
305363
  "::/128": "Unspecified",
305106
305364
  "::1/128": "Loopback",
305365
+ "::ffff:0:0/96": "IPv4-mapped",
305107
305366
  "ff00::/8": "Multicast",
305108
305367
  "fe80::/10": "Link-local unicast",
305109
305368
  "fc00::/7": "Unique local",
@@ -305116,8 +305375,8 @@ var require_constants9 = __commonJS({
305116
305375
  exports2.RE_BAD_ADDRESS = /([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi;
305117
305376
  exports2.RE_SUBNET_STRING = /\/\d{1,3}(?=%|$)/;
305118
305377
  exports2.RE_ZONE_STRING = /%.*$/;
305119
- exports2.RE_URL = /^\[{0,1}([0-9a-f:]+)\]{0,1}/;
305120
- exports2.RE_URL_WITH_PORT = /\[([0-9a-f:]+)\]:([0-9]{1,5})/;
305378
+ exports2.RE_URL = /^(?:\[([0-9a-f:.]+)\]|([0-9a-f:.]+))(?:[/?#].*)?$/i;
305379
+ exports2.RE_URL_WITH_PORT = /^\[([0-9a-f:.]+)\]:([0-9]{1,5})(?:[/?#].*)?$/i;
305121
305380
  }
305122
305381
  });
305123
305382
 
@@ -305358,6 +305617,7 @@ var require_ipv6 = __commonJS({
305358
305617
  this.v4 = false;
305359
305618
  this.zone = "";
305360
305619
  this.isInSubnet = common.isInSubnet;
305620
+ this.isHostInSubnet = common.isHostInSubnet;
305361
305621
  this.isCorrect = isCorrect6;
305362
305622
  if (optionalGroups === void 0) {
305363
305623
  this.groups = constants6.GROUPS;
@@ -305374,7 +305634,8 @@ var require_ipv6 = __commonJS({
305374
305634
  throw new address_error_1.AddressError("Invalid subnet mask.");
305375
305635
  }
305376
305636
  address = address.replace(constants6.RE_SUBNET_STRING, "");
305377
- } else if (/\//.test(address)) {
305637
+ }
305638
+ if (/\//.test(address)) {
305378
305639
  throw new address_error_1.AddressError("Invalid subnet mask.");
305379
305640
  }
305380
305641
  const zone = constants6.RE_ZONE_STRING.exec(address);
@@ -305396,7 +305657,7 @@ var require_ipv6 = __commonJS({
305396
305657
  try {
305397
305658
  new _Address6(address);
305398
305659
  return true;
305399
- } catch (e6) {
305660
+ } catch {
305400
305661
  return false;
305401
305662
  }
305402
305663
  }
@@ -305411,7 +305672,7 @@ var require_ipv6 = __commonJS({
305411
305672
  * address.correctForm(); // '::e8:d4a5:1000'
305412
305673
  */
305413
305674
  static fromBigInt(bigInt) {
305414
- if (bigInt < 0n || bigInt > (1n << BigInt(constants6.BITS)) - 1n) {
305675
+ if (bigInt < BigInt(0) || bigInt > (BigInt(1) << BigInt(constants6.BITS)) - BigInt(1)) {
305415
305676
  throw new address_error_1.AddressError("IPv6 BigInt must be in the range 0 to 2**128 - 1");
305416
305677
  }
305417
305678
  const hex = bigInt.toString(16).padStart(32, "0");
@@ -305432,11 +305693,13 @@ var require_ipv6 = __commonJS({
305432
305693
  * addressAndPort.port; // 8080
305433
305694
  */
305434
305695
  static fromURL(url) {
305696
+ var _a2;
305435
305697
  let host;
305436
305698
  let port = null;
305437
305699
  let result2;
305438
- if (url.indexOf("[") !== -1 && url.indexOf("]:") !== -1) {
305439
- result2 = constants6.RE_URL_WITH_PORT.exec(url);
305700
+ const stripped = url.replace(/^[a-z][a-z0-9+.-]*:\/\//i, "");
305701
+ if (stripped.indexOf("[") !== -1 && stripped.indexOf("]:") !== -1) {
305702
+ result2 = constants6.RE_URL_WITH_PORT.exec(stripped);
305440
305703
  if (result2 === null) {
305441
305704
  return {
305442
305705
  error: "failed to parse address with port",
@@ -305446,9 +305709,8 @@ var require_ipv6 = __commonJS({
305446
305709
  }
305447
305710
  host = result2[1];
305448
305711
  port = result2[2];
305449
- } else if (url.indexOf("/") !== -1) {
305450
- url = url.replace(/^[a-z0-9]+:\/\//, "");
305451
- result2 = constants6.RE_URL.exec(url);
305712
+ } else {
305713
+ result2 = constants6.RE_URL.exec(stripped);
305452
305714
  if (result2 === null) {
305453
305715
  return {
305454
305716
  error: "failed to parse address from URL",
@@ -305456,13 +305718,11 @@ var require_ipv6 = __commonJS({
305456
305718
  port: null
305457
305719
  };
305458
305720
  }
305459
- host = result2[1];
305460
- } else {
305461
- host = url;
305721
+ host = (_a2 = result2[1]) !== null && _a2 !== void 0 ? _a2 : result2[2];
305462
305722
  }
305463
305723
  if (port) {
305464
305724
  port = parseInt(port, 10);
305465
- if (port < 0 || port > 65536) {
305725
+ if (port < 0 || port > 65535) {
305466
305726
  port = null;
305467
305727
  }
305468
305728
  } else {
@@ -305724,7 +305984,7 @@ var require_ipv6 = __commonJS({
305724
305984
  getType() {
305725
305985
  for (let i6 = 0; i6 < TYPE_SUBNETS.length; i6++) {
305726
305986
  const entry = TYPE_SUBNETS[i6];
305727
- if (this.isInSubnet(entry[0])) {
305987
+ if (this.isHostInSubnet(entry[0])) {
305728
305988
  return entry[1];
305729
305989
  }
305730
305990
  }
@@ -305857,18 +306117,20 @@ var require_ipv6 = __commonJS({
305857
306117
  }
305858
306118
  const groups = address.split(":");
305859
306119
  const lastGroup = groups.slice(-1)[0];
306120
+ const v4Octets = lastGroup.split(".");
306121
+ if (v4Octets.length === constants4.GROUPS && v4Octets.every((octet) => /^\d{1,3}$/.test(octet))) {
306122
+ if (v4Octets.some((octet) => /^0\d/.test(octet))) {
306123
+ const highlighted = v4Octets.map(spanLeadingZeroes4).join(".");
306124
+ const prefix = groups.slice(0, -1).map(helpers.escapeHtml).join(":");
306125
+ const separator = groups.length > 1 ? ":" : "";
306126
+ throw new address_error_1.AddressError("IPv4 addresses can't have leading zeroes.", `${prefix}${separator}${highlighted}`);
306127
+ }
306128
+ }
305860
306129
  const address4 = lastGroup.match(constants4.RE_ADDRESS);
305861
306130
  if (address4) {
305862
306131
  this.parsedAddress4 = address4[0];
305863
- this.address4 = new ipv4_1.Address4(this.parsedAddress4);
305864
- for (let i6 = 0; i6 < this.address4.groups; i6++) {
305865
- if (/^0[0-9]+/.test(this.address4.parsedAddress[i6])) {
305866
- const highlighted = this.address4.parsedAddress.map(spanLeadingZeroes4).join(".");
305867
- const prefix = groups.slice(0, -1).map(helpers.escapeHtml).join(":");
305868
- const separator = groups.length > 1 ? ":" : "";
305869
- throw new address_error_1.AddressError("IPv4 addresses can't have leading zeroes.", `${prefix}${separator}${highlighted}`);
305870
- }
305871
- }
306132
+ const v4Suffix = this.subnetMask >= 96 ? `/${this.subnetMask - 96}` : "";
306133
+ this.address4 = new ipv4_1.Address4(`${this.parsedAddress4}${v4Suffix}`);
305872
306134
  this.v4 = true;
305873
306135
  groups[groups.length - 1] = this.address4.toGroup6();
305874
306136
  address = groups.join(":");
@@ -305952,7 +306214,11 @@ var require_ipv6 = __commonJS({
305952
306214
  return BigInt(`0x${this.parsedAddress.map(paddedHex).join("")}`);
305953
306215
  }
305954
306216
  /**
305955
- * Return the last two groups of this address as an IPv4 address string
306217
+ * Return the last two groups of this address as an IPv4 address string.
306218
+ * If this address carries a CIDR prefix that covers the trailing 32 bits
306219
+ * (i.e. `subnetMask >= 96`), the resulting `Address4` inherits the
306220
+ * corresponding v4 prefix (`subnetMask - 96`); otherwise it defaults to
306221
+ * `/32`.
305956
306222
  * @returns {Address4}
305957
306223
  * @example
305958
306224
  * var address = new Address6('2001:4860:4001::1825:bf11');
@@ -305960,7 +306226,16 @@ var require_ipv6 = __commonJS({
305960
306226
  */
305961
306227
  to4() {
305962
306228
  const binary = this.binaryZeroPad().split("");
305963
- return ipv4_1.Address4.fromHex(BigInt(`0b${binary.slice(96, 128).join("")}`).toString(16).padStart(8, "0"));
306229
+ const hex = BigInt(`0b${binary.slice(96, 128).join("")}`).toString(16).padStart(8, "0");
306230
+ if (this.subnetMask >= 96) {
306231
+ const v4Mask = this.subnetMask - 96;
306232
+ const groups = [];
306233
+ for (let i6 = 0; i6 < 8; i6 += 2) {
306234
+ groups.push(parseInt(hex.slice(i6, i6 + 2), 16));
306235
+ }
306236
+ return new ipv4_1.Address4(`${groups.join(".")}/${v4Mask}`);
306237
+ }
306238
+ return ipv4_1.Address4.fromHex(hex);
305964
306239
  }
305965
306240
  /**
305966
306241
  * Return the v4-in-v6 form of the address
@@ -305974,7 +306249,7 @@ var require_ipv6 = __commonJS({
305974
306249
  if (!/:$/.test(correct)) {
305975
306250
  infix = ":";
305976
306251
  }
305977
- return correct + infix + address4.address;
306252
+ return correct + infix + address4.correctForm();
305978
306253
  }
305979
306254
  /**
305980
306255
  * Decodes the Teredo tunneling fields embedded in this address. Returns the
@@ -306064,7 +306339,14 @@ var require_ipv6 = __commonJS({
306064
306339
  bits = prefixBits.slice(0, 96) + v4Bits;
306065
306340
  } else {
306066
306341
  const beforeU = 64 - pl2;
306067
- bits = prefixBits.slice(0, pl2) + v4Bits.slice(0, beforeU) + "00000000" + v4Bits.slice(beforeU) + "0".repeat(128 - 72 - (32 - beforeU));
306342
+ bits = [
306343
+ prefixBits.slice(0, pl2),
306344
+ v4Bits.slice(0, beforeU),
306345
+ // Bits 64 to 71 are the reserved u octet and are always zero.
306346
+ "00000000",
306347
+ v4Bits.slice(beforeU),
306348
+ "0".repeat(128 - 72 - (32 - beforeU))
306349
+ ].join("");
306068
306350
  }
306069
306351
  const hex = BigInt(`0b${bits}`).toString(16).padStart(32, "0");
306070
306352
  const groups = [];
@@ -306087,7 +306369,7 @@ var require_ipv6 = __commonJS({
306087
306369
  if (pl2 !== 32 && pl2 !== 40 && pl2 !== 48 && pl2 !== 56 && pl2 !== 64 && pl2 !== 96) {
306088
306370
  throw new address_error_1.AddressError("NAT64 prefix length must be 32, 40, 48, 56, 64, or 96");
306089
306371
  }
306090
- if (!this.isInSubnet(prefix6)) {
306372
+ if (!this.isHostInSubnet(prefix6)) {
306091
306373
  return null;
306092
306374
  }
306093
306375
  const bits = this.binaryZeroPad();
@@ -306111,9 +306393,7 @@ var require_ipv6 = __commonJS({
306111
306393
  * @returns {Array}
306112
306394
  */
306113
306395
  toByteArray() {
306114
- const valueWithoutPadding = this.bigInt().toString(16);
306115
- const leadingPad = "0".repeat(valueWithoutPadding.length % 2);
306116
- const value = `${leadingPad}${valueWithoutPadding}`;
306396
+ const value = this.bigInt().toString(16).padStart(constants6.BITS / 4, "0");
306117
306397
  const bytes = [];
306118
306398
  for (let i6 = 0, length = value.length; i6 < length; i6 += 2) {
306119
306399
  bytes.push(parseInt(value.substring(i6, i6 + 2), 16));
@@ -306132,19 +306412,28 @@ var require_ipv6 = __commonJS({
306132
306412
  /**
306133
306413
  * Convert a byte array to an Address6 object.
306134
306414
  *
306415
+ * Accepts unsigned bytes (0 to 255) or signed bytes (-128 to 127, as an
306416
+ * `Int8Array` or a Java `byte[]` holds them), folding signed values to their
306417
+ * unsigned equivalent. Throws `AddressError` unless given exactly 16
306418
+ * integers from -128 to 255.
306419
+ *
306135
306420
  * To convert from a Node.js `Buffer`, spread it: `Address6.fromByteArray([...buf])`.
306136
306421
  * @returns {Address6}
306137
306422
  */
306138
306423
  static fromByteArray(bytes) {
306424
+ common.assertByteArray(bytes, 16, "IPv6", -128);
306139
306425
  return this.fromUnsignedByteArray(bytes.map(unsignByte));
306140
306426
  }
306141
306427
  /**
306142
306428
  * Convert an unsigned byte array to an Address6 object.
306143
306429
  *
306430
+ * Throws `AddressError` unless given exactly 16 integers from 0 to 255.
306431
+ *
306144
306432
  * To convert from a Node.js `Buffer`, spread it: `Address6.fromUnsignedByteArray([...buf])`.
306145
306433
  * @returns {Address6}
306146
306434
  */
306147
306435
  static fromUnsignedByteArray(bytes) {
306436
+ common.assertByteArray(bytes, 16, "IPv6", 0);
306148
306437
  const BYTE_MAX = BigInt("256");
306149
306438
  let result2 = BigInt("0");
306150
306439
  let multiplier = BigInt("1");
@@ -306166,6 +306455,10 @@ var require_ipv6 = __commonJS({
306166
306455
  * @returns {boolean}
306167
306456
  */
306168
306457
  isLinkLocal() {
306458
+ const embedded = this.embeddedIPv4();
306459
+ if (embedded) {
306460
+ return embedded.isLinkLocal();
306461
+ }
306169
306462
  if (this.getBitsBase2(0, 64) === "1111111010000000000000000000000000000000000000000000000000000000") {
306170
306463
  return true;
306171
306464
  }
@@ -306176,6 +306469,10 @@ var require_ipv6 = __commonJS({
306176
306469
  * @returns {boolean}
306177
306470
  */
306178
306471
  isMulticast() {
306472
+ const embedded = this.embeddedIPv4();
306473
+ if (embedded) {
306474
+ return embedded.isMulticast();
306475
+ }
306179
306476
  const type = this.getType();
306180
306477
  return type === "Multicast" || type.startsWith("Multicast ");
306181
306478
  }
@@ -306198,27 +306495,54 @@ var require_ipv6 = __commonJS({
306198
306495
  * @returns {boolean}
306199
306496
  */
306200
306497
  isMapped4() {
306201
- return this.isInSubnet(IPV4_MAPPED_SUBNET);
306498
+ return this.isHostInSubnet(IPV4_MAPPED_SUBNET);
306499
+ }
306500
+ /**
306501
+ * If this address embeds a routable IPv4 address — i.e. it is IPv4-mapped
306502
+ * (`::ffff:0:0/96`) or sits in the NAT64 well-known prefix (`64:ff9b::/96`,
306503
+ * [RFC 6052](https://datatracker.ietf.org/doc/html/rfc6052)) — return that
306504
+ * embedded address as an {@link Address4}; otherwise return null.
306505
+ *
306506
+ * The special-property checks (`isLoopback`, `isLinkLocal`, `isMulticast`,
306507
+ * `isUnspecified`, `isPrivate`, `isCGNAT`, `isBroadcast`) call this first and
306508
+ * delegate to the embedded {@link Address4} when present, so a literal such as
306509
+ * `::ffff:127.0.0.1` is classified by what it actually reaches (loopback)
306510
+ * rather than by its IPv6 wrapper (which `getType()` reports as IPv4-mapped).
306511
+ * This matters wherever the checks back a trust-boundary decision (e.g. an
306512
+ * SSRF allow/deny filter): without normalization, `::ffff:10.0.0.1`,
306513
+ * `::ffff:169.254.169.254`, `64:ff9b::7f00:1`, etc. would all read as
306514
+ * non-internal.
306515
+ * @returns {Address4 | null}
306516
+ */
306517
+ embeddedIPv4() {
306518
+ if (this.isMapped4() || this.isHostInSubnet(NAT64_WELL_KNOWN_SUBNET)) {
306519
+ return this.to4();
306520
+ }
306521
+ return null;
306202
306522
  }
306203
306523
  /**
306204
306524
  * Returns true if the address is a Teredo address, false otherwise
306205
306525
  * @returns {boolean}
306206
306526
  */
306207
306527
  isTeredo() {
306208
- return this.isInSubnet(TEREDO_SUBNET);
306528
+ return this.isHostInSubnet(TEREDO_SUBNET);
306209
306529
  }
306210
306530
  /**
306211
306531
  * Returns true if the address is a 6to4 address, false otherwise
306212
306532
  * @returns {boolean}
306213
306533
  */
306214
306534
  is6to4() {
306215
- return this.isInSubnet(SIX_TO_FOUR_SUBNET);
306535
+ return this.isHostInSubnet(SIX_TO_FOUR_SUBNET);
306216
306536
  }
306217
306537
  /**
306218
306538
  * Returns true if the address is a loopback address, false otherwise
306219
306539
  * @returns {boolean}
306220
306540
  */
306221
306541
  isLoopback() {
306542
+ const embedded = this.embeddedIPv4();
306543
+ if (embedded) {
306544
+ return embedded.isLoopback();
306545
+ }
306222
306546
  return this.getType() === "Loopback";
306223
306547
  }
306224
306548
  /**
@@ -306226,13 +306550,64 @@ var require_ipv6 = __commonJS({
306226
306550
  * @returns {boolean}
306227
306551
  */
306228
306552
  isULA() {
306229
- return this.isInSubnet(ULA_SUBNET);
306553
+ return this.isHostInSubnet(ULA_SUBNET);
306554
+ }
306555
+ /**
306556
+ * Returns true if the address is private, i.e. a Unique Local Address in
306557
+ * `fc00::/7` ([RFC 4193](https://datatracker.ietf.org/doc/html/rfc4193)) or an
306558
+ * IPv4-mapped / NAT64 address whose embedded IPv4 address is in one of the
306559
+ * [RFC 1918](https://datatracker.ietf.org/doc/html/rfc1918) private ranges
306560
+ * (e.g. `::ffff:10.0.0.1`). This is the IPv6 counterpart to
306561
+ * {@link Address4.isPrivate}; use it instead of {@link isULA} when you need to
306562
+ * catch mapped RFC 1918 addresses as well as native ULAs.
306563
+ * @returns {boolean}
306564
+ */
306565
+ isPrivate() {
306566
+ const embedded = this.embeddedIPv4();
306567
+ if (embedded) {
306568
+ return embedded.isPrivate();
306569
+ }
306570
+ return this.isULA();
306571
+ }
306572
+ /**
306573
+ * Returns true if the address is an IPv4-mapped / NAT64 address whose embedded
306574
+ * IPv4 address is in the carrier-grade NAT range `100.64.0.0/10`
306575
+ * ([RFC 6598](https://datatracker.ietf.org/doc/html/rfc6598)), false
306576
+ * otherwise. There is no native IPv6 CGNAT range, so this only ever returns
306577
+ * true for an embedded IPv4 address (e.g. `::ffff:100.64.0.1`).
306578
+ * @returns {boolean}
306579
+ */
306580
+ isCGNAT() {
306581
+ const embedded = this.embeddedIPv4();
306582
+ if (embedded) {
306583
+ return embedded.isCGNAT();
306584
+ }
306585
+ return false;
306586
+ }
306587
+ /**
306588
+ * Returns true if the address is an IPv4-mapped / NAT64 address whose embedded
306589
+ * IPv4 address is the limited broadcast address `255.255.255.255`
306590
+ * ([RFC 919](https://datatracker.ietf.org/doc/html/rfc919)), false otherwise.
306591
+ * There is no IPv6 broadcast, so this only ever returns true for an embedded
306592
+ * IPv4 address (e.g. `::ffff:255.255.255.255`).
306593
+ * @returns {boolean}
306594
+ */
306595
+ isBroadcast() {
306596
+ const embedded = this.embeddedIPv4();
306597
+ if (embedded) {
306598
+ return embedded.isBroadcast();
306599
+ }
306600
+ return false;
306230
306601
  }
306231
306602
  /**
306232
306603
  * Returns true if the address is the unspecified address `::`.
306233
306604
  * @returns {boolean}
306234
306605
  */
306235
306606
  isUnspecified() {
306607
+ const embedded = this.embeddedIPv4();
306608
+ if (embedded) {
306609
+ return embedded.isUnspecified();
306610
+ }
306236
306611
  return this.getType() === "Unspecified";
306237
306612
  }
306238
306613
  /**
@@ -306240,7 +306615,7 @@ var require_ipv6 = __commonJS({
306240
306615
  * @returns {boolean}
306241
306616
  */
306242
306617
  isDocumentation() {
306243
- return this.isInSubnet(DOCUMENTATION_SUBNET);
306618
+ return this.isHostInSubnet(DOCUMENTATION_SUBNET);
306244
306619
  }
306245
306620
  // #endregion
306246
306621
  // #region HTML
@@ -306385,6 +306760,7 @@ var require_ipv6 = __commonJS({
306385
306760
  var ULA_SUBNET = new Address6("fc00::/7");
306386
306761
  var DOCUMENTATION_SUBNET = new Address6("2001:db8::/32");
306387
306762
  var IPV4_MAPPED_SUBNET = new Address6("::ffff:0:0/96");
306763
+ var NAT64_WELL_KNOWN_SUBNET = new Address6("64:ff9b::/96");
306388
306764
  }
306389
306765
  });
306390
306766