@launchdarkly/js-sdk-common 2.31.0 → 2.32.0

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 (93) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/index.cjs +85 -0
  3. package/dist/cjs/index.cjs.map +1 -1
  4. package/dist/cjs/internal/fdv2/protocolHandler.d.ts.map +1 -1
  5. package/dist/cjs/internal/fetch/followRedirects.d.ts +34 -0
  6. package/dist/cjs/internal/fetch/followRedirects.d.ts.map +1 -0
  7. package/dist/cjs/internal/fetch/index.d.ts +1 -0
  8. package/dist/cjs/internal/fetch/index.d.ts.map +1 -1
  9. package/dist/esm/AttributeReference.d.ts +1 -1
  10. package/dist/esm/Context.d.ts +2 -2
  11. package/dist/esm/ContextFilter.d.ts +2 -2
  12. package/dist/esm/api/context/LDContext.d.ts +3 -3
  13. package/dist/esm/api/context/LDContextCommon.d.ts +1 -1
  14. package/dist/esm/api/context/LDMultiKindContext.d.ts +1 -1
  15. package/dist/esm/api/context/LDSingleKindContext.d.ts +1 -1
  16. package/dist/esm/api/context/index.d.ts +6 -6
  17. package/dist/esm/api/data/LDEvaluationDetail.d.ts +2 -2
  18. package/dist/esm/api/data/LDFlagSet.d.ts +1 -1
  19. package/dist/esm/api/data/index.d.ts +4 -4
  20. package/dist/esm/api/index.d.ts +7 -7
  21. package/dist/esm/api/integrations/index.d.ts +1 -1
  22. package/dist/esm/api/logging/BasicLoggerOptions.d.ts +1 -1
  23. package/dist/esm/api/logging/index.d.ts +3 -3
  24. package/dist/esm/api/options/LDClientContext.d.ts +2 -2
  25. package/dist/esm/api/options/index.d.ts +1 -1
  26. package/dist/esm/api/platform/EventSource.d.ts +1 -1
  27. package/dist/esm/api/platform/Info.d.ts +1 -1
  28. package/dist/esm/api/platform/Platform.d.ts +6 -6
  29. package/dist/esm/api/platform/Requests.d.ts +1 -1
  30. package/dist/esm/api/platform/index.d.ts +9 -9
  31. package/dist/esm/api/subsystem/DataSystem/CallbackHandler.d.ts +1 -1
  32. package/dist/esm/api/subsystem/DataSystem/index.d.ts +1 -1
  33. package/dist/esm/api/subsystem/LDContextDeduplicator.d.ts +1 -1
  34. package/dist/esm/api/subsystem/LDEventProcessor.d.ts +1 -1
  35. package/dist/esm/api/subsystem/index.d.ts +5 -5
  36. package/dist/esm/datasource/CompositeDataSource.d.ts +3 -3
  37. package/dist/esm/datasource/errors.d.ts +1 -1
  38. package/dist/esm/datasource/index.d.ts +5 -5
  39. package/dist/esm/datasource/retry/RetryState.d.ts +3 -3
  40. package/dist/esm/datasource/retry/index.d.ts +2 -2
  41. package/dist/esm/index.d.ts +11 -11
  42. package/dist/esm/index.mjs +85 -0
  43. package/dist/esm/index.mjs.map +1 -1
  44. package/dist/esm/internal/context/index.d.ts +1 -1
  45. package/dist/esm/internal/diagnostics/DiagnosticsManager.d.ts +2 -2
  46. package/dist/esm/internal/diagnostics/index.d.ts +1 -1
  47. package/dist/esm/internal/evaluation/EventFactoryBase.d.ts +3 -3
  48. package/dist/esm/internal/evaluation/index.d.ts +2 -2
  49. package/dist/esm/internal/events/EventProcessor.d.ts +6 -6
  50. package/dist/esm/internal/events/EventSender.d.ts +3 -3
  51. package/dist/esm/internal/events/InputClickEvent.d.ts +1 -1
  52. package/dist/esm/internal/events/InputCustomEvent.d.ts +1 -1
  53. package/dist/esm/internal/events/InputEvalEvent.d.ts +2 -2
  54. package/dist/esm/internal/events/InputEvent.d.ts +6 -6
  55. package/dist/esm/internal/events/InputEventBase.d.ts +1 -1
  56. package/dist/esm/internal/events/InputIdentifyEvent.d.ts +1 -1
  57. package/dist/esm/internal/events/InputMigrationEvent.d.ts +1 -1
  58. package/dist/esm/internal/events/InputPageViewEvent.d.ts +1 -1
  59. package/dist/esm/internal/events/LDEventSummarizer.d.ts +1 -1
  60. package/dist/esm/internal/events/MultiEventSummarizer.d.ts +4 -4
  61. package/dist/esm/internal/events/NullEventProcessor.d.ts +1 -1
  62. package/dist/esm/internal/events/guards.d.ts +4 -4
  63. package/dist/esm/internal/events/index.d.ts +10 -10
  64. package/dist/esm/internal/fdv2/FDv1PayloadAdaptor.d.ts +1 -1
  65. package/dist/esm/internal/fdv2/index.d.ts +8 -8
  66. package/dist/esm/internal/fdv2/payloadProcessor.d.ts +4 -4
  67. package/dist/esm/internal/fdv2/payloadStreamReader.d.ts +3 -3
  68. package/dist/esm/internal/fdv2/protocolHandler.d.ts +2 -2
  69. package/dist/esm/internal/fdv2/protocolHandler.d.ts.map +1 -1
  70. package/dist/esm/internal/fetch/StreamingResponse.d.ts +1 -1
  71. package/dist/esm/internal/fetch/followRedirects.d.ts +34 -0
  72. package/dist/esm/internal/fetch/followRedirects.d.ts.map +1 -0
  73. package/dist/esm/internal/fetch/index.d.ts +3 -2
  74. package/dist/esm/internal/fetch/index.d.ts.map +1 -1
  75. package/dist/esm/internal/fetch/toRequestInit.d.ts +1 -1
  76. package/dist/esm/internal/index.d.ts +9 -9
  77. package/dist/esm/internal/json/index.d.ts +1 -1
  78. package/dist/esm/internal/metadata/index.d.ts +1 -1
  79. package/dist/esm/internal/plugins/index.d.ts +3 -3
  80. package/dist/esm/internal/plugins/safeGetHooks.d.ts +2 -2
  81. package/dist/esm/internal/plugins/safeGetName.d.ts +2 -2
  82. package/dist/esm/internal/plugins/safeRegisterPlugins.d.ts +2 -2
  83. package/dist/esm/logging/BasicLogger.d.ts +1 -1
  84. package/dist/esm/logging/SafeLogger.d.ts +1 -1
  85. package/dist/esm/logging/createSafeLogger.d.ts +3 -3
  86. package/dist/esm/logging/index.d.ts +3 -3
  87. package/dist/esm/options/ApplicationTags.d.ts +1 -1
  88. package/dist/esm/options/ClientContext.d.ts +3 -3
  89. package/dist/esm/options/index.d.ts +4 -4
  90. package/dist/esm/utils/cancelableTimedPromise.d.ts +1 -1
  91. package/dist/esm/utils/http.d.ts +2 -2
  92. package/dist/esm/utils/index.d.ts +12 -12
  93. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -2,6 +2,21 @@
2
2
 
3
3
  All notable changes to `@launchdarkly/js-sdk-common` will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org).
4
4
 
5
+ ## [2.32.0](https://github.com/launchdarkly/js-core/compare/js-sdk-common-v2.31.0...js-sdk-common-v2.32.0) (2026-10-27)
6
+
7
+
8
+ ### Features
9
+
10
+ * Migrate the Node.js server and client SDKs to @launchdarkly/eventsource through the platform fetch ([10b57b0](https://github.com/launchdarkly/js-core/commit/10b57b01ce348b216fd98e515740bc5d50830017))
11
+ * Verify TLS certificates on streaming connections by default; a stream served by a private CA now requires tlsParams ([10b57b0](https://github.com/launchdarkly/js-core/commit/10b57b01ce348b216fd98e515740bc5d50830017))
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * Allow polling and event delivery to connect through a proxy when a private CA is configured ([10b57b0](https://github.com/launchdarkly/js-core/commit/10b57b01ce348b216fd98e515740bc5d50830017))
17
+ * Ignore FDv2 put-object and delete-object events with unsupported kinds ([#2109](https://github.com/launchdarkly/js-core/issues/2109)) ([2729c04](https://github.com/launchdarkly/js-core/commit/2729c046493ba4c84ce0f4abf5be0b369d86c68c))
18
+ * Resolve types under node16/nodenext module resolution ([#2115](https://github.com/launchdarkly/js-core/issues/2115)) ([ca1613c](https://github.com/launchdarkly/js-core/commit/ca1613c20130b9308bafb8c98e0843d8d92fee01))
19
+
5
20
  ## [2.31.0](https://github.com/launchdarkly/js-core/compare/js-sdk-common-v2.30.0...js-sdk-common-v2.31.0) (2026-10-16)
6
21
 
7
22
 
@@ -3400,6 +3400,11 @@ function createProtocolHandler(objProcessors, logger) {
3400
3400
  let protocolState = 'inactive';
3401
3401
  let tempType = 'partial';
3402
3402
  let tempUpdates = [];
3403
+ // Only kinds with a registered processor are supported. An own-property check keeps
3404
+ // kinds such as 'constructor' from resolving to inherited members.
3405
+ function isSupportedKind(kind) {
3406
+ return Object.prototype.hasOwnProperty.call(objProcessors, kind);
3407
+ }
3403
3408
  function processObj(kind, jsonObj) {
3404
3409
  return objProcessors[kind]?.(jsonObj);
3405
3410
  }
@@ -3470,6 +3475,12 @@ function createProtocolHandler(objProcessors, logger) {
3470
3475
  logger?.warn(`Ignoring put-object with missing fields: kind=${data.kind}, key=${data.key}, version=${data.version}`);
3471
3476
  return ACTION_NONE;
3472
3477
  }
3478
+ // Objects of unsupported kinds are dropped silently so the protocol can add new kinds
3479
+ // without disrupting older SDKs.
3480
+ if (!isSupportedKind(data.kind)) {
3481
+ logger?.debug(`Ignoring put-object with unsupported kind: '${data.kind}'`);
3482
+ return ACTION_NONE;
3483
+ }
3473
3484
  const obj = processObj(data.kind, data.object);
3474
3485
  if (!obj) {
3475
3486
  logger?.warn(`Unable to process object for kind: '${data.kind}'`);
@@ -3492,6 +3503,10 @@ function createProtocolHandler(objProcessors, logger) {
3492
3503
  logger?.warn(`Ignoring delete-object with missing fields: kind=${data.kind}, key=${data.key}, version=${data.version}`);
3493
3504
  return ACTION_NONE;
3494
3505
  }
3506
+ if (!isSupportedKind(data.kind)) {
3507
+ logger?.debug(`Ignoring delete-object with unsupported kind: '${data.kind}'`);
3508
+ return ACTION_NONE;
3509
+ }
3495
3510
  tempUpdates.push({
3496
3511
  kind: data.kind,
3497
3512
  key: data.key,
@@ -3674,6 +3689,74 @@ class PayloadStreamReader {
3674
3689
  }
3675
3690
  }
3676
3691
 
3692
+ /**
3693
+ * The most redirect hops one streaming request follows. When a chain exceeds the cap, the last
3694
+ * redirect response goes to the caller as an ordinary non-200 response. The caller's error
3695
+ * handling decides whether to retry.
3696
+ */
3697
+ const MAX_STREAMING_REDIRECT_HOPS = 5;
3698
+ /**
3699
+ * Resolves the target of a redirect response. The target can be relative, and it resolves
3700
+ * against the URL of the redirected request. Only an `http:` or `https:` target can carry
3701
+ * the stream; any other scheme, a missing or empty `Location`, and an unparsable value all
3702
+ * resolve to `undefined`, and the redirect response then goes to the caller unfollowed.
3703
+ */
3704
+ function redirectTarget(headers, baseUrl) {
3705
+ const raw = headers.location;
3706
+ const value = Array.isArray(raw) ? raw[0] : raw;
3707
+ if (typeof value !== 'string' || value === '') {
3708
+ return undefined;
3709
+ }
3710
+ try {
3711
+ const resolved = new URL(value, baseUrl);
3712
+ if (resolved.protocol !== 'http:' && resolved.protocol !== 'https:') {
3713
+ return undefined;
3714
+ }
3715
+ return resolved.href;
3716
+ }
3717
+ catch {
3718
+ return undefined;
3719
+ }
3720
+ }
3721
+ /**
3722
+ * Issues a streaming request and follows up to {@link MAX_STREAMING_REDIRECT_HOPS} hops of
3723
+ * `301` and `307` redirects. Each hop calls `doRequest` again with the target URL, so the
3724
+ * request carries the same method, body, and headers to each target, the `Authorization`
3725
+ * header included. A `302` and every other status return to the caller unfollowed.
3726
+ *
3727
+ * The loop holds no state across calls. A reconnect starts from the original URL again and
3728
+ * re-follows the chain.
3729
+ *
3730
+ * @param url The URL of the initial request.
3731
+ * @param doRequest Issues one request and resolves with its response. The caller builds the
3732
+ * options inside it from the given URL, so each hop gets options for its own target.
3733
+ */
3734
+ async function followStreamingRedirects(url, doRequest) {
3735
+ let currentUrl = url;
3736
+ let res = await doRequest(currentUrl);
3737
+ let hops = 0;
3738
+ while ((res.statusCode === 301 || res.statusCode === 307) && hops < MAX_STREAMING_REDIRECT_HOPS) {
3739
+ const target = redirectTarget(res.headers, currentUrl);
3740
+ if (target === undefined) {
3741
+ return res;
3742
+ }
3743
+ hops += 1;
3744
+ // The destroy releases the skipped redirect response and its connection at once, so a
3745
+ // redirect body that never ends cannot hold a socket for the life of the attempt.
3746
+ try {
3747
+ res.destroy?.();
3748
+ }
3749
+ catch {
3750
+ // A throwing destroy has nothing left to release.
3751
+ }
3752
+ currentUrl = target;
3753
+ // The hops are sequential. The next request cannot start until this response arrives.
3754
+ // eslint-disable-next-line no-await-in-loop
3755
+ res = await doRequest(currentUrl);
3756
+ }
3757
+ return res;
3758
+ }
3759
+
3677
3760
  /**
3678
3761
  * Wraps the raw headers in the fetch `Headers` shape. Lookups are case-insensitive.
3679
3762
  * Multi-value headers are joined with ", ", names that differ only by case merge into one
@@ -3874,12 +3957,14 @@ var index = /*#__PURE__*/Object.freeze({
3874
3957
  InputCustomEvent: InputCustomEvent,
3875
3958
  InputEvalEvent: InputEvalEvent,
3876
3959
  InputIdentifyEvent: InputIdentifyEvent,
3960
+ MAX_STREAMING_REDIRECT_HOPS: MAX_STREAMING_REDIRECT_HOPS,
3877
3961
  NullEventProcessor: NullEventProcessor,
3878
3962
  PayloadProcessor: PayloadProcessor,
3879
3963
  PayloadStreamReader: PayloadStreamReader,
3880
3964
  canonicalize: canonicalize,
3881
3965
  createProtocolHandler: createProtocolHandler,
3882
3966
  createStreamingResponse: createStreamingResponse,
3967
+ followStreamingRedirects: followStreamingRedirects,
3883
3968
  initMetadataFromHeaders: initMetadataFromHeaders,
3884
3969
  isLegacyUser: isLegacyUser,
3885
3970
  isMultiKind: isMultiKind,