@bagelink/auth 1.6.53 → 1.6.61
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/README.md +284 -219
- package/dist/Callback-BHqVaZZm.cjs +4 -0
- package/dist/Callback-C-XghN_z.js +4 -0
- package/dist/ForgotPasswordPage-BV9tyhHl.cjs +4 -0
- package/dist/ForgotPasswordPage-DvttMGb0.js +4 -0
- package/dist/LoginPage-hv1wc54S.cjs +4 -0
- package/dist/LoginPage-klj1NV4J.js +4 -0
- package/dist/ResetPasswordPage-COPrJmW8.cjs +4 -0
- package/dist/ResetPasswordPage-nvQ4uupb.js +4 -0
- package/dist/SignupPage-m36w9PLJ.cjs +4 -0
- package/dist/SignupPage-oUFYApYW.js +4 -0
- package/dist/api.d.ts +115 -0
- package/dist/components/auth/ForgotPasswordForm.vue.d.ts +23 -0
- package/dist/components/auth/LoginForm.vue.d.ts +58 -0
- package/dist/components/auth/ResetPasswordForm.vue.d.ts +28 -0
- package/dist/components/auth/SignupForm.vue.d.ts +34 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/constants.d.ts +34 -0
- package/dist/index.cjs +1227 -30
- package/dist/index.d.ts +16 -631
- package/dist/index.mjs +1242 -24
- package/dist/pages/Callback.vue.d.ts +2 -0
- package/dist/pages/ForgotPasswordPage.vue.d.ts +13 -0
- package/dist/pages/LoginPage.vue.d.ts +38 -0
- package/dist/pages/ResetPasswordPage.vue.d.ts +13 -0
- package/dist/pages/SignupPage.vue.d.ts +16 -0
- package/dist/routes.d.ts +49 -0
- package/dist/sso.d.ts +145 -0
- package/dist/types/index.d.ts +41 -0
- package/dist/types.d.ts +254 -0
- package/dist/useAuth.d.ts +112 -0
- package/dist/utils.d.ts +11 -0
- package/package.json +11 -13
- package/src/components/auth/ForgotPasswordForm.vue +97 -0
- package/src/components/auth/LoginForm.vue +257 -0
- package/src/components/auth/ResetPasswordForm.vue +146 -0
- package/src/components/auth/SignupForm.vue +224 -0
- package/src/components/index.ts +5 -0
- package/src/constants.ts +10 -0
- package/src/index.ts +26 -1
- package/src/pages/Callback.vue +183 -0
- package/src/pages/ForgotPasswordPage.vue +42 -0
- package/src/pages/LoginPage.vue +68 -0
- package/src/pages/ResetPasswordPage.vue +47 -0
- package/src/pages/SignupPage.vue +46 -0
- package/src/routes.ts +122 -0
- package/src/types/index.ts +45 -0
- package/dist/index.d.cts +0 -631
- package/dist/index.d.mts +0 -631
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, HTMLDivElement>;
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ForgotPasswordTexts } from '../components/auth/ForgotPasswordForm.vue';
|
|
2
|
+
interface Props {
|
|
3
|
+
/** Custom texts for the forgot password form */
|
|
4
|
+
texts?: Partial<ForgotPasswordTexts>;
|
|
5
|
+
/** Card styling */
|
|
6
|
+
cardWidth?: string;
|
|
7
|
+
cardShadow?: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare const _default: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<Props> & Readonly<{}>, {
|
|
10
|
+
cardWidth: string;
|
|
11
|
+
cardShadow: boolean;
|
|
12
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { LoginTexts } from '../components/auth/LoginForm.vue';
|
|
2
|
+
interface Props {
|
|
3
|
+
/** Custom texts for the login form */
|
|
4
|
+
texts?: Partial<LoginTexts>;
|
|
5
|
+
/** Show/hide specific SSO providers */
|
|
6
|
+
showGithub?: boolean;
|
|
7
|
+
showGoogle?: boolean;
|
|
8
|
+
showMicrosoft?: boolean;
|
|
9
|
+
showApple?: boolean;
|
|
10
|
+
showOkta?: boolean;
|
|
11
|
+
showFacebook?: boolean;
|
|
12
|
+
/** SSO button styling */
|
|
13
|
+
ssoOutline?: boolean;
|
|
14
|
+
ssoShowValue?: boolean;
|
|
15
|
+
ssoBrandBackground?: boolean;
|
|
16
|
+
/** Show/hide form elements */
|
|
17
|
+
showForgotPassword?: boolean;
|
|
18
|
+
showSignupButton?: boolean;
|
|
19
|
+
/** Card styling */
|
|
20
|
+
cardWidth?: string;
|
|
21
|
+
cardShadow?: boolean;
|
|
22
|
+
}
|
|
23
|
+
declare const _default: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<Props> & Readonly<{}>, {
|
|
24
|
+
showForgotPassword: boolean;
|
|
25
|
+
showSignupButton: boolean;
|
|
26
|
+
ssoOutline: boolean;
|
|
27
|
+
ssoShowValue: boolean;
|
|
28
|
+
ssoBrandBackground: boolean;
|
|
29
|
+
cardWidth: string;
|
|
30
|
+
cardShadow: boolean;
|
|
31
|
+
showGithub: boolean;
|
|
32
|
+
showGoogle: boolean;
|
|
33
|
+
showMicrosoft: boolean;
|
|
34
|
+
showApple: boolean;
|
|
35
|
+
showOkta: boolean;
|
|
36
|
+
showFacebook: boolean;
|
|
37
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
38
|
+
export default _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ResetPasswordTexts } from '../components/auth/ResetPasswordForm.vue';
|
|
2
|
+
interface Props {
|
|
3
|
+
/** Custom texts for the reset password form */
|
|
4
|
+
texts?: Partial<ResetPasswordTexts>;
|
|
5
|
+
/** Card styling */
|
|
6
|
+
cardWidth?: string;
|
|
7
|
+
cardShadow?: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare const _default: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<Props> & Readonly<{}>, {
|
|
10
|
+
cardWidth: string;
|
|
11
|
+
cardShadow: boolean;
|
|
12
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SignupTexts } from '../components/auth/SignupForm.vue';
|
|
2
|
+
interface Props {
|
|
3
|
+
/** Custom texts for the signup form */
|
|
4
|
+
texts?: Partial<SignupTexts>;
|
|
5
|
+
/** Show name fields (first name, last name) */
|
|
6
|
+
showNames?: boolean;
|
|
7
|
+
/** Card styling */
|
|
8
|
+
cardWidth?: string;
|
|
9
|
+
cardShadow?: boolean;
|
|
10
|
+
}
|
|
11
|
+
declare const _default: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<Props> & Readonly<{}>, {
|
|
12
|
+
showNames: boolean;
|
|
13
|
+
cardWidth: string;
|
|
14
|
+
cardShadow: boolean;
|
|
15
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
16
|
+
export default _default;
|
package/dist/routes.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { RouteRecordRaw } from 'vue-router';
|
|
2
|
+
export interface AuthRouteConfig {
|
|
3
|
+
/** Base path for auth routes. Defaults to '/' */
|
|
4
|
+
basePath?: string;
|
|
5
|
+
/** Route names prefix. Defaults to '' */
|
|
6
|
+
namePrefix?: string;
|
|
7
|
+
/** Custom route names */
|
|
8
|
+
routeNames?: {
|
|
9
|
+
login?: string;
|
|
10
|
+
signup?: string;
|
|
11
|
+
forgotPassword?: string;
|
|
12
|
+
resetPassword?: string;
|
|
13
|
+
callback?: string;
|
|
14
|
+
};
|
|
15
|
+
/** Redirect path after successful auth. Defaults to '/' */
|
|
16
|
+
redirectTo?: string;
|
|
17
|
+
/** Custom layout wrapper component */
|
|
18
|
+
layout?: any;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Creates auth routes for Vue Router
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* import { createAuthRoutes } from '@bagelink/auth'
|
|
26
|
+
*
|
|
27
|
+
* const routes = [
|
|
28
|
+
* ...createAuthRoutes({
|
|
29
|
+
* basePath: '/auth',
|
|
30
|
+
* redirectTo: '/dashboard'
|
|
31
|
+
* }),
|
|
32
|
+
* // ... other routes
|
|
33
|
+
* ]
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function createAuthRoutes(config?: AuthRouteConfig): RouteRecordRaw[];
|
|
37
|
+
/**
|
|
38
|
+
* Creates a navigation guard to redirect authenticated users away from auth pages
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* import { createAuthGuard } from '@bagelink/auth'
|
|
43
|
+
*
|
|
44
|
+
* router.beforeEach(createAuthGuard({ redirectTo: '/dashboard' }))
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function createAuthGuard(config?: {
|
|
48
|
+
redirectTo?: string;
|
|
49
|
+
}): (to: any, _from: any, next: any) => Promise<void>;
|
package/dist/sso.d.ts
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { SSOProvider, AuthenticationResponse } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Set the auth context for SSO operations
|
|
4
|
+
* This is called automatically when using useAuth()
|
|
5
|
+
*/
|
|
6
|
+
export declare function setAuthContext(authApi: any): void;
|
|
7
|
+
/**
|
|
8
|
+
* SSO Provider Configuration
|
|
9
|
+
*/
|
|
10
|
+
export interface SSOProviderConfig {
|
|
11
|
+
/** Provider identifier */
|
|
12
|
+
id: SSOProvider;
|
|
13
|
+
/** Display name */
|
|
14
|
+
name: string;
|
|
15
|
+
/** Brand color (hex) */
|
|
16
|
+
color: string;
|
|
17
|
+
/** Icon identifier (for UI libraries) */
|
|
18
|
+
icon: string;
|
|
19
|
+
/** Default OAuth scopes */
|
|
20
|
+
defaultScopes: string[];
|
|
21
|
+
/** Provider-specific metadata */
|
|
22
|
+
metadata?: {
|
|
23
|
+
authDomain?: string;
|
|
24
|
+
buttonText?: string;
|
|
25
|
+
[key: string]: any;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* OAuth Flow Options
|
|
30
|
+
*/
|
|
31
|
+
export interface OAuthFlowOptions {
|
|
32
|
+
/** Custom redirect URI (defaults to current origin + /auth/callback) */
|
|
33
|
+
redirectUri?: string;
|
|
34
|
+
/** State parameter for CSRF protection (auto-generated if not provided) */
|
|
35
|
+
state?: string;
|
|
36
|
+
/** Custom scopes (overrides provider defaults) */
|
|
37
|
+
scopes?: string[];
|
|
38
|
+
/** Additional OAuth parameters (prompt, login_hint, hd, domain, etc.) */
|
|
39
|
+
params?: Record<string, string>;
|
|
40
|
+
/** Popup window dimensions */
|
|
41
|
+
popupDimensions?: {
|
|
42
|
+
width?: number;
|
|
43
|
+
height?: number;
|
|
44
|
+
};
|
|
45
|
+
/** Timeout for popup flow in milliseconds (default: 90000) */
|
|
46
|
+
popupTimeout?: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Popup Result
|
|
50
|
+
*/
|
|
51
|
+
export interface PopupResult {
|
|
52
|
+
code: string;
|
|
53
|
+
state?: string;
|
|
54
|
+
error?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* SSO Error Types
|
|
58
|
+
*/
|
|
59
|
+
export declare class SSOError extends Error {
|
|
60
|
+
code: string;
|
|
61
|
+
constructor(message: string, code: string);
|
|
62
|
+
}
|
|
63
|
+
export declare class PopupBlockedError extends SSOError {
|
|
64
|
+
constructor();
|
|
65
|
+
}
|
|
66
|
+
export declare class PopupClosedError extends SSOError {
|
|
67
|
+
constructor();
|
|
68
|
+
}
|
|
69
|
+
export declare class PopupTimeoutError extends SSOError {
|
|
70
|
+
constructor();
|
|
71
|
+
}
|
|
72
|
+
export declare class StateMismatchError extends SSOError {
|
|
73
|
+
constructor();
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* SSO Provider Instance with functional methods
|
|
77
|
+
*/
|
|
78
|
+
export interface SSOProviderInstance extends SSOProviderConfig {
|
|
79
|
+
/**
|
|
80
|
+
* Initiate OAuth flow with redirect (most common)
|
|
81
|
+
* User is redirected to provider's authorization page
|
|
82
|
+
*/
|
|
83
|
+
redirect: (options?: OAuthFlowOptions) => Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Initiate OAuth flow in a popup window
|
|
86
|
+
* Returns the authorization code without leaving the page
|
|
87
|
+
*/
|
|
88
|
+
popup: (options?: OAuthFlowOptions) => Promise<AuthenticationResponse>;
|
|
89
|
+
/**
|
|
90
|
+
* Complete OAuth flow after callback
|
|
91
|
+
* Call this on your callback page
|
|
92
|
+
*/
|
|
93
|
+
callback: (code: string, state?: string) => Promise<AuthenticationResponse>;
|
|
94
|
+
/**
|
|
95
|
+
* Link this provider to the current logged-in user
|
|
96
|
+
* Call this after OAuth redirect completes on link callback page
|
|
97
|
+
*/
|
|
98
|
+
link: (code: string, state?: string) => Promise<void>;
|
|
99
|
+
/**
|
|
100
|
+
* Unlink this provider from the current user
|
|
101
|
+
*/
|
|
102
|
+
unlink: () => Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Get authorization URL without redirecting
|
|
105
|
+
*/
|
|
106
|
+
getAuthUrl: (options?: OAuthFlowOptions) => Promise<string>;
|
|
107
|
+
/**
|
|
108
|
+
* Whether this provider supports popup flow
|
|
109
|
+
* Some providers (like Apple) work better with redirect
|
|
110
|
+
*/
|
|
111
|
+
supportsPopup?: boolean;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* SSO object type with providers and helper methods
|
|
115
|
+
*/
|
|
116
|
+
export interface SSOObject {
|
|
117
|
+
google: SSOProviderInstance;
|
|
118
|
+
microsoft: SSOProviderInstance;
|
|
119
|
+
github: SSOProviderInstance;
|
|
120
|
+
okta: SSOProviderInstance;
|
|
121
|
+
apple: SSOProviderInstance;
|
|
122
|
+
facebook: SSOProviderInstance;
|
|
123
|
+
handleCallback: () => Promise<AuthenticationResponse | null>;
|
|
124
|
+
handleLinkCallback: () => Promise<void>;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* SSO object with providers and global helper methods
|
|
128
|
+
*/
|
|
129
|
+
export declare const sso: SSOObject;
|
|
130
|
+
/**
|
|
131
|
+
* Array of all SSO provider instances
|
|
132
|
+
*/
|
|
133
|
+
export declare const ssoProvidersList: readonly SSOProviderInstance[];
|
|
134
|
+
/**
|
|
135
|
+
* Get SSO provider instance by ID
|
|
136
|
+
*/
|
|
137
|
+
export declare function getSSOProvider(provider: SSOProvider): SSOProviderInstance | undefined;
|
|
138
|
+
/**
|
|
139
|
+
* Get all available SSO providers
|
|
140
|
+
*/
|
|
141
|
+
export declare function getAllSSOProviders(): readonly SSOProviderInstance[];
|
|
142
|
+
/**
|
|
143
|
+
* Check if a provider is supported
|
|
144
|
+
*/
|
|
145
|
+
export declare function isSupportedProvider(provider: string): provider is SSOProvider;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface ForgotPasswordTexts {
|
|
2
|
+
title?: string;
|
|
3
|
+
emailLabel?: string;
|
|
4
|
+
submitButton?: string;
|
|
5
|
+
backToLogin?: string;
|
|
6
|
+
emailSentTitle?: string;
|
|
7
|
+
emailSentMessage?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface LoginTexts {
|
|
10
|
+
title?: string;
|
|
11
|
+
emailLabel?: string;
|
|
12
|
+
passwordLabel?: string;
|
|
13
|
+
forgotPassword?: string;
|
|
14
|
+
submitButton?: string;
|
|
15
|
+
noAccount?: string;
|
|
16
|
+
signupLink?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface ResetPasswordTexts {
|
|
19
|
+
title?: string;
|
|
20
|
+
newPasswordLabel?: string;
|
|
21
|
+
confirmPasswordLabel?: string;
|
|
22
|
+
submitButton?: string;
|
|
23
|
+
passwordStrength?: {
|
|
24
|
+
weak?: string;
|
|
25
|
+
medium?: string;
|
|
26
|
+
strong?: string;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export interface SignupTexts {
|
|
30
|
+
title?: string;
|
|
31
|
+
emailLabel?: string;
|
|
32
|
+
passwordLabel?: string;
|
|
33
|
+
submitButton?: string;
|
|
34
|
+
haveAccount?: string;
|
|
35
|
+
loginLink?: string;
|
|
36
|
+
passwordStrength?: {
|
|
37
|
+
weak?: string;
|
|
38
|
+
medium?: string;
|
|
39
|
+
strong?: string;
|
|
40
|
+
};
|
|
41
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { AxiosResponse } from 'axios';
|
|
2
|
+
export declare enum AuthState {
|
|
3
|
+
LOGIN = "login",
|
|
4
|
+
LOGOUT = "logout",
|
|
5
|
+
SIGNUP = "signup",
|
|
6
|
+
PASSWORD_RESET = "password_reset",
|
|
7
|
+
PASSWORD_CHANGE = "password_change",
|
|
8
|
+
PROFILE_UPDATE = "profile_update",
|
|
9
|
+
AUTH_CHECK = "auth_check",
|
|
10
|
+
EMAIL_VERIFIED = "email_verified",
|
|
11
|
+
SESSION_REFRESH = "session_refresh"
|
|
12
|
+
}
|
|
13
|
+
export type AuthEventHandler = () => void;
|
|
14
|
+
export interface AuthEventMap {
|
|
15
|
+
[AuthState.LOGIN]: AuthEventHandler;
|
|
16
|
+
[AuthState.LOGOUT]: AuthEventHandler;
|
|
17
|
+
[AuthState.SIGNUP]: AuthEventHandler;
|
|
18
|
+
[AuthState.PASSWORD_RESET]: AuthEventHandler;
|
|
19
|
+
[AuthState.PASSWORD_CHANGE]: AuthEventHandler;
|
|
20
|
+
[AuthState.PROFILE_UPDATE]: AuthEventHandler;
|
|
21
|
+
[AuthState.AUTH_CHECK]: AuthEventHandler;
|
|
22
|
+
[AuthState.EMAIL_VERIFIED]: AuthEventHandler;
|
|
23
|
+
[AuthState.SESSION_REFRESH]: AuthEventHandler;
|
|
24
|
+
}
|
|
25
|
+
export type AuthenticationAccountType = 'person' | 'entity' | 'service';
|
|
26
|
+
export type AuthenticationMethodType = 'password' | 'email_token' | 'sso' | 'otp';
|
|
27
|
+
export type SSOProvider = 'google' | 'microsoft' | 'github' | 'okta' | 'apple' | 'facebook';
|
|
28
|
+
export interface AuthenticationAccount {
|
|
29
|
+
created_at?: string;
|
|
30
|
+
updated_at?: string;
|
|
31
|
+
account_type?: AuthenticationAccountType;
|
|
32
|
+
person_id?: string;
|
|
33
|
+
entity_id?: string;
|
|
34
|
+
display_name?: string;
|
|
35
|
+
is_active?: boolean;
|
|
36
|
+
is_verified?: boolean;
|
|
37
|
+
account_metadata?: string;
|
|
38
|
+
last_login_at?: string;
|
|
39
|
+
failed_login_attempts?: number;
|
|
40
|
+
locked_until?: string;
|
|
41
|
+
id: string;
|
|
42
|
+
}
|
|
43
|
+
export interface PersonInfo {
|
|
44
|
+
id: string;
|
|
45
|
+
name: string;
|
|
46
|
+
email?: string;
|
|
47
|
+
phone?: string;
|
|
48
|
+
roles: string[];
|
|
49
|
+
first_name: string;
|
|
50
|
+
last_name: string;
|
|
51
|
+
}
|
|
52
|
+
export interface AuthMethodInfo {
|
|
53
|
+
id: string;
|
|
54
|
+
type: string;
|
|
55
|
+
identifier?: string;
|
|
56
|
+
is_verified: boolean;
|
|
57
|
+
last_used?: string;
|
|
58
|
+
use_count: number;
|
|
59
|
+
provider?: SSOProvider;
|
|
60
|
+
provider_user_id?: string;
|
|
61
|
+
}
|
|
62
|
+
export interface AccountInfo {
|
|
63
|
+
id: string;
|
|
64
|
+
account_type: string;
|
|
65
|
+
display_name: string;
|
|
66
|
+
is_active: boolean;
|
|
67
|
+
is_verified: boolean;
|
|
68
|
+
last_login?: string;
|
|
69
|
+
authentication_methods: AuthMethodInfo[];
|
|
70
|
+
person?: PersonInfo;
|
|
71
|
+
entity?: EntityInfo;
|
|
72
|
+
}
|
|
73
|
+
export interface EntityInfo {
|
|
74
|
+
id: string;
|
|
75
|
+
name: string;
|
|
76
|
+
type?: string;
|
|
77
|
+
metadata?: Record<string, any>;
|
|
78
|
+
}
|
|
79
|
+
export interface SessionInfo {
|
|
80
|
+
id: string;
|
|
81
|
+
created_at: string;
|
|
82
|
+
expires_at: string;
|
|
83
|
+
ip_address?: string;
|
|
84
|
+
user_agent?: string;
|
|
85
|
+
is_current?: boolean;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Unified user representation that works for both person and entity accounts
|
|
89
|
+
* This is the primary interface for accessing user data in the application
|
|
90
|
+
*/
|
|
91
|
+
export interface User {
|
|
92
|
+
/** Unique identifier (person_id or entity_id) */
|
|
93
|
+
id: string;
|
|
94
|
+
/** Account ID */
|
|
95
|
+
accountId: string;
|
|
96
|
+
/** Display name */
|
|
97
|
+
name: string;
|
|
98
|
+
/** Email address (from person or authentication methods) */
|
|
99
|
+
email?: string;
|
|
100
|
+
/** Account type: 'person', 'entity', or 'service' */
|
|
101
|
+
type: AuthenticationAccountType;
|
|
102
|
+
/** User roles (only for person accounts) */
|
|
103
|
+
roles?: string[];
|
|
104
|
+
/** Is the account active */
|
|
105
|
+
isActive: boolean;
|
|
106
|
+
/** Is the account verified */
|
|
107
|
+
isVerified: boolean;
|
|
108
|
+
/** Last login timestamp */
|
|
109
|
+
lastLogin?: string;
|
|
110
|
+
/** Entity-specific info (only for entity accounts) */
|
|
111
|
+
entityType?: string;
|
|
112
|
+
/** Additional metadata */
|
|
113
|
+
metadata?: Record<string, any>;
|
|
114
|
+
/** Person-specific info (only for person accounts) */
|
|
115
|
+
person?: PersonInfo;
|
|
116
|
+
}
|
|
117
|
+
export interface RegisterRequest {
|
|
118
|
+
email: string;
|
|
119
|
+
first_name: string;
|
|
120
|
+
last_name: string;
|
|
121
|
+
phone_number?: string;
|
|
122
|
+
password?: string;
|
|
123
|
+
}
|
|
124
|
+
export interface UpdateAccountRequest {
|
|
125
|
+
first_name?: string;
|
|
126
|
+
last_name?: string;
|
|
127
|
+
email?: string;
|
|
128
|
+
phone_number?: string;
|
|
129
|
+
}
|
|
130
|
+
export interface PasswordLoginRequest {
|
|
131
|
+
email: string;
|
|
132
|
+
password: string;
|
|
133
|
+
}
|
|
134
|
+
export interface ChangePasswordRequest {
|
|
135
|
+
current_password: string;
|
|
136
|
+
new_password: string;
|
|
137
|
+
}
|
|
138
|
+
export interface ForgotPasswordRequest {
|
|
139
|
+
email: string;
|
|
140
|
+
}
|
|
141
|
+
export interface ResetPasswordRequest {
|
|
142
|
+
token: string;
|
|
143
|
+
new_password: string;
|
|
144
|
+
}
|
|
145
|
+
export interface SendVerificationRequest {
|
|
146
|
+
email?: string;
|
|
147
|
+
}
|
|
148
|
+
export interface VerifyEmailRequest {
|
|
149
|
+
token: string;
|
|
150
|
+
}
|
|
151
|
+
export interface NewUser extends RegisterRequest {
|
|
152
|
+
confirmPassword: string;
|
|
153
|
+
}
|
|
154
|
+
export interface UpdatePasswordForm extends ChangePasswordRequest {
|
|
155
|
+
confirmNewPassword: string;
|
|
156
|
+
}
|
|
157
|
+
export interface MessageResponse {
|
|
158
|
+
message: string;
|
|
159
|
+
}
|
|
160
|
+
export interface AuthStatusResponse {
|
|
161
|
+
status: string;
|
|
162
|
+
methods: string[];
|
|
163
|
+
}
|
|
164
|
+
export interface AvailableMethodsResponse {
|
|
165
|
+
available_methods: {
|
|
166
|
+
[key: string]: any;
|
|
167
|
+
}[];
|
|
168
|
+
}
|
|
169
|
+
export interface OTPMetadata {
|
|
170
|
+
nonce: string;
|
|
171
|
+
verification_hash: string;
|
|
172
|
+
timestamp: number;
|
|
173
|
+
expires_in_minutes: number;
|
|
174
|
+
autofill: {
|
|
175
|
+
[key: string]: any;
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
export interface SSOMetadata {
|
|
179
|
+
provider: SSOProvider;
|
|
180
|
+
sso_user_info: {
|
|
181
|
+
[key: string]: any;
|
|
182
|
+
};
|
|
183
|
+
can_create_account?: boolean;
|
|
184
|
+
}
|
|
185
|
+
export interface SSOInitiateRequest {
|
|
186
|
+
provider: SSOProvider;
|
|
187
|
+
redirect_uri?: string;
|
|
188
|
+
state?: string;
|
|
189
|
+
scopes?: string[];
|
|
190
|
+
params?: Record<string, string>;
|
|
191
|
+
code_challenge?: string;
|
|
192
|
+
code_challenge_method?: 'S256' | 'plain';
|
|
193
|
+
}
|
|
194
|
+
export interface SSOCallbackRequest {
|
|
195
|
+
provider: SSOProvider;
|
|
196
|
+
code: string;
|
|
197
|
+
state?: string;
|
|
198
|
+
}
|
|
199
|
+
export interface SSOLinkRequest {
|
|
200
|
+
provider: SSOProvider;
|
|
201
|
+
code: string;
|
|
202
|
+
state: string;
|
|
203
|
+
}
|
|
204
|
+
export interface SSOUnlinkRequest {
|
|
205
|
+
provider: SSOProvider;
|
|
206
|
+
}
|
|
207
|
+
export interface AuthenticationResponse {
|
|
208
|
+
success: boolean;
|
|
209
|
+
account_id?: string;
|
|
210
|
+
session_token?: string;
|
|
211
|
+
requires_verification?: boolean;
|
|
212
|
+
verification_method?: AuthenticationMethodType;
|
|
213
|
+
message?: string;
|
|
214
|
+
metadata?: OTPMetadata | SSOMetadata | {
|
|
215
|
+
[key: string]: any;
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
export interface SessionListResponse {
|
|
219
|
+
account_id: string;
|
|
220
|
+
sessions: SessionInfo[];
|
|
221
|
+
}
|
|
222
|
+
export type LoginResponse = AxiosResponse<AuthenticationResponse>;
|
|
223
|
+
export type RegisterResponse = AxiosResponse<AuthenticationResponse>;
|
|
224
|
+
export type LogoutResponse = AxiosResponse<MessageResponse>;
|
|
225
|
+
export type GetMeResponse = AxiosResponse<AccountInfo>;
|
|
226
|
+
export type UpdateMeResponse = AxiosResponse<AccountInfo>;
|
|
227
|
+
export type DeleteMeResponse = AxiosResponse<MessageResponse>;
|
|
228
|
+
export type GetAccountResponse = AxiosResponse<AccountInfo>;
|
|
229
|
+
export type UpdateAccountResponse = AxiosResponse<AccountInfo>;
|
|
230
|
+
export type DeleteAccountResponse = AxiosResponse<MessageResponse>;
|
|
231
|
+
export type ActivateAccountResponse = AxiosResponse<AccountInfo>;
|
|
232
|
+
export type DeactivateAccountResponse = AxiosResponse<AccountInfo>;
|
|
233
|
+
export type ChangePasswordResponse = AxiosResponse<MessageResponse>;
|
|
234
|
+
export type ForgotPasswordResponse = AxiosResponse<MessageResponse>;
|
|
235
|
+
export type ResetPasswordResponse = AxiosResponse<MessageResponse>;
|
|
236
|
+
export type VerifyResetTokenResponse = AxiosResponse<MessageResponse>;
|
|
237
|
+
export type SendVerificationResponse = AxiosResponse<MessageResponse>;
|
|
238
|
+
export type VerifyEmailResponse = AxiosResponse<MessageResponse>;
|
|
239
|
+
export type RefreshSessionResponse = AxiosResponse<AuthenticationResponse>;
|
|
240
|
+
export type GetSessionsResponse = AxiosResponse<SessionListResponse>;
|
|
241
|
+
export type DeleteSessionResponse = AxiosResponse<MessageResponse>;
|
|
242
|
+
export type DeleteAllSessionsResponse = AxiosResponse<MessageResponse>;
|
|
243
|
+
export type CleanupSessionsResponse = AxiosResponse<MessageResponse>;
|
|
244
|
+
export type GetMethodsResponse = AxiosResponse<AvailableMethodsResponse>;
|
|
245
|
+
export type SSOInitiateResponse = AxiosResponse<{
|
|
246
|
+
authorization_url: string;
|
|
247
|
+
}>;
|
|
248
|
+
export type SSOCallbackResponse = AxiosResponse<AuthenticationResponse>;
|
|
249
|
+
export type SSOLinkResponse = AxiosResponse<MessageResponse>;
|
|
250
|
+
export type SSOUnlinkResponse = AxiosResponse<MessageResponse>;
|
|
251
|
+
/**
|
|
252
|
+
* Extract unified user from account info
|
|
253
|
+
*/
|
|
254
|
+
export declare function accountToUser(account: AccountInfo | null): User | null;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { App } from 'vue';
|
|
2
|
+
import { AccountInfo, User, NewUser, UpdatePasswordForm, UpdateAccountRequest, AuthEventMap, SSOProvider, SSOInitiateRequest, SSOCallbackRequest, SSOLinkRequest, AuthState } from './types';
|
|
3
|
+
export declare function initAuth({ baseURL, }: {
|
|
4
|
+
baseURL: string;
|
|
5
|
+
}): {
|
|
6
|
+
on<K extends AuthState>(event: K, handler: AuthEventMap[K]): void;
|
|
7
|
+
off<K extends AuthState>(event: K, handler: AuthEventMap[K]): void;
|
|
8
|
+
removeAllListeners<K extends AuthState>(event?: K): void;
|
|
9
|
+
install(app: App): void;
|
|
10
|
+
};
|
|
11
|
+
export declare function useAuth(): {
|
|
12
|
+
user: import('vue').ComputedRef<User | null>;
|
|
13
|
+
accountInfo: import('vue').Ref<{
|
|
14
|
+
id: string;
|
|
15
|
+
account_type: string;
|
|
16
|
+
display_name: string;
|
|
17
|
+
is_active: boolean;
|
|
18
|
+
is_verified: boolean;
|
|
19
|
+
last_login?: string | undefined;
|
|
20
|
+
authentication_methods: {
|
|
21
|
+
id: string;
|
|
22
|
+
type: string;
|
|
23
|
+
identifier?: string | undefined;
|
|
24
|
+
is_verified: boolean;
|
|
25
|
+
last_used?: string | undefined;
|
|
26
|
+
use_count: number;
|
|
27
|
+
provider?: SSOProvider | undefined;
|
|
28
|
+
provider_user_id?: string | undefined;
|
|
29
|
+
}[];
|
|
30
|
+
person?: {
|
|
31
|
+
id: string;
|
|
32
|
+
name: string;
|
|
33
|
+
email?: string | undefined;
|
|
34
|
+
phone?: string | undefined;
|
|
35
|
+
roles: string[];
|
|
36
|
+
first_name: string;
|
|
37
|
+
last_name: string;
|
|
38
|
+
} | undefined;
|
|
39
|
+
entity?: {
|
|
40
|
+
id: string;
|
|
41
|
+
name: string;
|
|
42
|
+
type?: string | undefined;
|
|
43
|
+
metadata?: Record<string, any> | undefined;
|
|
44
|
+
} | undefined;
|
|
45
|
+
} | null, AccountInfo | {
|
|
46
|
+
id: string;
|
|
47
|
+
account_type: string;
|
|
48
|
+
display_name: string;
|
|
49
|
+
is_active: boolean;
|
|
50
|
+
is_verified: boolean;
|
|
51
|
+
last_login?: string | undefined;
|
|
52
|
+
authentication_methods: {
|
|
53
|
+
id: string;
|
|
54
|
+
type: string;
|
|
55
|
+
identifier?: string | undefined;
|
|
56
|
+
is_verified: boolean;
|
|
57
|
+
last_used?: string | undefined;
|
|
58
|
+
use_count: number;
|
|
59
|
+
provider?: SSOProvider | undefined;
|
|
60
|
+
provider_user_id?: string | undefined;
|
|
61
|
+
}[];
|
|
62
|
+
person?: {
|
|
63
|
+
id: string;
|
|
64
|
+
name: string;
|
|
65
|
+
email?: string | undefined;
|
|
66
|
+
phone?: string | undefined;
|
|
67
|
+
roles: string[];
|
|
68
|
+
first_name: string;
|
|
69
|
+
last_name: string;
|
|
70
|
+
} | undefined;
|
|
71
|
+
entity?: {
|
|
72
|
+
id: string;
|
|
73
|
+
name: string;
|
|
74
|
+
type?: string | undefined;
|
|
75
|
+
metadata?: Record<string, any> | undefined;
|
|
76
|
+
} | undefined;
|
|
77
|
+
} | null>;
|
|
78
|
+
sso: import('./sso').SSOObject;
|
|
79
|
+
getFullName: () => string;
|
|
80
|
+
getIsLoggedIn: () => boolean;
|
|
81
|
+
getEmail: () => string;
|
|
82
|
+
getRoles: () => string[];
|
|
83
|
+
getAccountType: () => import('./types').AuthenticationAccountType;
|
|
84
|
+
isPersonAccount: () => boolean;
|
|
85
|
+
isEntityAccount: () => boolean;
|
|
86
|
+
login: (credentials: {
|
|
87
|
+
email: string;
|
|
88
|
+
password: string;
|
|
89
|
+
}) => Promise<import('./types').AuthenticationResponse>;
|
|
90
|
+
logout: () => Promise<void>;
|
|
91
|
+
signup: (newUser: NewUser) => Promise<import('./types').AuthenticationResponse>;
|
|
92
|
+
checkAuth: () => Promise<boolean>;
|
|
93
|
+
refreshSession: () => Promise<void>;
|
|
94
|
+
initiateSSO: (params: SSOInitiateRequest) => Promise<string>;
|
|
95
|
+
loginWithSSO: (params: SSOCallbackRequest) => Promise<import('./types').AuthenticationResponse>;
|
|
96
|
+
linkSSOProvider: (params: SSOLinkRequest) => Promise<void>;
|
|
97
|
+
unlinkSSOProvider: (provider: SSOProvider) => Promise<void>;
|
|
98
|
+
updateProfile: (updates: UpdateAccountRequest) => Promise<void>;
|
|
99
|
+
deleteCurrentUser: () => Promise<void>;
|
|
100
|
+
changePassword: (form: UpdatePasswordForm) => Promise<void>;
|
|
101
|
+
forgotPassword: (email: string) => Promise<void>;
|
|
102
|
+
verifyResetToken: (token: string) => Promise<void>;
|
|
103
|
+
resetPassword: (token: string, newPassword: string) => Promise<void>;
|
|
104
|
+
sendVerification: (email?: string) => Promise<void>;
|
|
105
|
+
verifyEmail: (token: string) => Promise<void>;
|
|
106
|
+
activateAccount: (accountId: string) => Promise<void>;
|
|
107
|
+
deactivateAccount: (accountId: string) => Promise<void>;
|
|
108
|
+
deleteAccount: (accountId: string) => Promise<void>;
|
|
109
|
+
getSessions: (accountId?: string) => Promise<import('./types').GetSessionsResponse>;
|
|
110
|
+
revokeSession: (sessionToken: string) => Promise<void>;
|
|
111
|
+
revokeAllSessions: (accountId?: string) => Promise<void>;
|
|
112
|
+
};
|