@cdk8s/awscdk-resolver 0.0.609 → 0.0.611

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.
Files changed (145) hide show
  1. package/.jsii +3 -3
  2. package/lib/resolve.js +1 -1
  3. package/node_modules/@aws-sdk/client-cloudformation/package.json +3 -3
  4. package/node_modules/@aws-sdk/core/package.json +2 -2
  5. package/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
  6. package/node_modules/@aws-sdk/credential-provider-http/package.json +2 -2
  7. package/node_modules/@aws-sdk/credential-provider-ini/package.json +9 -9
  8. package/node_modules/@aws-sdk/credential-provider-login/package.json +3 -3
  9. package/node_modules/@aws-sdk/credential-provider-node/package.json +7 -7
  10. package/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
  11. package/node_modules/@aws-sdk/credential-provider-sso/package.json +4 -4
  12. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
  13. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +1 -1
  14. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +1 -1
  15. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +1 -1
  16. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +1 -1
  17. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +1 -1
  18. package/node_modules/@aws-sdk/nested-clients/package.json +2 -2
  19. package/node_modules/@aws-sdk/token-providers/package.json +3 -3
  20. package/node_modules/@aws-sdk/xml-builder/dist-cjs/xml-parser.browser.js +1 -1
  21. package/node_modules/@aws-sdk/xml-builder/dist-cjs/xml-parser.js +233 -43
  22. package/node_modules/@aws-sdk/xml-builder/dist-es/xml-parser.browser.js +1 -1
  23. package/node_modules/@aws-sdk/xml-builder/dist-es/xml-parser.js +233 -43
  24. package/node_modules/@aws-sdk/xml-builder/dist-types/ts3.4/xml-parser.d.ts +1 -1
  25. package/node_modules/@aws-sdk/xml-builder/dist-types/xml-parser.d.ts +2 -1
  26. package/node_modules/@aws-sdk/xml-builder/package.json +4 -4
  27. package/node_modules/@smithy/core/dist-cjs/submodules/cbor/index.js +518 -371
  28. package/node_modules/@smithy/core/dist-cjs/submodules/client/index.js +1 -1
  29. package/node_modules/@smithy/core/dist-es/submodules/cbor/cbor-decode.js +326 -269
  30. package/node_modules/@smithy/core/dist-es/submodules/cbor/cbor-encode.js +192 -103
  31. package/node_modules/@smithy/core/dist-es/submodules/cbor/cbor.js +4 -2
  32. package/node_modules/@smithy/core/dist-es/submodules/client/smithy-client/get-value-from-text-node.js +1 -1
  33. package/node_modules/@smithy/core/dist-types/submodules/cbor/cbor-decode.d.ts +4 -0
  34. package/node_modules/@smithy/core/dist-types/submodules/cbor/cbor-encode.d.ts +8 -4
  35. package/node_modules/@smithy/core/package.json +1 -1
  36. package/node_modules/@smithy/credential-provider-imds/package.json +2 -2
  37. package/node_modules/@smithy/fetch-http-handler/package.json +2 -2
  38. package/node_modules/@smithy/node-http-handler/package.json +2 -2
  39. package/node_modules/@smithy/signature-v4/package.json +2 -2
  40. package/package.json +9 -9
  41. package/node_modules/@aws-sdk/xml-builder/dist-cjs/xml-external/nodable_entities.js +0 -333
  42. package/node_modules/@aws-sdk/xml-builder/dist-es/xml-external/nodable_entities.js +0 -332
  43. package/node_modules/@aws-sdk/xml-builder/dist-types/ts3.4/xml-external/nodable_entities.d.ts +0 -66
  44. package/node_modules/@aws-sdk/xml-builder/dist-types/xml-external/nodable_entities.d.ts +0 -65
  45. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/CHANGELOG.md +0 -827
  46. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/LICENSE +0 -21
  47. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/README.md +0 -202
  48. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxbuilder.min.js +0 -2
  49. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxbuilder.min.js.map +0 -1
  50. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxp.cjs +0 -1
  51. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxp.d.cts +0 -770
  52. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxp.min.js +0 -2
  53. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxp.min.js.map +0 -1
  54. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxparser.min.js +0 -2
  55. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxparser.min.js.map +0 -1
  56. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxvalidator.min.js +0 -2
  57. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxvalidator.min.js.map +0 -1
  58. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/package.json +0 -93
  59. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/cli/cli.js +0 -97
  60. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/cli/man.js +0 -17
  61. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/cli/read.js +0 -43
  62. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/fxp.d.ts +0 -739
  63. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/fxp.js +0 -14
  64. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/ignoreAttributes.js +0 -18
  65. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/util.js +0 -61
  66. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/CharsSymbol.js +0 -16
  67. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/EntitiesParser.js +0 -106
  68. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/OptionsBuilder.js +0 -61
  69. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/OutputBuilders/BaseOutputBuilder.js +0 -69
  70. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsArrBuilder.js +0 -103
  71. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsMinArrBuilder.js +0 -100
  72. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsObjBuilder.js +0 -154
  73. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/OutputBuilders/ParserOptionsBuilder.js +0 -94
  74. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/Report.js +0 -0
  75. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/TagPath.js +0 -81
  76. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/TagPathMatcher.js +0 -13
  77. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/XMLParser.js +0 -83
  78. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/Xml2JsParser.js +0 -235
  79. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/XmlPartReader.js +0 -210
  80. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/XmlSpecialTagsReader.js +0 -111
  81. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/inputSource/BufferSource.js +0 -116
  82. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/inputSource/StringSource.js +0 -121
  83. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/valueParsers/EntitiesParser.js +0 -105
  84. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/valueParsers/booleanParser.js +0 -22
  85. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/valueParsers/booleanParserExt.js +0 -19
  86. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/valueParsers/currency.js +0 -38
  87. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/valueParsers/join.js +0 -13
  88. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/valueParsers/number.js +0 -14
  89. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/valueParsers/trim.js +0 -6
  90. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/validator.js +0 -425
  91. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlbuilder/json2xml.js +0 -6
  92. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js +0 -407
  93. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js +0 -163
  94. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js +0 -840
  95. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/XMLParser.js +0 -71
  96. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/node2json.js +0 -177
  97. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/xmlNode.js +0 -40
  98. package/node_modules/@nodable/entities/README.md +0 -41
  99. package/node_modules/@nodable/entities/package.json +0 -57
  100. package/node_modules/@nodable/entities/src/EntityDecoder.js +0 -644
  101. package/node_modules/@nodable/entities/src/EntityEncoder.js +0 -194
  102. package/node_modules/@nodable/entities/src/entities.js +0 -1159
  103. package/node_modules/@nodable/entities/src/entityTries.js +0 -49
  104. package/node_modules/@nodable/entities/src/index.d.ts +0 -341
  105. package/node_modules/@nodable/entities/src/index.js +0 -29
  106. package/node_modules/anynum/LICENSE +0 -21
  107. package/node_modules/anynum/README.md +0 -142
  108. package/node_modules/anynum/anynum.js +0 -135
  109. package/node_modules/anynum/digitTable.js +0 -116
  110. package/node_modules/anynum/package.json +0 -42
  111. package/node_modules/fast-xml-builder/CHANGELOG.md +0 -40
  112. package/node_modules/fast-xml-builder/LICENSE +0 -21
  113. package/node_modules/fast-xml-builder/README.md +0 -74
  114. package/node_modules/fast-xml-builder/lib/fxb.cjs +0 -1
  115. package/node_modules/fast-xml-builder/lib/fxb.d.cts +0 -270
  116. package/node_modules/fast-xml-builder/lib/fxb.min.js +0 -2
  117. package/node_modules/fast-xml-builder/lib/fxb.min.js.map +0 -1
  118. package/node_modules/fast-xml-builder/package.json +0 -81
  119. package/node_modules/fast-xml-builder/src/fxb.d.ts +0 -270
  120. package/node_modules/fast-xml-builder/src/fxb.js +0 -599
  121. package/node_modules/fast-xml-builder/src/ignoreAttributes.js +0 -18
  122. package/node_modules/fast-xml-builder/src/orderedJs2Xml.js +0 -359
  123. package/node_modules/fast-xml-builder/src/prettifyJs2Xml.js +0 -0
  124. package/node_modules/fast-xml-builder/src/util.js +0 -16
  125. package/node_modules/path-expression-matcher/LICENSE +0 -21
  126. package/node_modules/path-expression-matcher/README.md +0 -947
  127. package/node_modules/path-expression-matcher/lib/pem.cjs +0 -1
  128. package/node_modules/path-expression-matcher/lib/pem.d.cts +0 -715
  129. package/node_modules/path-expression-matcher/lib/pem.min.js +0 -2
  130. package/node_modules/path-expression-matcher/lib/pem.min.js.map +0 -1
  131. package/node_modules/path-expression-matcher/package.json +0 -79
  132. package/node_modules/path-expression-matcher/src/Expression.js +0 -232
  133. package/node_modules/path-expression-matcher/src/ExpressionSet.js +0 -225
  134. package/node_modules/path-expression-matcher/src/Matcher.js +0 -660
  135. package/node_modules/path-expression-matcher/src/index.d.ts +0 -589
  136. package/node_modules/path-expression-matcher/src/index.js +0 -29
  137. package/node_modules/strnum/CHANGELOG.md +0 -51
  138. package/node_modules/strnum/LICENSE +0 -21
  139. package/node_modules/strnum/README.md +0 -113
  140. package/node_modules/strnum/package.json +0 -36
  141. package/node_modules/strnum/strnum.js +0 -171
  142. package/node_modules/xml-naming/README.md +0 -189
  143. package/node_modules/xml-naming/package.json +0 -54
  144. package/node_modules/xml-naming/src/index.d.ts +0 -74
  145. package/node_modules/xml-naming/src/index.js +0 -270
@@ -1,13 +1,14 @@
1
- import { nv, toUtf8 } from "@smithy/core/serde";
1
+ import { nv } from "@smithy/core/serde";
2
2
  import { alloc, extendedFloat16, extendedFloat32, extendedFloat64, extendedOneByte, majorList, majorMap, majorNegativeInt64, majorTag, majorUint64, majorUnstructuredByteString, majorUtf8String, minorIndefinite, specialFalse, specialNull, specialTrue, specialUndefined, tag, } from "./cbor-types";
3
- const USE_TEXT_DECODER = typeof TextDecoder !== "undefined";
4
3
  const USE_BUFFER = typeof Buffer !== "undefined";
4
+ const textDecoder = new TextDecoder();
5
5
  let payload = alloc(0);
6
+ let isBuffer = false;
6
7
  let dataView = new DataView(payload.buffer, payload.byteOffset, payload.byteLength);
7
- const textDecoder = USE_TEXT_DECODER ? new TextDecoder() : null;
8
8
  let _offset = 0;
9
9
  export function setPayload(bytes) {
10
10
  payload = bytes;
11
+ isBuffer = USE_BUFFER && payload instanceof Buffer;
11
12
  dataView = new DataView(payload.buffer, payload.byteOffset, payload.byteLength);
12
13
  }
13
14
  export function decode(at, to) {
@@ -16,10 +17,13 @@ export function decode(at, to) {
16
17
  }
17
18
  const major = (payload[at] & 0b1110_0000) >> 5;
18
19
  const minor = payload[at] & 0b0001_1111;
20
+ if (minor === minorIndefinite && 2 <= major && major <= 5) {
21
+ return decodeIndefinite(at, to);
22
+ }
19
23
  switch (major) {
20
24
  case majorUint64:
21
25
  case majorNegativeInt64:
22
- case majorTag:
26
+ case majorTag: {
23
27
  let unsignedInt;
24
28
  let offset;
25
29
  if (minor < 24) {
@@ -29,31 +33,43 @@ export function decode(at, to) {
29
33
  else {
30
34
  switch (minor) {
31
35
  case extendedOneByte:
32
- case extendedFloat16:
33
- case extendedFloat32:
34
- case extendedFloat64:
35
- const countLength = minorValueToArgumentLength[minor];
36
- const countOffset = (countLength + 1);
37
- offset = countOffset;
38
- if (to - at < countOffset) {
39
- throw new Error(`countLength ${countLength} greater than remaining buf len.`);
36
+ if (to - at < 2) {
37
+ overflow(1);
40
38
  }
41
- const countIndex = at + 1;
42
- if (countLength === 1) {
43
- unsignedInt = payload[countIndex];
39
+ unsignedInt = payload[at + 1];
40
+ offset = 2;
41
+ break;
42
+ case extendedFloat16:
43
+ if (to - at < 3) {
44
+ overflow(2);
44
45
  }
45
- else if (countLength === 2) {
46
- unsignedInt = dataView.getUint16(countIndex);
46
+ unsignedInt = dataView.getUint16(at + 1);
47
+ offset = 3;
48
+ break;
49
+ case extendedFloat32:
50
+ if (to - at < 5) {
51
+ overflow(4);
47
52
  }
48
- else if (countLength === 4) {
49
- unsignedInt = dataView.getUint32(countIndex);
53
+ unsignedInt = dataView.getUint32(at + 1);
54
+ offset = 5;
55
+ break;
56
+ case extendedFloat64:
57
+ if (to - at < 9) {
58
+ overflow(8);
50
59
  }
51
- else {
52
- unsignedInt = dataView.getBigUint64(countIndex);
60
+ {
61
+ const hi = dataView.getUint32(at + 1);
62
+ if (hi < 0x00200000) {
63
+ unsignedInt = hi * 4294967296 + dataView.getUint32(at + 5);
64
+ }
65
+ else {
66
+ unsignedInt = dataView.getBigUint64(at + 1);
67
+ }
53
68
  }
69
+ offset = 9;
54
70
  break;
55
71
  default:
56
- throw new Error(`unexpected minor value ${minor}.`);
72
+ unexpectedMinor(minor);
57
73
  }
58
74
  }
59
75
  if (major === majorUint64) {
@@ -72,234 +88,98 @@ export function decode(at, to) {
72
88
  return castBigInt(negativeInt);
73
89
  }
74
90
  else {
75
- if (minor === 2 || minor === 3) {
76
- const length = decodeCount(at + offset, to);
77
- let b = BigInt(0);
78
- const start = at + offset + _offset;
79
- for (let i = start; i < start + length; ++i) {
80
- b = (b << BigInt(8)) | BigInt(payload[i]);
81
- }
82
- _offset = offset + _offset + length;
83
- return minor === 3 ? -b - BigInt(1) : b;
84
- }
85
- else if (minor === 4) {
86
- const decimalFraction = decode(at + offset, to);
87
- const [exponent, mantissa] = decimalFraction;
88
- const normalizer = mantissa < 0 ? -1 : 1;
89
- const mantissaStr = "0".repeat(Math.abs(exponent) + 1) + String(BigInt(normalizer) * BigInt(mantissa));
90
- let numericString;
91
- const sign = mantissa < 0 ? "-" : "";
92
- numericString =
93
- exponent === 0
94
- ? mantissaStr
95
- : mantissaStr.slice(0, mantissaStr.length + exponent) + "." + mantissaStr.slice(exponent);
96
- numericString = numericString.replace(/^0+/g, "");
97
- if (numericString === "") {
98
- numericString = "0";
99
- }
100
- if (numericString[0] === ".") {
101
- numericString = "0" + numericString;
102
- }
103
- numericString = sign + numericString;
104
- _offset = offset + _offset;
105
- return nv(numericString);
106
- }
107
- else {
108
- const value = decode(at + offset, to);
109
- const valueOffset = _offset;
110
- _offset = offset + valueOffset;
111
- return tag({ tag: castBigInt(unsignedInt), value });
112
- }
91
+ return decodeTagValue(at, to, minor, unsignedInt, offset);
113
92
  }
93
+ }
114
94
  case majorUtf8String:
95
+ return decodeUtf8String(at, to);
115
96
  case majorMap:
97
+ return decodeMap(at, to);
116
98
  case majorList:
99
+ return decodeList(at, to);
117
100
  case majorUnstructuredByteString:
118
- if (minor === minorIndefinite) {
119
- switch (major) {
120
- case majorUtf8String:
121
- return decodeUtf8StringIndefinite(at, to);
122
- case majorMap:
123
- return decodeMapIndefinite(at, to);
124
- case majorList:
125
- return decodeListIndefinite(at, to);
126
- case majorUnstructuredByteString:
127
- return decodeUnstructuredByteStringIndefinite(at, to);
128
- }
129
- }
130
- else {
131
- switch (major) {
132
- case majorUtf8String:
133
- return decodeUtf8String(at, to);
134
- case majorMap:
135
- return decodeMap(at, to);
136
- case majorList:
137
- return decodeList(at, to);
138
- case majorUnstructuredByteString:
139
- return decodeUnstructuredByteString(at, to);
140
- }
141
- }
101
+ return decodeUnstructuredByteString(at, to);
142
102
  default:
143
103
  return decodeSpecial(at, to);
144
104
  }
145
105
  }
146
- function bytesToUtf8(bytes, at, to) {
147
- if (USE_BUFFER && bytes.constructor?.name === "Buffer") {
148
- return bytes.toString("utf-8", at, to);
149
- }
150
- if (textDecoder) {
151
- return textDecoder.decode(bytes.subarray(at, to));
152
- }
153
- return toUtf8(bytes.subarray(at, to));
154
- }
155
- function demote(bigInteger) {
156
- const num = Number(bigInteger);
157
- if (num < Number.MIN_SAFE_INTEGER || Number.MAX_SAFE_INTEGER < num) {
158
- console.warn(new Error(`@smithy/core/cbor - truncating BigInt(${bigInteger}) to ${num} with loss of precision.`));
106
+ function decodeIndefinite(at, to) {
107
+ const major = (payload[at] & 0b1110_0000) >> 5;
108
+ const minor = payload[at] & 0b0001_1111;
109
+ if (minor === minorIndefinite) {
110
+ switch (major) {
111
+ case majorUtf8String:
112
+ return decodeUtf8StringIndefinite(at, to);
113
+ case majorMap:
114
+ return decodeMapIndefinite(at, to);
115
+ case majorList:
116
+ return decodeListIndefinite(at, to);
117
+ case majorUnstructuredByteString:
118
+ return decodeUnstructuredByteStringIndefinite(at, to);
119
+ default:
120
+ }
159
121
  }
160
- return num;
161
122
  }
162
- const minorValueToArgumentLength = {
163
- [extendedOneByte]: 1,
164
- [extendedFloat16]: 2,
165
- [extendedFloat32]: 4,
166
- [extendedFloat64]: 8,
167
- };
168
123
  export function bytesToFloat16(a, b) {
169
124
  const sign = a >> 7;
170
125
  const exponent = (a & 0b0111_1100) >> 2;
171
126
  const fraction = ((a & 0b0000_0011) << 8) | b;
172
127
  const scalar = sign === 0 ? 1 : -1;
173
- let exponentComponent;
174
- let summation;
175
128
  if (exponent === 0b00000) {
176
- if (fraction === 0b00000_00000) {
129
+ if (fraction === 0) {
177
130
  return 0;
178
131
  }
179
- else {
180
- exponentComponent = Math.pow(2, 1 - 15);
181
- summation = 0;
182
- }
132
+ return scalar * (Math.pow(2, 1 - 15) * (fraction / 1024));
183
133
  }
184
134
  else if (exponent === 0b11111) {
185
- if (fraction === 0b00000_00000) {
135
+ if (fraction === 0) {
186
136
  return scalar * Infinity;
187
137
  }
188
- else {
189
- return NaN;
190
- }
191
- }
192
- else {
193
- exponentComponent = Math.pow(2, exponent - 15);
194
- summation = 1;
138
+ return NaN;
195
139
  }
196
- summation += fraction / 1024;
197
- return scalar * (exponentComponent * summation);
140
+ return scalar * (Math.pow(2, exponent - 15) * (1 + fraction / 1024));
198
141
  }
199
- function decodeCount(at, to) {
200
- const minor = payload[at] & 0b0001_1111;
201
- if (minor < 24) {
202
- _offset = 1;
203
- return minor;
204
- }
205
- if (minor === extendedOneByte ||
206
- minor === extendedFloat16 ||
207
- minor === extendedFloat32 ||
208
- minor === extendedFloat64) {
209
- const countLength = minorValueToArgumentLength[minor];
210
- _offset = (countLength + 1);
211
- if (to - at < _offset) {
212
- throw new Error(`countLength ${countLength} greater than remaining buf len.`);
213
- }
214
- const countIndex = at + 1;
215
- if (countLength === 1) {
216
- return payload[countIndex];
217
- }
218
- else if (countLength === 2) {
219
- return dataView.getUint16(countIndex);
220
- }
221
- else if (countLength === 4) {
222
- return dataView.getUint32(countIndex);
223
- }
224
- return demote(dataView.getBigUint64(countIndex));
142
+ function decodeMap(at, to) {
143
+ const mapDataLength = decodeCount(at, to);
144
+ if (mapDataLength < 15) {
145
+ return decodeMapSmall(at, to, mapDataLength);
225
146
  }
226
- throw new Error(`unexpected minor value ${minor}.`);
147
+ return decodeMapLarge(at, to, mapDataLength);
227
148
  }
228
- function decodeUtf8String(at, to) {
229
- const length = decodeCount(at, to);
149
+ function decodeMapLarge(at, to, mapDataLength) {
230
150
  const offset = _offset;
231
151
  at += offset;
232
- if (to - at < length) {
233
- throw new Error(`string len ${length} greater than remaining buf len.`);
234
- }
235
- const value = bytesToUtf8(payload, at, at + length);
236
- _offset = offset + length;
237
- return value;
238
- }
239
- function decodeUtf8StringIndefinite(at, to) {
240
- at += 1;
241
- const vector = [];
242
- for (const base = at; at < to;) {
243
- if (payload[at] === 0b1111_1111) {
244
- const data = alloc(vector.length);
245
- data.set(vector, 0);
246
- _offset = at - base + 2;
247
- return bytesToUtf8(data, 0, data.length);
248
- }
249
- const major = (payload[at] & 0b1110_0000) >> 5;
250
- const minor = payload[at] & 0b0001_1111;
251
- if (major !== majorUtf8String) {
252
- throw new Error(`unexpected major type ${major} in indefinite string.`);
253
- }
254
- if (minor === minorIndefinite) {
255
- throw new Error("nested indefinite string.");
152
+ const base = at;
153
+ const map = Object.create(null);
154
+ for (let i = 0; i < mapDataLength; ++i) {
155
+ const key = decodeUtf8String(at, to);
156
+ at += _offset;
157
+ const valMajor = (payload[at] & 0b1110_0000) >> 5;
158
+ if (valMajor === majorUtf8String) {
159
+ map[key] = decodeUtf8String(at, to);
256
160
  }
257
- const bytes = decodeUnstructuredByteString(at, to);
258
- const length = _offset;
259
- at += length;
260
- for (let i = 0; i < bytes.length; ++i) {
261
- vector.push(bytes[i]);
161
+ else {
162
+ map[key] = decode(at, to);
262
163
  }
164
+ at += _offset;
263
165
  }
264
- throw new Error("expected break marker.");
166
+ _offset = offset + (at - base);
167
+ Object.setPrototypeOf(map, Object.prototype);
168
+ return map;
265
169
  }
266
- function decodeUnstructuredByteString(at, to) {
267
- const length = decodeCount(at, to);
170
+ function decodeMapSmall(at, to, mapDataLength) {
268
171
  const offset = _offset;
269
172
  at += offset;
270
- if (to - at < length) {
271
- throw new Error(`unstructured byte string len ${length} greater than remaining buf len.`);
272
- }
273
- const value = payload.subarray(at, at + length);
274
- _offset = offset + length;
275
- return value;
276
- }
277
- function decodeUnstructuredByteStringIndefinite(at, to) {
278
- at += 1;
279
- const vector = [];
280
- for (const base = at; at < to;) {
281
- if (payload[at] === 0b1111_1111) {
282
- const data = alloc(vector.length);
283
- data.set(vector, 0);
284
- _offset = at - base + 2;
285
- return data;
286
- }
287
- const major = (payload[at] & 0b1110_0000) >> 5;
288
- const minor = payload[at] & 0b0001_1111;
289
- if (major !== majorUnstructuredByteString) {
290
- throw new Error(`unexpected major type ${major} in indefinite string.`);
291
- }
292
- if (minor === minorIndefinite) {
293
- throw new Error("nested indefinite string.");
294
- }
295
- const bytes = decodeUnstructuredByteString(at, to);
296
- const length = _offset;
297
- at += length;
298
- for (let i = 0; i < bytes.length; ++i) {
299
- vector.push(bytes[i]);
300
- }
173
+ const base = at;
174
+ const map = {};
175
+ for (let i = 0; i < mapDataLength; ++i) {
176
+ const key = decodeUtf8String(at, to);
177
+ at += _offset;
178
+ map[key] = decode(at, to);
179
+ at += _offset;
301
180
  }
302
- throw new Error("expected break marker.");
181
+ _offset = offset + (at - base);
182
+ return map;
303
183
  }
304
184
  function decodeList(at, to) {
305
185
  const listDataLength = decodeCount(at, to);
@@ -308,75 +188,115 @@ function decodeList(at, to) {
308
188
  const base = at;
309
189
  const list = Array(listDataLength);
310
190
  for (let i = 0; i < listDataLength; ++i) {
311
- const item = decode(at, to);
312
- const itemOffset = _offset;
313
- list[i] = item;
314
- at += itemOffset;
191
+ list[i] = decode(at, to);
192
+ at += _offset;
315
193
  }
316
194
  _offset = offset + (at - base);
317
195
  return list;
318
196
  }
319
- function decodeListIndefinite(at, to) {
320
- at += 1;
321
- const list = [];
322
- for (const base = at; at < to;) {
323
- if (payload[at] === 0b1111_1111) {
324
- _offset = at - base + 2;
325
- return list;
197
+ function decodeUtf8String(at, to) {
198
+ const length = decodeCount(at, to);
199
+ const offset = _offset;
200
+ at += offset;
201
+ if (to - at < length) {
202
+ overflow(length);
203
+ }
204
+ _offset = offset + length;
205
+ if (length < 24) {
206
+ return decodeUtf8StringCached(at, length);
207
+ }
208
+ if (isBuffer) {
209
+ return payload.toString("utf-8", at, at + length);
210
+ }
211
+ return textDecoder.decode(payload.subarray(at, at + length));
212
+ }
213
+ const stringCache = new Array(2048);
214
+ const stringCacheEpochs = new Uint16Array(2048);
215
+ let cacheEpoch = 0;
216
+ export function advanceDecodingEpoch() {
217
+ cacheEpoch = (cacheEpoch + 1) & 0b1111_1111_1111_1111;
218
+ }
219
+ function decodeUtf8StringCached(at, length) {
220
+ let h = length;
221
+ for (let i = 0; i < length; ++i) {
222
+ h = (h * 31 + payload[at + i]) | 0;
223
+ }
224
+ const slot = (h >>> 0) & 2047;
225
+ const cached = stringCache[slot];
226
+ if (cached !== undefined) {
227
+ if (cached.length === length) {
228
+ let match = true;
229
+ for (let i = 0; i < length; ++i) {
230
+ if (cached.charCodeAt(i) !== payload[at + i]) {
231
+ match = false;
232
+ break;
233
+ }
234
+ }
235
+ if (match) {
236
+ stringCacheEpochs[slot] = cacheEpoch;
237
+ return cached;
238
+ }
326
239
  }
327
- const item = decode(at, to);
328
- const n = _offset;
329
- at += n;
330
- list.push(item);
331
240
  }
332
- throw new Error("expected break marker.");
241
+ const result = isBuffer
242
+ ? payload.toString("utf-8", at, at + length)
243
+ : textDecoder.decode(payload.subarray(at, at + length));
244
+ if (stringCacheEpochs[slot] !== cacheEpoch) {
245
+ stringCache[slot] = result;
246
+ stringCacheEpochs[slot] = cacheEpoch;
247
+ }
248
+ return result;
333
249
  }
334
- function decodeMap(at, to) {
335
- const mapDataLength = decodeCount(at, to);
250
+ function decodeUnstructuredByteString(at, to) {
251
+ const length = decodeCount(at, to);
336
252
  const offset = _offset;
337
253
  at += offset;
338
- const base = at;
339
- const map = {};
340
- for (let i = 0; i < mapDataLength; ++i) {
341
- if (at >= to) {
342
- throw new Error("unexpected end of map payload.");
343
- }
344
- const major = (payload[at] & 0b1110_0000) >> 5;
345
- if (major !== majorUtf8String) {
346
- throw new Error(`unexpected major type ${major} for map key at index ${at}.`);
347
- }
348
- const key = decode(at, to);
349
- at += _offset;
350
- const value = decode(at, to);
351
- at += _offset;
352
- map[key] = value;
254
+ if (to - at < length) {
255
+ overflow(length);
353
256
  }
354
- _offset = offset + (at - base);
355
- return map;
257
+ const value = payload.subarray(at, at + length);
258
+ _offset = offset + length;
259
+ return value;
356
260
  }
357
- function decodeMapIndefinite(at, to) {
358
- at += 1;
359
- const base = at;
360
- const map = {};
361
- for (; at < to;) {
362
- if (at >= to) {
363
- throw new Error("unexpected end of map payload.");
261
+ function decodeTagValue(at, to, minor, unsignedInt, offset) {
262
+ if (minor === 2 || minor === 3) {
263
+ const length = decodeCount(at + offset, to);
264
+ let b = BigInt(0);
265
+ const start = at + offset + _offset;
266
+ for (let i = start; i < start + length; ++i) {
267
+ b = (b << BigInt(8)) | BigInt(payload[i]);
364
268
  }
365
- if (payload[at] === 0b1111_1111) {
366
- _offset = at - base + 2;
367
- return map;
269
+ _offset = offset + _offset + length;
270
+ return minor === 3 ? -b - BigInt(1) : b;
271
+ }
272
+ else if (minor === 4) {
273
+ const decimalFraction = decode(at + offset, to);
274
+ const [exponent, mantissa] = decimalFraction;
275
+ const normalizer = mantissa < 0 ? -1 : 1;
276
+ const mantissaStr = "0".repeat(Math.abs(exponent) + 1) + String(BigInt(normalizer) * BigInt(mantissa));
277
+ let numericString;
278
+ const sign = mantissa < 0 ? "-" : "";
279
+ numericString =
280
+ exponent === 0
281
+ ? mantissaStr
282
+ : mantissaStr.slice(0, mantissaStr.length + exponent) + "." + mantissaStr.slice(exponent);
283
+ numericString = numericString.replace(/^0+/g, "");
284
+ if (numericString === "") {
285
+ numericString = "0";
368
286
  }
369
- const major = (payload[at] & 0b1110_0000) >> 5;
370
- if (major !== majorUtf8String) {
371
- throw new Error(`unexpected major type ${major} for map key.`);
287
+ if (numericString[0] === ".") {
288
+ numericString = "0" + numericString;
372
289
  }
373
- const key = decode(at, to);
374
- at += _offset;
375
- const value = decode(at, to);
376
- at += _offset;
377
- map[key] = value;
290
+ numericString = sign + numericString;
291
+ _offset = offset + _offset;
292
+ return nv(numericString);
293
+ }
294
+ else {
295
+ const value = decode(at + offset, to);
296
+ const valueOffset = _offset;
297
+ _offset = offset + valueOffset;
298
+ return tag({ tag: castBigInt(unsignedInt), value });
378
299
  }
379
- throw new Error("expected break marker.");
380
300
  }
381
301
  function decodeSpecial(at, to) {
382
302
  const minor = payload[at] & 0b0001_1111;
@@ -410,8 +330,129 @@ function decodeSpecial(at, to) {
410
330
  _offset = 9;
411
331
  return dataView.getFloat64(at + 1);
412
332
  default:
413
- throw new Error(`unexpected minor value ${minor}.`);
333
+ unexpectedMinor(minor);
334
+ }
335
+ }
336
+ function decodeCount(at, to) {
337
+ const minor = payload[at] & 0b0001_1111;
338
+ if (minor < 24) {
339
+ _offset = 1;
340
+ return minor;
341
+ }
342
+ switch (minor) {
343
+ case extendedOneByte:
344
+ if (to - at < 2) {
345
+ overflow(1);
346
+ }
347
+ _offset = 2;
348
+ return payload[at + 1];
349
+ case extendedFloat16:
350
+ if (to - at < 3) {
351
+ overflow(2);
352
+ }
353
+ _offset = 3;
354
+ return dataView.getUint16(at + 1);
355
+ case extendedFloat32:
356
+ if (to - at < 5) {
357
+ overflow(4);
358
+ }
359
+ _offset = 5;
360
+ return dataView.getUint32(at + 1);
361
+ case extendedFloat64:
362
+ if (to - at < 9) {
363
+ overflow(8);
364
+ }
365
+ _offset = 9;
366
+ return demote(dataView.getBigUint64(at + 1));
367
+ default:
368
+ unexpectedMinor(minor);
369
+ }
370
+ }
371
+ function decodeMapIndefinite(at, to) {
372
+ at += 1;
373
+ const base = at;
374
+ const map = {};
375
+ for (; at < to;) {
376
+ if (payload[at] === 0b1111_1111) {
377
+ _offset = at - base + 2;
378
+ return map;
379
+ }
380
+ const key = decodeUtf8String(at, to);
381
+ at += _offset;
382
+ map[key] = decode(at, to);
383
+ at += _offset;
384
+ }
385
+ throw new Error("expected break marker.");
386
+ }
387
+ function decodeListIndefinite(at, to) {
388
+ at += 1;
389
+ const list = [];
390
+ for (const base = at; at < to;) {
391
+ if (payload[at] === 0b1111_1111) {
392
+ _offset = at - base + 2;
393
+ return list;
394
+ }
395
+ list.push(decode(at, to));
396
+ at += _offset;
397
+ }
398
+ throw new Error("expected break marker.");
399
+ }
400
+ function decodeUtf8StringIndefinite(at, to) {
401
+ at += 1;
402
+ const vector = [];
403
+ for (const base = at; at < to;) {
404
+ if (payload[at] === 0b1111_1111) {
405
+ const data = alloc(vector.length);
406
+ data.set(vector, 0);
407
+ _offset = at - base + 2;
408
+ if (USE_BUFFER) {
409
+ return data.toString("utf-8", 0, data.length);
410
+ }
411
+ return textDecoder.decode(data);
412
+ }
413
+ const major = (payload[at] & 0b1110_0000) >> 5;
414
+ const minor = payload[at] & 0b0001_1111;
415
+ if (major !== majorUtf8String) {
416
+ unexpectedMajorInIndefiniteString(major);
417
+ }
418
+ if (minor === minorIndefinite) {
419
+ throw new Error("nested indefinite string.");
420
+ }
421
+ const bytes = decodeUnstructuredByteString(at, to);
422
+ const length = _offset;
423
+ at += length;
424
+ for (let i = 0; i < bytes.length; ++i) {
425
+ vector.push(bytes[i]);
426
+ }
427
+ }
428
+ throw new Error("expected break marker.");
429
+ }
430
+ function decodeUnstructuredByteStringIndefinite(at, to) {
431
+ at += 1;
432
+ const vector = [];
433
+ for (const base = at; at < to;) {
434
+ if (payload[at] === 0b1111_1111) {
435
+ const data = alloc(vector.length);
436
+ data.set(vector, 0);
437
+ _offset = at - base + 2;
438
+ return data;
439
+ }
440
+ const major = (payload[at] & 0b1110_0000) >> 5;
441
+ const minor = payload[at] & 0b0001_1111;
442
+ if (major !== majorUnstructuredByteString) {
443
+ unexpectedMajorInIndefiniteString(major);
444
+ }
445
+ if (minor === minorIndefinite) {
446
+ throw new Error("nested indefinite string.");
447
+ }
448
+ const bytes = decodeUnstructuredByteString(at, to);
449
+ const length = _offset;
450
+ at += length;
451
+ for (let i = 0; i < bytes.length; ++i) {
452
+ vector.push(bytes[i]);
453
+ }
414
454
  }
455
+ throw new Error("expected break marker.");
415
456
  }
416
457
  function castBigInt(bigInt) {
417
458
  if (typeof bigInt === "number") {
@@ -423,3 +464,19 @@ function castBigInt(bigInt) {
423
464
  }
424
465
  return bigInt;
425
466
  }
467
+ function demote(bigInteger) {
468
+ const num = Number(bigInteger);
469
+ if (num < Number.MIN_SAFE_INTEGER || Number.MAX_SAFE_INTEGER < num) {
470
+ console.warn(new Error(`@smithy/core/cbor - truncating BigInt(${bigInteger}) to ${num} with loss of precision.`));
471
+ }
472
+ return num;
473
+ }
474
+ function overflow(n) {
475
+ throw new Error(`length ${n} greater than remaining buf len.`);
476
+ }
477
+ function unexpectedMinor(minor) {
478
+ throw new Error(`unexpected minor value ${minor}.`);
479
+ }
480
+ function unexpectedMajorInIndefiniteString(major) {
481
+ throw new Error(`unexpected major type ${major} in indefinite string.`);
482
+ }