@launchdarkly/js-sdk-common 2.31.0 → 2.32.1

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 (126) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/cjs/datasource/CompositeDataSource.d.ts.map +1 -1
  3. package/dist/cjs/index.cjs +97 -3
  4. package/dist/cjs/index.cjs.map +1 -1
  5. package/dist/cjs/internal/events/EventProcessor.d.ts.map +1 -1
  6. package/dist/cjs/internal/events/EventSender.d.ts.map +1 -1
  7. package/dist/cjs/internal/events/InputCustomEvent.d.ts +2 -2
  8. package/dist/cjs/internal/events/InputCustomEvent.d.ts.map +1 -1
  9. package/dist/cjs/internal/events/MultiEventSummarizer.d.ts.map +1 -1
  10. package/dist/cjs/internal/fdv2/payloadProcessor.d.ts.map +1 -1
  11. package/dist/cjs/internal/fdv2/payloadStreamReader.d.ts.map +1 -1
  12. package/dist/cjs/internal/fdv2/protocolHandler.d.ts.map +1 -1
  13. package/dist/cjs/internal/fetch/followRedirects.d.ts +34 -0
  14. package/dist/cjs/internal/fetch/followRedirects.d.ts.map +1 -0
  15. package/dist/cjs/internal/fetch/index.d.ts +1 -0
  16. package/dist/cjs/internal/fetch/index.d.ts.map +1 -1
  17. package/dist/cjs/logging/createSafeLogger.d.ts.map +1 -1
  18. package/dist/cjs/utils/debounce.d.ts +1 -1
  19. package/dist/cjs/utils/debounce.d.ts.map +1 -1
  20. package/dist/cjs/utils/deepCompact.d.ts +1 -1
  21. package/dist/cjs/utils/deepCompact.d.ts.map +1 -1
  22. package/dist/cjs/utils/http.d.ts.map +1 -1
  23. package/dist/cjs/utils/isEmptyObject.d.ts.map +1 -1
  24. package/dist/cjs/utils/sleep.d.ts.map +1 -1
  25. package/dist/cjs/utils/timedPromise.d.ts.map +1 -1
  26. package/dist/esm/AttributeReference.d.ts +1 -1
  27. package/dist/esm/Context.d.ts +2 -2
  28. package/dist/esm/ContextFilter.d.ts +2 -2
  29. package/dist/esm/api/context/LDContext.d.ts +3 -3
  30. package/dist/esm/api/context/LDContextCommon.d.ts +1 -1
  31. package/dist/esm/api/context/LDMultiKindContext.d.ts +1 -1
  32. package/dist/esm/api/context/LDSingleKindContext.d.ts +1 -1
  33. package/dist/esm/api/context/index.d.ts +6 -6
  34. package/dist/esm/api/data/LDEvaluationDetail.d.ts +2 -2
  35. package/dist/esm/api/data/LDFlagSet.d.ts +1 -1
  36. package/dist/esm/api/data/index.d.ts +4 -4
  37. package/dist/esm/api/index.d.ts +7 -7
  38. package/dist/esm/api/integrations/index.d.ts +1 -1
  39. package/dist/esm/api/logging/BasicLoggerOptions.d.ts +1 -1
  40. package/dist/esm/api/logging/index.d.ts +3 -3
  41. package/dist/esm/api/options/LDClientContext.d.ts +2 -2
  42. package/dist/esm/api/options/index.d.ts +1 -1
  43. package/dist/esm/api/platform/EventSource.d.ts +1 -1
  44. package/dist/esm/api/platform/Info.d.ts +1 -1
  45. package/dist/esm/api/platform/Platform.d.ts +6 -6
  46. package/dist/esm/api/platform/Requests.d.ts +1 -1
  47. package/dist/esm/api/platform/index.d.ts +9 -9
  48. package/dist/esm/api/subsystem/DataSystem/CallbackHandler.d.ts +1 -1
  49. package/dist/esm/api/subsystem/DataSystem/index.d.ts +1 -1
  50. package/dist/esm/api/subsystem/LDContextDeduplicator.d.ts +1 -1
  51. package/dist/esm/api/subsystem/LDEventProcessor.d.ts +1 -1
  52. package/dist/esm/api/subsystem/index.d.ts +5 -5
  53. package/dist/esm/datasource/CompositeDataSource.d.ts +3 -3
  54. package/dist/esm/datasource/CompositeDataSource.d.ts.map +1 -1
  55. package/dist/esm/datasource/errors.d.ts +1 -1
  56. package/dist/esm/datasource/index.d.ts +5 -5
  57. package/dist/esm/datasource/retry/RetryState.d.ts +3 -3
  58. package/dist/esm/datasource/retry/index.d.ts +2 -2
  59. package/dist/esm/index.d.ts +11 -11
  60. package/dist/esm/index.mjs +97 -3
  61. package/dist/esm/index.mjs.map +1 -1
  62. package/dist/esm/internal/context/index.d.ts +1 -1
  63. package/dist/esm/internal/diagnostics/DiagnosticsManager.d.ts +2 -2
  64. package/dist/esm/internal/diagnostics/index.d.ts +1 -1
  65. package/dist/esm/internal/evaluation/EventFactoryBase.d.ts +3 -3
  66. package/dist/esm/internal/evaluation/index.d.ts +2 -2
  67. package/dist/esm/internal/events/EventProcessor.d.ts +6 -6
  68. package/dist/esm/internal/events/EventProcessor.d.ts.map +1 -1
  69. package/dist/esm/internal/events/EventSender.d.ts +3 -3
  70. package/dist/esm/internal/events/EventSender.d.ts.map +1 -1
  71. package/dist/esm/internal/events/InputClickEvent.d.ts +1 -1
  72. package/dist/esm/internal/events/InputCustomEvent.d.ts +3 -3
  73. package/dist/esm/internal/events/InputCustomEvent.d.ts.map +1 -1
  74. package/dist/esm/internal/events/InputEvalEvent.d.ts +2 -2
  75. package/dist/esm/internal/events/InputEvent.d.ts +6 -6
  76. package/dist/esm/internal/events/InputEventBase.d.ts +1 -1
  77. package/dist/esm/internal/events/InputIdentifyEvent.d.ts +1 -1
  78. package/dist/esm/internal/events/InputMigrationEvent.d.ts +1 -1
  79. package/dist/esm/internal/events/InputPageViewEvent.d.ts +1 -1
  80. package/dist/esm/internal/events/LDEventSummarizer.d.ts +1 -1
  81. package/dist/esm/internal/events/MultiEventSummarizer.d.ts +4 -4
  82. package/dist/esm/internal/events/MultiEventSummarizer.d.ts.map +1 -1
  83. package/dist/esm/internal/events/NullEventProcessor.d.ts +1 -1
  84. package/dist/esm/internal/events/guards.d.ts +4 -4
  85. package/dist/esm/internal/events/index.d.ts +10 -10
  86. package/dist/esm/internal/fdv2/FDv1PayloadAdaptor.d.ts +1 -1
  87. package/dist/esm/internal/fdv2/index.d.ts +8 -8
  88. package/dist/esm/internal/fdv2/payloadProcessor.d.ts +4 -4
  89. package/dist/esm/internal/fdv2/payloadProcessor.d.ts.map +1 -1
  90. package/dist/esm/internal/fdv2/payloadStreamReader.d.ts +3 -3
  91. package/dist/esm/internal/fdv2/payloadStreamReader.d.ts.map +1 -1
  92. package/dist/esm/internal/fdv2/protocolHandler.d.ts +2 -2
  93. package/dist/esm/internal/fdv2/protocolHandler.d.ts.map +1 -1
  94. package/dist/esm/internal/fetch/StreamingResponse.d.ts +1 -1
  95. package/dist/esm/internal/fetch/followRedirects.d.ts +34 -0
  96. package/dist/esm/internal/fetch/followRedirects.d.ts.map +1 -0
  97. package/dist/esm/internal/fetch/index.d.ts +3 -2
  98. package/dist/esm/internal/fetch/index.d.ts.map +1 -1
  99. package/dist/esm/internal/fetch/toRequestInit.d.ts +1 -1
  100. package/dist/esm/internal/index.d.ts +9 -9
  101. package/dist/esm/internal/json/index.d.ts +1 -1
  102. package/dist/esm/internal/metadata/index.d.ts +1 -1
  103. package/dist/esm/internal/plugins/index.d.ts +3 -3
  104. package/dist/esm/internal/plugins/safeGetHooks.d.ts +2 -2
  105. package/dist/esm/internal/plugins/safeGetName.d.ts +2 -2
  106. package/dist/esm/internal/plugins/safeRegisterPlugins.d.ts +2 -2
  107. package/dist/esm/logging/BasicLogger.d.ts +1 -1
  108. package/dist/esm/logging/SafeLogger.d.ts +1 -1
  109. package/dist/esm/logging/createSafeLogger.d.ts +3 -3
  110. package/dist/esm/logging/createSafeLogger.d.ts.map +1 -1
  111. package/dist/esm/logging/index.d.ts +3 -3
  112. package/dist/esm/options/ApplicationTags.d.ts +1 -1
  113. package/dist/esm/options/ClientContext.d.ts +3 -3
  114. package/dist/esm/options/index.d.ts +4 -4
  115. package/dist/esm/utils/cancelableTimedPromise.d.ts +1 -1
  116. package/dist/esm/utils/debounce.d.ts +1 -1
  117. package/dist/esm/utils/debounce.d.ts.map +1 -1
  118. package/dist/esm/utils/deepCompact.d.ts +1 -1
  119. package/dist/esm/utils/deepCompact.d.ts.map +1 -1
  120. package/dist/esm/utils/http.d.ts +2 -2
  121. package/dist/esm/utils/http.d.ts.map +1 -1
  122. package/dist/esm/utils/index.d.ts +12 -12
  123. package/dist/esm/utils/isEmptyObject.d.ts.map +1 -1
  124. package/dist/esm/utils/sleep.d.ts.map +1 -1
  125. package/dist/esm/utils/timedPromise.d.ts.map +1 -1
  126. package/package.json +4 -4
@@ -0,0 +1,34 @@
1
+ import type { RawHeaders } from './StreamingResponse';
2
+ /**
3
+ * The most redirect hops one streaming request follows. When a chain exceeds the cap, the last
4
+ * redirect response goes to the caller as an ordinary non-200 response. The caller's error
5
+ * handling decides whether to retry.
6
+ */
7
+ export declare const MAX_STREAMING_REDIRECT_HOPS = 5;
8
+ /**
9
+ * The response shape the redirect loop inspects. A Node `IncomingMessage` satisfies it.
10
+ */
11
+ export interface RedirectResponseSource {
12
+ statusCode?: number;
13
+ headers: RawHeaders;
14
+ /**
15
+ * Destroys the stream, so a followed redirect response releases its connection at once. A
16
+ * source without it leaves the skipped body to the socket teardown.
17
+ */
18
+ destroy?(): unknown;
19
+ }
20
+ /**
21
+ * Issues a streaming request and follows up to {@link MAX_STREAMING_REDIRECT_HOPS} hops of
22
+ * `301` and `307` redirects. Each hop calls `doRequest` again with the target URL, so the
23
+ * request carries the same method, body, and headers to each target, the `Authorization`
24
+ * header included. A `302` and every other status return to the caller unfollowed.
25
+ *
26
+ * The loop holds no state across calls. A reconnect starts from the original URL again and
27
+ * re-follows the chain.
28
+ *
29
+ * @param url The URL of the initial request.
30
+ * @param doRequest Issues one request and resolves with its response. The caller builds the
31
+ * options inside it from the given URL, so each hop gets options for its own target.
32
+ */
33
+ export declare function followStreamingRedirects<T extends RedirectResponseSource>(url: string, doRequest: (requestUrl: string) => Promise<T>): Promise<T>;
34
+ //# sourceMappingURL=followRedirects.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"followRedirects.d.ts","sourceRoot":"","sources":["../../../src/internal/fetch/followRedirects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,UAAU,CAAC;IAEpB;;;OAGG;IACH,OAAO,CAAC,IAAI,OAAO,CAAC;CACrB;AAyBD;;;;;;;;;;;;GAYG;AACH,wBAAsB,wBAAwB,CAAC,CAAC,SAAS,sBAAsB,EAC7E,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,GAC5C,OAAO,CAAC,CAAC,CAAC,CAuBZ"}
@@ -1,3 +1,4 @@
1
+ export * from './followRedirects';
1
2
  export * from './StreamingResponse';
2
3
  export * from './toRequestInit';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/internal/fetch/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/internal/fetch/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"createSafeLogger.d.ts","sourceRoot":"","sources":["../../src/logging/createSafeLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,QAAA,MAAM,gBAAgB,YAAa,QAAQ,6BAQ1C,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"createSafeLogger.d.ts","sourceRoot":"","sources":["../../src/logging/createSafeLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,QAAA,MAAM,gBAAgB,GAAI,SAAS,QAAQ,6BAQ1C,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -18,6 +18,6 @@
18
18
  * @param fn The function to be debounced.
19
19
  * @param delayMs Defaults to 5 seconds.
20
20
  */
21
- declare const debounce: <T extends (...args: any[]) => ReturnType<T>>(fn: T, delayMs?: number) => (...args: Parameters<T>) => void;
21
+ declare const debounce: <T extends (...args: any[]) => ReturnType<T>>(fn: T, delayMs?: number) => ((...args: Parameters<T>) => void);
22
22
  export default debounce;
23
23
  //# sourceMappingURL=debounce.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"debounce.d.ts","sourceRoot":"","sources":["../../src/utils/debounce.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,QAAA,MAAM,QAAQ,uBAAwB,GAAG,EAAE,qCAEhC,MAAM,iCACe,IAS/B,CAAC;AAEF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"debounce.d.ts","sourceRoot":"","sources":["../../src/utils/debounce.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,QAAA,MAAM,QAAQ,GAAI,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,UAAU,CAAC,CAAC,CAAC,EAC3D,IAAI,CAAC,EACL,UAAS,MAAa,KACrB,CAAC,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CASnC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -6,6 +6,6 @@
6
6
  * @param obj
7
7
  * @param ignoreKeys
8
8
  */
9
- declare const deepCompact: <T extends object>(obj?: T | undefined, ignoreKeys?: string[]) => T | undefined;
9
+ declare const deepCompact: <T extends object>(obj?: T, ignoreKeys?: string[]) => T | undefined;
10
10
  export default deepCompact;
11
11
  //# sourceMappingURL=deepCompact.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deepCompact.d.ts","sourceRoot":"","sources":["../../src/utils/deepCompact.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,QAAA,MAAM,WAAW,uDAA4C,MAAM,EAAE,kBAWpE,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"deepCompact.d.ts","sourceRoot":"","sources":["../../src/utils/deepCompact.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,QAAA,MAAM,WAAW,GAAI,CAAC,SAAS,MAAM,EAAE,MAAM,CAAC,EAAE,aAAa,MAAM,EAAE,kBAWpE,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/utils/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE3D,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,MAAM,SAAS,GAAG;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,4BAA4B,CAAC,EAAE,MAAM,CAAC;CACvC,CAAC;AAEF,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,IAAI,EACV,IAAI,CAAC,EAAE,eAAe,EACtB,0BAA0B,GAAE,OAAc,EAC1C,mBAAmB,GAAE,YAAY,GAAG,2BAA0C,EAC9E,UAAU,CAAC,EAAE,MAAM,GAClB,SAAS,CAiCX;AAED,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,iBAAiB,EACtB,OAAO,EAAE,MAAM,EACf,YAAY,CAAC,EAAE,MAAM,GACpB,MAAM,CASR;AAED,wBAAgB,WAAW,CAAC,EAAE,MAAM,EAAE,EAAE,iBAAiB,WAExD;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,MAAO,MAAM,YAAY,QAAQ,KAAG,MACa,CAAC"}
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/utils/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE3D,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,MAAM,SAAS,GAAG;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,4BAA4B,CAAC,EAAE,MAAM,CAAC;CACvC,CAAC;AAEF,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,IAAI,EACV,IAAI,CAAC,EAAE,eAAe,EACtB,0BAA0B,GAAE,OAAc,EAC1C,mBAAmB,GAAE,YAAY,GAAG,2BAA0C,EAC9E,UAAU,CAAC,EAAE,MAAM,GAClB,SAAS,CAiCX;AAED,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,iBAAiB,EACtB,OAAO,EAAE,MAAM,EACf,YAAY,CAAC,EAAE,MAAM,GACpB,MAAM,CASR;AAED,wBAAgB,WAAW,CAAC,EAAE,MAAM,EAAE,EAAE,iBAAiB,WAExD;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,GAAI,GAAG,MAAM,EAAE,UAAU,QAAQ,KAAG,MACa,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"isEmptyObject.d.ts","sourceRoot":"","sources":["../../src/utils/isEmptyObject.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,aAAa,QAAS,GAAG,YAAiC,CAAC;AAEjE,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"isEmptyObject.d.ts","sourceRoot":"","sources":["../../src/utils/isEmptyObject.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,aAAa,GAAI,KAAK,GAAG,YAAiC,CAAC;AAEjE,eAAe,aAAa,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sleep.d.ts","sourceRoot":"","sources":["../../src/utils/sleep.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,KAAK,iBAAuB,MAAM,qBAGpC,CAAC;AAEL,eAAe,KAAK,CAAC"}
1
+ {"version":3,"file":"sleep.d.ts","sourceRoot":"","sources":["../../src/utils/sleep.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,KAAK,GAAU,cAAa,MAAa,qBAG3C,CAAC;AAEL,eAAe,KAAK,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"timedPromise.d.ts","sourceRoot":"","sources":["../../src/utils/timedPromise.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,QAAA,MAAM,YAAY,MAAO,MAAM,YAAY,MAAM,kBAM7C,CAAC;AAEL,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"timedPromise.d.ts","sourceRoot":"","sources":["../../src/utils/timedPromise.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,QAAA,MAAM,YAAY,GAAI,GAAG,MAAM,EAAE,UAAU,MAAM,kBAM7C,CAAC;AAEL,eAAe,YAAY,CAAC"}
@@ -1,4 +1,4 @@
1
- import { LDContextCommon } from './api/context/LDContextCommon';
1
+ import { LDContextCommon } from './api/context/LDContextCommon.js';
2
2
  export default class AttributeReference {
3
3
  readonly isValid: boolean;
4
4
  /**
@@ -1,5 +1,5 @@
1
- import type { LDContext, LDContextCommon } from './api';
2
- import AttributeReference from './AttributeReference';
1
+ import type { LDContext, LDContextCommon } from './api/index.js';
2
+ import AttributeReference from './AttributeReference.js';
3
3
  /**
4
4
  * Container for a context/contexts. Because contexts come from external code
5
5
  * they must be thoroughly validated and then formed to comply with
@@ -1,5 +1,5 @@
1
- import AttributeReference from './AttributeReference';
2
- import Context from './Context';
1
+ import AttributeReference from './AttributeReference.js';
2
+ import Context from './Context.js';
3
3
  export default class ContextFilter {
4
4
  private readonly _allAttributesPrivate;
5
5
  private readonly _privateAttributes;
@@ -1,6 +1,6 @@
1
- import { LDMultiKindContext } from './LDMultiKindContext';
2
- import { LDSingleKindContext } from './LDSingleKindContext';
3
- import { LDUser } from './LDUser';
1
+ import { LDMultiKindContext } from './LDMultiKindContext.js';
2
+ import { LDSingleKindContext } from './LDSingleKindContext.js';
3
+ import { LDUser } from './LDUser.js';
4
4
  /**
5
5
  * A LaunchDarkly context object. LaunchDarkly contexts are objects representing users, devices, organizations, and
6
6
  * other entities that feature flags serve different variations to according to your flag targeting rules. These data
@@ -1,4 +1,4 @@
1
- import { LDContextMeta } from './LDContextMeta';
1
+ import { LDContextMeta } from './LDContextMeta.js';
2
2
  /**
3
3
  * Common attributes shared by the various context types.
4
4
  */
@@ -1,4 +1,4 @@
1
- import { LDContextCommon } from './LDContextCommon';
1
+ import { LDContextCommon } from './LDContextCommon.js';
2
2
  /**
3
3
  * A context which represents multiple kinds. Each kind having its own key and attributes.
4
4
  *
@@ -1,4 +1,4 @@
1
- import { LDContextCommon } from './LDContextCommon';
1
+ import { LDContextCommon } from './LDContextCommon.js';
2
2
  /**
3
3
  * A context which represents a single kind.
4
4
  *
@@ -1,7 +1,7 @@
1
- export * from './LDContextCommon';
2
- export * from './LDContextMeta';
3
- export * from './LDMultiKindContext';
4
- export * from './LDSingleKindContext';
5
- export * from './LDUser';
6
- export * from './LDContext';
1
+ export * from './LDContextCommon.js';
2
+ export * from './LDContextMeta.js';
3
+ export * from './LDMultiKindContext.js';
4
+ export * from './LDSingleKindContext.js';
5
+ export * from './LDUser.js';
6
+ export * from './LDContext.js';
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,5 @@
1
- import { LDEvaluationReason } from './LDEvaluationReason';
2
- import { LDFlagValue } from './LDFlagValue';
1
+ import { LDEvaluationReason } from './LDEvaluationReason.js';
2
+ import { LDFlagValue } from './LDFlagValue.js';
3
3
  /**
4
4
  * An object that combines the result of a feature flag evaluation with information about
5
5
  * how it was calculated.
@@ -1,4 +1,4 @@
1
- import { LDFlagValue } from './LDFlagValue';
1
+ import { LDFlagValue } from './LDFlagValue.js';
2
2
  /**
3
3
  * A map of feature flags from their keys to their values.
4
4
  */
@@ -1,5 +1,5 @@
1
- export * from './LDEvaluationDetail';
2
- export * from './LDEvaluationReason';
3
- export * from './LDFlagSet';
4
- export * from './LDFlagValue';
1
+ export * from './LDEvaluationDetail.js';
2
+ export * from './LDEvaluationReason.js';
3
+ export * from './LDFlagSet.js';
4
+ export * from './LDFlagValue.js';
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1,8 +1,8 @@
1
- export * from './context';
2
- export * from './logging';
3
- export * from './data';
4
- export * from './options';
5
- export * from './platform';
6
- export * as subsystem from './subsystem';
7
- export * from './integrations';
1
+ export * from './context/index.js';
2
+ export * from './logging/index.js';
3
+ export * from './data/index.js';
4
+ export * from './options/index.js';
5
+ export * from './platform/index.js';
6
+ export * as subsystem from './subsystem/index.js';
7
+ export * from './integrations/index.js';
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -1,2 +1,2 @@
1
- export * from './plugins';
1
+ export * from './plugins.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,4 @@
1
- import { LDLogLevel } from './LDLogLevel';
1
+ import { LDLogLevel } from './LDLogLevel.js';
2
2
  /**
3
3
  * Configuration for {@link basicLogger}.
4
4
  */
@@ -1,4 +1,4 @@
1
- export * from './BasicLoggerOptions';
2
- export * from './LDLogger';
3
- export * from './LDLogLevel';
1
+ export * from './BasicLoggerOptions.js';
2
+ export * from './LDLogger.js';
3
+ export * from './LDLogLevel.js';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,5 @@
1
- import { LDLogger } from '../logging';
2
- import { Platform } from '../platform';
1
+ import { LDLogger } from '../logging/index.js';
2
+ import { Platform } from '../platform/index.js';
3
3
  /**
4
4
  * Specifies the base service URIs used by SDK components.
5
5
  */
@@ -1,3 +1,3 @@
1
- import { LDClientContext } from './LDClientContext';
1
+ import { LDClientContext } from './LDClientContext.js';
2
2
  export { LDClientContext };
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,4 @@
1
- import type { HttpErrorResponse } from './Requests';
1
+ import type { HttpErrorResponse } from './Requests.js';
2
2
  export type EventName = string;
3
3
  export type EventListener = (event?: {
4
4
  data?: any;
@@ -1,4 +1,4 @@
1
- import type { LDApplication, LDDevice } from './AutoEnv';
1
+ import type { LDApplication, LDDevice } from './AutoEnv.js';
2
2
  /**
3
3
  * Information about the platform of the SDK and the environment it is executing.
4
4
  */
@@ -1,9 +1,9 @@
1
- import { Crypto } from './Crypto';
2
- import { Encoding } from './Encoding';
3
- import { Filesystem } from './Filesystem';
4
- import { Info } from './Info';
5
- import { Requests } from './Requests';
6
- import { Storage } from './Storage';
1
+ import { Crypto } from './Crypto.js';
2
+ import { Encoding } from './Encoding.js';
3
+ import { Filesystem } from './Filesystem.js';
4
+ import { Info } from './Info.js';
5
+ import { Requests } from './Requests.js';
6
+ import { Storage } from './Storage.js';
7
7
  export interface Platform {
8
8
  /**
9
9
  * The interface for performing encoding operations.
@@ -1,4 +1,4 @@
1
- import type { EventSource, EventSourceInitDict } from './EventSource';
1
+ import type { EventSource, EventSourceInitDict } from './EventSource.js';
2
2
  /**
3
3
  * Interface for headers that are part of a fetch response.
4
4
  */
@@ -1,10 +1,10 @@
1
- export * from './AutoEnv';
2
- export * from './Crypto';
3
- export * from './Encoding';
4
- export * from './EventSource';
5
- export * from './Filesystem';
6
- export * from './Info';
7
- export * from './Platform';
8
- export * from './Requests';
9
- export * from './Storage';
1
+ export * from './AutoEnv.js';
2
+ export * from './Crypto.js';
3
+ export * from './Encoding.js';
4
+ export * from './EventSource.js';
5
+ export * from './Filesystem.js';
6
+ export * from './Info.js';
7
+ export * from './Platform.js';
8
+ export * from './Requests.js';
9
+ export * from './Storage.js';
10
10
  //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,4 @@
1
- import { DataSourceState } from './DataSource';
1
+ import { DataSourceState } from './DataSource.js';
2
2
  /**
3
3
  * Handler that connects the current {@link DataSource} to the {@link CompositeDataSource}. A single
4
4
  * {@link CallbackHandler} should only be given to one {@link DataSource}. Use {@link disable()} to
@@ -1,2 +1,2 @@
1
- export { DataSource, DataSourceState, LDDataSourceFactory } from './DataSource';
1
+ export { DataSource, DataSourceState, LDDataSourceFactory } from './DataSource.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,4 @@
1
- import Context from '../../Context';
1
+ import Context from '../../Context.js';
2
2
  /**
3
3
  * Interface for a strategy for removing duplicate contexts from the event stream.
4
4
  * Client side event processors do not do this de-duplication, so the implementation
@@ -1,4 +1,4 @@
1
- import InputEvent from '../../internal/events/InputEvent';
1
+ import InputEvent from '../../internal/events/InputEvent.js';
2
2
  export default interface LDEventProcessor {
3
3
  close(): void;
4
4
  flush(): Promise<void>;
@@ -1,7 +1,7 @@
1
- import { DataSource, DataSourceState, LDDataSourceFactory } from './DataSystem';
2
- import LDContextDeduplicator from './LDContextDeduplicator';
3
- import LDEventProcessor from './LDEventProcessor';
4
- import LDEventSender, { LDDeliveryStatus, LDEventSenderResult, LDEventType } from './LDEventSender';
5
- import { LDStreamProcessor } from './LDStreamProcessor';
1
+ import { DataSource, DataSourceState, LDDataSourceFactory } from './DataSystem/index.js';
2
+ import LDContextDeduplicator from './LDContextDeduplicator.js';
3
+ import LDEventProcessor from './LDEventProcessor.js';
4
+ import LDEventSender, { LDDeliveryStatus, LDEventSenderResult, LDEventType } from './LDEventSender.js';
5
+ import { LDStreamProcessor } from './LDStreamProcessor.js';
6
6
  export { DataSource, DataSourceState, LDDataSourceFactory, LDEventProcessor, LDContextDeduplicator, LDEventSender, LDDeliveryStatus, LDEventType, LDEventSenderResult, LDStreamProcessor, };
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1,6 +1,6 @@
1
- import { LDLogger } from '../api/logging';
2
- import { DataSource, DataSourceState, LDDataSourceFactory } from '../api/subsystem/DataSystem/DataSource';
3
- import { Backoff } from './Backoff';
1
+ import { LDLogger } from '../api/logging/index.js';
2
+ import { DataSource, DataSourceState, LDDataSourceFactory } from '../api/subsystem/DataSystem/DataSource.js';
3
+ import { Backoff } from './Backoff.js';
4
4
  /**
5
5
  * Represents a transition between data sources.
6
6
  */
@@ -1 +1 @@
1
- {"version":3,"file":"CompositeDataSource.d.ts","sourceRoot":"","sources":["../../src/datasource/CompositeDataSource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EACL,UAAU,EACV,eAAe,EACf,mBAAmB,EACpB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,OAAO,EAAkB,MAAM,WAAW,CAAC;AAOpD;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,cAAc,GAAG,UAAU,GAAG,SAAS,GAAG,MAAM,CAAC;AAE1E;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;KAChC,CAAC,IAAI,eAAe,CAAC,CAAC,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,UAAU,CAAA;KAAE;CACxE,CAAC;AAOF;;;GAGG;AACH,qBAAa,mBAAoB,YAAW,UAAU;IA8BlD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;IACzB,OAAO,CAAC,QAAQ,CAAC,qBAAqB;IAUtC,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAtC3B,OAAO,CAAC,gBAAgB,CAAU;IAClC,OAAO,CAAC,cAAc,CAAsC;IAC5D,OAAO,CAAC,cAAc,CAAsC;IAC5D,OAAO,CAAC,kBAAkB,CAAsC;IAKhE,OAAO,CAAC,oBAAoB,CAAkB;IAE9C,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,0BAA0B,CAA6B;IAC/D,OAAO,CAAC,0BAA0B,CAAC,CAAqC;IACxE,OAAO,CAAC,aAAa,CAAsB;IAE3C;;;;;;;OAOG;gBAED,YAAY,EAAE,mBAAmB,EAAE,EACnC,aAAa,EAAE,mBAAmB,EAAE,EACpC,iBAAiB,EAAE,mBAAmB,EAAE,EACvB,OAAO,CAAC,sBAAU,EAClB,qBAAqB,GAAE,oBASvC,EACgB,QAAQ,GAAE,OAAyC;IAWhE,KAAK,CACT,YAAY,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,KAAK,IAAI,EACjD,cAAc,EAAE,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,CAAC,EAAE,GAAG,KAAK,IAAI,EAC5D,cAAc,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,GACxC,OAAO,CAAC,IAAI,CAAC;IAuMV,IAAI;IAMV,OAAO,CAAC,MAAM;IAad;;;;OAIG;IACH,OAAO,CAAC,eAAe;IA0DvB;;;OAGG;IACH,OAAO,CAAC,0BAA0B;IAclC,OAAO,CAAC,iBAAiB,CAcvB;IAEF,OAAO,CAAC,mBAAmB;IAQ3B;;;;;;OAMG;IACH,OAAO,CAAC,gCAAgC;CAgCzC"}
1
+ {"version":3,"file":"CompositeDataSource.d.ts","sourceRoot":"","sources":["../../src/datasource/CompositeDataSource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EACL,UAAU,EACV,eAAe,EACf,mBAAmB,EACpB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,OAAO,EAAkB,MAAM,WAAW,CAAC;AAOpD;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,cAAc,GAAG,UAAU,GAAG,SAAS,GAAG,MAAM,CAAC;AAE1E;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;KAChC,CAAC,IAAI,eAAe,CAAC,CAAC,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,UAAU,CAAA;KAAE;CACxE,CAAC;AAOF;;;GAGG;AACH,qBAAa,mBAAoB,YAAW,UAAU;IA8BlD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;IACzB,OAAO,CAAC,QAAQ,CAAC,qBAAqB;IAUtC,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAtC3B,OAAO,CAAC,gBAAgB,CAAU;IAClC,OAAO,CAAC,cAAc,CAAsC;IAC5D,OAAO,CAAC,cAAc,CAAsC;IAC5D,OAAO,CAAC,kBAAkB,CAAsC;IAKhE,OAAO,CAAC,oBAAoB,CAAkB;IAE9C,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,0BAA0B,CAA6B;IAC/D,OAAO,CAAC,0BAA0B,CAAC,CAAqC;IACxE,OAAO,CAAC,aAAa,CAAsB;IAE3C;;;;;;;OAOG;gBAED,YAAY,EAAE,mBAAmB,EAAE,EACnC,aAAa,EAAE,mBAAmB,EAAE,EACpC,iBAAiB,EAAE,mBAAmB,EAAE,EACvB,OAAO,CAAC,EAAE,QAAQ,YAAA,EAClB,qBAAqB,GAAE,oBASvC,EACgB,QAAQ,GAAE,OAAyC;IAWhE,KAAK,CACT,YAAY,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,KAAK,IAAI,EACjD,cAAc,EAAE,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,CAAC,EAAE,GAAG,KAAK,IAAI,EAC5D,cAAc,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,GACxC,OAAO,CAAC,IAAI,CAAC;IAuMV,IAAI;IAMV,OAAO,CAAC,MAAM;IAad;;;;OAIG;IACH,OAAO,CAAC,eAAe;IA0DvB;;;OAGG;IACH,OAAO,CAAC,0BAA0B;IAclC,OAAO,CAAC,iBAAiB,CAcvB;IAEF,OAAO,CAAC,mBAAmB;IAQ3B;;;;;;OAMG;IACH,OAAO,CAAC,gCAAgC;CAgCzC"}
@@ -1,4 +1,4 @@
1
- import { DataSourceErrorKind } from './DataSourceErrorKinds';
1
+ import { DataSourceErrorKind } from './DataSourceErrorKinds.js';
2
2
  export declare class LDFileDataSourceError extends Error {
3
3
  constructor(message: string);
4
4
  }
@@ -1,7 +1,7 @@
1
- import { Backoff, DefaultBackoff } from './Backoff';
2
- import { CompositeDataSource } from './CompositeDataSource';
3
- import { DataSourceErrorKind } from './DataSourceErrorKinds';
4
- import { LDFileDataSourceError, LDFlagDeliveryFallbackError, LDPollingError, LDStreamingError, StreamingErrorHandler } from './errors';
5
- import { createAfterConsecutiveSuccesses, createAfterHealthyFor, createRetryState, forPolling, forStreaming, ResetPolicy, RetryState, RetryStateConfig } from './retry';
1
+ import { Backoff, DefaultBackoff } from './Backoff.js';
2
+ import { CompositeDataSource } from './CompositeDataSource.js';
3
+ import { DataSourceErrorKind } from './DataSourceErrorKinds.js';
4
+ import { LDFileDataSourceError, LDFlagDeliveryFallbackError, LDPollingError, LDStreamingError, StreamingErrorHandler } from './errors.js';
5
+ import { createAfterConsecutiveSuccesses, createAfterHealthyFor, createRetryState, forPolling, forStreaming, ResetPolicy, RetryState, RetryStateConfig } from './retry/index.js';
6
6
  export { Backoff, CompositeDataSource, createAfterConsecutiveSuccesses, createAfterHealthyFor, createRetryState, DefaultBackoff, DataSourceErrorKind, forPolling, forStreaming, LDFileDataSourceError, LDFlagDeliveryFallbackError, LDPollingError, LDStreamingError, ResetPolicy, RetryState, RetryStateConfig, StreamingErrorHandler, };
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1,6 +1,6 @@
1
- import { LDLogger } from '../../api/logging/LDLogger';
2
- import { FailureKind } from '../../errors';
3
- import { ResetPolicy } from './ResetPolicy';
1
+ import { LDLogger } from '../../api/logging/LDLogger.js';
2
+ import { FailureKind } from '../../errors.js';
3
+ import { ResetPolicy } from './ResetPolicy.js';
4
4
  /**
5
5
  * Configuration for a {@link RetryState}.
6
6
  *
@@ -1,4 +1,4 @@
1
- import { createAfterConsecutiveSuccesses, createAfterHealthyFor, ResetPolicy } from './ResetPolicy';
2
- import { createRetryState, forPolling, forStreaming, RetryState, RetryStateConfig } from './RetryState';
1
+ import { createAfterConsecutiveSuccesses, createAfterHealthyFor, ResetPolicy } from './ResetPolicy.js';
2
+ import { createRetryState, forPolling, forStreaming, RetryState, RetryStateConfig } from './RetryState.js';
3
3
  export { createAfterConsecutiveSuccesses, createAfterHealthyFor, createRetryState, forPolling, forStreaming, ResetPolicy, RetryState, RetryStateConfig, };
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1,13 +1,13 @@
1
- import AttributeReference from './AttributeReference';
2
- import Context from './Context';
3
- import ContextFilter from './ContextFilter';
4
- import { Backoff, CompositeDataSource, createAfterConsecutiveSuccesses, createAfterHealthyFor, createRetryState, DataSourceErrorKind, DefaultBackoff, forPolling, forStreaming, LDFileDataSourceError, LDFlagDeliveryFallbackError, LDPollingError, LDStreamingError, ResetPolicy, RetryState, RetryStateConfig, StreamingErrorHandler } from './datasource';
5
- export * from './api';
6
- export * from './validators';
7
- export * from './logging';
8
- export * from './options';
9
- export * from './utils';
10
- export * as internal from './internal';
11
- export * from './errors';
1
+ import AttributeReference from './AttributeReference.js';
2
+ import Context from './Context.js';
3
+ import ContextFilter from './ContextFilter.js';
4
+ import { Backoff, CompositeDataSource, createAfterConsecutiveSuccesses, createAfterHealthyFor, createRetryState, DataSourceErrorKind, DefaultBackoff, forPolling, forStreaming, LDFileDataSourceError, LDFlagDeliveryFallbackError, LDPollingError, LDStreamingError, ResetPolicy, RetryState, RetryStateConfig, StreamingErrorHandler } from './datasource/index.js';
5
+ export * from './api/index.js';
6
+ export * from './validators.js';
7
+ export * from './logging/index.js';
8
+ export * from './options/index.js';
9
+ export * from './utils/index.js';
10
+ export * as internal from './internal/index.js';
11
+ export * from './errors.js';
12
12
  export { AttributeReference, Context, ContextFilter, CompositeDataSource, DataSourceErrorKind, Backoff, DefaultBackoff, LDPollingError, LDStreamingError, StreamingErrorHandler, LDFileDataSourceError, LDFlagDeliveryFallbackError, createAfterConsecutiveSuccesses, createAfterHealthyFor, createRetryState, forPolling, forStreaming, ResetPolicy, RetryState, RetryStateConfig, };
13
13
  //# sourceMappingURL=index.d.ts.map
@@ -2647,6 +2647,12 @@ class ClientMessages {
2647
2647
  }
2648
2648
  ClientMessages.MissingContextKeyNoEvent = 'Context was unspecified or had no key; event will not be sent';
2649
2649
 
2650
+ /**
2651
+ * The Fetch Standard caps the total body size of in-flight keepalive requests at 64 KiB. The
2652
+ * body length is in UTF-16 code units, and each code unit is at least one byte, so a body over
2653
+ * this length is always over the cap. A shorter body with non-ASCII text can still be over it.
2654
+ */
2655
+ const KEEPALIVE_BODY_LIMIT = 64 * 1024;
2650
2656
  class EventSender {
2651
2657
  constructor(clientContext, baseHeaders) {
2652
2658
  const { basicConfiguration, platform } = clientContext;
@@ -2672,14 +2678,17 @@ class EventSender {
2672
2678
  }
2673
2679
  let error;
2674
2680
  try {
2681
+ const body = JSON.stringify(events);
2675
2682
  const { status, headers: resHeaders } = await this._requests.fetch(uri, {
2676
2683
  headers,
2677
- body: JSON.stringify(events),
2684
+ body,
2678
2685
  compressBodyIfPossible: true,
2679
2686
  method: 'POST',
2680
2687
  // When sending events from browser environments the request should be completed even
2681
- // if the user is navigating away from the page.
2682
- keepalive: true,
2688
+ // if the user is navigating away from the page. A browser rejects a keepalive request
2689
+ // with a large body, so a large body is sent without it. The retry is the last attempt,
2690
+ // so it never asks for keepalive. This lets a body the length check missed get through.
2691
+ keepalive: canRetry && body.length <= KEEPALIVE_BODY_LIMIT,
2683
2692
  });
2684
2693
  const serverDate = Date.parse(resHeaders.get('date') || '');
2685
2694
  if (serverDate) {
@@ -3398,6 +3407,11 @@ function createProtocolHandler(objProcessors, logger) {
3398
3407
  let protocolState = 'inactive';
3399
3408
  let tempType = 'partial';
3400
3409
  let tempUpdates = [];
3410
+ // Only kinds with a registered processor are supported. An own-property check keeps
3411
+ // kinds such as 'constructor' from resolving to inherited members.
3412
+ function isSupportedKind(kind) {
3413
+ return Object.prototype.hasOwnProperty.call(objProcessors, kind);
3414
+ }
3401
3415
  function processObj(kind, jsonObj) {
3402
3416
  return objProcessors[kind]?.(jsonObj);
3403
3417
  }
@@ -3468,6 +3482,12 @@ function createProtocolHandler(objProcessors, logger) {
3468
3482
  logger?.warn(`Ignoring put-object with missing fields: kind=${data.kind}, key=${data.key}, version=${data.version}`);
3469
3483
  return ACTION_NONE;
3470
3484
  }
3485
+ // Objects of unsupported kinds are dropped silently so the protocol can add new kinds
3486
+ // without disrupting older SDKs.
3487
+ if (!isSupportedKind(data.kind)) {
3488
+ logger?.debug(`Ignoring put-object with unsupported kind: '${data.kind}'`);
3489
+ return ACTION_NONE;
3490
+ }
3471
3491
  const obj = processObj(data.kind, data.object);
3472
3492
  if (!obj) {
3473
3493
  logger?.warn(`Unable to process object for kind: '${data.kind}'`);
@@ -3490,6 +3510,10 @@ function createProtocolHandler(objProcessors, logger) {
3490
3510
  logger?.warn(`Ignoring delete-object with missing fields: kind=${data.kind}, key=${data.key}, version=${data.version}`);
3491
3511
  return ACTION_NONE;
3492
3512
  }
3513
+ if (!isSupportedKind(data.kind)) {
3514
+ logger?.debug(`Ignoring delete-object with unsupported kind: '${data.kind}'`);
3515
+ return ACTION_NONE;
3516
+ }
3493
3517
  tempUpdates.push({
3494
3518
  kind: data.kind,
3495
3519
  key: data.key,
@@ -3672,6 +3696,74 @@ class PayloadStreamReader {
3672
3696
  }
3673
3697
  }
3674
3698
 
3699
+ /**
3700
+ * The most redirect hops one streaming request follows. When a chain exceeds the cap, the last
3701
+ * redirect response goes to the caller as an ordinary non-200 response. The caller's error
3702
+ * handling decides whether to retry.
3703
+ */
3704
+ const MAX_STREAMING_REDIRECT_HOPS = 5;
3705
+ /**
3706
+ * Resolves the target of a redirect response. The target can be relative, and it resolves
3707
+ * against the URL of the redirected request. Only an `http:` or `https:` target can carry
3708
+ * the stream; any other scheme, a missing or empty `Location`, and an unparsable value all
3709
+ * resolve to `undefined`, and the redirect response then goes to the caller unfollowed.
3710
+ */
3711
+ function redirectTarget(headers, baseUrl) {
3712
+ const raw = headers.location;
3713
+ const value = Array.isArray(raw) ? raw[0] : raw;
3714
+ if (typeof value !== 'string' || value === '') {
3715
+ return undefined;
3716
+ }
3717
+ try {
3718
+ const resolved = new URL(value, baseUrl);
3719
+ if (resolved.protocol !== 'http:' && resolved.protocol !== 'https:') {
3720
+ return undefined;
3721
+ }
3722
+ return resolved.href;
3723
+ }
3724
+ catch {
3725
+ return undefined;
3726
+ }
3727
+ }
3728
+ /**
3729
+ * Issues a streaming request and follows up to {@link MAX_STREAMING_REDIRECT_HOPS} hops of
3730
+ * `301` and `307` redirects. Each hop calls `doRequest` again with the target URL, so the
3731
+ * request carries the same method, body, and headers to each target, the `Authorization`
3732
+ * header included. A `302` and every other status return to the caller unfollowed.
3733
+ *
3734
+ * The loop holds no state across calls. A reconnect starts from the original URL again and
3735
+ * re-follows the chain.
3736
+ *
3737
+ * @param url The URL of the initial request.
3738
+ * @param doRequest Issues one request and resolves with its response. The caller builds the
3739
+ * options inside it from the given URL, so each hop gets options for its own target.
3740
+ */
3741
+ async function followStreamingRedirects(url, doRequest) {
3742
+ let currentUrl = url;
3743
+ let res = await doRequest(currentUrl);
3744
+ let hops = 0;
3745
+ while ((res.statusCode === 301 || res.statusCode === 307) && hops < MAX_STREAMING_REDIRECT_HOPS) {
3746
+ const target = redirectTarget(res.headers, currentUrl);
3747
+ if (target === undefined) {
3748
+ return res;
3749
+ }
3750
+ hops += 1;
3751
+ // The destroy releases the skipped redirect response and its connection at once, so a
3752
+ // redirect body that never ends cannot hold a socket for the life of the attempt.
3753
+ try {
3754
+ res.destroy?.();
3755
+ }
3756
+ catch {
3757
+ // A throwing destroy has nothing left to release.
3758
+ }
3759
+ currentUrl = target;
3760
+ // The hops are sequential. The next request cannot start until this response arrives.
3761
+ // eslint-disable-next-line no-await-in-loop
3762
+ res = await doRequest(currentUrl);
3763
+ }
3764
+ return res;
3765
+ }
3766
+
3675
3767
  /**
3676
3768
  * Wraps the raw headers in the fetch `Headers` shape. Lookups are case-insensitive.
3677
3769
  * Multi-value headers are joined with ", ", names that differ only by case merge into one
@@ -3872,12 +3964,14 @@ var index = /*#__PURE__*/Object.freeze({
3872
3964
  InputCustomEvent: InputCustomEvent,
3873
3965
  InputEvalEvent: InputEvalEvent,
3874
3966
  InputIdentifyEvent: InputIdentifyEvent,
3967
+ MAX_STREAMING_REDIRECT_HOPS: MAX_STREAMING_REDIRECT_HOPS,
3875
3968
  NullEventProcessor: NullEventProcessor,
3876
3969
  PayloadProcessor: PayloadProcessor,
3877
3970
  PayloadStreamReader: PayloadStreamReader,
3878
3971
  canonicalize: canonicalize,
3879
3972
  createProtocolHandler: createProtocolHandler,
3880
3973
  createStreamingResponse: createStreamingResponse,
3974
+ followStreamingRedirects: followStreamingRedirects,
3881
3975
  initMetadataFromHeaders: initMetadataFromHeaders,
3882
3976
  isLegacyUser: isLegacyUser,
3883
3977
  isMultiKind: isMultiKind,