Skip to content

Commit

Permalink
fix: support enhanced domains
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Dec 16, 2020
1 parent 64590cc commit a89ce21
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/authInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ function getJwtAudienceUrl(options: OAuth2Options & { createdOrgInstance?: strin
if (
createdOrgInstance.startsWith('cs') ||
createdOrgInstance.endsWith('s') ||
options.loginUrl?.includes('sandbox.my.salesforce.com') || // enhanced domains >= 230
options.loginUrl?.match(/(cs[0-9]+.my.salesforce.com)/g) ||
(options.loginUrl && urlParse(options.loginUrl).hostname === 'test.salesforce.com')
) {
Expand Down
11 changes: 11 additions & 0 deletions test/unit/authInfoTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1663,6 +1663,17 @@ describe('AuthInfo', () => {
it('should use the correct audience URL for createdOrgInstance beginning with "gs1"', async () => {
await runTest({ createdOrgInstance: 'gs1' }, 'https://gs1.salesforce.com');
});

it('should use the correct audience URL for production enhanced domains', async () => {
await runTest({ loginUrl: 'https://customdomain.my.salesforce.com' }, 'https://login.salesforce.com');
});

it('should use the correct audience URL for sandbox enhanced domains', async () => {
await runTest(
{ loginUrl: 'https://customdomain--sandboxname.sandbox.my.salesforce.com' },
'https://test.salesforce.com'
);
});
});

describe('getDefaultInstanceUrl', () => {
Expand Down

0 comments on commit a89ce21

Please sign in to comment.