@smithy/core 3.35.0 → 3.35.2

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Change Log
2
2
 
3
+ ## 3.35.2
4
+
5
+ ### Patch Changes
6
+
7
+ - d74fb5f: fix endpoint cache key collision between empty-string and absent parameters
8
+
9
+ ## 3.35.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 4734e1c: fix for SDK ServiceException instanceof detection relating to mangled class names
14
+ - 4f51625: restore a compat name-string fallback in ServiceException instanceof for clients predating shapeId stamping, gated on a class-name length of at least 6
15
+
3
16
  ## 3.35.0
4
17
 
5
18
  ### Minor Changes
@@ -765,6 +765,7 @@ const createAggregatedClient = (commands, Client, options) => {
765
765
  };
766
766
 
767
767
  class ServiceException extends Error {
768
+ static shapeId = "smithy.ts.sdk.synthetic.nonamespace.client#ServiceException";
768
769
  $fault;
769
770
  $response;
770
771
  $retryable;
@@ -796,22 +797,43 @@ class ServiceException extends Error {
796
797
  if (this.prototype.isPrototypeOf(instance)) {
797
798
  return true;
798
799
  }
799
- const targetName = this.name;
800
- if (!targetName || !candidate.name) {
801
- return false;
800
+ const targetId = Object.prototype.hasOwnProperty.call(this, "shapeId")
801
+ ? this.shapeId
802
+ : undefined;
803
+ let candidateHasShapeId = false;
804
+ if (targetId) {
805
+ let proto = Object.getPrototypeOf(candidate);
806
+ while (proto && proto !== Object.prototype) {
807
+ const ctor = proto.constructor;
808
+ const candidateId = ctor !== ServiceException && Object.prototype.hasOwnProperty.call(ctor, "shapeId")
809
+ ? ctor?.shapeId
810
+ : undefined;
811
+ if (candidateId) {
812
+ candidateHasShapeId = true;
813
+ if (candidateId === targetId) {
814
+ return true;
815
+ }
816
+ }
817
+ proto = Object.getPrototypeOf(proto);
818
+ }
802
819
  }
803
- if (candidate.name === targetName) {
804
- return true;
820
+ if (targetId && candidateHasShapeId) {
821
+ return false;
805
822
  }
806
- let proto = Object.getPrototypeOf(candidate);
807
- while (proto && proto !== Object.prototype) {
808
- const ctorName = proto.constructor?.name;
809
- if (ctorName && ctorName !== "Error" && ctorName === targetName) {
823
+ const targetName = this.name;
824
+ if (targetName && targetName.length >= 6) {
825
+ if (candidate.name === targetName) {
810
826
  return true;
811
827
  }
812
- proto = Object.getPrototypeOf(proto);
828
+ let proto = Object.getPrototypeOf(candidate);
829
+ while (proto && proto !== Object.prototype) {
830
+ const ctorName = proto.constructor?.name;
831
+ if (ctorName && ctorName !== "Error" && ctorName === targetName) {
832
+ return true;
833
+ }
834
+ proto = Object.getPrototypeOf(proto);
835
+ }
813
836
  }
814
- return false;
815
837
  }
816
838
  return false;
817
839
  }
@@ -307,7 +307,8 @@ class EndpointCache {
307
307
  return false;
308
308
  }
309
309
  for (const param of parameters) {
310
- const val = String(endpointParams[param] ?? "");
310
+ const raw = endpointParams[param];
311
+ const val = raw == null ? "\0" : String(raw);
311
312
  if (val.includes("|;")) {
312
313
  return false;
313
314
  }
@@ -355,7 +355,8 @@ class EndpointCache {
355
355
  return false;
356
356
  }
357
357
  for (const param of parameters) {
358
- const val = String(endpointParams[param] ?? "");
358
+ const raw = endpointParams[param];
359
+ const val = raw == null ? "\0" : String(raw);
359
360
  if (val.includes("|;")) {
360
361
  return false;
361
362
  }
@@ -630,6 +630,9 @@ class TypeRegistry {
630
630
  const $error = es;
631
631
  const ns = $error[1];
632
632
  const qualifiedName = ns + "#" + $error[2];
633
+ if (!ctor.hasOwnProperty?.("shapeId")) {
634
+ ctor.shapeId = qualifiedName;
635
+ }
633
636
  for (const r of [this, TypeRegistry.for(ns)]) {
634
637
  if (!r.schemas.has(qualifiedName) && !r.exceptions.has($error)) {
635
638
  r.schemas.set(qualifiedName, $error);
@@ -1,4 +1,5 @@
1
1
  export class ServiceException extends Error {
2
+ static shapeId = "smithy.ts.sdk.synthetic.nonamespace.client#ServiceException";
2
3
  $fault;
3
4
  $response;
4
5
  $retryable;
@@ -30,22 +31,43 @@ export class ServiceException extends Error {
30
31
  if (this.prototype.isPrototypeOf(instance)) {
31
32
  return true;
32
33
  }
33
- const targetName = this.name;
34
- if (!targetName || !candidate.name) {
35
- return false;
34
+ const targetId = Object.prototype.hasOwnProperty.call(this, "shapeId")
35
+ ? this.shapeId
36
+ : undefined;
37
+ let candidateHasShapeId = false;
38
+ if (targetId) {
39
+ let proto = Object.getPrototypeOf(candidate);
40
+ while (proto && proto !== Object.prototype) {
41
+ const ctor = proto.constructor;
42
+ const candidateId = ctor !== ServiceException && Object.prototype.hasOwnProperty.call(ctor, "shapeId")
43
+ ? ctor?.shapeId
44
+ : undefined;
45
+ if (candidateId) {
46
+ candidateHasShapeId = true;
47
+ if (candidateId === targetId) {
48
+ return true;
49
+ }
50
+ }
51
+ proto = Object.getPrototypeOf(proto);
52
+ }
36
53
  }
37
- if (candidate.name === targetName) {
38
- return true;
54
+ if (targetId && candidateHasShapeId) {
55
+ return false;
39
56
  }
40
- let proto = Object.getPrototypeOf(candidate);
41
- while (proto && proto !== Object.prototype) {
42
- const ctorName = proto.constructor?.name;
43
- if (ctorName && ctorName !== "Error" && ctorName === targetName) {
57
+ const targetName = this.name;
58
+ if (targetName && targetName.length >= 6) {
59
+ if (candidate.name === targetName) {
44
60
  return true;
45
61
  }
46
- proto = Object.getPrototypeOf(proto);
62
+ let proto = Object.getPrototypeOf(candidate);
63
+ while (proto && proto !== Object.prototype) {
64
+ const ctorName = proto.constructor?.name;
65
+ if (ctorName && ctorName !== "Error" && ctorName === targetName) {
66
+ return true;
67
+ }
68
+ proto = Object.getPrototypeOf(proto);
69
+ }
47
70
  }
48
- return false;
49
71
  }
50
72
  return false;
51
73
  }
@@ -39,7 +39,8 @@ export class EndpointCache {
39
39
  return false;
40
40
  }
41
41
  for (const param of parameters) {
42
- const val = String(endpointParams[param] ?? "");
42
+ const raw = endpointParams[param];
43
+ const val = raw == null ? "\0" : String(raw);
43
44
  if (val.includes("|;")) {
44
45
  return false;
45
46
  }
@@ -58,6 +58,9 @@ export class TypeRegistry {
58
58
  const $error = es;
59
59
  const ns = $error[1];
60
60
  const qualifiedName = ns + "#" + $error[2];
61
+ if (!ctor.hasOwnProperty?.("shapeId")) {
62
+ ctor.shapeId = qualifiedName;
63
+ }
61
64
  for (const r of [this, TypeRegistry.for(ns)]) {
62
65
  if (!r.schemas.has(qualifiedName) && !r.exceptions.has($error)) {
63
66
  r.schemas.set(qualifiedName, $error);
@@ -18,6 +18,7 @@ export interface ServiceExceptionOptions extends SmithyException, MetadataBearer
18
18
  * @public
19
19
  */
20
20
  export declare class ServiceException extends Error implements SmithyException, MetadataBearer {
21
+ static readonly shapeId: string;
21
22
  readonly $fault: "client" | "server";
22
23
  $response?: HttpResponse;
23
24
  $retryable?: RetryableTrait;
@@ -18,6 +18,7 @@ export interface ServiceExceptionOptions extends SmithyException, MetadataBearer
18
18
  * @public
19
19
  */
20
20
  export declare class ServiceException extends Error implements SmithyException, MetadataBearer {
21
+ static readonly shapeId: string;
21
22
  readonly $fault: "client" | "server";
22
23
  $response?: HttpResponse;
23
24
  $retryable?: RetryableTrait;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/core",
3
- "version": "3.35.0",
3
+ "version": "3.35.2",
4
4
  "homepage": "https://github.com/smithy-lang/smithy-typescript/tree/main/packages/core",
5
5
  "license": "Apache-2.0",
6
6
  "author": {