File tree Expand file tree Collapse file tree 3 files changed +11
-11
lines changed
Expand file tree Collapse file tree 3 files changed +11
-11
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @navigraph/auth " : minor
3+ ---
4+
5+ Fix issue where wrong endpoint would be called with ` withCredentials ` set to true, causing CORS issues.
Original file line number Diff line number Diff line change 77 DeviceFlowTokenExpiredError ,
88 InvalidClientError ,
99 InvalidScopeError ,
10- Scope ,
1110} from "@navigraph/app" ;
1211import axios , { AxiosError } from "axios" ;
1312import { getIdentityDeviceAuthEndpoint } from "../constants" ;
@@ -59,10 +58,7 @@ export async function signInWithDeviceFlow(callback: DeviceFlowCallback): Promis
5958 code_challenge,
6059 code_challenge_method : "S256" ,
6160 } ) ,
62- {
63- headers : { "Content-Type" : "application/x-www-form-urlencoded" } ,
64- withCredentials : app . scopes . includes ( Scope . TILES ) ? true : undefined ,
65- }
61+ { headers : { "Content-Type" : "application/x-www-form-urlencoded" } }
6662 )
6763 . catch ( ( err : AxiosError < FailedAuthorizationResponse > ) => {
6864 const status = err . response ?. status ;
Original file line number Diff line number Diff line change 1- import { Logger } from "@navigraph/app" ;
1+ import { Logger , Scope } from "@navigraph/app" ;
22import axios from "axios" ;
33import { getIdentityTokenEndpoint } from "../constants" ;
44import { setUser , tokenStorage } from "../internal" ;
@@ -7,11 +7,10 @@ import { TokenResponse } from "../types";
77
88export async function tokenCall ( params : Record < string , string > ) {
99 return axios
10- . post < TokenResponse > (
11- getIdentityTokenEndpoint ( ) ,
12- new URLSearchParams ( params ) ,
13- { headers : { "Content-Type" : "application/x-www-form-urlencoded" } } // prettier-ignore
14- )
10+ . post < TokenResponse > ( getIdentityTokenEndpoint ( ) , new URLSearchParams ( params ) , {
11+ withCredentials : params . scopes ?. includes ( Scope . TILES ) ? true : undefined ,
12+ headers : { "Content-Type" : "application/x-www-form-urlencoded" } ,
13+ } )
1514 . then ( async ( { data } ) => {
1615 if ( data . access_token && data . refresh_token ) {
1716 await tokenStorage . setAccessToken ( data . access_token ) ;
You can’t perform that action at this time.
0 commit comments