-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Hyperforce China Support #141
Conversation
Hi, I reopened a PR, with all the requested changes. |
Hi, please approve and merge this request asap. We are working on China/Alibaba developments and need this functionality as well. Thanks! |
Hi @yaacov9 @stenebenau , Could one of you create me an account on a scratch org hosted on AlibabaCloud to be able to do some tests ? |
HI @tprouvot, I understand your request. However this is not really allowed just yet. Can i test a beta package somehow? |
@tprouvot sorry I can't provide you a sandbox @stenebenau you already can download my version since it's open source |
Hi @tprouvot, i did some testing and ran the unit-tests. That worked until the export test, it tries to do something with an unknown field. |
Hi Guys, I understand the issue with providing access to a sandbox which may include some metadata / data but with an empty scratch org it should be ok. @yaacov9 the number of domains to check is increasing, could you refactor a little bit ie on background.js ? "use strict";
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
// Perform cookie operations in the background page, because not all foreground pages have access to the cookie API.
// Firefox does not support incognito split mode, so we use sender.tab.cookieStoreId to select the right cookie store.
// Chrome does not support sender.tab.cookieStoreId, which means it is undefined, and we end up using the default cookie store according to incognito split mode.
if (request.message == "getSfHost") {
// When on a *.visual.force.com page, the session in the cookie does not have API access,
// so we read the corresponding session from *.salesforce.com page.
// The first part of the session cookie is the OrgID,
// which we use as key to support being logged in to multiple orgs at once.
// http://salesforce.stackexchange.com/questions/23277/different-session-ids-in-different-contexts
// There is no straight forward way to unambiguously understand if the user authenticated against salesforce.com or cloudforce.com
// (and thereby the domain of the relevant cookie) cookie domains are therefore tried in sequence.
chrome.cookies.get({url: request.url, name: "sid", storeId: sender.tab.cookieStoreId}, cookie => {
if (!cookie) {
sendResponse(null);
return;
}
let [orgId] = cookie.value.split("!");
let orderedDomains = ["salesforce.com", "cloudforce.com", "salesforce.mil", "cloudforce.mil", "sfcrmproducts.cn"];
orderedDomains.forEach(currentDomain => {
chrome.cookies.getAll({name: "sid", domain: currentDomain, secure: true, storeId: sender.tab.cookieStoreId}, cookies => {
let sessionCookie = cookies.find(c => c.value.startsWith(orgId + "!"));
if (sessionCookie) {
sendResponse(sessionCookie.domain);
} else if (orderedDomains[orderedDomains.length] === currentDomain){
sendResponse(null);
}
});
});
});
return true; // Tell Chrome that we want to call sendResponse asynchronously.
}
if (request.message == "getSession") {
chrome.cookies.get({url: "https://" + request.sfHost, name: "sid", storeId: sender.tab.cookieStoreId}, sessionCookie => {
if (!sessionCookie) {
sendResponse(null);
return;
}
let session = {key: sessionCookie.value, hostname: sessionCookie.domain};
sendResponse(session);
});
return true; // Tell Chrome that we want to call sendResponse asynchronously.
}
return false;
}); |
Hi @stenebenau, |
Hi, we have some clients that are now using a new Salesforce product called Hyperforce. For China clients, Hyperforce are available only from new url. So I implemented a way to retrieve the sessionCookie, the recordId, the hostname etc, and it's now works on differents clients that are using Hyperforce China. My code supports both Classic and Lightning --------- Co-authored-by: Thomas Prouvot <prouvot.t@gmail.com>
Hi, we have some clients that are now using a new Salesforce product called Hyperforce. For China clients, Hyperforce are available only from new url. So I implemented a way to retrieve the sessionCookie, the recordId, the hostname etc, and it's now works on differents clients that are using Hyperforce China. My code supports both Classic and Lightning --------- Co-authored-by: Thomas Prouvot <prouvot.t@gmail.com>
Hi, we have some clients that are now using a new Salesforce product called Hyperforce.
For China clients, Hyperforce are available only from new url.
So I implemented a way to retrieve the sessionCookie, the recordId, the hostname etc, and it's now works on differents clients that are using Hyperforce China.
My code supports both Classic and Lightning