Skip to content

Commit c4c1d99

Browse files
committed
Only pass dangerouslyAllowInsecureHttpRequests to authorize/refresh methods on Android
1 parent 25c1b14 commit c4c1d99

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

index.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import invariant from 'invariant';
2-
import { NativeModules } from 'react-native';
2+
import { NativeModules, Platform } from 'react-native';
33

44
const { RNAppAuth } = NativeModules;
55

@@ -19,14 +19,18 @@ export const authorize = ({ issuer, redirectUrl, clientId, scopes, additionalPar
1919
validateRedirectUrl(redirectUrl);
2020
// TODO: validateAdditionalParameters
2121

22-
return RNAppAuth.authorize(
22+
const nativeMethodArguments = [
2323
issuer,
2424
redirectUrl,
2525
clientId,
2626
scopes,
27-
additionalParameters,
28-
dangerouslyAllowInsecureHttpRequests
29-
);
27+
additionalParameters
28+
]
29+
if (Platform.OS === 'android') {
30+
nativeMethodArguments.push(dangerouslyAllowInsecureHttpRequests);
31+
}
32+
33+
return RNAppAuth.authorize(...nativeMethodArguments);
3034
};
3135

3236
export const refresh = (
@@ -40,15 +44,20 @@ export const refresh = (
4044
invariant(refreshToken, 'Please pass in a refresh token');
4145
// TODO: validateAdditionalParameters
4246

43-
return RNAppAuth.refresh(
47+
const nativeMethodArguments = [
4448
issuer,
4549
redirectUrl,
4650
clientId,
4751
refreshToken,
4852
scopes,
49-
additionalParameters,
50-
dangerouslyAllowInsecureHttpRequests
51-
);
53+
additionalParameters
54+
];
55+
56+
if (Platform.OS === 'android') {
57+
nativeMethodArguments.push(dangerouslyAllowInsecureHttpRequests);
58+
}
59+
60+
return RNAppAuth.refresh(...nativeMethodArguments);
5261
};
5362

5463
export const revoke = async ({ clientId, issuer }, { tokenToRevoke, sendClientId = false }) => {

0 commit comments

Comments
 (0)