Skip to content

Commit 79d5326

Browse files
remove token type validation logic
1 parent 54e0425 commit 79d5326

File tree

3 files changed

+3
-52
lines changed

3 files changed

+3
-52
lines changed

__tests__/Auth0Client/exchangeToken.test.ts

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ describe('Auth0Client', () => {
6161
window.location = oldWindowLocation;
6262
});
6363

64-
describe('getTokenWithPopup()', () => {
64+
describe('exchangeToken()', () => {
6565
const localSetup = async (clientOptions?: Partial<Auth0ClientOptions>) => {
6666
const auth0 = setup(clientOptions);
6767

@@ -98,7 +98,7 @@ describe('Auth0Client', () => {
9898
return auth0;
9999
};
100100

101-
it('calls `loginWithPopup` with the correct default options', async () => {
101+
it('calls `exchangeToken` with the correct default options', async () => {
102102
const auth0 = await localSetup();
103103
const cteOptions: CustomTokenExchangeOptions = {
104104
subject_token: 'external_token_value',
@@ -113,26 +113,5 @@ describe('Auth0Client', () => {
113113
expect(result.expires_in).toEqual(3600);
114114
expect(typeof result.scope).toBe('string');
115115
});
116-
117-
it('should throw an error for invalid subject_token_type from reserved namespaces', async () => {
118-
// List of reserved token types that must be rejected.
119-
const invalidTokenTypes = [
120-
'urn:ietf:params:oauth:foo',
121-
'https://auth0.com/token',
122-
'urn:auth0:token'
123-
];
124-
125-
const auth0 = await localSetup();
126-
127-
// Each invalid token type should cause exchangeToken to reject with an Error.
128-
for (const tokenType of invalidTokenTypes) {
129-
const cteOptions: CustomTokenExchangeOptions = {
130-
subject_token: 'external_token_value',
131-
subject_token_type: tokenType,
132-
audience: 'https://api.test.com'
133-
};
134-
await expect(auth0.exchangeToken(cteOptions)).rejects.toThrow(Error);
135-
}
136-
});
137116
});
138117
});

src/Auth0Client.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ import {
9292
OLD_IS_AUTHENTICATED_COOKIE_NAME,
9393
patchOpenUrlWithOnRedirect
9494
} from './Auth0Client.utils';
95-
import { CustomTokenExchangeOptions, validateTokenType } from './TokenExchange';
95+
import { CustomTokenExchangeOptions } from './TokenExchange';
9696

9797
/**
9898
* @ignore
@@ -1195,8 +1195,6 @@ export class Auth0Client {
11951195
async exchangeToken(
11961196
options: CustomTokenExchangeOptions
11971197
): Promise<TokenEndpointResponse> {
1198-
validateTokenType(options.subject_token_type);
1199-
12001198
return this._requestToken({
12011199
grant_type: 'urn:ietf:params:oauth:grant-type:token-exchange',
12021200
subject_token: options.subject_token,

src/TokenExchange.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -72,29 +72,3 @@ export type CustomTokenExchangeOptions = {
7272
*/
7373
[key: string]: unknown;
7474
};
75-
76-
/**
77-
* Enforces namespace ownership requirements for token types
78-
*
79-
* @param tokenType - Proposed subject_token_type value
80-
* @throws {Error} When reserved namespace pattern detected
81-
*
82-
* @privateRemarks
83-
* Implements RFC 8693 Section 4.1 requirements for token type URIs
84-
*
85-
* @see {@link https://www.rfc-editor.org/rfc/rfc8693#section-4.1 | RFC 8693 Section 4.1}
86-
*/
87-
export const validateTokenType = (tokenType: string): void => {
88-
const reservedPatterns = [
89-
/^urn:ietf:params:oauth:/i,
90-
/^https:\/\/auth0\.com\//i,
91-
/^urn:auth0:/i
92-
];
93-
94-
if (reservedPatterns.some(pattern => pattern.test(tokenType))) {
95-
throw new Error(
96-
`Invalid subject_token_type '${tokenType}'. ` +
97-
`Reserved namespaces are prohibited. Use URIs under your organization's control.`
98-
);
99-
}
100-
};

0 commit comments

Comments
 (0)