@plyaz/types 1.12.0 → 1.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,67 +0,0 @@
1
- import type { UserContext, AuthCredentials } from '../types';
2
- /**
3
- * @plyaz/auth/providers/base/auth-service-provider.interface
4
- * The contract for all external authentication service adapters (Supabase, Internal DB, etc.).
5
- * This ensures our strategies remain vendor-agnostic.
6
- */
7
- export interface AuthServiceProvider {
8
- /**
9
- * Synchronizes an external user ID (e.g., from Clerk or Web3) with the internal RLS database.
10
- * This method ensures the user exists internally and issues an RLS token.
11
- * * @param externalId The unique ID from the external provider (e.g., Clerk's 'sub').
12
- * @param email The user's primary email address.
13
- * @returns An object containing the internal UserContext and the RLS JWT.
14
- */
15
- syncUserFromExternalToken(externalId: string, email: string): Promise<{
16
- user: UserContext;
17
- supabaseRlsToken: string;
18
- }>;
19
- /** Handles traditional login via email/password (used as a fallback or if Clerk is bypassed). */
20
- authenticate(credentials: AuthCredentials): Promise<UserContext>;
21
- /** Registers a new user with the provider. */
22
- register(credentials: AuthCredentials): Promise<UserContext>;
23
- /** Retrieves basic user profile information by internal ID. */
24
- getUserById(userId: string): Promise<UserContext | null>;
25
- /** Requests a password reset (only relevant for traditional auth flows). */
26
- requestPasswordReset(email: string): Promise<void>;
27
- }
28
- /**
29
- * The contract for all external OAuth authentication providers (Google, GitHub, etc.).
30
- * This interface ensures our strategies remain vendor-agnostic and defines
31
- * the core functionality required to authenticate with an OAuth service.
32
- */
33
- export interface OAuthProvider {
34
- /**
35
- * Generates the URL to redirect the user to for authentication.
36
- * This URL will typically include a client ID, redirect URI, and scopes.
37
- * @param redirectUrl The URL to which the user will be redirected after authentication.
38
- * @returns The full URL for the OAuth login page.
39
- */
40
- getRedirectUrl(redirectUrl: string): string;
41
- /**
42
- * Exchanges an authorization code for an access token and user information.
43
- * This method is called after the user has successfully authenticated with the provider.
44
- * @param code The authorization code received from the OAuth provider.
45
- * @returns A promise that resolves to the user's details and a refresh token.
46
- */
47
- exchangeCodeForToken(code: string): Promise<{
48
- accessToken: string;
49
- refreshToken: string;
50
- expiresIn: number;
51
- user: {
52
- providerId: string;
53
- email: string;
54
- name?: string;
55
- profileImageUrl?: string;
56
- };
57
- }>;
58
- /**
59
- * (Optional) Refreshes an access token using a refresh token.
60
- * @param refreshToken The refresh token provided by the provider.
61
- * @returns A new access token and its expiration time.
62
- */
63
- refreshToken?(refreshToken: string): Promise<{
64
- accessToken: string;
65
- expiresIn: number;
66
- }>;
67
- }