astro-tokenkit 1.0.11 → 1.0.13

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/types.d.ts CHANGED
@@ -7,6 +7,7 @@ export interface TokenBundle {
7
7
  accessToken: string;
8
8
  refreshToken: string;
9
9
  accessExpiresAt: number;
10
+ tokenType?: string;
10
11
  refreshExpiresAt?: number;
11
12
  sessionPayload?: Record<string, any>;
12
13
  }
@@ -23,6 +24,7 @@ export interface TokenKitContext {
23
24
  export interface Session {
24
25
  accessToken: string;
25
26
  expiresAt: number;
27
+ tokenType?: string;
26
28
  payload?: Record<string, any>;
27
29
  }
28
30
  /**
@@ -59,6 +61,7 @@ export interface APIResponse<T = any> {
59
61
  statusText: string;
60
62
  headers: Headers;
61
63
  url: string;
64
+ ok: boolean;
62
65
  }
63
66
  /**
64
67
  * Field mapping for auto-detection
@@ -68,12 +71,17 @@ export interface FieldMapping {
68
71
  refreshToken?: string;
69
72
  expiresAt?: string;
70
73
  expiresIn?: string;
74
+ tokenType?: string;
71
75
  sessionPayload?: string;
72
76
  }
73
77
  /**
74
78
  * Callback after successful login
75
79
  */
76
80
  export type OnLoginCallback = (bundle: TokenBundle, body: any, ctx: TokenKitContext) => void | Promise<void>;
81
+ /**
82
+ * Callback after failed login
83
+ */
84
+ export type OnErrorCallback = (error: AuthError, ctx: TokenKitContext) => void | Promise<void>;
77
85
  /**
78
86
  * Auth override options
79
87
  */
@@ -89,6 +97,8 @@ export interface LoginOptions extends AuthOptions {
89
97
  headers?: Record<string, string>;
90
98
  /** Callback after successful login */
91
99
  onLogin?: OnLoginCallback;
100
+ /** Callback after failed login */
101
+ onError?: OnErrorCallback;
92
102
  }
93
103
  /**
94
104
  * Auth configuration
@@ -117,7 +127,7 @@ export interface AuthConfig {
117
127
  /** Custom refresh response parser */
118
128
  parseRefresh?: (body: any) => TokenBundle;
119
129
  /** Custom token injection function (default: Bearer) */
120
- injectToken?: (token: string) => string;
130
+ injectToken?: (token: string, type?: string) => string;
121
131
  /** Refresh policy */
122
132
  policy?: RefreshPolicy;
123
133
  /** Cookie configuration */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro-tokenkit",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "A powerful API client for Astro with automatic token rotation, session management, and seamless context integration.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",