@hamak/auth-api 0.6.0 → 0.7.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.
Files changed (38) hide show
  1. package/package.json +2 -2
  2. package/dist/api/auth-service.d.ts +0 -111
  3. package/dist/api/auth-service.d.ts.map +0 -1
  4. package/dist/api/auth-service.js +0 -5
  5. package/dist/api/index.d.ts +0 -2
  6. package/dist/api/index.d.ts.map +0 -1
  7. package/dist/api/index.js +0 -1
  8. package/dist/es2015/api/auth-service.js +0 -5
  9. package/dist/es2015/api/index.js +0 -1
  10. package/dist/es2015/index.js +0 -12
  11. package/dist/es2015/tokens/index.js +0 -1
  12. package/dist/es2015/tokens/service-tokens.js +0 -24
  13. package/dist/es2015/types/auth-result.js +0 -5
  14. package/dist/es2015/types/config.js +0 -5
  15. package/dist/es2015/types/credentials.js +0 -5
  16. package/dist/es2015/types/index.js +0 -4
  17. package/dist/es2015/types/user.js +0 -5
  18. package/dist/tokens/index.d.ts +0 -2
  19. package/dist/tokens/index.d.ts.map +0 -1
  20. package/dist/tokens/index.js +0 -1
  21. package/dist/tokens/service-tokens.d.ts +0 -25
  22. package/dist/tokens/service-tokens.d.ts.map +0 -1
  23. package/dist/tokens/service-tokens.js +0 -24
  24. package/dist/types/auth-result.d.ts +0 -69
  25. package/dist/types/auth-result.d.ts.map +0 -1
  26. package/dist/types/auth-result.js +0 -5
  27. package/dist/types/config.d.ts +0 -130
  28. package/dist/types/config.d.ts.map +0 -1
  29. package/dist/types/config.js +0 -5
  30. package/dist/types/credentials.d.ts +0 -52
  31. package/dist/types/credentials.d.ts.map +0 -1
  32. package/dist/types/credentials.js +0 -5
  33. package/dist/types/index.d.ts +0 -5
  34. package/dist/types/index.d.ts.map +0 -1
  35. package/dist/types/index.js +0 -4
  36. package/dist/types/user.d.ts +0 -39
  37. package/dist/types/user.d.ts.map +0 -1
  38. package/dist/types/user.js +0 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hamak/auth-api",
3
- "version": "0.6.0",
3
+ "version": "0.7.1",
4
4
  "description": "[DEPRECATED] Use @hamak/auth/api instead",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -24,7 +24,7 @@
24
24
  "access": "public"
25
25
  },
26
26
  "scripts": {
27
- "build": "tsc -p tsconfig.lib.json",
27
+ "build": "tsc -p tsconfig.lib.json && node ../../../scripts/fix-esm-extensions.mjs ./dist",
28
28
  "clean": "rm -rf dist"
29
29
  },
30
30
  "keywords": [
@@ -1,111 +0,0 @@
1
- /**
2
- * Auth Service Interface
3
- * Core authentication service contract
4
- */
5
- import type { User } from '../types/user';
6
- import type { LoginCredentials, OAuthCallbackParams } from '../types/credentials';
7
- import type { AuthResult, AuthStateCallback } from '../types/auth-result';
8
- /**
9
- * Main authentication service interface
10
- *
11
- * Provides a unified API for all authentication operations regardless
12
- * of the underlying strategy (password, OAuth2, Keycloak, etc.)
13
- */
14
- export interface IAuthService {
15
- /**
16
- * Check if the user is currently authenticated
17
- * @returns true if authenticated with a valid token
18
- */
19
- isAuthenticated(): boolean;
20
- /**
21
- * Get the currently authenticated user
22
- * @returns The user object or null if not authenticated
23
- */
24
- getCurrentUser(): User | null;
25
- /**
26
- * Get the current access token
27
- * @returns The access token or null if not authenticated
28
- */
29
- getAccessToken(): string | null;
30
- /**
31
- * Get the user's permissions
32
- * @returns Array of permission strings
33
- */
34
- getPermissions(): string[];
35
- /**
36
- * Get the user's roles
37
- * @returns Array of role strings
38
- */
39
- getRoles(): string[];
40
- /**
41
- * Check if the user has a specific permission
42
- * @param permission The permission to check
43
- */
44
- hasPermission(permission: string): boolean;
45
- /**
46
- * Check if the user has a specific role
47
- * @param role The role to check
48
- */
49
- hasRole(role: string): boolean;
50
- /**
51
- * Check if the user has any of the specified roles
52
- * @param roles The roles to check
53
- */
54
- hasAnyRole(roles: string[]): boolean;
55
- /**
56
- * Check if the user has all of the specified roles
57
- * @param roles The roles to check
58
- */
59
- hasAllRoles(roles: string[]): boolean;
60
- /**
61
- * Authenticate with credentials
62
- * @param credentials The login credentials
63
- * @returns Authentication result
64
- */
65
- login(credentials: LoginCredentials): Promise<AuthResult>;
66
- /**
67
- * Log out the current user
68
- * Clears tokens and session data
69
- */
70
- logout(): Promise<void>;
71
- /**
72
- * Refresh the current access token
73
- * @returns New authentication result with fresh tokens
74
- */
75
- refreshToken(): Promise<AuthResult>;
76
- /**
77
- * Initiate OAuth login flow
78
- * Redirects the user to the OAuth provider's authorization page
79
- * @param provider Optional provider name for multi-provider setups
80
- */
81
- initiateOAuth(provider?: string): void;
82
- /**
83
- * Handle OAuth callback after authorization
84
- * @param params The callback parameters from the OAuth provider
85
- * @returns Authentication result
86
- */
87
- handleOAuthCallback(params: OAuthCallbackParams): Promise<AuthResult>;
88
- /**
89
- * Get the OAuth authorization URL without redirecting
90
- * @param provider Optional provider name
91
- * @returns The authorization URL
92
- */
93
- getAuthorizationUrl(provider?: string): string | null;
94
- /**
95
- * Subscribe to authentication state changes
96
- * @param callback Function called when auth state changes
97
- * @returns Unsubscribe function
98
- */
99
- onAuthStateChange(callback: AuthStateCallback): () => void;
100
- /**
101
- * Initialize the auth service
102
- * Restores session from storage if available
103
- */
104
- initialize(): Promise<void>;
105
- /**
106
- * Destroy the auth service
107
- * Cleans up resources and event listeners
108
- */
109
- destroy(): void;
110
- }
111
- //# sourceMappingURL=auth-service.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth-service.d.ts","sourceRoot":"","sources":["../../src/api/auth-service.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAClF,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE1E;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAK3B;;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**
2
- * Auth Service Interface
3
- * Core authentication service contract
4
- */
5
- export {};
@@ -1,2 +0,0 @@
1
- export * from './auth-service';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
package/dist/api/index.js DELETED
@@ -1 +0,0 @@
1
- export * from './auth-service';
@@ -1,5 +0,0 @@
1
- /**
2
- * Auth Service Interface
3
- * Core authentication service contract
4
- */
5
- export {};
@@ -1 +0,0 @@
1
- export * from './auth-service';
@@ -1,12 +0,0 @@
1
- /**
2
- * @hamak/auth-api
3
- *
4
- * Pure interfaces and types for the pluggable authentication system.
5
- * This package contains no implementation - only contracts.
6
- */
7
- // Service tokens
8
- export * from './tokens';
9
- // Type definitions
10
- export * from './types';
11
- // API interfaces
12
- export * from './api';
@@ -1 +0,0 @@
1
- export * from './service-tokens';
@@ -1,24 +0,0 @@
1
- /**
2
- * Auth Service Tokens
3
- * Symbol-based tokens for dependency injection
4
- */
5
- /**
6
- * Token for the main authentication service
7
- */
8
- export const AUTH_SERVICE_TOKEN = Symbol('AuthService');
9
- /**
10
- * Token for the authentication strategy registry
11
- */
12
- export const AUTH_STRATEGY_REGISTRY_TOKEN = Symbol('AuthStrategyRegistry');
13
- /**
14
- * Token for the token storage service
15
- */
16
- export const TOKEN_STORAGE_TOKEN = Symbol('TokenStorage');
17
- /**
18
- * Token for the auth configuration
19
- */
20
- export const AUTH_CONFIG_TOKEN = Symbol('AuthConfig');
21
- /**
22
- * Token for the auth state selector
23
- */
24
- export const AUTH_STATE_TOKEN = Symbol('AuthState');
@@ -1,5 +0,0 @@
1
- /**
2
- * Auth Result Types
3
- * Types for authentication operation results
4
- */
5
- export {};
@@ -1,5 +0,0 @@
1
- /**
2
- * Auth Configuration Types
3
- * Configuration options for the auth system
4
- */
5
- export {};
@@ -1,5 +0,0 @@
1
- /**
2
- * Credentials Types
3
- * Types for various authentication credentials
4
- */
5
- export {};
@@ -1,4 +0,0 @@
1
- export * from './user';
2
- export * from './credentials';
3
- export * from './auth-result';
4
- export * from './config';
@@ -1,5 +0,0 @@
1
- /**
2
- * User Types
3
- * Core user-related type definitions
4
- */
5
- export {};
@@ -1,2 +0,0 @@
1
- export * from './service-tokens';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tokens/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
@@ -1 +0,0 @@
1
- export * from './service-tokens';
@@ -1,25 +0,0 @@
1
- /**
2
- * Auth Service Tokens
3
- * Symbol-based tokens for dependency injection
4
- */
5
- /**
6
- * Token for the main authentication service
7
- */
8
- export declare const AUTH_SERVICE_TOKEN: unique symbol;
9
- /**
10
- * Token for the authentication strategy registry
11
- */
12
- export declare const AUTH_STRATEGY_REGISTRY_TOKEN: unique symbol;
13
- /**
14
- * Token for the token storage service
15
- */
16
- export declare const TOKEN_STORAGE_TOKEN: unique symbol;
17
- /**
18
- * Token for the auth configuration
19
- */
20
- export declare const AUTH_CONFIG_TOKEN: unique symbol;
21
- /**
22
- * Token for the auth state selector
23
- */
24
- export declare const AUTH_STATE_TOKEN: unique symbol;
25
- //# sourceMappingURL=service-tokens.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"service-tokens.d.ts","sourceRoot":"","sources":["../../src/tokens/service-tokens.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB,eAAwB,CAAC;AAExD;;GAEG;AACH,eAAO,MAAM,4BAA4B,eAAiC,CAAC;AAE3E;;GAEG;AACH,eAAO,MAAM,mBAAmB,eAAyB,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,iBAAiB,eAAuB,CAAC;AAEtD;;GAEG;AACH,eAAO,MAAM,gBAAgB,eAAsB,CAAC"}
@@ -1,24 +0,0 @@
1
- /**
2
- * Auth Service Tokens
3
- * Symbol-based tokens for dependency injection
4
- */
5
- /**
6
- * Token for the main authentication service
7
- */
8
- export const AUTH_SERVICE_TOKEN = Symbol('AuthService');
9
- /**
10
- * Token for the authentication strategy registry
11
- */
12
- export const AUTH_STRATEGY_REGISTRY_TOKEN = Symbol('AuthStrategyRegistry');
13
- /**
14
- * Token for the token storage service
15
- */
16
- export const TOKEN_STORAGE_TOKEN = Symbol('TokenStorage');
17
- /**
18
- * Token for the auth configuration
19
- */
20
- export const AUTH_CONFIG_TOKEN = Symbol('AuthConfig');
21
- /**
22
- * Token for the auth state selector
23
- */
24
- export const AUTH_STATE_TOKEN = Symbol('AuthState');
@@ -1,69 +0,0 @@
1
- /**
2
- * Auth Result Types
3
- * Types for authentication operation results
4
- */
5
- import type { User } from './user';
6
- /**
7
- * Error codes for authentication failures
8
- */
9
- export type AuthErrorCode = 'invalid_credentials' | 'invalid_token' | 'token_expired' | 'refresh_failed' | 'no_refresh_token' | 'invalid_state' | 'network_error' | 'server_error' | 'unauthorized' | 'forbidden' | 'user_not_found' | 'account_locked' | 'account_disabled' | 'mfa_required' | 'unknown_error';
10
- /**
11
- * Authentication error details
12
- */
13
- export interface AuthError {
14
- /** Error code for programmatic handling */
15
- code: AuthErrorCode;
16
- /** Human-readable error message */
17
- message?: string;
18
- /** Additional error details */
19
- details?: Record<string, unknown>;
20
- }
21
- /**
22
- * Token information
23
- */
24
- export interface TokenInfo {
25
- /** The access token */
26
- accessToken: string;
27
- /** The refresh token (if provided) */
28
- refreshToken?: string;
29
- /** Token type (usually 'Bearer') */
30
- tokenType?: string;
31
- /** When the access token expires (timestamp in ms) */
32
- expiresAt?: number;
33
- /** Token scopes */
34
- scope?: string[];
35
- }
36
- /**
37
- * Result of an authentication operation
38
- */
39
- export interface AuthResult {
40
- /** Whether the operation succeeded */
41
- success: boolean;
42
- /** The authenticated user (on success) */
43
- user?: User;
44
- /** Access token (on success) */
45
- accessToken?: string;
46
- /** Refresh token (on success) */
47
- refreshToken?: string;
48
- /** Token type */
49
- tokenType?: string;
50
- /** When the access token expires (timestamp in ms) */
51
- expiresAt?: number;
52
- /** Token scopes */
53
- scope?: string[];
54
- /** Error details (on failure) */
55
- error?: AuthError;
56
- /** Whether MFA is required to complete login */
57
- mfaRequired?: boolean;
58
- /** MFA challenge token if MFA is required */
59
- mfaToken?: string;
60
- }
61
- /**
62
- * Auth state change event types
63
- */
64
- export type AuthStateChangeType = 'login' | 'logout' | 'token_refresh' | 'session_expired' | 'user_updated';
65
- /**
66
- * Callback for auth state changes
67
- */
68
- export type AuthStateCallback = (isAuthenticated: boolean, user: User | null, changeType?: AuthStateChangeType) => void;
69
- //# sourceMappingURL=auth-result.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth-result.d.ts","sourceRoot":"","sources":["../../src/types/auth-result.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEnC;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,qBAAqB,GACrB,eAAe,GACf,eAAe,GACf,gBAAgB,GAChB,kBAAkB,GAClB,eAAe,GACf,eAAe,GACf,cAAc,GACd,cAAc,GACd,WAAW,GACX,gBAAgB,GAChB,gBAAgB,GAChB,kBAAkB,GAClB,cAAc,GACd,eAAe,CAAC;AAEpB;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,2CAA2C;IAC3C,IAAI,EAAE,aAAa,CAAC;IACpB,mCAAmC;IACnC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,uBAAuB;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,sCAAsC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oCAAoC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mBAAmB;IACnB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,sCAAsC;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,0CAA0C;IAC1C,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,gCAAgC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iCAAiC;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mBAAmB;IACnB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,iCAAiC;IACjC,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,gDAAgD;IAChD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAC3B,OAAO,GACP,QAAQ,GACR,eAAe,GACf,iBAAiB,GACjB,cAAc,CAAC;AAEnB;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAC9B,eAAe,EAAE,OAAO,EACxB,IAAI,EAAE,IAAI,GAAG,IAAI,EACjB,UAAU,CAAC,EAAE,mBAAmB,KAC7B,IAAI,CAAC"}
@@ -1,5 +0,0 @@
1
- /**
2
- * Auth Result Types
3
- * Types for authentication operation results
4
- */
5
- export {};
@@ -1,130 +0,0 @@
1
- /**
2
- * Auth Configuration Types
3
- * Configuration options for the auth system
4
- */
5
- /**
6
- * Supported authentication strategy types
7
- */
8
- export type AuthStrategyType = 'password' | 'oauth2' | 'keycloak' | 'oidc' | 'custom';
9
- /**
10
- * Token storage options
11
- */
12
- export type TokenStorageType = 'localStorage' | 'sessionStorage' | 'memory' | 'cookie';
13
- /**
14
- * Password strategy configuration
15
- */
16
- export interface PasswordStrategyConfig {
17
- /** Endpoint for login requests */
18
- loginEndpoint: string;
19
- /** Endpoint for token refresh */
20
- refreshEndpoint: string;
21
- /** Endpoint for logout */
22
- logoutEndpoint: string;
23
- /** Endpoint for user info (optional, if not in login response) */
24
- userInfoEndpoint?: string;
25
- /** Additional headers for auth requests */
26
- headers?: Record<string, string>;
27
- }
28
- /**
29
- * OAuth2 strategy configuration
30
- */
31
- export interface OAuth2StrategyConfig {
32
- /** OAuth client ID */
33
- clientId: string;
34
- /** Client secret (only for server-side flows, not recommended for SPA) */
35
- clientSecret?: string;
36
- /** Authorization endpoint URL */
37
- authorizationUrl: string;
38
- /** Token endpoint URL */
39
- tokenUrl: string;
40
- /** User info endpoint URL */
41
- userInfoUrl?: string;
42
- /** Redirect URI after authorization */
43
- redirectUri: string;
44
- /** OAuth scopes to request */
45
- scope: string[];
46
- /** Whether to use PKCE (recommended for public clients) */
47
- usePkce?: boolean;
48
- /** Response type (default: 'code') */
49
- responseType?: 'code' | 'token';
50
- /** Additional authorization params */
51
- additionalParams?: Record<string, string>;
52
- }
53
- /**
54
- * Keycloak-specific configuration
55
- */
56
- export interface KeycloakStrategyConfig {
57
- /** Keycloak realm name */
58
- realm: string;
59
- /** Keycloak server URL */
60
- serverUrl: string;
61
- /** Client ID in Keycloak */
62
- clientId: string;
63
- /** Redirect URI after login */
64
- redirectUri: string;
65
- /** OAuth scopes (defaults to ['openid', 'profile', 'email']) */
66
- scope?: string[];
67
- /** Whether to use PKCE (default: true) */
68
- usePkce?: boolean;
69
- /** Enable direct grant (password login) if allowed in Keycloak */
70
- enableDirectGrant?: boolean;
71
- /** Keycloak realm public key for token validation (optional) */
72
- realmPublicKey?: string;
73
- }
74
- /**
75
- * Auto-refresh configuration
76
- */
77
- export interface AutoRefreshConfig {
78
- /** Enable auto-refresh of tokens */
79
- enabled: boolean;
80
- /** Time before expiry to trigger refresh (in ms, default: 60000) */
81
- threshold?: number;
82
- /** Interval to check for token expiry (in ms, default: 30000) */
83
- checkInterval?: number;
84
- }
85
- /**
86
- * Session configuration
87
- */
88
- export interface SessionConfig {
89
- /** Session timeout in ms (for inactivity) */
90
- timeout?: number;
91
- /** Warn user before session expires (in ms before timeout) */
92
- warnBefore?: number;
93
- /** Extend session on activity */
94
- extendOnActivity?: boolean;
95
- }
96
- /**
97
- * Main auth plugin configuration
98
- */
99
- export interface AuthPluginConfig {
100
- /** Primary authentication strategy */
101
- strategy: AuthStrategyType;
102
- /** Password strategy config (when strategy is 'password' or as fallback) */
103
- password?: PasswordStrategyConfig;
104
- /** OAuth2 strategy config */
105
- oauth2?: OAuth2StrategyConfig;
106
- /** Keycloak strategy config */
107
- keycloak?: KeycloakStrategyConfig;
108
- /** Token storage type (default: 'localStorage') */
109
- tokenStorage?: TokenStorageType;
110
- /** Storage key prefix (default: '@hamak/auth') */
111
- storageKeyPrefix?: string;
112
- /** Auto-refresh configuration */
113
- autoRefresh?: AutoRefreshConfig;
114
- /** Session configuration */
115
- session?: SessionConfig;
116
- /** Routes configuration */
117
- routes?: {
118
- /** Path to redirect to after login */
119
- afterLogin?: string;
120
- /** Path to redirect to after logout */
121
- afterLogout?: string;
122
- /** Login page path */
123
- login?: string;
124
- /** Unauthorized page path */
125
- unauthorized?: string;
126
- };
127
- /** Enable debug logging */
128
- debug?: boolean;
129
- }
130
- //# sourceMappingURL=config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEtF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,cAAc,GAAG,gBAAgB,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEvF;;GAEG;AACH,MAAM,WAAW,sBA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jB"}
@@ -1,5 +0,0 @@
1
- /**
2
- * Auth Configuration Types
3
- * Configuration options for the auth system
4
- */
5
- export {};
@@ -1,52 +0,0 @@
1
- /**
2
- * Credentials Types
3
- * Types for various authentication credentials
4
- */
5
- /**
6
- * Password-based login credentials
7
- */
8
- export interface PasswordCredentials {
9
- type: 'password';
10
- username: string;
11
- password: string;
12
- /** Optional remember me flag for persistent sessions */
13
- rememberMe?: boolean;
14
- }
15
- /**
16
- * OAuth authorization code credentials
17
- */
18
- export interface OAuthCredentials {
19
- type: 'oauth';
20
- /** The authorization code received from OAuth provider */
21
- code: string;
22
- /** The state parameter for CSRF protection */
23
- state?: string;
24
- /** The OAuth provider name */
25
- provider?: string;
26
- }
27
- /**
28
- * Token-based credentials (for refresh or API key auth)
29
- */
30
- export interface TokenCredentials {
31
- type: 'token';
32
- token: string;
33
- tokenType?: 'bearer' | 'api-key' | 'refresh';
34
- }
35
- /**
36
- * Union type for all credential types
37
- */
38
- export type LoginCredentials = PasswordCredentials | OAuthCredentials | TokenCredentials;
39
- /**
40
- * OAuth callback parameters received from the provider
41
- */
42
- export interface OAuthCallbackParams {
43
- /** Authorization code */
44
- code: string;
45
- /** State parameter for CSRF validation */
46
- state?: string;
47
- /** Error code if authorization failed */
48
- error?: string;
49
- /** Error description */
50
- errorDescription?: string;
51
- }
52
- //# sourceMappingURL=credentials.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../src/types/credentials.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8BAA8B;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC;CAC9C;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GACxB,mBAAmB,GACnB,gBAAgB,GAChB,gBAAgB,CAAC;AAErB;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,yBAAyB;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,0CAA0C;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wBAAwB;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B"}
@@ -1,5 +0,0 @@
1
- /**
2
- * Credentials Types
3
- * Types for various authentication credentials
4
- */
5
- export {};
@@ -1,5 +0,0 @@
1
- export * from './user';
2
- export * from './credentials';
3
- export * from './auth-result';
4
- export * from './config';
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC"}
@@ -1,4 +0,0 @@
1
- export * from './user';
2
- export * from './credentials';
3
- export * from './auth-result';
4
- export * from './config';
@@ -1,39 +0,0 @@
1
- /**
2
- * User Types
3
- * Core user-related type definitions
4
- */
5
- /**
6
- * Represents an authenticated user
7
- */
8
- export interface User {
9
- /** Unique user identifier */
10
- id: string;
11
- /** User's email address */
12
- email: string;
13
- /** User's display name */
14
- name?: string;
15
- /** User's username (for login) */
16
- username?: string;
17
- /** URL to user's avatar image */
18
- avatar?: string;
19
- /** User's assigned roles */
20
- roles: string[];
21
- /** User's specific permissions */
22
- permissions: string[];
23
- /** Additional user metadata */
24
- metadata?: Record<string, unknown>;
25
- /** When the user was created */
26
- createdAt?: string;
27
- /** When the user was last updated */
28
- updatedAt?: string;
29
- }
30
- /**
31
- * Minimal user info for display purposes
32
- */
33
- export interface UserInfo {
34
- id: string;
35
- name?: string;
36
- email: string;
37
- avatar?: string;
38
- }
39
- //# sourceMappingURL=user.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/types/user.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,6BAA6B;IAC7B,EAAE,EAAE,MAAM,CAAC;IAEX,2BAA2B;IAC3B,KAAK,EAAE,MAAM,CAAC;IAEd,0BAA0B;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,kCAAkC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,iCAAiC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,4BAA4B;IAC5B,KAAK,EAAE,MAAM,EAAE,CAAC;IAEhB,kCAAkC;IAClC,WAAW,EAAE,MAAM,EAAE,CAAC;IAEtB,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEnC,gCAAgC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,qCAAqC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
@@ -1,5 +0,0 @@
1
- /**
2
- * User Types
3
- * Core user-related type definitions
4
- */
5
- export {};