lifecycleion 0.0.19 → 0.0.21

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 (74) hide show
  1. package/README.md +39 -36
  2. package/dist/lib/event-emitter.cjs +195 -9
  3. package/dist/lib/event-emitter.cjs.map +1 -1
  4. package/dist/lib/event-emitter.js +195 -9
  5. package/dist/lib/event-emitter.js.map +1 -1
  6. package/dist/lib/global-event-target.cjs +217 -0
  7. package/dist/lib/global-event-target.cjs.map +1 -0
  8. package/dist/lib/global-event-target.d.cts +70 -0
  9. package/dist/lib/global-event-target.d.ts +70 -0
  10. package/dist/lib/global-event-target.js +189 -0
  11. package/dist/lib/global-event-target.js.map +1 -0
  12. package/dist/lib/http-client/index.cjs +554 -193
  13. package/dist/lib/http-client/index.cjs.map +1 -1
  14. package/dist/lib/http-client/index.d.cts +9 -3
  15. package/dist/lib/http-client/index.d.ts +9 -3
  16. package/dist/lib/http-client/index.js +554 -193
  17. package/dist/lib/http-client/index.js.map +1 -1
  18. package/dist/lib/http-client-mock/index.cjs +71 -24
  19. package/dist/lib/http-client-mock/index.cjs.map +1 -1
  20. package/dist/lib/http-client-mock/index.d.cts +50 -2
  21. package/dist/lib/http-client-mock/index.d.ts +50 -2
  22. package/dist/lib/http-client-mock/index.js +71 -24
  23. package/dist/lib/http-client-mock/index.js.map +1 -1
  24. package/dist/lib/http-client-node/index.cjs +135 -33
  25. package/dist/lib/http-client-node/index.cjs.map +1 -1
  26. package/dist/lib/http-client-node/index.d.cts +33 -2
  27. package/dist/lib/http-client-node/index.d.ts +33 -2
  28. package/dist/lib/http-client-node/index.js +135 -33
  29. package/dist/lib/http-client-node/index.js.map +1 -1
  30. package/dist/lib/http-client-xhr/index.cjs +0 -14
  31. package/dist/lib/http-client-xhr/index.cjs.map +1 -1
  32. package/dist/lib/http-client-xhr/index.d.cts +3 -2
  33. package/dist/lib/http-client-xhr/index.d.ts +3 -2
  34. package/dist/lib/http-client-xhr/index.js +0 -14
  35. package/dist/lib/http-client-xhr/index.js.map +1 -1
  36. package/dist/lib/lifecycle-manager/index.cjs +199 -13
  37. package/dist/lib/lifecycle-manager/index.cjs.map +1 -1
  38. package/dist/lib/lifecycle-manager/index.js +199 -13
  39. package/dist/lib/lifecycle-manager/index.js.map +1 -1
  40. package/dist/lib/logger/index.cjs +203 -21
  41. package/dist/lib/logger/index.cjs.map +1 -1
  42. package/dist/lib/logger/index.d.cts +5 -1
  43. package/dist/lib/logger/index.d.ts +5 -1
  44. package/dist/lib/logger/index.js +203 -21
  45. package/dist/lib/logger/index.js.map +1 -1
  46. package/dist/lib/lru-cache/index.cjs +195 -9
  47. package/dist/lib/lru-cache/index.cjs.map +1 -1
  48. package/dist/lib/lru-cache/index.js +195 -9
  49. package/dist/lib/lru-cache/index.js.map +1 -1
  50. package/dist/lib/process-signal-manager.cjs +199 -13
  51. package/dist/lib/process-signal-manager.cjs.map +1 -1
  52. package/dist/lib/process-signal-manager.js +199 -13
  53. package/dist/lib/process-signal-manager.js.map +1 -1
  54. package/dist/lib/promise-protected-resolver.cjs +195 -9
  55. package/dist/lib/promise-protected-resolver.cjs.map +1 -1
  56. package/dist/lib/promise-protected-resolver.js +195 -9
  57. package/dist/lib/promise-protected-resolver.js.map +1 -1
  58. package/dist/lib/retry-utils/index.cjs +195 -9
  59. package/dist/lib/retry-utils/index.cjs.map +1 -1
  60. package/dist/lib/retry-utils/index.js +195 -9
  61. package/dist/lib/retry-utils/index.js.map +1 -1
  62. package/dist/lib/safe-handle-callback.cjs +196 -18
  63. package/dist/lib/safe-handle-callback.cjs.map +1 -1
  64. package/dist/lib/safe-handle-callback.d.cts +14 -4
  65. package/dist/lib/safe-handle-callback.d.ts +14 -4
  66. package/dist/lib/safe-handle-callback.js +196 -18
  67. package/dist/lib/safe-handle-callback.js.map +1 -1
  68. package/dist/lib/single-event-observer.cjs +195 -9
  69. package/dist/lib/single-event-observer.cjs.map +1 -1
  70. package/dist/lib/single-event-observer.js +195 -9
  71. package/dist/lib/single-event-observer.js.map +1 -1
  72. package/dist/{types-CWw885iO.d.cts → types-BFvpJPMt.d.cts} +72 -11
  73. package/dist/{types-Mso0dYOS.d.ts → types-BONtIhQ5.d.ts} +72 -11
  74. package/package.json +31 -12
@@ -1,4 +1,5 @@
1
- import { H as HTTPAdapter, A as AdapterType, a as AdapterRequest, b as AdapterResponse } from '../../types-CWw885iO.cjs';
1
+ import { H as HTTPAdapter, A as AdapterType, a as AdapterRequest, b as AdapterResponse } from '../../types-BFvpJPMt.cjs';
2
+ export { c as AdapterProgressEvent, d as HTTPMethod, S as StreamResponseCancel, e as StreamResponseContext, f as StreamResponseFactory, g as StreamResponseInfo, W as WritableLike } from '../../types-BFvpJPMt.cjs';
2
3
  import '../../types-BW0vnSzd.cjs';
3
4
 
4
5
  interface NodeAdapterConfig {
@@ -48,6 +49,36 @@ interface NodeAdapterConfig {
48
49
  * routes by Host, also set defaultHeaders: { host: 'billing.internal' }.
49
50
  */
50
51
  servername?: string;
52
+ /**
53
+ * Certificate revocation list(s), used to reject a server certificate whose
54
+ * serial has been revoked even though its chain and hostname still check out.
55
+ * A revoked certificate fails the handshake with `CERT_REVOKED`.
56
+ *
57
+ * Accepts whatever your CA tooling produced. A PEM string holding SEVERAL
58
+ * concatenated CRLs — the format Apache's `SSLCARevocationFile`, nginx's
59
+ * `ssl_crl` and HAProxy's `crl-file` all expect, and what `openssl ca
60
+ * -gencrl` output is usually assembled into — is split into the array Node
61
+ * requires. A single CRL, a DER `Buffer`, or an array you built yourself is
62
+ * passed through untouched.
63
+ *
64
+ * The split exists because Node reads only the FIRST CRL of a concatenated
65
+ * string and silently ignores the rest, unlike `ca`, which reads every
66
+ * certificate in a bundle. See docs/http-client.md.
67
+ *
68
+ * Two things to know before using this:
69
+ *
70
+ * - **Every certificate in the chain needs a covering CRL.** Node enables
71
+ * `X509_V_FLAG_CRL_CHECK_ALL`, so supplying a CRL for one root while
72
+ * connecting through another fails with `UNABLE_TO_GET_CRL` even when
73
+ * nothing was revoked. Cover every root you talk to, or scope the client.
74
+ * - **CRLs expire.** Past `nextUpdate` the handshake fails with
75
+ * `CRL_HAS_EXPIRED`, including for certificates that were never revoked.
76
+ * Re-pass a fresh CRL before then; the refresh cadence is yours to own.
77
+ *
78
+ * Both failures are fail-closed, so a stale CRL never silently stops
79
+ * enforcing — but both can take out healthy connections.
80
+ */
81
+ crl?: string | Buffer | Array<string | Buffer>;
51
82
  /**
52
83
  * Set to false to accept self-signed certificates in dev/test environments.
53
84
  * Defaults to true (Node.js default — rejects invalid certs).
@@ -61,4 +92,4 @@ declare class NodeAdapter implements HTTPAdapter {
61
92
  send(request: AdapterRequest): Promise<AdapterResponse>;
62
93
  }
63
94
 
64
- export { NodeAdapter, type NodeAdapterConfig };
95
+ export { AdapterRequest, AdapterResponse, AdapterType, HTTPAdapter, NodeAdapter, type NodeAdapterConfig };
@@ -1,4 +1,5 @@
1
- import { H as HTTPAdapter, A as AdapterType, a as AdapterRequest, b as AdapterResponse } from '../../types-Mso0dYOS.js';
1
+ import { H as HTTPAdapter, A as AdapterType, a as AdapterRequest, b as AdapterResponse } from '../../types-BONtIhQ5.js';
2
+ export { c as AdapterProgressEvent, d as HTTPMethod, S as StreamResponseCancel, e as StreamResponseContext, f as StreamResponseFactory, g as StreamResponseInfo, W as WritableLike } from '../../types-BONtIhQ5.js';
2
3
  import '../../types-BW0vnSzd.js';
3
4
 
4
5
  interface NodeAdapterConfig {
@@ -48,6 +49,36 @@ interface NodeAdapterConfig {
48
49
  * routes by Host, also set defaultHeaders: { host: 'billing.internal' }.
49
50
  */
50
51
  servername?: string;
52
+ /**
53
+ * Certificate revocation list(s), used to reject a server certificate whose
54
+ * serial has been revoked even though its chain and hostname still check out.
55
+ * A revoked certificate fails the handshake with `CERT_REVOKED`.
56
+ *
57
+ * Accepts whatever your CA tooling produced. A PEM string holding SEVERAL
58
+ * concatenated CRLs — the format Apache's `SSLCARevocationFile`, nginx's
59
+ * `ssl_crl` and HAProxy's `crl-file` all expect, and what `openssl ca
60
+ * -gencrl` output is usually assembled into — is split into the array Node
61
+ * requires. A single CRL, a DER `Buffer`, or an array you built yourself is
62
+ * passed through untouched.
63
+ *
64
+ * The split exists because Node reads only the FIRST CRL of a concatenated
65
+ * string and silently ignores the rest, unlike `ca`, which reads every
66
+ * certificate in a bundle. See docs/http-client.md.
67
+ *
68
+ * Two things to know before using this:
69
+ *
70
+ * - **Every certificate in the chain needs a covering CRL.** Node enables
71
+ * `X509_V_FLAG_CRL_CHECK_ALL`, so supplying a CRL for one root while
72
+ * connecting through another fails with `UNABLE_TO_GET_CRL` even when
73
+ * nothing was revoked. Cover every root you talk to, or scope the client.
74
+ * - **CRLs expire.** Past `nextUpdate` the handshake fails with
75
+ * `CRL_HAS_EXPIRED`, including for certificates that were never revoked.
76
+ * Re-pass a fresh CRL before then; the refresh cadence is yours to own.
77
+ *
78
+ * Both failures are fail-closed, so a stale CRL never silently stops
79
+ * enforcing — but both can take out healthy connections.
80
+ */
81
+ crl?: string | Buffer | Array<string | Buffer>;
51
82
  /**
52
83
  * Set to false to accept self-signed certificates in dev/test environments.
53
84
  * Defaults to true (Node.js default — rejects invalid certs).
@@ -61,4 +92,4 @@ declare class NodeAdapter implements HTTPAdapter {
61
92
  send(request: AdapterRequest): Promise<AdapterResponse>;
62
93
  }
63
94
 
64
- export { NodeAdapter, type NodeAdapterConfig };
95
+ export { AdapterRequest, AdapterResponse, AdapterType, HTTPAdapter, NodeAdapter, type NodeAdapterConfig };
@@ -325,19 +325,63 @@ var CERT_ERROR_CODES = /* @__PURE__ */ new Set([
325
325
  "ERR_SSL_TLSV13_ALERT_CERTIFICATE_REQUIRED",
326
326
  "ERR_SSL_PEER_DID_NOT_RETURN_A_CERTIFICATE",
327
327
  "SELF_SIGNED_CERT_IN_CHAIN",
328
- "UNABLE_TO_GET_ISSUER_CERT_LOCALLY"
328
+ "UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
329
+ "CERT_REVOKED"
329
330
  ]);
331
+ var CRL_CODE_PATTERN = /(?:^|_)CRLS?(?:_|$)/;
332
+ var TRANSPORT_ERROR_CODES = /* @__PURE__ */ new Set([
333
+ "ENOTFOUND",
334
+ "EAI_AGAIN",
335
+ "ECONNREFUSED",
336
+ "ECONNRESET",
337
+ "ECONNABORTED",
338
+ "ETIMEDOUT",
339
+ "EPIPE",
340
+ "EHOSTUNREACH",
341
+ "EHOSTDOWN",
342
+ "ENETUNREACH",
343
+ "ENETDOWN",
344
+ "EADDRNOTAVAIL"
345
+ ]);
346
+ var UNDICI_TRANSPORT_ERROR_PREFIX = "UND_ERR_";
330
347
  function isTLSCertificateError(error) {
331
- const code = error.code ?? "";
348
+ if (isTLSCertificateErrorSelf(error)) {
349
+ return true;
350
+ }
351
+ const cause = readMember(error, "cause");
352
+ return isErrorValue(cause) ? isTLSCertificateErrorSelf(cause) : false;
353
+ }
354
+ function isErrorValue(value) {
355
+ try {
356
+ return value instanceof Error;
357
+ } catch {
358
+ return false;
359
+ }
360
+ }
361
+ function isTLSCertificateErrorSelf(error) {
362
+ const rawCode = readMember(error, "code");
363
+ const code = typeof rawCode === "string" ? rawCode : "";
332
364
  if (CERT_ERROR_CODES.has(code)) {
333
365
  return true;
334
366
  }
367
+ if (CRL_CODE_PATTERN.test(code)) {
368
+ return true;
369
+ }
335
370
  if ((code.startsWith("ERR_TLS_") || code.startsWith("ERR_SSL_")) && code.includes("CERT")) {
336
371
  return true;
337
372
  }
338
- return /certificate|self signed|unable to verify|altname/i.test(
339
- error.message
340
- );
373
+ if (TRANSPORT_ERROR_CODES.has(code) || code.startsWith(UNDICI_TRANSPORT_ERROR_PREFIX)) {
374
+ return false;
375
+ }
376
+ const message = readMember(error, "message");
377
+ return typeof message === "string" ? /certificate|self signed|unable to verify|altname/i.test(message) : false;
378
+ }
379
+ function readMember(error, key) {
380
+ try {
381
+ return error[key];
382
+ } catch {
383
+ return void 0;
384
+ }
341
385
  }
342
386
 
343
387
  // src/lib/http-client/adapters/node-adapter-utils.ts
@@ -368,20 +412,6 @@ function materializeNodeRequestHeaders(headers) {
368
412
 
369
413
  // src/lib/http-client/utils.ts
370
414
  import qs from "qs";
371
-
372
- // src/lib/domain-utils/domain-utils.ts
373
- import { getDomain, getSubdomain, getPublicSuffix } from "tldts";
374
-
375
- // src/lib/domain-utils/helpers.ts
376
- import { toASCII } from "tr46";
377
- var INTERNAL_PSEUDO_TLDS = Object.freeze(
378
- /* @__PURE__ */ new Set(["localhost", "local", "test", "internal"])
379
- );
380
-
381
- // src/lib/domain-utils/domain-utils.ts
382
- import { getDomain as getDomain2, getSubdomain as getSubdomain2 } from "tldts";
383
-
384
- // src/lib/http-client/utils.ts
385
415
  function resolveAbsoluteURL(url, baseURL) {
386
416
  if (!url) {
387
417
  return url;
@@ -471,6 +501,9 @@ var NodeAdapter = class {
471
501
  }
472
502
  httpsOptions.rejectUnauthorized = true;
473
503
  }
504
+ if (this._config.crl !== void 0) {
505
+ httpsOptions.crl = normalizeCRL(this._config.crl);
506
+ }
474
507
  if (this._config.rejectUnauthorized === false) {
475
508
  httpsOptions.rejectUnauthorized = false;
476
509
  }
@@ -479,7 +512,6 @@ var NodeAdapter = class {
479
512
  let activeResponseStream;
480
513
  let activeBufferedResponse;
481
514
  let isStreamFactoryPending = false;
482
- let uploadedBodyBytes = 0;
483
515
  let didFireUpload100 = false;
484
516
  const reportUploadProgress = (event) => {
485
517
  if (didFireUpload100) {
@@ -488,7 +520,6 @@ var NodeAdapter = class {
488
520
  if (event.progress === 1) {
489
521
  didFireUpload100 = true;
490
522
  }
491
- uploadedBodyBytes = Math.max(uploadedBodyBytes, event.loaded);
492
523
  request.onUploadProgress?.(event);
493
524
  };
494
525
  reportUploadProgress({ loaded: 0, total: 0, progress: 0 });
@@ -538,7 +569,7 @@ var NodeAdapter = class {
538
569
  return;
539
570
  }
540
571
  if (writable === null || isStreamResponseCancel(writable)) {
541
- const cancelReason = writable !== null ? writable.reason : void 0;
572
+ const cancelReason = writable !== null ? readObjectMember(writable, "reason") : void 0;
542
573
  streamAbort.abort();
543
574
  req.destroy();
544
575
  const abortErr = new Error(
@@ -710,7 +741,7 @@ var NodeAdapter = class {
710
741
  );
711
742
  });
712
743
  })().catch((error) => {
713
- reject(error instanceof Error ? error : new Error(String(error)));
744
+ reject(normalizeError(error));
714
745
  });
715
746
  });
716
747
  req.on("error", (error) => {
@@ -737,7 +768,7 @@ var NodeAdapter = class {
737
768
  );
738
769
  return;
739
770
  }
740
- const isRetryableTransportError = uploadedBodyBytes === 0;
771
+ const wasDefinitelyNotSent = isPreConnectionError(error);
741
772
  resolveAdapterResponse(
742
773
  resolve,
743
774
  req,
@@ -746,7 +777,7 @@ var NodeAdapter = class {
746
777
  {
747
778
  status: 0,
748
779
  isTransportError: true,
749
- isRetryable: isRetryableTransportError,
780
+ ...wasDefinitelyNotSent ? { wasDefinitelyNotSent: true } : {},
750
781
  headers: {},
751
782
  body: null,
752
783
  errorCause: error
@@ -837,12 +868,14 @@ var NodeAdapter = class {
837
868
  request.requestURL,
838
869
  request.headers,
839
870
  {
871
+ // No isRetryable veto: that would stop retrying an idempotent
872
+ // PUT or DELETE. Delivery is unproven rather than disproven, so
873
+ // nothing is claimed and the client's method rule decides.
840
874
  status: 0,
841
875
  isTransportError: true,
842
- isRetryable: false,
843
876
  headers: {},
844
877
  body: null,
845
- errorCause: error instanceof Error ? error : new Error(String(error))
878
+ errorCause: normalizeError(error)
846
879
  }
847
880
  );
848
881
  });
@@ -859,12 +892,14 @@ var NodeAdapter = class {
859
892
  request.requestURL,
860
893
  request.headers,
861
894
  {
895
+ // No isRetryable veto: that would stop retrying an idempotent
896
+ // PUT or DELETE. Delivery is unproven rather than disproven, so
897
+ // nothing is claimed and the client's method rule decides.
862
898
  status: 0,
863
899
  isTransportError: true,
864
- isRetryable: false,
865
900
  headers: {},
866
901
  body: null,
867
- errorCause: error instanceof Error ? error : new Error(String(error))
902
+ errorCause: normalizeError(error)
868
903
  }
869
904
  );
870
905
  });
@@ -934,7 +969,7 @@ async function streamResponseBody(res, writable, totalBytes, onProgress) {
934
969
  } catch (error) {
935
970
  settle({
936
971
  code: "stream_write_error",
937
- cause: error instanceof Error ? error : new Error(String(error))
972
+ cause: normalizeError(error)
938
973
  });
939
974
  return;
940
975
  }
@@ -965,7 +1000,7 @@ async function streamResponseBody(res, writable, totalBytes, onProgress) {
965
1000
  } catch (error) {
966
1001
  settle({
967
1002
  code: "stream_write_error",
968
- cause: error instanceof Error ? error : new Error(String(error))
1003
+ cause: normalizeError(error)
969
1004
  });
970
1005
  }
971
1006
  };
@@ -994,6 +1029,36 @@ async function streamResponseBody(res, writable, totalBytes, onProgress) {
994
1029
  res.on("close", onResponseClose);
995
1030
  });
996
1031
  }
1032
+ var PEM_CRL_HEADER = "-----BEGIN X509 CRL-----";
1033
+ var PEM_CRL_BLOCK = /-----BEGIN X509 CRL-----[\s\S]*?-----END X509 CRL-----/g;
1034
+ var RESIDUE_OUTSIDE_PEM_BLOCKS = /\S/;
1035
+ function normalizeCRL(crl) {
1036
+ if (Array.isArray(crl)) {
1037
+ return crl.flatMap((entry) => normalizeCRLEntry(entry));
1038
+ }
1039
+ return normalizeCRLEntry(crl);
1040
+ }
1041
+ function normalizeCRLEntry(entry) {
1042
+ if (typeof entry === "string") {
1043
+ return splitCRLString(entry);
1044
+ }
1045
+ const text = entry.toString("latin1");
1046
+ if (!text.includes(PEM_CRL_HEADER)) {
1047
+ return entry;
1048
+ }
1049
+ const split = splitCRLString(text);
1050
+ return Array.isArray(split) ? split : entry;
1051
+ }
1052
+ function splitCRLString(crl) {
1053
+ const blocks = crl.match(PEM_CRL_BLOCK) ?? [];
1054
+ const residue = crl.replace(PEM_CRL_BLOCK, "");
1055
+ if (RESIDUE_OUTSIDE_PEM_BLOCKS.test(residue)) {
1056
+ throw new Error(
1057
+ "NodeAdapter: the `crl` value contains content outside any complete -----BEGIN/END X509 CRL----- block. Only PEM CRL blocks separated by whitespace are accepted, because a truncated CRL and a line of commentary are indistinguishable \u2014 accepting the second would mean silently dropping the first and enforcing an incomplete revocation set. Common causes: a partial download, a clipped or mistyped delimiter, or decoded text from `openssl ... -text`, which must be stripped before the bundle is passed here."
1058
+ );
1059
+ }
1060
+ return blocks.length > 1 ? blocks : crl;
1061
+ }
997
1062
  function normalizeResponseHeaders(headers) {
998
1063
  const result = {};
999
1064
  for (const [key, value] of Object.entries(headers)) {
@@ -1041,6 +1106,16 @@ function removeWritableListener(writable, event, listener) {
1041
1106
  const removable = writable;
1042
1107
  removable.off?.(event, listener);
1043
1108
  }
1109
+ var PRE_CONNECTION_ERROR_CODES = /* @__PURE__ */ new Set([
1110
+ "ECONNREFUSED",
1111
+ "ENOTFOUND",
1112
+ "EAI_AGAIN",
1113
+ "EADDRNOTAVAIL"
1114
+ ]);
1115
+ function isPreConnectionError(error) {
1116
+ const code = readObjectMember(error, "code");
1117
+ return typeof code === "string" && PRE_CONNECTION_ERROR_CODES.has(code);
1118
+ }
1044
1119
  function makeResponseStreamError(message, cause) {
1045
1120
  const error = new Error(message);
1046
1121
  if (cause) {
@@ -1049,7 +1124,7 @@ function makeResponseStreamError(message, cause) {
1049
1124
  return error;
1050
1125
  }
1051
1126
  function markStreamFactoryError(error, req, fallbackHeaders) {
1052
- const normalized = error instanceof Error ? error : new Error(String(error));
1127
+ const normalized = normalizeError(error);
1053
1128
  const tagged = normalized;
1054
1129
  tagged[NON_RETRYABLE_HTTP_CLIENT_CALLBACK_ERROR_FLAG] = true;
1055
1130
  Object.assign(normalized, { [STREAM_FACTORY_ERROR_FLAG]: true });
@@ -1073,7 +1148,34 @@ function markResponseStreamAbortError(error, req, fallbackHeaders, status, heade
1073
1148
  return error;
1074
1149
  }
1075
1150
  function isStreamResponseCancel(value) {
1076
- return value !== null && typeof value === "object" && value.cancel === true;
1151
+ return readObjectMember(value, "cancel") === true;
1152
+ }
1153
+ function readObjectMember(source, key) {
1154
+ if (source === null || typeof source !== "object" && typeof source !== "function") {
1155
+ return void 0;
1156
+ }
1157
+ try {
1158
+ return source[key];
1159
+ } catch {
1160
+ return void 0;
1161
+ }
1162
+ }
1163
+ function isErrorValue2(value) {
1164
+ try {
1165
+ return value instanceof Error;
1166
+ } catch {
1167
+ return false;
1168
+ }
1169
+ }
1170
+ function normalizeError(value) {
1171
+ if (isErrorValue2(value)) {
1172
+ return value;
1173
+ }
1174
+ try {
1175
+ return new Error(String(value));
1176
+ } catch {
1177
+ return new Error("Unknown error");
1178
+ }
1077
1179
  }
1078
1180
  export {
1079
1181
  NodeAdapter