Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/docs/usage/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ See specific example [configurations for your provider](/docs/category/providers
- **skipCodeExchange** - (`boolean`) (default: false) just return the authorization response, instead of automatically exchanging the authorization code. This is useful if this exchange needs to be done manually (not client-side)
- **iosCustomBrowser** - (`string`) (default: undefined) _IOS_ override the used browser for authorization, used to open an external browser. If no value is provided, the `ASWebAuthenticationSession` or `SFSafariViewController` are used by the `AppAuth-iOS` library.
- **iosPrefersEphemeralSession** - (`boolean`) (default: `false`) _IOS_ indicates whether the session should ask the browser for a private authentication session.
-**androidPrefersEphemeralSession** - (`boolean`) (default: `false`) _ANDROID_ indicates whether the session should ask the browser for a private authentication session.
- **androidAllowCustomBrowsers** - (`string[]`) (default: undefined) _ANDROID_ override the used browser for authorization. If no value is provided, all browsers are allowed.
- **androidTrustedWebActivity** - (`boolean`) (default: `false`) _ANDROID_ Use [`EXTRA_LAUNCH_AS_TRUSTED_WEB_ACTIVITY`](https://developer.chrome.com/docs/android/trusted-web-activity/) when opening web view.
- **connectionTimeoutSeconds** - (`number`) configure the request timeout interval in seconds. This must be a positive number. The default values are 60 seconds on iOS and 15 seconds on Android.
2 changes: 1 addition & 1 deletion packages/react-native-app-auth/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,5 @@ dependencies {
//noinspection GradleDynamicVersion
implementation 'com.facebook.react:react-native:+' // From node_modules
implementation 'net.openid:appauth:0.11.1'
implementation 'androidx.browser:browser:1.4.0'
implementation 'androidx.browser:browser:1.9.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ public void authorize(
final ReadableMap customHeaders,
final ReadableArray androidAllowCustomBrowsers,
final boolean androidTrustedWebActivity,
final boolean androidPrefersEphemeralSession,
final Promise promise) {
this.parseHeaderMap(customHeaders);
final ConnectionBuilder builder = createConnectionBuilder(dangerouslyAllowInsecureHttpRequests,
Expand Down Expand Up @@ -277,7 +278,8 @@ public void authorize(
useNonce,
usePKCE,
additionalParametersMap,
androidTrustedWebActivity);
androidTrustedWebActivity,
androidPrefersEphemeralSession);
} catch (ActivityNotFoundException e) {
promise.reject("browser_not_found", e.getMessage());
} catch (Exception e) {
Expand Down Expand Up @@ -308,7 +310,8 @@ public void onFetchConfigurationCompleted(
useNonce,
usePKCE,
additionalParametersMap,
androidTrustedWebActivity);
androidTrustedWebActivity,
androidPrefersEphemeralSession);
} catch (ActivityNotFoundException e) {
promise.reject("browser_not_found", e.getMessage());
} catch (Exception e) {
Expand Down Expand Up @@ -660,7 +663,8 @@ private void authorizeWithConfiguration(
final Boolean useNonce,
final Boolean usePKCE,
final Map<String, String> additionalParametersMap,
final Boolean androidTrustedWebActivity) {
final Boolean androidTrustedWebActivity,
final Boolean androidPrefersEphemeralSession) {

String scopesString = null;

Expand Down Expand Up @@ -731,8 +735,8 @@ private void authorizeWithConfiguration(
AuthorizationService authService = new AuthorizationService(context, appAuthConfiguration);

CustomTabsIntent.Builder intentBuilder = authService.createCustomTabsIntentBuilder();
CustomTabsIntent customTabsIntent = intentBuilder.build();

CustomTabsIntent customTabsIntent = intentBuilder.setEphemeralBrowsingEnabled(androidPrefersEphemeralSession).build();
if (androidTrustedWebActivity) {
customTabsIntent.intent.putExtra(TrustedWebUtils.EXTRA_LAUNCH_AS_TRUSTED_WEB_ACTIVITY, true);
}
Expand Down
1 change: 1 addition & 0 deletions packages/react-native-app-auth/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export type AuthConfiguration = BaseAuthConfiguration & {
| 'samsungCustomTab'
)[];
androidTrustedWebActivity?: boolean;
androidPrefersEphemeralSession?: boolean;
iosPrefersEphemeralSession?: boolean;
};

Expand Down
2 changes: 2 additions & 0 deletions packages/react-native-app-auth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ export const authorize = ({
androidTrustedWebActivity = false,
connectionTimeoutSeconds,
iosPrefersEphemeralSession = false,
androidPrefersEphemeralSession = false
}) => {
validateIssuerOrServiceConfigurationEndpoints(issuer, serviceConfiguration);
validateClientId(clientId);
Expand Down Expand Up @@ -243,6 +244,7 @@ export const authorize = ({
nativeMethodArguments.push(customHeaders);
nativeMethodArguments.push(androidAllowCustomBrowsers);
nativeMethodArguments.push(androidTrustedWebActivity);
nativeMethodArguments.push(androidPrefersEphemeralSession);
}

if (Platform.OS === 'ios') {
Expand Down
16 changes: 11 additions & 5 deletions packages/react-native-app-auth/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ describe('AppAuth', () => {
iosPrefersEphemeralSession: true,
androidAllowCustomBrowsers: ['chrome'],
androidTrustedWebActivity: false,
androidPrefersEphemeralSession: true
};

const registerConfig = {
Expand Down Expand Up @@ -745,7 +746,8 @@ describe('AppAuth', () => {
false,
config.customHeaders,
config.androidAllowCustomBrowsers,
config.androidTrustedWebActivity
config.androidTrustedWebActivity,
config.androidPrefersEphemeralSession
);
});
});
Expand All @@ -769,7 +771,8 @@ describe('AppAuth', () => {
false,
config.customHeaders,
config.androidAllowCustomBrowsers,
config.androidTrustedWebActivity
config.androidTrustedWebActivity,
config.androidPrefersEphemeralSession
);
});

Expand All @@ -791,7 +794,8 @@ describe('AppAuth', () => {
false,
config.customHeaders,
config.androidAllowCustomBrowsers,
config.androidTrustedWebActivity
config.androidTrustedWebActivity,
config.androidPrefersEphemeralSession
);
});

Expand All @@ -813,7 +817,8 @@ describe('AppAuth', () => {
true,
config.customHeaders,
config.androidAllowCustomBrowsers,
config.androidTrustedWebActivity
config.androidTrustedWebActivity,
config.androidPrefersEphemeralSession
);
});
});
Expand Down Expand Up @@ -844,7 +849,8 @@ describe('AppAuth', () => {
false,
customHeaders,
config.androidAllowCustomBrowsers,
config.androidTrustedWebActivity
config.androidTrustedWebActivity,
config.androidPrefersEphemeralSession
);
});
});
Expand Down