From ea3e5a381ab6c5cd52391d48dbf6ca3e1db0fb67 Mon Sep 17 00:00:00 2001 From: "Natalie B." <22222885+espeon@users.noreply.github.com> Date: Fri, 12 Dec 2025 15:10:09 -0600 Subject: [PATCH] extract resolver out so there's no import conflicts --- js/app/features/bluesky/oauthClient.tsx | 41 +---------------------- js/app/features/bluesky/oauthResolver.tsx | 40 ++++++++++++++++++++++ 2 files changed, 41 insertions(+), 40 deletions(-) create mode 100644 js/app/features/bluesky/oauthResolver.tsx diff --git a/js/app/features/bluesky/oauthClient.tsx b/js/app/features/bluesky/oauthClient.tsx index 0dee866e..89d464e4 100644 --- a/js/app/features/bluesky/oauthClient.tsx +++ b/js/app/features/bluesky/oauthClient.tsx @@ -1,8 +1,3 @@ -import type { OAuthAuthorizationServerMetadata } from "@atproto/oauth-client"; -import { - OAuthResolver, - ResolveOAuthOptions, -} from "@atproto/oauth-client/dist/oauth-resolver"; import { ClientMetadata, clientMetadataSchema, @@ -10,41 +5,7 @@ import { } from "@streamplace/atproto-oauth-client-react-native"; import Constants from "expo-constants"; import { Platform } from "react-native"; - -class StreamplaceOAuthResolver extends OAuthResolver { - private currentResourceServer: string | null = null; - - constructor( - private streamplaceUrl: string, - ...args: ConstructorParameters - ) { - super(...args); - } - - async resolveFromService( - input: string, - options?: ResolveOAuthOptions, - ): Promise<{ - metadata: OAuthAuthorizationServerMetadata; - }> { - // Input is the resource server URL (e.g., https://selfhosted.social) - // Store it for use in login_hint - this.currentResourceServer = input; - - // Always fetch metadata from our backend - // The issuer will be our backend, not the resource server - const metadata = await this.getResourceServerMetadata( - this.streamplaceUrl, - options, - ); - - return { metadata }; - } - - getCurrentResourceServer(): string | null { - return this.currentResourceServer; - } -} +import { StreamplaceOAuthResolver } from "./oauthResolver"; export type StreamplaceOAuthClient = Omit< ReactNativeOAuthClient, diff --git a/js/app/features/bluesky/oauthResolver.tsx b/js/app/features/bluesky/oauthResolver.tsx new file mode 100644 index 00000000..54addc14 --- /dev/null +++ b/js/app/features/bluesky/oauthResolver.tsx @@ -0,0 +1,40 @@ +import type { OAuthAuthorizationServerMetadata } from "@atproto/oauth-client"; +import { + OAuthResolver, + ResolveOAuthOptions, +} from "@atproto/oauth-client/dist/oauth-resolver"; + +export class StreamplaceOAuthResolver extends OAuthResolver { + private currentResourceServer: string | null = null; + + constructor( + private streamplaceUrl: string, + ...args: ConstructorParameters + ) { + super(...args); + } + + async resolveFromService( + input: string, + options?: ResolveOAuthOptions, + ): Promise<{ + metadata: OAuthAuthorizationServerMetadata; + }> { + // Input is the resource server URL (e.g., https://selfhosted.social) + // Store it for use in login_hint + this.currentResourceServer = input; + + // Always fetch metadata from our backend + // The issuer will be our backend, not the resource server + const metadata = await this.getResourceServerMetadata( + this.streamplaceUrl, + options, + ); + + return { metadata }; + } + + getCurrentResourceServer(): string | null { + return this.currentResourceServer; + } +} -- 2.51.2