From 86999412f0dae93c329500059f624aaa91fbc419 Mon Sep 17 00:00:00 2001 From: blagoev Date: Mon, 14 Aug 2017 16:05:52 +0300 Subject: [PATCH] Depreciate setAccessToken rename setAccessToken to setFeatureToken expose both functions while setAccessToken is depreciated Trim token argument string --- lib/extensions.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/extensions.js b/lib/extensions.js index 6d08f1df..07b99453 100644 --- a/lib/extensions.js +++ b/lib/extensions.js @@ -104,6 +104,19 @@ module.exports = function(realmConstructor) { setConstructorOnPrototype(realmConstructor.Sync.User); setConstructorOnPrototype(realmConstructor.Sync.Session); + + if (realmConstructor.Sync._setFeatureToken) { + realmConstructor.Sync.setFeatureToken = function(featureToken) { + if (typeof featureToken !== 'string' || !featureToken instanceof String) { + throw new Error("featureToken should be a string"); + } + + realmConstructor.Sync._setFeatureToken(featureToken.trim()); + } + + //enable depreciated setAccessToken + realmConstructor.Sync.setAccessToken = realmConstructor.Sync.setFeatureToken; + } } // TODO: Remove this now useless object.