11import { NativeModules , Platform } from 'react-native' ;
2- import { type startVPN } from './types'
2+ import { type startVPN } from './types' ;
33
44const LINKING_ERROR =
55 `The package 'react-native-outline-vpn' doesn't seem to be linked. Make sure: \n\n` +
@@ -18,7 +18,8 @@ const OutlineVpn = NativeModules.OutlineVpn
1818 }
1919 ) ;
2020
21- export const startOutlineVPN : startVPN = function startOutlineVPN ( host : string ,
21+ export const startOutlineVPN : startVPN = function startOutlineVPN (
22+ host : string ,
2223 port : number ,
2324 password : string ,
2425 method : string ,
@@ -28,8 +29,8 @@ export const startOutlineVPN : startVPN = function startOutlineVPN ( host: stri
2829 tunnelId ?: string ,
2930 localizedDescription ?: string
3031) {
31- return new Promise ( ( resolve , reject ) => {
32- if ( Platform . OS === " ios" ) {
32+ return new Promise ( ( resolve , reject ) => {
33+ if ( Platform . OS === ' ios' ) {
3334 OutlineVpn . startVpn (
3435 host ,
3536 port ,
@@ -40,29 +41,21 @@ export const startOutlineVPN : startVPN = function startOutlineVPN ( host: stri
4041 serverAddress ,
4142 tunnelId ,
4243 localizedDescription
43- )
44+ ) ;
4445 } else {
45- OutlineVpn . saveCredential (
46- host ,
47- port ,
48- password ,
49- method ,
50- prefix ,
51- ) . then ( ( credentialResult : any ) => {
52- if ( credentialResult ) {
53- OutlineVpn . getCredential ( ) . then ( ( cr : any ) => {
54- OutlineVpn . prepareLocalVPN ( ) . then ( ( prepareRes : any ) => {
55- OutlineVpn . connectLocalVPN ( )
56- . then ( ( vpnResult : any ) => { } )
57- . catch ( ( e : any ) => { } ) ;
46+ OutlineVpn . saveCredential ( host , port , password , method , prefix ) . then (
47+ ( credentialResult : any ) => {
48+ if ( credentialResult ) {
49+ OutlineVpn . getCredential ( ) . then ( ( ) => {
50+ OutlineVpn . prepareLocalVPN ( ) . then ( ( ) => {
51+ OutlineVpn . connectLocalVPN ( )
52+ . then ( ( vpnResult : string ) => resolve ( vpnResult ) )
53+ . catch ( ( e : any ) => reject ( e ) ) ;
54+ } ) ;
5855 } ) ;
59- } ) ;
56+ }
6057 }
61- } ) ;
58+ ) ;
6259 }
63-
64-
65- } )
66-
67-
68- }
60+ } ) ;
61+ } ;
0 commit comments