Skip to content

Commit 7643364

Browse files
committed
feat(types): add new token-related types and update existing interfaces
1 parent 8726078 commit 7643364

File tree

2 files changed

+65
-21
lines changed

2 files changed

+65
-21
lines changed

src/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ export { getClientIP } from './utils/ipHelper.js';
33

44
export type {
55
CookieConfig, InvalidFingerprintEvent,
6-
MaxDevicesEvent, RotationConfig, SecurityConfig, TokenExpiringEvent, TokenRevokedEvent, TokenlyConfig, TokenlyResponse
6+
MaxDevicesEvent, RotationConfig, SecurityConfig, TokenExpiringEvent,
7+
TokenRevokedEvent, TokenRotationResponse,
8+
TokenlyConfig,
9+
TokenlyContext,
10+
TokenlyLoginResponse, TokenlyPayload, TokenlyRefreshResponse,
11+
TokenlyResponse
712
} from './types.js';
813

src/types.d.ts

Lines changed: 59 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,40 @@
1-
// Configuración principal
1+
// Tipos genéricos sin dependencia de Express
2+
export interface TokenlyResponse {
3+
raw: string;
4+
payload: {
5+
userId: string;
6+
[key: string]: any;
7+
};
8+
cookieConfig?: {
9+
name: string;
10+
value: string;
11+
options: CookieConfig;
12+
};
13+
}
14+
15+
export interface TokenRotationResponse {
16+
accessToken: TokenlyResponse;
17+
refreshToken: TokenlyResponse;
18+
}
19+
20+
// Tipos base sin Express
21+
export interface TokenlyContext {
22+
userAgent: string;
23+
ip: string;
24+
}
25+
26+
export interface TokenlyPayload {
27+
userId: string;
28+
[key: string]: any;
29+
}
30+
31+
// Configuraciones
232
export interface TokenlyConfig {
3-
accessTokenExpiry?: string;
4-
refreshTokenExpiry?: string;
5-
securityConfig?: SecurityConfig;
6-
rotationConfig?: RotationConfig;
7-
cookieConfig?: CookieConfig;
33+
accessTokenExpiry?: string;
34+
refreshTokenExpiry?: string;
35+
securityConfig?: SecurityConfig;
36+
rotationConfig?: RotationConfig;
37+
cookieConfig?: CookieConfig;
838
}
939

1040
// Configuraciones específicas
@@ -30,20 +60,6 @@ export interface CookieConfig {
3060
maxAge?: number;
3161
}
3262

33-
// Respuesta de token
34-
export interface TokenlyResponse {
35-
raw: string;
36-
payload: {
37-
userId: string;
38-
[key: string]: any;
39-
};
40-
cookieConfig?: {
41-
name: string;
42-
value: string;
43-
options: CookieConfig;
44-
};
45-
}
46-
4763
// Eventos
4864
export interface TokenRevokedEvent {
4965
token: string;
@@ -92,4 +108,27 @@ interface TokenSecurityAnalysis {
92108
issuedAt: Date;
93109
timeUntilExpiry: number;
94110
strength: 'weak' | 'medium' | 'strong';
111+
}
112+
113+
// Nuevos tipos para endpoints
114+
export interface TokenlyLoginResponse {
115+
token: string;
116+
}
117+
118+
export interface TokenlyRefreshResponse {
119+
token: string;
120+
}
121+
122+
// Tipos para handlers
123+
export interface TokenlyRequestHandlers {
124+
LoginHandler: RequestHandler<
125+
{},
126+
TokenlyLoginResponse,
127+
{ username: string; password: string }
128+
>;
129+
130+
RefreshHandler: RequestHandler<
131+
{},
132+
TokenlyRefreshResponse
133+
>;
95134
}

0 commit comments

Comments
 (0)