@plyaz/types 1.39.4 → 1.39.6
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.
- package/dist/auth/adapter-interface.d.ts +140 -0
- package/dist/auth/index.cjs.map +1 -1
- package/dist/auth/index.d.ts +1 -0
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/types.d.ts +8 -2
- package/dist/campaign/index.cjs +13 -7
- package/dist/campaign/index.cjs.map +1 -1
- package/dist/campaign/index.js +13 -7
- package/dist/campaign/index.js.map +1 -1
- package/dist/campaign/schemas.d.ts +32 -17
- package/dist/index.cjs +13 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +13 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import type { AUTHPROVIDER } from "./enums";
|
|
2
|
+
import type { ConnectedAccount } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Represents an authenticated user within the system.
|
|
5
|
+
*/
|
|
6
|
+
export interface AuthAdapterUser {
|
|
7
|
+
/** Unique user identifier */
|
|
8
|
+
id: string;
|
|
9
|
+
/** Primary email address of the user */
|
|
10
|
+
email: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Represents a user session.
|
|
14
|
+
*/
|
|
15
|
+
export interface AuthSession {
|
|
16
|
+
/** Unique session identifier */
|
|
17
|
+
id: string;
|
|
18
|
+
/** Associated user identifier */
|
|
19
|
+
userId: string;
|
|
20
|
+
/** Session expiration timestamp */
|
|
21
|
+
expiresAt: Date;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Represents authentication tokens.
|
|
25
|
+
*/
|
|
26
|
+
export interface Tokens {
|
|
27
|
+
/** Access token used for authenticated requests */
|
|
28
|
+
accessToken: string;
|
|
29
|
+
/** Optional refresh token for session renewal */
|
|
30
|
+
refreshToken?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* AuthProviderAdapter
|
|
34
|
+
*
|
|
35
|
+
* Unified contract for all authentication providers (Clerk, NextAuth, Custom).
|
|
36
|
+
* Implementations must conform to this interface so that the application
|
|
37
|
+
* remains provider-agnostic.
|
|
38
|
+
*/
|
|
39
|
+
export interface AuthProviderAdapter {
|
|
40
|
+
/**
|
|
41
|
+
* Sign in an existing user.
|
|
42
|
+
*
|
|
43
|
+
* @param provider - Authentication provider identifier
|
|
44
|
+
* @param credentials - Provider-specific credentials
|
|
45
|
+
* @returns Auth result containing user, session, and tokens
|
|
46
|
+
*/
|
|
47
|
+
signIn(provider: AUTHPROVIDER, credentials?: unknown): Promise<{
|
|
48
|
+
user: AuthAdapterUser;
|
|
49
|
+
session: AuthSession;
|
|
50
|
+
tokens: Tokens;
|
|
51
|
+
}>;
|
|
52
|
+
/**
|
|
53
|
+
* Register a new user.
|
|
54
|
+
*
|
|
55
|
+
* Depending on the provider, this may be handled externally
|
|
56
|
+
* (e.g., Clerk UI) or internally (custom implementation).
|
|
57
|
+
*
|
|
58
|
+
* @param provider - Authentication provider identifier
|
|
59
|
+
* @param credentials - Provider-specific credentials
|
|
60
|
+
* @param data - Optional additional user data
|
|
61
|
+
* @returns Auth result or void if handled externally
|
|
62
|
+
*/
|
|
63
|
+
signUp(provider: AUTHPROVIDER, credentials: unknown, data?: unknown): Promise<{
|
|
64
|
+
user: AuthAdapterUser;
|
|
65
|
+
session: AuthSession;
|
|
66
|
+
tokens: Tokens;
|
|
67
|
+
}> | Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Sign out a user session.
|
|
70
|
+
*
|
|
71
|
+
* @param sessionId - Session identifier
|
|
72
|
+
*/
|
|
73
|
+
signOut(sessionId: string): Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Retrieve a session by its identifier.
|
|
76
|
+
*
|
|
77
|
+
* @param sessionId - Session identifier
|
|
78
|
+
* @returns Session or null if not found or expired
|
|
79
|
+
*/
|
|
80
|
+
getSession(sessionId: string): Promise<AuthSession | null>;
|
|
81
|
+
/**
|
|
82
|
+
* Validate a session.
|
|
83
|
+
*
|
|
84
|
+
* @param sessionId - Session identifier
|
|
85
|
+
* @returns True if session is valid, otherwise false
|
|
86
|
+
*/
|
|
87
|
+
validateSession(sessionId: string): Promise<boolean>;
|
|
88
|
+
/**
|
|
89
|
+
* Refresh an existing session using a refresh token.
|
|
90
|
+
*
|
|
91
|
+
* @param refreshToken - Refresh token
|
|
92
|
+
* @returns New session and tokens, or void if not supported
|
|
93
|
+
*/
|
|
94
|
+
refreshSession(refreshToken: string): Promise<{
|
|
95
|
+
session: AuthSession;
|
|
96
|
+
tokens: Tokens;
|
|
97
|
+
} | void>;
|
|
98
|
+
/**
|
|
99
|
+
* Generate an OAuth authorization URL.
|
|
100
|
+
*
|
|
101
|
+
* @param provider - OAuth provider
|
|
102
|
+
* @param redirectUri - Redirect URI after authentication
|
|
103
|
+
* @returns Authorization URL or void if handled externally
|
|
104
|
+
*/
|
|
105
|
+
getOAuthUrl(provider: AUTHPROVIDER, redirectUri: string): Promise<string | void>;
|
|
106
|
+
/**
|
|
107
|
+
* Handle OAuth callback after provider authentication.
|
|
108
|
+
*
|
|
109
|
+
* @param provider - OAuth provider
|
|
110
|
+
* @param code - Authorization code returned by provider
|
|
111
|
+
* @returns Provider account data or void if handled externally
|
|
112
|
+
*/
|
|
113
|
+
handleOAuthCallback(provider: AUTHPROVIDER, code: string): Promise<{
|
|
114
|
+
providerAccountId: string;
|
|
115
|
+
profile: unknown;
|
|
116
|
+
} | void>;
|
|
117
|
+
/**
|
|
118
|
+
* Link an external provider account to an existing user.
|
|
119
|
+
*
|
|
120
|
+
* @param userId - Local user identifier
|
|
121
|
+
* @param provider - Authentication provider
|
|
122
|
+
* @param data - Connected account metadata
|
|
123
|
+
* @returns Connected account or void if handled externally
|
|
124
|
+
*/
|
|
125
|
+
linkAccount(userId: string, provider: AUTHPROVIDER, data: ConnectedAccount): Promise<ConnectedAccount | void>;
|
|
126
|
+
/**
|
|
127
|
+
* Unlink an external provider account from a user.
|
|
128
|
+
*
|
|
129
|
+
* @param userId - Local user identifier
|
|
130
|
+
* @param accountId - Connected account identifier
|
|
131
|
+
*/
|
|
132
|
+
unlinkAccount(userId: string, accountId: string): Promise<void>;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Credentials object used for email/password authentication.
|
|
136
|
+
*/
|
|
137
|
+
export type Credentials = {
|
|
138
|
+
email: string;
|
|
139
|
+
password: string;
|
|
140
|
+
};
|