Skip to content

Commit a2078aa

Browse files
refactor(native): Simplify presentation style handling in authorize method
1 parent e6e4b17 commit a2078aa

1 file changed

Lines changed: 7 additions & 11 deletions

File tree

src/platforms/native/bridge/NativeBridgeManager.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type {
66
NativeClearSessionOptions,
77
} from '../../../types';
88
import {
9+
SafariViewControllerPresentationStyle,
910
type LocalAuthenticationOptions,
1011
type NativeAuthorizeOptions,
1112
} from '../../../types/platform-specific';
@@ -71,16 +72,11 @@ export class NativeBridgeManager implements INativeBridge {
7172
parameters: WebAuthorizeParameters,
7273
options: NativeAuthorizeOptions
7374
): Promise<Credentials> {
74-
let presentationStyle: number | undefined;
75-
if (options.useSFSafariViewController === true) {
76-
// If just `true`, default to a safe style like `fullScreen` (value 1 from our enum)
77-
presentationStyle = 1;
78-
} else if (typeof options.useSFSafariViewController === 'object') {
79-
presentationStyle = options.useSFSafariViewController.presentationStyle;
80-
} else {
81-
// If false or undefined, pass undefined to the native layer.
82-
presentationStyle = undefined;
83-
}
75+
let presentationStyle = options.useSFSafariViewController
76+
? (options.useSFSafariViewController as { presentationStyle: number })
77+
?.presentationStyle ??
78+
SafariViewControllerPresentationStyle.fullScreen
79+
: undefined;
8480
const scheme =
8581
parameters.redirectUrl?.split('://')[0] ?? options.customScheme;
8682
const credential = await this.a0_call(
@@ -97,7 +93,7 @@ export class NativeBridgeManager implements INativeBridge {
9793
parameters.invitationUrl,
9894
options.leeway ?? 0,
9995
options.ephemeralSession ?? false,
100-
presentationStyle,
96+
presentationStyle ?? 99,
10197
parameters.additionalParameters ?? {}
10298
);
10399
return new CredentialsModel(credential);

0 commit comments

Comments
 (0)