Skip to content

Commit f008255

Browse files
refactor: make isOAuthClientProvider check more explicit
Check typeof === 'function' on two required methods (tokens + clientInformation) instead of bare 'in' operator. Slightly more robust — verifies they're actually callable, not just properties with those names. Same semantics, reads cleaner.
1 parent 2016076 commit f008255

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/client/src/client/auth.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,14 @@ export interface AuthProvider {
8484
/**
8585
* Type guard distinguishing `OAuthClientProvider` from a minimal `AuthProvider`.
8686
* Transports use this at construction time to classify the `authProvider` option.
87+
*
88+
* Checks for `tokens()` + `clientInformation()` — two required `OAuthClientProvider`
89+
* methods that a minimal `AuthProvider` `{ token: ... }` would never have.
8790
*/
8891
export function isOAuthClientProvider(provider: AuthProvider | OAuthClientProvider | undefined): provider is OAuthClientProvider {
89-
return provider !== undefined && 'tokens' in provider && 'clientMetadata' in provider;
92+
if (provider == null) return false;
93+
const p = provider as OAuthClientProvider;
94+
return typeof p.tokens === 'function' && typeof p.clientInformation === 'function';
9095
}
9196

9297
/**

0 commit comments

Comments
 (0)