@splitsoftware/splitio-commons 1.17.0-rc.4 → 1.17.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.
|
@@ -63,14 +63,16 @@ var SSEClient = /** @class */ (function () {
|
|
|
63
63
|
return encodeURIComponent(params + channel);
|
|
64
64
|
}).join(',');
|
|
65
65
|
var url = this.settings.urls.streaming + "/sse?channels=" + channelsQueryParam + "&accessToken=" + authToken.token + "&v=" + ABLY_API_VERSION + "&heartbeats=true"; // same results using `&heartbeats=false`
|
|
66
|
-
|
|
67
|
-
var useHeaders = !this.settings.core.key || ((_a = this.settings.sync.requestOptions) === null || _a === void 0 ? void 0 : _a.getHeaderOverrides);
|
|
66
|
+
var isServerSide = !this.settings.core.key;
|
|
68
67
|
this.connection = new this.eventSource(
|
|
69
|
-
// For client-side SDKs,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
68
|
+
// For client-side SDKs, metadata is passed as query param to avoid CORS issues and because native EventSource implementations in browsers do not support headers
|
|
69
|
+
isServerSide ? url : url + ("&SplitSDKVersion=" + this.headers.SplitSDKVersion + "&SplitSDKClientKey=" + this.headers.SplitSDKClientKey),
|
|
70
|
+
// For server-side SDKs, metadata is passed via headers
|
|
71
|
+
(0, objectAssign_1.objectAssign)(isServerSide ?
|
|
72
|
+
{ headers: (0, decorateHeaders_1.decorateHeaders)(this.settings, this.headers) } :
|
|
73
|
+
((_a = this.settings.sync.requestOptions) === null || _a === void 0 ? void 0 : _a.getHeaderOverrides) ?
|
|
74
|
+
{ headers: (0, decorateHeaders_1.decorateHeaders)(this.settings, {}) } : // User must provide a window.EventSource polyfill that supports headers
|
|
75
|
+
{}, this.options));
|
|
74
76
|
if (this.handler) { // no need to check if SSEClient is used only by PushManager
|
|
75
77
|
this.connection.addEventListener('open', this.handler.handleOpen);
|
|
76
78
|
this.connection.addEventListener('message', this.handler.handleMessage);
|
|
@@ -60,14 +60,16 @@ var SSEClient = /** @class */ (function () {
|
|
|
60
60
|
return encodeURIComponent(params + channel);
|
|
61
61
|
}).join(',');
|
|
62
62
|
var url = this.settings.urls.streaming + "/sse?channels=" + channelsQueryParam + "&accessToken=" + authToken.token + "&v=" + ABLY_API_VERSION + "&heartbeats=true"; // same results using `&heartbeats=false`
|
|
63
|
-
|
|
64
|
-
var useHeaders = !this.settings.core.key || ((_a = this.settings.sync.requestOptions) === null || _a === void 0 ? void 0 : _a.getHeaderOverrides);
|
|
63
|
+
var isServerSide = !this.settings.core.key;
|
|
65
64
|
this.connection = new this.eventSource(
|
|
66
|
-
// For client-side SDKs,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
// For client-side SDKs, metadata is passed as query param to avoid CORS issues and because native EventSource implementations in browsers do not support headers
|
|
66
|
+
isServerSide ? url : url + ("&SplitSDKVersion=" + this.headers.SplitSDKVersion + "&SplitSDKClientKey=" + this.headers.SplitSDKClientKey),
|
|
67
|
+
// For server-side SDKs, metadata is passed via headers
|
|
68
|
+
objectAssign(isServerSide ?
|
|
69
|
+
{ headers: decorateHeaders(this.settings, this.headers) } :
|
|
70
|
+
((_a = this.settings.sync.requestOptions) === null || _a === void 0 ? void 0 : _a.getHeaderOverrides) ?
|
|
71
|
+
{ headers: decorateHeaders(this.settings, {}) } : // User must provide a window.EventSource polyfill that supports headers
|
|
72
|
+
{}, this.options));
|
|
71
73
|
if (this.handler) { // no need to check if SSEClient is used only by PushManager
|
|
72
74
|
this.connection.addEventListener('open', this.handler.handleOpen);
|
|
73
75
|
this.connection.addEventListener('message', this.handler.handleMessage);
|
package/package.json
CHANGED
|
@@ -78,15 +78,20 @@ export class SSEClient implements ISSEClient {
|
|
|
78
78
|
}
|
|
79
79
|
).join(',');
|
|
80
80
|
const url = `${this.settings.urls.streaming}/sse?channels=${channelsQueryParam}&accessToken=${authToken.token}&v=${ABLY_API_VERSION}&heartbeats=true`; // same results using `&heartbeats=false`
|
|
81
|
-
|
|
82
|
-
const useHeaders = !this.settings.core.key || this.settings.sync.requestOptions?.getHeaderOverrides;
|
|
81
|
+
const isServerSide = !this.settings.core.key;
|
|
83
82
|
|
|
84
83
|
this.connection = new this.eventSource!(
|
|
85
|
-
// For client-side SDKs,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
84
|
+
// For client-side SDKs, metadata is passed as query param to avoid CORS issues and because native EventSource implementations in browsers do not support headers
|
|
85
|
+
isServerSide ? url : url + `&SplitSDKVersion=${this.headers.SplitSDKVersion}&SplitSDKClientKey=${this.headers.SplitSDKClientKey}`,
|
|
86
|
+
// For server-side SDKs, metadata is passed via headers
|
|
87
|
+
objectAssign(
|
|
88
|
+
isServerSide ?
|
|
89
|
+
{ headers: decorateHeaders(this.settings, this.headers) } :
|
|
90
|
+
this.settings.sync.requestOptions?.getHeaderOverrides ?
|
|
91
|
+
{ headers: decorateHeaders(this.settings, {}) } : // User must provide a window.EventSource polyfill that supports headers
|
|
92
|
+
{},
|
|
93
|
+
this.options
|
|
94
|
+
)
|
|
90
95
|
);
|
|
91
96
|
|
|
92
97
|
if (this.handler) { // no need to check if SSEClient is used only by PushManager
|