@douvery/auth 0.3.0 → 0.3.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.
- package/dist/qwik/index.d.ts +3 -279
- package/dist/qwik/index.js +3 -919
- package/dist/qwik/index.js.map +1 -1
- package/dist/react/index.d.ts +3 -279
- package/dist/react/index.js +3 -919
- package/dist/react/index.js.map +1 -1
- package/package.json +2 -5
package/dist/qwik/index.d.ts
CHANGED
|
@@ -1,283 +1,7 @@
|
|
|
1
1
|
import * as _builder_io_qwik from '@builder.io/qwik';
|
|
2
2
|
import { Signal } from '@builder.io/qwik';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* @douvery/auth - Core Types
|
|
6
|
-
* OAuth 2.0/OIDC type definitions
|
|
7
|
-
*/
|
|
8
|
-
interface DouveryAuthConfig {
|
|
9
|
-
/** OAuth Client ID */
|
|
10
|
-
clientId: string;
|
|
11
|
-
/** Authorization server base URL @default "https://auth.douvery.com" */
|
|
12
|
-
issuer?: string;
|
|
13
|
-
/** Redirect URI after authentication */
|
|
14
|
-
redirectUri: string;
|
|
15
|
-
/** Post-logout redirect URI */
|
|
16
|
-
postLogoutRedirectUri?: string;
|
|
17
|
-
/** OAuth scopes to request @default ["openid", "profile", "email"] */
|
|
18
|
-
scopes?: string[];
|
|
19
|
-
/** Token storage strategy @default "localStorage" */
|
|
20
|
-
storage?: "localStorage" | "sessionStorage" | "memory" | "cookie";
|
|
21
|
-
/** Custom storage implementation */
|
|
22
|
-
customStorage?: TokenStorage;
|
|
23
|
-
/** Auto-refresh tokens before expiry @default true */
|
|
24
|
-
autoRefresh?: boolean;
|
|
25
|
-
/** Seconds before expiry to trigger refresh @default 60 */
|
|
26
|
-
refreshThreshold?: number;
|
|
27
|
-
/** Enable debug logging @default false */
|
|
28
|
-
debug?: boolean;
|
|
29
|
-
}
|
|
30
|
-
interface TokenInfo {
|
|
31
|
-
accessToken: string;
|
|
32
|
-
refreshToken?: string;
|
|
33
|
-
idToken?: string;
|
|
34
|
-
expiresAt: number;
|
|
35
|
-
tokenType: string;
|
|
36
|
-
scope: string[];
|
|
37
|
-
}
|
|
38
|
-
interface User {
|
|
39
|
-
id: string;
|
|
40
|
-
email?: string;
|
|
41
|
-
emailVerified?: boolean;
|
|
42
|
-
name?: string;
|
|
43
|
-
firstName?: string;
|
|
44
|
-
lastName?: string;
|
|
45
|
-
picture?: string;
|
|
46
|
-
phoneNumber?: string;
|
|
47
|
-
phoneNumberVerified?: boolean;
|
|
48
|
-
locale?: string;
|
|
49
|
-
[key: string]: unknown;
|
|
50
|
-
}
|
|
51
|
-
type AuthStatus = "loading" | "authenticated" | "unauthenticated";
|
|
52
|
-
interface AuthState {
|
|
53
|
-
status: AuthStatus;
|
|
54
|
-
user: User | null;
|
|
55
|
-
tokens: TokenInfo | null;
|
|
56
|
-
error: AuthError | null;
|
|
57
|
-
}
|
|
58
|
-
interface TokenStorage {
|
|
59
|
-
get(key: string): string | null | Promise<string | null>;
|
|
60
|
-
set(key: string, value: string): void | Promise<void>;
|
|
61
|
-
remove(key: string): void | Promise<void>;
|
|
62
|
-
clear(): void | Promise<void>;
|
|
63
|
-
}
|
|
64
|
-
type AuthEvent = {
|
|
65
|
-
type: "INITIALIZED";
|
|
66
|
-
} | {
|
|
67
|
-
type: "LOGIN_STARTED";
|
|
68
|
-
} | {
|
|
69
|
-
type: "LOGIN_SUCCESS";
|
|
70
|
-
user: User;
|
|
71
|
-
tokens: TokenInfo;
|
|
72
|
-
} | {
|
|
73
|
-
type: "LOGIN_ERROR";
|
|
74
|
-
error: AuthError;
|
|
75
|
-
} | {
|
|
76
|
-
type: "LOGOUT_STARTED";
|
|
77
|
-
} | {
|
|
78
|
-
type: "LOGOUT_SUCCESS";
|
|
79
|
-
} | {
|
|
80
|
-
type: "LOGOUT_ERROR";
|
|
81
|
-
error: AuthError;
|
|
82
|
-
} | {
|
|
83
|
-
type: "TOKEN_REFRESHED";
|
|
84
|
-
tokens: TokenInfo;
|
|
85
|
-
} | {
|
|
86
|
-
type: "TOKEN_REFRESH_ERROR";
|
|
87
|
-
error: AuthError;
|
|
88
|
-
} | {
|
|
89
|
-
type: "SESSION_EXPIRED";
|
|
90
|
-
};
|
|
91
|
-
type AuthEventHandler = (event: AuthEvent) => void;
|
|
92
|
-
declare class AuthError extends Error {
|
|
93
|
-
code: AuthErrorCode;
|
|
94
|
-
cause?: Error | undefined;
|
|
95
|
-
constructor(code: AuthErrorCode, message: string, cause?: Error | undefined);
|
|
96
|
-
}
|
|
97
|
-
type AuthErrorCode = "invalid_request" | "invalid_client" | "invalid_grant" | "unauthorized_client" | "unsupported_grant_type" | "invalid_scope" | "access_denied" | "server_error" | "temporarily_unavailable" | "login_required" | "consent_required" | "interaction_required" | "invalid_token" | "insufficient_scope" | "token_expired" | "token_refresh_failed" | "pkce_error" | "state_mismatch" | "nonce_mismatch" | "network_error" | "configuration_error" | "unknown_error";
|
|
98
|
-
interface CallbackResult {
|
|
99
|
-
success: boolean;
|
|
100
|
-
user?: User;
|
|
101
|
-
tokens?: TokenInfo;
|
|
102
|
-
error?: AuthError;
|
|
103
|
-
returnTo?: string;
|
|
104
|
-
}
|
|
105
|
-
interface LoginOptions {
|
|
106
|
-
/** URL to return to after login */
|
|
107
|
-
returnTo?: string;
|
|
108
|
-
/** Additional authorization parameters */
|
|
109
|
-
authorizationParams?: Record<string, string>;
|
|
110
|
-
/** Prompt parameter (none, login, consent, select_account) */
|
|
111
|
-
prompt?: "none" | "login" | "consent" | "select_account";
|
|
112
|
-
/** Login hint (email or identifier) */
|
|
113
|
-
loginHint?: string;
|
|
114
|
-
/** UI locales preference */
|
|
115
|
-
uiLocales?: string;
|
|
116
|
-
/** Maximum authentication age in seconds */
|
|
117
|
-
maxAge?: number;
|
|
118
|
-
/** ACR values requested */
|
|
119
|
-
acrValues?: string;
|
|
120
|
-
}
|
|
121
|
-
interface LogoutOptions {
|
|
122
|
-
/** URL to return to after logout */
|
|
123
|
-
returnTo?: string;
|
|
124
|
-
/** Whether to federate logout (end session at IdP) @default true */
|
|
125
|
-
federated?: boolean;
|
|
126
|
-
/** Only clear local session, don't redirect @default false */
|
|
127
|
-
localOnly?: boolean;
|
|
128
|
-
}
|
|
129
|
-
/** Base options for all auth navigation redirects */
|
|
130
|
-
interface AuthNavigationOptions {
|
|
131
|
-
/** URL to return to after the action completes */
|
|
132
|
-
returnTo?: string;
|
|
133
|
-
/** OAuth client_id for branded experiences */
|
|
134
|
-
clientId?: string;
|
|
135
|
-
/** Open in a new tab/window instead of redirecting */
|
|
136
|
-
openInNewTab?: boolean;
|
|
137
|
-
}
|
|
138
|
-
interface SelectAccountOptions extends AuthNavigationOptions {
|
|
139
|
-
/** Pre-select a specific email/account */
|
|
140
|
-
loginHint?: string;
|
|
141
|
-
}
|
|
142
|
-
interface RegisterOptions extends AuthNavigationOptions {
|
|
143
|
-
/** Pre-fill email on register form */
|
|
144
|
-
email?: string;
|
|
145
|
-
/** Pre-fill first name */
|
|
146
|
-
firstName?: string;
|
|
147
|
-
/** Pre-fill last name */
|
|
148
|
-
lastName?: string;
|
|
149
|
-
/** UI locale preference */
|
|
150
|
-
uiLocales?: string;
|
|
151
|
-
}
|
|
152
|
-
interface RecoverAccountOptions extends AuthNavigationOptions {
|
|
153
|
-
/** Pre-fill email for recovery */
|
|
154
|
-
email?: string;
|
|
155
|
-
}
|
|
156
|
-
interface VerifyAccountOptions extends AuthNavigationOptions {
|
|
157
|
-
/** Email to verify */
|
|
158
|
-
email?: string;
|
|
159
|
-
}
|
|
160
|
-
interface UpgradeAccountOptions extends AuthNavigationOptions {
|
|
161
|
-
/** Scopes to request on upgrade */
|
|
162
|
-
scopes?: string[];
|
|
163
|
-
}
|
|
164
|
-
interface SetupPasskeyOptions extends AuthNavigationOptions {
|
|
165
|
-
}
|
|
166
|
-
interface SetupAddressOptions extends AuthNavigationOptions {
|
|
167
|
-
}
|
|
168
|
-
interface AddAccountOptions extends AuthNavigationOptions {
|
|
169
|
-
/** Pre-fill email hint for the new account */
|
|
170
|
-
loginHint?: string;
|
|
171
|
-
}
|
|
172
|
-
interface RevokeTokenOptions {
|
|
173
|
-
/** Specific token to revoke. If not provided, revokes current access token */
|
|
174
|
-
token?: string;
|
|
175
|
-
/** Token type hint: "access_token" or "refresh_token" */
|
|
176
|
-
tokenTypeHint?: "access_token" | "refresh_token";
|
|
177
|
-
}
|
|
178
|
-
/** Result of URL builder methods (non-redirecting) */
|
|
179
|
-
interface AuthUrl {
|
|
180
|
-
/** The full URL */
|
|
181
|
-
url: string;
|
|
182
|
-
/** Open the URL via redirect */
|
|
183
|
-
redirect: () => void;
|
|
184
|
-
/** Open the URL in a new tab */
|
|
185
|
-
open: () => Window | null;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* @douvery/auth - Auth Client
|
|
190
|
-
* Main OAuth 2.0/OIDC client implementation
|
|
191
|
-
*/
|
|
192
|
-
|
|
193
|
-
declare class DouveryAuthClient {
|
|
194
|
-
private config;
|
|
195
|
-
private tokenManager;
|
|
196
|
-
private discovery;
|
|
197
|
-
private eventHandlers;
|
|
198
|
-
private refreshTimer;
|
|
199
|
-
private state;
|
|
200
|
-
constructor(config: DouveryAuthConfig);
|
|
201
|
-
/** Initialize the auth client */
|
|
202
|
-
initialize(): Promise<AuthState>;
|
|
203
|
-
/** Start the login flow */
|
|
204
|
-
login(options?: LoginOptions): Promise<void>;
|
|
205
|
-
/** Logout the user */
|
|
206
|
-
logout(options?: LogoutOptions): Promise<void>;
|
|
207
|
-
/** Check if current URL is an OAuth callback */
|
|
208
|
-
isCallback(): boolean;
|
|
209
|
-
/** Handle the OAuth callback */
|
|
210
|
-
handleCallback(): Promise<CallbackResult>;
|
|
211
|
-
private exchangeCode;
|
|
212
|
-
/** Refresh the access token */
|
|
213
|
-
refreshTokens(): Promise<TokenInfo>;
|
|
214
|
-
/** Get current access token (auto-refreshes if needed) */
|
|
215
|
-
getAccessToken(): Promise<string | null>;
|
|
216
|
-
/** Redirect to select/switch account */
|
|
217
|
-
selectAccount(options?: SelectAccountOptions): void;
|
|
218
|
-
/** Build select-account URL without redirecting */
|
|
219
|
-
buildSelectAccountUrl(options?: SelectAccountOptions): AuthUrl;
|
|
220
|
-
/** Redirect to add another account (multi-session) */
|
|
221
|
-
addAccount(options?: AddAccountOptions): void;
|
|
222
|
-
/** Build add-account URL without redirecting */
|
|
223
|
-
buildAddAccountUrl(options?: AddAccountOptions): AuthUrl;
|
|
224
|
-
/** Redirect to register a new account */
|
|
225
|
-
register(options?: RegisterOptions): void;
|
|
226
|
-
/** Build register URL without redirecting */
|
|
227
|
-
buildRegisterUrl(options?: RegisterOptions): AuthUrl;
|
|
228
|
-
/** Redirect to recover account (forgot password) */
|
|
229
|
-
recoverAccount(options?: RecoverAccountOptions): void;
|
|
230
|
-
/** Build recover-account URL without redirecting */
|
|
231
|
-
buildRecoverAccountUrl(options?: RecoverAccountOptions): AuthUrl;
|
|
232
|
-
/** Redirect to verify account (email verification) */
|
|
233
|
-
verifyAccount(options?: VerifyAccountOptions): void;
|
|
234
|
-
/** Build verify-account URL without redirecting */
|
|
235
|
-
buildVerifyAccountUrl(options?: VerifyAccountOptions): AuthUrl;
|
|
236
|
-
/** Redirect to upgrade account (guest → full account) */
|
|
237
|
-
upgradeAccount(options?: UpgradeAccountOptions): void;
|
|
238
|
-
/** Build upgrade-account URL without redirecting */
|
|
239
|
-
buildUpgradeAccountUrl(options?: UpgradeAccountOptions): AuthUrl;
|
|
240
|
-
/** Redirect to passkey setup */
|
|
241
|
-
setupPasskey(options?: SetupPasskeyOptions): void;
|
|
242
|
-
/** Build setup-passkey URL without redirecting */
|
|
243
|
-
buildSetupPasskeyUrl(options?: SetupPasskeyOptions): AuthUrl;
|
|
244
|
-
/** Redirect to address setup */
|
|
245
|
-
setupAddress(options?: SetupAddressOptions): void;
|
|
246
|
-
/** Build setup-address URL without redirecting */
|
|
247
|
-
buildSetupAddressUrl(options?: SetupAddressOptions): AuthUrl;
|
|
248
|
-
/** Build a login URL without redirecting (useful for links/buttons) */
|
|
249
|
-
buildLoginUrl(options?: LoginOptions): AuthUrl;
|
|
250
|
-
/** Build a logout URL without redirecting */
|
|
251
|
-
buildLogoutUrl(options?: LogoutOptions): AuthUrl;
|
|
252
|
-
/** Revoke a token (access or refresh) */
|
|
253
|
-
revokeToken(options?: RevokeTokenOptions): Promise<void>;
|
|
254
|
-
/** Check if the user's session is expired */
|
|
255
|
-
isSessionExpired(): boolean;
|
|
256
|
-
/** Check if user needs email verification */
|
|
257
|
-
needsEmailVerification(): boolean;
|
|
258
|
-
/** Check if user is a guest account */
|
|
259
|
-
isGuestAccount(): boolean;
|
|
260
|
-
private tokenSetToInfo;
|
|
261
|
-
/** Build an AuthUrl object for a given path and params */
|
|
262
|
-
private createAuthUrl;
|
|
263
|
-
/** Navigate to an auth URL, respecting openInNewTab option */
|
|
264
|
-
private navigate;
|
|
265
|
-
private fetchUser;
|
|
266
|
-
private extractUserFromIdToken;
|
|
267
|
-
private normalizeUser;
|
|
268
|
-
private getDiscovery;
|
|
269
|
-
private setupAutoRefresh;
|
|
270
|
-
private clearAutoRefresh;
|
|
271
|
-
getState(): AuthState;
|
|
272
|
-
isAuthenticated(): boolean;
|
|
273
|
-
getUser(): User | null;
|
|
274
|
-
subscribe(handler: AuthEventHandler): () => void;
|
|
275
|
-
private updateState;
|
|
276
|
-
private emit;
|
|
277
|
-
private log;
|
|
278
|
-
}
|
|
279
|
-
/** Create a new DouveryAuthClient instance */
|
|
280
|
-
declare function createDouveryAuth(config: DouveryAuthConfig): DouveryAuthClient;
|
|
3
|
+
import { AuthState, DouveryAuthClient, DouveryAuthConfig, LoginOptions, LogoutOptions, SelectAccountOptions, AddAccountOptions, RegisterOptions, RecoverAccountOptions, VerifyAccountOptions, UpgradeAccountOptions, SetupPasskeyOptions, SetupAddressOptions, RevokeTokenOptions, AuthUrl, User } from '@douvery/auth';
|
|
4
|
+
export { AddAccountOptions, AuthState, AuthUrl, DouveryAuthClient, DouveryAuthConfig, LoginOptions, LogoutOptions, RecoverAccountOptions, RegisterOptions, RevokeTokenOptions, SelectAccountOptions, SetupAddressOptions, SetupPasskeyOptions, UpgradeAccountOptions, User, VerifyAccountOptions, createDouveryAuth } from '@douvery/auth';
|
|
281
5
|
|
|
282
6
|
interface DouveryAuthContextValue {
|
|
283
7
|
state: Signal<AuthState>;
|
|
@@ -328,4 +52,4 @@ declare function useSessionStatus(): {
|
|
|
328
52
|
isGuest: Signal<boolean>;
|
|
329
53
|
};
|
|
330
54
|
|
|
331
|
-
export {
|
|
55
|
+
export { DouveryAuthContext, DouveryAuthProvider, type DouveryAuthProviderProps, useAuthActions, useAuthUrls, useDouveryAuth, useIsAuthenticated, useSessionStatus, useUser };
|