Skip to content

Commit 563dbba

Browse files
committed
chore: apply feedback
1 parent 01d461c commit 563dbba

File tree

4 files changed

+9
-15
lines changed

4 files changed

+9
-15
lines changed

EXAMPLES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ const auth = new AuthenticationClient({
165165

166166
const { data: token } = await auth.oauth.tokenForConnection({
167167
subject_token: '{refresh_token}',
168-
subject_token_type: SUBJECT_TOKEN_TYPES.SUBJECT_TYPE_REFRESH_TOKEN, // Optional: defaults to refresh token type
168+
subject_token_type: SUBJECT_TOKEN_TYPES.REFRESH_TOKEN, // Optional: defaults to refresh token type
169169
connection: 'google-oauth2', // The target social provider connection
170170
login_hint: 'user@example.com', // Optional: to target a specific account
171171
});

src/auth/oauth.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -310,22 +310,22 @@ export enum SUBJECT_TOKEN_TYPES {
310310
*
311311
* @see {@link https://tools.ietf.org/html/rfc8693#section-3.1 RFC 8693 Section 3.1}
312312
*/
313-
SUBJECT_TYPE_REFRESH_TOKEN = 'urn:ietf:params:oauth:token-type:refresh_token',
313+
REFRESH_TOKEN = 'urn:ietf:params:oauth:token-type:refresh_token',
314314

315315
/**
316316
* Constant representing the subject type for a access token.
317317
* This is used in OAuth 2.0 token exchange to specify that the token being exchanged is an access token.
318318
*
319319
* @see {@link https://tools.ietf.org/html/rfc8693#section-3.1 RFC 8693 Section 3.1}
320320
*/
321-
SUBJECT_TYPE_ACCESS_TOKEN = 'urn:ietf:params:oauth:token-type:access_token',
321+
ACCESS_TOKEN = 'urn:ietf:params:oauth:token-type:access_token',
322322
}
323323

324324
export const TOKEN_FOR_CONNECTION_GRANT_TYPE =
325325
'urn:auth0:params:oauth:grant-type:token-exchange:federated-connection-access-token';
326326

327327
/**
328-
* @deprecated Use {@link SUBJECT_TOKEN_TYPES.SUBJECT_TYPE_REFRESH_TOKEN} instead.
328+
* @deprecated Use {@link SUBJECT_TOKEN_TYPES.REFRESH_TOKEN} instead.
329329
*/
330330
export const TOKEN_FOR_CONNECTION_TOKEN_TYPE = 'urn:ietf:params:oauth:token-type:refresh_token';
331331
export const TOKEN_FOR_CONNECTION_REQUESTED_TOKEN_TYPE =
@@ -636,16 +636,10 @@ export class OAuth extends BaseAuthAPI {
636636
): Promise<JSONApiResponse<TokenSet>> {
637637
validateRequiredRequestParams(bodyParameters, ['connection', 'subject_token']);
638638

639-
let subjectTokenType = SUBJECT_TOKEN_TYPES.SUBJECT_TYPE_REFRESH_TOKEN;
640-
641-
if (bodyParameters.subject_token_type) {
642-
subjectTokenType = bodyParameters.subject_token_type;
643-
}
644-
645639
const body: Record<string, string> = {
640+
subject_token_type: SUBJECT_TOKEN_TYPES.REFRESH_TOKEN,
646641
...bodyParameters,
647642
grant_type: TOKEN_FOR_CONNECTION_GRANT_TYPE,
648-
subject_token_type: subjectTokenType,
649643
requested_token_type: TOKEN_FOR_CONNECTION_REQUESTED_TOKEN_TYPE,
650644
};
651645

test/auth/fixtures/oauth.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@
194194
"scope": "https://test-domain.auth0.com",
195195
"method": "POST",
196196
"path": "/oauth/token",
197-
"body": "connection=google-oauth2&subject_token=test-refresh-token&grant_type=urn%3Aauth0%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange%3Afederated-connection-access-token&subject_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Arefresh_token&requested_token_type=http%3A%2F%2Fauth0.com%2Foauth%2Ftoken-type%2Ffederated-connection-access-token&client_secret=test-client-secret",
197+
"body": "subject_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Arefresh_token&connection=google-oauth2&subject_token=test-refresh-token&grant_type=urn%3Aauth0%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange%3Afederated-connection-access-token&requested_token_type=http%3A%2F%2Fauth0.com%2Foauth%2Ftoken-type%2Ffederated-connection-access-token&client_secret=test-client-secret",
198198
"status": 200,
199199
"response": {
200200
"access_token": "connection-access-token",
@@ -206,7 +206,7 @@
206206
"scope": "https://test-domain.auth0.com",
207207
"method": "POST",
208208
"path": "/oauth/token",
209-
"body": "connection=google-oauth2&subject_token=test-refresh-token&login_hint=user%40example.com&grant_type=urn%3Aauth0%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange%3Afederated-connection-access-token&subject_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Arefresh_token&requested_token_type=http%3A%2F%2Fauth0.com%2Foauth%2Ftoken-type%2Ffederated-connection-access-token&client_secret=test-client-secret",
209+
"body": "subject_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Arefresh_token&connection=google-oauth2&subject_token=test-refresh-token&login_hint=user%40example.com&grant_type=urn%3Aauth0%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange%3Afederated-connection-access-token&requested_token_type=http%3A%2F%2Fauth0.com%2Foauth%2Ftoken-type%2Ffederated-connection-access-token&client_secret=test-client-secret",
210210
"status": 200,
211211
"response": {
212212
"access_token": "connection-access-token",
@@ -218,7 +218,7 @@
218218
"scope": "https://test-domain.auth0.com",
219219
"method": "POST",
220220
"path": "/oauth/token",
221-
"body": "connection=google-oauth2&subject_token=test-id-token&subject_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&grant_type=urn%3Aauth0%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange%3Afederated-connection-access-token&requested_token_type=http%3A%2F%2Fauth0.com%2Foauth%2Ftoken-type%2Ffederated-connection-access-token&client_secret=test-client-secret",
221+
"body": "subject_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&connection=google-oauth2&subject_token=test-id-token&grant_type=urn%3Aauth0%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange%3Afederated-connection-access-token&requested_token_type=http%3A%2F%2Fauth0.com%2Foauth%2Ftoken-type%2Ffederated-connection-access-token&client_secret=test-client-secret",
222222
"status": 200,
223223
"response": {
224224
"access_token": "connection-access-token",

test/auth/oauth.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ describe('OAuth', () => {
426426
oauth.tokenForConnection({
427427
connection: 'google-oauth2',
428428
subject_token: 'test-id-token',
429-
subject_token_type: SUBJECT_TOKEN_TYPES.SUBJECT_TYPE_ACCESS_TOKEN,
429+
subject_token_type: SUBJECT_TOKEN_TYPES.ACCESS_TOKEN,
430430
})
431431
).resolves.toMatchObject({
432432
data: {

0 commit comments

Comments
 (0)