@salesforce/core 5.1.6 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/org/authInfo.d.ts +1 -0
- package/lib/org/authInfo.js +26 -0
- package/lib/testSetup.d.ts +1 -0
- package/lib/testSetup.js +1 -0
- package/package.json +1 -1
package/lib/org/authInfo.d.ts
CHANGED
package/lib/org/authInfo.js
CHANGED
|
@@ -662,6 +662,10 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
662
662
|
}
|
|
663
663
|
}
|
|
664
664
|
authConfig.isDevHub = await this.determineIfDevHub((0, ts_types_1.ensureString)(authConfig.instanceUrl), (0, ts_types_1.ensureString)(authConfig.accessToken));
|
|
665
|
+
const namespacePrefix = await this.getNamespacePrefix((0, ts_types_1.ensureString)(authConfig.instanceUrl), (0, ts_types_1.ensureString)(authConfig.accessToken));
|
|
666
|
+
if (namespacePrefix) {
|
|
667
|
+
authConfig.namespacePrefix = namespacePrefix;
|
|
668
|
+
}
|
|
665
669
|
if (authConfig.username)
|
|
666
670
|
await this.stateAggregator.orgs.read(authConfig.username, false, false);
|
|
667
671
|
// Update the auth fields WITH encryption
|
|
@@ -918,6 +922,28 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
918
922
|
}
|
|
919
923
|
throw new sfError_1.SfError(errorMsg);
|
|
920
924
|
}
|
|
925
|
+
async getNamespacePrefix(instanceUrl, accessToken) {
|
|
926
|
+
// Make a REST call for the Organization obj directly. Normally this is done via a connection
|
|
927
|
+
// but we don't want to create circular dependencies or lots of snowflakes
|
|
928
|
+
// within this file to support it.
|
|
929
|
+
const apiVersion = 'v51.0'; // hardcoding to v51.0 just for this call is okay.
|
|
930
|
+
const instance = (0, ts_types_1.ensure)(instanceUrl);
|
|
931
|
+
const baseUrl = new sfdcUrl_1.SfdcUrl(instance);
|
|
932
|
+
const namespacePrefixOrgUrl = `${baseUrl.toString()}/services/data/${apiVersion}/query?q=Select%20Namespaceprefix%20FROM%20Organization`;
|
|
933
|
+
const headers = Object.assign({ Authorization: `Bearer ${accessToken}` }, connection_1.SFDX_HTTP_HEADERS);
|
|
934
|
+
try {
|
|
935
|
+
const res = await new transport_1.default().httpRequest({ url: namespacePrefixOrgUrl, method: 'GET', headers });
|
|
936
|
+
if (res.statusCode >= 400) {
|
|
937
|
+
return;
|
|
938
|
+
}
|
|
939
|
+
const namespacePrefix = JSON.parse(res.body);
|
|
940
|
+
return (0, ts_types_1.ensureString)(namespacePrefix.records[0]?.NamespacePrefix);
|
|
941
|
+
}
|
|
942
|
+
catch (err) {
|
|
943
|
+
/* Doesn't have a namespace */
|
|
944
|
+
return;
|
|
945
|
+
}
|
|
946
|
+
}
|
|
921
947
|
/**
|
|
922
948
|
* Returns `true` if the org is a Dev Hub.
|
|
923
949
|
*
|
package/lib/testSetup.d.ts
CHANGED
package/lib/testSetup.js
CHANGED
|
@@ -733,6 +733,7 @@ class MockTestOrgData {
|
|
|
733
733
|
this.accessToken = `${this.testId}/accessToken`;
|
|
734
734
|
this.refreshToken = `${this.testId}/refreshToken`;
|
|
735
735
|
this.redirectUri = 'http://localhost:1717/OauthRedirect';
|
|
736
|
+
this.namespacePrefix = `acme_${this.testId}`;
|
|
736
737
|
}
|
|
737
738
|
/**
|
|
738
739
|
* Add devhub username to properties.
|