Skip to content
Merged
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
13 changes: 11 additions & 2 deletions examples/test-app/src/screens/AuthSessionLabScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from 'react';
import { useRef, useState } from 'react';
import { ScrollView, StyleSheet, Text } from 'react-native';

import { AUTH_IDP_DEFAULT_URL } from '../auth-idp-fixture';
Expand All @@ -17,8 +17,11 @@
const styles = createStyles(colors);
const [status, setStatus] = useState<SheetStatus>(initialStatus);
const [message, setMessage] = useState('Ready to open the system sign-in sheet.');
const presenting = useRef(false);

async function openSheet() {
if (presenting.current) return;
presenting.current = true;
setStatus('presenting');
setMessage('Sign-in sheet requested.');

Expand All @@ -27,9 +30,15 @@
setStatus('completed');
setMessage(`Signed in: ${callbackUrl}`);
} catch (error) {
const canceled = error instanceof Error && error.name === 'AuthSessionCanceled';
const canceled =
typeof error === 'object' &&
error !== null &&
'code' in error &&
error.code === 'ERR_AUTH_SESSION_CANCELED';

Check warning on line 37 in examples/test-app/src/screens/AuthSessionLabScreen.tsx

View check run for this annotation

apex-sentinel-staging / Apex Sentinel

minor: Cancellation still renders "error": the native module sets no error code

User taps SIGN IN then dismisses the sheet: the Swift module rejects with `Exception(name: "AuthSessionCanceled", description: ...)` and never supplies a `code:`, so `error.code === 'ERR_AUTH_SESSION_CANCELED'` is false and the screen renders `error`. Expo populates `code` only from a `code:` parameter on `Exception`; a name-only Exception surfaces its name on `error.name`, not as an `ERR_*` code.
Comment on lines +33 to +37

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Minor · Cancellation still renders "error": the native module sets no error code

User taps SIGN IN then dismisses the sheet: the Swift module rejects with Exception(name: "AuthSessionCanceled", description: ...) and never supplies a code:, so error.code === 'ERR_AUTH_SESSION_CANCELED' is false and the screen renders error. Expo populates code only from a code: parameter on Exception; a name-only Exception surfaces its name on error.name, not as an ERR_* code.

Suggested change
const canceled =
typeof error === 'object' &&
error !== null &&
'code' in error &&
error.code === 'ERR_AUTH_SESSION_CANCELED';
const canceled =
(typeof error === 'object' &&
error !== null &&
'code' in error &&
error.code === 'ERR_AUTH_SESSION_CANCELED') ||
(error instanceof Error && error.name === 'AuthSessionCanceled');
Details

persona: senior-developer, javascript

Useful? Reply @apex-sentinel-staging like, or @apex-sentinel-staging dislike <why> if it is not.

Reply @apex-sentinel-staging note ... to add context, or @apex-sentinel-staging pivot ... if it is wrong — I will re-check the cited code.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@apex-sentinel-staging pivot The pinned Expo version derives a code when Exception has a name and no explicit code. In expo-modules-core@58.0.3, Exception.code returns customCode ?? errorCodeFromString(name). I compiled Expo's unchanged Swift sources and passed the fixture's name-only exception through any Error and then any JavaScriptThrowable. It yielded ERR_AUTH_SESSION_CANCELED. The pinned expo-modules-jsi@58.0.2 async promise rejection calls JavaScriptError.from, which sets the JS Error's code from that witness. The screen's code check matches that path, so an error.name fallback would add a second contract without evidence. This verifies the pinned bridge source and the Swift code witness. Live dismissal is still unverified.

setStatus(canceled ? 'canceled' : 'error');
setMessage(error instanceof Error ? error.message : String(error));
} finally {
presenting.current = false;
}
}

Expand Down
Loading