1
- import { LocalStorageConstants , LocalStorageUtils , URLConstants , URLUtils } from '@deriv-com/utils' ;
1
+ import { AppIDConstants , LocalStorageConstants , LocalStorageUtils , URLConstants , URLUtils } from '@deriv-com/utils' ;
2
2
3
3
export const BUY_SELL_URL = '/buy-sell' ;
4
4
export const ORDERS_URL = '/orders' ;
@@ -13,9 +13,33 @@ export const DERIV_COM = URLConstants.derivComProduction;
13
13
export const HELP_CENTRE = `${ URLConstants . derivComProduction } /help-centre/` ;
14
14
export const RESPONSIBLE = `${ URLConstants . derivComProduction } /responsible/` ;
15
15
16
+ const SocketURL = {
17
+ [ URLConstants . derivP2pProduction ] : 'blue.derivws.com' ,
18
+ [ URLConstants . derivP2pStaging ] : 'red.derivws.com' ,
19
+ } ;
20
+
16
21
export const getOauthUrl = ( ) => {
22
+ const hostname = window . location . origin ;
23
+
24
+ // since we don't have official app_id for staging,
25
+ // we will use the red server with app_id=62019 for the staging-p2p.deriv.com for now
26
+ // to fix the login issue
27
+ if ( hostname === URLConstants . derivP2pStaging ) {
28
+ localStorage . setItem (
29
+ LocalStorageConstants . configServerURL . toString ( ) ,
30
+ SocketURL [ hostname as keyof typeof SocketURL ]
31
+ ) ;
32
+ localStorage . setItem (
33
+ LocalStorageConstants . configAppId ,
34
+ AppIDConstants . domainAppId [ hostname as keyof typeof AppIDConstants . domainAppId ]
35
+ ) ;
36
+ }
37
+
38
+ const storedServerUrl = localStorage . getItem ( LocalStorageConstants . configServerURL . toString ( ) ) ;
39
+ const serverUrl = / q a / . test ( storedServerUrl || '' ) ? storedServerUrl : 'oauth.deriv.com' ;
40
+
17
41
const appId = LocalStorageUtils . getValue ( LocalStorageConstants . configAppId ) ;
18
- const serverUrl = localStorage . getItem ( LocalStorageConstants . configServerURL . toString ( ) ) ;
42
+
19
43
const oauthUrl =
20
44
appId && serverUrl
21
45
? `https://${ serverUrl } /oauth2/authorize?app_id=${ appId } &l=EN&&brand=deriv`
0 commit comments