From 5d05e92bdff9da2d67cf57ab846047f7e73418c8 Mon Sep 17 00:00:00 2001 From: Mahrukh Date: Mon, 25 Oct 2021 16:26:13 +0500 Subject: [PATCH 1/3] Added warning when public key is used --- src/index.js | 7 +++++++ src/messages.js | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 810df60..eb57d43 100644 --- a/src/index.js +++ b/src/index.js @@ -320,6 +320,13 @@ export function initialize(clientSdkKey, flagKeys, user, specifiedOptions, platf console.warn("[UL] Disabling local storage in production is not recommended. Please enable it. For more information see: https://docs.unlaunch.io/docs/sdks/javascript-library#client-configuration") } + const isPublicSdkKey = clientSdkKey.split('-')[1] == 'public' ? true : false + if(!isPublicSdkKey){ + console.warn("To obtain the API key, please sign in to the Unlaunch Console at https://app.unlaunch.io" + +". Then on the right sidebar, click on 'Settings'. Then from the 'Projects' tab. Copy the 'PUBLIC KEY' for the " + +"environment you want to connect to, and provide it to this SDK. For more information, visit: https://docs.unlaunch.io/docs/sdks/sdk-keys") + } + ident.setUser(realUser); if (useLocalStorage) { console.log("finishInitWithLocalStorage"); diff --git a/src/messages.js b/src/messages.js index 720b469..5791f17 100644 --- a/src/messages.js +++ b/src/messages.js @@ -14,7 +14,7 @@ export const clientInitialized = function() { return 'Unlaunch client initialized'; }; -const invalidSdkKeyHelpMsg = `To obtain the SDK key for your project, please sign in to the Unlaunch Console at https://app.unlaunch.io Then on the right sidebar, click on 'Settings'. From the 'Projects' tab, Copy the 'Browser / Public Key' for the environment you want to connect with, and provide it to this SDK. For more information, see this: https://docs.unlaunch.io/docs/sdks/sdk-keys`; +const invalidSdkKeyHelpMsg = "To obtain the API key, please sign in to the Unlaunch Console at https://app.unlaunch.io. Then on the right sidebar, click on 'Settings'. Then from the 'Projects' tab. Copy the 'PUBLIC KEY' for the environment you want to connect to, and provide it to this SDK. For more information, visit: https://docs.unlaunch.io/docs/sdks/sdk-keys" const docLink = "Read more at https://docs.unlaunch.io/docs/sdks/javascript-library" From e0e4d1418aa35edfec4e4e7b8dd31452fa2cfeb6 Mon Sep 17 00:00:00 2001 From: Mahrukh Date: Tue, 26 Oct 2021 22:27:08 +0500 Subject: [PATCH 2/3] message change --- src/index.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index eb57d43..73b5a1c 100644 --- a/src/index.js +++ b/src/index.js @@ -320,9 +320,8 @@ export function initialize(clientSdkKey, flagKeys, user, specifiedOptions, platf console.warn("[UL] Disabling local storage in production is not recommended. Please enable it. For more information see: https://docs.unlaunch.io/docs/sdks/javascript-library#client-configuration") } - const isPublicSdkKey = clientSdkKey.split('-')[1] == 'public' ? true : false - if(!isPublicSdkKey){ - console.warn("To obtain the API key, please sign in to the Unlaunch Console at https://app.unlaunch.io" + if(clientSdkKey.split('-')[1] !== 'public'){ + console.warn("You're using NOT using public key to connect to Unlaunch. If your application is client-side, not using public key can compromise security. To obtain the public API key, please sign in the Unlaunch Console at https://app.unlaunch.io" +". Then on the right sidebar, click on 'Settings'. Then from the 'Projects' tab. Copy the 'PUBLIC KEY' for the " +"environment you want to connect to, and provide it to this SDK. For more information, visit: https://docs.unlaunch.io/docs/sdks/sdk-keys") } From aa0ab6c10311b5a1feaeb62667587482481a8aea Mon Sep 17 00:00:00 2001 From: Mahrukh Date: Fri, 29 Oct 2021 08:42:38 +0500 Subject: [PATCH 3/3] Changed text to sdk key --- src/index.js | 2 +- src/messages.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 73b5a1c..940dbf0 100644 --- a/src/index.js +++ b/src/index.js @@ -321,7 +321,7 @@ export function initialize(clientSdkKey, flagKeys, user, specifiedOptions, platf } if(clientSdkKey.split('-')[1] !== 'public'){ - console.warn("You're using NOT using public key to connect to Unlaunch. If your application is client-side, not using public key can compromise security. To obtain the public API key, please sign in the Unlaunch Console at https://app.unlaunch.io" + console.warn("You're using NOT using public key to connect to Unlaunch. If your application is client-side, not using public key can compromise security. To obtain the public SDK key, please sign in the Unlaunch Console at https://app.unlaunch.io" +". Then on the right sidebar, click on 'Settings'. Then from the 'Projects' tab. Copy the 'PUBLIC KEY' for the " +"environment you want to connect to, and provide it to this SDK. For more information, visit: https://docs.unlaunch.io/docs/sdks/sdk-keys") } diff --git a/src/messages.js b/src/messages.js index 5791f17..15eac4e 100644 --- a/src/messages.js +++ b/src/messages.js @@ -14,7 +14,7 @@ export const clientInitialized = function() { return 'Unlaunch client initialized'; }; -const invalidSdkKeyHelpMsg = "To obtain the API key, please sign in to the Unlaunch Console at https://app.unlaunch.io. Then on the right sidebar, click on 'Settings'. Then from the 'Projects' tab. Copy the 'PUBLIC KEY' for the environment you want to connect to, and provide it to this SDK. For more information, visit: https://docs.unlaunch.io/docs/sdks/sdk-keys" +const invalidSdkKeyHelpMsg = "To obtain the SDK key, please sign in to the Unlaunch Console at https://app.unlaunch.io. Then on the right sidebar, click on 'Settings'. Then from the 'Projects' tab. Copy the 'PUBLIC KEY' for the environment you want to connect to, and provide it to this SDK. For more information, visit: https://docs.unlaunch.io/docs/sdks/sdk-keys" const docLink = "Read more at https://docs.unlaunch.io/docs/sdks/javascript-library"