Skip to content

Added warning when public key is used #3

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,12 @@ 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")
}

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 SDK key, please # the Unlaunch Console at https://app.unlaunch.io"
Copy link
Contributor

@umermansoor umermansoor Nov 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We detected that you're not using the public SDK key to connect to Unlaunch from a browser SDK. For security reasons, we highly recommend using the public SDK key to access Unlaunch from JavaScript or other public SDKs. To obtain the public SDK key, please # the Unlaunch Console at https://app.unlaunch.io"
+". Then on the right sidebar, click on 'Settings'. Then from the 'Projects' tab. Copy the 'Browser / 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"

+". 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");
Expand Down
2 changes: 1 addition & 1 deletion src/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const clientInitialized = function() {
return 'Unlaunch client initialized';
};

const invalidSdkKeyHelpMsg = `To obtain the SDK key for your project, please # 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 SDK key, please # 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"

Expand Down