From 537be9c54bd0ecbca2db04e4afd92988071331c5 Mon Sep 17 00:00:00 2001 From: Corentin Ardeois Date: Tue, 4 Jul 2017 13:32:12 -0400 Subject: [PATCH 1/2] feat: remove `@synhaptein` fork from falcor-http-datasource This was used to have dynamic headers, but this could be handled by client directly. If you want dynamic headers, you could have an object with dynamic properties. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty for more details BREAKING CHANGE: `dynamicHeaders` is not supported anymore, use `headers` config instead --- lib/falcor-http-ws-datasource.js | 15 +++++---------- package.json | 2 +- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/falcor-http-ws-datasource.js b/lib/falcor-http-ws-datasource.js index ad49943..dd621f4 100644 --- a/lib/falcor-http-ws-datasource.js +++ b/lib/falcor-http-ws-datasource.js @@ -1,5 +1,5 @@ import SocketIoClient from 'socket.io-client'; -import FalcorHttpDataSource from '@synhaptein/falcor-http-datasource'; +import FalcorHttpDataSource from 'falcor-http-datasource'; import Uuid from 'uuid'; import DelayedFunction from './delayed-function'; import Q from 'q'; @@ -51,11 +51,6 @@ class FalcorHttpPullWebSocketPushDataSource extends FalcorHttpDataSource { config.headers[config.tabIdLabel || 'X-TabId'] = tabId; - if (!config.bearerToken && config.headers['Authorization']) { - let tokens = config.headers.Authorization.split(' '); - config.bearerToken = tokens[1]; - } - let socket = null; if (pushUrl && pushUrl.length > 0) { let wsUrlPath = pushUrl.match(/(ws+:\/\/[A-Za-z0-9\-\.]*:?[0-9]*)(\/?.*)/); @@ -75,9 +70,9 @@ class FalcorHttpPullWebSocketPushDataSource extends FalcorHttpDataSource { this.requestWatcher = new DelayedFunction(200); // Delay maxium between 2 falcor requests } - _readBearerTokenFromDynamicHeaders() { - if (this.config.dynamicHeaders) { - let tokens = this.config.dynamicHeaders ? this.config.dynamicHeaders()['Authorization'].split(' ') : null; + _readBearerTokenFromHeaders() { + if (!this.config.bearerToken && this.config.headers.Authorization) { + let tokens = this.config.headers.Authorization.split(' '); this.config.bearerToken = tokens[1]; } @@ -96,7 +91,7 @@ class FalcorHttpPullWebSocketPushDataSource extends FalcorHttpDataSource { this.socket = new SocketIoClient(this.pushUrl, this.config); this.socket.on('connect', () => { - this.socket.emit('authorization', {bearerToken: this._readBearerTokenFromDynamicHeaders(), tabId: this.tabId}); + this.socket.emit('authorization', {bearerToken: this._readBearerTokenFromHeaders(), tabId: this.tabId}); }); if (this.callback) { diff --git a/package.json b/package.json index 29358b6..658acd2 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "" ], "dependencies": { - "@synhaptein/falcor-http-datasource": "0.1.6", + "falcor-http-datasource": "0.1.3", "q": "1.4.1", "socket.io-client": "1.5.0", "uuid": "2.0.1" From bd0add2c6e3a7cf3a97d9ac04b7ac7fac744b93a Mon Sep 17 00:00:00 2001 From: Corentin Ardeois Date: Tue, 1 Aug 2017 15:16:36 -0400 Subject: [PATCH 2/2] chore: bump to major version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 658acd2..edccaa9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "falcor-http-ws-datasource", - "version": "0.2.2", + "version": "1.0.0", "description": "Falcor HTTP and WebSocket datasource", "homepage": "", "author": {