Skip to content

Commit

Permalink
fix: audiences handle uppercased CS instances
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Jan 15, 2021
1 parent a89ce21 commit 0d6d3ea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/authInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ function getJwtAudienceUrl(options: OAuth2Options & { createdOrgInstance?: strin
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?.match(/([Cc][Ss][0-9]+.my.salesforce.com)/g) ||
(options.loginUrl && urlParse(options.loginUrl).hostname === 'test.salesforce.com')
) {
return SfdcUrl.SANDBOX;
Expand Down
4 changes: 4 additions & 0 deletions test/unit/authInfoTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1652,6 +1652,10 @@ describe('AuthInfo', () => {
await runTest({ createdOrgInstance: 'cs17' }, 'https://test.salesforce.com');
});

it('should use the correct audience URL for createdOrgInstance beginning with "CS"', async () => {
await runTest({ createdOrgInstance: 'CS17' }, 'https://test.salesforce.com');
});

it('should use the correct audience URL for createdOrgInstance ending with "s"', async () => {
await runTest({ createdOrgInstance: 'usa2s' }, 'https://test.salesforce.com');
});
Expand Down

0 comments on commit 0d6d3ea

Please sign in to comment.